/** * Changes the <code>attributes</code> of the cell. * * @deprecated Use getAttributes().applyMap */ public Map changeAttributes(Map change) { return getAttributes().applyMap(change); }
@Override protected void postProcessEntity(Entity entity, DefaultGraphCell cell) { super.postProcessEntity(entity, cell); GraphConstants.setBackground(cell.getAttributes(), ENTITY_COLOR); GraphConstants.setOpaque(cell.getAttributes(), true); }
/** * Updates specified entity on the graph */ protected void updateEntityCell(Entity e) { DefaultGraphCell cell = entityCells.get(e.getName()); if (cell != null) { GraphConstants.setValue(cell.getAttributes(), getCellMetadata(e)); GraphConstants.setResize(cell.getAttributes(), true); Map nested = new HashMap(); nested.put(cell, cell.getAttributes()); edit(nested); } }
@Override protected void postProcessEntity(Entity entity, DefaultGraphCell cell) { super.postProcessEntity(entity, cell); GraphConstants.setBackground(cell.getAttributes(), ENTITY_COLOR); GraphConstants.setOpaque(cell.getAttributes(), true); DefaultEdge edge = createInheritanceEdge((ObjEntity) entity); if (edge != null) { createdObjects.add(edge); } }
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; }
protected DefaultGraphCell createEntityCell(Entity entity) { DefaultGraphCell cell = new DefaultGraphCell(getCellMetadata(entity)); GraphConstants.setResize(cell.getAttributes(), true); GraphConstants.setBorder(cell.getAttributes(), new LineBorder(Color.BLACK)); GraphConstants.setEditable(cell.getAttributes(), false); entityCells.put(entity.getName(), cell); cell.addPort(); return cell; }
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]; }
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 void storeContraints(DefaultGraphCell cell) { Hashtable<DefaultGraphCell, Dimension> cellDimension = new Hashtable<DefaultGraphCell, Dimension>(); Entity ent=(Entity)cell.getUserObject(); String constraintKey = this.hashCode()+":"+cell.hashCode() + ":" + ent.getPrefs(jg.getModel().getAttributes(cell)).getView(); entityConstraints.put( constraintKey, cellDimension); for (int k = 0; k < jg.getModel().getRootCount(); k++) { if (jg.getModel().getRootAt(k) instanceof DefaultGraphCell && !(jg.getModel().getRootAt(k) instanceof DefaultEdge)) { DefaultGraphCell currentDGCRoot = (DefaultGraphCell) jg .getModel().getRootAt(k); //if (currentDGCRoot.getUserObject().equals(ent) if (currentDGCRoot.equals(cell) && currentDGCRoot.getAttributes() != null && GraphConstants.getBounds(currentDGCRoot .getAttributes()) != null) { cellDimension.put( currentDGCRoot, new Dimension((int) GraphConstants.getBounds( currentDGCRoot.getAttributes()).getWidth(), (int) GraphConstants.getBounds( currentDGCRoot.getAttributes()) .getHeight())); } } } }
@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); }
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(); } }
Map attributes=dgc.getAttributes(); Rectangle2D loc=GraphConstants.getBounds(attributes); loc.setRect(loc.getX(),loc.getY(),dim.getWidth(),dim.getHeight());
Object userobject=dgc.getUserObject(); CellView currentview=this.ids.editor.getGraph().getGraphLayoutCache().getMapping(dgc,false); Map attributes=dgc.getAttributes(); Rectangle2D loc=GraphConstants.getBounds(attributes); double dirx=0; DefaultGraphCell otherdgc = (DefaultGraphCell) gm.getRootAt(i); if (otherdgc!=dgc){ Map otheratts=otherdgc.getAttributes(); Rectangle2D otherloc=GraphConstants.getBounds(otheratts); if (otherloc!=null){ Map sourceat=source.getAttributes(); Map targetat=target.getAttributes(); Rectangle2D locporto = GraphConstants.getBounds(sourceat); Rectangle2D locportt=GraphConstants.getBounds(targetat); double module=Math.sqrt(p.x*p.x+p.y*p.y); if (module!=0){ Map m=dgc.getAttributes(); Rectangle2D loc=GraphConstants.getBounds(m); if (loc!=null){
GraphConstants.setBounds(isolatedObjects.get(isolatedIndex).getAttributes(), new Rectangle2D.Double(pref.width - posX, pref.height - 3 * posY / 2, 10, 10)); isolatedIndex += 2; // because every 2nd object is port
public void resizeCurrentDiagram(ActionEvent e) { GraphModel gm=editor.getGraph().getModel(); for (int k=0;k<gm.getRootCount();k++){ DefaultGraphCell dgc = (DefaultGraphCell) gm.getRootAt(k); if (editor.getGraph().getListenerContainer().parentHasVisibleContainers(dgc).isEmpty()){ Object userobject=dgc.getUserObject(); CellView currentview=editor.getGraph().getGraphLayoutCache().getMapping(dgc,false); Entity ent=(Entity)dgc.getUserObject(); Map dgcMap=gm.getAttributes(dgc); if (ent!=null && RenderComponentManager.retrievePanel(ent.getType(),ent.getPrefs(dgcMap).getView())!=null){ Dimension dim=RenderComponentManager.getSize(ent,ent.getType(),ent.getPrefs(dgcMap).getView()); if (dim!=null){ Map attributes=dgc.getAttributes(); Rectangle2D loc=GraphConstants.getBounds(attributes); loc.setRect(loc.getX(),loc.getY(),dim.getWidth(),dim.getHeight()); GraphConstants.setBounds(attributes,loc); //attributes.put("view", ent.getPrefs(null).getView().toString()); Map nmap=new Hashtable(); nmap.put(dgc,attributes); editor.getGraph().getModel().edit(nmap,null,null,null); editor.getGraph().repaint(); } } } } } }
GraphEntityImp gei = (ingenias.generator.browser.GraphEntityImp)ge; DefaultGraphCell dgc1=gei.getDgc(); AttributeMap attributes = dgc1.getAttributes(); Rectangle2D bounds = org.jgraph.graph.GraphConstants.getBounds(attributes); AttributeMap attributes = dgc1.getAttributes(); Rectangle2D bounds = org.jgraph.graph.GraphConstants.getBounds(attributes);