Java Code Examples for org.jgraph.graph.GraphConstants#setBorder()
The following examples show how to use
org.jgraph.graph.GraphConstants#setBorder() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GraphVisitor.java From Pydev with Eclipse Public License 1.0 | 6 votes |
public DefaultGraphCell createVertex(String name, double x, double y, Color bg, boolean raised) { // Create vertex with the given name DefaultGraphCell cell = new DefaultGraphCell(name); GraphConstants.setBorder(cell.getAttributes(), BorderFactory.createEtchedBorder()); GraphConstants.setBounds(cell.getAttributes(), new Rectangle2D.Double(x, y, 10, 10)); GraphConstants.setResize(cell.getAttributes(), true); GraphConstants.setAutoSize(cell.getAttributes(), true); // Set fill color if (bg != null) { GraphConstants.setOpaque(cell.getAttributes(), true); GraphConstants.setGradientColor(cell.getAttributes(), bg); } // Set raised border if (raised) GraphConstants.setBorder(cell.getAttributes(), BorderFactory.createRaisedBevelBorder()); else // Set black border GraphConstants.setBorderColor(cell.getAttributes(), Color.black); return cell; }
Example 2
Source File: OverviewGraphModel.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
/** * Returns an attribute map for SketchNodes * * @param node * @return The attribute mapping */ private static AttributeMap sketchAttributes(SketchNode node) { AttributeMap map = commonVertexAttributes(node); GraphConstants.setBorder(map, BorderFactory.createLineBorder(getColor("overview_sketch_border"), getIntWidth("overview_sketch_border", 2))); GraphConstants.setBackground(map, getColor("overview_sketch_bg")); GraphConstants.setForeground(map, getColor("overview_sketch_fg")); return map; }
Example 3
Source File: OverviewGraphModel.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
/** * Returns an attribute map for Overview views * * @param node * @return The attribute mapping */ private static AttributeMap viewAttributes(ViewNode node) { AttributeMap map = commonVertexAttributes(node); GraphConstants.setBorder(map, BorderFactory.createLineBorder(getColor("overview_view_border"), getIntWidth("overview_view_border", 2))); GraphConstants.setBackground(map, getColor("overview_view_bg")); GraphConstants.setForeground(map, getColor("overview_view_fg")); return map; }
Example 4
Source File: ViewGraphModel.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
/** * Returns the attribute map for vertices (i.e. EntityNodes). * * @return a map of attributes to be used for new vertices */ private AttributeMap vertexAttributes() { AttributeMap map = new AttributeMap(); GraphConstants.setAutoSize(map, true); GraphConstants.setInset(map, 5); GraphConstants.setBorder(map, BorderFactory.createLineBorder(getColor(_mode + "entity_border"), getIntWidth(_mode + "entity_border", 1))); GraphConstants.setBackground(map, getColor(_mode + "entity_bg")); GraphConstants.setForeground(map, getColor(_mode + "entity_fg")); GraphConstants.setFont(map, GraphConstants.DEFAULTFONT.deriveFont(Font.BOLD, 12)); GraphConstants.setOpaque(map, true); return map; }
Example 5
Source File: ViewGraphModel.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
/** * Returns the attribute map for virtual vertices (i.e. constaint nodes). * * @return a map of attributes to be used for new virtual vertices */ private AttributeMap virtualVertexAttributes() { AttributeMap map = new AttributeMap(); GraphConstants.setAutoSize(map, true); GraphConstants.setInset(map, 5); GraphConstants.setBorder(map, BorderFactory.createLineBorder(getColor(_mode + "constraint_border"), getIntWidth(_mode + "constraint_border", 1))); GraphConstants.setBackground(map, getColor(_mode + "constraint_bg")); GraphConstants.setForeground(map, getColor(_mode + "constraint_fg")); GraphConstants.setFont(map, GraphConstants.DEFAULTFONT.deriveFont(Font.BOLD, 12)); GraphConstants.setOpaque(map, true); return map; }
Example 6
Source File: SketchGraphModel.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
/** * Returns the attribute map for vertices (i.e. EntityNodes). * * @return a map of attributes to be used for new vertices */ private AttributeMap vertexAttributes() { AttributeMap map = new AttributeMap(); GraphConstants.setAutoSize(map, true); GraphConstants.setInset(map, 5); GraphConstants.setBorder(map, BorderFactory.createLineBorder(getColor(_mode + "entity_border"), getIntWidth(_mode + "entity_border", 1))); GraphConstants.setBackground(map, getColor(_mode + "entity_bg")); GraphConstants.setForeground(map, getColor(_mode + "entity_fg")); GraphConstants.setFont(map, GraphConstants.DEFAULTFONT.deriveFont(Font.BOLD, 12)); GraphConstants.setOpaque(map, true); return map; }
Example 7
Source File: SketchGraphModel.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
/** * Returns the attribute map for virtual vertices (i.e. constaint nodes). * * @return a map of attributes to be used for new virtual vertices */ private AttributeMap virtualVertexAttributes() { AttributeMap map = new AttributeMap(); GraphConstants.setAutoSize(map, true); GraphConstants.setInset(map, 5); GraphConstants.setBorder(map, BorderFactory.createLineBorder(getColor(_mode + "constraint_border"), getIntWidth(_mode + "constraint_border", 1))); GraphConstants.setBackground(map, getColor(_mode + "constraint_bg")); GraphConstants.setForeground(map, getColor(_mode + "constraint_fg")); GraphConstants.setFont(map, GraphConstants.DEFAULTFONT.deriveFont(Font.BOLD, 12)); GraphConstants.setOpaque(map, true); return map; }
Example 8
Source File: Main.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private static void positionVertexAt(Object vertex, int x, int y) { DefaultGraphCell cell = jgAdapter.getVertexCell(vertex); AttributeMap attr = cell.getAttributes(); AttributeMap map = new AttributeMap(); GraphConstants.setBounds(map, new Rectangle2D.Double(50, 50, 90, 30)); GraphConstants.setBorder(map, BorderFactory.createRaisedBevelBorder()); GraphConstants.setBackground(map, Color.BLUE); GraphConstants.setForeground(map, Color.white); GraphConstants.setFont(map, GraphConstants.DEFAULTFONT.deriveFont(Font.BOLD, 12)); GraphConstants.setOpaque(map, true); Rectangle2D bounds = GraphConstants.getBounds(map); Rectangle2D newBounds = new Rectangle2D.Double(x, y, bounds.getWidth(), bounds.getHeight()); GraphConstants.setBounds(map, newBounds); GraphConstants.setBounds(attr, newBounds); AttributeMap cellAttr = new AttributeMap(); if (findGoalByName((String) vertex).isSliced) cellAttr.put(cell, map); else cellAttr.put(cell, attr); jgAdapter.edit(cellAttr, null, null, null); }
Example 9
Source File: OverviewGraphModel.java From CQL with GNU Affero General Public License v3.0 | 4 votes |
/** * 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); }
Example 10
Source File: ViewGraphModel.java From CQL with GNU Affero General Public License v3.0 | 4 votes |
/** * 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); }
Example 11
Source File: SketchGraphModel.java From CQL with GNU Affero General Public License v3.0 | 4 votes |
/** * 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); }
Example 12
Source File: GraphVertex.java From chipster with MIT License | 4 votes |
/** * Creates a new graph vertex. The coordinates of the new vertex are * defined right and down from the upper left corner of the graph area. * The parent of the vertex is defined by the parent dataset of the * given data parameter. * * @param x Horizontal position of the new vertex (in pixel coordinates). * @param y Vertical position of the new vertex (in pixel coordinates). * @param data Dataset which this vertex is to represent on the graph. * @throws NullPointerException If the provided DataBean is null. */ public GraphVertex(int x, int y, DataBean data, MicroarrayGraph graph) { super(x, y, data, graph); children = new ArrayList<GraphVertex>(); Color c; if (data == null || data.getOperationRecord() == null || data.getOperationRecord().getCategoryColor() == null) { c = DEFAULT_VERTEX_COLOR; } else { c = data.getOperationRecord().getCategoryColor(); } GraphConstants.setGradientColor(this.getAttributes(),c); GraphConstants.setBackground(this.getAttributes(),c.brighter()); GraphConstants.setOpaque(this.getAttributes(), true); GraphConstants.setBorder(this.getAttributes(), BORDER_NORMAL); this.addPort(); this.graph = graph; try { Long rowCount = Session.getSession().getDataManager().getFastRowCount(data); if (rowCount != null) { if (rowCount < DataManager.MAX_ROWS_TO_COUNT) { tooltipText = ", " + rowCount + " rows"; } else { tooltipText = ", over " + rowCount + " rows"; } } else { tooltipText = ""; // too large file, maybe binary, cannot say anything } } catch (MicroarrayException e) { tooltipText = ""; } graph.getGraphLayoutCache().toFront(new Object[] { this } ); graph.repaint(); }