Commit b5786fc0 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

reaction style is based on center line of reaction

parent e24e5fef
......@@ -215,7 +215,7 @@ public class SbmlReactionExporter extends SbmlBioEntityExporter<Reaction, org.sb
}
firstReactant = false;
if (isExtensionEnabled(SbmlExtension.RENDER)) {
LocalStyle style = createStyle(reactant);
LocalStyle style = createStyle(reactant.getLine());
style.getGroup().setEndHead(reactant.getLine().getBeginAtd().getArrowType().name());
assignStyleToGlyph(reactantGlyph, style);
......@@ -244,7 +244,7 @@ public class SbmlReactionExporter extends SbmlBioEntityExporter<Reaction, org.sb
firstProduct = false;
if (isExtensionEnabled(SbmlExtension.RENDER)) {
LocalStyle style = createStyle(product);
LocalStyle style = createStyle(product.getLine());
style.getGroup().setEndHead(product.getLine().getEndAtd().getArrowType().name());
assignStyleToGlyph(productGlyph, style);
......@@ -261,7 +261,7 @@ public class SbmlReactionExporter extends SbmlBioEntityExporter<Reaction, org.sb
} else {
modifierGlyph.setRole(SpeciesReferenceRole.MODIFIER);
}
LocalStyle style = createStyle(modifier);
LocalStyle style = createStyle(modifier.getLine());
style.getGroup().setEndHead(modifier.getLine().getEndAtd().getArrowType().name());
if (isExtensionEnabled(SbmlExtension.RENDER)) {
......@@ -304,23 +304,23 @@ public class SbmlReactionExporter extends SbmlBioEntityExporter<Reaction, org.sb
return result;
}
private LocalStyle createStyle(ReactionNode node) {
private LocalStyle createStyle(PolylineData line) {
LocalRenderInformation renderInformation = getRenderInformation(getRenderPlugin());
LocalStyle style = new LocalStyle();
style.setGroup(new RenderGroup());
renderInformation.addLocalStyle(style);
ColorDefinition color = getColorDefinition(node.getLine().getColor());
ColorDefinition color = getColorDefinition(line.getColor());
style.getGroup().setStroke(color.getId());
style.getGroup().setFill(color.getId());
style.getGroup().setStrokeWidth(node.getLine().getWidth());
style.getGroup().setStrokeDashArray(strokeToArray(node.getLine().getType().getStroke()));
style.getGroup().setStrokeWidth(line.getWidth());
style.getGroup().setStrokeDashArray(strokeToArray(line.getType().getStroke()));
return style;
}
@Override
protected LocalStyle createStyle(Reaction node) {
return createStyle(node.getReactants().get(0));
protected LocalStyle createStyle(Reaction reaction) {
return createStyle(reaction.getLine());
}
private List<Short> strokeToArray(Stroke stroke) {
......
......@@ -220,6 +220,8 @@ public class SbmlReactionParser extends SbmlBioEntityParser {
NodeOperator operator = createOutputOperator(reactionWithLayout, glyph);
reactionWithLayout.addNode(operator);
}
reactionWithLayout.setLine(extractCurve(glyph, reactionWithLayout, null));
createCenterLineForReaction(reactionWithLayout);
assignRenderDataToReaction(glyph, reactionWithLayout);
for (ReactionNode reactionNode : reactionWithLayout.getReactionNodes()) {
......@@ -229,8 +231,6 @@ public class SbmlReactionParser extends SbmlBioEntityParser {
}
}
reactionWithLayout.setLine(extractCurve(glyph, reactionWithLayout, null));
createCenterLineForReaction(reactionWithLayout);
getMinervaModel().addReaction(reactionWithLayout);
......@@ -288,6 +288,8 @@ public class SbmlReactionParser extends SbmlBioEntityParser {
line.addPoint(pt.copyPoint(startNode.getLine().getEndPoint()));
line.addPoint(pt.copyPoint(endNode.getLine().getBeginPoint()));
line.setType(startNode.getLine().getType());
line.setColor(startNode.getLine().getColor());
}
}
}
......@@ -588,17 +590,20 @@ public class SbmlReactionParser extends SbmlBioEntityParser {
for (AbstractNode node : reactionWithLayout.getNodes()) {
node.getLine().setColor(color);
}
reactionWithLayout.getLine().setColor(color);
}
if (group.isSetStrokeWidth()) {
for (AbstractNode node : reactionWithLayout.getNodes()) {
node.getLine().setWidth(group.getStrokeWidth());
}
reactionWithLayout.getLine().setWidth(group.getStrokeWidth());
}
if (group.isSetStrokeDashArray()) {
LineType type = LineType.getTypeByDashArray(group.getStrokeDashArray());
for (AbstractNode node : reactionWithLayout.getNodes()) {
node.getLine().setType(type);
}
reactionWithLayout.getLine().setType(type);
}
if (group.isSetEndHead()) {
try {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment