edu.neu.ccs.gui
Class ShapeCapsule

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byedu.neu.ccs.gui.ShapeCapsule
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class ShapeCapsule
extends JComponent

A JComponent encapsulating a shape, and acting as its view.

Since:
1.1
Version:
2.2
See Also:
Serialized Form

Nested Class Summary
 
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  Paint paint
          Paint used to render the encapsulated shape.
protected  Shape shape
          Encapsulated shape for this component.
 
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 java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ShapeCapsule(Shape shape)
          Constructs an encapsulation of the given shape.
ShapeCapsule(Shape shape, Paint color)
          Constructs an encapsulation of the given shape to be rendered using the given color or paint.
 
Method Summary
 Paint getPaint()
          Returns the color or paint used to render this component.
 Shape getShape()
          Returns a clone of the encapsulated shape.
protected  void paintComponent(Graphics g)
          Paints this component to the given graphics context.
 void setBounds(int x, int y, int width, int height)
          Sets the location and size of this component to the given coordinate location, width, and height.
 void setBounds(Rectangle bounds)
          Sets the location and size of this component to the location and size of the given rectangle.
private  void setBoundsImpl(int x, int y, int width, int height)
          Sets the bounds of this component.
 void setLocation(int x, int y)
          Sets the absolute location of this component to the given coordinate location.
 void setLocation(Point location)
          Sets the absolute location of this component to the given location.
 void setPaint(Paint color)
          Sets the color or paint used to render this component to the given color or paint.
 void setShape(Shape s)
          Sets the encapsulated shape for this component to a clone of the given shape.
 void setSize(Dimension size)
          Sets the size of this component to the given size.
 void setSize(int width, int height)
          Sets the size of this component to the given width and height.
 
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
 

Field Detail

shape

protected Shape shape
Encapsulated shape for this component.


paint

protected Paint paint
Paint used to render the encapsulated shape.

Constructor Detail

ShapeCapsule

public ShapeCapsule(Shape shape)
Constructs an encapsulation of the given shape.

Parameters:
shape - the shape to encapsulate

ShapeCapsule

public ShapeCapsule(Shape shape,
                    Paint color)
Constructs an encapsulation of the given shape to be rendered using the given color or paint.

Parameters:
shape - the shape to encapsulate
color - the color or paint of the shape
Method Detail

setShape

public void setShape(Shape s)
Sets the encapsulated shape for this component to a clone of the given shape. If the given shape is null, the encapsulated shape is not changed.

Parameters:
s - the shape to be encapsulated
See Also:
getShape()

getShape

public Shape getShape()
Returns a clone of the encapsulated shape.

See Also:
setShape(Shape)

setPaint

public void setPaint(Paint color)
Sets the color or paint used to render this component to the given color or paint.

Parameters:
color - the color or paint to use for rendering
See Also:
getPaint()

getPaint

public Paint getPaint()
Returns the color or paint used to render this component.

See Also:
setPaint(Paint)

setLocation

public void setLocation(Point location)
Sets the absolute location of this component to the given location.

Parameters:
location - the location for this component
See Also:
setLocation(int, int)

setLocation

public void setLocation(int x,
                        int y)
Sets the absolute location of this component to the given coordinate location.

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

setSize

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

Parameters:
size - the size for this component
See Also:
setSize(int, int)

setSize

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

Parameters:
width - the width for this component
height - the height for this component
See Also:
setSize(Dimension)

setBounds

public void setBounds(Rectangle bounds)
Sets the location and size of this component to the location and size of the given rectangle.

Parameters:
bounds - the bounds for this component
See Also:
setBounds(int, int, int, int)

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Sets the location and size of this component to the given coordinate location, width, and height.

Parameters:
x - the x-coordinate of the location
y - the y-coordinate of the location
width - the width for this component
height - the height for this component
See Also:
setBounds(Rectangle)

paintComponent

protected void paintComponent(Graphics g)
Paints this component to the given graphics context.

Parameters:
g - the graphics context to which to paint

setBoundsImpl

private void setBoundsImpl(int x,
                           int y,
                           int width,
                           int height)
Sets the bounds of this component.

Parameters:
x - the x-coordinate for this component
y - the y-coordinate for this component
width - the width for this component
height - the height for this component