|
Search this API | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objecty.view.EdgeRealizer
y.view.GenericEdgeRealizer
public class GenericEdgeRealizer
This class can be used to easily create customized edge appearances. In contrast to the older yFiles way, developers don't need to and normally should not subclass this class in order to create a new visual appearance, but may use pluggable instances of specialized interfaces to replace different phases of the edge rendering process.
This class knows multiple inner interfaces that can be used as callback routines to customize
GenericEdgeRealizer.Painter)GenericEdgeRealizer.BendHandler)GenericEdgeRealizer.BendPainterGenericEdgeRealizer.PortPainterGenericEdgeRealizer.PathCalculatorGenericEdgeRealizer.ContainsTest
and GenericEdgeRealizer.IntersectionTest)GenericEdgeRealizer.UnionRectCalculator)GenericEdgeRealizer.UserDataHandler)MouseInputEditor instances for mouse interaction
(see GenericEdgeRealizer.GenericMouseInputEditorProvider)BridgeCalculator instances
(see GenericEdgeRealizer.BridgeCalculatorHandler)
This class provides access to a factory,
that is used by the implementation to manage different edge style configurations.
Programmers have to use that factory to register different style configurations using their own implementations of the interfaces described above.
Instances of this class correctly implement the createCopy(EdgeRealizer) method
and IO methods (read(ObjectInputStream) and write(ObjectOutputStream))
so that programmers don't have to re-implement these methods for each and every
realizer specialization.
Finally, this class makes it possible to generically attach user-defined data to realizer instances which may then be used for arbitrary purposes.
This type of realizer can be serialized and deserialized into the YGF graph exchange file format using theYGFIOHandler (if an appropriate GenericEdgeRealizer.UserDataHandler
instance is registered, the user-defined data object can be serialized and deserialized, too).
GMLIOHandler and XGMLIOHandler also support serialization
and deserialization of this kind of realizer (in this case the user-defined data is
written to the GML file if an appropriate ObjectStringConverter is registered
with the global ObjectStringConversion singleton.
Note that only the name of the configuration and optionally the user-defined data will
be stored and that it is the responsibility of the application to register and configure
the configurations in the factory so that the I/O mechanisms can serialize and deserialize
the information correctly.
The following piece of code demonstrates how to correctly initialize a custom generic edge realizer.
// Get the static default factory instance
GenericEdgeRealizer.Factory factory = GenericEdgeRealizer.getFactory();
// Retrieve a map that holds the default GenericEdgeRealizer configuration.
// The implementations contained therein can be replaced one by one in order
// to create custom configurations...
Map implementationsMap = factory.createDefaultConfigurationMap();
// create and register customizations...
// e.g. create a custom painter
// (see demo.view.realizer.GenericEdgeRealizerDemo for example implementations)
MyCustomPainter painter = new MyCustomPainter();
// put it into the map using the interface class as the key
implementationsMap.put(GenericEdgeRealizer.Painter.class, painter);
// add the configuration using an arbitrary String identifier to the factory
factory.addConfiguration("type1", implementationsMap);
// now create an instance that uses our customizations
GenericEdgeRealizer er = new GenericEdgeRealizer();
// initialize the instance using the previously registered configuration
er.setConfiguration("type1");
Note that each custom configuration must contain implementations for interfaces
GenericEdgeRealizer.BendHandler and GenericEdgeRealizer.PathCalculator
to form a valid configuration.
GenericEdgePainter,
SimpleUserDataHandler,
GenericNodeRealizer![]() |
![]() |
![]() |
![]() |
| Nested Class Summary | |
|---|---|
static interface |
GenericEdgeRealizer.ArrowPainter
This interface is used as a callback by EdgeRealizer to paint the arrows. |
static interface |
GenericEdgeRealizer.BendHandler
This interface is used as a callback by GenericEdgeRealizer to handle the list of bends. |
static interface |
GenericEdgeRealizer.BendPainter
This interface is used as a callback by GenericEdgeRealizer to paint the bends. |
static interface |
GenericEdgeRealizer.BridgeCalculatorHandler
This interface is used as a callback by GenericEdgeRealizer to insert obstacles
into a given BridgeCalculator instance for a two-pass rendering. |
static interface |
GenericEdgeRealizer.ContainsTest
This interface is used as a callback by GenericEdgeRealizer to evaluate hit tests. |
static class |
GenericEdgeRealizer.Factory
This class is used for managing the different configurations for GenericEdgeRealizer
instances. |
static interface |
GenericEdgeRealizer.GenericMouseInputEditorProvider
This interface is used by GenericEdgeRealizer to delegate the work of the MouseInputEditorProvider interface to. |
static interface |
GenericEdgeRealizer.Initializer
This interface is used by GenericEdgeRealizer for initialization purposes. |
static interface |
GenericEdgeRealizer.IntersectionTest
This interface is used as a callback by GenericEdgeRealizer to evaluate intersection tests. |
static interface |
GenericEdgeRealizer.LabelFactory
This interface is used by GenericEdgeRealizer to delegate the work of the createEdgeLabel() method to. |
static interface |
GenericEdgeRealizer.LabelPainter
This interface is used as a callback by EdgeRealizer to paint the labels. |
static interface |
GenericEdgeRealizer.Painter
This interface is used as a callback by GenericEdgeRealizer to perform the painting. |
static interface |
GenericEdgeRealizer.PathCalculator
This interface is used as a callback by GenericEdgeRealizer to calculate the final path. |
static interface |
GenericEdgeRealizer.PortPainter
This interface is used as a callback by GenericEdgeRealizer to paint the ports. |
static interface |
GenericEdgeRealizer.SelectionChangeHandler
This interface is used by GenericEdgeRealizer to notify
interested parties of selection state changes. |
static interface |
GenericEdgeRealizer.UnionRectCalculator
This interface is used as a callback by GenericEdgeRealizer to calculate the bounds. |
static interface |
GenericEdgeRealizer.UserDataHandler
This interface is used by GenericEdgeRealizer to delegate the copying and serialization/deserialization of any user-defined data to. |
| Field Summary |
|---|
| Fields inherited from class y.view.EdgeRealizer |
|---|
bends, path, PATH_CLIPPED_AT_SOURCE, PATH_CLIPPED_AT_SOURCE_AND_TARGET, PATH_CLIPPED_AT_TARGET, PATH_INVISBLE, PATH_UNCLIPPED |
| Constructor Summary | |
|---|---|
GenericEdgeRealizer()
Creates a new instance of GenericEdgeRealizer using the default configuration. |
|
GenericEdgeRealizer(EdgeRealizer er)
Creates a new instance of GenericEdgeRealizer which is a copy of the given realizer instance. |
|
GenericEdgeRealizer(java.lang.String configuration)
Creates a new instances of GenericEdgeRealizer using the given configuration. |
|
| Method Summary | |
|---|---|
void |
bendChanged(Bend b,
double oldX,
double oldY)
Informs the edge, that a bend has changed position By default this method does nothing. |
protected byte |
calculatePath(java.awt.geom.Point2D sourceIntersectionPointOut,
java.awt.geom.Point2D targetIntersectionPointOut)
Calculates the visible path of this realizer. |
void |
calcUnionRect(java.awt.geom.Rectangle2D r)
Calculates the union of rectangle enclosed by this realizer and r. |
void |
clearBends()
Removes all bends from this realizer. |
boolean |
contains(double x,
double y)
Query if the visible path of this realizer contains the point (x,y). |
int |
containsSeg(double x,
double y)
like contains(), but returns number of the hit segment, 0 otherwise. |
Bend |
createBend(double x,
double y,
Bend refBend,
int dir)
Adds a new bend before or after the given reference bend. |
EdgeRealizer |
createCopy(EdgeRealizer er)
Returns a realizer of the same type as this realizer, that adopts as many attributes as possible from the given realizer. |
EdgeLabel |
createEdgeLabel()
Creates a new edge label that can be added to this realizer. |
MouseInputEditor |
findMouseInputEditor(Graph2DView view,
double x,
double y,
HitInfo hitInfo)
Uses the registered GenericEdgeRealizer.GenericMouseInputEditorProvider
implementation to delegate the actual work to. |
java.lang.String |
getConfiguration()
Returns the name of the current configuration for this GenericEdgeRealizer |
static GenericEdgeRealizer.Factory |
getFactory()
Returns the factory instance that will be used to read and write customization configurations. |
int |
getMinBendCount()
Returns the minimal number of bends the edge must have. |
MouseInputEditorProvider |
getMouseInputEditorProvider()
Returns a provider, that can be used to query for a mouse input editor for this realizer. |
java.util.Set |
getStyleProperties()
Yields a Set of Map.Entry instances that
contains all property value pairs that have been associated with this
instance via the setStyleProperty(String, Object) method. |
java.lang.Object |
getStyleProperty(java.lang.String propertyKey)
Retrieves the value of the property that has been stored with this instance for the given key using setStyleProperty(String, Object) |
java.lang.Object |
getUserData()
Returns the user-defined data object. |
Bend |
insertBend(double x,
double y)
Inserts a new bend into this realizer and returns it. |
void |
paint(java.awt.Graphics2D gfx)
Paints this realizer on the given graphics context. |
protected void |
paintArrows(java.awt.Graphics2D g)
Paints the arrows of this realizer. |
protected void |
paintBends(java.awt.Graphics2D gfx)
Paints the bends if they are in selected state. |
protected void |
paintHighlightedBends(java.awt.Graphics2D gfx)
Paints the bends if this realizer is in a selected state |
protected void |
paintLabels(java.awt.Graphics2D gfx)
Paints the labels belonging to this realizer. |
protected void |
paintPorts(java.awt.Graphics2D gfx)
Paints the ports of this realizer. |
void |
paintSloppy(java.awt.Graphics2D gfx)
Paints this realizer in a quick and rather sloppy way. |
boolean |
pathIntersects(java.awt.geom.Rectangle2D box,
boolean considerLabels)
This method complements the EdgeRealizer.contains(double,double) method. |
void |
read(java.io.ObjectInputStream in)
Reads in the serialized form of this realizer. |
void |
registerObstacles(BridgeCalculator calculator)
This callback method is e.g. by DefaultGraph2DRenderer if a BridgeCalculator
is used for the rendering whose crossing mode is set to
values other than BridgeCalculator.CROSSING_MODE_ORDER_INDUCED. |
void |
reInsertBend(Bend bend,
Bend refBend,
int dir)
Reinserts a bend to the edge which had been removed before. |
Bend |
removeBend(Bend b)
Removes a Bend of this realizer. |
void |
removeStyleProperty(java.lang.String propertyKey)
Removes a previously stored style property from this instance's set of style properties. |
void |
setConfiguration(java.lang.String configuration)
Configures this instance to use the implementations provided by the factory
under the given configuration name. |
void |
setStyleProperty(java.lang.String propertyKey,
java.lang.Object value)
Sets a named key value pair that is a property which can be used by the implementations in the configuration to retrieve per instance settings. |
void |
setUserData(java.lang.Object userData)
Sets the user-defined data object. |
void |
write(java.io.ObjectOutputStream out)
Deprecated. Use the GraphML format instead. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public GenericEdgeRealizer()
setConfiguration(String)public GenericEdgeRealizer(java.lang.String configuration)
configuration - the identifier of the configuration to use
java.lang.IllegalArgumentException - if configuration is not registered in the factoryGenericEdgeRealizer.Factory.addConfiguration(String, java.util.Map)public GenericEdgeRealizer(EdgeRealizer er)
er is not of type GenericEdgeRealizer, the default
configuration will be used for the new GenericEdgeRealizer object.
er - The realizer to copy the values from.setConfiguration(String)| Method Detail |
|---|
public static GenericEdgeRealizer.Factory getFactory()
public void setStyleProperty(java.lang.String propertyKey,
java.lang.Object value)
copies of
this instance.
propertyKey - The key under which the value will be stored.value - The value that is stored.getStyleProperty(String),
getStyleProperties()public java.lang.Object getStyleProperty(java.lang.String propertyKey)
setStyleProperty(String, Object)
propertyKey - the key to retrieve the property value of
null.public java.util.Set getStyleProperties()
Set of Map.Entry instances that
contains all property value pairs that have been associated with this
instance via the setStyleProperty(String, Object) method.
Set of Map.Entry instances.getStyleProperty(String)public void removeStyleProperty(java.lang.String propertyKey)
propertyKey - The key which was used to set
the style property earlier.public java.lang.Object getUserData()
GenericEdgeRealizer.UserDataHandler installed
with this instance.
public void setUserData(java.lang.Object userData)
GenericEdgeRealizer.UserDataHandler installed
with this instance.
userData - the new instancepublic MouseInputEditorProvider getMouseInputEditorProvider()
GenericEdgeRealizer.GenericMouseInputEditorProvider.
getMouseInputEditorProvider in class EdgeRealizerMouseInputEditorProvider or null,
if no such provider is bound to this realizer.findMouseInputEditor(Graph2DView, double, double, HitInfo)
public MouseInputEditor findMouseInputEditor(Graph2DView view,
double x,
double y,
HitInfo hitInfo)
GenericEdgeRealizer.GenericMouseInputEditorProvider
implementation to delegate the actual work to.
If no such instance is registered with this instance null is returned.
findMouseInputEditor in interface MouseInputEditorProviderview - the view that will host the editorx - the x coordinate of the mouse eventy - the y coordinate of the mouse eventhitInfo - the HitInfo that may be used to determine what instance to return or null
nullMouseInputMode.setEdgeSearchingEnabled(boolean)public void calcUnionRect(java.awt.geom.Rectangle2D r)
EdgeRealizer
calcUnionRect in class EdgeRealizer
public void reInsertBend(Bend bend,
Bend refBend,
int dir)
EdgeRealizer
reInsertBend in class EdgeRealizerbend - the bend to be reinsertedrefBend - reference bend already contained in this realizerdir - indicates whether the bend should be inserted before or after the
reference bend.Allowed values are Graph.AFTER and Graph.BEFORE.public Bend removeBend(Bend b)
EdgeRealizer
removeBend in class EdgeRealizerb - Bend to be removedpublic EdgeRealizer createCopy(EdgeRealizer er)
EdgeRealizer
createCopy in class EdgeRealizer
public Bend createBend(double x,
double y,
Bend refBend,
int dir)
EdgeRealizer
createBend in class EdgeRealizerx - X-coordinate of the Bendy - Y-coordinate of the BendrefBend - Bend which should be neighbordir - indicates if the new Bend should be added before
Graph.BEFORE or after Graph.AFTER the refBend in
the bend sequence of the edgeprotected void paintArrows(java.awt.Graphics2D g)
EdgeRealizer
paintArrows in class EdgeRealizerprotected void paintLabels(java.awt.Graphics2D gfx)
EdgeRealizer
paintLabels in class EdgeRealizer
public void bendChanged(Bend b,
double oldX,
double oldY)
EdgeRealizer
bendChanged in class EdgeRealizerb - Bend which has changed positionoldX - previous x-coordinateoldY - previous y-coordinate
public Bend insertBend(double x,
double y)
EdgeRealizer
insertBend in class EdgeRealizerx - X-coordinates of the bendy - Y-coordinates of the bend
Bend instance or null if no
bend was created for the given coordinates.public void registerObstacles(BridgeCalculator calculator)
EdgeRealizerDefaultGraph2DRenderer if a BridgeCalculator
is used for the rendering whose crossing mode is set to
values other than BridgeCalculator.CROSSING_MODE_ORDER_INDUCED.
Implementations should use the provided calculator instance to call
BridgeCalculator.registerObstacles(java.awt.geom.PathIterator) using the EdgeRealizer.getPath()
method for example or
BridgeCalculator.registerObstacleLine(double, double, double, double) directly to
add obstacle lines for the calculation directly.
This implementation does nothing.
registerObstacles in class EdgeRealizercalculator - the calculator instance used for the next rendering pass.
protected byte calculatePath(java.awt.geom.Point2D sourceIntersectionPointOut,
java.awt.geom.Point2D targetIntersectionPointOut)
EdgeRealizerlength of
the source and/or target arrow.
Implementations of this method may use the
EdgeRealizer.calculateClippingAndIntersection(EdgeRealizer, java.awt.geom.GeneralPath, java.awt.geom.GeneralPath, java.awt.geom.Point2D, java.awt.geom.Point2D)
method to perform the clipping.
calculatePath in class EdgeRealizersourceIntersectionPointOut - a Point2D instance that must be set by the implementation to point
to the source intersection point unless the path is empty.targetIntersectionPointOut - a Point2D instance that must be set by the implementation to point
to the target intersection point unless the path is empty.
EdgeRealizer.PATH_UNCLIPPED, EdgeRealizer.PATH_CLIPPED_AT_SOURCE,
EdgeRealizer.PATH_CLIPPED_AT_TARGET, or EdgeRealizer.PATH_CLIPPED_AT_SOURCE_AND_TARGETEdgeRealizer.path,
EdgeRealizer.isPathClippedAtSource(),
EdgeRealizer.isPathClippedAtTarget()public void paint(java.awt.Graphics2D gfx)
EdgeRealizer
paint in class EdgeRealizerprotected void paintPorts(java.awt.Graphics2D gfx)
EdgeRealizer
paintPorts in class EdgeRealizerprotected void paintHighlightedBends(java.awt.Graphics2D gfx)
EdgeRealizer
paintHighlightedBends in class EdgeRealizerprotected void paintBends(java.awt.Graphics2D gfx)
EdgeRealizer
paintBends in class EdgeRealizerpublic void paintSloppy(java.awt.Graphics2D gfx)
EdgeRealizer
paintSloppy in class EdgeRealizerpublic int getMinBendCount()
EdgeRealizer
getMinBendCount in class EdgeRealizerpublic void clearBends()
EdgeRealizer
clearBends in class EdgeRealizer
public boolean contains(double x,
double y)
EdgeRealizer
contains in class EdgeRealizer
public int containsSeg(double x,
double y)
EdgeRealizer
containsSeg in class EdgeRealizer
public boolean pathIntersects(java.awt.geom.Rectangle2D box,
boolean considerLabels)
EdgeRealizerEdgeRealizer.contains(double,double) method.
Its primary use is for checking whether or not an edge lies within
the bounds of a selection box.
pathIntersects in class EdgeRealizerbox - the box that will be used for the intersection testconsiderLabels - if true, labels will be considered
public EdgeLabel createEdgeLabel()
EdgeRealizer
createEdgeLabel in class EdgeRealizerpublic void setConfiguration(java.lang.String configuration)
factory
under the given configuration name.
configuration - the name of the configuration to use. It must have been registered with the factory prior to
the invocation of this method.
java.lang.IllegalArgumentException - if configuration is not registered within the factorypublic java.lang.String getConfiguration()
public void read(java.io.ObjectInputStream in)
throws java.io.IOException,
java.lang.ClassNotFoundException
EdgeRealizerEdgeRealizer.write(ObjectOutputStream) method.
read in class EdgeRealizerjava.io.IOException
java.lang.ClassNotFoundException
public void write(java.io.ObjectOutputStream out)
throws java.io.IOException
GraphML format instead.
EdgeRealizer
write in class EdgeRealizerjava.io.IOException
|
© Copyright 2000-2025, yWorks GmbH. All rights reserved. |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||