Search in sources :

Example 6 with ViewNode

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();
}
Also used : Sketch(easik.sketch.Sketch) ViewNode(easik.overview.vertex.ViewNode) SketchNode(easik.overview.vertex.SketchNode) View(easik.view.View)

Example 7 with ViewNode

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();
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) ViewNode(easik.overview.vertex.ViewNode) OverviewVertex(easik.overview.vertex.OverviewVertex) SketchNode(easik.overview.vertex.SketchNode)

Example 8 with ViewNode

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;
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) ViewNode(easik.overview.vertex.ViewNode) Component(java.awt.Component) SketchNode(easik.overview.vertex.SketchNode)

Example 9 with ViewNode

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);
}
Also used : AttributeMap(org.jgraph.graph.AttributeMap) Rectangle2D(java.awt.geom.Rectangle2D) ViewNode(easik.overview.vertex.ViewNode) SketchNode(easik.overview.vertex.SketchNode) Point(java.awt.Point)

Example 10 with ViewNode

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();
}
Also used : ViewNode(easik.overview.vertex.ViewNode) SketchNode(easik.overview.vertex.SketchNode) ViewDefinitionEdge(easik.overview.edge.ViewDefinitionEdge)

Aggregations

ViewNode (easik.overview.vertex.ViewNode)16 SketchNode (easik.overview.vertex.SketchNode)11 ViewDefinitionEdge (easik.overview.edge.ViewDefinitionEdge)5 DocumentInfo (easik.DocumentInfo)3 Sketch (easik.sketch.Sketch)3 Cascade (easik.model.edge.ModelEdge.Cascade)2 OverviewVertex (easik.overview.vertex.OverviewVertex)2 SketchEdge (easik.sketch.edge.SketchEdge)2 SketchFrame (easik.ui.SketchFrame)2 ViewFrame (easik.ui.ViewFrame)2 Point (java.awt.Point)2 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 AttributeMap (org.jgraph.graph.AttributeMap)2 ModelConstraint (easik.model.constraint.ModelConstraint)1 OverviewGraphModel (easik.overview.util.graph.OverviewGraphModel)1 SketchGraphModel (easik.sketch.util.graph.SketchGraphModel)1 EntityNode (easik.sketch.vertex.EntityNode)1 OverviewInfoTreeUI (easik.ui.tree.OverviewInfoTreeUI)1 View (easik.view.View)1 InjectiveViewEdge (easik.view.edge.InjectiveViewEdge)1