use of easik.overview.vertex.ViewNode in project fql by CategoricalData.
the class Overview method refreshAll.
/**
* Refreshes the overview GUI as well as the GUIs of all Sketches and Views.
*/
public void refreshAll() {
for (SketchNode node : _sketchNodes.values()) {
Sketch s = node.getFrame().getMModel();
s.refresh();
s.updateThumb();
}
for (ViewNode node : _viewNodes.values()) {
View v = node.getMModel();
v.refresh();
v.updateThumb();
}
refresh();
}
use of easik.overview.vertex.ViewNode in project fql by CategoricalData.
the class RenameInOverviewFromTreeAction method actionPerformed.
/**
* Called when clicked upon, will rename an article.
*
* @param e
* The action event
*/
@Override
public void actionPerformed(ActionEvent e) {
// If there is nothing seleceted then just do nothing
if (_theFrame.getInfoTreeUI().getInfoTree().isSelectionEmpty()) {
System.err.println("'OK'");
return;
}
// Get currently selected object
DefaultMutableTreeNode curSelected = (DefaultMutableTreeNode) _theFrame.getInfoTreeUI().getInfoTree().getSelectionPath().getLastPathComponent();
OverviewVertex nodeToRename;
String originalName = "";
// Check what is currently selected
if (curSelected.getUserObject() instanceof SketchNode) {
nodeToRename = (SketchNode) curSelected.getUserObject();
} else if (curSelected.getUserObject() instanceof ViewNode) {
nodeToRename = (ViewNode) curSelected.getUserObject();
} else {
return;
}
originalName = nodeToRename.getName();
String s = (String) JOptionPane.showInputDialog(_theFrame, "New name:", "Rename", JOptionPane.QUESTION_MESSAGE, null, null, originalName);
if (s != null) {
s = s.trim();
if (s.equals("")) {
JOptionPane.showMessageDialog(_theFrame, "Entity name is empty", "Error", JOptionPane.ERROR_MESSAGE);
} else if (_theFrame.getOverview().isNameUsed(s)) {
JOptionPane.showMessageDialog(_theFrame, "Entity name is already in use", "Error", JOptionPane.ERROR_MESSAGE);
} else {
nodeToRename.setName(s);
_theFrame.getInfoTreeUI().refreshTree();
_theFrame.getOverview().getGraphLayoutCache().reload();
_theFrame.getOverview().repaint();
if (nodeToRename instanceof SketchNode) {
((SketchNode) nodeToRename).getFrame().getMModel().setDirty();
} else if (nodeToRename instanceof ViewNode) {
((ViewNode) nodeToRename).getFrame().getMModel().setDirty();
}
}
}
_theFrame.getOverview().clearSelection();
}
use of easik.overview.vertex.ViewNode 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.ViewNode 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.ViewNode 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();
}
Aggregations