|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.view.DefaultGraph2DRenderer yext.svg.io.SVGGraph2DRenderer yext.svg.io.SVGDOMEnhancer
public class SVGDOMEnhancer
A SVGGraph2DRenderer
that allows to enhance the svg document
while it gets generated by SVGIOHandler
.
This renderer adds named group elements <g> around the SVG definition of each node and edge in the graph.
Additionally this renderer provides callback methods that will be invoked whenever a node label, a node, an edge, an edge label or a graph has been added to the document. Subclasses can override these methods to add to or modify the generated DOM structure.
As an example, one can hyperlink all graph nodes in the SVG document by overwriting
method nodeAddedToDOM(y.base.Node yNode, org.w3c.dom.Element element)
in
the following way:
protected void nodeAddedToDOM(y.base.Node yNode, org.w3c.dom.Element element) { org.w3c.dom.Element a = createElement("a"); a.setAttribute("xlink:href", "http://www.yworks.com"); insertNodeBelow(a, element); }
Field Summary | |
---|---|
static byte |
LABEL_DETECTION_BY_RECONFIGURING
Label detection strategy specifier. |
static byte |
LABEL_DETECTION_BY_SEPARATE_RENDERING
Label detection strategy specifier. |
static byte |
LABEL_DETECTION_BY_TEXT_SEARCH
Label detection strategy specifier. |
static byte |
LABEL_DETECTION_BY_WRAPPING
Label detection strategy specifier. |
static byte |
LABEL_DETECTION_NONE
Label detection strategy specifier. |
Constructor Summary | |
---|---|
SVGDOMEnhancer()
Creates a new instance of SVGDOMEnhancer |
Method Summary | |
---|---|
protected String |
createGroupID(Edge edge)
Returns the group identifier assigned to the group element encapsulating the given edge in the SVG document. |
protected String |
createGroupID(Node node)
Returns the group identifier assigned to the group element encapsulating the given node in the SVG document. |
protected void |
edgeAddedToDOM(Edge yEdge,
Element element)
Callback method that will be invoked whenever the given edge has been added to the SVG document. |
protected void |
edgeLabelAddedToDOM(EdgeLabel yEdgeLabel,
Element element)
Callback method that will be invoked whenever the given edge label has been added to the SVG document. |
byte |
getLabelDetectionStrategy()
Returns the detection strategy used for DOM elements that enclose node and edge label graphics. |
protected void |
initializeDOM()
Callback method that will be invoked just before the graph will be added to the SVG document. |
protected void |
nodeAddedToDOM(Node yNode,
Element element)
Callback method that will be invoked whenever the given node has been added to the SVG document. |
protected void |
nodeLabelAddedToDOM(NodeLabel yNodeLabel,
Element element)
Callback method that will be invoked whenever the given node label has been added to the SVG document. |
protected void |
onPaint(Graphics2D gfx,
Graph2D graph,
boolean sloppy)
Notifies interested parties that the given graph is about to be painted. |
protected void |
onPainted(Graphics2D gfx,
Graph2D graph,
boolean sloppy)
Notifies interested parties that the given graph has been painted. |
void |
paint(Graphics2D gfx,
EdgeRealizer r)
|
protected void |
paint(Graphics2D gfx,
EdgeRealizer r,
boolean sloppyMode)
Renders the given edge realizer on the given graphics context. |
void |
paint(Graphics2D gfx,
Graph2D graph)
Renders the graph on the given graphics context. |
void |
paint(Graphics2D gfx,
NodeRealizer r)
|
protected void |
paint(Graphics2D gfx,
NodeRealizer r,
boolean sloppyMode)
Renders the given node realizer on the given graphics context. |
void |
paintSloppy(Graphics2D gfx,
EdgeRealizer r)
|
void |
paintSloppy(Graphics2D gfx,
Graph2D graph)
Renders the graph sloppily on the given graphics context. |
void |
paintSloppy(Graphics2D gfx,
NodeRealizer r)
|
void |
setLabelDetectionStrategy(byte labelDetectionStrategy)
Sets the detection strategy used for DOM elements that enclose node label and edge label graphics. |
Methods inherited from class yext.svg.io.SVGGraph2DRenderer |
---|
addToSVGDefinition, createCDATASection, createElement, getSVGDocument, getSVGIOHandler, getTopLevelGroup, insertNodeAbove, insertNodeBelow, setSVGIOHandler, setTopLevelGroup, writeDocument |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final byte LABEL_DETECTION_NONE
public static final byte LABEL_DETECTION_BY_TEXT_SEARCH
public static final byte LABEL_DETECTION_BY_SEPARATE_RENDERING
public static final byte LABEL_DETECTION_BY_WRAPPING
YLabel.paint(java.awt.Graphics2D)
.
public static final byte LABEL_DETECTION_BY_RECONFIGURING
YLabel.paint(java.awt.Graphics2D)
.
Constructor Detail |
---|
public SVGDOMEnhancer()
Method Detail |
---|
public void paint(Graphics2D gfx, Graph2D graph)
Before the rendering process starts, method
onPaint(Graphics2D, Graph2D, boolean)
is invoked.
After the rendering process has finished,
onPainted(Graphics2D, Graph2D, boolean)
is invoked.
paint
in interface Graph2DRenderer
paint
in class DefaultGraph2DRenderer
public void paintSloppy(Graphics2D gfx, Graph2D graph)
Before the rendering process starts, method
onPaint(Graphics2D, Graph2D, boolean)
is invoked.
After the rendering process has finished,
onPainted(Graphics2D, Graph2D, boolean)
is invoked.
paintSloppy
in interface Graph2DRenderer
paintSloppy
in class DefaultGraph2DRenderer
protected void onPaint(Graphics2D gfx, Graph2D graph, boolean sloppy)
The default implementation calls initializeDOM()
.
Called from paint(Graphics2D, Graph2D)
and
paintSloppy(Graphics2D, Graph2D)
.
gfx
- the graphics context to paint on.graph
- the graph structure that will be painted.sloppy
- if true
low-detail rendering was requested,
otherwise high-detail rendering was requested.protected void onPainted(Graphics2D gfx, Graph2D graph, boolean sloppy)
The default implementation does nothing.
Called from paint(Graphics2D, Graph2D)
and
paintSloppy(Graphics2D, Graph2D)
.
gfx
- the graphics context on which the graph was painted.graph
- the graph structure that was painted.sloppy
- if true
low-detail rendering was requested,
otherwise high-detail rendering was requested.public void paint(Graphics2D gfx, NodeRealizer r)
paint
in class SVGGraph2DRenderer
public void paintSloppy(Graphics2D gfx, NodeRealizer r)
paintSloppy
in class SVGGraph2DRenderer
public void paint(Graphics2D gfx, EdgeRealizer r)
paint
in class SVGGraph2DRenderer
public void paintSloppy(Graphics2D gfx, EdgeRealizer r)
paintSloppy
in class SVGGraph2DRenderer
protected void paint(Graphics2D gfx, NodeRealizer r, boolean sloppyMode)
nodeAddedToDOM(y.base.Node, org.w3c.dom.Element)
will be
invoked. Also, the method nodeLabelAddedToDOM(NodeLabel, org.w3c.dom.Element)
will be invoked for each node label that has been added to the SVG document.
protected void paint(Graphics2D gfx, EdgeRealizer r, boolean sloppyMode)
edgeAddedToDOM(Edge, org.w3c.dom.Element)
will be
invoked. Also, the method edgeLabelAddedToDOM(EdgeLabel, org.w3c.dom.Element)
will be invoked for each edge label that has been added to the SVG document.
protected void nodeAddedToDOM(Node yNode, Element element)
protected void nodeLabelAddedToDOM(NodeLabel yNodeLabel, Element element)
protected void edgeAddedToDOM(Edge yEdge, Element element)
protected void edgeLabelAddedToDOM(EdgeLabel yEdgeLabel, Element element)
protected void initializeDOM()
protected String createGroupID(Node node)
By default the identifier "y.node." + node.index() will be returned.
protected String createGroupID(Edge edge)
By default the identifier "y.edge." + edge.index() will be returned.
public byte getLabelDetectionStrategy()
By default, strategy LABEL_DETECTION_BY_RECONFIGURING
is set.
setLabelDetectionStrategy(byte)
public void setLabelDetectionStrategy(byte labelDetectionStrategy)
By default, strategy LABEL_DETECTION_BY_RECONFIGURING
is set.
labelDetectionStrategy
- one of
getLabelDetectionStrategy()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |