public class Tableau.Anchor extends Object implements Serializable
Anchor
objects encapsulate the presence of
Paintable
objects including spot and dimension on the
Tableau
.Modifier and Type | Field and Description |
---|---|
protected Dimension |
dim
The element's dimension within the tableau.
|
protected Paintable |
element
The Paintable element &qout;moored".
|
protected Point |
loc
The element's spot (left upper corner) in the Tableau.
|
Constructor and Description |
---|
Anchor(Paintable element,
int x,
int y,
int width,
int height)
Constructor with setting; centred.
|
Anchor(Paintable element,
Point loc,
Dimension dim)
Constructor with setting.
|
Anchor(Paintable element,
Point loc,
int width,
int height)
Constructor with setting.
|
Modifier and Type | Method and Description |
---|---|
Dimension |
getDim()
The element's dimension within the tableau.
|
Paintable |
getElement()
The Paintable element &qout;moored".
|
Point |
getLoc()
The element's spot (left upper corner) in the Tableau.
|
int |
getX()
The element's spot (left upper corner) in the Tableau, X coordinate.
|
int |
getY()
The element's spot (left upper corner) in the Tableau, Y coordinate.
|
boolean |
isPaintable()
Determine if paintable.
|
void |
moveLoc(int dx,
int dy)
Move the spot.
|
void |
newDim(int width,
int height)
Set the element's dimension within the tableau.
|
void |
newLoc(int x,
int y)
Set the spot.
|
boolean |
pointInside(Point p,
int s)
Is a point within this anchor.
|
void |
setDim(Dimension dim)
Set the element's dimension within the tableau.
|
void |
setDim(int width,
int height)
Set the element's dimension within the tableau.
|
void |
setElement(Paintable element)
Set the Paintable element &qout;moored".
|
void |
setLoc(int x,
int y)
Set the spot.
|
void |
setLoc(Point loc)
Set the spots.
|
protected Paintable element
protected Point loc
protected Dimension dim
public Anchor(Paintable element, Point loc, Dimension dim)
element
- the element paintable within the tableauloc
- its place (0,0) is left upper;dim
- its dimensions;public Anchor(Paintable element, Point loc, int width, int height)
public Anchor(Paintable element, int x, int y, int width, int height)
dim
and loc
will be made accordingly. The loc
made in the end
will as usual point to the element's upper left corner.element
- the element paintable within the tableaux
- its place (x, y) as centre of the elementy
- its place (x, y) as centre of the elementwidth
- the element's widthheight
- the element's heightpublic Paintable getElement()
public void setElement(Paintable element)
public Point getLoc()
public int getX()
public int getY()
public void setLoc(Point loc)
loc
- will be taken as reference, (no copy/clone here)getLoc()
public void setLoc(int x, int y)
x
- coordinatey
- coordinategetLoc()
,
newLoc(int, int)
,
setLoc(Point)
public void newLoc(int x, int y)
loc
will
be made.) loc
shared with other Anchor
objects, those will not move.x
- coordinatey
- coordinatesetLoc(int, int)
public void moveLoc(int dx, int dy)
loc
will
be made. Is the object loc
being shared with other
Anchor objects, those will move too.dx
- coordinate deltady
- coordinate deltapublic Dimension getDim()
public void setDim(Dimension dim)
dim
- this reference will be taken (no copy / clone will be made)setDim(int, int)
public void setDim(int width, int height)
width
- sizeheight
- sizesetDim(Dimension)
,
newDim(int, int)
public void newDim(int width, int height)
setDim(int, int)
,
setDim(Dimension)
public boolean isPaintable()
loc
) and dimension (dim
) have to
exist, and the rectangle described by loc
and
dim
has to be within the tableau — at least
partly: one pixel is enough.public boolean pointInside(Point p, int s)
p
- the point in question.s
- widening the "hit area" to at least s * s pixel (if smaller)