geofasc.swing.model
public class DefaultPolylineModel extends DefaultFigureModel implements PolylineModel
DefaultPolylineModel
is the default implementation of
PolylineModel
. This class is inherited from
DefaultFigureModel
.Constructor and Description |
---|
DefaultPolylineModel() |
Modifier and Type | Method and Description |
---|---|
boolean |
addPoint(int x,
int y)
Adds a point to this model's poly[gon|line].
|
boolean |
addPoint(int index,
int x,
int y)
Adds a point to this model's poly[gon|line] at the specified index.
|
boolean |
addPoint(int index,
Point point)
Adds a point to this model's poly[gon|line] at the specified index.
|
boolean |
addPoint(Point point)
Adds a point to this model's poly[gon|line].
|
Rectangle |
getBounds()
Gets the bounds (size and location) of this model's figure.
|
int |
getIndexOfPoint(int x,
int y)
Gets the index of the point of this model's poly[gon|line] with the given
coordinates.
|
int |
getIndexOfPoint(Point point)
Gets the index of the point of this model's poly[gon|line].
|
int |
getNumberOfPoints()
Gets the total number of points defining this model's poly[gon|line].
|
Point |
getPoint(int index)
Gets the point of this model's poly[gon|line] with the given index.
|
Point[] |
getPoints()
Gets all points of this model's poly[gon|line].
|
int[] |
getXPoints()
Gets all x-locations of all points of this model's poly[gon|line].
|
int[] |
getYPoints()
Gets all y-locations of all points of this model's poly[gon|line].
|
boolean |
isClosed()
Determines whether this model's polyline is closed.
|
boolean |
removePoint(int index)
Removes the point with the given index from this model's poly[gon|line].
|
boolean |
removePoint(int x,
int y)
Removes the point with the given coordinates from this model's
poly[gon|line].
|
boolean |
removePoint(Point point)
Removes the given point from this model's poly[gon|line].
|
Point |
setPoint(int index,
int x,
int y)
Substitutes the point with the given index by a new one.
|
Point |
setPoint(int index,
Point point)
Substitutes the point with the given index by a new one.
|
boolean |
setPoints(Point[] points)
Substitutes all the points of this model's poly[gon|line].
|
Polygon |
toAWTPolygon() |
addChangeListener, getBounds, getDirection, getFillColor, getHeight, getLineColor, getLocation, getLocationX, getLocationY, getSize, getWidth, isFilled, moveLocationBy, moveLocationBy, moveLocationBy, moveLocationXBy, moveLocationYBy, removeChangeListener, setDirection, setFillColor, setFilled, setLineColor, setLocation, setLocation, setLocationX, setLocationY, turnDirectionBy, turnDirectionTo
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addChangeListener, getBounds, getDirection, getFillColor, getHeight, getLineColor, getLocation, getLocationX, getLocationY, getSize, getWidth, isFilled, moveLocationBy, moveLocationBy, moveLocationBy, moveLocationXBy, moveLocationYBy, removeChangeListener, setDirection, setFillColor, setFilled, setLineColor, setLocation, setLocation, setLocationX, setLocationY, turnDirectionBy, turnDirectionTo
public boolean addPoint(int x, int y)
addPoint
in interface PolylineModel
x
- the x-location of the new pointy
- the y-location of the new pointpublic boolean addPoint(int index, int x, int y)
addPoint
in interface PolylineModel
index
- the index the new point is added tox
- the x-location of the new pointy
- the y-location of the new pointpublic boolean addPoint(int index, Point point)
addPoint
in interface PolylineModel
index
- the index the new point is added topoint
- the new pointpublic boolean addPoint(Point point)
addPoint
in interface PolylineModel
point
- the new pointpublic Rectangle getBounds()
DefaultFigureModel
getBounds
in interface FigureModel
getBounds
in class DefaultFigureModel
FigureModel.getBounds(Rectangle)
,
FigureModel.getLocation()
,
FigureModel.getSize()
public int getIndexOfPoint(int x, int y)
getIndexOfPoint
in interface PolylineModel
x
- the x-location of the pointy
- the y-location of the pointpublic int getIndexOfPoint(Point point)
getIndexOfPoint
in interface PolylineModel
point
- the point whose index is computedpublic int getNumberOfPoints()
getNumberOfPoints
in interface PolylineModel
public Point getPoint(int index)
getPoint
in interface PolylineModel
index
- the index of the pointpublic Point[] getPoints()
getPoints
in interface PolylineModel
public int[] getXPoints()
getXPoints
in interface PolylineModel
public int[] getYPoints()
getYPoints
in interface PolylineModel
public boolean isClosed()
isClosed
in interface PolylineModel
public boolean removePoint(int index)
removePoint
in interface PolylineModel
index
- the index of the point to removepublic boolean removePoint(int x, int y)
removePoint
in interface PolylineModel
x
- the x-location of the pointy
- the y-location of the pointpublic boolean removePoint(Point point)
removePoint
in interface PolylineModel
point
- the point to removepublic Point setPoint(int index, int x, int y)
setPoint
in interface PolylineModel
index
- the index of the point to be substitutedx
- the x-locationy
- the y-locationpublic Point setPoint(int index, Point point)
setPoint
in interface PolylineModel
index
- the index of the point to be substitutedpoint
- the new pointpublic boolean setPoints(Point[] points)
setPoints
in interface PolylineModel
points
- the new pointspublic Polygon toAWTPolygon()
toAWTPolygon
in interface PolylineModel