/** * Update attributes for this view and indicate to the parent this child has * been updated */ public void update(GraphLayoutCache cache) { mergeAttributes(); // Notify Parent groupBounds = null; childUpdated(); }
/** * Updates the bounds of this view and its children * */ protected void updateGroupBounds() { // Note: Prevent infinite recursion by removing // child edges that point to their parent. CellView[] childViews = getChildViews(); LinkedList result = new LinkedList(); for (int i = 0; i < childViews.length; i++) if (includeInGroupBounds(childViews[i])) result.add(childViews[i]); childViews = new CellView[result.size()]; result.toArray(childViews); Rectangle2D r = getBounds(childViews); int groupBorder = GraphConstants.getInset(getAllAttributes()); if (r != null) r.setFrame(r.getX() - groupBorder, r.getY() - groupBorder, r .getWidth() + 2 * groupBorder, r.getHeight() + 2 * groupBorder); groupBounds = r; }
/** * Returns the intersection of the bounding rectangle and the straight line * between the source and the specified point p. The specified point is * expected not to intersect the bounds. Note: You must override this method * if you use a different renderer. This is because this method relies on * the VertexRenderer interface, which can not be safely assumed for * subclassers. */ public Point2D getPerimeterPoint(EdgeView edge, Point2D source, Point2D p) { return getCenterPoint(this); }
/** * Translates <code>view</code> (group) by <code>dx, dy</code>. * * @param dx * the x-coordinate amount to translate by * @param dy * the y-coordinate amount to translate by */ public void translate(double dx, double dy) { if (isLeaf()) getAllAttributes().translate(dx, dy); else { int moveableAxis = GraphConstants .getMoveableAxis(getAllAttributes()); if (moveableAxis == GraphConstants.X_AXIS) dy = 0; else if (moveableAxis == GraphConstants.Y_AXIS) dx = 0; Iterator it = childViews.iterator(); while (it.hasNext()) { Object view = it.next(); if (view instanceof AbstractCellView) { AbstractCellView child = (AbstractCellView) view; child.translate(dx, dy); } } } }
/** * Sets the bounds of this <code>view</code>. Calls translateView and * scaleView. * * @param bounds * the new bounds for this cell view */ public void setBounds(Rectangle2D bounds) { Rectangle2D oldBounds = getBounds(); if (oldBounds == null) oldBounds = new Rectangle2D.Double(); Point2D p0 = new Point2D.Double(oldBounds.getX(), oldBounds.getY()); Point2D pe = new Point2D.Double(bounds.getX(), bounds.getY()); Rectangle2D localBounds = new Rectangle2D.Double(bounds.getX(), bounds .getY(), bounds.getWidth(), bounds.getHeight()); if (GraphConstants.isMoveable(getAllAttributes()) && !pe.equals(p0)) translate(pe.getX() - p0.getX(), pe.getY() - p0.getY()); else localBounds.setFrame(localBounds.getX(), localBounds.getY(), bounds .getWidth() - pe.getX() + p0.getX(), bounds.getHeight() - pe.getY() + p0.getY()); double lbw = localBounds.getWidth(), lbh = localBounds.getHeight(); double obw = oldBounds.getWidth(), obh = oldBounds.getHeight(); if ((lbw != obw || lbh != obh) && obw > 0 && obh > 0) scale(lbw / obw, lbh / obh, pe); }
if (isLeaf()) getAttributes().scale(sx, sy, origin); else { int sizeableAxis = GraphConstants .getSizeableAxis(getAllAttributes()); if (sizeableAxis == GraphConstants.X_AXIS) sy = 1; if (view instanceof AbstractCellView) { AbstractCellView child = (AbstractCellView) view; Map attrs = child.getAttributes(); if (GraphConstants.isSizeable(attrs) || GraphConstants.isAutoSize(attrs)) child.scale(sx, sy, origin);
/** * Returns true if the view intersects the given rectangle. * * @param graph * the <code>JGraph</code> instance of the view * @param rect * the rectangle within which intersection is being checked for * * @return whether or not the rectangle specified intersects the view */ public boolean intersects(JGraph graph, Rectangle2D rect) { if (isLeaf() || GraphConstants.isGroupOpaque(getAllAttributes())) { Rectangle2D bounds = getBounds(); if (bounds != null) return bounds.intersects(rect); } else { // Check If Children Intersect Iterator it = childViews.iterator(); while (it.hasNext()) if (((CellView) it.next()).intersects(graph, rect)) return true; } return false; }
allAttributes = getCellAttributes(model); CellView tmp = mapper.getMapping(par, createDependentViews); if (tmp != parent) removeFromParent(); parent = tmp; update(cache);
/** * Returns the cached bounds for the vertex. */ public Rectangle2D getBounds() { Rectangle2D rect = super.getBounds(); if (rect == null) rect = bounds; return rect; }
if (offgraphics != null || !graph.isXorEnabled()) { dirty = graph .toScreen((Rectangle2D) vertex.getBounds().clone()); Rectangle2D t = graph.toScreen(AbstractCellView .getBounds(contextViews)); if (t != null) dirty.add(t); .getDescendantViews(new CellView[] { vertex }); for (int i = 0; i < all.length; i++) { CellView orig = graph.getGraphLayoutCache().getMapping( .clone())); Rectangle2D t = graph.toScreen(AbstractCellView .getBounds(contextViews)); if (t != null) dirty.add(t);
/** * Returns the next view at the specified location wrt. <code>current</code>. * This is used to iterate overlapping cells, and cells that are grouped. * The current selection affects this method. <br> * Note: This returns the next <i>selectable </i> view. <br> * Note: Arguments are not expected to be scaled (they are scaled in here). */ public CellView getNextViewAt(CellView current, double x, double y, boolean leafsOnly) { CellView[] cells = AbstractCellView .getDescendantViews(getGraphLayoutCache().getRoots()); return getNextViewAt(cells, current, x, y, leafsOnly); }
/** * This method ensures a non-null value. If the super method returns null * then the last valid parent is returned. Note: If a vertex is removed, all * ports will be replaced in connected edges. The ports are replaced by the * center point of the <i>last </i> valid vertex view. */ public CellView getParentView() { CellView parent = super.getParentView(); if (parent == null) parent = lastParent; else lastParent = parent; return parent; }
&& getCell() instanceof DefaultMutableTreeNode) { EdgeView edgeView = (EdgeView) view; if (edgeView.getCell() instanceof DefaultMutableTreeNode) {
/** * Returns the location for this edgeview. */ public Rectangle2D getBounds() { Rectangle2D rect = super.getBounds(); if (rect == null) { if (cachedBounds == null) { cachedBounds = getEdgeRenderer().getBounds(this); } rect = cachedBounds; } return rect; }
/** Process mouse pressed event. */ public void mousePressed(MouseEvent event) { if (!graph.isSizeable()) return; for (int i = 0; i < r.length; i++) { if (r[i].contains(event.getPoint()) && cursors[i] != 0) { Set set = new HashSet(); set.add(vertex.getCell()); contextViews = context.createTemporaryContextViews(set); Object[] all = AbstractCellView .getDescendantViews(new CellView[] { vertex }); if (all.length >= org.jgraph.plaf.basic.BasicGraphUI.MAXHANDLES) cachedBounds = (Rectangle2D) initialBounds.clone(); event.consume(); index = i; return; } } }
/** * @deprecated replaced by * {@link #getPerimeterPoint(EdgeView edge, Point2D source, Point2D p)} */ public Point2D getPerimeterPoint(Point2D source, Point2D p) { return AbstractCellView.getCenterPoint(this); }
&& initialLocation != null && start != null) { Rectangle2D graphBounds = graph.getBounds(); Rectangle2D viewBounds = AbstractCellView.getBounds(views); if (initialLocation.getX() + totDx + viewBounds.getWidth() > graphBounds .getWidth())
public void mouseReleased(MouseEvent e) { if (index != -1) { cachedBounds = computeBounds(e); vertex.setBounds(cachedBounds); CellView[] views = AbstractCellView .getDescendantViews(new CellView[] { vertex }); Map attributes = GraphConstants.createAttributes(views, null); graph.getGraphLayoutCache().edit(attributes, null, null, null); } e.consume(); cachedBounds = null; initialBounds = null; firstDrag = true; }
/** * @deprecated replaced by * {@link AbstractCellView#getCenterPoint(CellView vertex)} * @return the center point of this vertex */ public Point2D getCenterPoint() { return AbstractCellView.getCenterPoint(this); }
Rectangle2D size = AbstractCellView.getBounds(graphLayoutCache .getRoots()); if (size == null)