edu.neu.ccs.gui
Class Laminate

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--edu.neu.ccs.gui.Laminate
All Implemented Interfaces:
ComponentListener, EventListener, ImageObserver, MenuContainer, Serializable

public class Laminate
extends JComponent
implements ComponentListener

Component used to "laminate" an existing component by mimicing its size and location and always maintaining a higher z-order, in order to impart mouse handling without intervention by the laminated component.

Since:
1.1
See Also:
Serialized Form

Field Summary
 
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 java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Laminate(Component c, boolean isActivated)
          Constructs a laminate for the given component.
 
Method Summary
 void componentHidden(ComponentEvent evt)
          Called when the laminated component is hidden.
 void componentMoved(ComponentEvent evt)
          Called when the laminated component is moved.
 void componentResized(ComponentEvent evt)
          Called when the laminated component is resized.
 void componentShown(ComponentEvent evt)
          Called when the laminated component is shown.
 MouseActionAdapter getMouseActionAdapter()
          Returns the mouse action adapter for this laminate.
 Component getTarget()
          Returns the component this laminate is covering.
protected  Zoo getZoo()
          Returns the zoo containing this laminate.
protected  boolean inE(int x, int y, int delta)
          Returns true if the given position is in the right-hand middle of this component within the given constraint, and false otherwise.
protected  boolean inS(int x, int y, int delta)
          Returns true if the given position is in the bottom middle of this component within the given constraint, and false otherwise.
protected  boolean inSE(int x, int y, int delta)
          Returns true if the given position is in the bottom right-hand corner of this component within the given constraint, and false otherwise.
protected  void installCursorActions()
          Installs the mouse actions that affect the mouse cursor for this laminate.
protected  void installManipulationActions()
          Installs the mouse actions that affect manipulation of this laminate.
protected  void installMouseAdapter()
          Installs the mouse action adapter for this laminate.
protected  void installSelectionActions()
          Installs the mouse actions that affect selection of this laminate.
 boolean isActivated()
          Returns whether or not this laminate is activated.
 boolean isMoveable()
          Returns true if this laminate can be moved to another location using direct manipulation and false if it can not be moved.
protected  boolean isResizableX()
          Returns true if the target component is resizeable in the horizontal direction, and false if it is not.
protected  boolean isResizableXY()
          Returns true if the target component is resizeable in both the horizontal and vertical directions, and false if it is not.
protected  boolean isResizableY()
          Returns true if the target component is resizeable in the vertical direction, and false if it is not.
 boolean isResizeable()
          Returns true if this laminate can be resized using direct manipulation and false if it can not be resized.
 boolean isSelected()
          Returns whether or not this laminate is selected.
protected  void moveTo(MouseEvent evt)
          Moves this laminate and its covered component based on the given mouse event.
protected  void paintComponent(Graphics g)
          Paints a selection box around this laminate, if this laminate is selected.
protected  void resizeTo(MouseEvent evt)
          Resizes this laminate and its covered component based on the given mouse event.
protected  Rectangle restrictBounds(int x, int y, int width, int height)
          Restricts the given proposed bounds based on the zoo in which this laminate is contained.
 void setActivated(boolean isActivated)
          Sets whether or not this laminate handles mouse events targeted for the covered component.
 void setBounds(int x, int y, int width, int height)
          Sets the bounds of this laminate and its laminated component to the given position, width, and height.
 void setBounds(Rectangle bounds)
          Sets the bounds of this laminate and its laminated component to the given bounds.
 void setLocation(int x, int y)
          Sets the location of this laminate and its laminated component to the given position.
 void setLocation(Point p)
          Sets the location of this laminate and its laminated component to the given point.
 void setMoveable(boolean isMoveable)
          Sets whether or not this laminate can be moved to another location using direct manipulation to the given value.
 void setResizeable(boolean isResizeable)
          Sets whether or not this laminate can be resized using direct manipulation, to the given value.
protected  void setResizing(boolean xAxis, boolean yAxis)
          Sets on which axis(es) this component is being resized.
 void setSelected(boolean isSelected)
          Sets whether or not this laminate is selected.
 void setSize(Dimension size)
          Sets the size of this laminate and its laminated component to the given size.
 void setSize(int width, int height)
          Sets the size of this laminate and its laminated component to the given width and height.
 void setTarget(Component c)
          Sets the target component this laminate is covering to the given component.
protected  void startMoveAt(MouseEvent evt)
          Sets the point at which a move is initiated based on the given mouse event.
 
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, getAccessibleContext, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, 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, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, 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, remove, remove, removeAll, 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, 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
 

Constructor Detail

Laminate

public Laminate(Component c,
                boolean isActivated)
Constructs a laminate for the given component.

Parameters:
c - a component to laminate
isActivated - whether or not this laminate is activated
Method Detail

componentHidden

public void componentHidden(ComponentEvent evt)
Called when the laminated component is hidden.

Specified by:
componentHidden in interface ComponentListener

componentMoved

public void componentMoved(ComponentEvent evt)
Called when the laminated component is moved.

Specified by:
componentMoved in interface ComponentListener

componentResized

public void componentResized(ComponentEvent evt)
Called when the laminated component is resized.

Specified by:
componentResized in interface ComponentListener

componentShown

public void componentShown(ComponentEvent evt)
Called when the laminated component is shown.

Specified by:
componentShown in interface ComponentListener

setTarget

public void setTarget(Component c)
Sets the target component this laminate is covering to the given component. If the given component is null, this laminate will not cover a component

Parameters:
c - a component to laminate
See Also:
getTarget()

getTarget

public Component getTarget()
Returns the component this laminate is covering.

See Also:
setTarget(Component)

setActivated

public void setActivated(boolean isActivated)
Sets whether or not this laminate handles mouse events targeted for the covered component.

Parameters:
isActivated - whether or not this laminate should handle mouse events
See Also:
isActivated()

isActivated

public boolean isActivated()
Returns whether or not this laminate is activated.

See Also:
setActivated(boolean)

setSelected

public void setSelected(boolean isSelected)
Sets whether or not this laminate is selected.

Parameters:
isSelected - whether or not this laminate is to be selected
See Also:
isSelected()

isSelected

public boolean isSelected()
Returns whether or not this laminate is selected.

See Also:
setSelected(boolean)

getMouseActionAdapter

public MouseActionAdapter getMouseActionAdapter()
Returns the mouse action adapter for this laminate.


setLocation

public void setLocation(int x,
                        int y)
Sets the location of this laminate and its laminated component to the given position.

Overrides:
setLocation in class Component
Parameters:
x - the x-coordinate of the position to which to move this laminate
y - the y-coordinate of the position to which to move this laminate
See Also:
setLocation(Point)

setLocation

public void setLocation(Point p)
Sets the location of this laminate and its laminated component to the given point.

Overrides:
setLocation in class Component
Parameters:
p - the point to which to move this laminate
See Also:
setLocation(int, int)

setSize

public void setSize(int width,
                    int height)
Sets the size of this laminate and its laminated component to the given width and height.

Overrides:
setSize in class Component
Parameters:
width - the width to which to size this laminate
height - the height to which to size this laminate
See Also:
setSize(Dimension)

setSize

public void setSize(Dimension size)
Sets the size of this laminate and its laminated component to the given size.

Overrides:
setSize in class Component
Parameters:
size - the size for this laminate
See Also:
setSize(int, int)

setBounds

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

Overrides:
setBounds in class Component
Parameters:
x - the x-coordinate for the bounds for this laminate
y - the y-coordinate for the bounds for this laminate
width - the width for the bounds of this laminate
height - the height for the bounds of this laminate
See Also:
setBounds(Rectangle)

setBounds

public void setBounds(Rectangle bounds)
Sets the bounds of this laminate and its laminated component to the given bounds.

Overrides:
setBounds in class Component
Parameters:
bounds - the new bounds for this laminate
See Also:
setBounds(int, int, int, int)

setMoveable

public void setMoveable(boolean isMoveable)
Sets whether or not this laminate can be moved to another location using direct manipulation to the given value. The setLocation method is not affected by this property.

Parameters:
isMoveable - whether or not this laminate can be moved
Since:
2.0
See Also:
isMoveable()

isMoveable

public boolean isMoveable()
Returns true if this laminate can be moved to another location using direct manipulation and false if it can not be moved. The setLocation method is not affected by this property.

Since:
2.0
See Also:
setMoveable(boolean)

setResizeable

public void setResizeable(boolean isResizeable)
Sets whether or not this laminate can be resized using direct manipulation, to the given value. Methods such as setSize are not affected by this property.

Parameters:
isResizeable - whether or not this laminate can be sized
Since:
2.0
See Also:
isResizeable()

isResizeable

public boolean isResizeable()
Returns true if this laminate can be resized using direct manipulation and false if it can not be resized. Methods such as setSize are not affected by this property.

Since:
2.0
See Also:
setResizeable(boolean)

paintComponent

protected void paintComponent(Graphics g)
Paints a selection box around this laminate, if this laminate is selected.

Overrides:
paintComponent in class JComponent
Parameters:
g - the graphics context to which to paint

getZoo

protected Zoo getZoo()
Returns the zoo containing this laminate.


installMouseAdapter

protected void installMouseAdapter()
Installs the mouse action adapter for this laminate.


installSelectionActions

protected void installSelectionActions()
Installs the mouse actions that affect selection of this laminate.


installCursorActions

protected void installCursorActions()
Installs the mouse actions that affect the mouse cursor for this laminate.


installManipulationActions

protected void installManipulationActions()
Installs the mouse actions that affect manipulation of this laminate.


startMoveAt

protected void startMoveAt(MouseEvent evt)
Sets the point at which a move is initiated based on the given mouse event.

Parameters:
evt - the mouse event initiating the move

restrictBounds

protected Rectangle restrictBounds(int x,
                                   int y,
                                   int width,
                                   int height)
Restricts the given proposed bounds based on the zoo in which this laminate is contained.

Parameters:
x - the x-coordinate of the proposed bounds
y - the y-coordinate of the proposed bounds
width - the width of the proposed bounds
height - the height of the proposed bounds

moveTo

protected void moveTo(MouseEvent evt)
Moves this laminate and its covered component based on the given mouse event.

Parameters:
evt - the mouse event initiating the move

resizeTo

protected void resizeTo(MouseEvent evt)
Resizes this laminate and its covered component based on the given mouse event.

Parameters:
evt - the mouse event initiating the resize

setResizing

protected void setResizing(boolean xAxis,
                           boolean yAxis)
Sets on which axis(es) this component is being resized.

Parameters:
xAxis - whether or not it is resizing on the x-axis
yAxis - whether or not it is resizing on the y-axis

isResizableX

protected boolean isResizableX()
Returns true if the target component is resizeable in the horizontal direction, and false if it is not.

See Also:
isResizableY(), isResizableXY()

isResizableY

protected boolean isResizableY()
Returns true if the target component is resizeable in the vertical direction, and false if it is not.

See Also:
isResizableX(), isResizableXY()

isResizableXY

protected boolean isResizableXY()
Returns true if the target component is resizeable in both the horizontal and vertical directions, and false if it is not.

Since:
2.1
See Also:
isResizableX(), isResizableY()

inSE

protected boolean inSE(int x,
                       int y,
                       int delta)
Returns true if the given position is in the bottom right-hand corner of this component within the given constraint, and false otherwise.

See Also:
inS(int, int, int), inE(int, int, int)

inS

protected boolean inS(int x,
                      int y,
                      int delta)
Returns true if the given position is in the bottom middle of this component within the given constraint, and false otherwise.

See Also:
inSE(int, int, int), inE(int, int, int)

inE

protected boolean inE(int x,
                      int y,
                      int delta)
Returns true if the given position is in the right-hand middle of this component within the given constraint, and false otherwise.

See Also:
inSE(int, int, int), inS(int, int, int)