public class EditableLine2D extends Line2D.Double implements EditableShape
Line2D.Double, Line2D.Float
x1, x2, y1, y2
Constructor and Description |
---|
EditableLine2D(double x1,
double y1,
double x2,
double y2)
Creates new EditableLine2D
|
EditableLine2D(Point2D p1,
Point2D p2) |
Modifier and Type | Method and Description |
---|---|
void |
aproximateNearestBorder(double x,
double y)
Moves towards a specific point the side of the shape that is located nearest it.
.
|
void |
changeBorder(double x,
double y)
Changes the co-ordinates of the previously marked corner to (x, y)
|
Object |
clone()
Makes a copy of the shape.
|
void |
deselectBorder()
Unselects the selected border of the shape, if any.
|
double |
distanceTo(double x,
double y)
Computes the distance between a supplied point and the nearest limit of the shape.
|
EditableShape[] |
divide(double x,
double y)
Divides the shape taking (x,y) as the "significant" point of the division.
|
void |
drawBorders(Graphics g)
Draws the shape with dragable sides
|
Point2D[] |
getBorders()
Gets an array with all the corners and other special points of the shape.
|
Point2D |
getEndPoint()
Gets the point of the shape that is considered as "ending" point.
|
Point2D |
getInitialPoint()
Returns the point of the shape that acts as "starting" point.
|
Point2D |
getNearestBorder(double x,
double y)
Rerturns the starting point of the side of the shape nearest to a specific point.
|
Point2D |
getNotSelectedBorder()
Gets the starting point of the first non-selected side of the shape
|
boolean |
hasClickedBorder(double x,
double y,
boolean needSelected)
Checks if the specified point lies within a side of the shape
|
boolean |
hasSelectedBorder()
Checks if the shape currently has a selected side.
|
boolean |
isAdjacentTo(Point2D p)
Checks if the shape is adjacent to a specific point.
|
boolean |
isInto(Rectangle2D r)
Checks if the shape is into the limits of a specific
Rectangle . |
boolean |
isSelected()
Checks if the shape is selected
|
void |
move(double incX,
double incY) |
void |
paint(Graphics g,
int drawingMode)
Draws the shape with the default colour
|
void |
paintSelection(Graphics g)
Draws squares in black and the remainder objects in the selection color
(EditableShapeConstants.selectedColor)
|
void |
paintWithColor(Graphics g,
int drawingMode,
Color c)
Draws the shape with the indicated color.
|
void |
selectBorder(double x,
double y)
Selects the side of the shape that lies with the specified point (if any).
|
void |
setSelected(boolean b)
Selects/unselects the shape
|
void |
transform(AffineTransform aTransf)
Applies an affine transformation (rotation, trnaslation, scale...) to the shape
|
getBounds2D, getP1, getP2, getX1, getX2, getY1, getY2, setLine
contains, contains, contains, contains, getBounds, getPathIterator, getPathIterator, intersects, intersects, intersectsLine, intersectsLine, linesIntersect, ptLineDist, ptLineDist, ptLineDist, ptLineDistSq, ptLineDistSq, ptLineDistSq, ptSegDist, ptSegDist, ptSegDist, ptSegDistSq, ptSegDistSq, ptSegDistSq, relativeCCW, relativeCCW, relativeCCW, setLine, setLine
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
contains, contains, contains, contains, getBounds, getBounds2D, getPathIterator, getPathIterator, intersects, intersects
public EditableLine2D(double x1, double y1, double x2, double y2)
public boolean isSelected()
EditableShape
isSelected
in interface EditableShape
true
if the shape is selected, false
otherwise.public void drawBorders(Graphics g)
EditableShape
drawBorders
in interface EditableShape
g
- The graphic environment where to draw the shapepublic boolean hasClickedBorder(double x, double y, boolean needSelected)
EditableShape
hasClickedBorder
in interface EditableShape
x
- The horizontal co-ordinate of the point to checky
- The vertical co-ordinate of the point to checkneedSelected
- When the value of this param is true
, the side must be selected.true
when a side of the shape is near the point defined by x and y.public void aproximateNearestBorder(double x, double y)
EditableShape
aproximateNearestBorder
in interface EditableShape
x
- The horizontal co-ordinate of the pointy
- The vertival co-ordinate of the pointpublic Point2D getNearestBorder(double x, double y)
EditableShape
getNearestBorder
in interface EditableShape
x
- The horizontal co-ordinate of the pointy
- The vertical co-ordinate of the pointpublic void setSelected(boolean b)
EditableShape
setSelected
in interface EditableShape
b
- The state (selected/unselected) of the shapepublic void paintWithColor(Graphics g, int drawingMode, Color c)
EditableShape
paintWithColor
in interface EditableShape
g
- The graphic environment where to draw the shapedrawingMode
- The drawing mode. Squares are drawed in red when this value is
ShapeGenPanel.NEW_POINTc
- The color to be used to draw the shapepublic void paint(Graphics g, int drawingMode)
EditableShape
paint
in interface EditableShape
g
- The graphic environment where to draw the shapedrawingMode
- The drawing mode. Squares are drawed in red when this value is ShapeGenPanel.NEW_POINTpublic void paintSelection(Graphics g)
EditableShape
paintSelection
in interface EditableShape
g
- The graphic environment where to draw the shapepublic void changeBorder(double x, double y)
EditableShape
changeBorder
in interface EditableShape
x
- The horizontal co-ordinate of the pointy
- The vertical co-ordinate of the pointpublic double distanceTo(double x, double y)
EditableShape
distanceTo
in interface EditableShape
x
- The horizontal co-ordinate of the pointy
- The vertical co-ordinate of the pointpublic boolean isInto(Rectangle2D r)
EditableShape
Rectangle
.isInto
in interface EditableShape
r
- The rectangle to be checkedtrue
if the shape intersects with the rectangle, false
otherwise.public void move(double incX, double incY)
public void transform(AffineTransform aTransf)
EditableShape
transform
in interface EditableShape
aTransf
- The affine transformation to be appliedpublic EditableShape[] divide(double x, double y)
EditableShape
divide
in interface EditableShape
x
- The horizontal co-ordinate of the pointy
- The vertical co-ordinate of the pointpublic boolean isAdjacentTo(Point2D p)
EditableShape
isAdjacentTo
in interface EditableShape
p
- The point to be checkedtrue
if the shape is adjacent to the point, false
otherwisepublic Point2D getEndPoint()
EditableShape
getEndPoint
in interface EditableShape
public Point2D getInitialPoint()
EditableShape
getInitialPoint
in interface EditableShape
public Object clone()
EditableShape
clone
in interface EditableShape
clone
in class Line2D
public Point2D[] getBorders()
EditableShape
getBorders
in interface EditableShape
public void selectBorder(double x, double y)
EditableShape
selectBorder
in interface EditableShape
x
- The horizontal co-ordinate of the point to checky
- The vertical co-ordinate of the point to checkpublic void deselectBorder()
EditableShape
deselectBorder
in interface EditableShape
public boolean hasSelectedBorder()
EditableShape
hasSelectedBorder
in interface EditableShape
true
if the shape has a selected side, false
otherwise.public Point2D getNotSelectedBorder()
EditableShape
getNotSelectedBorder
in interface EditableShape
Copyright © 2004-15 Francesc Busquets (fbusquets@xtec.cat) & Departament d'Educació de la Generalitat de Catalunya (info@xtec.cat)
Licensed under the terms of the GNU General Public License.