JGraphAddons
v1.0.8


org.jgraph.util
Class JGraphGXLCodec

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

public class JGraphGXLCodec
extends Object


Constructor Summary
JGraphGXLCodec()
           
 
Method Summary
protected static Map createDefaultAttributes(Map map)
          Returns an attributeMap for the specified position and color.
static void decode(InputStream inputStream, JGraph graph)
          Decodes a GXL File.
protected static void decodeCell(Node gnode, 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(Node enode, Map enode_attrs)
          Decodes a Edge.
static String encode(JGraph graph)
          Create a GXL-representation for all the cells.
static String encode(JGraph graph, Object[] cells)
          Create a GXL-representation for the specified cells.
protected static String encodeAttribute(String values, String attributeName, int level)
          Attribute encoding.
protected static String encodeBean(Object bean, String attributeName, int level)
          Bean encoding.
protected static String encodeBoolean(boolean value, String attributeName, int level)
          Boolean encoding.
protected static String encodeColor(Color color, String attributeName, int level)
          Color encoding.
protected static String encodeEdge(JGraph graph, Object id, Object edge)
          Encode a Edge of a graph
protected static String encodeFont(Font font, String attributeName, int level)
          Font encoding.
protected static String encodeInteger(int value, String attributeName, int level)
          Integer encoding.
protected static String encodeRectangle(Rectangle2D rec, String attributeName, int level)
          Rectangle encoding.
protected static String encodeString(String value, String attributeName, int level)
          String encoding.
protected static String encodeValue(int value, int level)
          Basic integer encoding.
protected static String encodeValue(String value, int level)
          Basic String encoding.
protected static String encodeValue(String type, String value, int level)
          Basic value encoding.
protected static String encodeVertex(JGraph graph, String id, Object vertex)
          Encode a Vertex of a graph
protected static String getLabel(Node node)
           
static Hashtable getLastDecodingHashtable()
          Retrieves the decoding Hashtable with the node's Id.
static Hashtable getLastEncodingHashtable()
          Retrieves the encoding Hashtable with the node's Id.
static boolean getValidateDTD()
          Getter for the property validateDTD
protected static void readGXLAttributeValues(Node enode, 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 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 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 String encode(JGraph graph)
Create a GXL-representation for all the cells.

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

encode

public static String encode(JGraph graph,
                            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 String encodeValue(String type,
                                    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 String encodeValue(int value,
                                    int level)
Basic integer encoding.

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

encodeValue

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

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

encodeAttribute

protected static String encodeAttribute(String values,
                                        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 String encodeString(String value,
                                     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 String encodeInteger(int value,
                                      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 String encodeBoolean(boolean value,
                                      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 String encodeColor(Color color,
                                    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 String encodeFont(Font font,
                                   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 String encodeRectangle(Rectangle2D rec,
                                        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 String encodeBean(Object bean,
                                   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 String encodeVertex(JGraph graph,
                                     String id,
                                     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 String encodeEdge(JGraph graph,
                                   Object id,
                                   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(Node gnode,
                                 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(Node enode,
                                             LinkedList values)
Reads the values of an GXL Attribute.

Parameters:
enode - Node to read.

decodeEdge

protected static void decodeEdge(Node enode,
                                 Map enode_attrs)
Decodes a Edge.

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

decode

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

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

createDefaultAttributes

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


getLabel

protected static String getLabel(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


JGraphAddons
v1.0.8


Copyright (C) 2003-2005 Gaudenz Alder. All rights reserved.