/** * 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); }
private void moveChildrenToParent(Hashtable map, Vector<DefaultGraphCell> children, Object changed, Map attsparent, Map newatts) { Rectangle2D coordParent = GraphConstants.getBounds(attsparent); Rectangle2D newCoordParent = GraphConstants.getBounds(newatts); Rectangle2D coordAtts = GraphConstants.getBounds(newatts); for (Object child : children) { Map attsChildren = dgm.getAttributes(child); // System.err.println("moving "+child); Rectangle2D coordChildren = GraphConstants.getBounds(attsChildren); int xchild = (int) coordChildren.getX(); int ychild = (int) coordChildren.getY(); int widthchild = (int) coordChildren.getWidth(); int heightchild = (int) coordChildren.getHeight(); xchild = (xchild + ((int) coordParent.getX() - (int) newCoordParent .getX())); ychild = ychild + ((int) coordParent.getY() - (int) newCoordParent.getY()); Hashtable newMap = new Hashtable(); GraphConstants.setBounds(newMap, new Rectangle(xchild, ychild, widthchild, heightchild)); map.put(child, newMap); } }
protected void insertEntityCell(Entity entity) { DefaultGraphCell cell = createEntityCell(entity); // putting cell to a random posistion.. GraphConstants.setBounds(cell.getAttributes(), new Rectangle2D.Double(Math.random() * graph.getWidth(), Math.random() * graph.getHeight(), 10, 10)); // setting graph type-specific attrs postProcessEntity(entity, cell); insert(cell); }
public DefaultGraphCell insert(Point point, String entity) throws InvalidEntity { // CellView information is not available after creating the cell. // Create a Map that holds the attributes for the Vertex Map map = new Hashtable(); // Snap the Point to the Grid // Construct Vertex with no Label DefaultGraphCell vertex; Dimension size; vertex=this.createCell(entity); size=this.getDefaultSize((Entity)vertex.getUserObject()); // Add a Bounds Attribute to the Map GraphConstants.setBounds(map, new Rectangle(point, size)); // Construct a Map from cells to Maps (for insert) Hashtable attributes = new Hashtable(); // Associate the Vertex with its Attributes attributes.put(vertex, map); // Insert the Vertex and its Attributes this.getModel().insert(new Object[] {vertex},attributes , null, null, null); return vertex; }
/** * 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; }
public DefaultGraphCell insert(Point point, String entity) throws InvalidEntity { // CellView information is not available after creating the cell. // Create a Map that holds the attributes for the Vertex Map map = new Hashtable(); // Snap the Point to the Grid // Construct Vertex with no Label DefaultGraphCell vertex; Dimension size; vertex=this.createCell(entity); size=this.getDefaultSize((Entity)vertex.getUserObject()); // Add a Bounds Attribute to the Map GraphConstants.setBounds(map, new Rectangle(point, size)); // Construct a Map from cells to Maps (for insert) Hashtable attributes = new Hashtable(); // Associate the Vertex with its Attributes attributes.put(vertex, map); // Insert the Vertex and its Attributes this.getModel().insert(new Object[] {vertex},attributes , null, null, null); return vertex; }
public DefaultGraphCell insert(Point point, String entity) throws InvalidEntity { // CellView information is not available after creating the cell. // Create a Map that holds the attributes for the Vertex Map map = new Hashtable(); // Snap the Point to the Grid // Construct Vertex with no Label DefaultGraphCell vertex; Dimension size; vertex=this.createCell(entity); size=this.getDefaultSize((Entity)vertex.getUserObject()); // Add a Bounds Attribute to the Map GraphConstants.setBounds(map, new Rectangle(point, size)); // Construct a Map from cells to Maps (for insert) Hashtable attributes = new Hashtable(); // Associate the Vertex with its Attributes attributes.put(vertex, map); // Insert the Vertex and its Attributes this.getModel().insert(new Object[] {vertex},attributes , null, null, null); return vertex; }
public DefaultGraphCell insert(Point point, String entity) throws InvalidEntity { // CellView information is not available after creating the cell. // Create a Map that holds the attributes for the Vertex Map map = new Hashtable(); // Snap the Point to the Grid // Construct Vertex with no Label DefaultGraphCell vertex; Dimension size; vertex=this.createCell(entity); size=this.getDefaultSize((Entity)vertex.getUserObject()); // Add a Bounds Attribute to the Map GraphConstants.setBounds(map, new Rectangle(point, size)); // Construct a Map from cells to Maps (for insert) Hashtable attributes = new Hashtable(); // Associate the Vertex with its Attributes attributes.put(vertex, map); // Insert the Vertex and its Attributes this.getModel().insert(new Object[] {vertex},attributes , null, null, null); return vertex; }
public DefaultGraphCell insert(Point point, String entity) throws InvalidEntity { // CellView information is not available after creating the cell. // Create a Map that holds the attributes for the Vertex Map map = new Hashtable(); // Snap the Point to the Grid // Construct Vertex with no Label DefaultGraphCell vertex; Dimension size; vertex=this.createCell(entity); size=this.getDefaultSize((Entity)vertex.getUserObject()); // Add a Bounds Attribute to the Map GraphConstants.setBounds(map, new Rectangle(point, size)); // Construct a Map from cells to Maps (for insert) Hashtable attributes = new Hashtable(); // Associate the Vertex with its Attributes attributes.put(vertex, map); // Insert the Vertex and its Attributes this.getModel().insert(new Object[] {vertex},attributes , null, null, null); return vertex; }
public DefaultGraphCell insert(Point point, String entity) throws InvalidEntity { // CellView information is not available after creating the cell. // Create a Map that holds the attributes for the Vertex Map map = new Hashtable(); // Snap the Point to the Grid // Construct Vertex with no Label DefaultGraphCell vertex; Dimension size; vertex=this.createCell(entity); size=this.getDefaultSize((Entity)vertex.getUserObject()); // Add a Bounds Attribute to the Map GraphConstants.setBounds(map, new Rectangle(point, size)); // Construct a Map from cells to Maps (for insert) Hashtable attributes = new Hashtable(); // Associate the Vertex with its Attributes attributes.put(vertex, map); // Insert the Vertex and its Attributes this.getModel().insert(new Object[] {vertex},attributes , null, null, null); return vertex; }
/** * 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 DefaultGraphCell insert(Point point, String entity) throws InvalidEntity { // CellView information is not available after creating the cell. // Create a Map that holds the attributes for the Vertex Map map = new Hashtable(); // Snap the Point to the Grid // Construct Vertex with no Label DefaultGraphCell vertex; Dimension size; vertex=this.createCell(entity); size=this.getDefaultSize((Entity)vertex.getUserObject()); // Add a Bounds Attribute to the Map GraphConstants.setBounds(map, new Rectangle(point, size)); // Construct a Map from cells to Maps (for insert) Hashtable attributes = new Hashtable(); // Associate the Vertex with its Attributes attributes.put(vertex, map); // Insert the Vertex and its Attributes this.getModel().insert(new Object[] {vertex},attributes , null, null, null); return vertex; }
public DefaultGraphCell insert(Point point, String entity) throws InvalidEntity { // CellView information is not available after creating the cell. // Create a Map that holds the attributes for the Vertex Map map = new Hashtable(); // Snap the Point to the Grid // Construct Vertex with no Label DefaultGraphCell vertex; Dimension size; vertex=this.createCell(entity); size=this.getDefaultSize((Entity)vertex.getUserObject()); // Add a Bounds Attribute to the Map GraphConstants.setBounds(map, new Rectangle(point, size)); // Construct a Map from cells to Maps (for insert) Hashtable attributes = new Hashtable(); // Associate the Vertex with its Attributes attributes.put(vertex, map); // Insert the Vertex and its Attributes this.getModel().insert(new Object[] {vertex},attributes , null, null, null); return vertex; }
public DefaultGraphCell insert(Point point, String entity) throws InvalidEntity { // CellView information is not available after creating the cell. // Create a Map that holds the attributes for the Vertex Map map = new Hashtable(); // Snap the Point to the Grid // Construct Vertex with no Label DefaultGraphCell vertex; Dimension size; vertex=this.createCell(entity); size=this.getDefaultSize((Entity)vertex.getUserObject()); // Add a Bounds Attribute to the Map GraphConstants.setBounds(map, new Rectangle(point, size)); // Construct a Map from cells to Maps (for insert) Hashtable attributes = new Hashtable(); // Associate the Vertex with its Attributes attributes.put(vertex, map); // Insert the Vertex and its Attributes this.getModel().insert(new Object[] {vertex},attributes , null, null, null); return vertex; }
@SuppressWarnings("unchecked") // FIXME hb 28-nov-05: See FIXME below private void positionVertexAt(Object vertex, int x, int y) { DefaultGraphCell cell = jgAdapter.getVertexCell(vertex); AttributeMap attr = cell.getAttributes(); Rectangle2D bounds = GraphConstants.getBounds(attr); Rectangle2D newBounds = new Rectangle2D.Double( x, y, bounds.getWidth(), bounds.getHeight()); GraphConstants.setBounds(attr, newBounds); // TODO: Clean up generics once JGraph goes generic AttributeMap cellAttr = new AttributeMap(); cellAttr.put(cell, attr); jgAdapter.edit(cellAttr, null, null, null); }
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; }
public void restoreContraints(DefaultGraphCell cell) { Entity ent=(Entity)cell.getUserObject(); Hashtable<DefaultGraphCell, Dimension> cellDimension = entityConstraints .get(this.hashCode()+":"+cell.hashCode() + ":" + ent.getPrefs(jg.getModel().getAttributes(cell)).getView()); Hashtable<Object, Map> changes = new Hashtable<Object, Map>(); if (cellDimension != null) { for (DefaultGraphCell dgc : cellDimension.keySet()) { if (dgc.getAttributes() != null) { // still exists Map oldmap = dgc.getAttributes(); Rectangle oldbounds = GraphConstants.getBounds(oldmap) .getBounds(); oldbounds.setSize(cellDimension.get(dgc)); GraphConstants.setBounds(oldmap, oldbounds); changes.put(dgc, oldmap); } } jg.getModel().edit(changes, null, null, null); jg.invalidate(); jg.repaint(); } }
private DefaultGraphCell createCell(String name, Point2d placement, int index) { // System.out.println(name + " " + placement + " " + index); stateCells[index] = new DefaultGraphCell(new String(name)); Font f = new Font("Arial", Font.PLAIN, 12); GraphConstants.setFont(stateCells[index].getAttributes(), f); GraphConstants.setAutoSize(stateCells[index].getAttributes(), true); GraphConstants.setOpaque(stateCells[index].getAttributes(), true); Color color = colorStateCell(stateMachine.states.get(indexOfStateinStateMachine(name))); GraphConstants.setBackground(stateCells[index].getAttributes(), color); GraphConstants.setBounds(stateCells[index].getAttributes(), new Rectangle2D.Double(placement.getX(), placement.getY(), 0, 0)); stateCells[index].addPort(); return stateCells[index]; }
private DefaultGraphCell createCell(String name, Point2D placement, int index) { // System.out.println(name + " " + placement + " " + index); stateCells[index] = new DefaultGraphCell(new String(name)); Font f = new Font("Arial", Font.PLAIN, 12); GraphConstants.setFont(stateCells[index].getAttributes(), f); GraphConstants.setAutoSize(stateCells[index].getAttributes(), true); GraphConstants.setOpaque(stateCells[index].getAttributes(), true); Color color = colorStateCell(stateMachine.states.get(indexOfStateinStateMachine(name))); GraphConstants.setBackground(stateCells[index].getAttributes(), color); GraphConstants.setBounds(stateCells[index].getAttributes(), new Rectangle2D.Double(placement.getX(), placement.getY(), 0, 0)); stateCells[index].addPort(); return stateCells[index]; }
/** * 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; }