Diagrammer building based on flat files

Article ID: 2236
Last updated: 28 May, 2018
Article ID: 2236
Last updated: 28 May, 2018
Revision: 3
Views: 552
Posted: 23 Jun, 2010
by Dean J.
Updated: 28 May, 2018
by Gargani A.


Showing an SDM diagram using an XML file and a style sheet


This sample is a small application that starts an IlvSDMEngine shown on a frame, rendering the contents of an .xml file with the style stated in a .css file. The details of the data used by the application are as follows:

  • The diagram consists of two nodes with a link between them, defined in the file simple.xml
  • The style adds a link layout and color and is defined in the file simple.css
  • A select interactor is active, enabling nodes to be dragged.

To run the sample, put the files Main.java, simple.xml, and simple.css in the same folder. Then, compile and run the Main class with java Main.


import ilog.views.*;

import ilog.views.interactor.*;

import ilog.views.sdm.*;

import ilog.views.swing.*;

import java.io.*;

import javax.swing.*;

public class Main


public static void main(String args[]) throws IOException, IlvSDMException


// Create a window

JFrame window = new JFrame("Main");


window.setBounds(20, 20, 400, 300);

// Add an SDM engine with a select interactor to the window

IlvSDMEngine engine = new IlvSDMEngine();

IlvManagerView view = new IlvManagerView(engine.getGrapher());

view.setInteractor(new IlvSelectInteractor());

window.getContentPane().add(new IlvJScrollManagerView(view));

// Load the style sheet and the XML file

engine.setStyleSheets(new String[] { "file:simple.css" });


// Show the window





<?xml version="1.0" encoding="UTF-8"?>



<node id="node1">

<property name="label">Node 1</property>

<property name="x">50</property>

<property name="y">50</property>


<node id="node2">

<property name="label">Node 2</property>

<property name="x">150</property>

<property name="y">50</property>


<link islink="true" id="link1" from="node1" to="node2">

<property name="type">IN</property>





GraphLayout : "true";

LinkLayout : "true";


GraphLayout {

enabled : "false";


LinkLayout {

enabled : "true";

performingLayoutOnZoom : "true";


link {

class : ilog.views.sdm.graphic.IlvGeneralLink;

lineWidth : 4;

minimumLineWidth : 2;

maximumLineWidth : 8;

oriented : true;

foreground : "blue";


node {

class : ilog.views.sdm.graphic.IlvGeneralNode;

shapeType : Rectangle;

shapeWidth : 20;

borderWidth : 2;

fillColor1 : "gray";

foreground : "blue";

label : @label;


Note: In order to run this sample with JViews 8.7 and later, you must call the ilog.views.util.IlvProductUtil.DeploymentLicenseRequired method with the appropriate argument. See the General information > Deployment licenses > Declaring the use of IBM ILOG JViews services section in the documentation for more information.

This article was:   Helpful | Not helpful
Report an issue
Article ID: 2236
Last updated: 28 May, 2018
Revision: 3
Views: 552
Posted: 23 Jun, 2010 by Dean J.
Updated: 28 May, 2018 by Gargani A.
Attached files
item simple.xml (488 b) Download
item simple.css (582 b) Download

Also listed in

Others in this category