Skip to content

Commit

Permalink
Added a few null pointer checks
Browse files Browse the repository at this point in the history
  • Loading branch information
cjmyers committed Oct 2, 2022
1 parent 88d02ca commit f74c41a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ public static void cloneDimensions(SBase source,SBase target) {
}

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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,14 @@ private void createLayoutConnection(Layout layout,Reaction r,String reactant,Str
// 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) {
Expand All @@ -223,8 +227,12 @@ private static void addSpeciesReferenceGlyph(Layout layout,mxCell cell,ReactionG
// 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()));
}
}
}

Expand Down

0 comments on commit f74c41a

Please sign in to comment.