From: <nik...@us...> - 2015-05-01 09:53:15
|
Revision: 2269 http://sourceforge.net/p/jsbml/code/2269 Author: niko-rodrigue Date: 2015-05-01 09:53:13 +0000 (Fri, 01 May 2015) Log Message: ----------- merged from trunk until rev 2226 Revision Links: -------------- http://sourceforge.net/p/jsbml/code/2226 Modified Paths: -------------- branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/AbstractSBase.java branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/CVTerm.java branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/SBase.java branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/xml/XMLAttributes.java branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/ParametricGeometry.java branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/SpatialModelPlugin.java branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/SpatialReactionPlugin.java branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/TransformationComponent.java branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/xml/parsers/SpatialParser.java Added Paths: ----------- branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/CompressionKind.java branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/DataKind.java Property Changed: ---------------- branches/astnode2-merging-alternate/ Index: branches/astnode2-merging-alternate =================================================================== --- branches/astnode2-merging-alternate 2015-05-01 09:46:00 UTC (rev 2268) +++ branches/astnode2-merging-alternate 2015-05-01 09:53:13 UTC (rev 2269) Property changes on: branches/astnode2-merging-alternate ___________________________________________________________________ Modified: svn:mergeinfo ## -1 +1 ## -/trunk:2191,2194-2195,2197-2200,2202-2206,2209-2213,2216-2217 +/trunk:2191,2194-2195,2197-2200,2202-2206,2209-2213,2216-2220,2222,2224-2226 \ No newline at end of property 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:46:00 UTC (rev 2268) +++ branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/AbstractSBase.java 2015-05-01 09:53:13 UTC (rev 2269) @@ -318,10 +318,9 @@ */ @Override public void addDeclaredNamespace(String prefix, String namespace) { - if ((!prefix.startsWith("xmlns:")) && (!prefix.equals("xmlns"))) { if (prefix.indexOf(":") != -1) { - throw new IllegalArgumentException("The only allowed prefix for a namespace is 'xmlns:'."); + throw new IllegalArgumentException(resourceBundle.getString("AbstractSBase.addDeclaredNamespace")); } prefix = "xmlns:" + prefix; } @@ -360,7 +359,7 @@ firePropertyChange(TreeNodeChangeEvent.addExtension, null, sbasePlugin); } else { throw new IllegalArgumentException(MessageFormat.format( - "The package namespace or name ''{0}'' is unknown!", nameOrUri)); + resourceBundle.getString("AbstractSBase.addExtensionExc"), nameOrUri)); } } @@ -384,12 +383,12 @@ * @param namespace the XML namespace to which this {@link SBase} belong. */ public void setNamespace(String namespace) { - if ((elementNamespace != null) && (!elementNamespace.equals(namespace))) { // if we implement proper conversion some days, we need to unset the namespace before changing it. - logger.error(MessageFormat.format("An SBase element cannot belong to two different namespaces! Current namespace = ''{0}'', new namespace = ''{1}''", elementNamespace, namespace)); - // throw new IllegalArgumentException(MessageFormat.format("An SBase element cannot belong to two different namespaces ! " - // + "Current namespace = '{0}', new namespace = '{1}' ", elementNamespace, namespace)); + logger.error(MessageFormat.format( + resourceBundle.getString("AbstractSBase.setNamespaceExc"), + elementNamespace, namespace)); + // throw new IllegalArgumentException(MessageFormat.format(resourceBundle.getString("AbstractSBase.setNamespaceExc"), elementNamespace, namespace)); } String old = elementNamespace; elementNamespace = namespace; @@ -496,7 +495,7 @@ else { // the given notes is empty - logger.info("The notes to append are empty !!"); + logger.info(resourceBundle.getString("AbstractSBase.emptyNotes")); return; } } @@ -533,7 +532,7 @@ // The given notes node needs to be added to a parent node // if the node is neither "html" nor "body" element because the // children of addedNotes will be added to the current notes later if the - // node is neither "html" nor "body" (i.e. any XHTML element that + // node is neither "html" nor "body" (i.e., any XHTML element that // would be permitted within a "body" element) addedNotes.addChild(notes); addedNotesType = NOTES_TYPE.NotesAny; @@ -569,7 +568,7 @@ if (!headFound || !bodyFound || otherElementFound) { // TODO - throw an exception as well - logger.warn("The given 'notes' String does not have the proper structure, excepting the children 'head' and 'body' to the 'html' element."); + logger.warn(resourceBundle.getString("AbstractSBase.invalidNotesStructure")); return; } } @@ -639,7 +638,9 @@ for (i=0; i < addedBody.getChildCount(); i++) { if (curBody.addChild(addedBody.getChildAt(i)) < 0) { - logger.warn("There was a problem adding the given XMLNode: '" + SBMLtools.toXML(addedBody.getChildAt(i)) + "' to the 'body' XMLNode."); + logger.warn(MessageFormat.format( + resourceBundle.getString("AbstractSBase.problemAddingXMLNode"), + SBMLtools.toXML(addedBody.getChildAt(i)))); return; } } @@ -650,10 +651,12 @@ // adds the given body or other tag (permitted in the body) to the current // html tag - for (i=0; i < addedNotes.getChildCount(); i++) + for (i = 0; i < addedNotes.getChildCount(); i++) { if (curBody.addChild(addedNotes.getChildAt(i)) < 0) { - logger.warn("There was a problem adding the given XMLNode: '" + SBMLtools.toXML(addedNotes.getChildAt(i)) + "' to the 'body' XMLNode."); + logger.warn(MessageFormat.format( + resourceBundle.getString("AbstractSBase.problemAddingXMLNode"), + SBMLtools.toXML(addedNotes.getChildAt(i)))); return; } } @@ -1775,7 +1778,7 @@ // Could/Should be used by the method #firePropertyChange // TODO - set package version and namespace if needed - + int childCount = sbasePlugin.getChildCount(); if (childCount > 0) { @@ -1828,6 +1831,22 @@ } /* (non-Javadoc) + * @see org.sbml.jsbml.SBase#setAnnotation(org.sbml.jsbml.xml.XMLNode) + */ + @Override + public void setAnnotation(XMLNode nonRDFAnnotation) { + getAnnotation().setNonRDFAnnotation(nonRDFAnnotation); + } + + /* (non-Javadoc) + * @see org.sbml.jsbml.SBase#setAnnotation(java.lang.String) + */ + @Override + public void setAnnotation(String nonRDFAnnotation) throws XMLStreamException { + setAnnotation(XMLNode.convertStringToXMLNode(StringTools.toXMLAnnotationString(nonRDFAnnotation))); + } + + /* (non-Javadoc) * @see org.sbml.jsbml.SBase#setHistory(org.sbml.jsbml.History) */ @Override @@ -2204,7 +2223,7 @@ return; } - throw new IllegalArgumentException(MessageFormat.format("The package namespace or name ''{0}'' is unknown!!", nameOrUri)); + throw new IllegalArgumentException(MessageFormat.format("The package namespace or name ''{0}'' is unknown!", nameOrUri)); } @Override 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:46:00 UTC (rev 2268) +++ branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/CVTerm.java 2015-05-01 09:53:13 UTC (rev 2269) @@ -29,10 +29,13 @@ 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; import org.sbml.jsbml.util.TreeNodeChangeEvent; +import org.sbml.jsbml.xml.XMLAttributes; +import org.sbml.jsbml.xml.XMLNode; /** * Contains all the MIRIAM URIs for a MIRIAM qualifier in the annotation element @@ -507,6 +510,42 @@ } /** + * + * @param miriam + */ + public CVTerm(XMLNode miriam) { + this(); + if (miriam.getName().equals("annotation")) { + miriam = miriam.getChildAt(0); + } + if (miriam.getName().equals("RDF")) { + miriam = miriam.getChildAt(0); + } + if (miriam.getName().equals("Description")) { + miriam = miriam.getChildAt(0); + } + if (miriam.getURI().equals("http://biomodels.net/biology-qualifiers/")) { + if (miriam.getPrefix().equals("bqbiol")) { + setQualifier(Qualifier.getBiologicalQualifierFor(miriam.getName())); + } else { + setQualifier(Qualifier.getModelQualifierFor(miriam.getName())); + } + miriam = miriam.getChildAt(0); + } + if (miriam.getName().equals("Bag")) { + for (int j = 0; j < miriam.getChildCount(); j++) { + XMLNode child = miriam.getChildAt(j); + if (child.getName().equals("li")) { + XMLAttributes attributes = child.getAttributes(); + for (int i = 0; i < attributes.size(); i++) { + addResource(attributes.getValue(i)); + } + } + } + } + } + + /** * Creates a {@link CVTerm} instance from a given {@link CVTerm}. * * @param term the {@link CVTerm} to clone Modified: branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/SBase.java =================================================================== --- branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/SBase.java 2015-05-01 09:46:00 UTC (rev 2268) +++ branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/SBase.java 2015-05-01 09:53:13 UTC (rev 2269) @@ -503,15 +503,15 @@ public int getCVTermCount(); /** - * Returns the name of the SBML Level 3 package in which this element is defined, as + * Returns the name of the SBML Level 3 package in which this element is defined, as * defined in <a href="http://sbml.org/Community/Wiki"> the sbml.org community wiki</a>. * - * <p> For example, the string "core" will be returned if this element is defined in SBML Level 3 Core. + * <p> For example, the string "core" will be returned if this element is defined in SBML Level 3 Core. * * @return the name of the SBML Level 3 package in which this element is defined. */ public String getPackageName(); - + /** * Returns the version of the SBML Level 3 package to which this element belongs. * @@ -522,7 +522,7 @@ * @return the version of the SBML Level 3 package to which this element belongs. */ public int getPackageVersion(); - + /** * Returns the parent of this {@link SBase}. * @@ -584,16 +584,16 @@ /** * Returns the namespace to which this {@link SBase} belong to. Same as {@link #getNamespace()}. * - * <p>For example, all elements that belong to Layout Extension Version 1 for SBML Level 3 Version 1 Core + * <p>For example, all elements that belong to Layout Extension Version 1 for SBML Level 3 Version 1 Core * must have the URI 'http://www.sbml.org/sbml/level3/version1/layout/version1'. * <p>The elements that belong to SBML core might return null. * * @return the namespace to which this {@link SBase} belong to. * @see SBase#getNamespace() - * @libsbml.deprecated + * @libsbml.deprecated */ public String getURI(); - + /** * Returns the Version within the SBML Level of the overall SBML document. * Return -1 if it is not set. @@ -858,6 +858,19 @@ public void setAnnotation(Annotation annotation); /** + * + * @param nonRDFAnnotation + */ + public void setAnnotation(XMLNode nonRDFAnnotation); + + /** + * + * @param nonRDFAnnotation + * @throws XMLStreamException + */ + public void setAnnotation(String nonRDFAnnotation) throws XMLStreamException; + + /** * Sets the history. * * @param history the history of this {@link SBase} Modified: branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/xml/XMLAttributes.java =================================================================== --- branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/xml/XMLAttributes.java 2015-05-01 09:46:00 UTC (rev 2268) +++ branches/astnode2-merging-alternate/core/src/org/sbml/jsbml/xml/XMLAttributes.java 2015-05-01 09:53:13 UTC (rev 2269) @@ -510,11 +510,18 @@ * @return the number of attributes in this {@link XMLAttributes} set. */ public int getLength() { + return attributeNames.size(); + } + /** + * + * @return + * @see #getLength() + */ + public int size() { return attributeNames.size(); } - /** * Returns the local name of an attribute in this {@link XMLAttributes} set (by position). * <p> Copied: branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/CompressionKind.java (from rev 2226, trunk/extensions/spatial/src/org/sbml/jsbml/ext/spatial/CompressionKind.java) =================================================================== --- branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/CompressionKind.java (rev 0) +++ branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/CompressionKind.java 2015-05-01 09:53:13 UTC (rev 2269) @@ -0,0 +1,44 @@ +/* + * $Id: CompressionKind.java 2206 2015-04-23 09:57:59Z pdp10 $ + * $URL: svn+ssh://pd...@sv.../p/jsbml/code/trunk/extensions/spatial/src/org/sbml/jsbml/ext/spatial/CompressionKind.java $ + * ---------------------------------------------------------------------------- + * 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.spatial; + +/** + * This enum type was created following the specifications defined in Spatial Package v0.90. + * @author Piero Dalle Pezze + * @version $Rev$ + * @since 1.0 + * @date 23 Apr 2015 + */ +public enum CompressionKind { + /** + * If no compression is used + */ + UNCOMPRESSED, + /** + * If the deflation algorithm was used to compress the text version of the data + */ + DEFLATED, + /** + * If the base 64 algorithm was used to transform the binary form of the actual members into text + */ + BASE64; +} \ No newline at end of file Copied: branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/DataKind.java (from rev 2226, trunk/extensions/spatial/src/org/sbml/jsbml/ext/spatial/DataKind.java) =================================================================== --- branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/DataKind.java (rev 0) +++ branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/DataKind.java 2015-05-01 09:53:13 UTC (rev 2269) @@ -0,0 +1,53 @@ +/* + * $Id: DataKind.java 2206 2015-04-23 09:57:59Z pdp10 $ + * $URL: svn+ssh://pd...@sv.../p/jsbml/code/trunk/extensions/spatial/src/org/sbml/jsbml/ext/spatial/DataKind.java $ + * ---------------------------------------------------------------------------- + * 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.spatial; + + +/** + * This enum type was created following the specifications defined in Spatial Package v0.90. + * @author Piero Dalle Pezze + * @version $Rev$ + * @since 1.0 + * @date 23 Apr 2015 + */ +public enum DataKind { + /** + * To indicate 8-bit unsigned integer + */ + UINT8, + /** + * To indicate 16-bit unsigned integer + */ + UINT16, + /** + * To indicate 32-bit unsigned integer + */ + UINT32, + /** + * To indicate single-precision (32-bit) floating point values + */ + FLOAT, + /** + * To indicate double-precision (64-bit) floating point values + */ + DOUBLE; +} \ No newline at end of file Modified: branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/ParametricGeometry.java =================================================================== --- branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/ParametricGeometry.java 2015-05-01 09:46:00 UTC (rev 2268) +++ branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/ParametricGeometry.java 2015-05-01 09:53:13 UTC (rev 2269) @@ -28,6 +28,7 @@ import javax.swing.tree.TreeNode; import org.sbml.jsbml.ListOf; +import org.sbml.jsbml.PropertyUndefinedError; /** * @author Alex Thomas @@ -41,7 +42,7 @@ /** * */ - ListOf<SpatialPoints> listOfSpatialPoints; + SpatialPoints spatialPoints; /** * */ @@ -69,8 +70,8 @@ setListOfParametricObjects(pg.getListOfParametricObjects().clone()); } - if (pg.isSetListOfSpatialPoints()) { - setListOfSpatialPoints(pg.getListOfSpatialPoints().clone()); + if (pg.isSetSpatialPoints()) { + setSpatialPoints(pg.getSpatialPoints().clone()); } } @@ -113,9 +114,9 @@ equal &= pg.getListOfParametricObjects().equals(getListOfParametricObjects()); } - equal &= pg.isSetListOfSpatialPoints() == isSetListOfSpatialPoints(); - if (equal && isSetListOfSpatialPoints()) { - equal &= pg.getListOfSpatialPoints().equals(getListOfSpatialPoints()); + equal &= pg.isSetSpatialPoints() == isSetSpatialPoints(); + if (equal && isSetSpatialPoints()) { + equal &= pg.getSpatialPoints().equals(getSpatialPoints()); } } @@ -129,8 +130,8 @@ if (isSetListOfParametricObjects()) { hashCode += prime * getListOfParametricObjects().hashCode(); } - if (isSetListOfSpatialPoints()) { - hashCode += prime * getListOfSpatialPoints().hashCode(); + if (isSetSpatialPoints()) { + hashCode += prime * getSpatialPoints().hashCode(); } return hashCode; } @@ -251,7 +252,7 @@ //} /** * Creates a new ParametricObject element and adds it to the ListOfParametricObjects list - * @return + * @return a new {@link ParametricObject} element */ public ParametricObject createParametricObject() { return createParametricObject(null); @@ -270,146 +271,60 @@ return parametricObject; } - /** - * - */ - + /** - * Returns {@code true}, if listOfSpatialPoints contains at least one element. + * Returns the value of {@link #spatialPoints}. * - * @return {@code true}, if listOfSpatialPoints contains at least one element, - * otherwise {@code false} + * @return the value of {@link #spatialPoints}. */ - public boolean isSetListOfSpatialPoints() { - if ((listOfSpatialPoints == null) || listOfSpatialPoints.isEmpty()) { - return false; + public SpatialPoints getSpatialPoints() { + if (isSetSpatialPoints()) { + return spatialPoints; } - return true; + // This is necessary if we cannot return null here. For variables of type String return an empty String if no value is defined. + throw new PropertyUndefinedError(SpatialConstants.spatialPoints, this); } /** - * Returns the listOfSpatialPoints. Creates it if it is not already existing. + * Returns whether {@link #spatialPoints} is set. * - * @return the listOfSpatialPoints + * @return whether {@link #spatialPoints} is set. */ - public ListOf<SpatialPoints> getListOfSpatialPoints() { - if (!isSetListOfSpatialPoints()) { - listOfSpatialPoints = new ListOf<SpatialPoints>(getLevel(), - getVersion()); - listOfSpatialPoints.setNamespace(SpatialConstants.namespaceURI); - listOfSpatialPoints.setSBaseListType(ListOf.Type.other); - registerChild(listOfSpatialPoints); - } - return listOfSpatialPoints; + public boolean isSetSpatialPoints() { + return this.spatialPoints != null; } /** - * Sets the given {@code ListOf<SpatialPoint>}. If listOfSpatialPoints - * was defined before and contains some elements, they are all unset. + * Sets the value of spatialPoints * - * @param listOfSpatialPoints + * @param spatialPoints the value of spatialPoints to be set. */ - public void setListOfSpatialPoints(ListOf<SpatialPoints> listOfSpatialPoints) { - unsetListOfSpatialPoints(); - this.listOfSpatialPoints = listOfSpatialPoints; - registerChild(this.listOfSpatialPoints); + public void setSpatialPoints(SpatialPoints spatialPoints) { + SpatialPoints oldSpatialPoints = this.spatialPoints; + this.spatialPoints = spatialPoints; + firePropertyChange(SpatialConstants.spatialPoints, oldSpatialPoints, this.spatialPoints); } /** - * Returns {@code true}, if listOfSpatialPoints contain at least one element, - * otherwise {@code false} + * Unsets the variable spatialPoints. * - * @return {@code true}, if listOfSpatialPoints contain at least one element, - * otherwise {@code false} + * @return {@code true} if spatialPoints was set before, otherwise {@code false}. */ - public boolean unsetListOfSpatialPoints() { - if (isSetListOfSpatialPoints()) { - ListOf<SpatialPoints> oldSpatialPoints = listOfSpatialPoints; - listOfSpatialPoints = null; - oldSpatialPoints.fireNodeRemovedEvent(); + public boolean unsetSpatialPoints() { + if (isSetSpatialPoints()) { + SpatialPoints oldSpatialPoints = this.spatialPoints; + this.spatialPoints = null; + firePropertyChange(SpatialConstants.spatialPoints, oldSpatialPoints, this.spatialPoints); return true; } return false; } - /** - * Adds a new {@link SpatialPoints} to the listOfSpatialPoints. - * <p>The listOfSpatialPoints is initialized if necessary. - * - * @param spatialPoints the element to add to the list - * @return true (as specified by {@link Collection#add}) - */ - public boolean addSpatialPoints(SpatialPoints spatialPoints) { - return getListOfSpatialPoints().add(spatialPoints); - } - - - /** - * Removes an element from the listOfSpatialPoints. - * - * @param spatialPoints the element to be removed from the list - * @return true if the list contained the specified element - * @see List#remove(Object) - */ - public boolean removeSpatialPoints(SpatialPoints spatialPoints) { - if (isSetListOfSpatialPoints()) { - return getListOfSpatialPoints().remove(spatialPoints); - } - return false; - } - - - /** - * Removes an element from the listOfSpatialPoints at the given index. - * - * @param i the index where to remove the {@link SpatialPoint} - * @throws IndexOutOfBoundsException if the listOf is not set or - * if the index is out of bound (index < 0 || index > list.size) - */ - public void removeSpatialPoints(int i) { - if (!isSetListOfSpatialPoints()) { - throw new IndexOutOfBoundsException(Integer.toString(i)); - } - // if (getListOfSpatialPoints().size() == 1) { - // throw new SBMLException("There must be at least one SpatialPoint defined for this list"); - // } - getListOfSpatialPoints().remove(i); - } - - - /* - * TODO: if the ID is mandatory for SpatialPoints objects, - * one should also add this methods - */ - //public void removeSpatialPoints(String id) { - // getListOfSpatialPoints().removeFirst(new NameFilter(id)); - //} - /** - * Creates a new SpatialPoints element and adds it to the ListOfSpatialPoints list - * @return - */ - public SpatialPoints createSpatialPoints() { - return createSpatialPoints(null); - } - - - /** - * Creates a new {@link SpatialPoints} element and adds it to the ListOfSpatialPoints list - * @param id - * - * @return a new {@link SpatialPoints} element - */ - public SpatialPoints createSpatialPoints(String id) { - SpatialPoints spatialPoints = new SpatialPoints(getLevel(), getVersion()); - addSpatialPoints(spatialPoints); - return spatialPoints; - } - /* (non-Javadoc) * @see org.sbml.jsbml.ext.spatial.AbstractSpatialNamedSBase#getAllowsChildren() */ @@ -427,7 +342,7 @@ if (isSetListOfParametricObjects()) { count++; } - if (isSetListOfSpatialPoints()) { + if (isSetSpatialPoints()) { count++; } return count; @@ -453,9 +368,9 @@ } pos++; } - if (isSetListOfSpatialPoints()) { + if (isSetSpatialPoints()) { if (pos == index) { - return getListOfSpatialPoints(); + return getSpatialPoints(); } pos++; } Modified: branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/SpatialModelPlugin.java =================================================================== --- branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/SpatialModelPlugin.java 2015-05-01 09:46:00 UTC (rev 2268) +++ branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/SpatialModelPlugin.java 2015-05-01 09:53:13 UTC (rev 2269) @@ -330,5 +330,34 @@ return success; } + + /* + * (non-Javadoc) + * @see org.sbml.jsbml.ext.AbstractSBasePlugin#hashCode() + */ + @Override + public int hashCode() { + final int prime = 2039; + int hashCode = super.hashCode(); + if (isSetGeometry()) { + hashCode += prime * getGeometry().hashCode(); + } + return hashCode; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("SpatialModelPlugin [geometry="); + builder.append(geometry); + builder.append(", spatialIdMap="); + builder.append(spatialIdMap); + builder.append("]"); + return builder.toString(); + } + } Modified: branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/SpatialReactionPlugin.java =================================================================== --- branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/SpatialReactionPlugin.java 2015-05-01 09:46:00 UTC (rev 2268) +++ branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/SpatialReactionPlugin.java 2015-05-01 09:53:13 UTC (rev 2269) @@ -197,7 +197,7 @@ */ @Override public int hashCode() { - final int prime = 983;//Change this prime number + final int prime = 2039; int hashCode = super.hashCode(); if (isSetIsLocal()) { hashCode += prime * isLocal.hashCode(); Modified: branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/TransformationComponent.java =================================================================== --- branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/TransformationComponent.java 2015-05-01 09:46:00 UTC (rev 2268) +++ branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/ext/spatial/TransformationComponent.java 2015-05-01 09:53:13 UTC (rev 2269) @@ -29,7 +29,6 @@ import org.sbml.jsbml.AbstractSBase; import org.sbml.jsbml.PropertyUndefinedError; import org.sbml.jsbml.util.StringTools; -import org.sbml.jsbml.util.TreeNodeChangeEvent; /** * @author Alex Thomas @@ -112,6 +111,9 @@ if (equal && isSetComponents()) { equal &= tc.getComponents().equals(getComponents()); } + if (equal && isSetComponentsLength()) { + equal &= tc.getComponentsLength() == getComponentsLength(); + } } return equal; } @@ -178,7 +180,7 @@ */ public int getComponentsLength() { if (isSetComponentsLength()) { - return componentsLength; + return componentsLength.intValue(); } // This is necessary if we cannot return null here. throw new PropertyUndefinedError(SpatialConstants.componentsLength, this); @@ -204,6 +206,9 @@ if (isSetComponents()) { hashCode += prime * getComponents().hashCode(); } + if (isSetComponentsLength()) { + hashCode += prime * getComponentsLength(); + } return hashCode; } @@ -223,15 +228,6 @@ attributes.put(SpatialConstants.shortLabel + ":componentsLength", String.valueOf(getComponentsLength())); } - - if (isSetSBOTerm()) { - attributes.remove(TreeNodeChangeEvent.sboTerm); - attributes.put(SpatialConstants.shortLabel + ":" + TreeNodeChangeEvent.sboTerm, getSBOTermID()); - } - if (isSetMetaId()) { - attributes.remove(TreeNodeChangeEvent.metaId); - attributes.put(SpatialConstants.shortLabel + ":" + TreeNodeChangeEvent.metaId, getMetaId()); - } return attributes; } Modified: branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/xml/parsers/SpatialParser.java =================================================================== --- branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/xml/parsers/SpatialParser.java 2015-05-01 09:46:00 UTC (rev 2268) +++ branches/astnode2-merging-alternate/extensions/spatial/src/org/sbml/jsbml/xml/parsers/SpatialParser.java 2015-05-01 09:53:13 UTC (rev 2269) @@ -378,9 +378,9 @@ } } else if (contextObject instanceof ParametricGeometry) { ParametricGeometry pg = (ParametricGeometry) contextObject; - if (elementName.equals(SpatialConstants.listOfSpatialPoints)){ - ListOf<SpatialPoints> listOfSpatialPoints = pg.getListOfSpatialPoints(); - return listOfSpatialPoints; + if (elementName.equals(SpatialConstants.spatialPoints)){ + SpatialPoints spatialPoints = pg.getSpatialPoints(); + return spatialPoints; } else if (elementName.equals(SpatialConstants.listOfParametricObjects)){ ListOf<ParametricObject> listOfParametricObjects = pg.getListOfParametricObjects(); return listOfParametricObjects; @@ -497,7 +497,7 @@ } else if (elementName.equals(SpatialConstants.spatialPoints)) { ParametricGeometry pg = (ParametricGeometry) listOf.getParentSBMLObject(); SpatialPoints elem = new SpatialPoints(); - pg.addSpatialPoints(elem); + pg.setSpatialPoints(elem); return elem; } else if (elementName.equals(SpatialConstants.parametricObject)) { ParametricGeometry pg = (ParametricGeometry) listOf.getParentSBMLObject(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |