001/* ---------------------------------------------------------------------------- 002 * This file was automatically generated by SWIG (http://www.swig.org). 003 * Version 3.0.8 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 * Representation of a linear gradient object from the SBML render extension. 013 <p> 014 * The concept of a linear gradient is more or or less taken from SVG. 015 * A linear gradient is defined by a vector which determines the direction and the length 016 * of the gradient. So for a valid gradient this vector should have a length different from 0. 017 * Otherwise all restrictions for the {@link GradientBase} class apply. ( 018 * The vector for a linear gradient is defined by a start and an endpoint and each point consists 019 * of three absolute-relative value pairs (@see RelAbsVector) 020 <p> 021 * For examples of LinearGradients see the render extension specification and/or 022 * the SVG specification. 023 <p> 024 * @see GradientBase) 025 */ 026 027public class LinearGradient extends GradientBase { 028 private long swigCPtr; 029 030 protected LinearGradient(long cPtr, boolean cMemoryOwn) 031 { 032 super(libsbmlJNI.LinearGradient_SWIGUpcast(cPtr), cMemoryOwn); 033 swigCPtr = cPtr; 034 } 035 036 protected static long getCPtr(LinearGradient obj) 037 { 038 return (obj == null) ? 0 : obj.swigCPtr; 039 } 040 041 protected static long getCPtrAndDisown (LinearGradient obj) 042 { 043 long ptr = 0; 044 045 if (obj != null) 046 { 047 ptr = obj.swigCPtr; 048 obj.swigCMemOwn = false; 049 } 050 051 return ptr; 052 } 053 054 protected void finalize() { 055 delete(); 056 } 057 058 public synchronized void delete() { 059 if (swigCPtr != 0) { 060 if (swigCMemOwn) { 061 swigCMemOwn = false; 062 libsbmlJNI.delete_LinearGradient(swigCPtr); 063 } 064 swigCPtr = 0; 065 } 066 super.delete(); 067 } 068 069 070/** 071 * Creates a new {@link LinearGradient} object with the given SBML level 072 * and SBML version. 073 <p> 074 * @param level SBML level of the new object 075 * @param level SBML version of the new object 076 */ public 077 LinearGradient(long level, long version, long pkgVersion) throws org.sbml.libsbml.SBMLConstructorException { 078 this(libsbmlJNI.new_LinearGradient__SWIG_0(level, version, pkgVersion), true); 079 } 080 081 082/** 083 * Creates a new {@link LinearGradient} object with the given SBML level 084 * and SBML version. 085 <p> 086 * @param level SBML level of the new object 087 * @param level SBML version of the new object 088 */ public 089 LinearGradient(long level, long version) throws org.sbml.libsbml.SBMLConstructorException { 090 this(libsbmlJNI.new_LinearGradient__SWIG_1(level, version), true); 091 } 092 093 094/** 095 * Creates a new {@link LinearGradient} object with the given SBML level 096 * and SBML version. 097 <p> 098 * @param level SBML level of the new object 099 * @param level SBML version of the new object 100 */ public 101 LinearGradient(long level) throws org.sbml.libsbml.SBMLConstructorException { 102 this(libsbmlJNI.new_LinearGradient__SWIG_2(level), true); 103 } 104 105 106/** 107 * Creates a new {@link LinearGradient} object with the given SBML level 108 * and SBML version. 109 <p> 110 * @param level SBML level of the new object 111 * @param level SBML version of the new object 112 */ public 113 LinearGradient() throws org.sbml.libsbml.SBMLConstructorException { 114 this(libsbmlJNI.new_LinearGradient__SWIG_3(), true); 115 } 116 117 118/** 119 * Creates a new {@link LinearGradient} object with the given {@link SBMLNamespaces}. 120 <p> 121 * @param sbmlns The SBML namespace for the object. 122 */ public 123 LinearGradient(RenderPkgNamespaces renderns) throws org.sbml.libsbml.SBMLConstructorException { 124 this(libsbmlJNI.new_LinearGradient__SWIG_4(RenderPkgNamespaces.getCPtr(renderns), renderns), true); 125 } 126 127 128/** 129 * Creates a new {@link LinearGradient} object from the given {@link XMLNode} object. 130 * The {@link XMLNode} object has to contain a valid XML representation of a 131 * {@link LinearGradient} object as defined in the render extension specification. 132 * This method is normally called when render information is read from a file and 133 * should normally not have to be called explicitly. 134 <p> 135 * @param node the {@link XMLNode} object reference that describes the {@link LinearGradient} 136 * object to be instantiated. 137 */ public 138 LinearGradient(XMLNode node, long l2version) throws org.sbml.libsbml.SBMLConstructorException { 139 this(libsbmlJNI.new_LinearGradient__SWIG_5(XMLNode.getCPtr(node), node, l2version), true); 140 } 141 142 143/** 144 * Creates a new {@link LinearGradient} object from the given {@link XMLNode} object. 145 * The {@link XMLNode} object has to contain a valid XML representation of a 146 * {@link LinearGradient} object as defined in the render extension specification. 147 * This method is normally called when render information is read from a file and 148 * should normally not have to be called explicitly. 149 <p> 150 * @param node the {@link XMLNode} object reference that describes the {@link LinearGradient} 151 * object to be instantiated. 152 */ public 153 LinearGradient(XMLNode node) throws org.sbml.libsbml.SBMLConstructorException { 154 this(libsbmlJNI.new_LinearGradient__SWIG_6(XMLNode.getCPtr(node), node), true); 155 } 156 157 158/** 159 * Constructor which creates a {@link LinearGradient} with no gradient stops. 160 * The id is set to the given value. 161 * The {@link LinearGradient} object is invalid until it has an id and at least two 162 * gradient stops. 163 * The start and the end of the linear gradient vector are set to (0,0,0). 164 * A linear gradient with a vector of length zero should also be considered invalid. 165 <p> 166 * @param id the new id for the {@link LinearGradient}. 167 <p> 168 * This constructor is deprecated. The new libsbml API only has 169 * constructors which take the SBML level and version or one that takes 170 * an {@link SBMLNamespaces} object. 171 */ public 172 LinearGradient(RenderPkgNamespaces renderns, String id) throws org.sbml.libsbml.SBMLConstructorException { 173 this(libsbmlJNI.new_LinearGradient__SWIG_7(RenderPkgNamespaces.getCPtr(renderns), renderns, id), true); 174 } 175 176 177/** 178 * Sets the 3D coordinates for the start and the end point of the linear gradient vector. 179 * Each value can be a combination of absolute and relative value and is represented by 180 * a {@link RelAbsVector} object. 181 <p> 182 * @param x1 x value of the start point of the linear gradient vector 183 * @param y1 y value of the start point of the linear gradient vector 184 * @param z1 z value of the start point of the linear gradient vector 185 * @param x2 x value of the end point of the linear gradient vector 186 * @param y2 y value of the end point of the linear gradient vector 187 * @param z2 z value of the end point of the linear gradient vector 188 */ public 189 void setCoordinates(RelAbsVector x1, RelAbsVector y1, RelAbsVector z1, RelAbsVector x2, RelAbsVector y2, RelAbsVector z2) { 190 libsbmlJNI.LinearGradient_setCoordinates__SWIG_0(swigCPtr, this, RelAbsVector.getCPtr(x1), x1, RelAbsVector.getCPtr(y1), y1, RelAbsVector.getCPtr(z1), z1, RelAbsVector.getCPtr(x2), x2, RelAbsVector.getCPtr(y2), y2, RelAbsVector.getCPtr(z2), z2); 191 } 192 193 194/** 195 * Sets the 2D coordinates for the start and the end point of the linear gradient vector. 196 * The z values are automatically set to 0. 197 * Each value can be a combination of absolute and relative value and is represented by 198 * a {@link RelAbsVector} object. 199 <p> 200 * @param x1 x value of the start point of the linear gradient vector 201 * @param y1 y value of the start point of the linear gradient vector 202 * @param x2 x value of the end point of the linear gradient vector 203 * @param y2 y value of the end point of the linear gradient vector 204 */ public 205 void setCoordinates(RelAbsVector x1, RelAbsVector y1, RelAbsVector x2, RelAbsVector y2) { 206 libsbmlJNI.LinearGradient_setCoordinates__SWIG_1(swigCPtr, this, RelAbsVector.getCPtr(x1), x1, RelAbsVector.getCPtr(y1), y1, RelAbsVector.getCPtr(x2), x2, RelAbsVector.getCPtr(y2), y2); 207 } 208 209 210/** 211 * Sets the coordinates for the start point of the linear gradient vector. 212 <p> 213 * Each value can be a combination of absolute and relative value and is represented by 214 * a {@link RelAbsVector} object. 215 <p> 216 * The z value can be omitted. In that case it is set to 0. 217 <p> 218 * @param x x value of the start point of the linear gradient vector 219 * @param y y value of the start point of the linear gradient vector 220 * @param z z value of the start point of the linear gradient vector 221 */ public 222 void setPoint1(RelAbsVector x, RelAbsVector y, RelAbsVector z) { 223 libsbmlJNI.LinearGradient_setPoint1__SWIG_0(swigCPtr, this, RelAbsVector.getCPtr(x), x, RelAbsVector.getCPtr(y), y, RelAbsVector.getCPtr(z), z); 224 } 225 226 227/** 228 * Sets the coordinates for the start point of the linear gradient vector. 229 <p> 230 * Each value can be a combination of absolute and relative value and is represented by 231 * a {@link RelAbsVector} object. 232 <p> 233 * The z value can be omitted. In that case it is set to 0. 234 <p> 235 * @param x x value of the start point of the linear gradient vector 236 * @param y y value of the start point of the linear gradient vector 237 * @param z z value of the start point of the linear gradient vector 238 */ public 239 void setPoint1(RelAbsVector x, RelAbsVector y) { 240 libsbmlJNI.LinearGradient_setPoint1__SWIG_1(swigCPtr, this, RelAbsVector.getCPtr(x), x, RelAbsVector.getCPtr(y), y); 241 } 242 243 244/** 245 * Sets the coordinates for the end point of the linear gradient vector. 246 <p> 247 * Each value can be a combination of absolute and relative value and is represented by 248 * a {@link RelAbsVector} object. 249 <p> 250 * The z value can be omitted. In that case it is set to 0. 251 <p> 252 * @param x x value of the end point of the linear gradient vector 253 * @param y y value of the end point of the linear gradient vector 254 * @param z z value of the end point of the linear gradient vector 255 */ public 256 void setPoint2(RelAbsVector x, RelAbsVector y, RelAbsVector z) { 257 libsbmlJNI.LinearGradient_setPoint2__SWIG_0(swigCPtr, this, RelAbsVector.getCPtr(x), x, RelAbsVector.getCPtr(y), y, RelAbsVector.getCPtr(z), z); 258 } 259 260 261/** 262 * Sets the coordinates for the end point of the linear gradient vector. 263 <p> 264 * Each value can be a combination of absolute and relative value and is represented by 265 * a {@link RelAbsVector} object. 266 <p> 267 * The z value can be omitted. In that case it is set to 0. 268 <p> 269 * @param x x value of the end point of the linear gradient vector 270 * @param y y value of the end point of the linear gradient vector 271 * @param z z value of the end point of the linear gradient vector 272 */ public 273 void setPoint2(RelAbsVector x, RelAbsVector y) { 274 libsbmlJNI.LinearGradient_setPoint2__SWIG_1(swigCPtr, this, RelAbsVector.getCPtr(x), x, RelAbsVector.getCPtr(y), y); 275 } 276 277 278/** 279 * Returns the x coordinate for the start point as a reference. 280 <p> 281 * @return {@link RelAbsVector} that represents the x value of the start point. 282 */ public 283 RelAbsVector getXPoint1() { 284 return new RelAbsVector(libsbmlJNI.LinearGradient_getXPoint1__SWIG_0(swigCPtr, this), false); 285 } 286 287 288/** 289 * Returns the y coordinate for the start point as a reference. 290 <p> 291 * @return {@link RelAbsVector} that represents the y value of the start point. 292 */ public 293 RelAbsVector getYPoint1() { 294 return new RelAbsVector(libsbmlJNI.LinearGradient_getYPoint1__SWIG_0(swigCPtr, this), false); 295 } 296 297 298/** 299 * Returns the z coordinate for the start point as a reference. 300 <p> 301 * @return {@link RelAbsVector} that represents the z value of the start point. 302 */ public 303 RelAbsVector getZPoint1() { 304 return new RelAbsVector(libsbmlJNI.LinearGradient_getZPoint1__SWIG_0(swigCPtr, this), false); 305 } 306 307 308/** 309 * Returns the x coordinate for the end point as a reference. 310 <p> 311 * @return {@link RelAbsVector} that represents the x value of the start point. 312 */ public 313 RelAbsVector getXPoint2() { 314 return new RelAbsVector(libsbmlJNI.LinearGradient_getXPoint2__SWIG_0(swigCPtr, this), false); 315 } 316 317 318/** 319 * Returns the y coordinate for the end point as a reference. 320 <p> 321 * @return {@link RelAbsVector} that represents the y value of the start point. 322 */ public 323 RelAbsVector getYPoint2() { 324 return new RelAbsVector(libsbmlJNI.LinearGradient_getYPoint2__SWIG_0(swigCPtr, this), false); 325 } 326 327 328/** 329 * Returns the z coordinate for the end point as a reference. 330 <p> 331 * @return {@link RelAbsVector} that represents the z value of the start point. 332 */ public 333 RelAbsVector getZPoint2() { 334 return new RelAbsVector(libsbmlJNI.LinearGradient_getZPoint2__SWIG_0(swigCPtr, this), false); 335 } 336 337 338/** 339 * Creates and returns a deep copy of this {@link LinearGradient} object. 340 <p> 341 * @return a (deep) copy of this {@link LinearGradient} object 342 */ public 343 LinearGradient cloneObject() { 344 long cPtr = libsbmlJNI.LinearGradient_cloneObject(swigCPtr, this); 345 return (cPtr == 0) ? null : new LinearGradient(cPtr, true); 346 } 347 348 349/** 350 * Returns the XML element name of this object. 351 <p> 352 * This is overridden by subclasses to return a string appropriate to the 353 * SBML component. For example, {@link Model} defines it as returning 'model', 354 * {@link CompartmentType} defines it as returning 'compartmentType', etc. 355 */ public 356 String getElementName() { 357 return libsbmlJNI.LinearGradient_getElementName(swigCPtr, this); 358 } 359 360 361/** 362 * Returns the libSBML type code for this SBML object. 363 <p> 364 * LibSBML attaches an 365 * identifying code to every kind of SBML object. These are known as 366 * <em>SBML type codes</em>. In other languages, the set of type codes 367 * is stored in an enumeration; in the Java language interface for 368 * libSBML, the type codes are defined as static integer constants in 369 * interface class {@link libsbmlConstants}. The names of the type codes 370 * all begin with the characters <code>SBML_.</code> 371 <p> 372 * @return the SBML type code for this object, or <code>SBML_UNKNOWN</code> (default). 373 <p> 374 * @see #getElementName() 375 */ public 376 int getTypeCode() { 377 return libsbmlJNI.LinearGradient_getTypeCode(swigCPtr, this); 378 } 379 380 381/** 382 * Creates an {@link XMLNode} object from this {@link LinearGradient} object. 383 <p> 384 * @return the {@link XMLNode} with the XML representation for the 385 * {@link LinearGradient} object. 386 */ public 387 XMLNode toXML() { 388 return new XMLNode(libsbmlJNI.LinearGradient_toXML(swigCPtr, this), true); 389 } 390 391}