ChartCat 1.2

li.netcat.chart.util
Class PanelPartConstraints

java.lang.Object
  extended byli.netcat.chart.util.PanelPartConstraints

public final class PanelPartConstraints
extends java.lang.Object

Immutable class that defines the positioning of parts in a PanelPart. The positioning is always relative to a reference. This reference can be

A very important aspect of the concept is, that the references in x and in y direction are independent of each other. That means that a part can be positioned relative to another part in x direction and relative to the bounding box in y direction! This approach reduces the purpose of positioning a rectangle relative to another rectangle to something like positioning a line relative to another parallel line in the direction of the line.

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.

Author:
Arthur Marxer
See Also:
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

DEFAULT

public static final PanelPartConstraints DEFAULT
Default constraints that can be used to derive other constraints. It's constructed with the following statement:
   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

PanelPartConstraints

public 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. Avoid this constructor by deriving from the DEFAULT constraints.

Parameters:
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

getReferenceX

public Part getReferenceX()
Returns the reference part in x direction.

Returns:
The reference part in x direction. null refers to the bounding box of all already added parts.

getReferenceY

public Part getReferenceY()
Returns the reference part in y direction.

Returns:
The reference part in y direction. null refers to the bounding box of all already added parts.

getAnchorX

public float getAnchorX()
Returns the anchor value in x direction.

Returns:
The anchor value in x direction. 0.0f refers to left, 0.5f to center and 1.0f to right. All other values are also possible.

getAnchorY

public float getAnchorY()
Returns the anchor value in y direction.

Returns:
The anchor value in y direction. 0.0f refers to top, 0.5f to center and 1.0f to bottom. All other values are also possible.

getTargetX

public float getTargetX()
Returns the target value in x direction.

Returns:
The target value in x direction. 0.0f refers to left, 0.5f to center and 1.0f to right. All other values are also possible.

getTargetY

public float getTargetY()
Returns the target value in y direction.

Returns:
The target value in y direction. 0.0f refers to top, 0.5f to center and 1.0f to bottom. All other values are also possible.

getShiftX

public int getShiftX()
Returns the absolute shift amount that separates the target from the anchor in x direction.

Returns:
The shift amount in pixel.

getShiftY

public int getShiftY()
Returns the absolute shift amount that separates the target from the anchor in y direction.

Returns:
The shift amount in pixel.

getLayer

public int getLayer()
Returns the layer (Z direction).

Returns:
The layer. The lower the value the earlier the painting.

reference

public 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.

Parameters:
reference - The new reference, null refers to the bounding box of all already added parts.
Returns:
A new constraints object.

referenceX

public 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.

Parameters:
reference - The new reference in x direction, null refers to the bounding box of all already added parts.
Returns:
A new constraints object.

referenceY

public 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.

Parameters:
reference - The new reference in y direction, null refers to the bounding box of all already added parts.
Returns:
A new constraints object.

reference

public 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.

Parameters:
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.
Returns:
A new constraints object.

anchor

public 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.

Parameters:
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.
Returns:
A new constraints object.

anchorNorthWest

public PanelPartConstraints anchorNorthWest()
Calls anchor(0.0f, 0.0f).

Returns:
A new constraints object.

anchorNorth

public PanelPartConstraints anchorNorth()
Calls anchor(0.5f, 0.0f).

Returns:
A new constraints object.

anchorNorthEast

public PanelPartConstraints anchorNorthEast()
Calls anchor(1.0f, 0.0f).

Returns:
A new constraints object.

anchorWest

public PanelPartConstraints anchorWest()
Calls anchor(0.0f, 0.5f).

Returns:
A new constraints object.

anchorCenter

public PanelPartConstraints anchorCenter()
Calls anchor(0.5f, 0.5f).

Returns:
A new constraints object.

anchorEast

public PanelPartConstraints anchorEast()
Calls anchor(1.0f, 0.5f).

Returns:
A new constraints object.

anchorSouthWest

public PanelPartConstraints anchorSouthWest()
Calls anchor(0.0f, 1.5f).

Returns:
A new constraints object.

anchorSouth

public PanelPartConstraints anchorSouth()
Calls anchor(0.5f, 1.0f).

Returns:
A new constraints object.

anchorSouthEast

public PanelPartConstraints anchorSouthEast()
Calls anchor(1.0f, 1.0f).

Returns:
A new constraints object.

target

public 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.

Parameters:
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.
Returns:
A new constraints object.

targetNorthWest

public PanelPartConstraints targetNorthWest()
Calls target(0.0f, 0.0f).

Returns:
A new constraints object.

targetNorth

public PanelPartConstraints targetNorth()
Calls target(0.5f, 0.0f).

Returns:
A new constraints object.

targetNorthEast

public PanelPartConstraints targetNorthEast()
Calls target(1.0f, 0.0f).

Returns:
A new constraints object.

targetWest

public PanelPartConstraints targetWest()
Calls target(0.0f, 0.5f).

Returns:
A new constraints object.

targetCenter

public PanelPartConstraints targetCenter()
Calls target(0.5f, 0.5f).

Returns:
A new constraints object.

targetEast

public PanelPartConstraints targetEast()
Calls target(1.0f, 0.5f).

Returns:
A new constraints object.

targetSouthWest

public PanelPartConstraints targetSouthWest()
Calls target(0.0f, 1.0f).

Returns:
A new constraints object.

targetSouth

public PanelPartConstraints targetSouth()
Calls target(0.5f, 1.0f).

Returns:
A new constraints object.

targetSouthEast

public PanelPartConstraints targetSouthEast()
Calls target(1.0f, 1.0f).

Returns:
A new constraints object.

shiftX

public 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.

Parameters:
shiftX - The absolute shift value in the x direction.
Returns:
A new constraints object.

shiftY

public 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.

Parameters:
shiftY - The absolute shift value in the y direction.
Returns:
A new constraints object.

layer

public 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.

Parameters:
layer - The Z layer. The lower the values the earlier the painting.
Returns:
A new constraints object.

ChartCat 1.2

Copyright © 2003 - 2005 NetCat Inc.. All rights reserved. Feedback

Chart,Charting,Charts,Java,Java Chart,Java Charting,Java Charts,Chart Java,Charts Java,3D,3D Chart,3Dchart,Graph,Graphs,Chart Graph,Java Graph,Diagram,Diagrams,Java Diagram,Java Diagrams,Curve,Curves,Bar Chart,Pie Chart,Line Chart,Area Chart,Bar Graph,Pie Graph,Line Graph,Java Diagram,Chart Diagram,Package,Library,Chart Library,Chart Engine,Chart Package,Graph Package,Paint,Support,Graphic,Graphics,Print, Chart,Charting,Charts,Java,Java Chart,Java Charting,Java Charts,Chart Java,Charts Java,3D,3D Chart,3Dchart,Graph,Graphs,Chart Graph,Java Graph,Diagram,Diagrams,Java Diagram,Java Diagrams,Curve,Curves,Bar Chart,Pie Chart,Line Chart,Area Chart,Bar Graph,Pie Graph,Line Graph,Java Diagram,Chart Diagram,Package,Library,Chart Library,Chart Engine,Chart Package,Graph Package,Paint,Support,Graphic,Graphics,Print, Chart,Charting,Charts,Java,Java Chart,Java Charting,Java Charts,Chart Java,Charts Java,3D,3D Chart,3Dchart,Graph,Graphs,Chart Graph,Java Graph,Diagram,Diagrams,Java Diagram,Java Diagrams,Curve,Curves,Bar Chart,Pie Chart,Line Chart,Area Chart,Bar Graph,Pie Graph,Line Graph,Java Diagram,Chart Diagram,Package,Library,Chart Library,Chart Engine,Chart Package,Graph Package,Paint,Support,Graphic,Graphics,Print