Package org.graphstream.ui.graphicGraph
Class GraphicElement
java.lang.Object
org.graphstream.graph.implementations.AbstractElement
org.graphstream.ui.graphicGraph.GraphicElement
- All Implemented Interfaces:
Element
- Direct Known Subclasses:
GraphicEdge,GraphicNode,GraphicSprite
public abstract class GraphicElement extends AbstractElement
Super class of all graphic node, edge, and sprite elements.
Each graphic element references a style, a graphic graph and has a label.
The element also defines the basic behaviour to reload the style when needed, defines abstract methods to set and get the position and bounds in spaces of the element, and to do appropriate actions when specific predefined attributes change (most of them starting with the prefix "ui.").
The graphic element has the ability to store attributes like any other graph element, however the attributes stored by the graphic element are restricted. There is a filter on the attribute adding methods that let pass only :
- All attributes starting with "ui.".
- The "x", "y", "z", "xy" and "xyz" attributes.
- The "stylesheet" attribute.
- The "label" attribute.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceGraphicElement.SwingElementRendererInterface for renderers registered in each style group.Nested classes/interfaces inherited from class org.graphstream.graph.implementations.AbstractElement
AbstractElement.AttributeChangeEvent -
Field Summary
-
Constructor Summary
Constructors Constructor Description GraphicElement(String id, GraphicGraph graph)New element. -
Method Summary
Modifier and Type Method Description ObjectgetComponent()The associated GUI component.StringgetLabel()Label or null if not set.abstract Selector.TypegetSelectorType()Type of selector for the graphic element (Node, Edge, Sprite ?).StyleGroupgetStyle()Style group.abstract doublegetX()Abscissa of the element, always in GU (graph units).abstract doublegetY()Ordinate of the element, always in GU (graph units).abstract doublegetZ()Depth of the element, always in GU (graph units).abstract voidmove(double x, double y, double z)Try to force the element to move at the give location in graph units (GU).GraphicGraphmyGraph()voidsetAttribute(String attribute, Object... values)Add or replace the value of an attribute.voidsetComponent(Object component)Set the GUI component of this element.Methods inherited from class org.graphstream.graph.implementations.AbstractElement
attributeKeys, clearAttributes, getAttribute, getAttribute, getAttributeCount, getFirstAttributeOf, getFirstAttributeOf, getId, getIndex, hasAttribute, hasAttribute, removeAttribute, toString
-
Field Details
-
Constructor Details
-
GraphicElement
New element.
-
-
Method Details
-
myGraph
-
getSelectorType
Type of selector for the graphic element (Node, Edge, Sprite ?). -
getStyle
Style group. An style group may reference several elements.- Returns:
- The style group corresponding to this element.
-
getLabel
Label or null if not set. -
getX
public abstract double getX()Abscissa of the element, always in GU (graph units). For edges this is the X of the "from" node. -
getY
public abstract double getY()Ordinate of the element, always in GU (graph units). For edges this is the Y of the "from" node. -
getZ
public abstract double getZ()Depth of the element, always in GU (graph units). For edges this is the Z of the "from" node. -
getComponent
The associated GUI component.- Returns:
- An object.
-
move
public abstract void move(double x, double y, double z)Try to force the element to move at the give location in graph units (GU). For edges, this may move the two attached nodes.- Parameters:
x- The new X.y- The new Y.z- the new Z.
-
setComponent
Set the GUI component of this element.- Parameters:
component- The component.
-
setAttribute
Description copied from interface:ElementAdd or replace the value of an attribute. Existing attributes are overwritten silently. All classes inheriting from Number can be considered as numbers. All classes inheriting from CharSequence can be considered as labels. You can pass zero, one or more arguments for the attribute values. If no value is given, a boolean with value "true" is added. If there is more than one value, an array is stored. If there is only one value, the value is stored (but not in an array).- Specified by:
setAttributein interfaceElement- Overrides:
setAttributein classAbstractElement- Parameters:
attribute- The attribute name.values- The attribute value or set of values.
-