001/* ---------------------------------------------------------------------------- 002 * This file was automatically generated by SWIG (http://www.swig.org). 003 * Version 3.0.7 004 * 005 * Do not make changes to this file unless you know what you are doing--modify 006 * the SWIG interface file instead. 007 * ----------------------------------------------------------------------------- */ 008 009package org.sbml.libsbml; 010 011/** 012 * LibSBML implementation of the gradient stop concept from the 013 <p> 014 * SBML render extension. The gradient stop concept was more or less taken from 015 * the corresponding concept in SVG. 016 * A {@link GradientStop} object represents the color at a certain location in a linear or 017 * radial gradient. 018 * Each gradient should contain two or more gradient stops which mark the edges of a region 019 * within this region color are interpolated based on the distance of the location to the 020 * edges of the region. 021 <p> 022 * A gradient stop has two attributes. The first attribute is an offset which determines the 023 * location for the gradient stop within the object the gradient is appllied to. 024 * The offset can either be ab absolute value or a relative value or a combination of absolute 025 * and relative value. E.g. a value of '50%' for the offset means that the gradient stop is located 026 * at 50% of the gradient vector. For more information and examples, see the render extension 027 * specification or the SVG specification. 028 <p> 029 * The second attribute defines the color for the gradient stop. The color can either be defined 030 * be a color value string or by the id of a {@link ColorDefinition} object. (@see ColorDefinition) 031 */ 032 033public class GradientStop extends SBase { 034 private long swigCPtr; 035 036 protected GradientStop(long cPtr, boolean cMemoryOwn) 037 { 038 super(libsbmlJNI.GradientStop_SWIGUpcast(cPtr), cMemoryOwn); 039 swigCPtr = cPtr; 040 } 041 042 protected static long getCPtr(GradientStop obj) 043 { 044 return (obj == null) ? 0 : obj.swigCPtr; 045 } 046 047 protected static long getCPtrAndDisown (GradientStop obj) 048 { 049 long ptr = 0; 050 051 if (obj != null) 052 { 053 ptr = obj.swigCPtr; 054 obj.swigCMemOwn = false; 055 } 056 057 return ptr; 058 } 059 060 protected void finalize() { 061 delete(); 062 } 063 064 public synchronized void delete() { 065 if (swigCPtr != 0) { 066 if (swigCMemOwn) { 067 swigCMemOwn = false; 068 libsbmlJNI.delete_GradientStop(swigCPtr); 069 } 070 swigCPtr = 0; 071 } 072 super.delete(); 073 } 074 075 076/** 077 * Creates a new {@link GradientStop} object with the given SBML level 078 * and SBML version. 079 <p> 080 * @param level SBML level of the new object 081 * @param level SBML version of the new object 082 */ public 083 GradientStop(long level, long version, long pkgVersion) throws org.sbml.libsbml.SBMLConstructorException { 084 this(libsbmlJNI.new_GradientStop__SWIG_0(level, version, pkgVersion), true); 085 } 086 087 088/** 089 * Creates a new {@link GradientStop} object with the given SBML level 090 * and SBML version. 091 <p> 092 * @param level SBML level of the new object 093 * @param level SBML version of the new object 094 */ public 095 GradientStop(long level, long version) throws org.sbml.libsbml.SBMLConstructorException { 096 this(libsbmlJNI.new_GradientStop__SWIG_1(level, version), true); 097 } 098 099 100/** 101 * Creates a new {@link GradientStop} object with the given SBML level 102 * and SBML version. 103 <p> 104 * @param level SBML level of the new object 105 * @param level SBML version of the new object 106 */ public 107 GradientStop(long level) throws org.sbml.libsbml.SBMLConstructorException { 108 this(libsbmlJNI.new_GradientStop__SWIG_2(level), true); 109 } 110 111 112/** 113 * Creates a new {@link GradientStop} object with the given SBML level 114 * and SBML version. 115 <p> 116 * @param level SBML level of the new object 117 * @param level SBML version of the new object 118 */ public 119 GradientStop() throws org.sbml.libsbml.SBMLConstructorException { 120 this(libsbmlJNI.new_GradientStop__SWIG_3(), true); 121 } 122 123 124/** 125 * Creates a new {@link GradientStop} object with the given {@link SBMLNamespaces}. 126 <p> 127 * @param sbmlns The SBML namespace for the object. 128 */ public 129 GradientStop(RenderPkgNamespaces renderns) throws org.sbml.libsbml.SBMLConstructorException { 130 this(libsbmlJNI.new_GradientStop__SWIG_4(RenderPkgNamespaces.getCPtr(renderns), renderns), true); 131 } 132 133 134/** 135 * Creates a new {@link GradientStop} object from the given {@link XMLNode} object. 136 * The {@link XMLNode} object has to contain a valid XML representation of a 137 * {@link GradientStop} object as defined in the render extension specification. 138 * This method is normally called when render information is read from a file and 139 * should normally not have to be called explicitly. 140 <p> 141 * @param node the {@link XMLNode} object reference that describes the {@link GradientStop} 142 * object to be instantiated. 143 */ public 144 GradientStop(XMLNode node, long l2version) throws org.sbml.libsbml.SBMLConstructorException { 145 this(libsbmlJNI.new_GradientStop__SWIG_5(XMLNode.getCPtr(node), node, l2version), true); 146 } 147 148 149/** 150 * Creates a new {@link GradientStop} object from the given {@link XMLNode} object. 151 * The {@link XMLNode} object has to contain a valid XML representation of a 152 * {@link GradientStop} object as defined in the render extension specification. 153 * This method is normally called when render information is read from a file and 154 * should normally not have to be called explicitly. 155 <p> 156 * @param node the {@link XMLNode} object reference that describes the {@link GradientStop} 157 * object to be instantiated. 158 */ public 159 GradientStop(XMLNode node) throws org.sbml.libsbml.SBMLConstructorException { 160 this(libsbmlJNI.new_GradientStop__SWIG_6(XMLNode.getCPtr(node), node), true); 161 } 162 163 164/** 165 * Returns the offset of the gradient. 166 <p> 167 * @return a reference to the offset of the gradient stop. 168 */ public 169 RelAbsVector getOffset() { 170 return new RelAbsVector(libsbmlJNI.GradientStop_getOffset__SWIG_0(swigCPtr, this), false); 171 } 172 173 174/** 175 * Sets the offset for the gradient stop. 176 <p> 177 * @param abs the absolute value of the offset. 178 <p> 179 * @param rel the relative value of the offset. 180 */ public 181 void setOffset(double abs, double rel) { 182 libsbmlJNI.GradientStop_setOffset__SWIG_0(swigCPtr, this, abs, rel); 183 } 184 185 186/** 187 * Sets the offset to the value specified by the given string. 188 * The string has to represent a combination of an absolute 189 * and relative value. 190 * Valid value string would e.g. be '45.0', '30%' or 191 * '10+5%'. If the value is a combination of both relative and 192 * absolute value, the absolute value has to come before the relative 193 * value. Number can be given as integer values or floating point values 194 * and the two components can be combined by '+' or '-'. Depending on 195 * whethr the relative value should be added or subtracted from the 196 * absolute value. 197 * If the given string is not valid, the offset will have an absolute 198 * and a relative value of NaN. 199 <p> 200 * @param a string representing a valid offset value. 201 */ public 202 void setOffset(String arg0) { 203 libsbmlJNI.GradientStop_setOffset__SWIG_1(swigCPtr, this, arg0); 204 } 205 206 207/** 208 * Sets the offset to the given vector object. 209 <p> 210 * @param offset The {@link RelAbsVector} object that specifies the 211 * offset of the gradient stop. 212 */ public 213 void setOffset(RelAbsVector offset) { 214 libsbmlJNI.GradientStop_setOffset__SWIG_2(swigCPtr, this, RelAbsVector.getCPtr(offset), offset); 215 } 216 217 218/** 219 * Returns the stop color id or the value string. 220 * Since ids can not start with the '#' character, 221 * this is the way to determine if the gradient stop 222 * uses a color value or a color id. 223 <p> 224 * @return the color id or value string 225 */ public 226 String getStopColor() { 227 return libsbmlJNI.GradientStop_getStopColor(swigCPtr, this); 228 } 229 230 231/** 232 * Sets the stop color id or the stop color value. 233 <p> 234 * @param color Either the id of a {@link ColorDefinition} object, or a color 235 * value string. 236 */ public 237 void setStopColor(String color) { 238 libsbmlJNI.GradientStop_setStopColor(swigCPtr, this, color); 239 } 240 241 242/** 243 * Creates and returns a deep copy of this {@link GradientStop} object. 244 <p> 245 * @return a (deep) copy of this {@link GradientStop} object 246 */ public 247 SBase cloneObject() { 248 long cPtr = libsbmlJNI.GradientStop_cloneObject(swigCPtr, this); 249 return (cPtr == 0) ? null : new GradientStop(cPtr, true); 250 } 251 252 253/** 254 * Returns the XML element name of this object. 255 <p> 256 * This is overridden by subclasses to return a string appropriate to the 257 * SBML component. For example, {@link Model} defines it as returning 'model', 258 * {@link CompartmentType} defines it as returning 'compartmentType', etc. 259 */ public 260 String getElementName() { 261 return libsbmlJNI.GradientStop_getElementName(swigCPtr, this); 262 } 263 264 265/** 266 * Creates an {@link XMLNode} object from this {@link GradientStop} object. 267 <p> 268 * @return the {@link XMLNode} with the XML representation for the 269 * {@link GradientStop} object. 270 */ public 271 XMLNode toXML() { 272 return new XMLNode(libsbmlJNI.GradientStop_toXML(swigCPtr, this), true); 273 } 274 275 276/** 277 * Returns the libSBML type code for this SBML object. 278 <p> 279 * LibSBML attaches an 280 * identifying code to every kind of SBML object. These are known as 281 * <em>SBML type codes</em>. In other languages, the set of type codes 282 * is stored in an enumeration; in the Java language interface for 283 * libSBML, the type codes are defined as static integer constants in 284 * interface class {@link libsbmlConstants}. The names of the type codes 285 * all begin with the characters <code>SBML_.</code> 286 <p> 287 * @return the SBML type code for this object, or <code>SBML_UNKNOWN</code> (default). 288 <p> 289 * @see #getElementName() 290 */ public 291 int getTypeCode() { 292 return libsbmlJNI.GradientStop_getTypeCode(swigCPtr, this); 293 } 294 295 296/** * @internal */ public 297 boolean hasRequiredAttributes() { 298 return libsbmlJNI.GradientStop_hasRequiredAttributes(swigCPtr, this); 299 } 300 301 302/** * @internal */ public 303 boolean hasRequiredElements() { 304 return libsbmlJNI.GradientStop_hasRequiredElements(swigCPtr, this); 305 } 306 307}