|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Container
|
+--javax.swing.JComponent
|
+--edu.neu.ccs.gui.JPTComponent
|
+--edu.neu.ccs.gui.PaintableComponent
Class PaintableComponent encapsulates a
Paintable and uses that paintable to define the
PaintComponent method and to determine the size
of the component.
This class also implements the Icon interface.
| Field Summary | |
static String |
SET_PAINTABLE
Bound property name for set paintable. |
| 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 | |
PaintableComponent(Paintable paintable)
This constructor provides the paintable needed to define the component. |
|
PaintableComponent(Paintable paintable,
Color color)
This constructor provides the paintable needed to define the component, and the optional background color. |
|
PaintableComponent(Paintable paintable,
Color color,
boolean opaque)
This constructor provides the paintable needed to define the component, the optional background color, and the opacity setting. |
|
PaintableComponent(Paintable paintable,
Color color,
boolean opaque,
Border border)
This constructor provides the paintable needed to define the component, the optional background color, the opacity setting, and the component border. |
|
| Method Summary | |
Rectangle2D |
getDefaultBounds2D()
Returns the default bounds for the component using the information in the encapsulated paintable and the insets if any. |
Point |
getDefaultLocation()
Returns the default location for the component using the information in the encapsulated paintable and the insets if any. |
int |
getIconHeight()
Returns the icon height which is the height of the bounds region of the encapsulated paintable. |
int |
getIconWidth()
Returns the icon width which is the width of the bounds region of the encapsulated paintable. |
Dimension |
getMaximumSize()
Returns the same dimension as getPreferredSize. |
Dimension |
getMinimumSize()
Returns the same dimension as getPreferredSize. |
Paintable |
getPaintable()
Returns the encapsulated paintable. |
Dimension |
getPreferredSize()
Returns the preferred size of the component based on the bounds of the encapsulated paintable and the component insets if any. |
Dimension |
getSize()
Returns the same dimension as getPreferredSize. |
protected void |
paintComponent(Graphics g)
Overrides the inherited paintComponent method to
paint the background if the component is set to be opaque and
then to use the paintable to paint the component details. |
void |
paintIcon(Component c,
Graphics g,
int x,
int y)
Draw this object as an icon at the specified location using the paintable to paint the icon details. |
void |
refresh()
Sets the component location and size using the information in the given paintable and then refreshes the component by repacking the parent window. |
void |
setPaintable(Paintable paintable)
Sets the encapsulated paintable to the given paintable and refreshes the screen provided the component is installed in a GUI. |
| Methods inherited from class edu.neu.ccs.gui.JPTComponent |
addForwardingListener, addPropertyChangeListeners, addPropertyChangeListeners, firePropertyChange, firePropertyChange, getForwardingListener, getKeyActionAdapter, getMouseActionAdapter, hasListeners, refreshComponent, removeAndAddForwardingListener, removeForwardingListener |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final String SET_PAINTABLE
| Constructor Detail |
public PaintableComponent(Paintable paintable)
This constructor provides the paintable needed to define the component.
Throws NullPointerException if the given paintable
is null.
paintable - the paintable to encapsulatePaintableComponent(Paintable, Color),
PaintableComponent(Paintable, Color, boolean),
PaintableComponent(Paintable, Color, boolean, Border)
public PaintableComponent(Paintable paintable,
Color color)
This constructor provides the paintable needed to define the component, and the optional background color.
Throws NullPointerException if the given paintable
is null.
Ignores the given color if it is null.
The background will not be painted unless the opaque property is also set to true.
paintable - the paintable to encapsulatecolor - the optional background colorPaintableComponent(Paintable),
PaintableComponent(Paintable, Color, boolean),
PaintableComponent(Paintable, Color, boolean, Border)
public PaintableComponent(Paintable paintable,
Color color,
boolean opaque)
This constructor provides the paintable needed to define the component, the optional background color, and the opacity setting.
Throws NullPointerException if the given paintable
is null.
Ignores the given color if it is null.
If the given value of opaque is true, then the background color is painted on the component area before painting the paintable.
paintable - the paintable to encapsulatecolor - the optional background coloropaque - whether or not to paint the component backgroundPaintableComponent(Paintable),
PaintableComponent(Paintable, Color),
PaintableComponent(Paintable, Color, boolean, Border)
public PaintableComponent(Paintable paintable,
Color color,
boolean opaque,
Border border)
This constructor provides the paintable needed to define the component, the optional background color, the opacity setting, and the component border.
Throws NullPointerException if the given paintable
is null.
Ignores the given color if it is null.
If the given value of opaque is true, then the background color is painted on the component area before painting the paintable.
Ignores the given border if it is null.
paintable - the paintable to encapsulatecolor - the optional background coloropaque - whether or not to paint the component backgroundborder - the border for the componentPaintableComponent(Paintable),
PaintableComponent(Paintable, Color),
PaintableComponent(Paintable, Color, boolean)| Method Detail |
public void setPaintable(Paintable paintable)
Sets the encapsulated paintable to the given paintable and refreshes the screen provided the component is installed in a GUI.
Does nothing if the given paintable is null or if it is
the same object as the encapsulated paintable.
Fires property change: SET_PAINTABLE.
paintable - the paintable to encapsulatepublic Paintable getPaintable()
Returns the encapsulated paintable.
public Rectangle2D getDefaultBounds2D()
Returns the default bounds for the component using the information in the encapsulated paintable and the insets if any.
A LayoutManager may change the actual bounds of the component in a GUI to satisfy layout decisions.
public Point getDefaultLocation()
Returns the default location for the component using the information in the encapsulated paintable and the insets if any.
A LayoutManager may change the actual location of the component in a GUI to satisfy layout decisions.
public Dimension getPreferredSize()
Returns the preferred size of the component based on the bounds of the encapsulated paintable and the component insets if any.
getPreferredSize in class JComponentpublic Dimension getMinimumSize()
Returns the same dimension as getPreferredSize.
getMinimumSize in class JComponentpublic Dimension getMaximumSize()
Returns the same dimension as getPreferredSize.
getMaximumSize in class JComponentpublic Dimension getSize()
Returns the same dimension as getPreferredSize.
getSize in class Componentpublic int getIconWidth()
Returns the icon width which is the width of the bounds region of the encapsulated paintable.
This width ignores the insets of the object viewed as a component.
getIconWidth in interface Iconpublic int getIconHeight()
Returns the icon height which is the height of the bounds region of the encapsulated paintable.
This height ignores the insets of the object viewed as a component.
getIconHeight in interface Icon
public void paintIcon(Component c,
Graphics g,
int x,
int y)
Draw this object as an icon at the specified location using the paintable to paint the icon details.
If the component parameter c is non-null,
if it is set to opaque, and if its background color is
non-null, then the background color will be
painted before the icon is painted.
Does nothing if the graphics context parameter g is
null.
paintIcon in interface Iconc - the component on which the icon will be paintedg - the graphics context on which to paintx - the x-locationy - the y-locationprotected void paintComponent(Graphics g)
Overrides the inherited paintComponent method to
paint the background if the component is set to be opaque and
then to use the paintable to paint the component details.
Note: The javadocs for JComponent claim that the
the component background is painted if the opaque setting is true.
This is not always the case in practice. In this class, we take
care to see that the opaque setting is always respected.
paintComponent in class JComponentg - the graphics context of the component that will be copied
prior to any paint operationspublic void refresh()
Sets the component location and size using the information in the given paintable and then refreshes the component by repacking the parent window.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||