Commit 0e633ee9 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

font color is properly encoded and compartments properly handle fill color

parent 4f2a0738
......@@ -4,6 +4,10 @@ minerva (15.1.0) unstable; urgency=medium
* Small improvement: plugin API allows to add/remove data overlays (#1153)
* Small improvement: logged user can change password (#1119)
* Small improvement: possibility to reset password added (#275)
* Small improvement: import SBML uses render:fill color for compartment
(#1254)
* Small improvement: in SBML render stroke color for glyphs is used for
defining font color
-- Piotr Gawron <piotr.gawron@uni.lu> Thu, 18 Jun 2020 16:00:00 +0200
......
......@@ -15,10 +15,6 @@ import lcsb.mapviewer.model.map.species.Element;
public abstract class SbmlElementExporter<T extends Element, S extends org.sbml.jsbml.Symbol>
extends SbmlBioEntityExporter<T, S> {
/**
* Default class logger.
*/
@SuppressWarnings("unused")
private static Logger logger = LogManager.getLogger();
public SbmlElementExporter(Model sbmlModel, lcsb.mapviewer.model.map.model.Model minervaModel,
......@@ -58,35 +54,37 @@ public abstract class SbmlElementExporter<T extends Element, S extends org.sbml.
LocalRenderInformation renderInformation = getRenderInformation(getRenderPlugin());
LocalStyle style = new LocalStyle();
style.getIDList().add(textGlyph.getId());
style.setGroup(new RenderGroup());
style.getGroup().setVTextAnchor(VTextAnchor.MIDDLE);
style.getGroup().setTextAnchor(HTextAnchor.MIDDLE);
RenderGroup group = new RenderGroup();
style.setGroup(group);
group.setVTextAnchor(VTextAnchor.MIDDLE);
group.setTextAnchor(HTextAnchor.MIDDLE);
switch (element.getNameHorizontalAlign()) {
case CENTER:
style.getGroup().setTextAnchor(HTextAnchor.MIDDLE);
group.setTextAnchor(HTextAnchor.MIDDLE);
break;
case LEFT:
style.getGroup().setTextAnchor(HTextAnchor.START);
group.setTextAnchor(HTextAnchor.START);
x = element.getNamePoint().getX();
break;
case RIGTH:
style.getGroup().setTextAnchor(HTextAnchor.END);
group.setTextAnchor(HTextAnchor.END);
width = element.getNamePoint().getX() - x;
break;
}
switch (element.getNameVerticalAlign()) {
case BOTTOM:
style.getGroup().setVTextAnchor(VTextAnchor.BOTTOM);
group.setVTextAnchor(VTextAnchor.BOTTOM);
height = element.getNamePoint().getY() - y;
break;
case MIDDLE:
style.getGroup().setVTextAnchor(VTextAnchor.MIDDLE);
group.setVTextAnchor(VTextAnchor.MIDDLE);
break;
case TOP:
style.getGroup().setVTextAnchor(VTextAnchor.TOP);
group.setVTextAnchor(VTextAnchor.TOP);
y = element.getNamePoint().getY();
break;
}
group.setStroke(getColorDefinition(element.getFontColor()).getId());
renderInformation.addLocalStyle(style);
}
textGlyph.setBoundingBox(createBoundingBox(x, y, element.getZ() + 1, width, height));
......
......@@ -18,7 +18,6 @@ import lcsb.mapviewer.model.LogMarker;
import lcsb.mapviewer.model.ProjectLogEntryType;
import lcsb.mapviewer.model.graphics.HorizontalAlign;
import lcsb.mapviewer.model.graphics.VerticalAlign;
import lcsb.mapviewer.model.map.compartment.Compartment;
import lcsb.mapviewer.model.map.species.Element;
public abstract class SbmlElementParser<T extends org.sbml.jsbml.Symbol> extends SbmlBioEntityParser {
......@@ -99,7 +98,12 @@ public abstract class SbmlElementParser<T extends org.sbml.jsbml.Symbol> extends
for (Pair<String, AbstractReferenceGlyph> idGlyphPair : getGlyphs()) {
String id = idGlyphPair.getLeft();
Element source = getAnyElementBySbmlElementId(id);
Element source = getMinervaModel().getElementByElementId(idGlyphPair.getRight().getId());
if (source == null) {
source = getAnyElementBySbmlElementId(id);
}
if (source == null) {
throw new InvalidInputDataExecption("Layout contains invalid Species id: " + idGlyphPair.getLeft());
}
......@@ -152,6 +156,10 @@ public abstract class SbmlElementParser<T extends org.sbml.jsbml.Symbol> extends
group.getTextAnchor() + " text alignment is not supported");
}
}
if (group.isSetStroke()) {
Color fontColor = getColorByColorDefinition(group.getStroke());
source.setFontColor(fontColor);
}
}
source.setNamePoint(new Point2D.Double(x, y));
}
......@@ -199,10 +207,13 @@ public abstract class SbmlElementParser<T extends org.sbml.jsbml.Symbol> extends
if (style.getGroup().isSetFill()) {
Color backgroundColor = getColorByColorDefinition(style.getGroup().getFill());
elementWithLayout.setFillColor(backgroundColor);
if (elementWithLayout instanceof Compartment) {
elementWithLayout.setBorderColor(backgroundColor);
}
}
if (style.getGroup().isSetStroke()) {
Color borderColor = getColorByColorDefinition(style.getGroup().getStroke());
elementWithLayout.setBorderColor(borderColor);
elementWithLayout.setFontColor(borderColor);
}
if (style.getGroup().isSetFontSize()) {
elementWithLayout.setFontSize(style.getGroup().getFontSize());
}
......
......@@ -73,12 +73,10 @@ public class SbmlCompartmentParser extends SbmlElementParser<org.sbml.jsbml.Comp
@Override
protected void applyStyleToElement(Element elementWithLayout, LocalStyle style) {
super.applyStyleToElement(elementWithLayout, style);
if (!style.getGroup().isSetFill() && style.getGroup().isSetStroke()) {
Color backgroundColor = getColorByColorDefinition(style.getGroup().getStroke());
elementWithLayout.setFillColor(backgroundColor);
if (elementWithLayout instanceof Compartment) {
elementWithLayout.setBorderColor(backgroundColor);
}
}
}
......
Supports Markdown
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