|
||||||||||
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 ShapeMethod Detail |
public void hide()
hide
in interface Graphic
public void show()
show
in interface Graphic
public 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 Graphic
g
- the Graphics2D for us to use.protected abstract void actualPaint(Graphics2D g)
public void setColor(Color color)
setColor
in interface Colorable
color
- the Color
for the Shapepublic Color getColor()
getColor
in interface Colorable
Color
for the ShapesetColor
public void setDrawingPanel(DrawingPanel dp)
setDrawingPanel
in interface Graphic
dp
- the new DrawingPanel for the ShapegetDrawingPanel
public DrawingPanel getDrawingPanel()
getDrawingPanel
in interface Graphic
setDrawingPanel
public boolean contains(Point p)
contains
in interface Graphic
p
- the Point to check for containment
true
if the Point is within the shape, otherwise
false
public boolean intersects(Graphic g)
Graphic
intersects with this
Shape
.
intersects
in interface Graphic
g
- the Graphic
we are testing against
true
if it does intersect, false
if notgetBounds
public void setRotation(int degrees)
setRotation
in interface Rotatable
degrees
- the degrees (clockwise) to rotate the ShapegetRotation
public int getRotation()
getRotation
in interface Rotatable
setRotation
public Rectangle getBounds()
getBounds
in interface Graphic
public Point getCenterLocation()
getCenterLocation
in interface Graphic
public void react()
react
in interface Reactor
public void drag(MouseEvent e)
public void mouseClicked(MouseEvent e)
react
will be called.
mouseClicked
in interface MouseListener
public void mouseDragged(MouseEvent e)
drag
will be called.
mouseDragged
in interface MouseMotionListener
public void mouseEntered(MouseEvent e)
mouseEntered
in interface MouseListener
public void mouseExited(MouseEvent e)
mouseExited
in interface MouseListener
public void mousePressed(MouseEvent e)
mousePressed
in interface MouseListener
public void mouseReleased(MouseEvent e)
mouseReleased
in interface MouseListener
public void mouseMoved(MouseEvent e)
mouseMoved
in interface MouseMotionListener
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |