use of gov.sandia.n2a.ui.eq.PanelEquationGraph.GraphPanel in project n2a by frothga.
the class GraphNode method nudge.
public void nudge(ActionEvent e, int dx, int dy) {
if (container.locked)
return;
if ((e.getModifiers() & ActionEvent.CTRL_MASK) != 0) {
dx *= 10;
dy *= 10;
}
List<GraphNode> selection = container.panelEquationGraph.getSelection();
selection.remove(this);
MNode metadata = new MVolatile();
NodePart np;
MNode bounds;
GraphPanel gp = container.panelEquationGraph.graphPanel;
if (this == gp.pinIn) {
np = container.part;
bounds = metadata.childOrCreate("gui", "pin", "bounds", "in");
} else if (this == gp.pinOut) {
np = container.part;
bounds = metadata.childOrCreate("gui", "pin", "bounds", "out");
} else {
np = node;
bounds = metadata.childOrCreate("gui", "bounds");
}
Rectangle now = getBounds();
if (dx != 0 || np != node)
metadata.set(now.x - parent.offset.x + dx, "gui", "bounds", "x");
if (dy != 0 || np != node)
metadata.set(now.y - parent.offset.y + dy, "gui", "bounds", "y");
ChangeAnnotations ca = new ChangeAnnotations(np, metadata);
ca.graph = true;
UndoManager um = MainFrame.instance.undoManager;
if (selection.isEmpty()) {
um.apply(ca);
} else {
CompoundEditView compound = new CompoundEditView(CompoundEditView.CLEAR_GRAPH);
um.addEdit(compound);
// delayed execution
compound.addEdit(ca);
if (np == node)
compound.leadPath = np.getKeyPath();
for (GraphNode g : selection) {
metadata = new MVolatile();
if (g == gp.pinIn) {
np = container.part;
bounds = metadata.childOrCreate("gui", "pin", "bounds", "in");
} else if (g == gp.pinOut) {
np = container.part;
bounds = metadata.childOrCreate("gui", "pin", "bounds", "out");
} else {
np = g.node;
bounds = metadata.childOrCreate("gui", "bounds");
if (compound.leadPath == null)
compound.leadPath = np.getKeyPath();
}
now = g.getBounds();
if (dx != 0 || np != node)
bounds.set(now.x - parent.offset.x + dx, "x");
if (dy != 0 || np != node)
bounds.set(now.y - parent.offset.y + dy, "y");
ca = new ChangeAnnotations(np, metadata);
ca.graph = true;
compound.addEdit(ca);
}
um.endCompoundEdit();
compound.redo();
}
}
use of gov.sandia.n2a.ui.eq.PanelEquationGraph.GraphPanel in project n2a by frothga.
the class GraphEdge method animate.
public void animate(Point p) {
if (p == null) {
tipDrag = false;
} else {
tipDrag = true;
tip.x = p.x;
tip.y = p.y;
}
Rectangle paintRegion = bounds;
if (edgeOther != null)
paintRegion = paintRegion.union(edgeOther.bounds);
updateShape(true);
paintRegion = paintRegion.union(bounds);
GraphPanel parent = nodeFrom.parent;
parent.layout.componentMoved(bounds);
if (edgeOther != null) {
paintRegion = paintRegion.union(edgeOther.bounds);
parent.layout.componentMoved(edgeOther.bounds);
}
parent.repaint(paintRegion);
}
Aggregations