|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectNGP.Graphics.Shape
A geometric object that knows how to draw itself on the screen.
| Field Summary | |
protected Shape |
_awtShape
The AWT geometric shape used for drawing |
protected DrawingPanel |
_dpanel
The DrawingPanel that contains this Shape |
| Fields inherited from interface NGP.Colorable |
DEFAULT_GRAY |
| Constructor Summary | |
Shape(DrawingPanel dpanel,
Shape s)
Create a Shape with the specified DrawingPanel |
|
| Method Summary | |
protected abstract void |
actualPaint(Graphics2D g)
Subclasses will define how painting actually works, filled or framed |
boolean |
contains(Point p)
Determine if a Point is within this shape. |
void |
drag(MouseEvent e)
Override to do something useful. |
Rectangle |
getBounds()
Find the bounding rectangle of this Shape. |
Point |
getCenterLocation()
Return the Point that represents the center of the bounding rectangle of this shape. |
Color |
getColor()
Get the color of the Shape |
DrawingPanel |
getDrawingPanel()
Return the DrawingPanel for this Shape |
int |
getRotation()
Get the rotation of the Shape. |
void |
hide()
Hide the Shape so it won't be drawn anymore (NGP will lose it's reference to it). |
boolean |
intersects(Graphic g)
Determine if the passed in Graphic intersects with this
Shape. |
void |
mouseClicked(MouseEvent e)
Called when the Panel detects that the mouse was clicked. |
void |
mouseDragged(MouseEvent e)
Called when the Panel detects that the mouse was dragged. |
void |
mouseEntered(MouseEvent e)
Called when the Panel detects that the mouse entered. |
void |
mouseExited(MouseEvent e)
Called when the Panel detects that the mouse exited. |
void |
mouseMoved(MouseEvent e)
Called when the Panel detects that the mouse was moved. |
void |
mousePressed(MouseEvent e)
Called when the Panel detects that the mouse was pressed. |
void |
mouseReleased(MouseEvent e)
Called when the Panel detects that the mouse was released. |
void |
paint(Graphics2D g)
Normal users need not use this! |
void |
react()
Override to do something useful. |
void |
setColor(Color color)
Set the color of the Shape |
void |
setDrawingPanel(DrawingPanel dp)
Set the DrawingPanel of this Shape so that it appears somewhere else. |
void |
setRotation(int degrees)
Set the rotation of the Shape. |
void |
show()
Show the shape so it will be drawn (NGP now has a reference to it). |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected DrawingPanel _dpanel
protected Shape _awtShape
| Constructor Detail |
public Shape(DrawingPanel dpanel,
Shape s)
dpanel - the DrawingPanel for this Shape| Method Detail |
public void hide()
hide in interface Graphicpublic void show()
show in interface Graphicpublic void paint(Graphics2D g)
This is how we draw graphics using Java. First set the color of the Graphics Context. Then find out what rotation we want, the finally paint. Then reset the rotation if necessary.
paint in interface Graphicg - the Graphics2D for us to use.protected abstract void actualPaint(Graphics2D g)
public void setColor(Color color)
setColor in interface Colorablecolor - the Color for the Shapepublic Color getColor()
getColor in interface ColorableColor for the ShapesetColorpublic void setDrawingPanel(DrawingPanel dp)
setDrawingPanel in interface Graphicdp - the new DrawingPanel for the ShapegetDrawingPanelpublic DrawingPanel getDrawingPanel()
getDrawingPanel in interface GraphicsetDrawingPanelpublic boolean contains(Point p)
contains in interface Graphicp - the Point to check for containment
true if the Point is within the shape, otherwise
falsepublic boolean intersects(Graphic g)
Graphic intersects with this
Shape.
intersects in interface Graphicg - the Graphic we are testing against
true if it does intersect, false
if notgetBoundspublic void setRotation(int degrees)
setRotation in interface Rotatabledegrees - the degrees (clockwise) to rotate the ShapegetRotationpublic int getRotation()
getRotation in interface RotatablesetRotationpublic Rectangle getBounds()
getBounds in interface Graphicpublic Point getCenterLocation()
getCenterLocation in interface Graphicpublic void react()
react in interface Reactorpublic void drag(MouseEvent e)
public void mouseClicked(MouseEvent e)
react
will be called.
mouseClicked in interface MouseListenerpublic void mouseDragged(MouseEvent e)
drag
will be called.
mouseDragged in interface MouseMotionListenerpublic void mouseEntered(MouseEvent e)
mouseEntered in interface MouseListenerpublic void mouseExited(MouseEvent e)
mouseExited in interface MouseListenerpublic void mousePressed(MouseEvent e)
mousePressed in interface MouseListenerpublic void mouseReleased(MouseEvent e)
mouseReleased in interface MouseListenerpublic void mouseMoved(MouseEvent e)
mouseMoved in interface MouseMotionListener
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||