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

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

public final class FlexIOTools
extends java.lang.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 Port addPort(Node node, IPortLocationModelParameter locationModelParameter)
          Adds a port to the given node and returns it.
static Port addPort(Node node, IPortLocationModelParameter locationModelParameter, Graph graph)
          Adds a port to the given node and returns it.
static boolean canBeSerialized(java.lang.Object item, GraphMLWriteContext context)
          Tests and returns if item can be serialized using context i.e. an appropriate serialization handler can be found and used.
static void codeUserTag(GraphMLWriteContext context, java.lang.Object tagHolder, XmlWriter writer)
          Gets the user tag from the tagHolder and writes it in a <y:UserTag> element using the given writer.
static void codeUserTagValue(GraphMLWriteContext context, java.lang.Object tag, XmlWriter writer)
          writes the provided user tag in a <y:UserTag> element using the given writer.
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 commitPortLocation(Edge edge, boolean source)
          Commits the location of the edge's source or target end point to the source or target port of the edge.
static double[] convertAttributes(Graph graph, Edge edge, EdgeLabelLayout labelLayout, java.lang.Object parameter, boolean edgeRelativeAngle)
           
static double[] convertAttributes(Graph graph, Edge edge, EdgeLabelLayout labelLayout, java.lang.Object parameter, EdgeLabelModel javaModel, boolean edgeRelativeAngle)
           
static double[] convertAttributes(OrientedRectangle labelBounds, EdgeLayout edgeLayout, NodeLayout sourceLayout, NodeLayout targetLayout, boolean edgeRelativeDistance)
           
static void copyLabelLayouts(LayoutGraph graph)
          Copies the layout information of the yFiles Java label model parameters to the flex-compatible label models stored in the data providers GraphRoundtripSupportBase.NODE_LABELS_DPKEY and GraphRoundtripSupportBase.EDGE_LABELS_DPKEY.
static void copyPortLocations(LayoutGraph graph)
          Commits the source and target location for all edges in the graph to their source and target ports.
static void decodeUserTag(GraphMLParseContext context, org.w3c.dom.Node xmlNode, java.lang.Object tagHolder)
          Deserializes the user tag from a <y:UserTag> element and stores it as the given tagHolder's tag.
static java.lang.Object decodeUserTagValue(GraphMLParseContext context, org.w3c.dom.Node xmlNode)
          Deserializes the user tag from a <y:UserTag> element and returns the deserialized value.
static java.lang.Object deserialize(GraphMLParseContext context, org.w3c.dom.Node xmlNode)
          Tries to delegate deserialization to the context and silently ignores GraphMLParseExceptions.
static java.util.List edgesAtPort(Port port)
          Returns a list of edges attached to port.
static java.lang.String getARGBString(java.awt.Color c)
          Create an argb hex string (e.g.
static java.lang.Integer getExteriorPosition(java.lang.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 java.lang.String getGraphMLString(HttpServletRequest request)
          Returns the decoded GraphML string sent as AbstractGraphRoundtripSupport.PARAM_GRAPH parameter of request.
static java.lang.Integer getInteriorPosition(java.lang.String positionStr)
           
static java.util.List getLabels(Edge edge)
          Return the list of labels registered for the given edge.
static java.util.List getLabels(Node node)
          Return the list of labels registered for the given node.
static java.util.List getPorts(Node node)
          Returns the ports of the provided node.
static Port getSourcePort(Edge edge)
          Returns the port at the source node the edge is connected to.
static Port getSourcePort(Edge edge, Graph graph)
          Returns the port at the source node the edge is connected to.
static IEdgeStyle getStyle(Edge edge)
          Returns the style that is currently registered for the given edge.
static INodeStyle getStyle(Node node)
          Returns the style that is currently registered for the given node.
static Port getTargetPort(Edge edge)
          Returns the port at the target node the edge is connected to.
static Port getTargetPort(Edge edge, Graph graph)
          Returns the port at the target node the edge is connected to.
static java.lang.Object getUserTag(Edge edge)
          Returns the user tag of the provided edge.
static java.lang.Object getUserTag(Node node)
          Returns the user tag of the provided node.
static java.lang.Object getUserTag(java.lang.Object item, Graph graph)
          Returns the user tag of the provided node, edge or Label

The usertag is retrieved using the data mapper registered with key AbstractGraphRoundtripSupport.USERTAGS_DPKEY

static int getZOrder(Edge edge)
          Returns the z-order that is currently registered for the given edge.
static int getZOrder(Node node)
          Returns the z-order that is currently registered for the given node.
static java.awt.Color parseNamedOrARGBColor(java.lang.String colorStr)
          Parses a named or argb color string, e.g.
static void removePort(Port port, Node node, Graph graph)
          Removes a port from a node.
static void serialize(GraphMLWriteContext context, java.lang.Object subject, XmlWriter writer)
          Try to serialize the given instance and silently ignores GraphMLWriteExceptions.
static void setSourcePort(Edge edge, Port port)
          Assigns a new source port to edge.
static void setSourcePort(Edge edge, Port port, Graph graph)
          Assigns a new source port to edge.
static void setStyle(Edge edge, IEdgeStyle style)
          Set an edge style for the given edge.
static void setStyle(Node node, INodeStyle style)
          Set a node style for the given node.
static void setTargetPort(Edge edge, Port port)
          Assigns a new target port to edge.
static void setTargetPort(Edge edge, Port port, Graph graph)
          Assigns a new target port to edge.
static void setUserTag(Edge edge, java.lang.Object tag)
          Sets the user tag of the provided node.
static void setUserTag(Node node, java.lang.Object tag)
          Sets the user tag of the provided node.
static void setUserTag(java.lang.Object item, java.lang.Object tag, Graph graph)
          Sets the user tag of the provided node, edge or Label

The usertag is set on data mapper registered with key AbstractGraphRoundtripSupport.USERTAGS_DPKEY

static void setZOrder(Edge edge, int zOrder)
          Set a z-order for the given edge.
static void setZOrder(Node node, int zOrder)
          Set a z-order for the given node.
static boolean syncLabelModel(Node labelOwner, ILabelModelParameter labelModelParameter, NodeLabelLayoutImpl nodeLabelLayout)
          Try to find a suitable mapping from client-side label model and label model parameters to server-side label model data that can be considered by the yFiles for Java layout algorithms.
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.
static void syncLayoutBoxes(Edge edge, GraphLayout graphLayout)
          Synchronizes the oriented boxes of the edge's label layouts with their label model parameters.
static boolean syncLayouts(ILabelModelParameter edgeLabelModelParameter, EdgeLabelLayoutImpl edgeLabelLayout)
          Try to find a suitable mapping from client-side label layout properties to server-side label model data that can be considered by the yFiles for Java layout algorithms.
static boolean syncLayouts(Label label, EdgeLabelLayoutImpl layout)
          Try to find a suitable mapping from client-side label layout properties to server-side label model data that can be considered by the yFiles for Java layout algorithms.
static boolean syncLayouts(Label label, NodeLabelLayoutImpl layout)
          Try to find a suitable mapping from client-side label layout properties to server-side label model data that can be considered by the yFiles for Java layout algorithms.
static void syncPortLocation(Edge edge, boolean source)
          Synchronizes the location of the edge's source or target end point with the source or target port of the edge.
static void syncPortLocation(Edge edge, boolean source, LayoutGraph graph)
          Synchronizes the location of the edge's source or target end point with the source or target port of the edge.
static boolean trySerialize(java.lang.Object item, GraphMLWriteContext context)
          Tries to serialize item using context and returns if the serialization was successful.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

deserialize

public static java.lang.Object deserialize(GraphMLParseContext context,
                                           org.w3c.dom.Node xmlNode)
Tries to delegate deserialization to the context and silently ignores GraphMLParseExceptions.

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,
                             java.lang.Object subject,
                             XmlWriter writer)
Try to serialize the given instance and silently ignores GraphMLWriteExceptions.

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

canBeSerialized

public static boolean canBeSerialized(java.lang.Object item,
                                      GraphMLWriteContext context)
Tests and returns if item can be serialized using context i.e. an appropriate serialization handler can be found and used.

Parameters:
item - The item that shall be tested for serializability.
context - The context to use for the serialization test.
Returns:
false if the item is null or can't be serialized, true otherwise.

trySerialize

public static boolean trySerialize(java.lang.Object item,
                                   GraphMLWriteContext context)
Tries to serialize item using context and returns if the serialization was successful.

Parameters:
item - The item to serialize. If null is passed only false is returned.
context - The context used for serialization.
Returns:
true if the item could be serialized successfully, false otherwise.

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 GraphRoundtripSupportBase.NODE_STYLE_DPKEY

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

setStyle

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

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

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

setZOrder

public static void setZOrder(Node node,
                             int zOrder)
Set a z-order for the given node.

The z-order is set using the data mapper registered with the key GraphRoundtripSupportBase.NODE_Z_ORDER_DPKEY

Parameters:
node - The node
zOrder - the z-order to use for the given node
See Also:
GraphRoundtripSupportBase.NODE_Z_ORDER_DPKEY

setZOrder

public static void setZOrder(Edge edge,
                             int zOrder)
Set a z-order for the given edge.

The z-order is set using the data mapper registered with the key GraphRoundtripSupportBase.EDGE_Z_ORDER_DPKEY

Parameters:
edge - The edge
zOrder - the z-order to use for the given edge
See Also:
GraphRoundtripSupportBase.EDGE_Z_ORDER_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 GraphRoundtripSupportBase.NODE_LABELS_DPKEY

If no label list is registered 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:
GraphRoundtripSupportBase.NODE_LABELS_DPKEY

getLabels

public static java.util.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 GraphRoundtripSupportBase.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 GraphRoundtripSupportBase.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 GraphRoundtripSupportBase.EDGE_LABELS_DPKEY

If no label list is registered 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(Edge, boolean).

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

getLabels

public static java.util.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 GraphRoundtripSupportBase.EDGE_LABELS_DPKEY

If no label list is registered 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 GraphRoundtripSupportBase.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 currently registered for the given node.

The style is retrieved using the data mapper registered with key GraphRoundtripSupportBase.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 currently registered for the given edge.

The style is retrieved using the data mapper registered with key GraphRoundtripSupportBase.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.

getZOrder

public static int getZOrder(Node node)
Returns the z-order that is currently registered for the given node.

The z-order is retrieved using the data mapper registered with key GraphRoundtripSupportBase.NODE_Z_ORDER_DPKEY

Parameters:
node - The node to get the z-order for.
Returns:
The registered z-order, or 0 if no z-order has been registered yet.

getZOrder

public static int getZOrder(Edge edge)
Returns the z-order that is currently registered for the given edge.

The z-order is retrieved using the data mapper registered with key GraphRoundtripSupportBase.EDGE_Z_ORDER_DPKEY

Parameters:
edge - The edge to get the z-order for
Returns:
The registered z-order, or 0 if no z-order has been registered yet.

getUserTag

public static java.lang.Object getUserTag(java.lang.Object item,
                                          Graph graph)
Returns the user tag of the provided node, edge or Label

The usertag is retrieved using the data mapper registered with key AbstractGraphRoundtripSupport.USERTAGS_DPKEY

Parameters:
item - The graph item to retrieve the tag for.
graph - The graph which contains the item.
Returns:
The user tag, or null if no user tag has been registered for the provided item.

getUserTag

public static java.lang.Object getUserTag(Node node)
Returns the user tag of the provided node.

The usertag is retrieved using the data mapper registered with key AbstractGraphRoundtripSupport.USERTAGS_DPKEY

Parameters:
node - The node to retrieve the tag for.
Returns:
The user tag, or null if no user tag has been registered for the provided node.

getUserTag

public static java.lang.Object getUserTag(Edge edge)
Returns the user tag of the provided edge.

The usertag is retrieved using the data mapper registered with key AbstractGraphRoundtripSupport.USERTAGS_DPKEY

Parameters:
edge - The edge to retrieve the tag for
Returns:
The user tag, or null if no user tag has been registered for the provided edge.

setUserTag

public static void setUserTag(java.lang.Object item,
                              java.lang.Object tag,
                              Graph graph)
Sets the user tag of the provided node, edge or Label

The usertag is set on data mapper registered with key AbstractGraphRoundtripSupport.USERTAGS_DPKEY

Parameters:
item - The graph item to set the tag for.
tag - The user object to set.
graph - The graph which contains the item.

setUserTag

public static void setUserTag(Node node,
                              java.lang.Object tag)
Sets the user tag of the provided node.

Parameters:
node - The node to set the tag for.
tag - The user object to set.

setUserTag

public static void setUserTag(Edge edge,
                              java.lang.Object tag)
Sets the user tag of the provided node.

Parameters:
edge - The edge to set the tag for.
tag - The user object to set.

addPort

public static Port addPort(Node node,
                           IPortLocationModelParameter locationModelParameter)
Adds a port to the given node and returns it.

The port is added using the list found in the data mapper registered at the node's graph with the key GraphRoundtripSupportBase.NODE_PORTS_DPKEY

If no port list is registered in the corresponding data map yet, a new port list is created.

Parameters:
node - The node to add a port to
locationModelParameter - The model parameter describing the port location
See Also:
GraphRoundtripSupportBase.NODE_PORTS_DPKEY

addPort

public static Port addPort(Node node,
                           IPortLocationModelParameter locationModelParameter,
                           Graph graph)
Adds a port to the given node and returns it.

The port is added using the list found in the data mapper registered at the graph with the key GraphRoundtripSupportBase.NODE_PORTS_DPKEY

If no port list is registered in the corresponding data map yet, a new port list is created.

Parameters:
node - The node to add a port to
locationModelParameter - The model parameter describing the port location
graph - The graph to get the data provider from.
See Also:
GraphRoundtripSupportBase.NODE_PORTS_DPKEY

removePort

public static void removePort(Port port,
                              Node node,
                              Graph graph)
Removes a port from a node.

This method doesn't remove any edges connected to this port. Instead the port is only removed from the list found in the data mapper registered at the graph with the key GraphRoundtripSupportBase.NODE_PORTS_DPKEY

If edges connecting to the port should be removed as well the StyledLayoutGraph's removePort method should be used instead.

Parameters:
port - The port to remove from the node.
node - The node to remove the port from.
graph - The graph to get the data provider from.
See Also:
GraphRoundtripSupportBase.NODE_PORTS_DPKEY, StyledLayoutGraph.removePort(com.yworks.yfiles.server.graphml.folding.markup.Port)

getPorts

public static java.util.List getPorts(Node node)
Returns the ports of the provided node.

The port list is looked up using the data mapper registered with the key GraphRoundtripSupportBase.NODE_PORTS_DPKEY.

Parameters:
node - The node to provide ports for.
Returns:
A list of ports or null.

getSourcePort

public static Port getSourcePort(Edge edge)
Returns the port at the source node the edge is connected to.

This source port is looked up using the data mapper registered at the edge's graph with the key GraphRoundtripSupportBase.EDGE_SOURCE_PORT_DPKEY

Parameters:
edge - The edge to get the source port to.
Returns:
The source port of the edge.

getSourcePort

public static Port getSourcePort(Edge edge,
                                 Graph graph)
Returns the port at the source node the edge is connected to.

This source port is looked up using the data mapper registered at the graph with the key GraphRoundtripSupportBase.EDGE_SOURCE_PORT_DPKEY

Parameters:
edge - The edge to get the source port to.
graph - The graph to get the data provider from.
Returns:
The source port of the edge.

setSourcePort

public static void setSourcePort(Edge edge,
                                 Port port)
Assigns a new source port to edge.

To assign the port as source port of the edge, the data provider found in the data mapper registered with the key GraphRoundtripSupportBase.EDGE_SOURCE_PORT_DPKEY is updated.

Parameters:
edge - The edge to assign a new source port.
port - The new source port of the edge.

setSourcePort

public static void setSourcePort(Edge edge,
                                 Port port,
                                 Graph graph)
Assigns a new source port to edge.

To assign the port as source port of the edge, the data provider found in the data mapper registered at the graph with the key GraphRoundtripSupportBase.EDGE_SOURCE_PORT_DPKEY is updated.

Parameters:
edge - The edge to assign a new source port.
port - The new source port of the edge.
graph - The graph to get the data provider from.

getTargetPort

public static Port getTargetPort(Edge edge)
Returns the port at the target node the edge is connected to.

This target port is looked up using the data mapper registered at the edge's graph with the key GraphRoundtripSupportBase.EDGE_TARGET_PORT_DPKEY

Parameters:
edge - The edge to get the target port to.
Returns:
The target port of the edge.

getTargetPort

public static Port getTargetPort(Edge edge,
                                 Graph graph)
Returns the port at the target node the edge is connected to.

This target port is looked up using the data mapper registered at the graph with the key GraphRoundtripSupportBase.EDGE_TARGET_PORT_DPKEY

Parameters:
edge - The edge to get the target port to.
graph - The graph to get the data provider from.
Returns:
The target port of the edge.

setTargetPort

public static void setTargetPort(Edge edge,
                                 Port port)
Assigns a new target port to edge.

To assign the port as target port of the edge, the data provider found in the data mapper registered at the edge's graph with the key GraphRoundtripSupportBase.EDGE_TARGET_PORT_DPKEY is updated.

Parameters:
edge - The edge to assign a new target port.
port - The new target port of the edge.

setTargetPort

public static void setTargetPort(Edge edge,
                                 Port port,
                                 Graph graph)
Assigns a new target port to edge.

To assign the port as target port of the edge, the data provider found in the data mapper registered at the graph with the key GraphRoundtripSupportBase.EDGE_TARGET_PORT_DPKEY is updated.

Parameters:
edge - The edge to assign a new target port.
port - The new target port of the edge.

edgesAtPort

public static java.util.List edgesAtPort(Port port)
Returns a list of edges attached to port.

Parameters:
port - The port to collect the attached edges from.
Returns:
A list of edges attached to port.

copyLabelLayouts

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

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


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(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 either a reasonable preferred size should be set on the Label instance or a style which implements the interface LabelSizeCalculator (e.g. SimpleLabelStyle; in that case, a font should be set to that style, too). If neither 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(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 either a reasonable preferred size should be set on the Label instance or a style which implements the interface LabelSizeCalculator (e.g. SimpleLabelStyle; in that case, a font should be set to that style, too). If neither 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.

syncLayouts

public static boolean syncLayouts(Label label,
                                  EdgeLabelLayoutImpl layout)
Try to find a suitable mapping from client-side label layout properties to server-side label model data that can be considered by the yFiles for Java layout algorithms. To update the oriented box of the server-side label layout, syncLayoutBoxes has to be called afterwards.

Parameters:
label - The server-side representation of a client-side label
layout - The yFiles for Java label layout
Returns:
Whether a suitable mapping has been found

syncLayouts

public static boolean syncLayouts(ILabelModelParameter edgeLabelModelParameter,
                                  EdgeLabelLayoutImpl edgeLabelLayout)
Try to find a suitable mapping from client-side label layout properties to server-side label model data that can be considered by the yFiles for Java layout algorithms.

Parameters:
edgeLabelModelParameter - The client-side edge label model parameter
edgeLabelLayout - The yFiles for Java label layout
Returns:
Whether a suitable mapping has been found

syncLayoutBoxes

public static void syncLayoutBoxes(Edge edge,
                                   GraphLayout graphLayout)
Synchronizes the oriented boxes of the edge's label layouts with their label model parameters.

Parameters:
edge - The edge to synchronize the label layouts for.
graphLayout -

syncLayouts

public static boolean syncLayouts(Label label,
                                  NodeLabelLayoutImpl layout)
Try to find a suitable mapping from client-side label layout properties to server-side label model data that can be considered by the yFiles for Java layout algorithms.

Parameters:
label - The server-side representation of a client-side label
layout - The yFiles for Java label layout
Returns:
Whether a suitable mapping has been found

syncLabelModel

public static boolean syncLabelModel(Node labelOwner,
                                     ILabelModelParameter labelModelParameter,
                                     NodeLabelLayoutImpl nodeLabelLayout)
Try to find a suitable mapping from client-side label model and label model parameters to server-side label model data that can be considered by the yFiles for Java layout algorithms.

Parameters:
labelOwner - The owner of the node label to synchronize.
labelModelParameter - The client-side node label model parameter.
nodeLabelLayout - The yFiles for Java label layout.
Returns:
Whether a suitable mapping has been found.

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

convertAttributes

public static double[] convertAttributes(Graph graph,
                                         Edge edge,
                                         EdgeLabelLayout labelLayout,
                                         java.lang.Object parameter,
                                         boolean edgeRelativeAngle)

convertAttributes

public static double[] convertAttributes(Graph graph,
                                         Edge edge,
                                         EdgeLabelLayout labelLayout,
                                         java.lang.Object parameter,
                                         EdgeLabelModel javaModel,
                                         boolean edgeRelativeAngle)

convertAttributes

public static double[] convertAttributes(OrientedRectangle labelBounds,
                                         EdgeLayout edgeLayout,
                                         NodeLayout sourceLayout,
                                         NodeLayout targetLayout,
                                         boolean edgeRelativeDistance)

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

copyPortLocations

public static void copyPortLocations(LayoutGraph graph)
Commits the source and target location for all edges in the graph to their source and target ports.

Parameters:
graph - The graph containing the edges to commit the port location for.
See Also:
commitPortLocation(Edge, boolean)

commitPortLocation

public static void commitPortLocation(Edge edge,
                                      boolean source)
Commits the location of the edge's source or target end point to the source or target port of the edge.

LayoutGraph.getSourcePointAbs(Edge) or LayoutGraph.getTargetPointAbs(Edge) is used to create a new port location model parameter using the source/target port's port location model.

Parameters:
edge - The edge to commit the port location for.
source - Whether the source or target port location shall be committed. true for source ports.
See Also:
getSourcePort(Edge), getTargetPort(Edge), Port.setLocationModelParameter(com.yworks.yfiles.server.graphml.flexio.data.IPortLocationModelParameter)

syncPortLocation

public static void syncPortLocation(Edge edge,
                                    boolean source)
Synchronizes the location of the edge's source or target end point with the source or target port of the edge.

The offset of the source or target port is set to the edge layout using LayoutGraph.setSourcePointAbs(Edge, y.geom.YPoint) or LayoutGraph.setTargetPointAbs(Edge, y.geom.YPoint) of the edge's graph.

Parameters:
edge - The edge to synchronize the port location for.
source - Iff the source or target port location shall be synchronized.
See Also:
getSourcePort(Edge), getTargetPort(Edge), Port.getLocationModelParameter()

syncPortLocation

public static void syncPortLocation(Edge edge,
                                    boolean source,
                                    LayoutGraph graph)
Synchronizes the location of the edge's source or target end point with the source or target port of the edge.

The offset of the source or target port is set to the edge layout using LayoutGraph.setSourcePointAbs(Edge, y.geom.YPoint) or LayoutGraph.setTargetPointAbs(Edge, y.geom.YPoint) of the passed graph.

Parameters:
edge - The edge to synchronize the port location for.
source - Iff the source or target port location shall be synchronized.
graph - The graph
See Also:
getSourcePort(Edge), getTargetPort(Edge), Port.getLocationModelParameter()

getARGBString

public static java.lang.String getARGBString(java.awt.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 representation of.
Returns:
A string representation of the given color.

parseNamedOrARGBColor

public static java.awt.Color parseNamedOrARGBColor(java.lang.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 java.lang.Integer getInteriorPosition(java.lang.String positionStr)

getExteriorPosition

public static java.lang.Integer getExteriorPosition(java.lang.String positionStr)

getGraphMLString

public static java.lang.String getGraphMLString(HttpServletRequest request)
Returns the decoded GraphML string sent as AbstractGraphRoundtripSupport.PARAM_GRAPH parameter of request.

This method can be used to simplify logging the GraphML data sent from the client.

Parameters:
request - The request object of a HttpServlet.
Returns:
A decoded GraphML String.
See Also:
HttpServlet

codeUserTag

public static void codeUserTag(GraphMLWriteContext context,
                               java.lang.Object tagHolder,
                               XmlWriter writer)
Gets the user tag from the tagHolder and writes it in a <y:UserTag> element using the given writer.

User tags can be read and written using StyledLayoutGraph.getUserTag(Object) and StyledLayoutGraph.setUserTag(Object, Object).

Parameters:
context - The current write context.
tagHolder - The element to get the user tag from.
writer - The XML writer.
See Also:
codeUserTagValue(y.io.graphml.output.GraphMLWriteContext, Object, y.io.graphml.output.XmlWriter)

codeUserTagValue

public static void codeUserTagValue(GraphMLWriteContext context,
                                    java.lang.Object tag,
                                    XmlWriter writer)
writes the provided user tag in a <y:UserTag> element using the given writer.

Parameters:
context - The current write context.
tag - The user tag
writer - The XML writer.
See Also:
codeUserTag(y.io.graphml.output.GraphMLWriteContext, Object, y.io.graphml.output.XmlWriter)

decodeUserTag

public static void decodeUserTag(GraphMLParseContext context,
                                 org.w3c.dom.Node xmlNode,
                                 java.lang.Object tagHolder)
Deserializes the user tag from a <y:UserTag> element and stores it as the given tagHolder's tag.

User tags can be read and written using StyledLayoutGraph.getUserTag(Object) and StyledLayoutGraph.setUserTag(Object, Object).

Parameters:
context - The current parse context.
xmlNode - The <y:UserTag> element.
tagHolder - The tag holder to set the tag for.
See Also:
decodeUserTagValue(y.io.graphml.input.GraphMLParseContext, org.w3c.dom.Node)

decodeUserTagValue

public static java.lang.Object decodeUserTagValue(GraphMLParseContext context,
                                                  org.w3c.dom.Node xmlNode)
Deserializes the user tag from a <y:UserTag> element and returns the deserialized value.

Parameters:
context - The current parse context.
xmlNode - The <y:UserTag> element.
Returns:
The deserialized user tag value
See Also:
decodeUserTag(y.io.graphml.input.GraphMLParseContext, org.w3c.dom.Node, Object)


Copyright © 2000-2013 yWorks GmbH. All rights reserved