geofasc.swing.model
public interface FigureModel
FigureModel
is the interface for the data model of a
2-dimensional figure primarily maintaining information about its size and its
location.
In this model the size and location of a figure is interpreted as the size
and location of its bounding box (also called bounds). The
bounding box of a figure is the rectangle of minimum area size that encloses
the whole figure. At least its area is needed by a visualizing component to
show the figure entirely. In turn the location of the bounding box is given
by the point (with x-
and y-
coordinates) of its
top-left corner with respect to the 2-dimensional coordinate system of the
figure's parent component. Its size is given by its width
and
height
Besides this basic geometric information, the model also provides a few
common visual properties, e.g., the figure's line color or fill color. Access
for all the mentioned information is provided by appropriate methods (and
convenience methods allowing also partial access) except methods for changing
the size. This makes sense since the bounding box is defined by the figure
and not vice versa. Otherwise changing the bounding box would have influence
on changing the figure itself.Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(ChangeListener listener)
Adds a listener to this model which is notified on model changes.
|
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 listener)
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.
|
void addChangeListener(ChangeListener listener)
listener
- the listener to be added to this modelRectangle getBounds()
getBounds(Rectangle)
,
getLocation()
,
getSize()
Rectangle getBounds(Rectangle bounds)
bounds
- if not null this object will be overwritten with the bounds of
the figure and returned, otherwise a new object is returnedgetBounds()
,
getLocation()
,
getSize()
double getDirection()
Color getFillColor()
setFilled(boolean)
int getHeight()
getWidth()
,
getSize()
Color getLineColor()
Point getLocation()
getLocationX()
,
getLocationY()
int getLocationX()
getLocationY()
,
getLocation()
int getLocationY()
getLocationX()
,
getLocation()
Dimension getSize()
getWidth()
,
getHeight()
int getWidth()
getHeight()
,
getSize()
boolean isFilled()
setFilled(boolean)
,
setFillColor(Color)
void moveLocationBy(int pixels)
pixels
- the pixels to move bysetDirection(double)
,
turnDirectionBy(double)
,
turnDirectionTo(double)
void moveLocationBy(int dx, int dy)
x-
and
y-
direction by dx
and dy
respectively.dx
- the delta-x
to move the x-
location
bydy
- the delta-y
to move the y-
location
bymoveLocationBy(Point)
,
moveLocationXBy(int)
,
moveLocationYBy(int)
void moveLocationBy(Point dPoint)
x-
and
y-
direction as given by dPoint
.dPoint
- the delta-point
to move the location bymoveLocationBy(int, int)
,
moveLocationXBy(int)
,
moveLocationYBy(int)
void moveLocationXBy(int dx)
x-
direction by
dx
.dx
- the delta-x
to move the x-
location
bymoveLocationYBy(int)
,
moveLocationBy(int, int)
,
moveLocationBy(Point)
void moveLocationYBy(int dy)
y-
direction by
dy
.dy
- the delta-y
to move the y-
location
bymoveLocationXBy(int)
,
moveLocationBy(int, int)
,
moveLocationBy(Point)
void removeChangeListener(ChangeListener listener)
listener
- the listener to be removedaddChangeListener(ChangeListener)
void setDirection(double direction)
direction
- the new directionvoid setFillColor(Color fillColor)
fillColor
- the new fill colorsetFilled(boolean)
void setFilled(boolean isFilled)
isFilled
- true or falsesetFillColor(Color)
void setLineColor(Color lineColor)
lineColor
- the new line colorvoid setLocation(int x, int y)
x
- the new x-locationy
- the new y-locationsetLocation(Point)
,
setLocationX(int)
,
setLocationY(int)
void setLocation(Point p)
p
- the new locationsetLocation(int, int)
,
setLocationX(int)
,
setLocationY(int)
void setLocationX(int x)
x
- the new x-locationsetLocationY(int)
,
setLocation(Point)
,
setLocation(int, int)
void setLocationY(int y)
y
- the new y-locationsetLocationX(int)
,
setLocation(Point)
,
setLocation(int, int)
void turnDirectionBy(double dDirection)
dDirection
- the delta-direction
to turn the current direction
byvoid turnDirectionTo(double direction)
direction
- the new direction to turn to