ilog.views.diagrammer.application
Class IlvDiagrammerApplication

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Panel
              extended by java.applet.Applet
                  extended by javax.swing.JApplet
                      extended by ilog.views.diagrammer.application.IlvDiagrammerApplication
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer

public class IlvDiagrammerApplication
extends JApplet

IlvDiagrammerApplication is a ready-to-use Swing application based on the diagram component, IlvDiagrammer, and built using the other components of this package.

The Diagrammer application can be used to view Diagrammer data files. It also has an editing mode for modifying diagrams.

The Diagrammer application contains:

The tree, property sheet and overview panels are displayed inside JSplitPanes and JTabbedPanes on the leading side of the working area.

The application accepts the following command-line arguments:

Example::

   java ilog.views.diagrammer.application.IlvDiagrammerApplication -mdi -edit -data file:/c/examples/mydata.xml -style file:/c/examples/mystyle.css
 

The Diagrammer application can be used as an applet. In this case, the arguments are passed as applet parameters, without the initial '-' character, and the value is "true" (or "on", or "yes") for Boolean arguments.

Example::

 <applet archive="jviews-diagrammer.jar,..."
         code="ilog.views.diagrammer.application.IlvDiagrammerApplication"
         width="600" height="500">
   <param name="mdi" value="true"/>
   <param name="edit" value="true"/>
   <param name="data" value="file:/c/examples/mydata.xml"/>
   <param style="data" value="file:/c/examples/mystyle.xml"/>
 </applet>
 

For an applet, an additional Boolean argument frame can be used to create the GUI for the Diagrammer application in an independent JFrame.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JApplet
JApplet.AccessibleJApplet
 
Nested classes/interfaces inherited from class java.applet.Applet
Applet.AccessibleApplet
 
Nested classes/interfaces inherited from class java.awt.Panel
Panel.AccessibleAWTPanel
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JApplet
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
IlvDiagrammerApplication()
          Creates the application with the default resource bundle "ilog.views.diagrammer.application.application" and with no default command-line arguments.
IlvDiagrammerApplication(ResourceBundle bundle, String[] defaultArgs)
          Creates the application with the specified resource bundle.
IlvDiagrammerApplication(String[] defaultArgs)
          Creates the application with the default resource bundle "ilog.views.diagrammer.application.application".
 
Method Summary
protected  IlvDiagrammer createDiagrammer()
          Creates a new diagram component.
 JFrame createFrame()
          Creates the frame of this application.
protected  JToolBar[] createPaletteToolBars()
          Creates the palette toolbar(s) for this application.
protected  IlvDiagrammerStatusBar createStatusBar()
          Creates the status bar for this application.
 void destroy()
          Called when this class is run as an applet, when the applet is destroyed.
 void error(ResourceBundle bundle, String messageKey, Object[] args, Throwable t)
          Displays an error message.
protected  void exit()
          Exits this application.
 Container getApplicationContentPane()
          Returns the container of the application or applet, that is, the container that was passed as the contentPane argument to the init(java.awt.Container) method.
 URL getBaseURL()
          Returns a URL that can be used to resolve relative URLs for loading data files.
 ResourceBundle getBundle()
          Returns the resource bundle used to get localized messages for this application.
 IlvDiagrammer getCurrentDiagrammer()
          Returns the currently active diagram component.
 JDesktopPane getDesktopPane()
          Returns the desktop pane of this application if it is in multidocument (MDI) mode, or null if it is in single-document (SDI) mode.
 IlvDiagrammer[] getDiagrammers()
          Returns all the diagram components displayed by the application.
 IlvDiagrammerToolBar getEditToolBar()
          Returns the edit toolbar.
 IlvDiagrammerMenuBar getMenuBar()
          Returns the menu bar.
 IlvDiagrammerOverview getOverview()
          Returns the overview component.
 JToolBar[] getPaletteToolBars()
          Returns the palette toolbars.
 IlvDiagrammerPropertySheet getPropertySheet()
          Returns the property sheet.
 JPanel getSdiContainer()
          Returns the container of the (single) diagram component when this application is in single-document (SDI) mode.
 IlvDiagrammer getSdiDiagrammer()
          Returns the (single) diagram component when this application is in single-document (SDI) mode.
 IlvDiagrammerStatusBar getStatusBar()
          Returns the status bar.
 URL getStyleSheetURL()
          Returns the default style sheet used by this application.
 IlvDiagrammerTable getTable()
          Returns the table component.
 IlvDiagrammerTree getTree()
          Returns the tree component.
 IlvDiagrammerToolBar getViewToolBar()
          Returns the view toolbar.
 void init()
          Called when this class is run as an applet.
 void init(Container contentPane)
          This method is called both when the class is run as an application and when it is run as an applet.
 void init(String[] args)
          This method initializes a new instance of this class when it is run as an application.
 boolean isApplet()
          Returns true if this class is run as an applet.
 boolean isEditMode()
          Returns true if the application is in editing mode.
 boolean isFloatable()
          Decides if the tool bars are floatable or not.
 boolean isJnlp()
          Returns true if this class is run with JNLP.
 boolean isMdi()
          Returns true if the application is in multidocument (MDI) mode.
 boolean isOverviewVisible()
          Returns true if the overview is visible.
 boolean isPropertySheetVisible()
          Returns true if the property sheet is visible.
 boolean isTableVisible()
          Returns true if the table is visible.
 boolean isTreeVisible()
          Returns true if the tree is visible.
 boolean isUseAutomaticWaitCursor()
          Tests if the wait cursor is shown automatically.
static void main(String[] args)
          The main method of the application.
protected  IlvDiagrammer newDiagram()
          Creates a new diagram component in the application.
 void parseArgs(String[] args)
          Parses the command-line arguments.
protected  void ready()
          This method is called when the GUI is set up, after the application is made displayable.
 void setDefaultArgs(String[] defaultArgs)
          Sets the default command-line arguments.
 void setOverviewVisible(boolean visible)
          Shows or hides the overview.
 void setPropertySheetVisible(boolean visible)
          Shows or hides the property sheet.
 void setStyleSheetURL(URL styleSheetURL)
          Changes the default style sheet used by this application.
 void setTableVisible(boolean visible)
          Shows or hides the table.
 void setTreeVisible(boolean visible)
          Shows or hides the tree.
 void setUseAutomaticWaitCursor(boolean flag)
          Sets whether the wait cursor is displayed as soon as a mouse click causes any action that needs a runtime of more than 100 ms.
 void start()
          Called when this class is run as an applet, when the applet is started.
 void stop()
          Called when this class is run as an applet, when the applet is stopped.
 
Methods inherited from class javax.swing.JApplet
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, remove, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.applet.Applet
getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IlvDiagrammerApplication

public IlvDiagrammerApplication(ResourceBundle bundle,
                                String[] defaultArgs)
Creates the application with the specified resource bundle.

Parameters:
bundle - The resource bundle to use instead of the default resource bundle.
defaultArgs - You can pass default command-line arguments that will be used if they are not overridden on the command line or in the HTML element for the applet. For example, you can pass "-tree -psheet -edit" to start in editing mode with the tree and the property sheet visible.

IlvDiagrammerApplication

public IlvDiagrammerApplication(String[] defaultArgs)
Creates the application with the default resource bundle "ilog.views.diagrammer.application.application".

Parameters:
defaultArgs - You can pass default command-line arguments that will be used if they are not overridden on the command line or in the HTML element for the applet. For example, you can pass "-tree -psheet -edit" to start in editing mode with the tree and the property sheet visible.

IlvDiagrammerApplication

public IlvDiagrammerApplication()
Creates the application with the default resource bundle "ilog.views.diagrammer.application.application" and with no default command-line arguments. Note that you can set the default arguments later using the setDefaultArgs(java.lang.String[]) method.

Method Detail

main

public static void main(String[] args)
The main method of the application.

Parameters:
args - The command-line arguments.

getBundle

public ResourceBundle getBundle()
Returns the resource bundle used to get localized messages for this application.

Returns:
resource bundle

getDesktopPane

public JDesktopPane getDesktopPane()
Returns the desktop pane of this application if it is in multidocument (MDI) mode, or null if it is in single-document (SDI) mode.

Returns:
desktop pane

isEditMode

public boolean isEditMode()
Returns true if the application is in editing mode.

Returns:
true if edit mode

isMdi

public boolean isMdi()
Returns true if the application is in multidocument (MDI) mode.

Returns:
true if MDI

getMenuBar

public IlvDiagrammerMenuBar getMenuBar()
Returns the menu bar.

Returns:
menu bar

getPaletteToolBars

public JToolBar[] getPaletteToolBars()
Returns the palette toolbars.

Returns:
palette toolbar

getEditToolBar

public IlvDiagrammerToolBar getEditToolBar()
Returns the edit toolbar.

Returns:
edit toolbar

getViewToolBar

public IlvDiagrammerToolBar getViewToolBar()
Returns the view toolbar.

Returns:
view toolbar

getStatusBar

public IlvDiagrammerStatusBar getStatusBar()
Returns the status bar.

Returns:
status bar

getSdiContainer

public JPanel getSdiContainer()
Returns the container of the (single) diagram component when this application is in single-document (SDI) mode.

Returns:
panel

getSdiDiagrammer

public IlvDiagrammer getSdiDiagrammer()
Returns the (single) diagram component when this application is in single-document (SDI) mode.

Returns:
diagrammer

getStyleSheetURL

public URL getStyleSheetURL()
Returns the default style sheet used by this application.

Returns:
style sheet URL

setStyleSheetURL

public void setStyleSheetURL(URL styleSheetURL)
Changes the default style sheet used by this application.

Parameters:
styleSheetURL - the new style sheet

getTable

public IlvDiagrammerTable getTable()
Returns the table component.

Returns:
table component

getTree

public IlvDiagrammerTree getTree()
Returns the tree component.

Returns:
diagrammer tree

getOverview

public IlvDiagrammerOverview getOverview()
Returns the overview component.

Returns:
overview

getPropertySheet

public IlvDiagrammerPropertySheet getPropertySheet()
Returns the property sheet.

Returns:
property sheet

setTreeVisible

public void setTreeVisible(boolean visible)
Shows or hides the tree.

Parameters:
visible - new value

isTreeVisible

public boolean isTreeVisible()
Returns true if the tree is visible.

Returns:
true if tree is visible

setPropertySheetVisible

public void setPropertySheetVisible(boolean visible)
Shows or hides the property sheet.

Parameters:
visible - new value

isPropertySheetVisible

public boolean isPropertySheetVisible()
Returns true if the property sheet is visible.

Returns:
true if tree is visible

setOverviewVisible

public void setOverviewVisible(boolean visible)
Shows or hides the overview.

Parameters:
visible - new value

isOverviewVisible

public boolean isOverviewVisible()
Returns true if the overview is visible.

Returns:
true if tree is visible

setTableVisible

public void setTableVisible(boolean visible)
Shows or hides the table.

Parameters:
visible - new value

isTableVisible

public boolean isTableVisible()
Returns true if the table is visible.

Returns:
true if tree is visible

getCurrentDiagrammer

public IlvDiagrammer getCurrentDiagrammer()
Returns the currently active diagram component. If the application is in multidocument (MDI) mode and all frames have been closed, the method returns null.

Returns:
diagrammer

getDiagrammers

public IlvDiagrammer[] getDiagrammers()
Returns all the diagram components displayed by the application. If the application is in multidocument (MDI) mode and all frames have been closed, the returned array will be of size 0. If the application is in single-document (SDI) mode, the returned array will be of size 1.

Returns:
diagrammers

setDefaultArgs

public void setDefaultArgs(String[] defaultArgs)
Sets the default command-line arguments. These values will be used if they are not overridden on the command line or in the HTML element for the applet. For example, you can pass "-tree -psheet -edit" to start in editing mode with the tree and the property sheet visible.

Note that this method can be called only before the application is initialized, that is, before its init(java.awt.Container) method is called. Typically, you will write a subclass and set the default arguments in the constructor. If this method is called after init(java.awt.Container) has been called, an exception is thrown.

Parameters:
defaultArgs - The default command-line arguments.

init

public void init(String[] args)
This method initializes a new instance of this class when it is run as an application. The method parses the command-line arguments, creates a frame, and calls the init(java.awt.Container) method.

This method is typically called from the main method when this class is derived:

 public class MyDiagrammerApplication extends IlvDiagrammerApplication
 {
   public static void main(String[] args)
   {
     new MyDiagrammerApplication().init(args);
   }
 }
 

Parameters:
args - The command-line arguments passed to the main method.

init

public void init()
Called when this class is run as an applet.

Overrides:
init in class Applet

isApplet

public boolean isApplet()
Returns true if this class is run as an applet.

Returns:
true if applet

isJnlp

public boolean isJnlp()
Returns true if this class is run with JNLP.

Returns:
true if run with java web start

start

public void start()
Called when this class is run as an applet, when the applet is started.

Overrides:
start in class Applet

stop

public void stop()
Called when this class is run as an applet, when the applet is stopped.

Overrides:
stop in class Applet

destroy

public void destroy()
Called when this class is run as an applet, when the applet is destroyed.

Overrides:
destroy in class Applet

parseArgs

public void parseArgs(String[] args)
Parses the command-line arguments.

Parameters:
args - The command-line arguments. If null, the class is assumed to be run as an applet, and the arguments will be read by calling the getParameter method of the applet.

getBaseURL

public URL getBaseURL()
               throws MalformedURLException
Returns a URL that can be used to resolve relative URLs for loading data files. If the class is run as an applet, the base URL is the document base URL of the applet. If the class is run as an application, the base URL is the URL of the current directory.

Returns:
base URL
Throws:
MalformedURLException

createFrame

public JFrame createFrame()
Creates the frame of this application.

Returns:
a new JFrame.

init

public void init(Container contentPane)
This method is called both when the class is run as an application and when it is run as an applet. This is where the GUI for the application is created, and this is the method that you must override if you want to modify the GUI.

For an applet, this method is called from init(). For an application, it is called from init(java.lang.String[]), which is itself called from main(java.lang.String[]).

Parameters:
contentPane - The panel in which the GUI will be created.

isUseAutomaticWaitCursor

public boolean isUseAutomaticWaitCursor()
Tests if the wait cursor is shown automatically.

Returns:
If the wait cursor is shown automatically as soon as a mouse click causes any action that needs a runtime of more than 100 ms, true is returned.
Since:
JViews 8.1

setUseAutomaticWaitCursor

public void setUseAutomaticWaitCursor(boolean flag)
Sets whether the wait cursor is displayed as soon as a mouse click causes any action that needs a runtime of more than 100 ms.

This method activates the wait cursor mechanism via the event dispatch loop, hence the automatic wait cursor becomes effective with some delay. If modal dialogs are still open while this method is called, the effect will only be visible after all model dialogs are closed.

Parameters:
flag - Set to true so the wait cursor is displayed automatically. The default value is true.
Since:
JViews 8.1

isFloatable

public boolean isFloatable()
Decides if the tool bars are floatable or not.

Returns:
true if the tool bars are floatable.

getApplicationContentPane

public Container getApplicationContentPane()
Returns the container of the application or applet, that is, the container that was passed as the contentPane argument to the init(java.awt.Container) method.

Returns:
content pane

ready

protected void ready()
This method is called when the GUI is set up, after the application is made displayable. By default, it shows the tree, property sheet, and overview if requested, and activates the initial diagram component.


createPaletteToolBars

protected JToolBar[] createPaletteToolBars()
                                    throws Exception
Creates the palette toolbar(s) for this application.

The default implementation creates one IlvDiagrammerPaletteBar whose contents are specified by the paletteURL command-line (or applet) parameter.

Subclasses can override this method to create more palette toolbars if necessary.

Returns:
toolbars
Throws:
Exception - If an error occurred while loading a toolbar.

createStatusBar

protected IlvDiagrammerStatusBar createStatusBar()
Creates the status bar for this application.

Returns:
status bar

newDiagram

protected IlvDiagrammer newDiagram()
Creates a new diagram component in the application. In single-document mode, this method removes the current diagram component and replaces it by a new one. In multi-document mode, this method creates a new internal frame in the desktop manager.

This method can be overridden if you need to perform custom operations when a new diagram is created. If you need to create an instance of a subclass of IlvDiagrammer, you should override createDiagrammer() instead.

Returns:
The new diagram component or null if the new diagram component was not created (this can happen in single-document mode if the diagram has been modified but the user clicked "No" in the confirmation box).

createDiagrammer

protected IlvDiagrammer createDiagrammer()
Creates a new diagram component. This method is called by newDiagram(). It can be overridden if you need to use a subclass of IlvDiagrammer. The default implementation returns new IlvDiagrammer().

Returns:
a new instance of IlvDiagrammer.

exit

protected void exit()
Exits this application. The default implementation checks whether any diagram has been modified, and requests confirmation for exiting. If the class is running as an applet, and it runs in a separate frame (frame parameter set to true), the frame is closed and the applet is stopped. If the class is running as an application, this method calls System.exit(0).


error

public void error(ResourceBundle bundle,
                  String messageKey,
                  Object[] args,
                  Throwable t)
Displays an error message.

Parameters:
bundle - The set of resources used for localized messages.
messageKey - The message key, retrieved from the application's resource bundle.
args - The message arguments, if the message needs formatting.
t - The Thro