Next steps after the Designer

This topic shows you how to adapt your component and data configuration by using the Java™ API.

Integrating the project file into an application

A project file created with the Designer includes styling and data source information. See Integrating your development into an application for more about project files and CSS style sheets.
The project file is used by an application through the IlvDiagrammer and IlvDiagrammerProject classes.
Typical Java code for including the project file in an application
IlvDiagrammer diagrammer = new IlvDiagrammer()
diagrammer.setProject (new IlvDiagrammerProject(new 
                            URL("file:myproject.idpr")), true);

Specifying a different data source

Once the project is loaded into the application, you can specify a data source other than the one contained by default in the project. This is an important feature, since the Designer is used with sample data that contains only enough information to specify the drawing style.
The following code example shows how to include a different data source.
Specifying a different data source
//Retrieve the project
IlvDiagrammer project = diagrammer.getProject();

//Create a new data source based on XML format
IlvXMLDataSource dataSource = new IlvXMLDataSource();
dataSource.setDataURL(new URL("file:example.xml"));

//Associate new data source with current project
project.setDataSource(datasource);

//Update the diagrammer object with the newly created
//project
diagrammer.setProject(project);

Customizing your application

At this stage, depending on your specific needs, there are several options you can consider for the architecture of your application:
  • Replace the default data source with your own classes to feed the data model.
    This option is easy to implement and provides the flexibility you need to accommodate your own type of data. The library contains default implementations for common data sources, such as XML or JDBC. For other requirements, you can create your own implementation.
  • Create your own data model and apply the specified style.
    This option is recommended for advanced users who need to reuse existing objects and minimize overhead. The library contains several implementations of commonly used data models. For advanced requirements, you can write your own implementation of the IlvSDMModel interface.
Developing with the JViews Diagrammer SDK presents these different concepts in detail and guides you through different options and steps.

Integrating the style sheets into an application

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:
  1. Make sure that the project style sheet is accessible from the application.
    The .css file must be accessible from the application.
  2. In the application, after creating the diagram and loading the data model, use the following code:
    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 on how to load style sheets.

Assigning one specific value to a specific text element of an IlvDiagrammer object

This section describes how to set a different value for the base text direction of a specific text element in an IlvDiagrammer object by using a parameter-based method. The example is based on a link style rule, but the principle is the same for any object contained in the diagram.
Important
Each text element has a graphic property called baseTextDirection. The value of this property should correspond to one of the existing constants defined for base text direction. By default, the baseTextDirection property is Inherited. It is mapped to the baseTextDirection style of the top-level IlvDiagrammer component. It cannot be changed in the Designer, but can be set programmatically at run time. All Text elements that are contained in the current IlvDiagrammer object can inherit this property. The keyword baseTextDirection cannot be used as a name of a parameter.
  1. In Style Rules, under link, define a new parameter for link:selected that will define the link subject to the dynamic change of base text direction at run time.
    In this example, the parameter is named myBaseTextDir; make sure that your parameter name is different from the graphic property name baseTextDirection.
  2. In the Styling Customizer, select Label.
  3. Right-click in the Base Text Direction field and select Enter an Expression.
  4. Associate the new parameter with Base Text Direction by entering it as an expression: @myBaseTextDir.
Expression
@myBaseTextDir set for style rule link:selected to associate parameter
myBaseTextDir with the value of the Base Text Direction field.
Creating a reference for setting base text direction dynamically at run time
The value of the parameter can be set dynamically at run time by the Java API. See Dynamically assigning one specific base text direction value to a specific text element for how to do this.