From: <and...@us...> - 2012-05-15 07:43:14
|
Revision: 1257 http://jsbml.svn.sourceforge.net/jsbml/?rev=1257&view=rev Author: andreas-draeger Date: 2012-05-15 07:43:01 +0000 (Tue, 15 May 2012) Log Message: ----------- - Updated the version number in the trunk version of JSBML 1.0-rc1 because the previous value 0.8-rc1 was not appropriate anymore. - SBML Layout extension contained bugs that caused endless recursion when trying to access referenced instances of NamedSBase from a glyph (such as CompartmentGlyph, SpeciesGlyph etc.). - The pow function in the formula compiler was not working properly. - Added more convenient methods for Unit manipulation on ASTNode. Unit checks should be unified in all classes that can be associated with units. Currently, JSBML has three different implementations of the identical check. Modified Paths: -------------- trunk/core/NEWS.txt trunk/core/src/org/sbml/jsbml/ASTNode.java trunk/core/src/org/sbml/jsbml/AbstractNamedSBaseWithUnit.java trunk/core/src/org/sbml/jsbml/JSBML.java trunk/core/src/org/sbml/jsbml/KineticLaw.java trunk/core/src/org/sbml/jsbml/Unit.java trunk/core/src/org/sbml/jsbml/util/compilers/FindUnitsCompiler.java trunk/core/src/org/sbml/jsbml/util/compilers/FormulaCompiler.java trunk/core/src/org/sbml/jsbml/util/compilers/FormulaCompilerNoPiecewise.java trunk/core/src/org/sbml/jsbml/util/compilers/MathMLXMLStreamCompiler.java trunk/core/src/org/sbml/jsbml/util/filters/NameFilter.java trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/CompartmentGlyph.java trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/ExtendedLayoutModel.java trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Layout.java trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/ReactionGlyph.java trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesGlyph.java trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesReferenceGlyph.java trunk/modules/celldesigner/src/org/sbml/jsbml/cdplugin/PluginChangeListener.java Modified: trunk/core/NEWS.txt =================================================================== --- trunk/core/NEWS.txt 2012-05-14 12:02:32 UTC (rev 1256) +++ trunk/core/NEWS.txt 2012-05-15 07:43:01 UTC (rev 1257) @@ -57,6 +57,10 @@ * Bug Fixes: + - SBML Layout extension contained bugs that caused endless recursion when + trying to access referenced instances of NamedSBase from a glyph (such + as CompartmentGlyph, SpeciesGlyph etc.). + - It was sometimes possible to unregister elements from a model that were the result of cloning, removal of the original entry and linking the clone to the model. When altering the previous element, pointers were deleted Modified: trunk/core/src/org/sbml/jsbml/ASTNode.java =================================================================== --- trunk/core/src/org/sbml/jsbml/ASTNode.java 2012-05-14 12:02:32 UTC (rev 1256) +++ trunk/core/src/org/sbml/jsbml/ASTNode.java 2012-05-15 07:43:01 UTC (rev 1257) @@ -3541,6 +3541,22 @@ this.unitId = unitId; this.firePropertyChange(TreeNodeChangeEvent.units, oldValue, unitId); } + + /** + * + * @param unit + */ + public void setUnits(Unit.Kind unit) { + setUnits(unit.toString().toLowerCase()); + } + + /** + * + * @param ud + */ + public void setUnits(UnitDefinition ud) { + setUnits(ud.getId()); + } /** * Sets the value of this ASTNode to the given double number and sets the Modified: trunk/core/src/org/sbml/jsbml/AbstractNamedSBaseWithUnit.java =================================================================== --- trunk/core/src/org/sbml/jsbml/AbstractNamedSBaseWithUnit.java 2012-05-14 12:02:32 UTC (rev 1256) +++ trunk/core/src/org/sbml/jsbml/AbstractNamedSBaseWithUnit.java 2012-05-15 07:43:01 UTC (rev 1257) @@ -20,6 +20,8 @@ package org.sbml.jsbml; +import java.text.MessageFormat; + import org.sbml.jsbml.Unit.Kind; import org.sbml.jsbml.util.TreeNodeChangeEvent; @@ -262,7 +264,7 @@ if ((units != null) && (units.trim().length() == 0)) { units = null; // If we pass the empty String or null, the value is reset. } - + // TODO: Use the method Units.isValidUnit here! String oldUnits = this.unitsID; if (units == null) { unitsID = null; @@ -284,7 +286,7 @@ } } if (illegalArgument) { - throw new IllegalArgumentException(String.format( + throw new IllegalArgumentException(MessageFormat.format( JSBML.ILLEGAL_UNIT_EXCEPTION_MSG, units)); } } Modified: trunk/core/src/org/sbml/jsbml/JSBML.java =================================================================== --- trunk/core/src/org/sbml/jsbml/JSBML.java 2012-05-14 12:02:32 UTC (rev 1256) +++ trunk/core/src/org/sbml/jsbml/JSBML.java 2012-05-15 07:43:01 UTC (rev 1257) @@ -49,7 +49,7 @@ * Error message for the case that an invalid unit identifier is to be added * to this object. */ - public static final String ILLEGAL_UNIT_EXCEPTION_MSG = "Cannot identify unit %s in the model. Only a valid unit kind or the identifier of an existing unit definition are allowed."; + public static final String ILLEGAL_UNIT_EXCEPTION_MSG = "Cannot identify unit {0} in the model. Only a valid unit kind or the identifier of an existing unit definition are allowed."; public static final int INDEX_EXCEEDS_SIZE = -1; public static final int INVALID_ATTRIBUTE_VALUE = -4; public static final int INVALID_OBJECT = -5; @@ -57,7 +57,7 @@ /** * The current version number of JSBML. */ - private static final String jsbmlVersion = "0.8-rc1"; // TODO : replace automatically this version number with [BUILD.NUMBER] + private static final String jsbmlVersion = "1.0-rc1"; // TODO : replace automatically this version number with [BUILD.NUMBER] public static final int LEVEL_MISMATCH = -7; public static final int OPERATION_FAILED = -3; Modified: trunk/core/src/org/sbml/jsbml/KineticLaw.java =================================================================== --- trunk/core/src/org/sbml/jsbml/KineticLaw.java 2012-05-14 12:02:32 UTC (rev 1256) +++ trunk/core/src/org/sbml/jsbml/KineticLaw.java 2012-05-15 07:43:01 UTC (rev 1257) @@ -20,6 +20,7 @@ package org.sbml.jsbml; +import java.text.MessageFormat; import java.util.HashMap; import java.util.Map; @@ -856,6 +857,7 @@ @Deprecated public void setUnits(String units) { String oldUnits = this.unitsID; + // TODO: Use the method Units.isValidUnit here! if (units == null) { unitsID = null; } else { @@ -874,7 +876,7 @@ } } if (illegalArgument) { - throw new IllegalArgumentException(String.format( + throw new IllegalArgumentException(MessageFormat.format( JSBML.ILLEGAL_UNIT_EXCEPTION_MSG, units)); } } Modified: trunk/core/src/org/sbml/jsbml/Unit.java =================================================================== --- trunk/core/src/org/sbml/jsbml/Unit.java 2012-05-14 12:02:32 UTC (rev 1256) +++ trunk/core/src/org/sbml/jsbml/Unit.java 2012-05-15 07:43:01 UTC (rev 1257) @@ -1005,7 +1005,7 @@ public static boolean isValidUnit(Model model, String unit) { boolean isValidUnit = false; - if (unit != null && model != null) { + if ((unit != null) && (model != null)) { unit = unit.trim(); if (unit.length() > 0) { if (Kind.isValidUnitKindString(unit, model.getLevel(), model @@ -1015,7 +1015,7 @@ isValidUnit = true; } } - } else if (model == null && unit != null) { + } else if ((model == null) && (unit != null)) { isValidUnit = true; } Modified: trunk/core/src/org/sbml/jsbml/util/compilers/FindUnitsCompiler.java =================================================================== --- trunk/core/src/org/sbml/jsbml/util/compilers/FindUnitsCompiler.java 2012-05-14 12:02:32 UTC (rev 1256) +++ trunk/core/src/org/sbml/jsbml/util/compilers/FindUnitsCompiler.java 2012-05-15 07:43:01 UTC (rev 1257) @@ -185,7 +185,7 @@ */ public ASTNodeValue compile(double mantissa, int exponent, String units) { - if (units != null && units.length() > 0) { + if ((units != null) && (units.length() > 0)) { isUnitsDefined = true; throw new SBMLException("Stopping the recursion, a units has been found and the SBML namespace is needed."); } @@ -198,7 +198,7 @@ */ public ASTNodeValue compile(double real, String units) { - if (units != null && units.length() > 0) { + if ((units != null) && (units.length() > 0)) { isUnitsDefined = true; throw new SBMLException("Stopping the recursion, a units has been found and the SBML namespace is needed."); } @@ -211,7 +211,7 @@ */ public ASTNodeValue compile(int integer, String units) { - if (units != null && units.length() > 0) { + if ((units != null) && (units.length() > 0)) { isUnitsDefined = true; throw new SBMLException("Stopping the recursion, a units has been found and the SBML namespace is needed."); } Modified: trunk/core/src/org/sbml/jsbml/util/compilers/FormulaCompiler.java =================================================================== --- trunk/core/src/org/sbml/jsbml/util/compilers/FormulaCompiler.java 2012-05-14 12:02:32 UTC (rev 1256) +++ trunk/core/src/org/sbml/jsbml/util/compilers/FormulaCompiler.java 2012-05-15 07:43:01 UTC (rev 1257) @@ -262,163 +262,106 @@ return arith('*', factors); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#abs(org.sbml.jsbml.ASTNode) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#abs(org.sbml.jsbml.ASTNode) */ public ASTNodeValue abs(ASTNode node) throws SBMLException { return function("abs", node); } - /* - * (non-Javadoc) - * + /* (non-Javadoc) * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#and(java.util.List) */ public ASTNodeValue and(List<ASTNode> nodes) throws SBMLException { return logicalOperation(" and ", nodes); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccos(org.sbml.jsbml.ASTNode - * ) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccos(org.sbml.jsbml.ASTNode) */ public ASTNodeValue arccos(ASTNode node) throws SBMLException { return function("acos", node); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccosh(org.sbml.jsbml. - * ASTNode) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccosh(org.sbml.jsbml.ASTNode) */ public ASTNodeValue arccosh(ASTNode node) throws SBMLException { return function("acosh", node); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccot(org.sbml.jsbml.ASTNode - * ) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccot(org.sbml.jsbml.ASTNode) */ public ASTNodeValue arccot(ASTNode node) throws SBMLException { return function("acot", node); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccoth(org.sbml.jsbml. - * ASTNode) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccoth(org.sbml.jsbml.ASTNode) */ public ASTNodeValue arccoth(ASTNode node) throws SBMLException { return function("acoth", node); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccsc(org.sbml.jsbml.ASTNode - * ) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccsc(org.sbml.jsbml.ASTNode) */ public ASTNodeValue arccsc(ASTNode node) throws SBMLException { return function("acsc", node); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccsch(org.sbml.jsbml. - * ASTNode) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccsch(org.sbml.jsbml.ASTNode) */ public ASTNodeValue arccsch(ASTNode node) throws SBMLException { return function("acsch", node); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arcsec(org.sbml.jsbml.ASTNode - * ) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arcsec(org.sbml.jsbml.ASTNode) */ public ASTNodeValue arcsec(ASTNode node) throws SBMLException { return function("asec", node); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arcsech(org.sbml.jsbml. - * ASTNode) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arcsech(org.sbml.jsbml.ASTNode) */ public ASTNodeValue arcsech(ASTNode node) throws SBMLException { return function("asech", node); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arcsin(org.sbml.jsbml.ASTNode - * ) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arcsin(org.sbml.jsbml.ASTNode) */ public ASTNodeValue arcsin(ASTNode node) throws SBMLException { return function("asin", node); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arcsinh(org.sbml.jsbml. - * ASTNode) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arcsinh(org.sbml.jsbml.ASTNode) */ public ASTNodeValue arcsinh(ASTNode node) throws SBMLException { return function("asinh", node); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arctan(org.sbml.jsbml.ASTNode - * ) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arctan(org.sbml.jsbml.ASTNode) */ public ASTNodeValue arctan(ASTNode node) throws SBMLException { return function("atan", node); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arctanh(org.sbml.jsbml. - * ASTNode) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arctanh(org.sbml.jsbml.ASTNode) */ public ASTNodeValue arctanh(ASTNode node) throws SBMLException { return function("atanh", node); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#ceiling(org.sbml.jsbml. - * ASTNode) + /* (non-Javadoc) + * @seeorg.sbml.jsbml.util.compilers.ASTNodeCompiler#ceiling(org.sbml.jsbml.ASTNode) */ public ASTNodeValue ceiling(ASTNode node) throws SBMLException { return function("ceil", node); @@ -437,7 +380,7 @@ if (node.isSum() || node.isDifference() || node.isUMinus()) { term = brackets(term).toString(); } else if (node.isReal()) { - if (node.getReal() < 0.0) { + if (node.getReal() < 0d) { term = brackets(term).toString(); } } @@ -453,30 +396,27 @@ * @throws SBMLException */ private String checkDenominatorBrackets(ASTNode nodes) throws SBMLException { - String term = nodes.compile(this).toString(); - if (nodes.isSum() || nodes.isDifference() || nodes.isUMinus() - || nodes.getType() == Type.TIMES) { - term = brackets(term).toString(); - } - return term; + if ((nodes.getType() == Type.POWER) && (nodes.getChildCount() > 1) + && nodes.getRightChild().toString().equals("1")) { + return checkDenominatorBrackets(nodes.getLeftChild()); + } + String term = nodes.compile(this).toString(); + if (nodes.isSum() || nodes.isDifference() || nodes.isUMinus() + || (nodes.getType() == Type.TIMES)) { + term = brackets(term).toString(); + } + return term; } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(org.sbml.jsbml. - * Compartment) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(org.sbml.jsbml.Compartment) */ public ASTNodeValue compile(Compartment c) { return new ASTNodeValue(c.getId(), this); } - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(double, int, - * java.lang.String) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(double, int, java.lang.String) */ public ASTNodeValue compile(double mantissa, int exponent, String units) { if (exponent == 0) { @@ -489,113 +429,78 @@ .format(mantissa), "E", exponent).toString(), this); } - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(double, - * java.lang.String) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(double, java.lang.String) */ public ASTNodeValue compile(double real, String units) { return new ASTNodeValue(toString(Locale.ENGLISH, real), this); } - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(int, - * java.lang.String) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(int, java.lang.String) */ public ASTNodeValue compile(int integer, String units) { return new ASTNodeValue(integer, this); } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(org.sbml.jsbml.CallableSBase) */ public ASTNodeValue compile(CallableSBase variable) { return new ASTNodeValue(variable.getId(), this); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(java.lang.String) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(java.lang.String) */ public ASTNodeValue compile(String name) { return new ASTNodeValue(name, this); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#cos(org.sbml.jsbml.ASTNode) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#cos(org.sbml.jsbml.ASTNode) */ public ASTNodeValue cos(ASTNode node) throws SBMLException { return function("cos", node); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#cosh(org.sbml.jsbml.ASTNode - * ) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#cosh(org.sbml.jsbml.ASTNode) */ public ASTNodeValue cosh(ASTNode node) throws SBMLException { return function("cosh", node); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#cot(org.sbml.jsbml.ASTNode) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#cot(org.sbml.jsbml.ASTNode) */ public ASTNodeValue cot(ASTNode node) throws SBMLException { return function("cot", node); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#coth(org.sbml.jsbml.ASTNode - * ) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#coth(org.sbml.jsbml.ASTNode) */ public ASTNodeValue coth(ASTNode node) throws SBMLException { return function("coth", node); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#csc(org.sbml.jsbml.ASTNode) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#csc(org.sbml.jsbml.ASTNode) */ public ASTNodeValue csc(ASTNode node) throws SBMLException { return function("csc", node); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#csch(org.sbml.jsbml.ASTNode - * ) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#csch(org.sbml.jsbml.ASTNode) */ public ASTNodeValue csch(ASTNode node) throws SBMLException { return function("csch", node); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#delay(java.lang.String, - * org.sbml.jsbml.ASTNode, double, java.lang.String) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#delay(java.lang.String, org.sbml.jsbml.ASTNode, double, java.lang.String) */ public ASTNodeValue delay(String delayName, ASTNode x, ASTNode y, String timeUnits) throws SBMLException { @@ -603,33 +508,22 @@ y.compile(this), ")").toString(), this); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#eq(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#eq(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) */ public ASTNodeValue eq(ASTNode left, ASTNode right) throws SBMLException { return new ASTNodeValue(relation(left, " == ", right), this); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#exp(org.sbml.jsbml.ASTNode) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#exp(org.sbml.jsbml.ASTNode) */ public ASTNodeValue exp(ASTNode node) throws SBMLException { return function("exp", node); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#factorial(org.sbml.jsbml - * .ASTNode) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#factorial(org.sbml.jsbml.ASTNode) */ public ASTNodeValue factorial(ASTNode node) { return new ASTNodeValue(append(brackets(node), Character.valueOf('!')) @@ -638,32 +532,25 @@ /* * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#floor(org.sbml.jsbml.ASTNode - * ) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#floor(org.sbml.jsbml.ASTNode) */ public ASTNodeValue floor(ASTNode node) throws SBMLException { return function("floor", node); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#frac(org.sbml.jsbml.ASTNode - * , org.sbml.jsbml.ASTNode) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#frac(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) */ public ASTNodeValue frac(ASTNode numerator, ASTNode denominator) throws SBMLException { - return new ASTNodeValue(concat(checkBrackets(numerator), - Character.valueOf('/'), checkDenominatorBrackets(denominator)) - .toString(), this); + return new ASTNodeValue( + concat(checkBrackets(numerator), + Character.valueOf('/'), + checkDenominatorBrackets(denominator)).toString(), + this); } - /* - * (non-Javadoc) - * + /* (non-Javadoc) * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#frac(int, int) */ public ASTNodeValue frac(int numerator, int denominator) { @@ -675,12 +562,8 @@ : compile(denominator, null)).toString(), this); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#function(org.sbml.jsbml - * .FunctionDefinition, java.util.List) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#function(org.sbml.jsbml.FunctionDefinition, java.util.List) */ public ASTNodeValue function(FunctionDefinition func, List<ASTNode> nodes) throws SBMLException { @@ -718,96 +601,70 @@ .toString(), this); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#geq(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#geq(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) */ public ASTNodeValue geq(ASTNode left, ASTNode right) throws SBMLException { return new ASTNodeValue(relation(left, " >= ", right), this); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#getConstantAvogadro(java - * .lang.String) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#getConstantAvogadro(java.lang.String) */ public ASTNodeValue getConstantAvogadro(String name) { return new ASTNodeValue("avogadro", this); } - /* - * (non-Javadoc) - * + /* (non-Javadoc) * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#getConstantE() */ public ASTNodeValue getConstantE() { return new ASTNodeValue(Character.toString('e'), this); } - /* - * (non-Javadoc) - * + /* (non-Javadoc) * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#getConstantFalse() */ public ASTNodeValue getConstantFalse() { return new ASTNodeValue(false, this); } - /* - * (non-Javadoc) - * + /* (non-Javadoc) * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#getConstantPi() */ public ASTNodeValue getConstantPi() { return new ASTNodeValue("pi", this); } - /* - * (non-Javadoc) - * + /* (non-Javadoc) * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#getConstantTrue() */ public ASTNodeValue getConstantTrue() { return new ASTNodeValue(true, this); } - /* - * (non-Javadoc) - * + /* (non-Javadoc) * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#getNegativeInfinity() */ public ASTNodeValue getNegativeInfinity() { return new ASTNodeValue(Double.NEGATIVE_INFINITY, this); } - /* - * (non-Javadoc) - * + /* (non-Javadoc) * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#getPositiveInfinity() */ public ASTNodeValue getPositiveInfinity() { return new ASTNodeValue(Double.POSITIVE_INFINITY, this); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#gt(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#gt(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) */ public ASTNodeValue gt(ASTNode left, ASTNode right) throws SBMLException { return new ASTNodeValue(relation(left, " > ", right), this); } - /* - * (non-Javadoc) - * + /* (non-Javadoc) * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#lambda(java.util.List) */ public ASTNodeValue lambda(List<ASTNode> nodes) throws SBMLException { @@ -835,43 +692,29 @@ return lambda.toString(); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#leq(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#leq(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) */ public ASTNodeValue leq(ASTNode left, ASTNode right) throws SBMLException { return new ASTNodeValue(relation(left, " <= ", right), this); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#ln(org.sbml.jsbml.ASTNode) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#ln(org.sbml.jsbml.ASTNode) */ public ASTNodeValue ln(ASTNode node) throws SBMLException { return function("log", node); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#log(org.sbml.jsbml.ASTNode) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#log(org.sbml.jsbml.ASTNode) */ public ASTNodeValue log(ASTNode node) throws SBMLException { return function("log10", node); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#log(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#log(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) */ public ASTNodeValue log(ASTNode left, ASTNode right) throws SBMLException { return function("log", left, right); @@ -904,20 +747,14 @@ return new ASTNodeValue(value.toString(), this); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#lt(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#lt(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) */ public ASTNodeValue lt(ASTNode left, ASTNode right) throws SBMLException { return new ASTNodeValue(relation(left, " < ", right), this); } - /* - * (non-Javadoc) - * + /* (non-Javadoc) * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#minus(java.util.List) */ public ASTNodeValue minus(List<ASTNode> nodes) throws SBMLException { @@ -939,49 +776,35 @@ } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#neq(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#neq(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) */ public ASTNodeValue neq(ASTNode left, ASTNode right) throws SBMLException { return new ASTNodeValue(relation(left, " != ", right), this); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#not(org.sbml.jsbml.ASTNode) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#not(org.sbml.jsbml.ASTNode) */ public ASTNodeValue not(ASTNode node) throws SBMLException { return function("not", node); } - /* - * (non-Javadoc) - * + /* (non-Javadoc) * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#or(java.util.List) */ public ASTNodeValue or(List<ASTNode> nodes) throws SBMLException { return logicalOperation(" or ", nodes); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#piecewise(java.util.List) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#piecewise(java.util.List) */ public ASTNodeValue piecewise(List<ASTNode> nodes) throws SBMLException { return function("piecewise", nodes); } - /* - * (non-Javadoc) - * + /* (non-Javadoc) * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#plus(java.util.List) */ public ASTNodeValue plus(List<ASTNode> nodes) throws SBMLException { @@ -1002,26 +825,11 @@ } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#pow(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#pow(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) */ public ASTNodeValue pow(ASTNode left, ASTNode right) throws SBMLException { - - // Adding brackets all the time for the exponent/right ASTNode - - if (left.getChildCount() < 2) { - return new ASTNodeValue(StringTools.concat(left.compile(this), "^", "(", - right.compile(this), ")").toString(), this); - } else { - return new ASTNodeValue(StringTools.concat(Character.valueOf('('), - left.compile(this), Character.valueOf(')'), "^", "(", - right.compile(this), ")").toString(), this); - } - + return new ASTNodeValue(pow(left.compile(this), right.compile(this)).toString(), this); } /** @@ -1039,12 +847,8 @@ (right.isRelational()) ? brackets(right) : right).toString(); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#root(org.sbml.jsbml.ASTNode - * , org.sbml.jsbml.ASTNode) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#root(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) */ public ASTNodeValue root(ASTNode rootExponent, ASTNode radiant) throws SBMLException @@ -1057,15 +861,11 @@ rootExponent.compile(this), "))").toString(), this); } - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#root(double, - * org.sbml.jsbml.ASTNode) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#root(double, org.sbml.jsbml.ASTNode) */ public ASTNodeValue root(double rootExponent, ASTNode radiant) - throws SBMLException - { + throws SBMLException { // Writing the root function as '(radiant)^(1/rootExponent)' return new ASTNodeValue(StringTools.concat(Character.valueOf('('), @@ -1073,95 +873,64 @@ rootExponent, ")").toString(), this); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#sec(org.sbml.jsbml.ASTNode) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#sec(org.sbml.jsbml.ASTNode) */ public ASTNodeValue sec(ASTNode node) throws SBMLException { return function("sec", node); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#sech(org.sbml.jsbml.ASTNode - * ) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#sech(org.sbml.jsbml.ASTNode) */ public ASTNodeValue sech(ASTNode node) throws SBMLException { return function("sech", node); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#sin(org.sbml.jsbml.ASTNode) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#sin(org.sbml.jsbml.ASTNode) */ public ASTNodeValue sin(ASTNode node) throws SBMLException { return function("sin", node); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#sinh(org.sbml.jsbml.ASTNode - * ) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#sinh(org.sbml.jsbml.ASTNode) */ public ASTNodeValue sinh(ASTNode node) throws SBMLException { return function("sinh", node); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#sqrt(org.sbml.jsbml.ASTNode - * ) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#sqrt(org.sbml.jsbml.ASTNode) */ public ASTNodeValue sqrt(ASTNode node) throws SBMLException { return new ASTNodeValue(StringTools.concat(Character.valueOf('('), node.compile(this), Character.valueOf(')'), "^", "(0.5)").toString(), this); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#symbolTime(java.lang.String - * ) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#symbolTime(java.lang.String) */ public ASTNodeValue symbolTime(String time) { return new ASTNodeValue(time, this); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#tan(org.sbml.jsbml.ASTNode) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#tan(org.sbml.jsbml.ASTNode) */ public ASTNodeValue tan(ASTNode node) throws SBMLException { return function("tan", node); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#tanh(org.sbml.jsbml.ASTNode - * ) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#tanh(org.sbml.jsbml.ASTNode) */ public ASTNodeValue tanh(ASTNode node) throws SBMLException { return function("tanh", node); } - /* - * (non-Javadoc) - * + /* (non-Javadoc) * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#times(java.util.List) */ public ASTNodeValue times(List<ASTNode> nodes) throws SBMLException { @@ -1173,21 +942,15 @@ return new ASTNodeValue(times(n).toString(), this); } - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#uMinus(org.sbml.jsbml.ASTNode - * ) + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#uMinus(org.sbml.jsbml.ASTNode) */ public ASTNodeValue uMinus(ASTNode node) throws SBMLException { return new ASTNodeValue(concat(Character.valueOf('-'), checkBrackets(node)).toString(), this); } - /* - * (non-Javadoc) - * + /* (non-Javadoc) * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#unknownValue() */ public ASTNodeValue unknownValue() throws SBMLException { @@ -1195,12 +958,11 @@ "cannot write unknown syntax tree nodes to a formula String"); } - /* - * (non-Javadoc) - * + /* (non-Javadoc) * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#xor(java.util.List) */ public ASTNodeValue xor(List<ASTNode> nodes) throws SBMLException { return logicalOperation(" xor ", nodes); } + } Modified: trunk/core/src/org/sbml/jsbml/util/compilers/FormulaCompilerNoPiecewise.java =================================================================== --- trunk/core/src/org/sbml/jsbml/util/compilers/FormulaCompilerNoPiecewise.java 2012-05-14 12:02:32 UTC (rev 1256) +++ trunk/core/src/org/sbml/jsbml/util/compilers/FormulaCompilerNoPiecewise.java 2012-05-15 07:43:01 UTC (rev 1257) @@ -55,14 +55,11 @@ * */ private String orReplacement = " | "; - - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#piecewise(java.util.List) + + /* (non-Javadoc) + * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#piecewise(java.util.List) */ + @Override public ASTNodeValue piecewise(List<ASTNode> nodes) throws SBMLException { // create the piecewise output with if/then/else Modified: trunk/core/src/org/sbml/jsbml/util/compilers/MathMLXMLStreamCompiler.java =================================================================== --- trunk/core/src/org/sbml/jsbml/util/compilers/MathMLXMLStreamCompiler.java 2012-05-14 12:02:32 UTC (rev 1256) +++ trunk/core/src/org/sbml/jsbml/util/compilers/MathMLXMLStreamCompiler.java 2012-05-15 07:43:01 UTC (rev 1257) @@ -145,7 +145,7 @@ SBase sbase = astNode.getParentSBMLObject(); - if (sbase != null && sbase.getLevel() < 3) { + if ((sbase != null) && (sbase.getLevel() < 3)) { return false; } Modified: trunk/core/src/org/sbml/jsbml/util/filters/NameFilter.java =================================================================== --- trunk/core/src/org/sbml/jsbml/util/filters/NameFilter.java 2012-05-14 12:02:32 UTC (rev 1256) +++ trunk/core/src/org/sbml/jsbml/util/filters/NameFilter.java 2012-05-15 07:43:01 UTC (rev 1257) @@ -67,9 +67,7 @@ this.name = name; } - /* - * (non-Javadoc) - * + /* (non-Javadoc) * @see org.sbml.jsbml.util.Filter#fulfilsProperty(java.lang.Object) */ public boolean accepts(Object o) { Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/CompartmentGlyph.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/CompartmentGlyph.java 2012-05-14 12:02:32 UTC (rev 1256) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/CompartmentGlyph.java 2012-05-15 07:43:01 UTC (rev 1257) @@ -108,7 +108,7 @@ */ @Override public Compartment getNamedSBaseInstance() { - return (Compartment) getNamedSBaseInstance(); + return (Compartment) super.getNamedSBaseInstance(); } /** Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/ExtendedLayoutModel.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/ExtendedLayoutModel.java 2012-05-14 12:02:32 UTC (rev 1256) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/ExtendedLayoutModel.java 2012-05-15 07:43:01 UTC (rev 1257) @@ -55,26 +55,6 @@ /** * - */ - public ExtendedLayoutModel(Model model) { - super(model); - - this.model = model; - createListOfLayout(); - } - - /** - * Creates a new list of layout - */ - private void createListOfLayout() { - listOfLayouts = new ListOf<Layout>(); - listOfLayouts.addNamespace(LayoutConstant.namespaceURI); - listOfLayouts.setSBaseListType(ListOf.Type.other); - model.registerChild(listOfLayouts); - } - - /** - * * @param elm */ public ExtendedLayoutModel(ExtendedLayoutModel elm) { @@ -84,7 +64,16 @@ } } + /** + * + */ + public ExtendedLayoutModel(Model model) { + super(model); + this.model = model; + createListOfLayout(); + } + /** * * @param layout @@ -111,8 +100,36 @@ return new ExtendedLayoutModel(this); } - /* - * (non-Javadoc) + /** + * Creates a new layout and adds it to the current list of layouts. + * @return new layout. + */ + public Layout createLayout() { + return createLayout(null); + } + + /** + * + * @param id + * @return + */ + public Layout createLayout(String id) { + Layout layout = new Layout(id, model.getLevel(), model.getVersion()); + addLayout(layout); + return layout; + } + + /** + * Creates a new list of layout + */ + private void createListOfLayout() { + listOfLayouts = new ListOf<Layout>(); + listOfLayouts.addNamespace(LayoutConstant.namespaceURI); + listOfLayouts.setSBaseListType(ListOf.Type.other); + model.registerChild(listOfLayouts); + } + + /* (non-Javadoc) * @see org.sbml.jsbml.Model#equals(java.lang.Object) */ @Override @@ -131,16 +148,15 @@ } return equals; } - + /* (non-Javadoc) * @see javax.swing.tree.TreeNode#getAllowsChildren() */ public boolean getAllowsChildren() { return true; } - - /* - * (non-Javadoc) + + /* (non-Javadoc) * @see org.sbml.jsbml.ext.SBasePlugin#getChildAt(int) */ public SBase getChildAt(int index) { @@ -149,9 +165,9 @@ } return null; } - - /* - * (non-Javadoc) + + + /* (non-Javadoc) * @see org.sbml.jsbml.ext.SBasePlugin#getChildCount() */ public int getChildCount() { @@ -162,6 +178,7 @@ return count; } + /** * * @param i @@ -170,8 +187,7 @@ public Layout getLayout(int i) { return listOfLayouts.get(i); } - - + /** * * @return @@ -182,12 +198,19 @@ } return listOfLayouts; } - - + + /** + * + * @return + */ + public Model getModel() { + return (Model) extendedSBase; + } + public Model getParent() { return model; } - + public Model getParentSBMLObject() { return model; } @@ -223,8 +246,7 @@ model.registerChild(listOfLayouts); } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see java.lang.Object#toString() */ @Override @@ -233,7 +255,7 @@ return null; } - /** + /** * Removes the {@link #listOfLayouts} from this {@link Model} and notifies * all registered instances of {@link TreeNodeChangeListener}. * @@ -249,33 +271,12 @@ } return false; } - - /* - * (non-Javadoc) + + /* (non-Javadoc) * @see org.sbml.jsbml.ext.SBasePlugin#writeXMLAttributes() */ public Map<String, String> writeXMLAttributes() { return null; } - - /** - * - * @return - */ - public Model getModel() { - return (Model) extendedSBase; - } - - - /** - * Creates a new layout and adds it to the current list of layouts. - * @return new layout. - */ - public Layout createLayout() { - Layout layout = new Layout(model.getLevel(), model.getVersion()); - addLayout(layout); - return layout; - } - } Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Layout.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Layout.java 2012-05-14 12:02:32 UTC (rev 1256) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Layout.java 2012-05-15 07:43:01 UTC (rev 1257) @@ -54,11 +54,11 @@ /** * */ - private ListOf<GraphicalObject> listOfAdditionalGraphicalObjects = new ListOf<GraphicalObject>(); + private Dimensions dimensions; /** * */ - private Dimensions dimensions; + private ListOf<GraphicalObject> listOfAdditionalGraphicalObjects = new ListOf<GraphicalObject>(); /** * */ @@ -94,7 +94,8 @@ initDefault(); } - /** + + /** * @param layout * */ @@ -121,8 +122,20 @@ } } + /** * + * @param id + * @param level + * @param version + */ + public Layout(String id, int level, int version) { + super(id, level, version); + initDefault(); + } + + /** + * * @param reactionGlyph */ public void add(ReactionGlyph reactionGlyph) { @@ -202,6 +215,49 @@ } /** + * + * @param compartment + * @return + */ + public boolean containsGlyph(Compartment compartment) { + return containsGlyph(listOfCompartmentGlyphs, compartment); + } + + /** + * + * @param listOfGlyphs + * @param nsb + * @return + */ + private <T extends NamedSBaseGlyph> boolean containsGlyph(ListOf<T> listOfGlyphs, + NamedSBase nsb) { + if ((nsb != null) && (listOfGlyphs != null) && !listOfGlyphs.isEmpty()) { + NamedSBaseReferenceFilter filter = new NamedSBaseReferenceFilter(nsb.getId()); + filter.setFilterForReference(true); + return listOfGlyphs.firstHit(filter) != null; + } + return false; + } + + /** + * + * @param reaction + * @return + */ + public boolean containsGlyph(Reaction reaction) { + return containsGlyph(listOfReactionGlyphs, reaction); + } + + /** + * + * @param species + * @return + */ + public boolean containsGlyph(Species species) { + return containsGlyph(listOfSpeciesGlyphs, species); + } + + /** * Creates and adds a new {@link CompartmentGlyph}. * @param compartment {@link Compartment} ID. * @return new {@link CompartmentGlyph}. @@ -241,7 +297,7 @@ addReactionGlyph(glyph); return glyph; } - + /** * Creates and adds a new {@link SpeciesGlyph}. * @param species {@link Species} ID. @@ -293,7 +349,7 @@ } return new ArrayList<T>(0); } - + /** * Searches all instances of {@link ReactionGlyph} within this {@link Layout} that * refer to the {@link Reaction} with the given id. @@ -317,7 +373,7 @@ public List<SpeciesGlyph> findSpeciesGlyphs(String speciesID) { return findGlyphs(listOfSpeciesGlyphs, speciesID); } - + /** * * @param i @@ -330,7 +386,7 @@ } return null; } - + /* (non-Javadoc) * @see org.sbml.jsbml.AbstractSBase#getChildAt(int) */ @@ -383,7 +439,7 @@ throw new IndexOutOfBoundsException(String.format("Index %d >= %d", index, +((int) Math.min(pos, 0)))); } - + /* (non-Javadoc) * @see org.sbml.jsbml.AbstractSBase#getChildCount() */ @@ -423,7 +479,7 @@ } return null; } - + /** * * @param id @@ -435,7 +491,7 @@ } return null; } - + /** * * @return @@ -451,7 +507,7 @@ public ListOf<GraphicalObject> getListOfAdditionalGraphicalObjects() { return listOfAdditionalGraphicalObjects; } - + /** * * @return @@ -465,7 +521,8 @@ } return listOfCompartmentGlyphs; } - + + /** * * @return @@ -479,7 +536,7 @@ } return listOfReactionGlyphs; } - + /** * * @return @@ -493,7 +550,7 @@ } return listOfSpeciesGlyphs; } - + /** * * @return @@ -507,7 +564,7 @@ } return listOfTextGlyphs; } - + /** * * @param i @@ -520,7 +577,6 @@ } return null; } - /** * @@ -533,7 +589,7 @@ } return null; } - + /** * * @param i @@ -560,32 +616,34 @@ } return null; } - + + /** + * + */ private void initDefault() { - addNamespace(LayoutConstant.namespaceURI); + addNamespace(LayoutConstant.namespaceURI); - listOfCompartmentGlyphs.addNamespace(LayoutConstant.namespaceURI); - listOfCompartmentGlyphs.setSBaseListType(ListOf.Type.other); - registerChild(listOfCompartmentGlyphs); - - listOfSpeciesGlyphs.addNamespace(LayoutConstant.namespaceURI); - listOfSpeciesGlyphs.setSBaseListType(ListOf.Type.other); - registerChild(listOfSpeciesGlyphs); + listOfCompartmentGlyphs.addNamespace(LayoutConstant.namespaceURI); + listOfCompartmentGlyphs.setSBaseListType(ListOf.Type.other); + registerChild(listOfCompartmentGlyphs); - listOfReactionGlyphs.addNamespace(LayoutConstant.namespaceURI); - listOfReactionGlyphs.setSBaseListType(ListOf.Type.other); - registerChild(listOfReactionGlyphs); + listOfSpeciesGlyphs.addNamespace(LayoutConstant.namespaceURI); + listOfSpeciesGlyphs.setSBaseListType(ListOf.Type.other); + registerChild(listOfSpeciesGlyphs); - listOfTextGlyphs.addNamespace(LayoutConstant.namespaceURI); - listOfTextGlyphs.setSBaseListType(ListOf.Type.other); - registerChild(listOfTextGlyphs); + listOfReactionGlyphs.addNamespace(LayoutConstant.namespaceURI); + listOfReactionGlyphs.setSBaseListType(ListOf.Type.other); + registerChild(listOfReactionGlyphs); - listOfAdditionalGraphicalObjects.addNamespace(LayoutConstant.namespaceURI); - listOfAdditionalGraphicalObjects.setSBaseListType(ListOf.Type.other); - registerChild(listOfAdditionalGraphicalObjects); + listOfTextGlyphs.addNamespace(LayoutConstant.namespaceURI); + listOfTextGlyphs.setSBaseListType(ListOf.Type.other); + registerChild(listOfTextGlyphs); -} - + listOfAdditionalGraphicalObjects.addNamespace(LayoutConstant.namespaceURI); + listOfAdditionalGraphicalObjects.setSBaseListType(ListOf.Type.other); + registerChild(listOfAdditionalGraphicalObjects); + } + /* (non-Javadoc) * @see org.sbml.jsbml.NamedSBase#isIdMandatory() */ @@ -600,14 +658,14 @@ public boolean isSetAddGraphicalObjects() { return (listOfAdditionalGraphicalObjects != null) && (listOfAdditionalGraphicalObjects.size() > 0); } - + /** * @return */ public boolean isSetDimensions() { return dimensions != null; } - + /** * @return */ @@ -628,7 +686,7 @@ public boolean isSetListOfReactionGlyphs() { return (listOfReactionGlyphs != null) && (listOfReactionGlyphs.size() > 0); } - + /** * * @return @@ -643,7 +701,7 @@ public boolean isSetListOfTextGlyphs() { return (listOfTextGlyphs != null) && (listOfTextGlyphs.size() > 0); } - + /** * @param attributeName * @param prefix @@ -657,49 +715,6 @@ value); return isAttributeRead; } - - /** - * - * @param compartment - * @return - */ - public boolean containsGlyph(Compartment compartment) { - return containsGlyph(listOfCompartmentGlyphs, compartment); - } - - /** - * - * @param listOfGlyphs - * @param nsb - * @return - */ - private <T extends NamedSBaseGlyph> boolean containsGlyph(ListOf<T> listOfGlyphs, - NamedSBase nsb) { - if ((nsb != null) && (listOfGlyphs != null) && !listOfGlyphs.isEmpty()) { - NamedSBaseReferenceFilter filter = new NamedSBaseReferenceFilter(nsb.getId()); - filter.setFilterForReference(true); - return listOfGlyphs.firstHit(filter) != null; - } - return false; - } - - /** - * - * @param reaction - * @return - */ - public boolean containsGlyph(Reaction reaction) { - return containsGlyph(listOfReactionGlyphs, reaction); - } - - /** - * - * @param species - * @return - */ - public boolean containsGlyph(Species species) { - return containsGlyph(listOfSpeciesGlyphs, species); - } /** * Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/ReactionGlyph.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/ReactionGlyph.java 2012-05-14 12:02:32 UTC (rev 1256) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/ReactionGlyph.java 2012-05-15 07:43:01 UTC (rev 1257) @@ -210,7 +210,7 @@ */ @Override public Reaction getNamedSBaseInstance() { - return (Reaction) getNamedSBaseInstance(); + return (Reaction) super.getNamedSBaseInstance(); } /** Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesGlyph.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesGlyph.java 2012-05-14 12:02:32 UTC (rev 1256) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesGlyph.java 2012-05-15 07:43:01 UTC (rev 1257) @@ -93,7 +93,7 @@ */ @Override public Species getNamedSBaseInstance() { - return (Species) getNamedSBaseInstance(); + return (Species) super.getNamedSBaseInstance(); } /** @@ -111,7 +111,7 @@ public Species getSpeciesInstance() { return getNamedSBaseInstance(); } - + /** * @return the {@link #speciesId} */ Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesReferenceGlyph.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesReferenceGlyph.java 2012-05-14 12:02:32 UTC (rev 1256) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesReferenceGlyph.java 2012-05-15 07:43:01 UTC (rev 1257) @@ -184,7 +184,7 @@ */ @Override public SimpleSpeciesReference getNamedSBaseInstance() { - return (SimpleSpeciesReference) getNamedSBaseInstance(); + return (SimpleSpeciesReference) super.getNamedSBaseInstance(); } /** Modified: trunk/modules/celldesigner/src/org/sbml/jsbml/cdplugin/PluginChangeListener.java =================================================================== --- trunk/modules/celldesigner/src/org/sbml/jsbml/cdplugin/PluginChangeListener.java 2012-05-14 12:02:32 UTC (rev 1256) +++ trunk/modules/celldesigner/src/org/sbml/jsbml/cdplugin/PluginChangeListener.java 2012-05-15 07:43:01 UTC (rev 1257) @@ -17,6 +17,7 @@ package org.sbml.jsbml.cdplugin; import java.beans.PropertyChangeEvent; +import java.text.MessageFormat; import java.util.Enumeration; import javax.swing.tree.TreeNode; @@ -498,7 +499,7 @@ pKlaw.setTimeUnits(klaw.getTimeUnits()); plugin.notifySBaseChanged(pKlaw); } else if (eventsource instanceof Model){ - logger.log(Level.DEBUG, String.format("Changing %s in the Model only supported with SBML version > 3.", eventsource.getClass().getSimpleName())); + logger.log(Level.DEBUG, MessageFormat.format("Changing {0} in the Model only supported with SBML version > 3.", eventsource.getClass().getSimpleName())); } } else if (prop.equals(TreeNodeChangeEvent.type)) { ASTNode n = (ASTNode) eventsource; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |