Communicating with yFiles.NET on the Server

Because yFiles.NET and yFiles FLEX use a very similar architecture for rendering the visual representation of graph items, they use the same GraphML extension format. Therefore, communicating with a yFiles.NET server should work out-of-the-box for most yFiles FLEX usecases.

To read/write the yFiles.NET/yFiles FLEX GraphML extension format, either a default RoundtripHandler or a DefaultGraphMLIOHandler or DotnetCompatGraphMLIOHandler can be used. See Chapter 4, Input and Output for details on configuration of the client's I/O mechanism and Chapter 5, Communicating with the Server for configuration of server communication features on the client.

Note that although yFiles FLEX and yFiles.NET use the same GraphML extension format, both libraries are distinct products. Therefore, there could be some features that are implemented in only one of the libraries. If, for example, a certain style implementation is available only in yFiles.NET, but has not been implemented for the client library, the style will not be parsed and displayed on the client.

The following table provides an overview of the style implementations available in yFiles FLEX and yFiles.NET.

Table 6.3. yFiles FLEX and yFiles.NET style implementations

Style yFiles FLEX yFiles.NET
BevelNodeStyle + +
CollapsibleNodeStyleDecorator + + (1)
GeneralPathNodeStyle + +
ImageNodeStyle + - (2)
BitmapNodeStyle + + (2)
ShapeNodeStyle + +
ShinyPlateNodeStyle + +
TemplateNodeStyle + +
SimpleLabelStyle + +
IconLabelStyle + +
IconLabelStyleDecorator + -
NodeStyleLabelStyleAdapter + +
TemplateLabelStyle + +
PolylineEdgeStyle + +
SimplePortStyle + -


(1) yWorks.yFiles.Graph.Web.Style.Markup.CollapsibleNodeStyleDecorator.
(2) The yFiles.NET ImageNodeStyle corresponds to the yFiles FLEX BitmapNodeStyle.

The following table provides an overview of the label model implementations available in yFiles FLEX and yFiles.NET.

Table 6.4. yFiles FLEX and yFiles.NET label model implementations

Label Model yFiles FLEX yFiles.NET
ExteriorLabelModel + +
InteriorLabelModel + +
InteriorStretchLabelModel + +
FreeNodeLabelModel + +
FreeEdgeLabelModel + +
RotatingEdgeLabelModel + +
SliderEdgeLabelModel + +
RotatedSliderEdgeLabelModel + +
RotatedSideSliderEdgeLabelModel + +
NinePositionsEdgeLabelModel - +
SandwichLabelModel - +
SideSliderEdgeLabelModel - +
GenericLabelModel + +

The XML Data of a serialized custom style that is only available on the client will not be lost when a full server roundtrip is performed. For details on manipulating custom yFiles FLEX styles on the server, please see the section called “XML Styles”.

Handling Fonts

When there are labels created on the server one has to take account of differences in font handling between .NET and Flex. .NET interprets the font size as Points (pt, 1/72 inch) whereas Flex uses Pixel (px, 1/96 inch). As a consequence the label fonts are smaller at the client than on .NET side.

Figure 6.2. Label with the wrong (left) and correct (right) font size.

A label which is created on a .NET server and displayed
  by a Flex client.
A label which is created on a .NET server and displayed by a Flex client. Left: the font size appears to be too small. Right: correct font size.

To overcome this problem, yFiles FLEX offers a correction mechanism. It can be enabled either at the client or at the server side.

Client side

Adjusting the size of a font which is created on a .NET server can be enabled by setting the RoundtripHandler's adjustFontSize property to true.

API Excerpt 6.1. RoundtripHandler's font size adjustment properties

// Whether to adjust the font size when serializing / deserializing fonts.
public function get adjustFontSize():Boolean
public function set adjustFontSize( value:Boolean ):void

Using a GraphMLIOHandler adjusting the font size can be enabled by setting the adjustFontSize property to true. It also allows to change the factor which is applied to the font size using the fontSizeFactor property. The default value is 0.75 which is appropriate for conversion between points and pixels.

API Excerpt 6.2. GraphMLIOHandler's font size adjustment properties

// Whether to adjust the font size when serializing / deserializing fonts.
public function get adjustFontSize():Boolean
public function set adjustFontSize( value:Boolean ):void

// The factor to adjust the font size when serializing / deserializing fonts.
public function get fontSizeFactor():Number
public function set fontSizeFactor( value:Number ):void

The RoundtripHandler sets the adjustFontSize properties of its inputIOHandler and outputIOHandler according to its own adjustFontSize property.

Server side

At the server side font size adjusting can be enabled by setting the AdjustFontSize property of the GraphRoundtripSupport to true. The factor which is applied to the font size can be changed using the FontSizeFactor property. The default value is 0.75 which is appropriate for conversion between points and pixels.

API Excerpt 6.3. GraphRoundtripSupport's font size adjustment properties

// Whether to adjust the font size when serializing / deserializing fonts.
public bool AdjustFontSize

// The factor to adjust the font size when serializing / deserializing fonts.
public double FontSizeFactor

To ensure backward compatibility, font size adjustment is disabled by default.

The font size adjustment has to be enabled either on the client or on the server. Setting adjustLabelSize to true on both the server and the client will lead to incorrect results.