Package net.sf.basedb.core
Class Coloring
- java.lang.Object
-
- 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 aColorGenerator
based on this coloring information and the colors specified by user settings.- Version:
- 2.0
- Author:
- nicklas
- See Also:
ColorGenerator
- Last modified
- $Date: 2012-09-14 09:28:35 +0200 (fr, 14 sep 2012) $
-
-
Field Summary
Fields Modifier and Type Field Description private ColoringData
data
private AccessControlled
item
-
Constructor Summary
Constructors Constructor Description Coloring()
Create a new independent coloring object.Coloring(ColoringData data, AccessControlled item)
Create Coloring object which links to an existing item.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.
-
-
-
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 dataitem
- 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 interfaceAccessControlled
- 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 interfaceAccessControlled
-
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 interfaceAccessControlled
- 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.
-
-