diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/ImageGenerators.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/ImageGenerators.java index bbe7a85463d49da3a0641ebe1086900535722026..def4fbc887b886ef0abcce359c77e7b2ea308ba3 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/ImageGenerators.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/ImageGenerators.java @@ -89,9 +89,11 @@ public class ImageGenerators { * @return {@link MimeType} of the generated object * @throws IOException * thrown when there is a problem with output file - * @throws DrawingException + * @throws DrawingException + * thrown when there is a problem drawing map */ - public MimeType generate(Class<? extends AbstractImageGenerator> generatorClass, AbstractImageGenerator.Params params, String filename) throws IOException, DrawingException { + public MimeType generate(Class<? extends AbstractImageGenerator> generatorClass, AbstractImageGenerator.Params params, String filename) + throws IOException, DrawingException { try { AbstractImageGenerator generator = generatorClass.getConstructor(AbstractImageGenerator.Params.class).newInstance(params); generator.saveToFile(filename); @@ -125,7 +127,8 @@ public class ImageGenerators { * @return {@link MimeType} of the generated object * @throws IOException * thrown when there is a problem with output file - * @throws DrawingException + * @throws DrawingException + * thrown when there is a problem drawing map */ public MimeType generate(String generatorClass, Params params, String filename) throws IOException, DrawingException { for (Pair<String, Class<? extends AbstractImageGenerator>> element : availableGenerators) { 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 index 3c0969d891be604f9df1bd07431ce44885f34655..7f85a9f5e76f309a1d654980f0a0bfe83e6c0a80 100644 --- 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 @@ -39,18 +39,23 @@ public abstract class BioEntityConverter<T extends BioEntity> { * Default class logger. */ @SuppressWarnings("unused") - private final Logger logger = Logger.getLogger(BioEntityConverter.class); + private final Logger logger = Logger.getLogger(BioEntityConverter.class); + /** + * Class that allows to check if element is visible (or transparent) when + * drawing. It's used to filter out invisible elements when drawing + * semantic/hierarchy view. + */ private SemanticZoomLevelMatcher zoomLevelMatcher = new SemanticZoomLevelMatcher(); /** * Alpha value (0..255) used for visualizing overlay data that are normally * visualized in javascript. */ - public static final int LAYOUT_ALPHA = 200; + public static final int LAYOUT_ALPHA = 200; /** - * This function draw representation of the alias on the graphics object. + * This function draw {@link BioEntity} on the {@link Graphics2D} object. * * @param bioEntity * {@link BioEntity} that should be drawn @@ -60,7 +65,8 @@ public abstract class BioEntityConverter<T extends BioEntity> { * visuzalization params (like, should the object be filled with * solid color, etc.), for more information see * {@link ConverterParams} - * @throws DrawingException + * @throws DrawingException + * thrown when there is a problem with drawing {@link BioEntity} * */ public void draw(T bioEntity, Graphics2D graphics, ConverterParams params) throws DrawingException { @@ -82,23 +88,25 @@ public abstract class BioEntityConverter<T extends BioEntity> { * list of {@link ColorSchema} that were used for visualizing this * bioentity in different data overlays that should be overlayed on * the alias - * @throws DrawingException + * @throws DrawingException + * thrown when there is a problem with drawing {@link BioEntity} * */ - public abstract void draw(T bioEntity, Graphics2D graphics, ConverterParams params, List<ColorSchema> visualizedOverlaysColorSchemas) throws DrawingException; + public abstract void draw(T bioEntity, Graphics2D graphics, ConverterParams params, List<ColorSchema> visualizedOverlaysColorSchemas) + throws DrawingException; /** * 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 + * {@link 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 + * thrown when there is a problem with drawing {@link BioEntity} */ public abstract void drawText(T bioEntity, Graphics2D graphics, ConverterParams params) throws DrawingException; @@ -186,6 +194,17 @@ public abstract class BioEntityConverter<T extends BioEntity> { return true; } + /** + * Checks if {@link Element} given in the argument is transparent accordind to + * the level given in the {@link ConverterParams}. + * + * @param bioEntity + * {@link BioEntity} to be checked + * @param params + * params against which check is run + * @return <code>true</code> if object is transparent, <code>false</code> + * otherwise + */ protected boolean isTransparent(Element bioEntity, ConverterParams params) { return zoomLevelMatcher.isTransparent(params.getLevel(), bioEntity.getTransparencyLevel()); } diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/BottomSquareCompartmentConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/BottomSquareCompartmentConverter.java index b2af327cf2453121bd80963f61a6a657b3bb54ec..862cdb82efa56b106a3f560cb038e447d77adf4a 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/BottomSquareCompartmentConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/BottomSquareCompartmentConverter.java @@ -9,16 +9,15 @@ import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; +import org.apache.log4j.Logger; + import lcsb.mapviewer.commands.ColorExtractor; import lcsb.mapviewer.converter.graphics.ConverterParams; import lcsb.mapviewer.model.graphics.LineType; import lcsb.mapviewer.model.map.compartment.BottomSquareCompartment; import lcsb.mapviewer.model.map.layout.ColorSchema; -import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.map.species.Species; -import org.apache.log4j.Logger; - /** * Class responsible for drawing BottomSquareCompartment on the Graphics2D. * @@ -31,7 +30,7 @@ public class BottomSquareCompartmentConverter extends CompartmentConverter<Botto * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(BottomSquareCompartmentConverter.class.getName()); + private static Logger logger = Logger.getLogger(BottomSquareCompartmentConverter.class.getName()); /** * Default constructor. @@ -45,24 +44,24 @@ public class BottomSquareCompartmentConverter extends CompartmentConverter<Botto } @Override - public void draw(final BottomSquareCompartment alias, final Graphics2D graphics, final ConverterParams params) { + public void draw(final BottomSquareCompartment compartment, final Graphics2D graphics, final ConverterParams params) { // keep the old values of colors and line Color oldColor = graphics.getColor(); Stroke oldStroke = graphics.getStroke(); // create shape of the compartment - Shape s1 = new Line2D.Double(0, alias.getY(), alias.getWidth(), alias.getY()); - Shape s3 = new Line2D.Double(0, alias.getY() + alias.getThickness(), alias.getWidth(), alias.getY() + alias.getThickness()); - Area a1 = new Area(new Rectangle2D.Double(0.0, alias.getY(), alias.getWidth(), alias.getHeight())); + Shape s1 = new Line2D.Double(0, compartment.getY(), compartment.getWidth(), compartment.getY()); + Shape s3 = new Line2D.Double(0, compartment.getY() + compartment.getThickness(), compartment.getWidth(), compartment.getY() + compartment.getThickness()); + Area a1 = new Area(new Rectangle2D.Double(0.0, compartment.getY(), compartment.getWidth(), compartment.getHeight())); - Color c1 = alias.getColor(); + Color c1 = compartment.getColor(); Color c2 = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), HIGH_ALPHA_LEVEL); if (c1.equals(Color.WHITE)) { c1 = Color.BLACK; } // fill the background - boolean fill = !isTransparent(alias, params); + boolean fill = !isTransparent(compartment, params); if (fill) { graphics.setColor(c1); } else { @@ -87,10 +86,10 @@ public class BottomSquareCompartmentConverter extends CompartmentConverter<Botto // draw description if (fill) { - Point2D tmpPoint = alias.getNamePoint(); - alias.setNamePoint(alias.getCenter()); - drawText(alias, graphics, params); - alias.setNamePoint(tmpPoint); + Point2D tmpPoint = compartment.getNamePoint(); + compartment.setNamePoint(compartment.getCenter()); + drawText(compartment, graphics, params); + compartment.setNamePoint(tmpPoint); } } } diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/CompartmentConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/CompartmentConverter.java index 4db51f040bdcc18e9b7636c5d3abf9c386def466..2221b5a5d7acac56a3492111056ef1bf19917165 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/CompartmentConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/CompartmentConverter.java @@ -9,7 +9,6 @@ import java.util.List; import org.apache.log4j.Logger; import lcsb.mapviewer.commands.ColorExtractor; -import lcsb.mapviewer.commands.SemanticZoomLevelMatcher; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.geometry.EllipseTransformation; @@ -99,32 +98,33 @@ public abstract class CompartmentConverter<T extends Compartment> extends Elemen }; @Override - public void drawText(final T alias, final Graphics2D graphics, final ConverterParams params) { - if (alias.getWidth() < Configuration.EPSILON || alias.getHeight() < Configuration.EPSILON) { + public void drawText(final T compartment, final Graphics2D graphics, final ConverterParams params) { + if (compartment.getWidth() < Configuration.EPSILON || compartment.getHeight() < Configuration.EPSILON) { throw new InvalidArgumentException( - "Dimension of the alias must be bigger than 0. Alias id: " + alias.getElementId() + " (name: \"" + alias.getName() + "\")"); + "Dimension of the alias must be bigger than 0. Alias id: " + compartment.getElementId() + " (name: \"" + compartment.getName() + "\")"); } - Rectangle2D border = alias.getBorder(); - if (isVisible(alias, params) && !isTransparent(alias, params)) { + Rectangle2D border = compartment.getBorder(); + if (isVisible(compartment, params) && !isTransparent(compartment, params)) { synchronized (placeFinderSynchronization) { - if (placeFinder == null || placeFinder.getModel() != alias.getModelData()) { - placeFinder = new PlaceFinder(alias.getModelData().getModel()); + if (placeFinder == null || placeFinder.getModel() != compartment.getModelData()) { + placeFinder = new PlaceFinder(compartment.getModelData().getModel()); } - border = placeFinder.getRetangle(alias, params.getLevel()); + border = placeFinder.getRetangle(compartment, params.getLevel()); } } else if (!params.isTextCentered()) { border = new Rectangle2D.Double( - alias.getNamePoint().getX(), alias.getNamePoint().getY(), alias.getWidth() - (alias.getNamePoint().getX() - alias.getX()), - alias.getHeight() - (alias.getNamePoint().getY() - alias.getY())); + compartment.getNamePoint().getX(), compartment.getNamePoint().getY(), + compartment.getWidth() - (compartment.getNamePoint().getX() - compartment.getX()), + compartment.getHeight() - (compartment.getNamePoint().getY() - compartment.getY())); } double fontSize = DEFAULT_FONT_SIZE * params.getScale(); - if (alias.getFontSize() != null) { - fontSize = alias.getFontSize() * params.getScale(); + if (compartment.getFontSize() != null) { + fontSize = compartment.getFontSize() * params.getScale(); } String fontName = Font.SANS_SERIF; try { - fontSize = FontFinder.findMaxFontSize((int) Math.round(fontSize), fontName, graphics, border, alias.getName()); - FontFinder.drawText((int) fontSize, fontName, graphics, border, alias.getName(), params.isTextCentered()); + fontSize = FontFinder.findMaxFontSize((int) Math.round(fontSize), fontName, graphics, border, compartment.getName()); + FontFinder.drawText((int) fontSize, fontName, graphics, border, compartment.getName(), params.isTextCentered()); } catch (RectangleTooSmallException e) { // if it's too small then don't draw return; diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/LeftSquareCompartmentConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/LeftSquareCompartmentConverter.java index e6767a608f602797e282f952b321c19f302e23d9..cacd7fa860b2fac75d447b62ccac7d998e12cb46 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/LeftSquareCompartmentConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/LeftSquareCompartmentConverter.java @@ -44,24 +44,25 @@ public class LeftSquareCompartmentConverter extends CompartmentConverter<LeftSqu } @Override - public void draw(final LeftSquareCompartment alias, final Graphics2D graphics, final ConverterParams params) { + public void draw(final LeftSquareCompartment compartment, final Graphics2D graphics, final ConverterParams params) { // keep the old values of color and line type Color oldColor = graphics.getColor(); Stroke oldStroke = graphics.getStroke(); // create shape of the compartment - Shape s1 = new Line2D.Double(alias.getWidth(), alias.getHeight(), alias.getWidth(), 0); - Shape s3 = new Line2D.Double(alias.getWidth() - alias.getThickness(), 0, alias.getWidth() - alias.getThickness(), alias.getHeight()); - Area a1 = new Area(new Rectangle2D.Double(0.0, 0.0, alias.getWidth(), alias.getHeight())); + Shape s1 = new Line2D.Double(compartment.getWidth(), compartment.getHeight(), compartment.getWidth(), 0); + Shape s3 = new Line2D.Double( + compartment.getWidth() - compartment.getThickness(), 0, compartment.getWidth() - compartment.getThickness(), compartment.getHeight()); + Area a1 = new Area(new Rectangle2D.Double(0.0, 0.0, compartment.getWidth(), compartment.getHeight())); - Color c1 = alias.getColor(); + Color c1 = compartment.getColor(); Color c2 = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), HIGH_ALPHA_LEVEL); if (c1.equals(Color.WHITE)) { c1 = Color.BLACK; } // fill the background - boolean fill = !isTransparent(alias, params); + boolean fill = !isTransparent(compartment, params); if (fill) { graphics.setColor(c1); } else { @@ -87,10 +88,10 @@ public class LeftSquareCompartmentConverter extends CompartmentConverter<LeftSqu // draw description if (fill) { - Point2D tmpPoint = alias.getNamePoint(); - alias.setNamePoint(alias.getCenter()); - drawText(alias, graphics, params); - alias.setNamePoint(tmpPoint); + Point2D tmpPoint = compartment.getNamePoint(); + compartment.setNamePoint(compartment.getCenter()); + drawText(compartment, graphics, params); + compartment.setNamePoint(tmpPoint); } } } diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/OvalCompartmentConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/OvalCompartmentConverter.java index ea5a579a5aad3c38e683933a718782a2bf05d708..94bf3c470241e0fe1c5c09feeaef1c03c3be91a2 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/OvalCompartmentConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/OvalCompartmentConverter.java @@ -11,9 +11,9 @@ import java.awt.geom.Point2D; import lcsb.mapviewer.commands.ColorExtractor; import lcsb.mapviewer.converter.graphics.ConverterParams; import lcsb.mapviewer.model.graphics.LineType; +import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.compartment.OvalCompartment; import lcsb.mapviewer.model.map.layout.ColorSchema; -import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.map.species.Species; /** @@ -38,27 +38,27 @@ public class OvalCompartmentConverter extends CompartmentConverter<OvalCompartme /** * Returns shape representing alias. * - * @param alias + * @param compartment * alias for which we are looking for a Shape * @return Shape object that represents alias */ - private Shape getShape(final Element alias) { - return new Ellipse2D.Double(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight()); + private Shape getShape(final Compartment compartment) { + return new Ellipse2D.Double(compartment.getX(), compartment.getY(), compartment.getWidth(), compartment.getHeight()); } @Override - public void draw(final OvalCompartment alias, final Graphics2D graphics, final ConverterParams params) { + public void draw(final OvalCompartment compartment, final Graphics2D graphics, final ConverterParams params) { // keep the old values of color and line type Color oldColor = graphics.getColor(); Stroke oldStroke = graphics.getStroke(); // create shape of the compartment - Shape s1 = getShape(alias); - alias.increaseBorder(-alias.getThickness()); - Shape s3 = getShape(alias); - alias.increaseBorder(alias.getThickness()); + Shape s1 = getShape(compartment); + compartment.increaseBorder(-compartment.getThickness()); + Shape s3 = getShape(compartment); + compartment.increaseBorder(compartment.getThickness()); - Color c1 = alias.getColor(); + Color c1 = compartment.getColor(); Color c2 = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), HIGH_ALPHA_LEVEL); if (c1.equals(Color.WHITE)) { c1 = Color.BLACK; @@ -68,7 +68,7 @@ public class OvalCompartmentConverter extends CompartmentConverter<OvalCompartme a1.subtract(new Area(s3)); // fill the background - boolean fill = !isTransparent(alias, params); + boolean fill = !isTransparent(compartment, params); if (fill) { graphics.setColor(c1); } else { @@ -92,13 +92,13 @@ public class OvalCompartmentConverter extends CompartmentConverter<OvalCompartme // draw description if (fill) { - Point2D tmpPoint = alias.getNamePoint(); - alias.setNamePoint(alias.getCenter()); - drawText(alias, graphics, params); - alias.setNamePoint(tmpPoint); + Point2D tmpPoint = compartment.getNamePoint(); + compartment.setNamePoint(compartment.getCenter()); + drawText(compartment, graphics, params); + compartment.setNamePoint(tmpPoint); } else { - if (!alias.containsIdenticalSpecies()) { - drawText(alias, graphics, params); + if (!compartment.containsIdenticalSpecies()) { + drawText(compartment, graphics, params); } } } diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/PathwayCompartmentConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/PathwayCompartmentConverter.java index b9ff85306fdb47ea1c2eee4576774e348a14cd24..fb3518522110b69d730092da16c54e940b3063e1 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/PathwayCompartmentConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/PathwayCompartmentConverter.java @@ -40,17 +40,17 @@ public class PathwayCompartmentConverter extends CompartmentConverter<PathwayCom private Color backgroundColor = Color.LIGHT_GRAY; @Override - public void draw(final PathwayCompartment alias, final Graphics2D graphics, final ConverterParams params) { + public void draw(final PathwayCompartment compartment, final Graphics2D graphics, final ConverterParams params) { // keep the old values of colors and line Color oldColor = graphics.getColor(); Stroke oldStroke = graphics.getStroke(); - Shape shape = new Rectangle2D.Double(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight()); + Shape shape = new Rectangle2D.Double(compartment.getX(), compartment.getY(), compartment.getWidth(), compartment.getHeight()); - Color color = alias.getColor(); + Color color = compartment.getColor(); // fill the background - boolean fill = !isTransparent(alias, params); + boolean fill = !isTransparent(compartment, params); if (fill) { graphics.setColor(backgroundColor); } else { @@ -70,13 +70,13 @@ public class PathwayCompartmentConverter extends CompartmentConverter<PathwayCom // draw description of the compartment if (fill) { - Point2D tmpPoint = alias.getNamePoint(); - alias.setNamePoint(alias.getCenter()); - drawText(alias, graphics, params); - alias.setNamePoint(tmpPoint); + Point2D tmpPoint = compartment.getNamePoint(); + compartment.setNamePoint(compartment.getCenter()); + drawText(compartment, graphics, params); + compartment.setNamePoint(tmpPoint); } else { - if (!alias.containsIdenticalSpecies()) { - drawText(alias, graphics, params); + if (!compartment.containsIdenticalSpecies()) { + drawText(compartment, graphics, params); } } } diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/RightSquareCompartmentConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/RightSquareCompartmentConverter.java index 92303a36f88bcc4bcc0008c1bdb270693a1f9f90..a9461ebb57a23f986f6502d192abbe30f10ad1ea 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/RightSquareCompartmentConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/RightSquareCompartmentConverter.java @@ -44,24 +44,24 @@ public class RightSquareCompartmentConverter extends CompartmentConverter<RightS } @Override - public void draw(final RightSquareCompartment alias, final Graphics2D graphics, final ConverterParams params) { + public void draw(final RightSquareCompartment compartment, final Graphics2D graphics, final ConverterParams params) { // keep the old values of color and line type Color oldColor = graphics.getColor(); Stroke oldStroke = graphics.getStroke(); // create shape of the compartment - Shape s1 = new Line2D.Double(alias.getX(), alias.getHeight(), alias.getX(), 0); - Shape s3 = new Line2D.Double(alias.getX() + alias.getThickness(), alias.getHeight(), alias.getX(), 0); - Area a1 = new Area(new Rectangle2D.Double(alias.getX(), 0.0, alias.getWidth(), alias.getHeight())); + Shape s1 = new Line2D.Double(compartment.getX(), compartment.getHeight(), compartment.getX(), 0); + Shape s3 = new Line2D.Double(compartment.getX() + compartment.getThickness(), compartment.getHeight(), compartment.getX(), 0); + Area a1 = new Area(new Rectangle2D.Double(compartment.getX(), 0.0, compartment.getWidth(), compartment.getHeight())); - Color c1 = alias.getColor(); + Color c1 = compartment.getColor(); Color c2 = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), HIGH_ALPHA_LEVEL); if (c1.equals(Color.WHITE)) { c1 = Color.BLACK; } // fill the background - boolean fill = !isTransparent(alias, params); + boolean fill = !isTransparent(compartment, params); if (fill) { graphics.setColor(c1); } else { @@ -85,18 +85,18 @@ public class RightSquareCompartmentConverter extends CompartmentConverter<RightS graphics.setStroke(oldStroke); // three lines below are only temporary fix... - double x = alias.getNamePoint().getX() - alias.getX(); - double y = alias.getNamePoint().getY(); - alias.getNamePoint().setLocation(x, y); + double x = compartment.getNamePoint().getX() - compartment.getX(); + double y = compartment.getNamePoint().getY(); + compartment.getNamePoint().setLocation(x, y); // draw description if (fill) { - Point2D tmpPoint = alias.getNamePoint(); - alias.setNamePoint(alias.getCenter()); - drawText(alias, graphics, params); - alias.setNamePoint(tmpPoint); + Point2D tmpPoint = compartment.getNamePoint(); + compartment.setNamePoint(compartment.getCenter()); + drawText(compartment, graphics, params); + compartment.setNamePoint(tmpPoint); } - x += alias.getX(); - alias.getNamePoint().setLocation(x, y); + x += compartment.getX(); + compartment.getNamePoint().setLocation(x, y); } } diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/SquareCompartmentConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/SquareCompartmentConverter.java index c19e0deb0c9fd9a2abf9735ff134fa4eee39c168..2cd4017c5eaefa760d42456e522be50c03cdf9e2 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/SquareCompartmentConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/SquareCompartmentConverter.java @@ -13,13 +13,13 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.commands.ColorExtractor; import lcsb.mapviewer.converter.graphics.ConverterParams; import lcsb.mapviewer.model.graphics.LineType; +import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.compartment.SquareCompartment; import lcsb.mapviewer.model.map.layout.ColorSchema; -import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.map.species.Species; /** - * Class responsible for drawing SquareCompartment on the Graphics2D. + * Class responsible for drawing SquareCompartment on the {@link Graphics2D}. * * @author Piotr Gawron * @@ -48,29 +48,30 @@ public class SquareCompartmentConverter extends CompartmentConverter<SquareCompa } /** - * Returns shape representing alias. + * Returns shape representing compartment. * - * @param alias - * alias for which we are looking for a Shape - * @return Shape object that represents alias + * @param compartment + * compartment for which we are looking for a {@link Shape} + * @return {@link Shape} object that represents compartment */ - private Shape getShape(final Element alias) { - return new RoundRectangle2D.Double(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight(), RECTANGLE_CORNER_ARC_SIZE, RECTANGLE_CORNER_ARC_SIZE); + private Shape getShape(final Compartment compartment) { + return new RoundRectangle2D.Double( + compartment.getX(), compartment.getY(), compartment.getWidth(), compartment.getHeight(), RECTANGLE_CORNER_ARC_SIZE, RECTANGLE_CORNER_ARC_SIZE); } @Override - public void draw(final SquareCompartment alias, final Graphics2D graphics, final ConverterParams params) { + public void draw(final SquareCompartment compartment, final Graphics2D graphics, final ConverterParams params) { // keep the old values of color and line type Color oldColor = graphics.getColor(); Stroke oldStroke = graphics.getStroke(); // create shape of the compartment - Shape s1 = getShape(alias); - alias.increaseBorder(-alias.getThickness()); - Shape s3 = getShape(alias); - alias.increaseBorder(alias.getThickness()); + Shape s1 = getShape(compartment); + compartment.increaseBorder(-compartment.getThickness()); + Shape s3 = getShape(compartment); + compartment.increaseBorder(compartment.getThickness()); - Color c1 = alias.getColor(); + Color c1 = compartment.getColor(); Color c2 = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), HIGH_ALPHA_LEVEL); if (c1.equals(Color.WHITE)) { c1 = Color.BLACK; @@ -80,7 +81,7 @@ public class SquareCompartmentConverter extends CompartmentConverter<SquareCompa a1.subtract(new Area(s3)); // fill the background - boolean fill = !isTransparent(alias, params); + boolean fill = !isTransparent(compartment, params); if (fill) { graphics.setColor(c1); } else { @@ -104,10 +105,10 @@ public class SquareCompartmentConverter extends CompartmentConverter<SquareCompa // draw description if (fill) { - Point2D tmpPoint = alias.getNamePoint(); - alias.setNamePoint(alias.getCenter()); - drawText(alias, graphics, params); - alias.setNamePoint(tmpPoint); + Point2D tmpPoint = compartment.getNamePoint(); + compartment.setNamePoint(compartment.getCenter()); + drawText(compartment, graphics, params); + compartment.setNamePoint(tmpPoint); } } } diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/TopSquareCompartmentConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/TopSquareCompartmentConverter.java index 33a325562f0c7fc4322b2083f7ea13b4166f9ffa..7832bd282364731c4245f950f3e5959ff1ea4a01 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/TopSquareCompartmentConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/TopSquareCompartmentConverter.java @@ -19,7 +19,7 @@ import lcsb.mapviewer.model.map.species.Species; import org.apache.log4j.Logger; /** - * Class responsible for drawing TopSquareCompartment on the Graphics2D. + * Class responsible for drawing TopSquareCompartment on the {@link Graphics2D}. * * @author Piotr Gawron * @@ -44,22 +44,23 @@ public class TopSquareCompartmentConverter extends CompartmentConverter<TopSquar } @Override - public void draw(final TopSquareCompartment alias, final Graphics2D graphics, final ConverterParams params) { + public void draw(final TopSquareCompartment compartment, final Graphics2D graphics, final ConverterParams params) { Color oldColor = graphics.getColor(); Stroke oldStroke = graphics.getStroke(); - Shape s1 = new Line2D.Double(0, alias.getHeight(), alias.getWidth(), alias.getHeight()); - Shape s3 = new Line2D.Double(0, alias.getHeight() - alias.getThickness(), alias.getWidth(), alias.getHeight() - alias.getThickness()); - Area a1 = new Area(new Rectangle2D.Double(0.0, 0.0, alias.getWidth(), alias.getHeight())); + Shape s1 = new Line2D.Double(0, compartment.getHeight(), compartment.getWidth(), compartment.getHeight()); + Shape s3 = new Line2D.Double( + 0, compartment.getHeight() - compartment.getThickness(), compartment.getWidth(), compartment.getHeight() - compartment.getThickness()); + Area a1 = new Area(new Rectangle2D.Double(0.0, 0.0, compartment.getWidth(), compartment.getHeight())); - Color c1 = alias.getColor(); + Color c1 = compartment.getColor(); Color c2 = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), HIGH_ALPHA_LEVEL); if (c1.equals(Color.WHITE)) { c1 = Color.BLACK; } // fill the background - boolean fill = !isTransparent(alias, params); + boolean fill = !isTransparent(compartment, params); if (fill) { graphics.setColor(c1); } else { @@ -83,10 +84,10 @@ public class TopSquareCompartmentConverter extends CompartmentConverter<TopSquar graphics.setStroke(oldStroke); // draw description if (fill) { - Point2D tmpPoint = alias.getNamePoint(); - alias.setNamePoint(alias.getCenter()); - drawText(alias, graphics, params); - alias.setNamePoint(tmpPoint); + Point2D tmpPoint = compartment.getNamePoint(); + compartment.setNamePoint(compartment.getCenter()); + drawText(compartment, graphics, params); + compartment.setNamePoint(tmpPoint); } } } diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/AntisenseRnaConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/AntisenseRnaConverter.java index 84d00dc02a8c969fcc03de52697d7d17a7f988cb..f8b7777cdc7a41ecf1397b49f59c5ff9c86d61e8 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/AntisenseRnaConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/AntisenseRnaConverter.java @@ -15,16 +15,15 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.commands.ColorExtractor; import lcsb.mapviewer.converter.graphics.ConverterParams; -import lcsb.mapviewer.model.map.species.Element; -import lcsb.mapviewer.model.map.species.Species; import lcsb.mapviewer.model.map.layout.ColorSchema; import lcsb.mapviewer.model.map.species.AntisenseRna; +import lcsb.mapviewer.model.map.species.Species; import lcsb.mapviewer.model.map.species.field.AntisenseRnaRegion; import lcsb.mapviewer.model.map.species.field.ModificationState; /** - * This class defines methods used for drawing Antisense Rna SpeciesAlias on the - * graphics2d object. + * This class defines methods used for drawing {@link AntisenseRna} on the + * {@link Graphics2D} object. * * @author Piotr Gawron * @@ -48,40 +47,39 @@ public class AntisenseRnaConverter extends SpeciesConverter<AntisenseRna> { super(colorExtractor); } - @Override - public void draw(final AntisenseRna alias, final Graphics2D graphics, final ConverterParams params) { - GeneralPath path = getAntisenseRnaPath(alias); + public void draw(final AntisenseRna antisenseRna, final Graphics2D graphics, final ConverterParams params) { + GeneralPath path = getAntisenseRnaPath(antisenseRna); Color c = graphics.getColor(); - graphics.setColor(alias.getColor()); + graphics.setColor(antisenseRna.getColor()); graphics.fill(path); graphics.setColor(c); Stroke stroke = graphics.getStroke(); - graphics.setStroke(getBorderLine(alias)); + graphics.setStroke(getBorderLine(antisenseRna)); graphics.draw(path); graphics.setStroke(stroke); - for (AntisenseRnaRegion mr : alias.getRegions()) { - drawRegion(alias, mr, graphics, false, false); + for (AntisenseRnaRegion mr : antisenseRna.getRegions()) { + drawRegion(antisenseRna, mr, graphics, false, false); } - drawText(alias, graphics, params); + drawText(antisenseRna, graphics, params); } /** - * Returns alias border as a GeneralPath object. + * Returns {@link AntisenseRna} border as a {@link GeneralPath} object. * - * @param alias - * alias for which we want to get border - * @return border of the alias + * @param antisenseRna + * {@link AntisenseRna} for which we want to get border + * @return border of the {@link AntisenseRna} */ - private GeneralPath getAntisenseRnaPath(final Element alias) { + private GeneralPath getAntisenseRnaPath(final AntisenseRna antisenseRna) { // CHECKSTYLE:OFF GeneralPath path = new GeneralPath(Path2D.WIND_EVEN_ODD, 4); - path.moveTo(alias.getX(), alias.getY()); - path.lineTo(alias.getX() + alias.getWidth() * 3 / 4, alias.getY()); - path.lineTo(alias.getX() + alias.getWidth(), alias.getY() + alias.getHeight()); - path.lineTo(alias.getX() + alias.getWidth() / 4, alias.getY() + alias.getHeight()); + path.moveTo(antisenseRna.getX(), antisenseRna.getY()); + path.lineTo(antisenseRna.getX() + antisenseRna.getWidth() * 3 / 4, antisenseRna.getY()); + path.lineTo(antisenseRna.getX() + antisenseRna.getWidth(), antisenseRna.getY() + antisenseRna.getHeight()); + path.lineTo(antisenseRna.getX() + antisenseRna.getWidth() / 4, antisenseRna.getY() + antisenseRna.getHeight()); // CHECKSTYLE:ON path.closePath(); return path; @@ -95,33 +93,33 @@ public class AntisenseRnaConverter extends SpeciesConverter<AntisenseRna> { /** * This method draws antisense rna region for given alias. * - * @param alias - * alias on which region should be drawn - * @param mr - * region to be drawn + * @param antisenseRna + * {@link AntisenseRna} on which region should be drawn + * @param region + * {@link AntisenseRnaRegion} to be drawn * @param graphics - * graphics where we draw region + * {@link Graphics2D} where we draw region * @param drawEmptyRegion * flag determining if we shoudl draw empty regions * @param drawDescription * flag determining if we want to draw description as well */ - private void drawRegion(final AntisenseRna alias, final AntisenseRnaRegion mr, final Graphics2D graphics, final boolean drawEmptyRegion, + private void drawRegion(final AntisenseRna antisenseRna, final AntisenseRnaRegion region, final Graphics2D graphics, final boolean drawEmptyRegion, final boolean drawDescription) { - if ((!drawEmptyRegion) && (mr.getState() == null)) { + if ((!drawEmptyRegion) && (region.getState() == null)) { return; } double diameter = DEFAULT_MODIFICATION_DIAMETER; - double x = alias.getX(); - double y = alias.getY(); + double x = antisenseRna.getX(); + double y = antisenseRna.getY(); - double width = alias.getWidth(); + double width = antisenseRna.getWidth(); // CHECKSTYLE:OFF // we draw modifier on the upper border of antisense rna (which is only in // 3/4 of the width of alias) - Point2D p = new Point2D.Double(x + width * 3.0 / 4.0 * mr.getPos(), y - diameter); + Point2D p = new Point2D.Double(x + width * 3.0 / 4.0 * region.getPos(), y - diameter); // CHECKSTYLE:ON Ellipse2D ellipse = new Ellipse2D.Double(p.getX() - diameter / 2, p.getY() - diameter / 2, diameter, diameter); @@ -132,13 +130,13 @@ public class AntisenseRnaConverter extends SpeciesConverter<AntisenseRna> { graphics.draw(ellipse); graphics.drawLine((int) p.getX(), (int) (p.getY() + diameter / 2), (int) p.getX(), (int) y); - String text = mr.getName(); + String text = region.getName(); if (!text.equals("") && drawDescription) { double textWidth = graphics.getFontMetrics().stringWidth(text); Point2D p2 = new Point2D.Double(p.getX() - textWidth / 2, p.getY() - DEFAULT_SPECIES_MODIFIER_FONT_SIZE); graphics.drawString(text, (int) p2.getX(), (int) p2.getY()); } - ModificationState state = mr.getState(); + ModificationState state = region.getState(); if (state != null) { String str = state.getAbbreviation(); Font tmpFont = graphics.getFont(); diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/ComplexConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/ComplexConverter.java index 760c24e23e7f3975de8e0221491e489576ad5b20..2fa74bcc721df4921075d13d89df47699f43c564 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/ComplexConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/ComplexConverter.java @@ -12,15 +12,13 @@ import java.awt.geom.PathIterator; import org.apache.log4j.Logger; import lcsb.mapviewer.commands.ColorExtractor; -import lcsb.mapviewer.commands.SemanticZoomLevelMatcher; import lcsb.mapviewer.converter.graphics.ConverterParams; import lcsb.mapviewer.converter.graphics.geometry.FontFinder; import lcsb.mapviewer.converter.graphics.geometry.RectangleTooSmallException; import lcsb.mapviewer.model.graphics.LineType; -import lcsb.mapviewer.model.map.species.Element; -import lcsb.mapviewer.model.map.species.Species; import lcsb.mapviewer.model.map.layout.ColorSchema; import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Species; /** * This class defines methods used for drawing ComplexAlias on the graphics2d @@ -143,50 +141,50 @@ public class ComplexConverter extends SpeciesConverter<Complex> { } @Override - public void drawText(final Complex alias, final Graphics2D graphics, final ConverterParams params) { - if (((Complex) alias).getElements().size() > 0) { - if (isTransparent(alias, params)) { - super.drawText(alias, graphics, params); + public void drawText(final Complex complex, final Graphics2D graphics, final ConverterParams params) { + if (complex.getElements().size() > 0) { + if (isTransparent(complex, params)) { + super.drawText(complex, graphics, params); return; } } - String text = getText(alias); + String text = getText(complex); try { double fontSize = DEFAULT_SPECIES_FONT_SIZE; - if (alias.getFontSize() != null) { - fontSize = alias.getFontSize(); + if (complex.getFontSize() != null) { + fontSize = complex.getFontSize(); } - int size = (int) FontFinder.findMaxFontSize(params.getScale() * fontSize, Font.SANS_SERIF, graphics, alias.getBorder(), text); - FontFinder.drawText(size, Font.SANS_SERIF, graphics, alias.getBorder(), text); + int size = (int) FontFinder.findMaxFontSize(params.getScale() * fontSize, Font.SANS_SERIF, graphics, complex.getBorder(), text); + FontFinder.drawText(size, Font.SANS_SERIF, graphics, complex.getBorder(), text); } catch (RectangleTooSmallException e) { logger.warn("Problem with finding font size", e); - super.drawText(alias, graphics, params); + super.drawText(complex, graphics, params); } } /** - * Returns the border of complex alias. + * Returns the border of {@link Complex}. * - * @param alias + * @param complex * exact object for which we want to get a border - * @return border of the alias + * @return border of the {@link Complex} */ - private GeneralPath getAliasPath(final Element alias) { + private GeneralPath getAliasPath(final Complex complex) { GeneralPath path = new GeneralPath(Path2D.WIND_EVEN_ODD); - path.moveTo(alias.getX() + TRIMMED_CORNER_SIZE, alias.getY()); - path.lineTo(alias.getX() + alias.getWidth() - TRIMMED_CORNER_SIZE, alias.getY()); - path.lineTo(alias.getX() + alias.getWidth(), alias.getY() + TRIMMED_CORNER_SIZE); - path.lineTo(alias.getX() + alias.getWidth(), alias.getY() + alias.getHeight() - TRIMMED_CORNER_SIZE); - path.lineTo(alias.getX() + alias.getWidth() - TRIMMED_CORNER_SIZE, alias.getY() + alias.getHeight()); - path.lineTo(alias.getX() + TRIMMED_CORNER_SIZE, alias.getY() + alias.getHeight()); - path.lineTo(alias.getX(), alias.getY() + alias.getHeight() - TRIMMED_CORNER_SIZE); - path.lineTo(alias.getX(), alias.getY() + TRIMMED_CORNER_SIZE); + path.moveTo(complex.getX() + TRIMMED_CORNER_SIZE, complex.getY()); + path.lineTo(complex.getX() + complex.getWidth() - TRIMMED_CORNER_SIZE, complex.getY()); + path.lineTo(complex.getX() + complex.getWidth(), complex.getY() + TRIMMED_CORNER_SIZE); + path.lineTo(complex.getX() + complex.getWidth(), complex.getY() + complex.getHeight() - TRIMMED_CORNER_SIZE); + path.lineTo(complex.getX() + complex.getWidth() - TRIMMED_CORNER_SIZE, complex.getY() + complex.getHeight()); + path.lineTo(complex.getX() + TRIMMED_CORNER_SIZE, complex.getY() + complex.getHeight()); + path.lineTo(complex.getX(), complex.getY() + complex.getHeight() - TRIMMED_CORNER_SIZE); + path.lineTo(complex.getX(), complex.getY() + TRIMMED_CORNER_SIZE); path.closePath(); return path; } @Override - public PathIterator getBoundPathIterator(final Complex alias) { - return getAliasPath(alias).getPathIterator(new AffineTransform()); + public PathIterator getBoundPathIterator(final Complex complex) { + return getAliasPath(complex).getPathIterator(new AffineTransform()); } } diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/DegradedConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/DegradedConverter.java index 42152ef9f1c518e85485ab9c268049202831b667..2b8c6d163a165b366e4a93d36dd316f69263d822 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/DegradedConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/DegradedConverter.java @@ -16,12 +16,11 @@ import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.converter.graphics.ConverterParams; import lcsb.mapviewer.model.map.layout.ColorSchema; import lcsb.mapviewer.model.map.species.Degraded; -import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.map.species.Species; /** - * This class defines methods used for drawing Degraded SpeciesAlias on the - * graphics2d object. + * This class defines methods used for drawing {@link Degraded} on the + * {@link Graphics2D} object. * * @author Piotr Gawron * @@ -50,17 +49,17 @@ public class DegradedConverter extends SpeciesConverter<Degraded> { } @Override - 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); + public void draw(final Degraded degraded, final Graphics2D graphics, final ConverterParams params) { + double diameter = getDiameter(degraded); + double x = getXCoord(degraded, diameter); + double y = getYCoord(degraded); Area a1 = new Area(new Ellipse2D.Double(x, y, diameter, diameter)); - double lineX1 = alias.getX() + alias.getWidth() / 2 + CROSS_LINE_EXTENDED_LENGTH; - double lineY1 = alias.getY(); + double lineX1 = degraded.getX() + degraded.getWidth() / 2 + CROSS_LINE_EXTENDED_LENGTH; + double lineY1 = degraded.getY(); - double lineX2 = alias.getX() + alias.getWidth() / 2 - CROSS_LINE_EXTENDED_LENGTH; - double lineY2 = alias.getY() + diameter + 2 * CROSS_LINE_EXTENDED_LENGTH; + double lineX2 = degraded.getX() + degraded.getWidth() / 2 - CROSS_LINE_EXTENDED_LENGTH; + double lineY2 = degraded.getY() + diameter + 2 * CROSS_LINE_EXTENDED_LENGTH; GeneralPath path = new GeneralPath(Path2D.WIND_EVEN_ODD, 2); path.moveTo(lineX1, lineY1); @@ -71,51 +70,51 @@ public class DegradedConverter extends SpeciesConverter<Degraded> { a1.exclusiveOr(new Area(path)); Color c = graphics.getColor(); - graphics.setColor(alias.getColor()); + graphics.setColor(degraded.getColor()); graphics.fill(a1); graphics.setColor(c); Stroke stroke = graphics.getStroke(); - graphics.setStroke(getBorderLine(alias)); + graphics.setStroke(getBorderLine(degraded)); graphics.draw(a1); graphics.setStroke(stroke); - drawText(alias, graphics, params); + drawText(degraded, graphics, params); } /** - * Returns transformed y coordinate for the degraded alias. + * Returns transformed y coordinate for the {@link Degraded} bioentity. * - * @param alias - * object alias to to which we are looking for y coordinate + * @param degraded + * {@link Degraded} to to which we are looking for y coordinate * @return y coordinate of the alias */ - private double getYCoord(final Element alias) { - double y = alias.getY() + CROSS_LINE_EXTENDED_LENGTH; + private double getYCoord(final Degraded degraded) { + double y = degraded.getY() + CROSS_LINE_EXTENDED_LENGTH; return y; } /** * Returns transformed x coordinate for the degraded alias. * - * @param alias + * @param degraded * object alias to to which we are looking for x coordinate * @param diameter * diameter of cross line used in this alias - * @return x coordinate of the alias + * @return x coordinate of the {@link Degraded} bioentity. */ - private double getXCoord(final Element alias, final double diameter) { - double x = alias.getX() + (alias.getWidth() - diameter) / 2; + private double getXCoord(final Degraded degraded, final double diameter) { + double x = degraded.getX() + (degraded.getWidth() - diameter) / 2; return x; } /** * Computes diameter of cross line for the degraded alias. * - * @param alias + * @param degraded * object alias to to which we are looking for diameter. * @return diameter of the cross line */ - private double getDiameter(final Element alias) { - double diameter = Math.min(alias.getWidth(), alias.getHeight()) - 2 * CROSS_LINE_EXTENDED_LENGTH; + private double getDiameter(final Degraded degraded) { + double diameter = Math.min(degraded.getWidth(), degraded.getHeight()) - 2 * CROSS_LINE_EXTENDED_LENGTH; if (diameter < 0) { logger.warn("Diameter cannot be negative..."); diameter = 0; @@ -124,12 +123,12 @@ public class DegradedConverter extends SpeciesConverter<Degraded> { } @Override - public String getText(Degraded alias) { + public String getText(Degraded degraded) { return ""; } @Override - public PathIterator getBoundPathIterator(Degraded alias) { + public PathIterator getBoundPathIterator(Degraded degraded) { throw new InvalidStateException("This class doesn't have bound"); } diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/DrugConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/DrugConverter.java index 4c412634f46f78414c63f1a7426463cd1aaeb92d..8765dd6e30dc0e71b8bac1382537e92fa97d0a77 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/DrugConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/DrugConverter.java @@ -10,15 +10,14 @@ import java.awt.geom.Point2D; import java.awt.geom.RoundRectangle2D; import java.util.ArrayList; +import org.apache.log4j.Logger; + import lcsb.mapviewer.commands.ColorExtractor; import lcsb.mapviewer.converter.graphics.ConverterParams; import lcsb.mapviewer.model.map.layout.ColorSchema; import lcsb.mapviewer.model.map.species.Drug; -import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.map.species.Species; -import org.apache.log4j.Logger; - /** * This class defines methods used for drawing Drug SpeciesAlias on the * graphics2d object. @@ -27,23 +26,23 @@ import org.apache.log4j.Logger; * */ public class DrugConverter extends SpeciesConverter<Drug> { - + /** * Distance between internal and external border of drug graphical * representation. */ - private static final int OFFSET_BETWEEN_BORDERS = 4; - + private static final int OFFSET_BETWEEN_BORDERS = 4; + /** * How big should be the arc in rectangle for drug representation. */ - private static final int RECTANGLE_CORNER_ARC_SIZE = 40; - + private static final int RECTANGLE_CORNER_ARC_SIZE = 40; + /** * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(DrugConverter.class.getName()); + private static Logger logger = Logger.getLogger(DrugConverter.class.getName()); /** * Default constructor. @@ -59,47 +58,47 @@ public class DrugConverter extends SpeciesConverter<Drug> { /** * Returns shape of the Drug . * - * @param alias - * alias for which we are looking for a border + * @param drug + * {@link Drug} for which we are looking for a border * @return Shape object defining given alias */ - private Shape getDrugShape(final Element alias) { - return new RoundRectangle2D.Double(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight(), RECTANGLE_CORNER_ARC_SIZE, RECTANGLE_CORNER_ARC_SIZE); + private Shape getDrugShape(final Drug drug) { + return new RoundRectangle2D.Double(drug.getX(), drug.getY(), drug.getWidth(), drug.getHeight(), RECTANGLE_CORNER_ARC_SIZE, RECTANGLE_CORNER_ARC_SIZE); } @Override - public void draw(Drug alias, final Graphics2D graphics, final ConverterParams params) { - Shape a1 = getDrugShape(alias); + public void draw(Drug drug, final Graphics2D graphics, final ConverterParams params) { + Shape a1 = getDrugShape(drug); double offset = OFFSET_BETWEEN_BORDERS; Shape a2 = new RoundRectangle2D.Double( - alias.getX() + offset, alias.getY() + offset, alias.getWidth() - 2 * offset, alias.getHeight() - 2 * offset, RECTANGLE_CORNER_ARC_SIZE, + drug.getX() + offset, drug.getY() + offset, drug.getWidth() - 2 * offset, drug.getHeight() - 2 * offset, RECTANGLE_CORNER_ARC_SIZE, RECTANGLE_CORNER_ARC_SIZE); Color c = graphics.getColor(); - graphics.setColor(alias.getColor()); + graphics.setColor(drug.getColor()); graphics.fill(a1); graphics.setColor(c); Stroke stroke = graphics.getStroke(); - graphics.setStroke(getBorderLine(alias)); + graphics.setStroke(getBorderLine(drug)); graphics.draw(a1); graphics.draw(a2); graphics.setStroke(stroke); - drawText(alias, graphics, params); + drawText(drug, graphics, params); } /** - * Returns shape of the Drug as a list of points. + * Returns shape of the {@link Drug} as a list of points. * - * @param alias - * alias for which we are looking for a border - * @return list of points defining border of the given alias + * @param drug + * {@link Drug} for which we are looking for a border + * @return list of points defining border of the given {@link Drug} */ - protected ArrayList<Point2D> getDrugPoints(final Species alias) { + protected ArrayList<Point2D> getDrugPoints(final Drug drug) { ArrayList<Point2D> list = new ArrayList<Point2D>(); - double x = alias.getX(); - double y = alias.getY(); - double width = alias.getWidth(); - double height = alias.getHeight(); + double x = drug.getX(); + double y = drug.getY(); + double width = drug.getWidth(); + double height = drug.getHeight(); // CHECKSTYLE:OFF list.add(new Point2D.Double(x, y + height / 2)); @@ -116,8 +115,8 @@ public class DrugConverter extends SpeciesConverter<Drug> { } @Override - public PathIterator getBoundPathIterator(Drug alias) { - return getDrugShape(alias).getPathIterator(new AffineTransform()); + public PathIterator getBoundPathIterator(Drug drug) { + return getDrugShape(drug).getPathIterator(new AffineTransform()); } } diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/GeneConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/GeneConverter.java index 514475cf86205411fc334f3dc88b411aecde5443..8528b749fca21bab36324abe8e66c7d5f29cb16e 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/GeneConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/GeneConverter.java @@ -16,7 +16,6 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.commands.ColorExtractor; import lcsb.mapviewer.converter.graphics.ConverterParams; import lcsb.mapviewer.model.map.layout.ColorSchema; -import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.map.species.Gene; import lcsb.mapviewer.model.map.species.Species; import lcsb.mapviewer.model.map.species.field.ModificationResidue; @@ -48,22 +47,22 @@ public class GeneConverter extends SpeciesConverter<Gene> { } @Override - public void draw(final Gene alias, final Graphics2D graphics, final ConverterParams params) { - Shape shape = getGeneShape(alias); + public void draw(final Gene gene, final Graphics2D graphics, final ConverterParams params) { + Shape shape = getGeneShape(gene); Color c = graphics.getColor(); - graphics.setColor(alias.getColor()); + graphics.setColor(gene.getColor()); graphics.fill(shape); graphics.setColor(c); Stroke stroke = graphics.getStroke(); - graphics.setStroke(getBorderLine(alias)); + graphics.setStroke(getBorderLine(gene)); graphics.draw(shape); graphics.setStroke(stroke); - for (ModificationResidue mr : alias.getModificationResidues()) { - drawModification(alias, mr, graphics, false, false); + for (ModificationResidue mr : gene.getModificationResidues()) { + drawModification(gene, mr, graphics, false, false); } - drawText(alias, graphics, params); + drawText(gene, graphics, params); } /** @@ -72,7 +71,7 @@ public class GeneConverter extends SpeciesConverter<Gene> { * set then also description (position) of the modification is drawn on the * canvas. * - * @param alias + * @param gene * object that is 'parent' of the residue * @param mr * modification to be drawn @@ -84,17 +83,17 @@ public class GeneConverter extends SpeciesConverter<Gene> { * flag that indicates if we should draw description of the * modification */ - private void drawModification(final Gene alias, final ModificationResidue mr, final Graphics2D graphics, final boolean drawEmptyModification, + private void drawModification(final Gene gene, final ModificationResidue mr, final Graphics2D graphics, final boolean drawEmptyModification, final boolean drawDescription) { if ((!drawEmptyModification) && (mr.getState() == null)) { return; } double diameter = DEFAULT_MODIFICATION_DIAMETER; - double x = alias.getX(); - double y = alias.getY(); + double x = gene.getX(); + double y = gene.getY(); - double width = alias.getWidth(); + double width = gene.getWidth(); Point2D p = new Point2D.Double(x + width * mr.getAngle(), y - DEFAULT_MODIFICATION_DIAMETER); @@ -126,21 +125,21 @@ public class GeneConverter extends SpeciesConverter<Gene> { } /** - * Shape representation of the gene alias. + * Shape representation of the {@link Gene}. * - * @param alias - * alias for which we are looking for a Shape - * @return Shape object that represents alias + * @param gene + * {@link Gene} for which we are looking for a {@link Shape} + * @return {@link Shape} that represents {@link Gene} */ - private Shape getGeneShape(final Element alias) { + private Shape getGeneShape(final Gene gene) { Shape shape; - shape = new Rectangle(alias.getX().intValue(), alias.getY().intValue(), alias.getWidth().intValue(), alias.getHeight().intValue()); + shape = new Rectangle(gene.getX().intValue(), gene.getY().intValue(), gene.getWidth().intValue(), gene.getHeight().intValue()); return shape; } @Override - public PathIterator getBoundPathIterator(final Gene alias) { - return getGeneShape(alias).getPathIterator(new AffineTransform()); + public PathIterator getBoundPathIterator(final Gene gene) { + return getGeneShape(gene).getPathIterator(new AffineTransform()); } } diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/IonConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/IonConverter.java index 733f3b7ddb0dcf1f165360352c9e603854b8db3f..6b0237b7498984c0ee2b5f301a2b725a9fcb8c18 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/IonConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/IonConverter.java @@ -14,14 +14,12 @@ import lcsb.mapviewer.commands.ColorExtractor; import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.converter.graphics.ConverterParams; import lcsb.mapviewer.model.map.layout.ColorSchema; -import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.map.species.Ion; import lcsb.mapviewer.model.map.species.Species; /** - * This class defines methods used for drawing SpeciesAlias of - * {@link lcsb.mapviewer.converter.model.celldesigner.structure.db.model.map.species.Ion - * Ion} on the {@link Graphics2D} object. + * This class defines methods used for drawing SpeciesAlias of {@link Ion} on + * the {@link Graphics2D} object. * * @author Piotr Gawron * @@ -45,57 +43,57 @@ public class IonConverter extends SpeciesConverter<Ion> { } @Override - public void draw(Ion alias, final Graphics2D graphics, final ConverterParams params) { - double diameter = getDiameter(alias); - double x = getXCoord(alias, diameter); - double y = getYCoord(alias); + public void draw(Ion ion, final Graphics2D graphics, final ConverterParams params) { + double diameter = getDiameter(ion); + double x = getXCoord(ion, diameter); + double y = getYCoord(ion); Shape shape = new Ellipse2D.Double(x, y, diameter, diameter); Color c = graphics.getColor(); - graphics.setColor(alias.getColor()); + graphics.setColor(ion.getColor()); graphics.fill(shape); graphics.setColor(c); Stroke stroke = graphics.getStroke(); - graphics.setStroke(getBorderLine(alias)); + graphics.setStroke(getBorderLine(ion)); graphics.draw(shape); graphics.setStroke(stroke); - drawText(alias, graphics, params); + drawText(ion, graphics, params); } /** - * Returns transformed y coordinate for the ion alias. + * Returns transformed y coordinate for the {@link Ion}. * - * @param alias - * object alias to to which we are looking for y coordinate - * @return y coordinate of the alias + * @param ion + * {@link Ion} to to which we are looking for y coordinate + * @return y coordinate of the {@link Ion} */ - private double getYCoord(final Element alias) { - double y = alias.getY(); + private double getYCoord(final Ion ion) { + double y = ion.getY(); return y; } /** - * Returns transformed x coordinate for the ion alias. + * Returns transformed x coordinate for the {@link Ion}. * - * @param alias - * object alias to to which we are looking for x coordinate + * @param ion + * {@link Ion} to which we are looking for x coordinate * @param diameter * diameter of circle representation of ion - * @return x coordinate of the alias + * @return x coordinate of the {@link Ion} */ - private double getXCoord(final Element alias, final double diameter) { - double x = alias.getX() + (alias.getWidth() - diameter) / 2; + private double getXCoord(final Ion ion, final double diameter) { + double x = ion.getX() + (ion.getWidth() - diameter) / 2; return x; } /** - * Returns diameter of circle representation of ion. + * Returns diameter of circle representation of an {@link Ion}. * - * @param alias - * object alias to to which we are looking for diameter. - * @return diameter of ion circle representation + * @param ion + * {@link Ion} to to which we are looking for diameter. + * @return diameter of {@link Ion} circle representation */ - private double getDiameter(final Element alias) { - double diameter = Math.min(alias.getWidth(), alias.getHeight()); + private double getDiameter(final Ion ion) { + double diameter = Math.min(ion.getWidth(), ion.getHeight()); if (diameter < 0) { logger.warn("Something is wrong. Size cannot be negative"); diameter = 0; @@ -105,19 +103,19 @@ public class IonConverter extends SpeciesConverter<Ion> { } @Override - public PathIterator getBoundPathIterator(Ion alias) { + public PathIterator getBoundPathIterator(Ion ion) { throw new InvalidStateException("This class doesn't have bound"); } @Override - public Point2D getPointCoordinatesOnBorder(Ion alias, final double angle) { - if (alias.getWidth() == 0 && alias.getHeight() == 0) { + public Point2D getPointCoordinatesOnBorder(Ion ion, final double angle) { + if (ion.getWidth() == 0 && ion.getHeight() == 0) { logger.warn("Looking for coordinates for the alias with 0 size"); - return alias.getCenter(); + return ion.getCenter(); } - double diameter = getDiameter(alias); - double x = getXCoord(alias, diameter); - double y = getYCoord(alias); + double diameter = getDiameter(ion); + double x = getXCoord(ion, diameter); + double y = getYCoord(ion); Point2D result = getEllipseTransformation().getPointOnEllipseByRadian(x, y, diameter, diameter, angle); return result; diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/PhenotypeConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/PhenotypeConverter.java index 0a6a2a059b9bd3d4cf9024797bd17d88c112b949..b9674dc86420941f54ea81233b83f62ddafda7d5 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/PhenotypeConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/PhenotypeConverter.java @@ -13,13 +13,11 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.commands.ColorExtractor; import lcsb.mapviewer.converter.graphics.ConverterParams; import lcsb.mapviewer.model.map.layout.ColorSchema; -import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.map.species.Phenotype; /** - * This class defines methods used for drawing SpeciesAlias of - * {@link lcsb.mapviewer.converter.model.celldesigner.structure.db.model.map.species.Phenotype - * Phenotype} on the {@link Graphics2D} object. + * This class defines methods used for drawing SpeciesAlias of {@link Phenotype} + * on the {@link Graphics2D} object. * * @author Piotr Gawron * @@ -44,44 +42,45 @@ public class PhenotypeConverter extends SpeciesConverter<Phenotype> { } @Override - public void draw(Phenotype alias, final Graphics2D graphics, final ConverterParams params) { - GeneralPath path = getPhenotypePath(alias); + public void draw(Phenotype phenotype, final Graphics2D graphics, final ConverterParams params) { + GeneralPath path = getPhenotypePath(phenotype); Color c = graphics.getColor(); - graphics.setColor(alias.getColor()); + graphics.setColor(phenotype.getColor()); graphics.fill(path); graphics.setColor(c); Stroke stroke = graphics.getStroke(); - graphics.setStroke(getBorderLine(alias)); + graphics.setStroke(getBorderLine(phenotype)); graphics.draw(path); graphics.setStroke(stroke); - drawText(alias, graphics, params); + drawText(phenotype, graphics, params); } /** - * Returns shape of the Phenotype as a GeneralPath object. + * Returns shape of the {@link Phenotype} as a {@link GeneralPath} object. * - * @param alias - * alias for which we are looking for a border - * @return GeneralPath object defining border of the given alias + * @param phenotype + * {@link Phenotype} for which we are looking for a border + * @return {@link GeneralPath} object defining border of the given + * {@link Phenotype} */ - private GeneralPath getPhenotypePath(final Element alias) { + private GeneralPath getPhenotypePath(final Phenotype phenotype) { // CHECKSTYLE:OFF GeneralPath path = new GeneralPath(Path2D.WIND_EVEN_ODD, 6); - path.moveTo(alias.getX() + alias.getWidth() / 6, alias.getY()); - path.lineTo(alias.getX() + alias.getWidth() * 5 / 6, alias.getY()); - path.lineTo(alias.getX() + alias.getWidth(), alias.getY() + alias.getHeight() / 2); - path.lineTo(alias.getX() + alias.getWidth() * 5 / 6, alias.getY() + alias.getHeight()); - path.lineTo(alias.getX() + alias.getWidth() / 6, alias.getY() + alias.getHeight()); - path.lineTo(alias.getX(), alias.getY() + alias.getHeight() / 2); + path.moveTo(phenotype.getX() + phenotype.getWidth() / 6, phenotype.getY()); + path.lineTo(phenotype.getX() + phenotype.getWidth() * 5 / 6, phenotype.getY()); + path.lineTo(phenotype.getX() + phenotype.getWidth(), phenotype.getY() + phenotype.getHeight() / 2); + path.lineTo(phenotype.getX() + phenotype.getWidth() * 5 / 6, phenotype.getY() + phenotype.getHeight()); + path.lineTo(phenotype.getX() + phenotype.getWidth() / 6, phenotype.getY() + phenotype.getHeight()); + path.lineTo(phenotype.getX(), phenotype.getY() + phenotype.getHeight() / 2); // CHECKSTYLE:ON path.closePath(); return path; } @Override - public PathIterator getBoundPathIterator(Phenotype alias) { - return getPhenotypePath(alias).getPathIterator(new AffineTransform()); + public PathIterator getBoundPathIterator(Phenotype phenotype) { + return getPhenotypePath(phenotype).getPathIterator(new AffineTransform()); } } diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/ProteinConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/ProteinConverter.java index 0e794ffa6e425ca2af04a2a9d87c185b3728ebb3..0f97b3998052c234e8602675ece715111de38352 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/ProteinConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/ProteinConverter.java @@ -23,7 +23,6 @@ import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.converter.graphics.ConverterParams; import lcsb.mapviewer.model.graphics.LineType; import lcsb.mapviewer.model.map.layout.ColorSchema; -import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.map.species.GenericProtein; import lcsb.mapviewer.model.map.species.IonChannelProtein; import lcsb.mapviewer.model.map.species.Protein; @@ -47,6 +46,7 @@ public class ProteinConverter extends SpeciesConverter<Protein> { * Width of the ion part in the open channel representation. */ private static final int ION_CHANNEL_WIDTH = 20; + /** * Width of the gap in the open channel representation. */ @@ -56,6 +56,7 @@ public class ProteinConverter extends SpeciesConverter<Protein> { * How big should be the arc in rectangle for protein representation. */ private static final int RECTANGLE_CORNER_ARC_SIZE = 10; + /** * Default class logger. */ @@ -78,29 +79,30 @@ public class ProteinConverter extends SpeciesConverter<Protein> { } /** - * Returns shape of generic protein. + * Returns shape of {@link Protein}. * - * @param alias - * alias for which we are looking for a border + * @param protein + * {@link Protein} for which we are looking for a border * @return Shape object defining given alias */ - private Shape getGenericShape(final Element alias) { - return new RoundRectangle2D.Double(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight(), RECTANGLE_CORNER_ARC_SIZE, RECTANGLE_CORNER_ARC_SIZE); + private Shape getGenericShape(final Protein protein) { + return new RoundRectangle2D.Double( + protein.getX(), protein.getY(), protein.getWidth(), protein.getHeight(), RECTANGLE_CORNER_ARC_SIZE, RECTANGLE_CORNER_ARC_SIZE); } @Override - public void draw(final Protein alias, final Graphics2D graphics, final ConverterParams params) { + public void draw(final Protein protein, final Graphics2D graphics, final ConverterParams params) { // Local variable setting the SBGN visualization boolean sbgnFormat = params.isSbgnFormat(); // Unit of information text (multimer cardinality and/or ion channel's // state) String unitOfInformationText = ""; - if (alias.getStatePrefix() != null && alias.getStateLabel() != null) { - if (alias.getStatePrefix().equals("free input")) { - unitOfInformationText = alias.getStateLabel(); + if (protein.getStatePrefix() != null && protein.getStateLabel() != null) { + if (protein.getStatePrefix().equals("free input")) { + unitOfInformationText = protein.getStateLabel(); } else { - unitOfInformationText = alias.getStatePrefix() + ":" + alias.getStateLabel(); + unitOfInformationText = protein.getStatePrefix() + ":" + protein.getStateLabel(); } } @@ -108,88 +110,88 @@ public class ProteinConverter extends SpeciesConverter<Protein> { if (sbgnFormat) { // If the SBGN display mode is set, multimer is shown as two stacked // glyphs - if (alias.getHomodimer() > 1) { + if (protein.getHomodimer() > 1) { homodir = 2; } else { homodir = 1; } } else { - homodir = alias.getHomodimer(); + homodir = protein.getHomodimer(); } - alias.setWidth(alias.getWidth() - SpeciesConverter.HOMODIMER_OFFSET * (alias.getHomodimer() - 1)); - alias.setHeight(alias.getHeight() - SpeciesConverter.HOMODIMER_OFFSET * (alias.getHomodimer() - 1)); + protein.setWidth(protein.getWidth() - SpeciesConverter.HOMODIMER_OFFSET * (protein.getHomodimer() - 1)); + protein.setHeight(protein.getHeight() - SpeciesConverter.HOMODIMER_OFFSET * (protein.getHomodimer() - 1)); - alias.setX(alias.getX() + SpeciesConverter.HOMODIMER_OFFSET * (homodir)); - alias.setY(alias.getY() + SpeciesConverter.HOMODIMER_OFFSET * (homodir)); + protein.setX(protein.getX() + SpeciesConverter.HOMODIMER_OFFSET * (homodir)); + protein.setY(protein.getY() + SpeciesConverter.HOMODIMER_OFFSET * (homodir)); for (int homodimerId = 0; homodimerId < homodir; homodimerId++) { - alias.setX(alias.getX() - SpeciesConverter.HOMODIMER_OFFSET); - alias.setY(alias.getY() - SpeciesConverter.HOMODIMER_OFFSET); + protein.setX(protein.getX() - SpeciesConverter.HOMODIMER_OFFSET); + protein.setY(protein.getY() - SpeciesConverter.HOMODIMER_OFFSET); Shape shape = null; - if (alias instanceof GenericProtein || sbgnFormat) { - shape = getGenericShape(alias); - if (alias.getActivity() && !sbgnFormat) { - drawActivityGenericProtein(alias, graphics); + if (protein instanceof GenericProtein || sbgnFormat) { + shape = getGenericShape(protein); + if (protein.getActivity() && !sbgnFormat) { + drawActivityGenericProtein(protein, graphics); } - } else if (alias instanceof IonChannelProtein) { + } else if (protein instanceof IonChannelProtein) { Area a1; - if (!alias.getActivity()) { + if (!protein.getActivity()) { a1 = new Area( new RoundRectangle2D.Double( - alias.getX(), alias.getY(), alias.getWidth() - ION_CHANNEL_WIDTH - 1, alias.getHeight(), RECTANGLE_CORNER_ARC_SIZE, + protein.getX(), protein.getY(), protein.getWidth() - ION_CHANNEL_WIDTH - 1, protein.getHeight(), RECTANGLE_CORNER_ARC_SIZE, RECTANGLE_CORNER_ARC_SIZE)); } else { a1 = new Area( new RoundRectangle2D.Double( - alias.getX(), alias.getY(), alias.getWidth() - ION_CHANNEL_WIDTH - OPEN_ION_CHANNEL_WIDTH - 1, alias.getHeight(), RECTANGLE_CORNER_ARC_SIZE, - RECTANGLE_CORNER_ARC_SIZE)); + protein.getX(), protein.getY(), protein.getWidth() - ION_CHANNEL_WIDTH - OPEN_ION_CHANNEL_WIDTH - 1, protein.getHeight(), + RECTANGLE_CORNER_ARC_SIZE, RECTANGLE_CORNER_ARC_SIZE)); } Area a2 = new Area( new RoundRectangle2D.Double( - alias.getX() + alias.getWidth() - ION_CHANNEL_WIDTH, alias.getY(), ION_CHANNEL_WIDTH, alias.getHeight(), RECTANGLE_CORNER_ARC_SIZE, + protein.getX() + protein.getWidth() - ION_CHANNEL_WIDTH, protein.getY(), ION_CHANNEL_WIDTH, protein.getHeight(), RECTANGLE_CORNER_ARC_SIZE, RECTANGLE_CORNER_ARC_SIZE)); a1.add(a2); shape = a1; - } else if (alias instanceof TruncatedProtein) { - shape = getTruncatedShape(alias); - if (alias.getActivity()) { - drawActivityTruncatedShape(alias, graphics); + } else if (protein instanceof TruncatedProtein) { + shape = getTruncatedShape(protein); + if (protein.getActivity()) { + drawActivityTruncatedShape(protein, graphics); } - } else if (alias instanceof ReceptorProtein) { - shape = getReceptorShape(alias); - if (alias.getActivity()) { - drawActivityReceptorProtein(alias, graphics); + } else if (protein instanceof ReceptorProtein) { + shape = getReceptorShape(protein); + if (protein.getActivity()) { + drawActivityReceptorProtein(protein, graphics); } } else { - logger.warn(eu.getElementTag(alias) + "Unknown shape for protein"); - shape = getDefaultAliasShape(alias); + logger.warn(eu.getElementTag(protein) + "Unknown shape for protein"); + shape = getDefaultAliasShape(protein); } Color c = graphics.getColor(); - graphics.setColor(alias.getColor()); + graphics.setColor(protein.getColor()); graphics.fill(shape); graphics.setColor(c); Stroke stroke = graphics.getStroke(); - graphics.setStroke(getBorderLine(alias)); + graphics.setStroke(getBorderLine(protein)); graphics.draw(shape); graphics.setStroke(stroke); // SBGN display mode - units of information and state variables are // printed on the top element only if (!sbgnFormat || (homodimerId == homodir - 1)) { - for (ModificationResidue mr : alias.getModificationResidues()) { + for (ModificationResidue mr : protein.getModificationResidues()) { // SBGN display mode - print empty state variables - drawModification(alias, mr, graphics, sbgnFormat, false); + drawModification(protein, mr, graphics, sbgnFormat, false); } if (sbgnFormat) { // SBGN display mode - ion channel's state is marked as a unit of // information - if (alias instanceof IonChannelProtein) { + if (protein instanceof IonChannelProtein) { if (!unitOfInformationText.equals("")) { unitOfInformationText = unitOfInformationText.concat("; "); } - if (alias.getActivity()) { + if (protein.getActivity()) { unitOfInformationText = unitOfInformationText.concat("open"); } else { unitOfInformationText = unitOfInformationText.concat("closed"); @@ -202,7 +204,7 @@ public class ProteinConverter extends SpeciesConverter<Protein> { if (!unitOfInformationText.equals("")) { unitOfInformationText = unitOfInformationText.concat("; "); } - unitOfInformationText = unitOfInformationText.concat("N:").concat(Integer.toString(alias.getHomodimer())); + unitOfInformationText = unitOfInformationText.concat("N:").concat(Integer.toString(protein.getHomodimer())); } } } @@ -212,81 +214,81 @@ public class ProteinConverter extends SpeciesConverter<Protein> { unitOfInformationText = null; } - String text = alias.getStructuralState(); - drawStructuralState(text, alias, graphics); - drawUnitOfInformation(unitOfInformationText, alias, graphics); - drawText(alias, graphics, params); - alias.setWidth(alias.getWidth() + SpeciesConverter.HOMODIMER_OFFSET * (alias.getHomodimer() - 1)); - alias.setHeight(alias.getHeight() + SpeciesConverter.HOMODIMER_OFFSET * (alias.getHomodimer() - 1)); + String text = protein.getStructuralState(); + drawStructuralState(text, protein, graphics); + drawUnitOfInformation(unitOfInformationText, protein, graphics); + drawText(protein, graphics, params); + protein.setWidth(protein.getWidth() + SpeciesConverter.HOMODIMER_OFFSET * (protein.getHomodimer() - 1)); + protein.setHeight(protein.getHeight() + SpeciesConverter.HOMODIMER_OFFSET * (protein.getHomodimer() - 1)); } /** * Draws activity border of {@link GenericProtein}. * - * @param alias - * {@link Species} that will be drawn + * @param protein + * {@link Protein} that will be drawn * @param graphics * where we are drawing */ - private void drawActivityGenericProtein(final Protein alias, final Graphics2D graphics) { + private void drawActivityGenericProtein(final Protein protein, final Graphics2D graphics) { int border = ACTIVITY_BORDER_DISTANCE; - alias.increaseBorder(border); - Shape shape2 = getGenericShape(alias); + protein.increaseBorder(border); + Shape shape2 = getGenericShape(protein); Stroke stroke = graphics.getStroke(); graphics.setStroke(LineType.DOTTED.getStroke()); graphics.draw(shape2); graphics.setStroke(stroke); - alias.increaseBorder(-border); + protein.increaseBorder(-border); } /** * Draws activity border of {@link ReceptorProtein}. * - * @param alias - * {@link Species} that will be drawn + * @param protein + * {@link Protein} that will be drawn * @param graphics * where we are drawing */ - public void drawActivityReceptorProtein(final Protein alias, final Graphics2D graphics) { + public void drawActivityReceptorProtein(final Protein protein, final Graphics2D graphics) { int border = ACTIVITY_BORDER_DISTANCE; - alias.setX(alias.getX() - border); - alias.setY(alias.getY() - border); - alias.setWidth(alias.getWidth() + border * 2); - alias.setHeight(alias.getHeight() + border * 2); - Shape shape2 = getReceptorShape(alias); + protein.setX(protein.getX() - border); + protein.setY(protein.getY() - border); + protein.setWidth(protein.getWidth() + border * 2); + protein.setHeight(protein.getHeight() + border * 2); + Shape shape2 = getReceptorShape(protein); Stroke stroke = graphics.getStroke(); graphics.setStroke(LineType.DOTTED.getStroke()); graphics.draw(shape2); graphics.setStroke(stroke); - alias.setX(alias.getX() + border); - alias.setY(alias.getY() + border); - alias.setWidth(alias.getWidth() - border * 2); - alias.setHeight(alias.getHeight() - border * 2); + protein.setX(protein.getX() + border); + protein.setY(protein.getY() + border); + protein.setWidth(protein.getWidth() - border * 2); + protein.setHeight(protein.getHeight() - border * 2); } /** * Draws activity border of {@link TruncatedProtein}. * - * @param alias - * {@link Species} that will be drawn + * @param protein + * {@link Protein} that will be drawn * @param graphics * where we are drawing */ - public void drawActivityTruncatedShape(final Protein alias, final Graphics2D graphics) { + public void drawActivityTruncatedShape(final Protein protein, final Graphics2D graphics) { int border = ACTIVITY_BORDER_DISTANCE; - alias.setX(alias.getX() - border); - alias.setY(alias.getY() - border); - alias.setWidth(alias.getWidth() + border * 2); - alias.setHeight(alias.getHeight() + border * 2); - Shape shape2 = getTruncatedShape(alias); + protein.setX(protein.getX() - border); + protein.setY(protein.getY() - border); + protein.setWidth(protein.getWidth() + border * 2); + protein.setHeight(protein.getHeight() + border * 2); + Shape shape2 = getTruncatedShape(protein); Stroke stroke = graphics.getStroke(); graphics.setStroke(LineType.DOTTED.getStroke()); graphics.draw(shape2); graphics.setStroke(stroke); - alias.setX(alias.getX() + border); - alias.setY(alias.getY() + border); - alias.setWidth(alias.getWidth() - border * 2); - alias.setHeight(alias.getHeight() - border * 2); + protein.setX(protein.getX() + border); + protein.setY(protein.getY() + border); + protein.setWidth(protein.getWidth() - border * 2); + protein.setHeight(protein.getHeight() - border * 2); } /** @@ -295,7 +297,7 @@ public class ProteinConverter extends SpeciesConverter<Protein> { * set then also description (position) of the modification is drawn on the * canvas. * - * @param alias + * @param protein * object that is 'parent' of the residue * @param mr * modification to be drawn @@ -307,7 +309,7 @@ public class ProteinConverter extends SpeciesConverter<Protein> { * flag that indicates if we should draw description of the * modification */ - private void drawModification(final Protein alias, final ModificationResidue mr, final Graphics2D graphics, final boolean drawEmptyModification, + private void drawModification(final Protein protein, final ModificationResidue mr, final Graphics2D graphics, final boolean drawEmptyModification, final boolean drawDescription) { if ((!drawEmptyModification) && (mr.getState() == null)) { return; @@ -321,7 +323,7 @@ public class ProteinConverter extends SpeciesConverter<Protein> { angle -= Math.PI * 2; } - Point2D p = getResidueCoordinates(alias, mr.getAngle()); + Point2D p = getResidueCoordinates(protein, mr.getAngle()); Ellipse2D ellipse = new Ellipse2D.Double(p.getX() - diameter / 2, p.getY() - diameter / 2, diameter, diameter); Color c = graphics.getColor(); graphics.setColor(Color.WHITE); @@ -332,9 +334,9 @@ public class ProteinConverter extends SpeciesConverter<Protein> { String text = mr.getName(); if (!text.equals("") && drawDescription) { - alias.increaseBorder(-diameter / 2); - Point2D p2 = getResidueCoordinates(alias, mr.getAngle()); - alias.increaseBorder(diameter / 2); + protein.increaseBorder(-diameter / 2); + Point2D p2 = getResidueCoordinates(protein, mr.getAngle()); + protein.increaseBorder(diameter / 2); double width = graphics.getFontMetrics().stringWidth(text); double height = graphics.getFontMetrics().getHeight(); @@ -368,14 +370,14 @@ public class ProteinConverter extends SpeciesConverter<Protein> { /** * Returns shape of receptor protein. * - * @param alias + * @param protein * alias for which we are looking for a border * @return Shape object defining given alias */ - protected Shape getReceptorShape(final Element alias) { + protected Shape getReceptorShape(final Protein protein) { Shape shape; GeneralPath path = new GeneralPath(Path2D.WIND_EVEN_ODD); - ArrayList<Point2D> points = getReceptorPoints(alias); + ArrayList<Point2D> points = getReceptorPoints(protein); path.moveTo(points.get(0).getX(), points.get(0).getY()); for (int i = 1; i < points.size(); i++) { path.lineTo(points.get(i).getX(), points.get(i).getY()); @@ -388,25 +390,25 @@ public class ProteinConverter extends SpeciesConverter<Protein> { /** * Returns shape of truncated protein. * - * @param alias + * @param protein * alias for which we are looking for a border * @return Shape object defining given alias */ - protected Shape getTruncatedShape(final Element alias) { + protected Shape getTruncatedShape(final Protein protein) { Shape shape; GeneralPath path = new GeneralPath(); // CHECKSTYLE:OFF - path.moveTo(alias.getX() + 10, alias.getY()); - path.lineTo(alias.getX() + alias.getWidth(), alias.getY()); - path.lineTo(alias.getX() + alias.getWidth(), alias.getY() + alias.getHeight() * 3 / 5); - path.lineTo(alias.getX() + alias.getWidth() * 4 / 5, alias.getY() + alias.getHeight() * 2 / 5); - path.lineTo(alias.getX() + alias.getWidth() * 4 / 5, alias.getY() + alias.getHeight()); - path.lineTo(alias.getX() + 10, alias.getY() + alias.getHeight()); + path.moveTo(protein.getX() + 10, protein.getY()); + path.lineTo(protein.getX() + protein.getWidth(), protein.getY()); + path.lineTo(protein.getX() + protein.getWidth(), protein.getY() + protein.getHeight() * 3 / 5); + path.lineTo(protein.getX() + protein.getWidth() * 4 / 5, protein.getY() + protein.getHeight() * 2 / 5); + path.lineTo(protein.getX() + protein.getWidth() * 4 / 5, protein.getY() + protein.getHeight()); + path.lineTo(protein.getX() + 10, protein.getY() + protein.getHeight()); path.curveTo( - alias.getX() + 5, alias.getY() + alias.getHeight() - 2, alias.getX() + 2, alias.getY() + alias.getHeight() - 5, alias.getX(), - alias.getY() + alias.getHeight() - 10); - path.lineTo(alias.getX(), alias.getY() + 10); - path.curveTo(alias.getX() + 2, alias.getY() + 5, alias.getX() + 5, alias.getY() + 2, alias.getX() + 10, alias.getY()); + protein.getX() + 5, protein.getY() + protein.getHeight() - 2, protein.getX() + 2, protein.getY() + protein.getHeight() - 5, protein.getX(), + protein.getY() + protein.getHeight() - 10); + path.lineTo(protein.getX(), protein.getY() + 10); + path.curveTo(protein.getX() + 2, protein.getY() + 5, protein.getX() + 5, protein.getY() + 2, protein.getX() + 10, protein.getY()); // CHECKSTYLE:ON path.closePath(); @@ -417,15 +419,15 @@ public class ProteinConverter extends SpeciesConverter<Protein> { /** * Returns shape of receptor protein as a list of points. * - * @param alias + * @param protein * alias for which we are looking for a border * @return list of points defining border of the given alias */ - private ArrayList<Point2D> getReceptorPoints(final Element alias) { - double x = alias.getX(); - double y = alias.getY(); - double width = alias.getWidth(); - double height = alias.getHeight(); + private ArrayList<Point2D> getReceptorPoints(final Protein protein) { + double x = protein.getX(); + double y = protein.getY(); + double width = protein.getWidth(); + double height = protein.getHeight(); ArrayList<Point2D> points = new ArrayList<Point2D>(); // CHECKSTYLE:OFF @@ -443,17 +445,17 @@ public class ProteinConverter extends SpeciesConverter<Protein> { } @Override - public PathIterator getBoundPathIterator(final Protein alias) { - if (alias instanceof GenericProtein) { - return getGenericShape(alias).getPathIterator(new AffineTransform()); - } else if (alias instanceof ReceptorProtein) { - return getReceptorShape(alias).getPathIterator(new AffineTransform()); - } else if (alias instanceof IonChannelProtein) { - return getGenericShape(alias).getPathIterator(new AffineTransform()); - } else if (alias instanceof TruncatedProtein) { - return getTruncatedShape(alias).getPathIterator(new AffineTransform()); + public PathIterator getBoundPathIterator(final Protein protein) { + if (protein instanceof GenericProtein) { + return getGenericShape(protein).getPathIterator(new AffineTransform()); + } else if (protein instanceof ReceptorProtein) { + return getReceptorShape(protein).getPathIterator(new AffineTransform()); + } else if (protein instanceof IonChannelProtein) { + return getGenericShape(protein).getPathIterator(new AffineTransform()); + } else if (protein instanceof TruncatedProtein) { + return getTruncatedShape(protein).getPathIterator(new AffineTransform()); } else { - throw new InvalidArgumentException("Not implemented protein converter for type: " + alias.getClass()); + throw new InvalidArgumentException("Not implemented protein converter for type: " + protein.getClass()); } } diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/RnaConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/RnaConverter.java index 277a8afc651d80665eaf652fd9d4dae4622926b4..bf0b0533f521cf4572b7b00fdcca619f978c9263 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/RnaConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/RnaConverter.java @@ -1,10 +1,10 @@ - /** - * Default constructor. - * - * @param colorExtractor - * Object that helps to convert {@link ColorSchema} values into - * colors when drawing {@link Species} - */ +/** + * Default constructor. + * + * @param colorExtractor + * Object that helps to convert {@link ColorSchema} values into colors + * when drawing {@link Species} + */ package lcsb.mapviewer.converter.graphics.bioEntity.element.species; import java.awt.Color; @@ -23,7 +23,6 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.commands.ColorExtractor; import lcsb.mapviewer.converter.graphics.ConverterParams; import lcsb.mapviewer.model.map.layout.ColorSchema; -import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.map.species.Rna; import lcsb.mapviewer.model.map.species.Species; import lcsb.mapviewer.model.map.species.field.ModificationState; @@ -55,46 +54,46 @@ public class RnaConverter extends SpeciesConverter<Rna> { } @Override - public void draw(final Rna alias, final Graphics2D graphics, final ConverterParams params) { - GeneralPath path = getRnaPath(alias); + public void draw(final Rna rna, final Graphics2D graphics, final ConverterParams params) { + GeneralPath path = getRnaPath(rna); Color c = graphics.getColor(); - graphics.setColor(alias.getColor()); + graphics.setColor(rna.getColor()); graphics.fill(path); graphics.setColor(c); Stroke stroke = graphics.getStroke(); - graphics.setStroke(getBorderLine(alias)); + graphics.setStroke(getBorderLine(rna)); graphics.draw(path); graphics.setStroke(stroke); - for (RnaRegion mr : alias.getRegions()) { - drawModification(alias, mr, graphics, false, false); + for (RnaRegion mr : rna.getRegions()) { + drawModification(rna, mr, graphics, false, false); } - drawText(alias, graphics, params); + drawText(rna, graphics, params); } /** - * Returns shape of the Rna as a GeneralPath object. + * Returns shape of the {@link Rna} as a {@link GeneralPath} object. * - * @param alias - * alias for which we are looking for a border - * @return GeneralPath object defining border of the given alias + * @param rna + * {@link Rna} for which we are looking for a border + * @return {@link GeneralPath} object defining border of the given {@link Rna} */ - private GeneralPath getRnaPath(final Element alias) { + private GeneralPath getRnaPath(final Rna rna) { // CHECKSTYLE:OFF GeneralPath path = new GeneralPath(Path2D.WIND_EVEN_ODD, 4); - path.moveTo(alias.getX() + alias.getWidth() / 4, alias.getY()); - path.lineTo(alias.getX() + alias.getWidth(), alias.getY()); - path.lineTo(alias.getX() + alias.getWidth() * 3 / 4, alias.getY() + alias.getHeight()); - path.lineTo(alias.getX(), alias.getY() + alias.getHeight()); + path.moveTo(rna.getX() + rna.getWidth() / 4, rna.getY()); + path.lineTo(rna.getX() + rna.getWidth(), rna.getY()); + path.lineTo(rna.getX() + rna.getWidth() * 3 / 4, rna.getY() + rna.getHeight()); + path.lineTo(rna.getX(), rna.getY() + rna.getHeight()); // CHECKSTYLE:ON path.closePath(); return path; } @Override - public PathIterator getBoundPathIterator(final Rna alias) { - return getRnaPath(alias).getPathIterator(new AffineTransform()); + public PathIterator getBoundPathIterator(final Rna rna) { + return getRnaPath(rna).getPathIterator(new AffineTransform()); } /** @@ -103,10 +102,10 @@ public class RnaConverter extends SpeciesConverter<Rna> { * set then also description (position) of the modification is drawn on the * canvas. * - * @param alias + * @param rna * object that is 'parent' of the residue - * @param mr - * modification to be drawn + * @param region + * {@link RnaRegion modification} to be drawn * @param graphics * - where the modification should be drawn * @param drawEmptyModification @@ -115,22 +114,22 @@ public class RnaConverter extends SpeciesConverter<Rna> { * flag that indicates if we should draw description of the * modification */ - private void drawModification(final Rna alias, final RnaRegion mr, final Graphics2D graphics, final boolean drawEmptyModification, + private void drawModification(final Rna rna, final RnaRegion region, final Graphics2D graphics, final boolean drawEmptyModification, final boolean drawDescription) { - if ((!drawEmptyModification) && (mr.getState() == null)) { + if ((!drawEmptyModification) && (region.getState() == null)) { return; } double diameter = DEFAULT_MODIFICATION_DIAMETER; - double x = alias.getX(); - double y = alias.getY(); + double x = rna.getX(); + double y = rna.getY(); - double width = alias.getWidth(); + double width = rna.getWidth(); // CHECKSTYLE:OFF // we draw modifier on the upper border of rna (which is only in // 3/4 of the width of alias, but starts in 1/4 of the width) - Point2D p = new Point2D.Double(x + width / 4.0 + width * 3.0 / 4.0 * mr.getPos(), y - DEFAULT_MODIFICATION_DIAMETER); + Point2D p = new Point2D.Double(x + width / 4.0 + width * 3.0 / 4.0 * region.getPos(), y - DEFAULT_MODIFICATION_DIAMETER); // CHECKSTYLE:ON Ellipse2D ellipse = new Ellipse2D.Double(p.getX() - diameter / 2, p.getY() - diameter / 2, diameter, diameter); @@ -141,13 +140,13 @@ public class RnaConverter extends SpeciesConverter<Rna> { graphics.draw(ellipse); graphics.drawLine((int) p.getX(), (int) (p.getY() + diameter / 2), (int) p.getX(), (int) y); - String text = mr.getName(); + String text = region.getName(); if (!text.equals("") && drawDescription) { double textWidth = graphics.getFontMetrics().stringWidth(text); Point2D p2 = new Point2D.Double(p.getX() - textWidth / 2, p.getY() - DEFAULT_SPECIES_MODIFIER_FONT_SIZE); graphics.drawString(text, (int) p2.getX(), (int) p2.getY()); } - ModificationState state = mr.getState(); + ModificationState state = region.getState(); if (state != null) { String str = state.getAbbreviation(); Font tmpFont = graphics.getFont(); diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SBGNNucleicAcidFeatureConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SBGNNucleicAcidFeatureConverter.java index 5412c1b961a4f388bf754aea9e8452528312722c..cd82b37bc9e91e2e3aba4f947c688f2de3ec4d73 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SBGNNucleicAcidFeatureConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SBGNNucleicAcidFeatureConverter.java @@ -11,11 +11,10 @@ import java.awt.geom.PathIterator; import lcsb.mapviewer.commands.ColorExtractor; import lcsb.mapviewer.converter.graphics.ConverterParams; import lcsb.mapviewer.model.map.layout.ColorSchema; -import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.map.species.Species; /** - * This class defines methods used for drawing SpeciesAlias of nucleic acid + * This class defines methods used for drawing {@link Species} of nucleic acid * feature in the SBGN way on the {@link Graphics2D} object. * * @author Michał Kuźma @@ -44,13 +43,13 @@ public class SBGNNucleicAcidFeatureConverter extends SpeciesConverter<Species> { /** * Returns shape of SBGN Nucleic acid feature. * - * @param alias - * alias for which the shape should be returned + * @param species + * {@link Species} for which the shape should be returned * @return shape of the SBGN Nucleic acid feature for given alias */ - private Shape getShape(final Element alias) { + private Shape getShape(final Species species) { GeneralPath bottomRoundedRectangle = new GeneralPath(GeneralPath.WIND_EVEN_ODD); - double x = alias.getX(), y = alias.getY(), width = alias.getWidth(), height = alias.getHeight(); + double x = species.getX(), y = species.getY(), width = species.getWidth(), height = species.getHeight(); bottomRoundedRectangle.moveTo(x, y); bottomRoundedRectangle.lineTo(x, y + height - RECTANGLE_CORNER_ARC_SIZE); @@ -64,24 +63,24 @@ public class SBGNNucleicAcidFeatureConverter extends SpeciesConverter<Species> { } @Override - public void draw(Species alias, Graphics2D graphics, ConverterParams params) { + public void draw(Species species, Graphics2D graphics, ConverterParams params) { // Unit of information text - multimer cardinality String unitOfInformationText = null; - if (alias.getStatePrefix() != null && alias.getStateLabel() != null) { - if (alias.getStatePrefix().equals("free input")) { - unitOfInformationText = alias.getStateLabel(); + if (species.getStatePrefix() != null && species.getStateLabel() != null) { + if (species.getStatePrefix().equals("free input")) { + unitOfInformationText = species.getStateLabel(); } else { - unitOfInformationText = alias.getStatePrefix() + ":" + alias.getStateLabel(); + unitOfInformationText = species.getStatePrefix() + ":" + species.getStateLabel(); } } - int homodir = alias.getHomodimer(); + int homodir = species.getHomodimer(); - alias.setWidth(alias.getWidth() - SpeciesConverter.HOMODIMER_OFFSET * (alias.getHomodimer() - 1)); - alias.setHeight(alias.getHeight() - SpeciesConverter.HOMODIMER_OFFSET * (alias.getHomodimer() - 1)); + species.setWidth(species.getWidth() - SpeciesConverter.HOMODIMER_OFFSET * (species.getHomodimer() - 1)); + species.setHeight(species.getHeight() - SpeciesConverter.HOMODIMER_OFFSET * (species.getHomodimer() - 1)); - alias.setX(alias.getX() + SpeciesConverter.HOMODIMER_OFFSET * homodir); - alias.setY(alias.getY() + SpeciesConverter.HOMODIMER_OFFSET * homodir); + species.setX(species.getX() + SpeciesConverter.HOMODIMER_OFFSET * homodir); + species.setY(species.getY() + SpeciesConverter.HOMODIMER_OFFSET * homodir); int glyphCount; if (homodir > 1) { @@ -90,18 +89,18 @@ public class SBGNNucleicAcidFeatureConverter extends SpeciesConverter<Species> { glyphCount = 1; } for (int i = 0; i < glyphCount; i++) { - alias.setX(alias.getX() - SpeciesConverter.HOMODIMER_OFFSET); - alias.setY(alias.getY() - SpeciesConverter.HOMODIMER_OFFSET); + species.setX(species.getX() - SpeciesConverter.HOMODIMER_OFFSET); + species.setY(species.getY() - SpeciesConverter.HOMODIMER_OFFSET); - Shape shape = getShape(alias); + Shape shape = getShape(species); Color c = graphics.getColor(); - graphics.setColor(alias.getColor()); + graphics.setColor(species.getColor()); graphics.fill(shape); graphics.setColor(c); Stroke stroke = graphics.getStroke(); - graphics.setStroke(getBorderLine(alias)); + graphics.setStroke(getBorderLine(species)); graphics.draw(shape); graphics.setStroke(stroke); @@ -118,16 +117,16 @@ public class SBGNNucleicAcidFeatureConverter extends SpeciesConverter<Species> { } - drawUnitOfInformation(unitOfInformationText, alias, graphics); - drawText(alias, graphics, params); + drawUnitOfInformation(unitOfInformationText, species, graphics); + drawText(species, graphics, params); - alias.setWidth(alias.getWidth() + SpeciesConverter.HOMODIMER_OFFSET * (homodir - 1)); - alias.setHeight(alias.getHeight() + SpeciesConverter.HOMODIMER_OFFSET * (homodir - 1)); + species.setWidth(species.getWidth() + SpeciesConverter.HOMODIMER_OFFSET * (homodir - 1)); + species.setHeight(species.getHeight() + SpeciesConverter.HOMODIMER_OFFSET * (homodir - 1)); } @Override - protected PathIterator getBoundPathIterator(Species alias) { - return getShape(alias).getPathIterator(new AffineTransform()); + protected PathIterator getBoundPathIterator(Species species) { + return getShape(species).getPathIterator(new AffineTransform()); } } diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SimpleMoleculeConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SimpleMoleculeConverter.java index 8abca141bd11232bed19933a0737079b56a8c016..8ce04bcc3d88e37d14e34c3f439c3cf2f9bd26c0 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SimpleMoleculeConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SimpleMoleculeConverter.java @@ -18,8 +18,8 @@ import lcsb.mapviewer.model.map.species.SimpleMolecule; import lcsb.mapviewer.model.map.species.Species; /** - * This class defines methods used for drawing {@link SimpleMolecule} on - * the {@link Graphics2D} object. + * This class defines methods used for drawing {@link SimpleMolecule} on the + * {@link Graphics2D} object. * * @author Piotr Gawron * @@ -42,42 +42,42 @@ public class SimpleMoleculeConverter extends SpeciesConverter<SimpleMolecule> { } @Override - public void draw(final SimpleMolecule alias, final Graphics2D graphics, final ConverterParams params) { + public void draw(final SimpleMolecule simpleMolecule, final Graphics2D graphics, final ConverterParams params) { int homodir; if (params.isSbgnFormat()) { // If the SBGN display mode is set, multimer is shown as two stacked // glyphs - if (alias.getHomodimer() > 1) { + if (simpleMolecule.getHomodimer() > 1) { homodir = 2; } else { homodir = 1; } } else { - homodir = alias.getHomodimer(); + homodir = simpleMolecule.getHomodimer(); } - alias.setWidth(alias.getWidth() - SpeciesConverter.HOMODIMER_OFFSET * (homodir - 1)); - alias.setHeight(alias.getHeight() - SpeciesConverter.HOMODIMER_OFFSET * (homodir - 1)); + simpleMolecule.setWidth(simpleMolecule.getWidth() - SpeciesConverter.HOMODIMER_OFFSET * (homodir - 1)); + simpleMolecule.setHeight(simpleMolecule.getHeight() - SpeciesConverter.HOMODIMER_OFFSET * (homodir - 1)); // SBGN view - simple molecules are represented as circles if (params.isSbgnFormat()) { - alias.setX(alias.getX() + (alias.getWidth() - alias.getHeight()) / 2); - alias.setWidth(alias.getHeight()); + simpleMolecule.setX(simpleMolecule.getX() + (simpleMolecule.getWidth() - simpleMolecule.getHeight()) / 2); + simpleMolecule.setWidth(simpleMolecule.getHeight()); } - alias.setX(alias.getX() + SpeciesConverter.HOMODIMER_OFFSET * (homodir)); - alias.setY(alias.getY() + SpeciesConverter.HOMODIMER_OFFSET * (homodir)); + simpleMolecule.setX(simpleMolecule.getX() + SpeciesConverter.HOMODIMER_OFFSET * (homodir)); + simpleMolecule.setY(simpleMolecule.getY() + SpeciesConverter.HOMODIMER_OFFSET * (homodir)); for (int i = 0; i < homodir; i++) { - alias.setX(alias.getX() - SpeciesConverter.HOMODIMER_OFFSET); - alias.setY(alias.getY() - SpeciesConverter.HOMODIMER_OFFSET); - Shape shape = new Ellipse2D.Double(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight()); + simpleMolecule.setX(simpleMolecule.getX() - SpeciesConverter.HOMODIMER_OFFSET); + simpleMolecule.setY(simpleMolecule.getY() - SpeciesConverter.HOMODIMER_OFFSET); + Shape shape = new Ellipse2D.Double(simpleMolecule.getX(), simpleMolecule.getY(), simpleMolecule.getWidth(), simpleMolecule.getHeight()); Color c = graphics.getColor(); - graphics.setColor(alias.getColor()); + graphics.setColor(simpleMolecule.getColor()); graphics.fill(shape); graphics.setColor(c); Stroke stroke = graphics.getStroke(); - graphics.setStroke(getBorderLine(alias)); + graphics.setStroke(getBorderLine(simpleMolecule)); graphics.draw(shape); graphics.setStroke(stroke); @@ -85,8 +85,8 @@ public class SimpleMoleculeConverter extends SpeciesConverter<SimpleMolecule> { // containing cardinality if (params.isSbgnFormat() && (i == homodir - 1)) { String unitOfInformationText = null; - if (alias.getStatePrefix() != null && alias.getStateLabel() != null) { - unitOfInformationText = alias.getStatePrefix() + ":" + alias.getStateLabel(); + if (simpleMolecule.getStatePrefix() != null && simpleMolecule.getStateLabel() != null) { + unitOfInformationText = simpleMolecule.getStatePrefix() + ":" + simpleMolecule.getStateLabel(); } if (homodir == 2 && (unitOfInformationText == null || !unitOfInformationText.contains("N:"))) { if (unitOfInformationText != null) { @@ -94,30 +94,31 @@ public class SimpleMoleculeConverter extends SpeciesConverter<SimpleMolecule> { } else { unitOfInformationText = ""; } - unitOfInformationText += "N:" + alias.getHomodimer(); + unitOfInformationText += "N:" + simpleMolecule.getHomodimer(); } - drawUnitOfInformation(unitOfInformationText, alias, graphics); + drawUnitOfInformation(unitOfInformationText, simpleMolecule, graphics); } } - alias.setWidth(alias.getWidth() + SpeciesConverter.HOMODIMER_OFFSET * (homodir - 1)); - alias.setHeight(alias.getHeight() + SpeciesConverter.HOMODIMER_OFFSET * (homodir - 1)); - drawText(alias, graphics, params); + simpleMolecule.setWidth(simpleMolecule.getWidth() + SpeciesConverter.HOMODIMER_OFFSET * (homodir - 1)); + simpleMolecule.setHeight(simpleMolecule.getHeight() + SpeciesConverter.HOMODIMER_OFFSET * (homodir - 1)); + drawText(simpleMolecule, graphics, params); } @Override - public PathIterator getBoundPathIterator(final SimpleMolecule alias) { + public PathIterator getBoundPathIterator(final SimpleMolecule simpleMolecule) { throw new InvalidStateException("This class doesn't provide boundPath"); } @Override - public Point2D getPointCoordinatesOnBorder(final SimpleMolecule alias, final double angle) { - if (alias.getWidth() == 0 && alias.getHeight() == 0) { + public Point2D getPointCoordinatesOnBorder(final SimpleMolecule simpleMolecule, final double angle) { + if (simpleMolecule.getWidth() == 0 && simpleMolecule.getHeight() == 0) { logger.warn("Looking for coordinates on border of alias of size 0"); - return alias.getCenter(); + return simpleMolecule.getCenter(); } Point2D result; - result = getEllipseTransformation().getPointOnEllipseByRadian(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight(), angle); + result = getEllipseTransformation() + .getPointOnEllipseByRadian(simpleMolecule.getX(), simpleMolecule.getY(), simpleMolecule.getWidth(), simpleMolecule.getHeight(), angle); return result; } diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SpeciesConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SpeciesConverter.java index fb2460619fcd85d355aac51b301c351525d48b53..2bf368852c188ceceb829c2009a4541d6007d2df 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SpeciesConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SpeciesConverter.java @@ -16,7 +16,6 @@ import java.util.List; import org.apache.log4j.Logger; import lcsb.mapviewer.commands.ColorExtractor; -import lcsb.mapviewer.commands.SemanticZoomLevelMatcher; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.common.geometry.EllipseTransformation; @@ -27,22 +26,19 @@ 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; -import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.map.species.Species; /** - * This class defines basics used for drawing aliases of {@link Species} (node - * in the graph representation) on the graphics2d object. + * This class defines basics used for drawing {@link Species} (node in the graph + * representation) on the {@link Graphics2D} object. * * @param <T> - * alias class that can be drawn with this converter + * type of {@link Species} class that can be drawn with this converter * @author Piotr Gawron * */ public abstract class SpeciesConverter<T extends Species> extends ElementConverter<T> { - private SemanticZoomLevelMatcher zoomLevelMatcher = new SemanticZoomLevelMatcher(); - /** * PI value. */ @@ -167,45 +163,47 @@ public abstract class SpeciesConverter<T extends Species> extends ElementConvert }; /** - * Returns coordinates on the alias border for given angle. + * Returns coordinates on the {@link Species} border for given angle. * - * @param alias - * object on border which the point is looked for + * @param species + * {@link Species} on border which the point is looked for * @param angle - * angle between X axis center point of alias and point that we are - * looking for - * @return coordinates on the alias border that correspond to the angle + * angle between X axis center point of {@link Species} and point + * that we are looking for + * @return coordinates on the {@link Species} border that correspond to the + * angle */ - protected Point2D getPointCoordinatesOnBorder(final T alias, final double angle) { + protected Point2D getPointCoordinatesOnBorder(final T species, final double angle) { Point2D result = null; - if (alias.getWidth() == 0 && alias.getHeight() == 0) { - result = alias.getCenter(); + if (species.getWidth() == 0 && species.getHeight() == 0) { + result = species.getCenter(); } else { - double dist = Math.max(alias.getWidth(), alias.getHeight()) * 2; - Point2D startPoint = alias.getCenter(); + double dist = Math.max(species.getWidth(), species.getHeight()) * 2; + Point2D startPoint = species.getCenter(); double x = startPoint.getX() + Math.cos(angle) * dist; double y = startPoint.getY() - Math.sin(angle) * dist; Point2D endPoint = new Point2D.Double(x, y); Line2D line = new Line2D.Double(startPoint, endPoint); - result = lineTransformation.getIntersectionWithPathIterator(line, getBoundPathIterator(alias)); + result = lineTransformation.getIntersectionWithPathIterator(line, getBoundPathIterator(species)); } return result; } /** - * Returns coordinates on the alias border for given angle for residues. + * Returns coordinates on the {@link Species} border for given angle for + * residues. * - * @param alias + * @param species * object on border which the point is looked for * @param angle * CellDEsigner specific angle defining coordinates (;/) * @return coordinates on the alias border that correspond to the angle */ - protected Point2D getResidueCoordinates(final T alias, double angle) { + protected Point2D getResidueCoordinates(final T species, double angle) { Point2D result = null; - if (alias.getWidth() == 0 && alias.getHeight() == 0) { - result = alias.getCenter(); + if (species.getWidth() == 0 && species.getHeight() == 0) { + result = species.getCenter(); } else { double x = 0; double y = 0; @@ -219,74 +217,76 @@ public abstract class SpeciesConverter<T extends Species> extends ElementConvert // CHECKSTYLE:OFF 0.5 is much readable than any other suggestion double ratio = 0.5 + angle / (PI / 2); // CHECKSTYLE:ON - x = alias.getX() + alias.getWidth(); - y = alias.getY() + alias.getHeight() * (1 - ratio); + x = species.getX() + species.getWidth(); + y = species.getY() + species.getHeight() * (1 - ratio); } else if (angle < TOP_RESIDUE_MAX_ANGLE) { double ratio = (angle - RIGHT_TOP_RESIDUE_MAX_ANGLE) / (PI / 2); - y = alias.getY(); - x = alias.getX() + alias.getWidth() * (1 - ratio); + y = species.getY(); + x = species.getX() + species.getWidth() * (1 - ratio); } else if (angle < LEFT_RESIDUE_MAX_ANGLE) { double ratio = (angle - TOP_RESIDUE_MAX_ANGLE) / (PI / 2); - y = alias.getY() + alias.getHeight() * (ratio); - x = alias.getX(); + y = species.getY() + species.getHeight() * (ratio); + x = species.getX(); } else if (angle < BOTTOM_RESIDUE_MAX_ANGLE) { double ratio = (angle - LEFT_RESIDUE_MAX_ANGLE) / (PI / 2); - y = alias.getY() + alias.getHeight(); - x = alias.getX() + alias.getWidth() * ratio; + y = species.getY() + species.getHeight(); + x = species.getX() + species.getWidth() * ratio; } else if (angle <= 2 * PI + Configuration.EPSILON) { double ratio = (angle - BOTTOM_RESIDUE_MAX_ANGLE) / (PI / 2); - y = alias.getY() + alias.getHeight() * (1 - ratio); - x = alias.getX() + alias.getWidth(); + y = species.getY() + species.getHeight() * (1 - ratio); + x = species.getX() + species.getWidth(); } else { throw new InvalidStateException(); } - Point2D center = alias.getCenter(); + Point2D center = species.getCenter(); double correctedAngle = -Math.atan2((y - center.getY()), (x - center.getX())); - result = getPointCoordinatesOnBorder(alias, correctedAngle); + result = getPointCoordinatesOnBorder(species, correctedAngle); } return result; } /** - * Returns default shape of the alias. + * Returns default shape of the {@link Species}. * - * @param alias - * alias for which we are looking for a border - * @return Shape object defining given alias + * @param species + * {@link Species} for which we are looking for a border + * @return {@link Shape} object defining given {@link Species} */ - protected Shape getDefaultAliasShape(final Element alias) { + protected Shape getDefaultAliasShape(final Species species) { Shape shape; - shape = new Rectangle(alias.getX().intValue(), alias.getY().intValue(), alias.getWidth().intValue(), alias.getHeight().intValue()); + shape = new Rectangle(species.getX().intValue(), species.getY().intValue(), species.getWidth().intValue(), species.getHeight().intValue()); return shape; } /** - * Returns font that should be used for drawing description of the alias. + * Returns font that should be used for drawing description of the + * {@link Species}. * - * @param alias - * alias for which we are looking for a font + * @param species + * {@link Species} for which we are looking for a font * @param params * specific drawing parameters (like scale) - * @return Font that should be used for drawing alias description + * @return {@link Font} that should be used for drawing {@link Species} + * description */ - protected Font getFont(final Element alias, ConverterParams params) { + protected Font getFont(final Species species, ConverterParams params) { double fontSize = DEFAULT_SPECIES_FONT_SIZE; - if (alias.getFontSize() != null) { - fontSize = alias.getFontSize(); + if (species.getFontSize() != null) { + fontSize = species.getFontSize(); } return new Font(Font.SANS_SERIF, 0, (int) (fontSize * params.getScale())); } /** - * Returns text describing alias. + * Returns text describing {@link Species}. * - * @param alias + * @param species * object under investigation - * @return description of the alias + * @return description of the {@link Species} */ - protected String getText(final T alias) { - String name = alias.getName(); + protected String getText(final T species) { + String name = species.getName(); if (name.equals("")) { name = " "; } @@ -295,18 +295,18 @@ public abstract class SpeciesConverter<T extends Species> extends ElementConvert } @Override - public void drawText(final T alias, final Graphics2D graphics, final ConverterParams params) { - String text = getText(alias); + public void drawText(final T species, final Graphics2D graphics, final ConverterParams params) { + String text = getText(species); Font oldFont = graphics.getFont(); - Font font = getFont(alias, params); + Font font = getFont(species, params); graphics.setColor(Color.BLACK); graphics.setFont(font); - Point2D point = alias.getCenter(); - if (alias instanceof Complex) { - if (((Complex) alias).getElements().size() > 0) { - if (zoomLevelMatcher.isTransparent(params.getLevel(), alias.getTransparencyLevel())) { - point.setLocation(point.getX(), alias.getY() + alias.getHeight() - graphics.getFontMetrics().getAscent()); + Point2D point = species.getCenter(); + if (species instanceof Complex) { + if (((Complex) species).getElements().size() > 0) { + if (isTransparent(species, params)) { + point.setLocation(point.getX(), species.getY() + species.getHeight() - graphics.getFontMetrics().getAscent()); } } } @@ -403,19 +403,19 @@ public abstract class SpeciesConverter<T extends Species> extends ElementConvert /** * Returns line style used for drawing alias border. * - * @param alias - * alias to be drawn - * @return style of the line used to draw alias + * @param species + * {@link Species} to be drawn + * @return style of the line used to draw {@link Species} */ - protected Stroke getBorderLine(final Species alias) { - if (!alias.isHypothetical()) { - if (alias instanceof Complex) { + protected Stroke getBorderLine(final Species species) { + if (!species.isHypothetical()) { + if (species instanceof Complex) { return LineType.SOLID_BOLD.getStroke(); } else { return LineType.SOLID.getStroke(); } } else { - if (alias instanceof Complex) { + if (species instanceof Complex) { return LineType.DASHED_BOLD.getStroke(); } else { return LineType.DASHED.getStroke(); @@ -424,13 +424,13 @@ public abstract class SpeciesConverter<T extends Species> extends ElementConvert } /** - * Returns border of the alias as PathIterator. + * Returns border of the {@link Species} as {@link PathIterator}. * - * @param alias - * alias for which we are looking for a border - * @return PathIterator object defining given alias + * @param species + * {@link Species} for which we are looking for a border + * @return {@link PathIterator} object defining given {@link Species} */ - protected abstract PathIterator getBoundPathIterator(T alias); + protected abstract PathIterator getBoundPathIterator(T species); /** * @return the lineTransformation @@ -498,23 +498,23 @@ public abstract class SpeciesConverter<T extends Species> extends ElementConvert * * @param text * state description text - * @param alias - * state description should be drawn on this alias + * @param species + * state description should be drawn on this {@link Species} * @param graphics * where the drawing should be performed */ - protected void drawStructuralState(String text, T alias, final Graphics2D graphics) { + protected void drawStructuralState(String text, T species, final Graphics2D graphics) { if (text == null) { return; } - Point2D p = getPointCoordinatesOnBorder(alias, Math.PI / 2); + Point2D p = getPointCoordinatesOnBorder(species, Math.PI / 2); double width = MIN_STRUCTURAL_STATE_WIDTH; if (!text.trim().equals("")) { width = Math.max(MIN_STRUCTURAL_STATE_WIDTH, graphics.getFontMetrics().stringWidth(text) + TEXT_MARGIN_FOR_STRUCTURAL_STATE_DESC); } - width = Math.min(width, alias.getWidth()); + width = Math.min(width, species.getWidth()); double height = STRUCTURAL_STATE_HEIGHT; Ellipse2D ellipse = new Ellipse2D.Double(p.getX() - width / 2, p.getY() - height / 2, width, height); @@ -537,28 +537,28 @@ public abstract class SpeciesConverter<T extends Species> extends ElementConvert } /** - * Draws unit of information for the alias (rectangle in the top part of the - * alias). + * Draws unit of information for the {@link Species} (rectangle in the top + * part of the alias). * * @param text * unit of information text - * @param alias - * unit of information should be drawn on this alias + * @param species + * unit of information should be drawn on this {@link Species} * @param graphics * where the drawing should be performed */ - protected void drawUnitOfInformation(String text, T alias, final Graphics2D graphics) { + protected void drawUnitOfInformation(String text, T species, final Graphics2D graphics) { if (text == null) { return; } - Point2D p = getPointCoordinatesOnBorder(alias, Math.PI / 2); + Point2D p = getPointCoordinatesOnBorder(species, Math.PI / 2); double width = MIN_UNIT_OF_INFORMATION_WIDTH; if (!text.trim().equals("")) { width = Math.max(MIN_UNIT_OF_INFORMATION_WIDTH, graphics.getFontMetrics().stringWidth(text) + TEXT_MARGIN_FOR_UNIT_OF_INFORMATION_DESC); } - width = Math.min(width, alias.getWidth()); + width = Math.min(width, species.getWidth()); double height = UNIT_OF_INFORMATION_HEIGHT; Rectangle2D rectangle = new Rectangle2D.Double(p.getX() - width / 2, p.getY() - height / 2, width, height); @@ -580,24 +580,24 @@ public abstract class SpeciesConverter<T extends Species> extends ElementConvert } @Override - public void draw(T alias, Graphics2D graphics, ConverterParams params, List<ColorSchema> visualizedLayoutsColorSchemas) throws DrawingException { - draw(alias, graphics, params); + public void draw(T species, Graphics2D graphics, ConverterParams params, List<ColorSchema> visualizedLayoutsColorSchemas) throws DrawingException { + draw(species, graphics, params); Color oldColor = graphics.getColor(); int count = 0; - double width = alias.getWidth() / visualizedLayoutsColorSchemas.size(); + double width = species.getWidth() / visualizedLayoutsColorSchemas.size(); for (ColorSchema schema : visualizedLayoutsColorSchemas) { if (schema != null) { double startX = (double) count / (double) visualizedLayoutsColorSchemas.size(); graphics.setColor(Color.BLACK); - int x = (int) (startX * alias.getWidth() + alias.getX()); - graphics.drawRect(x, alias.getY().intValue(), (int) width, alias.getHeight().intValue()); + int x = (int) (startX * species.getWidth() + species.getX()); + graphics.drawRect(x, species.getY().intValue(), (int) width, species.getHeight().intValue()); Color color = colorExtractor.getNormalizedColor(schema); Color bgAlphaColor = new Color(color.getRed(), color.getGreen(), color.getBlue(), LAYOUT_ALPHA); graphics.setColor(bgAlphaColor); - graphics.fillRect(x, alias.getY().intValue(), (int) width, alias.getHeight().intValue()); + graphics.fillRect(x, species.getY().intValue(), (int) width, species.getHeight().intValue()); } count++; } diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/UnknownConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/UnknownConverter.java index e304953c08b75d94805cb84ae052e4c912611228..8103b5141e06e83004616ac0ccd9e8941fdd2e97 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/UnknownConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/UnknownConverter.java @@ -19,9 +19,8 @@ import lcsb.mapviewer.model.map.species.Species; import lcsb.mapviewer.model.map.species.Unknown; /** - * This class defines methods used for drawing SpeciesAlias of - * {@link lcsb.mapviewer.converter.model.celldesigner.structure.db.model.map.species.Unknown - * Unknown} on the {@link Graphics2D} object. + * This class defines methods used for drawing {@link Unknown} on the + * {@link Graphics2D} object. * * @author Piotr Gawron * @@ -45,41 +44,39 @@ public class UnknownConverter extends SpeciesConverter<Unknown> { } @Override - public void draw(Unknown alias, final Graphics2D graphics, final ConverterParams params) { - if (alias.getActivity()) { + public void draw(Unknown unknown, final Graphics2D graphics, final ConverterParams params) { + if (unknown.getActivity()) { int border = ACTIVITY_BORDER_DISTANCE; - alias.increaseBorder(border); - Shape shape2 = new Ellipse2D.Double(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight()); + unknown.increaseBorder(border); + Shape shape2 = new Ellipse2D.Double(unknown.getX(), unknown.getY(), unknown.getWidth(), unknown.getHeight()); Stroke stroke = graphics.getStroke(); graphics.setStroke(LineType.DOTTED.getStroke()); graphics.draw(shape2); graphics.setStroke(stroke); - alias.increaseBorder(-border); + unknown.increaseBorder(-border); } - Shape shape = new Ellipse2D.Double(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight()); + Shape shape = new Ellipse2D.Double(unknown.getX(), unknown.getY(), unknown.getWidth(), unknown.getHeight()); Color c = graphics.getColor(); - graphics.setColor(alias.getColor()); + graphics.setColor(unknown.getColor()); graphics.fill(shape); graphics.setColor(c); - drawText(alias, graphics, params); + drawText(unknown, graphics, params); } @Override - public PathIterator getBoundPathIterator(Unknown alias) { + public PathIterator getBoundPathIterator(Unknown unknown) { throw new InvalidStateException("This class doesn't provide boundPath"); } @Override - public Point2D getPointCoordinatesOnBorder(Unknown alias, final double angle) { - if (alias.getWidth() == 0 && alias.getHeight() == 0) { + public Point2D getPointCoordinatesOnBorder(Unknown unknown, final double angle) { + if (unknown.getWidth() == 0 && unknown.getHeight() == 0) { logger.warn("Looking for coordinates for unknown of 0 size"); - return alias.getCenter(); + return unknown.getCenter(); } Point2D result; - result = getEllipseTransformation().getPointOnEllipseByRadian(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight(), angle); + result = getEllipseTransformation().getPointOnEllipseByRadian(unknown.getX(), unknown.getY(), unknown.getWidth(), unknown.getHeight(), angle); return result; - } - } diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/placefinder/PlaceFinder.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/placefinder/PlaceFinder.java index 474275f24240426e29992f8e95fb33107f37f06b..48de38bd017c4be0b12050ec89d03c1a3dfae26f 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/placefinder/PlaceFinder.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/placefinder/PlaceFinder.java @@ -8,13 +8,13 @@ import java.util.Map; import java.util.Set; import java.util.TreeSet; +import org.apache.log4j.Logger; + import lcsb.mapviewer.commands.SemanticZoomLevelMatcher; import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.species.Element; -import org.apache.log4j.Logger; - /** * This class allows to find free space where description should appear for the * alias in hierarchical view. @@ -24,6 +24,11 @@ import org.apache.log4j.Logger; */ public class PlaceFinder { + /** + * Class that allows to check if element is visible (or transparent) when + * drawing. It's used to filter out invisible elements when drawing + * semantic/hierarchy view. + */ private SemanticZoomLevelMatcher zoomLevelMatcher = new SemanticZoomLevelMatcher(); /** @@ -339,24 +344,27 @@ public class PlaceFinder { } /** - * This method looks for a place to put description of the alias on the map. + * This method looks for a place to put description of the {@link Compartment} + * on the map. * - * @param alias - * alias for which we try to determine text position + * @param compartment + * {@link Compartment} for which we try to determine text position + * @param level + * level at which we will visualize element * @return bounds where text could be put */ - public Rectangle2D getRetangle(Compartment alias, int level) { - Map<Integer, List<Compartment>> lists = otherAliases.get(alias); + public Rectangle2D getRetangle(Compartment compartment, int level) { + Map<Integer, List<Compartment>> lists = otherAliases.get(compartment); if (lists == null) { lists = new HashMap<>(); - otherAliases.put(alias, lists); + otherAliases.put(compartment, lists); } List<Compartment> list = lists.get(level); if (list == null) { list = new ArrayList<Compartment>(); for (Compartment compAlias : model.getCompartments()) { if (zoomLevelMatcher.isVisible(level, compAlias.getVisibilityLevel()) && !zoomLevelMatcher.isTransparent(level, compAlias.getTransparencyLevel())) { - if (compAlias.cross(alias) && compAlias.getSize() <= alias.getSize()) { + if (compAlias.cross(compartment) && compAlias.getSize() <= compartment.getSize()) { list.add(compAlias); } } @@ -364,13 +372,13 @@ public class PlaceFinder { lists.put(level, list); } - this.mainAlias = alias; + this.mainAlias = compartment; this.aliases = list; - leftBound = alias.getX(); - rightBound = (alias.getX() + alias.getWidth()); - upBound = alias.getY(); - bottomBound = (alias.getY() + alias.getHeight()); + leftBound = compartment.getX(); + rightBound = (compartment.getX() + compartment.getWidth()); + upBound = compartment.getY(); + bottomBound = (compartment.getY() + compartment.getHeight()); createMatrix();