com.realtime.crossfire.jxclient.gui.gauge
Class AbstractOrientation

java.lang.Object
  extended by com.realtime.crossfire.jxclient.gui.gauge.AbstractOrientation
All Implemented Interfaces:
Orientation
Direct Known Subclasses:
OrientationEW, OrientationNS, OrientationSN, OrientationWE

public abstract class AbstractOrientation
extends java.lang.Object
implements Orientation

Abstract base class for implementing Orientation instances.


Field Summary
private  int cur
          The current value.
private  int h
          The height of the highlighted part of the image.
private  boolean hasNegativeImage
          Whether the gauge can display negative images.
private  int height
          The total height of the image.
private  int max
          The maximum value; the gauge is displayed as full if cur >= max.
private  int min
          The minimum value; the gauge is displayed as empty if cur >= min.
private  int w
          The width of the highlighted part of the image.
private  int width
          The total width of the image.
private  int x
          The x-coordinate of the highlighted part of the image.
private  int y
          The y-coordinate of the highlighted part of the image.
 
Constructor Summary
protected AbstractOrientation()
          Creates a new instance.
 
Method Summary
protected static int calculate(int val, int max, int size)
          Returns the fraction val/max rounded to [0..size].
 int getCur()
          Returns the current value.
 int getH()
          Returns the height of the highlighted part of the image.
 int getHeight()
          Returns the total height of the image.
 int getMax()
          Returns the maximum value.
 int getMin()
          Returns the minimum value.
 int getW()
          Returns the width of the highlighted part of the image.
 int getWidth()
          Returns the total width of the image.
 int getX()
          Returns the x-coordinate of the highlighted part of the image.
 int getY()
          Returns the y-coordinate of the highlighted part of the image.
 boolean isNegativeImage()
          Returns whether the negative image should be shown.
 boolean isValid()
          Returns whether the gauge's values are valid.
protected abstract  void reCalculate()
          Recalculate the extents of the highlighted image part.
 void setExtends(int width, int height)
          Sets the extends of the image.
protected  void setExtent(int x, int y, int w, int h)
          Sets the extent of the highlighted part of the image.
 void setHasNegativeImage(boolean hasNegativeImage)
          Sets whether the gauge can display negative images.
 boolean setValues(int cur, int min, int max)
          Sets the gauge's values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cur

private int cur
The current value.


h

private int h
The height of the highlighted part of the image.


hasNegativeImage

private boolean hasNegativeImage
Whether the gauge can display negative images.


height

private int height
The total height of the image.


max

private int max
The maximum value; the gauge is displayed as full if cur >= max.


min

private int min
The minimum value; the gauge is displayed as empty if cur >= min.


w

private int w
The width of the highlighted part of the image.


width

private int width
The total width of the image.


x

private int x
The x-coordinate of the highlighted part of the image.


y

private int y
The y-coordinate of the highlighted part of the image.

Constructor Detail

AbstractOrientation

protected AbstractOrientation()
Creates a new instance.

Method Detail

calculate

protected static int calculate(int val,
                               int max,
                               int size)
Returns the fraction val/max rounded to [0..size].

Parameters:
val - the value
max - the range size
size - the size of the result
Returns:
the fraction in pixels

getCur

public int getCur()
Returns the current value.

Returns:
the current value

getH

public int getH()
Returns the height of the highlighted part of the image.

Specified by:
getH in interface Orientation
Returns:
the height

getHeight

public int getHeight()
Returns the total height of the image.

Returns:
the height

getMax

public int getMax()
Returns the maximum value.

Returns:
the maximum value

getMin

public int getMin()
Returns the minimum value.

Returns:
the minimum value

getW

public int getW()
Returns the width of the highlighted part of the image.

Specified by:
getW in interface Orientation
Returns:
the width

getWidth

public int getWidth()
Returns the total width of the image.

Returns:
the width

getX

public int getX()
Returns the x-coordinate of the highlighted part of the image.

Specified by:
getX in interface Orientation
Returns:
the x-coordinate

getY

public int getY()
Returns the y-coordinate of the highlighted part of the image.

Specified by:
getY in interface Orientation
Returns:
the y-coordinate

isNegativeImage

public boolean isNegativeImage()
Returns whether the negative image should be shown.

Specified by:
isNegativeImage in interface Orientation
Returns:
whether the negative image should be shown

isValid

public boolean isValid()
Returns whether the gauge's values are valid.

Specified by:
isValid in interface Orientation
Returns:
whether the values are valid

reCalculate

protected abstract void reCalculate()
Recalculate the extents of the highlighted image part.


setExtends

public void setExtends(int width,
                       int height)
Sets the extends of the image.

Specified by:
setExtends in interface Orientation
Parameters:
width - the width
height - the height

setExtent

protected void setExtent(int x,
                         int y,
                         int w,
                         int h)
Sets the extent of the highlighted part of the image.

Parameters:
x - the x-coordinate
y - the y-coordinate
w - the width
h - the height

setHasNegativeImage

public void setHasNegativeImage(boolean hasNegativeImage)
Sets whether the gauge can display negative images. By default negative images are not supported.

Specified by:
setHasNegativeImage in interface Orientation
Parameters:
hasNegativeImage - whether the gauge can display negative images

setValues

public boolean setValues(int cur,
                         int min,
                         int max)
Sets the gauge's values.

Specified by:
setValues in interface Orientation
Parameters:
cur - the current value
min - the minimum value
max - the maximum value
Returns:
whether the values have been updated