diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/cache/WebPageDownloader.java b/annotation/src/main/java/lcsb/mapviewer/annotation/cache/WebPageDownloader.java index 9a7e8d6fe33c600b4c321c5af9e2ed88da9654b8..80d2c2f7a7d76259ebfd9e032514fb1d70abf7be 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/cache/WebPageDownloader.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/cache/WebPageDownloader.java @@ -4,7 +4,6 @@ import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; -import java.net.ConnectException; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; @@ -85,8 +84,8 @@ public class WebPageDownloader { urlConn.setRequestMethod("GET"); urlConn.addRequestProperty("User-Agent", "minerva-framework"); try { - urlConn.connect(); - code = urlConn.getResponseCode(); + urlConn.connect(); + code = urlConn.getResponseCode(); } catch (FileNotFoundException e) { code = HttpURLConnection.HTTP_NOT_FOUND; } catch (IOException e) { diff --git a/commons/src/main/java/lcsb/mapviewer/common/Configuration.java b/commons/src/main/java/lcsb/mapviewer/common/Configuration.java index 4db91ad32b813654ab30e0ec872690109f6c1398..8afe7171c40f77edb086d39c1258edee4c7be199 100644 --- a/commons/src/main/java/lcsb/mapviewer/common/Configuration.java +++ b/commons/src/main/java/lcsb/mapviewer/common/Configuration.java @@ -67,6 +67,10 @@ public final class Configuration { * Where the main webpgae is located. */ public static final String MAIN_PAGE = "/index.xhtml"; + + /** + * Name of the cookie for authentication token. + */ public static final String AUTH_TOKEN = "MINERVA_AUTH_TOKEN"; /** diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/annotation/NoteField.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/annotation/NoteField.java index db00f59da024510942394ca4db3cf790efa3d0f4..f9ec3e0770b7e80ca0f178a8dded4d8d3aa8dcf8 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/annotation/NoteField.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/annotation/NoteField.java @@ -5,6 +5,8 @@ import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSpecies import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Species; /** * Describes structural information that appears in the cell designer notes. @@ -116,7 +118,12 @@ public enum NoteField { /** * {@link Species#charge}. */ - CHARGE("Charge", CellDesignerSpecies.class, null); // + CHARGE("Charge", CellDesignerSpecies.class, null), // + + /** + * {@link Element#getSemanticZoomLevelVisibility()}. + */ + SEMANTIC_ZOOM_LEVEL_VISIBILITY("SemanticZoomLevelVisibility", AnnotatedObject.class, null); // /** * Name used in the notes to distinguish fields. diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/annotation/RestAnnotationParser.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/annotation/RestAnnotationParser.java index b46d75a00ff20d1f8623ba227e437b44f9d5ce6c..a1ab11fc4ad10cb3e8b74f6fb9e6b0196013f9b4 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/annotation/RestAnnotationParser.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/annotation/RestAnnotationParser.java @@ -562,6 +562,28 @@ public class RestAnnotationParser extends XmlParser { } } + /** + * Assigns semanticZoomingLevel to the element from notes string. + * + * @param element + * element to which data should be put to + * @param annotationString + * notes string + */ + private void setSemanticZoomLevelVisibility(AnnotatedObject element, String annotationString) { + String zoomLevelVisibility = getParamByPrefix(annotationString, NoteField.SEMANTIC_ZOOM_LEVEL_VISIBILITY.getCommonName() + ":"); + if (zoomLevelVisibility == null) { + return; + } + if (element.getSemanticZoomLevelVisibility() == null) { + element.setSemanticZoomLevelVisibility(zoomLevelVisibility); + } else if (!element.getSemanticZoomLevelVisibility().equals(zoomLevelVisibility)) { + logger.warn( + elementUtils.getElementTag(element) + " New " + NoteField.SEMANTIC_ZOOM_LEVEL_VISIBILITY.getCommonName() + " different than default [" + + zoomLevelVisibility + "][" + element.getSemanticZoomLevelVisibility() + "]. Ignoring."); + } + } + /** * Assigns notes to the element from notes string. This might look strange. * The idea is that sometimes we have notes from more then one source. And the @@ -620,6 +642,7 @@ public class RestAnnotationParser extends XmlParser { setNotes(object, ann); setSymbol(object, ann); setSynonyms(object, ann); + setSemanticZoomLevelVisibility(object, ann); setAbbreviation(object, ann); setFormula(object, ann); if (object instanceof Reaction) { 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..16e997154b53d5419fbf41c379f9d409dd39ac33 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,8 @@ 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.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 +172,16 @@ public abstract class AbstractImageGenerator { * Should the visualization include hierarchical view or not. */ private boolean nested = false; - + + /** + * Should the visualization include semantic zoom view or not. + */ + private boolean semanticZoom = false; + /** * Should sbgn standard be used. */ - private boolean sbgn = false; + private boolean sbgn = false; /** * List of objects containging information about layouts visualized in the @@ -208,6 +213,17 @@ public abstract class AbstractImageGenerator { return this; } + /** + * @param semanticZoom + * semanticZoom to set + * @return object with all parameters + * @see #semanticZoom + */ + public Params semanticZoom(boolean semanticZoom) { + this.semanticZoom = semanticZoom; + return this; + } + /** * @param scale * scale to set @@ -561,7 +577,8 @@ public abstract class AbstractImageGenerator { } /** - * @param sbgn the sbgn to set + * @param sbgn + * the sbgn to set * @see #sbgn * @return object with all parameters */ @@ -659,13 +676,13 @@ public abstract class AbstractImageGenerator { // compartment/complexes) if (element instanceof Species) { if (((Species) element).getComplex() == null) { - drawSpecies((Species) element, params.getVisibleLayoutsForElement(element)); + drawSpecies((Species) element, params.getVisibleLayoutsForElement(element), params); } } } // draw all reactions for (Reaction reaction : params.getModel().getSortedReactions()) { - drawReaction(reaction, params.getVisibleLayoutsForElement(reaction)); + drawReaction(reaction, params.getVisibleLayoutsForElement(reaction), params); } // draw all compartments for (Compartment compartment : params.getModel().getSortedCompartments()) { @@ -738,8 +755,8 @@ public abstract class AbstractImageGenerator { } // get a converter for this compartment - ElementConverterImpl converter = new ElementConverterImpl(compartment, colorExtractor); - ConverterParams compartmentParams = new ConverterParams().textCentered(fill).level(level); + BioEntityConverterImpl converter = new BioEntityConverterImpl(compartment, colorExtractor); + ConverterParams compartmentParams = new ConverterParams().textCentered(fill).level(level).semanticZoomingOn(params.semanticZoom); if (nested) { compartmentParams.fill(fill).scale(Math.max(scale, 1)); @@ -749,7 +766,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); } @@ -769,7 +786,7 @@ public abstract class AbstractImageGenerator { for (Element element : result) { // if a child is a standard species if (element instanceof Species) { - drawSpecies((Species) element, params.getVisibleLayoutsForElement(element)); + drawSpecies((Species) element, params.getVisibleLayoutsForElement(element), params); } else if (element instanceof Compartment) { drawCompartment((Compartment) element, nested, params.getVisibleLayoutsForElement(element), params); } else { @@ -793,10 +810,12 @@ public abstract class AbstractImageGenerator { * object to be drawn * @param visibleLayouts * list of {@link ColorSchema} used for coloring species in layouts + * @param params + * list of all params to create apropriate image * @throws DrawingException * thrown when there was a problem with drawing a {@link Species} */ - protected void drawSpecies(final Species species, List<ColorSchema> visibleLayouts) throws DrawingException { + protected void drawSpecies(final Species species, List<ColorSchema> visibleLayouts, Params params) throws DrawingException { // The displaying of species is indicated by values of VisibilityLevel. If // VisibilityLevel is big enough, then it is @@ -825,14 +844,16 @@ 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).semanticZoomingOn(params.semanticZoom), + visibleLayouts); } catch (Exception e) { throw new DrawingException(eu.getElementTag(species) + "Problem with drawing element.", e); } @@ -847,7 +868,7 @@ public abstract class AbstractImageGenerator { // depending on current zoom level, children are drawn or not if (complex.getTransparencyLevel() <= level) { for (Species a : complex.getElements()) { - drawSpecies(a, visibleLayouts); + drawSpecies(a, visibleLayouts, params); } } } @@ -861,13 +882,15 @@ public abstract class AbstractImageGenerator { * object to be drawn * @param visibleLayouts * list of {@link ColorSchema} used for coloring reaction in layouts + * @param params + * list of all params to create apropriate image */ - protected void drawReaction(final Reaction reaction, List<ColorSchema> visibleLayouts) { + protected void drawReaction(final Reaction reaction, List<ColorSchema> visibleLayouts, Params params) { 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).semanticZoomingOn(params.semanticZoom).level(level), 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/ElementConverter.java deleted file mode 100644 index d1992b796ce8c4c30531713a9f4e9451cfd89a05..0000000000000000000000000000000000000000 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/ElementConverter.java +++ /dev/null @@ -1,73 +0,0 @@ -package lcsb.mapviewer.converter.graphics; - -import java.awt.Graphics2D; -import java.util.List; - -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. - * - * @author Piotr Gawron - * - * @param <T> - * class of alias to convert - */ -public interface ElementConverter<T extends Element> { - /** - * Alpha value (0..255) used for visualizing layout data that are normally - * visualized in javascript. - */ - int LAYOUT_ALPHA = 200; - - /** - * This function draw representation of the alias on the graphics object. - * - * @param alias - * alias that should be drawn - * @param graphics - * where we want to draw alias - * @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); - - /** - * This function draw representation of the alias on the graphics object. - * - * @param alias - * alias that should be drawn - * @param graphics - * where we want to draw alias - * @param params - * visuzalization params (like, should the object be filled with - * solid color, etc.), for more information see - * {@link ConverterParams} - * @param visualizedLayoutsColorSchemas - * list of {@link ColorSchema} that were used for visualizing this - * alias in different layouts that should be overlayed on the alias - * - */ - void drawElement(T alias, Graphics2D graphics, ConverterParams params, List<ColorSchema> visualizedLayoutsColorSchemas); - - /** - * 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 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 - */ - void drawText(T alias, Graphics2D graphics, ConverterParams params) throws DrawingException; - -} diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/MapGenerator.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/MapGenerator.java index d9e35b48dfd43e10d49d4a9e2c4a9a7a61bb8f05..5e44baf42537fb87f7051a0005efa08c45a86f97 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/MapGenerator.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/MapGenerator.java @@ -57,21 +57,25 @@ public class MapGenerator { * Do we want to generate images in hierarchical view or normal. * */ - private boolean nested = false; + private boolean nested = false; + /** + * Do we want to generate images with semantic zoom view or not. + */ + private boolean semanticZoom = false; /** * Should we remove empty elements in nested view. * */ - private boolean removeEmpty = false; + private boolean removeEmpty = false; /** * Callback function that update progress information. * */ - private IProgressUpdater updater = new IProgressUpdater() { - @Override - public void setProgress(double progress) { - } - }; + private IProgressUpdater updater = new IProgressUpdater() { + @Override + public void setProgress(double progress) { + } + }; /** * Zoom factor on the lowest level. @@ -135,6 +139,17 @@ public class MapGenerator { return this; } + /** + * @param semanticZoom + * the semanticZoom to set + * @see #nested + * @return full {@link MapGeneratorParams} object + */ + public MapGeneratorParams semanticZoom(boolean semanticZoom) { + this.semanticZoom = semanticZoom; + return this; + } + /** * @return the removeEmpty * @see #removeEmpty @@ -326,6 +341,8 @@ public class MapGenerator { imgParams.height(TILE_SIZE * TILES_CACHE_NUM); imgParams.model(params.model); imgParams.sbgn(params.sbgn); + imgParams.level(i); + imgParams.semanticZoom(params.semanticZoom); if (params.nested) { imgParams.level(i).nested(params.nested); diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/BioEntityConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/BioEntityConverter.java new file mode 100644 index 0000000000000000000000000000000000000000..0f3fbea1f767125d5922bbed62ae53ee300e4999 --- /dev/null +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/BioEntityConverter.java @@ -0,0 +1,253 @@ +package lcsb.mapviewer.converter.graphics.bioEntity; + +import java.awt.Graphics2D; +import java.util.ArrayList; +import java.util.List; + +import org.apache.log4j.Logger; + +import lcsb.mapviewer.common.exception.InvalidArgumentException; +import lcsb.mapviewer.common.exception.InvalidStateException; +import lcsb.mapviewer.converter.graphics.ConverterParams; +import lcsb.mapviewer.converter.graphics.DrawingException; +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.reaction.AbstractNode; +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.species.Complex; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Species; + +/** + * This interface defines what operations should be possible to convert + * {@link AnnotatedObject} into a graphics on Graphics2D object. + * + * @author Piotr Gawron + * + * @param <T> + * class of alias to convert + */ +public abstract class BioEntityConverter<T extends AnnotatedObject> { + + /** + * Default class logger. + */ + @SuppressWarnings("unused") + private final Logger logger = Logger.getLogger(BioEntityConverter.class); + + /** + * Alpha value (0..255) used for visualizing overlay data that are normally + * visualized in javascript. + */ + public static final int LAYOUT_ALPHA = 200; + + /** + * This function draw representation of the alias on the graphics object. + * + * @param bioEntity + * {@link AnnotatedObject} that should be drawn + * @param graphics + * 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} + * + */ + public void draw(T bioEntity, Graphics2D graphics, ConverterParams params) { + draw(bioEntity, graphics, params, new ArrayList<>()); + } + + /** + * This function draw representation of the alias on the graphics object. + * + * @param bioEntity + * {@link AnnotatedObject} that should be drawn + * @param graphics + * 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 visualizedOverlaysColorSchemas + * list of {@link ColorSchema} that were used for visualizing this + * bioentity in different data overlays that should be overlayed on + * the alias + * + */ + public abstract 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 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 bioEntity + */ + public abstract void drawText(T bioEntity, Graphics2D graphics, ConverterParams params) throws DrawingException; + + /** + * Checks if {@link AbstractNode} is visible according to visualization given + * in params. + * + * @param node + * visibility of this object will be checked + * @param params + * visualization params + * @return true if object is visible + */ + protected 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()); + } + } + + /** + * Checks if {@link NodeOperator} is visible according to visualization given + * in params. + * + * @param operator + * visibility of this object will be checked + * @param params + * visualization params + * @return true if object is visible + */ + protected 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; + } + + /** + * Checks if {@link AnnotatedObject} is visible according to visualization + * given in params. + * + * @param bioEntity + * visibility of this object will be checked + * @param params + * visualization params + * @return true if object is visible + */ + protected 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); + } + } + } else if (bioEntity instanceof Reaction) { + if (!isAnyProductVisible(((Reaction) bioEntity).getProducts(), params)) { + result = false; + } else if (!isAnyReactantVisible(((Reaction) bioEntity).getReactants(), params)) { + result = false; + } + + } else { + throw new InvalidArgumentException("Unknown class type: " + bioEntity.getClass()); + } + + return result; + } + return true; + } + + /** + * Checks if at least one reactant is visible. + * + * @param reactants + * list of reactants + * @param params + * params against which check is run + * @return true if at least one reactant is visible + */ + private boolean isAnyReactantVisible(List<Reactant> reactants, ConverterParams params) { + boolean result = false; + for (Reactant reactant : reactants) { + if (isVisible(reactant, params)) { + result = true; + } + } + return result; + } + + /** + * Checks if at least one product is visible. + * + * @param products + * list of products + * @param params + * params against which check is run + * @return true if at least one product is visible + */ + private boolean isAnyProductVisible(List<Product> products, ConverterParams params) { + boolean result = false; + for (Product product : products) { + if (isVisible(product, params)) { + result = true; + } + } + return result; + } + + /** + * Checks if level belongs to the range defined in + * semanticZoomLevelVisibility. + * + * @param level + * level to ve checked + * @param semanticZoomLevelVisibility + * range of levels to be checked + * @return true if level is in the range + */ + protected 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; + } + +} 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..bb68987a1ce1d12af1161f848bfea2622930a5ce 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 extends 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,24 @@ 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 drawText(final AnnotatedObject element, final Graphics2D graphics, final ConverterParams params) throws DrawingException { + if (isVisible(element, params)) { + elementConverter.drawText(element, graphics, params); + } } @SuppressWarnings("unchecked") @Override - public void drawText(final Element element, final Graphics2D graphics, final ConverterParams params) throws DrawingException { - elementConverter.drawText(element, graphics, params); + public void draw(AnnotatedObject element, Graphics2D graphics, ConverterParams params, List<ColorSchema> visualizedLayoutsColorSchemas) { + if (isVisible(element, params)) { + elementConverter.draw(element, graphics, params, visualizedLayoutsColorSchemas); + } } - @SuppressWarnings("unchecked") - @Override - public void drawElement(Element element, Graphics2D graphics, ConverterParams params, List<ColorSchema> visualizedLayoutsColorSchemas) { - elementConverter.drawElement(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..1bec6b8f64c1e7350cac580ae3b56077b7a5b273 --- /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 abstract class 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 91% 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..555a06d3d0e4ffb5246bc36d5b137c9c9b8d79c6 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; @@ -31,7 +31,7 @@ import lcsb.mapviewer.model.map.layout.ColorSchema; * class for which the comparator is created * */ -public abstract class CompartmentConverter<T extends Compartment> implements ElementConverter<T> { +public abstract class CompartmentConverter<T extends Compartment> extends ElementConverter<T> { /** * Default class logger. @@ -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/bioEntity/element/package-info.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..2a4ce8bf838bfe86d594989af69d186381caa8e7 --- /dev/null +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/package-info.java @@ -0,0 +1,5 @@ +/** + * Provides classes that draws {@link lcsb.mapviewer.model.map.species.Element + * Elements} on the Graphics2D object. + */ +package lcsb.mapviewer.converter.graphics.bioEntity.element; 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 94% 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..73cb492d1e5dbf4873b41fb636622ca5add02b16 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; @@ -37,7 +37,7 @@ import lcsb.mapviewer.model.map.species.Species; * @author Piotr Gawron * */ -public abstract class SpeciesConverter<T extends Species> implements ElementConverter<T> { +public abstract class SpeciesConverter<T extends Species> extends ElementConverter<T> { /** * PI value. @@ -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/bioEntity/element/species/package-info.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..bb5eba0424d844789420b16d4b88a0c4c8962213 --- /dev/null +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/package-info.java @@ -0,0 +1,6 @@ +/** + * Provides classes that draws + * {@link lcsb.mapviewer.db.model.map.species.Species Species} on the Graphics2D + * object. + */ +package lcsb.mapviewer.converter.graphics.bioEntity.element.species; diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/package-info.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..128760d664f8f39309c72c3a0713eb13dcd171fc --- /dev/null +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/package-info.java @@ -0,0 +1,5 @@ +/** + * Provides classes that draws {@link lcsb.mapviewer.model.map.AnnotatedObject + * BioEntites} on the Graphics2D object. + */ +package lcsb.mapviewer.converter.graphics.bioEntity; 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 86% 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..1881210ae7ea63ec35a9382d0950bafea12cfc9d 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; @@ -17,6 +17,9 @@ import lcsb.mapviewer.commands.ColorExtractor; import lcsb.mapviewer.common.Pair; 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; @@ -37,7 +40,7 @@ import lcsb.mapviewer.model.map.reaction.type.ReactionRect; * @author Piotr Gawron * */ -public class ReactionConverter { +public class ReactionConverter extends BioEntityConverter<Reaction> { /** * When drawing operator this value defines radius of the joining operator @@ -184,35 +187,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,32 +222,20 @@ public class ReactionConverter { graphics.setColor(color); } - /** - * 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 - * @param visualizedLayoutsColorSchemas - * 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) { + @Override + 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 +248,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 +438,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/main/java/lcsb/mapviewer/converter/graphics/species/package-info.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/package-info.java deleted file mode 100644 index 19c8857d76af552ecc6677e4120e7f498e72c447..0000000000000000000000000000000000000000 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Provides classes that draws aliases of - * {@link lcsb.mapviewer.db.model.map.species.Species Species} on the Graphics2D - * object. - */ -package lcsb.mapviewer.converter.graphics.species; - 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..712c9d780cc68a7801c4536f6d38d703ec5d54e6 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,19 +1,18 @@ package lcsb.mapviewer.converter.graphics; -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; import org.junit.runners.Suite.SuiteClasses; +import lcsb.mapviewer.converter.graphics.bioEntity.AllBioEntityTests; +import lcsb.mapviewer.converter.graphics.geometry.AllGeometryTests; +import lcsb.mapviewer.converter.graphics.placefinder.AllPlaceFinderTest; + @RunWith(Suite.class) -@SuiteClasses({ AllGeometryTests.class, // +@SuiteClasses({ // + AllBioEntityTests.class, // + AllGeometryTests.class, // AllPlaceFinderTest.class, // - AllReactionTests.class, // - AllSpeciesConverterTests.class, // ConverterTest.class, // ImageGeneratorsTest.class, // MapGeneratorTest.class, // 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/bioEntity/AllBioEntityTests.java b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/AllBioEntityTests.java new file mode 100644 index 0000000000000000000000000000000000000000..4feec5c7d2f55a7a9f1e0888bc0ac822acb149ef --- /dev/null +++ b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/AllBioEntityTests.java @@ -0,0 +1,18 @@ +package lcsb.mapviewer.converter.graphics.bioEntity; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +import lcsb.mapviewer.converter.graphics.bioEntity.element.species.AllSpeciesConverterTests; +import lcsb.mapviewer.converter.graphics.bioEntity.reaction.AllReactionTests; + +@RunWith(Suite.class) +@SuiteClasses({ // + AllSpeciesConverterTests.class, // + AllReactionTests.class, // + BioEntityConverterImplTest.class// +}) +public class AllBioEntityTests { + +} diff --git a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/BioEntityConverterImplTest.java b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/BioEntityConverterImplTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8ba25ceb5b694c44954955c85a691d880e1aa439 --- /dev/null +++ b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/BioEntityConverterImplTest.java @@ -0,0 +1,98 @@ +package lcsb.mapviewer.converter.graphics.bioEntity; + +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.geom.GeneralPath; +import java.awt.geom.Point2D; + +import org.junit.After; +import org.junit.AfterClass; +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.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; +import lcsb.mapviewer.model.map.species.GenericProtein; + +public class BioEntityConverterImplTest { + + ColorExtractor colorExtractor = new ColorExtractor(Color.RED, Color.GREEN); + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testDrawReactionWithSemanticZoomingAndReactantOff() throws Exception { + try { + Graphics2D graphics = Mockito.mock(Graphics2D.class); + Reaction reaction = createReaction(1.0); + reaction.getReactants().get(0).getElement().setSemanticZoomLevelVisibility("11"); + + BioEntityConverterImpl rc = new BioEntityConverterImpl(reaction, false, colorExtractor); + rc.draw(reaction, graphics, new ConverterParams().semanticZoomingOn(true).level(10)); + + verify(graphics, times(0)).draw(any(GeneralPath.class)); + + } catch (Exception e) { + throw e; + } + } + + @Test + public void testDrawReactionWithSemanticZoomingAndProductOff() throws Exception { + try { + Graphics2D graphics = Mockito.mock(Graphics2D.class); + + Reaction reaction = createReaction(1.0); + reaction.getProducts().get(0).getElement().setSemanticZoomLevelVisibility("11"); + + BioEntityConverterImpl rc = new BioEntityConverterImpl(reaction, false, colorExtractor); + rc.draw(reaction, graphics, new ConverterParams().semanticZoomingOn(true).level(10)); + + verify(graphics, times(0)).draw(any(GeneralPath.class)); + + } 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; + } + +} 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..4623a640195498ae168413bdec83498a2e4ebc6b --- /dev/null +++ b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/reaction/ReactionConverterTest.java @@ -0,0 +1,404 @@ +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.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.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 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..2a9ec585d0e782d016f3e629837005049d058213 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/AnnotatedObject.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/AnnotatedObject.java @@ -125,14 +125,32 @@ public interface AnnotatedObject extends Serializable { */ void setName(String name); + /** + * Returns database identifier of the object. + * + * @return database identifier of the object + */ int getId(); - /** * Return human readable {@link String} representing class. * * @return human readable {@link String} representing class */ - public abstract String getStringType(); - + String getStringType(); + + /** + * Sets semantic zoom level visibility. + * + * @param zoomLevelVisibility + * semantic zoom level visibility + */ + void setSemanticZoomLevelVisibility(String zoomLevelVisibility); + + /** + * Returns semantic zoom level visibility. + * + * @return semantic zoom level visibility + */ + String getSemanticZoomLevelVisibility(); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/compartment/OvalCompartment.java b/model/src/main/java/lcsb/mapviewer/model/map/compartment/OvalCompartment.java index be5a84f3f9c1349ebe938d52cf86d0de5402f740..3dbbeab40d75cdde78a7c11d1c4e4ed5b54a397d 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/compartment/OvalCompartment.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/compartment/OvalCompartment.java @@ -38,6 +38,12 @@ public class OvalCompartment extends Compartment { super(original); } + /** + * Default constructor. + * + * @param elementId + * identifier of the compartment + */ public OvalCompartment(String elementId) { super(); setElementId(elementId); 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..c1eb4a094427f36cfe14e5d45f7f4061489c688e 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. */ @@ -231,7 +236,7 @@ public class Reaction implements AnnotatedObject { name = original.getName(); reversible = original.reversible; kineticLaw = original.kineticLaw; - miriamDataSet = new HashSet<MiriamData>(); + miriamDataSet = new HashSet<>(); for (MiriamData md : original.getMiriamData()) { miriamDataSet.add(new MiriamData(md)); } @@ -244,10 +249,11 @@ public class Reaction implements AnnotatedObject { upperBound = original.getUpperBound(); subsystem = original.getSubsystem(); geneProteinReaction = original.getGeneProteinReaction(); - synonyms = new ArrayList<String>(); + synonyms = new ArrayList<>(); for (String synonym : original.getSynonyms()) { synonyms.add(synonym); } + setSemanticZoomLevelVisibility(original.getSemanticZoomLevelVisibility()); } @@ -867,4 +873,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..386c2995adde11c9d6870a8b9b243c87ee696007 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,14 @@ public abstract class Element implements AnnotatedObject, Serializable { dataMining.setElement(this); } + @Override + public void setSemanticZoomLevelVisibility(String zoomLevelVisibility) { + this.zoomLevelVisibility = zoomLevelVisibility; + } + + @Override + public String getSemanticZoomLevelVisibility() { + return this.zoomLevelVisibility; + } + } \ No newline at end of file diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/Species.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Species.java index 62875191ca8a99293cb0a87b49e0f4069b891554..237aee82abc42b6d8ce6711067084fcf8006b1b2 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/Species.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Species.java @@ -168,6 +168,7 @@ public abstract class Species extends Element { homodimer = original.getHomodimer(); positionToCompartment = original.getPositionToCompartment(); hypothetical = original.getHypothetical(); + setSemanticZoomLevelVisibility(original.getSemanticZoomLevelVisibility()); // don't copy reaction nodes } diff --git a/persist/src/db/11/fix_db_20170616.sql b/persist/src/db/11/fix_db_20170616.sql new file mode 100644 index 0000000000000000000000000000000000000000..1123f0a8a930fa1bc6fe1b2a40857a0d6621103b --- /dev/null +++ b/persist/src/db/11/fix_db_20170616.sql @@ -0,0 +1,3 @@ +-- semantic zooming +alter table element_table add column zoomlevelvisibility character varying default null; +alter table reaction_table add column zoomlevelvisibility character varying default null; diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/genomics/ReferenceGenomeController.java b/rest-api/src/main/java/lcsb/mapviewer/api/genomics/ReferenceGenomeController.java index 1374985424da145d3af1a72412c0597c673b5152..80caa2d0fdf8af75475909a5233562ddf1e074ea 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/genomics/ReferenceGenomeController.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/genomics/ReferenceGenomeController.java @@ -6,7 +6,6 @@ import org.springframework.web.bind.annotation.CookieValue; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import lcsb.mapviewer.api.BaseController; diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java index d3182f0880ec74f8d3d52d341dc7fa57b0e51e41..1f5526d0370ff3831445b04e5a2d1af8f2437ee5 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java @@ -17,8 +17,6 @@ import org.apache.commons.io.IOUtils; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.RequestParam; import lcsb.mapviewer.api.BaseRestImpl; import lcsb.mapviewer.api.QueryException; @@ -266,19 +264,19 @@ public class ProjectRestImpl extends BaseRestImpl { Double minY = originalModel.getHeight(); Double maxX = 0.0; Double maxY = 0.0; - Path2D polygon = cc.latLngToPolygon(polygonString); - - PathIterator pathIter = polygon.getPathIterator(null); - while (!pathIter.isDone()) { - final double[] segment = new double[PATH_ITERATOR_SEGMENT_SIZE]; - if (pathIter.currentSegment(segment) != PathIterator.SEG_CLOSE) { - minX = Math.min(minX, segment[0]); - maxX = Math.max(maxX, segment[0]); - minY = Math.min(minY, segment[1]); - maxY = Math.max(maxY, segment[1]); - } - pathIter.next(); + Path2D polygon = cc.latLngToPolygon(polygonString); + + PathIterator pathIter = polygon.getPathIterator(null); + while (!pathIter.isDone()) { + final double[] segment = new double[PATH_ITERATOR_SEGMENT_SIZE]; + if (pathIter.currentSegment(segment) != PathIterator.SEG_CLOSE) { + minX = Math.min(minX, segment[0]); + maxX = Math.max(maxX, segment[0]); + minY = Math.min(minY, segment[1]); + maxY = Math.max(maxY, segment[1]); } + pathIter.next(); + } maxX = Math.min(originalModel.getWidth(), maxX); maxY = Math.min(originalModel.getHeight(), maxY); diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/chemicals/ChemicalController.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/chemicals/ChemicalController.java index 95cdfe87f7512719d1860a4c7bda61f9cb2dc170..427b20fb2a8c6fc641c77a781ff8c19080ee73a8 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/chemicals/ChemicalController.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/chemicals/ChemicalController.java @@ -1,6 +1,5 @@ package lcsb.mapviewer.api.projects.chemicals; -import java.awt.geom.Point2D; import java.util.ArrayList; import java.util.List; import java.util.Map; diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/drugs/DrugRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/drugs/DrugRestImpl.java index f7ec8bcfb8c201cc49df0a229cd872e8491b07b8..75f01d1125cadac9bd7edb37bcf0020f62d3f3d4 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/drugs/DrugRestImpl.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/drugs/DrugRestImpl.java @@ -21,8 +21,6 @@ import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.species.Element; -import lcsb.mapviewer.persist.dao.map.ReactionDao; -import lcsb.mapviewer.persist.dao.map.species.ElementDao; import lcsb.mapviewer.services.SecurityException; import lcsb.mapviewer.services.interfaces.IModelService; import lcsb.mapviewer.services.interfaces.IUserService; diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/bioEntities/BioEntitiesController.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/bioEntities/BioEntitiesController.java index 9f8bd3fe86291062473e0240e67a49eef7a7cfa1..2c96827f476b4a9a847018358401e3b5b0995976 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/bioEntities/BioEntitiesController.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/bioEntities/BioEntitiesController.java @@ -68,7 +68,7 @@ public class BioEntitiesController extends BaseController { @RequestMapping(value = "/projects/{projectId}/models/{modelId}/bioEntities/suggestedQueryList", method = { RequestMethod.GET, RequestMethod.POST }, produces = { MediaType.APPLICATION_JSON_VALUE }) - public String[] getSuggestedQueryList( // + public String[] getSuggestedQueryList(// @PathVariable(value = "projectId") String projectId, // @CookieValue(value = Configuration.AUTH_TOKEN) String token// ) throws SecurityException { diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/bioEntities/reactions/ReactionsRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/bioEntities/reactions/ReactionsRestImpl.java index c1305c14372b227c0cbbe080b7237a8ffc2152d3..3529d79e687dcd402cc7727327db39c31385ba4c 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/bioEntities/reactions/ReactionsRestImpl.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/bioEntities/reactions/ReactionsRestImpl.java @@ -1,6 +1,5 @@ package lcsb.mapviewer.api.projects.models.bioEntities.reactions; -import java.awt.geom.PathIterator; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/publications/PublicationsRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/publications/PublicationsRestImpl.java index a17deb36691a28a079d48478b158aaa848a707cc..50f9b691892db89ac0941f0c54abe744bf448191 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/publications/PublicationsRestImpl.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/publications/PublicationsRestImpl.java @@ -16,27 +16,21 @@ import org.springframework.transaction.annotation.Transactional; import lcsb.mapviewer.annotation.services.PubmedParser; import lcsb.mapviewer.api.BaseRestImpl; import lcsb.mapviewer.api.QueryException; -import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.model.map.model.Model; -import lcsb.mapviewer.model.map.model.ModelData; -import lcsb.mapviewer.model.map.model.ModelSubmodelConnection; import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.services.SecurityException; -import lcsb.mapviewer.services.interfaces.ILayoutService; import lcsb.mapviewer.services.interfaces.IModelService; import lcsb.mapviewer.services.interfaces.ISearchService; import lcsb.mapviewer.services.interfaces.IUserService; -import lcsb.mapviewer.services.search.data.ElementIdentifier.ElementIdentifierType; import lcsb.mapviewer.services.view.AnnotationViewFactory; -import lcsb.mapviewer.services.view.AuthenticationToken; import lcsb.mapviewer.services.view.OverviewImageViewFactory; @Transactional(value = "txManager") -public class PublicationsRestImpl extends BaseRestImpl{ +public class PublicationsRestImpl extends BaseRestImpl { Logger logger = Logger.getLogger(PublicationsRestImpl.class); @@ -158,7 +152,8 @@ public class PublicationsRestImpl extends BaseRestImpl{ this.factory = factory; } - public Map<String, Object> getPublications(String projectId, String modelId, String token, String startString, Integer length) throws SecurityException, QueryException { + public Map<String, Object> getPublications(String projectId, String modelId, String token, String startString, Integer length) + throws SecurityException, QueryException { List<Model> models = getModels(projectId, modelId, token); Integer start = Math.max(0, Integer.valueOf(startString)); diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/overlays/OverlayController.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/overlays/OverlayController.java index 45a4ada00d1e377fb5074471b13441b6bf8ae353..815d1b9aff25e37ad4bc32f9c02f300313ac4f16 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/overlays/OverlayController.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/overlays/OverlayController.java @@ -90,7 +90,7 @@ public class OverlayController extends BaseController { } @RequestMapping(value = "/projects/{projectId}/overlays/", method = { RequestMethod.POST }, produces = { MediaType.APPLICATION_JSON_VALUE }) - public LayoutView addOverlay( // + public LayoutView addOverlay(// @CookieValue(value = Configuration.AUTH_TOKEN) String token, // @PathVariable(value = "projectId") String projectId, // @RequestParam(value = "name") String name, // @@ -103,7 +103,7 @@ public class OverlayController extends BaseController { } @RequestMapping(value = "/projects/{projectId}/overlays/{overlayId}", method = { RequestMethod.DELETE }, produces = { MediaType.APPLICATION_JSON_VALUE }) - public Map<String, Object> removeOverlay( // + public Map<String, Object> removeOverlay(// @CookieValue(value = Configuration.AUTH_TOKEN) String token, // @PathVariable(value = "projectId") String projectId, // @PathVariable(value = "overlayId") String overlayId // @@ -112,7 +112,7 @@ public class OverlayController extends BaseController { } @RequestMapping(value = "/projects/{projectId}/overlays/{overlayId}", method = { RequestMethod.PATCH }, produces = { MediaType.APPLICATION_JSON_VALUE }) - public LayoutView updateOverlay( // + public LayoutView updateOverlay(// @RequestBody String body, // @PathVariable(value = "projectId") String projectId, // @PathVariable(value = "overlayId") String overlayId, // @@ -125,7 +125,7 @@ public class OverlayController extends BaseController { @RequestMapping(value = "/projects/{projectId}/overlays/{overlayId}:downloadSource", method = { RequestMethod.GET }, produces = { MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity<byte[]> getOverlaySource( // + public ResponseEntity<byte[]> getOverlaySource(// @CookieValue(value = Configuration.AUTH_TOKEN) String token, // @PathVariable(value = "projectId") String projectId, // @PathVariable(value = "overlayId") String overlayId // diff --git a/service/src/main/java/lcsb/mapviewer/services/impl/ModelService.java b/service/src/main/java/lcsb/mapviewer/services/impl/ModelService.java index 9544bbeb5b86719879c212700278259070095e89..ed690aaad7e343d312adb59129a0ee2b7889f400 100644 --- a/service/src/main/java/lcsb/mapviewer/services/impl/ModelService.java +++ b/service/src/main/java/lcsb/mapviewer/services/impl/ModelService.java @@ -38,8 +38,6 @@ import lcsb.mapviewer.persist.dao.map.ModelDao; import lcsb.mapviewer.services.interfaces.ILayoutService; import lcsb.mapviewer.services.interfaces.IModelService; import lcsb.mapviewer.services.interfaces.IUserService; -import lcsb.mapviewer.services.search.data.FullAliasView; -import lcsb.mapviewer.services.search.data.FullAliasViewFactory; import lcsb.mapviewer.services.search.data.LightAliasView; import lcsb.mapviewer.services.search.data.LightAliasViewFactory; import lcsb.mapviewer.services.search.data.LightReactionView; diff --git a/service/src/main/java/lcsb/mapviewer/services/impl/ProjectService.java b/service/src/main/java/lcsb/mapviewer/services/impl/ProjectService.java index eea455176c321f0b3e8fc651fc288a3196ff29fa..212e7360c7dcd0c7e1849862b1e3126a30c488ac 100644 --- a/service/src/main/java/lcsb/mapviewer/services/impl/ProjectService.java +++ b/service/src/main/java/lcsb/mapviewer/services/impl/ProjectService.java @@ -636,6 +636,9 @@ public class ProjectService implements IProjectService { IProgressUpdater.MAX_PROGRESS * imgCounter / finalSize + progress / finalSize, params); } }); + if (layout.getTitle().contains(BuildInLayout.SEMANTIC.getTitle())) { + imgParams.semanticZoom(params.isSemanticZoom()); + } generator.generateMapImages(imgParams); } counter++; @@ -704,18 +707,21 @@ public class ProjectService implements IProjectService { if (params.isNetworkLayoutAsDefault()) { buildInLayouts.add(BuildInLayout.NORMAL); for (BuildInLayout buildInLayout : BuildInLayout.values()) { - if (!buildInLayout.equals(BuildInLayout.NORMAL)) { + if (!buildInLayout.equals(BuildInLayout.NORMAL) && !buildInLayout.equals(BuildInLayout.SEMANTIC)) { buildInLayouts.add(buildInLayout); } } } else { buildInLayouts.add(BuildInLayout.NESTED); for (BuildInLayout buildInLayout : BuildInLayout.values()) { - if (!buildInLayout.equals(BuildInLayout.NESTED)) { + if (!buildInLayout.equals(BuildInLayout.NESTED) && !buildInLayout.equals(BuildInLayout.SEMANTIC)) { buildInLayouts.add(buildInLayout); } } } + if (params.isSemanticZoom()) { + buildInLayouts.add(BuildInLayout.SEMANTIC); + } // reverse the order of build in layouts, so we can insert them at the // beginning of list of layouts (the order will be the same) diff --git a/service/src/main/java/lcsb/mapviewer/services/interfaces/IModelService.java b/service/src/main/java/lcsb/mapviewer/services/interfaces/IModelService.java index 67952223b4b70e21706c1bfe295064caf50a8c1e..43cc0ff508433a0296c7596093d257bcbe3460a1 100644 --- a/service/src/main/java/lcsb/mapviewer/services/interfaces/IModelService.java +++ b/service/src/main/java/lcsb/mapviewer/services/interfaces/IModelService.java @@ -7,7 +7,6 @@ import lcsb.mapviewer.common.Pair; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelData; import lcsb.mapviewer.model.user.User; -import lcsb.mapviewer.services.search.data.FullAliasView; import lcsb.mapviewer.services.search.data.LightAliasView; import lcsb.mapviewer.services.search.data.LightReactionView; import lcsb.mapviewer.services.view.AuthenticationToken; diff --git a/service/src/main/java/lcsb/mapviewer/services/interfaces/IUserService.java b/service/src/main/java/lcsb/mapviewer/services/interfaces/IUserService.java index 704b6abb7a4b58ec875a78a72196aa057df606db..bc59fb9104b9321272dececad18ec75e053a8afc 100644 --- a/service/src/main/java/lcsb/mapviewer/services/interfaces/IUserService.java +++ b/service/src/main/java/lcsb/mapviewer/services/interfaces/IUserService.java @@ -4,7 +4,6 @@ import java.util.Collection; import java.util.List; import lcsb.mapviewer.commands.ColorExtractor; -import lcsb.mapviewer.model.Project; import lcsb.mapviewer.model.user.BasicPrivilege; import lcsb.mapviewer.model.user.PrivilegeType; import lcsb.mapviewer.model.user.User; diff --git a/service/src/main/java/lcsb/mapviewer/services/search/SearchResultFactory.java b/service/src/main/java/lcsb/mapviewer/services/search/SearchResultFactory.java index e1a59f32d37cb373563a3aa7e40ed93aa5860aa1..ee446efa7ec86b8158848196155c4a4fb1941df7 100644 --- a/service/src/main/java/lcsb/mapviewer/services/search/SearchResultFactory.java +++ b/service/src/main/java/lcsb/mapviewer/services/search/SearchResultFactory.java @@ -1,26 +1,16 @@ package lcsb.mapviewer.services.search; import java.util.Collection; -import java.util.HashSet; import java.util.List; -import java.util.Set; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import lcsb.mapviewer.annotation.data.Article; -import lcsb.mapviewer.annotation.data.TargetType; import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.species.Element; -import lcsb.mapviewer.model.map.species.Complex; -import lcsb.mapviewer.model.map.species.Gene; -import lcsb.mapviewer.model.map.species.Protein; -import lcsb.mapviewer.model.map.species.Rna; -import lcsb.mapviewer.model.map.species.Species; import lcsb.mapviewer.services.search.data.ElementIdentifier; import lcsb.mapviewer.services.search.data.ElementIdentifier.ElementIdentifierType; import lcsb.mapviewer.services.search.db.GeneRow; @@ -62,10 +52,10 @@ public abstract class SearchResultFactory<T, S extends ISearchResultView> extend * {@link lcsb.mapviewer.services.view.AnnotationView} elements. */ @Autowired - private AnnotationViewFactory annotationViewFactory; + private AnnotationViewFactory annotationViewFactory; @Autowired - private ElementMatcher elementMatcher; + private ElementMatcher elementMatcher; /** * Returns detailed information about element respective to the set of targets @@ -114,12 +104,10 @@ public abstract class SearchResultFactory<T, S extends ISearchResultView> extend return null; } - protected boolean elementMatch(TargetView target, Element element) { return elementMatcher.elementMatch(target, element); } - /** * @return the annotationViewFactory * @see #annotationViewFactory @@ -137,7 +125,6 @@ public abstract class SearchResultFactory<T, S extends ISearchResultView> extend this.annotationViewFactory = annotationViewFactory; } - /** * @return the elementMatcher * @see #elementMatcher @@ -146,9 +133,9 @@ public abstract class SearchResultFactory<T, S extends ISearchResultView> extend return elementMatcher; } - /** - * @param elementMatcher the elementMatcher to set + * @param elementMatcher + * the elementMatcher to set * @see #elementMatcher */ public void setElementMatcher(ElementMatcher elementMatcher) { diff --git a/service/src/main/java/lcsb/mapviewer/services/utils/CreateProjectParams.java b/service/src/main/java/lcsb/mapviewer/services/utils/CreateProjectParams.java index 7edaee16379296a7511c59557ccdcb652ddc5ba4..21df2ed92d971e0160604b9b9f9b859b8075fdcf 100644 --- a/service/src/main/java/lcsb/mapviewer/services/utils/CreateProjectParams.java +++ b/service/src/main/java/lcsb/mapviewer/services/utils/CreateProjectParams.java @@ -59,6 +59,7 @@ public class CreateProjectParams { * Is the project a complex multi-file project. */ private boolean complex; + private boolean semanticZoom; /** * List of zip entries in the complex model definition. @@ -722,4 +723,13 @@ public class CreateProjectParams { return this; } + public CreateProjectParams semanticZoom(boolean semanticZoom) { + this.semanticZoom = semanticZoom; + return this; + } + + public boolean isSemanticZoom() { + return this.semanticZoom; + } + } diff --git a/service/src/main/java/lcsb/mapviewer/services/utils/data/BuildInLayout.java b/service/src/main/java/lcsb/mapviewer/services/utils/data/BuildInLayout.java index 13011324b3e60a4f273d4a3e8fe6cef6be72938a..3bdf5704f793378735a463ae359cb91e99cd36fe 100644 --- a/service/src/main/java/lcsb/mapviewer/services/utils/data/BuildInLayout.java +++ b/service/src/main/java/lcsb/mapviewer/services/utils/data/BuildInLayout.java @@ -32,6 +32,7 @@ public enum BuildInLayout { // * Standard visualization with hierarchical view. */ NESTED("Pathways and compartments", "_nested", null, true), + SEMANTIC("Semantic zoom", "_semantic", null, false), /** * Clean visualization (with colors reset to black and white). */ diff --git a/web/src/main/java/lcsb/mapviewer/bean/ProjectBean.java b/web/src/main/java/lcsb/mapviewer/bean/ProjectBean.java index bafe1cd65ace628698072d51d347e9bc89035db9..0e08e4a105f21283040a4609fe99c885458f1cfb 100644 --- a/web/src/main/java/lcsb/mapviewer/bean/ProjectBean.java +++ b/web/src/main/java/lcsb/mapviewer/bean/ProjectBean.java @@ -209,6 +209,8 @@ public class ProjectBean extends AbstractManagedBean implements Serializable { */ private String sbgnFormat = "false"; + private String semanticOverlay = "false"; + /** * List of zip entries corresponding to * {@link lcsb.mapviewer.model.map.OverviewImage OverviewImage} files in the @@ -664,6 +666,7 @@ public class ProjectBean extends AbstractManagedBean implements Serializable { params.addZipEntry(submodel); } params.sbgnFormat("true".equalsIgnoreCase(sbgnFormat)); + params.semanticZoom("true".equalsIgnoreCase(semanticOverlay)); params.networkLayoutAsDefault("true".equalsIgnoreCase(networkLayoutAsDefault)); projectService.createProject(params); projectService.updateClassAnnotatorTreeForUser( @@ -1485,4 +1488,21 @@ public class ProjectBean extends AbstractManagedBean implements Serializable { this.newProjectOrganism = newProjectOrganism; } + /** + * @return the semanticOverlay + * @see #semanticOverlay + */ + public String getSemanticOverlay() { + return semanticOverlay; + } + + /** + * @param semanticOverlay + * the semanticOverlay to set + * @see #semanticOverlay + */ + public void setSemanticOverlay(String semanticOverlay) { + this.semanticOverlay = semanticOverlay; + } + } diff --git a/web/src/main/webapp/admin/projects.xhtml b/web/src/main/webapp/admin/projects.xhtml index a036465233728e14a31fb7ed97666ede4951fb0d..ba3c03ba04460b79659a3220a86625450d5ff672 100644 --- a/web/src/main/webapp/admin/projects.xhtml +++ b/web/src/main/webapp/admin/projects.xhtml @@ -303,6 +303,10 @@ configurations of the source file are discussed in <a href="#{request.context <p:selectBooleanCheckbox value="#{projectMB.networkLayoutAsDefault}" /> <cc:helpButton helpText='If this checkbox is checked, the default overlay in User panel will present pure network. If the checkbox is unchecked then default overlay will present pathways and compartments view.'/> + <h:outputText value="Semantic zooming: " /> + <p:selectBooleanCheckbox value="#{projectMB.semanticOverlay}" /> + <cc:helpButton helpText=''/> + </h:panelGrid> <center> <p:commandButton value="Submit" icon="ui-icon-disk" actionListener="#{projectMB.createProject}" onclick="PF('addProjectDialog').hide();" update=":projectForm:projectDataTable"/>