com.yworks.yfiles.server.graphml.flexio
Class FlexIOTools

java.lang.Object
  extended bycom.yworks.yfiles.server.graphml.flexio.FlexIOTools

public final class FlexIOTools
extends Object

Provides static utility methods for reading and writing graph data using the yFiles FLEX GraphML format.


Method Summary
static void addLabel(Edge edge, Label label)
          Add a label to the given edge.
static void addLabel(Node node, Label label)
          Add a label to the given node.
static void commitLabelLayout(ILabelModelParameter flexParameter, EdgeLabelLayout labelLayout, Edge edge)
          Commit a single label layout to the given yFiles FLEX-compatible label model parameters.
static void commitLabelLayout(ILabelModelParameter flexParameter, NodeLabelLayout labelLayout, Node node)
          Commit a single label layout to the given yFiles FLEX-compatible label model parameters.
static void copyLabelLayouts(LayoutGraph graph)
          Copys the layout information of the yFiles Java label model parameters to the flex-compatible label models stored in the data providers GraphRoundtripSupport.NODE_LABELS_DPKEY and GraphRoundtripSupport.EDGE_LABELS_DPKEY.
static Object deserialize(GraphMLParseContext context, Node xmlNode)
          Try to deserialize the given xmlNode using an IDeserializer instance that is retrieved from a SerializerRegistry contained in the context.
static String getARGBString(Color c)
          Create an argb hex string (e.g.
static Integer getExteriorPosition(String positionStr)
           
static Label getFirstLabel(Edge edge)
          Returns the first label registered with the given edge, or null if no labels are registered.
static Label getFirstLabel(Node node)
          Returns the first label registered with the given node, or null if no labels are registered.
static Integer getInteriorPosition(String positionStr)
           
static List getLabels(Edge edge)
          Return the list of labels registered for the given edge.
static List getLabels(Node node)
          Return the list of labels registered for the given node.
static IEdgeStyle getStyle(Edge edge)
          Returns the style that is currenlty registered for the given edge.
static INodeStyle getStyle(Node node)
          Returns the style that is currenlty registered for the given node.
static Color parseNamedOrARGBColor(String colorStr)
          Parses a named or argb color string, e.g.
static void serialize(GraphMLWriteContext context, Object subject, XmlWriter writer)
          Try to serialize the given instance using an ISerializer instance that is retrieved from a SerializerRegistry contained in the context.
static void setStyle(Edge edge, INodeStyle style)
          Set an edge style for the given node.
static void setStyle(Node node, INodeStyle style)
          Set a node style for the given node.
static void syncLabels(Edge edge, boolean createIfNotExisting)
          Synchronizes all Label instances associated with the given edge with the EdgeLabelLayouts of the LayoutGraph.
static void syncLabels(Node node, boolean createIfNotExisting)
          Synchronizes all Label instances associated with the given node with the NodeLabelLayouts of the LayoutGraph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

deserialize

public static Object deserialize(GraphMLParseContext context,
                                 Node xmlNode)
Try to deserialize the given xmlNode using an IDeserializer instance that is retrieved from a SerializerRegistry contained in the context.

Parameters:
context - The current parse context.
xmlNode - The xmlNode that is to be deserialized.
Returns:
The deserialized instance, or null if the node could not be deserialized.

serialize

public static void serialize(GraphMLWriteContext context,
                             Object subject,
                             XmlWriter writer)
Try to serialize the given instance using an ISerializer instance that is retrieved from a SerializerRegistry contained in the context.

Parameters:
context - The current write context.
subject - The instance that is to be serialized.
writer - The XML writer

setStyle

public static void setStyle(Node node,
                            INodeStyle style)
Set a node style for the given node.

The style is set using the data mapper registered with the key GraphRoundtripSupport.NODE_STYLE_DPKEY

Parameters:
node - The node
style - the style to use for the given node
See Also:
GraphRoundtripSupport.NODE_STYLE_DPKEY

setStyle

public static void setStyle(Edge edge,
                            INodeStyle style)
Set an edge style for the given node.

The style is set using the data mapper registered with the key GraphRoundtripSupport.EDGE_STYLE_DPKEY

Parameters:
edge - The edge
style - the style to use for the given edge
See Also:
GraphRoundtripSupport.EDGE_STYLE_DPKEY

addLabel

public static void addLabel(Node node,
                            Label label)
Add a label to the given node.

The label is added using the list found in the data mapper registered with the key GraphRoundtripSupport.NODE_LABELS_DPKEY

If no label list is registed in the corresponding data map yet, a new list is created.

Adding a label will not automatically add a label layout instance to the layout graph. Therefore, a label that was newly added using this method will not be considered in a layout calculation. To synchronize the labels of a node with the layout graph, use syncLabels(y.base.Node, boolean).

Parameters:
node - The node to add a label to
label - The label to add to the node.
See Also:
GraphRoundtripSupport.NODE_LABELS_DPKEY

getLabels

public static List getLabels(Node node)
Return the list of labels registered for the given node.

The list is retrieved using the data mapper registered with key GraphRoundtripSupport.NODE_LABELS_DPKEY

If no label list is registed in the corresponding data map yet, a new list is created.

Parameters:
node - The node to get the registered labels for.
Returns:
The list of labels that are registred for the given node.

getFirstLabel

public static Label getFirstLabel(Node node)
Returns the first label registered with the given node, or null if no labels are registered.

The list of labels is retrieved using the data mapper registered with key GraphRoundtripSupport.NODE_LABELS_DPKEY

Parameters:
node - The node to get the label for
Returns:
The first label or null

addLabel

public static void addLabel(Edge edge,
                            Label label)
Add a label to the given edge.

The label is added using the list found in the data mapper registered with the key GraphRoundtripSupport.EDGE_LABELS_DPKEY

If no label list is registed in the corresponding data map yet, a new label list is created.

Adding a label will not automatically add a label layout instance to the layout graph. Therefore, a label that was newly added using this method will not be considered in a layout calculation. To synchronize the labels of an edge with the layout graph, use syncLabels(y.base.Edge, boolean).

Parameters:
edge - The edge to add a label to
label - The label to add to the edge.
See Also:
GraphRoundtripSupport.EDGE_LABELS_DPKEY

getLabels

public static List getLabels(Edge edge)
Return the list of labels registered for the given edge.

The list is retrieved using the data mapper registered with key GraphRoundtripSupport.EDGE_LABELS_DPKEY

If no label list is registed in the corresponding data map yet, a new list is created.

Parameters:
edge - the edge to retrieve the labels for
Returns:
The list of labels that are registered for the given edge.

getFirstLabel

public static Label getFirstLabel(Edge edge)
Returns the first label registered with the given edge, or null if no labels are registered.

The list of labels is retrieved using the data mapper registered with key GraphRoundtripSupport.EDGE_LABELS_DPKEY

Parameters:
edge - The node to get the label for
Returns:
The first label or null

getStyle

public static INodeStyle getStyle(Node node)
Returns the style that is currenlty registered for the given node.

The style is retrieved using the data mapper registered with key GraphRoundtripSupport.NODE_STYLE_DPKEY

Parameters:
node - The node to get the style for
Returns:
The registered style, or null if no style has been registered yet.

getStyle

public static IEdgeStyle getStyle(Edge edge)
Returns the style that is currenlty registered for the given edge.

The style is retrieved using the data mapper registered with key GraphRoundtripSupport.EDGE_STYLE_DPKEY

Parameters:
edge - The edge to get the style for
Returns:
The registered style, or null if no style has been registered yet.

copyLabelLayouts

public static void copyLabelLayouts(LayoutGraph graph)
Copys the layout information of the yFiles Java label model parameters to the flex-compatible label models stored in the data providers GraphRoundtripSupport.NODE_LABELS_DPKEY and GraphRoundtripSupport.EDGE_LABELS_DPKEY.

This method can be called to commit the label layouts after running a layout algorithm that changes the label locations.

This will only work for the slider- and free edge label models and for the interior/exterior node label models.


syncLabels

public static void syncLabels(Node node,
                              boolean createIfNotExisting)
Synchronizes all Label instances associated with the given node with the NodeLabelLayouts of the LayoutGraph.

This method can be called if a label was created on the server (e.g. using addLabel(y.base.Node, com.yworks.yfiles.server.graphml.flexio.data.Label) and a label layout calculation will be executed before the graph is sent back to the client. Note that a reasonable preferred size should be set on the Label instance. If no preferred size is set, (40,40) is used.

Parameters:
node - The node to update the labels from.
createIfNotExisting - Whether to create new label layout instances for the LayoutGraph, if there are more Label instances associated with this node than label layouts known by the LayoutGraph.

syncLabels

public static void syncLabels(Edge edge,
                              boolean createIfNotExisting)
Synchronizes all Label instances associated with the given edge with the EdgeLabelLayouts of the LayoutGraph.

This method can be called if a label was created on the server (e.g. using addLabel(y.base.Edge, com.yworks.yfiles.server.graphml.flexio.data.Label) and a label layout calculation will be executed before the graph is sent back to the client. Note that a reasonable preferred size should be set on the Label instance. If no preferred size is set, (40,40) is used.

Parameters:
edge - The edge to update the labels from.
createIfNotExisting - Whether to create new label layout instances for the LayoutGraph, if there are more Label instances associated with this edge than label layouts known by the LayoutGraph.

commitLabelLayout

public static void commitLabelLayout(ILabelModelParameter flexParameter,
                                     EdgeLabelLayout labelLayout,
                                     Edge edge)
Commit a single label layout to the given yFiles FLEX-compatible label model parameters.

Parameters:
flexParameter - The yFiles FLEX compatible label model parameters.
labelLayout - The yFiles Java edge label layout
edge - The edge

commitLabelLayout

public static void commitLabelLayout(ILabelModelParameter flexParameter,
                                     NodeLabelLayout labelLayout,
                                     Node node)
Commit a single label layout to the given yFiles FLEX-compatible label model parameters.

Parameters:
flexParameter - The yFiles FLEX compatible label model parameters.
labelLayout - The yFiles Java node label layout
node - The node

getARGBString

public static String getARGBString(Color c)
Create an argb hex string (e.g. #FF00CC00) that represents the color value of a Java color instance.

This method will always create an argb representation, no symbolic color names will be returned.

Parameters:
c - The color to create a String represantation of.
Returns:
A string represantation of the given color.

parseNamedOrARGBColor

public static Color parseNamedOrARGBColor(String colorStr)
Parses a named or argb color string, e.g. "Lime" or "#FF00CC00".

If the color string can't be parsed, Color.WHITE is returned.

Parameters:
colorStr - The string to be parsed.
Returns:
A Java Color instance that represents the parsed color value.

getInteriorPosition

public static Integer getInteriorPosition(String positionStr)

getExteriorPosition

public static Integer getExteriorPosition(String positionStr)


Copyright © 2000-2007 yWorks GmbH. All rights reserved