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 * 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 const 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 a (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 210/** 211 * Sets this SBML object to child SBML objects (if any). 212 * (Creates a child-parent relationship by the parent) 213 <p> 214 * Subclasses must override this function if they define 215 * one ore more child elements. 216 * Basically, this function needs to be called in 217 * constructor, copy constructor, assignment operator. 218 <p> 219 <p> 220 * @internal 221 */ public 222 void connectToChild() { 223 libsbmlJNI.GradientBase_connectToChild(swigCPtr, this); 224 } 225 226 227/** 228 * Enables/Disables the given package with this element and child 229 * elements (if any). 230 * (This is an internal implementation for enablePackage function) 231 <p> 232 * @note Subclasses in which one or more child elements are defined 233 * must override this function. 234 <p> 235 <p> 236 * @see #connectToChild() 237 * @internal 238 */ public 239 void enablePackageInternal(String pkgURI, String pkgPrefix, boolean flag) { 240 libsbmlJNI.GradientBase_enablePackageInternal(swigCPtr, this, pkgURI, pkgPrefix, flag); 241 } 242 243 244/** * @internal */ public 245 String getId() { 246 return libsbmlJNI.GradientBase_getId(swigCPtr, this); 247 } 248 249 250/** * @internal */ public 251 boolean isSetId() { 252 return libsbmlJNI.GradientBase_isSetId(swigCPtr, this); 253 } 254 255 256/** * @internal */ public 257 int setId(String id) { 258 return libsbmlJNI.GradientBase_setId(swigCPtr, this, id); 259 } 260 261 262/** 263 * Unsets the value of the 'id' attribute of this SBML object. 264 <p> 265 * Most (but not all) objects in SBML include two common attributes: 'id' 266 * and 'name'. The identifier given by an object's 'id' attribute value 267 * is used to identify the object within the SBML model definition. 268 * Other objects can refer to the component using this identifier. 269 <p> 270 * @return integer value indicating success/failure of the 271 * function. The possible values returned by this function are: 272 * <ul> 273 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 274 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED } 275 * </ul> 276 */ public 277 int unsetId() { 278 return libsbmlJNI.GradientBase_unsetId(swigCPtr, this); 279 } 280 281 282/** * @internal */ public 283 boolean hasRequiredAttributes() { 284 return libsbmlJNI.GradientBase_hasRequiredAttributes(swigCPtr, this); 285 } 286 287 288/** * @internal */ public 289 boolean hasRequiredElements() { 290 return libsbmlJNI.GradientBase_hasRequiredElements(swigCPtr, this); 291 } 292 293 // SPREADMETHOD 294 public final static int PAD = 0; 295 public final static int REFLECT = PAD + 1; 296 public final static int REPEAT = REFLECT + 1; 297 298}