DroidDiagram Programmer's Guide
DiagramAdapter.serializeControl Method
See Also
 






Lets you save the attributes of controls hosted inside ControlNode objects.

Namespace: com.mindfusion.diagramming
Package: com.mindfusion.diagramming

 Syntax

Java  Copy Code

public void serializeControl (
    ControlNodeEvent e
)

 Parameters

e

A ControlNodeEvent instance providing more information about the event.

 Remarks

By default, the diagram component saves and loads hosted controls by getting or setting their property values via the Java introspection API. If the default mechanism cannot serialize the content of nodes automatically, the serializeControl and deserializeControl events can be handled to implement custom serialization.

 Example

Java  Copy Code
diagram.addDiagramListener(new DiagramAdapter() {
    @Override
    public void serializeControl(ControlNodeEvent e)
    {
        JButton button = (JButton)e.getNode().getControl();
        e.getContext().writeString(button.getText(), "Text", e.getXmlElement());
        e.setHandled(true);
    };
 
    @Override
    public void deserializeControl(ControlNodeEvent e)
    {
        JButton button = new JButton();
        try
        {
            button.setText(e.getContext().readString("Text", e.getXmlElement()));
        }
        catch (TransformerException ex)
        {
            ex.printStackTrace();
        }
        e.getNode().setControl(button);
        e.setHandled(true);
    };
}

 See Also

DiagramAdapter Members
DiagramAdapter Class
com.mindfusion.diagramming Namespace