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 * 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 explicitly.
140   <p>
141   * (FOR BACKWARD COMPATIBILITY)
142   <p>
143   * @param node the {@link XMLNode} object reference that describes the {@link ColorDefinition}
144   * object to be instantiated.
145   */ public
146 ColorDefinition(XMLNode node, long l2version) throws org.sbml.libsbml.SBMLConstructorException {
147    this(libsbmlJNI.new_ColorDefinition__SWIG_5(XMLNode.getCPtr(node), node, l2version), true);
148  }
149
150  
151/**
152   * Creates a new {@link ColorDefinition} object from the given {@link XMLNode} object.
153   * The {@link XMLNode} object has to contain a valid XML representation of a 
154   * {@link ColorDefinition} object as defined in the render extension specification.
155   * This method is normally called when render information is read from a file and 
156   * should normally not have to be called explicitly.
157   <p>
158   * (FOR BACKWARD COMPATIBILITY)
159   <p>
160   * @param node the {@link XMLNode} object reference that describes the {@link ColorDefinition}
161   * object to be instantiated.
162   */ public
163 ColorDefinition(XMLNode node) throws org.sbml.libsbml.SBMLConstructorException {
164    this(libsbmlJNI.new_ColorDefinition__SWIG_6(XMLNode.getCPtr(node), node), true);
165  }
166
167  
168/**
169   * Constructor which sets the {@link ColorDefinition} to the given RGBA values.
170   <p>
171   * @param r Red component value. Has to be in the range of 0 to 255.
172   * @param g Green component value. Has to be in the range of 0 to 255.
173   * @param b Blue component value. Has to be in the range of 0 to 255.
174   * @param a Alpha component value. Has to be in the range of 0 to 255. 
175   * The alpha component can be omitted. In that case it has a default value of 255.
176   <p>
177   * This constructor is deprecated. The new libsbml API only has
178   * constructors which take the SBML level and version or one that takes
179   * an {@link SBMLNamespaces} object.
180   */ public
181 ColorDefinition(RenderPkgNamespaces renderns, short r, short g, short b, short a) throws org.sbml.libsbml.SBMLConstructorException {
182    this(libsbmlJNI.new_ColorDefinition__SWIG_7(RenderPkgNamespaces.getCPtr(renderns), renderns, r, g, b, a), true);
183  }
184
185  
186/**
187   * Constructor which sets the {@link ColorDefinition} to the given RGBA values.
188   <p>
189   * @param r Red component value. Has to be in the range of 0 to 255.
190   * @param g Green component value. Has to be in the range of 0 to 255.
191   * @param b Blue component value. Has to be in the range of 0 to 255.
192   * @param a Alpha component value. Has to be in the range of 0 to 255. 
193   * The alpha component can be omitted. In that case it has a default value of 255.
194   <p>
195   * This constructor is deprecated. The new libsbml API only has
196   * constructors which take the SBML level and version or one that takes
197   * an {@link SBMLNamespaces} object.
198   */ public
199 ColorDefinition(RenderPkgNamespaces renderns, short r, short g, short b) throws org.sbml.libsbml.SBMLConstructorException {
200    this(libsbmlJNI.new_ColorDefinition__SWIG_8(RenderPkgNamespaces.getCPtr(renderns), renderns, r, g, b), true);
201  }
202
203  
204/**
205   * Constructor which sets the {@link ColorDefinition} to completely opaque
206   * black and sets the id to the given string.
207   <p>
208   * @param id the id of the color definition. The user has to make sure 
209   * that the id is unique within the given set of color definitions. 
210   <p>
211   * This constructor is deprecated. The new libsbml API only has
212   * constructors which take the SBML level and version or one that takes
213   * an {@link SBMLNamespaces} object.
214   */ public
215 ColorDefinition(RenderPkgNamespaces renderns, String id) throws org.sbml.libsbml.SBMLConstructorException {
216    this(libsbmlJNI.new_ColorDefinition__SWIG_9(RenderPkgNamespaces.getCPtr(renderns), renderns, id), true);
217  }
218
219  
220/**
221   * Constructor which sets the {@link ColorDefinition} to the given RGBA values
222   * and sets the id.
223   <p>
224   * @param id the id of the color definition. The user has to make sure 
225   * that the id is unique within the given set of color definitions. 
226   * @param r Red component value. Has to be in the range of 0 to 255.
227   * @param g Green component value. Has to be in the range of 0 to 255.
228   * @param b Blue component value. Has to be in the range of 0 to 255.
229   * @param a Alpha component value. Has to be in the range of 0 to 255. 
230   * The alpha component can be omitted. In that case it has a default value of 255.
231   <p>
232   * This constructor is deprecated. The new libsbml API only has
233   * constructors which take the SBML level and version or one that takes
234   * an {@link SBMLNamespaces} object.
235   */ public
236 ColorDefinition(RenderPkgNamespaces renderns, String id, short r, short g, short b, short a) throws org.sbml.libsbml.SBMLConstructorException {
237    this(libsbmlJNI.new_ColorDefinition__SWIG_10(RenderPkgNamespaces.getCPtr(renderns), renderns, id, r, g, b, a), true);
238  }
239
240  
241/**
242   * Constructor which sets the {@link ColorDefinition} to the given RGBA values
243   * and sets the id.
244   <p>
245   * @param id the id of the color definition. The user has to make sure 
246   * that the id is unique within the given set of color definitions. 
247   * @param r Red component value. Has to be in the range of 0 to 255.
248   * @param g Green component value. Has to be in the range of 0 to 255.
249   * @param b Blue component value. Has to be in the range of 0 to 255.
250   * @param a Alpha component value. Has to be in the range of 0 to 255. 
251   * The alpha component can be omitted. In that case it has a default value of 255.
252   <p>
253   * This constructor is deprecated. The new libsbml API only has
254   * constructors which take the SBML level and version or one that takes
255   * an {@link SBMLNamespaces} object.
256   */ public
257 ColorDefinition(RenderPkgNamespaces renderns, String id, short r, short g, short b) throws org.sbml.libsbml.SBMLConstructorException {
258    this(libsbmlJNI.new_ColorDefinition__SWIG_11(RenderPkgNamespaces.getCPtr(renderns), renderns, id, r, g, b), true);
259  }
260
261  
262/**
263   * Returns the red color component.
264   <p>
265   * @return the red color component for the {@link ColorDefinition}.
266   */ public
267 short getRed() {
268    return libsbmlJNI.ColorDefinition_getRed(swigCPtr, this);
269  }
270
271  
272/**
273   * Returns the green color component.
274   <p>
275   * @return the green color component for the {@link ColorDefinition}.
276   */ public
277 short getGreen() {
278    return libsbmlJNI.ColorDefinition_getGreen(swigCPtr, this);
279  }
280
281  
282/**
283   * Returns the blue color component.
284   <p>
285   * @return the blue color component for the {@link ColorDefinition}.
286   */ public
287 short getBlue() {
288    return libsbmlJNI.ColorDefinition_getBlue(swigCPtr, this);
289  }
290
291  
292/**
293   * Returns the alpha color component.
294   <p>
295   * @return the alpha color component for the {@link ColorDefinition}.
296   */ public
297 short getAlpha() {
298    return libsbmlJNI.ColorDefinition_getAlpha(swigCPtr, this);
299  }
300
301  
302/**
303   * Sets the red color component.
304   <p>
305   * @param c the new red component value for the color definition.
306   */ public
307 void setRed(short c) {
308    libsbmlJNI.ColorDefinition_setRed(swigCPtr, this, c);
309  }
310
311  
312/**
313   * Sets the green color component.
314   <p>
315   * @param c the new green component value for the color definition.
316   */ public
317 void setGreen(short c) {
318    libsbmlJNI.ColorDefinition_setGreen(swigCPtr, this, c);
319  }
320
321  
322/**
323   * Sets the blue color component.
324   <p>
325   * @param c the new blue component value for the color definition.
326   */ public
327 void setBlue(short c) {
328    libsbmlJNI.ColorDefinition_setBlue(swigCPtr, this, c);
329  }
330
331  
332/**
333   * Sets alpha red color component.
334   <p>
335   * @param c the new alpha component value for the color definition.
336   */ public
337 void setAlpha(short c) {
338    libsbmlJNI.ColorDefinition_setAlpha(swigCPtr, this, c);
339  }
340
341  
342/**
343   * Sets the red green, blue and alpha color component.
344   * The alpha value is optional and defaults to 255 if not given.
345   * @param r Red component value. Has to be in the range of 0 to 255.
346   * @param g Green component value. Has to be in the range of 0 to 255.
347   * @param b Blue component value. Has to be in the range of 0 to 255.
348   * @param a Alpha component value. Has to be in the range of 0 to 255. 
349   * The alpha component can be omitted. In that case it has a default value of 255.
350   */ public
351 void setRGBA(short r, short g, short b, short a) {
352    libsbmlJNI.ColorDefinition_setRGBA__SWIG_0(swigCPtr, this, r, g, b, a);
353  }
354
355  
356/**
357   * Sets the red green, blue and alpha color component.
358   * The alpha value is optional and defaults to 255 if not given.
359   * @param r Red component value. Has to be in the range of 0 to 255.
360   * @param g Green component value. Has to be in the range of 0 to 255.
361   * @param b Blue component value. Has to be in the range of 0 to 255.
362   * @param a Alpha component value. Has to be in the range of 0 to 255. 
363   * The alpha component can be omitted. In that case it has a default value of 255.
364   */ public
365 void setRGBA(short r, short g, short b) {
366    libsbmlJNI.ColorDefinition_setRGBA__SWIG_1(swigCPtr, this, r, g, b);
367  }
368
369  
370/**
371   * Sets the color value from a given value string.
372   * If the string is not a valid value string, the color value is set to
373   * black and false is returned.
374   <p>
375   * @param valueString A  reference to a string that represents a valid color value,
376   * e.g. '#FFFFFFFF' for fully opaque white.
377   <p>
378   * @return true or false depending on whether setting the color value from the string
379   * was successfull.
380   */ public
381 boolean setColorValue(String valueString) {
382    return libsbmlJNI.ColorDefinition_setColorValue(swigCPtr, this, valueString);
383  }
384
385  
386/**
387   * Creates a string the represents the current color value.
388   <p>
389   * @return The string representation of the color value.
390   */ public
391 String createValueString() {
392    return libsbmlJNI.ColorDefinition_createValueString(swigCPtr, this);
393  }
394
395  
396/**
397   * Creates and returns a deep copy of this {@link ColorDefinition} object.
398   <p>
399   * @return a (deep) copy of this {@link ColorDefinition} object
400   */ public
401 ColorDefinition cloneObject() {
402    long cPtr = libsbmlJNI.ColorDefinition_cloneObject(swigCPtr, this);
403    return (cPtr == 0) ? null : new ColorDefinition(cPtr, true);
404  }
405
406  
407/**
408   * Returns the XML element name of this object.
409   <p>
410   * This is overridden by subclasses to return a string appropriate to the
411   * SBML component.  For example, {@link Model} defines it as returning 'model',
412   * {@link CompartmentType} defines it as returning 'compartmentType', etc.
413   */ public
414 String getElementName() {
415    return libsbmlJNI.ColorDefinition_getElementName(swigCPtr, this);
416  }
417
418  
419/**
420   * Returns the libSBML type code for this SBML object.
421   <p>
422   * LibSBML attaches an
423   * identifying code to every kind of SBML object.  These are known as
424   * <em>SBML type codes</em>.  In other languages, the set of type codes
425   * is stored in an enumeration; in the Java language interface for
426   * libSBML, the type codes are defined as static integer constants in
427   * interface class {@link libsbmlConstants}.  The names of the type codes
428   * all begin with the characters <code>SBML_.</code> 
429   <p>
430   * @return the SBML type code for this object, or <code>SBML_UNKNOWN</code> (default).
431   <p>
432   * @see #getElementName()
433   */ public
434 int getTypeCode() {
435    return libsbmlJNI.ColorDefinition_getTypeCode(swigCPtr, this);
436  }
437
438  
439/**
440   * Creates an {@link XMLNode} object from this {@link ColorDefinition} object.
441   <p>
442   * @return the {@link XMLNode} with the XML representation for the 
443   * {@link ColorDefinition} object.
444   */ public
445 XMLNode toXML() {
446    return new XMLNode(libsbmlJNI.ColorDefinition_toXML(swigCPtr, this), true);
447  }
448
449  
450/**
451   * Returns the value of the 'id' attribute of this {@link ColorDefinition}.
452   <p>
453   * @return the id of the {@link ColorDefinition}
454   */ public
455 String getId() {
456    return libsbmlJNI.ColorDefinition_getId(swigCPtr, this);
457  }
458
459  
460/**
461   * Predicate returning <code>true</code> or <code>false</code> depending on whether this
462   * GraphicalPrimitive's 'id' attribute has been set.
463   <p>
464   * @return returns true or false depending on whether the id on the 
465   * GraphicalPrimitive has been set.
466   */ public
467 boolean isSetId() {
468    return libsbmlJNI.ColorDefinition_isSetId(swigCPtr, this);
469  }
470
471  
472/**
473   * Sets the value of the 'id' attribute of this GraphicalPrimitive.
474   <p>
475   * @param id the new id for the GraphicalPrimitive 
476   <p>
477   * @return status if the operation succeeded
478   */ public
479 int setId(String id) {
480    return libsbmlJNI.ColorDefinition_setId(swigCPtr, this, id);
481  }
482
483  
484/**
485   * Unsets the value of the 'id' attribute of this {@link ColorDefinition}.
486   */ public
487 int unsetId() {
488    return libsbmlJNI.ColorDefinition_unsetId(swigCPtr, this);
489  }
490
491  
492/** * @internal */ public
493 boolean hasRequiredAttributes() {
494    return libsbmlJNI.ColorDefinition_hasRequiredAttributes(swigCPtr, this);
495  }
496
497  
498/** * @internal */ public
499 boolean hasRequiredElements() {
500    return libsbmlJNI.ColorDefinition_hasRequiredElements(swigCPtr, this);
501  }
502
503}