Added a few null pointer checks

This commit is contained in:
Chris Myers 2022-10-02 16:59:34 -06:00
parent 88d02ca2d4
commit f74c41aa59
2 changed files with 15 additions and 6 deletions

View file

@ -461,6 +461,7 @@ public class SBMLutilities extends CoreObservable
}
public static void copyDimensionsToEdgeIndex(SBase source,SBase target,SBase edge,String attribute) {
if (source==null || target==null) return;
if (SBMLutilities.dimensionsMatch(source,target)) {
ArraysSBasePlugin sBasePlugin = SBMLutilities.getArraysSBasePlugin(source);
ArraysSBasePlugin sBasePluginEdge = SBMLutilities.getArraysSBasePlugin(edge);

View file

@ -209,10 +209,14 @@ public class BioGraph extends mxGraph {
// SBMLutilities.copyIndices(getGlyph(layout,GlobalConstants.GLYPH+"__"+product), speciesReferenceGlyph, "layout:speciesGlyph");
// SBMLutilities.copyIndices(reactionGlyph, speciesReferenceGlyph, "layout:id");
LineSegment lineSegment = speciesReferenceGlyph.createCurve().createLineSegment();
lineSegment.setStart(new Point(this.getSpeciesOrPromoterCell(reactant).getGeometry().getCenterX(),
this.getSpeciesOrPromoterCell(reactant).getGeometry().getCenterY()));
lineSegment.setEnd(new Point(this.getSpeciesOrPromoterCell(product).getGeometry().getCenterX(),
this.getSpeciesOrPromoterCell(product).getGeometry().getCenterY()));
if (this.getSpeciesOrPromoterCell(reactant)!=null) {
lineSegment.setStart(new Point(this.getSpeciesOrPromoterCell(reactant).getGeometry().getCenterX(),
this.getSpeciesOrPromoterCell(reactant).getGeometry().getCenterY()));
}
if (this.getSpeciesOrPromoterCell(product)!=null) {
lineSegment.setEnd(new Point(this.getSpeciesOrPromoterCell(product).getGeometry().getCenterX(),
this.getSpeciesOrPromoterCell(product).getGeometry().getCenterY()));
}
}
private static void addSpeciesReferenceGlyph(Layout layout,mxCell cell,ReactionGlyph reactionGlyph,String reactionId,String speciesId, String role) {
@ -223,8 +227,12 @@ public class BioGraph extends mxGraph {
// SBMLutilities.copyIndices(getGlyph(layout,GlobalConstants.GLYPH+"__"+speciesId), speciesReferenceGlyph, "layout:speciesGlyph");
// SBMLutilities.copyIndices(reactionGlyph, speciesReferenceGlyph, "layout:id");
LineSegment lineSegment = speciesReferenceGlyph.createCurve().createLineSegment();
lineSegment.setStart(new Point(cell.getSource().getGeometry().getCenterX(),cell.getSource().getGeometry().getCenterY()));
lineSegment.setEnd(new Point(cell.getTarget().getGeometry().getCenterX(),cell.getTarget().getGeometry().getCenterY()));
if (cell.getSource()!=null) {
lineSegment.setStart(new Point(cell.getSource().getGeometry().getCenterX(),cell.getSource().getGeometry().getCenterY()));
}
if (cell.getTarget()!=null) {
lineSegment.setEnd(new Point(cell.getTarget().getGeometry().getCenterX(),cell.getTarget().getGeometry().getCenterY()));
}
}
}