|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectks.common.view.Widget
For all view.* entities, this is the superclass that defines important concepts.
The widget is drawn at location (x,y) extending width pixels to the right and height pixels down.
Every widget has an associated CardImages object to retrieve cards and the card reverse image. When a widget is initially constructed, it is marked as 'dirty'.
Constructor Summary | |
Widget(Element me)
Default constructor for Widgets. |
Method Summary | |
java.awt.Rectangle |
getBounds()
Return the bounds of the Widget as a newly instantiated rectangle. |
CardImages |
getCardImages()
Return the Cards of this widget. |
Container |
getContainer()
Return the container for this Widget. |
int |
getHeight()
Return the height of the widget. |
java.awt.Image |
getImage()
Return the image of this Widget (used for drawing the Widget on screen). |
Element |
getModelElement()
Return the Model Element associated with this Widget. |
MouseManager |
getMouseManager()
Return the MouseManager associated with this Widget. |
java.lang.String |
getName()
Return the name of this widget. |
int |
getWidth()
Return the width of the widget. |
int |
getX()
Return the x coordinate for the Widget's location. |
java.awt.Point |
getXY()
Return the (x,y) coordinates of top-left corner of Widget as a Point. |
int |
getY()
Return the y coordinate for the Widget's location. |
boolean |
inBounds(java.awt.Point p)
If (x,y) point is within this widget, return true, else false. |
boolean |
isDirty()
Determine whether this widget needs to be recalculated. |
void |
modelChanged(Element e)
Respond to underlying changes in this widget's model. |
void |
paint()
Default paint() method for a widget is to draw in peer's Graphics Context. |
void |
paint(java.awt.Graphics g)
Each widget must contain the logic to visually represent itself into the given Graphics context. |
void |
paint(java.awt.Graphics g,
java.awt.Rectangle clip)
Each widget must contain the logic to visually represent itself into the given Graphics context. |
abstract void |
redraw()
Redraws the view from the model. |
void |
refresh()
Refresh is an optimized command that only redraws the widget if it is dirty. |
void |
refresh(java.awt.Rectangle clip)
Refresh is an optimized command that only redraws the widget if it is dirty. |
boolean |
returnWidget(Widget w)
Each Widget presents the graphical representation of an entity element. |
void |
setBounds(int x,
int y,
int width,
int height)
Set the graphical bounds for this widget within the Container. |
void |
setBounds(java.awt.Rectangle r)
Set the graphical bounds for this widget within the Container using a Rectangle. |
void |
setContainer(Container container)
All Widget objects need to know the Container within which they will be made visible. |
void |
setDirty(boolean newDirty)
Determines whether this widget's screen representation needs to be recalculated. |
void |
setHeight(int newHeight)
Set the height of this widget. |
void |
setImage(java.awt.Image newImage)
To update the image as shown by this widget, the subclass will create an off-screen image and call this method. |
void |
setMouseAdapter(java.awt.event.MouseAdapter ma)
Alter the way in which this Widget reacts to MouseEvents. |
void |
setMouseManager(MouseManager mm)
Set the aggregate entity that consolidates MouseAdapter and MouseMotionAdapter. |
void |
setMouseMotionAdapter(java.awt.event.MouseMotionAdapter ma)
Alter the way in which this Widget's MouseManager reacts to MouseMotion events. |
void |
setName(java.lang.String newName)
Set the name for this Widget. |
void |
setUndoAdapter(UndoAdapter ua)
Alter the way in which this Widget reacts to UndoRequested events. |
void |
setWidth(int newWidth)
Set the width of this Widget. |
void |
setX(int newX)
Set the X position of the widget. |
void |
setXY(int x,
int y)
Set the (x,y) position of the widget. |
void |
setY(int newY)
Set the Y position of the widget. |
java.lang.String |
toString()
Return String representation of the given View Widget. |
java.awt.Point |
translate(java.awt.Point p)
Return new Point object that translates p into local widget coordinates. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Widget(Element me)
me
- ks.common.model.ElementMethod Detail |
public java.awt.Rectangle getBounds()
public Container getContainer()
public int getHeight()
public java.awt.Image getImage()
public Element getModelElement()
public MouseManager getMouseManager()
At some point in the future, this manager will return boolean to signal whether it processed the event or not. This will allow us to produce a layered approach to controllers. Develop MouseMotionController, MouseController in controller package just for this purpose.
public CardImages getCardImages()
public java.lang.String getName()
public int getWidth()
public int getX()
public java.awt.Point getXY()
public int getY()
public boolean inBounds(java.awt.Point p)
p
- java.awt.Point
public boolean isDirty()
public void modelChanged(Element e)
See ElementListener.
modelChanged
in interface ElementListener
e
- ks.common.model.Elementpublic void paint()
If no Container
is associated with this widget, an IllegalArgumentException
is thrown.
Creation date: (10/1/01 7:33:33 PM)
public void paint(java.awt.Graphics g)
Graphics
context. Paint is an imperative command that forces the
widget to draw itself.
If the widget is dirty, or if it has never been drawn before, then it is redrawn before being painted to the screen, and is marked as clean.
g
- java.awt.Graphicspublic void paint(java.awt.Graphics g, java.awt.Rectangle clip)
Clip to this clip rectangle [clip is unaffected by this invocation.]
If the widget is dirty, or if it has never been drawn before, then it is redrawn before being painted to the screen. Because this method only paints within the specified clipping region, we are unable to definitively assert that the widget is clean, so the dirty status of the Widget is unaffected by this method invocation.
g
- java.awt.Graphicsclip
- java.awt.Rectanglepublic abstract void redraw()
public void refresh()
public void refresh(java.awt.Rectangle clip)
Clip to the specified rectangle [clip is unaffected.]
clip
- java.awt.Rectanglepublic boolean returnWidget(Widget w)
CardView
, then this
returnWidget()
method would return the card back onto the underlying
Column.
This method as provided returns true
in all cases; simply override it
in your Widget subclass as you deem appropriate.
This method will only work if the extraction methods, shown above, actually call the setDragSource() on the container when the initial extraction takes place.
w
- ks.common.view.Widget
public void setBounds(int x, int y, int width, int height)
x
- inty
- intwidth
- intheight
- intpublic void setBounds(java.awt.Rectangle r)
r
- java.awt.Rectanglepublic void setContainer(Container container)
This method sets the cards
field so that the widget knows the cards
to be used for drawing.
container
- Containerpublic void setDirty(boolean newDirty)
newDirty
- booleanpublic void setHeight(int newHeight)
newHeight
- intpublic void setImage(java.awt.Image newImage)
This sets the dirty state of the Widget.
newImage
- java.awt.Imagepublic void setMouseAdapter(java.awt.event.MouseAdapter ma)
Add our own MouseController so we can return boolean values.
ma
- java.awt.event.MouseAdapterpublic void setMouseManager(MouseManager mm)
Add our own Controllers so we can return boolean values.
mm
- MouseManagerpublic void setMouseMotionAdapter(java.awt.event.MouseMotionAdapter ma)
Add our own MouseMotionController
ma
- java.awt.event.MouseMotionAdapterpublic void setName(java.lang.String newName)
newName
- java.lang.Stringpublic void setUndoAdapter(UndoAdapter ua)
Change this to be UndoController to be consistent with everything else in the universe!
ua
- java.awt.event.UndoAdapterpublic void setWidth(int newWidth)
newWidth
- intpublic void setX(int newX)
newX
- intpublic void setXY(int x, int y)
x
- inty
- intpublic void setY(int newY)
newY
- intpublic java.lang.String toString()
If this method is called on the EmptyWidget, then "[EMPTYWIDGET]" is returned.
public java.awt.Point translate(java.awt.Point p)
p
- java.awt.Point
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |