com.davisor.graphics.data
Class StrokeType

java.lang.Object
  extended byjava.text.Format
      extended bycom.davisor.data.Type
          extended bycom.davisor.graphics.data.StrokeType
All Implemented Interfaces:
java.lang.Cloneable, java.util.Comparator, com.davisor.core.Dupable, java.io.Serializable

public class StrokeType
extends Type

StrokeType defines a stroke mapper that provides convenient conversion tool from stroke specification strings to stroke objects.

StrokeType uses a stroke definition resource bundle file to map stroke names to stroke definitions. The resource bundle name is:

com.davisor.graphics.data.strokes

The default resource bundle defines a set of default strokes. Overriding and extending this bundle allows system administrator to define custom and localized stroke sets.

Since:
JDK1.1
See Also:
createStroke(String,ParsePosition), StrokeData, Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.text.Format
java.text.Format.Field
 
Field Summary
static StrokeType DEFAULT
          Default stroke type.
static java.lang.String TYPENAME
          Type name ("STROKE").
 
Fields inherited from class com.davisor.data.Type
METADATA_GROUP, METADATA_NAME, METADATA_PARENT, METADATA_SUBCHANNELS
 
Constructor Summary
  StrokeType()
          Default constructor.
  StrokeType(java.lang.String dataName)
          Creates a new default type with no identity.
  StrokeType(java.lang.String dataName, java.lang.String id)
          Creates a new type.
  StrokeType(java.lang.String dataName, java.lang.String id, java.util.Map metaData)
          Creates a new type.
  StrokeType(java.lang.String dataName, java.lang.String id, java.lang.String format)
          Constructs a new type with given spesification.
protected StrokeType(java.lang.String typeName, java.lang.String dataName, java.lang.String id, java.util.Map metaData)
          Creates a new type.
  StrokeType(StrokeType st)
          Copy constructor.
 
Method Summary
static java.awt.Stroke createStroke(java.lang.String format)
          Converts a string to a stroke value.
static java.awt.Stroke createStroke(java.lang.String format, java.text.ParsePosition status)
          Converts a string to a stroke value.
 com.davisor.core.Dupable dup()
          Makes a deep copy of this object.
 boolean equals(java.lang.Object o)
          Tests if this object is equal to another object.
static StrokeParameters getStrokeParameters(java.lang.String name)
          Gets stock stroke parameters.
 java.lang.Class getValueClass()
          Gets value container class.
 DataValue one()
          Gets unit data value for this type.
 DataValue toData(java.sql.CallableStatement call, int column)
          Get callable statement result value.
 DataValue toData(java.lang.Object value)
          Converts object to a stroke value.
 DataValue toData(java.sql.ResultSet set, int column)
          Parse a result set output value as a data object.
 DataValue toData(java.lang.String value, java.text.ParsePosition status)
          Converts string to a stroke value.
 DataValue zero()
          Gets zero data value for this type.
 
Methods inherited from class com.davisor.data.Type
ceil, check, check, compare, create, create, create, create, create, dup, floor, format, getCompatibility, getDataName, getFormat, getId, getID, getMetaData, getMetaData, getSpecs, getSQLCode, getSQLName, getSQLName, getTypeName, hashCode, isNull, parseObject, register, register, setDataName, setFormat, setId, setID, setMetaData, setMetaData, setSpecs, toString, toXML, xmlEnd, xmlStart
 
Methods inherited from class java.text.Format
clone, format, formatToCharacterIterator, parseObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT

public static final StrokeType DEFAULT
Default stroke type.


TYPENAME

public static final java.lang.String TYPENAME
Type name ("STROKE").

See Also:
Constant Field Values
Constructor Detail

StrokeType

public StrokeType()
Default constructor.


StrokeType

public StrokeType(StrokeType st)
Copy constructor.


StrokeType

public StrokeType(java.lang.String dataName)
Creates a new default type with no identity.

Parameters:
dataName - data name (may be null)

StrokeType

public StrokeType(java.lang.String dataName,
                  java.lang.String id)
Creates a new type.

Parameters:
dataName - data name (may be null)
id - type identity (may be null)

StrokeType

public StrokeType(java.lang.String dataName,
                  java.lang.String id,
                  java.lang.String format)
Constructs a new type with given spesification.

Parameters:
dataName - data name (may be null)
id - type identity (may be null)
format - type spesification (may be null)
See Also:
Type.setFormat(java.lang.String)

StrokeType

public StrokeType(java.lang.String dataName,
                  java.lang.String id,
                  java.util.Map metaData)
Creates a new type.

Parameters:
dataName - data name (may be null)
id - type identity (may be null)
metaData - type meta data map (may be null)

StrokeType

protected StrokeType(java.lang.String typeName,
                     java.lang.String dataName,
                     java.lang.String id,
                     java.util.Map metaData)
Creates a new type.

Parameters:
typeName - type name
dataName - data name (may be null)
id - type identity (may be null)
metaData - type meta data map (may be null)
Method Detail

dup

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

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

equals

public boolean equals(java.lang.Object o)
Tests if this object is equal to another object.

Stroke type objects are equal if their super-classes are.

Specified by:
equals in interface java.util.Comparator
Overrides:
equals in class Type
See Also:
Compare.equals(Object,Object)

createStroke

public static java.awt.Stroke createStroke(java.lang.String format)
                                    throws InvalidDataException
Converts a string to a stroke value. The string is passed to a new StrokeParameters instance, which analyzes the string and creates a corresponding new stroke instance.

Parameters:
format - stroke spesification string
Throws:
InvalidDataException
See Also:
createStroke(String,ParsePosition)

createStroke

public static java.awt.Stroke createStroke(java.lang.String format,
                                           java.text.ParsePosition status)
                                    throws InvalidDataException
Converts a string to a stroke value. The string is passed to a new StrokeParameters instance, which analyzes the string and creates a corresponding new stroke instance.

Parameters:
format - stroke spesification string
status - parse status
Throws:
InvalidDataException
See Also:
getStrokeParameters(String), StrokeParameters.StrokeParameters(String,ParsePosition), StrokeParameters.toStroke()

getStrokeParameters

public static StrokeParameters getStrokeParameters(java.lang.String name)
Gets stock stroke parameters. If the given name does not match any of the current stock strokes, null is returned.

Parameters:
name - stock stroke name (may be null)
Returns:
stock stroke parameters (may be null)
See Also:
createStroke(String,ParsePosition)

getValueClass

public java.lang.Class getValueClass()
Gets value container class.

Specified by:
getValueClass in class Type

one

public DataValue one()
Gets unit data value for this type.

See Also:
zero()

toData

public DataValue toData(java.lang.Object value)
                 throws InvalidDataException
Converts object to a stroke value.

Overrides:
toData in class Type
Parameters:
value - the object to be converted
Returns:
a new stroke data object
Throws:
InvalidDataException - if object can not be converted
See Also:
Type.toData(CallableStatement,int), Type.toData(ResultSet,int), Type.toData(String,ParsePosition), DataValue.toString()

toData

public DataValue toData(java.sql.CallableStatement call,
                        int column)
                 throws java.sql.SQLException
Get callable statement result value.

Overrides:
toData in class Type
Parameters:
call - statement holding the data value to be converted
column - SQL column index for the data value to be converted
Returns:
a data value object corresponding to given object value
Throws:
java.sql.SQLException - if a SQL error occurs
See Also:
Type.toData(Object), Type.toData(ResultSet,int), Type.toData(String,ParsePosition), DataValue.toString()

toData

public DataValue toData(java.sql.ResultSet set,
                        int column)
                 throws java.sql.SQLException
Parse a result set output value as a data object.

Overrides:
toData in class Type
Parameters:
set - resultSet holding the data value to be converted
column - SQL column index for the data value to be converted
Returns:
a data value object corresponding to given object value
Throws:
java.sql.SQLException - if a SQL error occurs
See Also:
Type.toData(CallableStatement,int), Type.toData(Object), Type.toData(String,ParsePosition), DataValue.toString()

toData

public DataValue toData(java.lang.String value,
                        java.text.ParsePosition status)
                 throws InvalidDataException
Converts string to a stroke value.

Specified by:
toData in class Type
Parameters:
value - a stroke data string
status - parse status
Returns:
a new stroke data object
Throws:
InvalidDataException - if value can not be converted
See Also:
StrokeData

zero

public DataValue zero()
Gets zero data value for this type.

Specified by:
zero in class Type
Returns:
a new zero value data object sharing this type
See Also:
one()


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