com.davisor.graphics.data
Class AnnotatedPaintValue

java.lang.Object
  extended bycom.davisor.graphics.IndirectAnnotatedPaint
      extended bycom.davisor.graphics.data.AnnotatedPaintValue
All Implemented Interfaces:
com.davisor.core.Annotated, AnnotatedPaint, BetterPaint, java.lang.Comparable, Data, DataValue, com.davisor.core.Dupable, java.awt.Paint, PaintValue, java.io.Serializable, SerializableData, java.awt.Transparency

public class AnnotatedPaintValue
extends IndirectAnnotatedPaint
implements PaintValue

AnnotatedPaintValue allows annotation information to be assosiated to paint values.

Since:
JDK1.1
See Also:
AnnotatedGraphics2D, PaintValue, Serialized Form

Field Summary
 
Fields inherited from class com.davisor.graphics.IndirectAnnotatedPaint
M_channelIndex, M_contextIndex, M_elementIndex, M_id, M_paint, M_properties
 
Fields inherited from interface java.awt.Transparency
BITMASK, OPAQUE, TRANSLUCENT
 
Constructor Summary
AnnotatedPaintValue(AnnotatedPaintValue apv, boolean deep)
          Deep or shallow copy constructor.
AnnotatedPaintValue(PaintValue paintValue, com.davisor.core.Annotated annotation)
          Constructs an annotated paint from a paint value and annotation string.
AnnotatedPaintValue(PaintValue paintValue, java.util.Properties properties, long elementIndex, int channelIndex, short contextIndex)
          Constructs an annotated paint from a paint value and annotation string.
AnnotatedPaintValue(PaintValue paintValue, java.util.Properties properties, long elementIndex, int channelIndex, short contextIndex, java.lang.String id)
          Deprecated. explicit identity strings are obsolete
 
Method Summary
 DataValue abs()
          Returns absolute data value of current value.
 DataValue add(DataValue value)
          Adds data values together.
 java.awt.Paint brighterPaint()
          Creates a brighter version of this paint.
 DataValue ceil(DataValue precision)
          Quantizes the current value up to an even value within given precision.
 int compareTo(java.lang.Object o)
          Compares this annotated paint value with other value objects.
 java.awt.Paint darkerPaint()
          Creates a darker version of this paint.
 double deinterpolate(DataValue min, DataValue max)
          De-interpolates the current data value to a scalar value in respect with the given data value range.
 DataValue div(DataValue value)
          Divides current value with a data value.
 com.davisor.core.Dupable dup()
          Makes a deep copy of this object.
 DataValue floor(DataValue precision)
          Quantizes the current value down to an even value within given precision.
 java.lang.String getCreationString()
          Implements PaintValue interface method.
 java.lang.String getFormat()
          Gets the type specification optimal for this particular value.
 Type getType()
          Gets the color data type.
 DataValue interpolate(double value, DataValue max)
          Interpolates the given scalar value to data value in respect with the range defined by this value and the given maximum value.
 boolean isNull()
          Tests if this data object value is undetermined.
 DataValue max(DataValue value)
          Finds the larger of this and the given data value.
 DataValue min(DataValue value)
          Finds the smaller of this and the given data value.
 DataValue mul(DataValue value)
          Multiplies current value with a data value.
 DataValue negate()
          Returns the negation of current value.
 BetterPaint next()
          Gets the next paint in this paint series.
 void setCreationString(java.lang.String creationString)
          Implements PaintValue interface method.
 void setValue(java.lang.String stringValue, java.text.ParsePosition status)
          Sets the data value from a string value.
 DataValue sub(DataValue value)
          Substracts a data value.
 void toStatement(java.sql.PreparedStatement statement, int parameter)
          Converts the data to a prepared statement input parameter.
 java.lang.String toXML()
          Gets the XML string representation of this value.
 DataValue unit(DataValue targetValue, double maxSteps)
          Gets the largest suitable unit step to represent a value change between this value and the given target value.
 
Methods inherited from class com.davisor.graphics.IndirectAnnotatedPaint
createContext, equals, getAddress, getChannelIndex, getContextIndex, getDescription, getElementIndex, getID, getPaint, getProperties, getProperty, getPropertyNames, getTarget, getTransparency, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.davisor.data.DataValue
toString
 
Methods inherited from interface java.awt.Paint
createContext
 
Methods inherited from interface java.awt.Transparency
getTransparency
 

Constructor Detail

AnnotatedPaintValue

public AnnotatedPaintValue(AnnotatedPaintValue apv,
                           boolean deep)
Deep or shallow copy constructor.

Parameters:
apv - source data
deep - determine if the copying is deep or shallow
See Also:
getType(), Type.dup()

AnnotatedPaintValue

public AnnotatedPaintValue(PaintValue paintValue,
                           com.davisor.core.Annotated annotation)
Constructs an annotated paint from a paint value and annotation string.

Parameters:
paintValue - paint value to be annotated
annotation - annotation information the paint is to be annotated with

AnnotatedPaintValue

public AnnotatedPaintValue(PaintValue paintValue,
                           java.util.Properties properties,
                           long elementIndex,
                           int channelIndex,
                           short contextIndex)
Constructs an annotated paint from a paint value and annotation string.

Parameters:
paintValue - paint value to be annotated
properties - annotation information (may be null)
elementIndex - annotation element index
channelIndex - annotation channel index
contextIndex - annotation context index

AnnotatedPaintValue

public AnnotatedPaintValue(PaintValue paintValue,
                           java.util.Properties properties,
                           long elementIndex,
                           int channelIndex,
                           short contextIndex,
                           java.lang.String id)
Deprecated. explicit identity strings are obsolete

Constructs an annotated paint from a paint value and annotation string.

Parameters:
paintValue - paint value to be annotated
properties - annotation information (may be null)
elementIndex - annotation element index
channelIndex - annotation channel index
contextIndex - annotation context index
id - paint identity (may be null)
Method Detail

getType

public Type getType()
             throws InvalidDataException
Gets the color data type.

Specified by:
getType in interface Data
Returns:
type of this color data instance
Throws:
InvalidDataException - if type retrieval fails

isNull

public boolean isNull()
Tests if this data object value is undetermined.

Specified by:
isNull in interface SerializableData
See Also:
Type.isNull(com.davisor.data.SerializableData)

abs

public DataValue abs()
              throws InvalidDataException
Returns absolute data value of current value. The result will share annotation information with this object.

Specified by:
abs in interface DataValue
Returns:
a new data object, sharing the current type of this object
Throws:
InvalidDataException - if absolute value can not be computed

add

public DataValue add(DataValue value)
              throws InvalidDataException
Adds data values together. The result will share annotation information with this object.

Specified by:
add in interface DataValue
Parameters:
value - a data value to be added to this data value
Returns:
an added data value
Throws:
InvalidDataException - if data values can not added together.

ceil

public DataValue ceil(DataValue precision)
               throws InvalidDataException
Quantizes the current value up to an even value within given precision. The result will share annotation information with this object.

Specified by:
ceil in interface DataValue
Parameters:
precision - the precision within quantization occurs
Returns:
a new data object, sharing the current type of this object
Throws:
InvalidDataException - if precision was of unacceptable type
See Also:
floor(com.davisor.data.DataValue)

deinterpolate

public double deinterpolate(DataValue min,
                            DataValue max)
                     throws InvalidDataException
De-interpolates the current data value to a scalar value in respect with the given data value range.

Specified by:
deinterpolate in interface DataValue
Parameters:
min - a data value representing a range's lower limit
max - a data value representing a range's higher limit
Returns:
the de-interpolated scalar value
Throws:
DeinterpolationException - if the de-interpolation fails due to a de-interpolation value conflict
InvalidDataException - if the de-interpolation fails for some other reason
See Also:
interpolate(double, com.davisor.data.DataValue), DeinterpolationException, TupleData.deinterpolate(com.davisor.data.DataValue, com.davisor.data.DataValue)

div

public DataValue div(DataValue value)
              throws InvalidDataException
Divides current value with a data value. The result will share annotation information with this object.

Specified by:
div in interface DataValue
Parameters:
value - the divider
Returns:
the result of division
Throws:
InvalidDataException - if current data value can not be divided.

floor

public DataValue floor(DataValue precision)
                throws InvalidDataException
Quantizes the current value down to an even value within given precision. The result will share annotation information with this object.

Specified by:
floor in interface DataValue
Parameters:
precision - the precision within the quantization occurs
Returns:
a new data object, sharing the current type of this object
Throws:
InvalidDataException - if precision was of unacceptable type
See Also:
ceil(com.davisor.data.DataValue)

getFormat

public java.lang.String getFormat()
Gets the type specification optimal for this particular value. The specification returned may differ from the current type specification. If so, setting the current type specification equal with the value returned by this method will ensure optimal value formatting and parsing for values of the same magnitude as this value.

Specified by:
getFormat in interface DataValue
See Also:
Data.getType(), Type.getFormat(), Type.setFormat(java.lang.String)

interpolate

public DataValue interpolate(double value,
                             DataValue max)
                      throws InvalidDataException
Interpolates the given scalar value to data value in respect with the range defined by this value and the given maximum value. The result will share annotation information with this object.

Specified by:
interpolate in interface DataValue
Parameters:
value - the scalar value to be interpolated
max - a data value representing a range's higher limit
Returns:
interpolated data value
Throws:
InvalidDataException - if the interpolation fails
See Also:
deinterpolate(com.davisor.data.DataValue, com.davisor.data.DataValue)

max

public DataValue max(DataValue value)
              throws InvalidDataException
Finds the larger of this and the given data value. The result will share annotation information with this object.

Specified by:
max in interface DataValue
Parameters:
value - a data value to be compared with this data value
Returns:
the larger of the compared data values, or a new data value that is larger than or the same as the largest of the compared data values.
Throws:
InvalidDataException - if the values cannot be compared

min

public DataValue min(DataValue value)
              throws InvalidDataException
Finds the smaller of this and the given data value. The result will share annotation information with this object.

Specified by:
min in interface DataValue
Parameters:
value - a data value to be compared with this data value
Returns:
the smaller of the compared data values, or a new data value that is smaller than or the same as the smallest of the compared data values.
Throws:
InvalidDataException - if the values cannot be compared

mul

public DataValue mul(DataValue value)
              throws InvalidDataException
Multiplies current value with a data value. The result will share annotation information with this object.

Specified by:
mul in interface DataValue
Parameters:
value - the multiplier
Returns:
the result of multiplication
Throws:
InvalidDataException - if current data value can not be multiplied.

negate

public DataValue negate()
                 throws InvalidDataException
Returns the negation of current value. The result will share annotation information with this object.

Specified by:
negate in interface DataValue
Returns:
a new data object, sharing the current type of this object
Throws:
InvalidDataException - if absolute value can not be computed

setValue

public void setValue(java.lang.String stringValue,
                     java.text.ParsePosition status)
              throws InvalidDataException
Sets the data value from a string value.

Specified by:
setValue in interface DataValue
Parameters:
stringValue - string value to be parsed (may be null)
status - parse status (may be null)
Throws:
InvalidDataException - if string value could not be parser
See Also:
CountType.countValue(String,ParsePosition)

sub

public DataValue sub(DataValue value)
              throws InvalidDataException
Substracts a data value. The result will share annotation information with this object.

Specified by:
sub in interface DataValue
Parameters:
value - a data value to be substracted from this data value
Returns:
a substracted data value
Throws:
InvalidDataException - if value can not be substracted.

toStatement

public void toStatement(java.sql.PreparedStatement statement,
                        int parameter)
                 throws java.sql.SQLException
Converts the data to a prepared statement input parameter.

Specified by:
toStatement in interface DataValue
Throws:
java.sql.SQLException - if a SQL error occurs

toXML

public java.lang.String toXML()
Gets the XML string representation of this value.

Specified by:
toXML in interface DataValue
Returns:
complete string representing the data.
See Also:
IndirectAnnotatedPaint.toString()

unit

public DataValue unit(DataValue targetValue,
                      double maxSteps)
               throws InvalidDataException
Gets the largest suitable unit step to represent a value change between this value and the given target value. The result will share annotation information with this object.

Specified by:
unit in interface DataValue
Parameters:
targetValue - target value to be reached (may be null)
maxSteps - maximum number of steps (zero leaves the choise open)
Returns:
step value, as described above
Throws:
InvalidDataException - if precision was of unacceptable type

dup

public com.davisor.core.Dupable dup()
Makes a deep copy of this object.

Specified by:
dup in interface com.davisor.core.Dupable

compareTo

public int compareTo(java.lang.Object o)
Compares this annotated paint value with other value objects.

This object will be greater than any object that is not an instance of AnnotatedPaintValue. If the other object is also an instance of AnnotatedPaintValue, the paint values of these objects are compared. If the paint values are equal, paint annotation strings are compared.

Specified by:
compareTo in interface java.lang.Comparable
See Also:
Compare.compareTo(Object,Object)

brighterPaint

public java.awt.Paint brighterPaint()
Creates a brighter version of this paint. The annotation value of this paint is copied to the new paint.

Specified by:
brighterPaint in interface BetterPaint
See Also:
darkerPaint()

darkerPaint

public java.awt.Paint darkerPaint()
Creates a darker version of this paint. The annotation value of this paint is copied to the new paint.

Specified by:
darkerPaint in interface BetterPaint
See Also:
brighterPaint()

next

public BetterPaint next()
Gets the next paint in this paint series.

Specified by:
next in interface BetterPaint
Returns:
a reference to this object

getCreationString

public java.lang.String getCreationString()
Implements PaintValue interface method.

Specified by:
getCreationString in interface PaintValue

setCreationString

public void setCreationString(java.lang.String creationString)
Implements PaintValue interface method.

Specified by:
setCreationString in interface PaintValue


Copyright © 2001-2004 Davisor Oy. All Rights Reserved.