use of easik.overview.vertex.SketchNode in project fql by CategoricalData.
the class OverviewInfoTreeUI method setPopMenuItems.
/**
* Sets which of the menu items will be visible
*
* @return true if the popup should be displayed, false otherwise
*/
public boolean setPopMenuItems() {
// If there is nothing seleceted then just do nothing
if (_theFrame.getInfoTreeUI().getInfoTree().isSelectionEmpty()) {
return false;
}
// Get currently selected object
DefaultMutableTreeNode curSelected = (DefaultMutableTreeNode) _theFrame.getInfoTreeUI().getInfoTree().getSelectionPath().getLastPathComponent();
// Hide all elements
for (Component c : _popupMenu.getComponents()) {
c.setVisible(false);
}
// Check what is currently selected
if (curSelected.getUserObject() instanceof SketchNode) {
_addViewItem.setVisible(true);
_renameSketchItem.setVisible(true);
_deleteSketchItem.setVisible(true);
} else if (curSelected.getUserObject() instanceof ViewNode) {
_renameViewItem.setVisible(true);
_deleteViewItem.setVisible(true);
} else if (curSelected == _tree_sketches) {
_addSketchItem.setVisible(true);
} else {
return false;
}
return true;
}
use of easik.overview.vertex.SketchNode in project fql by CategoricalData.
the class Overview method addNewSketch.
/**
* Add a new sketch at point (x,y). Returns the new SketchNode.
*
* @param name
* The name of the new sketch being added
* @param x
* X Coordinate of new sketch
* @param y
* Y Coordinate of new sketch
* @return the created SketchNode
*/
public SketchNode addNewSketch(String name, double x, double y) {
SketchFrame newFrame = new SketchFrame(this);
SketchNode newNode = new SketchNode(name, (int) x, (int) y, newFrame);
addVertex(newNode);
return newNode;
}
use of easik.overview.vertex.SketchNode in project fql by CategoricalData.
the class Overview method addVertex.
/**
* Add one one of our verticies to the overview
*
* @param theNode
* The node to be added
*/
public void addVertex(OverviewVertex theNode) {
// The next call will fire a rendering. At this point, the model adapter
// does not know
// where it should place the node, and picks a default value. This will
// cause an update
// in our Node's x and y coordinates, making it forget where it was
// initialized.
// We store it's initializeded position so as not to lose them in the
// first rendering.
int initX = theNode.getX();
int initY = theNode.getY();
// Make sure the name is unique; increment it if not.
if (isNameUsed(theNode.getName())) {
theNode.setName(getNewName(theNode.getName()));
}
// Add our sketch to the graph
getGraphLayoutCache().insert(theNode);
// Add our vertex to the appropriate map
if (theNode instanceof SketchNode) {
_sketchNodes.put(theNode.toString(), (SketchNode) theNode);
_appFrame.getInfoTreeUI().addSketch((SketchNode) theNode);
} else if (theNode instanceof ViewNode) {
_viewNodes.put(theNode.toString(), (ViewNode) theNode);
_appFrame.getInfoTreeUI().addView((ViewNode) theNode);
}
// Set the on-screen position of our sketch to the attributes of the
// sketch
AttributeMap nAttribs = theNode.getAttributes();
GraphConstants.setAutoSize(nAttribs, true);
GraphConstants.setBounds(nAttribs, new Rectangle2D.Double(initX, initY, 0, 0));
// Reload the graph to reflect the new changes
refresh(theNode);
}
use of easik.overview.vertex.SketchNode in project fql by CategoricalData.
the class Overview method initializeFromData.
/**
* Used to initialise a new sketch based on provided data (usually from the
* Sketch loading methods).
*
* @param sketchNodes
* A Map of all of the sketches in the overview
* @param viewNodes
* @param viewDefinitionEdges
* @param docInfo
* The document information to be stored along with this overview
*/
public void initializeFromData(Map<String, SketchNode> sketchNodes, Map<String, ViewNode> viewNodes, Map<String, ViewDefinitionEdge> viewDefinitionEdges, DocumentInfo docInfo) {
initializeOverview();
_sketchNodes = new HashMap<>();
_viewNodes = new HashMap<>();
_viewEdges = new HashMap<>();
_docInfo = docInfo;
for (SketchNode node : sketchNodes.values()) {
if (node != null) {
addVertex(node);
}
}
for (ViewNode node : viewNodes.values()) {
if (node != null) {
addVertex(node);
}
}
for (ViewDefinitionEdge edge : viewDefinitionEdges.values()) {
if (edge != null) {
addViewEdge(edge);
}
}
refresh();
}
use of easik.overview.vertex.SketchNode in project fql by CategoricalData.
the class Overview method setDirty.
/**
* Used to mark a sketch as dirty or not. Since it's only marked as
* non-dirty when saving, we mark all the current node/view positions if
* setting non-dirty.
*
* @param inDirty
* NEw dirtiness.
*/
public void setDirty(boolean inDirty) {
_dirty = inDirty;
if (_dirty) {
getDocInfo().updateModificationDate();
}
if (!_dirty) {
for (SketchNode n : _sketchNodes.values()) {
n.savePosition();
}
for (ViewNode v : _viewNodes.values()) {
v.savePosition();
}
}
_appFrame.setDirty(_dirty);
}
Aggregations