/** * Returns the text to draw. Subclasses can override this class to * perform custom text selection. * @param item the item to represent as a <code>String</code> * @return a <code>String</code> to draw */ protected String getText(VisualItem item) { String s = null; if ( item.canGetString(m_labelName) ) { return item.getString(m_labelName); } return s; }
/** * 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; }
/** * @see prefuse.controls.Control#itemEntered(prefuse.visual.VisualItem, java.awt.event.MouseEvent) */ public void itemEntered(VisualItem item, MouseEvent e) { Display d = (Display)e.getSource(); if ( label.length == 1 ) { // optimize the simple case if ( item.canGetString(label[0]) ) { d.setToolTipText(item.getString(label[0])); } } else { sBuf.delete(0, sBuf.length()); for ( int i=0; i<label.length; ++i ) { if ( item.canGetString(label[i]) ) { if ( sBuf.length() > 0 ) sBuf.append("; "); sBuf.append(item.getString(label[i])); } } // show tool tip only, if at least one field is available if (sBuf.length() > 0) { d.setToolTipText(sBuf.toString()); } } }
String type = visualItem.getString(AnalysisConstants.EDGE_TYPE); if (type != null && type.equals(AnalysisConstants.GENERALIZATION)){ return generalizationRenderer; return referenceRenderer; if (visualItem.getString(AnalysisConstants.EDGE_TYPE) != null && visualItem.getString(AnalysisConstants.EDGE_TYPE).equals(AnalysisConstants.FILE_EDGE_TYPE) ){ return fileEdgeRenderer;
/** * @see prefuse.render.Renderer#render(java.awt.Graphics2D, prefuse.visual.VisualItem) */ public void render(Graphics2D g, VisualItem item) { Shape s = getShape(item); GraphicsLib.paint(g, item, m_line, getStroke(item), getRenderType(item)); // check if we have a text label, if so, render it if ( item.canGetString(VisualItem.LABEL) ) { float x = (float)m_box.getMinX(); float y = (float)m_box.getMinY() + m_ascent; // draw label background GraphicsLib.paint(g, item, s, null, RENDER_TYPE_FILL); String str = item.getString(VisualItem.LABEL); AffineTransform origTransform = g.getTransform(); AffineTransform transform = this.getTransform(item); if ( transform != null ) g.setTransform(transform); g.setFont(item.getFont()); g.setColor(ColorLib.getColor(item.getTextColor())); g.drawString(str, x, y); if ( transform != null ) g.setTransform(origTransform); } }
return m_line; String label = item.getString(VisualItem.LABEL); if ( label == null ) return m_line;
/** * Edit text for the given VisualItem and field. Presents a text * editing widget spanning the given bounding box. Use stopEditing() * to hide the text widget. When stopEditing() is called, the field * will automatically be updated with the VisualItem. * @param item the VisualItem to edit * @param attribute the attribute to edit * @param r Rectangle representing the desired bounding box of the text * editing widget */ public void editText(VisualItem item, String attribute, Rectangle r) { if ( m_editing ) { stopEditing(); } String txt = item.getString(attribute); m_editItem = item; m_editAttribute = attribute; Color tc = ColorLib.getColor(item.getTextColor()); Color fc = ColorLib.getColor(item.getFillColor()); m_editor.setForeground(tc); m_editor.setBackground(fc); editText(txt, r); }
fileName = item.getString(AnalysisConstants.XML_FILENAME);
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