From: <nik...@us...> - 2015-05-01 09:56:21
|
Revision: 2270 http://sourceforge.net/p/jsbml/code/2270 Author: niko-rodrigue Date: 2015-05-01 09:56:17 +0000 (Fri, 01 May 2015) Log Message: ----------- merged from trunk until rev 2227 Revision Links: -------------- http://sourceforge.net/p/jsbml/code/2227 Modified Paths: -------------- branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/AbstractMathContainer.java branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/AbstractSBase.java branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/Annotation.java branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/CVTerm.java branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/Constraint.java branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/Event.java branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/KineticLaw.java branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/Model.java branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/Reaction.java branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/SBMLDocument.java branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/SpeciesReference.java branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/util/compilers/MathMLXMLStreamCompiler.java branches/astnode2-merging-alternate/extensions/comp/src/org/sbml/jsbml/ext/comp/CompModelPlugin.java branches/astnode2-merging-alternate/extensions/comp/src/org/sbml/jsbml/ext/comp/CompSBMLDocumentPlugin.java branches/astnode2-merging-alternate/extensions/comp/src/org/sbml/jsbml/ext/comp/CompSBasePlugin.java branches/astnode2-merging-alternate/extensions/comp/src/org/sbml/jsbml/ext/comp/SBaseRef.java branches/astnode2-merging-alternate/extensions/comp/src/org/sbml/jsbml/ext/comp/Submodel.java branches/astnode2-merging-alternate/extensions/distrib/src/org/sbml/jsbml/ext/distrib/DistribFunctionDefinitionPlugin.java branches/astnode2-merging-alternate/extensions/distrib/src/org/sbml/jsbml/ext/distrib/DistribSBasePlugin.java branches/astnode2-merging-alternate/extensions/distrib/src/org/sbml/jsbml/ext/distrib/DrawFromDistribution.java branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/BoundingBox.java branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/CubicBezier.java branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/Curve.java branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/GeneralGlyph.java branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/GraphicalObject.java branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/Layout.java branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/LineSegment.java branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/ReactionGlyph.java branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/ReferenceGlyph.java branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesReferenceGlyph.java branches/astnode2-merging-alternate/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiModelPlugin.java branches/astnode2-merging-alternate/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiSpeciesPlugin.java branches/astnode2-merging-alternate/extensions/multi/src/org/sbml/jsbml/ext/multi/SpeciesFeatureType.java branches/astnode2-merging-alternate/extensions/multi/src/org/sbml/jsbml/ext/multi/SpeciesType.java branches/astnode2-merging-alternate/extensions/qual/src/org/sbml/jsbml/ext/qual/QualModelPlugin.java branches/astnode2-merging-alternate/extensions/qual/src/org/sbml/jsbml/ext/qual/Transition.java branches/astnode2-merging-alternate/extensions/render/src/org/sbml/jsbml/ext/render/GlobalRenderInformation.java branches/astnode2-merging-alternate/extensions/render/src/org/sbml/jsbml/ext/render/GradientBase.java branches/astnode2-merging-alternate/extensions/render/src/org/sbml/jsbml/ext/render/GradientStop.java branches/astnode2-merging-alternate/extensions/render/src/org/sbml/jsbml/ext/render/Image.java branches/astnode2-merging-alternate/extensions/render/src/org/sbml/jsbml/ext/render/LineEnding.java branches/astnode2-merging-alternate/extensions/render/src/org/sbml/jsbml/ext/render/LinearGradient.java branches/astnode2-merging-alternate/extensions/render/src/org/sbml/jsbml/ext/render/LocalRenderInformation.java branches/astnode2-merging-alternate/extensions/render/src/org/sbml/jsbml/ext/render/Polygon.java branches/astnode2-merging-alternate/extensions/render/src/org/sbml/jsbml/ext/render/Rectangle.java branches/astnode2-merging-alternate/extensions/render/src/org/sbml/jsbml/ext/render/RenderCubicBezier.java branches/astnode2-merging-alternate/extensions/render/src/org/sbml/jsbml/ext/render/RenderGroup.java branches/astnode2-merging-alternate/extensions/render/src/org/sbml/jsbml/ext/render/RenderInformationBase.java branches/astnode2-merging-alternate/extensions/render/src/org/sbml/jsbml/ext/render/RenderLayoutPlugin.java branches/astnode2-merging-alternate/extensions/render/src/org/sbml/jsbml/ext/render/RenderListOfLayoutsPlugin.java branches/astnode2-merging-alternate/extensions/render/src/org/sbml/jsbml/ext/render/RenderPoint.java branches/astnode2-merging-alternate/extensions/render/src/org/sbml/jsbml/ext/render/Style.java branches/astnode2-merging-alternate/extensions/req/src/org/sbml/jsbml/ext/req/ReqSBasePlugin.java branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/AnalyticGeometry.java branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/CSGHomogeneousTransformation.java branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/CSGObject.java branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/CSGSetOperator.java branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/CSGTransformation.java branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/CoordinateComponent.java branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/Domain.java branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/Geometry.java branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/MixedGeometry.java branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/SampledField.java branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/SampledFieldGeometry.java branches/astnode2-merging-alternate/modules/celldesigner/src/org/sbml/jsbml/celldesigner/SBMLLayoutVisualizer.java Property Changed: ---------------- branches/astnode2-merging-alternate/ Index: branches/astnode2-merging-alternate =================================================================== --- branches/astnode2-merging-alternate 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate 2015-05-01 09:56:17 UTC (rev 2270) Property changes on: branches/astnode2-merging-alternate ___________________________________________________________________ Modified: svn:mergeinfo ## -1 +1 ## -/trunk:2191,2194-2195,2197-2200,2202-2206,2209-2213,2216-2220,2222,2224-2226 +/trunk:2191,2194-2195,2197-2200,2202-2206,2209-2213,2216-2220,2222,2224-2227 \ No newline at end of property Modified: branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/AbstractMathContainer.java =================================================================== --- branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/AbstractMathContainer.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/AbstractMathContainer.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -151,7 +151,7 @@ } throw new IndexOutOfBoundsException(MessageFormat.format( "Index {0,number,integer} >= {1,number,integer}", - index, +Math.min(pos, 0))); + index, Math.min(pos, 0))); } /* (non-Javadoc) Modified: branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/AbstractSBase.java =================================================================== --- branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/AbstractSBase.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/AbstractSBase.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -397,7 +397,7 @@ } /* (non-Javadoc) - * @see org.sbml.jlibsbml.SBase#appendNotes(java.lang.String) + * @see org.sbml.jsbml.SBase#appendNotes(java.lang.String) */ @Override public void appendNotes(String notes) throws XMLStreamException { Modified: branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/Annotation.java =================================================================== --- branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/Annotation.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/Annotation.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -577,6 +577,14 @@ return getNonRDFannotation(); } + /** + * + * @param nonRDFannotation + */ + public void setXMLNode(XMLNode nonRDFannotation) { + setNonRDFAnnotation(nonRDFannotation); + } + /* (non-Javadoc) * @see org.sbml.jsbml.AbstractTreeNode#hashCode() */ Modified: branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/CVTerm.java =================================================================== --- branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/CVTerm.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/CVTerm.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -29,7 +29,6 @@ import java.util.regex.Pattern; import javax.swing.tree.TreeNode; -import javax.xml.stream.XMLStreamException; import org.sbml.jsbml.util.StringTools; import org.sbml.jsbml.util.TreeNodeAdapter; Modified: branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/Constraint.java =================================================================== --- branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/Constraint.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/Constraint.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -126,7 +126,7 @@ } throw new IndexOutOfBoundsException(MessageFormat.format( "Index {0,number,integer} >= {1,number,integer}", - index, +Math.min(pos, 0))); + index, Math.min(pos, 0))); } /* (non-Javadoc) Modified: branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/Event.java =================================================================== --- branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/Event.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/Event.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -405,7 +405,7 @@ } throw new IndexOutOfBoundsException(MessageFormat.format( "Index {0,number,integer} >= {1,number,integer}", - index, +Math.min(pos, 0))); + index, Math.min(pos, 0))); } /* (non-Javadoc) Modified: branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/KineticLaw.java =================================================================== --- branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/KineticLaw.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/KineticLaw.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -289,7 +289,7 @@ } throw new IndexOutOfBoundsException(MessageFormat.format( "Index {0,number,integer} >= {1,number,integer}", - index, +Math.min(pos, 0))); + index, Math.min(pos, 0))); } /* (non-Javadoc) Modified: branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/Model.java =================================================================== --- branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/Model.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/Model.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -1877,7 +1877,7 @@ } throw new IndexOutOfBoundsException(MessageFormat.format( "Index {0,number,integer} >= {1,number,integer}", - index, +Math.min(pos, 0))); + index, Math.min(pos, 0))); } /* (non-Javadoc) Modified: branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/Reaction.java =================================================================== --- branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/Reaction.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/Reaction.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -512,7 +512,7 @@ } throw new IndexOutOfBoundsException(MessageFormat.format( "Index {0,number,integer} >= {1,number,integer}", - index, +Math.min(pos, 0))); + index, Math.min(pos, 0))); } /* (non-Javadoc) Modified: branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/SBMLDocument.java =================================================================== --- branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/SBMLDocument.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/SBMLDocument.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -663,7 +663,7 @@ } } throw new IndexOutOfBoundsException(MessageFormat.format("Index {0,number,integer} >= {1,number,integer}", - index, +Math.min(pos, 0))); + index, Math.min(pos, 0))); } /* (non-Javadoc) Modified: branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/SpeciesReference.java =================================================================== --- branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/SpeciesReference.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/SpeciesReference.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -280,7 +280,7 @@ } throw new IndexOutOfBoundsException(MessageFormat.format( "Index {0,number,integer} >= {1,number,integer}", - index, +Math.min(pos, 0))); + index, Math.min(pos, 0))); } /* (non-Javadoc) Modified: branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/util/compilers/MathMLXMLStreamCompiler.java =================================================================== --- branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/util/compilers/MathMLXMLStreamCompiler.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/util/compilers/MathMLXMLStreamCompiler.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -114,6 +114,25 @@ } /** + * + * @param indent + * @throws XMLStreamException + */ + public MathMLXMLStreamCompiler(String indent) throws XMLStreamException { + SMOutputFactory smFactory = new SMOutputFactory(XMLOutputFactory.newInstance()); + writer = smFactory.createStax2Writer(new StringWriter()); + this.indent = indent; + } + + /** + * @throws XMLStreamException + * + */ + public MathMLXMLStreamCompiler() throws XMLStreamException { + this(""); + } + + /** * Writes an {@link ASTNode} the mathML. * * @param astNode the {@link ASTNode} to serialize as mathML Modified: branches/astnode2-merging-alternate/extensions/comp/src/org/sbml/jsbml/ext/comp/CompModelPlugin.java =================================================================== --- branches/astnode2-merging-alternate/extensions/comp/src/org/sbml/jsbml/ext/comp/CompModelPlugin.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/extensions/comp/src/org/sbml/jsbml/ext/comp/CompModelPlugin.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -273,7 +273,7 @@ } throw new IndexOutOfBoundsException(MessageFormat.format( "Index {0,number,integer} >= {1,number,integer}", - childIndex, +Math.min(pos, 0))); + childIndex, Math.min(pos, 0))); } /* (non-Javadoc) Modified: branches/astnode2-merging-alternate/extensions/comp/src/org/sbml/jsbml/ext/comp/CompSBMLDocumentPlugin.java =================================================================== --- branches/astnode2-merging-alternate/extensions/comp/src/org/sbml/jsbml/ext/comp/CompSBMLDocumentPlugin.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/extensions/comp/src/org/sbml/jsbml/ext/comp/CompSBMLDocumentPlugin.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -601,7 +601,7 @@ } throw new IndexOutOfBoundsException(MessageFormat.format( "Index {0,number,integer} >= {1,number,integer}", - childIndex, +Math.min(pos, 0))); + childIndex, Math.min(pos, 0))); } /* (non-Javadoc) Modified: branches/astnode2-merging-alternate/extensions/comp/src/org/sbml/jsbml/ext/comp/CompSBasePlugin.java =================================================================== --- branches/astnode2-merging-alternate/extensions/comp/src/org/sbml/jsbml/ext/comp/CompSBasePlugin.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/extensions/comp/src/org/sbml/jsbml/ext/comp/CompSBasePlugin.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -536,7 +536,7 @@ throw new IndexOutOfBoundsException(MessageFormat.format( "Index {0,number,integer} >= {1,number,integer}", index, - +Math.min(pos, 0))); + Math.min(pos, 0))); } Modified: branches/astnode2-merging-alternate/extensions/comp/src/org/sbml/jsbml/ext/comp/SBaseRef.java =================================================================== --- branches/astnode2-merging-alternate/extensions/comp/src/org/sbml/jsbml/ext/comp/SBaseRef.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/extensions/comp/src/org/sbml/jsbml/ext/comp/SBaseRef.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -486,7 +486,7 @@ throw new IndexOutOfBoundsException(MessageFormat.format( "Index {0,number,integer} >= {1,number,integer}", index, - +Math.min(pos, 0))); + Math.min(pos, 0))); } /* (non-Javadoc) Modified: branches/astnode2-merging-alternate/extensions/comp/src/org/sbml/jsbml/ext/comp/Submodel.java =================================================================== --- branches/astnode2-merging-alternate/extensions/comp/src/org/sbml/jsbml/ext/comp/Submodel.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/extensions/comp/src/org/sbml/jsbml/ext/comp/Submodel.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -616,7 +616,7 @@ throw new IndexOutOfBoundsException(MessageFormat.format( "Index {0,number,integer} >= {1,number,integer}", index, - +Math.min(pos, 0))); + Math.min(pos, 0))); } /* (non-Javadoc) Modified: branches/astnode2-merging-alternate/extensions/distrib/src/org/sbml/jsbml/ext/distrib/DistribFunctionDefinitionPlugin.java =================================================================== --- branches/astnode2-merging-alternate/extensions/distrib/src/org/sbml/jsbml/ext/distrib/DistribFunctionDefinitionPlugin.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/extensions/distrib/src/org/sbml/jsbml/ext/distrib/DistribFunctionDefinitionPlugin.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -178,7 +178,7 @@ } throw new IndexOutOfBoundsException(MessageFormat.format( "Index {0,number,integer} >= {1,number,integer}", index, - +Math.min(pos, 0))); + Math.min(pos, 0))); } @Override Modified: branches/astnode2-merging-alternate/extensions/distrib/src/org/sbml/jsbml/ext/distrib/DistribSBasePlugin.java =================================================================== --- branches/astnode2-merging-alternate/extensions/distrib/src/org/sbml/jsbml/ext/distrib/DistribSBasePlugin.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/extensions/distrib/src/org/sbml/jsbml/ext/distrib/DistribSBasePlugin.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -1,208 +1,208 @@ -/* - * $Id$ - * $URL$ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit <http://sbml.org/Software/JSBML> - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2014 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * 4. The University of California, San Diego, La Jolla, CA, USA - * 5. The Babraham Institute, Cambridge, UK - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as <http://sbml.org/Software/JSBML/License>. - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.ext.distrib; - -import java.text.MessageFormat; - -import javax.swing.tree.TreeNode; - -import org.sbml.jsbml.SBase; -import org.sbml.jsbml.ext.AbstractSBasePlugin; - -/** - * - * @author Nicolas Rodriguez - * @version $Rev$ - * @since 1.1 - * @date 26.03.2015 - */ -public class DistribSBasePlugin extends AbstractSBasePlugin { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -1732369832900356125L; - /** - * - */ - private Uncertainty uncertainty; - - /** - * Creates a new {@link DistribSBasePlugin} instance. - * - * @param sbase the {@link SBase} to be extended. - */ - public DistribSBasePlugin(SBase sbase) { - super(sbase); - setPackageVersion(-1); - } - - /** - * Creates a new {@link DistribSBasePlugin} instance, cloned from - * the input parameter. - * - * @param obj the {@link DistribSBasePlugin} to clone - */ - public DistribSBasePlugin(DistribSBasePlugin obj) { - super(obj); - - if (obj.isSetUncertainty()) { - setUncertainty(obj.getUncertainty().clone()); - } - } - - - /** - * Creates and Sets a new {@link Uncertainty} instance. - * - * @return the newly created {@link Uncertainty} instance. - */ - public Uncertainty createUncertainty() { - Uncertainty uncert = new Uncertainty(); - setUncertainty(uncert); - return uncert; - } - - - /** - * Returns the value of {@link #uncertainty}. - * - * @return the value of {@link #uncertainty}. - */ - public Uncertainty getUncertainty() { - if (isSetUncertainty()) { - return uncertainty; - } - - return null; - } - - - /** - * Returns whether {@link #uncertainty} is set. - * - * @return whether {@link #uncertainty} is set. - */ - public boolean isSetUncertainty() { - return uncertainty != null; - } - - - /** - * Sets the value of uncertainty - * - * @param uncertainty the value of uncertainty to be set. - */ - public void setUncertainty(Uncertainty uncertainty) { - Uncertainty oldUncertainty = this.uncertainty; - this.uncertainty = uncertainty; - if (getExtendedSBase() != null) { - getExtendedSBase().registerChild(uncertainty); - } - firePropertyChange(DistribConstants.uncertainty, oldUncertainty, this.uncertainty); - } - - - /** - * Unsets the variable uncertainty. - * - * @return {@code true} if uncertainty was set before, otherwise {@code false}. - */ - public boolean unsetUncertainty() { - if (isSetUncertainty()) { - Uncertainty oldUncertainty = uncertainty; - uncertainty = null; - firePropertyChange(DistribConstants.uncertainty, oldUncertainty, uncertainty); - return true; - } - return false; - } - - - @Override - public String getElementNamespace() { - return DistribConstants.namespaceURI_L3V1V1; // TODO - change to return a String attribute that can be changed - } - - @Override - public String getPackageName() { - return DistribConstants.shortLabel; - } - - @Override - public String getPrefix() { - return DistribConstants.shortLabel; - } - - @Override - public String getURI() { - return DistribConstants.namespaceURI; // TODO - change to return a String attribute that can be changed - } - - - @Override - public int getChildCount() { - int count = 0; - - if (isSetUncertainty()) { - count++; - } - - return count; - } - - - @Override - public TreeNode getChildAt(int index) { - if (index < 0) { - throw new IndexOutOfBoundsException(index + " < 0"); - } - int pos = 0; - - if (isSetUncertainty()) { - if (pos == index) { - return getUncertainty(); - } - pos++; - } - throw new IndexOutOfBoundsException(MessageFormat.format( - "Index {0,number,integer} >= {1,number,integer}", index, - +Math.min(pos, 0))); - } - - @Override - public boolean getAllowsChildren() { - return true; - } - - @Override - public AbstractSBasePlugin clone() { - return new DistribSBasePlugin(this); - } - - @Override - public boolean readAttribute(String attributeName, String prefix, - String value) { - return false; - } - -} +/* + * $Id$ + * $URL$ + * ---------------------------------------------------------------------------- + * This file is part of JSBML. Please visit <http://sbml.org/Software/JSBML> + * for the latest version of JSBML and more information about SBML. + * + * Copyright (C) 2009-2014 jointly by the following organizations: + * 1. The University of Tuebingen, Germany + * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK + * 3. The California Institute of Technology, Pasadena, CA, USA + * 4. The University of California, San Diego, La Jolla, CA, USA + * 5. The Babraham Institute, Cambridge, UK + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation. A copy of the license agreement is provided + * in the file named "LICENSE.txt" included with this software distribution + * and also available online as <http://sbml.org/Software/JSBML/License>. + * ---------------------------------------------------------------------------- + */ +package org.sbml.jsbml.ext.distrib; + +import java.text.MessageFormat; + +import javax.swing.tree.TreeNode; + +import org.sbml.jsbml.SBase; +import org.sbml.jsbml.ext.AbstractSBasePlugin; + +/** + * + * @author Nicolas Rodriguez + * @version $Rev$ + * @since 1.1 + * @date 26.03.2015 + */ +public class DistribSBasePlugin extends AbstractSBasePlugin { + + /** + * Generated serial version identifier. + */ + private static final long serialVersionUID = -1732369832900356125L; + /** + * + */ + private Uncertainty uncertainty; + + /** + * Creates a new {@link DistribSBasePlugin} instance. + * + * @param sbase the {@link SBase} to be extended. + */ + public DistribSBasePlugin(SBase sbase) { + super(sbase); + setPackageVersion(-1); + } + + /** + * Creates a new {@link DistribSBasePlugin} instance, cloned from + * the input parameter. + * + * @param obj the {@link DistribSBasePlugin} to clone + */ + public DistribSBasePlugin(DistribSBasePlugin obj) { + super(obj); + + if (obj.isSetUncertainty()) { + setUncertainty(obj.getUncertainty().clone()); + } + } + + + /** + * Creates and Sets a new {@link Uncertainty} instance. + * + * @return the newly created {@link Uncertainty} instance. + */ + public Uncertainty createUncertainty() { + Uncertainty uncert = new Uncertainty(); + setUncertainty(uncert); + return uncert; + } + + + /** + * Returns the value of {@link #uncertainty}. + * + * @return the value of {@link #uncertainty}. + */ + public Uncertainty getUncertainty() { + if (isSetUncertainty()) { + return uncertainty; + } + + return null; + } + + + /** + * Returns whether {@link #uncertainty} is set. + * + * @return whether {@link #uncertainty} is set. + */ + public boolean isSetUncertainty() { + return uncertainty != null; + } + + + /** + * Sets the value of uncertainty + * + * @param uncertainty the value of uncertainty to be set. + */ + public void setUncertainty(Uncertainty uncertainty) { + Uncertainty oldUncertainty = this.uncertainty; + this.uncertainty = uncertainty; + if (getExtendedSBase() != null) { + getExtendedSBase().registerChild(uncertainty); + } + firePropertyChange(DistribConstants.uncertainty, oldUncertainty, this.uncertainty); + } + + + /** + * Unsets the variable uncertainty. + * + * @return {@code true} if uncertainty was set before, otherwise {@code false}. + */ + public boolean unsetUncertainty() { + if (isSetUncertainty()) { + Uncertainty oldUncertainty = uncertainty; + uncertainty = null; + firePropertyChange(DistribConstants.uncertainty, oldUncertainty, uncertainty); + return true; + } + return false; + } + + + @Override + public String getElementNamespace() { + return DistribConstants.namespaceURI_L3V1V1; // TODO - change to return a String attribute that can be changed + } + + @Override + public String getPackageName() { + return DistribConstants.shortLabel; + } + + @Override + public String getPrefix() { + return DistribConstants.shortLabel; + } + + @Override + public String getURI() { + return DistribConstants.namespaceURI; // TODO - change to return a String attribute that can be changed + } + + + @Override + public int getChildCount() { + int count = 0; + + if (isSetUncertainty()) { + count++; + } + + return count; + } + + + @Override + public TreeNode getChildAt(int index) { + if (index < 0) { + throw new IndexOutOfBoundsException(index + " < 0"); + } + int pos = 0; + + if (isSetUncertainty()) { + if (pos == index) { + return getUncertainty(); + } + pos++; + } + throw new IndexOutOfBoundsException(MessageFormat.format( + "Index {0,number,integer} >= {1,number,integer}", index, + Math.min(pos, 0))); + } + + @Override + public boolean getAllowsChildren() { + return true; + } + + @Override + public AbstractSBasePlugin clone() { + return new DistribSBasePlugin(this); + } + + @Override + public boolean readAttribute(String attributeName, String prefix, + String value) { + return false; + } + +} Modified: branches/astnode2-merging-alternate/extensions/distrib/src/org/sbml/jsbml/ext/distrib/DrawFromDistribution.java =================================================================== --- branches/astnode2-merging-alternate/extensions/distrib/src/org/sbml/jsbml/ext/distrib/DrawFromDistribution.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/extensions/distrib/src/org/sbml/jsbml/ext/distrib/DrawFromDistribution.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -480,7 +480,7 @@ throw new IndexOutOfBoundsException(MessageFormat.format( "Index {0,number,integer} >= {1,number,integer}", index, - +Math.min(pos, 0))); + Math.min(pos, 0))); } Modified: branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/BoundingBox.java =================================================================== --- branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/BoundingBox.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/BoundingBox.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -230,7 +230,7 @@ } throw new IndexOutOfBoundsException(MessageFormat.format( "Index {0,number,integer} >= {1,number,integer}", - index, +Math.min(pos, 0))); + index, Math.min(pos, 0))); } /* (non-Javadoc) Modified: branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/CubicBezier.java =================================================================== --- branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/CubicBezier.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/CubicBezier.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -238,7 +238,7 @@ } throw new IndexOutOfBoundsException(MessageFormat.format( "Index {0,number,integer} >= {1,number,integer}", - index, +Math.min(pos, 0))); + index, Math.min(pos, 0))); } /* (non-Javadoc) Modified: branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/Curve.java =================================================================== --- branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/Curve.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/Curve.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -172,7 +172,7 @@ } throw new IndexOutOfBoundsException(MessageFormat.format( "Index {0,number,integer} >= {1,number,integer}", - index, +Math.min(pos, 0))); + index, Math.min(pos, 0))); } /* (non-Javadoc) Modified: branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/GeneralGlyph.java =================================================================== --- branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/GeneralGlyph.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/GeneralGlyph.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -526,7 +526,7 @@ } throw new IndexOutOfBoundsException(MessageFormat.format( "Index {0,number,integer} >= {1,number,integer}", - index, +Math.min(pos, 0))); + index, Math.min(pos, 0))); } /* (non-Javadoc) Modified: branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/GraphicalObject.java =================================================================== --- branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/GraphicalObject.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/GraphicalObject.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -250,7 +250,7 @@ } throw new IndexOutOfBoundsException(MessageFormat.format( "Index {0,number,integer} >= {1,number,integer}", - index, +Math.min(pos, 0))); + index, Math.min(pos, 0))); } /* (non-Javadoc) Modified: branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/Layout.java =================================================================== --- branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/Layout.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/Layout.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -623,7 +623,7 @@ } throw new IndexOutOfBoundsException(MessageFormat.format( "Index {0,number,integer} >= {1,number,integer}", - index, +Math.min(pos, 0))); + index, Math.min(pos, 0))); } /* (non-Javadoc) Modified: branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/LineSegment.java =================================================================== --- branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/LineSegment.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/LineSegment.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -219,7 +219,7 @@ } throw new IndexOutOfBoundsException(MessageFormat.format( "Index {0,number,integer} >= {1,number,integer}", - index, +Math.min(pos, 0))); + index, Math.min(pos, 0))); } /* (non-Javadoc) Modified: branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/ReactionGlyph.java =================================================================== --- branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/ReactionGlyph.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/ReactionGlyph.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -228,7 +228,7 @@ } throw new IndexOutOfBoundsException(MessageFormat.format( "Index {0,number,integer} >= {1,number,integer}", - index, +Math.min(pos, 0))); + index, Math.min(pos, 0))); } /* (non-Javadoc) Modified: branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/ReferenceGlyph.java =================================================================== --- branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/ReferenceGlyph.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/ReferenceGlyph.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -180,7 +180,7 @@ throw new IndexOutOfBoundsException(MessageFormat.format( "Index {0,number,integer} >= {1,number,integer}", - index, +Math.min(pos, 0))); + index, Math.min(pos, 0))); } /* (non-Javadoc) Modified: branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesReferenceGlyph.java =================================================================== --- branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesReferenceGlyph.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesReferenceGlyph.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -179,7 +179,7 @@ throw new IndexOutOfBoundsException(MessageFormat.format( "Index {0,number,integer} >= {1,number,integer}", - index, +Math.min(pos, 0))); + index, Math.min(pos, 0))); } /* (non-Javadoc) Modified: branches/astnode2-merging-alternate/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiModelPlugin.java =================================================================== --- branches/astnode2-merging-alternate/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiModelPlugin.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiModelPlugin.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -1,321 +1,321 @@ -/* - * $Id$ - * $URL$ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit <http://sbml.org/Software/JSBML> - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2015 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * 4. The University of California, San Diego, La Jolla, CA, USA - * 5. The Babraham Institute, Cambridge, UK - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as <http://sbml.org/Software/JSBML/License>. - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.ext.multi; - -import java.text.MessageFormat; -import java.util.Map; - -import org.sbml.jsbml.ListOf; -import org.sbml.jsbml.Model; -import org.sbml.jsbml.SBMLDocument; -import org.sbml.jsbml.SBase; -import org.sbml.jsbml.ext.AbstractSBasePlugin; -import org.sbml.jsbml.util.filters.NameFilter; - -/** - * In order to encode the structures needed to define and use multistate and multi-component - * complexes, the element model is extended to be linked to a list of {@link SpeciesType}s. - * - * @author Nicolas Rodriguez - * @version $Rev$ - * @since 1.0 - */ -public class MultiModelPlugin extends AbstractSBasePlugin { - - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.SBasePlugin#getPackageName() - */ - @Override - public String getPackageName() { - return MultiConstants.shortLabel; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.SBasePlugin#getPrefix() - */ - @Override - public String getPrefix() { - return MultiConstants.shortLabel; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.SBasePlugin#getURI() - */ - @Override - public String getURI() { - return getElementNamespace(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractTreeNode#getParent() - */ - @Override - public SBMLDocument getParent() { - return (SBMLDocument) getExtendedSBase().getParent(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.AbstractSBasePlugin#getParentSBMLObject() - */ - @Override - public SBMLDocument getParentSBMLObject() { - return getParent(); - } - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -2875299722787282885L; - /** - * - */ - ListOf<SpeciesType> listOfSpeciesTypes; - - /** - * - * @param model - */ - public MultiModelPlugin(Model model) { - super(model); - setNamespace(MultiConstants.namespaceURI); // TODO - removed once the mechanism are in place to set package version and namespace - } - - /** - * - * @param multiModel - */ - public MultiModelPlugin(MultiModelPlugin multiModel) { - super(multiModel); - - if (multiModel == null) { - return; - } - if (multiModel.isSetListOfSpeciesTypes()) { - setListOfSpeciesTypes(multiModel.getListOfSpeciesTypes().clone()); - } - } - - @Override - public MultiModelPlugin clone() { - return new MultiModelPlugin(this); - } - - /** - * Returns the {@link Model} - * - * @return the {@link Model} - */ - public Model getModel() { - return (Model) extendedSBase; - } - - - /** - * Returns the listOfSpeciesTypes. - * - * @return the listOfSpeciesTypes - */ - public ListOf<SpeciesType> getListOfSpeciesTypes() { - if (listOfSpeciesTypes == null) { - listOfSpeciesTypes = new ListOf<SpeciesType>(); - listOfSpeciesTypes.setNamespace(MultiConstants.namespaceURI); // TODO - removed once the mechanism are in place to set package version and namespace - listOfSpeciesTypes.setPackageVersion(-1); - // changing the ListOf package name from 'core' to 'multi' - listOfSpeciesTypes.setPackageName(null); - listOfSpeciesTypes.setPackageName(MultiConstants.shortLabel); - listOfSpeciesTypes.setSBaseListType(ListOf.Type.other); - - if (isSetExtendedSBase()) { - extendedSBase.registerChild(listOfSpeciesTypes); - } - } - - return listOfSpeciesTypes; - } - - /** - * Adds a {@link SpeciesType}. - * - * @param speciesType the speciesType to add - * @return - */ - public boolean addSpeciesType(SpeciesType speciesType) { - return getListOfSpeciesTypes().add(speciesType); - } - - /** - * Creates a new {@link SpeciesType} inside this {@link MultiModelPlugin} and returns it. - * <p> - * - * @return the {@link SpeciesType} object created - * <p> - * @see #addSpeciesType(SpeciesType r) - */ - public SpeciesType createSpeciesType() { - return createSpeciesType(null); - } - - /** - * Creates a new {@link SpeciesType} inside this {@link MultiModelPlugin} and returns it. - * - * @param id - * the id of the new element to create - * @return the {@link SpeciesType} object created - */ - public SpeciesType createSpeciesType(String id) { - SpeciesType speciesType = new SpeciesType(); - speciesType.setId(id); - addSpeciesType(speciesType); - - return speciesType; - } - - /** - * Gets the ith {@link SpeciesType}. - * - * @param i - * - * @return the ith {@link SpeciesType} - * @throws IndexOutOfBoundsException if the index is invalid. - */ - public SpeciesType getSpeciesType(int i) { - return getListOfSpeciesTypes().get(i); - } - - /** - * Gets the {@link SpeciesType} that has the given id. - * - * @param id - * @return the {@link SpeciesType} that has the given id or null if - * no {@link SpeciesType} are found that match {@code id}. - */ - public SpeciesType getSpeciesType(String id) { - if (isSetListOfSpeciesTypes()) { - return listOfSpeciesTypes.firstHit(new NameFilter(id)); - } - return null; - } - - /** - * Returns {@code true} if the listOfSpeciesType is set. - * - * @return {@code true} if the listOfSpeciesType is set. - */ - public boolean isSetListOfSpeciesTypes() { - return listOfSpeciesTypes != null; - } - - /** - * Sets the listOfSpeciesTypes. If there was already some elements defined - * on listOfSpeciesTypes, they will be unset beforehand. - * - * @param listOfSpeciesTypes - */ - public void setListOfSpeciesTypes(ListOf<SpeciesType> listOfSpeciesTypes) { - unsetListOfSpeciesTypes(); - this.listOfSpeciesTypes = listOfSpeciesTypes; - - if (listOfSpeciesTypes != null) { - listOfSpeciesTypes.unsetNamespace(); - listOfSpeciesTypes.setNamespace(MultiConstants.namespaceURI); // TODO - removed once the mechanism are in place to set package version and namespace - listOfSpeciesTypes.setPackageVersion(-1); - // changing the ListOf package name from 'core' to 'multi' - listOfSpeciesTypes.setPackageName(null); - listOfSpeciesTypes.setPackageName(MultiConstants.shortLabel); - listOfSpeciesTypes.setSBaseListType(ListOf.Type.other); - } - if (extendedSBase != null) { - extendedSBase.registerChild(this.listOfSpeciesTypes); - } - } - - - /** - * Sets the listOfSpeciesTypes to null - * - * @return {@code true} is successful - */ - public boolean unsetListOfSpeciesTypes() { - if (isSetListOfSpeciesTypes()) { - ListOf<SpeciesType> oldSpeciesTypeElements = listOfSpeciesTypes; - listOfSpeciesTypes = null; - oldSpeciesTypeElements.fireNodeRemovedEvent(); - return true; - } - return false; - } - - - - @Override - public boolean readAttribute(String attributeName, String prefix, String value) { - // no attribute to read - return false; - } - - /* (non-Javadoc) - * @see javax.swing.tree.TreeNode#getChildAt(int) - */ - @Override - public SBase getChildAt(int childIndex) { - if (childIndex < 0) { - throw new IndexOutOfBoundsException(childIndex + " < 0"); - } - - int pos = 0; - if (isSetListOfSpeciesTypes()) { - if (pos == childIndex) { - return getListOfSpeciesTypes(); - } - pos++; - } - - throw new IndexOutOfBoundsException(MessageFormat.format( - "Index {0,number,integer} >= {1,number,integer}", - childIndex, +Math.min(pos, 0))); - } - - /* (non-Javadoc) - * @see javax.swing.tree.TreeNode#getChildCount() - */ - @Override - public int getChildCount() { - int count = 0; - if (isSetListOfSpeciesTypes()) { - count++; - } - - return count; - } - - @Override - public boolean getAllowsChildren() { - return true; - } - - @Override - public Map<String, String> writeXMLAttributes() { - // no attribute to write - return null; - } - - -} +/* + * $Id$ + * $URL$ + * ---------------------------------------------------------------------------- + * This file is part of JSBML. Please visit <http://sbml.org/Software/JSBML> + * for the latest version of JSBML and more information about SBML. + * + * Copyright (C) 2009-2015 jointly by the following organizations: + * 1. The University of Tuebingen, Germany + * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK + * 3. The California Institute of Technology, Pasadena, CA, USA + * 4. The University of California, San Diego, La Jolla, CA, USA + * 5. The Babraham Institute, Cambridge, UK + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation. A copy of the license agreement is provided + * in the file named "LICENSE.txt" included with this software distribution + * and also available online as <http://sbml.org/Software/JSBML/License>. + * ---------------------------------------------------------------------------- + */ +package org.sbml.jsbml.ext.multi; + +import java.text.MessageFormat; +import java.util.Map; + +import org.sbml.jsbml.ListOf; +import org.sbml.jsbml.Model; +import org.sbml.jsbml.SBMLDocument; +import org.sbml.jsbml.SBase; +import org.sbml.jsbml.ext.AbstractSBasePlugin; +import org.sbml.jsbml.util.filters.NameFilter; + +/** + * In order to encode the structures needed to define and use multistate and multi-component + * complexes, the element model is extended to be linked to a list of {@link SpeciesType}s. + * + * @author Nicolas Rodriguez + * @version $Rev$ + * @since 1.0 + */ +public class MultiModelPlugin extends AbstractSBasePlugin { + + /* (non-Javadoc) + * @see org.sbml.jsbml.ext.SBasePlugin#getPackageName() + */ + @Override + public String getPackageName() { + return MultiConstants.shortLabel; + } + + /* (non-Javadoc) + * @see org.sbml.jsbml.ext.SBasePlugin#getPrefix() + */ + @Override + public String getPrefix() { + return MultiConstants.shortLabel; + } + + /* (non-Javadoc) + * @see org.sbml.jsbml.ext.SBasePlugin#getURI() + */ + @Override + public String getURI() { + return getElementNamespace(); + } + + /* (non-Javadoc) + * @see org.sbml.jsbml.AbstractTreeNode#getParent() + */ + @Override + public SBMLDocument getParent() { + return (SBMLDocument) getExtendedSBase().getParent(); + } + + /* (non-Javadoc) + * @see org.sbml.jsbml.ext.AbstractSBasePlugin#getParentSBMLObject() + */ + @Override + public SBMLDocument getParentSBMLObject() { + return getParent(); + } + /** + * Generated serial version identifier. + */ + private static final long serialVersionUID = -2875299722787282885L; + /** + * + */ + ListOf<SpeciesType> listOfSpeciesTypes; + + /** + * + * @param model + */ + public MultiModelPlugin(Model model) { + super(model); + setNamespace(MultiConstants.namespaceURI); // TODO - removed once the mechanism are in place to set package version and namespace + } + + /** + * + * @param multiModel + */ + public MultiModelPlugin(MultiModelPlugin multiModel) { + super(multiModel); + + if (multiModel == null) { + return; + } + if (multiModel.isSetListOfSpeciesTypes()) { + setListOfSpeciesTypes(multiModel.getListOfSpeciesTypes().clone()); + } + } + + @Override + public MultiModelPlugin clone() { + return new MultiModelPlugin(this); + } + + /** + * Returns the {@link Model} + * + * @return the {@link Model} + */ + public Model getModel() { + return (Model) extendedSBase; + } + + + /** + * Returns the listOfSpeciesTypes. + * + * @return the listOfSpeciesTypes + */ + public ListOf<SpeciesType> getListOfSpeciesTypes() { + if (listOfSpeciesTypes == null) { + listOfSpeciesTypes = new ListOf<SpeciesType>(); + listOfSpeciesTypes.setNamespace(MultiConstants.namespaceURI); // TODO - removed once the mechanism are in place to set package version and namespace + listOfSpeciesTypes.setPackageVersion(-1); + // changing the ListOf package name from 'core' to 'multi' + listOfSpeciesTypes.setPackageName(null); + listOfSpeciesTypes.setPackageName(MultiConstants.shortLabel); + listOfSpeciesTypes.setSBaseListType(ListOf.Type.other); + + if (isSetExtendedSBase()) { + extendedSBase.registerChild(listOfSpeciesTypes); + } + } + + return listOfSpeciesTypes; + } + + /** + * Adds a {@link SpeciesType}. + * + * @param speciesType the speciesType to add + * @return + */ + public boolean addSpeciesType(SpeciesType speciesType) { + return getListOfSpeciesTypes().add(speciesType); + } + + /** + * Creates a new {@link SpeciesType} inside this {@link MultiModelPlugin} and returns it. + * <p> + * + * @return the {@link SpeciesType} object created + * <p> + * @see #addSpeciesType(SpeciesType r) + */ + public SpeciesType createSpeciesType() { + return createSpeciesType(null); + } + + /** + * Creates a new {@link SpeciesType} inside this {@link MultiModelPlugin} and returns it. + * + * @param id + * the id of the new element to create + * @return the {@link SpeciesType} object created + */ + public SpeciesType createSpeciesType(String id) { + SpeciesType speciesType = new SpeciesType(); + speciesType.setId(id); + addSpeciesType(speciesType); + + return speciesType; + } + + /** + * Gets the ith {@link SpeciesType}. + * + * @param i + * + * @return the ith {@link SpeciesType} + * @throws IndexOutOfBoundsException if the index is invalid. + */ + public SpeciesType getSpeciesType(int i) { + return getListOfSpeciesTypes().get(i); + } + + /** + * Gets the {@link SpeciesType} that has the given id. + * + * @param id + * @return the {@link SpeciesType} that has the given id or null if + * no {@link SpeciesType} are found that match {@code id}. + */ + public SpeciesType getSpeciesType(String id) { + if (isSetListOfSpeciesTypes()) { + return listOfSpeciesTypes.firstHit(new NameFilter(id)); + } + return null; + } + + /** + * Returns {@code true} if the listOfSpeciesType is set. + * + * @return {@code true} if the listOfSpeciesType is set. + */ + public boolean isSetListOfSpeciesTypes() { + return listOfSpeciesTypes != null; + } + + /** + * Sets the listOfSpeciesTypes. If there was already some elements defined + * on listOfSpeciesTypes, they will be unset beforehand. + * + * @param listOfSpeciesTypes + */ + public void setListOfSpeciesTypes(ListOf<SpeciesType> listOfSpeciesTypes) { + unsetListOfSpeciesTypes(); + this.listOfSpeciesTypes = listOfSpeciesTypes; + + if (listOfSpeciesTypes != null) { + listOfSpeciesTypes.unsetNamespace(); + listOfSpeciesTypes.setNamespace(MultiConstants.namespaceURI); // TODO - removed once the mechanism are in place to set package version and namespace + listOfSpeciesTypes.setPackageVersion(-1); + // changing the ListOf package name from 'core' to 'multi' + listOfSpeciesTypes.setPackageName(null); + listOfSpeciesTypes.setPackageName(MultiConstants.shortLabel); + listOfSpeciesTypes.setSBaseListType(ListOf.Type.other); + } + if (extendedSBase != null) { + extendedSBase.registerChild(this.listOfSpeciesTypes); + } + } + + + /** + * Sets the listOfSpeciesTypes to null + * + * @return {@code true} is successful + */ + public boolean unsetListOfSpeciesTypes() { + if (isSetListOfSpeciesTypes()) { + ListOf<SpeciesType> oldSpeciesTypeElements = listOfSpeciesTypes; + listOfSpeciesTypes = null; + oldSpeciesTypeElements.fireNodeRemovedEvent(); + return true; + } + return false; + } + + + + @Override + public boolean readAttribute(String attributeName, String prefix, String value) { + // no attribute to read + return false; + } + + /* (non-Javadoc) + * @see javax.swing.tree.TreeNode#getChildAt(int) + */ + @Override + public SBase getChildAt(int childIndex) { + if (childIndex < 0) { + throw new IndexOutOfBoundsException(childIndex + " < 0"); + } + + int pos = 0; + if (isSetListOfSpeciesTypes()) { + if (pos == childIndex) { + return getListOfSpeciesTypes(); + } + pos++; + } + + throw new IndexOutOfBoundsException(MessageFormat.format( + "Index {0,number,integer} >= {1,number,integer}", + childIndex, Math.min(pos, 0))); + } + + /* (non-Javadoc) + * @see javax.swing.tree.TreeNode#getChildCount() + */ + @Override + public int getChildCount() { + int count = 0; + if (isSetListOfSpeciesTypes()) { + count++; + } + + return count; + } + + @Override + public boolean getAllowsChildren() { + return true; + } + + @Override + public Map<String, String> writeXMLAttributes() { + // no attribute to write + return null; + } + + +} Modified: branches/astnode2-merging-alternate/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiSpeciesPlugin.java =================================================================== --- branches/astnode2-merging-alternate/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiSpeciesPlugin.java 2015-05-01 09:53:13 UTC (rev 2269) +++ branches/astnode2-merging-alternate/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiSpeciesPlugin.java 2015-05-01 09:56:17 UTC (rev 2270) @@ -1,672 +1,672 @@ -/* - * $Id$ - * $URL$ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit <http://sbml.org/Software/JSBML> - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2015 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * 4. The University of California, San Diego, La Jolla, CA, USA - * 5. The Babraham Institute, Cambridge, UK - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as <http://sbml.org/Software/JSBML/License>. - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.ext.multi; - -import java.text.MessageFormat; -import java.util.Map; - -import org.sbml.jsbml.ListOf; -import org.sbml.jsbml.SBase; -import org.sbml.jsbml.Species; -import org.sbml.jsbml.ext.AbstractSBasePlugin; - -/** - * - * @author Nicolas Rodriguez - * @author Marine Dumousseau - * @since 1.0 - * @version $Rev$ - */ -public class MultiSpeciesPlugin extends AbstractSBasePlugin { - - // TODO - implements IdManager: SpeciesFeature are id unique within one Species - - - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.SBasePlugin#getPackageName() - */ - @Override - public String getPackageName() { - return MultiConstants.shortLabel; - } - - - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.SBasePlugin#getPrefix() - */ - @Override - public String getPrefix() { - return MultiConstants.shortLabel; - } - - - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.SBasePlugin#getURI() - */ - @Override - public String getURI() { - return getElementNamespace(); - } - - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -5396837209115412420L; - - /** - * - */ - private ListOf<OutwardBindingSite> listOfOutwardBindingSites; - - /** - * - */ - private ListOf<SpeciesFeature> listOfSpeciesFeatures; - - /** - * - */ - private String speciesType; - - /** - * - * @param species - */ - public MultiSpeciesPlugin(Species species) { - super(species); - setNamespace(MultiConstants.namespaceURI); // TODO - removed once the mechanism are in place to set package version and namespace - } - - - /** - * @param multiSpecies - */ - public MultiSpeciesPlugin(MultiSpeciesPlugin multiSpecies) { - super(multiSpecies); - - // c... [truncated message content] |