edu.neu.ccs.gui
Class Display

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byedu.neu.ccs.gui.DisplayPanel
                      extended byedu.neu.ccs.gui.Display
All Implemented Interfaces:
Accessible, AlertListener, Displayable, EventListener, ImageObserver, JPTConstants, MalformedDataListener, MenuContainer, Serializable, SwingConstants
Direct Known Subclasses:
InputDialog.CompoundView

public class Display
extends DisplayPanel

A panel containing a >Displayable> object, with the option of a title and an >Annotation>.

The object on display always appears at the center of the view and takes up all available space.

The title can appear at the top or bottom of the view.

The annotation can appear at any of the four main compass directions relative to the object on display.

The valid alignment constants for the title are ABOVE, BELOW, and DEFAULT (leads to ABOVE); these constants are inherited from JPTConstants.

The valid alignment constants for the annotation are LEFT, RIGHT, ABOVE, BELOW, and DEFAULT (leads to LEFT); these constants are inherited from JPTConstants.

The functionality of this container assumes use of a >BorderLayout> and effects are undefined if the user changes this layout.

The >Display> is the simplest and most versatile of the recursive container classes available in the JPT.

Displays can be recursively nested to any depth, although screen real estate imposes a physical limit to the number of displays that could be contained within an actual visualization.

In 2.4.0, added two contructors that provide for a title but assume no annotation. This has turned out in practice to be the most commonly used situation.

Since:
1.0
Version:
2.4.0
See Also:
Serialized Form

Nested Class Summary
static class Display.Settings
          Data structure encapsulating the content and layout properties for a >Display>.
 
Nested classes inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  int aAlign
          The alignment of the annotation relative to displayed object.
static String ANNOTATION
          Bound property name for the annotation object property.
static String ANNOTATION_ALIGNMENT
          Bound property name for the annotation alignment property.
static String ANNOTATION_TEXT
          Bound property name for the annotation text property.
protected  Annotation caption
          The annotation for this display.
static int DEFAULT_ANNOTATION_ALIGNMENT
          The default alignment of the annotation relative to displayed object for a display.
static String DEFAULT_ANNOTATION_TEXT
          The default annotation text for a display.
static int DEFAULT_TITLE_ALIGNMENT
          The default alignment of the title relative to displayed object.
static String DEFAULT_TITLE_TEXT
          The default title text for a display.
static String DISPLAY
          Bound property name for the displayed object property.
protected  int tAlign
          The alignment of the title relative to displayed object.
protected  String title
          The title text for this display.
static String TITLE_ALIGNMENT
          Bound property name for the title alignment property.
static String TITLE_TEXT
          Bound property name for the title text property.
protected  Displayable view
          The displayed object for this display.
 
Fields inherited from class edu.neu.ccs.gui.DisplayPanel
background, codec, CODEC
 
Fields inherited from class javax.swing.JPanel
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_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 edu.neu.ccs.gui.Displayable
DEFAULT_VIEW_STATE, VIEW_STATE
 
Fields inherited from interface edu.neu.ccs.util.JPTConstants
ABOVE, ALIGNMENT, BELOW, BOTTOM_LEFT, BOTTOM_RIGHT, DEFAULT, FONT, INPUT_PROPERTIES, MANDATORY, OPTIONAL, ORIENTATION, TOP_LEFT, TOP_RIGHT, VALUE
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Display()
          Constructs a display containing an empty >DisplayPanel>, with no annotation or title.
Display(Displayable viewObject)
          Constructs a display containing the given object, with no annotation or title.
Display(Displayable viewObject, Display.Settings settings)
          Constructs a display containing the given object, with the remaining settings taken from the given >Settings> object.
Display(Displayable viewObject, String titleText)
          Constructs a display containing the given object, with no annotation, but with the given title.
Display(Displayable viewObject, String titleText, int titleAlign)
          Constructs a display containing the given object, with no annotation, but with the given title and title alignment.
Display(Displayable viewObject, String annotationText, String titleText)
          Constructs a display containing the given object, with the given annotation text and title text.
Display(Displayable viewObject, String annotationText, String titleText, int annotationAlign, int titleAlign)
          Constructors a display containing the given object, with the given annotation text and title text, using the given alignments for the title and annotation.
 
Method Summary
 Annotation getAnnotation()
          Returns the annotation component, or >null> if this display does not have an annotation.
 int getAnnotationAlignment()
          Returns the value for the alignment of the annotation relative to the displayed object.
 String getAnnotationText()
          Returns the annotation text, or >null> if this display does not have an annotation.
 Displayable getDisplay()
          Returns the displayed object.
 Display.Settings getSettings()
          Returns the properties for this display as a >Settings> object.
 int getTitleAlignment()
          Returns the alignment value of the title relative to the object on display.
 String getTitleText()
          Returns the title text, or >null> if this display does not have a title.
 String getViewState()
          Returns the encoded view state for the Displayable() objects in the panel.
protected  void revalidateAnnotationAndAlignment()
          Rebuilds the annotation and its alignment based on the current annotation text and alignment.
protected  void revalidateTitleAndAlignment()
          Rebuilds the titled border and its alignment based on the current title text and alignment.
 void setAnnotation(Annotation annotation)
          Sets the annotation component to the given >Annotation>.
 void setAnnotationAlignment(int alignment)
          Sets the alignment of the annotation relative to the displayed object.
 void setAnnotationText(String text)
          Sets the annotation text to the given text.
 void setDefaultViewState(String data)
          Sets the default view states for the Displayable objects in the container to the data encoded in the given String.
 void setDisplay(Displayable viewObject)
          Sets the displayed object to the given >Displayable> object.
 void setSettings(Display.Settings s)
          Sets the properties for this display to the settings taken from the given >Settings> object.
 void setTitleAlignment(int alignment)
          Sets the alignment of the title relative to the displayed object.
 void setTitleText(String text)
          Sets the title text to the given text.
 void setViewState(String data)
          Sets the view states for the Displayable objects in the container to the data encoded in the given String.
 
Methods inherited from class edu.neu.ccs.gui.DisplayPanel
add, add, add, add, add, addBorder, addObject, addObject, addObject, addObject, bevelBorderLowered, bevelBorderLowered, bevelBorderLowered, bevelBorderLowered, bevelBorderLowered, bevelBorderRaised, bevelBorderRaised, bevelBorderRaised, bevelBorderRaised, bevelBorderRaised, compoundBorder, compoundBorder, dataMalformed, emptyBorder, emptyBorder, emptyBorder, endAlert, etchBorderLowered, etchBorderLowered, etchBorderLowered, etchBorderRaised, etchBorderRaised, etchBorderRaised, frame, frame, frame, frame, frame, frame, generalDialog, generalDialog, generalDialog, generalDialog, getCodec, getDefaultViewState, getDefaultViewStates, getDisplayables, getViewStates, lineBorder, lineBorder, lineBorder, lineBorder, makeComponent, matteBorder, matteBorder, matteBorder, matteBorder, matteBorder, matteBorder, OKCancelDialog, OKCancelDialog, OKDialog, OKDialog, refreshComponent, remove, remove, removeAll, removeBorder, reset, sandwichBorder, setCodec, setDeepBackground, setDeepBackground, setDefaultViewStates, setEnabled, setViewStates, startAlert, titleBorder, titleBorder, titleBorder, titleBorder, titleBorder, titleBorder, titleBorder, titleBorder, uniformizeHeight, uniformizeSize, uniformizeWidth, YesNoCancelDialog, YesNoCancelDialog
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, 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, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ANNOTATION_TEXT

public static final String ANNOTATION_TEXT
Bound property name for the annotation text property.

See Also:
Constant Field Values

ANNOTATION_ALIGNMENT

public static final String ANNOTATION_ALIGNMENT
Bound property name for the annotation alignment property.

See Also:
Constant Field Values

TITLE_TEXT

public static final String TITLE_TEXT
Bound property name for the title text property.

See Also:
Constant Field Values

TITLE_ALIGNMENT

public static final String TITLE_ALIGNMENT
Bound property name for the title alignment property.

See Also:
Constant Field Values

DISPLAY

public static final String DISPLAY
Bound property name for the displayed object property.

See Also:
Constant Field Values

ANNOTATION

public static final String ANNOTATION
Bound property name for the annotation object property.

See Also:
Constant Field Values

DEFAULT_ANNOTATION_TEXT

public static final String DEFAULT_ANNOTATION_TEXT
The default annotation text for a display.


DEFAULT_TITLE_TEXT

public static final String DEFAULT_TITLE_TEXT
The default title text for a display.


DEFAULT_ANNOTATION_ALIGNMENT

public static final int DEFAULT_ANNOTATION_ALIGNMENT
The default alignment of the annotation relative to displayed object for a display.

See Also:
Constant Field Values

DEFAULT_TITLE_ALIGNMENT

public static final int DEFAULT_TITLE_ALIGNMENT
The default alignment of the title relative to displayed object.

See Also:
Constant Field Values

title

protected String title
The title text for this display.


aAlign

protected int aAlign
The alignment of the annotation relative to displayed object.


tAlign

protected int tAlign
The alignment of the title relative to displayed object.


view

protected Displayable view
The displayed object for this display. Since this object must never be >null>, an empty >DisplayPanel> will be provided on any attempt to set a >null> displayed object.


caption

protected Annotation caption
The annotation for this display.

Constructor Detail

Display

public Display()
Constructs a display containing an empty >DisplayPanel>, with no annotation or title.


Display

public Display(Displayable viewObject)
Constructs a display containing the given object, with no annotation or title.

Parameters:
viewObject - the object to display

Display

public Display(Displayable viewObject,
               String titleText)
Constructs a display containing the given object, with no annotation, but with the given title.

Parameters:
viewObject - the object to display
titleText - the title text

Display

public Display(Displayable viewObject,
               String titleText,
               int titleAlign)
Constructs a display containing the given object, with no annotation, but with the given title and title alignment.

Parameters:
viewObject - the object to display
titleText - the title text
titleAlign - the relative alignment of the title relative to the object on display

Display

public Display(Displayable viewObject,
               String annotationText,
               String titleText)
Constructs a display containing the given object, with the given annotation text and title text.

Parameters:
viewObject - the object to display
annotationText - the annotation text
titleText - the title text

Display

public Display(Displayable viewObject,
               String annotationText,
               String titleText,
               int annotationAlign,
               int titleAlign)
Constructors a display containing the given object, with the given annotation text and title text, using the given alignments for the title and annotation.

Parameters:
viewObject - the object to display
annotationText - the annotation text
titleText - the title text
annotationAlign - the relative alignment of the annotation relative to the object on display
titleAlign - the relative alignment of the title relative to the object on display

Display

public Display(Displayable viewObject,
               Display.Settings settings)
Constructs a display containing the given object, with the remaining settings taken from the given >Settings> object.

Parameters:
viewObject - the object to display
settings - the object containing the desired settings
Method Detail

setViewState

public void setViewState(String data)
Description copied from class: DisplayPanel

Sets the view states for the Displayable objects in the container to the data encoded in the given String.

If the given encoded data is null, then the view states are not changed.

The String data is decoded using the method Strings.decode to allow the data to be submitted in several formats.

Sets the view states of as many Displayable objects as possible but ignores any mismatch in the number of Displayable objects and the number of Strings decoded from the given encoded String data.

Fires property change VIEW_STATE.

Specified by:
setViewState in interface Displayable
Overrides:
setViewState in class DisplayPanel
Parameters:
data - the encoded String data

getViewState

public String getViewState()
Description copied from class: DisplayPanel

Returns the encoded view state for the Displayable() objects in the panel.

The encoded data is constructed by passing the array returned by getViewStates() to the method CodecUtilities.encode. This method call uses the codec returned by the method getCodec().

Specified by:
getViewState in interface Displayable
Overrides:
getViewState in class DisplayPanel

setDefaultViewState

public void setDefaultViewState(String data)
Description copied from class: DisplayPanel

Sets the default view states for the Displayable objects in the container to the data encoded in the given String.

If the given encoded data is null, then the default view states are not changed.

The String data is decoded using the method Strings.decode to allow the data to be submitted in several formats.

Sets the default view states of as many Displayable objects as possible but ignores any mismatch in the number of Displayable objects and the number of Strings decoded from the given encoded String data.

Fires property change DEFAULT_VIEW_STATE.

Specified by:
setDefaultViewState in interface Displayable
Overrides:
setDefaultViewState in class DisplayPanel
Parameters:
data - the encoded default String data

setAnnotationText

public void setAnnotationText(String text)
Sets the annotation text to the given text. If the given text is >null>, the current annotation is removed from this display an no annotation is displayed. If the annotation text was previously >null>, a new >Annotation> object is created.

Parameters:
text - the annotation text to display

getAnnotationText

public String getAnnotationText()
Returns the annotation text, or >null> if this display does not have an annotation. If this display does not contain an annotation, this method returns >null>.


setAnnotationAlignment

public void setAnnotationAlignment(int alignment)
Sets the alignment of the annotation relative to the displayed object. If the given alignment value is invalid, the annotation alignment is not changed.

Parameters:
alignment - the new alignment for the annotation relative to the displayed object

getAnnotationAlignment

public int getAnnotationAlignment()
Returns the value for the alignment of the annotation relative to the displayed object.


setTitleText

public void setTitleText(String text)
Sets the title text to the given text. If the given text is >null>, the current titled border is removed from this display and no title is displayed. If the title text was previously >null>, a new titled border is created.

Parameters:
text - the title text to display

getTitleText

public String getTitleText()
Returns the title text, or >null> if this display does not have a title.


setTitleAlignment

public void setTitleAlignment(int alignment)
Sets the alignment of the title relative to the displayed object. If the given alignment value is invalid, the title alignment is not changed.

Parameters:
alignment - the new alignment for the title relative to the displayed object

getTitleAlignment

public int getTitleAlignment()
Returns the alignment value of the title relative to the object on display.


setDisplay

public void setDisplay(Displayable viewObject)
Sets the displayed object to the given >Displayable> object. If the given object is >null>, an empty >DisplayPanel> is created and displayed.

Parameters:
viewObject - the new object to display

getDisplay

public Displayable getDisplay()
Returns the displayed object.


setAnnotation

public void setAnnotation(Annotation annotation)
Sets the annotation component to the given >Annotation>. If the given object is >null>, the current annotation is removed from this display and no annotation is displayed.

Parameters:
annotation - the new >Annotation>

getAnnotation

public Annotation getAnnotation()
Returns the annotation component, or >null> if this display does not have an annotation.


setSettings

public void setSettings(Display.Settings s)
Sets the properties for this display to the settings taken from the given >Settings> object. If the given object is >null>, then all settings are reset to defaults.

Parameters:
s - encapsulation of the new settings for this display

getSettings

public Display.Settings getSettings()
Returns the properties for this display as a >Settings> object.


revalidateTitleAndAlignment

protected void revalidateTitleAndAlignment()
Rebuilds the titled border and its alignment based on the current title text and alignment.


revalidateAnnotationAndAlignment

protected void revalidateAnnotationAndAlignment()
Rebuilds the annotation and its alignment based on the current annotation text and alignment.