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. |