Class GradationCurve
java.lang.Object
com.levigo.jadice.web.shared.model.settings.gradation.ControlCurve
com.levigo.jadice.web.shared.model.settings.gradation.NaturalCubicSpline1D
com.levigo.jadice.web.shared.model.settings.gradation.GradationCurve
- All Implemented Interfaces:
Serializable
This class represents a gradation curve which can be used to map pixel intensity values to
rendered intensities. Like its ancestor,
NaturalCubicSpline1D
, the GradationCurve is defined by a
set of control points which may be set, removed and modified. However, the control points are
subject to certain restrictions which are due to the nature of a GradationCurve:
- x and y values of the control points must be in the range [0..255]
- with x1 being the x value of control point p and x2 the one of p+1, the condition x2>x1 must hold.
- the curve may be evaluated in the range [0..255]
- for x values within two control points x1, x2, the value is calculated by fitting the natural cubic spline which achieves a smooth transition at the points (first derivatives left and right of the control point are equal and second derivatives are zero)
- with n0 being the first control point and pn being the last one, y=y0 for x<x0 and y=yn for x>xn
- there are at least two control points
- See Also:
-
Field Summary
Fields inherited from class com.levigo.jadice.web.shared.model.settings.gradation.ControlCurve
curveChanged, points
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new GradationCurve which is initialised as a linear identity curve.GradationCurve
(GradationCurve gradCurve) Create a new GradationCurve as clone of a given gradation curve.GradationCurve
(Polygon points) Create a new GradationCurve based on a given set of control points. -
Method Summary
Modifier and TypeMethodDescriptionint
Adds a control point to the end of the list.protected void
boolean
getControlPoint
(int n) Gets a specified control point.byte[]
getLookupTable
(int size) Return a lookup table based on the curve in the range 0...size.int
getValueAt
(int x) Get the intensity value for a given point.int
hashCode()
Calculate a hash code based on all points on the curve.int
insertControlPoint
(int n, Point p) Inserts a control point at a given location.boolean
Returns whether this curve is a identity curvevoid
removeControlPoint
(int n) Removes the specified control point.void
reset()
Removes all intermediate controls points and keeps just a start and end point for this curve.void
setControlPoint
(int n, Point p) Sets the specified control point.toString()
Methods inherited from class com.levigo.jadice.web.shared.model.settings.gradation.NaturalCubicSpline1D
getCurve, getValueAt
Methods inherited from class com.levigo.jadice.web.shared.model.settings.gradation.ControlCurve
getControlPoints, getPointCount
-
Constructor Details
-
GradationCurve
public GradationCurve()Create a new GradationCurve which is initialised as a linear identity curve. -
GradationCurve
Create a new GradationCurve based on a given set of control points. This constructor is used to clone the curve only.- Parameters:
points
- the set of control points defined by aPolygon
-
-
Method Details
-
addControlPoint
Description copied from class:ControlCurve
Adds a control point to the end of the list.- Overrides:
addControlPoint
in classControlCurve
- Parameters:
p
- thePoint
to add- Returns:
- The total number of control points.
- See Also:
-
getControlPoint
Description copied from class:ControlCurve
Gets a specified control point.- Overrides:
getControlPoint
in classControlCurve
- Parameters:
n
- The index of the point in question.- Returns:
- The control point at the given index.
- See Also:
-
insertControlPoint
Description copied from class:ControlCurve
Inserts a control point at a given location.- Overrides:
insertControlPoint
in classControlCurve
- Parameters:
n
- the position to insert atp
- thePoint
to insert- Returns:
- The total number of control points.
- See Also:
-
removeControlPoint
public void removeControlPoint(int n) Description copied from class:ControlCurve
Removes the specified control point.- Overrides:
removeControlPoint
in classControlCurve
- Parameters:
n
- the index of the point to remove- See Also:
-
reset
public void reset()Removes all intermediate controls points and keeps just a start and end point for this curve. -
setControlPoint
Description copied from class:ControlCurve
Sets the specified control point.- Overrides:
setControlPoint
in classControlCurve
- Parameters:
n
- the index of the point to modifyp
- thePoint
to set- See Also:
-
getValueAt
public int getValueAt(int x) Get the intensity value for a given point. The curve is automatically mirrored around the zero point.- Parameters:
x
- The point in question.- Returns:
- The intensity.
-
equals
-
isLinearIdentity
public boolean isLinearIdentity()Returns whether this curve is a identity curve- Returns:
- boolean flag
-
hashCode
public int hashCode()Calculate a hash code based on all points on the curve. -
toString
-
getLookupTable
public byte[] getLookupTable(int size) Return a lookup table based on the curve in the range 0...size. Lookup value interpretation: x=0 - black, x=255 - white.- Parameters:
size
- The size of the lookup table.- Returns:
- A lookup table.
-
computeCurve
protected void computeCurve()- Overrides:
computeCurve
in classNaturalCubicSpline1D
-