edu.neu.ccs.gui
Class ZooGroup

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.ZooContainer
                          extended byedu.neu.ccs.gui.ZooGroup
All Implemented Interfaces:
Accessible, AlertListener, Displayable, EventListener, ImageObserver, JPTConstants, MalformedDataListener, MenuContainer, Serializable, SwingConstants

public class ZooGroup
extends ZooContainer

Associative collection of components contained within a Zoo. Groups may be nested to an arbitrary depth.

By default, a group has a transparent background and its bounds are determined by the union of the bounds for the components it groups. When a group is resized, its contained components are scaled accordingly so that they maintain the same relative size and location within the group. The minimum and maximum sizes for a group are determined by minimum and maximum scaling factors that can be applied to the contained components without violating the minimum and maximum sizes for any of the contained components.

This panel assumes an AbsoluteLayout. Behavior is undefined if this panel is set to have a layout other than an AbsoluteLayout.

A grouped component resized through direct manipulation will appear to scale in size as the group is resized, whether or not the component will actually scale in size when the resize is completed. If the parent container for the grouped component does not scale its contents, the grouped component will snap back to its original size when the resize is completed.

Since:
1.1
Version:
2.2
See Also:
Zoo, 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
protected  Dimension oldSize
          Previous size of the group before a direct manipulation resize was initiated.
protected  AffineTransform transform
          Temporary transform applied to the graphics context for this group during a direct manipulation resize.
 
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
ZooGroup(Vector v)
          Creates a new group containing the given vector of components.
 
Method Summary
 void addNotify()
          Called when the native peer for this group is created.
protected  Dimension calculateMaximumSize()
          Returns the minimum size for this group, calculated from its current size and the smallest ratio of maximum size to current size among the contained components.
protected  Dimension calculateMinimumSize()
          Returns the minimum size for this group, calculated from its current size and the largest ratio of minimum size to current size among the contained components.
(package private)  void endResize()
          Completes a direct manipulation resize.
private  Rectangle getBoundingBox(Component[] c)
          Returns the union of the bounds of the given components.
 void paint(Graphics g)
          Paints this group to the given graphics context.
private  void revalidate(Component c)
          Revalidates the given component, if appropriate.
 void setBounds(int x, int y, int width, int height)
          Sets the bounds of this group to the given position, width and height.
 void setBounds(Rectangle bounds)
          Sets the bounds of this group to the given rectangle.
private  void setBoundsImpl(int x, int y, int width, int height)
          Resizes this group and its contained components.
 void setLocation(int x, int y)
          Sets the location of this group to the given position.
 void setLocation(Point p)
          Sets the location of this group to the given point.
 void setSize(Dimension size)
          Sets the size of this group to the given dimension.
 void setSize(int width, int height)
          Sets the size of this group to the given width and height.
(package private)  void startResize()
          Initiates a direct manipulation resize.
private  void updateBoundsRestrictions()
          Updates the stored minimum and maximum sizes for this group.
 
Methods inherited from class edu.neu.ccs.gui.ZooContainer
addChildItem, addChildItem, bringToFront, findChildItemAt, findChildItemAt, findItemAt, findItemAt, getAncestorZoo, getChildItem, getChildItemCount, getChildItems, getItem, getItemCount, getItems, getParentContainer, getRootZoo, group, inverseGetChildItem, inverseGetItem, isFocusTraversable, isManagingFocus, moveDown, moveToZOrder, moveUp, nextDeeperInZOrder, nextHigherInZOrder, removeAllItems, removeChildItem, removeChildItem, sendToBack, ungroup
 
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, getViewState, 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, setDefaultViewState, setDefaultViewStates, setEnabled, setViewState, 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, 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, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, 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, 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, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setName, 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

oldSize

protected Dimension oldSize
Previous size of the group before a direct manipulation resize was initiated.


transform

protected AffineTransform transform
Temporary transform applied to the graphics context for this group during a direct manipulation resize.

Constructor Detail

ZooGroup

public ZooGroup(Vector v)
Creates a new group containing the given vector of components.

Parameters:
v - a vector of components to group
Method Detail

setLocation

public void setLocation(int x,
                        int y)
Sets the location of this group to the given position.

Parameters:
x - the x-coordinate of the desired position
y - the y-coordinate of the desired position
See Also:
setLocation(Point)

setLocation

public void setLocation(Point p)
Sets the location of this group to the given point.

Parameters:
p - the desired point
See Also:
setLocation(int, int)

setSize

public void setSize(int width,
                    int height)
Sets the size of this group to the given width and height.

Parameters:
width - the width of the desired size
height - the height of the desired size
See Also:
setSize(Dimension)

setSize

public void setSize(Dimension size)
Sets the size of this group to the given dimension.

Parameters:
size - the desired size
See Also:
setSize(int, int)

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Sets the bounds of this group to the given position, width and height.

Parameters:
x - the x-coordinate of the desired position
y - the y-coordinate of the desired position
width - the width of the desired size
height - the height of the desired size
See Also:
setBounds(Rectangle)

setBounds

public void setBounds(Rectangle bounds)
Sets the bounds of this group to the given rectangle.

Parameters:
bounds - the desired bounds
See Also:
setBounds(int, int, int, int)

addNotify

public void addNotify()
Called when the native peer for this group is created.


paint

public void paint(Graphics g)
Paints this group to the given graphics context.

Parameters:
g - the graphics context to which to paint

calculateMinimumSize

protected Dimension calculateMinimumSize()
Returns the minimum size for this group, calculated from its current size and the largest ratio of minimum size to current size among the contained components.

See Also:
calculateMaximumSize()

calculateMaximumSize

protected Dimension calculateMaximumSize()
Returns the minimum size for this group, calculated from its current size and the smallest ratio of maximum size to current size among the contained components.

See Also:
calculateMinimumSize()

startResize

void startResize()
Initiates a direct manipulation resize.


endResize

void endResize()
Completes a direct manipulation resize.


updateBoundsRestrictions

private void updateBoundsRestrictions()
Updates the stored minimum and maximum sizes for this group.


setBoundsImpl

private void setBoundsImpl(int x,
                           int y,
                           int width,
                           int height)
Resizes this group and its contained components.


getBoundingBox

private Rectangle getBoundingBox(Component[] c)
Returns the union of the bounds of the given components.


revalidate

private void revalidate(Component c)
Revalidates the given component, if appropriate.