com.levigo.jadice.document.util
Class GradationCurve

java.lang.Object
  extended by com.levigo.jadice.document.util.ControlCurve
      extended by com.levigo.jadice.document.util.NaturalCubicSpline1D
          extended by com.levigo.jadice.document.util.GradationCurve
All Implemented Interfaces:
Serializable, Cloneable

public class GradationCurve
extends NaturalCubicSpline1D
implements Cloneable

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:

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.levigo.jadice.document.util.ControlCurve
curveChanged, points
 
Constructor Summary
GradationCurve()
          Create 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.
 
Method Summary
 int addControlPoint(Point p)
          Add a control point to the end of the list.
protected  GradationCurve clone()
           
protected  void computeCurve()
           
 boolean equals(Object obj)
           
 Point getControlPoint(int n)
          Get 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)
          Insert a control point at a given location
 boolean isLinearIdentity()
          Returns whether this curve is a identity curve
 void load(Properties properties, String curveName)
          Load the curve from the given properties object.
 void removeControlPoint(int n)
          Remove the specified control point
 void reset()
          Removes all intermediate controls points and keeps just a start and end point for this curve.
 void save(Properties properties, String curveName)
          Save the curve into the given properties object.
 void setControlPoint(int n, Point p)
          Set the specified control point
 String toString()
           
 
Methods inherited from class com.levigo.jadice.document.util.NaturalCubicSpline1D
getCurve, getValueAt
 
Methods inherited from class com.levigo.jadice.document.util.ControlCurve
getControlPoints, getPointCount
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GradationCurve

public GradationCurve()
Create a new GradationCurve which is initialised as a linear identity curve.


GradationCurve

public GradationCurve(GradationCurve gradCurve)
Create a new GradationCurve as clone of a given gradation curve.

Method Detail

addControlPoint

public int addControlPoint(Point p)
Description copied from class: ControlCurve
Add a control point to the end of the list.

Overrides:
addControlPoint in class ControlCurve
Parameters:
p - the Pointto add
See Also:
The addition makes sure that the x values of the points are ascending.

getControlPoint

public Point getControlPoint(int n)
Description copied from class: ControlCurve
Get a specified control point.

Overrides:
getControlPoint in class ControlCurve
See Also:
ControlCurve.getControlPoint(int)

insertControlPoint

public int insertControlPoint(int n,
                              Point p)
Description copied from class: ControlCurve
Insert a control point at a given location

Overrides:
insertControlPoint in class ControlCurve
Parameters:
n - the position to insert at
p - the Pointto insert
See Also:
The insertion makes sure that the x values of the points are ascending, if necessary, the x value is modified.

removeControlPoint

public void removeControlPoint(int n)
Description copied from class: ControlCurve
Remove the specified control point

Overrides:
removeControlPoint in class ControlCurve
Parameters:
n - the index of the point to remove
See Also:
ControlCurve.removeControlPoint(int)

reset

public void reset()
Removes all intermediate controls points and keeps just a start and end point for this curve.


setControlPoint

public void setControlPoint(int n,
                            Point p)
Description copied from class: ControlCurve
Set the specified control point

Overrides:
setControlPoint in class ControlCurve
Parameters:
n - the index of the point to modify
p - the Pointto set
See Also:
The modification makes sure that the x values of the points are ascending, if necessary, the x value is modified.

load

public void load(Properties properties,
                 String curveName)
Load the curve from the given properties object. The points must be defined in the properties object by keys of the style [curveName.]point.i.x and [curveName.]point.i.y with curveName being the supplied curve name and i being an index from 0 to n-1.

Parameters:
properties - the Propertiesfrom which to load the curve
curveName - the optional name of the curve. If non- null, the name is prepended to the keys with a separating dot.

save

public void save(Properties properties,
                 String curveName)
Save the curve into the given properties object. The points are defined in the properties object by keys of the style [curveName.]point.i.x and [curveName.]point.i.y with curveName being the supplied curve name and i being an index from 0 to n-1.

Parameters:
properties - the Propertiesfrom which to load the curve
curveName - the optional name of the curve. If non- null, the name is prepended to the keys with a separating dot.

getValueAt

public int getValueAt(int x)
Get the intensity value for a given point. The curve is automatically mirrored around the zero point.


clone

protected GradationCurve clone()
                        throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException

equals

public boolean equals(Object obj)
Overrides:
equals in class Object
See Also:
Object.equals(Object)

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.

Overrides:
hashCode in class Object
See Also:
Object.hashCode()

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.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.

Returns:
a lookup table

computeCurve

protected void computeCurve()
Overrides:
computeCurve in class NaturalCubicSpline1D


Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.