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 * LibSBML implementation for the ColorDefinition construct from
013 * the SBML render extension.
014 <p>
015 * A <em>ColorDefinition</em> specifies an id for a certain RGBA value which can
016 * then be referenced by this id in other render extension constructs.
017 * The use of ids like e.g. 'lightyellow' might be more descriptive than the
018 * corresponding RGBA value.
019 <p>
020 * A {@link ColorDefinition} has two mandatory attributes which are the id for the
021 * color definition and the corresponding RGBA value. The RGBA value has the 
022 * same notation as in HTML files or CSS style sheets. It starts with the '#'
023 * character followed by 8 digit hexadecimal string. Optionally the alpha part
024 * can be omited in which case it defaults to FF.
025 <p>
026 * Valid value string are e.g. '#000000' or '#000000FF' for fully opaque black
027 * or '#FF000010' for an almost completly transparent red.
028 <p>
029 * Internally the RGBA components are stored as integer values in the range of 0 to 255
030 * and most methods use integer values instead of the hexadecimal value string.
031 */
032
033public class ColorDefinition extends SBase {
034   private long swigCPtr;
035
036   protected ColorDefinition(long cPtr, boolean cMemoryOwn)
037   {
038     super(libsbmlJNI.ColorDefinition_SWIGUpcast(cPtr), cMemoryOwn);
039     swigCPtr = cPtr;
040   }
041
042   protected static long getCPtr(ColorDefinition obj)
043   {
044     return (obj == null) ? 0 : obj.swigCPtr;
045   }
046
047   protected static long getCPtrAndDisown (ColorDefinition obj)
048   {
049     long ptr = 0;
050
051     if (obj != null)
052     {
053       ptr             = obj.swigCPtr;
054       obj.swigCMemOwn = false;
055     }
056
057     return ptr;
058   }
059
060  protected void finalize() {
061    delete();
062  }
063
064  public synchronized void delete() {
065    if (swigCPtr != 0) {
066      if (swigCMemOwn) {
067        swigCMemOwn = false;
068        libsbmlJNI.delete_ColorDefinition(swigCPtr);
069      }
070      swigCPtr = 0;
071    }
072    super.delete();
073  }
074
075  
076/**
077   * Creates a new {@link ColorDefinition} object with the given SBML level
078   * and SBML version.
079   <p>
080   * @param level SBML level of the new object
081   * @param level SBML version of the new object
082   */ public
083 ColorDefinition(long level, long version, long pkgVersion) throws org.sbml.libsbml.SBMLConstructorException {
084    this(libsbmlJNI.new_ColorDefinition__SWIG_0(level, version, pkgVersion), true);
085  }
086
087  
088/**
089   * Creates a new {@link ColorDefinition} object with the given SBML level
090   * and SBML version.
091   <p>
092   * @param level SBML level of the new object
093   * @param level SBML version of the new object
094   */ public
095 ColorDefinition(long level, long version) throws org.sbml.libsbml.SBMLConstructorException {
096    this(libsbmlJNI.new_ColorDefinition__SWIG_1(level, version), true);
097  }
098
099  
100/**
101   * Creates a new {@link ColorDefinition} object with the given SBML level
102   * and SBML version.
103   <p>
104   * @param level SBML level of the new object
105   * @param level SBML version of the new object
106   */ public
107 ColorDefinition(long level) throws org.sbml.libsbml.SBMLConstructorException {
108    this(libsbmlJNI.new_ColorDefinition__SWIG_2(level), true);
109  }
110
111  
112/**
113   * Creates a new {@link ColorDefinition} object with the given SBML level
114   * and SBML version.
115   <p>
116   * @param level SBML level of the new object
117   * @param level SBML version of the new object
118   */ public
119 ColorDefinition() throws org.sbml.libsbml.SBMLConstructorException {
120    this(libsbmlJNI.new_ColorDefinition__SWIG_3(), true);
121  }
122
123  
124/**
125   * Creates a new {@link ColorDefinition} object with the given {@link SBMLNamespaces}.
126   <p>
127   * @param sbmlns The SBML namespace for the object.
128   */ public
129 ColorDefinition(RenderPkgNamespaces renderns) throws org.sbml.libsbml.SBMLConstructorException {
130    this(libsbmlJNI.new_ColorDefinition__SWIG_4(RenderPkgNamespaces.getCPtr(renderns), renderns), true);
131  }
132
133  
134/**
135   * Creates a new {@link ColorDefinition} object from the given {@link XMLNode} object.
136   * The {@link XMLNode} object has to contain a valid XML representation of a 
137   * {@link ColorDefinition} object as defined in the render extension specification.
138   * This method is normally called when render information is read from a file and 
139   * should normally not have to be called explicitely.
140   <p>
141   <p>
142   * (FOR BACKWARD COMPATIBILITY)
143   <p>
144   * @param node the {@link XMLNode} object reference that describes the {@link ColorDefinition}
145   * object to be instantiated.
146   */ public
147 ColorDefinition(XMLNode node, long l2version) throws org.sbml.libsbml.SBMLConstructorException {
148    this(libsbmlJNI.new_ColorDefinition__SWIG_5(XMLNode.getCPtr(node), node, l2version), true);
149  }
150
151  
152/**
153   * Creates a new {@link ColorDefinition} object from the given {@link XMLNode} object.
154   * The {@link XMLNode} object has to contain a valid XML representation of a 
155   * {@link ColorDefinition} object as defined in the render extension specification.
156   * This method is normally called when render information is read from a file and 
157   * should normally not have to be called explicitely.
158   <p>
159   <p>
160   * (FOR BACKWARD COMPATIBILITY)
161   <p>
162   * @param node the {@link XMLNode} object reference that describes the {@link ColorDefinition}
163   * object to be instantiated.
164   */ public
165 ColorDefinition(XMLNode node) throws org.sbml.libsbml.SBMLConstructorException {
166    this(libsbmlJNI.new_ColorDefinition__SWIG_6(XMLNode.getCPtr(node), node), true);
167  }
168
169  
170/**
171   * Constructor which sets the {@link ColorDefinition} to the given RGBA values.
172   <p>
173   * @param r Red component value. Has to be in the range of 0 to 255.
174   * @param g Green component value. Has to be in the range of 0 to 255.
175   * @param b Blue component value. Has to be in the range of 0 to 255.
176   * @param a Alpha component value. Has to be in the range of 0 to 255. 
177   * The alpha component can be omitted. In that case it has a default value of 255.
178   <p>
179   * This constructor is deprecated. The new libsbml API only has
180   * constructors which take the SBML level and version or one that takes
181   * an {@link SBMLNamespaces} object.
182   */ public
183 ColorDefinition(RenderPkgNamespaces renderns, short r, short g, short b, short a) throws org.sbml.libsbml.SBMLConstructorException {
184    this(libsbmlJNI.new_ColorDefinition__SWIG_7(RenderPkgNamespaces.getCPtr(renderns), renderns, r, g, b, a), true);
185  }
186
187  
188/**
189   * Constructor which sets the {@link ColorDefinition} to the given RGBA values.
190   <p>
191   * @param r Red component value. Has to be in the range of 0 to 255.
192   * @param g Green component value. Has to be in the range of 0 to 255.
193   * @param b Blue component value. Has to be in the range of 0 to 255.
194   * @param a Alpha component value. Has to be in the range of 0 to 255. 
195   * The alpha component can be omitted. In that case it has a default value of 255.
196   <p>
197   * This constructor is deprecated. The new libsbml API only has
198   * constructors which take the SBML level and version or one that takes
199   * an {@link SBMLNamespaces} object.
200   */ public
201 ColorDefinition(RenderPkgNamespaces renderns, short r, short g, short b) throws org.sbml.libsbml.SBMLConstructorException {
202    this(libsbmlJNI.new_ColorDefinition__SWIG_8(RenderPkgNamespaces.getCPtr(renderns), renderns, r, g, b), true);
203  }
204
205  
206/**
207   * Constructor which sets the {@link ColorDefinition} to completely opaque
208   * black and sets the id to the given string.
209   <p>
210   * @param id the id of the color definition. The user has to make sure 
211   * that the id is unique within the given set of color definitions. 
212   <p>
213   * This constructor is deprecated. The new libsbml API only has
214   * constructors which take the SBML level and version or one that takes
215   * an {@link SBMLNamespaces} object.
216   */ public
217 ColorDefinition(RenderPkgNamespaces renderns, String id) throws org.sbml.libsbml.SBMLConstructorException {
218    this(libsbmlJNI.new_ColorDefinition__SWIG_9(RenderPkgNamespaces.getCPtr(renderns), renderns, id), true);
219  }
220
221  
222/**
223   * Constructor which sets the {@link ColorDefinition} to the given RGBA values
224   * and sets the id.
225   <p>
226   * @param id the id of the color definition. The user has to make sure 
227   * that the id is unique within the given set of color definitions. 
228   * @param r Red component value. Has to be in the range of 0 to 255.
229   * @param g Green component value. Has to be in the range of 0 to 255.
230   * @param b Blue component value. Has to be in the range of 0 to 255.
231   * @param a Alpha component value. Has to be in the range of 0 to 255. 
232   * The alpha component can be omitted. In that case it has a default value of 255.
233   <p>
234   * This constructor is deprecated. The new libsbml API only has
235   * constructors which take the SBML level and version or one that takes
236   * an {@link SBMLNamespaces} object.
237   */ public
238 ColorDefinition(RenderPkgNamespaces renderns, String id, short r, short g, short b, short a) throws org.sbml.libsbml.SBMLConstructorException {
239    this(libsbmlJNI.new_ColorDefinition__SWIG_10(RenderPkgNamespaces.getCPtr(renderns), renderns, id, r, g, b, a), true);
240  }
241
242  
243/**
244   * Constructor which sets the {@link ColorDefinition} to the given RGBA values
245   * and sets the id.
246   <p>
247   * @param id the id of the color definition. The user has to make sure 
248   * that the id is unique within the given set of color definitions. 
249   * @param r Red component value. Has to be in the range of 0 to 255.
250   * @param g Green component value. Has to be in the range of 0 to 255.
251   * @param b Blue component value. Has to be in the range of 0 to 255.
252   * @param a Alpha component value. Has to be in the range of 0 to 255. 
253   * The alpha component can be omitted. In that case it has a default value of 255.
254   <p>
255   * This constructor is deprecated. The new libsbml API only has
256   * constructors which take the SBML level and version or one that takes
257   * an {@link SBMLNamespaces} object.
258   */ public
259 ColorDefinition(RenderPkgNamespaces renderns, String id, short r, short g, short b) throws org.sbml.libsbml.SBMLConstructorException {
260    this(libsbmlJNI.new_ColorDefinition__SWIG_11(RenderPkgNamespaces.getCPtr(renderns), renderns, id, r, g, b), true);
261  }
262
263  
264/**
265   * Returns the red color component.
266   <p>
267   * @return the red color component for the {@link ColorDefinition}.
268   */ public
269 short getRed() {
270    return libsbmlJNI.ColorDefinition_getRed(swigCPtr, this);
271  }
272
273  
274/**
275   * Returns the green color component.
276   <p>
277   * @return the green color component for the {@link ColorDefinition}.
278   */ public
279 short getGreen() {
280    return libsbmlJNI.ColorDefinition_getGreen(swigCPtr, this);
281  }
282
283  
284/**
285   * Returns the blue color component.
286   <p>
287   * @return the blue color component for the {@link ColorDefinition}.
288   */ public
289 short getBlue() {
290    return libsbmlJNI.ColorDefinition_getBlue(swigCPtr, this);
291  }
292
293  
294/**
295   * Returns the alpha color component.
296   <p>
297   * @return the alpha color component for the {@link ColorDefinition}.
298   */ public
299 short getAlpha() {
300    return libsbmlJNI.ColorDefinition_getAlpha(swigCPtr, this);
301  }
302
303  
304/**
305   * Sets the red color component.
306   <p>
307   * @param c the new red component value for the color definition.
308   */ public
309 void setRed(short c) {
310    libsbmlJNI.ColorDefinition_setRed(swigCPtr, this, c);
311  }
312
313  
314/**
315   * Sets the green color component.
316   <p>
317   * @param c the new green component value for the color definition.
318   */ public
319 void setGreen(short c) {
320    libsbmlJNI.ColorDefinition_setGreen(swigCPtr, this, c);
321  }
322
323  
324/**
325   * Sets the blue color component.
326   <p>
327   * @param c the new blue component value for the color definition.
328   */ public
329 void setBlue(short c) {
330    libsbmlJNI.ColorDefinition_setBlue(swigCPtr, this, c);
331  }
332
333  
334/**
335   * Sets alpha red color component.
336   <p>
337   * @param c the new alpha component value for the color definition.
338   */ public
339 void setAlpha(short c) {
340    libsbmlJNI.ColorDefinition_setAlpha(swigCPtr, this, c);
341  }
342
343  
344/**
345   * Sets the red green, blue and alpha color component.
346   * The alpha value is optional and defaults to 255 if not given.
347   * @param r Red component value. Has to be in the range of 0 to 255.
348   * @param g Green component value. Has to be in the range of 0 to 255.
349   * @param b Blue component value. Has to be in the range of 0 to 255.
350   * @param a Alpha component value. Has to be in the range of 0 to 255. 
351   * The alpha component can be omitted. In that case it has a default value of 255.
352   */ public
353 void setRGBA(short r, short g, short b, short a) {
354    libsbmlJNI.ColorDefinition_setRGBA__SWIG_0(swigCPtr, this, r, g, b, a);
355  }
356
357  
358/**
359   * Sets the red green, blue and alpha color component.
360   * The alpha value is optional and defaults to 255 if not given.
361   * @param r Red component value. Has to be in the range of 0 to 255.
362   * @param g Green component value. Has to be in the range of 0 to 255.
363   * @param b Blue component value. Has to be in the range of 0 to 255.
364   * @param a Alpha component value. Has to be in the range of 0 to 255. 
365   * The alpha component can be omitted. In that case it has a default value of 255.
366   */ public
367 void setRGBA(short r, short g, short b) {
368    libsbmlJNI.ColorDefinition_setRGBA__SWIG_1(swigCPtr, this, r, g, b);
369  }
370
371  
372/**
373   * Sets the color value from a given value string.
374   * If the string is not a valid value string, the color value is set to
375   * black and false is returned.
376   <p>
377   * @param valueString A const reference to a string that represents a valid color value,
378   * e.g. '#FFFFFFFF' for fully opaque white.
379   <p>
380   * @return true or false depending on whether setting the color value from the string
381   * was successfull.
382   */ public
383 boolean setColorValue(String valueString) {
384    return libsbmlJNI.ColorDefinition_setColorValue(swigCPtr, this, valueString);
385  }
386
387  
388/**
389   * Creates a string the represents the current color value.
390   <p>
391   * @return The string representation of the color value.
392   */ public
393 String createValueString() {
394    return libsbmlJNI.ColorDefinition_createValueString(swigCPtr, this);
395  }
396
397  
398/**
399   * Creates and returns a deep copy of this {@link ColorDefinition} object.
400   <p>
401   * @return a (deep) copy of this {@link ColorDefinition} object
402   */ public
403 ColorDefinition cloneObject() {
404    long cPtr = libsbmlJNI.ColorDefinition_cloneObject(swigCPtr, this);
405    return (cPtr == 0) ? null : new ColorDefinition(cPtr, true);
406  }
407
408  
409/**
410   * Returns the XML element name of this object.
411   <p>
412   * This is overridden by subclasses to return a string appropriate to the
413   * SBML component.  For example, {@link Model} defines it as returning 'model',
414   * {@link CompartmentType} defines it as returning 'compartmentType', etc.
415   */ public
416 String getElementName() {
417    return libsbmlJNI.ColorDefinition_getElementName(swigCPtr, this);
418  }
419
420  
421/**
422   * Returns the libSBML type code for this SBML object.
423   <p>
424   * LibSBML attaches an
425   * identifying code to every kind of SBML object.  These are known as
426   * <em>SBML type codes</em>.  In other languages, the set of type codes
427   * is stored in an enumeration; in the Java language interface for
428   * libSBML, the type codes are defined as static integer constants in
429   * interface class {@link libsbmlConstants}.  The names of the type codes
430   * all begin with the characters <code>SBML_.</code> 
431   <p>
432   * @return the SBML type code for this object, or <code>SBML_UNKNOWN</code> (default).
433   <p>
434   * @see #getElementName()
435   */ public
436 int getTypeCode() {
437    return libsbmlJNI.ColorDefinition_getTypeCode(swigCPtr, this);
438  }
439
440  
441/**
442   * Creates an {@link XMLNode} object from this {@link ColorDefinition} object.
443   <p>
444   * @return the {@link XMLNode} with the XML representation for the 
445   * {@link ColorDefinition} object.
446   */ public
447 XMLNode toXML() {
448    return new XMLNode(libsbmlJNI.ColorDefinition_toXML(swigCPtr, this), true);
449  }
450
451  
452/**
453   * Returns the value of the 'id' attribute of this {@link ColorDefinition}.
454   <p>
455   * @return the id of the {@link ColorDefinition}
456   */ public
457 String getId() {
458    return libsbmlJNI.ColorDefinition_getId(swigCPtr, this);
459  }
460
461  
462/**
463   * Predicate returning <code>true</code> or <code>false</code> depending on whether this
464   * GraphicalPrimitive's 'id' attribute has been set.
465   <p>
466   * @return returns true or false depending on whether the id on the 
467   * GraphicalPrimitive has been set.
468   */ public
469 boolean isSetId() {
470    return libsbmlJNI.ColorDefinition_isSetId(swigCPtr, this);
471  }
472
473  
474/**
475   * Sets the value of the 'id' attribute of this GraphicalPrimitive.
476   <p>
477   * @param id the new id for the GraphicalPrimitive 
478   <p>
479   * @return status if the operation succeeded
480   */ public
481 int setId(String id) {
482    return libsbmlJNI.ColorDefinition_setId(swigCPtr, this, id);
483  }
484
485  
486/**
487   * Unsets the value of the 'id' attribute of this {@link ColorDefinition}.
488   */ public
489 int unsetId() {
490    return libsbmlJNI.ColorDefinition_unsetId(swigCPtr, this);
491  }
492
493  
494/** * @internal */ public
495 boolean hasRequiredAttributes() {
496    return libsbmlJNI.ColorDefinition_hasRequiredAttributes(swigCPtr, this);
497  }
498
499  
500/** * @internal */ public
501 boolean hasRequiredElements() {
502    return libsbmlJNI.ColorDefinition_hasRequiredElements(swigCPtr, this);
503  }
504
505}