|
ChartCat 1.2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectli.netcat.chart.util.PanelPartConstraints
Immutable class that defines the positioning of parts in a PanelPart
.
The positioning is always relative to a reference. This reference can be
The relative positioning is solved by defining two points, an anchor (on the reference) and a target point (on the current part) that are separated by an absolute shift value. Loosely spoken the layout uses the following equation: anchor + shift = target.
Anchor and target point are defined as float, whereas 0.0f denotes the "left" edge and 1.0f denotes the "right" edge. Values < 0.0f and > 1.0f are also supported.
Finally the layer (Z direction) can also be defined. If two parts are in the same layer, the first added part get painted first, otherwise the one in the lower layer gets painted first.
See the tutorial for examples.
PanelPart
Field Summary | |
static PanelPartConstraints |
DEFAULT
Default constraints that can be used to derive other constraints. |
Constructor Summary | |
PanelPartConstraints(Part referenceX,
Part referenceY,
float anchorX,
float anchorY,
float targetX,
float targetY,
int shiftX,
int shiftY,
int layer)
Constructs a new instance of PanelPartConstraints using the given parameters.
|
Method Summary | |
PanelPartConstraints |
anchor(float anchorX,
float anchorY)
Constructs a new constraints object by using all properties of this instance and replacing the anchor values by the given values. |
PanelPartConstraints |
anchorCenter()
Calls anchor(0.5f, 0.5f) . |
PanelPartConstraints |
anchorEast()
Calls anchor(1.0f, 0.5f) . |
PanelPartConstraints |
anchorNorth()
Calls anchor(0.5f, 0.0f) . |
PanelPartConstraints |
anchorNorthEast()
Calls anchor(1.0f, 0.0f) . |
PanelPartConstraints |
anchorNorthWest()
Calls anchor(0.0f, 0.0f) . |
PanelPartConstraints |
anchorSouth()
Calls anchor(0.5f, 1.0f) . |
PanelPartConstraints |
anchorSouthEast()
Calls anchor(1.0f, 1.0f) . |
PanelPartConstraints |
anchorSouthWest()
Calls anchor(0.0f, 1.5f) . |
PanelPartConstraints |
anchorWest()
Calls anchor(0.0f, 0.5f) . |
float |
getAnchorX()
Returns the anchor value in x direction. |
float |
getAnchorY()
Returns the anchor value in y direction. |
int |
getLayer()
Returns the layer (Z direction). |
Part |
getReferenceX()
Returns the reference part in x direction. |
Part |
getReferenceY()
Returns the reference part in y direction. |
int |
getShiftX()
Returns the absolute shift amount that separates the target from the anchor in x direction. |
int |
getShiftY()
Returns the absolute shift amount that separates the target from the anchor in y direction. |
float |
getTargetX()
Returns the target value in x direction. |
float |
getTargetY()
Returns the target value in y direction. |
PanelPartConstraints |
layer(int layer)
Constructs a new constraints object by using all properties of this instance and replacing the layer value by the given value. |
PanelPartConstraints |
reference(Part reference)
Constructs a new constraints object by using all properties of this instance and replacing the reference in x and y direction by the given part. |
PanelPartConstraints |
reference(Part referenceX,
Part referenceY)
Constructs a new constraints object by using all properties of this instance and replacing the reference in x and y direction by the given parts. |
PanelPartConstraints |
referenceX(Part reference)
Constructs a new constraints object by using all properties of this instance and replacing the reference in x direction by the given part. |
PanelPartConstraints |
referenceY(Part reference)
Constructs a new constraints object by using all properties of this instance and replacing the reference in y direction by the given part. |
PanelPartConstraints |
shiftX(int shiftX)
Constructs a new constraints object by using all properties of this instance and replacing the shift value in x direction by the given value. |
PanelPartConstraints |
shiftY(int shiftY)
Constructs a new constraints object by using all properties of this instance and replacing the shift value in y direction by the given value. |
PanelPartConstraints |
target(float targetX,
float targetY)
Constructs a new constraints object by using all properties of this instance and replacing the target values by the given values. |
PanelPartConstraints |
targetCenter()
Calls target(0.5f, 0.5f) . |
PanelPartConstraints |
targetEast()
Calls target(1.0f, 0.5f) . |
PanelPartConstraints |
targetNorth()
Calls target(0.5f, 0.0f) . |
PanelPartConstraints |
targetNorthEast()
Calls target(1.0f, 0.0f) . |
PanelPartConstraints |
targetNorthWest()
Calls target(0.0f, 0.0f) . |
PanelPartConstraints |
targetSouth()
Calls target(0.5f, 1.0f) . |
PanelPartConstraints |
targetSouthEast()
Calls target(1.0f, 1.0f) . |
PanelPartConstraints |
targetSouthWest()
Calls target(0.0f, 1.0f) . |
PanelPartConstraints |
targetWest()
Calls target(0.0f, 0.5f) . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final PanelPartConstraints DEFAULT
DEFAULT = new PanelPartConstraints(null, null, 0.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0);To derive other constraints from this one, use the different copy methods like the following example shows:
PanelPartConstraints c = PanelPartConstraints.DEFAULT; PanelPart panel = new PanelPart(); panel.add(grid); panel.add(title, c.anchorNorth().targetSouth().shiftY(-10));The last line is equivalent to
panel.add(title, new PanelPartConstraints(null, null, 0.5f, 0.0f, 0.5f, 1.0f, 0, -10, 0));Prefer to derive constraints form other constraints instead of using the constructor.
Constructor Detail |
public PanelPartConstraints(Part referenceX, Part referenceY, float anchorX, float anchorY, float targetX, float targetY, int shiftX, int shiftY, int layer)
PanelPartConstraints
using the given parameters.
Avoid this constructor by deriving from the DEFAULT
constraints.
anchorX
- The anchor point in x direction. 0.0f refers to left, 0.5f to center and 1.0f to right.
All other values are also possible.anchorY
- The anchor point in y direction. 0.0f refers to top, 0.5f to center and 1.0f to bottom.
All other values are also possible.targetX
- The target point in x direction. 0.0f refers to left, 0.5f to center and 1.0f to right.
All other values are also possible.targetY
- The target point in y direction. 0.0f refers to top, 0.5f to center and 1.0f to bottom.
All other values are also possible.shiftX
- The absolute shift value in the x direction.shiftY
- The absolute shift value in the y direction.layer
- The Z layer. The lower the values the earlier the painting.Method Detail |
public Part getReferenceX()
null
refers to the bounding box of all already added parts.public Part getReferenceY()
null
refers to the bounding box of all already added parts.public float getAnchorX()
public float getAnchorY()
public float getTargetX()
public float getTargetY()
public int getShiftX()
public int getShiftY()
public int getLayer()
public PanelPartConstraints reference(Part reference)
reference
- The new reference, null
refers to the bounding box of all already added parts.
public PanelPartConstraints referenceX(Part reference)
reference
- The new reference in x direction, null
refers to the bounding box of all already added parts.
public PanelPartConstraints referenceY(Part reference)
reference
- The new reference in y direction, null
refers to the bounding box of all already added parts.
public PanelPartConstraints reference(Part referenceX, Part referenceY)
referenceX
- The new reference in x direction, null
refers to the bounding box of all already added parts.referenceY
- The new reference in y direction, null
refers to the bounding box of all already added parts.
public PanelPartConstraints anchor(float anchorX, float anchorY)
anchorX
- The anchor point in x direction. 0.0f refers to left, 0.5f to center and 1.0f to right.
All other values are also possible.anchorY
- The anchor point in y direction. 0.0f refers to top, 0.5f to center and 1.0f to bottom.
All other values are also possible.
public PanelPartConstraints anchorNorthWest()
anchor(0.0f, 0.0f)
.
public PanelPartConstraints anchorNorth()
anchor(0.5f, 0.0f)
.
public PanelPartConstraints anchorNorthEast()
anchor(1.0f, 0.0f)
.
public PanelPartConstraints anchorWest()
anchor(0.0f, 0.5f)
.
public PanelPartConstraints anchorCenter()
anchor(0.5f, 0.5f)
.
public PanelPartConstraints anchorEast()
anchor(1.0f, 0.5f)
.
public PanelPartConstraints anchorSouthWest()
anchor(0.0f, 1.5f)
.
public PanelPartConstraints anchorSouth()
anchor(0.5f, 1.0f)
.
public PanelPartConstraints anchorSouthEast()
anchor(1.0f, 1.0f)
.
public PanelPartConstraints target(float targetX, float targetY)
targetX
- The target point in x direction. 0.0f refers to left, 0.5f to center and 1.0f to right.
All other values are also possible.targetY
- The target point in y direction. 0.0f refers to top, 0.5f to center and 1.0f to bottom.
All other values are also possible.
public PanelPartConstraints targetNorthWest()
target(0.0f, 0.0f)
.
public PanelPartConstraints targetNorth()
target(0.5f, 0.0f)
.
public PanelPartConstraints targetNorthEast()
target(1.0f, 0.0f)
.
public PanelPartConstraints targetWest()
target(0.0f, 0.5f)
.
public PanelPartConstraints targetCenter()
target(0.5f, 0.5f)
.
public PanelPartConstraints targetEast()
target(1.0f, 0.5f)
.
public PanelPartConstraints targetSouthWest()
target(0.0f, 1.0f)
.
public PanelPartConstraints targetSouth()
target(0.5f, 1.0f)
.
public PanelPartConstraints targetSouthEast()
target(1.0f, 1.0f)
.
public PanelPartConstraints shiftX(int shiftX)
shiftX
- The absolute shift value in the x direction.
public PanelPartConstraints shiftY(int shiftY)
shiftY
- The absolute shift value in the y direction.
public PanelPartConstraints layer(int layer)
layer
- The Z layer. The lower the values the earlier the painting.
|
ChartCat 1.2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |