protected void installAttributes(CellView view) { super.installAttributes(view); Map map = view.getAllAttributes(); if (map.containsKey("progress")) { String progressStringValue = (String) map.get("progress");
public void installAttributes(CellView view) { super.installAttributes(view); // Map map = view.getAllAttributes(); shape = SVGGraphConstants.getShape(view.getAllAttributes()); }
/** * Returns a nested map of (cell, map) pairs that represent all attributes * of all cell views in this view. * * @see #getCellViews */ public Map createNestedMap() { CellView[] cellViews = getCellViews(); Map nested = new Hashtable(); for (int i = 0; i < cellViews.length; i++) { nested.put(cellViews[i].getCell(), new Hashtable((Map) cellViews[i] .getAllAttributes().clone())); } return nested; }
public void updateAutoSize(CellView view) { if (!view.isLeaf()) { CellView[] children = view.getChildViews(); Rectangle2D rect = GraphConstants.getBounds(children[0] .getAllAttributes()); double x = rect.getMaxX() + 10; double y = rect.getY(); for (int index = 1; index < children.length; index++) { Rectangle2D childRect = GraphConstants .getBounds(children[index].getAllAttributes()); childRect.setFrame(x, y, childRect.getWidth(), childRect .getHeight()); x += childRect.getWidth() + 10; children[index].update(); } } else { super.updateAutoSize(view); } }
/** * Returns the bounds to be used to highlight the given cell view. * * @param graph * @param cellView * @return */ protected Rectangle getHighlightBounds(JGraph graph, CellView cellView) { boolean offset = (GraphConstants.getOffset(cellView.getAllAttributes()) != null); Rectangle2D r = (offset) ? cellView.getBounds() : cellView .getParentView().getBounds(); r = graph.toScreen((Rectangle2D) r.clone()); int s = 3; return new Rectangle((int) (r.getX() - s), (int) (r.getY() - s), (int) (r.getWidth() + 2 * s), (int) (r.getHeight() + 2 * s)); }
view = cm.getMapping(key, false); if (view != null) attributes.put(key, view.getAllAttributes().clone()); // FIXME:
int x = (new Double( (GraphConstants.getBounds(sourceView.getAllAttributes() ).getX() + GraphConstants.getBounds(targetGraphLayoutCache.getAllAttributes()). getX()) / 2)).intValue(); int y = (new Double( (GraphConstants.getBounds(sourceView.getAllAttributes() ).getY() + GraphConstants.getBounds(targetGraphLayoutCache.getAllAttributes()). getY()) / 2)).intValue();
protected void paintPort(Graphics g, CellView p) { boolean offset = (GraphConstants.getOffset(p.getAllAttributes()) != null); Rectangle2D r = (offset) ? p.getBounds() : p.getParentView() .getBounds(); r = graph.toScreen((Rectangle2D) r.clone()); int s = 3; r.setFrame(r.getX() - s, r.getY() - s, r.getWidth() + 2 * s, r .getHeight() + 2 * s); graph.getUI().paintCell(g, p, r, true); }
/** * Overriding this in order to set the size of an editor to that of an * edited view. */ public Component getGraphCellEditorComponent(JGraph graph, Object cell, boolean isSelected) { Component component = super.getGraphCellEditorComponent(graph, cell, isSelected); // set the size of an editor to that of the view CellView view = graph.getGraphLayoutCache().getMapping(cell, false); Rectangle2D tmp = view.getBounds(); editingComponent.setBounds((int) tmp.getX(), (int) tmp.getY(), (int) tmp.getWidth(), (int) tmp.getHeight()); // I have to set a font here instead of in the // RealCellEditor.getGraphCellEditorComponent() because // I don't know what cell is being edited when in the // RealCellEditor.getGraphCellEditorComponent(). Font font = GraphConstants.getFont(view.getAllAttributes()); editingComponent.setFont((font != null) ? font : graph.getFont()); return component; }
/** * Returns <code>true</code> if the graph and the cell are editable. This * is invoked from the UI before editing begins to ensure that the given * cell can be edited. * * @return true if the specified cell is editable * @see #isEditable * */ public boolean isCellEditable(Object cell) { if (cell != null) { CellView view = graphLayoutCache.getMapping(cell, false); if (view != null) { return isEditable() && GraphConstants.isEditable(view.getAllAttributes()); } } return false; }
/** * Returns the attributes for the specified cell. If the layout cache * returns a view for the cell then this method returns allAttributes, * otherwise the method returns model.getAttributes(cell). */ public AttributeMap getAttributes(Object cell) { AttributeMap attrs; CellView cellView = getGraphLayoutCache().getMapping(cell, false); if (cellView != null) { attrs = cellView.getAllAttributes(); } else { attrs = getModel().getAttributes(cell); } return attrs; }
CellView view = getMapping(cell, false); if (view != null) { AttributeMap attrs = view.getAllAttributes(); Rectangle2D bounds = GraphConstants.getBounds(attrs); Rectangle2D dummyBounds = null;
/** * Configures the editor. Passed onto the realEditor. */ public Component getGraphCellEditorComponent( JGraph graph, Object cell, boolean isSelected) { setGraph(graph); editingComponent = realEditor.getGraphCellEditorComponent(graph, cell, isSelected); determineOffset(graph, cell, isSelected); canEdit = (lastCell != null && cell != null && lastCell.equals(cell)); CellView view = graph.getGraphLayoutCache().getMapping(cell, false); if (view != null) setFont(GraphConstants.getFont(view.getAllAttributes())); editingContainer.setFont(font); return editingContainer; }
map = view.getAllAttributes(); bounds = (Rectangle2D)view.getBounds().clone();
.getAllAttributes()); Rectangle2D rect = parent.getBounds(); if (rect != null && src != null) {
/** * Returns the nearest point wrt to the source or target. This method * returns the next or previous point or port in the points list, eg. if * source is true it returns the location of the point or port at index 1 * without calling the getLocation method on any ports.<br> * Likewise, the method returns the location at index getPointCount()-2 if * source is false. */ protected Point2D getNearestPoint(boolean source) { if (getPointCount() == 2) { if (source && target instanceof PortView && GraphConstants.getOffset(target.getAllAttributes()) != null) { return ((PortView) target).getLocation(this); } if (!source && this.source instanceof PortView && GraphConstants.getOffset(this.source.getAllAttributes()) != null) { return ((PortView) this.source).getLocation(this); } if (source && targetParentView != null && targetParentView.isLeaf()) return getCenterPoint(targetParentView); else if (!source && sourceParentView != null && sourceParentView.isLeaf()) return getCenterPoint(sourceParentView); } return getPointLocation((source) ? 1 : getPointCount() - 2); }
if (bounds != null) { boolean autosize = GraphConstants.isAutoSize(view .getAllAttributes()); boolean resize = GraphConstants.isResize(view .getAllAttributes()); if (autosize || resize) { Dimension2D d = getUI().getPreferredSize(this, view);
/** * Returns the default portview for the specified cell. The default * implementation returns the first floating port (ie. the first port that * does not define an offset) or <b>the </b> port, if there is only one * port. * * @param cell * the cell whose port is to be obtained * @return the port view of the specified cell */ public PortView getDefaultPortForCell(Object cell) { if (cell != null && !getModel().isEdge(cell)) { int childCount = getModel().getChildCount(cell); for (int i = 0; i < childCount; i++) { Object childCell = getModel().getChild(cell, i); CellView child = getGraphLayoutCache().getMapping(childCell, false); if (child instanceof PortView) { Point2D offset = GraphConstants.getOffset(child .getAllAttributes()); if (offset == null || childCount == 1) return (PortView) child; } } } return null; }
if (port != null && GraphConstants.isDisconnectable(port .getParentView().getAllAttributes()) && !contains(port.getCell())) { view.setSource(null); if (port != null && GraphConstants.isDisconnectable(port .getParentView().getAllAttributes()) && !contains(port.getCell())) { view.setTarget(null);
/** * Install the attributes of specified cell in this renderer instance. This * means, retrieve every published key from the cells hashtable and set * global variables or superclass properties accordingly. * * @param view * the cell view to retrieve the attribute values from. */ protected void installAttributes(CellView view) { Map map = view.getAllAttributes(); setIcon(GraphConstants.getIcon(map)); setOpaque(GraphConstants.isOpaque(map)); setBorder(GraphConstants.getBorder(map)); setVerticalAlignment(GraphConstants.getVerticalAlignment(map)); setHorizontalAlignment(GraphConstants.getHorizontalAlignment(map)); setVerticalTextPosition(GraphConstants.getVerticalTextPosition(map)); setHorizontalTextPosition(GraphConstants.getHorizontalTextPosition(map)); bordercolor = GraphConstants.getBorderColor(map); borderWidth = Math.max(1, Math.round(GraphConstants.getLineWidth(map))); if (getBorder() == null && bordercolor != null) setBorder(BorderFactory.createLineBorder(bordercolor, borderWidth)); Color foreground = GraphConstants.getForeground(map); setForeground((foreground != null) ? foreground : defaultForeground); Color gradientColor = GraphConstants.getGradientColor(map); setGradientColor(gradientColor); Color background = GraphConstants.getBackground(map); setBackground((background != null) ? background : defaultBackground); setFont(GraphConstants.getFont(map)); labelEnabled = GraphConstants.isLabelEnabled(map); }