Search in sources :

Example 11 with SketchNode

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

Example 12 with SketchNode

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

Example 13 with SketchNode

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);
}
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 14 with SketchNode

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

Example 15 with SketchNode

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

Aggregations

SketchNode (easik.overview.vertex.SketchNode)18 ViewNode (easik.overview.vertex.ViewNode)11 ViewDefinitionEdge (easik.overview.edge.ViewDefinitionEdge)4 Sketch (easik.sketch.Sketch)4 SketchFrame (easik.ui.SketchFrame)4 DocumentInfo (easik.DocumentInfo)3 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)3 Cascade (easik.model.edge.ModelEdge.Cascade)2 OverviewVertex (easik.overview.vertex.OverviewVertex)2 Component (java.awt.Component)2 Point (java.awt.Point)2 JMenuItem (javax.swing.JMenuItem)2 AttributeMap (org.jgraph.graph.AttributeMap)2 OverviewGraphModel (easik.overview.util.graph.OverviewGraphModel)1 SketchEdge (easik.sketch.edge.SketchEdge)1 ViewFrame (easik.ui.ViewFrame)1 AboutAction (easik.ui.menu.AboutAction)1 ExportDatabaseAction (easik.ui.menu.ExportDatabaseAction)1 FileNewOverviewAction (easik.ui.menu.FileNewOverviewAction)1 FileOpenAction (easik.ui.menu.FileOpenAction)1