/* * 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. */ import ilog.views.IlvManager; import ilog.views.IlvManagerView; import ilog.views.IlvPoint; import ilog.views.IlvRect; import ilog.views.graphic.IlvEllipse; import ilog.views.graphic.IlvRectangle; import ilog.views.graphic.IlvText; import ilog.views.graphic.composite.IlvCompositeGraphic; import ilog.views.graphic.composite.layout.IlvAttachmentConstraint; import ilog.views.graphic.composite.layout.IlvAttachmentLayout; import ilog.views.graphic.composite.layout.IlvAttachmentLocation; import ilog.views.graphic.composite.layout.IlvCenteredLayout; import ilog.views.graphic.composite.layout.IlvStackerLayout; import ilog.views.swing.IlvJScrollManagerView; //import ilog.views.util.IlvProductUtil; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Insets; import javax.swing.JFrame; import javax.swing.SwingConstants; import javax.swing.SwingUtilities; /** * Composite sample * * Creates a composite graphic consisting of several subgraphics, and displays * it in a manager view. */ public class Composite extends JFrame { IlvManager manager; IlvManagerView mgrview; public Composite() { // Create a composite graphic object IlvCompositeGraphic composite = new IlvCompositeGraphic(); // Create the attachment layout. IlvAttachmentLayout layout = new IlvAttachmentLayout(); composite.setLayout(layout); // Creates the first child IlvRectangle rectangle = new IlvRectangle(new IlvRect(100, 100, 40, 40), true, true); rectangle.setBackground(Color.blue); composite.setChildren(0, rectangle); // Creates a label IlvText text = new IlvText(); text.setLabel("Composite Graphic"); composite.setChildren(1, text); // Places the label below the rectangle composite.setConstraints(1, new IlvAttachmentConstraint( IlvAttachmentLocation.TopCenter, IlvAttachmentLocation.BottomCenter)); // Creates a stacker IlvCompositeGraphic rectangles = new IlvCompositeGraphic(); IlvStackerLayout stacker = new IlvStackerLayout(SwingConstants.RIGHT, SwingConstants.BOTTOM, 3); rectangles.setLayout(stacker); // Create three small rectangles hold in the stacker IlvRectangle r1 = new IlvRectangle(new IlvRect(0, 0, 5, 5), true, true); r1.setBackground(Color.red); rectangles.setChildren(0, r1); IlvRectangle r2 = new IlvRectangle(new IlvRect(0, 0, 5, 5), true, true); r2.setBackground(Color.yellow); rectangles.setChildren(1, r2); IlvRectangle r3 = new IlvRectangle(new IlvRect(0, 0, 5, 5), true, true); r3.setBackground(Color.green); rectangles.setChildren(2, r3); composite.setChildren(2, rectangles); composite.setConstraints(2, new IlvAttachmentConstraint( IlvAttachmentLocation.BottomLeft, IlvAttachmentLocation.TopRight)); // Creates a balloon, made of two graphics with a centered layout IlvCompositeGraphic balloon = new IlvCompositeGraphic(); IlvCenteredLayout centered = new IlvCenteredLayout(new Insets(5, 5, 5, 5)); balloon.setLayout(centered); // The outer graphic IlvEllipse ellipse = new IlvEllipse(); ellipse.setFillOn(true); ellipse.setBackground(Color.yellow); balloon.setChildren(0, ellipse); // The innner graphic IlvText balloonText = new IlvText(new IlvPoint(0, 0), "Balloon"); balloon.setChildren(1, balloonText); composite.setChildren(3, balloon); composite.setConstraints(3, new IlvAttachmentConstraint( IlvAttachmentLocation.BottomCenter, IlvAttachmentLocation.TopLeft)); // Creates the manager object manager = new IlvManager(); // Add the composite to the manager manager.addObject(composite, false); // Creates a view associated to the manager mgrview = new IlvManagerView(manager); mgrview.setAntialiasing(true); mgrview.setBackground(Color.white); // Creates the necessary swing components getContentPane().setLayout(new BorderLayout(0, 0)); getContentPane().add(new IlvJScrollManagerView(mgrview), BorderLayout.CENTER); } 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 Perforce JViews Diagrammer Deployment license. // IlvProductUtil.DeploymentLicenseRequired( // IlvProductUtil.JViews_Diagrammer_Deployment); // Sun recommends that to put the entire GUI initialization into the // AWT thread SwingUtilities.invokeLater( new Runnable() { Override public void run() { JFrame frame = new Composite(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(450, 350); frame.setVisible(true); } }); } }