GraphConstants.setValue(map, getValue(node)); if (node instanceof Processor) GraphConstants.setOpaque(map, true); GraphConstants.setBorder(map, new TitledBorder(new LineBorder(Color.GRAY), "Inputs")); GraphConstants.setBackground(map, Color.WHITE); GraphConstants.setEditable(map, false); GraphConstants.setSelectable(map, false); GraphConstants.setInset(map, 5); GraphConstants.setValue(map, ""); GraphConstants.setOpaque(map, true); GraphConstants.setBorder(map, new TitledBorder(new LineBorder(Color.GRAY), "Outputs")); GraphConstants.setBackground(map, Color.WHITE); GraphConstants.setEditable(map, false); GraphConstants.setSelectable(map, false); GraphConstants.setInset(map, 5); GraphConstants.setValue(map, ""); GraphConstants.setBounds(map, new Rectangle(100, 20)); GraphConstants.setBackground(map, GraphColours.getColour(ProcessorHelper .getPreferredColour(processor), Color.WHITE)); GraphConstants.setOpaque(map, true); GraphConstants.setResize(map, true); GraphConstants.setBorder(map, new LineBorder(Color.BLACK)); GraphConstants.setInset(map, 3);
/** * Clones special object entried in the given map. */ public AttributeMap cloneEntries(AttributeMap newMap) { // Clone Bounds Rectangle2D bounds = GraphConstants.getBounds(newMap); if (bounds != null) GraphConstants.setBounds(newMap, (Rectangle2D) (bounds.clone())); // Clone List Of Points List points = GraphConstants.getPoints(newMap); if (points != null) GraphConstants.setPoints(newMap, clonePoints(points)); // Clone extra label positions Point2D[] positions = GraphConstants.getExtraLabelPositions(newMap); if (positions != null) GraphConstants.setExtraLabelPositions(newMap, clonePoints(positions)); // Clone Edge Label Point2D label = GraphConstants.getLabelPosition(newMap); if (label != null) GraphConstants.setLabelPosition(newMap, (Point2D) label.clone()); return newMap; }
/** * Returns an attributeMap for the specified position and color. */ public static Map createBounds(AttributeMap map, int x, int y, Color c) { GraphConstants.setBounds(map, map.createRect(x, y, 90, 30)); GraphConstants.setBorder(map, BorderFactory.createRaisedBevelBorder()); GraphConstants.setBackground(map, c.darker().darker()); GraphConstants .setGradientColor(map, c.brighter().brighter().brighter()); GraphConstants.setForeground(map, Color.white); if (GraphConstants.DEFAULTFONT != null) { GraphConstants.setFont(map, GraphConstants.DEFAULTFONT.deriveFont( Font.BOLD, 12)); } GraphConstants.setOpaque(map, true); return map; }
public void initialiseDefaultPoints(){ List controlPoints = GraphConstants.getPoints(allAttributes); if (controlPoints == null) { controlPoints = new ArrayList(4); controlPoints.add(allAttributes.createPoint(10, 10)); controlPoints.add(allAttributes.createPoint(20, 20)); GraphConstants.setPoints(allAttributes, controlPoints); } points=controlPoints; }
private DefaultGraphCell createCell(K stateKey, Point2D placement) { // System.out.println(name + " " + placement + " " + index); String cellName = stateKey.toString(); DefaultGraphCell stateCell = new DefaultGraphCell(new String(cellName)); Font font = new Font("Arial", Font.PLAIN, 12); GraphConstants.setFont(stateCell.getAttributes(), font); GraphConstants.setAutoSize(stateCell.getAttributes(), true); GraphConstants.setOpaque(stateCell.getAttributes(), true); Color color = colorStateCell(stateKey); GraphConstants.setBackground(stateCell.getAttributes(), color); GraphConstants.setBounds(stateCell.getAttributes(), new Rectangle2D.Double(placement.getX(), placement.getY(), 0, 0)); stateCell.addPort(); return stateCell; }
/** * Overrides the parent method to udpate the cached points. */ public void update(GraphLayoutCache cache) { super.update(cache); bounds = GraphConstants.getBounds(allAttributes); if (bounds == null) { bounds = allAttributes.createRect(defaultBounds); GraphConstants.setBounds(allAttributes, bounds); } groupBounds = null; }
GraphConstants.setLineEnd(attr, GraphConstants.ARROW_SIMPLE); GraphConstants.setDisconnectable(attr,false); GraphConstants.setLineWidth(attr, 1); GraphConstants.setEndSize(attr, 7); GraphConstants.setBendable(attr,false); GraphConstants.setLabelEnabled(attr,false); GraphConstants.setLabelPosition(attr, GraphConstants.setLabelEnabled(attr,true); GraphConstants.setLabelPosition(attr, GraphConstants.setOpaque(attr,true); GraphConstants.setBackground(attr,new Color(212,219,206)); GraphConstants.setBorderColor(attr, Color.GRAY); GraphConstants.setLabelAlongEdge(attr,true);
/** * Sets the current bounds for the specified cell. * * @param cell * the cell whose bounds are to be set * @param rect * the new bounds of the specified cell */ public void setBounds(Object cell, Rectangle2D rect) { Map map = getAttributes(cell); GraphConstants.setBounds(map, rect); }
GraphConstants.setLineBegin(implementStyle, GraphConstants.ARROW_TECHNICAL); GraphConstants.setBeginSize(implementStyle, 10); GraphConstants.setDashPattern(implementStyle, new float[] { 3, 3 }); if (GraphConstants.DEFAULTFONT != null) { GraphConstants.setFont(implementStyle, GraphConstants.DEFAULTFONT .deriveFont(10)); .setLineBegin(extendStyle, GraphConstants.ARROW_TECHNICAL); GraphConstants.setBeginFill(extendStyle, true); GraphConstants.setBeginSize(extendStyle, 10); if (GraphConstants.DEFAULTFONT != null) { GraphConstants.setFont(extendStyle, GraphConstants.DEFAULTFONT .deriveFont(10)); GraphConstants.setLineBegin(aggregateStyle, GraphConstants.ARROW_DIAMOND); GraphConstants.setBeginFill(aggregateStyle, true); GraphConstants.setBeginSize(aggregateStyle, 6); GraphConstants.setLineEnd(aggregateStyle, GraphConstants.ARROW_SIMPLE); GraphConstants.setEndSize(aggregateStyle, 8); GraphConstants.setLabelPosition(aggregateStyle, new Point2D.Double(500, 0)); if (GraphConstants.DEFAULTFONT != null) { GraphConstants.setFont(aggregateStyle, GraphConstants.DEFAULTFONT .deriveFont(10));
private void applyChanges(final Hashtable<DefaultGraphCell, Map> map) { final Set<DefaultGraphCell> allchildren = parentship.keySet(); if (!map.isEmpty()) { glc.edit(map, null, null, null); for (Object key : map.keySet()) { if (GraphConstants.getBounds(map.get(key)) != null) { occupiedpositions.put((DefaultGraphCell) key, GraphConstants.getBounds(map.get(key)).getBounds()); } } } }
re.show(j); GraphConstants.setLabelEnabled(am,true); GraphConstants.setLabelPosition(am, new Point2D.Double(GraphConstants.PERMILLE/2, -20)); GraphConstants.setOpaque(am, true); GraphConstants.setBackground(am,new Color(212,219,206)); GraphConstants.setBorderColor(am, Color.GRAY); GraphConstants.setLabelAlongEdge(am,true);
GraphConstants.setValue(attrs, newName); GraphConstants.setResize(attrs, true); GraphConstants.setBounds(attrs, GraphConstants.getBounds(model .getAttributes(source))); changed.add(source); assert newName != null : source; assert !newName.equals(((ScuflModelRenameEvent) event).getOldName()) : source; GraphConstants.setValue(attrs, newName); GraphConstants.setResize(attrs, true); GraphConstants.setBounds(attrs, GraphConstants.getBounds(model .getAttributes(source))); changed.add(source);
int length = jta.getFontMetrics(GraphConstants.getFont(this. getAllAttributes())).stringWidth(text) + 10; int height = jta.getFontMetrics(GraphConstants.getFont(this. getAllAttributes())).getHeight(); jta.setSize(length, height + 5); GraphConstants.setSize(m, new Dimension(length, height + 5)); GraphConstants.setMoveable(m, true); Rectangle rec = GraphConstants.getBounds(m).getBounds(); rec.setSize(new Dimension(length, height + 5)); GraphConstants.setBounds(m, rec); ((DefaultGraphCell)this.getCell()).setAttributes(m);
List points = GraphConstants.getPoints(attrMap); ArrayList result = new ArrayList(); GraphConstants.setPoints(attrMap, result); GraphConstants.setLineBegin(attrMap, Integer.parseInt(lineBegin)); GraphConstants.setLineEnd(attrMap, Integer.parseInt(lineEnd));
private static Hashtable edgesAttributes(DefaultEdge[] edges, String[] roleAssignation) { Hashtable edgesAttributes = new Hashtable(); for (int i = 0; i < roleAssignation.length; i++) { // Create a Map that holds the attributes for the edge RoleEntity re = (RoleEntity) edges[i].getUserObject(); Map attr = re.getAttributes(); // Source /*if (selectedAssignation[i].indexOf("source") >= 0) // Add a Line Begin Attribute GraphConstants.setLineBegin(attr, GraphConstants.SIMPLE);*/ // Target if (roleAssignation[i].toUpperCase().indexOf("TARGET") >= 0 || roleAssignation[i].endsWith("T")) { // Add a Line End Attribute GraphConstants.setLineEnd(attr, GraphConstants.ARROW_SIMPLE); // Associate the Edge with its Attributes } GraphConstants.setDisconnectable(attr,false); GraphConstants.setLineWidth(attr, 1); GraphConstants.setEndSize(attr, 7); GraphConstants.setBendable(attr,false); edgesAttributes.put(edges[i], attr); } return edgesAttributes; }
@Override protected void postProcessEntity(Entity entity, DefaultGraphCell cell) { super.postProcessEntity(entity, cell); GraphConstants.setBackground(cell.getAttributes(), ENTITY_COLOR); GraphConstants.setOpaque(cell.getAttributes(), true); }
private void createArrow(K source, K target) { if (!arrowAlreadyExist(source, target)) { DefaultGraphCell[] arrowCell = new DefaultGraphCell[1]; DefaultEdge edge = new DefaultEdge(); edge.setSource(stateCells.get(source).getChildAt(0)); edge.setTarget(stateCells.get(target).getChildAt(0)); arrowCell[0] = edge; int arrow = GraphConstants.ARROW_TECHNICAL; GraphConstants.setLineEnd(edge.getAttributes(), arrow); GraphConstants.setEndFill(edge.getAttributes(), true); graph.getGraphLayoutCache().insert(arrowCell); Set<K> targetSet = arrows.get(source); if (targetSet == null) { targetSet = EnumSet.noneOf(keyType); arrows.put(source, targetSet); } targetSet.add(target); } }
/** * Translates <code>map</code> by the given amount. */ public void translate(double dx, double dy) { // Translate Bounds if (GraphConstants.isMoveable(this)) { Rectangle2D bounds = GraphConstants.getBounds(this); if (bounds != null) { int moveableAxis = GraphConstants.getMoveableAxis(this); if (moveableAxis == GraphConstants.X_AXIS) dy = 0; else if (moveableAxis == GraphConstants.Y_AXIS) dx = 0; bounds.setFrame(bounds.getX() + dx, bounds.getY() + dy, bounds .getWidth(), bounds.getHeight()); } // Translate Points List points = GraphConstants.getPoints(this); if (points != null) { for (int i = 0; i < points.size(); i++) { Object obj = points.get(i); if (obj instanceof Point2D) { Point2D pt = (Point2D) obj; pt.setLocation(pt.getX() + dx, pt.getY() + dy); } } } } }
private void updateStateMachine() { if (oldStateDiagram) { this.repaint(); } else { K currentStateKey = stateMachine.getCurrentStateKey(); DefaultGraphCell currentStateCell = stateCells.get(currentStateKey); GraphConstants.setBackground(graph.getAttributes(currentStateCell), Color.RED); currentStateCell.setAttributes(graph.getAttributes(currentStateCell)); for (Entry<K, DefaultGraphCell> entry : stateCells.entrySet()) { if (entry.getKey() != currentStateKey) { DefaultGraphCell stateCell = entry.getValue(); GraphConstants.setBackground(graph.getAttributes(stateCell), Color.CYAN); stateCell.setAttributes(graph.getAttributes(stateCell)); } } graph.repaint(); graph.refresh(); } }
Rectangle2D bounds = GraphConstants.getBounds(this); if (bounds != null) { Point2D p = createPoint(bounds.getX(), bounds.getY()); if (!p.equals(loc)) // Scale Location translate(p.getX() - loc.getX(), p.getY() - loc.getY()); int sizeableAxis = GraphConstants.getSizeableAxis(this); if (sizeableAxis == GraphConstants.X_AXIS) sy = 1; List points = GraphConstants.getPoints(this); if (points != null) { Iterator it = points.iterator();