if ( item.isFixed() ) continue; item.setX(item.getEndX()); item.setY(item.getEndY()); item.setSize(item.getEndSize()); Rectangle2D bBox = item.getBounds(); double x = item.getX(); double y = item.getY(); item.setX(x=distortX(x, anchor, bounds)); if ( m_distortY ) item.setY(y=distortY(y, anchor, bounds)); item.setSize(sz*item.getSize());
/** * @see prefuse.render.Renderer#setBounds(prefuse.visual.VisualItem) */ public void setBounds(VisualItem item) { if ( !m_manageBounds ) return; Shape shape = getShape(item); if ( shape == null ) { item.setBounds(item.getX(), item.getY(), 0, 0); return; } GraphicsLib.setBounds(item, shape, getStroke(item)); if ( m_curArrow != null ) { Rectangle2D bBox = (Rectangle2D)item.get(VisualItem.BOUNDS); Rectangle2D.union(bBox, m_curArrow.getBounds2D(), bBox); } }
/** * @see prefuse.action.Action#run(double) */ public void run(double frac) { Iterator iter = m_vis.items(m_group); while ( iter.hasNext() ) { VisualItem item = (VisualItem)iter.next(); try { if ( m_xfield != null ) setX(item, null, item.getDouble(m_xfield)); if ( m_yfield != null ) setY(item, null, item.getDouble(m_yfield)); if ( m_fixedfield != null ) item.setFixed(item.getBoolean(m_fixedfield)); } catch ( Exception e ) { } } }
/** * Returns a location string for the image to draw. Subclasses can override * this class to perform custom image selection beyond looking up the value * from a data field. * @param item the item for which to select an image to draw * @return the location string for the image to use, or null for no image */ protected String getImageLocation(VisualItem item) { return item.canGetString(m_imageName) ? item.getString(m_imageName) : null; }
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); } }
public void run (double frac) { VisualItem item = null; SwimlanesStatePalette pal = new SwimlanesStatePalette(); Iterator<?> curr_group_items = this.m_vis.items(this.m_group); while (curr_group_items.hasNext()) { item = (VisualItem) curr_group_items.next(); double start_time = item.getDouble(START_FIELD_NAME); double finish_time = item.getDouble(END_FIELD_NAME); item.setShape(Constants.POLY_TYPE_LINE); item.setX(0.0); item.setY(0.0); float [] coords = new float[4]; coords[0] = (float) cs.get_x_coord(start_time); coords[1] = (float) cs.get_y_coord((double)item.getInt("ycoord")); coords[2] = (float) cs.get_x_coord(finish_time); coords[3] = (float) cs.get_y_coord((double)item.getInt("ycoord")); item.set(VisualItem.POLYGON,coords); item.setStrokeColor(pal.getColour(item.getString("state_name"))); } } } // SwimlanesStateAction
if ( UILib.isButtonPressed(e, button) && e.getClickCount() == ccount) { Visualization vis = item.getVisualization(); if (ccount == 1){ selectNode(item,e); if (item.canGetBoolean(AnalysisConstants.IS_FILE_GROUP_AGGREGATE) && item.getBoolean(AnalysisConstants.IS_FILE_GROUP_AGGREGATE) && item.canGetInt(AnalysisConstants.ID)){ aggregateItemFileGroup = item.getInt(AnalysisConstants.ID); if ((item.canGetBoolean(AnalysisConstants.IS_FILE_NODE) && item.getBoolean(AnalysisConstants.IS_FILE_NODE) ) || aggregateItemFileGroup > -1) { else if (item.canGet(AnalysisConstants.REFACTORING_ELEMENT, RefactoringElement.class)) { RefactoringElement comp = (RefactoringElement) item.get(AnalysisConstants.REFACTORING_ELEMENT);
public int getColor(VisualItem item) { if (item.isHighlighted()){ return AnalysisConstants.COLOR_HIGHLIGHT; if (item.canGetString(AnalysisConstants.XML_FILENAME)){ fileName = item.getString(AnalysisConstants.XML_FILENAME); item.getVisualization().getFocusGroup(Visualization.FOCUS_ITEMS); boolean mouseover = false; if (item.canGetBoolean(AnalysisConstants.MOUSEOVER) && item.getBoolean(AnalysisConstants.MOUSEOVER)){ mouseover = true; } else if (item.canGetBoolean(AnalysisConstants.IS_QUERY_NODE) && item.getBoolean(AnalysisConstants.IS_QUERY_NODE)){ return AnalysisConstants.COLOR_QUERY_NODE; } else if (item.canGetBoolean(AnalysisConstants.IS_USAGE_NODE) && item.getBoolean(AnalysisConstants.IS_USAGE_NODE)){ return AnalysisConstants.COLOR_USAGE_NODE; } else if (item.canGetBoolean(AnalysisConstants.IS_HEAD_ELEMENT) && item.getBoolean(AnalysisConstants.IS_HEAD_ELEMENT)){ return AnalysisConstants.COLOR_QUERY_NODE;
/** * Get the distance between the x,y points of two VisualItems. * @param vi1 the first VisualItem * @param vi2 the second VisualItem * @return the distance between the items' x,y coordinates */ public static double distance(VisualItem vi1, VisualItem vi2) { double dx = vi1.getX() - vi2.getX(); double dy = vi1.getY() - vi2.getY(); return Math.sqrt(dx*dx + dy*dy); }
private static void addPoint(double[] pts, int idx, VisualItem item, int growth) { Rectangle2D b = item.getBounds(); double minX = (b.getMinX())-growth, minY = (b.getMinY())-growth; double maxX = (b.getMaxX())+growth, maxY = (b.getMaxY())+growth; pts[idx] = minX; pts[idx+1] = minY; pts[idx+2] = minX; pts[idx+3] = maxY; pts[idx+4] = maxX; pts[idx+5] = minY; pts[idx+6] = maxX; pts[idx+7] = maxY; }
public int getColor(VisualItem item) { boolean mouseover = false; if (item.canGetBoolean(AnalysisConstants.MOUSEOVER) && item.getBoolean(AnalysisConstants.MOUSEOVER)){ mouseover = true; } TupleSet selected = item.getVisualization().getFocusGroup(Visualization.FOCUS_ITEMS); if (selected.containsTuple(item) || mouseover){ // return Color.WHITE.getRGB(); return Color.BLACK.getRGB(); } if (item.canGetBoolean(AnalysisConstants.IS_QUERY_NODE) && item.getBoolean(AnalysisConstants.IS_QUERY_NODE)){ item.setFont(item.getFont().deriveFont(Font.BOLD)); if (item.canGetBoolean(AnalysisConstants.MOUSEOVER) && item.getBoolean(AnalysisConstants.MOUSEOVER) == false && item.isHighlighted() == false){ return Color.WHITE.getRGB(); } } return Color.BLACK.getRGB(); }
while ( iter.hasNext() ) { VisualItem item = (VisualItem)iter.next(); ForceItem fitem = (ForceItem)item.get(FORCEITEM); if ( item.isFixed() ) { fitem.velocity[1] = 0.0f; if ( Double.isNaN(item.getX()) ) { setX(item, referrer, 0.0); setY(item, referrer, 0.0); Rectangle2D b = item.getBounds(); double hw = b.getWidth()/2; double hh = b.getHeight()/2;
} catch ( IllegalArgumentException iae ) { /* ignored */ } float startX = (referrer == null ? 0f : (float)referrer.getX()); float startY = (referrer == null ? 0f : (float)referrer.getY()); startX = Float.isNaN(startX) ? 0f : startX; startY = Float.isNaN(startY) ? 0f : startY; while ( iter.hasNext() ) { VisualItem item = (VisualItem)iter.next(); ForceItem fitem = (ForceItem)item.get(FORCEITEM); fitem.mass = getMassValue(item); double x = item.getEndX(); double y = item.getEndY(); fitem.location[0] = (Double.isNaN(x) ? startX : (float)x); fitem.location[1] = (Double.isNaN(y) ? startY : (float)y);
/** * Update the x-coordinate of an item. The current x value will become the * new starting x value, while the given value will become the new current * x and ending x values. This method also supports an optional referrer * item, whose x coordinate will become the new starting x coordinate * of item if item's current x value is NaN. * @param item the VisualItem to update * @param referrer an optional referrer VisualItem * @param x the x value to set */ public static void setX(VisualItem item, VisualItem referrer, double x) { double sx = item.getX(); if ( Double.isNaN(sx) ) sx = (referrer != null ? referrer.getX() : x); item.setStartX(sx); item.setEndX(x); item.setX(x); }
/** * 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); }