Sprite objects allow to add data representations in a graphic display of a graph. A sprite is a graphical representation that can double anywhere in the graph drawing surface, or be "attached" to nodes or edges. When attached to an edge, a sprite can be positioned easily at any point along the edge, or perpendicular to it with one or two coordinates. When attached to a node, a sprite "orbits" around the node at any given radius and angle around it.
Sprites can have many shapes. Most of the CSS nodes shapes are available for sprites, but more are possible. Some shapes follow the form of the element (node or edge) they are attached to.
Sprites can be moved and animated easily along edges, around nodes, or anywhere on the graph surface. Their shape can change. Some sprites allows to draw pie charts or statistics, or images.
Sprites are not part of a graph so to speak. Furthermore they make sense only when a graph is displayed with a viewer that supports sprites. Therefore they are handled by a {@link SpriteManager} which is always associated to a graphand is in charge of handling the whole set of sprites, creating them, enumerating them, and destroying them.
Implementation note: sprites do not exist ! In fact the sprite class only handles a set of attributes that are stored in the graph (the one associated with the sprite manager that created the sprite). These special attributes are handled for you by the sprite class. This technique allows to pass sprites informations through the I/O system of GraphStream. Indeed sprites appearing in a graph can therefore be stored in files and retrieved if the graph file format supports attributes. If this is a dynamic graph format, like DGS, the whole sprite history is remembered: when it moved, when it changed, etc.
Second implementation node : often you will need to extend the sprite class. This is easily possible, but you must remember that you cannot create sprites yourself, you must use the {@link SpriteManager}. In order to create a sprite of a special kind, you can either use a {@link SpriteFactory} with theSpriteManager or the special {@link SpriteManager#addSprite(String,Class)}method of the SpriteManager. In both cases, the {@link #init(String,SpriteManager,Values)} method of the sprite will becalled. Override this method to initialise your sprite.
@see SpriteManager @see SpriteFactory
|
|
|
|