Commit 952df6f0 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

simple molecules are visualized as ellipses not circles

parent 5f6b4efc
minerva (15.0.0~alpha.1) stable; urgency=medium minerva (15.0.0~alpha.1) stable; urgency=medium
* Small improvement: sort order of tables in admin panel is preserved among * Small improvement: sort order of tables in admin panel is preserved among
sessions (#836) sessions (#836)
* Small improvement: simple molecules in sbgn compliant view are drawn as
ellipses not circles (#796)
* Bug fix: structural states of proteins are imported properly from SBGNML PD * Bug fix: structural states of proteins are imported properly from SBGNML PD
(#995) (#995)
* Bug fix: clear button icon, refresh comments button and show overview * Bug fix: clear button icon, refresh comments button and show overview
......
...@@ -44,8 +44,7 @@ public class SimpleMoleculeConverter extends SpeciesConverter<SimpleMolecule> { ...@@ -44,8 +44,7 @@ public class SimpleMoleculeConverter extends SpeciesConverter<SimpleMolecule> {
final ConverterParams params) { final ConverterParams params) {
int homodir; int homodir;
if (params.isSbgnFormat()) { if (params.isSbgnFormat()) {
// If the SBGN display mode is set, multimer is shown as two stacked // If the SBGN display mode is set, multimer is shown as two stacked glyphs
// glyphs
if (simpleMolecule.getHomodimer() > 1) { if (simpleMolecule.getHomodimer() > 1) {
homodir = 2; homodir = 2;
} else { } else {
...@@ -58,12 +57,6 @@ public class SimpleMoleculeConverter extends SpeciesConverter<SimpleMolecule> { ...@@ -58,12 +57,6 @@ public class SimpleMoleculeConverter extends SpeciesConverter<SimpleMolecule> {
simpleMolecule.setWidth(simpleMolecule.getWidth() - SpeciesConverter.HOMODIMER_OFFSET * (homodir - 1)); simpleMolecule.setWidth(simpleMolecule.getWidth() - SpeciesConverter.HOMODIMER_OFFSET * (homodir - 1));
simpleMolecule.setHeight(simpleMolecule.getHeight() - SpeciesConverter.HOMODIMER_OFFSET * (homodir - 1)); simpleMolecule.setHeight(simpleMolecule.getHeight() - SpeciesConverter.HOMODIMER_OFFSET * (homodir - 1));
// SBGN view - simple molecules are represented as circles
if (params.isSbgnFormat()) {
simpleMolecule.setX(simpleMolecule.getX() + (simpleMolecule.getWidth() - simpleMolecule.getHeight()) / 2);
simpleMolecule.setWidth(simpleMolecule.getHeight());
}
simpleMolecule.setX(simpleMolecule.getX() + SpeciesConverter.HOMODIMER_OFFSET * (homodir)); simpleMolecule.setX(simpleMolecule.getX() + SpeciesConverter.HOMODIMER_OFFSET * (homodir));
simpleMolecule.setY(simpleMolecule.getY() + SpeciesConverter.HOMODIMER_OFFSET * (homodir)); simpleMolecule.setY(simpleMolecule.getY() + SpeciesConverter.HOMODIMER_OFFSET * (homodir));
...@@ -82,8 +75,8 @@ public class SimpleMoleculeConverter extends SpeciesConverter<SimpleMolecule> { ...@@ -82,8 +75,8 @@ public class SimpleMoleculeConverter extends SpeciesConverter<SimpleMolecule> {
graphics.setStroke(stroke); graphics.setStroke(stroke);
graphics.setColor(oldColor); graphics.setColor(oldColor);
// SBGN view - multimers are displayed with a unit of information // SBGN view - multimers are displayed with a unit of information containing
// containing cardinality // cardinality
if (params.isSbgnFormat() && (i == homodir - 1)) { if (params.isSbgnFormat() && (i == homodir - 1)) {
String unitOfInformationText = null; String unitOfInformationText = null;
if (simpleMolecule.getStatePrefix() != null && simpleMolecule.getStateLabel() != null) { if (simpleMolecule.getStatePrefix() != null && simpleMolecule.getStateLabel() != null) {
......
...@@ -16,8 +16,7 @@ import lcsb.mapviewer.common.UnitTestFailedWatcher; ...@@ -16,8 +16,7 @@ import lcsb.mapviewer.common.UnitTestFailedWatcher;
import lcsb.mapviewer.model.graphics.PolylineData; import lcsb.mapviewer.model.graphics.PolylineData;
import lcsb.mapviewer.model.map.modifier.Catalysis; import lcsb.mapviewer.model.map.modifier.Catalysis;
import lcsb.mapviewer.model.map.reaction.*; import lcsb.mapviewer.model.map.reaction.*;
import lcsb.mapviewer.model.map.species.Complex; import lcsb.mapviewer.model.map.species.*;
import lcsb.mapviewer.model.map.species.GenericProtein;
public abstract class GraphicsTestFunctions { public abstract class GraphicsTestFunctions {
...@@ -89,4 +88,15 @@ public abstract class GraphicsTestFunctions { ...@@ -89,4 +88,15 @@ public abstract class GraphicsTestFunctions {
return result; return result;
} }
protected SimpleMolecule createSimpleMolecule() {
SimpleMolecule protein = new SimpleMolecule ("sm" + elementCounter++);
protein.setX(10);
protein.setY(20);
protein.setWidth(100);
protein.setHeight(80);
protein.setFillColor(Color.WHITE);
return protein;
}
} }
...@@ -6,6 +6,7 @@ import org.junit.runners.Suite.SuiteClasses; ...@@ -6,6 +6,7 @@ import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class) @RunWith(Suite.class)
@SuiteClasses({ ComplexConverterTest.class, @SuiteClasses({ ComplexConverterTest.class,
SimpleMoleculeConverterTest.class,
SpeciesConverterTest.class, SpeciesConverterTest.class,
SpeciesGenericConverterTests.class }) SpeciesGenericConverterTests.class })
public class AllSpeciesConverterTests { public class AllSpeciesConverterTests {
......
package lcsb.mapviewer.converter.graphics.bioEntity.element.species;
import static org.junit.Assert.assertEquals;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.*;
import lcsb.mapviewer.commands.ColorExtractor;
import lcsb.mapviewer.common.Configuration;
import lcsb.mapviewer.converter.graphics.ConverterParams;
import lcsb.mapviewer.converter.graphics.GraphicsTestFunctions;
import lcsb.mapviewer.model.map.species.SimpleMolecule;
public class SimpleMoleculeConverterTest extends GraphicsTestFunctions {
Logger logger = LogManager.getLogger();
ColorExtractor colorExtractor = new ColorExtractor(Color.RED, Color.GREEN, Color.BLUE);
@Before
public void setUp() throws Exception {
}
@After
public void tearDown() throws Exception {
}
@Test
public void testDrawText() throws Exception {
int size = 200;
BufferedImage bi = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics = bi.createGraphics();
SimpleMoleculeConverter rc = new SimpleMoleculeConverter(colorExtractor);
SimpleMolecule simpleMolecule = createSimpleMolecule();
double x = simpleMolecule.getX();
double width = simpleMolecule.getWidth();
rc.drawImpl(simpleMolecule, graphics, new ConverterParams().sbgnFormat(true));
assertEquals("Coordinates shouldn't be changed when drawing SBGN-ML", x, simpleMolecule.getX(),
Configuration.EPSILON);
assertEquals("Width shouldn't be changed when drawing SBGN-ML", width, simpleMolecule.getWidth(),
Configuration.EPSILON);
}
}
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