/*
* Licensed Materials - Property of Rogue Wave Software, Inc.
* © Copyright Rogue Wave Software, Inc. 2014, 2017
* © Copyright IBM Corp. 2009, 2014
* © Copyright ILOG 1996, 2009
* All Rights Reserved.
*
* Note to U.S. Government Users Restricted Rights:
* The Software and Documentation were developed at private expense and
* are "Commercial Items" as that term is defined at 48 CFR 2.101,
* consisting of "Commercial Computer Software" and
* "Commercial Computer Software Documentation", as such terms are
* used in 48 CFR 12.212 or 48 CFR 227.7202-1 through 227.7202-4,
* as applicable.
*/
import java.awt.BorderLayout;
import java.net.URL;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import ilog.views.diagrammer.IlvDiagrammer;
import ilog.views.diagrammer.application.IlvDiagrammerViewBar;
import ilog.views.util.IlvProductUtil;
/**
* This is a very simple application based on a diagram component,
* {@link ilog.views.diagrammer.IlvDiagrammer}.
* <p>
* This application displays a diagram component in a frame. A simple data file
* is loaded and displayed using a basic style sheet. A predefined toolbar is
* also used.
*/
public class BasicDiagrammerApplication extends JFrame {
// Create the main frame.
//
public BasicDiagrammerApplication() {
// Set up the frame.
//
super("Basic Diagrammer Application");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocation(100, 100);
setSize(450, 400);
// Create the IlvDiagrammer instance.
//
final IlvDiagrammer diagrammer = new IlvDiagrammer();
// Allow selection.
//
diagrammer.setSelectMode(true);
// Allow scrolling
diagrammer.setScrollable(true);
// Add the IlvDiagrammer instance.
//
getContentPane().setLayout(new BorderLayout());
getContentPane().add(diagrammer, BorderLayout.CENTER);
// Add a predefined toolbar for controlling the view
// at the north of the frame.
//
getContentPane().add(new IlvDiagrammerViewBar(), BorderLayout.NORTH);
SwingUtilities.invokeLater(new Runnable() {
Override
public void run() {
try {
// Load a simple project file.
//
diagrammer.setDataFile(new URL("file:data/molecule.idpr"));
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* The main method of the application.
*/
public static void main(String[] args) {
// This sample uses JViews Diagrammer features. When deploying an
// application that includes this code, you need to be in possession
// of a Rogue Wave JViews Diagrammer Deployment license.
IlvProductUtil.DeploymentLicenseRequired(IlvProductUtil.JViews_Diagrammer_Deployment);
SwingUtilities.invokeLater(new Runnable() {
Override
public void run() {
// Create an instance of the application, and
// show it.
//
new BasicDiagrammerApplication().setVisible(true);
}
});
}
}