previous   next   contents   properties   index  

3 Basic Data Types and Interfaces


Contents


3.1 Basic data types

The common data types for SVG's properties and attributes fall into the following categories:


3.2 Basic DOM interfaces

The following interfaces are defined below: SVGAngle, SVGInteger, SVGLength, SVGNumber, SVGRect, SVGList, SVGLengthList, SVGUnitTypes.


Interface SVGAngle

The SVGAngle interface corresponds to the <angle> basic data type.


IDL Definition
interface SVGAngle {
  // Angle Unit Types
  constant unsigned short SVG_ANGLETYPE_UNKNOWN     = 0;
  constant unsigned short SVG_ANGLETYPE_UNSPECIFIED = 1;
  constant unsigned short SVG_ANGLETYPE_DEG         = 2;
  constant unsigned short SVG_ANGLETYPE_RAD         = 3;
  constant unsigned short SVG_ANGLETYPE_GRAD        = 4;

  readonly attribute unsigned short unitType;
           attribute float          value;
           attribute float          valueInSpecifiedUnits;
           attribute DOMString      valueAsString;
  readonly attribute float          animatedValue;

  void newValueSpecifiedUnits ( in unsigned short unitType, in float valueInSpecifiedUnits )
                  raises( SVGException );
  void convertToSpecifiedUnits ( in unsigned short unitType )
                  raises( SVGException );
};

Definition group Angle Unit Types
Defined constants
SVG_ANGLETYPE_UNKNOWN The unit type is not one of predefined unit types. It is invalid to attempt to define a new value of this type or to attempt to switch an existing value to this type.
SVG_ANGLETYPE_UNSPECIFIED No unit type was provided (i.e., a unitless value was specified). For angles, a unitless value is treated the same as if degrees were specified.
SVG_ANGLETYPE_DEG The unit type was explicitly set to degrees.
SVG_ANGLETYPE_RAD The unit type is radians.
SVG_ANGLETYPE_GRAD The unit type is grads.
Attributes
readonly unsigned short unitType
The type of the value as specified by one of the constants specified above.
float value
The angle value as a floating point value, in degrees. Setting this attribute will cause valueInSpecifiedUnits and valueAsString to be updated automatically to reflect this setting.
float valueInSpecifiedUnits
The angle value as a floating point value, in the units expressed by unitType. Setting this attribute will cause value and valueAsString to be updated automatically to reflect this setting.
DOMString valueAsString
The angle value as a string value, in the units expressed by unitType. Setting this attribute will cause value and valueInSpecifiedUnits to be updated automatically to reflect this setting.
readonly float animatedValue
If the given attribute or property is being animated, contains the current animated value of the attribute or property. If the given attribute or property is not currently being animated, contains the same value as value. The value is in degrees.
Methods
newValueSpecifiedUnits
Reset the value as a number with an associated unitType, thereby replacing the values for all of the attributes on the object.
Parameters
in unsigned short unitType The unitType for the angle value (e.g., SVG_ANGLETYPE_DEG).
in float valueInSpecifiedUnits The angle value.
No Return Value
Exceptions
SVGException
SVG_WRONG_TYPE_ERR: Raised if an invalid unitType is specified.
convertToSpecifiedUnits
Preserve the same value, but convert to the specified unitType. Object attributes unitType, valueAsSpecified and valueAsString might be modified as a result of this method,
Parameters
in unsigned short unitType The unitType to switch to (e.g., SVG_ANGLETYPE_DEG).
No Return Value
Exceptions
SVGException
SVG_WRONG_TYPE_ERR: Raised if an invalid unitType is specified.

Interface SVGInteger

The SVGInteger interface corresponds to the <integer> basic data type.


IDL Definition
interface SVGInteger {
           attribute long value;
  readonly attribute long animatedValue;
};

Attributes
long value
The value as an integer.
readonly long animatedValue
If the given attribute or property is being animated, contains the current animated value of the attribute or property. If the given attribute or property is not currently being animated, contains the same value as DOM property value.

Interface SVGLength

The SVGLength interface corresponds to the <length> basic data type.


IDL Definition
interface SVGLength {
  // Length Unit Types
  constant unsigned short SVG_LENGTHTYPE_UNKNOWN    = 0;
  constant unsigned short SVG_LENGTHTYPE_NUMBER     = 1;
  constant unsigned short SVG_LENGTHTYPE_PERCENTAGE = 2;
  constant unsigned short SVG_LENGTHTYPE_EMS        = 3;
  constant unsigned short SVG_LENGTHTYPE_EXS        = 4;
  constant unsigned short SVG_LENGTHTYPE_PX         = 5;
  constant unsigned short SVG_LENGTHTYPE_CM         = 6;
  constant unsigned short SVG_LENGTHTYPE_MM         = 7;
  constant unsigned short SVG_LENGTHTYPE_IN         = 8;
  constant unsigned short SVG_LENGTHTYPE_PT         = 9;
  constant unsigned short SVG_LENGTHTYPE_PC         = 10;

  readonly attribute unsigned short unitType;
           attribute float          value;
           attribute float          valueInSpecifiedUnits;
           attribute DOMString      valueAsString;
  readonly attribute float          animatedValue;

  void newValueSpecifiedUnits ( in unsigned short unitType, in float valueInSpecifiedUnits )
                  raises( SVGException );
  void convertToSpecifiedUnits ( in unsigned short unitType )
                  raises( SVGException );
};

Definition group Length Unit Types
Defined constants
SVG_LENGTHTYPE_UNKNOWN The unit type is not one of predefined unit types. It is invalid to attempt to define a new value of this type or to attempt to switch an existing value to this type.
SVG_LENGTHTYPE_NUMBER No unit type was provided (i.e., a unitless value was specified), which indicates a value in user units.
SVG_LENGTHTYPE_PERCENTAGE A percentage value was specified.
SVG_LENGTHTYPE_EMS A value was specified using the "em" units defined in CSS2.
SVG_LENGTHTYPE_EXS A value was specified using the "ex" units defined in CSS2.
SVG_LENGTHTYPE_PX A value was specified using the "px" units defined in CSS2.
SVG_LENGTHTYPE_CM A value was specified using the "cm" units defined in CSS2.
SVG_LENGTHTYPE_MM A value was specified using the "mm" units defined in CSS2.
SVG_LENGTHTYPE_IN A value was specified using the "in" units defined in CSS2.
SVG_LENGTHTYPE_PT A value was specified using the "pt" units defined in CSS2.
SVG_LENGTHTYPE_PC A value was specified using the "pc" units defined in CSS2.
Attributes
readonly unsigned short unitType
The type of the value as specified by one of the constants specified above.
float value
The value as an floating point value, in user units. Setting this attribute will cause valueInSpecifiedUnits and valueAsString to be updated automatically to reflect this setting.
float valueInSpecifiedUnits
The value as an floating point value, in the units expressed by unitType. Setting this attribute will cause value and valueAsString to be updated automatically to reflect this setting.
DOMString valueAsString
The value as a string value, in the units expressed by unitType. Setting this attribute will cause value and valueInSpecifiedUnits to be updated automatically to reflect this setting.
readonly float animatedValue
If the given attribute or property is being animated, contains the current animated value of the attribute or property. If the given attribute or property is not currently being animated, contains the same value as DOM property value. The value is in user units.
Methods
newValueSpecifiedUnits
Reset the value as a number with an associated unitType, thereby replacing the values for all of the attributes on the object.
Parameters
in unsigned short unitType The unitType for the value (e.g., SVG_LENGTHTYPE_MM).
in float valueInSpecifiedUnits The new value.
No Return Value
Exceptions
SVGException
SVG_WRONG_TYPE_ERR: Raised if an invalid unitType is specified.
convertToSpecifiedUnits
Preserve the same value, but convert to the specified unitType. Object attributes unitType, valueAsSpecified and valueAsString might be modified as a result of this method,
Parameters
in unsigned short unitType The unitType to switch to (e.g., SVG_LENGTHTYPE_MM).
No Return Value
Exceptions
SVGException
SVG_WRONG_TYPE_ERR: Raised if an invalid unitType is specified.

Interface SVGNumber

The SVGNumber interface corresponds to the <number> basic data type.


IDL Definition
interface SVGNumber {
           attribute float value;
  readonly attribute float animatedValue;
};

Attributes
float value
The value as a floating point number.
readonly float animatedValue
If the given attribute or property is being animated, contains the current animated value of the attribute or property. If the given attribute or property is not currently being animated, contains the same value as DOM property value.

Interface SVGRect

Rectangles are defined as consisting of a (x,y) coordinate pair identifying a minimum X value, a minimum Y value, and a width and height, which are usually constrained to be non-negative.


IDL Definition
interface SVGRect {
           attribute SVGNumber x;
           attribute SVGNumber y;
           attribute SVGNumber width;
           attribute SVGNumber height;
};

Attributes
SVGNumber x
Corresponds to attribute x on the given element.
SVGNumber y
Corresponds to attribute y on the given element.
SVGNumber width
Corresponds to attribute width on the given element.
SVGNumber height
Corresponds to attribute height on the given element.

Interface SVGList

This interface defines a set of generic list handling attributes and methods.


IDL Definition
interface SVGList {
  readonly attribute unsigned long numberOfItems;

  void   clear (  );
  Object initialize ( in Object newItem )
                  raises( SVGException );
  Object createItem (  );
  Object getItem ( in unsigned long index )
                  raises( DOMException );
  Object insertBefore ( in Object newItem, in unsigned long index )
                  raises( SVGException );
  Object replace ( in Object newItem, in unsigned long index )
                  raises( DOMException, SVGException );
  Object remove ( in unsigned long index )
                  raises( DOMException );
  Object append ( in Object newItem )
                  raises( SVGException );
};

Attributes
readonly unsigned long numberOfItems
The number of items in the list.
Methods
clear
Clears all existing current items from the list, with the result being an empty list.
No Parameters
No Return Value
No Exceptions
initialize
Clears all existing current items from the list and re-initializes the list to hold the single item specified by the parameter.
Parameters
in Object newItem The item which should become the only member of the list.
Return value
Object The item being inserted into the list.
Exceptions
SVGException
SVG_WRONG_TYPE_ERR: Raised if parameter newItem is the wrong type of object for the given list.
createItem
Creates an initialized item of the appropriate type for this list.
No Parameters
Return value
Object The created item.
No Exceptions
getItem
Returns the specified item from the list.
Parameters
in unsigned long index The index of the item from the list which is to be returned. The first item is number 1.
Return value
Object The selected item.
Exceptions
DOMException
INDEX_SIZE_ERR: Raised if the index number is less than 1 or greater than number_of_items.
insertBefore
Inserts a new item into the list at the specified position.
Parameters
in Object newItem The item which is to be inserted into the list.
in unsigned long index The index of the item before which the new item is to be inserted. If the index is less than or equal to 1, then the new item is inserted at the front of the list. If the index is greater than number_of_items, then the new item is appended to the end of the list.
Return value
Object The inserted item.
Exceptions
SVGException
SVG_WRONG_TYPE_ERR: Raised if parameter newItem is the wrong type of object for the given list.
replace
Replaces an existing item in the list with a new item.
Parameters
in Object newItem The item which is to be inserted into the list.
in unsigned long index The index of the item which is to be replaced.
Return value
Object The inserted item.
Exceptions
DOMException
INDEX_SIZE_ERR: Raised if the index number is less than 1 or greater than number_of_items.
SVGException
SVG_WRONG_TYPE_ERR: Raised if parameter newItem is the wrong type of object for the given list.
remove
Removes an existing item from the list.
Parameters
in unsigned long index The index of the item which is to be removed.
Return value
Object The removed item.
Exceptions
DOMException
INDEX_SIZE_ERR: Raised if the index number is less than 1 or greater than number_of_items.
append
Inserts a new item at the end of the list.
Parameters
in Object newItem The item which is to be inserted into the list.
Return value
Object The inserted item.
Exceptions
SVGException
SVG_WRONG_TYPE_ERR: Raised if parameter newItem is the wrong type of object for the given list.

Interface SVGLengthList

Used for values that can be expressed as an array of SVGLengths.

The various methods inherited from SVGList, which are defined in SVGList to accept parameters and return values of type Object, must receive parameters of type SVGLength and return values of type SVGLength.


IDL Definition
interface SVGLengthList : SVGList;


Interface SVGUnitTypes

The SVGUnitTypes interface defines a commonly used set of constants and is a base interface used by SVGGradientElement, SVGPatternElement, SVGClipPathElement, SVGMaskElement, and SVGFilterElement.


IDL Definition
interface SVGUnitTypes {
  // Unit Types
  constant unsigned short SVG_UNIT_TYPE_UNKNOWN           = 0;
  constant unsigned short SVG_UNIT_TYPE_USERSPACE         = 1;
  constant unsigned short SVG_UNIT_TYPE_USERSPACEONUSE    = 2;
  constant unsigned short SVG_UNIT_TYPE_OBJECTBOUNDINGBOX = 3;
};

Definition group Unit Types
Defined constants
SVG_UNIT_TYPE_UNKNOWN The type is not one of predefined types. It is invalid to attempt to define a new value of this type or to attempt to switch an existing value to this type.
SVG_UNIT_TYPE_USERSPACE Corresponds to value userSpace.
SVG_UNIT_TYPE_USERSPACEONUSE Corresponds to value userSpaceOnUse.
SVG_UNIT_TYPE_OBJECTBOUNDINGBOX Corresponds to value objectBoundingBox.

previous   next   contents   properties   index