pmlib
Class PMLRange

java.lang.Object
  extended by pmlib.PMLRange

public class PMLRange
extends java.lang.Object

PMLRange Class

The PMLRange object allows the storage of upper and lower range values, alongside an identifier tag. The class provides limit, normalise and scale functionality.

This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/.


Constructor Summary
PMLRange(float a, float b)
          Create a new object instance with the specified minimum and maximum values
PMLRange(int a, int b)
          Create a new object instance with the specified minimum and maximum values
PMLRange(java.lang.String t, float a, float b)
          Create a new object instance with the specified tag, minimum and maximum values
PMLRange(java.lang.String t, int a, int b)
          Create a new object instance with the specified tag, minimum and maximum values
 
Method Summary
 boolean hasTag(java.lang.String t)
          Return true if the stored tag matches that specified
 float limit(float v)
          Limit the specified value to the range of this object
static float limit(float v, float a, float b)
          Limit the specified value to the specified range
 int limit(int v)
          Limit the specified value to the range of this object
 float max()
          Return the stored maximum value
 float min()
          Return the stored minimum value
 float normalise(float v)
          Normalise the specified value based on the range of this object
static float normalise(float v, float a, float b)
          Normalise the specified value based on the specified range
 float normalise(int v)
          Normalise the specified value based on the range of this object
 float scale(float v)
          Scale the specified value to the range of this object
static float scale(float v, float a, float b)
          Scale the specified value to the specified range
 java.lang.String tag()
          Return the stored tag string
 java.lang.String toString()
          Return the contents of this object as a String
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PMLRange

public PMLRange(int a,
                int b)
Create a new object instance with the specified minimum and maximum values

Parameters:
a - minimum
b - maximum

PMLRange

public PMLRange(float a,
                float b)
Create a new object instance with the specified minimum and maximum values

Parameters:
a - minimum
b - maximum

PMLRange

public PMLRange(java.lang.String t,
                int a,
                int b)
Create a new object instance with the specified tag, minimum and maximum values

Parameters:
t - tag
a - minimum
b - maximum

PMLRange

public PMLRange(java.lang.String t,
                float a,
                float b)
Create a new object instance with the specified tag, minimum and maximum values

Parameters:
t - tag
a - minimum
b - maximum
Method Detail

min

public float min()
Return the stored minimum value

Returns:
the stored minimum value

max

public float max()
Return the stored maximum value

Returns:
the stored maximum value

tag

public java.lang.String tag()
Return the stored tag string

Returns:
the stored tag string

hasTag

public boolean hasTag(java.lang.String t)
Return true if the stored tag matches that specified

Parameters:
t - tag
Returns:
true if the stored tag matches that specified

limit

public int limit(int v)
Limit the specified value to the range of this object

The returned value will be rounded to the nearest integer value.

Parameters:
v - value
Returns:
the limited value

limit

public float limit(float v)
Limit the specified value to the range of this object

Parameters:
v - value
Returns:
the limited value

limit

public static float limit(float v,
                          float a,
                          float b)
Limit the specified value to the specified range

Parameters:
v - value
a - minimum
b - maximum
Returns:
the limited value

normalise

public float normalise(int v)
Normalise the specified value based on the range of this object

Parameters:
v - value
Returns:
the normalised value

normalise

public float normalise(float v)
Normalise the specified value based on the range of this object

Parameters:
v - value
Returns:
the normalised value

normalise

public static float normalise(float v,
                              float a,
                              float b)
Normalise the specified value based on the specified range

Parameters:
v - value
a - minimum
b - maximum
Returns:
the normalised value

scale

public float scale(float v)
Scale the specified value to the range of this object

Parameters:
v - value (0.0 - 1.0)
Returns:
the scaled value

scale

public static float scale(float v,
                          float a,
                          float b)
Scale the specified value to the specified range

Parameters:
v - value (0.0 - 1.0)
a - minimum
b - maximum
Returns:
the scaled value

toString

public java.lang.String toString()
Return the contents of this object as a String

Overrides:
toString in class java.lang.Object
Returns:
the contents of this object as a String