org.graphstream.stream.file
Class FileSourceGML

java.lang.Object
  extended by org.graphstream.stream.SourceBase
      extended by org.graphstream.stream.file.FileSourceParser
          extended by org.graphstream.stream.file.FileSourceGML
All Implemented Interfaces:
FileSource, Source

public class FileSourceGML
extends FileSourceParser

A GML parser. This parser should understand the whole GML syntax. It transforms any unknown tag into an attribute. Depending on the location of the unknown tag, the attribute is added to the graph, to nodes or to the edges. The "graphics" attributes are, as far as possible, transformed into "ui.style" attributes that are merged with the style sheet. The understood graphics tags are "x", "y", "z", "w", "h", "d" for position and size, "fill" for the background color (becomes "fill-color"), "outline" (becomes "stroke-color"), "type" (becomes "shape", the known shapes being the ones of the GraphStream CSS, plus the "ellipse" tag wich maps to "circle" and the "rectangle" tag that maps to "box"), "outline_width" (becomes "stroke-width", in pixels). If edges have no "id" tag, the id is the concatenation of the source and target node identifiers separated by a "_" character and a random number. You can declare nodes either with the full declaration:

                node [ Id "foo" ]
 
Which is useful when adding attributes to it. Or you can use a lighter declaration with:
      node "foo"
 
You can also remove nodes and edges by using:
      -node "foo"
      del-node "foo"
      -node [ Id "foo" ]
      del-node [ Id "foo" ]
 
And the same for edges with "-edge" or "del-edge". All the dynamic events of GraphStream are supported as an extension. You can add or remove attributes to or from a node or edge using a minus sign in front of the attribute name and following the attribute name by []. You can remove a node or edge using a minus sign in front of the node and edge tags:
     -node [ id "foo" ]
 
Or
     -node "foo"
 
You can change the attributes of a node or edge using a plus sign in front of the node and edge tags:
     +node [ id "foo" someAttribute "added" -removedAttribute [] ]
 
Be careful, that files exported with the dynamic extensions will not be compatible with most GML readers of other programs. The standard extension for GML files is ".gml". If your file contains dynamic additions, you can use the ".dgml" (Dynamic GML) extensions. The parser will handle both dynamic and non dynamic files with the extension ".gml".


Nested Class Summary
 
Nested classes/interfaces inherited from class org.graphstream.stream.SourceBase
SourceBase.ElementType
 
Constructor Summary
FileSourceGML()
           
 
Method Summary
 ParserFactory getNewParserFactory()
          Get a new parser factory.
 boolean nextStep()
          Since there is no step in DOT, this does the same action than FileSourceParser.nextEvents().
 
Methods inherited from class org.graphstream.stream.file.FileSourceParser
begin, begin, begin, begin, end, nextEvents, readAll, readAll, readAll, readAll
 
Methods inherited from class org.graphstream.stream.SourceBase
addAttributeSink, addElementSink, addSink, attributeSinks, clearAttributeSinks, clearElementSinks, clearSinks, elementSinks, removeAttributeSink, removeElementSink, removeSink, sendAttributeChangedEvent, sendAttributeChangedEvent, sendEdgeAdded, sendEdgeAdded, sendEdgeRemoved, sendEdgeRemoved, sendGraphCleared, sendGraphCleared, sendNodeAdded, sendNodeAdded, sendNodeRemoved, sendNodeRemoved, sendStepBegins, sendStepBegins
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.graphstream.stream.Source
addAttributeSink, addElementSink, addSink, clearAttributeSinks, clearElementSinks, clearSinks, removeAttributeSink, removeElementSink, removeSink
 

Constructor Detail

FileSourceGML

public FileSourceGML()
Method Detail

nextStep

public boolean nextStep()
                 throws IOException
Description copied from class: FileSourceParser
Since there is no step in DOT, this does the same action than FileSourceParser.nextEvents().

Specified by:
nextStep in interface FileSource
Overrides:
nextStep in class FileSourceParser
Returns:
true if there are still events to read, false as soon as the file is finished.
Throws:
IOException - If an I/O error occurs while reading.

getNewParserFactory

public ParserFactory getNewParserFactory()
Description copied from class: FileSourceParser
Get a new parser factory.

Specified by:
getNewParserFactory in class FileSourceParser
Returns:
a parser factory


Copyright © 2011. All Rights Reserved.