org.jgraph.util
Class JGraphGXLCodec

java.lang.Object
  extended byorg.jgraph.util.JGraphGXLCodec

public class JGraphGXLCodec
extends java.lang.Object


Constructor Summary
JGraphGXLCodec()
           
 
Method Summary
protected static java.util.Map createDefaultAttributes(java.util.Map map)
          Returns an attributeMap for the specified position and color.
static void decode(java.io.InputStream inputStream, JGraph graph)
          Decodes a GXL File.
protected static void decodeCell(org.w3c.dom.Node gnode, java.util.Map gnode_attrs)
          Extracts visual properties of the node from the child 'view' element Currently recognized properties: - Bounds - color - background-color - autosize - Font - Line-End, Line-size, Line-color
protected static void decodeEdge(org.w3c.dom.Node enode, java.util.Map enode_attrs)
          Decodes a Edge.
static java.lang.String encode(JGraph graph)
          Create a GXL-representation for all the cells.
static java.lang.String encode(JGraph graph, java.lang.Object[] cells)
          Create a GXL-representation for the specified cells.
protected static java.lang.String encodeAttribute(java.lang.String values, java.lang.String attributeName, int level)
          Attribute encoding.
protected static java.lang.String encodeBean(java.lang.Object bean, java.lang.String attributeName, int level)
          Bean encoding.
protected static java.lang.String encodeBoolean(boolean value, java.lang.String attributeName, int level)
          Boolean encoding.
protected static java.lang.String encodeColor(java.awt.Color color, java.lang.String attributeName, int level)
          Color encoding.
protected static java.lang.String encodeEdge(JGraph graph, java.lang.Object id, java.lang.Object edge)
          Encode a Edge of a graph
protected static java.lang.String encodeFont(java.awt.Font font, java.lang.String attributeName, int level)
          Font encoding.
protected static java.lang.String encodeInteger(int value, java.lang.String attributeName, int level)
          Integer encoding.
protected static java.lang.String encodeRectangle(java.awt.geom.Rectangle2D rec, java.lang.String attributeName, int level)
          Rectangle encoding.
protected static java.lang.String encodeString(java.lang.String value, java.lang.String attributeName, int level)
          String encoding.
protected static java.lang.String encodeValue(int value, int level)
          Basic integer encoding.
protected static java.lang.String encodeValue(java.lang.String value, int level)
          Basic String encoding.
protected static java.lang.String encodeValue(java.lang.String type, java.lang.String value, int level)
          Basic value encoding.
protected static java.lang.String encodeVertex(JGraph graph, java.lang.String id, java.lang.Object vertex)
          Encode a Vertex of a graph
protected static java.lang.String getLabel(org.w3c.dom.Node node)
           
static java.util.Hashtable getLastDecodingHashtable()
          Retrieves the decoding Hashtable with the node's Id.
static java.util.Hashtable getLastEncodingHashtable()
          Retrieves the encoding Hashtable with the node's Id.
static boolean getValidateDTD()
          Getter for the property validateDTD
protected static void readGXLAttributeValues(org.w3c.dom.Node enode, java.util.LinkedList values)
          Reads the values of an GXL Attribute.
static void setValidateDTD(boolean validate)
          Setter for the property validateDTD
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JGraphGXLCodec

public JGraphGXLCodec()
Method Detail

getLastEncodingHashtable

public static java.util.Hashtable getLastEncodingHashtable()
Retrieves the encoding Hashtable with the node's Id. It may be usefull to sirialize the values of the nodes.

Returns:
Hastable with elements : ((key : node), (value : GXL id)).

getLastDecodingHashtable

public static java.util.Hashtable getLastDecodingHashtable()
Retrieves the decoding Hashtable with the node's Id. It may be usefull to sirialize the values of the nodes.

Returns:
Hastable with elements : ((key : node), (value : GXL id)).

encode

public static java.lang.String encode(JGraph graph)
Create a GXL-representation for all the cells.

Parameters:
graph - JGraph to encode.
Returns:
Encoded string.

encode

public static java.lang.String encode(JGraph graph,
                                      java.lang.Object[] cells)
Create a GXL-representation for the specified cells.

Parameters:
graph - JGraph to encode.
cells - Selected cells to be encoded.
Returns:
Encoded string.

encodeValue

protected static java.lang.String encodeValue(java.lang.String type,
                                              java.lang.String value,
                                              int level)
Basic value encoding.

Parameters:
type - GXL Type of the value (int, bool, ...)
value - Value to be encoded.
level - Tab level.
Returns:
Encoded string.

encodeValue

protected static java.lang.String encodeValue(int value,
                                              int level)
Basic integer encoding.

Parameters:
value - Value to be encoded.
level - Tab level.
Returns:
Encoded string.

encodeValue

protected static java.lang.String encodeValue(java.lang.String value,
                                              int level)
Basic String encoding.

Parameters:
value - Value to be encoded.
level - Tab level.
Returns:
Encoded string.

encodeAttribute

protected static java.lang.String encodeAttribute(java.lang.String values,
                                                  java.lang.String attributeName,
                                                  int level)
Attribute encoding.

Parameters:
values - Values of the attribute.
attributeName - name of the attribute.
level - Tab level.
Returns:
Encoded string.

encodeString

protected static java.lang.String encodeString(java.lang.String value,
                                               java.lang.String attributeName,
                                               int level)
String encoding.

Parameters:
value - Value of the attribute.
attributeName - name of the attribute.
level - Tab level.
Returns:
Encoded string.

encodeInteger

protected static java.lang.String encodeInteger(int value,
                                                java.lang.String attributeName,
                                                int level)
Integer encoding.

Parameters:
value - Value of the attribute.
attributeName - name of the attribute.
level - Tab level.
Returns:
Encoded string.

encodeBoolean

protected static java.lang.String encodeBoolean(boolean value,
                                                java.lang.String attributeName,
                                                int level)
Boolean encoding.

Parameters:
value - Value of the attribute.
attributeName - name of the attribute.
level - Tab level.
Returns:
Encoded string.

encodeColor

protected static java.lang.String encodeColor(java.awt.Color color,
                                              java.lang.String attributeName,
                                              int level)
Color encoding.

Parameters:
color - Color of the attribute.
attributeName - name of the attribute.
level - Tab level.
Returns:
Encoded string.

encodeFont

protected static java.lang.String encodeFont(java.awt.Font font,
                                             java.lang.String attributeName,
                                             int level)
Font encoding.

Parameters:
font - Font of the attribute.
attributeName - name of the attribute.
level - Tab level.
Returns:
Encoded string.

encodeRectangle

protected static java.lang.String encodeRectangle(java.awt.geom.Rectangle2D rec,
                                                  java.lang.String attributeName,
                                                  int level)
Rectangle encoding.

Parameters:
rec - Rectangle to be encoded.
attributeName - name of the attribute.
level - Tab level.
Returns:
Encoded string.

encodeBean

protected static java.lang.String encodeBean(java.lang.Object bean,
                                             java.lang.String attributeName,
                                             int level)
Bean encoding. This is usefull to encode the userObject in the Vertex. It must be a bean with a beanInfo class in order to inspect it.

Parameters:
bean - Bean to be encoded.
attributeName - name of the attribute.
level - Tab level.
Returns:
Encoded string.

encodeVertex

protected static java.lang.String encodeVertex(JGraph graph,
                                               java.lang.String id,
                                               java.lang.Object vertex)
Encode a Vertex of a graph

Parameters:
graph - Graph containing the vertex.
id - Id of the vertex.
vertex - Vertex to be encoded.
Returns:
Encoded string.

encodeEdge

protected static java.lang.String encodeEdge(JGraph graph,
                                             java.lang.Object id,
                                             java.lang.Object edge)
Encode a Edge of a graph

Parameters:
graph - Graph containing the edge.
id - Id of the vertex.
Returns:
Encoded string.

decodeCell

protected static void decodeCell(org.w3c.dom.Node gnode,
                                 java.util.Map gnode_attrs)
Extracts visual properties of the node from the child 'view' element Currently recognized properties: - Bounds - color - background-color - autosize - Font - Line-End, Line-size, Line-color


readGXLAttributeValues

protected static void readGXLAttributeValues(org.w3c.dom.Node enode,
                                             java.util.LinkedList values)
Reads the values of an GXL Attribute.

Parameters:
enode - Node to read.

decodeEdge

protected static void decodeEdge(org.w3c.dom.Node enode,
                                 java.util.Map enode_attrs)
Decodes a Edge.

Parameters:
enode - XML Node.
enode_attrs - Cell Attributes.

decode

public static void decode(java.io.InputStream inputStream,
                          JGraph graph)
                   throws java.lang.Exception
Decodes a GXL File.

Parameters:
inputStream - Stream to be decoded.
graph - Graph where the decode file is inserted.
Throws:
java.lang.Exception

createDefaultAttributes

protected static java.util.Map createDefaultAttributes(java.util.Map map)
Returns an attributeMap for the specified position and color.


getLabel

protected static java.lang.String getLabel(org.w3c.dom.Node node)

setValidateDTD

public static void setValidateDTD(boolean validate)
Setter for the property validateDTD

Parameters:
validate - True, the validation will occur.

getValidateDTD

public static boolean getValidateDTD()
Getter for the property validateDTD