ca.utoronto.cs.prefuseextensions.render
Class ArcLabelRenderer

java.lang.Object
  extended by prefuse.render.AbstractShapeRenderer
      extended by ca.utoronto.cs.prefuseextensions.render.ArcLabelRenderer
All Implemented Interfaces:
prefuse.render.Renderer

public class ArcLabelRenderer
extends prefuse.render.AbstractShapeRenderer

CMC Modified copy of LabelRenderer v 2.2 Renderer that draws a label, which consists of a text string, an image, or both.

When created using the default constructor, the renderer attempts to use text from the "label" field. To use a different field, use the appropriate constructor or use the setTextField(String) method. To perform custom String selection, subclass this Renderer and override the getText(VisualItem) method. When the text field is null, no text label will be shown. Labels can span multiple lines of text, determined by the presence of newline characters ('\n') within the text string.

By default, no image is shown. To show an image, the image field needs to be set, either using the appropriate constructor or the setImageField(String) method. The value of the image field should be a text string indicating the location of the image file to use. The string should be either a URL, a file located on the current classpath, or a file on the local filesystem. If found, the image will be managed internally by an ImageFactory instance, which maintains a cache of loaded images.

The position of the image relative to text can be set using the #setImagePosition(int) method. Images can be placed to the left, right, above, or below the text. The horizontal and vertical alignments of either the text or the image can be set explicitly using the appropriate methods of this class (e.g., #setHorizontalTextAlignment(int)). By default, both the text and images are centered along both the horizontal and vertical directions.

Author:
jeffrey heer, Christopher Collins

Field Summary
static prefuse.data.Schema LABEL_SCHEMA
           
 
Fields inherited from class prefuse.render.AbstractShapeRenderer
RENDER_TYPE_DRAW, RENDER_TYPE_DRAW_AND_FILL, RENDER_TYPE_FILL, RENDER_TYPE_NONE
 
Fields inherited from interface prefuse.render.Renderer
DEFAULT_GRAPHICS
 
Constructor Summary
ArcLabelRenderer()
          Create a new LabelRenderer.
ArcLabelRenderer(java.lang.String textField)
          Create a new LabelRenderer.
ArcLabelRenderer(java.lang.String textField, double minimumRenderSize)
          Create a new LabelRenderer.
ArcLabelRenderer(java.lang.String textField, double minimumRenderSize, double maximumRenderSize)
          Create a new LabelRenderer.
 
Method Summary
 java.lang.String getImageField()
          Get the data field for image locations.
 java.lang.String getTextField()
          Get the field name to use for text labels.
 void render(java.awt.Graphics2D g, prefuse.visual.VisualItem item)
           
 void setImageField(java.lang.String imageField)
          Set the data field for image locations.
 void setMaxImageDimensions(int width, int height)
          Sets the maximum image dimensions, used to control scaling of loaded images.
 void setMaxTextWidth(int maxWidth)
          Sets the maximum width that should be allowed of the text label.
 void setRoundedCorner(int arcWidth, int arcHeight)
          Rounds the corners of the bounding rectangle in which the text string is rendered.
 void setTextField(java.lang.String textField)
          Set the field name to use for text labels.
 
Methods inherited from class prefuse.render.AbstractShapeRenderer
getRenderType, getShape, locatePoint, setBounds, setManageBounds, setRenderType
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LABEL_SCHEMA

public static final prefuse.data.Schema LABEL_SCHEMA
Constructor Detail

ArcLabelRenderer

public ArcLabelRenderer()
Create a new LabelRenderer. By default the field "label" is used as the field name for looking up text, and no image is used.


ArcLabelRenderer

public ArcLabelRenderer(java.lang.String textField)
Create a new LabelRenderer. Draws a text label using the given text data field and does not draw an image.

Parameters:
textField - the data field for the text label.

ArcLabelRenderer

public ArcLabelRenderer(java.lang.String textField,
                        double minimumRenderSize)
Create a new LabelRenderer. Draws a text label using the given text data field and does not draw an image.

Parameters:
textField - the data field for the text label.
minimumRenderSize - do not render text with height smaller than the specified point size

ArcLabelRenderer

public ArcLabelRenderer(java.lang.String textField,
                        double minimumRenderSize,
                        double maximumRenderSize)
Create a new LabelRenderer. Draws a text label using the given text data field and does not draw an image.

Parameters:
textField - the data field for the text label.
minimumRenderSize - do not render text with height smaller than the specified point size
maximumRenderSize - cap font height at this point size
Method Detail

setRoundedCorner

public void setRoundedCorner(int arcWidth,
                             int arcHeight)
Rounds the corners of the bounding rectangle in which the text string is rendered. This will only be seen if either the stroke or fill color is non-transparent.

Parameters:
arcWidth - the width of the curved corner
arcHeight - the height of the curved corner

getTextField

public java.lang.String getTextField()
Get the field name to use for text labels.

Returns:
the data field for text labels, or null for no text

setTextField

public void setTextField(java.lang.String textField)
Set the field name to use for text labels.

Parameters:
textField - the data field for text labels, or null for no text

setMaxTextWidth

public void setMaxTextWidth(int maxWidth)
Sets the maximum width that should be allowed of the text label. A value of -1 specifies no limit (this is the default).

Parameters:
maxWidth - the maximum width of the text or -1 for no limit

getImageField

public java.lang.String getImageField()
Get the data field for image locations. The value stored in the data field should be a URL, a file within the current classpath, a file on the filesystem, or null for no image.

Returns:
the data field for image locations, or null for no images

setImageField

public void setImageField(java.lang.String imageField)
Set the data field for image locations. The value stored in the data field should be a URL, a file within the current classpath, a file on the filesystem, or null for no image. If the imageField parameter is null, no images at all will be drawn.

Parameters:
imageField - the data field for image locations, or null for no images

setMaxImageDimensions

public void setMaxImageDimensions(int width,
                                  int height)
Sets the maximum image dimensions, used to control scaling of loaded images. This scaling is enforced immediately upon loading of the image.

Parameters:
width - the maximum width of images (-1 for no limit)
height - the maximum height of images (-1 for no limit)

render

public void render(java.awt.Graphics2D g,
                   prefuse.visual.VisualItem item)
Specified by:
render in interface prefuse.render.Renderer
Overrides:
render in class prefuse.render.AbstractShapeRenderer
See Also:
Renderer.render(java.awt.Graphics2D, prefuse.visual.VisualItem)