001/* ----------------------------------------------------------------------------
002 * This file was automatically generated by SWIG (http://www.swig.org).
003 * Version 3.0.10
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 * abstract base class for linear and radial gradients
013 <p>
014 * The base class implements common structures to both gradient classes.
015 * Both gradients have an id attribute which is used to reference a gradient
016 * within other render extension constructs. The id of a gradient can be used
017 * to define the fill style of 2D objects like e.g. rectangles.
018 <p>
019 * Further both gradient classes have a ListOfGradientStop objects which holds
020 * the {@link GradientStop} objects that define the gradient and bothe classes have an 
021 * attribute called spreadMethod which defines how a gradient is applied to an
022 * object.
023 */
024
025public class GradientBase extends SBase {
026   private long swigCPtr;
027
028   protected GradientBase(long cPtr, boolean cMemoryOwn)
029   {
030     super(libsbmlJNI.GradientBase_SWIGUpcast(cPtr), cMemoryOwn);
031     swigCPtr = cPtr;
032   }
033
034   protected static long getCPtr(GradientBase obj)
035   {
036     return (obj == null) ? 0 : obj.swigCPtr;
037   }
038
039   protected static long getCPtrAndDisown (GradientBase obj)
040   {
041     long ptr = 0;
042
043     if (obj != null)
044     {
045       ptr             = obj.swigCPtr;
046       obj.swigCMemOwn = false;
047     }
048
049     return ptr;
050   }
051
052  protected void finalize() {
053    delete();
054  }
055
056  public synchronized void delete() {
057    if (swigCPtr != 0) {
058      if (swigCMemOwn) {
059        swigCMemOwn = false;
060        libsbmlJNI.delete_GradientBase(swigCPtr);
061      }
062      swigCPtr = 0;
063    }
064    super.delete();
065  }
066
067  
068/**
069   * Returns the spreadmethod of the gradient.
070   * Valid values are GradientBase.PAD, GradientBase.REFLECT
071   * and GradientBase.REPEAT.
072   <p>
073   * @return the spread method for the gradient object.
074   */ public
075 int getSpreadMethod() {
076    return libsbmlJNI.GradientBase_getSpreadMethod(swigCPtr, this);
077  }
078
079  
080/**
081   * Sets the spread method.
082   * Valid values are GradientBase.PAD, GradientBase.REFLECT
083   * and GradientBase.REPEAT.
084   <p>
085   * @param method The new spread method for the gradient.
086   */ public
087 void setSpreadMethod(int method) {
088    libsbmlJNI.GradientBase_setSpreadMethod(swigCPtr, this, method);
089  }
090
091  
092/**
093   * Returns the number of gradient stops.
094   * A valid gradient needs at least two gradient stops
095   <p>
096   * @return the number of gradient stops in the gradient.
097   */ public
098 long getNumGradientStops() {
099    return libsbmlJNI.GradientBase_getNumGradientStops(swigCPtr, this);
100  }
101
102  
103/**
104   * Returns a pointer to the gradient stop vector.
105   <p>
106   * @return a pointer to the {@link ListOfGradientStops} object
107   * for the gradient.
108   */ public
109 ListOfGradientStops getListOfGradientStops() {
110    long cPtr = libsbmlJNI.GradientBase_getListOfGradientStops__SWIG_0(swigCPtr, this);
111    return (cPtr == 0) ? null : new ListOfGradientStops(cPtr, false);
112  }
113
114  
115/**
116   * Returns a pointer to the gradient stop with the given index or null
117   * if the index is invalid.
118   <p>
119   * @param i index of the gradient stop to be returned. The index has to be between 0 and
120   * getNumGradientStops() - 1.
121   <p>
122   * @return a pointer to the gradient stop with the given index
123   * or null if the index was out of bounds.
124   */ public
125 GradientStop getGradientStop(long i) {
126    long cPtr = libsbmlJNI.GradientBase_getGradientStop__SWIG_0(swigCPtr, this, i);
127    return (cPtr == 0) ? null : new GradientStop(cPtr, false);
128  }
129
130  
131/**
132   * Creates a new {@link GradientStop}. The new {@link GradientStop} object is automatically
133   * added to the gradient and the gradient own the object-
134   <p>
135   * @return a pointer to the newly created {@link GradientStop}.
136   */ public
137 GradientStop createGradientStop() {
138    long cPtr = libsbmlJNI.GradientBase_createGradientStop(swigCPtr, this);
139    return (cPtr == 0) ? null : new GradientStop(cPtr, false);
140  }
141
142  
143/**
144   * Adds a copy of the given {@link GradientStop} object to the end
145   * of the list of gradient stops.
146   <p>
147   * @param pStop a  pointer to the new gradient stop 
148   <p>
149   * @return integer value indicating success/failure of the
150   * function.   The possible values
151   * returned by this function are:
152   * <ul>
153   * <li> LIBSBML_OPERATION_SUCCESS
154   * <li> LIBSBML_LEVEL_MISMATCH
155   * <li> LIBSBML_VERSION_MISMATCH
156   * <li> LIBSBML_OPERATION_FAILED
157   *
158   * </ul> <p>
159   * @note This method should be used with some caution.  The fact that
160   * this method <em>copies</em> the object passed to it means that the caller
161   * will be left holding a physically different object instance than the
162   * one contained in this {@link GradientBase}.  Changes made to the original object
163   * instance (such as resetting attribute values) will <em>not affect the
164   * instance in the {@link GradientBase}</em>.  In addition, the caller should make
165   * sure to free the original object if it is no longer being used, or
166   * else a memory leak will result.  Please see {@link GradientBase#createGradientStop()}
167   * for a method that does not lead to these issues.
168   <p>
169   * @see #createGradientStop()
170   */ public
171 int addGradientStop(GradientStop pStop) {
172    return libsbmlJNI.GradientBase_addGradientStop(swigCPtr, this, GradientStop.getCPtr(pStop), pStop);
173  }
174
175  
176/**
177   * Creates and returns a deep copy of this {@link SBase} object.
178   <p>
179   * @return the (deep) copy of this {@link SBase} object.
180   */ public
181 SBase cloneObject() {
182  return (GradientBase) libsbml.DowncastSBase(libsbmlJNI.GradientBase_cloneObject(swigCPtr, this), true);
183}
184
185  
186/**
187   * Returns the XML element name of this object.
188   <p>
189   * This is overridden by subclasses to return a string appropriate to the
190   * SBML component.  For example, {@link Model} defines it as returning 
191   * <code>'model'</code>, {@link CompartmentType} defines it as returning <code>'compartmentType'</code>,
192   * and so on.
193   */ public
194 String getElementName() {
195    return libsbmlJNI.GradientBase_getElementName(swigCPtr, this);
196  }
197
198  
199/**
200   * Creates an {@link Text} object from this {@link Group} object.
201   <p>
202   * @return the {@link XMLNode} with the XML representation for the 
203   * {@link Text} object.
204   */ public
205 XMLNode toXML() {
206    return new XMLNode(libsbmlJNI.GradientBase_toXML(swigCPtr, this), true);
207  }
208
209  public void connectToChild() {
210    libsbmlJNI.GradientBase_connectToChild(swigCPtr, this);
211  }
212
213  
214/** * @internal */ public
215 void enablePackageInternal(String pkgURI, String pkgPrefix, boolean flag) {
216    libsbmlJNI.GradientBase_enablePackageInternal(swigCPtr, this, pkgURI, pkgPrefix, flag);
217  }
218
219  
220/**
221   * Returns the value of the 'id' attribute of this SBML object, if it has one, 
222   * or the 'variable' attribute of a {@link Rule}, or the 'symbol' attribute of
223   * an {@link InitialAssignment}.
224   <p>
225   * @note Because of the inconsistent behavior of this function with 
226   * respect to assignments and rules, it is now recommended to
227   * use the getIdAttribute() function instead.
228   <p>
229   * <p>
230 * The identifier given by an object's 'id' attribute value
231 * is used to identify the object within the SBML model definition.
232 * Other objects can refer to the component using this identifier.  The
233 * data type of 'id' is always <code>SId</code> or a type derived
234 * from that, such as <code>UnitSId</code>, depending on the object in 
235 * question.  All data types are defined as follows:
236 * <pre style='margin-left: 2em; border: none; font-weight: bold; color: black'>
237 *   letter .= 'a'..'z','A'..'Z'
238 *   digit  .= '0'..'9'
239 *   idChar .= letter | digit | '_'
240 *   SId    .= ( letter | '_' ) idChar*
241 * </pre>
242 <p>
243 * The characters <code>(</code> and <code>)</code> are used for grouping, the
244 * character <code>*</code> 'zero or more times', and the character
245 * <code>|</code> indicates logical 'or'.  The equality of SBML identifiers is
246 * determined by an exact character sequence match; i.e., comparisons must be
247 * performed in a case-sensitive manner.  This applies to all uses of <code>SId</code>, 
248 * <code>SIdRef</code>, and derived types.
249 <p>
250 * In SBML Level&nbsp;3 Version&nbsp;2, the 'id' and 'name' attributes were
251 * moved to {@link SBase} directly, instead of being defined individually for many
252 * (but not all) objects.  Libsbml has for a long time provided functions
253 * defined on {@link SBase} itself to get, set, check, and unset those attributes, which 
254 * would fail or otherwise return empty strings if executed on any object 
255 * for which those attributes were not defined.  Now that all {@link SBase} objects 
256 * define those attributes, those functions now succeed for any object with 
257 * the appropriate level and version.
258 <p>
259 * The exception to this rule is that for {@link InitialAssignment}, {@link EventAssignment}, 
260 * {@link AssignmentRule}, and {@link RateRule} objects, the getId() function and the isSetId() 
261 * functions (though not the setId() or unsetId() functions) would instead 
262 * reference the value of the 'variable' attribute (for the rules and event 
263 * assignments) or the 'symbol' attribute (for initial assignments).  
264 * The {@link AlgebraicRule} fell into this category as well, though because it 
265 * contained neither a 'variable' nor a 'symbol' attribute, getId() would 
266 * always return an empty string, and isSetId() would always return <code>false.</code>
267 * For this reason, four new functions are now provided 
268 * (getIdAttribute(), setIdAttribute(String), 
269 * isSetIdAttribute(), and unsetIdAttribute()) that will always
270 * act on the actual 'id' attribute, regardless of the object's type.  The
271 * new functions should be used instead of the old ones unless the old behavior
272 * is somehow necessary.
273 <p>
274 * Regardless of the level and version of the SBML, these functions allow
275 * client applications to use more generalized code in some situations 
276 * (for instance, when manipulating objects that are all known to have 
277 * identifiers).  If the object in question does not posess an 'id' attribute 
278 * according to the SBML specification for the Level and Version in use,
279 * libSBML will not allow the identifier to be set, nor will it read or 
280 * write 'id' attributes for those objects.
281   <p>
282   * @return the id of this SBML object, or the 'variable' if the object 
283   * is a {@link Rule}, or the 'symbol' if the object is an {@link InitialAssignment}.
284   <p>
285   * @see #getIdAttribute()
286   * @see #setIdAttribute(String sid)
287   * @see #isSetIdAttribute()
288   * @see #unsetIdAttribute()
289   */ public
290 String getId() {
291    return libsbmlJNI.GradientBase_getId(swigCPtr, this);
292  }
293
294  
295/**
296   * Predicate returning <code>true</code> if a call to getId() returns a 
297   * non-empty string.  This means that for most objects, this 
298   * function will return <code>true</code> if its 'id' attribute is set, and
299   * <code>false</code> if it is not, or if the object has no 'id' attribute
300   * at all.  However, for an {@link EventAssignment} or a {@link Rule}, isSetId() 
301   * checks whether the 'variable' attribute is set, and for an
302   * {@link InitialAssignment}, it checks whether the 'symbol' attribute
303   * is set.  Because those elements will also have an 'id'
304   * attribute in SBML Level&nbsp;3 Version&nbsp;2 which isSetId()
305   * will not check, the function itself is deprecated, and it
306   * is recommended to use isSetIdAttribute() in all cases where
307   * one needs to know whether the 'id' attribute is set, and
308   * to use {@link EventAssignment#isSetVariable()}, {@link Rule#isSetVariable()}
309   * and {@link InitialAssignment#isSetSymbol()} when the status of the
310   * 'variable' or 'symbol' attributes need to be checked.
311   <p>
312   * <p>
313 * @note Because of the inconsistent behavior of this function with 
314 * respect to assignments and rules, it is now recommended to
315 * use the isSetIdAttribute() function instead.
316 <p>
317 * <p>
318 * The identifier given by an object's 'id' attribute value
319 * is used to identify the object within the SBML model definition.
320 * Other objects can refer to the component using this identifier.  The
321 * data type of 'id' is always <code>SId</code> or a type derived
322 * from that, such as <code>UnitSId</code>, depending on the object in 
323 * question.  All data types are defined as follows:
324 * <pre style='margin-left: 2em; border: none; font-weight: bold; color: black'>
325 *   letter .= 'a'..'z','A'..'Z'
326 *   digit  .= '0'..'9'
327 *   idChar .= letter | digit | '_'
328 *   SId    .= ( letter | '_' ) idChar*
329 * </pre>
330 <p>
331 * The characters <code>(</code> and <code>)</code> are used for grouping, the
332 * character <code>*</code> 'zero or more times', and the character
333 * <code>|</code> indicates logical 'or'.  The equality of SBML identifiers is
334 * determined by an exact character sequence match; i.e., comparisons must be
335 * performed in a case-sensitive manner.  This applies to all uses of <code>SId</code>, 
336 * <code>SIdRef</code>, and derived types.
337 <p>
338 * In SBML Level&nbsp;3 Version&nbsp;2, the 'id' and 'name' attributes were
339 * moved to {@link SBase} directly, instead of being defined individually for many
340 * (but not all) objects.  Libsbml has for a long time provided functions
341 * defined on {@link SBase} itself to get, set, check, and unset those attributes, which 
342 * would fail or otherwise return empty strings if executed on any object 
343 * for which those attributes were not defined.  Now that all {@link SBase} objects 
344 * define those attributes, those functions now succeed for any object with 
345 * the appropriate level and version.
346 <p>
347 * The exception to this rule is that for {@link InitialAssignment}, {@link EventAssignment}, 
348 * {@link AssignmentRule}, and {@link RateRule} objects, the getId() function and the isSetId() 
349 * functions (though not the setId() or unsetId() functions) would instead 
350 * reference the value of the 'variable' attribute (for the rules and event 
351 * assignments) or the 'symbol' attribute (for initial assignments).  
352 * The {@link AlgebraicRule} fell into this category as well, though because it 
353 * contained neither a 'variable' nor a 'symbol' attribute, getId() would 
354 * always return an empty string, and isSetId() would always return <code>false.</code>
355 * For this reason, four new functions are now provided 
356 * (getIdAttribute(), setIdAttribute(String), 
357 * isSetIdAttribute(), and unsetIdAttribute()) that will always
358 * act on the actual 'id' attribute, regardless of the object's type.  The
359 * new functions should be used instead of the old ones unless the old behavior
360 * is somehow necessary.
361 <p>
362 * Regardless of the level and version of the SBML, these functions allow
363 * client applications to use more generalized code in some situations 
364 * (for instance, when manipulating objects that are all known to have 
365 * identifiers).  If the object in question does not posess an 'id' attribute 
366 * according to the SBML specification for the Level and Version in use,
367 * libSBML will not allow the identifier to be set, nor will it read or 
368 * write 'id' attributes for those objects.
369 <p>
370 * @return <code>true</code> if the 'id' attribute of this SBML object is
371 * set, <code>false</code> otherwise.
372 <p>
373 * @see #getIdAttribute()
374 * @see #setIdAttribute(String sid)
375 * @see #unsetIdAttribute()
376 * @see #isSetIdAttribute()
377   */ public
378 boolean isSetId() {
379    return libsbmlJNI.GradientBase_isSetId(swigCPtr, this);
380  }
381
382  
383/**
384   * Sets the value of the 'id' attribute of this SBML object.
385   <p>
386   * <p>
387 * The string <code>sid</code> is copied.
388 <p>
389 * <p>
390 * The identifier given by an object's 'id' attribute value
391 * is used to identify the object within the SBML model definition.
392 * Other objects can refer to the component using this identifier.  The
393 * data type of 'id' is always <code>SId</code> or a type derived
394 * from that, such as <code>UnitSId</code>, depending on the object in 
395 * question.  All data types are defined as follows:
396 * <pre style='margin-left: 2em; border: none; font-weight: bold; color: black'>
397 *   letter .= 'a'..'z','A'..'Z'
398 *   digit  .= '0'..'9'
399 *   idChar .= letter | digit | '_'
400 *   SId    .= ( letter | '_' ) idChar*
401 * </pre>
402 <p>
403 * The characters <code>(</code> and <code>)</code> are used for grouping, the
404 * character <code>*</code> 'zero or more times', and the character
405 * <code>|</code> indicates logical 'or'.  The equality of SBML identifiers is
406 * determined by an exact character sequence match; i.e., comparisons must be
407 * performed in a case-sensitive manner.  This applies to all uses of <code>SId</code>, 
408 * <code>SIdRef</code>, and derived types.
409 <p>
410 * In SBML Level&nbsp;3 Version&nbsp;2, the 'id' and 'name' attributes were
411 * moved to {@link SBase} directly, instead of being defined individually for many
412 * (but not all) objects.  Libsbml has for a long time provided functions
413 * defined on {@link SBase} itself to get, set, check, and unset those attributes, which 
414 * would fail or otherwise return empty strings if executed on any object 
415 * for which those attributes were not defined.  Now that all {@link SBase} objects 
416 * define those attributes, those functions now succeed for any object with 
417 * the appropriate level and version.
418 <p>
419 * The exception to this rule is that for {@link InitialAssignment}, {@link EventAssignment}, 
420 * {@link AssignmentRule}, and {@link RateRule} objects, the getId() function and the isSetId() 
421 * functions (though not the setId() or unsetId() functions) would instead 
422 * reference the value of the 'variable' attribute (for the rules and event 
423 * assignments) or the 'symbol' attribute (for initial assignments).  
424 * The {@link AlgebraicRule} fell into this category as well, though because it 
425 * contained neither a 'variable' nor a 'symbol' attribute, getId() would 
426 * always return an empty string, and isSetId() would always return <code>false.</code>
427 * For this reason, four new functions are now provided 
428 * (getIdAttribute(), setIdAttribute(String), 
429 * isSetIdAttribute(), and unsetIdAttribute()) that will always
430 * act on the actual 'id' attribute, regardless of the object's type.  The
431 * new functions should be used instead of the old ones unless the old behavior
432 * is somehow necessary.
433 <p>
434 * Regardless of the level and version of the SBML, these functions allow
435 * client applications to use more generalized code in some situations 
436 * (for instance, when manipulating objects that are all known to have 
437 * identifiers).  If the object in question does not posess an 'id' attribute 
438 * according to the SBML specification for the Level and Version in use,
439 * libSBML will not allow the identifier to be set, nor will it read or 
440 * write 'id' attributes for those objects.
441 <p>
442 * @param sid the string to use as the identifier of this object.
443 <p>
444 * <p>
445 * @return integer value indicating success/failure of the
446 * function.   The possible values
447 * returned by this function are:
448 * <ul>
449 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
450 * <li> {@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE}
451 * <li> {@link libsbmlConstants#LIBSBML_UNEXPECTED_ATTRIBUTE LIBSBML_UNEXPECTED_ATTRIBUTE}
452 *
453 * </ul> <p>
454 * @see #getIdAttribute()
455 * @see #setIdAttribute(String sid)
456 * @see #isSetIdAttribute()
457 * @see #unsetIdAttribute()
458   */ public
459 int setId(String id) {
460    return libsbmlJNI.GradientBase_setId(swigCPtr, this, id);
461  }
462
463  
464/**
465   * Unsets the value of the 'id' attribute of this SBML object.
466   <p>
467   * <p>
468 * <p>
469 * The identifier given by an object's 'id' attribute value
470 * is used to identify the object within the SBML model definition.
471 * Other objects can refer to the component using this identifier.  The
472 * data type of 'id' is always <code>SId</code> or a type derived
473 * from that, such as <code>UnitSId</code>, depending on the object in 
474 * question.  All data types are defined as follows:
475 * <pre style='margin-left: 2em; border: none; font-weight: bold; color: black'>
476 *   letter .= 'a'..'z','A'..'Z'
477 *   digit  .= '0'..'9'
478 *   idChar .= letter | digit | '_'
479 *   SId    .= ( letter | '_' ) idChar*
480 * </pre>
481 <p>
482 * The characters <code>(</code> and <code>)</code> are used for grouping, the
483 * character <code>*</code> 'zero or more times', and the character
484 * <code>|</code> indicates logical 'or'.  The equality of SBML identifiers is
485 * determined by an exact character sequence match; i.e., comparisons must be
486 * performed in a case-sensitive manner.  This applies to all uses of <code>SId</code>, 
487 * <code>SIdRef</code>, and derived types.
488 <p>
489 * In SBML Level&nbsp;3 Version&nbsp;2, the 'id' and 'name' attributes were
490 * moved to {@link SBase} directly, instead of being defined individually for many
491 * (but not all) objects.  Libsbml has for a long time provided functions
492 * defined on {@link SBase} itself to get, set, check, and unset those attributes, which 
493 * would fail or otherwise return empty strings if executed on any object 
494 * for which those attributes were not defined.  Now that all {@link SBase} objects 
495 * define those attributes, those functions now succeed for any object with 
496 * the appropriate level and version.
497 <p>
498 * The exception to this rule is that for {@link InitialAssignment}, {@link EventAssignment}, 
499 * {@link AssignmentRule}, and {@link RateRule} objects, the getId() function and the isSetId() 
500 * functions (though not the setId() or unsetId() functions) would instead 
501 * reference the value of the 'variable' attribute (for the rules and event 
502 * assignments) or the 'symbol' attribute (for initial assignments).  
503 * The {@link AlgebraicRule} fell into this category as well, though because it 
504 * contained neither a 'variable' nor a 'symbol' attribute, getId() would 
505 * always return an empty string, and isSetId() would always return <code>false.</code>
506 * For this reason, four new functions are now provided 
507 * (getIdAttribute(), setIdAttribute(String), 
508 * isSetIdAttribute(), and unsetIdAttribute()) that will always
509 * act on the actual 'id' attribute, regardless of the object's type.  The
510 * new functions should be used instead of the old ones unless the old behavior
511 * is somehow necessary.
512 <p>
513 * Regardless of the level and version of the SBML, these functions allow
514 * client applications to use more generalized code in some situations 
515 * (for instance, when manipulating objects that are all known to have 
516 * identifiers).  If the object in question does not posess an 'id' attribute 
517 * according to the SBML specification for the Level and Version in use,
518 * libSBML will not allow the identifier to be set, nor will it read or 
519 * write 'id' attributes for those objects.
520 <p>
521 * <p>
522 * @return integer value indicating success/failure of the
523 * function.   The possible values
524 * returned by this function are:
525 * <ul>
526 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
527 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED}
528 *
529 * </ul> <p>
530 * @see #getIdAttribute()
531 * @see #setIdAttribute(String sid)
532 * @see #isSetIdAttribute()
533 * @see #unsetIdAttribute()
534   */ public
535 int unsetId() {
536    return libsbmlJNI.GradientBase_unsetId(swigCPtr, this);
537  }
538
539  
540/** * @internal */ public
541 boolean hasRequiredAttributes() {
542    return libsbmlJNI.GradientBase_hasRequiredAttributes(swigCPtr, this);
543  }
544
545  
546/** * @internal */ public
547 boolean hasRequiredElements() {
548    return libsbmlJNI.GradientBase_hasRequiredElements(swigCPtr, this);
549  }
550
551  // SPREADMETHOD 
552  public final static int PAD = 0;
553  public final static int REFLECT = PAD + 1;
554  public final static int REPEAT = REFLECT + 1;
555
556}