geofasc.swing.model
public abstract class DefaultFigureModel extends Object implements FigureModel
DefaultFigureModel
is the default implementation of
FigureModel
.Constructor and Description |
---|
DefaultFigureModel() |
Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(ChangeListener l)
Adds a listener to this model which is notified on model changes.
|
abstract Rectangle |
getBounds()
Gets the bounds (size and location) of this model's figure.
|
Rectangle |
getBounds(Rectangle bounds)
Gets the bounds (size and location) of this model's figure.
|
double |
getDirection()
Gets the direction (in degrees) of this model's figure.
|
Color |
getFillColor()
Gets the fill color of this model's figure used when drawing it (has to
be set extra).
|
int |
getHeight()
Gets the height of this model's figure
|
Color |
getLineColor()
Gets the outer line color of this model's figure used when drawing it.
|
Point |
getLocation()
Gets the location as point of this model's figure.
|
int |
getLocationX()
Gets the x-location of this model's figure.
|
int |
getLocationY()
Gets the y-location of this model's figure.
|
Dimension |
getSize()
Gets the size (width and height) of this model's figure.
|
int |
getWidth()
Gets the width of this model's figure.
|
boolean |
isFilled()
Determines whether this model's figure is filled when it is drawn.
|
void |
moveLocationBy(int pixels)
Moves the location of this model's figure by the given length (as pixels)
dependent on the direction of movement.
|
void |
moveLocationBy(int dx,
int dy)
Moves the location of this model's figure in
x- and
y- direction by dx and dy
respectively. |
void |
moveLocationBy(Point dPoint)
Moves the location of this model's figure in
x- and
y- direction as given by dPoint . |
void |
moveLocationXBy(int dx)
Moves the location of this model's figure in
x- direction by
dx . |
void |
moveLocationYBy(int dy)
Moves the location of this model's figure in
y- direction by
dy . |
void |
removeChangeListener(ChangeListener l)
Removes a previously added listener from the model.
|
void |
setDirection(double direction)
Sets the direction (in degrees) of this model's figure.
|
void |
setFillColor(Color fillColor)
Sets the fill color of this model's figure.
|
void |
setFilled(boolean isFilled)
Sets whether this model's figure is filled when it is drawn.
|
void |
setLineColor(Color lineColor)
Sets the outer line color of this model's figure used when drawing it.
|
void |
setLocation(int x,
int y)
Sets the location of this model's figure.
|
void |
setLocation(Point p)
Sets the location of this model's figure.
|
void |
setLocationX(int x)
Sets the x-location of this model's figure.
|
void |
setLocationY(int y)
Sets the y-location of this model's figure.
|
void |
turnDirectionBy(double dDirection)
Turns the current direction (in degrees) of this model's figure by the
given delta direction.
|
void |
turnDirectionTo(double direction)
Turns the direction (in degrees) of this model's figure to the given
direction.
|
public void addChangeListener(ChangeListener l)
addChangeListener
in interface FigureModel
l
- the listener to be added to this modelpublic abstract Rectangle getBounds()
getBounds
in interface FigureModel
FigureModel.getBounds(Rectangle)
,
FigureModel.getLocation()
,
FigureModel.getSize()
public Rectangle getBounds(Rectangle bounds)
getBounds
in interface FigureModel
bounds
- if not null this object will be overwritten with the bounds of
the figure and returned, otherwise a new object is returnedFigureModel.getBounds()
,
FigureModel.getLocation()
,
FigureModel.getSize()
public double getDirection()
getDirection
in interface FigureModel
public Color getFillColor()
getFillColor
in interface FigureModel
FigureModel.setFilled(boolean)
public int getHeight()
getHeight
in interface FigureModel
FigureModel.getWidth()
,
FigureModel.getSize()
public Color getLineColor()
getLineColor
in interface FigureModel
public Point getLocation()
getLocation
in interface FigureModel
FigureModel.getLocationX()
,
FigureModel.getLocationY()
public int getLocationX()
getLocationX
in interface FigureModel
FigureModel.getLocationY()
,
FigureModel.getLocation()
public int getLocationY()
getLocationY
in interface FigureModel
FigureModel.getLocationX()
,
FigureModel.getLocation()
public Dimension getSize()
getSize
in interface FigureModel
FigureModel.getWidth()
,
FigureModel.getHeight()
public int getWidth()
getWidth
in interface FigureModel
FigureModel.getHeight()
,
FigureModel.getSize()
public boolean isFilled()
isFilled
in interface FigureModel
FigureModel.setFilled(boolean)
,
FigureModel.setFillColor(Color)
public void moveLocationBy(int pixels)
moveLocationBy
in interface FigureModel
pixels
- the pixels to move byFigureModel.setDirection(double)
,
FigureModel.turnDirectionBy(double)
,
FigureModel.turnDirectionTo(double)
public void moveLocationBy(int dx, int dy)
x-
and
y-
direction by dx
and dy
respectively.moveLocationBy
in interface FigureModel
dx
- the delta-x
to move the x-
location
bydy
- the delta-y
to move the y-
location
byFigureModel.moveLocationBy(Point)
,
FigureModel.moveLocationXBy(int)
,
FigureModel.moveLocationYBy(int)
public void moveLocationBy(Point dPoint)
x-
and
y-
direction as given by dPoint
.moveLocationBy
in interface FigureModel
dPoint
- the delta-point
to move the location byFigureModel.moveLocationBy(int, int)
,
FigureModel.moveLocationXBy(int)
,
FigureModel.moveLocationYBy(int)
public void moveLocationXBy(int dx)
x-
direction by
dx
.moveLocationXBy
in interface FigureModel
dx
- the delta-x
to move the x-
location
byFigureModel.moveLocationYBy(int)
,
FigureModel.moveLocationBy(int, int)
,
FigureModel.moveLocationBy(Point)
public void moveLocationYBy(int dy)
y-
direction by
dy
.moveLocationYBy
in interface FigureModel
dy
- the delta-y
to move the y-
location
byFigureModel.moveLocationXBy(int)
,
FigureModel.moveLocationBy(int, int)
,
FigureModel.moveLocationBy(Point)
public void removeChangeListener(ChangeListener l)
removeChangeListener
in interface FigureModel
l
- the listener to be removedFigureModel.addChangeListener(ChangeListener)
public void setDirection(double direction)
setDirection
in interface FigureModel
direction
- the new directionpublic void setFillColor(Color fillColor)
setFillColor
in interface FigureModel
fillColor
- the new fill colorFigureModel.setFilled(boolean)
public void setFilled(boolean isFilled)
setFilled
in interface FigureModel
isFilled
- true or falseFigureModel.setFillColor(Color)
public void setLineColor(Color lineColor)
setLineColor
in interface FigureModel
lineColor
- the new line colorpublic void setLocation(int x, int y)
setLocation
in interface FigureModel
x
- the new x-locationy
- the new y-locationFigureModel.setLocation(Point)
,
FigureModel.setLocationX(int)
,
FigureModel.setLocationY(int)
public void setLocation(Point p)
setLocation
in interface FigureModel
p
- the new locationFigureModel.setLocation(int, int)
,
FigureModel.setLocationX(int)
,
FigureModel.setLocationY(int)
public void setLocationX(int x)
setLocationX
in interface FigureModel
x
- the new x-locationFigureModel.setLocationY(int)
,
FigureModel.setLocation(Point)
,
FigureModel.setLocation(int, int)
public void setLocationY(int y)
setLocationY
in interface FigureModel
y
- the new y-locationFigureModel.setLocationX(int)
,
FigureModel.setLocation(Point)
,
FigureModel.setLocation(int, int)
public void turnDirectionBy(double dDirection)
turnDirectionBy
in interface FigureModel
dDirection
- the delta-direction
to turn the current direction
bypublic void turnDirectionTo(double direction)
turnDirectionTo
in interface FigureModel
direction
- the new direction to turn to