Search in sources :

Example 11 with ViewNode

use of easik.overview.vertex.ViewNode 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)

Example 12 with ViewNode

use of easik.overview.vertex.ViewNode in project fql by CategoricalData.

the class OverviewFileIO method overviewToXML.

/**
 * Converts an overview to an XML file. Returns the success of the save.
 *
 * @param outputFile
 *            The file we will output to
 * @param overview
 *            The sketch we're reading to
 * @return True if successful, false otherwise
 */
public static boolean overviewToXML(File outputFile, Overview overview) {
    Document overviewAsXML;
    try {
        DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = docBuilderFactory.newDocumentBuilder();
        overviewAsXML = db.newDocument();
        Element rootElement = overviewAsXML.createElement("easketch_overview");
        Element header = overviewAsXML.createElement("header");
        Element sketches = overviewAsXML.createElement("sketches");
        Element views = overviewAsXML.createElement("views");
        // Add Header info to document
        DocumentInfo d = overview.getDocInfo();
        Element name = overviewAsXML.createElement("title");
        name.appendChild(overviewAsXML.createTextNode(d.getName()));
        header.appendChild(name);
        for (String aut : d.getAuthors()) {
            Element author = overviewAsXML.createElement("author");
            author.appendChild(overviewAsXML.createTextNode(aut));
            header.appendChild(author);
        }
        Element desc = overviewAsXML.createElement("description");
        desc.appendChild(overviewAsXML.createTextNode(d.getDesc()));
        header.appendChild(desc);
        Element creationDate = overviewAsXML.createElement("creationDate");
        creationDate.appendChild(overviewAsXML.createTextNode(EasikConstants.XML_DATETIME.format(d.getCreationDate())));
        header.appendChild(creationDate);
        Element modDate = overviewAsXML.createElement("lastModificationDate");
        modDate.appendChild(overviewAsXML.createTextNode(EasikConstants.XML_DATETIME.format(d.getModificationDate())));
        header.appendChild(modDate);
        // Loop through sketches, add them to the document
        for (SketchNode currentSketch : overview.getSketches()) {
            if (currentSketch != null) {
                Element thisSketch = SketchFileIO.sketchToElement(overviewAsXML, currentSketch.getFrame().getMModel());
                thisSketch.setAttribute("name", currentSketch.toString());
                thisSketch.setAttribute("x", currentSketch.getX() + "");
                thisSketch.setAttribute("y", currentSketch.getY() + "");
                Cascade c = currentSketch.getFrame().getMModel().getDefaultCascading();
                Cascade cp = currentSketch.getFrame().getMModel().getDefaultPartialCascading();
                thisSketch.setAttribute("cascade", (c == Cascade.CASCADE) ? "cascade" : "restrict");
                thisSketch.setAttribute("partial-cascade", (cp == Cascade.CASCADE) ? "cascade" : (cp == Cascade.RESTRICT) ? "restrict" : "set_null");
                sketches.appendChild(thisSketch);
            }
        }
        for (ViewNode currentView : overview.getViews()) {
            if (currentView != null) {
                Element thisView = viewToElement(overviewAsXML, currentView.getFrame().getMModel());
                thisView.setAttribute("name", currentView.toString());
                thisView.setAttribute("x", currentView.getX() + "");
                thisView.setAttribute("y", currentView.getY() + "");
                ViewDefinitionEdge thisViewEdge = overview.getViewEdge(currentView.getFrame().getMModel());
                thisView.setAttribute("viewDefinitionEdge", thisViewEdge.getName());
                thisView.setAttribute("on_sketch", thisViewEdge.getTargetNode().getName());
                views.appendChild(thisView);
            }
        }
        // Add root elements to document
        overviewAsXML.appendChild(rootElement);
        rootElement.appendChild(header);
        rootElement.appendChild(sketches);
        rootElement.appendChild(views);
    } catch (Exception e) {
        e.printStackTrace();
        overviewAsXML = null;
    }
    outputXMLtoFile(outputFile, overviewAsXML);
    return true;
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Element(org.w3c.dom.Element) ViewNode(easik.overview.vertex.ViewNode) Document(org.w3c.dom.Document) SketchNode(easik.overview.vertex.SketchNode) ViewDefinitionEdge(easik.overview.edge.ViewDefinitionEdge) Cascade(easik.model.edge.ModelEdge.Cascade) DocumentInfo(easik.DocumentInfo)

Example 13 with ViewNode

use of easik.overview.vertex.ViewNode in project fql by CategoricalData.

the class OverviewGraphModel method getAttributes.

/**
 * Overridden method to get cell attributes; we make sure the appropriate
 * attributes are applied to the Easik objects before returning them.
 *
 * @see DefaultGraphModel.getAttributes(Object)
 *
 * @param o
 *
 * @return
 */
@Override
public AttributeMap getAttributes(Object o) {
    if (o instanceof GraphCell) {
        GraphCell cell = (GraphCell) o;
        AttributeMap attribs = cell.getAttributes();
        AttributeMap easikAttribs = null;
        if (cell instanceof SketchNode) {
            easikAttribs = sketchAttributes((SketchNode) cell);
        } else if (cell instanceof ViewNode) {
            easikAttribs = viewAttributes((ViewNode) cell);
        } else if (cell instanceof ViewDefinitionEdge) {
            easikAttribs = viewEdgeAttributes((ViewDefinitionEdge) cell);
        // easikAttribs =
        // easik.sketch.util.graph.SketchGraphModel.normalEdgeAttributes();
        }
        if (easikAttribs != null) {
            if (_overview.isCellSelected(cell)) {
                Color selColor = getColor("selection");
                float lineWidth = getWidth("selection", 3);
                int borderWidth = 1;
                Border currentBorder = GraphConstants.getBorder(easikAttribs);
                if (currentBorder instanceof LineBorder) {
                    borderWidth = ((LineBorder) currentBorder).getThickness();
                }
                GraphConstants.setBorder(easikAttribs, BorderFactory.createLineBorder(selColor, borderWidth));
                GraphConstants.setForeground(easikAttribs, selColor);
                GraphConstants.setLineColor(easikAttribs, selColor);
                GraphConstants.setLineWidth(easikAttribs, lineWidth);
            }
            if (attribs == null) {
                cell.setAttributes(easikAttribs);
                attribs = easikAttribs;
            } else {
                attribs.applyMap(easikAttribs);
            }
            return attribs;
        }
    }
    return super.getAttributes(o);
}
Also used : AttributeMap(org.jgraph.graph.AttributeMap) GraphCell(org.jgraph.graph.GraphCell) Color(java.awt.Color) LineBorder(javax.swing.border.LineBorder) ViewNode(easik.overview.vertex.ViewNode) SketchNode(easik.overview.vertex.SketchNode) ViewDefinitionEdge(easik.overview.edge.ViewDefinitionEdge) LineBorder(javax.swing.border.LineBorder) Border(javax.swing.border.Border)

Example 14 with ViewNode

use of easik.overview.vertex.ViewNode in project fql by CategoricalData.

the class JDBCExporter method createViews.

/**
 * Generates views on the sketch.
 *
 * @return list of queries to create our views
 */
protected List<String> createViews() {
    final List<String> viewSQL = new LinkedList<>();
    final Set<ViewNode> views = new HashSet<>(sketch.getViews());
    for (final ViewNode node : views) {
        viewSQL.addAll(createView(node));
    }
    return viewSQL;
}
Also used : ViewNode(easik.overview.vertex.ViewNode) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet)

Example 15 with ViewNode

use of easik.overview.vertex.ViewNode in project fql by CategoricalData.

the class SketchEdge method setName.

/**
 * Sets the name of this edge.
 *
 * @param inName
 *            The unique name of the edge.
 */
public void setName(String inName) {
    final String oldName = getName();
    inName = _sourceObj.getMModel().edgeRenamed(this, oldName, inName);
    for (ViewNode v : _sourceObj.getMModel().getViews()) {
        if (v.getMModel().getEdges().containsKey(oldName)) {
            v.getMModel().getEdges().get(oldName).setName(inName);
        }
    }
    _uniqueName = inName;
    _sourceObj.getMModel().refresh(this);
}
Also used : ViewNode(easik.overview.vertex.ViewNode)

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