001/* ----------------------------------------------------------------------------
002 * This file was automatically generated by SWIG (http://www.swig.org).
003 * Version 2.0.12
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 * implementation of the {@link Curve} concept from the SBML render extension
013 <p>
014 * The curve concept in the SBML render extension is similar to the curves in the SBML layout.
015 * Each curve consists of a number of either straight line segments or cubic bezier elements.
016 * The two element types can also by mixed in a single curve object.
017 <p>
018 * In contrast to layout curves, render curves can not have gaps and the individual coordinates of the 
019 * curve elements can be specified as a combination of absolute and relative values.
020 <p>
021 * Another difference to layout curves is the fact that render curves can specify decorations to be applied
022 * to the start and/or the end of the curve (@see LineEnding).
023 <p>
024 * Since {@link RenderCurve} is derived from {@link GraphicalPrimitive1D}, it inherits all its attributes and methods. 
025 */
026
027public class RenderCurve extends GraphicalPrimitive1D {
028   private long swigCPtr;
029
030   protected RenderCurve(long cPtr, boolean cMemoryOwn)
031   {
032     super(libsbmlJNI.RenderCurve_SWIGUpcast(cPtr), cMemoryOwn);
033     swigCPtr = cPtr;
034   }
035
036   protected static long getCPtr(RenderCurve obj)
037   {
038     return (obj == null) ? 0 : obj.swigCPtr;
039   }
040
041   protected static long getCPtrAndDisown (RenderCurve 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_RenderCurve(swigCPtr);
063      }
064      swigCPtr = 0;
065    }
066    super.delete();
067  }
068
069  
070/**
071   * Creates a new {@link RenderCurve} 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 RenderCurve(long level, long version, long pkgVersion) throws org.sbml.libsbml.SBMLConstructorException {
078    this(libsbmlJNI.new_RenderCurve__SWIG_0(level, version, pkgVersion), true);
079  }
080
081  
082/**
083   * Creates a new {@link RenderCurve} 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 RenderCurve(long level, long version) throws org.sbml.libsbml.SBMLConstructorException {
090    this(libsbmlJNI.new_RenderCurve__SWIG_1(level, version), true);
091  }
092
093  
094/**
095   * Creates a new {@link RenderCurve} 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 RenderCurve(long level) throws org.sbml.libsbml.SBMLConstructorException {
102    this(libsbmlJNI.new_RenderCurve__SWIG_2(level), true);
103  }
104
105  
106/**
107   * Creates a new {@link RenderCurve} 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 RenderCurve() throws org.sbml.libsbml.SBMLConstructorException {
114    this(libsbmlJNI.new_RenderCurve__SWIG_3(), true);
115  }
116
117  
118/**
119   * Creates a new {@link RenderCurve} object with the given {@link SBMLNamespaces}.
120   <p>
121   * @param sbmlns The SBML namespace for the object.
122   */ public
123 RenderCurve(RenderPkgNamespaces renderns) throws org.sbml.libsbml.SBMLConstructorException {
124    this(libsbmlJNI.new_RenderCurve__SWIG_4(RenderPkgNamespaces.getCPtr(renderns), renderns), true);
125  }
126
127  
128/**
129   * Creates a new {@link RenderCurve} object from the given {@link XMLNode} object.
130   * The {@link XMLNode} object has to contain a valid XML representation of a 
131   * {@link RenderCurve} 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 explicitely.
134   <p>
135   * @param node the {@link XMLNode} object reference that describes the {@link RenderCurve}
136   * object to be instantiated.
137   */ public
138 RenderCurve(XMLNode node, long l2version) throws org.sbml.libsbml.SBMLConstructorException {
139    this(libsbmlJNI.new_RenderCurve__SWIG_5(XMLNode.getCPtr(node), node, l2version), true);
140  }
141
142  
143/**
144   * Creates a new {@link RenderCurve} object from the given {@link XMLNode} object.
145   * The {@link XMLNode} object has to contain a valid XML representation of a 
146   * {@link RenderCurve} 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 explicitely.
149   <p>
150   * @param node the {@link XMLNode} object reference that describes the {@link RenderCurve}
151   * object to be instantiated.
152   */ public
153 RenderCurve(XMLNode node) throws org.sbml.libsbml.SBMLConstructorException {
154    this(libsbmlJNI.new_RenderCurve__SWIG_6(XMLNode.getCPtr(node), node), true);
155  }
156
157  
158/**
159   * Instantiates an empty curve object with the given <code>id</code>.
160   * The decorations  are unset and there are no curve elements.
161   <p>
162   * This constructor is deprecated. The new libsbml API only has
163   * constructors which take the SBML level and version or one that takes
164   * an {@link SBMLNamespaces} object.
165   */ public
166 RenderCurve(RenderPkgNamespaces renderns, String id) throws org.sbml.libsbml.SBMLConstructorException {
167    this(libsbmlJNI.new_RenderCurve__SWIG_7(RenderPkgNamespaces.getCPtr(renderns), renderns, id), true);
168  }
169
170  
171/**
172   * Sets the id of the start head.
173   <p>
174   * @param The id of a {@link LineEnding} object to be applied to the start of the curve.
175   */ public
176 void setStartHead(String startHead) {
177    libsbmlJNI.RenderCurve_setStartHead(swigCPtr, this, startHead);
178  }
179
180  
181/**
182   * Sets the id of the end head.
183   <p>
184   * @param The id of a {@link LineEnding} object to be applied to the end of the curve.
185   */ public
186 void setEndHead(String endHead) {
187    libsbmlJNI.RenderCurve_setEndHead(swigCPtr, this, endHead);
188  }
189
190  
191/**
192   * Returns the id of the {@link LineEnding} object to be applied to the start of the curve.
193   <p>
194   * @return id of the {@link LineEnding} for the start of the curve.
195   */ public
196 String getStartHead() {
197    return libsbmlJNI.RenderCurve_getStartHead(swigCPtr, this);
198  }
199
200  
201/**
202   * Returns the id of the {@link LineEnding} object to be applied to the end of the curve.
203   <p>
204   * @return id of the {@link LineEnding} for the end of the curve.
205   */ public
206 String getEndHead() {
207    return libsbmlJNI.RenderCurve_getEndHead(swigCPtr, this);
208  }
209
210  
211/**
212   * Returns the number of curve segments.
213   <p>
214   * @return number of elements in the curve.
215   */ public
216 long getNumElements() {
217    return libsbmlJNI.RenderCurve_getNumElements(swigCPtr, this);
218  }
219
220  
221/**
222   * Creates a new bezier element.
223   * The element is added to and owned by the curve.
224   <p>
225   * @return The newly created {@link RenderCubicBezier} object.
226   */ public
227 RenderCubicBezier createCubicBezier() {
228    long cPtr = libsbmlJNI.RenderCurve_createCubicBezier(swigCPtr, this);
229    return (cPtr == 0) ? null : new RenderCubicBezier(cPtr, false);
230  }
231
232  
233/**
234   * Creates a new point element.
235   * The element is added to and owned by the curve.
236   <p>
237   * @return The newly created {@link RenderCubicBezier} object.
238   */ public
239 RenderPoint createPoint() {
240  return (RenderPoint) libsbml.DowncastSBase(libsbmlJNI.RenderCurve_createPoint(swigCPtr, this), false);
241}
242
243  
244/**
245   * Returns a const pointer to the curve segment with the given index or null if
246   * the id is invalid.
247   <p>
248   * @param index the index of the curve element to be returned
249   <p>
250   * @return a const pointer to the curve element with the given index or null 
251   * if the index was out of bounds.
252   */ public
253 RenderPoint getElement(long index) {
254  return (RenderPoint) libsbml.DowncastSBase(libsbmlJNI.RenderCurve_getElement__SWIG_0(swigCPtr, this, index), false);
255}
256
257  
258/**
259   * Returns a pointer to the curve segment with the given index or null if
260   * the id is invalid.
261   <p>
262   * This method call is deprecated, please use getElement instead.
263   <p>
264   * @param index the index of the curve element to be returned
265   <p>
266   * @return a pointer to the curve element with the given index or null 
267   * if the index was out of bounds.
268   */ public
269 RenderPoint getCurveElement(long index) {
270  return (RenderPoint) libsbml.DowncastSBase(libsbmlJNI.RenderCurve_getCurveElement__SWIG_0(swigCPtr, this, index), false);
271}
272
273  
274/**
275   * Adds a copy of the given curve segment to the end of the list of
276   * curve segments.
277   <p>
278   * @param cs pointer to the {@link RenderPoint} object to be added to the end of the curve elements list.
279   <p>
280   * @return integer value indicating success/failure of the
281   * function.   The possible values
282   * returned by this function are:
283   * <ul>
284   * <li> LIBSBML_OPERATION_SUCCESS
285   * <li> LIBSBML_LEVEL_MISMATCH
286   * <li> LIBSBML_VERSION_MISMATCH
287   * <li> LIBSBML_OPERATION_FAILED
288   *
289   * </ul> <p>
290   * @note This method should be used with some caution.  The fact that
291   * this method <em>copies</em> the object passed to it means that the caller
292   * will be left holding a physically different object instance than the
293   * one contained in this {@link RenderCurve}.  Changes made to the original object
294   * instance (such as resetting attribute values) will <em>not affect the
295   * instance in the {@link RenderCurve}</em>.  In addition, the caller should make
296   * sure to free the original object if it is no longer being used, or
297   * else a memory leak will result.  Please see {@link RenderCurve#createPoint()}
298   * or {@link RenderCurve#createCubicBezier()}
299   * for methods that do not lead to these issues.
300   <p>
301   * @see #createPoint()
302   * @see #createCubicBezier()
303   */ public
304 int addElement(RenderPoint cs) {
305    return libsbmlJNI.RenderCurve_addElement(swigCPtr, this, RenderPoint.getCPtr(cs), cs);
306  }
307
308  
309/**
310   * Removes the curve segment with the given index.
311   * If the index is valid, a pointer to the removed element is returned
312   * and the caller is responsible for deleting the object.
313   * If the index is not valid, <code>null</code> is returned.
314   <p>
315   * @param i index of element to be removed.
316   <p>
317   * @return pointer to removed element.
318   */ public
319 RenderPoint removeElement(long i) {
320  return (RenderPoint) libsbml.DowncastSBase(libsbmlJNI.RenderCurve_removeElement(swigCPtr, this, i), false);
321}
322
323  
324/**
325   * Returns a const pointer to the list of curve segments.
326   <p>
327   * @return const pointer to the {@link ListOfCurveElements} object for the {@link RenderCurve}.
328   */ public
329 ListOfCurveElements getListOfElements() {
330    long cPtr = libsbmlJNI.RenderCurve_getListOfElements__SWIG_0(swigCPtr, this);
331    return (cPtr == 0) ? null : new ListOfCurveElements(cPtr, false);
332  }
333
334  
335/**
336   * Renames all the <code>SIdRef</code> attributes on this element, including any
337   * found in MathML content (if such exists).
338   <p>
339   * This method works by looking at all attributes and (if appropriate)
340   * mathematical formulas, comparing the identifiers to the value of @p
341   * oldid.  If any matches are found, the matching identifiers are replaced
342   * with <code>newid</code>.  The method does <em>not</em> descend into child elements.
343   <p>
344   * @param oldid the old identifier
345   * @param newid the new identifier
346   */ public
347 void renameSIdRefs(String oldid, String newid) {
348    libsbmlJNI.RenderCurve_renameSIdRefs(swigCPtr, this, oldid, newid);
349  }
350
351  
352/**
353  * Creates and returns a deep copy of the {@link RenderCurve} object.
354  <p>
355  * @return a (deep) copy of this {@link RenderCurve}
356  */ public
357 RenderCurve cloneObject() {
358    long cPtr = libsbmlJNI.RenderCurve_cloneObject(swigCPtr, this);
359    return (cPtr == 0) ? null : new RenderCurve(cPtr, true);
360  }
361
362  
363/**
364  * Returns the XML element name of this object, which for
365  * {@link RenderCurve}, is always <code>'curve'.</code>
366  <p>
367  * @return the name of this element, i.e., <code>'curve'.</code>
368  */ public
369 String getElementName() {
370    return libsbmlJNI.RenderCurve_getElementName(swigCPtr, this);
371  }
372
373  
374/**
375  * Returns the libSBML type code for this SBML object.
376  <p>
377  * LibSBML attaches an
378  * identifying code to every kind of SBML object.  These are known as
379  * <em>SBML type codes</em>.  In other languages, the set of type codes
380  * is stored in an enumeration; in the Java language interface for
381  * libSBML, the type codes are defined as static integer constants in
382  * interface class {@link libsbmlConstants}.  The names of the type codes
383  * all begin with the characters <code>SBML_.</code> 
384  <p>
385  * @return the SBML type code for this object, or <code>SBML_UNKNOWN</code> (default).
386  <p>
387  * @see #getElementName()
388  */ public
389 int getTypeCode() {
390    return libsbmlJNI.RenderCurve_getTypeCode(swigCPtr, this);
391  }
392
393  
394/**
395  * Returns true if the start head is set or false otherwise.
396  * The start decoration is considered set if the string is not empty and if
397  * it is not the string 'none'
398  <p>
399  * @return true is the start decoration id is set
400  */ public
401 boolean isSetStartHead() {
402    return libsbmlJNI.RenderCurve_isSetStartHead(swigCPtr, this);
403  }
404
405  
406/**
407  * Returns true if the end head is set or false otherwise.
408  * The end decoration is considered set if the string is not empty and if
409  * it is not the string 'none'
410  <p>
411  * @return true is the end decoration id is set
412  */ public
413 boolean isSetEndHead() {
414    return libsbmlJNI.RenderCurve_isSetEndHead(swigCPtr, this);
415  }
416
417  
418/**
419  * Creates an {@link XMLNode} object from this {@link RenderCurve} object.
420  <p>
421  * @return the {@link XMLNode} with the XML representation for the 
422  * {@link RenderCurve} object.
423  */ public
424 XMLNode toXML() {
425    return new XMLNode(libsbmlJNI.RenderCurve_toXML(swigCPtr, this), true);
426  }
427
428  
429/**
430   * Sets this SBML object to child SBML objects (if any).
431   * (Creates a child-parent relationship by the parent)
432   <p>
433   * Subclasses must override this function if they define
434   * one ore more child elements.
435   * Basically, this function needs to be called in
436   * constructor, copy constructor, assignment operator.
437   <p>
438   * @see setSBMLDocument
439   * @see enablePackageInternal
440   * @internal
441   */ public
442 void connectToChild() {
443    libsbmlJNI.RenderCurve_connectToChild(swigCPtr, this);
444  }
445
446  
447/**
448   * Enables/Disables the given package with this element and child
449   * elements (if any).
450   * (This is an internal implementation for enablePakcage function)
451   <p>
452   * @note Subclasses in which one or more child elements are defined
453   * must override this function.
454   * @internal
455   */ public
456 void enablePackageInternal(String pkgURI, String pkgPrefix, boolean flag) {
457    libsbmlJNI.RenderCurve_enablePackageInternal(swigCPtr, this, pkgURI, pkgPrefix, flag);
458  }
459
460}