diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/annotation/RestAnnotationParserTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/annotation/RestAnnotationParserTest.java index ff04e704263c0441452fe77f708ad972460e4c8f..f8ab6d2d441325298cd4f0bc6455476c01aca300 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/annotation/RestAnnotationParserTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/annotation/RestAnnotationParserTest.java @@ -417,6 +417,18 @@ public class RestAnnotationParserTest extends CellDesignerTestFunctions { // TODO Auto-generated method stub return null; } + + @Override + public void setSemanticZoomLevelVisibility(String zoomLevelVisibility) { + // TODO Auto-generated method stub + + } + + @Override + public String getSemanticZoomLevelVisibility() { + // TODO Auto-generated method stub + return null; + } }); fail("Exception expected"); } catch (NotImplementedException e) { diff --git a/converter-SBGNML/src/main/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlExporter.java b/converter-SBGNML/src/main/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlExporter.java index c408b252ec46ad4dbd0e6197bca23debb212647c..c6d7b706742e0c5560469a846910d2ecf5059124 100644 --- a/converter-SBGNML/src/main/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlExporter.java +++ b/converter-SBGNML/src/main/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlExporter.java @@ -27,7 +27,7 @@ import org.sbgn.bindings.Sbgn; import lcsb.mapviewer.common.comparator.DoubleComparator; import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.converter.graphics.reaction.ReactionConverter; +import lcsb.mapviewer.converter.graphics.bioEntity.reaction.ReactionConverter; import lcsb.mapviewer.model.graphics.ArrowType; import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.model.Model; diff --git a/converter-SBGNML/src/main/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlParser.java b/converter-SBGNML/src/main/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlParser.java index f808c488be0611e3ff65a0cf13b43012b0691453..b66908389d19846ae461ed243800a41f0bb81577 100644 --- a/converter-SBGNML/src/main/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlParser.java +++ b/converter-SBGNML/src/main/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlParser.java @@ -28,7 +28,7 @@ import lcsb.mapviewer.common.comparator.DoubleComparator; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.converter.ConverterParams; import lcsb.mapviewer.converter.InvalidInputDataExecption; -import lcsb.mapviewer.converter.graphics.species.SpeciesConverter; +import lcsb.mapviewer.converter.graphics.bioEntity.element.species.SpeciesConverter; import lcsb.mapviewer.converter.model.celldesigner.types.ModifierType; import lcsb.mapviewer.converter.model.celldesigner.types.ModifierTypeUtils; import lcsb.mapviewer.converter.model.sbgnml.structures.Process; diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/AbstractImageGenerator.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/AbstractImageGenerator.java index c07d1422e660e6c34342af7f1f7b2e48106d7678..e452e977f39d17e4ce86d0f06631430afd253bc9 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/AbstractImageGenerator.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/AbstractImageGenerator.java @@ -16,8 +16,9 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.commands.ColorExtractor; import lcsb.mapviewer.common.MimeType; +import lcsb.mapviewer.converter.graphics.bioEntity.BioEntityConverterImpl; +import lcsb.mapviewer.converter.graphics.bioEntity.reaction.ReactionConverter; import lcsb.mapviewer.converter.graphics.layer.LayerConverter; -import lcsb.mapviewer.converter.graphics.reaction.ReactionConverter; import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.compartment.PathwayCompartment; import lcsb.mapviewer.model.map.layout.ColorSchema; @@ -172,11 +173,11 @@ public abstract class AbstractImageGenerator { * Should the visualization include hierarchical view or not. */ private boolean nested = false; - + /** * Should sbgn standard be used. */ - private boolean sbgn = false; + private boolean sbgn = false; /** * List of objects containging information about layouts visualized in the @@ -561,7 +562,8 @@ public abstract class AbstractImageGenerator { } /** - * @param sbgn the sbgn to set + * @param sbgn + * the sbgn to set * @see #sbgn * @return object with all parameters */ @@ -738,7 +740,7 @@ public abstract class AbstractImageGenerator { } // get a converter for this compartment - ElementConverterImpl converter = new ElementConverterImpl(compartment, colorExtractor); + BioEntityConverterImpl converter = new BioEntityConverterImpl(compartment, colorExtractor); ConverterParams compartmentParams = new ConverterParams().textCentered(fill).level(level); if (nested) { @@ -749,7 +751,7 @@ public abstract class AbstractImageGenerator { // standard compartment (not the pathway) if (nested || !(compartment instanceof PathwayCompartment)) { try { - converter.drawElement(compartment, graphics, compartmentParams, visibleLayouts); + converter.draw(compartment, graphics, compartmentParams, visibleLayouts); } catch (Exception e) { throw new DrawingException(eu.getElementTag(compartment) + "Problem with drawing element.", e); } @@ -825,14 +827,13 @@ public abstract class AbstractImageGenerator { } // at the beginning try to find an appropriate converter - ElementConverterImpl converter = new ElementConverterImpl(species, sbgnFormat, colorExtractor); + BioEntityConverterImpl converter = new BioEntityConverterImpl(species, sbgnFormat, colorExtractor); double customScale = 1; if (rescale) { customScale = scale; } try { - converter - .drawElement(species, graphics, new ConverterParams().scale(customScale).textCentered(rescale).level(level).sbgnFormat(sbgnFormat), visibleLayouts); + converter.draw(species, graphics, new ConverterParams().scale(customScale).textCentered(rescale).level(level).sbgnFormat(sbgnFormat), visibleLayouts); } catch (Exception e) { throw new DrawingException(eu.getElementTag(species) + "Problem with drawing element.", e); } @@ -866,8 +867,8 @@ public abstract class AbstractImageGenerator { if (!cross(reaction.getLines())) { return; } - ReactionConverter converter = new ReactionConverter(colorExtractor); - converter.drawReaction(reaction, graphics, sbgnFormat, visibleLayouts); + BioEntityConverterImpl converter = new BioEntityConverterImpl(reaction, sbgnFormat, colorExtractor); + converter.draw(reaction, graphics, new ConverterParams().sbgnFormat(sbgnFormat), visibleLayouts); } /** diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/ConverterParams.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/ConverterParams.java index c7499064c6533d5b85cc5d0cd9b06365da434c17..59577a9350b052778edde539029263c7bb881727 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/ConverterParams.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/ConverterParams.java @@ -11,28 +11,33 @@ public class ConverterParams { * Should the object be filled with the solid color. In other words it tells * us if the object is not transparent. */ - private boolean fill = false; + private boolean fill = false; /** * At which level the object is visualized. It helps to deterimine font size. * However it's possible that this value is not required. */ - private int level = 0; + private int level = 0; /** * What is the scale. It allows to adjust font size to be readable. */ - private double scale = 1; + private double scale = 1; /** * Should the text describing element be centered or not. */ - private boolean textCentered = false; + private boolean textCentered = false; /** * Should the map be displayed in SBGN format. */ - private boolean sbgnFormat = false; + private boolean sbgnFormat = false; + + /** + * Is the semantic zooming filtered. + */ + private boolean semanticZoomingOn = false; /** * @param fill @@ -56,6 +61,17 @@ public class ConverterParams { return this; } + /** + * @param semanticZoomingOn + * the semanticZoomingOn to set + * @return object with all parameters + * @see #semanticZoomingOn + */ + public ConverterParams semanticZoomingOn(final boolean semanticZoomingOn) { + this.semanticZoomingOn = semanticZoomingOn; + return this; + } + /** * @param textCentered * the textCentered to set @@ -129,6 +145,14 @@ public class ConverterParams { return sbgnFormat; } + /** + * @return the semanticZoomingOn + * @see #semanticZoomingOn + */ + public boolean isSemanticZoomingOn() { + return semanticZoomingOn; + } + @Override public String toString() { String result = "[" + this.getClass().getSimpleName() + "] " + // @@ -136,6 +160,7 @@ public class ConverterParams { "level:" + level + "," + // "scale:" + scale + "," + // "textCentered:" + textCentered + "," + // + "semanticZoomingOn:" + semanticZoomingOn + "," + // "sbgnFormat:" + sbgnFormat; return result; } diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/ElementConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/BioEntityConverter.java similarity index 50% rename from converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/ElementConverter.java rename to converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/BioEntityConverter.java index d1992b796ce8c4c30531713a9f4e9451cfd89a05..1d08111d03f7167651eb1b9aa24de46e3099e7e8 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/ElementConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/BioEntityConverter.java @@ -1,23 +1,26 @@ -package lcsb.mapviewer.converter.graphics; +package lcsb.mapviewer.converter.graphics.bioEntity; import java.awt.Graphics2D; import java.util.List; +import lcsb.mapviewer.converter.graphics.ConverterParams; +import lcsb.mapviewer.converter.graphics.DrawingException; +import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.layout.ColorSchema; import lcsb.mapviewer.model.map.species.Element; /** * This interface defines what operations should be possible to convert - * {@link Element} into a graphics on Graphics2D object. + * {@link AnnotatedObject} into a graphics on Graphics2D object. * * @author Piotr Gawron * * @param <T> * class of alias to convert */ -public interface ElementConverter<T extends Element> { +public interface BioEntityConverter<T extends AnnotatedObject> { /** - * Alpha value (0..255) used for visualizing layout data that are normally + * Alpha value (0..255) used for visualizing overlay data that are normally * visualized in javascript. */ int LAYOUT_ALPHA = 200; @@ -25,49 +28,50 @@ public interface ElementConverter<T extends Element> { /** * This function draw representation of the alias on the graphics object. * - * @param alias - * alias that should be drawn + * @param bioEntity + * {@link AnnotatedObject} that should be drawn * @param graphics - * where we want to draw alias + * where we want to draw bioEntity * @param params * visuzalization params (like, should the object be filled with * solid color, etc.), for more information see * {@link ConverterParams} * */ - void drawElement(T alias, Graphics2D graphics, ConverterParams params); + void draw(T bioEntity, Graphics2D graphics, ConverterParams params); /** * This function draw representation of the alias on the graphics object. * - * @param alias - * alias that should be drawn + * @param bioEntity + * {@link AnnotatedObject} that should be drawn * @param graphics - * where we want to draw alias + * where we want to draw bioEntity * @param params * visuzalization params (like, should the object be filled with * solid color, etc.), for more information see * {@link ConverterParams} - * @param visualizedLayoutsColorSchemas + * @param visualizedOverlaysColorSchemas * list of {@link ColorSchema} that were used for visualizing this - * alias in different layouts that should be overlayed on the alias + * bioentity in different data overlays that should be overlayed on + * the alias * */ - void drawElement(T alias, Graphics2D graphics, ConverterParams params, List<ColorSchema> visualizedLayoutsColorSchemas); + void draw(T bioEntity, Graphics2D graphics, ConverterParams params, List<ColorSchema> visualizedOverlaysColorSchemas); /** * This function will find proper font size to display text within it. Then it * will print this text. * - * @param alias - * alias with description to be drawn + * @param bioEntity + * bioEntity with description to be drawn * @param graphics * where the description should be drawn * @param params * parameters of visualization (centering, scale) * @throws DrawingException - * thrown when there is a problem with drawing alias + * thrown when there is a problem with drawing bioEntity */ - void drawText(T alias, Graphics2D graphics, ConverterParams params) throws DrawingException; + void drawText(T bioEntity, Graphics2D graphics, ConverterParams params) throws DrawingException; } diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/ElementConverterImpl.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/BioEntityConverterImpl.java similarity index 62% rename from converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/ElementConverterImpl.java rename to converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/BioEntityConverterImpl.java index e96615f6ef559df3540a69e0ad871d6760fa35bd..621c53734580d0ec4a9757dc730e2cb0f6357a41 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/ElementConverterImpl.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/BioEntityConverterImpl.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.graphics; +package lcsb.mapviewer.converter.graphics.bioEntity; import java.awt.Graphics2D; import java.util.List; @@ -8,25 +8,29 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.commands.ColorExtractor; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.converter.graphics.compartment.BottomSquareCompartmentConverter; -import lcsb.mapviewer.converter.graphics.compartment.LeftSquareCompartmentConverter; -import lcsb.mapviewer.converter.graphics.compartment.OvalCompartmentConverter; -import lcsb.mapviewer.converter.graphics.compartment.PathwayCompartmentConverter; -import lcsb.mapviewer.converter.graphics.compartment.RightSquareCompartmentConverter; -import lcsb.mapviewer.converter.graphics.compartment.SquareCompartmentConverter; -import lcsb.mapviewer.converter.graphics.compartment.TopSquareCompartmentConverter; -import lcsb.mapviewer.converter.graphics.species.AntisenseRnaConverter; -import lcsb.mapviewer.converter.graphics.species.ComplexConverter; -import lcsb.mapviewer.converter.graphics.species.DegradedConverter; -import lcsb.mapviewer.converter.graphics.species.DrugConverter; -import lcsb.mapviewer.converter.graphics.species.GeneConverter; -import lcsb.mapviewer.converter.graphics.species.IonConverter; -import lcsb.mapviewer.converter.graphics.species.PhenotypeConverter; -import lcsb.mapviewer.converter.graphics.species.ProteinConverter; -import lcsb.mapviewer.converter.graphics.species.RnaConverter; -import lcsb.mapviewer.converter.graphics.species.SBGNNucleicAcidFeatureConverter; -import lcsb.mapviewer.converter.graphics.species.SimpleMoleculeConverter; -import lcsb.mapviewer.converter.graphics.species.UnknownConverter; +import lcsb.mapviewer.converter.graphics.ConverterParams; +import lcsb.mapviewer.converter.graphics.DrawingException; +import lcsb.mapviewer.converter.graphics.bioEntity.element.compartment.BottomSquareCompartmentConverter; +import lcsb.mapviewer.converter.graphics.bioEntity.element.compartment.LeftSquareCompartmentConverter; +import lcsb.mapviewer.converter.graphics.bioEntity.element.compartment.OvalCompartmentConverter; +import lcsb.mapviewer.converter.graphics.bioEntity.element.compartment.PathwayCompartmentConverter; +import lcsb.mapviewer.converter.graphics.bioEntity.element.compartment.RightSquareCompartmentConverter; +import lcsb.mapviewer.converter.graphics.bioEntity.element.compartment.SquareCompartmentConverter; +import lcsb.mapviewer.converter.graphics.bioEntity.element.compartment.TopSquareCompartmentConverter; +import lcsb.mapviewer.converter.graphics.bioEntity.element.species.AntisenseRnaConverter; +import lcsb.mapviewer.converter.graphics.bioEntity.element.species.ComplexConverter; +import lcsb.mapviewer.converter.graphics.bioEntity.element.species.DegradedConverter; +import lcsb.mapviewer.converter.graphics.bioEntity.element.species.DrugConverter; +import lcsb.mapviewer.converter.graphics.bioEntity.element.species.GeneConverter; +import lcsb.mapviewer.converter.graphics.bioEntity.element.species.IonConverter; +import lcsb.mapviewer.converter.graphics.bioEntity.element.species.PhenotypeConverter; +import lcsb.mapviewer.converter.graphics.bioEntity.element.species.ProteinConverter; +import lcsb.mapviewer.converter.graphics.bioEntity.element.species.RnaConverter; +import lcsb.mapviewer.converter.graphics.bioEntity.element.species.SBGNNucleicAcidFeatureConverter; +import lcsb.mapviewer.converter.graphics.bioEntity.element.species.SimpleMoleculeConverter; +import lcsb.mapviewer.converter.graphics.bioEntity.element.species.UnknownConverter; +import lcsb.mapviewer.converter.graphics.bioEntity.reaction.ReactionConverter; +import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.compartment.BottomSquareCompartment; import lcsb.mapviewer.model.map.compartment.LeftSquareCompartment; import lcsb.mapviewer.model.map.compartment.OvalCompartment; @@ -35,6 +39,7 @@ import lcsb.mapviewer.model.map.compartment.RightSquareCompartment; import lcsb.mapviewer.model.map.compartment.SquareCompartment; import lcsb.mapviewer.model.map.compartment.TopSquareCompartment; import lcsb.mapviewer.model.map.layout.ColorSchema; +import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.species.AntisenseRna; import lcsb.mapviewer.model.map.species.Complex; import lcsb.mapviewer.model.map.species.Degraded; @@ -59,13 +64,13 @@ import lcsb.mapviewer.modelutils.map.ElementUtils; * @author Piotr Gawron * */ -public class ElementConverterImpl implements ElementConverter<Element> { +public class BioEntityConverterImpl implements BioEntityConverter<AnnotatedObject> { /** * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(ElementConverterImpl.class.getName()); + private static Logger logger = Logger.getLogger(BioEntityConverterImpl.class.getName()); /** * Returns a converter for given element. If converter doesn't exist then @@ -77,7 +82,7 @@ public class ElementConverterImpl implements ElementConverter<Element> { * object that helps to convert overlay values into colors * @return converter that can be applied for the given element */ - private ElementConverter<? extends Element> getConverterForElement(Element element, ColorExtractor colorExtractor) { + private BioEntityConverter<? extends AnnotatedObject> getConverterForElement(AnnotatedObject element, ColorExtractor colorExtractor) { if (element == null) { throw new InvalidArgumentException("element cannot be null"); } @@ -123,6 +128,8 @@ public class ElementConverterImpl implements ElementConverter<Element> { return new LeftSquareCompartmentConverter(colorExtractor); } else if (element instanceof RightSquareCompartment) { return new RightSquareCompartmentConverter(colorExtractor); + } else if (element instanceof Reaction) { + return new ReactionConverter(colorExtractor); } else { throw new NotImplementedException(new ElementUtils().getElementTag(element) + "Unknown element class"); } @@ -132,7 +139,7 @@ public class ElementConverterImpl implements ElementConverter<Element> { * Converter used for conversion of the {@link Element} given in constructor. */ @SuppressWarnings("rawtypes") - private ElementConverter elementConverter = null; + private BioEntityConverter elementConverter = null; /** * Support constructor. Used in case of SBGN format display @@ -144,7 +151,7 @@ public class ElementConverterImpl implements ElementConverter<Element> { * @param sbgnFormat * boolean value indicating if SBGN display format should be used */ - public ElementConverterImpl(final Element element, final boolean sbgnFormat, ColorExtractor colorExtractor) { + public BioEntityConverterImpl(final AnnotatedObject element, final boolean sbgnFormat, ColorExtractor colorExtractor) { // If element is a nucleic acid feature to be displayed in SBGN if (sbgnFormat && (element instanceof AntisenseRna || element instanceof Rna || element instanceof Gene)) { @@ -156,7 +163,7 @@ public class ElementConverterImpl implements ElementConverter<Element> { // if we don't know which converter to use then throw an exception if (elementConverter == null) { - throw new InvalidArgumentException("Unknown converter for class: " + element.getClass() + ". Element id: " + element.getElementId()); + throw new InvalidArgumentException(new ElementUtils().getElementTag(element) + "Unknown converter for class: " + element.getClass()); } } @@ -168,25 +175,25 @@ public class ElementConverterImpl implements ElementConverter<Element> { * @param element * {@link Element} for which this converter will be used */ - public ElementConverterImpl(final Element element, ColorExtractor colorExtractor) { + public BioEntityConverterImpl(final Element element, ColorExtractor colorExtractor) { this(element, false, colorExtractor); } @SuppressWarnings("unchecked") @Override - public void drawElement(final Element element, final Graphics2D graphics, final ConverterParams params) { - elementConverter.drawElement(element, graphics, params); + public void draw(final AnnotatedObject element, final Graphics2D graphics, final ConverterParams params) { + elementConverter.draw(element, graphics, params); } @SuppressWarnings("unchecked") @Override - public void drawText(final Element element, final Graphics2D graphics, final ConverterParams params) throws DrawingException { + public void drawText(final AnnotatedObject element, final Graphics2D graphics, final ConverterParams params) throws DrawingException { elementConverter.drawText(element, graphics, params); } @SuppressWarnings("unchecked") @Override - public void drawElement(Element element, Graphics2D graphics, ConverterParams params, List<ColorSchema> visualizedLayoutsColorSchemas) { - elementConverter.drawElement(element, graphics, params, visualizedLayoutsColorSchemas); + public void draw(AnnotatedObject element, Graphics2D graphics, ConverterParams params, List<ColorSchema> visualizedLayoutsColorSchemas) { + elementConverter.draw(element, graphics, params, visualizedLayoutsColorSchemas); } } diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/ElementConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/ElementConverter.java new file mode 100644 index 0000000000000000000000000000000000000000..de6dae1ae835ef1efba362861950b1b6b3788f1f --- /dev/null +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/ElementConverter.java @@ -0,0 +1,17 @@ +package lcsb.mapviewer.converter.graphics.bioEntity.element; + +import lcsb.mapviewer.converter.graphics.bioEntity.BioEntityConverter; +import lcsb.mapviewer.model.map.species.Element; + +/** + * This interface defines what operations should be possible to convert + * {@link Element} into a graphics on Graphics2D object. + * + * @author Piotr Gawron + * + * @param <T> + * class of alias to convert + */ +public interface ElementConverter<T extends Element> extends BioEntityConverter<T> { + +} diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/BottomSquareCompartmentConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/BottomSquareCompartmentConverter.java similarity index 90% rename from converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/BottomSquareCompartmentConverter.java rename to converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/BottomSquareCompartmentConverter.java index 07087ec3cda0e74b620bdda4b2b59ed1a0e90fe5..c13cdbdaf24231be3974fe5bc902b7caaf22072b 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/BottomSquareCompartmentConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/BottomSquareCompartmentConverter.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.graphics.compartment; +package lcsb.mapviewer.converter.graphics.bioEntity.element.compartment; import java.awt.Color; import java.awt.Graphics2D; @@ -44,7 +44,7 @@ public class BottomSquareCompartmentConverter extends CompartmentConverter<Botto } @Override - public void drawElement(final BottomSquareCompartment alias, final Graphics2D graphics, final ConverterParams params) { + public void draw(final BottomSquareCompartment alias, final Graphics2D graphics, final ConverterParams params) { // keep the old values of colors and line Color oldColor = graphics.getColor(); Stroke oldStroke = graphics.getStroke(); diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/CompartmentConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/CompartmentConverter.java similarity index 92% rename from converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/CompartmentConverter.java rename to converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/CompartmentConverter.java index ce31fb93bb7d3440fb7c0aeb93c28c7a37cc4e09..93dd6f583e72a5478f4fbfae4540b6df0f66381c 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/CompartmentConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/CompartmentConverter.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.graphics.compartment; +package lcsb.mapviewer.converter.graphics.bioEntity.element.compartment; import java.awt.Color; import java.awt.Font; @@ -14,7 +14,7 @@ import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.geometry.EllipseTransformation; import lcsb.mapviewer.common.geometry.LineTransformation; import lcsb.mapviewer.converter.graphics.ConverterParams; -import lcsb.mapviewer.converter.graphics.ElementConverter; +import lcsb.mapviewer.converter.graphics.bioEntity.element.ElementConverter; import lcsb.mapviewer.converter.graphics.geometry.FontFinder; import lcsb.mapviewer.converter.graphics.geometry.RectangleTooSmallException; import lcsb.mapviewer.converter.graphics.placefinder.PlaceFinder; @@ -175,8 +175,8 @@ public abstract class CompartmentConverter<T extends Compartment> implements Ele } @Override - public void drawElement(T alias, Graphics2D graphics, ConverterParams params, List<ColorSchema> visualizedLayoutsColorSchemas) { - drawElement(alias, graphics, params); + public void draw(T alias, Graphics2D graphics, ConverterParams params, List<ColorSchema> visualizedLayoutsColorSchemas) { + draw(alias, graphics, params); Color oldColor = graphics.getColor(); int count = 0; diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/LeftSquareCompartmentConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/LeftSquareCompartmentConverter.java similarity index 90% rename from converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/LeftSquareCompartmentConverter.java rename to converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/LeftSquareCompartmentConverter.java index a3cac76c0bfe0a722fcc95c45f004c942ce9431e..513684d8ad9e028c08f8e0d7f84f2034f43caebf 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/LeftSquareCompartmentConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/LeftSquareCompartmentConverter.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.graphics.compartment; +package lcsb.mapviewer.converter.graphics.bioEntity.element.compartment; import java.awt.Color; import java.awt.Graphics2D; @@ -44,7 +44,7 @@ public class LeftSquareCompartmentConverter extends CompartmentConverter<LeftSqu } @Override - public void drawElement(final LeftSquareCompartment alias, final Graphics2D graphics, final ConverterParams params) { + public void draw(final LeftSquareCompartment alias, final Graphics2D graphics, final ConverterParams params) { // keep the old values of color and line type Color oldColor = graphics.getColor(); Stroke oldStroke = graphics.getStroke(); diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/OvalCompartmentConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/OvalCompartmentConverter.java similarity index 90% rename from converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/OvalCompartmentConverter.java rename to converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/OvalCompartmentConverter.java index 3c385168fb6c31a65aa5eff8c7e1873afa43b57d..611eb3deade2953f84cf4eaaf47b024479cb04c5 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/OvalCompartmentConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/OvalCompartmentConverter.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.graphics.compartment; +package lcsb.mapviewer.converter.graphics.bioEntity.element.compartment; import java.awt.Color; import java.awt.Graphics2D; @@ -47,7 +47,7 @@ public class OvalCompartmentConverter extends CompartmentConverter<OvalCompartme } @Override - public void drawElement(final OvalCompartment alias, final Graphics2D graphics, final ConverterParams params) { + public void draw(final OvalCompartment alias, final Graphics2D graphics, final ConverterParams params) { // keep the old values of color and line type Color oldColor = graphics.getColor(); Stroke oldStroke = graphics.getStroke(); diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/PathwayCompartmentConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/PathwayCompartmentConverter.java similarity index 89% rename from converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/PathwayCompartmentConverter.java rename to converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/PathwayCompartmentConverter.java index a3d6fd00ffdb31571a81b3acd9e92cc60a7c9554..6d691cfab2def72d712c1f44930ae194b5f151e9 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/PathwayCompartmentConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/PathwayCompartmentConverter.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.graphics.compartment; +package lcsb.mapviewer.converter.graphics.bioEntity.element.compartment; import java.awt.Color; import java.awt.Graphics2D; @@ -40,7 +40,7 @@ public class PathwayCompartmentConverter extends CompartmentConverter<PathwayCom private Color backgroundColor = Color.LIGHT_GRAY; @Override - public void drawElement(final PathwayCompartment alias, final Graphics2D graphics, final ConverterParams params) { + public void draw(final PathwayCompartment alias, final Graphics2D graphics, final ConverterParams params) { // keep the old values of colors and line Color oldColor = graphics.getColor(); Stroke oldStroke = graphics.getStroke(); diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/RightSquareCompartmentConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/RightSquareCompartmentConverter.java similarity index 91% rename from converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/RightSquareCompartmentConverter.java rename to converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/RightSquareCompartmentConverter.java index 72099129b6492cce9758c90f0e32d4e25c0d44cf..c1dbe6fa02feade3f0bdbb25f31a667a0442a376 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/RightSquareCompartmentConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/RightSquareCompartmentConverter.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.graphics.compartment; +package lcsb.mapviewer.converter.graphics.bioEntity.element.compartment; import java.awt.Color; import java.awt.Graphics2D; @@ -44,7 +44,7 @@ public class RightSquareCompartmentConverter extends CompartmentConverter<RightS } @Override - public void drawElement(final RightSquareCompartment alias, final Graphics2D graphics, final ConverterParams params) { + public void draw(final RightSquareCompartment alias, final Graphics2D graphics, final ConverterParams params) { // keep the old values of color and line type Color oldColor = graphics.getColor(); Stroke oldStroke = graphics.getStroke(); diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/SquareCompartmentConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/SquareCompartmentConverter.java similarity index 91% rename from converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/SquareCompartmentConverter.java rename to converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/SquareCompartmentConverter.java index e67b330c239c03743dc7cb27accd089e80a8efc3..169950485e06c1e1e55659969a56d0093a2cacf4 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/SquareCompartmentConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/SquareCompartmentConverter.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.graphics.compartment; +package lcsb.mapviewer.converter.graphics.bioEntity.element.compartment; import java.awt.Color; import java.awt.Graphics2D; @@ -59,7 +59,7 @@ public class SquareCompartmentConverter extends CompartmentConverter<SquareCompa } @Override - public void drawElement(final SquareCompartment alias, final Graphics2D graphics, final ConverterParams params) { + public void draw(final SquareCompartment alias, final Graphics2D graphics, final ConverterParams params) { // keep the old values of color and line type Color oldColor = graphics.getColor(); Stroke oldStroke = graphics.getStroke(); diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/TopSquareCompartmentConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/TopSquareCompartmentConverter.java similarity index 90% rename from converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/TopSquareCompartmentConverter.java rename to converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/TopSquareCompartmentConverter.java index b074e084f5a04ee262d697be3c8896df9cf3f0fc..bdc72589df5e084cef1f4954297159415bf597af 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/TopSquareCompartmentConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/TopSquareCompartmentConverter.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.graphics.compartment; +package lcsb.mapviewer.converter.graphics.bioEntity.element.compartment; import java.awt.Color; import java.awt.Graphics2D; @@ -44,7 +44,7 @@ public class TopSquareCompartmentConverter extends CompartmentConverter<TopSquar } @Override - public void drawElement(final TopSquareCompartment alias, final Graphics2D graphics, final ConverterParams params) { + public void draw(final TopSquareCompartment alias, final Graphics2D graphics, final ConverterParams params) { Color oldColor = graphics.getColor(); Stroke oldStroke = graphics.getStroke(); diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/package-info.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/package-info.java similarity index 59% rename from converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/package-info.java rename to converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/package-info.java index 238015b528866ec59541387f040aa29e41c1b991..992fd5cbdd9dfdfd4011f20370be4540a06eab61 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/package-info.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/package-info.java @@ -2,4 +2,4 @@ * Provides classes that draws different implemention of * {@link Compartment} on the {@link Graphics2D}. */ -package lcsb.mapviewer.converter.graphics.compartment; +package lcsb.mapviewer.converter.graphics.bioEntity.element.compartment; diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/AntisenseRnaConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/AntisenseRnaConverter.java similarity index 93% rename from converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/AntisenseRnaConverter.java rename to converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/AntisenseRnaConverter.java index acc16bc98c697e1728e5f007131d20e9e1fc7698..84d00dc02a8c969fcc03de52697d7d17a7f988cb 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/AntisenseRnaConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/AntisenseRnaConverter.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.graphics.species; +package lcsb.mapviewer.converter.graphics.bioEntity.element.species; import java.awt.Color; import java.awt.Font; @@ -50,7 +50,7 @@ public class AntisenseRnaConverter extends SpeciesConverter<AntisenseRna> { @Override - public void drawElement(final AntisenseRna alias, final Graphics2D graphics, final ConverterParams params) { + public void draw(final AntisenseRna alias, final Graphics2D graphics, final ConverterParams params) { GeneralPath path = getAntisenseRnaPath(alias); Color c = graphics.getColor(); graphics.setColor(alias.getColor()); diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/ComplexConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/ComplexConverter.java similarity index 94% rename from converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/ComplexConverter.java rename to converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/ComplexConverter.java index 6a59e89cc68ad9229d7118f5df8ebefaac3a4695..345fb9394478a769db5eb1ffeee759a457a08b7f 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/ComplexConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/ComplexConverter.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.graphics.species; +package lcsb.mapviewer.converter.graphics.bioEntity.element.species; import java.awt.Color; import java.awt.Font; @@ -58,7 +58,7 @@ public class ComplexConverter extends SpeciesConverter<Complex> { @Override - public void drawElement(final Complex alias, final Graphics2D graphics, final ConverterParams params) { + public void draw(final Complex alias, final Graphics2D graphics, final ConverterParams params) { if (alias.getState().equalsIgnoreCase("complexnoborder")) { return; } diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/DegradedConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/DegradedConverter.java similarity index 92% rename from converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/DegradedConverter.java rename to converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/DegradedConverter.java index de6bcebb35da9439fd6481b637120d3c3532410d..42152ef9f1c518e85485ab9c268049202831b667 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/DegradedConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/DegradedConverter.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.graphics.species; +package lcsb.mapviewer.converter.graphics.bioEntity.element.species; import java.awt.Color; import java.awt.Graphics2D; @@ -50,7 +50,7 @@ public class DegradedConverter extends SpeciesConverter<Degraded> { } @Override - public void drawElement(final Degraded alias, final Graphics2D graphics, final ConverterParams params) { + public void draw(final Degraded alias, final Graphics2D graphics, final ConverterParams params) { double diameter = getDiameter(alias); double x = getXCoord(alias, diameter); double y = getYCoord(alias); diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/DrugConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/DrugConverter.java similarity index 92% rename from converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/DrugConverter.java rename to converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/DrugConverter.java index f55cf04258bfecf782c8c28dd94e6fddad6b9fc8..4c412634f46f78414c63f1a7426463cd1aaeb92d 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/DrugConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/DrugConverter.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.graphics.species; +package lcsb.mapviewer.converter.graphics.bioEntity.element.species; import java.awt.Color; import java.awt.Graphics2D; @@ -68,7 +68,7 @@ public class DrugConverter extends SpeciesConverter<Drug> { } @Override - public void drawElement(Drug alias, final Graphics2D graphics, final ConverterParams params) { + public void draw(Drug alias, final Graphics2D graphics, final ConverterParams params) { Shape a1 = getDrugShape(alias); double offset = OFFSET_BETWEEN_BORDERS; Shape a2 = new RoundRectangle2D.Double( diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/GeneConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/GeneConverter.java similarity index 93% rename from converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/GeneConverter.java rename to converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/GeneConverter.java index f5493ee149bf9f9270bc0b25eeb205ca0bcf3b2b..514475cf86205411fc334f3dc88b411aecde5443 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/GeneConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/GeneConverter.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.graphics.species; +package lcsb.mapviewer.converter.graphics.bioEntity.element.species; import java.awt.Color; import java.awt.Font; @@ -48,7 +48,7 @@ public class GeneConverter extends SpeciesConverter<Gene> { } @Override - public void drawElement(final Gene alias, final Graphics2D graphics, final ConverterParams params) { + public void draw(final Gene alias, final Graphics2D graphics, final ConverterParams params) { Shape shape = getGeneShape(alias); Color c = graphics.getColor(); graphics.setColor(alias.getColor()); diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/IonConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/IonConverter.java similarity index 92% rename from converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/IonConverter.java rename to converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/IonConverter.java index fe8699ac7232e1d7468cc45a52834fb9c2309c89..733f3b7ddb0dcf1f165360352c9e603854b8db3f 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/IonConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/IonConverter.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.graphics.species; +package lcsb.mapviewer.converter.graphics.bioEntity.element.species; import java.awt.Color; import java.awt.Graphics2D; @@ -45,7 +45,7 @@ public class IonConverter extends SpeciesConverter<Ion> { } @Override - public void drawElement(Ion alias, final Graphics2D graphics, final ConverterParams params) { + public void draw(Ion alias, final Graphics2D graphics, final ConverterParams params) { double diameter = getDiameter(alias); double x = getXCoord(alias, diameter); double y = getYCoord(alias); diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/PhenotypeConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/PhenotypeConverter.java similarity index 91% rename from converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/PhenotypeConverter.java rename to converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/PhenotypeConverter.java index 4ca043e2104412058387ac522854ba0350a028f6..0a6a2a059b9bd3d4cf9024797bd17d88c112b949 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/PhenotypeConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/PhenotypeConverter.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.graphics.species; +package lcsb.mapviewer.converter.graphics.bioEntity.element.species; import java.awt.Color; import java.awt.Graphics2D; @@ -44,7 +44,7 @@ public class PhenotypeConverter extends SpeciesConverter<Phenotype> { } @Override - public void drawElement(Phenotype alias, final Graphics2D graphics, final ConverterParams params) { + public void draw(Phenotype alias, final Graphics2D graphics, final ConverterParams params) { GeneralPath path = getPhenotypePath(alias); Color c = graphics.getColor(); diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/ProteinConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/ProteinConverter.java similarity index 96% rename from converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/ProteinConverter.java rename to converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/ProteinConverter.java index b3af8c09cb91bea6ed909a61ab5a3a002e12a1c3..0e794ffa6e425ca2af04a2a9d87c185b3728ebb3 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/ProteinConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/ProteinConverter.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.graphics.species; +package lcsb.mapviewer.converter.graphics.bioEntity.element.species; import java.awt.Color; import java.awt.Font; @@ -89,7 +89,7 @@ public class ProteinConverter extends SpeciesConverter<Protein> { } @Override - public void drawElement(final Protein alias, final Graphics2D graphics, final ConverterParams params) { + public void draw(final Protein alias, final Graphics2D graphics, final ConverterParams params) { // Local variable setting the SBGN visualization boolean sbgnFormat = params.isSbgnFormat(); diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/RnaConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/RnaConverter.java similarity index 94% rename from converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/RnaConverter.java rename to converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/RnaConverter.java index 6b13ac398f659d0b965f6f2d8797e720511443e4..277a8afc651d80665eaf652fd9d4dae4622926b4 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/RnaConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/RnaConverter.java @@ -5,7 +5,7 @@ * Object that helps to convert {@link ColorSchema} values into * colors when drawing {@link Species} */ -package lcsb.mapviewer.converter.graphics.species; +package lcsb.mapviewer.converter.graphics.bioEntity.element.species; import java.awt.Color; import java.awt.Font; @@ -55,7 +55,7 @@ public class RnaConverter extends SpeciesConverter<Rna> { } @Override - public void drawElement(final Rna alias, final Graphics2D graphics, final ConverterParams params) { + public void draw(final Rna alias, final Graphics2D graphics, final ConverterParams params) { GeneralPath path = getRnaPath(alias); Color c = graphics.getColor(); graphics.setColor(alias.getColor()); diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/SBGNNucleicAcidFeatureConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SBGNNucleicAcidFeatureConverter.java similarity index 93% rename from converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/SBGNNucleicAcidFeatureConverter.java rename to converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SBGNNucleicAcidFeatureConverter.java index 8dc25a7ffdc7ca1c1062f006dcc39fc15f75612b..5412c1b961a4f388bf754aea9e8452528312722c 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/SBGNNucleicAcidFeatureConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SBGNNucleicAcidFeatureConverter.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.graphics.species; +package lcsb.mapviewer.converter.graphics.bioEntity.element.species; import java.awt.Color; import java.awt.Graphics2D; @@ -64,7 +64,7 @@ public class SBGNNucleicAcidFeatureConverter extends SpeciesConverter<Species> { } @Override - public void drawElement(Species alias, Graphics2D graphics, ConverterParams params) { + public void draw(Species alias, Graphics2D graphics, ConverterParams params) { // Unit of information text - multimer cardinality String unitOfInformationText = null; if (alias.getStatePrefix() != null && alias.getStateLabel() != null) { diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/SimpleMoleculeConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SimpleMoleculeConverter.java similarity index 93% rename from converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/SimpleMoleculeConverter.java rename to converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SimpleMoleculeConverter.java index ca287bfc971da7cc9ab21e0174bc187887b99543..8abca141bd11232bed19933a0737079b56a8c016 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/SimpleMoleculeConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SimpleMoleculeConverter.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.graphics.species; +package lcsb.mapviewer.converter.graphics.bioEntity.element.species; import java.awt.Color; import java.awt.Graphics2D; @@ -42,7 +42,7 @@ public class SimpleMoleculeConverter extends SpeciesConverter<SimpleMolecule> { } @Override - public void drawElement(final SimpleMolecule alias, final Graphics2D graphics, final ConverterParams params) { + public void draw(final SimpleMolecule alias, final Graphics2D graphics, final ConverterParams params) { int homodir; if (params.isSbgnFormat()) { // If the SBGN display mode is set, multimer is shown as two stacked diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/SpeciesConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SpeciesConverter.java similarity index 95% rename from converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/SpeciesConverter.java rename to converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SpeciesConverter.java index cf3ca8313cb36184ca0b76ab1da5090fe3f8ac53..1f861eaef450bfb122e15e09c39c9199c79586dd 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/SpeciesConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SpeciesConverter.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.graphics.species; +package lcsb.mapviewer.converter.graphics.bioEntity.element.species; import java.awt.Color; import java.awt.Font; @@ -21,7 +21,7 @@ import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.common.geometry.EllipseTransformation; import lcsb.mapviewer.common.geometry.LineTransformation; import lcsb.mapviewer.converter.graphics.ConverterParams; -import lcsb.mapviewer.converter.graphics.ElementConverter; +import lcsb.mapviewer.converter.graphics.bioEntity.element.ElementConverter; import lcsb.mapviewer.model.graphics.LineType; import lcsb.mapviewer.model.map.layout.ColorSchema; import lcsb.mapviewer.model.map.species.Complex; @@ -576,8 +576,8 @@ public abstract class SpeciesConverter<T extends Species> implements ElementConv } @Override - public void drawElement(T alias, Graphics2D graphics, ConverterParams params, List<ColorSchema> visualizedLayoutsColorSchemas) { - drawElement(alias, graphics, params); + public void draw(T alias, Graphics2D graphics, ConverterParams params, List<ColorSchema> visualizedLayoutsColorSchemas) { + draw(alias, graphics, params); Color oldColor = graphics.getColor(); int count = 0; diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/UnknownConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/UnknownConverter.java similarity index 91% rename from converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/UnknownConverter.java rename to converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/UnknownConverter.java index 4d2045ebf9b86289bebdfb842b970ed688d1f31c..e304953c08b75d94805cb84ae052e4c912611228 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/UnknownConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/UnknownConverter.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.graphics.species; +package lcsb.mapviewer.converter.graphics.bioEntity.element.species; import java.awt.Color; import java.awt.Graphics2D; @@ -45,7 +45,7 @@ public class UnknownConverter extends SpeciesConverter<Unknown> { } @Override - public void drawElement(Unknown alias, final Graphics2D graphics, final ConverterParams params) { + public void draw(Unknown alias, final Graphics2D graphics, final ConverterParams params) { if (alias.getActivity()) { int border = ACTIVITY_BORDER_DISTANCE; alias.increaseBorder(border); diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/package-info.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/package-info.java similarity index 65% rename from converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/package-info.java rename to converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/package-info.java index 19c8857d76af552ecc6677e4120e7f498e72c447..2fb83e5d857d08503c4d1c7840c238107400c650 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/package-info.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/package-info.java @@ -3,5 +3,5 @@ * {@link lcsb.mapviewer.db.model.map.species.Species Species} on the Graphics2D * object. */ -package lcsb.mapviewer.converter.graphics.species; +package lcsb.mapviewer.converter.graphics.bioEntity.element.species; diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/reaction/ReactionConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/reaction/ReactionConverter.java similarity index 74% rename from converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/reaction/ReactionConverter.java rename to converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/reaction/ReactionConverter.java index 2697266eb836e792f109627dfb8afde82d028b29..0060e3a9b30d90ef72dd75b6d85a650e36401f65 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/reaction/ReactionConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/reaction/ReactionConverter.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.graphics.reaction; +package lcsb.mapviewer.converter.graphics.bioEntity.reaction; import java.awt.Color; import java.awt.Font; @@ -15,12 +15,19 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.commands.ColorExtractor; import lcsb.mapviewer.common.Pair; +import lcsb.mapviewer.common.exception.InvalidArgumentException; +import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.common.geometry.LineTransformation; import lcsb.mapviewer.common.geometry.PointTransformation; +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.ArrowType; import lcsb.mapviewer.model.graphics.ArrowTypeData; import lcsb.mapviewer.model.graphics.PolylineData; +import lcsb.mapviewer.model.map.AnnotatedObject; +import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.layout.ColorSchema; import lcsb.mapviewer.model.map.layout.GenericColorSchema; import lcsb.mapviewer.model.map.reaction.AbstractNode; @@ -29,7 +36,11 @@ import lcsb.mapviewer.model.map.reaction.NodeOperator; import lcsb.mapviewer.model.map.reaction.Product; import lcsb.mapviewer.model.map.reaction.Reactant; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.reaction.ReactionNode; import lcsb.mapviewer.model.map.reaction.type.ReactionRect; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Species; /** * Thics class allows to draw reaction on the graphics2D. @@ -37,7 +48,7 @@ import lcsb.mapviewer.model.map.reaction.type.ReactionRect; * @author Piotr Gawron * */ -public class ReactionConverter { +public class ReactionConverter implements BioEntityConverter<Reaction> { /** * When drawing operator this value defines radius of the joining operator @@ -184,35 +195,34 @@ public class ReactionConverter { } } - /** - * Draw reaction on the graphics2D. - * - * @param reaction - * object to be drawn - * @param graphics - * where we want to draw the object - * @param sbgnFormat - * true if reaction is to be drawn in SBGN format - */ - public void drawReaction(final Reaction reaction, final Graphics2D graphics, boolean sbgnFormat) { + @Override + public void draw(final Reaction reaction, final Graphics2D graphics, final ConverterParams params) { Color color = graphics.getColor(); graphics.setColor(reaction.getReactants().get(0).getLine().getColor()); // first reactants for (Reactant reactant : reaction.getReactants()) { - drawReactant(graphics, reactant); + if (isVisible(reactant, params)) { + drawReactant(graphics, reactant); + } } // now products for (Product product : reaction.getProducts()) { - drawProduct(graphics, product); + if (isVisible(product, params)) { + drawProduct(graphics, product); + } } // draw modifiers for (Modifier modifier : reaction.getModifiers()) { - drawModifier(graphics, modifier); + if (isVisible(modifier, params)) { + drawModifier(graphics, modifier); + } } // and operators for (NodeOperator operator : reaction.getOperators()) { - drawOperator(graphics, operator, sbgnFormat); + if (isVisible(operator, params)) { + drawOperator(graphics, operator, params.isSbgnFormat()); + } } // in the end we draw rectangle in the middle @@ -220,6 +230,71 @@ public class ReactionConverter { graphics.setColor(color); } + private boolean isVisible(AbstractNode node, ConverterParams params) { + if (node instanceof NodeOperator) { + return isVisible((NodeOperator) node, params); + } else if (node instanceof ReactionNode) { + return isVisible(((ReactionNode) node).getElement(), params); + } else { + throw new InvalidArgumentException("Unknown class type: " + node.getClass()); + } + } + + private boolean isVisible(NodeOperator operator, ConverterParams params) { + boolean result = false; + if (operator.isModifierOperator() || operator.isReactantOperator()) { + for (AbstractNode input : operator.getInputs()) { + result |= isVisible(input, params); + } + } else if (operator.isProductOperator()) { + for (AbstractNode output : operator.getOutputs()) { + result |= isVisible(output, params); + } + } else { + throw new InvalidStateException("Unknown class state: " + operator); + } + return result; + } + + private boolean isVisible(AnnotatedObject bioEntity, ConverterParams params) { + if (params.isSemanticZoomingOn()) { + boolean result = matchLevel(params.getLevel(), bioEntity.getSemanticZoomLevelVisibility()); + if (bioEntity instanceof Element) { + Compartment compartment = ((Element) bioEntity).getCompartment(); + if (compartment != null) { + result &= isVisible(compartment, params); + } + if (bioEntity instanceof Species) { + Complex complex = ((Species) bioEntity).getComplex(); + if (complex != null) { + result &= isVisible(complex, params); + } + } + } + return result; + } + return true; + } + + private boolean matchLevel(int level, String semanticZoomLevelVisibility) { + if (semanticZoomLevelVisibility == null || semanticZoomLevelVisibility.isEmpty()) { + return true; + } + if (semanticZoomLevelVisibility.contains("{")) { + String strLevels = semanticZoomLevelVisibility.replace("{", "").replace("}", ""); + String[] ranges = strLevels.split(","); + for (String string : ranges) { + if (Integer.valueOf(string).equals(level)) { + return true; + } + } + } + if (Integer.valueOf(semanticZoomLevelVisibility) <= level) { + return true; + } + return false; + } + /** * Draw reaction on the graphics2D. * @@ -233,19 +308,19 @@ public class ReactionConverter { * list of {@link ColorSchema} that were used for visualizing this * alias in different layouts that should be overlayed on the alias */ - public void drawReaction(final Reaction reaction, final Graphics2D graphics, boolean sbgnFormat, List<ColorSchema> visualizedLayoutsColorSchemas) { + public void draw(final Reaction reaction, final Graphics2D graphics, final ConverterParams params, List<ColorSchema> visualizedLayoutsColorSchemas) { if (visualizedLayoutsColorSchemas.size() == 0) { - drawReaction(reaction, graphics, sbgnFormat); + draw(reaction, graphics, params); } else if (visualizedLayoutsColorSchemas.size() == 1) { if (visualizedLayoutsColorSchemas.get(0) == null) { - drawReaction(reaction, graphics, sbgnFormat); + draw(reaction, graphics, params); } else { List<Pair<AbstractNode, PolylineData>> oldData = new ArrayList<>(); for (AbstractNode node : reaction.getNodes()) { oldData.add(new Pair<AbstractNode, PolylineData>(node, node.getLine())); } applyColorSchema(reaction, visualizedLayoutsColorSchemas.get(0)); - drawReaction(reaction, graphics, sbgnFormat); + draw(reaction, graphics, params); for (Pair<AbstractNode, PolylineData> pair : oldData) { pair.getLeft().setLine(pair.getRight()); } @@ -258,14 +333,14 @@ public class ReactionConverter { } } if (count == 0) { - drawReaction(reaction, graphics, sbgnFormat); + draw(reaction, graphics, params); } else { List<Pair<AbstractNode, PolylineData>> oldData = new ArrayList<>(); for (AbstractNode node : reaction.getNodes()) { oldData.add(new Pair<AbstractNode, PolylineData>(node, node.getLine())); } applyColorSchema(reaction, DEFAULT_COLOR_SCHEMA); - drawReaction(reaction, graphics, sbgnFormat); + draw(reaction, graphics, params); for (Pair<AbstractNode, PolylineData> pair : oldData) { pair.getLeft().setLine(pair.getRight()); } @@ -448,4 +523,8 @@ public class ReactionConverter { this.pointTransformation = pointTransformation; } + @Override + public void drawText(Reaction bioEntity, Graphics2D graphics, ConverterParams params) throws DrawingException { + } + } \ No newline at end of file diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/reaction/package-info.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/reaction/package-info.java similarity index 70% rename from converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/reaction/package-info.java rename to converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/reaction/package-info.java index b03d32c941ee5fe702e8d7f4c90dea7e9e647549..d3b737737c9fcfe6f3b63b74d9496584f2c6f67a 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/reaction/package-info.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/reaction/package-info.java @@ -3,5 +3,5 @@ * {@link lcsb.mapviewer.db.model.map.reaction.Reaction reactions} on the * {@link java.awt.Graphics2D Graphics2D} object. */ -package lcsb.mapviewer.converter.graphics.reaction; +package lcsb.mapviewer.converter.graphics.bioEntity.reaction; diff --git a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/AllGraphicsTests.java b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/AllGraphicsTests.java index 940247e162a4ea2ab262dbc9012f928d5fcf0a06..940785356395983a48c340979d981a2d65ffd175 100644 --- a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/AllGraphicsTests.java +++ b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/AllGraphicsTests.java @@ -1,9 +1,9 @@ package lcsb.mapviewer.converter.graphics; +import lcsb.mapviewer.converter.graphics.bioEntity.element.species.AllSpeciesConverterTests; +import lcsb.mapviewer.converter.graphics.bioEntity.reaction.AllReactionTests; import lcsb.mapviewer.converter.graphics.geometry.AllGeometryTests; import lcsb.mapviewer.converter.graphics.placefinder.AllPlaceFinderTest; -import lcsb.mapviewer.converter.graphics.reaction.AllReactionTests; -import lcsb.mapviewer.converter.graphics.species.AllSpeciesConverterTests; import org.junit.runner.RunWith; import org.junit.runners.Suite; diff --git a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/ConverterTest.java b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/ConverterTest.java index 66e7eaa7edd963b522a6713a7e7c66d0bd7ad385..59f4964c758ef2dd761a65abd1d6196885e54d99 100644 --- a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/ConverterTest.java +++ b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/ConverterTest.java @@ -7,6 +7,7 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.commands.ColorExtractor; +import lcsb.mapviewer.converter.graphics.bioEntity.BioEntityConverterImpl; import lcsb.mapviewer.model.map.compartment.BottomSquareCompartment; import lcsb.mapviewer.model.map.compartment.LeftSquareCompartment; import lcsb.mapviewer.model.map.compartment.RightSquareCompartment; @@ -26,10 +27,10 @@ public class ConverterTest { public void test() { try { ColorExtractor colorExtractor = new ColorExtractor(Color.BLUE, Color.RED); - new ElementConverterImpl(new BottomSquareCompartment("id1"), colorExtractor); - new ElementConverterImpl(new TopSquareCompartment("id2"), colorExtractor); - new ElementConverterImpl(new LeftSquareCompartment("id3"), colorExtractor); - new ElementConverterImpl(new RightSquareCompartment("id4"), colorExtractor); + new BioEntityConverterImpl(new BottomSquareCompartment("id1"), colorExtractor); + new BioEntityConverterImpl(new TopSquareCompartment("id2"), colorExtractor); + new BioEntityConverterImpl(new LeftSquareCompartment("id3"), colorExtractor); + new BioEntityConverterImpl(new RightSquareCompartment("id4"), colorExtractor); } catch (Exception e) { e.printStackTrace(); throw e; diff --git a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/NormalImageGeneratorTest.java b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/NormalImageGeneratorTest.java index 36d384f0070428c4f17bd8681ab851e7a1fa8a9b..36d84707d1901ea6c5e5a23e32f1f975708fcbef 100644 --- a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/NormalImageGeneratorTest.java +++ b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/NormalImageGeneratorTest.java @@ -15,7 +15,7 @@ import org.junit.Test; import lcsb.mapviewer.commands.ColorExtractor; import lcsb.mapviewer.commands.CreateHierarchyCommand; import lcsb.mapviewer.converter.graphics.AbstractImageGenerator.Params; -import lcsb.mapviewer.converter.graphics.species.ComplexConverter; +import lcsb.mapviewer.converter.graphics.bioEntity.element.species.ComplexConverter; import lcsb.mapviewer.model.graphics.PolylineData; import lcsb.mapviewer.model.map.layout.graphics.Layer; import lcsb.mapviewer.model.map.layout.graphics.LayerText; diff --git a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/species/AllSpeciesConverterTests.java b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/AllSpeciesConverterTests.java similarity index 73% rename from converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/species/AllSpeciesConverterTests.java rename to converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/AllSpeciesConverterTests.java index f964383c73143a290d137f3c480472d4585ad1fc..69e9b97b05c9d7cd6406a6a214914ee29c84da1a 100644 --- a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/species/AllSpeciesConverterTests.java +++ b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/AllSpeciesConverterTests.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.graphics.species; +package lcsb.mapviewer.converter.graphics.bioEntity.element.species; import org.junit.runner.RunWith; import org.junit.runners.Suite; diff --git a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/species/SpeciesConverterTest.java b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SpeciesConverterTest.java similarity index 87% rename from converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/species/SpeciesConverterTest.java rename to converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SpeciesConverterTest.java index bc8c2b2eaf147564f64e636c39878aee078b08c5..1bdacdc9d7ea94ec4328ca4f6305873286000a4a 100644 --- a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/species/SpeciesConverterTest.java +++ b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SpeciesConverterTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.graphics.species; +package lcsb.mapviewer.converter.graphics.bioEntity.element.species; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -15,6 +15,7 @@ import org.junit.Test; import lcsb.mapviewer.commands.ColorExtractor; import lcsb.mapviewer.converter.graphics.ConverterParams; +import lcsb.mapviewer.converter.graphics.bioEntity.element.species.ProteinConverter; import lcsb.mapviewer.model.map.layout.ColorSchema; import lcsb.mapviewer.model.map.layout.GenericColorSchema; import lcsb.mapviewer.model.map.species.GenericProtein; @@ -65,7 +66,7 @@ public class SpeciesConverterTest { ProteinConverter rc = new ProteinConverter(colorExtractor); GenericProtein alias = createAlias(); - rc.drawElement(alias, graphics, new ConverterParams()); + rc.draw(alias, graphics, new ConverterParams()); int val = bi.getRGB((int) alias.getCenterX(), (int) alias.getCenterY()); @@ -79,7 +80,7 @@ public class SpeciesConverterTest { List<ColorSchema> schemas = new ArrayList<>(); schemas.add(schema); - rc.drawElement(alias2, graphics, new ConverterParams(), schemas); + rc.draw(alias2, graphics, new ConverterParams(), schemas); int val2 = bi.getRGB((int) alias.getCenterX(), (int) alias.getCenterY()); @@ -98,7 +99,7 @@ public class SpeciesConverterTest { ProteinConverter rc = new ProteinConverter(colorExtractor); GenericProtein alias = createAlias(); - rc.drawElement(alias, graphics, new ConverterParams()); + rc.draw(alias, graphics, new ConverterParams()); int val = bi.getRGB((int) alias.getCenterX(), (int) alias.getCenterY()); @@ -112,14 +113,14 @@ public class SpeciesConverterTest { List<ColorSchema> schemas = new ArrayList<>(); schemas.add(schema); - rc.drawElement(alias2, graphics, new ConverterParams(), schemas); + rc.draw(alias2, graphics, new ConverterParams(), schemas); int val2 = bi.getRGB((int) alias.getCenterX(), (int) alias.getCenterY()); bi = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB); graphics = bi.createGraphics(); - rc.drawElement(alias2, graphics, new ConverterParams(), new ArrayList<>()); + rc.draw(alias2, graphics, new ConverterParams(), new ArrayList<>()); int val3 = bi.getRGB((int) alias.getCenterX(), (int) alias.getCenterY()); @@ -139,7 +140,7 @@ public class SpeciesConverterTest { ProteinConverter rc = new ProteinConverter(colorExtractor); GenericProtein alias = createAlias(); - rc.drawElement(alias, graphics, new ConverterParams()); + rc.draw(alias, graphics, new ConverterParams()); int val = bi.getRGB((int) alias.getCenterX(), (int) alias.getCenterY()); @@ -157,7 +158,7 @@ public class SpeciesConverterTest { schema.setColor(Color.BLUE); schemas.add(schema); - rc.drawElement(alias2, graphics, new ConverterParams(), schemas); + rc.draw(alias2, graphics, new ConverterParams(), schemas); int val2 = bi.getRGB((int) (alias.getX() + alias.getWidth() / 4), (int) alias.getCenterY()); int val3 = bi.getRGB((int) (alias.getCenterX()), (int) alias.getCenterY()); diff --git a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/reaction/AllReactionTests.java b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/reaction/AllReactionTests.java similarity index 74% rename from converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/reaction/AllReactionTests.java rename to converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/reaction/AllReactionTests.java index 532c850e89d8ab6200a64dd06d859fd0c5690b00..eb1ffeb4e95d059ab4f43d9ce91824429a3ae726 100644 --- a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/reaction/AllReactionTests.java +++ b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/reaction/AllReactionTests.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.graphics.reaction; +package lcsb.mapviewer.converter.graphics.bioEntity.reaction; import org.junit.runner.RunWith; import org.junit.runners.Suite; diff --git a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/reaction/ReactionConverterTest.java b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/reaction/ReactionConverterTest.java new file mode 100644 index 0000000000000000000000000000000000000000..6d2fe4eb5e8eb990290aede6ee4cfcb8cc431d42 --- /dev/null +++ b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/reaction/ReactionConverterTest.java @@ -0,0 +1,407 @@ +package lcsb.mapviewer.converter.graphics.bioEntity.reaction; + +import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.awt.Color; +import java.awt.Desktop; +import java.awt.FontMetrics; +import java.awt.Graphics2D; +import java.awt.geom.GeneralPath; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.imageio.ImageIO; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.output.ByteArrayOutputStream; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; + +import lcsb.mapviewer.commands.ColorExtractor; +import lcsb.mapviewer.converter.graphics.ConverterParams; +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.modifier.Catalysis; +import lcsb.mapviewer.model.map.reaction.AndOperator; +import lcsb.mapviewer.model.map.reaction.Modifier; +import lcsb.mapviewer.model.map.reaction.OrOperator; +import lcsb.mapviewer.model.map.reaction.Product; +import lcsb.mapviewer.model.map.reaction.Reactant; +import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.reaction.SplitOperator; +import lcsb.mapviewer.model.map.species.GenericProtein; + +public class ReactionConverterTest { + + ColorExtractor colorExtractor = new ColorExtractor(Color.RED, Color.GREEN); + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testDrawReactionWithLayouts() throws Exception { + try { + BufferedImage bi = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB); + Graphics2D graphics = bi.createGraphics(); + ReactionConverter rc = new ReactionConverter(colorExtractor); + + Reaction reaction = createReaction(5.0); + rc.draw(reaction, graphics, new ConverterParams().sbgnFormat(false)); + + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + ImageIO.write(bi, "PNG", outputStream); + byte[] output1 = outputStream.toByteArray(); + + Reaction reaction2 = createReaction(1.0); + + bi = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB); + graphics = bi.createGraphics(); + + ColorSchema schema = new GenericColorSchema(); + schema.setColor(Color.BLACK); + schema.setLineWidth(5.0); + List<ColorSchema> schemas = new ArrayList<>(); + schemas.add(schema); + + rc.draw(reaction2, graphics, new ConverterParams().sbgnFormat(false), schemas); + + outputStream = new ByteArrayOutputStream(); + ImageIO.write(bi, "PNG", outputStream); + byte[] output2 = outputStream.toByteArray(); + + // FileUtils.writeByteArrayToFile(new File("tmp.png"), output1); + // FileUtils.writeByteArrayToFile(new File("tmp2.png"), output2); + // + // Desktop.getDesktop().open(new File("tmp.png")); + // Desktop.getDesktop().open(new File("tmp2.png")); + + assertTrue(Arrays.equals(output1, output2)); + + } catch (Exception e) { + throw e; + } + } + + @Test + public void testDrawAfterDrawingReactionWithLayouts() throws Exception { + try { + BufferedImage bi = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB); + Graphics2D graphics = bi.createGraphics(); + ReactionConverter rc = new ReactionConverter(colorExtractor); + + Reaction reaction = createReaction(1.0); + rc.draw(reaction, graphics, new ConverterParams().sbgnFormat(false)); + + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + ImageIO.write(bi, "PNG", outputStream); + byte[] output1 = outputStream.toByteArray(); + + Reaction reaction2 = createReaction(1.0); + + bi = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB); + graphics = bi.createGraphics(); + + ColorSchema schema = new GenericColorSchema(); + schema.setColor(Color.BLACK); + schema.setLineWidth(5.0); + List<ColorSchema> schemas = new ArrayList<>(); + schemas.add(schema); + + rc.draw(reaction2, graphics, new ConverterParams().sbgnFormat(false), schemas); + bi = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB); + graphics = bi.createGraphics(); + rc.draw(reaction2, graphics, new ConverterParams().sbgnFormat(false), new ArrayList<>()); + + outputStream = new ByteArrayOutputStream(); + ImageIO.write(bi, "PNG", outputStream); + byte[] output2 = outputStream.toByteArray(); + + // FileUtils.writeByteArrayToFile(new File("tmp.png"), output1); + // FileUtils.writeByteArrayToFile(new File("tmp2.png"), output2); + // + // Desktop.getDesktop().open(new File("tmp.png")); + // Desktop.getDesktop().open(new File("tmp2.png")); + + assertTrue(Arrays.equals(output1, output2)); + + } catch (Exception e) { + throw e; + } + } + + @Test + public void testDrawReactionWithFewLayouts() throws Exception { + try { + BufferedImage bi = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB); + Graphics2D graphics = bi.createGraphics(); + ReactionConverter rc = new ReactionConverter(colorExtractor); + + Reaction reaction = createReaction(3.0); + rc.draw(reaction, graphics, new ConverterParams().sbgnFormat(false)); + + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + ImageIO.write(bi, "PNG", outputStream); + byte[] output1 = outputStream.toByteArray(); + + Reaction reaction2 = createReaction(1.0); + + bi = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB); + graphics = bi.createGraphics(); + + ColorSchema schema = new GenericColorSchema(); + schema.setColor(Color.BLACK); + schema.setLineWidth(5.0); + List<ColorSchema> schemas = new ArrayList<>(); + schemas.add(schema); + schemas.add(schema); + + rc.draw(reaction2, graphics, new ConverterParams().sbgnFormat(false), schemas); + + outputStream = new ByteArrayOutputStream(); + ImageIO.write(bi, "PNG", outputStream); + byte[] output2 = outputStream.toByteArray(); + + // FileUtils.writeByteArrayToFile(new File("tmp.png"), output1); + // FileUtils.writeByteArrayToFile(new File("tmp2.png"), output2); + // + // Desktop.getDesktop().open(new File("tmp.png")); + // Desktop.getDesktop().open(new File("tmp2.png")); + + assertTrue(Arrays.equals(output1, output2)); + + } catch (Exception e) { + throw e; + } + } + + private Reaction createReaction(double lineWidth) { + Reaction result = new Reaction(); + + Modifier modifier = new Catalysis(new GenericProtein("s1")); + modifier.setLine(new PolylineData(new Point2D.Double(100, 20), new Point2D.Double(100, 80))); + modifier.getLine().setWidth(lineWidth); + + Reactant reactant = new Reactant(new GenericProtein("s2")); + reactant.setLine(new PolylineData(new Point2D.Double(90, 90), new Point2D.Double(10, 90))); + reactant.getLine().setWidth(lineWidth); + Product product = new Product(new GenericProtein("s3")); + product.setLine(new PolylineData(new Point2D.Double(200, 90), new Point2D.Double(110, 90))); + product.getLine().setWidth(lineWidth); + result.addModifier(modifier); + result.addProduct(product); + result.addReactant(reactant); + return result; + } + + private Reaction createComplexReaction(double lineWidth) { + Reaction result = new Reaction(); + + Modifier modifier1 = new Catalysis(new GenericProtein("s1-1")); + modifier1.setLine(new PolylineData(new Point2D.Double(80, 20), new Point2D.Double(100, 40))); + modifier1.getLine().setWidth(lineWidth); + + Modifier modifier2 = new Catalysis(new GenericProtein("s1-2")); + modifier2.setLine(new PolylineData(new Point2D.Double(120, 20), new Point2D.Double(100, 40))); + modifier2.getLine().setWidth(lineWidth); + + AndOperator modifierOperator = new AndOperator(); + modifierOperator.addInput(modifier1); + modifierOperator.addInput(modifier2); + modifierOperator.setLine(new PolylineData(new Point2D.Double(100, 40), new Point2D.Double(100, 80))); + + Reactant reactant1 = new Reactant(new GenericProtein("s2-1")); + reactant1.setLine(new PolylineData(new Point2D.Double(60, 90), new Point2D.Double(10, 70))); + reactant1.getLine().setWidth(lineWidth); + Reactant reactant2 = new Reactant(new GenericProtein("s2-1")); + reactant2.setLine(new PolylineData(new Point2D.Double(60, 90), new Point2D.Double(10, 110))); + reactant2.getLine().setWidth(lineWidth); + OrOperator reactantOperator = new OrOperator(); + reactantOperator.addInput(reactant1); + reactantOperator.addInput(reactant2); + reactantOperator.setLine(new PolylineData(new Point2D.Double(60, 90), new Point2D.Double(90, 90))); + + Product product1 = new Product(new GenericProtein("s3-1")); + product1.setLine(new PolylineData(new Point2D.Double(200, 70), new Point2D.Double(130, 90))); + product1.getLine().setWidth(lineWidth); + Product product2 = new Product(new GenericProtein("s3-2")); + product2.setLine(new PolylineData(new Point2D.Double(200, 110), new Point2D.Double(130, 90))); + product2.getLine().setWidth(lineWidth); + SplitOperator productOperator = new SplitOperator(); + productOperator.addOutput(product1); + productOperator.addOutput(product2); + productOperator.setLine(new PolylineData(new Point2D.Double(130, 90), new Point2D.Double(110, 90))); + + result.addModifier(modifier1); + result.addModifier(modifier2); + result.addNode(modifierOperator); + result.addProduct(product1); + result.addProduct(product2); + result.addNode(productOperator); + result.addReactant(reactant1); + result.addReactant(reactant2); + result.addNode(reactantOperator); + return result; + } + + @Test + public void testDrawReactionWithSemanticZooming() throws Exception { + try { + Graphics2D graphics = Mockito.mock(Graphics2D.class); + ReactionConverter rc = new ReactionConverter(colorExtractor); + + Reaction reaction = createReaction(1.0); + rc.draw(reaction, graphics, new ConverterParams().semanticZoomingOn(true).level(10)); + + verify(graphics, times(4)).draw(any(GeneralPath.class)); + + } catch (Exception e) { + throw e; + } + } + + @Test + public void testDrawReactionWithSemanticZoomingAndModifierOff() throws Exception { + try { + Graphics2D graphics = Mockito.mock(Graphics2D.class); + ReactionConverter rc = new ReactionConverter(colorExtractor); + + Reaction reaction = createReaction(1.0); + reaction.getModifiers().get(0).getElement().setSemanticZoomLevelVisibility("11"); + rc.draw(reaction, graphics, new ConverterParams().semanticZoomingOn(true).level(10)); + + verify(graphics, times(3)).draw(any(GeneralPath.class)); + + } catch (Exception e) { + throw e; + } + } + + @Test + public void testDrawReactionWithSemanticZoomingAndReactantOff() throws Exception { + try { + Graphics2D graphics = Mockito.mock(Graphics2D.class); + ReactionConverter rc = new ReactionConverter(colorExtractor); + + Reaction reaction = createReaction(1.0); + reaction.getReactants().get(0).getElement().setSemanticZoomLevelVisibility("11"); + rc.draw(reaction, graphics, new ConverterParams().semanticZoomingOn(true).level(10)); + + verify(graphics, times(3)).draw(any(GeneralPath.class)); + + } catch (Exception e) { + throw e; + } + } + + @Test + public void testDrawReactionWithSemanticZoomingAndProductOff() throws Exception { + try { + Graphics2D graphics = Mockito.mock(Graphics2D.class); + ReactionConverter rc = new ReactionConverter(colorExtractor); + + Reaction reaction = createReaction(1.0); + reaction.getProducts().get(0).getElement().setSemanticZoomLevelVisibility("11"); + rc.draw(reaction, graphics, new ConverterParams().semanticZoomingOn(true).level(10)); + + verify(graphics, times(3)).draw(any(GeneralPath.class)); + + } catch (Exception e) { + throw e; + } + } + + @Test + public void testDrawComplexReactionWithSemanticZoomingAndModiferOff() throws Exception { + try { + Graphics2D graphics = createGraphicsMock(); + ReactionConverter rc = new ReactionConverter(colorExtractor); + + Reaction reaction = createComplexReaction(1.0); + reaction.getModifiers().get(0).getElement().setSemanticZoomLevelVisibility("11"); + rc.draw(reaction, graphics, new ConverterParams().semanticZoomingOn(true).level(10)); + + verify(graphics, times(12)).draw(any(GeneralPath.class)); + + } catch (Exception e) { + throw e; + } + } + + @Test + public void testDrawComplexReactionWithSemanticZoomingAndAllModifersOff() throws Exception { + try { + Graphics2D graphics = createGraphicsMock(); + ReactionConverter rc = new ReactionConverter(colorExtractor); + + Reaction reaction = createComplexReaction(1.0); + reaction.getModifiers().get(0).getElement().setSemanticZoomLevelVisibility("11"); + reaction.getModifiers().get(1).getElement().setSemanticZoomLevelVisibility("11"); + rc.draw(reaction, graphics, new ConverterParams().semanticZoomingOn(true).level(10)); + + verify(graphics, times(9)).draw(any(GeneralPath.class)); + + } catch (Exception e) { + throw e; + } + } + + private Graphics2D createGraphicsMock() { + Graphics2D graphics = Mockito.mock(Graphics2D.class); + FontMetrics fontMetrics = Mockito.mock(FontMetrics.class); + when(fontMetrics.getStringBounds(any(), any())).thenReturn(new Rectangle2D.Double()); + when(graphics.getFontMetrics()).thenReturn(fontMetrics); + return graphics; + } + + @Test + public void testDrawComplexReactionWithSemanticZoomingAndReactantOff() throws Exception { + try { + Graphics2D graphics = createGraphicsMock(); + ReactionConverter rc = new ReactionConverter(colorExtractor); + + Reaction reaction = createComplexReaction(1.0); + reaction.getReactants().get(0).getElement().setSemanticZoomLevelVisibility("11"); + rc.draw(reaction, graphics, new ConverterParams().semanticZoomingOn(true).level(10)); + + verify(graphics, times(12)).draw(any(GeneralPath.class)); + + } catch (Exception e) { + throw e; + } + } + + @Test + public void testDrawComplexReactionWithSemanticZoomingAndProductOff() throws Exception { + try { + Graphics2D graphics = createGraphicsMock(); + ReactionConverter rc = new ReactionConverter(colorExtractor); + + Reaction reaction = createComplexReaction(1.0); + reaction.getProducts().get(0).getElement().setSemanticZoomLevelVisibility("11"); + rc.draw(reaction, graphics, new ConverterParams().semanticZoomingOn(true).level(10)); + + verify(graphics, times(12)).draw(any(GeneralPath.class)); + + } catch (Exception e) { + throw e; + } + } + +} diff --git a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/reaction/ReactionConverterTest.java b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/reaction/ReactionConverterTest.java deleted file mode 100644 index fa4a9c6b2b145e8f3f3ea2f6b450c254a06d6f96..0000000000000000000000000000000000000000 --- a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/reaction/ReactionConverterTest.java +++ /dev/null @@ -1,196 +0,0 @@ -package lcsb.mapviewer.converter.graphics.reaction; - -import static org.junit.Assert.assertTrue; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.geom.Point2D; -import java.awt.image.BufferedImage; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import javax.imageio.ImageIO; - -import org.apache.commons.io.output.ByteArrayOutputStream; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import lcsb.mapviewer.commands.ColorExtractor; -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.modifier.Catalysis; -import lcsb.mapviewer.model.map.reaction.Modifier; -import lcsb.mapviewer.model.map.reaction.Product; -import lcsb.mapviewer.model.map.reaction.Reactant; -import lcsb.mapviewer.model.map.reaction.Reaction; - -public class ReactionConverterTest { - - ColorExtractor colorExtractor = new ColorExtractor(Color.RED, Color.GREEN); - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testDrawReactionWithLayouts() throws Exception { - try { - BufferedImage bi = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB); - Graphics2D graphics = bi.createGraphics(); - ReactionConverter rc = new ReactionConverter(colorExtractor); - - Reaction reaction = createReaction(5.0); - rc.drawReaction(reaction, graphics, false); - - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - ImageIO.write(bi, "PNG", outputStream); - byte[] output1 = outputStream.toByteArray(); - - Reaction reaction2 = createReaction(1.0); - - bi = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB); - graphics = bi.createGraphics(); - - ColorSchema schema = new GenericColorSchema(); - schema.setColor(Color.BLACK); - schema.setLineWidth(5.0); - List<ColorSchema> schemas = new ArrayList<>(); - schemas.add(schema); - - rc.drawReaction(reaction2, graphics, false, schemas); - - outputStream = new ByteArrayOutputStream(); - ImageIO.write(bi, "PNG", outputStream); - byte[] output2 = outputStream.toByteArray(); - - // FileUtils.writeByteArrayToFile(new File("tmp.png"), output1); - // FileUtils.writeByteArrayToFile(new File("tmp2.png"), output2); - // - // Desktop.getDesktop().open(new File("tmp.png")); - // Desktop.getDesktop().open(new File("tmp2.png")); - - assertTrue(Arrays.equals(output1, output2)); - - } catch (Exception e) { - throw e; - } - } - - @Test - public void testDrawAfterDrawingReactionWithLayouts() throws Exception { - try { - BufferedImage bi = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB); - Graphics2D graphics = bi.createGraphics(); - ReactionConverter rc = new ReactionConverter(colorExtractor); - - Reaction reaction = createReaction(1.0); - rc.drawReaction(reaction, graphics, false); - - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - ImageIO.write(bi, "PNG", outputStream); - byte[] output1 = outputStream.toByteArray(); - - Reaction reaction2 = createReaction(1.0); - - bi = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB); - graphics = bi.createGraphics(); - - ColorSchema schema = new GenericColorSchema(); - schema.setColor(Color.BLACK); - schema.setLineWidth(5.0); - List<ColorSchema> schemas = new ArrayList<>(); - schemas.add(schema); - - rc.drawReaction(reaction2, graphics, false, schemas); - bi = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB); - graphics = bi.createGraphics(); - rc.drawReaction(reaction2, graphics, false, new ArrayList<>()); - - outputStream = new ByteArrayOutputStream(); - ImageIO.write(bi, "PNG", outputStream); - byte[] output2 = outputStream.toByteArray(); - - // FileUtils.writeByteArrayToFile(new File("tmp.png"), output1); - // FileUtils.writeByteArrayToFile(new File("tmp2.png"), output2); - // - // Desktop.getDesktop().open(new File("tmp.png")); - // Desktop.getDesktop().open(new File("tmp2.png")); - - assertTrue(Arrays.equals(output1, output2)); - - } catch (Exception e) { - throw e; - } - } - - @Test - public void testDrawReactionWithFewLayouts() throws Exception { - try { - BufferedImage bi = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB); - Graphics2D graphics = bi.createGraphics(); - ReactionConverter rc = new ReactionConverter(colorExtractor); - - Reaction reaction = createReaction(3.0); - rc.drawReaction(reaction, graphics, false); - - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - ImageIO.write(bi, "PNG", outputStream); - byte[] output1 = outputStream.toByteArray(); - - Reaction reaction2 = createReaction(1.0); - - bi = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB); - graphics = bi.createGraphics(); - - ColorSchema schema = new GenericColorSchema(); - schema.setColor(Color.BLACK); - schema.setLineWidth(5.0); - List<ColorSchema> schemas = new ArrayList<>(); - schemas.add(schema); - schemas.add(schema); - - rc.drawReaction(reaction2, graphics, false, schemas); - - outputStream = new ByteArrayOutputStream(); - ImageIO.write(bi, "PNG", outputStream); - byte[] output2 = outputStream.toByteArray(); - - // FileUtils.writeByteArrayToFile(new File("tmp.png"), output1); - // FileUtils.writeByteArrayToFile(new File("tmp2.png"), output2); - // - // Desktop.getDesktop().open(new File("tmp.png")); - // Desktop.getDesktop().open(new File("tmp2.png")); - - assertTrue(Arrays.equals(output1, output2)); - - } catch (Exception e) { - throw e; - } - } - - private Reaction createReaction(double lineWidth) { - Reaction result = new Reaction(); - Modifier modifier = new Catalysis(); - modifier.setLine(new PolylineData(new Point2D.Double(10, 20), new Point2D.Double(10, 100))); - modifier.getLine().setWidth(lineWidth); - - Reactant reactant = new Reactant(); - reactant.setLine(new PolylineData(new Point2D.Double(100, 20), new Point2D.Double(100, 100))); - reactant.getLine().setWidth(lineWidth); - Product product = new Product(); - product.setLine(new PolylineData(new Point2D.Double(150, 20), new Point2D.Double(150, 100))); - product.getLine().setWidth(lineWidth); - result.addModifier(modifier); - result.addProduct(product); - result.addReactant(reactant); - return result; - } - -} diff --git a/model/src/main/java/lcsb/mapviewer/model/map/AnnotatedObject.java b/model/src/main/java/lcsb/mapviewer/model/map/AnnotatedObject.java index e13e3aa8648abd1b1ab023b1545aa4a151d6615b..cca3829b5240cd05fd511edf93cd51c514cc603c 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/AnnotatedObject.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/AnnotatedObject.java @@ -126,13 +126,15 @@ public interface AnnotatedObject extends Serializable { void setName(String name); int getId(); - /** * Return human readable {@link String} representing class. * * @return human readable {@link String} representing class */ - public abstract String getStringType(); - + String getStringType(); + + void setSemanticZoomLevelVisibility(String zoomLevelVisibility); + + String getSemanticZoomLevelVisibility(); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/reaction/Reaction.java b/model/src/main/java/lcsb/mapviewer/model/map/reaction/Reaction.java index 90c1e5cdc6b7efd6fa4076858312a6f7513941ee..79059ab4cb1124f75cf000368fca4bcf3bfcdd8d 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/reaction/Reaction.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/reaction/Reaction.java @@ -180,6 +180,11 @@ public class Reaction implements AnnotatedObject { */ private String geneProteinReaction = null; + /** + * Zoom level visibility for semantic zooming. + */ + private String zoomLevelVisibility; + /** * Lists of all synonyms used for describing this element. */ @@ -867,4 +872,14 @@ public class Reaction implements AnnotatedObject { this.synonyms.add(synonym); } + @Override + public String getSemanticZoomLevelVisibility() { + return zoomLevelVisibility; + } + + @Override + public void setSemanticZoomLevelVisibility(String zoomLevelVisibility) { + this.zoomLevelVisibility = zoomLevelVisibility; + } + } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/Element.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Element.java index e624b92ffb386407e46def4e5e20c34d7e050c8b..80530dda25a2054e2047923bb3ac015d3baf9052 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/Element.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Element.java @@ -214,6 +214,11 @@ public abstract class Element implements AnnotatedObject, Serializable { */ private String fullName; + /** + * Zoom level visibility for semantic zooming. + */ + private String zoomLevelVisibility; + /** * Abbreviation associated with the element. */ @@ -1086,4 +1091,13 @@ public abstract class Element implements AnnotatedObject, Serializable { dataMining.setElement(this); } + @Override + public void setSemanticZoomLevelVisibility(String zoomLevelVisibility) { + this.zoomLevelVisibility = zoomLevelVisibility; + } + + public String getSemanticZoomLevelVisibility(){ + return this.zoomLevelVisibility; + } + } \ No newline at end of file