/** * Update the y-coordinate of an item. The current y value will become the * new starting y value, while the given value will become the new current * x and ending y values. This method also supports an optional referrer * item, whose y coordinate will become the new starting y coordinate * of item if item's current x value is NaN. * @param item the VisualItem to update * @param referrer an optional referrer VisualItem * @param y the y value to set */ public static void setY(VisualItem item, VisualItem referrer, double y) { double sy = item.getY(); if ( Double.isNaN(sy) ) sy = (referrer != null ? referrer.getY() : y); item.setStartY(sy); item.setEndY(y); item.setY(y); }
/** * @see prefuse.controls.Control#itemDragged(prefuse.visual.VisualItem, java.awt.event.MouseEvent) */ public void itemDragged(VisualItem item, MouseEvent e) { if (!SwingUtilities.isLeftMouseButton(e)) return; dragged = true; Display d = (Display)e.getComponent(); d.getAbsoluteCoordinate(e.getPoint(), temp); double dx = temp.getX()-down.getX(); double dy = temp.getY()-down.getY(); double x = item.getX(); double y = item.getY(); item.setStartX(x); item.setStartY(y); item.setX(x+dx); item.setY(y+dy); item.setEndX(x+dx); item.setEndY(y+dy); if ( repaint ) item.getVisualization().repaint(); down.setLocation(temp); if ( action != null ) d.getVisualization().run(action); }
protected static void move(VisualItem item, double dx, double dy) { if ( item instanceof AggregateItem ) { Iterator items = ((AggregateItem)item).items(); while ( items.hasNext() ) { move((VisualItem)items.next(), dx, dy); } } else { double x = item.getX(); double y = item.getY(); item.setStartX(x); item.setStartY(y); item.setX(x+dx); item.setY(y+dy); item.setEndX(x+dx); item.setEndY(y+dy); } }