2.17.2: 2011-06-17

net.sf.basedb.core
Class Coloring

java.lang.Object
  extended by net.sf.basedb.core.Coloring
All Implemented Interfaces:
AccessControlled

public class Coloring
extends Object
implements AccessControlled

This class keeps coloring information for items which can be colored when values are displayed in a client application. Color values are calculated by a ColorGenerator based on this coloring information and the colors specified by user settings.

Version:
2.0
Author:
nicklas
See Also:
ColorGenerator
Last modified
$Date: 2008-09-11 22:11:02 +0200 (Thu, 11 Sep 2008) $

Field Summary
private  ColoringData data
           
private  AccessControlled item
           
 
Constructor Summary
Coloring()
          Create a new independent coloring object.
Coloring(ColoringData data, AccessControlled item)
          Create Coloring object which links to an existing item.
 
Method Summary
 void checkPermission(Permission permission)
          Check if the logged in user has the desired permission on the item, otherwise throw an exception.
 Float getMaxValue()
          Get the value that represents the maximum value.
 Float getMidValue()
          Get the value that represents the midpoint value.
 Float getMinValue()
          Get the value that represents the minimum value.
 Set<Permission> getPermissions()
          Get the logged in user's permissions on the item.
 boolean hasPermission(Permission permission)
          Check if the logged in user has the desired permission on the item.
 boolean isLogarithmic()
          If we should take the logarithm of values before the color is generated or not.
 boolean isUsingColors()
          If this item should be colored or not.
 void setLogarithmic(boolean logarithmic)
          Specify if we should take the logarithm of values before the color is generated or not.
 void setMaxValue(Float maxValue)
          Set the value that represents the maximum value.
 void setMidValue(Float midValue)
          Set the value that represents the midpoint value.
 void setMinValue(Float minValue)
          Set the value that represents the minimum value.
 void setUsingColors(boolean useColors)
          Specifiy if colors should be used when displaying values for this item or not.
(package private)  void validate()
          Check that all values has been specified and that minValue <= midValue >= maxValue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

data

private final ColoringData data

item

private final AccessControlled item
Constructor Detail

Coloring

Coloring(ColoringData data,
         AccessControlled item)
Create Coloring object which links to an existing item.

Parameters:
data - The coloring data
item - The access controlled item

Coloring

public Coloring()
Create a new independent coloring object.

Method Detail

checkPermission

public void checkPermission(Permission permission)
                     throws PermissionDeniedException
Description copied from interface: AccessControlled
Check if the logged in user has the desired permission on the item, otherwise throw an exception.

Specified by:
checkPermission in interface AccessControlled
Parameters:
permission - Permission the user should have.
Throws:
PermissionDeniedException - If the user doesn't have the requested permission

getPermissions

public Set<Permission> getPermissions()
Description copied from interface: AccessControlled
Get the logged in user's permissions on the item.

Specified by:
getPermissions in interface AccessControlled

hasPermission

public boolean hasPermission(Permission permission)
Description copied from interface: AccessControlled
Check if the logged in user has the desired permission on the item.

Specified by:
hasPermission in interface AccessControlled
Parameters:
permission - The permission to check if the user has.
Returns:
TRUE if the user has the permission, FALSE otherwise

validate

void validate()
        throws InvalidDataException
Check that all values has been specified and that minValue <= midValue >= maxValue.

Throws:
InvalidDataException

isUsingColors

public boolean isUsingColors()
If this item should be colored or not. If this method returns FALSE, the rest of the properties on this object are ignored.

Returns:
TRUE if colors should be used, FALSE otherwise

setUsingColors

public void setUsingColors(boolean useColors)
Specifiy if colors should be used when displaying values for this item or not.

Parameters:
useColors - TRUE to use colors, FALSE otherwise

isLogarithmic

public boolean isLogarithmic()
If we should take the logarithm of values before the color is generated or not.

Returns:
TRUE to calculate the logarithm, FALSE to leave the value as is

setLogarithmic

public void setLogarithmic(boolean logarithmic)
Specify if we should take the logarithm of values before the color is generated or not.

Parameters:
logarithmic - TRUE to calculate the logarithm, FALSE to leave the value as is

getMinValue

public Float getMinValue()
Get the value that represents the minimum value. All values below this will get the same color.

Returns:
The min value

setMinValue

public void setMinValue(Float minValue)
Set the value that represents the minimum value. All values below this will get the same color.

Parameters:
minValue - Value to set.

getMidValue

public Float getMidValue()
Get the value that represents the midpoint value.

Returns:
The midpoint value

setMidValue

public void setMidValue(Float midValue)
Set the value that represents the midpoint value.

Parameters:
midValue - The midpoint value

getMaxValue

public Float getMaxValue()
Get the value that represents the maximum value. All values above this will get the same color.

Returns:
The max value

setMaxValue

public void setMaxValue(Float maxValue)
Set the value that represents the maximum value. All values above this will get the same color.

Parameters:
maxValue - The value to set.

2.17.2: 2011-06-17