Search in sources :

Example 1 with GraphCell

use of org.jgraph.graph.GraphCell in project fql by CategoricalData.

the class ViewGraphModel 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
@SuppressWarnings("unchecked")
public AttributeMap getAttributes(Object o) {
    _mode = (_view.getSketch().getFrame().getMode() == Mode.EDIT) ? "edit_" : "manip_";
    if (o instanceof GraphCell) {
        GraphCell cell = (GraphCell) o;
        AttributeMap attribs = cell.getAttributes();
        AttributeMap easikAttribs = null;
        if (cell instanceof View_Edge) {
            easikAttribs = (cell instanceof InjectiveViewEdge) ? injectiveEdgeAttributes() : (cell instanceof PartialViewEdge) ? partialEdgeAttributes() : normalEdgeAttributes();
        } else if (cell instanceof TriangleEdge) {
            easikAttribs = triangleEdgeAttributes((TriangleEdge<ViewFrame, ViewGraphModel, View, QueryNode, View_Edge>) cell);
        } else if (cell instanceof GuideEdge) {
            easikAttribs = ((GuideEdge<ViewFrame, ViewGraphModel, View, QueryNode, View_Edge>) cell).isHighlighted() ? virtualHighlightedEdgeAttributes() : virtualEdgeAttributes();
        } else if (cell instanceof ModelConstraint) {
            easikAttribs = virtualVertexAttributes();
        } else if (cell instanceof QueryNode) {
            easikAttribs = vertexAttributes();
        }
        if (easikAttribs != null) {
            if (_view.isCellSelected(cell)) {
                Color selColor;
                float lineWidth;
                if (_view.getStateManager().peekState() instanceof GetPathState) {
                    selColor = getColor("path_selection");
                    lineWidth = getWidth("path_selection", 2);
                } else {
                    selColor = getColor("selection");
                    lineWidth = getWidth("selection", 3);
                }
                int borderWidth = getIntWidth(_mode + ((cell instanceof ModelConstraint) ? "constraint" : "entity") + "_border", 1);
                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 : ModelConstraint(easik.model.constraint.ModelConstraint) GraphCell(org.jgraph.graph.GraphCell) ViewFrame(easik.ui.ViewFrame) Color(java.awt.Color) TriangleEdge(easik.model.edge.TriangleEdge) View_Edge(easik.view.edge.View_Edge) InjectiveViewEdge(easik.view.edge.InjectiveViewEdge) View(easik.view.View) PartialViewEdge(easik.view.edge.PartialViewEdge) ModelConstraint(easik.model.constraint.ModelConstraint) AttributeMap(org.jgraph.graph.AttributeMap) QueryNode(easik.view.vertex.QueryNode) GetPathState(easik.model.states.GetPathState) GuideEdge(easik.model.edge.GuideEdge)

Example 2 with GraphCell

use of org.jgraph.graph.GraphCell 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 3 with GraphCell

use of org.jgraph.graph.GraphCell in project fql by CategoricalData.

the class SketchGraphModel 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
@SuppressWarnings("unchecked")
public AttributeMap getAttributes(Object o) {
    _mode = (_sketch.getFrame().getMode() == Mode.EDIT) ? "edit_" : "manip_";
    if (o instanceof GraphCell) {
        GraphCell cell = (GraphCell) o;
        AttributeMap attribs = cell.getAttributes();
        AttributeMap easikAttribs = null;
        if (cell instanceof SketchEdge) {
            easikAttribs = (cell instanceof InjectiveEdge) ? injectiveEdgeAttributes() : (cell instanceof PartialEdge) ? partialEdgeAttributes() : normalEdgeAttributes();
        } else if (cell instanceof TriangleEdge) {
            easikAttribs = triangleEdgeAttributes((TriangleEdge<SketchFrame, SketchGraphModel, Sketch, EntityNode, SketchEdge>) cell);
        } else if (cell instanceof GuideEdge) {
            easikAttribs = ((GuideEdge<SketchFrame, SketchGraphModel, Sketch, EntityNode, SketchEdge>) cell).isHighlighted() ? virtualHighlightedEdgeAttributes() : virtualEdgeAttributes();
        } else if (cell instanceof ModelConstraint) {
            easikAttribs = virtualVertexAttributes();
        } else if (cell instanceof EntityNode) {
            easikAttribs = vertexAttributes();
        }
        if (easikAttribs != null) {
            if (_sketch.isCellSelected(cell)) {
                Color selColor;
                float lineWidth;
                if (_sketch.getStateManager().peekState() instanceof GetPathState) {
                    selColor = getColor("path_selection");
                    lineWidth = getWidth("path_selection", 2);
                } else {
                    selColor = getColor("selection");
                    lineWidth = getWidth("selection", 3);
                }
                int borderWidth = getIntWidth(_mode + ((cell instanceof ModelConstraint) ? "constraint" : "entity") + "_border", 1);
                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 : ModelConstraint(easik.model.constraint.ModelConstraint) GraphCell(org.jgraph.graph.GraphCell) Color(java.awt.Color) TriangleEdge(easik.model.edge.TriangleEdge) PartialEdge(easik.sketch.edge.PartialEdge) ModelConstraint(easik.model.constraint.ModelConstraint) EntityNode(easik.sketch.vertex.EntityNode) SketchFrame(easik.ui.SketchFrame) AttributeMap(org.jgraph.graph.AttributeMap) InjectiveEdge(easik.sketch.edge.InjectiveEdge) SketchEdge(easik.sketch.edge.SketchEdge) GetPathState(easik.model.states.GetPathState) Sketch(easik.sketch.Sketch) GuideEdge(easik.model.edge.GuideEdge)

Aggregations

Color (java.awt.Color)3 AttributeMap (org.jgraph.graph.AttributeMap)3 GraphCell (org.jgraph.graph.GraphCell)3 ModelConstraint (easik.model.constraint.ModelConstraint)2 GuideEdge (easik.model.edge.GuideEdge)2 TriangleEdge (easik.model.edge.TriangleEdge)2 GetPathState (easik.model.states.GetPathState)2 ViewDefinitionEdge (easik.overview.edge.ViewDefinitionEdge)1 SketchNode (easik.overview.vertex.SketchNode)1 ViewNode (easik.overview.vertex.ViewNode)1 Sketch (easik.sketch.Sketch)1 InjectiveEdge (easik.sketch.edge.InjectiveEdge)1 PartialEdge (easik.sketch.edge.PartialEdge)1 SketchEdge (easik.sketch.edge.SketchEdge)1 EntityNode (easik.sketch.vertex.EntityNode)1 SketchFrame (easik.ui.SketchFrame)1 ViewFrame (easik.ui.ViewFrame)1 View (easik.view.View)1 InjectiveViewEdge (easik.view.edge.InjectiveViewEdge)1 PartialViewEdge (easik.view.edge.PartialViewEdge)1