In order to calculate label layouts on the server (either using integrated or generic labeling), some prerequisites have to be met:
If label mapping is enabled, the label layout data calculated by the layout
algorithm will be committed to the label data objects when the graph is
written back to the client. If the label has to be accessed/changed before
the graph is written back, but after the layout, this can be triggered manually
using
copyLabelLayouts(y.layout.LayoutGraph)
.
Label instances can be added on the server using
addLabel(y.base.Node, com.yworks.yfiles.server.graphml.flexio.data.Label)
and
addLabel(y.base.Edge, com.yworks.yfiles.server.graphml.flexio.data.Label)
,
or by adding the Label instances manually to the list of labels returned by
getLabels(y.base.Node)
and
getLabels(y.base.Edge)
.
When a label is added on the server, the layout graph is not automatically updated.
This shouldn't be a problem, as long as no label layout is calculated before sending
the graph back to the client. In order to synchronize the list of labels with
the layout graph, methods
syncLabels(y.base.Node, boolean)
and
syncLabels(y.base.Edge, boolean)
can be used.
Note that a reasonable preferred size should be set on the new labels before calling the synchronize methods. The synchronize methods don't try to calculate the label's size. If no preferred size is set, a default size (40,40) is used. If no preferred size is set and the synchronize methods are not used, the correct preferred size will be calculated on the client when the new label is parsed.
|
Copyright ©2007-2008, yWorks GmbH. All rights reserved. |