diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/AbstractImageGenerator.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/AbstractImageGenerator.java index 76024d26d3935a09e16739c63e6ed946d8d659a9..036d3b221f8cdf631b18cf7b2a5c5c09f1f50541 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/AbstractImageGenerator.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/AbstractImageGenerator.java @@ -68,6 +68,12 @@ import lcsb.mapviewer.modelutils.map.ElementUtils; * */ public abstract class AbstractImageGenerator { + + /** + * 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(); /** @@ -596,6 +602,9 @@ public abstract class AbstractImageGenerator { */ private boolean sbgnFormat = false; + /** + * List of params used for drawing. + */ private Params params; /** @@ -625,8 +634,17 @@ public abstract class AbstractImageGenerator { this.params = params; } + /** + * Flag indicating {@link #draw()} method was executed. + */ private boolean drawn = false; + /** + * Draw a model into {@link #getGraphics()} object. + * + * @throws DrawingException + * thrown when there is a problem with drawing + */ protected void draw() throws DrawingException { if (isDrawn()) { logger.warn("Model was already drawn. Skipping"); @@ -704,6 +722,9 @@ public abstract class AbstractImageGenerator { setDrawn(true); } + /** + * Method called after drawing. It should close drawing canvas properly. + */ protected abstract void closeImageObject(); /** @@ -902,6 +923,7 @@ public abstract class AbstractImageGenerator { * @throws IOException * thrown when there is problem with output file * @throws DrawingException + * thrown when there was a problem with drawing map */ public final void saveToFile(String fileName) throws IOException, DrawingException { if (!isDrawn()) { @@ -910,6 +932,16 @@ public abstract class AbstractImageGenerator { saveToFileImplementation(fileName); }; + /** + * Saves generated image from {@link #getGraphics()} into file. + * + * @param fileName + * file where the images should be saved + * @throws IOException + * thrown when there is problem with output file + * @throws DrawingException + * thrown when there was a problem with drawing map + */ protected abstract void saveToFileImplementation(String fileName) throws IOException; /** @@ -920,6 +952,7 @@ public abstract class AbstractImageGenerator { * @throws IOException * thrown when there is problem with output stream * @throws DrawingException + * thrown when there was a problem with drawing map */ public final void saveToOutputStream(OutputStream os) throws IOException, DrawingException { if (!isDrawn()) { @@ -928,6 +961,17 @@ public abstract class AbstractImageGenerator { saveToOutputStream(os); } + /** + * Saves generated image from {@link #getGraphics()} into {@link OutputStream} + * . + * + * @param os + * stream where the images should be saved + * @throws IOException + * thrown when there is problem with output stream + * @throws DrawingException + * thrown when there was a problem with drawing map + */ protected abstract void saveToOutputStreamImplementation(OutputStream os) throws IOException; /** @@ -946,6 +990,7 @@ public abstract class AbstractImageGenerator { * @throws IOException * thrown when there is problem with output file * @throws DrawingException + * thrown when there was a problem with drawing map */ public final void savePartToFile(final int x, final int y, final int width, final int height, final String fileName) throws IOException, DrawingException { if (!isDrawn()) { @@ -954,6 +999,22 @@ public abstract class AbstractImageGenerator { savePartToFileImplementation(x, y, width, height, fileName); } + /** + * Saves part of the generated image from {@link #getGraphics()} into file. + * + * @param fileName + * file where the images should be saved + * @param x + * x left margin of the image part + * @param y + * y top margin of the image part + * @param width + * width of the image part + * @param height + * hieght of the image part + * @throws IOException + * thrown when there is problem with output file + */ protected abstract void savePartToFileImplementation(final int x, final int y, final int width, final int height, final String fileName) throws IOException; /** @@ -972,6 +1033,7 @@ public abstract class AbstractImageGenerator { * @throws IOException * thrown when there is problem with output file * @throws DrawingException + * thrown when there was a problem with drawing map */ public final void savePartToOutputStream(final int x, final int y, final int width, final int height, final OutputStream os) throws IOException, DrawingException { @@ -981,7 +1043,26 @@ public abstract class AbstractImageGenerator { savePartToOutputStreamImplementation(x, y, width, height, os); } - public abstract void savePartToOutputStreamImplementation(final int x, final int y, final int width, final int height, final OutputStream os) + /** + * Saves part of the generated image from {@link #getGraphics()} into + * {@link OutputStream}. + * + * @param os + * stream where the images should be saved + * @param x + * x left margin of the image part + * @param y + * y top margin of the image part + * @param width + * width of the image part + * @param height + * hieght of the image part + * @throws IOException + * thrown when there is problem with output file + * @throws DrawingException + * thrown when there was a problem with drawing map + */ + protected abstract void savePartToOutputStreamImplementation(final int x, final int y, final int width, final int height, final OutputStream os) throws IOException; /** diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/ConverterParams.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/ConverterParams.java index 18c165403acb5c3cca33d02833de307aa617d4e0..d46ccdf50836f784cd2dcb166e6a9cd9f6622ca8 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/ConverterParams.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/ConverterParams.java @@ -12,19 +12,22 @@ public class ConverterParams { * At which level the object is visualized. It helps to deterimine font size. * However it's possible that this value is not required. */ - private int level = 0; + private int level = 0; /** * What is the scale. It allows to adjust font size to be readable. */ - private double scale = 1; + private double scale = 1; /** * Should the map be displayed in SBGN format. */ - private boolean sbgnFormat = false; + private boolean sbgnFormat = false; - private boolean nested = false; + /** + * Does the visualization include nesting/hierarchy. + */ + private boolean nested = false; /** * @param scale