|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
edu.neu.ccs.gui.LayeredComponent
Class LayeredComponent encapsulates a
JComponent which is in the foreground of the panel
and a background which consists of multiple layers.
The multiple layers of the background are provided as follows:
Paint object that is used to paint
the background initially.Both the repeated tile and the topmost paintable
may be provided as general objects. In that case, they are
converted to Paintable via
ComponentFactory.makePaintable.
Any of the background layers may be null.
If all layers are null, however, this panel is
not very useful. On the other hand, if all layers are
non-null, the background may be too busy and
may overwhelm the foreground. Hence, this facility must be
used with good taste.
The user of this class should not add additional components to an instance of this class beyond those installed by the constructor of the instance and should not change the layout manager. Methods of the class will permit the paint, the repeat tile, the topmost paintable, and the opacity to be changed, and when this happens the panel will repaint.
When the foreground JComponent is passed to the
constructor of this class, the opaqueness of the foreground is
set to false via setOpaque(false). This is what
allows the background to show through. This call is not made
recursively since it is up to the user of this class to decide
what to do about opaqueness inside the foreground component.
Experiment has shown that, for some Java components, things do not render properly if the opaqueness is set to false. This problem, if it occurs, cannot be resolved by this class. Hence, thorough testing is recommended.
| 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 boolean |
centered
Whether or not the topmost object should be centered. |
protected XPoint2D |
corner
The corner of the topmost object. |
protected JComponent |
foreground
The foreground component on which this layered component is built. |
protected PaintableComponent |
lowerLayer
The lower layer of this layered component. |
protected Tile |
tile1
The innermost Tile helper object. |
protected Tile |
tile2
The outermost Tile helper object. |
protected Paintable |
tilePaintable
The paintable used as the tile. |
protected Paintable |
topmostPaintable
The paintable used as the topmost object. |
| 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 | |
LayeredComponent(JComponent foreground,
Object topmost,
Object tile,
Paint paint,
float opacity,
boolean centered)
Constructs a LayeredComponent. |
|
| Method Summary | |
Paint |
getBackgroundPaint()
Gets the background paint for the bottom layer of this layered component. |
Paintable |
getBackgroundTile()
Gets the tile paintable object for the middle layer of this layered component. |
float |
getOpacity()
Gets the opacity of the background layers of this layered component. |
Paintable |
getTopmostPaintable()
Gets the topmost background paintable object of this layered component. |
boolean |
isCentered()
Gets whether or not the topmost background object is centered in this layered component. |
void |
setBackgroundPaint(Paint paint)
Sets the background paint for the bottom layer of this layered component. |
void |
setBackgroundTile(Object tile)
Sets the tile paintable object for the middle layer of this layered component. |
void |
setCentered(boolean centered)
Sets whether or not the topmost background object is centered in this layered component. |
void |
setOpacity(float opacity)
Sets the opacity of the background layers of this layered component. |
void |
setTopmostPaintable(Object topmost)
Sets the topmost background paintable object of this layered component. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected JComponent foreground
protected PaintableComponent lowerLayer
protected Paintable topmostPaintable
protected Paintable tilePaintable
protected XPoint2D corner
protected Tile tile1
protected Tile tile2
protected boolean centered
| Constructor Detail |
public LayeredComponent(JComponent foreground,
Object topmost,
Object tile,
Paint paint,
float opacity,
boolean centered)
Constructs a LayeredComponent.
See the introduction to this class for detailed discussion.
foreground - the foreground componenttopmost - the paintable in the topmost background layertile - the paintable to tile the middle background layerpaint - the paint to paint the bottom background layeropacity - the opacity of the background layerscentered - whether or not the topmost object is centered| Method Detail |
public void setTopmostPaintable(Object topmost)
Sets the topmost background paintable object of this layered component.
The topmost object is an object which should either be
null or be an object that is convertible to a
Paintable using
ComponentFactory.makePaintable.
topmost - the topmost background paintable objectpublic Paintable getTopmostPaintable()
Gets the topmost background paintable object of this layered component.
public void setBackgroundTile(Object tile)
Sets the tile paintable object for the middle layer of this layered component.
The tile tile object is an object which should either be
null or be an object that is convertible to a
Paintable using
ComponentFactory.makePaintable.
tile - the tile paintable objectpublic Paintable getBackgroundTile()
Gets the tile paintable object for the middle layer of this layered component.
public void setBackgroundPaint(Paint paint)
Sets the background paint for the bottom layer of this layered component.
paint - the background paint for the bottom layerpublic Paint getBackgroundPaint()
Gets the background paint for the bottom layer of this layered component.
public void setOpacity(float opacity)
opacity - the opacity of the background layerspublic float getOpacity()
public void setCentered(boolean centered)
centered - the centered setting for the topmost background objectpublic boolean isCentered()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||