/** * Returns true if the cell is moveable. If this returns false then the * cells bounds cannot be changed via the facade. The default implementation * checks the <code>moveable</code> attribute. Subclassers can override * this eg. to check if a cell is not selected in the graph. */ public boolean isMoveable(Object cell) { return GraphConstants.isMoveable(getAttributes(cell)); }
/** * 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); }
/** * Translates <code>map</code> by the given amount. */ public void translate(double dx, double dy) { // Translate Bounds if (GraphConstants.isMoveable(this)) { Rectangle2D bounds = GraphConstants.getBounds(this); if (bounds != null) { int moveableAxis = GraphConstants.getMoveableAxis(this); if (moveableAxis == GraphConstants.X_AXIS) dy = 0; else if (moveableAxis == GraphConstants.Y_AXIS) dx = 0; bounds.setFrame(bounds.getX() + dx, bounds.getY() + dy, bounds .getWidth(), bounds.getHeight()); } // Translate Points List points = GraphConstants.getPoints(this); if (points != null) { for (int i = 0; i < points.size(); i++) { Object obj = points.get(i); if (obj instanceof Point2D) { Point2D pt = (Point2D) obj; pt.setLocation(pt.getX() + dx, pt.getY() + dy); } } } } }
/** * Invoked when the mouse pointer has been moved on a component (with no * buttons down). */ public void mouseMoved(MouseEvent event) { for (int i = 0; i < r.length; i++) if (r[i].contains(event.getPoint())) { graph.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); event.consume(); return; } if (loc.contains(event.getPoint()) && graph.isMoveable() && GraphConstants.isMoveable(edge.getAllAttributes())) { graph.setCursor(new Cursor(Cursor.HAND_CURSOR)); event.consume(); } if (extraLabelLocations != null && graph.isMoveable() && GraphConstants.isMoveable(edge.getAllAttributes())) { for (int i = 0; i < extraLabelLocations.length; i++) { if (extraLabelLocations[i].contains(event.getPoint())) { graph.setCursor(new Cursor(Cursor.HAND_CURSOR)); event.consume(); } } } }
&& GraphConstants.isMoveable(edge.getAllAttributes()) && loc != null && loc.contains(x, y) && !isAddPointEvent(event) && !isRemovePointEvent(event) && GraphConstants.isMoveable(edge.getAllAttributes())) { for (int i = 0; i < extraLabelLocations.length; i++) { if (extraLabelLocations[i] != null