net.ctdp.rfdynhud.properties
Class Position

java.lang.Object
  extended by net.ctdp.rfdynhud.properties.Position

public class Position
extends java.lang.Object

The Position class is an abstraction of a positional value tuple. It can be used with percentual values or absolute pixels and can be global or Widget local.

Author:
Marvin Froehlich (CTDP)

Constructor Summary
protected Position(Widget widget, boolean isGlobalPosition, RelativePositioning positioning, float x, boolean xPercent, float y, boolean yPercent, AbstractSize size)
           
 
Method Summary
 void bake()
           
 boolean equalsEffective(int x, int y)
           
 Position flipXPercentagePx()
           
 Position flipYPercentagePx()
           
 int getEffectiveX()
          Gets the effective Widget's x-location using getPositioning().
 int getEffectiveY()
          Gets the effective Widget's y-location using getPositioning().
 RelativePositioning getPositioning()
           
 Property getPositioningProperty(java.lang.String name)
           
 Property getPositioningProperty(java.lang.String name, java.lang.String nameForDisplay)
           
 Widget getWidget()
           
 PosSizeProperty getXProperty(java.lang.String name)
           
 PosSizeProperty getXProperty(java.lang.String name, java.lang.String nameForDisplay)
           
 PosSizeProperty getYProperty(java.lang.String name)
           
 PosSizeProperty getYProperty(java.lang.String name, java.lang.String nameForDisplay)
           
 boolean isBaked()
           
 boolean isGlobalPosition()
           
static Position newGlobalPosition(Widget widget, RelativePositioning positioning, float x, boolean xPercent, float y, boolean yPercent, AbstractSize size)
          Create a new positional property for global positions on the whole screen area.
static Position newLocalPosition(Widget widget, RelativePositioning positioning, float x, boolean xPercent, float y, boolean yPercent, AbstractSize size)
          Create a new positional property for positions local to a Widget's area.
protected  void onPositioningPropertySet(RelativePositioning positioning)
           
protected  void onXPropertySet(float x)
           
protected  void onYPropertySet(float y)
           
static float parseValue(java.lang.String value, boolean defaultPerc)
           
 boolean setEffectivePosition(int x, int y)
          Sets this Widget's position.
 boolean setEffectivePosition(RelativePositioning positioning, int x, int y)
          Sets this Widget's position.
 void setTo(Position position)
          Sets the Position to the values of the given Position.
 Position setXToPercents()
           
 Position setXToPixels()
           
 Position setYToPercents()
           
 Position setYToPixels()
           
 void unbake()
           
static java.lang.String unparseValue(float value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Position

protected Position(Widget widget,
                   boolean isGlobalPosition,
                   RelativePositioning positioning,
                   float x,
                   boolean xPercent,
                   float y,
                   boolean yPercent,
                   AbstractSize size)
Method Detail

getWidget

public final Widget getWidget()

isGlobalPosition

public final boolean isGlobalPosition()

getPositioning

public final RelativePositioning getPositioning()

setTo

public void setTo(Position position)
Sets the Position to the values of the given Position.

Parameters:
position -

setEffectivePosition

public final boolean setEffectivePosition(RelativePositioning positioning,
                                          int x,
                                          int y)
Sets this Widget's position.

Parameters:
positioning - the used RelativePositioning
x - the absolute pixel x
y - the absolute pixel y
Returns:
changed?

setEffectivePosition

public final boolean setEffectivePosition(int x,
                                          int y)
Sets this Widget's position.

Parameters:
x - the absolute pixel x
y - the absolute pixel y
Returns:
changed?

getEffectiveX

public final int getEffectiveX()
Gets the effective Widget's x-location using getPositioning().

Returns:
the effective Widget's x-location.

getEffectiveY

public final int getEffectiveY()
Gets the effective Widget's y-location using getPositioning().

Returns:
the effective Widget's y-location.

equalsEffective

public final boolean equalsEffective(int x,
                                     int y)

unbake

public void unbake()

bake

public void bake()

isBaked

public final boolean isBaked()

setXToPercents

public Position setXToPercents()

setXToPixels

public Position setXToPixels()

flipXPercentagePx

public Position flipXPercentagePx()

setYToPercents

public Position setYToPercents()

setYToPixels

public Position setYToPixels()

flipYPercentagePx

public Position flipYPercentagePx()

parseValue

public static float parseValue(java.lang.String value,
                               boolean defaultPerc)

unparseValue

public static java.lang.String unparseValue(float value)

onPositioningPropertySet

protected void onPositioningPropertySet(RelativePositioning positioning)
Parameters:
positioning - the new positioning

getPositioningProperty

public Property getPositioningProperty(java.lang.String name,
                                       java.lang.String nameForDisplay)

getPositioningProperty

public final Property getPositioningProperty(java.lang.String name)

onXPropertySet

protected void onXPropertySet(float x)
Parameters:
x - the new x

getXProperty

public PosSizeProperty getXProperty(java.lang.String name,
                                    java.lang.String nameForDisplay)

getXProperty

public final PosSizeProperty getXProperty(java.lang.String name)

onYPropertySet

protected void onYPropertySet(float y)
Parameters:
y - the new y

getYProperty

public PosSizeProperty getYProperty(java.lang.String name,
                                    java.lang.String nameForDisplay)

getYProperty

public final PosSizeProperty getYProperty(java.lang.String name)

newLocalPosition

public static final Position newLocalPosition(Widget widget,
                                              RelativePositioning positioning,
                                              float x,
                                              boolean xPercent,
                                              float y,
                                              boolean yPercent,
                                              AbstractSize size)
Create a new positional property for positions local to a Widget's area.

Parameters:
widget - the owning Widget.
positioning - the used RelativePositioning
x - the x position
xPercent - interpret 'x' as percents?
y - the y position
yPercent - interpret 'y' as percents?
size - the size for the area
Returns:
the new Position.

newGlobalPosition

public static final Position newGlobalPosition(Widget widget,
                                               RelativePositioning positioning,
                                               float x,
                                               boolean xPercent,
                                               float y,
                                               boolean yPercent,
                                               AbstractSize size)
Create a new positional property for global positions on the whole screen area.

Parameters:
widget - the owning Widget.
positioning - the used RelativePositioning
x - the x position
xPercent - interpret 'x' as percents?
y - the y position
yPercent - interpret 'y' as percents?
size - the size for the area
Returns:
the new Position.