edu.neu.ccs.gui
Class DisplayCollection

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.DisplayCollection
All Implemented Interfaces:
Accessible, AlertListener, Displayable, EventListener, ImageObserver, JPTConstants, MalformedDataListener, MenuContainer, Serializable, SwingConstants

public class DisplayCollection
extends DisplayPanel

A dynamic linear collection of Displayable objects, displayed using either a horizontal or vertical layout.

The functionality of this container assumes use of a BoxLayout set through the setOrientation method and effects are undefined if the user changes the layout through other means.

Since:
1.0
Version:
2.2
See Also:
ArrayPanel, Serialized Form

Nested Class Summary
 
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
static int DEFAULT_ORIENTATION
          The default orientation for a display collection.
protected  int direction
          The orientation of this display collection.
protected  DisplayPanel inner
          Panel containing the actual collection of components.
 
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
DisplayCollection()
          Constructs an empty collection with the default orientation.
DisplayCollection(Displayable[] obj)
          Constructs a collection containing the given array of objects with the default orientation.
DisplayCollection(Displayable[] obj, int orientation)
          Constructs a collection containing the given array of objects with the given orientation.
DisplayCollection(int orientation)
          Constructs an empty collection with the provided layout orientation.
 
Method Summary
 Component add(Component c)
          Adds the specified component to the end of this container.
 Component add(Component c, int index)
          Adds the specified component to this container at the given position.
 void add(Component c, Object constraints)
          Adds the specified component to the end of this container.
 void add(Component c, Object constraints, int index)
          Adds the specified component at the given position.
 Component add(String name, Component c)
          Adds the specified component to this container.
 DisplayPanel getCollectionPanel()
          Returns the panel containing the collection.
 String getDefaultViewState()
          Returns the default view states for objects in the collection as an encoded String.
 Component getItem(int index)
          Returns the component at the specified index in the collection.
 Component[] getItemArray()
          Returns an array containing all of the components held in the collection.
 int getItemCount()
          Returns the number of objects in the collection.
 int getOrientation()
          Returns the orientation value for the collection.
 String getViewState()
          Returns the view states for objects in the collection as an encoded String.
 void remove(Component c)
          Removes the given component from this container.
 void remove(int index)
          Removes the component at the given index from this container.
 void removeAll()
          Removes all the components from this container.
 void reset()
          Recursively resets each of the objects in the collection.
 void setBackground(Color background)
          Sets the background color for the entire panel to the provided color.
 void setDefaultViewState(String data)
          Sets the default view states for objects in the collection to the data encoded in the given String.
 void setOrientation(int orientation)
          Sets the orientation for the collection to the given value.
 void setViewState(String data)
          Sets the view states for Displayable objects in the collection to the data encoded in the given String.
 
Methods inherited from class edu.neu.ccs.gui.DisplayPanel
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, getDefaultViewStates, getDisplayables, getViewStates, lineBorder, lineBorder, lineBorder, lineBorder, makeComponent, matteBorder, matteBorder, matteBorder, matteBorder, matteBorder, matteBorder, OKCancelDialog, OKCancelDialog, OKDialog, OKDialog, refreshComponent, removeBorder, 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, 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

DEFAULT_ORIENTATION

public static final int DEFAULT_ORIENTATION
The default orientation for a display collection.

See Also:
Constant Field Values

direction

protected int direction
The orientation of this display collection.


inner

protected DisplayPanel inner
Panel containing the actual collection of components.

Constructor Detail

DisplayCollection

public DisplayCollection()
Constructs an empty collection with the default orientation.

See Also:
DisplayCollection(int), DisplayCollection(Displayable[]), DisplayCollection(Displayable[], int)

DisplayCollection

public DisplayCollection(int orientation)
Constructs an empty collection with the provided layout orientation.

Parameters:
orientation - the desired layout orientation
See Also:
DisplayCollection(), DisplayCollection(Displayable[]), DisplayCollection(Displayable[], int)

DisplayCollection

public DisplayCollection(Displayable[] obj)
Constructs a collection containing the given array of objects with the default orientation.

Parameters:
obj - an array of Displayable objects
See Also:
DisplayCollection(), DisplayCollection(int), DisplayCollection(Displayable[], int)

DisplayCollection

public DisplayCollection(Displayable[] obj,
                         int orientation)
Constructs a collection containing the given array of objects with the given orientation.

Parameters:
obj - an array of Displayable objects
orientation - the orientation for this collection
See Also:
DisplayCollection(), DisplayCollection(Displayable[]), DisplayCollection(int)
Method Detail

setViewState

public void setViewState(String data)
Sets the view states for Displayable objects in the collection to the data encoded in the given String. Each object in the collection has its view state set from the encoded String data in the manner described in the API documentation for the DisplayPanel class.

Specified by:
setViewState in interface Displayable
Overrides:
setViewState in class DisplayPanel
Parameters:
data - the encoded String data
See Also:
getViewState(), Displayable

getViewState

public String getViewState()
Returns the view states for objects in the collection as an encoded String. The view state for the collection is encoded in the manner described in the API documentation for the DisplayPanel class.

Specified by:
getViewState in interface Displayable
Overrides:
getViewState in class DisplayPanel
See Also:
setViewState(String), Displayable

setDefaultViewState

public void setDefaultViewState(String data)
Sets the default view states for objects in the collection to the data encoded in the given String. Each object in the collection has its default view state set from the encoded String data in the manner described in the API documentation for the DisplayPanel class.

Specified by:
setDefaultViewState in interface Displayable
Overrides:
setDefaultViewState in class DisplayPanel
Parameters:
data - the desired default String data
See Also:
reset(), Displayable

getDefaultViewState

public String getDefaultViewState()
Returns the default view states for objects in the collection as an encoded String. The default view state for the collection is encoded in the manner described in the API documentation for the DisplayPanel class.

Specified by:
getDefaultViewState in interface Displayable
Overrides:
getDefaultViewState in class DisplayPanel
See Also:
setDefaultViewState(String), reset()

reset

public void reset()
Recursively resets each of the objects in the collection.

Specified by:
reset in interface Displayable
Overrides:
reset in class DisplayPanel
See Also:
setDefaultViewState(String), Displayable

add

public Component add(Component c)
Adds the specified component to the end of this container.

Overrides:
add in class DisplayPanel
Parameters:
c - the component to be added
Returns:
the component argument
See Also:
add(Component, int), add(Component, Object), add(Component, Object, int), add(String, Component), remove(Component), remove(int), removeAll()

add

public Component add(Component c,
                     int index)
Adds the specified component to this container at the given position.

Overrides:
add in class DisplayPanel
Parameters:
c - the component to be added
index - the position at which to insert the component, or -1 to insert the component at the end.
Returns:
the component argument
See Also:
add(Component), add(Component, Object), add(Component, Object, int), add(String, Component), remove(Component), remove(int), removeAll()

add

public void add(Component c,
                Object constraints)
Adds the specified component to the end of this container. Also notifies the layout manager to add the component to this container's layout using the specified constraints object.

Overrides:
add in class DisplayPanel
Parameters:
c - the component to be added
constraints - an object expressing layout constraints for this component
See Also:
add(Component), add(Component, int), add(Component, Object, int), add(String, Component), remove(Component), remove(int), removeAll()

add

public void add(Component c,
                Object constraints,
                int index)
Adds the specified component at the given position. Also notifies the layout manager to add the component to this container's layout using the specified constraints object.

Overrides:
add in class DisplayPanel
Parameters:
c - the component to be added
constraints - an object expressing layout constraints for this component
index - the position at which to insert the component, or -1 to insert the component at the end.
See Also:
add(Component), add(Component, int), add(Component, Object), add(String, Component), remove(Component), remove(int), removeAll()

add

public Component add(String name,
                     Component c)
Adds the specified component to this container. It is strongly advised to use the 1.1 method, add(Component, Object), in place of this method.

Overrides:
add in class DisplayPanel
Parameters:
name - the name of the component to be added
c - the component to be added
Returns:
the component argument
See Also:
add(Component), add(Component, int), add(Component, Object), add(Component, Object, int), remove(Component), remove(int), removeAll()

remove

public void remove(Component c)
Removes the given component from this container.

Overrides:
remove in class DisplayPanel
Parameters:
c - the component to be removed
See Also:
add(Component), add(Component, int), add(Component, Object), add(Component, Object, int), add(String, Component), remove(int), removeAll()

remove

public void remove(int index)
Removes the component at the given index from this container.

Overrides:
remove in class DisplayPanel
Parameters:
index - the index of the component to be removed
See Also:
add(Component), add(Component, int), add(Component, Object), add(Component, Object, int), add(String, Component), remove(Component), removeAll()

removeAll

public void removeAll()
Removes all the components from this container.

Overrides:
removeAll in class DisplayPanel
See Also:
add(Component), add(Component, int), add(Component, Object), add(Component, Object, int), add(String, Component), remove(Component), remove(int)

getItem

public Component getItem(int index)
Returns the component at the specified index in the collection. It is strongly advised to never use the getComponent method, as its behavior is undefined for this container.

Parameters:
index - the index of the desired component

getItemArray

public Component[] getItemArray()
Returns an array containing all of the components held in the collection. It is strongly advised to never use the getComponents method, as its behavior is undefined for this container.


getItemCount

public int getItemCount()
Returns the number of objects in the collection. It is strongly advised to never use the getComponentCount method, as its behavior is undefined for this container.


setOrientation

public void setOrientation(int orientation)
Sets the orientation for the collection to the given value. If the given orientation value is not valid, the orientation is not changed. The functionality of this container assumes use of a BoxLayout set through this method, and effects are undefined if the user changes the layout through other means.

Parameters:
orientation - the desired layout orientation value
See Also:
getOrientation(), SwingConstants.VERTICAL, SwingConstants.HORIZONTAL, JPTConstants.DEFAULT

getOrientation

public int getOrientation()
Returns the orientation value for the collection.

See Also:
setOrientation(int), SwingConstants.VERTICAL, SwingConstants.HORIZONTAL

getCollectionPanel

public DisplayPanel getCollectionPanel()
Returns the panel containing the collection. This method is provided with the intention of allowing the user to set properties of the panel such as borders, etc. and not with the intention of allowing the user to set layout properties of the panel. The functionality of this container assumes use of a BoxLayout set through the setOrientation method, and effects are undefined if the user changes the layout through other means.


setBackground

public void setBackground(Color background)
Sets the background color for the entire panel to the provided color.

Parameters:
background - the desired background color