001/* ----------------------------------------------------------------------------
002 * This file was automatically generated by SWIG (http://www.swig.org).
003 * Version 3.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 * <span class="pkg-marker pkg-color-layout"><a href="group__layout.html">layout</a></span>
013
014 A list of {@link GraphicalObject} objects.
015 <p>
016 * The {@link ListOfGraphicalObjects} class in libSBML actually represents the
017 * ListOfAdditionalGraphicalObjects class in the &ldquo;layout&rdquo;
018 * package, and is a container for the additional {@link GraphicalObject} elements of
019 * a {@link Layout}.
020 <p>
021 * <p>
022 * The various ListOf___ classes in SBML
023 * are merely containers used for organizing the main components of an SBML
024 * model.  In libSBML's implementation, ListOf___
025 * classes are derived from the
026 * intermediate utility class {@link ListOf}, which
027 * is not defined by the SBML specifications but serves as a useful
028 * programmatic construct.  {@link ListOf} is itself is in turn derived from {@link SBase},
029 * which provides all of the various ListOf___
030 * classes with common features
031 * defined by the SBML specification, such as 'metaid' attributes and
032 * annotations.
033 <p>
034 * The relationship between the lists and the rest of an SBML model is
035 * illustrated by the following (for SBML Level&nbsp;2 Version&nbsp;4):
036 <p>
037 * <figure>
038  <object type="image/svg+xml" data="listof-illustration.svg" class="centered"></object>
039</figure>
040
041 <p>
042 * SBML Level&nbsp;3 Version&nbsp;1 has essentially the same structure as 
043 * Level&nbsp;2 Version&nbsp;4, depicted above, but SBML Level&nbsp;3 
044 * Version&nbsp;2 allows
045 * containers to contain zero or more of the relevant object, instead of 
046 * requiring at least one.  As such, libsbml will write out an 
047 * otherwise-empty ListOf___ element that has any optional attribute set 
048 * (such as 'id' or 'metaid'), that has an optional child (such 
049 * as a 'notes' or 'annotation'), or that has attributes or children set
050 * from any SBML Level&nbsp;3 package, whether or not the ListOf___ has 
051 * any other children.
052 <p>
053 * Readers may wonder about the motivations for using the ListOf___
054 * containers in SBML.  A simpler approach in XML might be to place the
055 * components all directly at the top level of the model definition.  The
056 * choice made in SBML is to group them within XML elements named after
057 * ListOf<em>Classname</em>, in part because it helps organize the
058 * components.  More importantly, the fact that the container classes are
059 * derived from {@link SBase} means that software tools can add information <em>about</em>
060 * the lists themselves into each list container's 'annotation'.
061 <p>
062 * @see ListOfFunctionDefinitions
063 * @see ListOfUnitDefinitions
064 * @see ListOfCompartmentTypes
065 * @see ListOfSpeciesTypes
066 * @see ListOfCompartments
067 * @see ListOfSpecies
068 * @see ListOfParameters
069 * @see ListOfInitialAssignments
070 * @see ListOfRules
071 * @see ListOfConstraints
072 * @see ListOfReactions
073 * @see ListOfEvents
074 <p>
075 * @see GraphicalObject
076 */
077
078public class ListOfGraphicalObjects extends ListOf {
079   private long swigCPtr;
080
081   protected ListOfGraphicalObjects(long cPtr, boolean cMemoryOwn)
082   {
083     super(libsbmlJNI.ListOfGraphicalObjects_SWIGUpcast(cPtr), cMemoryOwn);
084     swigCPtr = cPtr;
085   }
086
087   protected static long getCPtr(ListOfGraphicalObjects obj)
088   {
089     return (obj == null) ? 0 : obj.swigCPtr;
090   }
091
092   protected static long getCPtrAndDisown (ListOfGraphicalObjects obj)
093   {
094     long ptr = 0;
095
096     if (obj != null)
097     {
098       ptr             = obj.swigCPtr;
099       obj.swigCMemOwn = false;
100     }
101
102     return ptr;
103   }
104
105  protected void finalize() {
106    delete();
107  }
108
109  public synchronized void delete() {
110    if (swigCPtr != 0) {
111      if (swigCMemOwn) {
112        swigCMemOwn = false;
113        libsbmlJNI.delete_ListOfGraphicalObjects(swigCPtr);
114      }
115      swigCPtr = 0;
116    }
117    super.delete();
118  }
119
120  
121/**
122   * Creates and returns a deep copy of this {@link ListOfGraphicalObjects}.
123   <p>
124   * @return a (deep) copy of this {@link ListOfGraphicalObjects}.
125   */ public
126 ListOfGraphicalObjects cloneObject() {
127    long cPtr = libsbmlJNI.ListOfGraphicalObjects_cloneObject(swigCPtr, this);
128    return (cPtr == 0) ? null : new ListOfGraphicalObjects(cPtr, true);
129  }
130
131  
132/**
133   * Constructor.
134   <p>
135   * @param level the SBML Level.
136   * @param version the Version within the SBML Level.
137   * @param pkgVersion the version of the package.
138   <p>
139   * <p>
140 * @note Attempting to add an object to an {@link SBMLDocument} having a different
141 * combination of SBML Level, Version and XML namespaces than the object
142 * itself will result in an error at the time a caller attempts to make the
143 * addition.  A parent object must have compatible Level, Version and XML
144 * namespaces.  (Strictly speaking, a parent may also have more XML
145 * namespaces than a child, but the reverse is not permitted.)  The
146 * restriction is necessary to ensure that an SBML model has a consistent
147 * overall structure.  This requires callers to manage their objects
148 * carefully, but the benefit is increased flexibility in how models can be
149 * created by permitting callers to create objects bottom-up if desired.  In
150 * situations where objects are not yet attached to parents (e.g.,
151 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help
152 * libSBML determine such things as whether it is valid to assign a
153 * particular value to an attribute.  For packages, this means that the 
154 * parent object to which this package element is being added must have
155 * been created with the package namespace, or that the package namespace
156 * was added to it, even if that parent is not a package object itself.
157   */ public
158 ListOfGraphicalObjects(long level, long version, long pkgVersion) throws org.sbml.libsbml.SBMLConstructorException {
159    this(libsbmlJNI.new_ListOfGraphicalObjects__SWIG_0(level, version, pkgVersion), true);
160  }
161
162  
163/**
164   * Constructor.
165   <p>
166   * @param level the SBML Level.
167   * @param version the Version within the SBML Level.
168   * @param pkgVersion the version of the package.
169   <p>
170   * <p>
171 * @note Attempting to add an object to an {@link SBMLDocument} having a different
172 * combination of SBML Level, Version and XML namespaces than the object
173 * itself will result in an error at the time a caller attempts to make the
174 * addition.  A parent object must have compatible Level, Version and XML
175 * namespaces.  (Strictly speaking, a parent may also have more XML
176 * namespaces than a child, but the reverse is not permitted.)  The
177 * restriction is necessary to ensure that an SBML model has a consistent
178 * overall structure.  This requires callers to manage their objects
179 * carefully, but the benefit is increased flexibility in how models can be
180 * created by permitting callers to create objects bottom-up if desired.  In
181 * situations where objects are not yet attached to parents (e.g.,
182 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help
183 * libSBML determine such things as whether it is valid to assign a
184 * particular value to an attribute.  For packages, this means that the 
185 * parent object to which this package element is being added must have
186 * been created with the package namespace, or that the package namespace
187 * was added to it, even if that parent is not a package object itself.
188   */ public
189 ListOfGraphicalObjects(long level, long version) throws org.sbml.libsbml.SBMLConstructorException {
190    this(libsbmlJNI.new_ListOfGraphicalObjects__SWIG_1(level, version), true);
191  }
192
193  
194/**
195   * Constructor.
196   <p>
197   * @param level the SBML Level.
198   * @param version the Version within the SBML Level.
199   * @param pkgVersion the version of the package.
200   <p>
201   * <p>
202 * @note Attempting to add an object to an {@link SBMLDocument} having a different
203 * combination of SBML Level, Version and XML namespaces than the object
204 * itself will result in an error at the time a caller attempts to make the
205 * addition.  A parent object must have compatible Level, Version and XML
206 * namespaces.  (Strictly speaking, a parent may also have more XML
207 * namespaces than a child, but the reverse is not permitted.)  The
208 * restriction is necessary to ensure that an SBML model has a consistent
209 * overall structure.  This requires callers to manage their objects
210 * carefully, but the benefit is increased flexibility in how models can be
211 * created by permitting callers to create objects bottom-up if desired.  In
212 * situations where objects are not yet attached to parents (e.g.,
213 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help
214 * libSBML determine such things as whether it is valid to assign a
215 * particular value to an attribute.  For packages, this means that the 
216 * parent object to which this package element is being added must have
217 * been created with the package namespace, or that the package namespace
218 * was added to it, even if that parent is not a package object itself.
219   */ public
220 ListOfGraphicalObjects(long level) throws org.sbml.libsbml.SBMLConstructorException {
221    this(libsbmlJNI.new_ListOfGraphicalObjects__SWIG_2(level), true);
222  }
223
224  
225/**
226   * Constructor.
227   <p>
228   * @param level the SBML Level.
229   * @param version the Version within the SBML Level.
230   * @param pkgVersion the version of the package.
231   <p>
232   * <p>
233 * @note Attempting to add an object to an {@link SBMLDocument} having a different
234 * combination of SBML Level, Version and XML namespaces than the object
235 * itself will result in an error at the time a caller attempts to make the
236 * addition.  A parent object must have compatible Level, Version and XML
237 * namespaces.  (Strictly speaking, a parent may also have more XML
238 * namespaces than a child, but the reverse is not permitted.)  The
239 * restriction is necessary to ensure that an SBML model has a consistent
240 * overall structure.  This requires callers to manage their objects
241 * carefully, but the benefit is increased flexibility in how models can be
242 * created by permitting callers to create objects bottom-up if desired.  In
243 * situations where objects are not yet attached to parents (e.g.,
244 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help
245 * libSBML determine such things as whether it is valid to assign a
246 * particular value to an attribute.  For packages, this means that the 
247 * parent object to which this package element is being added must have
248 * been created with the package namespace, or that the package namespace
249 * was added to it, even if that parent is not a package object itself.
250   */ public
251 ListOfGraphicalObjects() throws org.sbml.libsbml.SBMLConstructorException {
252    this(libsbmlJNI.new_ListOfGraphicalObjects__SWIG_3(), true);
253  }
254
255  
256/**
257   * Constructor.
258   <p>
259   * <p>
260 * The package namespaces object used in this constructor is derived from a
261 * {@link SBMLNamespaces} object, which encapsulates SBML Level/Version/namespaces
262 * information.  It is used to communicate the SBML Level, Version, and 
263 * package version and name information used in addition to SBML Level&nbsp;3 Core.  A
264 * common approach to using libSBML's {@link SBMLNamespaces} facilities is to create an
265 * package namespace object somewhere in a program once, then hand that object
266 * as needed to object constructors of that package that accept it as and
267 * argument, such as this one.
268   <p>
269   * @param layoutns the {@link LayoutPkgNamespaces} object.
270   <p>
271   * <p>
272 * @note Attempting to add an object to an {@link SBMLDocument} having a different
273 * combination of SBML Level, Version and XML namespaces than the object
274 * itself will result in an error at the time a caller attempts to make the
275 * addition.  A parent object must have compatible Level, Version and XML
276 * namespaces.  (Strictly speaking, a parent may also have more XML
277 * namespaces than a child, but the reverse is not permitted.)  The
278 * restriction is necessary to ensure that an SBML model has a consistent
279 * overall structure.  This requires callers to manage their objects
280 * carefully, but the benefit is increased flexibility in how models can be
281 * created by permitting callers to create objects bottom-up if desired.  In
282 * situations where objects are not yet attached to parents (e.g.,
283 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help
284 * libSBML determine such things as whether it is valid to assign a
285 * particular value to an attribute.  For packages, this means that the 
286 * parent object to which this package element is being added must have
287 * been created with the package namespace, or that the package namespace
288 * was added to it, even if that parent is not a package object itself.
289   */ public
290 ListOfGraphicalObjects(LayoutPkgNamespaces layoutns) throws org.sbml.libsbml.SBMLConstructorException {
291    this(libsbmlJNI.new_ListOfGraphicalObjects__SWIG_4(LayoutPkgNamespaces.getCPtr(layoutns), layoutns), true);
292  }
293
294  
295/**
296   * Returns the libSBML type code for the SBML objects
297   * contained in this {@link ListOf} object.
298   <p>
299   * <p>
300 * LibSBML attaches an identifying code to every kind of SBML object.  These
301 * are integer constants known as <em>SBML type codes</em>.  The names of all
302 * the codes begin with the characters <code>SBML_</code>.
303 * In the Java language interface for libSBML, the
304 * type codes are defined as static integer constants in the interface class
305 * {@link libsbmlConstants}.    Note that different Level&nbsp;3
306 * package plug-ins may use overlapping type codes; to identify the package
307 * to which a given object belongs, call the 
308 * <code>{@link SBase#getPackageName()}
309 * </code>
310 * method on the object.
311   <p>
312   * @return the SBML type code for objects contained in this list:
313   * {@link libsbmlConstants#SBML_LAYOUT_GRAPHICALOBJECT SBML_LAYOUT_GRAPHICALOBJECT} (default).
314   <p>
315   * @see #getElementName()
316   * @see #getPackageName()
317   */ public
318 int getItemTypeCode() {
319    return libsbmlJNI.ListOfGraphicalObjects_getItemTypeCode(swigCPtr, this);
320  }
321
322  
323/**
324   * Returns the XML element name of
325   * this SBML object.
326   <p>
327   * @return the string of the name of this element.
328   */ public
329 String getElementName() {
330    return libsbmlJNI.ListOfGraphicalObjects_getElementName(swigCPtr, this);
331  }
332
333  
334/** * @internal */ public
335 void setElementName(String elementName) {
336    libsbmlJNI.ListOfGraphicalObjects_setElementName(swigCPtr, this, elementName);
337  }
338
339  
340/**
341   * Get a {@link GraphicalObject} from the {@link ListOfGraphicalObjects}.
342   <p>
343   * @param n the index number of the {@link GraphicalObject} to get.
344   <p>
345   * @return the nth {@link GraphicalObject} in this {@link ListOfGraphicalObjects}.
346   <p>
347   * @see #size()
348   */ public
349 GraphicalObject get(long n) {
350    return (GraphicalObject) libsbml.DowncastSBase(libsbmlJNI.ListOfGraphicalObjects_get__SWIG_0(swigCPtr, this, n), false);
351}
352
353  
354/**
355   * Get a {@link GraphicalObject} from the {@link ListOfGraphicalObjects}
356   * based on its identifier.
357   <p>
358   * @param sid a string representing the identifier 
359   * of the {@link GraphicalObject} to get.
360   <p>
361   * @return {@link GraphicalObject} in this {@link ListOfGraphicalObjects}
362   * with the given <code>sid</code> or <code>null</code> if no such
363   * {@link GraphicalObject} exists.
364   <p>
365   * @see #get(long n)
366   * @see #size()
367   */ public
368 GraphicalObject get(String sid) {
369    return (GraphicalObject) libsbml.DowncastSBase(libsbmlJNI.ListOfGraphicalObjects_get__SWIG_2(swigCPtr, this, sid), false);
370}
371
372  
373/**
374   * Removes the nth item from this {@link ListOfGraphicalObjects} items and returns a pointer to
375   * it.
376   <p>
377   * The caller owns the returned item and is responsible for deleting it.
378   <p>
379   * @param n the index of the item to remove.
380   <p>
381   * @see #size()
382   */ public
383 GraphicalObject remove(long n) {
384    return (GraphicalObject) libsbml.DowncastSBase(libsbmlJNI.ListOfGraphicalObjects_remove__SWIG_0(swigCPtr, this, n), true);
385}
386
387  
388/**
389   * Removes item in this {@link ListOfGraphicalObjects} items with the given identifier.
390   <p>
391   * The caller owns the returned item and is responsible for deleting it.
392   * If none of the items in this list have the identifier <code>sid</code>, then
393   * <code>null</code> is returned.
394   <p>
395   * @param sid the identifier of the item to remove.
396   <p>
397   * @return the item removed.  As mentioned above, the caller owns the
398   * returned item.
399   */ public
400 GraphicalObject remove(String sid) {
401    return (GraphicalObject) libsbml.DowncastSBase(libsbmlJNI.ListOfGraphicalObjects_remove__SWIG_1(swigCPtr, this, sid), true);
402}
403
404  
405/**
406    * Creates an {@link XMLNode} object from this.
407    */ public
408 XMLNode toXML() {
409    return new XMLNode(libsbmlJNI.ListOfGraphicalObjects_toXML(swigCPtr, this), true);
410  }
411
412}