You can subscribe to this list here.
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(27) |
Jun
(63) |
Jul
(17) |
Aug
(58) |
Sep
(7) |
Oct
(9) |
Nov
(3) |
Dec
(9) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2013 |
Jan
(16) |
Feb
(5) |
Mar
(8) |
Apr
(3) |
May
(9) |
Jun
(7) |
Jul
(11) |
Aug
(1) |
Sep
(5) |
Oct
(33) |
Nov
(21) |
Dec
(32) |
2014 |
Jan
(8) |
Feb
(43) |
Mar
(36) |
Apr
(22) |
May
(69) |
Jun
(76) |
Jul
(66) |
Aug
(53) |
Sep
(39) |
Oct
(62) |
Nov
(28) |
Dec
(16) |
2015 |
Jan
(7) |
Feb
(2) |
Mar
(51) |
Apr
(97) |
May
(58) |
Jun
(20) |
Jul
(8) |
Aug
(5) |
Sep
(5) |
Oct
(27) |
Nov
(28) |
Dec
(43) |
2016 |
Jan
(17) |
Feb
(4) |
Mar
(12) |
Apr
(5) |
May
(15) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <nik...@us...> - 2012-06-15 08:50:10
|
Revision: 1314 http://jsbml.svn.sourceforge.net/jsbml/?rev=1314&view=rev Author: niko-rodrigue Date: 2012-06-15 08:49:59 +0000 (Fri, 15 Jun 2012) Log Message: ----------- corrected the Annotation.isSetAnnotation method to not create an History object when the History was not defined Modified Paths: -------------- trunk/core/src/org/sbml/jsbml/Annotation.java Modified: trunk/core/src/org/sbml/jsbml/Annotation.java =================================================================== --- trunk/core/src/org/sbml/jsbml/Annotation.java 2012-06-15 06:51:44 UTC (rev 1313) +++ trunk/core/src/org/sbml/jsbml/Annotation.java 2012-06-15 08:49:59 UTC (rev 1314) @@ -670,11 +670,11 @@ */ public boolean isSetAnnotation() { if ((getNonRDFannotation() == null) && getListOfCVTerms().isEmpty() - && getHistory().isEmpty()) + && !isSetHistory()) { return false; - } else if ((getNonRDFannotation() == null) && getHistory().isEmpty() + } else if ((getNonRDFannotation() == null) && !isSetHistory() && !getListOfCVTerms().isEmpty()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2012-06-15 06:51:50
|
Revision: 1313 http://jsbml.svn.sourceforge.net/jsbml/?rev=1313&view=rev Author: andreas-draeger Date: 2012-06-15 06:51:44 +0000 (Fri, 15 Jun 2012) Log Message: ----------- Added convenient methods in Layout again but this time with respect to interaction with multiple other packages, i.e., convenient methods do not return core elements such as species, but more general NamedSBases. Modified Paths: -------------- trunk/core/src/org/sbml/jsbml/SBMLDocument.java trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/CompartmentGlyph.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/extensions/layout/src/org/sbml/jsbml/ext/layout/TextGlyph.java trunk/modules/libSBMLio/src/org/sbml/jsbml/xml/libsbml/LibSBMLChangeListener.java Modified: trunk/core/src/org/sbml/jsbml/SBMLDocument.java =================================================================== --- trunk/core/src/org/sbml/jsbml/SBMLDocument.java 2012-06-14 16:27:15 UTC (rev 1312) +++ trunk/core/src/org/sbml/jsbml/SBMLDocument.java 2012-06-15 06:51:44 UTC (rev 1313) @@ -194,8 +194,8 @@ * @param URI */ public void addNamespace(String namespaceName, String prefix, String URI) { - if (prefix != null && prefix.trim().length() > 0) { - this.SBMLDocumentNamespaces.put(prefix + ":" + namespaceName, URI); + if ((prefix != null) && (prefix.trim().length() > 0)) { + this.SBMLDocumentNamespaces.put(prefix + ':' + namespaceName, URI); } else { this.SBMLDocumentNamespaces.put(namespaceName, URI); @@ -739,7 +739,7 @@ setVersion(StringTools.parseSBMLInt(value)); } if (prefix != null && prefix.trim().length() > 0) { - getSBMLDocumentAttributes().put(prefix + ":" + attributeName, value); + getSBMLDocumentAttributes().put(prefix + ':' + attributeName, value); } else { getSBMLDocumentAttributes().put(attributeName, value); } Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/CompartmentGlyph.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/CompartmentGlyph.java 2012-06-14 16:27:15 UTC (rev 1312) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/CompartmentGlyph.java 2012-06-15 06:51:44 UTC (rev 1313) @@ -22,6 +22,7 @@ import java.util.Map; import org.sbml.jsbml.Compartment; +import org.sbml.jsbml.NamedSBase; import org.sbml.jsbml.util.TreeNodeChangeEvent; /** @@ -94,6 +95,16 @@ public String getCompartment() { return getNamedSBase(); } + + /** + * Note that the return type of this method is {@link NamedSBase} because it + * could be possible to link some element from other packages to this glyph. + * + * @return + */ + public NamedSBase getCompartmentInstance() { + return getNamedSBaseInstance(); + } /** * @return Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/ReactionGlyph.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/ReactionGlyph.java 2012-06-14 16:27:15 UTC (rev 1312) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/ReactionGlyph.java 2012-06-15 06:51:44 UTC (rev 1313) @@ -25,6 +25,7 @@ import javax.swing.tree.TreeNode; import org.sbml.jsbml.ListOf; +import org.sbml.jsbml.NamedSBase; import org.sbml.jsbml.Reaction; /** @@ -214,8 +215,18 @@ } /** + * Note that the return type of this method is {@link NamedSBase} because it + * could be possible to link some element from other packages to this glyph. + * * @return */ + public NamedSBase getReactionInstance() { + return getNamedSBaseInstance(); + } + + /** + * @return + */ public boolean isSetCurve() { return curve != null; } Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesGlyph.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesGlyph.java 2012-06-14 16:27:15 UTC (rev 1312) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesGlyph.java 2012-06-15 06:51:44 UTC (rev 1313) @@ -21,6 +21,7 @@ import java.util.Map; +import org.sbml.jsbml.NamedSBase; import org.sbml.jsbml.Species; import org.sbml.jsbml.util.TreeNodeChangeEvent; @@ -95,6 +96,16 @@ public String getSpecies() { return getNamedSBase(); } + + /** + * Note that the return type of this method is {@link NamedSBase} because it + * could be possible to link some element from other packages to this glyph. + * + * @return + */ + public NamedSBase 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-06-14 16:27:15 UTC (rev 1312) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesReferenceGlyph.java 2012-06-15 06:51:44 UTC (rev 1313) @@ -23,6 +23,8 @@ import javax.swing.tree.TreeNode; +import org.sbml.jsbml.Model; +import org.sbml.jsbml.NamedSBase; import org.sbml.jsbml.SBMLException; import org.sbml.jsbml.SimpleSpeciesReference; @@ -186,6 +188,18 @@ public String getSpeciesGlyph() { return speciesGlyph; } + + /** + * + * @return + */ + public SpeciesGlyph getSpeciesGlyphInstance() { + if (!isSetSpeciesGlyph()) { + return null; + } + Model model = getModel(); + return (model != null) ? (SpeciesGlyph) model.findNamedSBase(getSpeciesGlyph()) : null; + } /** * @@ -194,6 +208,16 @@ public String getSpeciesReference() { return getNamedSBase(); } + + /** + * Note that the return type of this method is {@link NamedSBase} because it + * could be possible to link some element from other packages to this glyph. + * + * @return + */ + public NamedSBase getSpeciesReferenceInstance() { + return getNamedSBaseInstance(); + } /** * @return Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/TextGlyph.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/TextGlyph.java 2012-06-14 16:27:15 UTC (rev 1312) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/TextGlyph.java 2012-06-15 06:51:44 UTC (rev 1313) @@ -153,6 +153,14 @@ * * @return */ + public NamedSBase getOriginOfTextInstance() { + return getNamedSBaseInstance(); + } + + /** + * + * @return + */ public String getText() { return text; } Modified: trunk/modules/libSBMLio/src/org/sbml/jsbml/xml/libsbml/LibSBMLChangeListener.java =================================================================== --- trunk/modules/libSBMLio/src/org/sbml/jsbml/xml/libsbml/LibSBMLChangeListener.java 2012-06-14 16:27:15 UTC (rev 1312) +++ trunk/modules/libSBMLio/src/org/sbml/jsbml/xml/libsbml/LibSBMLChangeListener.java 2012-06-15 06:51:44 UTC (rev 1313) @@ -630,7 +630,7 @@ libDoc.delete(); } else if (node instanceof ListOf<?>) { // make recursion and remove all elements in the list - for(Object o : (ListOf<?>)node ) { + for (Object o : (ListOf<?>) node) { TreeNode newNode = new DefaultMutableTreeNode(o); nodeRemoved(new TreeNodeRemovedEvent(newNode, node)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nik...@us...> - 2012-06-14 16:27:21
|
Revision: 1312 http://jsbml.svn.sourceforge.net/jsbml/?rev=1312&view=rev Author: niko-rodrigue Date: 2012-06-14 16:27:15 +0000 (Thu, 14 Jun 2012) Log Message: ----------- improved the way we check if the History is set or not + added a method to unset the History.listOfModification dates Modified Paths: -------------- trunk/core/src/org/sbml/jsbml/Annotation.java trunk/core/src/org/sbml/jsbml/History.java Modified: trunk/core/src/org/sbml/jsbml/Annotation.java =================================================================== --- trunk/core/src/org/sbml/jsbml/Annotation.java 2012-06-14 15:24:51 UTC (rev 1311) +++ trunk/core/src/org/sbml/jsbml/Annotation.java 2012-06-14 16:27:15 UTC (rev 1312) @@ -670,11 +670,11 @@ */ public boolean isSetAnnotation() { if ((getNonRDFannotation() == null) && getListOfCVTerms().isEmpty() - && (!isSetHistory())) + && getHistory().isEmpty()) { return false; - } else if ((getNonRDFannotation() == null) && (!isSetHistory()) + } else if ((getNonRDFannotation() == null) && getHistory().isEmpty() && !getListOfCVTerms().isEmpty()) { @@ -693,7 +693,7 @@ * @return true if the {@link History} is initialised */ public boolean isSetHistory() { - return history != null; + return history != null && !history.isEmpty(); } Modified: trunk/core/src/org/sbml/jsbml/History.java =================================================================== --- trunk/core/src/org/sbml/jsbml/History.java 2012-06-14 15:24:51 UTC (rev 1311) +++ trunk/core/src/org/sbml/jsbml/History.java 2012-06-14 16:27:15 UTC (rev 1312) @@ -333,8 +333,9 @@ * </ul> */ public boolean isEmpty() { - return !isSetCreatedDate() && (getCreatorCount() == 0) - && (getModifiedDateCount() == 0) && !isSetModifiedDate(); + return !isSetCreatedDate() && !isSetListOfCreators() + && !isSetListOfModification() && !isSetModifiedDate(); + } /** @@ -353,7 +354,7 @@ * @return */ public boolean isSetListOfCreators() { - return listOfCreators != null; + return listOfCreators != null && listOfCreators.size() > 0; } /** @@ -361,7 +362,7 @@ * @return */ public boolean isSetListOfModification() { - return listOfModification != null; + return listOfModification != null && listOfModification.size() > 0; } /** @@ -472,4 +473,20 @@ } } + /** + * Sets the created of this {@link History} to null. + */ + public void unsetListOfModifiedDates() { + if(this.modified != null){ + modified = null; + } + if (listOfModification != null) { + for (Date date : listOfModification) { + firePropertyChange(TreeNodeChangeEvent.modified, date, null); + } + + listOfModification = null; + } + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <na...@us...> - 2012-06-14 15:25:00
|
Revision: 1311 http://jsbml.svn.sourceforge.net/jsbml/?rev=1311&view=rev Author: nagel86 Date: 2012-06-14 15:24:51 +0000 (Thu, 14 Jun 2012) Log Message: ----------- adapted to fit with TreeNodeChangeListener changes Modified Paths: -------------- trunk/modules/libSBMLio/src/org/sbml/jsbml/xml/libsbml/LibSBMLChangeListener.java Modified: trunk/modules/libSBMLio/src/org/sbml/jsbml/xml/libsbml/LibSBMLChangeListener.java =================================================================== --- trunk/modules/libSBMLio/src/org/sbml/jsbml/xml/libsbml/LibSBMLChangeListener.java 2012-06-14 13:20:15 UTC (rev 1310) +++ trunk/modules/libSBMLio/src/org/sbml/jsbml/xml/libsbml/LibSBMLChangeListener.java 2012-06-14 15:24:51 UTC (rev 1311) @@ -566,7 +566,7 @@ //@Override public void nodeRemoved(TreeNodeRemovedEvent evt) { TreeNode node = evt.getSource(); - TreeNode parent = evt.getPreviosParent(); + TreeNode parent = evt.getPreviousParent(); org.sbml.libsbml.Model libModel = libDoc.getModel(); if (node instanceof AbstractSBase) { if (node instanceof org.sbml.jsbml.AbstractNamedSBase) { @@ -632,7 +632,7 @@ // make recursion and remove all elements in the list for(Object o : (ListOf<?>)node ) { TreeNode newNode = new DefaultMutableTreeNode(o); - nodeRemoved(newNode); + nodeRemoved(new TreeNodeRemovedEvent(newNode, node)); } } else if (node instanceof AbstractMathContainer) { if (node instanceof FunctionDefinition) { @@ -650,7 +650,7 @@ } else if (node instanceof EventAssignment) { // search corresponding event and remove the EventAssignment indicated by the variable - Event event = (Event) (((ListOf<EventAssignment>) parent).getParentSBMLObject(); + Event event = (Event) (((ListOf<EventAssignment>) parent).getParentSBMLObject()); libModel.getEvent(event.getId()).removeEventAssignment(((EventAssignment) node).getVariable()); } else if (node instanceof StoichiometryMath) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nik...@us...> - 2012-06-14 13:20:27
|
Revision: 1310 http://jsbml.svn.sourceforge.net/jsbml/?rev=1310&view=rev Author: niko-rodrigue Date: 2012-06-14 13:20:15 +0000 (Thu, 14 Jun 2012) Log Message: ----------- Many fixes and improvements to the registering/unregistering of ids in the Model. AbstractNamedSBase.setId is not recursive anymore AbstractSBase.register and unregister methods are making a special cases for LocalParameters to register them directly into the KineticLaw, without going through the model. UnregisterTests has a lot more tests now and few of them are still failing, pointing some potential API vulnerabilities that we could fix (or not) Modified Paths: -------------- trunk/core/src/org/sbml/jsbml/AbstractNamedSBase.java trunk/core/src/org/sbml/jsbml/AbstractSBase.java trunk/core/src/org/sbml/jsbml/KineticLaw.java trunk/core/src/org/sbml/jsbml/ListOf.java trunk/core/src/org/sbml/jsbml/Model.java trunk/core/src/org/sbml/jsbml/Reaction.java trunk/core/test/org/sbml/jsbml/xml/test/UnregisterTests.java Modified: trunk/core/src/org/sbml/jsbml/AbstractNamedSBase.java =================================================================== --- trunk/core/src/org/sbml/jsbml/AbstractNamedSBase.java 2012-06-14 12:22:07 UTC (rev 1309) +++ trunk/core/src/org/sbml/jsbml/AbstractNamedSBase.java 2012-06-14 13:20:15 UTC (rev 1310) @@ -306,14 +306,14 @@ Model model = getModel(); if ((oldId != null) && (model != null)) { // Delete previous identifier only if defined. - model.registerId(this, false); + model.registerIds(this.getParent(), this, false, true); } if ((id == null) || (id.trim().length() == 0)) { this.id = null; } else if (checkIdentifier(id)) { this.id = id; } - if ((model != null) && !model.registerId(this, true)) { + if ((model != null) && !model.registerIds(this.getParent(), this, false, false)) { IdentifierException exc = new IdentifierException(this, this.id); this.id = oldId; // restore the previous setting! throw new IllegalArgumentException(exc); Modified: trunk/core/src/org/sbml/jsbml/AbstractSBase.java =================================================================== --- trunk/core/src/org/sbml/jsbml/AbstractSBase.java 2012-06-14 12:22:07 UTC (rev 1309) +++ trunk/core/src/org/sbml/jsbml/AbstractSBase.java 2012-06-14 13:20:15 UTC (rev 1310) @@ -751,26 +751,13 @@ */ @Override public void fireNodeRemovedEvent() { - if (isSetMetaId() || !isLeaf()) { - // update the set of meta identifiers within the SBMLDocument. - SBMLDocument doc = getSBMLDocument(); - if (doc != null) { - /* - * Recursively remove pointers to this element's and all - * sub-element's meta identifiers from the SBMLDocument. - */ - doc.registerMetaIds(this, true, true); - } + + TreeNode parent = getParent(); + + if (parent != null && parent instanceof SBase) { + ((SBase) parent).unregister(this); } - if ((this instanceof NamedSBase) || (getChildCount() > 0)) { - /* - * Do the same for all identifiers below this element. - */ - Model model = getModel(); - if (model != null) { - model.registerIds(getParent(), this, true, true); - } - } + super.fireNodeRemovedEvent(); } @@ -1238,6 +1225,16 @@ doc.registerMetaIds(sbase, (sbase.getSBMLDocument() == null) && (sbase instanceof AbstractSBase), false); } + if (sbase instanceof LocalParameter) { + + TreeNode klTreeNode = this.getParent(); + + if (klTreeNode != null && klTreeNode instanceof KineticLaw) { + KineticLaw kineticLaw = (KineticLaw) klTreeNode; + kineticLaw.registerLocalParameter((LocalParameter) sbase, false); + } + } + Model model = getModel(); /* * Check if the model to which this node is assigned equals the one to @@ -1279,13 +1276,14 @@ } /* - * Now, we cann add all previous listeners. The next change will + * Now, we can add all previous listeners. The next change will * be fired after registering all ids. */ sbase.addAllChangeListeners(listeners); // Add all TreeNodeChangeListeners from this current node also to the new SBase: - sbase.addAllChangeListeners(getListOfTreeNodeChangeListeners()); + sbase.addAllChangeListeners(getListOfTreeNodeChangeListeners()); + // Notify all listeners that a new node has been added to this subtree: sbase.fireNodeAddedEvent(); } @@ -1295,6 +1293,12 @@ * @see org.sbml.jsbml.SBase#unregisterChild(org.sbml.jsbml.SBase) */ public void unregister(SBase sbase) { + + if (logger.isDebugEnabled()) { + logger.debug("unregister called !! " + sbase.getElementName() + " " + + (sbase instanceof NamedSBase ? ((NamedSBase) sbase).getId() : "")); + } + if ((sbase != null)) { SBMLDocument doc = getSBMLDocument(); @@ -1303,11 +1307,22 @@ doc.registerMetaIds(sbase, true, true); } + if (sbase instanceof LocalParameter) { + + TreeNode klTreeNode = this.getParent(); + + if (klTreeNode != null && klTreeNode instanceof KineticLaw) { + + logger.debug("Unregister LP"); + + KineticLaw kineticLaw = (KineticLaw) klTreeNode; + kineticLaw.registerLocalParameter((LocalParameter) sbase, true); + sbase.setParentSBML(this); + } + } + Model model = getModel(); - // remove all changeListeners - sbase.removeAllTreeNodeChangeListeners(); - // If possible, recursively unregister all ids of the SBase in our model: if ((model != null) && !model.registerIds(this, sbase, true, true)) { @@ -1315,8 +1330,10 @@ sbase.getElementName())); } - // Notify all listeners that a new node has been added to this subtree: - sbase.fireNodeRemovedEvent(); + // fireNodeRemovedEvent is calling this method - sbase.fireNodeRemovedEvent(); + + // remove all changeListeners + sbase.removeAllTreeNodeChangeListeners(); } } Modified: trunk/core/src/org/sbml/jsbml/KineticLaw.java =================================================================== --- trunk/core/src/org/sbml/jsbml/KineticLaw.java 2012-06-14 12:22:07 UTC (rev 1309) +++ trunk/core/src/org/sbml/jsbml/KineticLaw.java 2012-06-14 13:20:15 UTC (rev 1310) @@ -645,6 +645,7 @@ * @return */ boolean registerLocalParameter(LocalParameter parameter, boolean delete) { + boolean success = false; if (parameter.isSetId()) { String id = parameter.getId(); @@ -669,6 +670,7 @@ logger.debug(String.format("registered id=%s in %s", id, toString())); } } + return success; } @@ -759,12 +761,36 @@ public void setListOfLocalParameters(ListOf<LocalParameter> listOfLocalParameters) { unsetListOfLocalParameters(); this.listOfLocalParameters = listOfLocalParameters; - if (this.listOfLocalParameters != null) { - if (this.listOfLocalParameters.getSBaseListType() != ListOf.Type.listOfLocalParameters) { - this.listOfLocalParameters.setSBaseListType(ListOf.Type.listOfLocalParameters); - } - registerChild(this.listOfLocalParameters); - } + if (this.listOfLocalParameters != null) { + if (this.listOfLocalParameters.getSBaseListType() != ListOf.Type.listOfLocalParameters) { + this.listOfLocalParameters.setSBaseListType(ListOf.Type.listOfLocalParameters); + } + + // In this case, we have to register by hand the localParameters to the kineticLaw as registerChild + // will not do it as we pass the listOf instead of directly the LocalParameters + for (LocalParameter lp : listOfLocalParameters) { + try + { + registerLocalParameter(lp, false); + } + catch (IllegalArgumentException e) { + + // The parent of the listOf is not set yet, so we have to unregister the parameters by hand + for (LocalParameter lp2 : listOfLocalParameters) { + this.registerLocalParameter(lp2, true); + } + + // The listOf is wrong so we unset all the local parameters + unsetListOfLocalParameters(); + + logger.error(String.format("The list of local parameters will not be set as some ids are duplicated.")); + throw e; + } + } + + registerChild(this.listOfLocalParameters); + + } if (isSetMath()) { getMath().updateVariables(); } Modified: trunk/core/src/org/sbml/jsbml/ListOf.java =================================================================== --- trunk/core/src/org/sbml/jsbml/ListOf.java 2012-06-14 12:22:07 UTC (rev 1309) +++ trunk/core/src/org/sbml/jsbml/ListOf.java 2012-06-14 13:20:15 UTC (rev 1310) @@ -360,8 +360,8 @@ * @see java.util.List#add(int, java.lang.Object) */ public void add(int index, T element) { + registerChild(element); listOf.add(index, element); - registerChild(element); } /* (non-Javadoc) @see java.util.List#add(java.lang.Object) @@ -425,11 +425,10 @@ * @see java.util.List#clear() */ public void clear() { - List<T> removedElements = listOf; + for (T element : listOf) { + ((TreeNodeWithChangeSupport) element).fireNodeRemovedEvent(); + } listOf.clear(); - for (T element : removedElements) { - ((TreeNodeWithChangeSupport) element).fireNodeRemovedEvent(); - } } /* (non-Javadoc) @@ -777,9 +776,9 @@ */ public boolean removeAll(Collection<?> c) { boolean success = listOf.removeAll(c); - if(success){ + if(success){ // TODO : a success does not mean that all elements from c have been removed from the listOf for(Iterator<?> i = c.iterator(); i.hasNext();){ - TreeNodeWithChangeSupport element = (TreeNodeWithChangeSupport) i.next(); + SBase element = (SBase) i.next(); element.fireNodeRemovedEvent(); } } @@ -909,6 +908,9 @@ */ @Override public String toString() { + + // TODO : replace the code below by log4j debug message ? + if (DEBUG_MODE) { return listOf.toString(); } Modified: trunk/core/src/org/sbml/jsbml/Model.java =================================================================== --- trunk/core/src/org/sbml/jsbml/Model.java 2012-06-14 12:22:07 UTC (rev 1309) +++ trunk/core/src/org/sbml/jsbml/Model.java 2012-06-14 13:20:15 UTC (rev 1310) @@ -3767,32 +3767,40 @@ private boolean registerId(KineticLaw kl, LocalParameter lp, boolean delete, boolean alreadyRegisteredInKL) { if (!alreadyRegisteredInKL) { // Register local parameter within its kinetic law first. + logger.debug("registerIds (LP) : calling kineticLaw.registerLocalParameter !"); + // should never be called from the model in fact + kl.registerLocalParameter(lp, delete); } - if (lp.isSetId()) { - Reaction r = kl.getParentSBMLObject(); + + logger.debug("registerIds (LP) : id = " + lp.getId()); + + if (lp.isSetId()) + { + Reaction r = kl.getParentSBMLObject(); String pId = lp.getId(); - if ((r != null) && r.isSetId()) { - if (delete) { - // Check if this method was called by some cloned object. - // In this case we must not delete the references to the objects - // within this model. - Reaction rTest = getReaction(r.getId()); - if ((rTest == null) || (rTest != r) || !rTest.isSetKineticLaw() - || (rTest.getKineticLaw().getLocalParameter(lp.getId()) == null)) { - return false; - } + + logger.debug("registerIds (LP) : reaction = " + r + " (r.isSetId = " + r.isSetId() + ")"); + + if ((r != null) && r.isSetId()) + { + if (delete) + { if (mapOfLocalParameters != null) { SortedSet<String> reactionSet = mapOfLocalParameters.get(pId); + if (reactionSet != null) { reactionSet.remove(r.getId()); + if (reactionSet.isEmpty()) { mapOfLocalParameters.remove(pId); } } } return true; - } else { + } + else // register + { // add new key or reaction for this local parameter. if (mapOfLocalParameters == null) { mapOfLocalParameters = new HashMap<String, SortedSet<String>>(); @@ -3801,10 +3809,12 @@ mapOfLocalParameters.put(pId, new TreeSet<String>()); } mapOfLocalParameters.get(pId).add(r.getId()); + return true; } } } + return false; } @@ -3832,13 +3842,10 @@ * @param delete * @return */ - private boolean registerId(UniqueNamedSBase unsb, boolean recursively, boolean delete) { + private boolean registerId(UniqueNamedSBase unsb, boolean delete) { String id = unsb.getId(); if (delete && (mapOfUniqueNamedSBases != null)) { - // Check if this method was called from some cloned element that is not part of this model: - if (mapOfUniqueNamedSBases.get(id) != unsb) { - return false; - } + mapOfUniqueNamedSBases.remove(id); if (logger.isDebugEnabled()) { logger.debug(MessageFormat.format("removed id={0} from model{1}", @@ -3849,18 +3856,10 @@ mapOfUniqueNamedSBases = new HashMap<String, UniqueNamedSBase>(); } /* - * Three reasons for non acceptance: + * Two reasons for non acceptance: * (1) another UniqueNamedSBase is already registered with the identical id. * - * No need to test this case (2) some Reaction refers to a LocalParameter - * with this id, but LV >= 2.3 and the - * overridden element is not an instance of Species, Compartment, or Parameter. - * - || ((0 < unsb.getLevelAndVersion().compareTo(Integer.valueOf(2), Integer.valueOf(2))) - && (mapOfLocalParameters != null) - && mapOfLocalParameters.containsKey(id) && !(unsb instanceof Symbol)) - - * (3) In Level 1 UnitDefinitions and UniqueNamedSBases use the same namespace. + * (2) In Level 1 UnitDefinitions and UniqueNamedSBases use the same namespace. */ if ((mapOfUniqueNamedSBases.containsKey(id) && (mapOfUniqueNamedSBases.get(id) != unsb)) @@ -3879,17 +3878,8 @@ id, (isSetId() ? " " + getId() : ""))); } } - boolean success = true; - if (recursively) { - TreeNode child; - for (int i = 0; i < unsb.getChildCount(); i++) { - child = unsb.getChildAt(i); - if (child instanceof SBase) { - success &= registerIds(unsb, (SBase) child, recursively, delete); - } - } - } - return success; + + return true; } /** @@ -3909,11 +3899,7 @@ if (add) { return mapOfUnitDefinitions.put(ud.getId(), ud) == null; } - // Check if the element to be removed is part of this model or maybe a clone: - UnitDefinition unitDef = mapOfUnitDefinitions.get(ud); - if ((unitDef != null) && (unitDef != ud)) { - return false; - } + return mapOfUnitDefinitions.remove(ud.getId()) != null; } @@ -3927,52 +3913,82 @@ * @return {@code true} if this operation was successfully performed, * {@code false} otherwise. */ - boolean registerIds(SBase parent, SBase newElem, boolean recursively, boolean delete) { + boolean registerIds(SBase parent, SBase newElem, boolean recursively, boolean delete) + { + /* + * the default return value is true to be able to register successfully objects that are + * not NamedSBase when the recursive boolean is set to false (happen with listOf objects for example). + * For these, the AbstractSBase.registerChild(SBase) method was throwing an exception although there was no problem. + */ boolean success = true; - if (newElem instanceof NamedSBase) { - NamedSBase newNsb = (NamedSBase) newElem; - if (newNsb.isSetId()) { - if (newNsb instanceof UniqueNamedSBase) { - success &= registerId((UniqueNamedSBase) newNsb, recursively, delete); - } else if ((newNsb instanceof LocalParameter) && (parent.getParent() != null)) { - success &= registerId((KineticLaw) parent.getParent(), - (LocalParameter) newNsb, delete, false); - } else if (newNsb instanceof UnitDefinition) { - success &= registerId((UnitDefinition) newNsb, !delete); - } else { - // in L3 packages we might have different id namespaces - logger.error(MessageFormat.format( - "registerIds: the object {0} is neither a UniqueNamedSBase, a LocalParameter or a UnitDefinition so its id will not be registered in the Model.", - newNsb.getClass().getCanonicalName())); - } - } else if (!newNsb.isIdMandatory()) { - // do nothing + logger.debug("registerIds (main) : newElem = " + newElem.getElementName() + " (recursive = " + recursively + ")"); + + if (newElem instanceof NamedSBase) + { + NamedSBase newNsb = (NamedSBase) newElem; + + if (newNsb.isSetId()) + { + if (newNsb instanceof UniqueNamedSBase) + { + success &= registerId((UniqueNamedSBase) newNsb, delete); + } + else if ((newNsb instanceof LocalParameter) && (parent.getParent() != null)) + { + success &= registerId((KineticLaw) parent.getParent(), (LocalParameter) newNsb, delete, true); + } + else if (newNsb instanceof UnitDefinition) + { + success &= registerId((UnitDefinition) newNsb, !delete); + } + else + { + // in L3 packages we might have different id namespaces + logger.error(MessageFormat.format( + "registerIds: the object {0} is neither a UniqueNamedSBase, a LocalParameter or a UnitDefinition so its id will not be registered in the Model.", + newNsb.getClass().getCanonicalName())); + } + } else if (!newNsb.isIdMandatory()) { + // do nothing + } + } + + logger.debug("registerIds (main) : success = " + success); + + if (recursively) { + for (int i = 0; (i < newElem.getChildCount()) && success; i++) { + TreeNode child = newElem.getChildAt(i); + if (child instanceof SBase) { + if (child instanceof LocalParameter) { + // The local parameter have already been registered in the KineticLaw in this case + logger.debug("registerIds (main) : registering a LocalParameter."); + success &= registerId((KineticLaw) parent, (LocalParameter) child, delete, true); + + // we still need to register recursively the children of a LocalParameter + if (child.getChildCount() > 0) { + for (int j = 0; (j < child.getChildCount()) && success; j++) { + TreeNode lpChild = child.getChildAt(j); + + if (lpChild instanceof SBase) { + success &= registerIds((SBase) child, (SBase) lpChild, recursively, delete); + } + } + } + } else { + success &= registerIds(newElem, (SBase) child, recursively, delete); + } + } + } + + logger.debug("registerIds (main) : success after recursion = " + success); + + return success; } - } - if (recursively) { - for (int i = 0; (i < newElem.getChildCount()) && success; i++) { - TreeNode child = newElem.getChildAt(i); - if (child instanceof SBase) { - if ((parent instanceof KineticLaw) && (child instanceof LocalParameter)) { - // The local parameter have already been registered in the KineticLaw in this case - success &= registerId((KineticLaw) parent, (LocalParameter) child, delete, true); - // TODO : we still need to register recursively the children of a LocalParameter - } else { - success &= registerIds(newElem, (SBase) child, recursively, delete); - } - } - } + return success; - } - /* - * the default return value is true to be able to register successfully objects that are - * not NamedSBase when the recursive boolean is set to false (happen with listOf objects for example). - * For these, the AbstractSBase.registerChild(SBase) method was throwing an exception although there was no problem. - */ - return success; } - + /** * Removes the i-th {@link Compartment} of the {@link Model}. * Modified: trunk/core/src/org/sbml/jsbml/Reaction.java =================================================================== --- trunk/core/src/org/sbml/jsbml/Reaction.java 2012-06-14 12:22:07 UTC (rev 1309) +++ trunk/core/src/org/sbml/jsbml/Reaction.java 2012-06-14 13:20:15 UTC (rev 1310) @@ -1213,31 +1213,8 @@ public void setKineticLaw(KineticLaw kineticLaw) { unsetKineticLaw(); this.kineticLaw = kineticLaw; - if (this.kineticLaw.isSetListOfLocalParameters()) { - /* - * Before we can register the new kineticLaw as a child of this - * reaction, we first have to clear the mapping from the kineticLaw - * to its local parameters (if there are any). Local parameters are - * registered at the level of the kineticLaw, i.e., besides all maps - * on the level of the model, kineticLaw contains its own map. - * Clearing this map is required because the registerChild method - * would recursively find all elements that have an id and try to - * the mapping. However, since all these local parameters have been - * existing already, this would cause an exception. The reason is - * that we could not distinguish between already correctly registered - * local parameters and new local parameters with an identical - * identifier. - */ - for (LocalParameter lp : this.kineticLaw.getListOfLocalParameters()) { - this.kineticLaw.registerLocalParameter(lp, true); - } - } + registerChild(this.kineticLaw); - if (this.kineticLaw.isSetListOfLocalParameters()) { - for (LocalParameter lp : this.kineticLaw.getListOfLocalParameters()) { - this.kineticLaw.registerLocalParameter(lp, false); - } - } } /** Modified: trunk/core/test/org/sbml/jsbml/xml/test/UnregisterTests.java =================================================================== --- trunk/core/test/org/sbml/jsbml/xml/test/UnregisterTests.java 2012-06-14 12:22:07 UTC (rev 1309) +++ trunk/core/test/org/sbml/jsbml/xml/test/UnregisterTests.java 2012-06-14 13:20:15 UTC (rev 1310) @@ -9,6 +9,7 @@ import org.sbml.jsbml.Compartment; import org.sbml.jsbml.IdentifierException; import org.sbml.jsbml.KineticLaw; +import org.sbml.jsbml.ListOf; import org.sbml.jsbml.LocalParameter; import org.sbml.jsbml.Model; import org.sbml.jsbml.Reaction; @@ -178,8 +179,11 @@ } try { - model.addSpecies(s3); - fail("We should not be able to register twice the same metaid."); + boolean speciesAdded = model.addSpecies(s3); + + if (speciesAdded) { + fail("We should not be able to register twice the same metaid."); + } } catch (IllegalArgumentException e) { assertTrue(true); // success @@ -192,6 +196,7 @@ @Test public void testRegister3() { Reaction r2 = new Reaction(2,4); + r2.setId("R2"); KineticLaw k = r2.createKineticLaw(); k.createLocalParameter("LP1"); @@ -202,19 +207,51 @@ // fail("We should not be able to add a local parameter with the same id as an other local parameter in the same kineticLaw."); } catch (IdentifierException e) { // success + } catch (IllegalArgumentException e) { + // success (this the exception returned often, IdentifierException would be better) } assertTrue(k.getLocalParameterCount() == 1); + try { + model.addReaction(r2); + } catch (IllegalArgumentException e) { + // failure + e.printStackTrace(); + } + + assertTrue(model.getReactionCount() == 2); + } + /** * */ + @Test public void testRegister3_1() { + + // Creating a new reaction without id + Reaction r2 = model.createReaction(); + + assertTrue(model.getReactionCount() == 2); + + KineticLaw k = r2.createKineticLaw(); + + k.createLocalParameter("LP1"); // Not possible at the moment to add a local parameter if the reaction has no id + + assertTrue(k.getLocalParameterCount() == 1); + + assertTrue(model.findLocalParameters("LP1").size() == 2); + } + + + /** + * + */ @Test public void testRegister4() { assertTrue(model.getId().equals("model")); - assertTrue(model.getNumSpecies() == 2); + assertTrue(model.getSpeciesCount() == 2); // We should be allowed to change an id ! model.setId("newModelID"); @@ -228,11 +265,230 @@ assertTrue(model.getId().equals("newModelID")); } + + /** + * + + @Test public void testRegister5() { + + Species s3 = new Species(); + s3.setId("S3"); + + MultiSpecies mS3 = new MultiSpecies(s3); + + s3.addExtension("any", mS3); + + // Setting the same id as an existing Species + mS3.createSpeciesTypeInstance("S1"); + + // Setting the parent by hand !! + s3.setParentSBML(model); + + try { + boolean speciesAdded = model.addSpecies(s3); + + fail("We should not be able to register twice the same id."); + } catch (IllegalArgumentException e) { + assertTrue(true); + // success + } + } + */ + + /** + * + + @Test public void testRegister5_1() { + + Species s3 = new Species(); + s3.setId("S3"); + + MultiSpecies mS3 = new MultiSpecies(s3); + + s3.addExtension("any", mS3); + + // Setting the same id as an existing Species + mS3.createSpeciesTypeInstance("S1"); + + try { + model.addSpecies(s3); + + fail("We should not be able to register twice the same id."); + } catch (IllegalArgumentException e) { + assertTrue(true); + // success + } + } + */ + + /** + * + */ + @Test public void testRegister5_2() { + + Reaction r2 = new Reaction(); + r2.setId("R2"); + + // Setting the same id as an existing Species + r2.createReactant("S1"); + + try { + model.addReaction(r2); + + fail("We should not be able to register twice the same id."); + } catch (IllegalArgumentException e) { + assertTrue(true); + // success + } + } + + /** + * + */ + @Test public void testRegister5_3() { + + Reaction r2 = new Reaction(); + r2.setId("R2"); + + // Setting the same id as an existing Species + r2.createReactant("S1"); + + // Setting the parent by hand !! // TODO : should we limit the access of SBase.setParentSBML and TreeNode.setParent (should be possible) ?? + r2.setParentSBML(new ListOf<Reaction>(2, 4)); + r2.getParent().setParentSBML(model); // This will make the registration of the reaction non recursive + + try { + model.addReaction(r2); + + fail("We should not be able to register twice the same id."); + } catch (IllegalArgumentException e) { + assertTrue(true); + // success + } + } /** * */ + @Test public void testRegister6() { + + Species s3 = new Species(); + s3.setId("S3"); + + try { + model.addSpecies(s3); + + // calling the registerChild by hand !! // TODO : should we limit the access of SBase.registerChild ?? + model.registerChild(s3); + + fail("We should not be able to register twice the same id."); + } catch (IllegalArgumentException e) { + assertTrue(true); + // success + } + } + + /** + * + */ + @Test public void testRegister7() { + + Reaction r2 = model.createReaction("R2"); + + r2.createReactant("SR3"); + + r2.createKineticLaw().createLocalParameter("LP1"); + + Reaction clonedR2 = r2.clone(); + + assertTrue(clonedR2.getKineticLaw().getLocalParameterCount() == 1); + + try { + clonedR2.getKineticLaw().createLocalParameter("LP1"); + + fail("We should not be able to register twice the same id."); + } catch (IllegalArgumentException e) { + assertTrue(true); + // success + } + + try { + clonedR2.getKineticLaw().createLocalParameter("LP2"); + assertTrue(true); + // success + } catch (IllegalArgumentException e) { + fail("We should be able to register a new local parameter on a cloned reaction."); + } + + assertTrue(clonedR2.getKineticLaw().getLocalParameterCount() == 2); + } + + /** + * + */ + @Test public void testRegister8() { + + Reaction r2 = model.createReaction("R2"); + + KineticLaw kl = r2.createKineticLaw(); + + ListOf<LocalParameter> listOfLP = new ListOf<LocalParameter>(2, 4); + listOfLP.add(new LocalParameter("LP1")); + listOfLP.add(new LocalParameter("LP2")); + listOfLP.add(new LocalParameter("LP3")); + listOfLP.add(new LocalParameter("LP1")); + + try { + + kl.setListOfLocalParameters(listOfLP); + + fail("We should not be able to register twice the same local parameter id."); + } catch(IllegalArgumentException e) { + // success + } + + assertTrue(kl.getLocalParameterCount() == 0); + assertTrue(model.findLocalParameters("LP1").size() == 1); + assertTrue(model.findLocalParameters("LP2").size() == 0); + + // listOfLP.remove(3); // TODO : at the moment the list of local parameter is emptied if there is an error !! Should we clone the listOf + // when using the setListOf methods ?? + + listOfLP.clear(); + listOfLP.add(new LocalParameter("LP1")); + listOfLP.add(new LocalParameter("LP2")); + listOfLP.add(new LocalParameter("LP3")); + + try { + + kl.setListOfLocalParameters(listOfLP); + + } catch(IllegalArgumentException e) { + fail("We should be able to set a valid list of local parameters."); + } + + assertTrue(kl.getLocalParameterCount() == 3); + assertTrue(model.findLocalParameters("LP1").size() == 2); + assertTrue(model.findLocalParameters("LP2").size() == 1); + + kl.removeLocalParameter("LP2"); + kl.removeLocalParameter(1); + + assertTrue(kl.getLocalParameterCount() == 1); + assertTrue(model.findLocalParameters("LP2").size() == 0); + assertTrue(model.findLocalParameters("LP3").size() == 0); + + kl.createLocalParameter("LP2"); + + assertTrue(kl.getLocalParameterCount() == 2); + assertTrue(model.findLocalParameters("LP2").size() == 1); + } + + + /** + * + */ @Test public void testUnRegister() { @@ -289,5 +545,45 @@ assertTrue(model.findNamedSBase("LP1") == null); } + + /** + * + */ + @Test public void testUnRegister3() { + + model.unsetListOfReactions(); + + assertTrue(model.getReaction("R1") == null); + assertTrue(model.getReaction(0) == null); + assertTrue(model.findNamedSBase("SP1") == null); + assertTrue(model.findNamedSBase("SP2") == null); + // assertTrue(model.findNamedSBase("LP1") == null); + assertTrue(doc.findSBase("SP1") == null); + assertTrue(doc.findSBase("R1") == null); + assertTrue(doc.findSBase("LP1") == null); + + Species s3 = new Species(); + + // Setting the same id as a removed SpeciesReference + s3.setId("SP1"); + + // Setting the same metaid as a removed LocalParameter + try { + s3.setMetaId("LP1"); + assertTrue(true); + } catch (IdentifierException e) { + fail("We should be able to put any metaId to a Species not linked to a model."); + } + + try { + model.addSpecies(s3); + assertTrue(true); + } catch (IllegalArgumentException e) { + fail("We should be able to register an id or metaid from a removed element."); + // success + } + + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nik...@us...> - 2012-06-14 12:22:17
|
Revision: 1309 http://jsbml.svn.sourceforge.net/jsbml/?rev=1309&view=rev Author: niko-rodrigue Date: 2012-06-14 12:22:07 +0000 (Thu, 14 Jun 2012) Log Message: ----------- small change to the CheckConsistencyTests, adding some output Modified Paths: -------------- trunk/core/test/org/sbml/jsbml/xml/test/CheckConsistencyTests.java Modified: trunk/core/test/org/sbml/jsbml/xml/test/CheckConsistencyTests.java =================================================================== --- trunk/core/test/org/sbml/jsbml/xml/test/CheckConsistencyTests.java 2012-06-14 10:14:23 UTC (rev 1308) +++ trunk/core/test/org/sbml/jsbml/xml/test/CheckConsistencyTests.java 2012-06-14 12:22:07 UTC (rev 1309) @@ -89,7 +89,12 @@ int nbErrors = doc.checkConsistency(); - System.out.println("Found " + nbErrors + " errors on Biomodels 025 with the unit checking turned on."); + int numRealErrors = doc.getErrorLog().getNumFailsWithSeverity(SEVERITY.ERROR); + if (numRealErrors > 0) { + System.out.println("# Found " + numRealErrors + " VALIDATION ERRORS !!!"); + } + + System.out.println("Found " + nbErrors + " errors/warnings on Biomodels 025 with the unit checking turned on."); assertTrue(nbErrors > 0); assertTrue(doc.getErrorLog().getNumFailsWithSeverity(SEVERITY.ERROR) == 0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2012-06-14 10:14:33
|
Revision: 1308 http://jsbml.svn.sourceforge.net/jsbml/?rev=1308&view=rev Author: andreas-draeger Date: 2012-06-14 10:14:23 +0000 (Thu, 14 Jun 2012) Log Message: ----------- Corrected an error in TreeNodeAdapter that was introduced when adding general userObjects to all SBML elements: By mistake a method that was already present in TreeNodeAdapter was overridden (isSetUserObjects). Modified Paths: -------------- trunk/core/src/org/sbml/jsbml/util/TreeNodeAdapter.java trunk/core/src/org/sbml/jsbml/xml/parsers/AbstractReaderWriter.java trunk/core/src/org/sbml/jsbml/xml/stax/SBMLObjectForXML.java trunk/core/src/org/sbml/jsbml/xml/stax/SBMLWriter.java trunk/extensions/render/test/org/sbml/jsbml/ext/render/RenderWriteTest.java Modified: trunk/core/src/org/sbml/jsbml/util/TreeNodeAdapter.java =================================================================== --- trunk/core/src/org/sbml/jsbml/util/TreeNodeAdapter.java 2012-06-14 07:07:30 UTC (rev 1307) +++ trunk/core/src/org/sbml/jsbml/util/TreeNodeAdapter.java 2012-06-14 10:14:23 UTC (rev 1308) @@ -107,6 +107,7 @@ /* (non-Javadoc) * @see org.sbml.jsbml.AbstractTreeNode#clone() */ + //@Override public TreeNode clone() { return new TreeNodeAdapter(this); } @@ -120,7 +121,7 @@ if (equals) { TreeNodeAdapter node = (TreeNodeAdapter) object; equals &= node.isUserObjectRecursiveDataType() == isUserObjectRecursiveDataType(); - if (equals && isSetUserObjects() && !isUserObjectRecursiveDataType()) { + if (equals && isSetUserObject() && !isUserObjectRecursiveDataType()) { equals &= node.getUserObject().equals(getUserObject()); } } @@ -130,8 +131,9 @@ /* (non-Javadoc) * @see javax.swing.tree.TreeNode#getAllowsChildren() */ + //@Override public boolean getAllowsChildren() { - if (isSetUserObjects() && (userObject instanceof Collection<?>)) { + if (isSetUserObject() && (userObject instanceof Collection<?>)) { return true; } return false; @@ -140,11 +142,12 @@ /* (non-Javadoc) * @see javax.swing.tree.TreeNode#getChildAt(int) */ + //@Override public TreeNode getChildAt(int childIndex) { if (childIndex < 0) { throw new IndexOutOfBoundsException(childIndex + " < 0"); } - if (isSetUserObjects()) { + if (isSetUserObject()) { if (userObject instanceof TreeNode) { return ((TreeNode) userObject).getChildAt(childIndex); } @@ -179,8 +182,9 @@ /* (non-Javadoc) * @see javax.swing.tree.TreeNode#getChildCount() */ + //@Override public int getChildCount() { - if (isSetUserObjects()) { + if (isSetUserObject()) { if (userObject instanceof Collection<?>) { return ((Collection<?>) userObject).size(); } @@ -219,23 +223,23 @@ /** * @return */ - public boolean isSetUserObjects() { + public boolean isSetUserObject() { return userObject != null; } /** * Checks whether or not the user's object has been set (see - * {@link #isSetUserObjects()}) and if so if it belongs to those elements + * {@link #isSetUserObject()}) and if so if it belongs to those elements * returned by the method {@link #getChildAt(int)}. * * @return <code>true</code> if the user's object has been defined and * belongs to those classes that are returned by the method * {@link #getChildAt(int)}. * @see #getChildAt(int) - * @see #isSetUserObjects() + * @see #isSetUserObject() */ public boolean isUserObjectRecursiveDataType() { - return isSetUserObjects() + return isSetUserObject() && ((userObject instanceof Collection<?>) || (userObject instanceof Map<?, ?>) || (userObject instanceof TreeNode)); } @@ -253,7 +257,7 @@ */ @Override public String toString() { - if (isSetUserObjects()) { + if (isSetUserObject()) { if (userObject instanceof Collection<?>) { Collection<?> collection = (Collection<?>) userObject; if (ListOf.isDebugMode()) { @@ -262,11 +266,10 @@ if (collection.size() > 0) { String name = collection.iterator().next().getClass() .getSimpleName(); - if (!name.endsWith("s")) { - name += "s"; + if (!name.endsWith("s") && !name.toLowerCase().endsWith("information")) { + name += 's'; } - String type = collection instanceof List<?> ? "listOf" - : "collectionOf"; + String type = collection instanceof List<?> ? "listOf" : "collectionOf"; return type + name; } return collection.getClass().getSimpleName(); Modified: trunk/core/src/org/sbml/jsbml/xml/parsers/AbstractReaderWriter.java =================================================================== --- trunk/core/src/org/sbml/jsbml/xml/parsers/AbstractReaderWriter.java 2012-06-14 07:07:30 UTC (rev 1307) +++ trunk/core/src/org/sbml/jsbml/xml/parsers/AbstractReaderWriter.java 2012-06-14 10:14:23 UTC (rev 1308) @@ -240,8 +240,8 @@ if (listOf.size() > 0) { String listOfName = "listOf" + listOf.get(0).getClass().getSimpleName(); - if (!listOfName.endsWith("s")) { - listOfName += "s"; + if (!listOfName.endsWith("s") && !listOfName.toLowerCase().endsWith("information")) { + listOfName += 's'; } xmlObject.setName(listOfName); } Modified: trunk/core/src/org/sbml/jsbml/xml/stax/SBMLObjectForXML.java =================================================================== --- trunk/core/src/org/sbml/jsbml/xml/stax/SBMLObjectForXML.java 2012-06-14 07:07:30 UTC (rev 1307) +++ trunk/core/src/org/sbml/jsbml/xml/stax/SBMLObjectForXML.java 2012-06-14 10:14:23 UTC (rev 1308) @@ -185,8 +185,7 @@ this.prefix = prefix; } - /* - * (non-Javadoc) + /* (non-Javadoc) * @see java.lang.Object#toString() */ @Override Modified: trunk/core/src/org/sbml/jsbml/xml/stax/SBMLWriter.java =================================================================== --- trunk/core/src/org/sbml/jsbml/xml/stax/SBMLWriter.java 2012-06-14 07:07:30 UTC (rev 1307) +++ trunk/core/src/org/sbml/jsbml/xml/stax/SBMLWriter.java 2012-06-14 10:14:23 UTC (rev 1308) @@ -30,6 +30,7 @@ import java.io.OutputStream; import java.io.StringReader; import java.io.StringWriter; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; @@ -72,6 +73,7 @@ import org.sbml.jsbml.SBMLException; import org.sbml.jsbml.SBase; import org.sbml.jsbml.UnitDefinition; +import org.sbml.jsbml.ext.SBasePlugin; import org.sbml.jsbml.util.JAXPFacade; import org.sbml.jsbml.util.StringTools; import org.sbml.jsbml.util.compilers.MathMLXMLStreamCompiler; @@ -121,7 +123,7 @@ if (args.length < 1) { System.out.println( - "Usage : java org.sbml.jsbml.xml.stax.SBMLWriter sbmlFileName"); + "Usage: java org.sbml.jsbml.xml.stax.SBMLWriter sbmlFileName"); System.exit(0); } @@ -167,8 +169,8 @@ } else { System.out.println("It took " + nbSecondes + " secondes."); } - System.out.println("Reading : " + nbSecondesRead + " secondes."); - System.out.println("Writing : " + nbSecondesWrite + " secondes."); + System.out.println("Reading: " + nbSecondesRead + " secondes."); + System.out.println("Writing: " + nbSecondesWrite + " secondes."); } /** @@ -286,7 +288,7 @@ Set<String> packageNamespaces = null; - // logger.debug("getInitializedParsers : name space, object = " + name space + ", " + object); + // logger.debug("getInitializedParsers: name space, object = " + name space + ", " + object); if (object instanceof SBase) { SBase sbase = (SBase) object; @@ -295,7 +297,7 @@ Annotation annotation = (Annotation) object; packageNamespaces = annotation.getNamespaces(); } else { - logger.warn("getInitializedParsers : I don't know what to do with " + object); + logger.warn("getInitializedParsers: I don't know what to do with " + object); } ArrayList<WritingParser> sbmlParsers = new ArrayList<WritingParser>(); @@ -380,8 +382,8 @@ */ public void setIndentationChar(char indentSymbol) { if ((indentSymbol != ' ') && (indentSymbol != '\t')) { - throw new IllegalArgumentException(String.format( - "Invalid argument '%s'. Only the blank symbols '\\t' and ' ' are allowed for indentation.", + throw new IllegalArgumentException(MessageFormat.format( + "Invalid argument \"{0}\". Only the blank symbols '\\t' and ' ' are allowed for indentation.", indentSymbol)); } this.indentChar = indentSymbol; @@ -401,8 +403,8 @@ */ public void setIndentationCount(short indentCount) { if (indentCount < 0) { - throw new IllegalArgumentException(String.format( - "Indent count must be non-negative. Invalid argument %d.", + throw new IllegalArgumentException(MessageFormat.format( + "Indent count must be non-negative. Invalid argument {0,number}.", indentCount)); } this.indentCount = indentCount; @@ -447,9 +449,9 @@ * Writes the SBMLDocument in a SBML file. * * @param sbmlDocument - * : the SBMLDocument to write + * the SBMLDocument to write * @param stream - * : a stream where to write the content of the model to. + * a stream where to write the content of the model to. * @throws XMLStreamException * @throws SBMLException * @throws IOException @@ -513,11 +515,10 @@ * which version of JSBML was used for this purpose. */ if ((programName != null) && (programName.length() > 0)) { - String date = String.format("%1$tY-%1$tm-%1$td %1$tR", Calendar - .getInstance().getTime()); - String msg = " Created by %s version %s on %s with jsbml version %s. "; + String date = String.format("%1$tY-%1$tm-%1$td %1$tR", Calendar.getInstance().getTime()); + String msg = " Created by {0} version {1} on {2} with JSBML version {3}. "; outputDocument.addComment( - String.format(msg, programName, (programVersion != null) + MessageFormat.format(msg, programName, (programVersion != null) && (programVersion.length() > 0) ? programVersion : "?", date, JSBML.getJSBMLDottedVersion())); outputDocument.addCharacters("\n"); @@ -542,14 +543,14 @@ Map.Entry<String, String> entry = it.next(); if (!entry.getKey().equals("xmlns")) { - logger.debug(" SBML name spaces : " + entry.getKey() + " = " + logger.debug(" SBML name spaces: " + entry.getKey() + " = " + entry.getValue()); String namespacePrefix = entry.getKey().substring( entry.getKey().indexOf(":") + 1); streamWriter.setPrefix(namespacePrefix, entry.getValue()); - logger.debug(" SBML namespaces : " + namespacePrefix + " = " + logger.debug(" SBML namespaces: " + namespacePrefix + " = " + entry.getValue()); } @@ -582,9 +583,9 @@ * Writes the XML representation of an {@link SBMLDocument} in a SBML file. * * @param sbmlDocument - * : the SBMLDocument to write + * the SBMLDocument to write * @param fileName - * : the name of the file where to write the {@link SBMLDocument} + * the name of the file where to write the {@link SBMLDocument} * * * @throws XMLStreamException @@ -666,13 +667,13 @@ * Writes the annotation of this sbase component. * * @param sbase - * : the sbase component + * the sbase component * @param element - * : the matching SMOutputElement + * the matching SMOutputElement * @param writer - * : the XMLStreamWriter2 + * the XMLStreamWriter2 * @param sbmlNamespace - * : the SBML namespace. + * the SBML namespace. * @param indent * the number of indent white spaces of this annotation. * @throws XMLStreamException @@ -737,7 +738,7 @@ // that is not yet linked to a SBMLDocument. allNamespacesDefined = false; } - // TODO : to be able to write broken annotations where the namespace declaration is missing + // TODO: to be able to write broken annotations where the namespace declaration is missing // we need to add dummy namespace here !! Or remove the namespace awareness on the writer !! StringTools.append(annotationBeginning, Character.valueOf('>'), @@ -758,7 +759,7 @@ domConversionDone = true; } catch (SAXException e) { e.printStackTrace(); - // TODO : log error or send SBMLException + // TODO: log error or send SBMLException logger.warn("Cannot parse the following XML\n@" + annotationString + "@"); logger.warn("NonRDFannotation =\n@" + annotation.getNonRDFannotation() + "@"); @@ -773,7 +774,7 @@ domConversionDone = true; } catch (SAXException e2) { e.printStackTrace(); - // TODO : log error or send SBMLException + // TODO: log error or send SBMLException } } } finally { @@ -805,8 +806,8 @@ * or the SBase is derived from a different SBase implementation, it * could fail. */ - logger.info(String.format( - "Could not write RDF annotation of %s due to missing metaid.", + logger.info(MessageFormat.format( + "Could not write RDF annotation of {0} due to missing metaid.", sbase.getElementName())); } } @@ -819,11 +820,11 @@ * Writes the listOfCVTerms. * * @param listOfCVTerms - * : the list of CVTerms to write + * the list of CVTerms to write * @param rdfNamespaces - * : the RDF name spaces and prefixes + * the RDF name spaces and prefixes * @param writer - * : the XMLStreamWriter2 + * the XMLStreamWriter2 * @param indent * @throws XMLStreamException */ @@ -902,11 +903,11 @@ * Writes the history represented by this History instance. * * @param history - * : the history to write + * the history to write * @param rdfNamespaces - * : contains the RDF namespaces and their prefixes. + * contains the RDF namespaces and their prefixes. * @param writer - * : the XMLStreamWriter2 + * the XMLStreamWriter2 * @param indent * @throws XMLStreamException */ @@ -1039,7 +1040,7 @@ // Writing the current modified dates. if (history.isSetModifiedDate()) { - for (int i = 0; i < history.getNumModifiedDates(); i++) { + for (int i = 0; i < history.getModifiedDateCount(); i++) { writeW3CDate(writer, indent, DateParser.getIsoDateNoMillis(history .getModifiedDate(i)), "modified", dctermPrefix, @@ -1057,11 +1058,11 @@ * component. * * @param m - * : the sbase component + * the sbase component * @param element - * : the matching SMOutputElement + * the matching SMOutputElement * @param writer - * : the XMLStreamWriter + * the XMLStreamWriter * @param indent * @throws XMLStreamException * @@ -1083,7 +1084,7 @@ writer, createIndentationString(indent + indentCount)); boolean isSBMLNamespaceNeeded = compiler.isSBMLNamespaceNeeded(m.getMath()); - // TODO : add all other namespaces !! + // TODO: add all other namespaces !! if (isSBMLNamespaceNeeded) { // writing the SBML namespace @@ -1096,7 +1097,7 @@ sbmlNamespace = doc.getSBMLDocumentNamespaces().get("xmlns"); if (sbmlNamespace == null) { - logger.warn("writeMathML : the SBML namespace of this SBMLDocument" + + logger.warn("writeMathML: the SBML namespace of this SBMLDocument" + " could not be found, using the default namespace (" + SBMLDocument.URI_NAMESPACE_L3V1Core + ") instead."); sbmlNamespace = SBMLDocument.URI_NAMESPACE_L3V1Core; @@ -1120,13 +1121,13 @@ * Writes the message of this Constraint. * * @param sbase - * : the Constraint component + * the Constraint component * @param element - * : the matching SMOUtputElement + * the matching SMOUtputElement * @param writer - * : the XMLStreamWriter2 + * the XMLStreamWriter2 * @param sbmlNamespace - * : the SBML namespace + * the SBML namespace * @throws XMLStreamException */ private void writeMessage(Constraint sbase, SMOutputElement element, @@ -1158,13 +1159,13 @@ * Writes the notes of this sbase component. * * @param sbase - * : the SBase component + * the SBase component * @param element - * : the matching SMOUtputElement + * the matching SMOUtputElement * @param writer - * : the XMLStreamWriter2 + * the XMLStreamWriter2 * @param sbmlNamespace - * : the SBML namespace + * the SBML namespace * @param indent * @throws XMLStreamException */ @@ -1181,11 +1182,11 @@ * Writes the RDF annotation contained in 'annotation'. * * @param annotation - * : the annotation to write + * the annotation to write * @param annotationElement - * : the matching SMOutputElement + * the matching SMOutputElement * @param writer - * : the XMLStreamWriter. + * the XMLStreamWriter. * @param indent * @throws XMLStreamException */ @@ -1217,7 +1218,7 @@ } // Checking if all the necessary namespaces are defined - // TODO : In fact, we could remove the rdfNamespaces map ? + // TODO: In fact, we could remove the rdfNamespaces map ? if (rdfNamespaces.get(Annotation.URI_RDF_SYNTAX_NS) == null || rdfNamespaces.get(Annotation.URI_RDF_SYNTAX_NS).equals("xmlns")) @@ -1286,21 +1287,21 @@ rdfElement.addCharacters(whiteSpace); annotationElement.addCharacters("\n"); } - + /** * Writes the SBML elements. * * @param parentXmlObject - * : contains the XML information of the parentElement. + * contains the XML information of the parentElement. * @param smOutputParentElement - * : SMOutputElement of the parentElement. + * SMOutputElement of the parentElement. * @param streamWriter * @param objectToWrite - * : the Object to write. + * the Object to write. * @param notesParser - * : the WritingParser to parse the notes. + * the WritingParser to parse the notes. * @param MathMLparser - * : the WritingParser to parse the MathML expressions. + * the WritingParser to parse the MathML expressions. * @param indent * The number of white spaces to indent this element. * @throws XMLStreamException @@ -1315,16 +1316,16 @@ String whiteSpaces = createIndentationString(indent); // Get the list of parsers to use. - ArrayList<WritingParser> listOfPackages = getWritingParsers( + List<WritingParser> listOfPackages = getWritingParsers( objectToWrite, smOutputParentElement.getNamespace().getURI()); if (logger.isDebugEnabled()) { - logger.debug("writeSBMLElements : xmlObject = " + parentXmlObject); - logger.debug("writeSBMLElements : parentElement = " + logger.debug("writeSBMLElements: xmlObject = " + parentXmlObject); + logger.debug("writeSBMLElements: parentElement = " + smOutputParentElement.getLocalName() + ", " + smOutputParentElement.getNamespace().getURI()); - logger.debug("writeSBMLElements : objectToWrite = " + objectToWrite + '\n'); - logger.debug("writeSBMLElements : listOfPackages = " + listOfPackages + '\n'); + logger.debug("writeSBMLElements: objectToWrite = " + objectToWrite + '\n'); + logger.debug("writeSBMLElements: listOfPackages = " + listOfPackages + '\n'); } Iterator<WritingParser> iterator = listOfPackages.iterator(); @@ -1334,12 +1335,12 @@ .getListOfSBMLElementsToWrite(objectToWrite); if (logger.isDebugEnabled()) { - logger.debug("writeSBMLElements : parser = " + parser); - logger.debug("writeSBMLElements : elementsToWrite = " + sbmlElementsToWrite); + logger.debug("writeSBMLElements: parser = " + parser); + logger.debug("writeSBMLElements: elementsToWrite = " + sbmlElementsToWrite); } if (sbmlElementsToWrite == null) { - // TODO : test if there are some characters to write ? + // TODO: test if there are some characters to write ? // to allow the XML parser to prune empty elements, this indent should not be added. // streamWriter.writeCharacters(whiteSpaces.substring(0, @@ -1388,8 +1389,8 @@ if (listType == Type.none) { // Prevent writing invalid SBML if list types are // not set appropriately. - throw new SBMLException(String.format( - "Unknown ListOf type \"%s\".", + throw new SBMLException(MessageFormat.format( + "Unknown ListOf type \"{0}\".", toTest.getElementName())); } if (listType.equals(ListOf.Type.listOfReactants) @@ -1416,7 +1417,7 @@ if (parentXmlObject.isSetName()) { boolean isClosedMathContainer = false, isClosedAnnotation = false; - // TODO : problem here as a children does not have the same namespace as his parent all the time !! + // TODO: problem here as a children does not have the same namespace as his parent all the time !! // use ((SBase) nextObjectToWrite).getNamespaces(); ?? if (parentXmlObject.isSetNamespace()) { @@ -1539,7 +1540,16 @@ return stream.toString(); } - + /** + * + * @param writer + * @param indent + * @param dateISO + * @param dcterm + * @param dctermPrefix + * @param rdfPrefix + * @throws XMLStreamException + */ private void writeW3CDate(XMLStreamWriter writer, int indent, String dateISO, String dcterm, String dctermPrefix, String rdfPrefix) throws XMLStreamException { @@ -1560,7 +1570,7 @@ writer.writeCharacters("\n"); } - // TODO : test a bit more Xstream and using Qname to see how it + // TODO: test a bit more Xstream and using Qname to see how it // can deal with math or rdf bloc } Modified: trunk/extensions/render/test/org/sbml/jsbml/ext/render/RenderWriteTest.java =================================================================== --- trunk/extensions/render/test/org/sbml/jsbml/ext/render/RenderWriteTest.java 2012-06-14 07:07:30 UTC (rev 1307) +++ trunk/extensions/render/test/org/sbml/jsbml/ext/render/RenderWriteTest.java 2012-06-14 10:14:23 UTC (rev 1308) @@ -51,7 +51,7 @@ ExtendedLayoutModel elm = new ExtendedLayoutModel(m); m.addExtension(LayoutConstants.getNamespaceURI(m.getLevel(), m.getVersion()), elm); Layout l1 = elm.createLayout("l1"); - + l1.createCompartmentGlyph("test"); RenderLayoutPlugin rlp = new RenderLayoutPlugin(l1); rlp.createLocalRenderInformation("info1"); l1.addExtension(RenderConstants.namespaceURI, rlp); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2012-06-14 07:07:39
|
Revision: 1307 http://jsbml.svn.sourceforge.net/jsbml/?rev=1307&view=rev Author: andreas-draeger Date: 2012-06-14 07:07:30 +0000 (Thu, 14 Jun 2012) Log Message: ----------- Corrected a typo in a method's name. Modified Paths: -------------- trunk/core/src/org/sbml/jsbml/util/TreeNodeRemovedEvent.java trunk/modules/celldesigner/src/org/sbml/jsbml/cdplugin/PluginChangeListener.java Modified: trunk/core/src/org/sbml/jsbml/util/TreeNodeRemovedEvent.java =================================================================== --- trunk/core/src/org/sbml/jsbml/util/TreeNodeRemovedEvent.java 2012-06-14 07:07:16 UTC (rev 1306) +++ trunk/core/src/org/sbml/jsbml/util/TreeNodeRemovedEvent.java 2012-06-14 07:07:30 UTC (rev 1307) @@ -39,7 +39,7 @@ * {@link TreeNodeChangeListener} wants to, e.g., undo this change, * it is necessary to identify the previous position of the node within the * tree. That's why this class has two important - * methods, namely {@link #getSource()} and {@link #getPreviosParent()}. + * methods, namely {@link #getSource()} and {@link #getPreviousParent()}. * * @author Andreas Dräger * @version $Rev$ @@ -81,7 +81,7 @@ * @param treeNodeRemovedEvent */ public TreeNodeRemovedEvent(TreeNodeRemovedEvent treeNodeRemovedEvent) { - this(treeNodeRemovedEvent.getSource(), treeNodeRemovedEvent.getPreviosParent()); + this(treeNodeRemovedEvent.getSource(), treeNodeRemovedEvent.getPreviousParent()); } /* (non-Javadoc) @@ -99,7 +99,7 @@ * @return the previosParent * @see #getSource() */ - public TreeNode getPreviosParent() { + public TreeNode getPreviousParent() { return previosParent; } Modified: trunk/modules/celldesigner/src/org/sbml/jsbml/cdplugin/PluginChangeListener.java =================================================================== --- trunk/modules/celldesigner/src/org/sbml/jsbml/cdplugin/PluginChangeListener.java 2012-06-14 07:07:16 UTC (rev 1306) +++ trunk/modules/celldesigner/src/org/sbml/jsbml/cdplugin/PluginChangeListener.java 2012-06-14 07:07:30 UTC (rev 1307) @@ -1199,7 +1199,7 @@ //@Override public void nodeRemoved(TreeNodeRemovedEvent evt) { TreeNode node = evt.getSource(); - TreeNode parent = evt.getPreviosParent(); + TreeNode parent = evt.getPreviousParent(); if (node instanceof AbstractSBase) { if (node instanceof AbstractNamedSBase) { if (node instanceof CompartmentType) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2012-06-14 07:07:25
|
Revision: 1306 http://jsbml.svn.sourceforge.net/jsbml/?rev=1306&view=rev Author: andreas-draeger Date: 2012-06-14 07:07:16 +0000 (Thu, 14 Jun 2012) Log Message: ----------- Corrected a typo in a method's name. Modified Paths: -------------- branches/jsbml-0.8/src/org/sbml/jsbml/util/TreeNodeRemovedEvent.java Modified: branches/jsbml-0.8/src/org/sbml/jsbml/util/TreeNodeRemovedEvent.java =================================================================== --- branches/jsbml-0.8/src/org/sbml/jsbml/util/TreeNodeRemovedEvent.java 2012-06-12 16:01:16 UTC (rev 1305) +++ branches/jsbml-0.8/src/org/sbml/jsbml/util/TreeNodeRemovedEvent.java 2012-06-14 07:07:16 UTC (rev 1306) @@ -39,7 +39,7 @@ * {@link TreeNodeChangeListener} wants to, e.g., undo this change, * it is necessary to identify the previous position of the node within the * tree. That's why this class has two important - * methods, namely {@link #getSource()} and {@link #getPreviosParent()}. + * methods, namely {@link #getSource()} and {@link #getPreviousParent()}. * * @author Andreas Dräger * @version $Rev$ @@ -81,7 +81,7 @@ * @param treeNodeRemovedEvent */ public TreeNodeRemovedEvent(TreeNodeRemovedEvent treeNodeRemovedEvent) { - this(treeNodeRemovedEvent.getSource(), treeNodeRemovedEvent.getPreviosParent()); + this(treeNodeRemovedEvent.getSource(), treeNodeRemovedEvent.getPreviousParent()); } /* (non-Javadoc) @@ -99,7 +99,7 @@ * @return the previosParent * @see #getSource() */ - public TreeNode getPreviosParent() { + public TreeNode getPreviousParent() { return previosParent; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nik...@us...> - 2012-06-12 16:01:27
|
Revision: 1305 http://jsbml.svn.sourceforge.net/jsbml/?rev=1305&view=rev Author: niko-rodrigue Date: 2012-06-12 16:01:16 +0000 (Tue, 12 Jun 2012) Log Message: ----------- corrected AbstractSBase.addExtension to not add the extension namespace to the list of namespaces and stax/SBMLWriter to use the namespaces from the extensions Map instead of the SBase list of namespaces (which should a single namespace in fact) + cleaned a bit the RenderParser Modified Paths: -------------- trunk/core/src/org/sbml/jsbml/AbstractSBase.java trunk/core/src/org/sbml/jsbml/xml/parsers/AbstractReaderWriter.java trunk/core/src/org/sbml/jsbml/xml/stax/SBMLWriter.java trunk/extensions/render/src/org/sbml/jsbml/xml/parsers/RenderParser.java Modified: trunk/core/src/org/sbml/jsbml/AbstractSBase.java =================================================================== --- trunk/core/src/org/sbml/jsbml/AbstractSBase.java 2012-06-12 13:15:01 UTC (rev 1304) +++ trunk/core/src/org/sbml/jsbml/AbstractSBase.java 2012-06-12 16:01:16 UTC (rev 1305) @@ -280,7 +280,6 @@ */ public void addExtension(String namespace, SBasePlugin sbase) { this.extensions.put(namespace, sbase); - addNamespace(namespace); firePropertyChange(TreeNodeChangeEvent.addExtension, null, sbase); } Modified: trunk/core/src/org/sbml/jsbml/xml/parsers/AbstractReaderWriter.java =================================================================== --- trunk/core/src/org/sbml/jsbml/xml/parsers/AbstractReaderWriter.java 2012-06-12 13:15:01 UTC (rev 1304) +++ trunk/core/src/org/sbml/jsbml/xml/parsers/AbstractReaderWriter.java 2012-06-12 16:01:16 UTC (rev 1305) @@ -175,6 +175,9 @@ listOfElementsToWrite.add(children.nextElement()); } + logger.debug("getListOfSBMLElementsToWrite : nb children = " + listOfElementsToWrite.size()); + logger.debug("getListOfSBMLElementsToWrite : children = " + listOfElementsToWrite); + if (listOfElementsToWrite.isEmpty()) { listOfElementsToWrite = null; } @@ -223,6 +226,14 @@ if (sbmlElementToWrite instanceof SBase) { SBase sbase = (SBase) sbmlElementToWrite; + logger.debug("writeElement : sbase.namespaces size = " + sbase.getNamespaces().size()); + logger.debug("writeElement : sbase.namespaces = " + sbase.getNamespaces()); + + if (!sbase.getNamespaces().contains(getNamespaceURI())) { + logger.debug("writeElement : rejected element"); + return; + } + if (!xmlObject.isSetName()) { if (sbase instanceof ListOf<?>) { ListOf<?> listOf = (ListOf<?>) sbase; Modified: trunk/core/src/org/sbml/jsbml/xml/stax/SBMLWriter.java =================================================================== --- trunk/core/src/org/sbml/jsbml/xml/stax/SBMLWriter.java 2012-06-12 13:15:01 UTC (rev 1304) +++ trunk/core/src/org/sbml/jsbml/xml/stax/SBMLWriter.java 2012-06-12 16:01:16 UTC (rev 1305) @@ -290,7 +290,7 @@ if (object instanceof SBase) { SBase sbase = (SBase) object; - packageNamespaces = sbase.getNamespaces(); + packageNamespaces = sbase.getExtensionPackages().keySet(); } else if (object instanceof Annotation) { Annotation annotation = (Annotation) object; packageNamespaces = annotation.getNamespaces(); Modified: trunk/extensions/render/src/org/sbml/jsbml/xml/parsers/RenderParser.java =================================================================== --- trunk/extensions/render/src/org/sbml/jsbml/xml/parsers/RenderParser.java 2012-06-12 13:15:01 UTC (rev 1304) +++ trunk/extensions/render/src/org/sbml/jsbml/xml/parsers/RenderParser.java 2012-06-12 16:01:16 UTC (rev 1305) @@ -58,67 +58,7 @@ */ private Logger logger = Logger.getLogger(RenderParser.class); - /* (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.AbstractReaderWriter#getListOfSBMLElementsToWrite(java.lang.Object) - */ - @Override - public ArrayList<Object> getListOfSBMLElementsToWrite(Object sbase) { - if (logger.isDebugEnabled()) { - logger.debug("getListOfSBMLElementsToWrite : " + sbase.getClass().getCanonicalName()); - } - - ArrayList<Object> listOfElementsToWrite = new ArrayList<Object>(); - - if (sbase instanceof SBMLDocument) { - // nothing to do - // TODO : the 'required' attribute is written even if there is no plugin class for the SBMLDocument, so I am not totally sure how this is done. - } - else if (sbase instanceof ListOf<?>) { - // if the sbase is a ListOf, we could have a RenderModelPlugin attached to it - ListOf<?> listOf = (ListOf<?>)sbase; - if (listOf.getSBaseListType() == Type.other) { - - SBasePlugin plugin = listOf.getExtension(RenderConstants.namespaceURI); - - if (plugin != null) { - RenderModelPlugin rmp = (RenderModelPlugin) plugin; - - // then add its extension children to the list of elements to write - Enumeration<TreeNode> children = rmp.children(); - while (children.hasMoreElements()) { - listOfElementsToWrite.add(children.nextElement()); - } - } - } - } - else if (sbase instanceof Layout) { - // if the sbase is a Layout get its extension - RenderLayoutPlugin rlp = (RenderLayoutPlugin)((Layout)sbase).getExtension(RenderConstants.namespaceURI); - - // then add its extension children to the list of elements to write - Enumeration<TreeNode> children = rlp.children(); - while (children.hasMoreElements()) { - listOfElementsToWrite.add(children.nextElement()); - } - } - else if (sbase instanceof TreeNode) { - Enumeration<TreeNode> children = ((TreeNode) sbase).children(); - - while (children.hasMoreElements()) { - listOfElementsToWrite.add(children.nextElement()); - } - } - - if (listOfElementsToWrite.isEmpty()) { - listOfElementsToWrite = null; - } else if (logger.isDebugEnabled()) { - logger.debug("getListOfSBMLElementsToWrite size = " + listOfElementsToWrite.size()); - } - - return listOfElementsToWrite; - } - /* (non-Javadoc) * @see org.sbml.jsbml.xml.parsers.AbstractReaderWriter#processStartElement(java.lang.String, java.lang.String, boolean, boolean, java.lang.Object) */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2012-06-12 13:15:07
|
Revision: 1304 http://jsbml.svn.sourceforge.net/jsbml/?rev=1304&view=rev Author: andreas-draeger Date: 2012-06-12 13:15:01 +0000 (Tue, 12 Jun 2012) Log Message: ----------- Added a new convenience function to check if a model contains a given reaction identifier. Modified Paths: -------------- trunk/core/src/org/sbml/jsbml/Model.java Modified: trunk/core/src/org/sbml/jsbml/Model.java =================================================================== --- trunk/core/src/org/sbml/jsbml/Model.java 2012-06-12 12:48:29 UTC (rev 1303) +++ trunk/core/src/org/sbml/jsbml/Model.java 2012-06-12 13:15:01 UTC (rev 1304) @@ -292,7 +292,7 @@ * Adds a Compartment instance to the listOfCompartments of this Model. * * @param compartment - * @return <code>true</code> if the {@link #listOfCompartments} was changed as + * @return {@code true} if the {@link #listOfCompartments} was changed as * a result of this call. */ public boolean addCompartment(Compartment compartment) { @@ -304,7 +304,7 @@ * Model. * * @param compartmentType - * @return <code>true</code> if the {@link #listOfCompartmentTypes} was + * @return {@code true} if the {@link #listOfCompartmentTypes} was * changed as a result of this call. * @deprecated Only valid in SBML Level 2 for Versions 2 through 4. */ @@ -318,7 +318,7 @@ * {@link Model}. * * @param constraint - * @return <code>true</code> if the {@link #listOfConstraints} was changed as + * @return {@code true} if the {@link #listOfConstraints} was changed as * a result of this call. */ public boolean addConstraint(Constraint constraint) { @@ -329,7 +329,7 @@ * Adds an {@link Event} instance to the listOfEvents of this Model. * * @param event - * @return <code>true</code> if the {@link #listOfEvents} was changed as a + * @return {@code true} if the {@link #listOfEvents} was changed as a * result of this call. * @throws PropertyNotAvailableException * for inappropriate Level/Version combinations. @@ -346,7 +346,7 @@ * of this {@link Model}. * * @param functionDefinition - * @return <code>true</code> if the {@link #listOfFunctionDefinitions} was + * @return {@code true} if the {@link #listOfFunctionDefinitions} was * changed as a result of this call. */ public boolean addFunctionDefinition(FunctionDefinition functionDefinition) { @@ -358,7 +358,7 @@ * Model. * * @param initialAssignment - * @return <code>true</code> if the {@link #listOfInitialAssignments} was + * @return {@code true} if the {@link #listOfInitialAssignments} was * changed as a result of this call. */ public boolean addInitialAssignment(InitialAssignment initialAssignment) { @@ -369,7 +369,7 @@ * Adds a Parameter instance to the listOfParameters of this Model. * * @param parameter - * @return <code>true</code> if the {@link #listOfParameters} was changed as a + * @return {@code true} if the {@link #listOfParameters} was changed as a * result of this call. */ public boolean addParameter(Parameter parameter) { @@ -489,7 +489,7 @@ * Adds a Reaction instance to the listOfReactions of this Model. * * @param reaction - * @return <code>true</code> if the {@link #listOfReactions} was changed as a + * @return {@code true} if the {@link #listOfReactions} was changed as a * result of this call. */ public boolean addReaction(Reaction reaction) { @@ -500,7 +500,7 @@ * Adds a Rule instance to the listOfRules of this Model. * * @param rule - * @return <code>true</code> if the {@link #listOfRules} was changed as a + * @return {@code true} if the {@link #listOfRules} was changed as a * result of this call. */ public boolean addRule(Rule rule) { @@ -511,7 +511,7 @@ * Adds a Species instance to the listOfSpecies of this Model. * * @param spec - * @return <code>true</code> if the {@link #listOfSpecies} was changed as a + * @return {@code true} if the {@link #listOfSpecies} was changed as a * result of this call. */ public boolean addSpecies(Species spec) { @@ -522,7 +522,7 @@ * Adds a SpeciesType instance to the listOfSpeciesTypes of this Model. * * @param speciesType - * @return <code>true</code> if the {@link #listOfSpeciesTypes} was changed as + * @return {@code true} if the {@link #listOfSpeciesTypes} was changed as * a result of this call. * @deprecated Only valid in SBML Level 2 for Versions 2 through 4. */ @@ -535,7 +535,7 @@ * Adds an UnitDefinition instance to the listOfUnitDefinitions of this Model. * * @param unitDefinition - * @return <code>true</code> if the {@link #listOfUnitDefinitions} was changed + * @return {@code true} if the {@link #listOfUnitDefinitions} was changed * as a result of this call. */ public boolean addUnitDefinition(UnitDefinition unitDefinition) { @@ -579,11 +579,11 @@ } /** - * Returns <code>true</code> if this model contains a reference to a {@link Compartment} + * Returns {@code true} if this model contains a reference to a {@link Compartment} * with the given identifier. * * @param id - * @return <code>true</code> if this model contains a reference to a {@link Compartment} + * @return {@code true} if this model contains a reference to a {@link Compartment} * with the given identifier. */ public boolean containsCompartment(String id) { @@ -591,11 +591,11 @@ } /** - * Returns <code>true</code> if this model contains a reference to a + * Returns {@code true} if this model contains a reference to a * {@link FunctionDefinition} with the given identifier. * * @param id - * @return <code>true</code> if this model contains a reference to a + * @return {@code true} if this model contains a reference to a * {@link FunctionDefinition} with the given identifier. */ public boolean containsFunctionDefinition(String id) { @@ -603,11 +603,11 @@ } /** - * Returns <code>true</code> if this model contains a reference to a {@link Parameter} with + * Returns {@code true} if this model contains a reference to a {@link Parameter} with * the given identifier. * * @param id - * @return <code>true</code> if this model contains a reference to a {@link Parameter} with + * @return {@code true} if this model contains a reference to a {@link Parameter} with * the given identifier. */ public boolean containsParameter(String id) { @@ -615,11 +615,11 @@ } /** - * Returns <code>true</code> if this {@link Model} contains a reference to the given + * Returns {@code true} if this {@link Model} contains a reference to the given * {@link Quantity}. * * @param quantity - * @return <code>true</code> if this {@link Model} contains a reference to the given + * @return {@code true} if this {@link Model} contains a reference to the given * {@link Quantity}. */ public boolean containsQuantity(Quantity quantity) { @@ -629,13 +629,26 @@ } return findQuantity(quantity.getId()) != null; } + + /** + * Returns {@code true} if this {@link Model} contains a reference to the + * given {@link Reaction}. + * + * @param id + * the identifier of a potential reaction. + * @return {@code true} if this {@link Model} contains a reference to the + * given {@link Reaction}. + */ + public boolean containsReaction(String id) { + return getReaction(id) != null; + } /** - * Returns <code>true</code> if this {@link Model} contains a reference to the given + * Returns {@code true} if this {@link Model} contains a reference to the given * {@link Species}. * * @param id - * @return <code>true</code> if this {@link Model} contains a reference to the given + * @return {@code true} if this {@link Model} contains a reference to the given * {@link Species}. */ public boolean containsSpecies(String id) { @@ -643,11 +656,11 @@ } /** - * Returns <code>true</code> if this {@link Model} contains a reference to the given + * Returns {@code true} if this {@link Model} contains a reference to the given * {@link UniqueNamedSBase}. * * @param units - * @return <code>true</code> if this {@link Model} contains a reference to the given + * @return {@code true} if this {@link Model} contains a reference to the given * {@link UniqueNamedSBase}. */ public boolean containsUniqueNamedSBase(String id) { @@ -655,11 +668,11 @@ } /** - * Returns <code>true</code> if this {@link Model} contains a reference to the given + * Returns {@code true} if this {@link Model} contains a reference to the given * {@link UnitDefinition}. * * @param units - * @return <code>true</code> if this {@link Model} contains a reference to the given + * @return {@code true} if this {@link Model} contains a reference to the given * {@link UnitDefinition}. */ public boolean containsUnitDefinition(String units) { @@ -2723,10 +2736,10 @@ /** * Returns the number of {@link Species} whose boundary condition is set to - * <code>true</code>. + * {@code true}. * * @return the number of {@link Species} whose boundary condition is set to - * <code>true</code>. + * {@code true}. * @deprecated use {@link #getSpeciesWithBoundaryConditionCount()} */ @Deprecated @@ -3089,10 +3102,10 @@ /** * Returns the number of {@link Species} whose boundary condition is set to - * <code>true</code>. + * {@code true}. * * @return the number of {@link Species} whose boundary condition is set to - * <code>true</code>. + * {@code true}. */ public int getSpeciesWithBoundaryConditionCount() { return getListOfSpecies().filterList(new BoundaryConditionFilter()).size(); @@ -3320,12 +3333,12 @@ } /** - * Returns <code>true</code> if this model has a reference to the unit with the given + * Returns {@code true} if this model has a reference to the unit with the given * identifier. * * @param id - * @return <code>true</code> if this model has a reference to the unit with the given - * identifier, <code>false</code> otherwise. + * @return {@code true} if this model has a reference to the unit with the given + * identifier, {@code false} otherwise. */ public boolean hasUnit(String id) { return getUnitDefinition(id) != null; @@ -3421,19 +3434,19 @@ } /** - * Returns <code>true</code> if the area units ID of this Model is not <code>null</code>. + * Returns {@code true} if the area units ID of this Model is not <code>null</code>. * - * @return <code>true</code> if the area units ID of this Model is not <code>null</code>. + * @return {@code true} if the area units ID of this Model is not <code>null</code>. */ public boolean isSetAreaUnits() { return this.areaUnitsID != null; } /** - * Returns <code>true</code> if the UnitDefinition which has the area units ID of this + * Returns {@code true} if the UnitDefinition which has the area units ID of this * Model as id is not <code>null</code>. * - * @return <code>true</code> if the UnitDefinition which has the area units ID of this + * @return {@code true} if the UnitDefinition which has the area units ID of this * Model as id is not <code>null</code>. */ public boolean isSetAreaUnitsInstance() { @@ -3441,19 +3454,19 @@ } /** - * Returns <code>true</code> if the conversionFactorID of this Model is not <code>null</code>. + * Returns {@code true} if the conversionFactorID of this Model is not <code>null</code>. * - * @return <code>true</code> if the conversionFactorID of this Model is not <code>null</code>. + * @return {@code true} if the conversionFactorID of this Model is not <code>null</code>. */ public boolean isSetConversionFactor() { return this.conversionFactorID != null; } /** - * Returns <code>true</code> if the Parameter which has the conversionFactorID of this + * Returns {@code true} if the Parameter which has the conversionFactorID of this * Model as id is not <code>null</code>. * - * @return <code>true</code> if the Parameter which has the conversionFactorID of this + * @return {@code true} if the Parameter which has the conversionFactorID of this * Model as id is not <code>null</code>. */ public boolean isSetConversionFactorInstance() { @@ -3461,19 +3474,19 @@ } /** - * Returns <code>true</code> if the extentUnitsID of this Model is not <code>null</code>. + * Returns {@code true} if the extentUnitsID of this Model is not <code>null</code>. * - * @return <code>true</code> if the extentUnitsID of this Model is not <code>null</code>. + * @return {@code true} if the extentUnitsID of this Model is not <code>null</code>. */ public boolean isSetExtentUnits() { return this.extentUnitsID != null; } /** - * Returns <code>true</code> if the UnitDefinition which has the extentUnitsID of this + * Returns {@code true} if the UnitDefinition which has the extentUnitsID of this * Model as id is not <code>null</code>. * - * @return <code>true</code> if the UnitDefinition which has the extentUnitsID of this + * @return {@code true} if the UnitDefinition which has the extentUnitsID of this * Model as id is not <code>null</code>. */ public boolean isSetExtentUnitsInstance() { @@ -3481,19 +3494,19 @@ } /** - * Returns <code>true</code> if the lengthUnitsID of this Model is not <code>null</code>. + * Returns {@code true} if the lengthUnitsID of this Model is not <code>null</code>. * - * @return <code>true</code> if the lengthUnitsID of this Model is not <code>null</code>. + * @return {@code true} if the lengthUnitsID of this Model is not <code>null</code>. */ public boolean isSetLengthUnits() { return this.lengthUnitsID != null; } /** - * Returns <code>true</code> if the UnitDefinition which has the lengthUnitsID of this + * Returns {@code true} if the UnitDefinition which has the lengthUnitsID of this * Model as id is not <code>null</code>. * - * @return <code>true</code> if the UnitDefinition which has the lengthUnitsID of this + * @return {@code true} if the UnitDefinition which has the lengthUnitsID of this * Model as id is not <code>null</code>. */ public boolean isSetLengthUnitsInstance() { @@ -3501,10 +3514,10 @@ } /** - * Returns <code>true</code> if the listOfCompartments of this Model is not <code>null</code> and not + * Returns {@code true} if the listOfCompartments of this Model is not <code>null</code> and not * empty. * - * @return <code>true</code> if the listOfCompartments of this Model is not <code>null</code> and not + * @return {@code true} if the listOfCompartments of this Model is not <code>null</code> and not * empty. */ public boolean isSetListOfCompartments() { @@ -3512,10 +3525,10 @@ } /** - * Returns <code>true</code> if the listOfCompartmentTypes of this Model is not <code>null</code> and + * Returns {@code true} if the listOfCompartmentTypes of this Model is not <code>null</code> and * not empty. * - * @return <code>true</code> if the listOfCompartmentTypes of this Model is not <code>null</code> and + * @return {@code true} if the listOfCompartmentTypes of this Model is not <code>null</code> and * not empty. * @deprecated Only valid in SBML Level 2 for Versions 2 through 4. */ @@ -3526,10 +3539,10 @@ } /** - * Returns <code>true</code> if the listOfConstraints of this Model is not <code>null</code> and not + * Returns {@code true} if the listOfConstraints of this Model is not <code>null</code> and not * empty. * - * @return <code>true</code> if the listOfConstraints of this Model is not <code>null</code> and not + * @return {@code true} if the listOfConstraints of this Model is not <code>null</code> and not * empty. */ public boolean isSetListOfConstraints() { @@ -3537,19 +3550,19 @@ } /** - * Returns <code>true</code> if the listOfEvents of this Model is not <code>null</code> and not empty. + * Returns {@code true} if the listOfEvents of this Model is not <code>null</code> and not empty. * - * @return <code>true</code> if the listOfEvents of this Model is not <code>null</code> and not empty. + * @return {@code true} if the listOfEvents of this Model is not <code>null</code> and not empty. */ public boolean isSetListOfEvents() { return (listOfEvents != null) && (listOfEvents.size() > 0); } /** - * Returns <code>true</code> if the listOfFunctionDefinitions of this Model is not <code>null</code> and + * Returns {@code true} if the listOfFunctionDefinitions of this Model is not <code>null</code> and * not empty. * - * @return <code>true</code> if the listOfFunctionDefinitions of this Model is not <code>null</code> and + * @return {@code true} if the listOfFunctionDefinitions of this Model is not <code>null</code> and * not empty. */ public boolean isSetListOfFunctionDefinitions() { @@ -3558,10 +3571,10 @@ } /** - * Returns <code>true</code> if the listOfInitialAssignments of this Model is not <code>null</code> and + * Returns {@code true} if the listOfInitialAssignments of this Model is not <code>null</code> and * not empty. * - * @return <code>true</code> if the listOfInitialAssignments of this Model is not <code>null</code> and + * @return {@code true} if the listOfInitialAssignments of this Model is not <code>null</code> and * not empty. */ public boolean isSetListOfInitialAssignments() { @@ -3570,10 +3583,10 @@ } /** - * Returns <code>true</code> if the listOfParameters of this Model is not <code>null</code> and not + * Returns {@code true} if the listOfParameters of this Model is not <code>null</code> and not * empty. * - * @return <code>true</code> if the listOfParameters of this Model is not <code>null</code> and not + * @return {@code true} if the listOfParameters of this Model is not <code>null</code> and not * empty. */ public boolean isSetListOfParameters() { @@ -3581,10 +3594,10 @@ } /** - * Returns <code>true</code> if the listOfReactions of this Model is not <code>null</code> and not + * Returns {@code true} if the listOfReactions of this Model is not <code>null</code> and not * empty. * - * @return <code>true</code> if the listOfReactions of this Model is not <code>null</code> and not + * @return {@code true} if the listOfReactions of this Model is not <code>null</code> and not * empty. */ public boolean isSetListOfReactions() { @@ -3592,28 +3605,28 @@ } /** - * Returns <code>true</code> if the listOfRules of this Model is not <code>null</code> and not empty. + * Returns {@code true} if the listOfRules of this Model is not <code>null</code> and not empty. * - * @return <code>true</code> if the listOfRules of this Model is not <code>null</code> and not empty. + * @return {@code true} if the listOfRules of this Model is not <code>null</code> and not empty. */ public boolean isSetListOfRules() { return (listOfRules != null) && (listOfRules.size() > 0); } /** - * Returns <code>true</code> if the listOfSpecies of this Model is not <code>null</code> and not empty. + * Returns {@code true} if the listOfSpecies of this Model is not <code>null</code> and not empty. * - * @return <code>true</code> if the listOfSpecies of this Model is not <code>null</code> and not empty. + * @return {@code true} if the listOfSpecies of this Model is not <code>null</code> and not empty. */ public boolean isSetListOfSpecies() { return (listOfSpecies != null) && (listOfSpecies.size() > 0); } /** - * Returns <code>true</code> if the listOfSpeciesTypes of this Model is not <code>null</code> and not + * Returns {@code true} if the listOfSpeciesTypes of this Model is not <code>null</code> and not * empty. * - * @return <code>true</code> if the listOfSpeciesTypes of this Model is not <code>null</code> and not + * @return {@code true} if the listOfSpeciesTypes of this Model is not <code>null</code> and not * empty. * @deprecated Only valid in SBML Level 2 for Versions 2 through 4. */ @@ -3623,10 +3636,10 @@ } /** - * Returns <code>true</code> if the listOfUnitDefinitions of this Model is not <code>null</code> and not + * Returns {@code true} if the listOfUnitDefinitions of this Model is not <code>null</code> and not * empty. * - * @return <code>true</code> if the listOfUnitDefinitions of this Model is not <code>null</code> and not + * @return {@code true} if the listOfUnitDefinitions of this Model is not <code>null</code> and not * empty. */ public boolean isSetListOfUnitDefinitions() { @@ -3647,19 +3660,19 @@ } /** - * Returns <code>true</code> if the substanceUnitsID of this Model is not <code>null</code>. + * Returns {@code true} if the substanceUnitsID of this Model is not <code>null</code>. * - * @return <code>true</code> if the substanceUnitsID of this Model is not <code>null</code>. + * @return {@code true} if the substanceUnitsID of this Model is not <code>null</code>. */ public boolean isSetSubstanceUnits() { return this.substanceUnitsID != null; } /** - * Returns <code>true</code> if the UnitDefinition which has the substanceUnitsID of this + * Returns {@code true} if the UnitDefinition which has the substanceUnitsID of this * Model as id is not <code>null</code>. * - * @return <code>true</code> if the UnitDefinition which has the substanceUnitsID of this + * @return {@code true} if the UnitDefinition which has the substanceUnitsID of this * Model as id is not <code>null</code>. */ public boolean isSetSubstanceUnitsInstance() { @@ -3667,19 +3680,19 @@ } /** - * Returns <code>true</code> if the timeUnitsID of this {@link Model} is not <code>null</code>. + * Returns {@code true} if the timeUnitsID of this {@link Model} is not <code>null</code>. * - * @return <code>true</code> if the timeUnitsID of this {@link Model} is not <code>null</code>. + * @return {@code true} if the timeUnitsID of this {@link Model} is not <code>null</code>. */ public boolean isSetTimeUnits() { return this.timeUnitsID != null; } /** - * Returns <code>true</code> if the UnitsDefinition which has the timeUnistID of this Model + * Returns {@code true} if the UnitsDefinition which has the timeUnistID of this Model * as id is not <code>null</code>. * - * @return <code>true</code> if the UnitsDefinition which has the timeUnistID of this Model + * @return {@code true} if the UnitsDefinition which has the timeUnistID of this Model * as id is not <code>null</code>. */ public boolean isSetTimeUnitsInstance() { @@ -3687,19 +3700,19 @@ } /** - * Returns <code>true</code> if the volumeUnitsID of this Model is not <code>null</code>. + * Returns {@code true} if the volumeUnitsID of this Model is not <code>null</code>. * - * @return <code>true</code> if the volumeUnitsID of this Model is not <code>null</code>. + * @return {@code true} if the volumeUnitsID of this Model is not <code>null</code>. */ public boolean isSetVolumeUnits() { return this.volumeUnitsID != null; } /** - * Returns <code>true</code> if the UnitDefinition which has the volumeUnitsID of this + * Returns {@code true} if the UnitDefinition which has the volumeUnitsID of this * Model as id is not <code>null</code>. * - * @return <code>true</code> if the UnitDefinition which has the volumeUnitsID of this + * @return {@code true} if the UnitDefinition which has the volumeUnitsID of this * Model as id is not <code>null</code>. */ public boolean isSetVolumeUnitsInstance() { @@ -3749,7 +3762,7 @@ * @param lp * the {@link LocalParameter} whose identifier is to be registered. * @param delete - * @return <code>true</code> in case of success, otherwise <code>false</code>. + * @return {@code true} in case of success, otherwise {@code false}. */ private boolean registerId(KineticLaw kl, LocalParameter lp, boolean delete, boolean alreadyRegisteredInKL) { if (!alreadyRegisteredInKL) { @@ -3802,11 +3815,11 @@ * @param nsb * the element, whose identifier is to be registered. * @param add - * If <code>true</code> the identifier of the given {@link NamedSBase} + * If {@code true} the identifier of the given {@link NamedSBase} * will be registered in this {@link Model} Otherwise, the given * identifier will be removed from this {@link Model}'s hash. - * @return <code>true</code> if this operation was successfully performed, - * <code>false</code> otherwise. + * @return {@code true} if this operation was successfully performed, + * {@code false} otherwise. */ boolean registerId(NamedSBase nsb, boolean add) { return registerIds(nsb.getParentSBMLObject(), nsb, true, !add); @@ -3911,8 +3924,8 @@ * @param newElem * @param recursively * @param delete - * @return <code>true</code> if this operation was successfully performed, - * <code>false</code> otherwise. + * @return {@code true} if this operation was successfully performed, + * {@code false} otherwise. */ boolean registerIds(SBase parent, SBase newElem, boolean recursively, boolean delete) { boolean success = true; @@ -4081,7 +4094,7 @@ * Removes the Parameter 'parameter' from this Model. * * @param parameter - * @return <code>true</code> if the {@link Parameter} was found and removed. + * @return {@code true} if the {@link Parameter} was found and removed. */ public boolean removeParameter(Parameter parameter) { return getListOfParameters().remove(parameter); @@ -4111,7 +4124,7 @@ * Removes a reaction from the model. * * @param reac - * @return <code>true</code> if the {@link Reaction} was found and removed. + * @return {@code true} if the {@link Reaction} was found and removed. */ public boolean removeReaction(Reaction reac) { return getListOfReactions().remove(reac); @@ -4163,7 +4176,7 @@ * Removes a species from the model. * * @param spec - * @return <code>true</code> if the {@link Species} was found and removed. + * @return {@code true} if the {@link Species} was found and removed. */ public boolean removeSpecies(Species spec) { return getListOfSpecies().remove(spec); @@ -4227,7 +4240,7 @@ * Removes a {@link UnitDefinition} of the {@link Model}. * * @param unitDefininition - * @return <code>true</code> if the UnitDefinition 'unitDefinition' has been removed from + * @return {@code true} if the UnitDefinition 'unitDefinition' has been removed from * the Model. */ public boolean removeUnitDefinition(UnitDefinition unitDefininition) { @@ -4707,7 +4720,7 @@ * Removes the {@link #listOfCompartments} from this {@link Model} and * notifies all registered instances of {@link TreeNodeChangeListener}. * - * @return <code>true</code> if calling this method lead to a change in this + * @return {@code true} if calling this method lead to a change in this * data structure. */ public boolean unsetListOfCompartments() { @@ -4724,7 +4737,7 @@ * Removes the {@link #listOfCompartmentTypes} from this {@link Model} and * notifies all registered instances of {@link TreeNodeChangeListener}. * - * @return <code>true</code> if calling this method lead to a change in this + * @return {@code true} if calling this method lead to a change in this * data structure. * @deprecated Only valid in SBML Level 2 for Versions 2 through 4. */ @@ -4743,7 +4756,7 @@ * Removes the {@link #listOfConstraints} from this {@link Model} and notifies * all registered instances of {@link TreeNodeChangeListener}. * - * @return <code>true</code> if calling this method lead to a change in this + * @return {@code true} if calling this method lead to a change in this * data structure. */ public boolean unsetListOfConstraints() { @@ -4760,7 +4773,7 @@ * Removes the {@link #listOfEvents} from this {@link Model} and notifies all * registered instances of {@link TreeNodeChangeListener}. * - * @return <code>true</code> if calling this method lead to a change in this + * @return {@code true} if calling this method lead to a change in this * data structure. */ public boolean unsetListOfEvents() { @@ -4777,7 +4790,7 @@ * Removes the {@link #listOfFunctionDefinitions} from this {@link Model} and * notifies all registered instances of {@link TreeNodeChangeListener}. * - * @return <code>true</code> if calling this method lead to a change in this + * @return {@code true} if calling this method lead to a change in this * data structure. */ public boolean unsetListOfFunctionDefinitions() { @@ -4794,7 +4807,7 @@ * Removes the {@link #listOfInitialAssignments} from this {@link Model} and * notifies all registered instances of {@link TreeNodeChangeListener}. * - * @return <code>true</code> if calling this method lead to a change in this + * @return {@code true} if calling this method lead to a change in this * data structure. */ public boolean unsetListOfInitialAssignments() { @@ -4811,7 +4824,7 @@ * Removes the {@link #listOfParameters} from this {@link Model} and notifies * all registered instances of {@link TreeNodeChangeListener}. * - * @return <code>true</code> if calling this method lead to a change in this + * @return {@code true} if calling this method lead to a change in this * data structure. */ public boolean unsetListOfParameters() { @@ -4828,7 +4841,7 @@ * Removes the {@link #listOfReactions} from this {@link Model} and notifies * all registered instances of {@link TreeNodeChangeListener}. * - * @return <code>true</code> if calling this method lead to a change in this + * @return {@code true} if calling this method lead to a change in this * data structure. */ public boolean unsetListOfReactions() { @@ -4845,7 +4858,7 @@ * Removes the {@link #listOfRules} from this {@link Model} and notifies all * registered instances of {@link TreeNodeChangeListener}. * - * @return <code>true</code> if calling this method lead to a change in this + * @return {@code true} if calling this method lead to a change in this * data structure. */ public boolean unsetListOfRules() { @@ -4862,7 +4875,7 @@ * Removes the {@link #listOfSpecies} from this {@link Model} and notifies all * registered instances of {@link TreeNodeChangeListener}. * - * @return <code>true</code> if calling this method lead to a change in this + * @return {@code true} if calling this method lead to a change in this * data structure. */ public boolean unsetListOfSpecies() { @@ -4879,7 +4892,7 @@ * Removes the {@link #listOfSpeciesTypes} from this {@link Model} and * notifies all registered instances of {@link TreeNodeChangeListener}. * - * @return <code>true</code> if calling this method lead to a change in this + * @return {@code true} if calling this method lead to a change in this * data structure. * @deprecated Only valid in SBML Level 2 for Versions 2 through 4. */ @@ -4898,7 +4911,7 @@ * Removes the {@link #listOfUnitDefinitions} from this {@link Model} and * notifies all registered instances of {@link TreeNodeChangeListener}. * - * @return <code>true</code> if calling this method lead to a change in this + * @return {@code true} if calling this method lead to a change in this * data structure. */ public boolean unsetListOfUnitDefinitions() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nik...@us...> - 2012-06-12 12:48:35
|
Revision: 1303 http://jsbml.svn.sourceforge.net/jsbml/?rev=1303&view=rev Author: niko-rodrigue Date: 2012-06-12 12:48:29 +0000 (Tue, 12 Jun 2012) Log Message: ----------- corrected potential NullPointerException in SBMLDocument + corrected several bugs in the generation of SubModel : the sbml element namespaces and attributes were not copied over to the submodel which could create some invalid XML, the events were never found and when the code was allowing to add several time the same event to the submodel Modified Paths: -------------- trunk/core/src/org/sbml/jsbml/SBMLDocument.java trunk/core/src/org/sbml/jsbml/util/SubModel.java Modified: trunk/core/src/org/sbml/jsbml/SBMLDocument.java =================================================================== --- trunk/core/src/org/sbml/jsbml/SBMLDocument.java 2012-06-12 09:40:18 UTC (rev 1302) +++ trunk/core/src/org/sbml/jsbml/SBMLDocument.java 2012-06-12 12:48:29 UTC (rev 1303) @@ -194,7 +194,7 @@ * @param URI */ public void addNamespace(String namespaceName, String prefix, String URI) { - if (!prefix.equals("")) { + if (prefix != null && prefix.trim().length() > 0) { this.SBMLDocumentNamespaces.put(prefix + ":" + namespaceName, URI); } else { @@ -738,9 +738,8 @@ } else if (attributeName.equals("version")) { setVersion(StringTools.parseSBMLInt(value)); } - if (!prefix.equals("")) { - getSBMLDocumentAttributes().put( - prefix + ":" + attributeName, value); + if (prefix != null && prefix.trim().length() > 0) { + getSBMLDocumentAttributes().put(prefix + ":" + attributeName, value); } else { getSBMLDocumentAttributes().put(attributeName, value); } Modified: trunk/core/src/org/sbml/jsbml/util/SubModel.java =================================================================== --- trunk/core/src/org/sbml/jsbml/util/SubModel.java 2012-06-12 09:40:18 UTC (rev 1302) +++ trunk/core/src/org/sbml/jsbml/util/SubModel.java 2012-06-12 12:48:29 UTC (rev 1303) @@ -171,7 +171,31 @@ // SBMLDocument object for submodel SBMLDocument subModelSbmlDocument = new SBMLDocument(modelLevel, modelVersion); - + SBMLDocument originalDocument = model.getSBMLDocument(); + + if (originalDocument != null) { + + // Copying namespaces + if (originalDocument.getSBMLDocumentNamespaces() != null && originalDocument.getSBMLDocumentNamespaces().size() > 0) + { + for (String prefix : originalDocument.getSBMLDocumentNamespaces().keySet()) { + String namespaceURI = originalDocument.getSBMLDocumentNamespaces().get(prefix); + + subModelSbmlDocument.addNamespace(prefix, null, namespaceURI); + } + } + + // Copying attributes + if (originalDocument.getSBMLDocumentAttributes() != null && originalDocument.getSBMLDocumentAttributes().size() > 0) + { + for (String attributeName : originalDocument.getSBMLDocumentAttributes().keySet()) { + String attributeValue = originalDocument.getSBMLDocumentAttributes().get(attributeName); + + subModelSbmlDocument.readAttribute(attributeName, null, attributeValue); + } + } + } + // creating submodel object Model subModel = subModelSbmlDocument.createModel(subModelId); subModel.setMetaId(subModelId); @@ -198,22 +222,6 @@ // not be present in the list of included elements !!! // - // annotations - // - - // TODO : set annotations - -// setAnnotations(subModel, -// null, -// null, -// new ArrayList(), -// DatetimeProcessor.instance.convertToGMT(current.getTime()), -// DatetimeProcessor.instance.convertToGMT(current.getTime()), -// null, -// Publication.UNPUBL); - - - // // Reactions. // @@ -288,6 +296,7 @@ subModel.addRule(modelRule.clone()); if (modelRule.getMath() != null) { getRelatedFunctionsId(relatedFunctionsIdSet, allFunctionsIdSet, modelRule.getMath()); + // TODO : analyze the math to add missing Species, ... } } } @@ -345,9 +354,6 @@ // // FunctionDefinition // - // TODO : if a function need an other function that in turn need an other function, the generated model will be invalid - // with the current code - for (String functionDefinitionId : relatedFunctionsIdSet) { FunctionDefinition func = model.getFunctionDefinition(functionDefinitionId); getRelatedFunctionsId(relatedFunctionsIdSet, allFunctionsIdSet, func.getMath()); @@ -631,7 +637,7 @@ } } - // TODO : check the math of rule to check if we need to add any more species or compartment + // TODO : check the math of rule to check if we need to add any more species, compartment or other // convert to array if ((selectedRules == null) || selectedRules.isEmpty()) { @@ -661,7 +667,7 @@ Model model, String[] eventsIds, String[] compartmentsIds, - String[] speciesIds) + String[] speciesIds) { Logger debugLogger = Logger.getLogger(SubModel.class); debugLogger.debug("getRelatedEvents "); @@ -685,25 +691,24 @@ for (EventAssignment eventAssigment : event.getListOfEventAssignments()) { - String variableId = null; eventAssigment.getVariable(); + String variableId = eventAssigment.getVariable(); for (String speciesId : speciesIds) { - if (speciesId.equals(variableId)) { + if (speciesId.equals(variableId) && !selectedEvents.contains(event.getMetaId())) { selectedEvents.add(event.getMetaId()); } } for (String compartmentId : compartmentsIds) { - if (compartmentId.equals(variableId)) { + if (compartmentId.equals(variableId) && !selectedEvents.contains(event.getMetaId())) { selectedEvents.add(event.getMetaId()); } } for (Parameter parameter : model.getListOfParameters()) { - if (parameter.getId().equals(variableId)) { + if (parameter.getId().equals(variableId) && !selectedEvents.contains(event.getMetaId())) { selectedEvents.add(event.getMetaId()); } } } - } // convert to array @@ -755,7 +760,7 @@ debugLogger.debug("getRelatedReactions : selected speciesIds : " + Arrays.toString(speciesIds) + "\n"); // get all related reactions - List<String> relatedReactsList = new ArrayList<String>(reactsIds.length); + List<String> relatedReactsList = new ArrayList<String>(); if ((reactsIds != null) || (speciesIds != null)) { @@ -847,6 +852,15 @@ */ private static void getRelatedFunctions(Set<String> relatedFunctionsSet, Set<String> allFunctionsIdSet, ASTNode mathNode) { + Logger debugLogger = Logger.getLogger(SubModel.class); + + debugLogger.debug("getRelatedFunctions "); + debugLogger.debug("getRelatedFunctions : math = " + mathNode); + + if (mathNode == null) { + return; + } + if ((mathNode.isName() || mathNode.isFunction()) && allFunctionsIdSet.contains(mathNode.getName().trim()) && !relatedFunctionsSet.contains(mathNode.getName().trim())) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2012-06-12 09:40:30
|
Revision: 1302 http://jsbml.svn.sourceforge.net/jsbml/?rev=1302&view=rev Author: thesentry Date: 2012-06-12 09:40:18 +0000 (Tue, 12 Jun 2012) Log Message: ----------- * first draft implementation of the render extension writer/parser * fixed some minor bugs * added render extension to PackageParserNamespaces.xml * added test class for the RenderParser (writing) Modified Paths: -------------- trunk/core/resources/org/sbml/jsbml/resources/cfg/PackageParserNamespaces.xml trunk/core/src/org/sbml/jsbml/ListOf.java trunk/core/src/org/sbml/jsbml/util/StringTools.java trunk/extensions/qual/src/org/sbml/jsbml/ext/qual/QualitativeModel.java trunk/extensions/render/src/org/sbml/jsbml/ext/render/AbstractRenderPlugin.java trunk/extensions/render/src/org/sbml/jsbml/ext/render/RenderLayoutPlugin.java trunk/extensions/render/src/org/sbml/jsbml/ext/render/RenderModelPlugin.java trunk/extensions/render/src/org/sbml/jsbml/xml/parsers/RenderParser.java Added Paths: ----------- trunk/extensions/render/test/org/ trunk/extensions/render/test/org/sbml/ trunk/extensions/render/test/org/sbml/jsbml/ trunk/extensions/render/test/org/sbml/jsbml/ext/ trunk/extensions/render/test/org/sbml/jsbml/ext/render/ trunk/extensions/render/test/org/sbml/jsbml/ext/render/RenderWriteTest.java Removed Paths: ------------- trunk/extensions/render/src/org/sbml/jsbml/ext/render/ExtendedRenderModel.java Modified: trunk/core/resources/org/sbml/jsbml/resources/cfg/PackageParserNamespaces.xml =================================================================== --- trunk/core/resources/org/sbml/jsbml/resources/cfg/PackageParserNamespaces.xml 2012-06-12 06:21:26 UTC (rev 1301) +++ trunk/core/resources/org/sbml/jsbml/resources/cfg/PackageParserNamespaces.xml 2012-06-12 09:40:18 UTC (rev 1302) @@ -42,6 +42,7 @@ <entry key="http://www.sbml.org/sbml/level3/version1/qual/version1">org.sbml.jsbml.xml.parsers.QualParser</entry> <entry key="http://www.sbml.org/sbml/level3/version1/layout/version1">org.sbml.jsbml.xml.parsers.L3LayoutParser</entry> <entry key="http://www.sbml.org/sbml/level3/version1/multi/version1">org.sbml.jsbml.xml.parsers.MultiParser</entry> + <entry key="http://www.sbml.org/sbml/level3/version1/render/version1">org.sbml.jsbml.xml.parsers.RenderParser</entry> <!-- Core parsers Modified: trunk/core/src/org/sbml/jsbml/ListOf.java =================================================================== --- trunk/core/src/org/sbml/jsbml/ListOf.java 2012-06-12 06:21:26 UTC (rev 1301) +++ trunk/core/src/org/sbml/jsbml/ListOf.java 2012-06-12 09:40:18 UTC (rev 1302) @@ -923,7 +923,9 @@ if (listType.equals(Type.other) && size() > 0) { String className = get(0).getClass().getSimpleName(); - return "listOf" + className + (className.endsWith("s") ? "" : "s"); + return "listOf" + className + + ((className.endsWith("s") || className.toLowerCase().endsWith( + "information")) ? "" : "s"); } return listType.toString(); Modified: trunk/core/src/org/sbml/jsbml/util/StringTools.java =================================================================== --- trunk/core/src/org/sbml/jsbml/util/StringTools.java 2012-06-12 06:21:26 UTC (rev 1301) +++ trunk/core/src/org/sbml/jsbml/util/StringTools.java 2012-06-12 09:40:18 UTC (rev 1302) @@ -410,7 +410,7 @@ * @return the {@link String} as an short. If the {@link String} is not a * valid short number, 0 is returned. */ - public static int parseSBMLShort(String value) { + public static short parseSBMLShort(String value) { short v = 0; try { v = Short.parseShort(value.trim()); Modified: trunk/extensions/qual/src/org/sbml/jsbml/ext/qual/QualitativeModel.java =================================================================== --- trunk/extensions/qual/src/org/sbml/jsbml/ext/qual/QualitativeModel.java 2012-06-12 06:21:26 UTC (rev 1301) +++ trunk/extensions/qual/src/org/sbml/jsbml/ext/qual/QualitativeModel.java 2012-06-12 09:40:18 UTC (rev 1302) @@ -62,7 +62,6 @@ super(model); } - /** * Adds a {@link QualitativeSpecies} to the model. * Modified: trunk/extensions/render/src/org/sbml/jsbml/ext/render/AbstractRenderPlugin.java =================================================================== --- trunk/extensions/render/src/org/sbml/jsbml/ext/render/AbstractRenderPlugin.java 2012-06-12 06:21:26 UTC (rev 1301) +++ trunk/extensions/render/src/org/sbml/jsbml/ext/render/AbstractRenderPlugin.java 2012-06-12 09:40:18 UTC (rev 1302) @@ -43,14 +43,15 @@ private Short versionMinor; private GlobalRenderInformation renderInformation; - /** - * Creates an AbstractRenderPlugin instance - */ - public AbstractRenderPlugin() { - super(); - initDefaults(); - } + /** + * Creates an AbstractRenderPlugin instance + */ + public AbstractRenderPlugin(SBase extendedElement) { + super(extendedElement); + initDefaults(); + } + /** * Creates a AbstractRenderPlugin instance with a level and version. * Deleted: trunk/extensions/render/src/org/sbml/jsbml/ext/render/ExtendedRenderModel.java =================================================================== --- trunk/extensions/render/src/org/sbml/jsbml/ext/render/ExtendedRenderModel.java 2012-06-12 06:21:26 UTC (rev 1301) +++ trunk/extensions/render/src/org/sbml/jsbml/ext/render/ExtendedRenderModel.java 2012-06-12 09:40:18 UTC (rev 1302) @@ -1,465 +0,0 @@ -/* - * $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-2012 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 - * - * 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.render; - -import java.text.MessageFormat; -import java.util.Map; - -import org.sbml.jsbml.ListOf; -import org.sbml.jsbml.SBase; -import org.sbml.jsbml.ext.AbstractSBasePlugin; -import org.sbml.jsbml.util.filters.NameFilter; - - -/** - * @author Eugen Netz - * @author Alexander Diamantikos - * @author Jakob Matthes - * @author Jan Rudolph - * @version $Rev$ - * @since 1.0 - * @date 14.05.2012 - */ -public class ExtendedRenderModel extends AbstractSBasePlugin { - /** - * - */ - private static final long serialVersionUID = -7046023464349980639L; - - private ListOf<LocalRenderInformation> listOfLocalRenderInformation; - private ListOf<GlobalRenderInformation> listOfGlobalRenderInformation; - private Integer versionMajor; - private Integer versionMinor; - - /** - * Creates an ExtendedRenderModel instance - */ - public ExtendedRenderModel() { - super(); - initDefaults(); - } - - /** - * Creates a ExtendedRenderModel instance with a level and version. - * - * @param level - * @param version - */ - public ExtendedRenderModel(int level, int version) { - this(null, null, level, version); - } - - /** - * Creates a ExtendedRenderModel instance with an id, level, and version. - * - * @param id - * @param level - * @param version - */ - public ExtendedRenderModel(String id, int level, int version) { - this(id, null, level, version); - } - - /** - * Creates a ExtendedRenderModel instance with an id, name, level, and version. - * - * @param id - * @param name - * @param level - * @param version - */ - public ExtendedRenderModel(String id, String name, int level, int version) { - super(); - /*if (getLevelAndVersion().compareTo(Integer.valueOf(MIN_SBML_LEVEL), - Integer.valueOf(MIN_SBML_VERSION)) < 0) { - throw new LevelVersionError(getElementName(), level, version); - } */ - initDefaults(); - } - - /** - * Clone constructor - */ - public ExtendedRenderModel(ExtendedRenderModel obj) { - super(); - versionMajor = obj.versionMajor; - versionMinor = obj.versionMinor; - listOfGlobalRenderInformation = obj.listOfGlobalRenderInformation; - listOfLocalRenderInformation = obj.listOfLocalRenderInformation; - } - - /** - * clones this class - */ - @Override - public ExtendedRenderModel clone() { - return new ExtendedRenderModel(this); - } - - /** - * Initializes the default values using the namespace. - */ - public void initDefaults() { - //addNamespace(RenderConstants.namespaceURI); - versionMajor = 0; - versionMinor = 0; - } - - /** - * @return the value of versionMinor - */ - public int getVersionMinor() { - return versionMinor; - } - /** - * @return whether versionMinor is set - */ - public boolean isSetVersionMinor() { - return true; - } - - /** - * Set the value of versionMinor - */ - public void setVersionMinor(int versionMinor) { -// int oldVersionMinor = this.versionMinor; - this.versionMinor = versionMinor; - // FIXME firePropertyChange(RenderConstants.versionMinor, oldVersionMinor, this.versionMinor); - } - - /** - * Unsets the variable versionMinor - * @return <code>true</code>, if versionMinor was set before, - * otherwise <code>false</code> - */ - public boolean unsetVersionMinor() { - if (isSetVersionMinor()) { -// int oldVersionMinor = this.versionMinor; - //FIXME firePropertyChange(RenderConstants.versionMinor, oldVersionMinor, this.versionMinor); - return true; - } - return false; - } - - - /** - * @return the value of versionMajor - */ - public int getVersionMajor() { - return versionMajor; - } - - /** - * @return whether versionMajor is set - */ - public boolean isSetVersionMajor() { - return true; - } - - /** - * Set the value of versionMajor - */ - public void setVersionMajor(int versionMajor) { -// int oldVersionMajor = this.versionMajor; - this.versionMajor = versionMajor; - //firePropertyChange(RenderConstants.versionMajor, oldVersionMajor, this.versionMajor); - } - - /** - * Unsets the variable versionMajor - * @return <code>true</code>, if versionMajor was set before, - * otherwise <code>false</code> - */ - public boolean unsetVersionMajor() { - if (isSetVersionMajor()) { -// int oldVersionMajor = this.versionMajor; - //firePropertyChange(RenderConstants.versionMajor, oldVersionMajor, this.versionMajor); - return true; - } - return false; - } - - - /** - * @return <code>true</code>, if listOfGlobalRenderInformation contains at least one element, - * otherwise <code>false</code> - */ - public boolean isSetListOfGlobalRenderInformation() { - if ((listOfGlobalRenderInformation == null) || listOfGlobalRenderInformation.isEmpty()) { - return false; - } - return true; - } - - /** - * @return the listOfGlobalRenderInformation - */ - public ListOf<GlobalRenderInformation> getListOfGlobalRenderInformation() { - if (!isSetListOfGlobalRenderInformation()) { - listOfGlobalRenderInformation = new ListOf<GlobalRenderInformation>(); - listOfGlobalRenderInformation.addNamespace(RenderConstants.namespaceURI); - listOfGlobalRenderInformation.setSBaseListType(ListOf.Type.other); - //FIXME registerChild(listOfGlobalRenderInformation); - } - return listOfGlobalRenderInformation; - } - - /** - * @param listOfGlobalRenderInformation - */ - public void setListOfGlobalRenderInformation(ListOf<GlobalRenderInformation> listOfGlobalRenderInformation) { - unsetListOfGlobalRenderInformation(); - this.listOfGlobalRenderInformation = listOfGlobalRenderInformation; - //FIXME registerChild(this.listOfGlobalRenderInformation); - } - - /** - * @return <code>true</code>, if listOfGlobalRenderInformation contained at least one element, - * otherwise <code>false</code> - */ - public boolean unsetListOfGlobalRenderInformation() { - if (isSetListOfGlobalRenderInformation()) { - ListOf<GlobalRenderInformation> oldGlobalRenderInformation = this.listOfGlobalRenderInformation; - this.listOfGlobalRenderInformation = null; - oldGlobalRenderInformation.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /** - * @param globalRenderInformation - */ - public boolean addGlobalRenderInformation(GlobalRenderInformation globalRenderInformation) { - return getListOfGlobalRenderInformation().add(globalRenderInformation); - } - - /** - * @param globalRenderInformation - */ - public boolean removeGlobalRenderInformation(GlobalRenderInformation globalRenderInformation) { - if (isSetListOfGlobalRenderInformation()) { - return getListOfGlobalRenderInformation().remove(globalRenderInformation); - } - return false; - } - - /** - * @param i - */ - public void removeGlobalRenderInformation(int i) { - if (!isSetListOfGlobalRenderInformation()) { - throw new IndexOutOfBoundsException(Integer.toString(i)); - } - getListOfGlobalRenderInformation().remove(i); - } - - /** - * - * @param id - */ - public void removeGlobalRenderInformation(String id) { - getListOfGlobalRenderInformation().removeFirst(new NameFilter(id)); - } - - /** - * create a new GlobalRenderInformation element and adds it to the ListOfGlobalRenderInformation list - * <p><b>NOTE:</b> - * only use this method, if ID is not mandatory in GlobalRenderInformation - * otherwise use @see createGlobalRenderInformation(String id)!</p> - */ - public GlobalRenderInformation createGlobalRenderInformation() { - return createGlobalRenderInformation(null); - } - - /** - * create a new GlobalRenderInformation element and adds it to the ListOfGlobalRenderInformation list - */ - public GlobalRenderInformation createGlobalRenderInformation(String id) { - GlobalRenderInformation globalRenderInformation = new GlobalRenderInformation(id); - addGlobalRenderInformation(globalRenderInformation); - return globalRenderInformation; - } - - /** - * @return <code>true</code>, if listOfLocalRenderInformation contains at least one element, - * otherwise <code>false</code> - */ - public boolean isSetListOfLocalRenderInformation() { - if ((listOfLocalRenderInformation == null) || listOfLocalRenderInformation.isEmpty()) { - return false; - } - return true; - } - - /** - * @return the listOfLocalRenderInformation - */ - public ListOf<LocalRenderInformation> getListOfLocalRenderInformation() { - if (!isSetListOfLocalRenderInformation()) { - listOfLocalRenderInformation = new ListOf<LocalRenderInformation>(); - listOfLocalRenderInformation.addNamespace(RenderConstants.namespaceURI); - listOfLocalRenderInformation.setSBaseListType(ListOf.Type.other); - //FIXME registerChild(listOfLocalRenderInformation); - } - return listOfLocalRenderInformation; - } - - /** - * @param listOfLocalRenderInformation - */ - public void setListOfLocalRenderInformation(ListOf<LocalRenderInformation> listOfLocalRenderInformation) { - unsetListOfLocalRenderInformation(); - this.listOfLocalRenderInformation = listOfLocalRenderInformation; - // FIXME registerChild(this.listOfLocalRenderInformation); - } - - /** - * @return <code>true</code>, if listOfLocalRenderInformation contained at least one element, - * otherwise <code>false</code> - */ - public boolean unsetListOfLocalRenderInformation() { - if (isSetListOfLocalRenderInformation()) { - ListOf<LocalRenderInformation> oldLocalRenderInformation = this.listOfLocalRenderInformation; - this.listOfLocalRenderInformation = null; - oldLocalRenderInformation.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /** - * @param localRenderInformation - */ - public boolean addLocalRenderInformation(LocalRenderInformation localRenderInformation) { - return getListOfLocalRenderInformation().add(localRenderInformation); - } - - /** - * @param localRenderInformation - */ - public boolean removeLocalRenderInformation(LocalRenderInformation localRenderInformation) { - if (isSetListOfLocalRenderInformation()) { - return getListOfLocalRenderInformation().remove(localRenderInformation); - } - return false; - } - - /** - * @param i - */ - public void removeLocalRenderInformation(int i) { - if (!isSetListOfLocalRenderInformation()) { - throw new IndexOutOfBoundsException(Integer.toString(i)); - } - getListOfLocalRenderInformation().remove(i); - } - - /** - * create a new LocalRenderInformation element and adds it to the ListOfLocalRenderInformation list - * <p><b>NOTE:</b> - * only use this method, if ID is not mandatory in LocalRenderInformation - * otherwise use @see createLocalRenderInformation(String id)!</p> - */ - public LocalRenderInformation createLocalRenderInformation() { - return createLocalRenderInformation(null); - } - - /** - * create a new LocalRenderInformation element and adds it to the ListOfLocalRenderInformation list - */ - public LocalRenderInformation createLocalRenderInformation(String id) { - LocalRenderInformation localRenderInformation = new LocalRenderInformation(id); - addLocalRenderInformation(localRenderInformation); - return localRenderInformation; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.SBasePlugin#getAllowsChildren() - */ - //@Override - public boolean getAllowsChildren() { - return true; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.SBasePlugin#getChildCount() - */ - //@Override - public int getChildCount() { - int count = 0; - - if (isSetListOfGlobalRenderInformation()) { - count++; - } - if (isSetListOfLocalRenderInformation()) { - count++; - } - - return count; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.SBasePlugin#getChildAt(int) - */ - //@Override - public SBase getChildAt(int childIndex) { - if (childIndex < 0) { - throw new IndexOutOfBoundsException(childIndex + " < 0"); - } - - int pos = 0; - if (isSetListOfGlobalRenderInformation()) { - if (pos == childIndex) { - return getListOfLocalRenderInformation(); - } - pos++; - } - if (isSetListOfLocalRenderInformation()) { - if (pos == childIndex) { - return getListOfLocalRenderInformation(); - } - pos++; - } - - throw new IndexOutOfBoundsException(MessageFormat.format( - "Index {0,number,integer} >= {1,number,integer}", childIndex, - +Math.min(pos, 0))); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.SBasePlugin#readAttribute(java.lang.String, java.lang.String, java.lang.String) - */ - //@Override - public boolean readAttribute(String attributeName, String prefix, - String value) { - return false; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.SBasePlugin#writeXMLAttributes() - */ - //@Override - public Map<String, String> writeXMLAttributes() { - return null; - } - -} Modified: trunk/extensions/render/src/org/sbml/jsbml/ext/render/RenderLayoutPlugin.java =================================================================== --- trunk/extensions/render/src/org/sbml/jsbml/ext/render/RenderLayoutPlugin.java 2012-06-12 06:21:26 UTC (rev 1301) +++ trunk/extensions/render/src/org/sbml/jsbml/ext/render/RenderLayoutPlugin.java 2012-06-12 09:40:18 UTC (rev 1302) @@ -45,7 +45,7 @@ * Creates an RenderLayoutPlugin instance */ public RenderLayoutPlugin(Layout layout) { - super(); + super(layout); initDefaults(); } Modified: trunk/extensions/render/src/org/sbml/jsbml/ext/render/RenderModelPlugin.java =================================================================== --- trunk/extensions/render/src/org/sbml/jsbml/ext/render/RenderModelPlugin.java 2012-06-12 06:21:26 UTC (rev 1301) +++ trunk/extensions/render/src/org/sbml/jsbml/ext/render/RenderModelPlugin.java 2012-06-12 09:40:18 UTC (rev 1302) @@ -50,7 +50,7 @@ * Creates an RenderModelPlugin instance */ public RenderModelPlugin(ListOf<Layout> listOfLayouts) { - super(); + super(listOfLayouts); initDefaults(); } Modified: trunk/extensions/render/src/org/sbml/jsbml/xml/parsers/RenderParser.java =================================================================== --- trunk/extensions/render/src/org/sbml/jsbml/xml/parsers/RenderParser.java 2012-06-12 06:21:26 UTC (rev 1301) +++ trunk/extensions/render/src/org/sbml/jsbml/xml/parsers/RenderParser.java 2012-06-12 09:40:18 UTC (rev 1302) @@ -20,9 +20,25 @@ */ package org.sbml.jsbml.xml.parsers; +import java.util.ArrayList; +import java.util.Enumeration; import java.util.List; +import javax.swing.tree.TreeNode; + +import org.apache.log4j.Logger; +import org.sbml.jsbml.ListOf; +import org.sbml.jsbml.ListOf.Type; +import org.sbml.jsbml.Model; import org.sbml.jsbml.SBMLDocument; +import org.sbml.jsbml.ext.SBasePlugin; +import org.sbml.jsbml.ext.layout.Layout; +import org.sbml.jsbml.ext.qual.FunctionTerm; +import org.sbml.jsbml.ext.qual.QualConstant; +import org.sbml.jsbml.ext.qual.QualitativeModel; +import org.sbml.jsbml.ext.render.RenderConstants; +import org.sbml.jsbml.ext.render.RenderLayoutPlugin; +import org.sbml.jsbml.ext.render.RenderModelPlugin; import org.sbml.jsbml.xml.stax.SBMLObjectForXML; @@ -35,104 +51,108 @@ * @since 1.0 * @date 04.06.2012 */ -public class RenderParser implements ReadingParser, WritingParser { - - /* (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.WritingParser#getListOfSBMLElementsToWrite(java.lang.Object) +public class RenderParser extends AbstractReaderWriter { + + /** + * The logger for this RenderParser */ - public List<Object> getListOfSBMLElementsToWrite(Object objectToWrite) { - // TODO Auto-generated method stub - return null; - } + private Logger logger = Logger.getLogger(RenderParser.class); - /* (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.WritingParser#writeAttributes(org.sbml.jsbml.xml.stax.SBMLObjectForXML, java.lang.Object) + * @see org.sbml.jsbml.xml.parsers.AbstractReaderWriter#getListOfSBMLElementsToWrite(java.lang.Object) */ - public void writeAttributes(SBMLObjectForXML xmlObject, - Object sbmlElementToWrite) { - // TODO Auto-generated method stub - } + @Override + public ArrayList<Object> getListOfSBMLElementsToWrite(Object sbase) { + if (logger.isDebugEnabled()) { + logger.debug("getListOfSBMLElementsToWrite : " + sbase.getClass().getCanonicalName()); + } + + ArrayList<Object> listOfElementsToWrite = new ArrayList<Object>(); - /* (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.WritingParser#writeCharacters(org.sbml.jsbml.xml.stax.SBMLObjectForXML, java.lang.Object) - */ - public void writeCharacters(SBMLObjectForXML xmlObject, - Object sbmlElementToWrite) { - // TODO Auto-generated method stub - } + if (sbase instanceof SBMLDocument) { + // nothing to do + // TODO : the 'required' attribute is written even if there is no plugin class for the SBMLDocument, so I am not totally sure how this is done. + } + else if (sbase instanceof ListOf<?>) { + // if the sbase is a ListOf, we could have a RenderModelPlugin attached to it + ListOf<?> listOf = (ListOf<?>)sbase; + if (listOf.getSBaseListType() == Type.other) { + + SBasePlugin plugin = listOf.getExtension(RenderConstants.namespaceURI); + + if (plugin != null) { + RenderModelPlugin rmp = (RenderModelPlugin) plugin; + // then add its extension children to the list of elements to write + Enumeration<TreeNode> children = rmp.children(); + while (children.hasMoreElements()) { + listOfElementsToWrite.add(children.nextElement()); + } + } + } + } + else if (sbase instanceof Layout) { + // if the sbase is a Layout get its extension + RenderLayoutPlugin rlp = (RenderLayoutPlugin)((Layout)sbase).getExtension(RenderConstants.namespaceURI); + + // then add its extension children to the list of elements to write + Enumeration<TreeNode> children = rlp.children(); + while (children.hasMoreElements()) { + listOfElementsToWrite.add(children.nextElement()); + } + } + else if (sbase instanceof TreeNode) { + Enumeration<TreeNode> children = ((TreeNode) sbase).children(); + + while (children.hasMoreElements()) { + listOfElementsToWrite.add(children.nextElement()); + } + } + + if (listOfElementsToWrite.isEmpty()) { + listOfElementsToWrite = null; + } else if (logger.isDebugEnabled()) { + logger.debug("getListOfSBMLElementsToWrite size = " + listOfElementsToWrite.size()); + } - /* (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.WritingParser#writeElement(org.sbml.jsbml.xml.stax.SBMLObjectForXML, java.lang.Object) - */ - public void writeElement(SBMLObjectForXML xmlObject, Object sbmlElementToWrite) { - // TODO Auto-generated method stub + return listOfElementsToWrite; } - /* (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.WritingParser#writeNamespaces(org.sbml.jsbml.xml.stax.SBMLObjectForXML, java.lang.Object) + * @see org.sbml.jsbml.xml.parsers.AbstractReaderWriter#processStartElement(java.lang.String, java.lang.String, boolean, boolean, java.lang.Object) */ - public void writeNamespaces(SBMLObjectForXML xmlObject, - Object sbmlElementToWrite) { + @Override + public Object processStartElement(String elementName, String prefix, + boolean hasAttributes, boolean hasNamespaces, Object contextObject) { // TODO Auto-generated method stub + return null; } - /* (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.ReadingParser#processAttribute(java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean, java.lang.Object) + * @see org.sbml.jsbml.xml.parsers.AbstractReaderWriter#processEndElement(java.lang.String, java.lang.String, boolean, java.lang.Object) */ - public void processAttribute(String elementName, String attributeName, - String value, String prefix, boolean isLastAttribute, Object contextObject) { - // TODO Auto-generated method stub - } - - - /* (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.ReadingParser#processCharactersOf(java.lang.String, java.lang.String, java.lang.Object) - */ - public void processCharactersOf(String elementName, String characters, - Object contextObject) { - // TODO Auto-generated method stub - } - - - /* (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.ReadingParser#processEndDocument(org.sbml.jsbml.SBMLDocument) - */ - public void processEndDocument(SBMLDocument sbmlDocument) { - // TODO Auto-generated method stub - } - - - /* (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.ReadingParser#processEndElement(java.lang.String, java.lang.String, boolean, java.lang.Object) - */ + @Override public boolean processEndElement(String elementName, String prefix, boolean isNested, Object contextObject) { // TODO Auto-generated method stub - return false; + return super.processEndElement(elementName, prefix, isNested, contextObject); } - - + /* (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.ReadingParser#processNamespace(java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean, boolean, java.lang.Object) + * @see org.sbml.jsbml.xml.parsers.AbstractReaderWriter#getShortLabel() */ - public void processNamespace(String elementName, String URI, String prefix, - String localName, boolean hasAttributes, boolean isLastNamespace, - Object contextObject) { - // TODO Auto-generated method stub + @Override + public String getShortLabel() { + return RenderConstants.shortLabel; } - /* (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.ReadingParser#processStartElement(java.lang.String, java.lang.String, boolean, boolean, java.lang.Object) + * @see org.sbml.jsbml.xml.parsers.AbstractReaderWriter#getNamespaceURI() */ - public Object processStartElement(String elementName, String prefix, - boolean hasAttributes, boolean hasNamespaces, Object contextObject) { - // TODO Auto-generated method stub - return null; + @Override + public String getNamespaceURI() { + return RenderConstants.namespaceURI; } + } Added: trunk/extensions/render/test/org/sbml/jsbml/ext/render/RenderWriteTest.java =================================================================== --- trunk/extensions/render/test/org/sbml/jsbml/ext/render/RenderWriteTest.java (rev 0) +++ trunk/extensions/render/test/org/sbml/jsbml/ext/render/RenderWriteTest.java 2012-06-12 09:40:18 UTC (rev 1302) @@ -0,0 +1,61 @@ +/* + * $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-2011 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 + * + * 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.render; + +import javax.xml.stream.XMLStreamException; + +import org.sbml.jsbml.Model; +import org.sbml.jsbml.SBMLDocument; +import org.sbml.jsbml.SBMLException; +import org.sbml.jsbml.SBMLWriter; +import org.sbml.jsbml.ext.layout.ExtendedLayoutModel; +import org.sbml.jsbml.ext.layout.Layout; +import org.sbml.jsbml.ext.layout.LayoutConstants; + + +/** + * @author Florian Mittag + * @author Andreas Dräger + * @version $Rev$ + * @since 0.8 + * @date 12.06.2012 + */ +public class RenderWriteTest { + + /** + * @param args + * @throws XMLStreamException + * @throws SBMLException + */ + public static void main(String[] args) throws SBMLException, XMLStreamException { + SBMLDocument doc = new SBMLDocument(3, 1); + Model m = doc.createModel("m1"); + ExtendedLayoutModel elm = new ExtendedLayoutModel(m); + m.addExtension(LayoutConstants.getNamespaceURI(m.getLevel(), m.getVersion()), elm); + Layout l1 = elm.createLayout("l1"); + + RenderLayoutPlugin rlp = new RenderLayoutPlugin(l1); + rlp.createLocalRenderInformation("info1"); + l1.addExtension(RenderConstants.namespaceURI, rlp); + + SBMLWriter.write(doc, System.out, ' ', (short) 2); + } +} Property changes on: trunk/extensions/render/test/org/sbml/jsbml/ext/render/RenderWriteTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Rev Id URL date tags This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2012-06-12 06:21:38
|
Revision: 1301 http://jsbml.svn.sourceforge.net/jsbml/?rev=1301&view=rev Author: andreas-draeger Date: 2012-06-12 06:21:26 +0000 (Tue, 12 Jun 2012) Log Message: ----------- Added several convenient methods and avoided null pointer exceptions when dealing with user objects. Modified Paths: -------------- trunk/core/src/org/sbml/jsbml/AbstractTreeNode.java trunk/core/src/org/sbml/jsbml/SBO.java trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/CompartmentGlyph.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/extensions/layout/src/org/sbml/jsbml/ext/layout/TextGlyph.java Modified: trunk/core/src/org/sbml/jsbml/AbstractTreeNode.java =================================================================== --- trunk/core/src/org/sbml/jsbml/AbstractTreeNode.java 2012-06-11 19:29:10 UTC (rev 1300) +++ trunk/core/src/org/sbml/jsbml/AbstractTreeNode.java 2012-06-12 06:21:26 UTC (rev 1301) @@ -61,6 +61,7 @@ * @return the index of the child in the parent's list of children or -1 if no * such child can be found. */ + @SuppressWarnings("unchecked") public static int indexOf(TreeNode parent, TreeNode child) { if (child == null) { throw new IllegalArgumentException("Argument is null."); @@ -249,7 +250,7 @@ */ //@Override public boolean containsUserObjectKey(Object key) { - return userObjects.containsKey(key); + return isSetUserObjects() ? userObjects.containsKey(key) : false; } /* (non-Javadoc) Modified: trunk/core/src/org/sbml/jsbml/SBO.java =================================================================== --- trunk/core/src/org/sbml/jsbml/SBO.java 2012-06-11 19:29:10 UTC (rev 1300) +++ trunk/core/src/org/sbml/jsbml/SBO.java 2012-06-12 06:21:26 UTC (rev 1301) @@ -700,6 +700,15 @@ return 534; } + /** + * Physical compartment. + * + * @return + */ + public static int getCompartment() { + return 290; + } + /** * * @return Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/CompartmentGlyph.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/CompartmentGlyph.java 2012-06-11 19:29:10 UTC (rev 1300) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/CompartmentGlyph.java 2012-06-12 06:21:26 UTC (rev 1301) @@ -94,14 +94,6 @@ public String getCompartment() { return getNamedSBase(); } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.layout.NamedSBaseGlyph#getNamedSBaseInstance() - */ - @Override - public Compartment getNamedSBaseInstance() { - return (Compartment) super.getNamedSBaseInstance(); - } /** * @return Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Layout.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Layout.java 2012-06-11 19:29:10 UTC (rev 1300) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Layout.java 2012-06-12 06:21:26 UTC (rev 1301) @@ -479,6 +479,14 @@ return null; } + /** + * + * @return + */ + public int getAdditionalGraphicalObjectCount() { + return isSetListOfAdditionalGraphicalObjects() ? listOfAdditionalGraphicalObjects.size() : 0; + } + /* (non-Javadoc) * @see org.sbml.jsbml.AbstractSBase#getChildAt(int) */ @@ -531,7 +539,7 @@ throw new IndexOutOfBoundsException(String.format("Index %d >= %d", index, +((int) Math.min(pos, 0)))); } - + /* (non-Javadoc) * @see org.sbml.jsbml.AbstractSBase#getChildCount() */ @@ -558,7 +566,7 @@ } return count; } - + /** * * @param i @@ -567,7 +575,7 @@ public CompartmentGlyph getCompartmentGlyph(int i) { return getListOfCompartmentGlyphs().get(i); } - + /** * * @param id @@ -584,10 +592,19 @@ * * @return */ + public int getCompartmentGlyphCount() { + return isSetListOfCompartmentGlyphs() ? listOfCompartmentGlyphs.size() : 0; + } + + /** + * + * @return + */ public Dimensions getDimensions() { return dimensions; } - + + /** * * @return @@ -599,7 +616,7 @@ } return listOfAdditionalGraphicalObjects; } - + /** * * @return @@ -611,7 +628,6 @@ } return listOfCompartmentGlyphs; } - /** * @@ -624,7 +640,7 @@ } return listOfReactionGlyphs; } - + /** * * @return @@ -669,16 +685,24 @@ } return null; } - + /** * + * @return + */ + public int getReactionGlyphCount() { + return isSetListOfReactionGlyphs() ? listOfReactionGlyphs.size() : 0; + } + + /** + * * @param i * @return */ public SpeciesGlyph getSpeciesGlyph(int i) { return getListOfSpeciesGlyphs().get(i); } - + /** * * @param id @@ -690,16 +714,24 @@ } return null; } - + /** * + * @return + */ + public int getSpeciesGlyphCount() { + return isSetListOfSpeciesGlyphs() ? listOfSpeciesGlyphs.size() : 0; + } + + /** + * * @param i * @return */ public TextGlyph getTextGlyph(int i) { return getListOfTextGlyphs().get(i); } - + /** * * @param id @@ -711,14 +743,22 @@ } return null; } - + /** * + * @return */ + public int getTextGlyphCount() { + return isSetListOfTextGlyphs() ? listOfTextGlyphs.size() : 0; + } + + /** + * + */ private void initDefault() { addNamespace(LayoutConstants.namespaceURI); } - + /* (non-Javadoc) * @see org.sbml.jsbml.NamedSBase#isIdMandatory() */ @@ -726,21 +766,21 @@ // See "Including Layout Information in SBML Files" Version 2.2, p. 6 return true; } - + /** * @return */ public boolean isSetAddGraphicalObjects() { return (listOfAdditionalGraphicalObjects != null) && (listOfAdditionalGraphicalObjects.size() > 0); } - + /** * @return */ public boolean isSetDimensions() { return dimensions != null; } - + /** * @return */ @@ -769,14 +809,14 @@ public boolean isSetListOfSpeciesGlyphs() { return (listOfSpeciesGlyphs != null) && (listOfSpeciesGlyphs.size() > 0); } - + /** * @return */ public boolean isSetListOfTextGlyphs() { return (listOfTextGlyphs != null) && (listOfTextGlyphs.size() > 0); } - + /** * @param attributeName * @param prefix @@ -814,7 +854,7 @@ this.dimensions = dimensions; registerChild(this.dimensions); } - + /** * * @param AdditionalGraphicalObjects @@ -827,7 +867,7 @@ registerChild(this.listOfAdditionalGraphicalObjects); } } - + /** * * @param compartmentGlyphs @@ -840,7 +880,7 @@ } registerChild(this.listOfCompartmentGlyphs); } - + /** * * @param reactionGlyphs @@ -853,7 +893,7 @@ registerChild(this.listOfReactionGlyphs); } } - + /** * * @param speciesGlyphs @@ -870,7 +910,7 @@ registerChild(this.listOfSpeciesGlyphs); } } - + /** * * @param textGlyphs @@ -883,7 +923,7 @@ registerChild(this.listOfTextGlyphs); } } - + /* (non-Javadoc) * @see org.sbml.jsbml.AbstractNamedSBase#toString() */ @@ -891,7 +931,7 @@ public String toString() { return getElementName(); } - + /** * Removes the {@link #listOfAdditionalGraphicalObjects} from this {@link Model} and notifies * all registered instances of {@link TreeNodeChangeListener}. @@ -925,7 +965,7 @@ } return false; } - + /** * Removes the {@link #listOfReactionGlyphs} from this {@link Model} and notifies * all registered instances of {@link TreeNodeChangeListener}. @@ -959,7 +999,7 @@ } return false; } - + /** * Removes the {@link #listOfTextGlyphs} from this {@link Model} and notifies * all registered instances of {@link TreeNodeChangeListener}. Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/ReactionGlyph.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/ReactionGlyph.java 2012-06-11 19:29:10 UTC (rev 1300) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/ReactionGlyph.java 2012-06-12 06:21:26 UTC (rev 1301) @@ -205,14 +205,6 @@ return listOfSpeciesReferencesGlyph; } - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.layout.NamedSBaseGlyph#getNamedSBaseInstance() - */ - @Override - public Reaction getNamedSBaseInstance() { - return (Reaction) super.getNamedSBaseInstance(); - } - /** * * @return @@ -331,7 +323,7 @@ Map<String, String> attributes = super.writeXMLAttributes(); if (isSetReaction()) { - attributes.put(LayoutConstants.shortLabel + ":" + attributes.put(LayoutConstants.shortLabel + ':' + LayoutConstants.reaction, getReaction()); } Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesGlyph.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesGlyph.java 2012-06-11 19:29:10 UTC (rev 1300) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesGlyph.java 2012-06-12 06:21:26 UTC (rev 1301) @@ -87,14 +87,6 @@ public SpeciesGlyph clone() { return new SpeciesGlyph(this); } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.layout.NamedSBaseGlyph#getNamedSBaseInstance() - */ - @Override - public Species getNamedSBaseInstance() { - return (Species) super.getNamedSBaseInstance(); - } /** * Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesReferenceGlyph.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesReferenceGlyph.java 2012-06-11 19:29:10 UTC (rev 1300) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesReferenceGlyph.java 2012-06-12 06:21:26 UTC (rev 1301) @@ -179,14 +179,6 @@ return curve; } - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.layout.NamedSBaseGlyph#getNamedSBaseInstance() - */ - @Override - public SimpleSpeciesReference getNamedSBaseInstance() { - return (SimpleSpeciesReference) super.getNamedSBaseInstance(); - } - /** * * @return @@ -356,15 +348,15 @@ Map<String, String> attributes = super.writeXMLAttributes(); if (isSetSpeciesGlyph()) { - attributes.put(LayoutConstants.shortLabel + ":" + attributes.put(LayoutConstants.shortLabel + ':' + LayoutConstants.speciesGlyph, speciesGlyph); } if (isSetSpeciesReference()) { - attributes.put(LayoutConstants.shortLabel + ":" + attributes.put(LayoutConstants.shortLabel + ':' + LayoutConstants.speciesReference, getSpeciesReference()); } if (isSetSpeciesReferenceRole()) { - attributes.put(LayoutConstants.shortLabel + ":" + attributes.put(LayoutConstants.shortLabel + ':' + LayoutConstants.role, role.toString().toLowerCase()); } Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/TextGlyph.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/TextGlyph.java 2012-06-11 19:29:10 UTC (rev 1300) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/TextGlyph.java 2012-06-12 06:21:26 UTC (rev 1301) @@ -285,15 +285,15 @@ Map<String, String> attributes = super.writeXMLAttributes(); if (isSetGraphicalObject()) { - attributes.put(LayoutConstants.shortLabel + ":" + attributes.put(LayoutConstants.shortLabel + ':' + LayoutConstants.graphicalObject, graphicalObject); } if (isSetText()) { - attributes.put(LayoutConstants.shortLabel + ":" + attributes.put(LayoutConstants.shortLabel + ':' + LayoutConstants.text, text); } if (isSetOriginOfText()) { - attributes.put(LayoutConstants.shortLabel + ":" + attributes.put(LayoutConstants.shortLabel + ':' + LayoutConstants.originOfText, getOriginOfText()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dia...@us...> - 2012-06-11 19:29:17
|
Revision: 1300 http://jsbml.svn.sourceforge.net/jsbml/?rev=1300&view=rev Author: diamantikos Date: 2012-06-11 19:29:10 +0000 (Mon, 11 Jun 2012) Log Message: ----------- Added XML Read/Write Modified Paths: -------------- trunk/extensions/render/src/org/sbml/jsbml/ext/render/Curve.java trunk/extensions/render/src/org/sbml/jsbml/ext/render/Ellipse.java trunk/extensions/render/src/org/sbml/jsbml/ext/render/GradientBase.java trunk/extensions/render/src/org/sbml/jsbml/ext/render/GradientStop.java trunk/extensions/render/src/org/sbml/jsbml/ext/render/GraphicalPrimitive1D.java trunk/extensions/render/src/org/sbml/jsbml/ext/render/GraphicalPrimitive2D.java trunk/extensions/render/src/org/sbml/jsbml/ext/render/Group.java trunk/extensions/render/src/org/sbml/jsbml/ext/render/Rectangle.java trunk/extensions/render/src/org/sbml/jsbml/ext/render/RenderInformationBase.java trunk/extensions/render/src/org/sbml/jsbml/ext/render/Transformation.java trunk/extensions/render/src/org/sbml/jsbml/ext/render/Transformation2D.java trunk/extensions/render/src/org/sbml/jsbml/ext/render/XMLTools.java Added Paths: ----------- trunk/extensions/render/src/org/sbml/jsbml/ext/render/ColorDefinition.java Removed Paths: ------------- trunk/extensions/render/src/org/sbml/jsbml/ext/render/ColorDefinition.java Deleted: trunk/extensions/render/src/org/sbml/jsbml/ext/render/ColorDefinition.java =================================================================== --- trunk/extensions/render/src/org/sbml/jsbml/ext/render/ColorDefinition.java 2012-06-11 12:47:53 UTC (rev 1299) +++ trunk/extensions/render/src/org/sbml/jsbml/ext/render/ColorDefinition.java 2012-06-11 19:29:10 UTC (rev 1300) @@ -1,252 +0,0 @@ -/* - * $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-2012 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 - * - * 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.render; - -import java.awt.Color; -import java.util.Map; - -import org.sbml.jsbml.AbstractNamedSBase; -import org.sbml.jsbml.LevelVersionError; -import org.sbml.jsbml.PropertyUndefinedError; -import org.sbml.jsbml.SBase; - - -/** - * @author Eugen Netz - * @author Alexander Diamantikos - * @author Jakob Matthes - * @author Jan Rudolph - * @version $Rev$ - * @since 1.0 - * @date 08.05.2012 - */ -public class ColorDefinition extends AbstractNamedSBase { - - /** - * - */ - private static final long serialVersionUID = 8904459123022343452L; - - private Color value; - - /** - * Creates an ColorDefinition instance - */ - public ColorDefinition() { - super(); - initDefaults(); - } - - - /** - * Creates a ColorDefinition instance with an id. - * - * @param id - */ - public ColorDefinition(String id) { - super(id); - initDefaults(); - } - - - /** - * Creates a ColorDefinition instance with a level and version. - * - * @param level - * @param version - */ - public ColorDefinition(int level, int version) { - this(null, null, level, version); - } - - - /** - * Creates a ColorDefinition instance with an id, level, and version. - * - * @param id - * @param level - * @param version - */ - public ColorDefinition(String id, int level, int version) { - this(id, null, level, version); - } - - - /** - * Creates a ColorDefinition instance with an id, name, level, and version. - * - * @param id - * @param name - * @param level - * @param version - */ - public ColorDefinition(String id, String name, int level, int version) { - super(id, name, level, version); - if (getLevelAndVersion().compareTo(Integer.valueOf(RenderConstants.MIN_SBML_LEVEL), - Integer.valueOf(RenderConstants.MIN_SBML_VERSION)) < 0) { - throw new LevelVersionError(getElementName(), level, version); - } - initDefaults(); - } - - - /** - * Clone constructor - */ - public ColorDefinition(ColorDefinition obj) { - super(obj); - value = obj.value; - } - - - /** - * clones this class - */ - public ColorDefinition clone() { - return new ColorDefinition(this); - } - - - /** - * Initializes the default values using the namespace. - */ - public void initDefaults() { - addNamespace(RenderConstants.namespaceURI); - } - - - /* (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#isIdMandatory() - */ - public boolean isIdMandatory() { - return true; - } - - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getAllowsChildren() - */ - @Override - public boolean getAllowsChildren() { - return false; - } - - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getChildCount() - */ - @Override - public int getChildCount() { - int count = 0; - return count; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getChildAt(int) - */ - @Override - public SBase getChildAt(int childIndex) { - return null; - } - - - - /** - * @return the value of value - */ - public Color getValue() { - if (isSetValue()) { - return value; - } - // This is necessary if we cannot return null here. - throw new PropertyUndefinedError(RenderConstants.value, this); - } - - - /** - * @return whether value is set - */ - public boolean isSetValue() { - return this.value != null; - } - - - /** - * Set the value of value - */ - public void setValue(Color value) { - Color oldValue = this.value; - this.value = value; - firePropertyChange(RenderConstants.value, oldValue, this.value); - } - - - /** - * Unsets the variable value - * @return <code>true</code>, if value was set before, - * otherwise <code>false</code> - */ - public boolean unsetValue() { - if (isSetValue()) { - Color oldValue = this.value; - this.value = null; - firePropertyChange(RenderConstants.value, oldValue, this.value); - return true; - } - return false; - } - - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#writeXMLAttributes() - */ - @Override - public Map<String, String> writeXMLAttributes() { - Map<String, String> attributes = super.writeXMLAttributes(); - if (isSetValue()) { - attributes.remove(RenderConstants.value); - attributes.put(RenderConstants.shortLabel + ":" + RenderConstants.value, - XMLTools.decodeColorToString(getValue())); - } - return attributes; - } - - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#readAttribute(java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public boolean readAttribute(String attributeName, String prefix, String value) { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, value); - if (!isAttributeRead) { - isAttributeRead = true; - if (attributeName.equals(RenderConstants.value)) { - setValue(Color.decode(value)); - } - // END TODO - else { - isAttributeRead = false; - } - } - return isAttributeRead; - } - -} Copied: trunk/extensions/render/src/org/sbml/jsbml/ext/render/ColorDefinition.java (from rev 1297, trunk/extensions/render/src/org/sbml/jsbml/ext/render/ColorDefinition.java) =================================================================== --- trunk/extensions/render/src/org/sbml/jsbml/ext/render/ColorDefinition.java (rev 0) +++ trunk/extensions/render/src/org/sbml/jsbml/ext/render/ColorDefinition.java 2012-06-11 19:29:10 UTC (rev 1300) @@ -0,0 +1,263 @@ +/* + * $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-2012 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 + * + * 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.render; + +import java.awt.Color; +import java.util.Map; + +import org.sbml.jsbml.AbstractNamedSBase; +import org.sbml.jsbml.LevelVersionError; +import org.sbml.jsbml.PropertyUndefinedError; +import org.sbml.jsbml.SBase; + + +/** + * @author Eugen Netz + * @author Alexander Diamantikos + * @author Jakob Matthes + * @author Jan Rudolph + * @version $Rev$ + * @since 1.0 + * @date 08.05.2012 + */ +public class ColorDefinition extends AbstractNamedSBase { + + /** + * + */ + private static final long serialVersionUID = 8904459123022343452L; + + private Color value; + + /** + * Creates an ColorDefinition instance + */ + public ColorDefinition() { + super(); + initDefaults(); + } + + + /** + * Creates a ColorDefinition instance with an id. + * + * @param id + */ + public ColorDefinition(String id) { + super(id); + initDefaults(); + } + + /** + * Creates a ColorDefinition instance with an id. + * + * @param id + */ + public ColorDefinition(String id, Color value) { + super(id); + this.value = value; + initDefaults(); + } + + + /** + * Creates a ColorDefinition instance with a level and version. + * + * @param level + * @param version + */ + public ColorDefinition(int level, int version) { + this(null, null, level, version); + } + + + /** + * Creates a ColorDefinition instance with an id, level, and version. + * + * @param id + * @param level + * @param version + */ + public ColorDefinition(String id, int level, int version) { + this(id, null, level, version); + } + + + /** + * Creates a ColorDefinition instance with an id, name, level, and version. + * + * @param id + * @param name + * @param level + * @param version + */ + public ColorDefinition(String id, String name, int level, int version) { + super(id, name, level, version); + if (getLevelAndVersion().compareTo(Integer.valueOf(RenderConstants.MIN_SBML_LEVEL), + Integer.valueOf(RenderConstants.MIN_SBML_VERSION)) < 0) { + throw new LevelVersionError(getElementName(), level, version); + } + initDefaults(); + } + + + /** + * Clone constructor + */ + public ColorDefinition(ColorDefinition obj) { + super(obj); + value = obj.value; + } + + + /** + * clones this class + */ + public ColorDefinition clone() { + return new ColorDefinition(this); + } + + + /** + * Initializes the default values using the namespace. + */ + public void initDefaults() { + addNamespace(RenderConstants.namespaceURI); + } + + + /* (non-Javadoc) + * @see org.sbml.jsbml.NamedSBase#isIdMandatory() + */ + public boolean isIdMandatory() { + return true; + } + + + /* (non-Javadoc) + * @see org.sbml.jsbml.AbstractSBase#getAllowsChildren() + */ + @Override + public boolean getAllowsChildren() { + return false; + } + + + /* (non-Javadoc) + * @see org.sbml.jsbml.AbstractSBase#getChildCount() + */ + @Override + public int getChildCount() { + int count = 0; + return count; + } + + /* (non-Javadoc) + * @see org.sbml.jsbml.AbstractSBase#getChildAt(int) + */ + @Override + public SBase getChildAt(int childIndex) { + return null; + } + + + + /** + * @return the value of value + */ + public Color getValue() { + if (isSetValue()) { + return value; + } + // This is necessary if we cannot return null here. + throw new PropertyUndefinedError(RenderConstants.value, this); + } + + + /** + * @return whether value is set + */ + public boolean isSetValue() { + return this.value != null; + } + + + /** + * Set the value of value + */ + public void setValue(Color value) { + Color oldValue = this.value; + this.value = value; + firePropertyChange(RenderConstants.value, oldValue, this.value); + } + + + /** + * Unsets the variable value + * @return <code>true</code>, if value was set before, + * otherwise <code>false</code> + */ + public boolean unsetValue() { + if (isSetValue()) { + Color oldValue = this.value; + this.value = null; + firePropertyChange(RenderConstants.value, oldValue, this.value); + return true; + } + return false; + } + + + /* (non-Javadoc) + * @see org.sbml.jsbml.AbstractNamedSBase#writeXMLAttributes() + */ + @Override + public Map<String, String> writeXMLAttributes() { + Map<String, String> attributes = super.writeXMLAttributes(); + if (isSetValue()) { + attributes.remove(RenderConstants.value); + attributes.put(RenderConstants.shortLabel + ":" + RenderConstants.value, + XMLTools.encodeColorToString(getValue())); + } + return attributes; + } + + + /* (non-Javadoc) + * @see org.sbml.jsbml.AbstractNamedSBase#readAttribute(java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public boolean readAttribute(String attributeName, String prefix, String value) { + boolean isAttributeRead = super.readAttribute(attributeName, prefix, value); + if (!isAttributeRead) { + isAttributeRead = true; + if (attributeName.equals(RenderConstants.value)) { + setValue(XMLTools.decodeStringToColor(value)); + } + // END TODO + else { + isAttributeRead = false; + } + } + return isAttributeRead; + } + +} Modified: trunk/extensions/render/src/org/sbml/jsbml/ext/render/Curve.java =================================================================== --- trunk/extensions/render/src/org/sbml/jsbml/ext/render/Curve.java 2012-06-11 12:47:53 UTC (rev 1299) +++ trunk/extensions/render/src/org/sbml/jsbml/ext/render/Curve.java 2012-06-11 19:29:10 UTC (rev 1300) @@ -20,6 +20,8 @@ */ package org.sbml.jsbml.ext.render; +import java.util.Map; + import org.sbml.jsbml.ListOf; import org.sbml.jsbml.PropertyUndefinedError; @@ -255,4 +257,44 @@ return element; } + /* (non-Javadoc) + * @see org.sbml.jsbml.AbstractNamedSBase#writeXMLAttributes() + */ + @Override + public Map<String, String> writeXMLAttributes() { + Map<String, String> attributes = super.writeXMLAttributes(); + if (isSetStartHead()) { + attributes.remove(RenderConstants.startHead); + attributes.put(RenderConstants.shortLabel + ":" + RenderConstants.startHead, + getStartHead()); + } + if (isSetEndHead()) { + attributes.remove(RenderConstants.endHead); + attributes.put(RenderConstants.shortLabel + ":" + RenderConstants.endHead, + getEndHead()); + } + return attributes; + } + + /* (non-Javadoc) + * @see org.sbml.jsbml.AbstractNamedSBase#readAttribute(java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public boolean readAttribute(String attributeName, String prefix, String value) { + boolean isAttributeRead = super.readAttribute(attributeName, prefix, value); + if (!isAttributeRead) { + isAttributeRead = true; + if (attributeName.equals(RenderConstants.startHead)) { + setStartHead(value); + } + else if (attributeName.equals(RenderConstants.endHead)) { + setEndHead(value); + } + else { + isAttributeRead = false; + } + } + return isAttributeRead; + } + } Modified: trunk/extensions/render/src/org/sbml/jsbml/ext/render/Ellipse.java =================================================================== --- trunk/extensions/render/src/org/sbml/jsbml/ext/render/Ellipse.java 2012-06-11 12:47:53 UTC (rev 1299) +++ trunk/extensions/render/src/org/sbml/jsbml/ext/render/Ellipse.java 2012-06-11 19:29:10 UTC (rev 1300) @@ -20,6 +20,8 @@ */ package org.sbml.jsbml.ext.render; +import java.util.Map; + import org.sbml.jsbml.PropertyUndefinedError; @@ -463,4 +465,77 @@ return false; } + /* (non-Javadoc) + * @see org.sbml.jsbml.AbstractSBase#writeXMLAttributes() + */ + @Override + public Map<String, String> writeXMLAttributes() { + Map<String, String> attributes = super.writeXMLAttributes(); + + if (isSetCx()) { + attributes.remove(RenderConstants.cx); + attributes.put(RenderConstants.shortLabel + ":" + RenderConstants.cx, + XMLTools.positioningToString(getCx(), isAbsoluteCx())); + } + if (isSetCy()) { + attributes.remove(RenderConstants.cy); + attributes.put(RenderConstants.shortLabel + ":" + RenderConstants.cy, + XMLTools.positioningToString(getCy(), isAbsoluteCy())); + } + if (isSetCz()) { + attributes.remove(RenderConstants.cz); + attributes.put(RenderConstants.shortLabel + ":" + RenderConstants.cz, + XMLTools.positioningToString(getCz(), isAbsoluteCz())); + } + if (isSetRx()) { + attributes.remove(RenderConstants.rx); + attributes.put(RenderConstants.shortLabel + ":" + RenderConstants.rx, + XMLTools.positioningToString(getRx(), isAbsoluteRx())); + } + if (isSetRy()) { + attributes.remove(RenderConstants.ry); + attributes.put(RenderConstants.shortLabel + ":" + RenderConstants.ry, + XMLTools.positioningToString(getRy(), isAbsoluteRy())); + } + + return attributes; + } + + + /* (non-Javadoc) + * @see org.sbml.jsbml.AbstractSBase#readAttribute(java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public boolean readAttribute(String attributeName, String prefix, String value) { + boolean isAttributeRead = super.readAttribute(attributeName, prefix, value); + if (!isAttributeRead) { + isAttributeRead = true; + // TODO: catch Exception if Enum.valueOf fails, generate logger output + if (attributeName.equals(RenderConstants.cx)) { + setCx(XMLTools.parsePosition(value)); + setAbsoluteCx(XMLTools.isAbsolutePosition(value)); + } + else if (attributeName.equals(RenderConstants.cy)) { + setCy(XMLTools.parsePosition(value)); + setAbsoluteCy(XMLTools.isAbsolutePosition(value)); + } + else if (attributeName.equals(RenderConstants.cz)) { + setCz(XMLTools.parsePosition(value)); + setAbsoluteCz(XMLTools.isAbsolutePosition(value)); + } + else if (attributeName.equals(RenderConstants.rx)) { + setRx(XMLTools.parsePosition(value)); + setAbsoluteRx(XMLTools.isAbsolutePosition(value)); + } + else if (attributeName.equals(RenderConstants.ry)) { + setRy(XMLTools.parsePosition(value)); + setAbsoluteRy(XMLTools.isAbsolutePosition(value)); + } + else { + isAttributeRead = false; + } + } + return isAttributeRead; + } + } Modified: trunk/extensions/render/src/org/sbml/jsbml/ext/render/GradientBase.java =================================================================== --- trunk/extensions/render/src/org/sbml/jsbml/ext/render/GradientBase.java 2012-06-11 12:47:53 UTC (rev 1299) +++ trunk/extensions/render/src/org/sbml/jsbml/ext/render/GradientBase.java 2012-06-11 19:29:10 UTC (rev 1300) @@ -20,7 +20,6 @@ */ package org.sbml.jsbml.ext.render; -import java.awt.Color; import java.text.MessageFormat; import java.util.Map; @@ -297,7 +296,7 @@ /** * create a new GradientStop element and adds it to the ListOfGradientStops list */ - public GradientStop createGradientStop(double offset, Color stopColor) { + public GradientStop createGradientStop(double offset, String stopColor) { GradientStop field = new GradientStop(offset, stopColor, getLevel(), getVersion()); addGradientStop(field); return field; Modified: trunk/extensions/render/src/org/sbml/jsbml/ext/render/GradientStop.java =================================================================== --- trunk/extensions/render/src/org/sbml/jsbml/ext/render/GradientStop.java 2012-06-11 12:47:53 UTC (rev 1299) +++ trunk/extensions/render/src/org/sbml/jsbml/ext/render/GradientStop.java 2012-06-11 19:29:10 UTC (rev 1300) @@ -20,7 +20,6 @@ */ package org.sbml.jsbml.ext.render; -import java.awt.Color; import java.text.MessageFormat; import java.util.Map; @@ -47,7 +46,7 @@ private Double offset; - private Color stopColor; + private String stopColor; /** @@ -56,7 +55,7 @@ * @param offset * @param color */ - public GradientStop(Double offset, Color stopColor) { + public GradientStop(Double offset, String stopColor) { this.offset = offset; this.stopColor = stopColor; } @@ -69,7 +68,7 @@ * @param level * @param version */ - public GradientStop(Double offset, Color stopColor, int level, int version) { + public GradientStop(Double offset, String stopColor, int level, int version) { super(level, version); if (getLevelAndVersion().compareTo(Integer.valueOf(RenderConstants.MIN_SBML_LEVEL), Integer.valueOf(RenderConstants.MIN_SBML_VERSION)) < 0) { @@ -140,7 +139,7 @@ /** * @return the value of stopColor */ - public Color getStopColor() { + public String getStopColor() { if (isSetStopColor()) { return stopColor; } @@ -174,8 +173,8 @@ /** * Set the value of stopColor */ - public void setStopColor(Color stopColor) { - Color oldStopColor = this.stopColor; + public void setStopColor(String stopColor) { + String oldStopColor = this.stopColor; this.stopColor = stopColor; firePropertyChange(RenderConstants.stopColor, oldStopColor, this.stopColor); } @@ -202,7 +201,7 @@ */ public boolean unsetStopColor() { if (isSetStopColor()) { - Color oldStopColor = this.stopColor; + String oldStopColor = this.stopColor; this.stopColor = null; firePropertyChange(RenderConstants.stopColor, oldStopColor, this.stopColor); return true; @@ -234,7 +233,7 @@ if (isSetStopColor()) { attributes.remove(RenderConstants.stopColor); attributes.put(RenderConstants.shortLabel + ":" + RenderConstants.stopColor, - XMLTools.decodeColorToString(getStopColor())); + getStopColor()); } return attributes; } @@ -252,7 +251,7 @@ setOffset(XMLTools.parsePosition(value)); } else if (attributeName.equals(RenderConstants.stopColor)) { - setStopColor(Color.decode(value)); + setStopColor(value); } else { isAttributeRead = false; Modified: trunk/extensions/render/src/org/sbml/jsbml/ext/render/GraphicalPrimitive1D.java =================================================================== --- trunk/extensions/render/src/org/sbml/jsbml/ext/render/GraphicalPrimitive1D.java 2012-06-11 12:47:53 UTC (rev 1299) +++ trunk/extensions/render/src/org/sbml/jsbml/ext/render/GraphicalPrimitive1D.java 2012-06-11 19:29:10 UTC (rev 1300) @@ -42,7 +42,7 @@ * */ private static final long serialVersionUID = 3705246334810811216L; - protected ColorDefinition stroke; + protected String stroke; protected Short[] strokeDashArray; protected Integer strokeWidth; @@ -151,7 +151,7 @@ /** * @return the value of stroke */ - public ColorDefinition getStroke() { + public String getStroke() { if (isSetStroke()) { return stroke; } @@ -194,8 +194,8 @@ /** * Set the value of stroke */ - public void setStroke(ColorDefinition stroke) { - ColorDefinition oldStroke = this.stroke; + public void setStroke(String stroke) { + String oldStroke = this.stroke; this.stroke = stroke; firePropertyChange(RenderConstants.stroke, oldStroke, this.stroke); } @@ -216,7 +216,7 @@ */ public boolean unsetStroke() { if (isSetStroke()) { - ColorDefinition oldStroke = this.stroke; + String oldStroke = this.stroke; this.stroke = null; firePropertyChange(RenderConstants.stroke, oldStroke, this.stroke); return true; @@ -248,7 +248,7 @@ if (isSetStroke()) { attributes.remove(RenderConstants.stroke); attributes.put(RenderConstants.shortLabel + ":" + RenderConstants.strokeWidth, - XMLTools.encodeColorDefintionToString(getStroke())); + getStroke()); } if (isSetStrokeDashArray()){ attributes.remove(RenderConstants.strokeDashArray); @@ -273,7 +273,7 @@ isAttributeRead = true; // TODO: catch Exception if Enum.valueOf fails, generate logger output if (attributeName.equals(RenderConstants.stroke)) { - setStroke(XMLTools.decodeStringToColorDefintion(value)); + setStroke(value); } else if (attributeName.equals(RenderConstants.strokeDashArray)) { setStrokeDashArray(XMLTools.decodeStringToArrayShort(value)); Modified: trunk/extensions/render/src/org/sbml/jsbml/ext/render/GraphicalPrimitive2D.java =================================================================== --- trunk/extensions/render/src/org/sbml/jsbml/ext/render/GraphicalPrimitive2D.java 2012-06-11 12:47:53 UTC (rev 1299) +++ trunk/extensions/render/src/org/sbml/jsbml/ext/render/GraphicalPrimitive2D.java 2012-06-11 19:29:10 UTC (rev 1300) @@ -20,6 +20,8 @@ */ package org.sbml.jsbml.ext.render; +import java.util.Map; + import org.sbml.jsbml.PropertyUndefinedError; @@ -160,5 +162,46 @@ } return false; } + + /* (non-Javadoc) + * @see org.sbml.jsbml.AbstractNamedSBase#writeXMLAttributes() + */ + @Override + public Map<String, String> writeXMLAttributes() { + Map<String, String> attributes = super.writeXMLAttributes(); + if (isSetFill()) { + attributes.remove(RenderConstants.fill); + attributes.put(RenderConstants.shortLabel + ":" + RenderConstants.fill, + getFill()); + } + if (isSetFillRule()) { + attributes.remove(RenderConstants.fillRule); + attributes.put(RenderConstants.shortLabel + ":" + RenderConstants.fillRule, + getFillRule().toString().toLowerCase()); + } + return attributes; + } + + /* (non-Javadoc) + * @see org.sbml.jsbml.AbstractNamedSBase#readAttribute(java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public boolean readAttribute(String attributeName, String prefix, String value) { + boolean isAttributeRead = super.readAttribute(attributeName, prefix, value); + if (!isAttributeRead) { + isAttributeRead = true; + if (attributeName.equals(RenderConstants.fill)) { + setFill(value); + } + else if (attributeName.equals(RenderConstants.fillRule)) { + setFillRule(FillRule.valueOf(value)); + } + else { + isAttributeRead = false; + } + } + return isAttributeRead; + } + } Modified: trunk/extensions/render/src/org/sbml/jsbml/ext/render/Group.java =================================================================== --- trunk/extensions/render/src/org/sbml/jsbml/ext/render/Group.java 2012-06-11 12:47:53 UTC (rev 1299) +++ trunk/extensions/render/src/org/sbml/jsbml/ext/render/Group.java 2012-06-11 19:29:10 UTC (rev 1300) @@ -21,6 +21,7 @@ package org.sbml.jsbml.ext.render; import java.text.MessageFormat; +import java.util.Map; import org.sbml.jsbml.LevelVersionError; import org.sbml.jsbml.PropertyUndefinedError; @@ -548,5 +549,103 @@ } return false; } + + /* (non-Javadoc) + * @see org.sbml.jsbml.AbstractSBase#writeXMLAttributes() + */ + @Override + public Map<String, String> writeXMLAttributes() { + Map<String, String> attributes = super.writeXMLAttributes(); + if(isSetId()){ + attributes.remove(RenderConstants.id); + attributes.put(RenderConstants.shortLabel + ":" + RenderConstants.id, + getId()); + } + if (isSetFontFamily()) { + attributes.remove(RenderConstants.fontFamily); + attributes.put(RenderConstants.shortLabel + ":" + RenderConstants.fontFamily, + getFontFamily().toString().toLowerCase()); + } + if (isSetTextAnchor()) { + attributes.remove(RenderConstants.textAnchor); + attributes.put(RenderConstants.shortLabel + ":" + RenderConstants.textAnchor, + getTextAnchor().toString().toLowerCase()); + } + if (isSetVTextAnchor()) { + attributes.remove(RenderConstants.vTextAnchor); + attributes.put(RenderConstants.shortLabel + ":" + RenderConstants.vTextAnchor, + getVTextAnchor().toString().toLowerCase()); + } + if (isSetFontSize()) { + attributes.remove(RenderConstants.fontSize); + attributes.put(RenderConstants.shortLabel + ":" + RenderConstants.fontSize, + Short.toString(getFontSize())); + } + if (isSetStartHead()) { + attributes.remove(RenderConstants.startHead); + attributes.put(RenderConstants.shortLabel + ":" + RenderConstants.startHead, + getStartHead()); + } + if (isSetEndHead()) { + attributes.remove(RenderConstants.endHead); + attributes.put(RenderConstants.shortLabel + ":" + RenderConstants.endHead, + getEndHead()); + } + if (isSetFontStyleItalic()) { + attributes.remove(RenderConstants.fontStyleItalic); + attributes.put(RenderConstants.fontStyleItalic, + XMLTools.fontStyleItalicToString(isFontStyleItalic())); + } + if (isSetFontWeightBold()) { + attributes.remove(RenderConstants.fontWeightBold); + attributes.put(RenderConstants.fontWeightBold, + XMLTools.fontWeightBoldToString(isFontWeightBold())); + } + return attributes; + } + + /* (non-Javadoc) + * @see org.sbml.jsbml.AbstractSBase#readAttribute(java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public boolean readAttribute(String attributeName, String prefix, String value) { + boolean isAttributeRead = super.readAttribute(attributeName, prefix, value); + if (!isAttributeRead) { + isAttributeRead = true; + // TODO: catch Exception if Enum.valueOf fails, generate logger output + if (attributeName.equals(RenderConstants.id)) { + setId(value); + } + else if (attributeName.equals(RenderConstants.fontFamily)) { + setFontFamily(FontFamily.valueOf(value.toUpperCase())); + } + else if (attributeName.equals(RenderConstants.fontSize)) { + setFontSize(Short.valueOf(value)); + } + else if (attributeName.equals(RenderConstants.fontWeightBold)) { + setFontWeightBold(XMLTools.parseFontWeightBold(value)); + } + else if (attributeName.equals(RenderConstants.fontStyleItalic)) { + setFontStyleItalic(XMLTools.parseFontStyleItalic(value)); + } + else if (attributeName.equals(RenderConstants.textAnchor)) { + setTextAnchor(TextAnchor.valueOf(value.toUpperCase())); + } + else if (attributeName.equals(RenderConstants.vTextAnchor)) { + setVTextAnchor(VTextAnchor.valueOf(value.toUpperCase())); + } + else if (attributeName.equals(RenderConstants.startHead)) { + setStartHead(value); + } + else if (attributeName.equals(RenderConstants.endHead)) { + setEndHead(value); + } + else { + isAttributeRead = false; + } + } + return isAttributeRead; + } + } Modified: trunk/extensions/render/src/org/sbml/jsbml/ext/render/Rectangle.java =================================================================== --- trunk/extensions/render/src/org/sbml/jsbml/ext/render/Rectangle.java 2012-06-11 12:47:53 UTC (rev 1299) +++ trunk/extensions/render/src/org/sbml/jsbml/ext/render/Rectangle.java 2012-06-11 19:29:10 UTC (rev 1300) @@ -21,6 +21,7 @@ package org.sbml.jsbml.ext.render; import java.text.MessageFormat; +import java.util.Map; import org.sbml.jsbml.PropertyUndefinedError; import org.sbml.jsbml.SBase; @@ -736,5 +737,96 @@ "Index {0,number,integer} >= {1,number,integer}", childIndex, +((int) Math.min(pos, 0)))); } + + /* (non-Javadoc) + * @see org.sbml.jsbml.AbstractSBase#writeXMLAttributes() + */ + @Override + public Map<String, String> writeXMLAttributes() { + Map<String, String> attributes = super.writeXMLAttributes(); + if (isSetX()) { + attributes.remove(RenderConstants.x); + attributes.put(RenderConstants.shortLabel + ":" + RenderConstants.x, + XMLTools.positioningToString(getX(), isAbsoluteX())); + } + if (isSetY()) { + attributes.remove(RenderConstants.y); + attributes.put(RenderConstants.shortLabel + ":" + RenderConstants.y, + XMLTools.positioningToString(getY(), isAbsoluteY())); + } + if (isSetZ()) { + attributes.remove(RenderConstants.z); + attributes.put(RenderConstants.shortLabel + ":" + RenderConstants.z, + XMLTools.positioningToString(getZ(), isAbsoluteZ())); + } + if (isSetWidth()) { + attributes.remove(RenderConstants.width); + attributes.put(RenderConstants.shortLabel + ":" + RenderConstants.width, + XMLTools.positioningToString(getWidth(), isAbsoluteWidth())); + } + if (isSetHeight()) { + attributes.remove(RenderConstants.height); + attributes.put(RenderConstants.shortLabel + ":" + RenderConstants.height, + XMLTools.positioningToString(getHeight(), isAbsoluteHeight())); + } + if (isSetRx()) { + attributes.remove(RenderConstants.rx); + attributes.put(RenderConstants.shortLabel + ":" + RenderConstants.rx, + XMLTools.positioningToString(getRx(), isAbsoluteRx())); + } + if (isSetRy()) { + attributes.remove(RenderConstants.ry); + attributes.put(RenderConstants.shortLabel + ":" + RenderConstants.ry, + XMLTools.positioningToString(getRy(), isAbsoluteRy())); + } + + return attributes; + } + + + /* (non-Javadoc) + * @see org.sbml.jsbml.AbstractSBase#readAttribute(java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public boolean readAttribute(String attributeName, String prefix, String value) { + boolean isAttributeRead = super.readAttribute(attributeName, prefix, value); + if (!isAttributeRead) { + isAttributeRead = true; + // TODO: catch Exception if Enum.valueOf fails, generate logger output + if (attributeName.equals(RenderConstants.cx)) { + setX(XMLTools.parsePosition(value)); + setAbsoluteX(XMLTools.isAbsolutePosition(value)); + } + else if (attributeName.equals(RenderConstants.cy)) { + setY(XMLTools.parsePosition(value)); + setAbsoluteY(XMLTools.isAbsolutePosition(value)); + } + else if (attributeName.equals(RenderConstants.cz)) { + setZ(XMLTools.parsePosition(value)); + setAbsoluteZ(XMLTools.isAbsolutePosition(value)); + } + else if (attributeName.equals(RenderConstants.width)) { + setWidth(XMLTools.parsePosition(value)); + setAbsoluteWidth(XMLTools.isAbsolutePosition(value)); + } + else if (attributeName.equals(RenderConstants.height)) { + setHeight(XMLTools.parsePosition(value)); + setAbsoluteHeight(XMLTools.isAbsolutePosition(value)); + } + else if (attributeName.equals(RenderConstants.rx)) { + setRx(XMLTools.parsePosition(value)); + setAbsoluteRx(XMLTools.isAbsolutePosition(value)); + } + else if (attributeName.equals(RenderConstants.ry)) { + setRy(XMLTools.parsePosition(value)); + setAbsoluteRy(XMLTools.isAbsolutePosition(value)); + } + else { + isAttributeRead = false; + } + } + return isAttributeRead; + } + } Modified: trunk/extensions/render/src/org/sbml/jsbml/ext/render/RenderInformationBase.java =================================================================== --- trunk/extensions/render/src/org/sbml/jsbml/ext/render/RenderInformationBase.java 2012-06-11 12:47:53 UTC (rev 1299) +++ trunk/extensions/render/src/org/sbml/jsbml/ext/render/RenderInformationBase.java 2012-06-11 19:29:10 UTC (rev 1300) @@ -639,7 +639,7 @@ if (isSetBackgroundColor()) { attributes.remove(RenderConstants.backgroundColor); attributes.put(RenderConstants.shortLabel + ":" + RenderConstants.backgroundColor, - XMLTools.decodeColorToString(getBackgroundColor())); + XMLTools.encodeColorToString(getBackgroundColor())); } return attributes; } @@ -663,7 +663,7 @@ setReferenceRenderInformation(value); } else if (attributeName.equals(RenderConstants.backgroundColor)) { - setBackgroundColor(Color.decode(value)); + setBackgroundColor(XMLTools.decodeStringToColor(value)); } else { isAttributeRead = false; Modified: trunk/extensions/render/src/org/sbml/jsbml/ext/render/Transformation.java =================================================================== --- trunk/extensions/render/src/org/sbml/jsbml/ext/render/Transformation.java 2012-06-11 12:47:53 UTC (rev 1299) +++ trunk/extensions/render/src/org/sbml/jsbml/ext/render/Transformation.java 2012-06-11 19:29:10 UTC (rev 1300) @@ -21,6 +21,7 @@ package org.sbml.jsbml.ext.render; import java.text.MessageFormat; +import java.util.Map; import org.sbml.jsbml.AbstractSBase; import org.sbml.jsbml.SBase; @@ -111,5 +112,45 @@ // TODO Auto-generated method stub return null; } + + /* (non-Javadoc) + * @see org.sbml.jsbml.AbstractSBase#writeXMLAttributes() + */ + @Override + public Map<String, String> writeXMLAttributes() { + Map<String, String> attributes = super.writeXMLAttributes(); + if (isSetTransform()) { + attributes.remove(RenderConstants.transform); + attributes.put(RenderConstants.shortLabel + ":" + RenderConstants.transform, + XMLTools.encodeArrayDoubleToString(transform)); + } + return attributes; + } + + private boolean isSetTransform() { + return this.transform != null; +} +/* (non-Javadoc) + * @see org.sbml.jsbml.AbstractSBase#readAttribute(java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public boolean readAttribute(String attributeName, String prefix, String value) { + boolean isAttributeRead = super.readAttribute(attributeName, prefix, value); + if (!isAttributeRead) { + isAttributeRead = true; + // TODO: catch Exception if Enum.valueOf fails, generate logger output + if (attributeName.equals(RenderConstants.transform)) { + setTransform(XMLTools.decodeStringToArrayDouble(value)); + } + } + return isAttributeRead; + } + + private void setTransform(Double[] transform) { + Double[] oldTransform = this.transform; + this.transform = transform; + firePropertyChange(RenderConstants.transform, oldTransform, this.transform); + } + } Modified: trunk/extensions/render/src/org/sbml/jsbml/ext/render/Transformation2D.java =================================================================== --- trunk/extensions/render/src/org/sbml/jsbml/ext/render/Transformation2D.java 2012-06-11 12:47:53 UTC (rev 1299) +++ trunk/extensions/render/src/org/sbml/jsbml/ext/render/Transformation2D.java 2012-06-11 19:29:10 UTC (rev 1300) @@ -20,8 +20,6 @@ */ package org.sbml.jsbml.ext.render; -import java.util.Map; - import org.sbml.jsbml.PropertyUndefinedError; @@ -116,36 +114,4 @@ } return false; } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#writeXMLAttributes() - */ - @Override - public Map<String, String> writeXMLAttributes() { - Map<String, String> attributes = super.writeXMLAttributes(); - if (isSetTransform()) { - - attributes.remove(RenderConstants.transform); - attributes.put(RenderConstants.shortLabel + ":" + RenderConstants.transform, - XMLTools.encodeArrayDoubleToString(transform)); - } - return attributes; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#readAttribute(java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public boolean readAttribute(String attributeName, String prefix, String value) { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, value); - if (!isAttributeRead) { - isAttributeRead = true; - // TODO: catch Exception if Enum.valueOf fails, generate logger output - if (attributeName.equals(RenderConstants.transform)) { - setTransform(XMLTools.decodeStringToArrayDouble(value, 6)); - } - } - return isAttributeRead; - } - } Modified: trunk/extensions/render/src/org/sbml/jsbml/ext/render/XMLTools.java =================================================================== --- trunk/extensions/render/src/org/sbml/jsbml/ext/render/XMLTools.java 2012-06-11 12:47:53 UTC (rev 1299) +++ trunk/extensions/render/src/org/sbml/jsbml/ext/render/XMLTools.java 2012-06-11 19:29:10 UTC (rev 1300) @@ -21,7 +21,7 @@ package org.sbml.jsbml.ext.render; import java.awt.Color; -import java.util.ArrayList; +import java.util.Locale; import org.sbml.jsbml.util.StringTools; @@ -44,10 +44,10 @@ */ public static String positioningToString(double x, boolean absoluteX) { if (absoluteX) { - return StringTools.toString(x); + return StringTools.toString(Locale.ENGLISH, x); } else { - return StringTools.toString(x * 100d) + "%"; + return StringTools.toString(Locale.ENGLISH, x) + "%"; } } @@ -55,6 +55,7 @@ * @param fontStyleItalic * @return */ + // Returns "italic" if fontStyleItalic is true, else "normal" public static String fontStyleItalicToString(boolean fontStyleItalic) { return (fontStyleItalic ? RenderConstants.fontStyleItalicTrue : RenderConstants.fontStyleItalicFalse); @@ -64,6 +65,7 @@ * @param fontWeightBold * @return */ +//Returns "italic" if fontStyleBold is true, else "normal" public static String fontWeightBoldToString(boolean fontWeightBold) { return (fontWeightBold ? RenderConstants.fontWeightBoldTrue : RenderConstants.fontWeightBoldFalse); @@ -86,8 +88,7 @@ return StringTools.parseSBMLDouble(value); } else { - return (StringTools.parseSBMLDouble(value.substring(0, value.length() - 1)) - / 100d); + return StringTools.parseSBMLDouble(value.substring(0, value.length() - 1)); } } @@ -112,13 +113,26 @@ * @param value * @return */ - public static String decodeColorToString(Color value) { + public static String encodeColorToString(Color value) { int r = value.getRed(); int g = value.getGreen(); int b = value.getBlue(); + int a = value.getAlpha(); return ("#" + Integer.toHexString(r) + - Integer.toHexString(g) + Integer.toHexString(b)).toUpperCase(); + Integer.toHexString(g) + Integer.toHexString(b) + Integer.toHexString(a)).toUpperCase(); } + + public static Color decodeStringToColor(String value) { + int r = Integer.parseInt(value.substring(1, 3)); + int g = Integer.parseInt(value.substring(3, 5)); + int b = Integer.parseInt(value.substring(5, 7)); + int a = 255; + if(value.length() == 9) { + a = Integer.parseInt(value.substring(7, 9)); + } + + return new Color(r, g, b, a); + } /** * @param roleList @@ -134,80 +148,37 @@ } return output; } - - - public static String encodeColorToString(Color value){ - int r = value.getRed(); - int g = value.getGreen(); - int b = value.getBlue(); - int a = value.getAlpha(); - return ("#" + Integer.toHexString(r) + Integer.toHexString(g) + - Integer.toHexString(b) + Integer.toHexString(a)).toUpperCase(); - } - - public static Color decodeStringToColor(String string){ - int r = Integer.parseInt(string.substring(1, 3), 16); - int g = Integer.parseInt(string.substring(3, 5), 16); - int b = Integer.parseInt(string.substring(5, 7), 16); - int a = 255; - if (string.length() == 9){ - a = Integer.parseInt(string.substring(7, 9), 16); - } - - return new Color(r,g,b,a); - } - - public static String encodeColorDefintionToString(ColorDefinition cd){ - return cd.getId() + "," + encodeColorToString(cd.getValue()); - } - - public static ColorDefinition decodeStringToColorDefintion(String value){ - String id = value.substring(0, value.indexOf(",")); - Color color = decodeStringToColor(value.substring(value.indexOf(",") + 1)); - return new ColorDefinition(id, color); - } - + public static String encodeArrayDoubleToString(Double[] array) { String s = ""; for (int i = 0; i < array.length; i++) { if(!s.isEmpty()){ - s+=","; + s+=", "; } - s+= Double.toString(array[i]); + s+= StringTools.toString(Locale.ENGLISH, array[i]); } return s; } - public static Double[] decodeStringToArrayDouble(String value, int length) { + public static Double[] decodeStringToArrayDouble(String value) { - Double[] array = new Double[length]; - String sub = ""; - - for (int i = 0; i < length; i++) { - int index = value.indexOf(","); - if(index == -1) { - sub = value.substring(0); - } - else{ - sub = value.substring(0, index); - value = value.substring(index+1); - } - - array[i] = StringTools.parseSBMLDouble(sub); - } - return array; + String[] array = value.split(", "); + Double[] temp = new Double[array.length]; + for (int i = 0; i < array.length; i++) { + temp[i] = StringTools.parseSBMLDouble(array[i]); + } + return temp; } public static String encodeArrayShortToString(Short[] array) { - String s = ""; for (int i = 0; i < array.length; i++) { if(!s.isEmpty()){ - s+=","; + s+=", "; } s+= Short.toString(array[i]); } @@ -216,25 +187,12 @@ public static Short[] decodeStringToArrayShort(String value) { - ArrayList<Short> list = new ArrayList<Short>(); - String sub = ""; - int index; - - while(!value.isEmpty()) { - index = value.indexOf(","); - if(index == -1) { - list.add(Short.valueOf(value.substring(0))); - return (Short[]) list.toArray(); - } - else{ - sub = value.substring(0, index); - value = value.substring(index+1); - } - - //array[i] = StringTools.parseSBMLShort(sub); - list.add(Short.valueOf(sub)); - } - return (Short[]) list.toArray(); + String[] array = value.split(", "); + Short[] temp = new Short[array.length]; + for (int i = 0; i < array.length; i++) { + temp[i] = StringTools.parseSBMLShort(array[i]); + } + return temp; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2012-06-11 12:48:04
|
Revision: 1299 http://jsbml.svn.sourceforge.net/jsbml/?rev=1299&view=rev Author: andreas-draeger Date: 2012-06-11 12:47:53 +0000 (Mon, 11 Jun 2012) Log Message: ----------- Solved the problem that sometimes non-English locale was used leading to incorrectly spelled double numbers. Added some missing convenient methods. Modified Paths: -------------- trunk/core/src/org/sbml/jsbml/ListOf.java trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Dimensions.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/LayoutConstants.java trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Point.java Modified: trunk/core/src/org/sbml/jsbml/ListOf.java =================================================================== --- trunk/core/src/org/sbml/jsbml/ListOf.java 2012-06-11 12:40:40 UTC (rev 1298) +++ trunk/core/src/org/sbml/jsbml/ListOf.java 2012-06-11 12:47:53 UTC (rev 1299) @@ -268,9 +268,7 @@ list.setVersion(parent.getVersion()); } list.setSBaseListType(type); - if (parent instanceof AbstractSBase) { - ((AbstractSBase) parent).registerChild(list); - } + parent.registerChild(list); return list; } Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Dimensions.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Dimensions.java 2012-06-11 12:40:40 UTC (rev 1298) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Dimensions.java 2012-06-11 12:47:53 UTC (rev 1299) @@ -19,6 +19,7 @@ */ package org.sbml.jsbml.ext.layout; +import java.util.Locale; import java.util.Map; import org.sbml.jsbml.AbstractNamedSBase; @@ -287,16 +288,16 @@ } if (isSetDepth()) { - attributes.put(LayoutConstants.shortLabel + ":" - + LayoutConstants.depth, StringTools.toString(depth)); + attributes.put(LayoutConstants.shortLabel + ':' + + LayoutConstants.depth, StringTools.toString(Locale.ENGLISH, depth)); } if (isSetHeight()) { - attributes.put(LayoutConstants.shortLabel + ":" - + LayoutConstants.height, StringTools.toString(height)); + attributes.put(LayoutConstants.shortLabel + ':' + + LayoutConstants.height, StringTools.toString(Locale.ENGLISH, height)); } if (isSetWidth()) { - attributes.put(LayoutConstants.shortLabel + ":" - + LayoutConstants.width, StringTools.toString(width)); + attributes.put(LayoutConstants.shortLabel + ':' + + LayoutConstants.width, StringTools.toString(Locale.ENGLISH, width)); } return attributes; Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/ExtendedLayoutModel.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/ExtendedLayoutModel.java 2012-06-11 12:40:40 UTC (rev 1298) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/ExtendedLayoutModel.java 2012-06-11 12:47:53 UTC (rev 1299) @@ -189,6 +189,14 @@ } /** + * + * @return + */ + public int getLayoutCount() { + return isSetListOfLayouts() ? listOfLayouts.size() : 0; + } + + /** * * @return */ @@ -229,7 +237,7 @@ return false; } - /** + /** * * @param listOfLayouts */ @@ -254,7 +262,7 @@ // TODO Auto-generated method stub return null; } - + /** * Removes the {@link #listOfLayouts} from this {@link Model} and notifies * all registered instances of {@link TreeNodeChangeListener}. @@ -271,7 +279,7 @@ } return false; } - + /* (non-Javadoc) * @see org.sbml.jsbml.ext.SBasePlugin#writeXMLAttributes() */ Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Layout.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Layout.java 2012-06-11 12:40:40 UTC (rev 1298) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Layout.java 2012-06-11 12:47:53 UTC (rev 1299) @@ -158,7 +158,6 @@ */ public void addAdditionalGraphical(GraphicalObject object) { if (object != null) { - registerChild(object); getListOfAdditionalGraphicalObjects().add(object); } } @@ -169,7 +168,6 @@ */ public void addCompartmentGlyph(CompartmentGlyph compartmentGlyph) { if (compartmentGlyph != null) { - registerChild(compartmentGlyph); getListOfCompartmentGlyphs().add(compartmentGlyph); } } @@ -180,7 +178,6 @@ */ public void addReactionGlyph(ReactionGlyph reactionGlyph) { if (reactionGlyph != null) { - registerChild(reactionGlyph); getListOfReactionGlyphs().add(reactionGlyph); } } @@ -191,7 +188,6 @@ */ public void addSpeciesGlyph(SpeciesGlyph speciesGlyph) { if (speciesGlyph != null) { - registerChild(speciesGlyph); getListOfSpeciesGlyphs().add(speciesGlyph); } } @@ -202,7 +198,6 @@ */ public void addTextGlyph(TextGlyph TextGlyph) { if (TextGlyph != null) { - registerChild(TextGlyph); getListOfTextGlyphs().add(TextGlyph); } } Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/LayoutConstants.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/LayoutConstants.java 2012-06-11 12:40:40 UTC (rev 1298) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/LayoutConstants.java 2012-06-11 12:47:53 UTC (rev 1299) @@ -87,5 +87,18 @@ public static final String basePoint1 = "basePoint1"; public static final String basePoint2 = "basePoint2"; public static final String reaction = "reaction"; + + /** + * + * @param level + * @param version + * @return + */ + public static String getNamespaceURI(int level, int version) { + if (level < 3) { + return namespaceURI_L2; + } + return namespaceURI; + } } Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Point.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Point.java 2012-06-11 12:40:40 UTC (rev 1298) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Point.java 2012-06-11 12:47:53 UTC (rev 1299) @@ -289,7 +289,7 @@ */ @Override public String toString() { - return "Point [" + x + ", " + y + ", " + z + "]"; + return "Point [" + x + ", " + y + ", " + z + ']'; } /* (non-Javadoc) @@ -305,15 +305,15 @@ } if (isSetX()) { - attributes.put(LayoutConstants.shortLabel + ":" + attributes.put(LayoutConstants.shortLabel + ':' + LayoutConstants.x, StringTools.toString(Locale.ENGLISH, x)); } if (isSetY()) { - attributes.put(LayoutConstants.shortLabel + ":" + attributes.put(LayoutConstants.shortLabel + ':' + LayoutConstants.y, StringTools.toString(Locale.ENGLISH, y)); } if (isSetZ()) { - attributes.put(LayoutConstants.shortLabel + ":" + attributes.put(LayoutConstants.shortLabel + ':' + LayoutConstants.z, StringTools.toString(Locale.ENGLISH, z)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nik...@us...> - 2012-06-11 12:40:50
|
Revision: 1298 http://jsbml.svn.sourceforge.net/jsbml/?rev=1298&view=rev Author: niko-rodrigue Date: 2012-06-11 12:40:40 +0000 (Mon, 11 Jun 2012) Log Message: ----------- corrected the cloning of SBase elements as the parent of the History element was not set properly and NullPointerException were encountered if using History.getParent() on cloned SBase Modified Paths: -------------- trunk/core/src/org/sbml/jsbml/AbstractSBase.java trunk/core/src/org/sbml/jsbml/Annotation.java Modified: trunk/core/src/org/sbml/jsbml/AbstractSBase.java =================================================================== --- trunk/core/src/org/sbml/jsbml/AbstractSBase.java 2012-06-10 07:18:20 UTC (rev 1297) +++ trunk/core/src/org/sbml/jsbml/AbstractSBase.java 2012-06-11 12:40:40 UTC (rev 1298) @@ -232,11 +232,10 @@ this.metaId = new String(sb.getMetaId()); } if (sb.isSetNotes()) { - this.notesXMLNode = sb.getNotes().clone(); + setNotes(sb.getNotes().clone()); } if (sb.isSetAnnotation()) { - this.annotation = sb.getAnnotation().clone(); - this.annotation.parent = this; + setAnnotation(sb.getAnnotation().clone()); } // TODO : we need to clone these extensions objects !! if (sb.isExtendedByOtherPackages()) { Modified: trunk/core/src/org/sbml/jsbml/Annotation.java =================================================================== --- trunk/core/src/org/sbml/jsbml/Annotation.java 2012-06-10 07:18:20 UTC (rev 1297) +++ trunk/core/src/org/sbml/jsbml/Annotation.java 2012-06-11 12:40:40 UTC (rev 1298) @@ -162,7 +162,7 @@ getListOfCVTerms().add(term.clone()); } if (annotation.isSetHistory()) { - this.history = annotation.getHistory().clone(); + setHistory(annotation.getHistory().clone()); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2012-06-10 07:18:26
|
Revision: 1297 http://jsbml.svn.sourceforge.net/jsbml/?rev=1297&view=rev Author: andreas-draeger Date: 2012-06-10 07:18:20 +0000 (Sun, 10 Jun 2012) Log Message: ----------- Created a convenient method for setting the referenced graphical object. Modified Paths: -------------- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/TextGlyph.java Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/TextGlyph.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/TextGlyph.java 2012-06-10 07:01:58 UTC (rev 1296) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/TextGlyph.java 2012-06-10 07:18:20 UTC (rev 1297) @@ -237,12 +237,20 @@ * * @param graphicalObject */ + public void setGraphicalObject(GraphicalObject graphicalObject) { + setGraphicalObject(graphicalObject.getId()); + } + + /** + * + * @param graphicalObject + */ public void setGraphicalObject(String graphicalObject) { String oldValue = this.graphicalObject; this.graphicalObject = graphicalObject; firePropertyChange(LayoutConstants.graphicalObject, oldValue, this.graphicalObject); } - + /** * * @param originOfText @@ -250,7 +258,7 @@ public void setOriginOfText(NamedSBase originOfText) { setNamedSBase(originOfText); } - + /** * * @param originOfText This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2012-06-10 07:02:05
|
Revision: 1296 http://jsbml.svn.sourceforge.net/jsbml/?rev=1296&view=rev Author: andreas-draeger Date: 2012-06-10 07:01:58 +0000 (Sun, 10 Jun 2012) Log Message: ----------- Renamed LayoutConstant to LayoutConstants because there are multiple constants within this class. Changed the default return type of the conversion method from Class<? extends SBase> to the listOf type from "none" to "other", because this is necessary for the packages. If some SBase is given, the listOf type should be "other", not "none". The default listOf type should still be "none", but not if a specific Class is given that is derived from SBase. Modified Paths: -------------- trunk/core/src/org/sbml/jsbml/ListOf.java trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/BoundingBox.java trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/CompartmentGlyph.java trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Curve.java trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/CurveSegment.java trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Dimensions.java trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/ExtendedLayoutModel.java trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/GraphicalObject.java trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Layout.java trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/NamedSBaseGlyph.java trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Point.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/extensions/layout/src/org/sbml/jsbml/ext/layout/TextGlyph.java trunk/extensions/layout/src/org/sbml/jsbml/xml/parsers/L3LayoutParser.java Added Paths: ----------- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/LayoutConstants.java Removed Paths: ------------- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/LayoutConstant.java Modified: trunk/core/src/org/sbml/jsbml/ListOf.java =================================================================== --- trunk/core/src/org/sbml/jsbml/ListOf.java 2012-06-10 06:46:51 UTC (rev 1295) +++ trunk/core/src/org/sbml/jsbml/ListOf.java 2012-06-10 07:01:58 UTC (rev 1296) @@ -171,9 +171,6 @@ return listOfModifiers; } else if (type.equals(Parameter.class)) { return listOfParameters; - } else if (type.equals(SpeciesReference.class)) { - // Can be reactant or product! - return other; } else if (type.equals(Reaction.class)) { return listOfReactions; } else if (type.equals(Rule.class)) { @@ -187,7 +184,7 @@ } else if (type.equals(Unit.class)) { return listOfUnits; } - return none; + return other; } /** Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/BoundingBox.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/BoundingBox.java 2012-06-10 06:46:51 UTC (rev 1295) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/BoundingBox.java 2012-06-10 07:01:58 UTC (rev 1296) @@ -55,7 +55,7 @@ * */ public BoundingBox() { - addNamespace(LayoutConstant.namespaceURI); + addNamespace(LayoutConstants.namespaceURI); } /** @@ -248,7 +248,7 @@ if (isSetId()) { attributes.remove("id"); - attributes.put(LayoutConstant.shortLabel + ":id", getId()); + attributes.put(LayoutConstants.shortLabel + ":id", getId()); } if (isSetName()) { // Problem !!! no name defined officially Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/CompartmentGlyph.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/CompartmentGlyph.java 2012-06-10 06:46:51 UTC (rev 1295) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/CompartmentGlyph.java 2012-06-10 07:01:58 UTC (rev 1296) @@ -121,7 +121,7 @@ if (!isAttributeRead) { - if (attributeName.equals(LayoutConstant.compartment)) { + if (attributeName.equals(LayoutConstants.compartment)) { setCompartment(value); } else { return false; @@ -164,8 +164,8 @@ Map<String, String> attributes = super.writeXMLAttributes(); if (isSetCompartment()) { - attributes.put(LayoutConstant.shortLabel + ":" - + LayoutConstant.compartment, getCompartment()); + attributes.put(LayoutConstants.shortLabel + ":" + + LayoutConstants.compartment, getCompartment()); } return attributes; Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Curve.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Curve.java 2012-06-10 06:46:51 UTC (rev 1295) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Curve.java 2012-06-10 07:01:58 UTC (rev 1296) @@ -61,9 +61,9 @@ */ public Curve() { super(); - addNamespace(LayoutConstant.namespaceURI); + addNamespace(LayoutConstants.namespaceURI); - listOfCurveSegments.addNamespace(LayoutConstant.namespaceURI); + listOfCurveSegments.addNamespace(LayoutConstants.namespaceURI); listOfCurveSegments.setSBaseListType(ListOf.Type.other); registerChild(listOfCurveSegments); } Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/CurveSegment.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/CurveSegment.java 2012-06-10 06:46:51 UTC (rev 1295) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/CurveSegment.java 2012-06-10 07:01:58 UTC (rev 1296) @@ -51,7 +51,7 @@ */ public CurveSegment() { super(); - addNamespace(LayoutConstant.namespaceURI); + addNamespace(LayoutConstants.namespaceURI); } /** Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Dimensions.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Dimensions.java 2012-06-10 06:46:51 UTC (rev 1295) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Dimensions.java 2012-06-10 07:01:58 UTC (rev 1296) @@ -54,7 +54,7 @@ * */ public Dimensions() { - addNamespace(LayoutConstant.namespaceURI); + addNamespace(LayoutConstants.namespaceURI); } /** @@ -96,7 +96,7 @@ */ public Dimensions(int level, int version) { super(level, version); - addNamespace(LayoutConstant.namespaceURI); + addNamespace(LayoutConstants.namespaceURI); } /** @@ -107,7 +107,7 @@ */ public Dimensions(String id, int level, int version) { super(id, level, version); - addNamespace(LayoutConstant.namespaceURI); + addNamespace(LayoutConstants.namespaceURI); } /* (non-Javadoc) @@ -221,15 +221,15 @@ { //isAttributeRead = true; - if(attributeName.equals(LayoutConstant.width)) + if(attributeName.equals(LayoutConstants.width)) { setWidth(StringTools.parseSBMLDouble(value)); } - else if(attributeName.equals(LayoutConstant.height)) + else if(attributeName.equals(LayoutConstants.height)) { setHeight(StringTools.parseSBMLDouble(value)); } - else if(attributeName.equals(LayoutConstant.depth)) + else if(attributeName.equals(LayoutConstants.depth)) { setDepth(StringTools.parseSBMLDouble(value)); } @@ -251,7 +251,7 @@ public void setDepth(double depth) { Double oldDepth = this.depth; this.depth = depth; - firePropertyChange(LayoutConstant.depth, oldDepth, this.depth); + firePropertyChange(LayoutConstants.depth, oldDepth, this.depth); } /** @@ -261,7 +261,7 @@ public void setHeight(double height) { Double oldHeight = this.height; this.height = height; - firePropertyChange(LayoutConstant.height, oldHeight, this.height); + firePropertyChange(LayoutConstants.height, oldHeight, this.height); } /** @@ -271,7 +271,7 @@ public void setWidth(double width) { Double oldWidth = this.width; this.width = width; - firePropertyChange(LayoutConstant.width, oldWidth, this.width); + firePropertyChange(LayoutConstants.width, oldWidth, this.width); } /* (non-Javadoc) @@ -283,20 +283,20 @@ if (isSetId()) { attributes.remove("id"); - attributes.put(LayoutConstant.shortLabel + ":id", getId()); + attributes.put(LayoutConstants.shortLabel + ":id", getId()); } if (isSetDepth()) { - attributes.put(LayoutConstant.shortLabel + ":" - + LayoutConstant.depth, StringTools.toString(depth)); + attributes.put(LayoutConstants.shortLabel + ":" + + LayoutConstants.depth, StringTools.toString(depth)); } if (isSetHeight()) { - attributes.put(LayoutConstant.shortLabel + ":" - + LayoutConstant.height, StringTools.toString(height)); + attributes.put(LayoutConstants.shortLabel + ":" + + LayoutConstants.height, StringTools.toString(height)); } if (isSetWidth()) { - attributes.put(LayoutConstant.shortLabel + ":" - + LayoutConstant.width, StringTools.toString(width)); + attributes.put(LayoutConstants.shortLabel + ":" + + LayoutConstants.width, StringTools.toString(width)); } return attributes; Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/ExtendedLayoutModel.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/ExtendedLayoutModel.java 2012-06-10 06:46:51 UTC (rev 1295) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/ExtendedLayoutModel.java 2012-06-10 07:01:58 UTC (rev 1296) @@ -124,7 +124,7 @@ */ private void createListOfLayout() { listOfLayouts = new ListOf<Layout>(); - listOfLayouts.addNamespace(LayoutConstant.namespaceURI); + listOfLayouts.addNamespace(LayoutConstants.namespaceURI); listOfLayouts.setSBaseListType(ListOf.Type.other); model.registerChild(listOfLayouts); } Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/GraphicalObject.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/GraphicalObject.java 2012-06-10 06:46:51 UTC (rev 1295) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/GraphicalObject.java 2012-06-10 07:01:58 UTC (rev 1296) @@ -51,7 +51,7 @@ */ public GraphicalObject() { super(); - addNamespace(LayoutConstant.namespaceURI); + addNamespace(LayoutConstants.namespaceURI); } /** @@ -70,7 +70,7 @@ */ public GraphicalObject(int level, int version) { super(level, version); - addNamespace(LayoutConstant.namespaceURI); + addNamespace(LayoutConstants.namespaceURI); } /** @@ -78,7 +78,7 @@ */ public GraphicalObject(String id) { super(id); - addNamespace(LayoutConstant.namespaceURI); + addNamespace(LayoutConstants.namespaceURI); } /** @@ -89,7 +89,7 @@ */ public GraphicalObject(String id, int level, int version) { super(id, level, version); - addNamespace(LayoutConstant.namespaceURI); + addNamespace(LayoutConstants.namespaceURI); } /* (non-Javadoc) @@ -250,7 +250,7 @@ if (isSetId()) { attributes.remove("id"); - attributes.put(LayoutConstant.shortLabel + ":id", getId()); + attributes.put(LayoutConstants.shortLabel + ":id", getId()); } return attributes; Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Layout.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Layout.java 2012-06-10 06:46:51 UTC (rev 1295) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Layout.java 2012-06-10 07:01:58 UTC (rev 1296) @@ -600,7 +600,7 @@ public ListOf<GraphicalObject> getListOfAdditionalGraphicalObjects() { if (!isSetListOfAdditionalGraphicalObjects()) { listOfAdditionalGraphicalObjects = ListOf.newInstance(this, GraphicalObject.class); - listOfAdditionalGraphicalObjects.addNamespace(LayoutConstant.namespaceURI); + listOfAdditionalGraphicalObjects.addNamespace(LayoutConstants.namespaceURI); } return listOfAdditionalGraphicalObjects; } @@ -612,7 +612,7 @@ public ListOf<CompartmentGlyph> getListOfCompartmentGlyphs() { if (!isSetListOfCompartmentGlyphs()) { listOfCompartmentGlyphs = ListOf.newInstance(this, CompartmentGlyph.class); - listOfCompartmentGlyphs.addNamespace(LayoutConstant.namespaceURI); + listOfCompartmentGlyphs.addNamespace(LayoutConstants.namespaceURI); } return listOfCompartmentGlyphs; } @@ -625,7 +625,7 @@ public ListOf<ReactionGlyph> getListOfReactionGlyphs() { if (!isSetListOfReactionGlyphs()) { listOfReactionGlyphs = ListOf.newInstance(this, ReactionGlyph.class); - listOfReactionGlyphs.addNamespace(LayoutConstant.namespaceURI); + listOfReactionGlyphs.addNamespace(LayoutConstants.namespaceURI); } return listOfReactionGlyphs; } @@ -637,7 +637,7 @@ public ListOf<SpeciesGlyph> getListOfSpeciesGlyphs() { if (!isSetListOfSpeciesGlyphs()) { listOfSpeciesGlyphs = ListOf.newInstance(this, SpeciesGlyph.class); - listOfSpeciesGlyphs.addNamespace(LayoutConstant.namespaceURI); + listOfSpeciesGlyphs.addNamespace(LayoutConstants.namespaceURI); } return listOfSpeciesGlyphs; } @@ -649,7 +649,7 @@ public ListOf<TextGlyph> getListOfTextGlyphs() { if (!isSetListOfTextGlyphs()) { listOfTextGlyphs = ListOf.newInstance(this, TextGlyph.class); - listOfTextGlyphs.addNamespace(LayoutConstant.namespaceURI); + listOfTextGlyphs.addNamespace(LayoutConstants.namespaceURI); } return listOfTextGlyphs; } @@ -721,7 +721,7 @@ * */ private void initDefault() { - addNamespace(LayoutConstant.namespaceURI); + addNamespace(LayoutConstants.namespaceURI); } /* (non-Javadoc) Deleted: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/LayoutConstant.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/LayoutConstant.java 2012-06-10 06:46:51 UTC (rev 1295) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/LayoutConstant.java 2012-06-10 07:01:58 UTC (rev 1296) @@ -1,87 +0,0 @@ -/* - * $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-2012 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 - * - * 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.layout; - -public class LayoutConstant { - - /** - * The namespace URI of this parser. - */ - public static final String namespaceURI = "http://www.sbml.org/sbml/level3/version1/layout/version1"; - public static final String namespaceURI_L2 = "http://projects.eml.org/bcb/sbml/level2"; - - public static final String shortLabel = "layout"; - - public static final String listOfLayouts = "listOfLayouts"; - public static final String listOfCompartmentGlyphs = "listOfCompartmentGlyphs"; - public static final String listOfSpeciesGlyphs = "listOfSpeciesGlyphs"; - public static final String listOfReactionGlyphs = "listOfReactionGlyphs"; - public static final String listOfTextGlyphs = "listOfTextGlyphs"; - public static final String listOfAdditionalGraphicalObjects = "listOfAdditionalGraphicalObjects"; - public static final String listOfCurveSegments = "listOfCurveSegments"; - public static final String listOfSpeciesReferenceGlyphs = "listOfSpeciesReferenceGlyphs"; - - public static final String layout = "layout"; - public static final String compartmentGlyph = "compartmentGlyph"; - public static final String speciesGlyph = "speciesGlyph"; - public static final String reactionGlyph = "reactionGlyph"; - public static final String textGlyph = "textGlyph"; - public static final String speciesReferenceGlyph = "speciesReferenceGlyph"; - public static final String boundingBox = "boundingBox"; - public static final String position = "position"; - public static final String dimensions = "dimensions"; - public static final String start = "start"; - public static final String end = "end"; - public static final String curve = "curve"; - public static final String curveSegment = "curveSegment"; - - // Attribute names of the Point XML type - public static final String x = "x"; - public static final String y = "y"; - public static final String z = "z"; - - // Attribute names of the Dimensions XML type - public static final String depth = "depth"; - public static final String width = "width"; - public static final String height = "height"; - - // Attribute names of the CompartmentGlyph XML type - public static final String compartment = "compartment"; - - // Attribute names of the speciesGlyph XML type - public static final String species = "species"; - - // Attribute names of the textGlyph XML type - public static final String graphicalObject = "graphicalObject"; - public static final String text = "text"; - public static final String originOfText = "originOfText"; - - // Attribute names of the speciesReferenceGlyph XML type - public static final String speciesReference = "speciesReference"; - public static final String role = "role"; - - - public static final String basePoint1 = "basePoint1"; - public static final String basePoint2 = "basePoint2"; - public static final String reaction = "reaction"; - - - -} Copied: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/LayoutConstants.java (from rev 1293, trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/LayoutConstant.java) =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/LayoutConstants.java (rev 0) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/LayoutConstants.java 2012-06-10 07:01:58 UTC (rev 1296) @@ -0,0 +1,91 @@ +/* + * $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-2012 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 + * + * 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.layout; + +/** + * + * @author + * @version $Rev$ + * @since 1.0 + */ +public class LayoutConstants { + + /** + * The namespace URI of this parser. + */ + public static final String namespaceURI = "http://www.sbml.org/sbml/level3/version1/layout/version1"; + public static final String namespaceURI_L2 = "http://projects.eml.org/bcb/sbml/level2"; + + public static final String shortLabel = "layout"; + + public static final String listOfLayouts = "listOfLayouts"; + public static final String listOfCompartmentGlyphs = "listOfCompartmentGlyphs"; + public static final String listOfSpeciesGlyphs = "listOfSpeciesGlyphs"; + public static final String listOfReactionGlyphs = "listOfReactionGlyphs"; + public static final String listOfTextGlyphs = "listOfTextGlyphs"; + public static final String listOfAdditionalGraphicalObjects = "listOfAdditionalGraphicalObjects"; + public static final String listOfCurveSegments = "listOfCurveSegments"; + public static final String listOfSpeciesReferenceGlyphs = "listOfSpeciesReferenceGlyphs"; + + public static final String layout = "layout"; + public static final String compartmentGlyph = "compartmentGlyph"; + public static final String speciesGlyph = "speciesGlyph"; + public static final String reactionGlyph = "reactionGlyph"; + public static final String textGlyph = "textGlyph"; + public static final String speciesReferenceGlyph = "speciesReferenceGlyph"; + public static final String boundingBox = "boundingBox"; + public static final String position = "position"; + public static final String dimensions = "dimensions"; + public static final String start = "start"; + public static final String end = "end"; + public static final String curve = "curve"; + public static final String curveSegment = "curveSegment"; + + // Attribute names of the Point XML type + public static final String x = "x"; + public static final String y = "y"; + public static final String z = "z"; + + // Attribute names of the Dimensions XML type + public static final String depth = "depth"; + public static final String width = "width"; + public static final String height = "height"; + + // Attribute names of the CompartmentGlyph XML type + public static final String compartment = "compartment"; + + // Attribute names of the speciesGlyph XML type + public static final String species = "species"; + + // Attribute names of the textGlyph XML type + public static final String graphicalObject = "graphicalObject"; + public static final String text = "text"; + public static final String originOfText = "originOfText"; + + // Attribute names of the speciesReferenceGlyph XML type + public static final String speciesReference = "speciesReference"; + public static final String role = "role"; + + + public static final String basePoint1 = "basePoint1"; + public static final String basePoint2 = "basePoint2"; + public static final String reaction = "reaction"; + +} Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/NamedSBaseGlyph.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/NamedSBaseGlyph.java 2012-06-10 06:46:51 UTC (rev 1295) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/NamedSBaseGlyph.java 2012-06-10 07:01:58 UTC (rev 1296) @@ -184,7 +184,7 @@ * */ public void unsetNamedSBase() { - setNamedSBase(null); + setNamedSBase((String) null); } } Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Point.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Point.java 2012-06-10 06:46:51 UTC (rev 1295) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Point.java 2012-06-10 07:01:58 UTC (rev 1296) @@ -57,7 +57,7 @@ */ public Point() { super(); - addNamespace(LayoutConstant.namespaceURI); + addNamespace(LayoutConstants.namespaceURI); x = y = z = Double.NaN; } @@ -96,7 +96,7 @@ */ public Point(int level, int version) { super(level, version); - addNamespace(LayoutConstant.namespaceURI); + addNamespace(LayoutConstants.namespaceURI); x = y = z = Double.NaN; } @@ -235,14 +235,14 @@ isAttributeRead = true; - if (attributeName.equals(LayoutConstant.x)) { + if (attributeName.equals(LayoutConstants.x)) { setX(StringTools.parseSBMLDouble(value)); } - else if(attributeName.equals(LayoutConstant.y)) + else if(attributeName.equals(LayoutConstants.y)) { setY(StringTools.parseSBMLDouble(value)); } - else if(attributeName.equals(LayoutConstant.z)) + else if(attributeName.equals(LayoutConstants.z)) { setZ(StringTools.parseSBMLDouble(value)); } @@ -261,7 +261,7 @@ public void setX(double x) { Double oldX = this.x; this.x = x; - firePropertyChange(LayoutConstant.x, oldX, this.x); + firePropertyChange(LayoutConstants.x, oldX, this.x); } /** @@ -271,7 +271,7 @@ public void setY(double y) { Double oldY = this.y; this.y = y; - firePropertyChange(LayoutConstant.y, oldY, this.y); + firePropertyChange(LayoutConstants.y, oldY, this.y); } /** @@ -281,7 +281,7 @@ public void setZ(double z) { Double oldZ = this.z; this.z = z; - firePropertyChange(LayoutConstant.z, oldZ, this.z); + firePropertyChange(LayoutConstants.z, oldZ, this.z); } /* (non-Javadoc) @@ -301,20 +301,20 @@ if (isSetId()) { attributes.remove("id"); - attributes.put(LayoutConstant.shortLabel + ":id", getId()); + attributes.put(LayoutConstants.shortLabel + ":id", getId()); } if (isSetX()) { - attributes.put(LayoutConstant.shortLabel + ":" - + LayoutConstant.x, StringTools.toString(Locale.ENGLISH, x)); + attributes.put(LayoutConstants.shortLabel + ":" + + LayoutConstants.x, StringTools.toString(Locale.ENGLISH, x)); } if (isSetY()) { - attributes.put(LayoutConstant.shortLabel + ":" - + LayoutConstant.y, StringTools.toString(Locale.ENGLISH, y)); + attributes.put(LayoutConstants.shortLabel + ":" + + LayoutConstants.y, StringTools.toString(Locale.ENGLISH, y)); } if (isSetZ()) { - attributes.put(LayoutConstant.shortLabel + ":" - + LayoutConstant.z, StringTools.toString(Locale.ENGLISH, z)); + attributes.put(LayoutConstants.shortLabel + ":" + + LayoutConstants.z, StringTools.toString(Locale.ENGLISH, z)); } return attributes; Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/ReactionGlyph.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/ReactionGlyph.java 2012-06-10 06:46:51 UTC (rev 1295) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/ReactionGlyph.java 2012-06-10 07:01:58 UTC (rev 1296) @@ -56,7 +56,7 @@ */ public ReactionGlyph() { super(); - addNamespace(LayoutConstant.namespaceURI); + addNamespace(LayoutConstants.namespaceURI); } /** @@ -198,7 +198,7 @@ public ListOf<SpeciesReferenceGlyph> getListOfSpeciesReferenceGlyphs() { if (!isSetListOfSpeciesReferencesGlyph()) { listOfSpeciesReferencesGlyph = new ListOf<SpeciesReferenceGlyph>(); - listOfSpeciesReferencesGlyph.addNamespace(LayoutConstant.namespaceURI); + listOfSpeciesReferencesGlyph.addNamespace(LayoutConstants.namespaceURI); listOfSpeciesReferencesGlyph.setSBaseListType(ListOf.Type.other); registerChild(listOfSpeciesReferencesGlyph); } @@ -302,7 +302,7 @@ * @param reaction */ public void setReaction(String reaction) { - setNamedSBase(reaction, LayoutConstant.reaction); + setNamedSBase(reaction, LayoutConstants.reaction); } /** @@ -331,8 +331,8 @@ Map<String, String> attributes = super.writeXMLAttributes(); if (isSetReaction()) { - attributes.put(LayoutConstant.shortLabel + ":" - + LayoutConstant.reaction, getReaction()); + attributes.put(LayoutConstants.shortLabel + ":" + + LayoutConstants.reaction, getReaction()); } return attributes; Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesGlyph.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesGlyph.java 2012-06-10 06:46:51 UTC (rev 1295) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesGlyph.java 2012-06-10 07:01:58 UTC (rev 1296) @@ -165,10 +165,10 @@ if (isSetId()) { attributes.remove("id"); - attributes.put(LayoutConstant.shortLabel + ":id", getId()); + attributes.put(LayoutConstants.shortLabel + ":id", getId()); } if (isSetSpecies()) { - attributes.put(LayoutConstant.shortLabel + ":species", getSpecies()); + attributes.put(LayoutConstants.shortLabel + ":species", getSpecies()); } return attributes; Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesReferenceGlyph.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesReferenceGlyph.java 2012-06-10 06:46:51 UTC (rev 1295) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesReferenceGlyph.java 2012-06-10 07:01:58 UTC (rev 1296) @@ -267,21 +267,21 @@ isAttributeRead = true; - if(attributeName.equals(LayoutConstant.speciesReference)) + if(attributeName.equals(LayoutConstants.speciesReference)) { setSpeciesReference(value); } - else if(attributeName.equals(LayoutConstant.speciesGlyph)) + else if(attributeName.equals(LayoutConstants.speciesGlyph)) { setSpeciesGlyph(value); } - else if(attributeName.equals(LayoutConstant.role)) + else if(attributeName.equals(LayoutConstants.role)) { try { setRole(SpeciesReferenceRole.valueOf(value.toUpperCase())); } catch (Exception e) { throw new SBMLException("Could not recognized the value '" + value - + "' for the attribute " + LayoutConstant.role + + "' for the attribute " + LayoutConstants.role + " on the 'SpeciesReferenceGlyph' element."); } } @@ -301,7 +301,7 @@ public void setCurve(Curve curve) { Curve oldCurve = this.curve; this.curve = curve; - firePropertyChange(LayoutConstant.curve, oldCurve, this.role); + firePropertyChange(LayoutConstants.curve, oldCurve, this.role); registerChild(this.curve); } @@ -312,7 +312,7 @@ public void setRole(SpeciesReferenceRole valueOf) { SpeciesReferenceRole oldRole = this.role; this.role = valueOf; - firePropertyChange(LayoutConstant.role, oldRole, this.role); + firePropertyChange(LayoutConstants.role, oldRole, this.role); } /** @@ -322,7 +322,7 @@ public void setSpeciesGlyph(String speciesGlyph) { String oldValue = this.speciesGlyph; this.speciesGlyph = speciesGlyph; - firePropertyChange(LayoutConstant.speciesGlyph, oldValue, this.speciesGlyph); + firePropertyChange(LayoutConstants.speciesGlyph, oldValue, this.speciesGlyph); } /** @@ -338,7 +338,7 @@ * @param speciesReference */ public void setSpeciesReference(String speciesReference) { - setNamedSBase(speciesReference, LayoutConstant.speciesReference); + setNamedSBase(speciesReference, LayoutConstants.speciesReference); } /** @@ -356,16 +356,16 @@ Map<String, String> attributes = super.writeXMLAttributes(); if (isSetSpeciesGlyph()) { - attributes.put(LayoutConstant.shortLabel + ":" - + LayoutConstant.speciesGlyph, speciesGlyph); + attributes.put(LayoutConstants.shortLabel + ":" + + LayoutConstants.speciesGlyph, speciesGlyph); } if (isSetSpeciesReference()) { - attributes.put(LayoutConstant.shortLabel + ":" - + LayoutConstant.speciesReference, getSpeciesReference()); + attributes.put(LayoutConstants.shortLabel + ":" + + LayoutConstants.speciesReference, getSpeciesReference()); } if (isSetSpeciesReferenceRole()) { - attributes.put(LayoutConstant.shortLabel + ":" - + LayoutConstant.role, role.toString().toLowerCase()); + attributes.put(LayoutConstants.shortLabel + ":" + + LayoutConstants.role, role.toString().toLowerCase()); } return attributes; Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/TextGlyph.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/TextGlyph.java 2012-06-10 06:46:51 UTC (rev 1295) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/TextGlyph.java 2012-06-10 07:01:58 UTC (rev 1296) @@ -54,7 +54,7 @@ */ public TextGlyph() { super(); - addNamespace(LayoutConstant.namespaceURI); + addNamespace(LayoutConstants.namespaceURI); } /** @@ -64,7 +64,7 @@ */ public TextGlyph(int level, int version) { super(level, version); - addNamespace(LayoutConstant.namespaceURI); + addNamespace(LayoutConstants.namespaceURI); } /** @@ -73,7 +73,7 @@ */ public TextGlyph(String id) { super(id); - addNamespace(LayoutConstant.namespaceURI); + addNamespace(LayoutConstants.namespaceURI); } /** @@ -84,7 +84,7 @@ */ public TextGlyph(String id, int level, int version) { super(id, level, version); - addNamespace(LayoutConstant.namespaceURI); + addNamespace(LayoutConstants.namespaceURI); } /** @@ -210,15 +210,15 @@ if(!isAttributeRead) { - if(attributeName.equals(LayoutConstant.graphicalObject)) + if(attributeName.equals(LayoutConstants.graphicalObject)) { setGraphicalObject(value); } - else if(attributeName.equals(LayoutConstant.text)) + else if(attributeName.equals(LayoutConstants.text)) { setText(value); } - else if(attributeName.equals(LayoutConstant.originOfText)) + else if(attributeName.equals(LayoutConstants.originOfText)) { setOriginOfText(value); } @@ -240,7 +240,7 @@ public void setGraphicalObject(String graphicalObject) { String oldValue = this.graphicalObject; this.graphicalObject = graphicalObject; - firePropertyChange(LayoutConstant.graphicalObject, oldValue, this.graphicalObject); + firePropertyChange(LayoutConstants.graphicalObject, oldValue, this.graphicalObject); } /** @@ -266,7 +266,7 @@ public void setText(String text) { String oldText = this.text; this.text = text; - firePropertyChange(LayoutConstant.text, oldText, this.text); + firePropertyChange(LayoutConstants.text, oldText, this.text); } /* (non-Javadoc) @@ -277,16 +277,16 @@ Map<String, String> attributes = super.writeXMLAttributes(); if (isSetGraphicalObject()) { - attributes.put(LayoutConstant.shortLabel + ":" - + LayoutConstant.graphicalObject, graphicalObject); + attributes.put(LayoutConstants.shortLabel + ":" + + LayoutConstants.graphicalObject, graphicalObject); } if (isSetText()) { - attributes.put(LayoutConstant.shortLabel + ":" - + LayoutConstant.text, text); + attributes.put(LayoutConstants.shortLabel + ":" + + LayoutConstants.text, text); } if (isSetOriginOfText()) { - attributes.put(LayoutConstant.shortLabel + ":" - + LayoutConstant.originOfText, getOriginOfText()); + attributes.put(LayoutConstants.shortLabel + ":" + + LayoutConstants.originOfText, getOriginOfText()); } return attributes; Modified: trunk/extensions/layout/src/org/sbml/jsbml/xml/parsers/L3LayoutParser.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/xml/parsers/L3LayoutParser.java 2012-06-10 06:46:51 UTC (rev 1295) +++ trunk/extensions/layout/src/org/sbml/jsbml/xml/parsers/L3LayoutParser.java 2012-06-10 07:01:58 UTC (rev 1296) @@ -19,30 +19,30 @@ */ package org.sbml.jsbml.xml.parsers; -import static org.sbml.jsbml.ext.layout.LayoutConstant.basePoint1; -import static org.sbml.jsbml.ext.layout.LayoutConstant.basePoint2; -import static org.sbml.jsbml.ext.layout.LayoutConstant.boundingBox; -import static org.sbml.jsbml.ext.layout.LayoutConstant.compartmentGlyph; -import static org.sbml.jsbml.ext.layout.LayoutConstant.curve; -import static org.sbml.jsbml.ext.layout.LayoutConstant.curveSegment; -import static org.sbml.jsbml.ext.layout.LayoutConstant.dimensions; -import static org.sbml.jsbml.ext.layout.LayoutConstant.end; -import static org.sbml.jsbml.ext.layout.LayoutConstant.layout; -import static org.sbml.jsbml.ext.layout.LayoutConstant.listOfAdditionalGraphicalObjects; -import static org.sbml.jsbml.ext.layout.LayoutConstant.listOfCompartmentGlyphs; -import static org.sbml.jsbml.ext.layout.LayoutConstant.listOfCurveSegments; -import static org.sbml.jsbml.ext.layout.LayoutConstant.listOfLayouts; -import static org.sbml.jsbml.ext.layout.LayoutConstant.listOfReactionGlyphs; -import static org.sbml.jsbml.ext.layout.LayoutConstant.listOfSpeciesGlyphs; -import static org.sbml.jsbml.ext.layout.LayoutConstant.listOfSpeciesReferenceGlyphs; -import static org.sbml.jsbml.ext.layout.LayoutConstant.listOfTextGlyphs; -import static org.sbml.jsbml.ext.layout.LayoutConstant.namespaceURI; -import static org.sbml.jsbml.ext.layout.LayoutConstant.position; -import static org.sbml.jsbml.ext.layout.LayoutConstant.reactionGlyph; -import static org.sbml.jsbml.ext.layout.LayoutConstant.speciesGlyph; -import static org.sbml.jsbml.ext.layout.LayoutConstant.speciesReferenceGlyph; -import static org.sbml.jsbml.ext.layout.LayoutConstant.start; -import static org.sbml.jsbml.ext.layout.LayoutConstant.textGlyph; +import static org.sbml.jsbml.ext.layout.LayoutConstants.basePoint1; +import static org.sbml.jsbml.ext.layout.LayoutConstants.basePoint2; +import static org.sbml.jsbml.ext.layout.LayoutConstants.boundingBox; +import static org.sbml.jsbml.ext.layout.LayoutConstants.compartmentGlyph; +import static org.sbml.jsbml.ext.layout.LayoutConstants.curve; +import static org.sbml.jsbml.ext.layout.LayoutConstants.curveSegment; +import static org.sbml.jsbml.ext.layout.LayoutConstants.dimensions; +import static org.sbml.jsbml.ext.layout.LayoutConstants.end; +import static org.sbml.jsbml.ext.layout.LayoutConstants.layout; +import static org.sbml.jsbml.ext.layout.LayoutConstants.listOfAdditionalGraphicalObjects; +import static org.sbml.jsbml.ext.layout.LayoutConstants.listOfCompartmentGlyphs; +import static org.sbml.jsbml.ext.layout.LayoutConstants.listOfCurveSegments; +import static org.sbml.jsbml.ext.layout.LayoutConstants.listOfLayouts; +import static org.sbml.jsbml.ext.layout.LayoutConstants.listOfReactionGlyphs; +import static org.sbml.jsbml.ext.layout.LayoutConstants.listOfSpeciesGlyphs; +import static org.sbml.jsbml.ext.layout.LayoutConstants.listOfSpeciesReferenceGlyphs; +import static org.sbml.jsbml.ext.layout.LayoutConstants.listOfTextGlyphs; +import static org.sbml.jsbml.ext.layout.LayoutConstants.namespaceURI; +import static org.sbml.jsbml.ext.layout.LayoutConstants.position; +import static org.sbml.jsbml.ext.layout.LayoutConstants.reactionGlyph; +import static org.sbml.jsbml.ext.layout.LayoutConstants.speciesGlyph; +import static org.sbml.jsbml.ext.layout.LayoutConstants.speciesReferenceGlyph; +import static org.sbml.jsbml.ext.layout.LayoutConstants.start; +import static org.sbml.jsbml.ext.layout.LayoutConstants.textGlyph; import java.util.ArrayList; @@ -62,7 +62,7 @@ import org.sbml.jsbml.ext.layout.ExtendedLayoutModel; import org.sbml.jsbml.ext.layout.GraphicalObject; import org.sbml.jsbml.ext.layout.Layout; -import org.sbml.jsbml.ext.layout.LayoutConstant; +import org.sbml.jsbml.ext.layout.LayoutConstants; import org.sbml.jsbml.ext.layout.Position; import org.sbml.jsbml.ext.layout.ReactionGlyph; import org.sbml.jsbml.ext.layout.SpeciesGlyph; @@ -90,11 +90,11 @@ * @return the namespaceURI of this parser. */ public String getNamespaceURI() { - return LayoutConstant.namespaceURI; + return LayoutConstants.namespaceURI; } public String getShortLabel() { - return LayoutConstant.shortLabel; + return LayoutConstants.shortLabel; } private Logger logger = Logger.getLogger(L3LayoutParser.class); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2012-06-10 06:46:57
|
Revision: 1295 http://jsbml.svn.sourceforge.net/jsbml/?rev=1295&view=rev Author: andreas-draeger Date: 2012-06-10 06:46:51 +0000 (Sun, 10 Jun 2012) Log Message: ----------- Corrected a typo within an error message. Modified Paths: -------------- branches/jsbml-0.8/src/org/sbml/jsbml/Model.java Modified: branches/jsbml-0.8/src/org/sbml/jsbml/Model.java =================================================================== --- branches/jsbml-0.8/src/org/sbml/jsbml/Model.java 2012-06-10 06:46:32 UTC (rev 1294) +++ branches/jsbml-0.8/src/org/sbml/jsbml/Model.java 2012-06-10 06:46:51 UTC (rev 1295) @@ -3483,7 +3483,7 @@ } else { // in L3 packages we might have different id namespaces logger.error("registerIds : the object " + newNsb.getClass().getCanonicalName() + " is neither " + - "a UniqueNamedSBase, a LocalParameter or a UnitDefinition so it's id will not be registered in the Model."); + "a UniqueNamedSBase, a LocalParameter or a UnitDefinition so its id will not be registered in the Model."); } } else if (!newNsb.isIdMandatory()) { // do nothing This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2012-06-10 06:46:39
|
Revision: 1294 http://jsbml.svn.sourceforge.net/jsbml/?rev=1294&view=rev Author: andreas-draeger Date: 2012-06-10 06:46:32 +0000 (Sun, 10 Jun 2012) Log Message: ----------- TextGlyph has now also become an instance of NamedSBaseGlyph. The methods returning an instance of core elements, e.g., getSpeciesInstance() in all derivatives of NamedSBaseGlyph have been removed because it is possible to let ids point to NamedSBases from other packages. Many classes that extend AbstractNamedSBase now have also become UniqueNamedSBase in order to better support their registration in the model. Modified Paths: -------------- trunk/core/src/org/sbml/jsbml/Model.java trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/CompartmentGlyph.java trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Layout.java trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/NamedSBaseGlyph.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/extensions/layout/src/org/sbml/jsbml/ext/layout/TextGlyph.java trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/ReactionRule.java trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/SpeciesTypeInstance.java trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/SpeciesTypeRestriction.java trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/SpeciesTypeState.java trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/StateFeature.java trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/StateFeatureInstance.java trunk/extensions/qual/src/org/sbml/jsbml/ext/qual/QualitativeSpecies.java trunk/extensions/qual/src/org/sbml/jsbml/ext/qual/SymbolicValue.java trunk/extensions/render/src/org/sbml/jsbml/ext/render/GradientBase.java trunk/extensions/render/src/org/sbml/jsbml/ext/render/RenderInformationBase.java trunk/extensions/render/src/org/sbml/jsbml/ext/render/Style.java Modified: trunk/core/src/org/sbml/jsbml/Model.java =================================================================== --- trunk/core/src/org/sbml/jsbml/Model.java 2012-06-08 14:48:51 UTC (rev 1293) +++ trunk/core/src/org/sbml/jsbml/Model.java 2012-06-10 06:46:32 UTC (rev 1294) @@ -3929,8 +3929,9 @@ success &= registerId((UnitDefinition) newNsb, !delete); } else { // in L3 packages we might have different id namespaces - logger.error("registerIds : the object " + newNsb.getClass().getCanonicalName() + " is neither " + - "a UniqueNamedSBase, a LocalParameter or a UnitDefinition so it's id will not be registered in the Model."); + logger.error(MessageFormat.format( + "registerIds: the object {0} is neither a UniqueNamedSBase, a LocalParameter or a UnitDefinition so its id will not be registered in the Model.", + newNsb.getClass().getCanonicalName())); } } else if (!newNsb.isIdMandatory()) { // do nothing Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/CompartmentGlyph.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/CompartmentGlyph.java 2012-06-08 14:48:51 UTC (rev 1293) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/CompartmentGlyph.java 2012-06-10 06:46:32 UTC (rev 1294) @@ -95,14 +95,6 @@ return getNamedSBase(); } - /** - * - * @return - */ - public Compartment getCompartmentInstance() { - return getNamedSBaseInstance(); - } - /* (non-Javadoc) * @see org.sbml.jsbml.ext.layout.NamedSBaseGlyph#getNamedSBaseInstance() */ Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Layout.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Layout.java 2012-06-08 14:48:51 UTC (rev 1293) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Layout.java 2012-06-10 06:46:32 UTC (rev 1294) @@ -31,6 +31,7 @@ import org.sbml.jsbml.NamedSBase; import org.sbml.jsbml.Reaction; import org.sbml.jsbml.Species; +import org.sbml.jsbml.UniqueNamedSBase; import org.sbml.jsbml.util.TreeNodeChangeListener; import org.sbml.jsbml.util.filters.NameFilter; @@ -43,7 +44,7 @@ * @since 1.0 * @version $Rev$ */ -public class Layout extends AbstractNamedSBase { +public class Layout extends AbstractNamedSBase implements UniqueNamedSBase { /** * Generated serial version identifier. @@ -58,6 +59,7 @@ /** * */ + // TODO: Why are there methods called addGraphicalObjects and additionalGraphicalObjects? private ListOf<GraphicalObject> listOfAdditionalGraphicalObjects; /** * @@ -157,7 +159,7 @@ public void addAdditionalGraphical(GraphicalObject object) { if (object != null) { registerChild(object); - listOfAdditionalGraphicalObjects.add(object); + getListOfAdditionalGraphicalObjects().add(object); } } @@ -179,7 +181,7 @@ public void addReactionGlyph(ReactionGlyph reactionGlyph) { if (reactionGlyph != null) { registerChild(reactionGlyph); - listOfReactionGlyphs.add(reactionGlyph); + getListOfReactionGlyphs().add(reactionGlyph); } } @@ -190,7 +192,7 @@ public void addSpeciesGlyph(SpeciesGlyph speciesGlyph) { if (speciesGlyph != null) { registerChild(speciesGlyph); - listOfSpeciesGlyphs.add(speciesGlyph); + getListOfSpeciesGlyphs().add(speciesGlyph); } } @@ -201,7 +203,7 @@ public void addTextGlyph(TextGlyph TextGlyph) { if (TextGlyph != null) { registerChild(TextGlyph); - listOfTextGlyphs.add(TextGlyph); + getListOfTextGlyphs().add(TextGlyph); } } @@ -262,15 +264,11 @@ * * @param id * the identifier of the {@link CompartmentGlyph} to be created. - * @param compartment - * {@link Compartment} ID. * @return a new {@link CompartmentGlyph}. + * @see #createCompartmentGlyph(String, String) */ - public CompartmentGlyph createCompartmentGlyph(String id, String compartment) { - CompartmentGlyph glyph = new CompartmentGlyph(id, getLevel(), getVersion()); - glyph.setCompartment(compartment); - addCompartmentGlyph(glyph); - return glyph; + public CompartmentGlyph createCompartmentGlyph(String id) { + return createCompartmentGlyph(id, null); } /** @@ -278,11 +276,15 @@ * * @param id * the identifier of the {@link CompartmentGlyph} to be created. + * @param compartment + * {@link Compartment} ID. * @return a new {@link CompartmentGlyph}. - * @see #createCompartmentGlyph(String, String) */ - public CompartmentGlyph createCompartmentGlyph(String id) { - return createCompartmentGlyph(id, null); + public CompartmentGlyph createCompartmentGlyph(String id, String compartment) { + CompartmentGlyph glyph = new CompartmentGlyph(id, getLevel(), getVersion()); + glyph.setCompartment(compartment); + addCompartmentGlyph(glyph); + return glyph; } /** @@ -325,6 +327,18 @@ * * @param id * the identifier of the {@link ReactionGlyph} to be created. + * @return a new {@link ReactionGlyph}. + * @see #createReactionGlyph(String, String) + */ + public ReactionGlyph createReactionGlyph(String id) { + return createReactionGlyph(id, null); + } + + /** + * Creates and adds a new {@link ReactionGlyph}. + * + * @param id + * the identifier of the {@link ReactionGlyph} to be created. * @param reaction * {@link Reaction} ID. * @return a new {@link ReactionGlyph}. @@ -335,19 +349,19 @@ addReactionGlyph(glyph); return glyph; } - + /** - * Creates and adds a new {@link ReactionGlyph}. + * Creates and adds a new {@link SpeciesGlyph} with the given identifier. * * @param id - * the identifier of the {@link ReactionGlyph} to be created. - * @return a new {@link ReactionGlyph}. - * @see #createReactionGlyph(String, String) + * the identifier for the {@link SpeciesGlyph} to be created. + * @return a new {@link SpeciesGlyph}. + * @see #createSpeciesGlyph(String, String) */ - public ReactionGlyph createReactionGlyph(String id) { - return createReactionGlyph(id, null); + public SpeciesGlyph createSpeciesGlyph(String id) { + return createSpeciesGlyph(id, null); } - + /** * Creates and adds a new {@link SpeciesGlyph}. * @@ -363,19 +377,19 @@ addSpeciesGlyph(glyph); return glyph; } - + /** - * Creates and adds a new {@link SpeciesGlyph} with the given identifier. + * Creates and adds a new {@link TextGlyph}. * * @param id - * the identifier for the {@link SpeciesGlyph} to be created. - * @return a new {@link SpeciesGlyph}. - * @see #createSpeciesGlyph(String, String) + * the identifier for the {@link TextGlyph} to be created. + * @return a new {@link TextGlyph}. + * @see #createTextGlyph(String, String) */ - public SpeciesGlyph createSpeciesGlyph(String id) { - return createSpeciesGlyph(id, null); + public TextGlyph createTextGlyph(String id) { + return createTextGlyph(id, null); } - + /** * Creates and adds a new {@link TextGlyph}. * @@ -393,18 +407,6 @@ } /** - * Creates and adds a new {@link TextGlyph}. - * - * @param id - * the identifier for the {@link TextGlyph} to be created. - * @return a new {@link TextGlyph}. - * @see #createTextGlyph(String, String) - */ - public TextGlyph createTextGlyph(String id) { - return createTextGlyph(id, null); - } - - /** * Searches all instances of {@link CompartmentGlyph} within this {@link Layout} that * refer to the {@link Compartment} with the given id. * @@ -424,14 +426,14 @@ */ @SuppressWarnings("unchecked") private <T> List<T> findGlyphs(ListOf<? extends T> listOfGlyphs, String id) { - if (isSetListOfReactionGlyphs()) { + if (isSetListOfReactionGlyphs() && (listOfGlyphs != null) && (!listOfGlyphs.isEmpty())) { NamedSBaseReferenceFilter filter = new NamedSBaseReferenceFilter(id); filter.setFilterForReference(true); return (List<T>) listOfReactionGlyphs.filter(filter); } 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. @@ -443,7 +445,7 @@ public List<ReactionGlyph> findReactionGlyphs(String reactionID) { return findGlyphs(listOfReactionGlyphs, reactionID); } - + /** * Searches all instances of {@link SpeciesGlyph} within this {@link Layout} that * refer to the {@link Species} with the given id. @@ -455,6 +457,19 @@ public List<SpeciesGlyph> findSpeciesGlyphs(String speciesID) { return findGlyphs(listOfSpeciesGlyphs, speciesID); } + + /** + * Searches within the {@link #listOfTextGlyphs} for {@link TextGlyph}s whose + * {@link TextGlyph#getOriginOfText()} points to the given id. + * + * @param id + * the identifier of the element for which {@link TextGlyph}s are to be + * found. + * @return all {@link TextGlyph}s associated to an element with the given id. + */ + public List<TextGlyph> findTextGlyphs(String id) { + return findGlyphs(listOfTextGlyphs, id); + } /** * @@ -683,7 +698,28 @@ /** * + * @param i + * @return */ + public TextGlyph getTextGlyph(int i) { + return getListOfTextGlyphs().get(i); + } + + /** + * + * @param id + * @return + */ + public TextGlyph getTextGlyph(String id) { + if (isSetListOfTextGlyphs()) { + return listOfTextGlyphs.firstHit(new NameFilter(id)); + } + return null; + } + + /** + * + */ private void initDefault() { addNamespace(LayoutConstant.namespaceURI); } Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/NamedSBaseGlyph.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/NamedSBaseGlyph.java 2012-06-08 14:48:51 UTC (rev 1293) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/NamedSBaseGlyph.java 2012-06-10 06:46:32 UTC (rev 1294) @@ -144,6 +144,14 @@ public boolean isSetNamedSBase() { return (sbaseID != null) && (sbaseID.length() > 0); } + + /** + * + * @param namedSBase + */ + public void setNamedSBase(NamedSBase namedSBase) { + setNamedSBase(namedSBase.getId()); + } /** * Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/ReactionGlyph.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/ReactionGlyph.java 2012-06-08 14:48:51 UTC (rev 1293) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/ReactionGlyph.java 2012-06-10 06:46:32 UTC (rev 1294) @@ -222,16 +222,8 @@ } /** - * * @return */ - public Reaction getReactionInstance() { - return getNamedSBaseInstance(); - } - - /** - * @return - */ public boolean isSetCurve() { return curve != null; } Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesGlyph.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesGlyph.java 2012-06-08 14:48:51 UTC (rev 1293) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesGlyph.java 2012-06-10 06:46:32 UTC (rev 1294) @@ -103,14 +103,6 @@ public String getSpecies() { return getNamedSBase(); } - - /** - * - * @return - */ - 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-06-08 14:48:51 UTC (rev 1293) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesReferenceGlyph.java 2012-06-10 06:46:32 UTC (rev 1294) @@ -204,16 +204,8 @@ } /** - * * @return */ - public SimpleSpeciesReference getSpeciesReferenceInstance() { - return getNamedSBaseInstance(); - } - - /** - * @return - */ public SpeciesReferenceRole getSpeciesReferenceRole() { return role; } Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/TextGlyph.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/TextGlyph.java 2012-06-08 14:48:51 UTC (rev 1293) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/TextGlyph.java 2012-06-10 06:46:32 UTC (rev 1294) @@ -21,8 +21,10 @@ import java.util.Map; +import org.sbml.jsbml.NamedSBase; + /** * @author Nicolas Rodriguez * @author Sebastian Frölich @@ -30,7 +32,7 @@ * @since 1.0 * @version $Rev$ */ -public class TextGlyph extends GraphicalObject { +public class TextGlyph extends NamedSBaseGlyph { /** * Generated serial version identifier. @@ -45,11 +47,6 @@ /** * */ - private String originOfText; - - /** - * - */ private String text; /** @@ -96,12 +93,12 @@ */ public TextGlyph(TextGlyph textGlyph) { super(textGlyph); - - // TODO : use the iSet methods - - this.graphicalObject = new String(textGlyph.getGraphicalObject()); - this.originOfText = new String(textGlyph.getOriginOfText()); - this.text = new String(textGlyph.getText()); + if (textGlyph.isSetGraphicalObject()) { + this.graphicalObject = new String(textGlyph.getGraphicalObject()); + } + if (textGlyph.isSetText()) { + this.text = new String(textGlyph.getText()); + } } /* (non-Javadoc) @@ -149,7 +146,7 @@ * @return */ public String getOriginOfText() { - return originOfText; + return getNamedSBase(); } /** @@ -191,7 +188,7 @@ * @return */ public boolean isSetOriginOfText() { - return originOfText != null; + return isSetNamedSBase(); } /** @@ -250,10 +247,16 @@ * * @param originOfText */ + public void setOriginOfText(NamedSBase originOfText) { + setNamedSBase(originOfText); + } + + /** + * + * @param originOfText + */ public void setOriginOfText(String originOfText) { - String oldOriginOfText = this.originOfText; - this.originOfText = originOfText; - firePropertyChange(LayoutConstant.originOfText, oldOriginOfText, this.originOfText); + setNamedSBase(originOfText); } /** @@ -283,7 +286,7 @@ } if (isSetOriginOfText()) { attributes.put(LayoutConstant.shortLabel + ":" - + LayoutConstant.originOfText, originOfText); + + LayoutConstant.originOfText, getOriginOfText()); } return attributes; Modified: trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/ReactionRule.java =================================================================== --- trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/ReactionRule.java 2012-06-08 14:48:51 UTC (rev 1293) +++ trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/ReactionRule.java 2012-06-10 06:46:32 UTC (rev 1294) @@ -8,7 +8,12 @@ public class ReactionRule extends AbstractNamedSBase { - ListOf<SpeciesTypeRestrictionReference> listOfConditions; + /** + * Generated serial version identifier. + */ + private static final long serialVersionUID = 7757296070294814156L; + + ListOf<SpeciesTypeRestrictionReference> listOfConditions; ListOf<SpeciesTypeRestrictionReference> listOfResults; // TODO : add a kineticLaw @@ -113,10 +118,17 @@ return false; } + /* (non-Javadoc) + * @see org.sbml.jsbml.NamedSBase#isIdMandatory() + */ + //@Override public boolean isIdMandatory() { return false; } + /* (non-Javadoc) + * @see org.sbml.jsbml.AbstractSBase#clone() + */ @Override public AbstractSBase clone() { // TODO Modified: trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/SpeciesTypeInstance.java =================================================================== --- trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/SpeciesTypeInstance.java 2012-06-08 14:48:51 UTC (rev 1293) +++ trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/SpeciesTypeInstance.java 2012-06-10 06:46:32 UTC (rev 1294) @@ -6,7 +6,12 @@ public class SpeciesTypeInstance extends AbstractNamedSBase { - private double initialAmount; + /** + * Generated serial version identifier. + */ + private static final long serialVersionUID = 1775590492963078468L; + + private double initialAmount; private double initialConcentration; Modified: trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/SpeciesTypeRestriction.java =================================================================== --- trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/SpeciesTypeRestriction.java 2012-06-08 14:48:51 UTC (rev 1293) +++ trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/SpeciesTypeRestriction.java 2012-06-10 06:46:32 UTC (rev 1294) @@ -5,7 +5,11 @@ public class SpeciesTypeRestriction extends AbstractNamedSBase { - private String speciesTypeInstance; + /** + * Generated serial version identifier. + */ + private static final long serialVersionUID = -6703552149441215128L; + private String speciesTypeInstance; /** * Returns the speciesTypeInstance. @@ -25,11 +29,17 @@ this.speciesTypeInstance = speciesTypeInstance; } - + /* (non-Javadoc) + * @see org.sbml.jsbml.NamedSBase#isIdMandatory() + */ + //@Override public boolean isIdMandatory() { return false; } + /* (non-Javadoc) + * @see org.sbml.jsbml.AbstractSBase#clone() + */ @Override public AbstractSBase clone() { // TODO Modified: trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/SpeciesTypeState.java =================================================================== --- trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/SpeciesTypeState.java 2012-06-08 14:48:51 UTC (rev 1293) +++ trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/SpeciesTypeState.java 2012-06-10 06:46:32 UTC (rev 1294) @@ -15,6 +15,11 @@ public class SpeciesTypeState extends AbstractNamedSBase implements UniqueNamedSBase { /** + * Generated serial version identifier. + */ + private static final long serialVersionUID = 7110790636241167977L; + + /** * */ private String speciesType; Modified: trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/StateFeature.java =================================================================== --- trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/StateFeature.java 2012-06-08 14:48:51 UTC (rev 1293) +++ trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/StateFeature.java 2012-06-10 06:46:32 UTC (rev 1294) @@ -23,6 +23,10 @@ public class StateFeature extends AbstractNamedSBase implements UniqueNamedSBase { /** + * Generated serial version identifier. + */ + private static final long serialVersionUID = -1796119514784158560L; + /** * */ ListOf<PossibleValue> listOfPossibleValues; Modified: trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/StateFeatureInstance.java =================================================================== --- trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/StateFeatureInstance.java 2012-06-08 14:48:51 UTC (rev 1293) +++ trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/StateFeatureInstance.java 2012-06-10 06:46:32 UTC (rev 1294) @@ -11,7 +11,12 @@ public class StateFeatureInstance extends AbstractNamedSBase { - private String stateFeature; + /** + * Generated serial version identifier. + */ + private static final long serialVersionUID = 3961860838884568696L; + + private String stateFeature; private ListOf<StateFeatureValue> listOfStateFeatureValues; @@ -23,10 +28,17 @@ initDefaults(); } + /* (non-Javadoc) + * @see org.sbml.jsbml.NamedSBase#isIdMandatory() + */ + //@Override public boolean isIdMandatory() { return false; } + /* (non-Javadoc) + * @see org.sbml.jsbml.AbstractSBase#clone() + */ @Override public AbstractSBase clone() { // TODO Modified: trunk/extensions/qual/src/org/sbml/jsbml/ext/qual/QualitativeSpecies.java =================================================================== --- trunk/extensions/qual/src/org/sbml/jsbml/ext/qual/QualitativeSpecies.java 2012-06-08 14:48:51 UTC (rev 1293) +++ trunk/extensions/qual/src/org/sbml/jsbml/ext/qual/QualitativeSpecies.java 2012-06-10 06:46:32 UTC (rev 1294) @@ -40,7 +40,7 @@ * @since 1.0 * @date $Date$ */ -public class QualitativeSpecies extends AbstractNamedSBase implements UniqueNamedSBase{ +public class QualitativeSpecies extends AbstractNamedSBase implements UniqueNamedSBase { /** * Generated serial version identifier. Modified: trunk/extensions/qual/src/org/sbml/jsbml/ext/qual/SymbolicValue.java =================================================================== --- trunk/extensions/qual/src/org/sbml/jsbml/ext/qual/SymbolicValue.java 2012-06-08 14:48:51 UTC (rev 1293) +++ trunk/extensions/qual/src/org/sbml/jsbml/ext/qual/SymbolicValue.java 2012-06-10 06:46:32 UTC (rev 1294) @@ -35,7 +35,7 @@ * @since 1.0 * @date $Date$ */ -public class SymbolicValue extends AbstractNamedSBase implements UniqueNamedSBase{ +public class SymbolicValue extends AbstractNamedSBase implements UniqueNamedSBase { /** * Generated serial version identifier. @@ -210,6 +210,7 @@ /* (non-Javadoc) * @see org.sbml.jsbml.AbstractNamedSBase#readAttribute(java.lang.String, java.lang.String, java.lang.String) */ + @Override public boolean readAttribute(String attributeName, String prefix, String value) { boolean isAttributeRead = super.readAttribute(attributeName, prefix, value); @@ -230,6 +231,7 @@ /* (non-Javadoc) * @see org.sbml.jsbml.AbstractNamedSBase#writeXMLAttributes() */ + @Override public Map<String, String> writeXMLAttributes() { Map<String, String> attributes = super.writeXMLAttributes(); Modified: trunk/extensions/render/src/org/sbml/jsbml/ext/render/GradientBase.java =================================================================== --- trunk/extensions/render/src/org/sbml/jsbml/ext/render/GradientBase.java 2012-06-08 14:48:51 UTC (rev 1293) +++ trunk/extensions/render/src/org/sbml/jsbml/ext/render/GradientBase.java 2012-06-10 06:46:32 UTC (rev 1294) @@ -28,6 +28,7 @@ import org.sbml.jsbml.LevelVersionError; import org.sbml.jsbml.ListOf; import org.sbml.jsbml.SBase; +import org.sbml.jsbml.UniqueNamedSBase; /** @@ -39,7 +40,7 @@ * @since 1.0 * @date 08.05.2012 */ -public class GradientBase extends AbstractNamedSBase { +public class GradientBase extends AbstractNamedSBase implements UniqueNamedSBase { /** * Modified: trunk/extensions/render/src/org/sbml/jsbml/ext/render/RenderInformationBase.java =================================================================== --- trunk/extensions/render/src/org/sbml/jsbml/ext/render/RenderInformationBase.java 2012-06-08 14:48:51 UTC (rev 1293) +++ trunk/extensions/render/src/org/sbml/jsbml/ext/render/RenderInformationBase.java 2012-06-10 06:46:32 UTC (rev 1294) @@ -29,6 +29,7 @@ import org.sbml.jsbml.ListOf; import org.sbml.jsbml.PropertyUndefinedError; import org.sbml.jsbml.SBase; +import org.sbml.jsbml.UniqueNamedSBase; import org.sbml.jsbml.util.filters.NameFilter; /** @@ -40,7 +41,7 @@ * @since 1.0 * @date 04.05.2012 */ -public class RenderInformationBase extends AbstractNamedSBase { +public class RenderInformationBase extends AbstractNamedSBase implements UniqueNamedSBase { /** * Modified: trunk/extensions/render/src/org/sbml/jsbml/ext/render/Style.java =================================================================== --- trunk/extensions/render/src/org/sbml/jsbml/ext/render/Style.java 2012-06-08 14:48:51 UTC (rev 1293) +++ trunk/extensions/render/src/org/sbml/jsbml/ext/render/Style.java 2012-06-10 06:46:32 UTC (rev 1294) @@ -26,6 +26,7 @@ import org.sbml.jsbml.LevelVersionError; import org.sbml.jsbml.PropertyUndefinedError; import org.sbml.jsbml.SBase; +import org.sbml.jsbml.UniqueNamedSBase; /** * @author Eugen Netz @@ -36,7 +37,7 @@ * @since 1.0 * @date 08.05.2012 */ -public class Style extends AbstractNamedSBase { +public class Style extends AbstractNamedSBase implements UniqueNamedSBase { /** * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2012-06-08 14:49:02
|
Revision: 1293 http://jsbml.svn.sourceforge.net/jsbml/?rev=1293&view=rev Author: andreas-draeger Date: 2012-06-08 14:48:51 +0000 (Fri, 08 Jun 2012) Log Message: ----------- Added several missing constructors in layout classes and improved the createXXX methods in Layout to propagate the level and version attribute to the children and to set the id of the new elements. Lists in Layout are now only initialized if needed. In the multi package I changed the return types of the clone methods to directly return an instance of the cloned object. For render, I added missing folders/files. Modified Paths: -------------- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Dimensions.java trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Layout.java trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/TextGlyph.java trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiEventAssignment.java trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiInitialAssignment.java trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiModel.java trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiReaction.java trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiRule.java trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiSpeciesReference.java Added Paths: ----------- trunk/extensions/render/build.xml trunk/extensions/render/doc/ trunk/extensions/render/doc/img/ trunk/extensions/render/lib/ trunk/extensions/render/resources/ trunk/extensions/render/test/ Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Dimensions.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Dimensions.java 2012-06-08 12:36:59 UTC (rev 1292) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Dimensions.java 2012-06-08 14:48:51 UTC (rev 1293) @@ -75,6 +75,21 @@ } /** + * + * @param width + * @param height + * @param depth + * @param level + * @param version + */ + public Dimensions(double width, double height, double depth, int level, int version) { + this(level, version); + this.width = width; + this.height = height; + this.depth = depth; + } + + /** * * @param level * @param version @@ -86,17 +101,13 @@ /** * - * @param width - * @param height - * @param depth + * @param id * @param level * @param version */ - public Dimensions(double width, double height, double depth, int level, int version) { - this(level, version); - this.width = width; - this.height = height; - this.depth = depth; + public Dimensions(String id, int level, int version) { + super(id, level, version); + addNamespace(LayoutConstant.namespaceURI); } /* (non-Javadoc) Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Layout.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Layout.java 2012-06-08 12:36:59 UTC (rev 1292) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Layout.java 2012-06-08 14:48:51 UTC (rev 1293) @@ -58,23 +58,23 @@ /** * */ - private ListOf<GraphicalObject> listOfAdditionalGraphicalObjects = new ListOf<GraphicalObject>(); + private ListOf<GraphicalObject> listOfAdditionalGraphicalObjects; /** * */ - private ListOf<CompartmentGlyph> listOfCompartmentGlyphs = new ListOf<CompartmentGlyph>(); + private ListOf<CompartmentGlyph> listOfCompartmentGlyphs; /** * */ - private ListOf<ReactionGlyph> listOfReactionGlyphs = new ListOf<ReactionGlyph>(); + private ListOf<ReactionGlyph> listOfReactionGlyphs; /** * */ - private ListOf<SpeciesGlyph> listOfSpeciesGlyphs = new ListOf<SpeciesGlyph>(); + private ListOf<SpeciesGlyph> listOfSpeciesGlyphs; /** * */ - private ListOf<TextGlyph> listOfTextGlyphs = new ListOf<TextGlyph>(); + private ListOf<TextGlyph> listOfTextGlyphs; /** * @@ -168,7 +168,7 @@ public void addCompartmentGlyph(CompartmentGlyph compartmentGlyph) { if (compartmentGlyph != null) { registerChild(compartmentGlyph); - listOfCompartmentGlyphs.add(compartmentGlyph); + getListOfCompartmentGlyphs().add(compartmentGlyph); } } @@ -259,70 +259,152 @@ /** * Creates and adds a new {@link CompartmentGlyph}. - * @param compartment {@link Compartment} ID. - * @return new {@link CompartmentGlyph}. + * + * @param id + * the identifier of the {@link CompartmentGlyph} to be created. + * @param compartment + * {@link Compartment} ID. + * @return a new {@link CompartmentGlyph}. */ - public CompartmentGlyph createCompartmentGlyph(String compartment) { - CompartmentGlyph glyph = new CompartmentGlyph(); + public CompartmentGlyph createCompartmentGlyph(String id, String compartment) { + CompartmentGlyph glyph = new CompartmentGlyph(id, getLevel(), getVersion()); glyph.setCompartment(compartment); addCompartmentGlyph(glyph); return glyph; } /** + * Creates and adds a new {@link CompartmentGlyph}. + * + * @param id + * the identifier of the {@link CompartmentGlyph} to be created. + * @return a new {@link CompartmentGlyph}. + * @see #createCompartmentGlyph(String, String) + */ + public CompartmentGlyph createCompartmentGlyph(String id) { + return createCompartmentGlyph(id, null); + } + + /** * Creates, sets and returns {@link Dimensions} based on the * given values. + * * @param width * @param height * @param depth - * @return new {@link Dimensions} object. + * @return a new {@link Dimensions} object. + * @see #createDimensions(String, double, double, double) */ public Dimensions createDimensions(double width, double height, double depth) { - Dimensions d = new Dimensions(); + return createDimensions(null, width, height, depth); + } + + /** + * Creates, sets and returns {@link Dimensions} based on the + * given values. + * + * @param id + * the identifier of the {@link Dimensions} to be created. + * @param width + * @param height + * @param depth + * @return a new {@link Dimensions} object. + */ + public Dimensions createDimensions(String id, double width, + double height, double depth) { + Dimensions d = new Dimensions(id, getLevel(), getVersion()); d.setWidth(width); d.setHeight(height); d.setDepth(depth); setDimensions(d); return d; } - + /** * Creates and adds a new {@link ReactionGlyph}. - * @param reaction {@link Reaction} ID. - * @return new {@link ReactionGlyph}. + * + * @param id + * the identifier of the {@link ReactionGlyph} to be created. + * @param reaction + * {@link Reaction} ID. + * @return a new {@link ReactionGlyph}. */ - public ReactionGlyph createReactionGlyph(String reaction) { - ReactionGlyph glyph = new ReactionGlyph(); + public ReactionGlyph createReactionGlyph(String id, String reaction) { + ReactionGlyph glyph = new ReactionGlyph(id, getLevel(), getVersion()); glyph.setReaction(reaction); addReactionGlyph(glyph); return glyph; } + + /** + * Creates and adds a new {@link ReactionGlyph}. + * + * @param id + * the identifier of the {@link ReactionGlyph} to be created. + * @return a new {@link ReactionGlyph}. + * @see #createReactionGlyph(String, String) + */ + public ReactionGlyph createReactionGlyph(String id) { + return createReactionGlyph(id, null); + } /** * Creates and adds a new {@link SpeciesGlyph}. - * @param species {@link Species} ID. - * @return new {@link SpeciesGlyph}. + * + * @param id + * the identifier for the {@link SpeciesGlyph} to be created. + * @param species + * {@link Species} ID. + * @return a new {@link SpeciesGlyph}. */ - public SpeciesGlyph createSpeciesGlyph(String species) { - SpeciesGlyph glyph = new SpeciesGlyph(); + public SpeciesGlyph createSpeciesGlyph(String id, String species) { + SpeciesGlyph glyph = new SpeciesGlyph(id, getLevel(), getVersion()); glyph.setSpecies(species); addSpeciesGlyph(glyph); return glyph; } /** + * Creates and adds a new {@link SpeciesGlyph} with the given identifier. + * + * @param id + * the identifier for the {@link SpeciesGlyph} to be created. + * @return a new {@link SpeciesGlyph}. + * @see #createSpeciesGlyph(String, String) + */ + public SpeciesGlyph createSpeciesGlyph(String id) { + return createSpeciesGlyph(id, null); + } + + /** * Creates and adds a new {@link TextGlyph}. - * @param text the text for the new glyph - * @return new {@link TextGlyph}. + * + * @param id + * the identifier for the {@link TextGlyph} to be created. + * @param text + * the text for the new glyph + * @return a new {@link TextGlyph}. */ - public TextGlyph createTextGlyph(String text) { - TextGlyph glyph = new TextGlyph(); + public TextGlyph createTextGlyph(String id, String text) { + TextGlyph glyph = new TextGlyph(id, getLevel(), getVersion()); glyph.setText(text); addTextGlyph(glyph); return glyph; } /** + * Creates and adds a new {@link TextGlyph}. + * + * @param id + * the identifier for the {@link TextGlyph} to be created. + * @return a new {@link TextGlyph}. + * @see #createTextGlyph(String, String) + */ + public TextGlyph createTextGlyph(String id) { + return createTextGlyph(id, null); + } + + /** * Searches all instances of {@link CompartmentGlyph} within this {@link Layout} that * refer to the {@link Compartment} with the given id. * @@ -473,11 +555,7 @@ * @return */ public CompartmentGlyph getCompartmentGlyph(int i) { - if (isSetListOfCompartmentGlyphs()) { - // No checks for index correctness! Throw IndexOutOfBoundsExceptions! - return listOfCompartmentGlyphs.get(i); - } - return null; + return getListOfCompartmentGlyphs().get(i); } /** @@ -487,7 +565,7 @@ */ public CompartmentGlyph getCompartmentGlyph(String id) { if (isSetListOfCompartmentGlyphs()) { - return listOfCompartmentGlyphs.firstHit(new NameFilter(id)); + return getListOfCompartmentGlyphs().firstHit(new NameFilter(id)); } return null; } @@ -505,6 +583,10 @@ * @return */ public ListOf<GraphicalObject> getListOfAdditionalGraphicalObjects() { + if (!isSetListOfAdditionalGraphicalObjects()) { + listOfAdditionalGraphicalObjects = ListOf.newInstance(this, GraphicalObject.class); + listOfAdditionalGraphicalObjects.addNamespace(LayoutConstant.namespaceURI); + } return listOfAdditionalGraphicalObjects; } @@ -514,10 +596,8 @@ */ public ListOf<CompartmentGlyph> getListOfCompartmentGlyphs() { if (!isSetListOfCompartmentGlyphs()) { - listOfCompartmentGlyphs = new ListOf<CompartmentGlyph>(getLevel(), getVersion()); + listOfCompartmentGlyphs = ListOf.newInstance(this, CompartmentGlyph.class); listOfCompartmentGlyphs.addNamespace(LayoutConstant.namespaceURI); - listOfCompartmentGlyphs.setSBaseListType(ListOf.Type.other); - registerChild(listOfCompartmentGlyphs); } return listOfCompartmentGlyphs; } @@ -529,10 +609,8 @@ */ public ListOf<ReactionGlyph> getListOfReactionGlyphs() { if (!isSetListOfReactionGlyphs()) { - listOfReactionGlyphs = new ListOf<ReactionGlyph>(getLevel(), getVersion()); + listOfReactionGlyphs = ListOf.newInstance(this, ReactionGlyph.class); listOfReactionGlyphs.addNamespace(LayoutConstant.namespaceURI); - listOfReactionGlyphs.setSBaseListType(ListOf.Type.other); - registerChild(listOfCompartmentGlyphs); } return listOfReactionGlyphs; } @@ -543,10 +621,8 @@ */ public ListOf<SpeciesGlyph> getListOfSpeciesGlyphs() { if (!isSetListOfSpeciesGlyphs()) { - listOfSpeciesGlyphs = new ListOf<SpeciesGlyph>(getLevel(), getVersion()); + listOfSpeciesGlyphs = ListOf.newInstance(this, SpeciesGlyph.class); listOfSpeciesGlyphs.addNamespace(LayoutConstant.namespaceURI); - listOfSpeciesGlyphs.setSBaseListType(ListOf.Type.other); - registerChild(listOfSpeciesGlyphs); } return listOfSpeciesGlyphs; } @@ -557,10 +633,8 @@ */ public ListOf<TextGlyph> getListOfTextGlyphs() { if (!isSetListOfTextGlyphs()) { - listOfTextGlyphs = new ListOf<TextGlyph>(getLevel(), getVersion()); + listOfTextGlyphs = ListOf.newInstance(this, TextGlyph.class); listOfTextGlyphs.addNamespace(LayoutConstant.namespaceURI); - listOfTextGlyphs.setSBaseListType(ListOf.Type.other); - registerChild(listOfTextGlyphs); } return listOfTextGlyphs; } @@ -571,11 +645,7 @@ * @return */ public ReactionGlyph getReactionGlyph(int i) { - if (isSetListOfReactionGlyphs()) { - // No check for index correctness! IndexOutOfBoundsExceptions! - return listOfReactionGlyphs.get(i); - } - return null; + return getListOfReactionGlyphs().get(i); } /** @@ -596,13 +666,7 @@ * @return */ public SpeciesGlyph getSpeciesGlyph(int i) { - if (isSetListOfSpeciesGlyphs()) { - // Do not check && i >= 0 && i < listOfSpeciesGlyphs.size() here! - // The expected behavior will be an IndexOutOfBoundsBxception! - // This is much better for finding bugs! - return listOfSpeciesGlyphs.get(i); - } - return null; + return getListOfSpeciesGlyphs().get(i); } /** @@ -622,26 +686,6 @@ */ private void initDefault() { 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); - - listOfReactionGlyphs.addNamespace(LayoutConstant.namespaceURI); - listOfReactionGlyphs.setSBaseListType(ListOf.Type.other); - registerChild(listOfReactionGlyphs); - - listOfTextGlyphs.addNamespace(LayoutConstant.namespaceURI); - listOfTextGlyphs.setSBaseListType(ListOf.Type.other); - registerChild(listOfTextGlyphs); - - listOfAdditionalGraphicalObjects.addNamespace(LayoutConstant.namespaceURI); - listOfAdditionalGraphicalObjects.setSBaseListType(ListOf.Type.other); - registerChild(listOfAdditionalGraphicalObjects); } /* (non-Javadoc) @@ -721,7 +765,7 @@ * @param listOfAdditionalGraphicalObjects */ public void setAddGraphicalObjects(ListOf<GraphicalObject> addGraphicalObjects) { - if(this.listOfAdditionalGraphicalObjects != null){ + if (this.listOfAdditionalGraphicalObjects != null) { this.listOfAdditionalGraphicalObjects.fireNodeRemovedEvent(); } this.listOfAdditionalGraphicalObjects = addGraphicalObjects; @@ -733,7 +777,7 @@ * @param dimensions */ public void setDimensions(Dimensions dimensions) { - if(this.dimensions != null){ + if (this.dimensions != null) { this.dimensions.fireNodeRemovedEvent(); } this.dimensions = dimensions; Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/TextGlyph.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/TextGlyph.java 2012-06-08 12:36:59 UTC (rev 1292) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/TextGlyph.java 2012-06-08 14:48:51 UTC (rev 1293) @@ -62,12 +62,33 @@ /** * + * @param level + * @param version + */ + public TextGlyph(int level, int version) { + super(level, version); + addNamespace(LayoutConstant.namespaceURI); + } + + /** + * * @param id */ public TextGlyph(String id) { super(id); addNamespace(LayoutConstant.namespaceURI); } + + /** + * + * @param id + * @param level + * @param version + */ + public TextGlyph(String id, int level, int version) { + super(id, level, version); + addNamespace(LayoutConstant.namespaceURI); + } /** * @@ -180,36 +201,6 @@ return text != null; } - /** - * - * @param graphicalObject - */ - public void setGraphicalObject(String graphicalObject) { - String oldValue = this.graphicalObject; - this.graphicalObject = graphicalObject; - firePropertyChange(LayoutConstant.graphicalObject, oldValue, this.graphicalObject); - } - - /** - * - * @param originOfText - */ - public void setOriginOfText(String originOfText) { - String oldOriginOfText = this.originOfText; - this.originOfText = originOfText; - firePropertyChange(LayoutConstant.originOfText, oldOriginOfText, this.originOfText); - } - - /** - * - * @param text - */ - public void setText(String text) { - String oldText = this.text; - this.text = text; - firePropertyChange(LayoutConstant.text, oldText, this.text); - } - /* (non-Javadoc) * @see org.sbml.jsbml.AbstractNamedSBase#readAttribute(java.lang.String, java.lang.String, java.lang.String) */ @@ -245,6 +236,36 @@ return isAttributeRead; } + /** + * + * @param graphicalObject + */ + public void setGraphicalObject(String graphicalObject) { + String oldValue = this.graphicalObject; + this.graphicalObject = graphicalObject; + firePropertyChange(LayoutConstant.graphicalObject, oldValue, this.graphicalObject); + } + + /** + * + * @param originOfText + */ + public void setOriginOfText(String originOfText) { + String oldOriginOfText = this.originOfText; + this.originOfText = originOfText; + firePropertyChange(LayoutConstant.originOfText, oldOriginOfText, this.originOfText); + } + + /** + * + * @param text + */ + public void setText(String text) { + String oldText = this.text; + this.text = text; + firePropertyChange(LayoutConstant.text, oldText, this.text); + } + /* (non-Javadoc) * @see org.sbml.jsbml.ext.layout.GraphicalObject#writeXMLAttributes() */ Modified: trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiEventAssignment.java =================================================================== --- trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiEventAssignment.java 2012-06-08 12:36:59 UTC (rev 1292) +++ trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiEventAssignment.java 2012-06-08 14:48:51 UTC (rev 1293) @@ -38,8 +38,8 @@ return null; } - @Override - public SBasePlugin clone() { + //@Override + public MultiEventAssignment clone() { // TODO Auto-generated method stub return null; } Modified: trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiInitialAssignment.java =================================================================== --- trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiInitialAssignment.java 2012-06-08 12:36:59 UTC (rev 1292) +++ trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiInitialAssignment.java 2012-06-08 14:48:51 UTC (rev 1293) @@ -38,8 +38,8 @@ return null; } - @Override - public SBasePlugin clone() { + //@Override + public MultiInitialAssignment clone() { // TODO Auto-generated method stub return null; } Modified: trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiModel.java =================================================================== --- trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiModel.java 2012-06-08 12:36:59 UTC (rev 1292) +++ trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiModel.java 2012-06-08 14:48:51 UTC (rev 1293) @@ -65,8 +65,8 @@ } - @Override - public SBasePlugin clone() { + //@Override + public MultiModel clone() { // TODO : when cloning, we should be able to be associated with a new cloned model !? return null; } Modified: trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiReaction.java =================================================================== --- trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiReaction.java 2012-06-08 12:36:59 UTC (rev 1292) +++ trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiReaction.java 2012-06-08 14:48:51 UTC (rev 1293) @@ -57,8 +57,8 @@ return null; } - @Override - public SBasePlugin clone() { + //@Override + public MultiReaction clone() { // TODO Auto-generated method stub return null; } Modified: trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiRule.java =================================================================== --- trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiRule.java 2012-06-08 12:36:59 UTC (rev 1292) +++ trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiRule.java 2012-06-08 14:48:51 UTC (rev 1293) @@ -42,8 +42,8 @@ return null; } - @Override - public SBasePlugin clone() { + //@Override + public MultiRule clone() { // TODO Auto-generated method stub return null; } Modified: trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiSpeciesReference.java =================================================================== --- trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiSpeciesReference.java 2012-06-08 12:36:59 UTC (rev 1292) +++ trunk/extensions/multi/src/org/sbml/jsbml/ext/multi/MultiSpeciesReference.java 2012-06-08 14:48:51 UTC (rev 1293) @@ -61,8 +61,8 @@ return null; } - @Override - public SBasePlugin clone() { + //@Override + public MultiSpeciesReference clone() { // TODO Auto-generated method stub return null; } Added: trunk/extensions/render/build.xml =================================================================== --- trunk/extensions/render/build.xml (rev 0) +++ trunk/extensions/render/build.xml 2012-06-08 14:48:51 UTC (rev 1293) @@ -0,0 +1,7 @@ +<?xml version="1.0"?> +<!-- $Id$ --> + +<!--<project default="usage" basedir="."> +</project>--> + +<!-- End of file --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nik...@us...> - 2012-06-08 12:37:05
|
Revision: 1292 http://jsbml.svn.sourceforge.net/jsbml/?rev=1292&view=rev Author: niko-rodrigue Date: 2012-06-08 12:36:59 +0000 (Fri, 08 Jun 2012) Log Message: ----------- added the biological qualifier hasTaxon Modified Paths: -------------- trunk/core/src/org/sbml/jsbml/CVTerm.java Modified: trunk/core/src/org/sbml/jsbml/CVTerm.java =================================================================== --- trunk/core/src/org/sbml/jsbml/CVTerm.java 2012-06-06 17:16:46 UTC (rev 1291) +++ trunk/core/src/org/sbml/jsbml/CVTerm.java 2012-06-08 12:36:59 UTC (rev 1292) @@ -76,6 +76,10 @@ */ BQB_HAS_PROPERTY, /** + * Represents the MIRIAM biological qualifier 'hasTaxon'. + */ + BQB_HAS_TAXON, + /** * Represents the MIRIAM biological qualifier 'hasVersion'. */ BQB_HAS_VERSION, @@ -147,6 +151,8 @@ return "hasVersion"; case BQB_HAS_PROPERTY: return "hasProperty"; + case BQB_HAS_TAXON: + return "hasTaxon"; case BQB_IS_PROPERTY_OF: return "isPropertyOf"; case BQB_IS: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2012-06-06 17:16:56
|
Revision: 1291 http://jsbml.svn.sourceforge.net/jsbml/?rev=1291&view=rev Author: andreas-draeger Date: 2012-06-06 17:16:46 +0000 (Wed, 06 Jun 2012) Log Message: ----------- Graphical object must implement UniqueNamedSBase. Modified Paths: -------------- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/GraphicalObject.java Modified: trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/GraphicalObject.java =================================================================== --- trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/GraphicalObject.java 2012-06-06 12:12:11 UTC (rev 1290) +++ trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/GraphicalObject.java 2012-06-06 17:16:46 UTC (rev 1291) @@ -24,6 +24,7 @@ import javax.swing.tree.TreeNode; import org.sbml.jsbml.AbstractNamedSBase; +import org.sbml.jsbml.UniqueNamedSBase; /** * @@ -34,7 +35,7 @@ * @since 1.0 * @version $Rev$ */ -public class GraphicalObject extends AbstractNamedSBase { +public class GraphicalObject extends AbstractNamedSBase implements UniqueNamedSBase { /** * Generated serial version identifier. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jak...@us...> - 2012-06-06 12:12:22
|
Revision: 1290 http://jsbml.svn.sourceforge.net/jsbml/?rev=1290&view=rev Author: jakobmatthes Date: 2012-06-06 12:12:11 +0000 (Wed, 06 Jun 2012) Log Message: ----------- render extension: remove superflous field in Polygon Modified Paths: -------------- trunk/extensions/render/src/org/sbml/jsbml/ext/render/Polygon.java Modified: trunk/extensions/render/src/org/sbml/jsbml/ext/render/Polygon.java =================================================================== --- trunk/extensions/render/src/org/sbml/jsbml/ext/render/Polygon.java 2012-06-06 11:55:07 UTC (rev 1289) +++ trunk/extensions/render/src/org/sbml/jsbml/ext/render/Polygon.java 2012-06-06 12:12:11 UTC (rev 1290) @@ -47,12 +47,7 @@ */ private ListOf<RenderPoint> listOfElements; - /** - * - */ - private ListOf<RenderPoint> listOfRenderPoints; - /** * Creates an Polygon instance */ @@ -72,8 +67,8 @@ /** * @param renderPoint */ - public boolean addRenderPoint(RenderPoint renderPoint) { - return getListOfRenderPoints().add(renderPoint); + public boolean addElement(RenderPoint element) { + return getListOfElements().add(element); } /* (non-Javadoc) @@ -117,7 +112,7 @@ */ @Override public int getChildCount() { - int count = 0; + int count = super.getChildCount(); if (isSetListOfElements()) { count++; } @@ -135,19 +130,6 @@ throw new PropertyUndefinedError(RenderConstants.listOfElements, this); } - /** - * @return the listOfRenderPoints - */ - public ListOf<RenderPoint> getListOfRenderPoints() { - if (!isSetListOfRenderPoints()) { - listOfRenderPoints = new ListOf<RenderPoint>(getLevel(), getVersion()); - listOfRenderPoints.addNamespace(RenderConstants.namespaceURI); - listOfRenderPoints.setSBaseListType(ListOf.Type.other); - registerChild(listOfRenderPoints); - } - return listOfRenderPoints; - } - /* (non-Javadoc) * @see org.sbml.jsbml.ext.render.GraphicalPrimitive2D#initDefaults() */ @@ -164,37 +146,6 @@ } /** - * @return <code>true</code>, if listOfRenderPoints contains at least one element, - * otherwise <code>false</code> - */ - public boolean isSetListOfRenderPoints() { - if ((listOfRenderPoints == null) || listOfRenderPoints.isEmpty()) { - return false; - } - return true; - } - - /** - * @param i - */ - public void removeRenderPoint(int i) { - if (!isSetListOfRenderPoints()) { - throw new IndexOutOfBoundsException(Integer.toString(i)); - } - getListOfRenderPoints().remove(i); - } - - /** - * @param renderPoint - */ - public boolean removeRenderPoint(RenderPoint renderPoint) { - if (isSetListOfRenderPoints()) { - return getListOfRenderPoints().remove(renderPoint); - } - return false; - } - - /** * Set the value of listOfElements */ public void setListOfElements(ListOf<RenderPoint> listOfElements) { @@ -204,15 +155,6 @@ } /** - * @param listOfRenderPoints - */ - public void setListOfRenderPoints(ListOf<RenderPoint> listOfRenderPoints) { - unsetListOfRenderPoints(); - this.listOfRenderPoints = listOfRenderPoints; - registerChild(this.listOfRenderPoints); - } - - /** * Unsets the variable listOfElements * @return <code>true</code>, if listOfElements was set before, * otherwise <code>false</code> @@ -227,18 +169,4 @@ return false; } - /** - * @return <code>true</code>, if listOfRenderPoints contained at least one element, - * otherwise <code>false</code> - */ - public boolean unsetListOfRenderPoints() { - if (isSetListOfRenderPoints()) { - ListOf<RenderPoint> oldRenderPoints = this.listOfRenderPoints; - this.listOfRenderPoints = null; - oldRenderPoints.fireNodeRemovedEvent(); - return true; - } - return false; - } - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |