edu.neu.ccs.gui
Class ComponentWrapper

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--edu.neu.ccs.gui.DisplayPanel
                                |
                                +--edu.neu.ccs.gui.ComponentWrapper
All Implemented Interfaces:
Accessible, AlertListener, Displayable, EventListener, ImageObserver, JPTConstants, MalformedDataListener, MenuContainer, Serializable, SwingConstants
Direct Known Subclasses:
DisplayWrapper

public class ComponentWrapper
extends DisplayPanel

Wrapper for a single component that uses a AlignedLayout and faithfully respects minimum, maximum, and preferred sizes.

Since:
1.0
See Also:
DisplayWrapper, TypedViewWrapper, GeneralViewWrapper, Serialized Form

Field Summary
protected  edu.neu.ccs.gui.ComponentWrapper.WrappedComponent wrapper
          The wrapper object which wraps component.
 
Fields inherited from class edu.neu.ccs.gui.DisplayPanel
background, codec, CODEC
 
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.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
 
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
ComponentWrapper(Component component)
          Constructs a wrapper for the given component.
ComponentWrapper(Component component, int alignment)
          Constructs a wrapper for the given component using the given alignment.
 
Method Summary
 int getAlignment()
          Returns the alignment for this wrapper.
 Dimension getMaximumSize()
          Returns the maximum size for the wrapped component.
 Dimension getMinimumSize()
          Returns the minimum size for the wrapped component.
 Dimension getPreferredSize()
          Returns the preferred size for the wrapped component.
 Component getWrappedComponent()
          Returns the wrapped component.
 void setAbsoluteSize(Dimension size)
          Sets the minimum, maximum, and preferred sizes for the wrapped component to the given Dimension.
 void setAbsoluteSize(int width, int height)
          Sets the minimum, maximum, and preferred sizes for the wrapped component to the given width and height.
 void setAlignment(int alignment)
          Sets the alignment for this wrapper to the alignment designated by the given value.
 void setEnabled(boolean isEnabled)
          Sets whether or not this wrapper and its wrapped component are enabled.
 void setMaximumSize(Dimension size)
          Sets the maximum size for the wrapped component to a copy of the given Dimension.
 void setMaximumSize(int width, int height)
          Sets the maximum size for the wrapped component to the given width and height.
 void setMinimumSize(Dimension size)
          Sets the minimum size for the wrapped component to a copy of the given Dimension.
 void setMinimumSize(int width, int height)
          Sets the minimum size for the wrapped component to the given width and height.
 void setPreferredSize(Dimension size)
          Sets the preferred size for the wrapped component to the given Dimension.
 void setPreferredSize(int width, int height)
          Sets the preferred size for the wrapped component to the given width and height.
 void setWrappedComponent(Component component)
          Sets the wrapped component to the given component.
 
Methods inherited from class edu.neu.ccs.gui.DisplayPanel
add, add, add, add, add, addObject, addObject, addObject, addObject, dataMalformed, endAlert, frame, frame, frame, frame, frame, frame, generalDialog, generalDialog, generalDialog, generalDialog, getCodec, getDefaultViewState, getViewState, makeComponent, OKCancelDialog, OKCancelDialog, OKDialog, OKDialog, refreshComponent, remove, remove, removeAll, reset, setCodec, setDeepBackground, setDeepBackground, setDefaultViewState, setViewState, startAlert, 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, getNextFocusableComponent, 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, setNextFocusableComponent, setOpaque, 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

wrapper

protected edu.neu.ccs.gui.ComponentWrapper.WrappedComponent wrapper
The wrapper object which wraps component.

Constructor Detail

ComponentWrapper

public ComponentWrapper(Component component)
Constructs a wrapper for the given component.

Parameters:
component - the component to be wrapped
Throws:
NullPointerException - if the given component is null

ComponentWrapper

public ComponentWrapper(Component component,
                        int alignment)
Constructs a wrapper for the given component using the given alignment.

Parameters:
component - the component to be wrapped
alignment - the alignment for this wrapper
Throws:
NullPointerException - if the given component is null
Since:
1.1
Method Detail

setEnabled

public void setEnabled(boolean isEnabled)
Sets whether or not this wrapper and its wrapped component are enabled.

Specified by:
setEnabled in interface Displayable
Overrides:
setEnabled in class DisplayPanel
Parameters:
isEnabled - whether or not this wrapper and its wrapped component are enabled
See Also:
Displayable

setWrappedComponent

public void setWrappedComponent(Component component)
Sets the wrapped component to the given component.

Parameters:
component - the component to be wrapped
Throws:
NullPointerException - if the given component is null
See Also:
getWrappedComponent()

getWrappedComponent

public Component getWrappedComponent()
Returns the wrapped component.

See Also:
setWrappedComponent(Component)

setAbsoluteSize

public void setAbsoluteSize(Dimension size)
Sets the minimum, maximum, and preferred sizes for the wrapped component to the given Dimension. If the given Dimension is null, the current minimum, maximum, and preferred sizes are not changed. If either the width or height of the given Dimension is negative, it is set to zero.

Parameters:
size - the new minimum, maximum, and preferred size
See Also:
setAbsoluteSize(int, int)

setAbsoluteSize

public void setAbsoluteSize(int width,
                            int height)
Sets the minimum, maximum, and preferred sizes for the wrapped component to the given width and height. If either the given width or height is negative, it is set to zero.

Parameters:
width - the new minimum, maximum, and preferred width
height - the new minimum, maximum, and preferred height
See Also:
setAbsoluteSize(Dimension)

setMinimumSize

public void setMinimumSize(Dimension size)
Sets the minimum size for the wrapped component to a copy of the given Dimension. If the given Dimension is null, the minimum size is set to a Dimension with zero width and height. If the width or the height of the given minimum size is greater than the corresponding component of the maximum size then the maximum size is adjusted.

Overrides:
setMinimumSize in class JComponent
Parameters:
size - the new minimum size
See Also:
setMinimumSize(int, int), getMinimumSize()

setMinimumSize

public void setMinimumSize(int width,
                           int height)
Sets the minimum size for the wrapped component to the given width and height. If the width or the height of the given minimum size is greater than the corresponding component of the maximum size then the maximum size is adjusted.

Parameters:
width - the new minimum width
height - the new minimum height
See Also:
setMinimumSize(Dimension), getMinimumSize()

getMinimumSize

public Dimension getMinimumSize()
Returns the minimum size for the wrapped component.

Overrides:
getMinimumSize in class JComponent
See Also:
setMinimumSize(int, int), setMinimumSize(Dimension)

setMaximumSize

public void setMaximumSize(Dimension size)
Sets the maximum size for the wrapped component to a copy of the given Dimension. If the given Dimension is null, the maximum size is set to a Dimension with the maximum width and height representable by int values. If the width or the height of the given maximum size is smaller than the corresponding component of the minimum size then the minimum size is adjusted.

Overrides:
setMaximumSize in class JComponent
Parameters:
size - the new maximum size
See Also:
setMaximumSize(int, int), getMaximumSize()

setMaximumSize

public void setMaximumSize(int width,
                           int height)
Sets the maximum size for the wrapped component to the given width and height. If the width or the height of the given maximum size is smaller than the corresponding component of the minimum size then the minimum size is adjusted.

Parameters:
width - the new maximum width
height - the new maximum height
See Also:
setMaximumSize(Dimension), getMaximumSize()

getMaximumSize

public Dimension getMaximumSize()
Returns the maximum size for the wrapped component.

Overrides:
getMaximumSize in class JComponent
See Also:
setMaximumSize(int, int), setMaximumSize(Dimension)

setPreferredSize

public void setPreferredSize(Dimension size)
Sets the preferred size for the wrapped component to the given Dimension. If the given preferred size is null, the current preferred size is not changed. The given preferred size will be restricted by the current minimum and maximum sizes for the wrapped component when the parent container for this wrapper is laid out.

Overrides:
setPreferredSize in class JComponent
Parameters:
size - the new preferred size
See Also:
setPreferredSize(int, int), getPreferredSize()

setPreferredSize

public void setPreferredSize(int width,
                             int height)
Sets the preferred size for the wrapped component to the given width and height. The given preferred size will be restricted by the current minimum and maximum sizes for the wrapped component when the parent container for this wrapper is laid out.

Parameters:
width - the new preferred width
height - the new preferred height
See Also:
setPreferredSize(Dimension), getPreferredSize()

getPreferredSize

public Dimension getPreferredSize()
Returns the preferred size for the wrapped component.

Overrides:
getPreferredSize in class JComponent
See Also:
setPreferredSize(int, int), setPreferredSize(Dimension)

setAlignment

public void setAlignment(int alignment)
Sets the alignment for this wrapper to the alignment designated by the given value. If the layout for this wrapper has been set to a layout that is not a AlignedLayout, this operation does nothing.

Parameters:
alignment - the alignment for this wrapper
Since:
1.1
See Also:
getAlignment(), JPTConstants.DEFAULT

getAlignment

public int getAlignment()
Returns the alignment for this wrapper. If the layout for this wrapper has been set to a layout that is not an instance of AlignedLayout, this operation returns -1.

Since:
1.1
See Also:
setAlignment(int)