/* * Licensed Materials - Property of Perforce Software, Inc. * © Copyright Perforce Software, Inc. 2014, 2021 * © 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. */ // the Perforce JViews Diagrammer Framework // the Java AWT package import java.awt.Color; import java.awt.SystemColor; // The Java Net package import java.net.URL; // the Java Swing package import javax.swing.JFrame; import javax.swing.SwingUtilities; import ilog.views.diagrammer.IlvDiagrammer; import ilog.views.util.IlvProductUtil; /** * A very simple example for the use of a Label Layout Algorithm. It shows how * to use graph layout directly with a diagram component. It loads a CSS style * sheet that contains all layout parameters. The layout is fully specified in * this style sheet. */ public class Sample1 { public static final void main(String[] arg) { // This sample uses JViews Diagrammer features. When deploying an // application that includes this code, you need to be in possession // of a Perforce JViews Diagrammer Deployment license. IlvProductUtil.DeploymentLicenseRequired(IlvProductUtil.JViews_Diagrammer_Deployment); javax.swing.SwingUtilities.invokeLater(new Runnable() { Override public void run() { // Create the diagrammer component IlvDiagrammer diagrammer = new IlvDiagrammer(); // Change diagrammer parameters. diagrammer.setSelectMode(false); diagrammer.setScrollable(false); diagrammer.setEditingAllowed(true); diagrammer.getView().setBackground(Color.white); diagrammer.getView().setForeground(SystemColor.windowText); // The name of the XML file containing the model data final String xmlFileName = "data/Sample.xml"; // The name of the CSS file containing the style sheet final String cssFileName = "data/Sample.css"; // Load the sample data file and the style sheet. // Since layout is fully specified in the style sheet, loading the style // sheet performs the layout. try { diagrammer.setDataFile(new URL("file:" + xmlFileName)); diagrammer.setStyleSheet(new URL("file:" + cssFileName)); } catch (Exception e) { System.out.println("could not read " + xmlFileName); return; } // A Swing Frame to display final JFrame frame = new JFrame("Layout Sample"); // EXIT_ON_CLOSE is not defined in jdk1.2, hence this way: frame.setDefaultCloseOperation(3 /* EXIT_ON_CLOSE, >= jdk1.2.2 */); // Put the manager view inside the Swing Frame frame.getContentPane().add(diagrammer); // and show it. Since JDK 1.4, Sun recommends to do it this way: SwingUtilities.invokeLater(new Runnable() { Override public void run() { frame.setSize(600, 600); frame.setVisible(true); } }); } }); } }