Gephi Toolkit Javadoc

org.gephi.preview.plugin.renderers
Class NodeLabelRenderer

java.lang.Object
  extended by org.gephi.preview.plugin.renderers.NodeLabelRenderer
All Implemented Interfaces:
Renderer

public class NodeLabelRenderer
extends java.lang.Object
implements Renderer

Author:
Yudi Xue, Mathieu Bastian

Field Summary
protected  DependantColor defaultBoxColor
           
protected  int defaultBoxOpacity
           
protected  DependantOriginalColor defaultColor
           
protected  java.awt.Font defaultFont
           
protected  int defaultMaxChar
           
protected  DependantColor defaultOutlineColor
           
protected  int defaultOutlineOpacity
           
protected  float defaultOutlineSize
           
protected  boolean defaultProportinalSize
           
protected  boolean defaultShorten
           
protected  boolean defaultShowBox
           
protected  boolean defaultShowLabels
           
static java.lang.String FONT_SIZE
           
protected  java.util.Map<java.lang.Integer,java.awt.Font> fontCache
           
static java.lang.String NODE_COLOR
           
static java.lang.String NODE_SIZE
           
static java.lang.String NODE_X
           
static java.lang.String NODE_Y
           
 
Constructor Summary
NodeLabelRenderer()
           
 
Method Summary
 java.lang.String getDisplayName()
          Provides an user friendly name for the renderer.
 PreviewProperty[] getProperties()
          Returns all associated properties for this renderer.
 boolean isRendererForitem(Item item, PreviewProperties properties)
          Based on properties, determine whether this renderer is valid to render Item.
 boolean needsItemBuilder(ItemBuilder itemBuilder, PreviewProperties properties)
          Based on the itemBuilder class and the properties, determine whether this renderer needs the given itemBuilder to be executed before rendering.
 void preProcess(PreviewModel previewModel)
          This method is called before rendering for all renderers and initializes items' additional attributes or run complex algorithms.
 void render(Item item, RenderTarget target, PreviewProperties properties)
          Render item to target using the global properties and item data.
 void renderPDF(PDFTarget target, Node node, java.lang.String label, float x, float y, int fontSize, java.awt.Color color, float outlineSize, java.awt.Color outlineColor, boolean showBox, java.awt.Color boxColor)
           
 void renderProcessing(ProcessingTarget target, java.lang.String label, float x, float y, int fontSize, java.awt.Color color, float outlineSize, java.awt.Color outlineColor, boolean showBox, java.awt.Color boxColor)
           
 void renderSVG(SVGTarget target, Node node, java.lang.String label, float x, float y, int fontSize, java.awt.Color color, float outlineSize, java.awt.Color outlineColor, boolean showBox, java.awt.Color boxColor)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NODE_COLOR

public static final java.lang.String NODE_COLOR
See Also:
Constant Field Values

NODE_SIZE

public static final java.lang.String NODE_SIZE
See Also:
Constant Field Values

NODE_X

public static final java.lang.String NODE_X
See Also:
Constant Field Values

NODE_Y

public static final java.lang.String NODE_Y
See Also:
Constant Field Values

FONT_SIZE

public static final java.lang.String FONT_SIZE
See Also:
Constant Field Values

defaultShowLabels

protected final boolean defaultShowLabels
See Also:
Constant Field Values

defaultFont

protected final java.awt.Font defaultFont

defaultShorten

protected final boolean defaultShorten
See Also:
Constant Field Values

defaultColor

protected final DependantOriginalColor defaultColor

defaultMaxChar

protected final int defaultMaxChar
See Also:
Constant Field Values

defaultProportinalSize

protected final boolean defaultProportinalSize
See Also:
Constant Field Values

defaultOutlineSize

protected final float defaultOutlineSize
See Also:
Constant Field Values

defaultOutlineColor

protected final DependantColor defaultOutlineColor

defaultOutlineOpacity

protected final int defaultOutlineOpacity
See Also:
Constant Field Values

defaultShowBox

protected final boolean defaultShowBox
See Also:
Constant Field Values

defaultBoxColor

protected final DependantColor defaultBoxColor

defaultBoxOpacity

protected final int defaultBoxOpacity
See Also:
Constant Field Values

fontCache

protected java.util.Map<java.lang.Integer,java.awt.Font> fontCache
Constructor Detail

NodeLabelRenderer

public NodeLabelRenderer()
Method Detail

preProcess

public void preProcess(PreviewModel previewModel)
Description copied from interface: Renderer
This method is called before rendering for all renderers and initializes items' additional attributes or run complex algorithms.

This method has access to any item using the getItems() methods of the preview model.

No data should be stored in the renderer itself but put in items using Item.setData(java.lang.String, java.lang.Object). Global states can be stored in properties using PreviewProperties.putValue(java.lang.String, java.lang.Object).

Specified by:
preProcess in interface Renderer
Parameters:
previewModel - the model to get items from

render

public void render(Item item,
                   RenderTarget target,
                   PreviewProperties properties)
Description copied from interface: Renderer
Render item to target using the global properties and item data.

The target can be one of the default target ProcessingTarget, SVGTarget or PDFTarget. Each target contains an access to it's drawing canvas so the renderer can draw visual items.

Specified by:
render in interface Renderer
Parameters:
item - the item to be rendered
target - the target to render the item on
properties - the central properties

renderProcessing

public void renderProcessing(ProcessingTarget target,
                             java.lang.String label,
                             float x,
                             float y,
                             int fontSize,
                             java.awt.Color color,
                             float outlineSize,
                             java.awt.Color outlineColor,
                             boolean showBox,
                             java.awt.Color boxColor)

renderSVG

public void renderSVG(SVGTarget target,
                      Node node,
                      java.lang.String label,
                      float x,
                      float y,
                      int fontSize,
                      java.awt.Color color,
                      float outlineSize,
                      java.awt.Color outlineColor,
                      boolean showBox,
                      java.awt.Color boxColor)

renderPDF

public void renderPDF(PDFTarget target,
                      Node node,
                      java.lang.String label,
                      float x,
                      float y,
                      int fontSize,
                      java.awt.Color color,
                      float outlineSize,
                      java.awt.Color outlineColor,
                      boolean showBox,
                      java.awt.Color boxColor)

getProperties

public PreviewProperty[] getProperties()
Description copied from interface: Renderer
Returns all associated properties for this renderer. Properties can be built using static PreviewProperty.createProperty() methods.

Specified by:
getProperties in interface Renderer
Returns:
a properties array

isRendererForitem

public boolean isRendererForitem(Item item,
                                 PreviewProperties properties)
Description copied from interface: Renderer
Based on properties, determine whether this renderer is valid to render Item.

Additional states in properties helps to make a decision, including:

Specified by:
isRendererForitem in interface Renderer
Parameters:
item - the item to be tested
properties - the current properties
Returns:
true if item can be rendered by this renderer, false otherwise

needsItemBuilder

public boolean needsItemBuilder(ItemBuilder itemBuilder,
                                PreviewProperties properties)
Description copied from interface: Renderer
Based on the itemBuilder class and the properties, determine whether this renderer needs the given itemBuilder to be executed before rendering.

This is used for avoiding building unnecessary items while refreshing preview.

You can simply return true if the builder builds items that this renderer renders, but you can also check the current properties to see if your renderer is going to produce any graphic.

Additional states in properties helps to make a decision, including:

Specified by:
needsItemBuilder in interface Renderer
Parameters:
itemBuilder - builder that your renderer may need
properties - Current properties
Returns:
true if you are going to use built items for rendering, false otherwise

getDisplayName

public java.lang.String getDisplayName()
Description copied from interface: Renderer
Provides an user friendly name for the renderer. This name will appear in the renderers manager UI.

Specified by:
getDisplayName in interface Renderer
Returns:
User friendly renderer name, not null

Gephi Toolkit Javadoc