1 /********************************************** 2 * Copyright (C) 2010 Lukas Laag 3 * This file is part of lib-gwt-svg. 4 * 5 * libgwtsvg is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU Lesser General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * libgwtsvg is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with libgwtsvg. If not, see http://www.gnu.org/licenses/ 17 **********************************************/ 18 /* 19 * Copyright (c) 2004 World Wide Web Consortium, 20 * 21 * (Massachusetts Institute of Technology, European Research Consortium for 22 * Informatics and Mathematics, Keio University). All Rights Reserved. This 23 * work is distributed under the W3C(r) Software License [1] in the hope that 24 * it will be useful, but WITHOUT ANY WARRANTY; without even the implied 25 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 26 * 27 * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 28 */ 29 30 package org.vectomatic.dom.svg; 31 32 import com.google.gwt.core.client.JavaScriptException; 33 import com.google.gwt.core.client.JavaScriptObject; 34 35 /** 36 * The {@link org.vectomatic.dom.svg.OMSVGAngle} interface corresponds to 37 * the <a href='types.html#DataTypeAngle'><angle></a> basic data type. 38 * <p id="ReadOnlyAngle">An {@link org.vectomatic.dom.svg.OMSVGAngle} object 39 * can be designated as <em>read only</em>, which means that attempts to modify 40 * the object will result in an exception being thrown, as described below.</p> 41 */ 42 public class OMSVGAngle extends JavaScriptObject { 43 /** 44 * The unit type is not one of predefined unit types. It is invalid to attempt 45 * to define a new value of this type or to attempt to switch an existing 46 * value to this type. 47 */ 48 public static final short SVG_ANGLETYPE_UNKNOWN = 0; 49 /** 50 * No unit type was provided (i.e., a unitless value was specified). For angles, 51 * a unitless value is treated the same as if degrees were specified. 52 */ 53 public static final short SVG_ANGLETYPE_UNSPECIFIED = 1; 54 /** 55 * The unit type was explicitly set to degrees. 56 */ 57 public static final short SVG_ANGLETYPE_DEG = 2; 58 /** 59 * The unit type is radians. 60 */ 61 public static final short SVG_ANGLETYPE_RAD = 3; 62 /** 63 * The unit type is radians. 64 */ 65 public static final short SVG_ANGLETYPE_GRAD = 4; 66 protected OMSVGAngle() { 67 } 68 69 // Implementation of the svg::SVGAngle W3C IDL interface 70 /** 71 * The type of the value as specified by one of the SVG_ANGLETYPE_ constants 72 * defined on this interface. 73 */ 74 public final native short getUnitType() /*-{ 75 return this.unitType; 76 }-*/; 77 /** 78 * The angle value as a floating point value, in degrees. Setting this attribute 79 * will cause {@link org.vectomatic.dom.svg.OMSVGAngle#getValueInSpecifiedUnits()} 80 * and {@link org.vectomatic.dom.svg.OMSVGAngle#getValueAsString()} to be 81 * updated automatically to reflect this setting. 82 */ 83 public final native float getValue() /*-{ 84 return this.value; 85 }-*/; 86 /** 87 * The angle value as a floating point value, in degrees. Setting this attribute 88 * will cause {@link org.vectomatic.dom.svg.OMSVGAngle#getValueInSpecifiedUnits()} 89 * and {@link org.vectomatic.dom.svg.OMSVGAngle#getValueAsString()} to be 90 * updated automatically to reflect this setting. 91 * @throws DOMException(NO_MODIFICATION_ALLOWED_ERR) Raised when the angle 92 * corresponds to a <a href="svgdom.html#ReadOnlyNodes">read only attribute</a> 93 * or when the object itself is <a href="#ReadOnlyAngle">read only</a>. 94 */ 95 public final native void setValue(float value) throws JavaScriptException /*-{ 96 this.value = value; 97 }-*/; 98 /** 99 * The angle value as a floating point value, in the units expressed by {@link 100 * org.vectomatic.dom.svg.OMSVGAngle#getUnitType()}. Setting this attribute 101 * will cause {@link org.vectomatic.dom.svg.OMSVGAngle#getValue()} and {@link 102 * org.vectomatic.dom.svg.OMSVGAngle#getValueAsString()} to be updated automatically 103 * to reflect this setting. 104 */ 105 public final native float getValueInSpecifiedUnits() /*-{ 106 return this.valueInSpecifiedUnits; 107 }-*/; 108 /** 109 * The angle value as a floating point value, in the units expressed by {@link 110 * org.vectomatic.dom.svg.OMSVGAngle#getUnitType()}. Setting this attribute 111 * will cause {@link org.vectomatic.dom.svg.OMSVGAngle#getValue()} and {@link 112 * org.vectomatic.dom.svg.OMSVGAngle#getValueAsString()} to be updated automatically 113 * to reflect this setting. 114 * @throws DOMException(NO_MODIFICATION_ALLOWED_ERR) Raised when the angle 115 * corresponds to a <a href="svgdom.html#ReadOnlyNodes">read only attribute</a> 116 * or when the object itself is <a href="#ReadOnlyAngle">read only</a>. 117 */ 118 public final native void setValueInSpecifiedUnits(float value) throws JavaScriptException /*-{ 119 this.valueInSpecifiedUnits = value; 120 }-*/; 121 /** 122 * The angle value as a string value, in the units expressed by {@link org.vectomatic.dom.svg.OMSVGAngle#getUnitType()}. 123 * Setting this attribute will cause {@link org.vectomatic.dom.svg.OMSVGAngle#getValue()}, 124 * {@link org.vectomatic.dom.svg.OMSVGAngle#getValueInSpecifiedUnits()} and 125 * {@link org.vectomatic.dom.svg.OMSVGAngle#getUnitType()} to be updated automatically 126 * to reflect this setting. 127 */ 128 public final native String getValueAsString() /*-{ 129 return this.valueAsString; 130 }-*/; 131 /** 132 * The angle value as a string value, in the units expressed by {@link org.vectomatic.dom.svg.OMSVGAngle#getUnitType()}. 133 * Setting this attribute will cause {@link org.vectomatic.dom.svg.OMSVGAngle#getValue()}, 134 * {@link org.vectomatic.dom.svg.OMSVGAngle#getValueInSpecifiedUnits()} and 135 * {@link org.vectomatic.dom.svg.OMSVGAngle#getUnitType()} to be updated automatically 136 * to reflect this setting. 137 * @throws DOMException(NO_MODIFICATION_ALLOWED_ERR) Raised when the angle 138 * corresponds to a <a href="svgdom.html#ReadOnlyNodes">read only attribute</a> 139 * or when the object itself is <a href="#ReadOnlyAngle">read only</a>. 140 * @throws DOMException(SYNTAX_ERR) Raised if the assigned string cannot 141 * be parsed as a valid <code><angle></code>. 142 */ 143 public final native void setValueAsString(String value) throws JavaScriptException /*-{ 144 this.valueAsString = value; 145 }-*/; 146 /** 147 * Reset the value as a number with an associated {@link org.vectomatic.dom.svg.OMSVGAngle#getUnitType()}, 148 * thereby replacing the values for all of the attributes on the object. 149 * @param unitType The unit type for the value (e.g., <code>SVG_ANGLETYPE_DEG</code>). 150 * @param valueInSpecifiedUnits The angle value. 151 * @throws DOMException(NO_MODIFICATION_ALLOWED_ERR) Raised when the angle 152 * corresponds to a <a href="svgdom.html#ReadOnlyNodes">read only attribute</a> 153 * or when the object itself is <a href="#ReadOnlyAngle">read only</a>. 154 * @throws DOMException(NOT_SUPPORTED_ERR) Raised if unitType is SVG_ANGLETYPE_UNKNOWN 155 * or not a valid unit type constant (one of the other SVG_ANGLETYPE_ constants 156 * defined on this interface). 157 */ 158 public final native void newValueSpecifiedUnits(short unitType, float valueInSpecifiedUnits) throws JavaScriptException /*-{ 159 this.newValueSpecifiedUnits(unitType, valueInSpecifiedUnits); 160 }-*/; 161 /** 162 * Preserve the same underlying stored value, but reset the stored unit identifier 163 * to the given <var>unitType</var>. Object attributes {@link org.vectomatic.dom.svg.OMSVGAngle#getUnitType()}, 164 * {@link org.vectomatic.dom.svg.OMSVGAngle#getValueInSpecifiedUnits()} and 165 * {@link org.vectomatic.dom.svg.OMSVGAngle#getValueAsString()} might be modified 166 * as a result of this method. 167 * @param unitType The unit type to switch to (e.g., <code>SVG_ANGLETYPE_DEG</code>). 168 * @throws DOMException(NO_MODIFICATION_ALLOWED_ERR) Raised when the angle 169 * corresponds to a <a href="svgdom.html#ReadOnlyNodes">read only attribute</a> 170 * or when the object itself is <a href="#ReadOnlyAngle">read only</a>. 171 * @throws DOMException(NOT_SUPPORTED_ERR) Raised if unitType is SVG_ANGLETYPE_UNKNOWN 172 * or not a valid unit type constant (one of the other SVG_ANGLETYPE_ constants 173 * defined on this interface). 174 */ 175 public final native void convertToSpecifiedUnits(short unitType) throws JavaScriptException /*-{ 176 this.convertToSpecifiedUnits(unitType); 177 }-*/; 178 179 }