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 * 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 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/** * @internal */ public
221 String getId() {
222    return libsbmlJNI.GradientBase_getId(swigCPtr, this);
223  }
224
225  
226/** * @internal */ public
227 boolean isSetId() {
228    return libsbmlJNI.GradientBase_isSetId(swigCPtr, this);
229  }
230
231  
232/** * @internal */ public
233 int setId(String id) {
234    return libsbmlJNI.GradientBase_setId(swigCPtr, this, id);
235  }
236
237  
238/**
239   * Unsets the value of the 'id' attribute of this SBML object.
240   <p>
241   * Most (but not all) objects in SBML include two common attributes: 'id'
242   * and 'name'.  The identifier given by an object's 'id' attribute value
243   * is used to identify the object within the SBML model definition.
244   * Other objects can refer to the component using this identifier.
245   <p>
246   * <p>
247 * @return integer value indicating success/failure of the
248 * function.   The possible values
249 * returned by this function are:
250   * <ul>
251   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
252   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED}
253   * </ul>
254   */ public
255 int unsetId() {
256    return libsbmlJNI.GradientBase_unsetId(swigCPtr, this);
257  }
258
259  
260/** * @internal */ public
261 boolean hasRequiredAttributes() {
262    return libsbmlJNI.GradientBase_hasRequiredAttributes(swigCPtr, this);
263  }
264
265  
266/** * @internal */ public
267 boolean hasRequiredElements() {
268    return libsbmlJNI.GradientBase_hasRequiredElements(swigCPtr, this);
269  }
270
271  // SPREADMETHOD 
272  public final static int PAD = 0;
273  public final static int REFLECT = PAD + 1;
274  public final static int REPEAT = REFLECT + 1;
275
276}