jcreek.cke.browser
Class Visualizer

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Window
              extended byjava.awt.Frame
                  extended byjavax.swing.JFrame
                      extended byjcreek.cke.browser.Visualizer
All Implemented Interfaces:
javax.accessibility.Accessible, java.util.EventListener, java.awt.image.ImageObserver, javax.swing.event.InternalFrameListener, java.awt.MenuContainer, javax.swing.RootPaneContainer, java.io.Serializable, javax.swing.WindowConstants, java.awt.event.WindowListener

public class Visualizer
extends javax.swing.JFrame
implements javax.swing.event.InternalFrameListener, java.awt.event.WindowListener

This class implements that main window of the application. There is typically only one of these in each session. It acts as a window listener for the internal windows it creates, notifying the document group when windows are closed and when they are activated.

Version:
Author:
See Also:
Serialized Form

Nested Class Summary
protected  class Visualizer.ActionChangedListener
          Watches for changes in actions and deals with them by changing the corresponding menu items or toolbar buttons.
 
Nested classes inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Nested classes inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static java.lang.String accelSuffix
          Suffix added to command strings to find accelerator.
protected  javax.swing.JPanel content
           
protected  int divLocation
           
protected  javax.swing.JDesktopPane dtp
          Holds all the internal windows within the main window.
protected  EntityList findEnt
           
protected  FrameProperty frameProperty
           
protected  FrameView fView
           
static java.lang.String imageSuffix
          Suffix added to command strings to find images.
protected  boolean isPropVisible
           
static java.lang.String labelSuffix
          Suffix added to command strings to find labels.
static java.lang.String memSuffix
          Suffix added to command strings to find mnemonics.
protected  jcreek.cke.browser.MousePositionIndicator mpi
          Indicates the position of the mouse over a canvas.
protected  PropertyControl pc
           
protected  java.lang.String propKey
           
protected  javax.swing.JPanel propPane
           
protected  javax.swing.JInternalFrame propWin
           
protected  StatusBar sb
          Common Area to hold Standard components or display Status Messages
protected  SideBar sideBar
           
protected  javax.swing.JScrollPane sPane
           
protected  javax.swing.JSplitPane splitter
           
static java.lang.String tipSuffix
          Suffix added to command strings to find tooltips.
static java.lang.String titleSuffix
          Suffix added to command strings to find title.
protected  jcreek.cke.browser.ToolManager toolMan
          Our window's tool manager.
 javax.swing.JInternalFrame toolWin
           
protected  TreeView treeView
          Holds a tree view of all the available views It allows to switch between the different views
protected  jcreek.cke.browser.ViewMenu viewMenu
           
protected  jcreek.cke.browser.WindowMenu winMenu
          Holds the names of the internal windows.
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Visualizer(java.lang.String title)
          Creates a new Visualizer object and puts up the main window.
 
Method Summary
 void activateWin(CreekDocument doc)
           
 void centerComponent(java.awt.Component c)
          Takes a component and centers it within the main window.
 void closePropertyWindow()
           
 void closeWindow()
          Closes the current window.
 void closeWindow(javax.swing.JInternalFrame fr)
           
protected  javax.swing.JMenuItem createCheckBoxMenuItem(java.lang.String cmd)
           
protected  javax.swing.JMenu createMenu(java.lang.String key)
          Create a menu for the app.
protected  javax.swing.JMenuBar createMenubar()
          Create the menubar for the app.
protected  javax.swing.JMenuItem createMenuItem(java.lang.String cmd)
          This is the hook through which all menu items are created.
protected  void createProps()
           
protected  javax.swing.JRadioButtonMenuItem createRadioButtonMenuItem(java.lang.String cmd)
           
protected  javax.swing.JToolBar createToolbar()
          Create the toolbar.
protected  javax.swing.JButton createToolbarButton(java.lang.String key)
          Create a button to go inside of the toolbar.
 void detach()
          Remove ourselves (and all our components) from any lists we might be one.
 void displayPropertyWindow(Entity selEntity)
           
protected  javax.swing.JInternalFrame findSelected()
          Finds the selected frame and returns a reference to it.
 CreekTool getCurrentTool()
          Returns the currently selected graph tool for this window.
protected  CreekDocument getDocument(javax.swing.JInternalFrame fr)
          Retrieves the document attached to the given frame.
 CreekDocument[] getDocuments()
          Retrieves all the open documents attached to this main window.
static Visualizer getFrame(java.awt.Component child)
          Find the hosting frame for this component.
 FrameView getFrameView()
           
static javax.swing.JInternalFrame getInternalFrame(java.awt.Component child)
           
 PropertyControl getPropertyControl()
           
 java.awt.Container getPropertyWindow()
           
 CreekDocument getSelContext()
           
 javax.swing.JInternalFrame getWin(CreekDocument doc)
          Retrieves the InternalFrame attached to the given document.
 void internalFrameActivated(javax.swing.event.InternalFrameEvent e)
          Use this notification to tell the document group which view is currently active.
 void internalFrameClosed(javax.swing.event.InternalFrameEvent e)
          We ignore this event.
 void internalFrameClosing(javax.swing.event.InternalFrameEvent e)
          Use this opportunity to save the document associated with this window.
 void internalFrameDeactivated(javax.swing.event.InternalFrameEvent e)
          Use this notification to tell the document group that there's no current document.
 void internalFrameDeiconified(javax.swing.event.InternalFrameEvent e)
          We ignore this event.
 void internalFrameIconified(javax.swing.event.InternalFrameEvent e)
          We ignore this event.
 void internalFrameOpened(javax.swing.event.InternalFrameEvent e)
          We ignore this event.
 boolean isShowing(java.lang.String key)
           
 void newEntityWindow(java.lang.String title)
           
 void newFrameWin(java.lang.String title)
           
 void newToolWindow(java.lang.String title)
           
 void newViewWindow(java.lang.String title)
           
 ConceptView newWindow(java.lang.String title)
          Create a new internal window and set its title to the passed argument.
 void registerWindow(javax.swing.JInternalFrame frame)
           
 void renameWindow(java.lang.String name)
          Renames the currently selected window to the given name.
 void show(java.lang.String key)
           
 void windowActivated(java.awt.event.WindowEvent e)
          Invoked when the window is set to be the user's active window, which means the window (or one of its subcomponents) will receive keyboard events.
 void windowClosed(java.awt.event.WindowEvent e)
          Invoked when a window has been closed.
 void windowClosing(java.awt.event.WindowEvent e)
          Invoked when a window is in the process of being closed.
 void windowDeactivated(java.awt.event.WindowEvent e)
          Invoked when a window is de-activated.
 void windowDeiconified(java.awt.event.WindowEvent e)
          Invoked when a window is de-iconified.
 void windowIconified(java.awt.event.WindowEvent e)
          Invoked when a window is iconified.
 void windowOpened(java.awt.event.WindowEvent e)
          Invoked when a window has been opened.
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setIconImage, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

sb

protected StatusBar sb
Common Area to hold Standard components or display Status Messages


pc

protected PropertyControl pc

propWin

protected javax.swing.JInternalFrame propWin

mpi

protected jcreek.cke.browser.MousePositionIndicator mpi
Indicates the position of the mouse over a canvas.


dtp

protected javax.swing.JDesktopPane dtp
Holds all the internal windows within the main window.


findEnt

protected EntityList findEnt

treeView

protected TreeView treeView
Holds a tree view of all the available views It allows to switch between the different views


fView

protected FrameView fView

toolWin

public javax.swing.JInternalFrame toolWin

winMenu

protected jcreek.cke.browser.WindowMenu winMenu
Holds the names of the internal windows. Allows switching between available document windows.


viewMenu

protected jcreek.cke.browser.ViewMenu viewMenu

toolMan

protected jcreek.cke.browser.ToolManager toolMan
Our window's tool manager. Builds and manages the tools.


imageSuffix

public static java.lang.String imageSuffix
Suffix added to command strings to find images.


labelSuffix

public static java.lang.String labelSuffix
Suffix added to command strings to find labels.


tipSuffix

public static java.lang.String tipSuffix
Suffix added to command strings to find tooltips.


memSuffix

public static java.lang.String memSuffix
Suffix added to command strings to find mnemonics.


accelSuffix

public static java.lang.String accelSuffix
Suffix added to command strings to find accelerator.


titleSuffix

public static java.lang.String titleSuffix
Suffix added to command strings to find title.


sPane

protected javax.swing.JScrollPane sPane

splitter

protected javax.swing.JSplitPane splitter

propPane

protected javax.swing.JPanel propPane

content

protected javax.swing.JPanel content

sideBar

protected SideBar sideBar

divLocation

protected int divLocation

isPropVisible

protected boolean isPropVisible

propKey

protected java.lang.String propKey

frameProperty

protected FrameProperty frameProperty
Constructor Detail

Visualizer

public Visualizer(java.lang.String title)
Creates a new Visualizer object and puts up the main window. Also creates a window listener to close the program when the close button is activated.

Parameters:
title - title for the main window
Method Detail

centerComponent

public void centerComponent(java.awt.Component c)
Takes a component and centers it within the main window. Usually used for displaying child dialogs.

Parameters:
c - component to be centered

closeWindow

public void closeWindow()
Closes the current window. This will remove the window from the desktop pane.


closeWindow

public void closeWindow(javax.swing.JInternalFrame fr)

createMenu

protected javax.swing.JMenu createMenu(java.lang.String key)
Create a menu for the app. By default this pulls the definition of the menu from the associated resource file.

Parameters:
key - menu key in resource bundle
Returns:
menu built out

createMenubar

protected javax.swing.JMenuBar createMenubar()
Create the menubar for the app. By default this pulls the definition of the menu from the associated resource file.

Returns:
menu bar with menus built out

createMenuItem

protected javax.swing.JMenuItem createMenuItem(java.lang.String cmd)
This is the hook through which all menu items are created. Using the cmd string it finds the menu item label and image (if any) in the resource bundle.

Parameters:
cmd - action command string for this menu item; used to get the label and image
Returns:
new menu item
See Also:
createMenu(java.lang.String)

createCheckBoxMenuItem

protected javax.swing.JMenuItem createCheckBoxMenuItem(java.lang.String cmd)

createRadioButtonMenuItem

protected javax.swing.JRadioButtonMenuItem createRadioButtonMenuItem(java.lang.String cmd)

createToolbar

protected javax.swing.JToolBar createToolbar()
Create the toolbar. By default this reads the resource file for the definition of the toolbar.

Returns:
new toolbar built out

createToolbarButton

protected javax.swing.JButton createToolbarButton(java.lang.String key)
Create a button to go inside of the toolbar. By default this will load an image resource. The image filename is relative to the classpath (including the '.' directory if its a part of the classpath), and may either be in a JAR file or a separate file.

Parameters:
key - key in resource bundle for tool
Returns:
new toolbar button

detach

public void detach()
Remove ourselves (and all our components) from any lists we might be one.


findSelected

protected javax.swing.JInternalFrame findSelected()
Finds the selected frame and returns a reference to it.

NOTE: We use this instead of simply tracking the active window via the internal frame listener because renameWindow() might be called just after a new window is created and that new window is not set active yet because the listener hasn't yet been notified.

Returns:
reference to currently selected frame, or null

getCurrentTool

public CreekTool getCurrentTool()
Returns the currently selected graph tool for this window.

Returns:
currently selected GraphTool object

getDocument

protected CreekDocument getDocument(javax.swing.JInternalFrame fr)
Retrieves the document attached to the given frame.

Parameters:
fr - internal frame
Returns:
document attached to internal frame

getWin

public javax.swing.JInternalFrame getWin(CreekDocument doc)
Retrieves the InternalFrame attached to the given document.

Parameters:
doc - CreekDocument attached to the frame
Returns:
JInternalFrame attached to the document

activateWin

public void activateWin(CreekDocument doc)

getDocuments

public CreekDocument[] getDocuments()
Retrieves all the open documents attached to this main window.

Returns:
array of graph document objects

getFrame

public static Visualizer getFrame(java.awt.Component child)
Find the hosting frame for this component. Often used when displaying dialogs which require a host frame.

Parameters:
child - component to find parent frame for
Returns:
hosting frame or null if none

getInternalFrame

public static javax.swing.JInternalFrame getInternalFrame(java.awt.Component child)

internalFrameActivated

public void internalFrameActivated(javax.swing.event.InternalFrameEvent e)
Use this notification to tell the document group which view is currently active.

Specified by:
internalFrameActivated in interface javax.swing.event.InternalFrameListener
Parameters:
e - internal frame event

internalFrameClosed

public void internalFrameClosed(javax.swing.event.InternalFrameEvent e)
We ignore this event.

Specified by:
internalFrameClosed in interface javax.swing.event.InternalFrameListener
Parameters:
e - internal frame event

internalFrameClosing

public void internalFrameClosing(javax.swing.event.InternalFrameEvent e)
Use this opportunity to save the document associated with this window. We can receive this message for a window that is not currently selected. Because of this, we need to get the document associated with this window and save it, not just save the current document in the document group. And by going through the file menu, we give the user the chance to not save the file.

Specified by:
internalFrameClosing in interface javax.swing.event.InternalFrameListener
Parameters:
e - internal frame event

internalFrameDeactivated

public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent e)
Use this notification to tell the document group that there's no current document. Hopefully another window will be activated soon and the current document will be set to that.

Specified by:
internalFrameDeactivated in interface javax.swing.event.InternalFrameListener
Parameters:
e - internal frame event

internalFrameDeiconified

public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent e)
We ignore this event.

Specified by:
internalFrameDeiconified in interface javax.swing.event.InternalFrameListener
Parameters:
e - internal frame event

internalFrameIconified

public void internalFrameIconified(javax.swing.event.InternalFrameEvent e)
We ignore this event.

Specified by:
internalFrameIconified in interface javax.swing.event.InternalFrameListener
Parameters:
e - internal frame event

internalFrameOpened

public void internalFrameOpened(javax.swing.event.InternalFrameEvent e)
We ignore this event.

Specified by:
internalFrameOpened in interface javax.swing.event.InternalFrameListener
Parameters:
e - internal frame event

newWindow

public ConceptView newWindow(java.lang.String title)
Create a new internal window and set its title to the passed argument. The window is given a default size and position. The window is also set selected. This also causes the window menu to update itself.

Parameters:
title - title to give new internal window
Returns:
reference to new view object inside window

getPropertyWindow

public java.awt.Container getPropertyWindow()

registerWindow

public void registerWindow(javax.swing.JInternalFrame frame)

getPropertyControl

public PropertyControl getPropertyControl()

getFrameView

public FrameView getFrameView()

displayPropertyWindow

public void displayPropertyWindow(Entity selEntity)

closePropertyWindow

public void closePropertyWindow()

newViewWindow

public void newViewWindow(java.lang.String title)

getSelContext

public CreekDocument getSelContext()

newEntityWindow

public void newEntityWindow(java.lang.String title)

newToolWindow

public void newToolWindow(java.lang.String title)

newFrameWin

public void newFrameWin(java.lang.String title)

renameWindow

public void renameWindow(java.lang.String name)
Renames the currently selected window to the given name.

Parameters:
name - new name to give to current window

windowActivated

public void windowActivated(java.awt.event.WindowEvent e)
Invoked when the window is set to be the user's active window, which means the window (or one of its subcomponents) will receive keyboard events.

We use this event to make sure that our selected internal frame's document is set as the current document. Otherwise unpredictable bad things could happen (with having multiple current documents, there could be two graph tools attached to the same document).

Specified by:
windowActivated in interface java.awt.event.WindowListener
Parameters:
e - window event

windowClosed

public void windowClosed(java.awt.event.WindowEvent e)
Invoked when a window has been closed.

Specified by:
windowClosed in interface java.awt.event.WindowListener
Parameters:
e - window event

windowClosing

public void windowClosing(java.awt.event.WindowEvent e)
Invoked when a window is in the process of being closed. The close operation can be overridden at this point.

Specified by:
windowClosing in interface java.awt.event.WindowListener
Parameters:
e - window event

windowDeactivated

public void windowDeactivated(java.awt.event.WindowEvent e)
Invoked when a window is de-activated.

We use this event to deactivate the tool manager which avoids a serious problem. If there are multiple tool managers active then they will register multiple tools with the current document, which leads to havoc.

Specified by:
windowDeactivated in interface java.awt.event.WindowListener
Parameters:
e - window event

windowDeiconified

public void windowDeiconified(java.awt.event.WindowEvent e)
Invoked when a window is de-iconified.

Specified by:
windowDeiconified in interface java.awt.event.WindowListener
Parameters:
e - window event

windowIconified

public void windowIconified(java.awt.event.WindowEvent e)
Invoked when a window is iconified.

Specified by:
windowIconified in interface java.awt.event.WindowListener
Parameters:
e - window event

windowOpened

public void windowOpened(java.awt.event.WindowEvent e)
Invoked when a window has been opened.

Specified by:
windowOpened in interface java.awt.event.WindowListener
Parameters:
e - window event

createProps

protected void createProps()

isShowing

public boolean isShowing(java.lang.String key)

show

public void show(java.lang.String key)


Created at IDI, NTNU by the Artificial Intelligence and Learning group