|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object prefuse.render.DefaultRendererFactory
public class DefaultRendererFactory
Default factory implementation from which to retrieve VisualItem renderers.
This class supports the use of a default renderer for EdgeItems (the default edge renderer) and another for all other non-edge VisualItems (the default item renderer). In addition, any number of additional Renderer mapping rules can be added, by specifying a Predicate to apply and a Renderer to return for matching items. Predicate/Renderer mappings are checked in the order in which they were added to the factory.
If left unspecified, a ShapeRenderer
is used as the default
item renderer and an EdgeRenderer
instance is used as the default
edge renderer.
For example, the following code snippet creates a new DefaultRendererFactory, changes the default edge renderer to be an EdgeRenderer using curved edges, and adds a new rule which maps items in the group "data" to a text renderer that pulls its text from a field named "label".
DefaultRendererFactory rf = new DefaultRendererFactory(); rf.setDefaultEdgeRenderer(new EdgeRenderer(Constants.EDGE_TYPE_CURVE); rf.add("INGROUP('data')", new LabelRenderer("label");
Constructor Summary | |
---|---|
DefaultRendererFactory()
Default Constructor. |
|
DefaultRendererFactory(Renderer itemRenderer)
Constructor. |
|
DefaultRendererFactory(Renderer itemRenderer,
Renderer edgeRenderer)
Constructor. |
Method Summary | |
---|---|
void |
add(Predicate p,
Renderer r)
Adds a new mapping to this RendererFactory. |
void |
add(java.lang.String predicate,
Renderer r)
Adds a new mapping to this RendererFactory. |
Renderer |
getDefaultEdgeRenderer()
Gets the default edge renderer. |
Renderer |
getDefaultRenderer()
Gets the default renderer. |
Renderer |
getRenderer(VisualItem item)
Return a Renderer instance for the input VisualItem. |
void |
setDefaultEdgeRenderer(Renderer r)
Sets the default edge renderer. |
void |
setDefaultRenderer(Renderer r)
Sets the default renderer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DefaultRendererFactory()
ShapeRenderer
,
EdgeRenderer
public DefaultRendererFactory(Renderer itemRenderer)
itemRenderer
- the default item renderer. This is the default for
rendering all items except EdgeItem instances.EdgeRenderer
public DefaultRendererFactory(Renderer itemRenderer, Renderer edgeRenderer)
itemRenderer
- the default item renderer. This is the default for
rendering all items except EdgeItem instances.edgeRenderer
- the default edge renderer. This is the default for
rendering EdgeItem instances.Method Detail |
---|
public void setDefaultRenderer(Renderer r)
getRenderer(VisualItem)
whenever there are no matching
predicates and the input item is not an EdgeItem. To set the
default renderer for EdgeItems, see
setDefaultEdgeRenderer(Renderer)
.
r
- the Renderer to use as the defaultsetDefaultEdgeRenderer(Renderer)
public Renderer getDefaultRenderer()
getRenderer(VisualItem)
whenever there are no matching
predicates and the input item is not an EdgeItem.
public void setDefaultEdgeRenderer(Renderer r)
getRenderer(VisualItem)
whenever there are no matching
predicates and the input item is an EdgeItem. To set the
default renderer for non-EdgeItems, see
setDefaultRenderer(Renderer)
.
r
- the Renderer to use as the default for EdgeItemssetDefaultRenderer(Renderer)
public Renderer getDefaultEdgeRenderer()
getRenderer(VisualItem)
whenever there are no matching
predicates and the input item is an EdgeItem.
public void add(Predicate p, Renderer r)
getRenderer(VisualItem)
matches the predicate, then the
corresponding Renderer will be returned. Predicates are evaluated in the
order in which they are added, so if an item matches multiple
predicates, the Renderer for the earliest match will be returned.
p
- a Predicate for testing a VisualItemr
- the Renderer to return if an item matches the Predicatepublic void add(java.lang.String predicate, Renderer r)
getRenderer(VisualItem)
matches the predicate, then the
corresponding Renderer will be returned. Predicates are evaluated in the
order in which they are added, so if an item matches multiple
predicates, the Renderer for the earliest match will be returned.
predicate
- a String in the prefuse expression language. This
String will be parsed to create a corresponding Predicate instance.r
- the Renderer to return if an item matches the Predicatepublic Renderer getRenderer(VisualItem item)
getRenderer
in interface RendererFactory
item
- the item for which to retrieve the renderer
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |