Renderer
Class Playground

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Frame
                          |
                          +--javax.swing.JFrame
                                |
                                +--Renderer.Playground
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.RootPaneContainer, java.io.Serializable, javax.swing.WindowConstants

public class Playground
extends javax.swing.JFrame

Defines the graphical equivalent of a "universe" full of "worlds." It is a collection of Sandbox containers, each with its own three-dimensional, interactive view of its "objects" (Toys). This is the top-level user interface that allows all aspects of the system to be viewed, manipulated, etc.

A Playground contains any number of Sandboxes. Each depicts a slightly different interpretation of the source-text description. They can be viewed independently or synchronized.

Version:
Created 17 February 2003
Author:
Dan Tappan
See Also:
Sandbox, Serialized Form

Nested Class Summary
private  class Playground.SandboxFrame
           
 
Field Summary
private  float CLUSTERED_COMPOSITE_OBJECT_TRANSPARENCY
           
static java.lang.String COLORMAP_FILENAME
           
static java.lang.String HOME_PATH
           
static java.lang.String INSTALL_PATH
           
protected static int INSTANTIATION_KEY
           
private  java.util.Hashtable m_color_map
           
private  javax.swing.JDesktopPane m_desktop
           
private  int m_frame_height
           
private  int m_frame_height_prev
           
private  int m_frame_location_x_prev
           
private  int m_frame_location_y_prev
           
private  int m_frame_width
           
private  int m_frame_width_prev
           
private  boolean m_is_wireframe
           
private  ModelLibrary m_model_library
           
private  java.util.LinkedList m_monte_carlo_run_sets
           
private  java.lang.String m_name
           
private  java.util.HashMap m_open_representation_viewers
           
private  java.util.LinkedHashMap m_sandbox_frames
           
private  java.util.Hashtable m_sandboxes
           
static java.lang.String MODEL_PATH
           
private  java.awt.Color PLAYGROUND_WINDOW_BACKGROUND_COLOR
           
private  java.awt.Color SANDBOX_WINDOW_BACKGROUND_COLOR
           
private  int SCREEN_HEIGHT
           
private  int SCREEN_WIDTH
           
static java.lang.String TEMP_PATH
           
private  int WINDOW_BASE_X
           
private  int WINDOW_BASE_Y
           
private  int WINDOW_CASCADE_SPACING_X
           
private  int WINDOW_CASCADE_SPACING_Y
           
private  int WINDOW_PLACEMENT_CASCADE
           
private  int WINDOW_PLACEMENT_RELOCATE
           
private  int WINDOW_PLACEMENT_TILE
           
private  int WINDOW_PLACEMENT_TO_FRONT
           
private  int WINDOW_TILE_SPACING_X
           
private  int WINDOW_TILE_SPACING_Y
           
 
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.Window
 
Fields inherited from class java.awt.Container
 
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
Playground(java.lang.String name, java.util.LinkedList monte_carlo_run_sets, boolean is_wireframe, int frame_width, int frame_height)
          Creates a new playground from the the MonteCarloRunSets created in the Reasoner and refined in the Distiller.
 
Method Summary
 void addColorMapEntry(java.lang.String region_name, javax.vecmath.Color3f color)
          Adds a palette entry for the colors of a named region.
 Sandbox createSandbox(java.lang.String sandbox_name, MonteCarloRunSet monte_carlo_run_set)
          Creates and adds a new sandbox.
 void depict(boolean show_clustering, boolean show_toy_geometry, boolean show_toy_topology)
          Builds the playground based on its contents at the time of this call.
private  void depict(java.lang.String monte_carlo_run_set_source_name, java.lang.String monte_carlo_run_set_mirror_name, boolean show_clustering, boolean show_toy_geometry, boolean show_toy_topology)
          Builds the playground based on its contents at the time of this call.
private  javax.vecmath.Color3f getClusterColor(int clusterID)
          Returns a color associated with a cluster.
private  MonteCarloRunSet getMonteCarloRunSet(java.lang.String run_set_name)
          Returns the Monte Carlo run set associated with a sandbox.
 java.lang.String getName()
          Returns the name of this playground.
private  javax.vecmath.Color3f getRegionColor(java.lang.String region_name)
          Returns the color stored in the palette for a region.
 Sandbox getSandbox(java.lang.String sandbox_name)
          Returns a sandbox.
 int getSandboxCount()
          Returns the number of sandboxes in this playground.
 java.util.Enumeration getSandboxNames()
          Returns the names of sandboxes in this playground.
private  void initializeColorMap()
          Initialize a palette with default colors from the colormap file for standard named regions.
 void mirrorSandbox(java.lang.String source_sandbox_name, java.lang.String mirror_sandbox_name, boolean show_clustering, boolean show_toy_geometry, boolean show_toy_topology)
          Creates a clone of a sandbox in its own window.
 void paint(java.awt.Graphics graphics)
          Catches the repaint event, which is the only known way to detect when the playground container has been resized.
private  void placeWindows(int mode)
          Places the sandbox windows according to the mode specified.
private  void placeWindows(int mode, int offset_x, int offset_y)
          Places the sandbox windows according to the mode and location specified.
protected  void processSandboxCallback(Sandbox sandbox, java.lang.String selection_identifier, java.awt.event.MouseEvent event)
          Handles a selection callback from the SandboxController in charge of one of the sandboxes and open a representation viewer for the selected toy.
private  void refresh()
          Redisplays the emulated MDI contents.
protected  void releaseRepresentationViewer(java.lang.String viewer_name)
          Releases a representation viewer from the in-use list upon its close.
 void synchronizeSandboxes(Sandbox master_sandbox)
          Forces all sandboxes to update based on the viewer properties of the given one.
 java.lang.String toString()
          Returns a string representation of this object.
 
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, 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, 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, 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

INSTANTIATION_KEY

protected static final int INSTANTIATION_KEY
See Also:
Constant Field Values

INSTALL_PATH

public static final java.lang.String INSTALL_PATH
See Also:
Constant Field Values

HOME_PATH

public static final java.lang.String HOME_PATH
See Also:
Constant Field Values

TEMP_PATH

public static final java.lang.String TEMP_PATH
See Also:
Constant Field Values

MODEL_PATH

public static final java.lang.String MODEL_PATH
See Also:
Constant Field Values

COLORMAP_FILENAME

public static final java.lang.String COLORMAP_FILENAME
See Also:
Constant Field Values

CLUSTERED_COMPOSITE_OBJECT_TRANSPARENCY

private final float CLUSTERED_COMPOSITE_OBJECT_TRANSPARENCY
See Also:
Constant Field Values

m_model_library

private ModelLibrary m_model_library

m_sandboxes

private java.util.Hashtable m_sandboxes

m_monte_carlo_run_sets

private java.util.LinkedList m_monte_carlo_run_sets

m_name

private java.lang.String m_name

m_is_wireframe

private boolean m_is_wireframe

m_color_map

private java.util.Hashtable m_color_map

SANDBOX_WINDOW_BACKGROUND_COLOR

private final java.awt.Color SANDBOX_WINDOW_BACKGROUND_COLOR

PLAYGROUND_WINDOW_BACKGROUND_COLOR

private final java.awt.Color PLAYGROUND_WINDOW_BACKGROUND_COLOR

SCREEN_WIDTH

private int SCREEN_WIDTH

SCREEN_HEIGHT

private int SCREEN_HEIGHT

WINDOW_BASE_X

private final int WINDOW_BASE_X
See Also:
Constant Field Values

WINDOW_BASE_Y

private final int WINDOW_BASE_Y
See Also:
Constant Field Values

WINDOW_CASCADE_SPACING_X

private int WINDOW_CASCADE_SPACING_X

WINDOW_CASCADE_SPACING_Y

private int WINDOW_CASCADE_SPACING_Y

WINDOW_TILE_SPACING_X

private int WINDOW_TILE_SPACING_X

WINDOW_TILE_SPACING_Y

private int WINDOW_TILE_SPACING_Y

WINDOW_PLACEMENT_TILE

private final int WINDOW_PLACEMENT_TILE
See Also:
Constant Field Values

WINDOW_PLACEMENT_CASCADE

private final int WINDOW_PLACEMENT_CASCADE
See Also:
Constant Field Values

WINDOW_PLACEMENT_TO_FRONT

private final int WINDOW_PLACEMENT_TO_FRONT
See Also:
Constant Field Values

WINDOW_PLACEMENT_RELOCATE

private final int WINDOW_PLACEMENT_RELOCATE
See Also:
Constant Field Values

m_desktop

private javax.swing.JDesktopPane m_desktop

m_sandbox_frames

private java.util.LinkedHashMap m_sandbox_frames

m_frame_width

private int m_frame_width

m_frame_height

private int m_frame_height

m_frame_width_prev

private int m_frame_width_prev

m_frame_height_prev

private int m_frame_height_prev

m_frame_location_x_prev

private int m_frame_location_x_prev

m_frame_location_y_prev

private int m_frame_location_y_prev

m_open_representation_viewers

private java.util.HashMap m_open_representation_viewers
Constructor Detail

Playground

public Playground(java.lang.String name,
                  java.util.LinkedList monte_carlo_run_sets,
                  boolean is_wireframe,
                  int frame_width,
                  int frame_height)
           throws java.lang.Exception
Creates a new playground from the the MonteCarloRunSets created in the Reasoner and refined in the Distiller.

Parameters:
name - - the arbitrary name of this playground
monte_carlo_run_sets - - the Monte Carlo run sets providing the source data
is_wireframe - - whether everything is this playground should be rendered in wireframe
frame_width - - the width of each sandbox window
frame_height - - the height of each sandbox window
Throws:
java.lang.Exception - - if the playground cannot be created
See Also:
Reasoner, Reasoner
Method Detail

addColorMapEntry

public void addColorMapEntry(java.lang.String region_name,
                             javax.vecmath.Color3f color)
Adds a palette entry for the colors of a named region. This can be used to define the color a new region or to override the standard color of a preprogrammed one. The palette ensures that the same regions across multiple sandboxes have the same color.

Regions that have neither a built-in color or nor an entry that has been added here will be displayed with a default color.

Parameters:
region_name - - the name of the region
color - - the color to associate with the region
See Also:
initializeColorMap(), getRegionColor(java.lang.String)

createSandbox

public Sandbox createSandbox(java.lang.String sandbox_name,
                             MonteCarloRunSet monte_carlo_run_set)
                      throws java.lang.Exception
Creates and adds a new sandbox.

Parameters:
sandbox_name - - the sandbox name
monte_carlo_run_set - - the Monte Carlo run set defining the contents of the sandbox to create
Returns:
the sandbox
Throws:
java.lang.Exception - - if a sandbox with the given name is already present in the playground

depict

public void depict(boolean show_clustering,
                   boolean show_toy_geometry,
                   boolean show_toy_topology)
            throws java.lang.Exception
Builds the playground based on its contents at the time of this call. This cannot be called more than once; therefore there is no means of display any later additions.

Parameters:
show_clustering - - whether clustering is indicated through colors that override the model colors
show_toy_geometry - - whether the region geometry meshes of each toy should be displayed
show_toy_topology - - whether the region topology meshes should be displayed with the geometry, if it is shown
Throws:
java.lang.Exception - - if the depiction fails; a duplicate-sandbox exception results if this is called twice

depict

private void depict(java.lang.String monte_carlo_run_set_source_name,
                    java.lang.String monte_carlo_run_set_mirror_name,
                    boolean show_clustering,
                    boolean show_toy_geometry,
                    boolean show_toy_topology)
             throws java.lang.Exception
Builds the playground based on its contents at the time of this call. This is the interal version of depict() that also handles optional mirroring (cloning) an existing sandbox.

Parameters:
monte_carlo_run_set_source_name - - the name of the sandbox to mirror, or null
monte_carlo_run_set_mirror_name - - the name to assign to the clone, or null
show_clustering - - whether clustering is indicated through colors that override the model colors
show_toy_geometry - - whether the region geometry meshes of each toy should be displayed
show_toy_topology - - whether the region topology meshes should be displayed with the geometry, if it is shown

The only valid combination of parameters is two strings or two nulls.

Throws:
java.lang.Exception - - if an attempt is made to mirror the mirror of sandbox

getClusterColor

private javax.vecmath.Color3f getClusterColor(int clusterID)
Returns a color associated with a cluster. This is used to color related toys across multiple sandboxes.

Parameters:
clusterID - - the cluster ID
Returns:
the cluster color

getMonteCarloRunSet

private MonteCarloRunSet getMonteCarloRunSet(java.lang.String run_set_name)
Returns the Monte Carlo run set associated with a sandbox.

Parameters:
run_set_name - - the run-set name, which is the same as the sandbox name
Returns:
the run set
Throws:
java.lang.Exception - - if the run set does not exist

getName

public java.lang.String getName()
Returns the name of this playground.

Overrides:
getName in class java.awt.Component
Returns:
the name

getRegionColor

private javax.vecmath.Color3f getRegionColor(java.lang.String region_name)
Returns the color stored in the palette for a region.

Side Effect: writes a warning to stderr if the given region has no palette entry.

Parameters:
region_name - - the region name
Returns:
the color or a default if the given region has no palette entry
See Also:
addColorMapEntry(java.lang.String, javax.vecmath.Color3f), initializeColorMap(), Support.writeWarning(java.lang.String, java.lang.String)

getSandbox

public Sandbox getSandbox(java.lang.String sandbox_name)
Returns a sandbox.

Parameters:
sandbox_name - - the sandbox name
Returns:
the sandbox, or null if it is not present

getSandboxCount

public int getSandboxCount()
Returns the number of sandboxes in this playground.

Returns:
the count

getSandboxNames

public java.util.Enumeration getSandboxNames()
Returns the names of sandboxes in this playground.

Returns:
the string list of names

initializeColorMap

private void initializeColorMap()
                         throws java.lang.Exception
Initialize a palette with default colors from the colormap file for standard named regions. These colors can be overridden, and new ones can be added for additional regions. This ensures that the same regions across multiple sandboxes have the same color.

This can be recoded for more attractive results and to reflect new standard region names.

Throws:
java.lang.Exception - - if the color-map file cannot be loaded
See Also:
addColorMapEntry(java.lang.String, javax.vecmath.Color3f), getRegionColor(java.lang.String)

mirrorSandbox

public void mirrorSandbox(java.lang.String source_sandbox_name,
                          java.lang.String mirror_sandbox_name,
                          boolean show_clustering,
                          boolean show_toy_geometry,
                          boolean show_toy_topology)
                   throws java.lang.Exception
Creates a clone of a sandbox in its own window. Both reference the same source data, but each has its own Sandbox and SandboxController to allow independent viewing.

Parameters:
source_sandbox_name - - the name of the sandbox to clone
mirror_sandbox_name - - the name to assign to the clone
show_clustering - - whether clustering is indicated through colors that override the model colors
show_toy_geometry - - whether the region geometry meshes of each toy should be displayed
show_toy_topology - - whether the region topology meshes should be displayed with the geometry, if it is shown
Throws:
java.lang.Exception - - if the sandbox to clone is not present

paint

public void paint(java.awt.Graphics graphics)
Catches the repaint event, which is the only known way to detect when the playground container has been resized. If so, refresh its contents.

Overrides:
paint in class java.awt.Container
Parameters:
graphics - - the graphics context of the paint event

placeWindows

private void placeWindows(int mode)
Places the sandbox windows according to the mode specified.

Parameters:
mode - - the mode
See Also:
WINDOW_PLACEMENT_TILE, WINDOW_PLACEMENT_CASCADE, WINDOW_PLACEMENT_RELOCATE, WINDOW_PLACEMENT_TO_FRONT

placeWindows

private void placeWindows(int mode,
                          int offset_x,
                          int offset_y)
Places the sandbox windows according to the mode and location specified.

Parameters:
mode - - the mode
offset_x - - the left starting point of the placement
offset_y - - the top starting point of the placement
See Also:
WINDOW_PLACEMENT_TILE, WINDOW_PLACEMENT_CASCADE, WINDOW_PLACEMENT_RELOCATE, WINDOW_PLACEMENT_TO_FRONT

processSandboxCallback

protected void processSandboxCallback(Sandbox sandbox,
                                      java.lang.String selection_identifier,
                                      java.awt.event.MouseEvent event)
Handles a selection callback from the SandboxController in charge of one of the sandboxes and open a representation viewer for the selected toy. Multiple viewers can be open at once, but only one can be open per toy.

Parameters:
sandbox - - the sandbox originating the callback
selection_identifier - - an identifier specifying what was clicked on
event - - the event that invoked this callback
See Also:
RepresentationViewer

refresh

private void refresh()
Redisplays the emulated MDI contents. Call this after any changes are made to the size, position, or visibility of any sandbox frame or their parent container.


releaseRepresentationViewer

protected void releaseRepresentationViewer(java.lang.String viewer_name)
Releases a representation viewer from the in-use list upon its close. This allows multiple viewers to be open at once but limits it to one per toy.

This is called by RepresentationViewer.

Parameters:
viewer_name - - the viewer name
See Also:
RepresentationViewer

synchronizeSandboxes

public void synchronizeSandboxes(Sandbox master_sandbox)
Forces all sandboxes to update based on the viewer properties of the given one.

Parameters:
master_sandbox - - the master sandbox

toString

public java.lang.String toString()
Returns a string representation of this object.

Overrides:
toString in class java.awt.Component
Returns:
the String representation
See Also:
Support.toPrettyString(java.lang.String)