AttributeMap undo = new AttributeMap(); if (change != null) { undo.putAll(this); clear(); Object oldValue = remove(remove[i]); if (oldValue != null) undo.put(remove[i], oldValue); && !key.equals(GraphConstants.REMOVEATTRIBUTES) && !key.equals(GraphConstants.VALUE)) { Object oldValue = applyValue(key, entry.getValue()); if (oldValue == null) { if (removeAttributes == null) { undo.put(key, oldValue);
/** * Apply the <code>key</code> to <code>value</code> * * @param key * the map key whose value is to be altered * @param value * the new value to be applied to the specified key * @return the old value. */ public Object applyValue(Object key, Object value) { // In all other cases we put the new value into the // map. If we encounter a list (of points) or rectangle // these will be cloned before insertion. Cloning includes // replacing the rectangle/points with serializable objects. if (value instanceof Rectangle2D) value = createRect((Rectangle2D) value); if (value instanceof Point2D) value = createPoint((Point2D) value); if (value instanceof Point2D[]) value = clonePoints((Point2D[]) value); if (value instanceof List) // FIXME: PointList interface? value = clonePoints((List) value); return put(key, value); }
/** * Returns a new map that contains all (key, value)-pairs of * <code>newState</code> where either key is not used or value is * different for key in <code>oldState</code>. In other words, this * method removes the common entries from oldState and newState, and returns * the "difference" between the two. * * This method never returns null. */ public Map diff(Map newState) { Map diff = new Hashtable(); Iterator it = newState.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); Object key = entry.getKey(); Object newValue = entry.getValue(); Object oldValue = get(key); if (oldValue == null || !oldValue.equals(newValue)) diff.put(key, newValue); } return diff; }
@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 actionPerformed(ActionEvent e) { graph.getListenerContainer().storeContraints(cell); graph.getModel().getAttributes(cell).put("view", "INGENIAS"); ent.getPrefs(graph.getModel().getAttributes(cell)).setView(ViewPreferences.ViewType.INGENIAS); graph.getListenerContainer().restoreContraints(cell); graph.invalidate(); graph.refresh(); } });
/** * Sets the attributes. * @param attributes The attributes to set */ public void setAttributes(AttributeMap attributes) { if (attributes == null) attributes = new AttributeMap(); this.attributes = attributes; }
/** * Creates a point of suitable type for this attribute map with the same * values as the point passed in * * @param p * the point whose values the new point are to be based on * @return a new copy of the point passed in */ public Point2D createPoint(Point2D p) { if (p != null) { return createPoint(p.getX(), p.getY()); } return null; }
Point2D p = createPoint(bounds.getX(), bounds.getY()); Point2D loc = (Point2D) p.clone(); p.setLocation(origin.getX() + Math.round((p.getY() - origin.getY()) * sy)); 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)
/** * Translates the maps in <code>c</code> using * <code>translate(Map, int, int)</code>. */ public static void translate(Collection c, double dx, double dy) { Iterator it = c.iterator(); while (it.hasNext()) { Object map = it.next(); if (map instanceof AttributeMap) ((AttributeMap) map).translate(dx, dy); } }
/** * Implements the merging of the cell's attributes, initially stored in * allAttributes, and the location attributes. The result should be stored * in allAttributes. This hook is for subclassers to change the merging * strategy. */ protected void mergeAttributes() { allAttributes.putAll(attributes); }
public void actionPerformed(ActionEvent e) { graph.getListenerContainer().storeContraints(cell); graph.getModel().getAttributes(cell).put("view", "INGENIAS"); ent.getPrefs(graph.getModel().getAttributes(cell)).setView(ViewPreferences.ViewType.INGENIAS); graph.getListenerContainer().restoreContraints(cell); graph.invalidate(); graph.refresh(); } });
/** * Hook for subclassers to avoid creating an empty AttributeMap during * construction of the instance. Override this and return null if you want * to avoid creation of an attribute map at construction time. */ protected AttributeMap createAttributeMap() { return new AttributeMap(); }
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; }
if (nested != null) { nested = GraphConstants.replaceKeys(clones, nested); AttributeMap.translate(nested.values(), dx, dy);
void updateAttributes(Map attributes) { if (attributes != null) { Iterator iterator = attributes.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry) iterator.next(); Object node = entry.getKey(); Map newAttributes = (Map) entry.getValue(); AttributeMap attr = getAttributes(node); if (attr != null) { attr.putAll(newAttributes); } } } }
public void actionPerformed(ActionEvent e) { graph.getListenerContainer().storeContraints(cell); graph.getModel().getAttributes(cell).put("view", "UML"); ent.getPrefs(graph.getModel().getAttributes(cell)).setView(ViewPreferences.ViewType.UML); graph.getListenerContainer().restoreContraints(cell); graph.invalidate(); graph.refresh(); } });
/** * Constructs a model that is not an attribute store. */ public DefaultGraphModel(List roots, AttributeMap attributes) { if (roots != null) this.roots = roots; else this.roots = new ArrayList(); if (attributes != null) this.attributes = attributes; else this.attributes = new AttributeMap(); }
/** * Returns a list where all instances of PortView are replaced by their * correspnding Point instance. */ public List clonePoints(Object[] points, boolean convertPortViews) { // TODO: Change the list in-place? ArrayList newList = new ArrayList(points.length); for (int i = 0; i < points.length; i++) { // Clone Point Object point = points[i]; if (point instanceof PortView && convertPortViews) point = createPoint(((PortView) point).getLocation()); else if (point instanceof Point2D) point = createPoint((Point2D) point); newList.add(point); } return newList; }
public int getChildCount(Object parent) { if (parent instanceof Processor) { int ports = ((Processor) parent).getPorts().length; if (getAttributes(parent) != null && getAttributes(parent).get(DUMMY_PORT) != null) { ports += 1; } return ports; } else if (parent instanceof Port && isPortOnWorkflowEdge(parent)) { return 0; } else if (parent instanceof List) { return ((List) parent).size(); } return 0; }