001/* ---------------------------------------------------------------------------- 002 * This file was automatically generated by SWIG (http://www.swig.org). 003 * Version 3.0.7 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 explicitly. 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 explicitly. 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 ( 160 * @param id id string for the polygon 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 <p> 166 * @see GraphicalPrimitive2D) 167 */ public 168 Polygon(RenderPkgNamespaces renderns, String id) throws org.sbml.libsbml.SBMLConstructorException { 169 this(libsbmlJNI.new_Polygon__SWIG_7(RenderPkgNamespaces.getCPtr(renderns), renderns, id), true); 170 } 171 172 173/** 174 * Returns the number of segments. 175 <p> 176 * @return number of elements in the polygon. 177 */ public 178 long getNumElements() { 179 return libsbmlJNI.Polygon_getNumElements(swigCPtr, this); 180 } 181 182 183/** 184 * Returns a pointer to the list of segments. 185 <p> 186 * @return pointer to the {@link ListOfCurveElements} object for the {@link Polygon}. 187 */ public 188 ListOfCurveElements getListOfElements() { 189 long cPtr = libsbmlJNI.Polygon_getListOfElements__SWIG_0(swigCPtr, this); 190 return (cPtr == 0) ? null : new ListOfCurveElements(cPtr, false); 191 } 192 193 194/** 195 * Creates a new point element. 196 * The element is added to and owned by the polygon. 197 <p> 198 * @return The newly created {@link RenderCubicBezier} object. 199 */ public 200 RenderPoint createPoint() { 201 return (RenderPoint) libsbml.DowncastSBase(libsbmlJNI.Polygon_createPoint(swigCPtr, this), false); 202} 203 204 205/** 206 * Creates a new bezier element. 207 * The element is added to and owned by the polygon. 208 <p> 209 * @return The newly created {@link RenderCubicBezier} object. 210 */ public 211 RenderCubicBezier createCubicBezier() { 212 long cPtr = libsbmlJNI.Polygon_createCubicBezier(swigCPtr, this); 213 return (cPtr == 0) ? null : new RenderCubicBezier(cPtr, false); 214 } 215 216 217/** 218 * Returns a pointer to the segment with the given index or null if 219 * the id is invalid. 220 <p> 221 * @param index the index of the element to be returned 222 <p> 223 * @return a pointer to the element with the given index or null 224 * if the index was out of bounds. 225 */ public 226 RenderPoint getElement(long index) { 227 return (RenderPoint) libsbml.DowncastSBase(libsbmlJNI.Polygon_getElement__SWIG_0(swigCPtr, this, index), false); 228} 229 230 231/** 232 * Adds a copy of the given segment to the end of the list of 233 * segments. 234 <p> 235 * @param cs pointer to the {@link RenderPoint} object to be added to the end of the elements list. 236 <p> 237 * @return integer value indicating success/failure of the 238 * function. The possible values 239 * returned by this function are: 240 * <ul> 241 * <li> LIBSBML_OPERATION_SUCCESS 242 * <li> LIBSBML_LEVEL_MISMATCH 243 * <li> LIBSBML_VERSION_MISMATCH 244 * <li> LIBSBML_OPERATION_FAILED 245 * 246 * </ul> <p> 247 * @note This method should be used with some caution. The fact that 248 * this method <em>copies</em> the object passed to it means that the caller 249 * will be left holding a physically different object instance than the 250 * one contained in this {@link Polygon}. Changes made to the original object 251 * instance (such as resetting attribute values) will <em>not affect the 252 * instance in the {@link Polygon}</em>. In addition, the caller should make 253 * sure to free the original object if it is no longer being used, or 254 * else a memory leak will result. Please see {@link Polygon#createPoint()} 255 * or {@link Polygon#createCubicBezier()} 256 * for methods that do not lead to these issues. 257 <p> 258 * @see #createPoint() 259 * @see #createCubicBezier() 260 */ public 261 int addElement(RenderPoint cs) { 262 return libsbmlJNI.Polygon_addElement(swigCPtr, this, RenderPoint.getCPtr(cs), cs); 263 } 264 265 266/** 267 * Creates and returns a deep copy of the {@link Polygon} object. 268 <p> 269 * @return a (deep) copy of this {@link Polygon} 270 */ public 271 Polygon cloneObject() { 272 long cPtr = libsbmlJNI.Polygon_cloneObject(swigCPtr, this); 273 return (cPtr == 0) ? null : new Polygon(cPtr, true); 274 } 275 276 277/** 278 * Returns the XML element name of this object, which for 279 * {@link Polygon}, is always <code>'polygon'.</code> 280 <p> 281 * @return the name of this element, i.e., <code>'polygon'.</code> 282 */ public 283 String getElementName() { 284 return libsbmlJNI.Polygon_getElementName(swigCPtr, this); 285 } 286 287 288/** 289 * Returns the libSBML type code for this SBML object. 290 <p> 291 * LibSBML attaches an 292 * identifying code to every kind of SBML object. These are known as 293 * <em>SBML type codes</em>. In other languages, the set of type codes 294 * is stored in an enumeration; in the Java language interface for 295 * libSBML, the type codes are defined as static integer constants in 296 * interface class {@link libsbmlConstants}. The names of the type codes 297 * all begin with the characters <code>SBML_.</code> 298 <p> 299 * @return the SBML type code for this object, or <code>SBML_UNKNOWN</code> (default). 300 <p> 301 * @see #getElementName() 302 */ public 303 int getTypeCode() { 304 return libsbmlJNI.Polygon_getTypeCode(swigCPtr, this); 305 } 306 307 308/** 309 * Creates an {@link XMLNode} object from this {@link Polygon} object. 310 <p> 311 * @return the {@link XMLNode} with the XML representation for the 312 * {@link Polygon} object. 313 */ public 314 XMLNode toXML() { 315 return new XMLNode(libsbmlJNI.Polygon_toXML(swigCPtr, this), true); 316 } 317 318 public void connectToChild() { 319 libsbmlJNI.Polygon_connectToChild(swigCPtr, this); 320 } 321 322 323/** * @internal */ public 324 void enablePackageInternal(String pkgURI, String pkgPrefix, boolean flag) { 325 libsbmlJNI.Polygon_enablePackageInternal(swigCPtr, this, pkgURI, pkgPrefix, flag); 326 } 327 328}