use of doc_gui.graph.Selection in project OpenNotebook by jaltekruse.
the class SelectionAttribute method clone.
@Override
public SelectionAttribute clone() {
SelectionAttribute newSelection = new SelectionAttribute(getName(), new Selection(getValue().getStart(), getValue().getEnd()));
copyRootManagedFields(newSelection);
return newSelection;
}
use of doc_gui.graph.Selection in project OpenNotebook by jaltekruse.
the class GraphObject method setDefaults.
public void setDefaults() {
try {
addList(new ListAttribute<>(EXPRESSIONS, new StringAttribute(EXPRESSION), 6, true, false));
addList(new ListAttribute<>(POINTS, new GridPointAttribute("", -7E8, 7E8, -7E8, 7E8), 1000000, true, false));
addList(new ListAttribute<>(LINE_GRAPH, new GridPointAttribute("", -7E8, 7E8, -7E8, 7E8), 1000000, true, false));
addList(new ListAttribute<>(BAR_GRAPH_VALUES, new DoubleAttribute("", -7E8, 7E8), 50, false, true));
addAttribute(new IntegerAttribute(BAR_GRAPH_GROUP_SIZE, 1, 1, 100, false));
addList(new ListAttribute<>(BAR_GRAPH_LABELS, new StringAttribute(""), 100, false, true));
addAttribute(new SelectionAttribute(SELECTION, new Selection(), false));
addAttribute(new DoubleAttribute(X_MIN, -7E8, 7E8, true, true));
getAttributeWithName(X_MIN).setValueWithString("-5");
addAttribute(new DoubleAttribute(X_MAX, -7E8, 7E8, true, true));
getAttributeWithName(X_MAX).setValueWithString("5");
addAttribute(new DoubleAttribute(Y_MIN, -7E8, 7E8, true, true));
getAttributeWithName(Y_MIN).setValueWithString("-5");
addAttribute(new DoubleAttribute(Y_MAX, -7E8, 7E8, true, true));
getAttributeWithName(Y_MAX).setValueWithString("5");
addAttribute(new DoubleAttribute(X_STEP, -3E8, 3E8, true, true));
getAttributeWithName(X_STEP).setValueWithString("1");
addAttribute(new DoubleAttribute(Y_STEP, -3E8, 3E8, true, true));
getAttributeWithName(Y_STEP).setValueWithString("1");
addAttribute(new IntegerAttribute(FONT_SIZE, 1, 20));
getAttributeWithName(FONT_SIZE).setValueWithString("8");
addAttribute(new BooleanAttribute(SHOW_AXIS));
getAttributeWithName(SHOW_AXIS).setValue(true);
addAttribute(new BooleanAttribute(SHOW_NUMBERS));
getAttributeWithName(SHOW_NUMBERS).setValue(true);
addAttribute(new BooleanAttribute(SHOW_GRID));
getAttributeWithName(SHOW_GRID).setValue(true);
addAttribute(new ColorAttribute(LINE_GRAPH_COLOR));
getAttributeWithName(LINE_GRAPH_COLOR).setValue(Color.BLUE);
} catch (Exception e) {
e.printStackTrace();
}
}
use of doc_gui.graph.Selection in project OpenNotebook by jaltekruse.
the class SelectionAttribute method readValueFromString.
@Override
public Selection readValueFromString(String s) throws AttributeException {
try {
if (s.equals("null")) {
return null;
}
StringTokenizer st = new StringTokenizer(s, ",");
double start = Double.parseDouble(st.nextToken());
double end = Double.parseDouble(st.nextToken());
return new Selection(start, end);
} catch (Exception e) {
throw new AttributeException("error setting Selection");
}
}
use of doc_gui.graph.Selection in project OpenNotebook by jaltekruse.
the class GraphObjectGUI method mouseClicked.
public void mouseClicked(GraphObject gObj, int x, int y, float zoomLevel) {
// and cannot be removed
if (false) {
// deliberately disabled, but this makes sure this code is still compiling (as commenting out would not do
//add a point to the graph
gObj.getPoints().add(new GridPointAttribute("", new GridPoint(graph.screenxToGrid(x), -1 * graph.screenyToGrid(y))));
// add a single x value "selection"
graph.pullVarsFromGraphObject(gObj, (int) (gObj.getWidth() * zoomLevel), (int) (gObj.getHeight() * zoomLevel));
((Selection) gObj.getAttributeWithName(GraphObject.SELECTION).getValue()).setStart(graph.screenxToGrid(x));
}
return;
}
Aggregations