When you have saved your diagram in the Designer, you
have a project file that you can use to integrate the diagram into
an application.
You can integrate the complete diagram into an application
through the project file, or you can integrate only the style sheet
to have the styling developed in the Designer applied to real data
in an application.
You need to add the symbol palettes used in the diagram
to the classpath of the application, otherwise the symbols cannot
be found and the project file cannot be executed.
To integrate the genealogy project file into an application:
-
Create a diagram component.
-
See the following code sample which illustrates these
two steps. It shows you how to integrate the genealogy example in Java™
:
first you create a diagram component and then you load the project
file into it.
Loading a project file into a diagram component
...
IlvDiagrammer diagrammer = new IlvDiagrammer();
...
try {
// Load a project file.
//
diagrammer.setDataFile(new URL("file:data/mygenealogy.idpr"));
} catch (Exception e) {
e.printStackTrace();
}
...
The Designer makes it much easier to write the style
sheet. You can use the Designer for styling a sample of dummy data
or an XML dump of your data. Then you can integrate the style sheet
from the Designer into your application. You apply the styling defined
in the style sheet to the real data used in the application.
To integrate an existing style sheet into an application:
-
Make sure that the project style sheet is accessible
from the application.
The .css file must
be accessible from the application.
-
In the application, after creating the diagram and loading
the data model, use the following code:
Styling the Diagram Component
try {
diagram.setStyleSheets(new String[]{"..."});
} catch (IlvStylingException x) {
System.err.println("Cannot load style sheets: " + x.getMessage());
}
See
The style sheets in
Developing with the JViews Diagrammer SDK for
more information about how to load style sheets.