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 * class representing a polygon from the SBML render extension
013 <p>
014 * The {@link Polygon} is very similar to the {@link RenderCurve} class. The only difference is that in the 
015 * polygon the end point of the last element in the curve segment list is
016 * automatically connected to the start point of the first element.
017 <p>
018 * Since a polygon is a closed shape and doesn't really have a start or an end, it does not get
019 * decorations as the {@link RenderCurve} does.
020 <p>
021 * So a polygon is always closed and can therefor have a fill style and fill style related attributes.
022 * Those attributes are inherited from Polygons base class {@link GraphicalPrimitive2D}. 
023 */
024
025public class Polygon extends GraphicalPrimitive2D {
026   private long swigCPtr;
027
028   protected Polygon(long cPtr, boolean cMemoryOwn)
029   {
030     super(libsbmlJNI.Polygon_SWIGUpcast(cPtr), cMemoryOwn);
031     swigCPtr = cPtr;
032   }
033
034   protected static long getCPtr(Polygon obj)
035   {
036     return (obj == null) ? 0 : obj.swigCPtr;
037   }
038
039   protected static long getCPtrAndDisown (Polygon 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_Polygon(swigCPtr);
061      }
062      swigCPtr = 0;
063    }
064    super.delete();
065  }
066
067  
068/**
069   * Creates a new {@link Polygon} object with the given SBML level
070   * and SBML version.
071   <p>
072   * @param level SBML level of the new object
073   * @param level SBML version of the new object
074   */ public
075 Polygon(long level, long version, long pkgVersion) throws org.sbml.libsbml.SBMLConstructorException {
076    this(libsbmlJNI.new_Polygon__SWIG_0(level, version, pkgVersion), true);
077  }
078
079  
080/**
081   * Creates a new {@link Polygon} object with the given SBML level
082   * and SBML version.
083   <p>
084   * @param level SBML level of the new object
085   * @param level SBML version of the new object
086   */ public
087 Polygon(long level, long version) throws org.sbml.libsbml.SBMLConstructorException {
088    this(libsbmlJNI.new_Polygon__SWIG_1(level, version), true);
089  }
090
091  
092/**
093   * Creates a new {@link Polygon} object with the given SBML level
094   * and SBML version.
095   <p>
096   * @param level SBML level of the new object
097   * @param level SBML version of the new object
098   */ public
099 Polygon(long level) throws org.sbml.libsbml.SBMLConstructorException {
100    this(libsbmlJNI.new_Polygon__SWIG_2(level), true);
101  }
102
103  
104/**
105   * Creates a new {@link Polygon} object with the given SBML level
106   * and SBML version.
107   <p>
108   * @param level SBML level of the new object
109   * @param level SBML version of the new object
110   */ public
111 Polygon() throws org.sbml.libsbml.SBMLConstructorException {
112    this(libsbmlJNI.new_Polygon__SWIG_3(), true);
113  }
114
115  
116/**
117   * Creates a new {@link Polygon} object with the given {@link SBMLNamespaces}.
118   <p>
119   * @param sbmlns The SBML namespace for the object.
120   */ public
121 Polygon(RenderPkgNamespaces renderns) throws org.sbml.libsbml.SBMLConstructorException {
122    this(libsbmlJNI.new_Polygon__SWIG_4(RenderPkgNamespaces.getCPtr(renderns), renderns), true);
123  }
124
125  
126/**
127   * Creates a new {@link Polygon} object from the given {@link XMLNode} object.
128   * The {@link XMLNode} object has to contain a valid XML representation of a 
129   * {@link Polygon} object as defined in the render extension specification.
130   * This method is normally called when render information is read from a file and 
131   * should normally not have to be called explicitely.
132   <p>
133   * @param node the {@link XMLNode} object reference that describes the {@link Polygon}
134   * object to be instantiated.
135   */ public
136 Polygon(XMLNode node, long l2version) throws org.sbml.libsbml.SBMLConstructorException {
137    this(libsbmlJNI.new_Polygon__SWIG_5(XMLNode.getCPtr(node), node, l2version), true);
138  }
139
140  
141/**
142   * Creates a new {@link Polygon} object from the given {@link XMLNode} object.
143   * The {@link XMLNode} object has to contain a valid XML representation of a 
144   * {@link Polygon} object as defined in the render extension specification.
145   * This method is normally called when render information is read from a file and 
146   * should normally not have to be called explicitely.
147   <p>
148   * @param node the {@link XMLNode} object reference that describes the {@link Polygon}
149   * object to be instantiated.
150   */ public
151 Polygon(XMLNode node) throws org.sbml.libsbml.SBMLConstructorException {
152    this(libsbmlJNI.new_Polygon__SWIG_6(XMLNode.getCPtr(node), node), true);
153  }
154
155  
156/**
157   * Instanciates a polygon with the given <code>id</code> and no elements.
158   * All attributes inherited from GraphicalPrimitive are set as described
159   * in the corresponding constructor of that class (@see GraphicalPrimitive2D)
160   <p>
161   * @param id id string for the polygon
162   <p>
163   * This constructor is deprecated. The new libsbml API only has
164   * constructors which take the SBML level and version or one that takes
165   * an {@link SBMLNamespaces} object.
166   */ public
167 Polygon(RenderPkgNamespaces renderns, String id) throws org.sbml.libsbml.SBMLConstructorException {
168    this(libsbmlJNI.new_Polygon__SWIG_7(RenderPkgNamespaces.getCPtr(renderns), renderns, id), true);
169  }
170
171  
172/**
173   * Returns the number of segments.
174   <p>
175   * @return number of elements in the polygon.
176   */ public
177 long getNumElements() {
178    return libsbmlJNI.Polygon_getNumElements(swigCPtr, this);
179  }
180
181  
182/**
183   * Returns a const pointer to the list of segments.
184   <p>
185   * @return const pointer to the {@link ListOfCurveElements} object for the {@link Polygon}.
186   */ public
187 ListOfCurveElements getListOfElements() {
188    long cPtr = libsbmlJNI.Polygon_getListOfElements__SWIG_0(swigCPtr, this);
189    return (cPtr == 0) ? null : new ListOfCurveElements(cPtr, false);
190  }
191
192  
193/**
194   * Creates a new point element.
195   * The element is added to and owned by the polygon.
196   <p>
197   * @return The newly created {@link RenderCubicBezier} object.
198   */ public
199 RenderPoint createPoint() {
200  return (RenderPoint) libsbml.DowncastSBase(libsbmlJNI.Polygon_createPoint(swigCPtr, this), false);
201}
202
203  
204/**
205   * Creates a new bezier element.
206   * The element is added to and owned by the polygon.
207   <p>
208   * @return The newly created {@link RenderCubicBezier} object.
209   */ public
210 RenderCubicBezier createCubicBezier() {
211    long cPtr = libsbmlJNI.Polygon_createCubicBezier(swigCPtr, this);
212    return (cPtr == 0) ? null : new RenderCubicBezier(cPtr, false);
213  }
214
215  
216/**
217   * Returns a pointer to the segment with the given index or null if
218   * the id is invalid.
219   <p>
220   * @param index the index of the element to be returned
221   <p>
222   * @return a pointer to the element with the given index or null 
223   * if the index was out of bounds.
224   */ public
225 RenderPoint getElement(long index) {
226  return (RenderPoint) libsbml.DowncastSBase(libsbmlJNI.Polygon_getElement__SWIG_0(swigCPtr, this, index), false);
227}
228
229  
230/**
231   * Adds a copy of the given segment to the end of the list of
232   * segments.
233   <p>
234   * @param cs pointer to the {@link RenderPoint} object to be added to the end of the elements list.
235   <p>
236   * @return integer value indicating success/failure of the
237   * function.   The possible values
238   * returned by this function are:
239   * <ul>
240   * <li> LIBSBML_OPERATION_SUCCESS
241   * <li> LIBSBML_LEVEL_MISMATCH
242   * <li> LIBSBML_VERSION_MISMATCH
243   * <li> LIBSBML_OPERATION_FAILED
244   *
245   * </ul> <p>
246   * @note This method should be used with some caution.  The fact that
247   * this method <em>copies</em> the object passed to it means that the caller
248   * will be left holding a physically different object instance than the
249   * one contained in this {@link Polygon}.  Changes made to the original object
250   * instance (such as resetting attribute values) will <em>not affect the
251   * instance in the {@link Polygon}</em>.  In addition, the caller should make
252   * sure to free the original object if it is no longer being used, or
253   * else a memory leak will result.  Please see {@link Polygon#createPoint()}
254   * or {@link Polygon#createCubicBezier()}
255   * for methods that do not lead to these issues.
256   <p>
257   * @see #createPoint()
258   * @see #createCubicBezier()
259   */ public
260 int addElement(RenderPoint cs) {
261    return libsbmlJNI.Polygon_addElement(swigCPtr, this, RenderPoint.getCPtr(cs), cs);
262  }
263
264  
265/**
266   * Creates and returns a deep copy of the {@link Polygon} object.
267   <p>
268   * @return a (deep) copy of this {@link Polygon}
269   */ public
270 Polygon cloneObject() {
271    long cPtr = libsbmlJNI.Polygon_cloneObject(swigCPtr, this);
272    return (cPtr == 0) ? null : new Polygon(cPtr, true);
273  }
274
275  
276/**
277   * Returns the XML element name of this object, which for
278   * {@link Polygon}, is always <code>'polygon'.</code>
279   <p>
280   * @return the name of this element, i.e., <code>'polygon'.</code>
281   */ public
282 String getElementName() {
283    return libsbmlJNI.Polygon_getElementName(swigCPtr, this);
284  }
285
286  
287/**
288   * Returns the libSBML type code for this SBML object.
289   <p>
290   * LibSBML attaches an
291   * identifying code to every kind of SBML object.  These are known as
292   * <em>SBML type codes</em>.  In other languages, the set of type codes
293   * is stored in an enumeration; in the Java language interface for
294   * libSBML, the type codes are defined as static integer constants in
295   * interface class {@link libsbmlConstants}.  The names of the type codes
296   * all begin with the characters <code>SBML_.</code> 
297   <p>
298   * @return the SBML type code for this object, or <code>SBML_UNKNOWN</code> (default).
299   <p>
300   * @see #getElementName()
301   */ public
302 int getTypeCode() {
303    return libsbmlJNI.Polygon_getTypeCode(swigCPtr, this);
304  }
305
306  
307/**
308   * Creates an {@link XMLNode} object from this {@link Polygon} object.
309   <p>
310   * @return the {@link XMLNode} with the XML representation for the 
311   * {@link Polygon} object.
312   */ public
313 XMLNode toXML() {
314    return new XMLNode(libsbmlJNI.Polygon_toXML(swigCPtr, this), true);
315  }
316
317  
318/**
319   * Sets this SBML object to child SBML objects (if any).
320   * (Creates a child-parent relationship by the parent)
321   <p>
322   * Subclasses must override this function if they define
323   * one ore more child elements.
324   * Basically, this function needs to be called in
325   * constructor, copy constructor, assignment operator.
326   <p>
327   * @see setSBMLDocument
328   * @see enablePackageInternal
329   * @internal
330   */ public
331 void connectToChild() {
332    libsbmlJNI.Polygon_connectToChild(swigCPtr, this);
333  }
334
335  
336/**
337   * Enables/Disables the given package with this element and child
338   * elements (if any).
339   * (This is an internal implementation for enablePakcage function)
340   <p>
341   * @note Subclasses in which one or more child elements are defined
342   * must override this function.
343   * @internal
344   */ public
345 void enablePackageInternal(String pkgURI, String pkgPrefix, boolean flag) {
346    libsbmlJNI.Polygon_enablePackageInternal(swigCPtr, this, pkgURI, pkgPrefix, flag);
347  }
348
349}