Skip to content
Snippets Groups Projects

Resolve "AND gate is not visible"

Merged Piotr Gawron requested to merge 1408-and-gate-in-sbgn-like-view into devel_15.1.x
14 files
+ 43
65
Compare changes
  • Side-by-side
  • Inline
Files
14
@@ -16,7 +16,8 @@ import lcsb.mapviewer.converter.graphics.ConverterParams;
import lcsb.mapviewer.converter.graphics.DrawingException;
import lcsb.mapviewer.converter.graphics.bioEntity.BioEntityConverter;
import lcsb.mapviewer.converter.graphics.geometry.ArrowTransformation;
import lcsb.mapviewer.model.graphics.*;
import lcsb.mapviewer.model.graphics.ArrowTypeData;
import lcsb.mapviewer.model.graphics.PolylineData;
import lcsb.mapviewer.model.map.layout.ColorSchema;
import lcsb.mapviewer.model.map.layout.GenericColorSchema;
import lcsb.mapviewer.model.map.reaction.*;
@@ -357,41 +358,28 @@ public class ReactionConverter extends BioEntityConverter<Reaction> {
// draw line
arrowTransformation.drawLine(operator.getLine(), graphics);
// in SBGN view - draw connecting point only if it's not connected to
// reactants or products
if (!sbgnFormat || operator.getLine().getEndAtd().getArrowType() != ArrowType.NONE
|| (!operator.getOutputs().isEmpty() && operator.getOutputs().get(0) instanceof NodeOperator)) {
// and now connecting point
Point2D centerPoint = operator.getLine().getPoints().get(0);
Color fillColor = Color.WHITE;
double radius = DEFAULT_OPERATOR_RADIUS;
// bigger connecting point circles in SBGN view
if (sbgnFormat) {
radius *= SBGN_RADIUS_MULTIPLIER;
} else if (operator instanceof AndOperator || operator instanceof SplitOperator
|| operator instanceof DissociationOperator || operator instanceof AssociationOperator
|| operator instanceof TruncationOperator) {
radius = 1.5;
fillColor = operator.getLine().getColor();
}
// it's a circle
Ellipse2D cir = new Ellipse2D.Double(centerPoint.getX() - radius, centerPoint.getY() - radius, 2 * radius,
2 * radius);
graphics.setColor(fillColor);
graphics.fill(cir);
graphics.setColor(operator.getLine().getColor());
graphics.draw(cir);
// and text defined by operator
String text;
if (!sbgnFormat) {
text = operator.getOperatorText();
} else {
text = operator.getSBGNOperatorText();
}
Rectangle2D rect = graphics.getFontMetrics().getStringBounds(text, graphics);
graphics.drawString(text, (int) (centerPoint.getX() - rect.getWidth() / 2 + 1),
(int) (centerPoint.getY() + rect.getHeight() / 2) - 2);
Point2D centerPoint = operator.getLine().getPoints().get(0);
Color fillColor = Color.WHITE;
double radius = DEFAULT_OPERATOR_RADIUS;
// bigger connecting point circles in SBGN view
if (operator instanceof AndOperator || operator instanceof SplitOperator
|| operator instanceof DissociationOperator || operator instanceof AssociationOperator
|| operator instanceof TruncationOperator) {
radius = 1.5;
fillColor = operator.getLine().getColor();
}
// it's a circle
Ellipse2D cir = new Ellipse2D.Double(centerPoint.getX() - radius, centerPoint.getY() - radius, 2 * radius,
2 * radius);
graphics.setColor(fillColor);
graphics.fill(cir);
graphics.setColor(operator.getLine().getColor());
graphics.draw(cir);
// and text defined by operator
String text = operator.getOperatorText();
Rectangle2D rect = graphics.getFontMetrics().getStringBounds(text, graphics);
graphics.drawString(text, (int) (centerPoint.getX() - rect.getWidth() / 2 + 1),
(int) (centerPoint.getY() + rect.getHeight() / 2) - 2);
graphics.setColor(oldColor);
}
Loading