Skip to content
Snippets Groups Projects
Commit 631e56f6 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

drawText throws DrawingException when necessary

parent 62206d27
No related branches found
No related tags found
1 merge request!44Resolve "semantic zoom"
Showing
with 17 additions and 11 deletions
......@@ -13,6 +13,7 @@ import org.apache.log4j.Logger;
import lcsb.mapviewer.commands.ColorExtractor;
import lcsb.mapviewer.converter.graphics.ConverterParams;
import lcsb.mapviewer.converter.graphics.DrawingException;
import lcsb.mapviewer.model.graphics.LineType;
import lcsb.mapviewer.model.map.compartment.BottomSquareCompartment;
import lcsb.mapviewer.model.map.layout.ColorSchema;
......@@ -44,7 +45,7 @@ public class BottomSquareCompartmentConverter extends CompartmentConverter<Botto
}
@Override
public void draw(final BottomSquareCompartment compartment, final Graphics2D graphics, final ConverterParams params) {
public void draw(final BottomSquareCompartment compartment, final Graphics2D graphics, final ConverterParams params) throws DrawingException {
// keep the old values of colors and line
Color oldColor = graphics.getColor();
Stroke oldStroke = graphics.getStroke();
......
......@@ -10,7 +10,6 @@ import org.apache.log4j.Logger;
import lcsb.mapviewer.commands.ColorExtractor;
import lcsb.mapviewer.common.Configuration;
import lcsb.mapviewer.common.exception.InvalidArgumentException;
import lcsb.mapviewer.common.geometry.EllipseTransformation;
import lcsb.mapviewer.common.geometry.LineTransformation;
import lcsb.mapviewer.converter.graphics.ConverterParams;
......@@ -21,6 +20,7 @@ import lcsb.mapviewer.converter.graphics.geometry.RectangleTooSmallException;
import lcsb.mapviewer.converter.graphics.placefinder.PlaceFinder;
import lcsb.mapviewer.model.map.compartment.Compartment;
import lcsb.mapviewer.model.map.layout.ColorSchema;
import lcsb.mapviewer.modelutils.map.ElementUtils;
/**
* Abstract class responsible for common methods to draw compartmentAliases on
......@@ -98,10 +98,9 @@ public abstract class CompartmentConverter<T extends Compartment> extends Elemen
};
@Override
public void drawText(final T compartment, final Graphics2D graphics, final ConverterParams params) {
public void drawText(final T compartment, final Graphics2D graphics, final ConverterParams params) throws DrawingException {
if (compartment.getWidth() < Configuration.EPSILON || compartment.getHeight() < Configuration.EPSILON) {
throw new InvalidArgumentException(
"Dimension of the alias must be bigger than 0. Alias id: " + compartment.getElementId() + " (name: \"" + compartment.getName() + "\")");
throw new DrawingException(new ElementUtils().getElementTag(compartment) + "Dimension of the alias must be bigger than 0.");
}
Rectangle2D border = compartment.getBorder();
if (isVisible(compartment, params) && !isTransparent(compartment, params)) {
......
......@@ -11,6 +11,7 @@ import java.awt.geom.Rectangle2D;
import lcsb.mapviewer.commands.ColorExtractor;
import lcsb.mapviewer.converter.graphics.ConverterParams;
import lcsb.mapviewer.converter.graphics.DrawingException;
import lcsb.mapviewer.model.graphics.LineType;
import lcsb.mapviewer.model.map.compartment.LeftSquareCompartment;
import lcsb.mapviewer.model.map.layout.ColorSchema;
......@@ -44,7 +45,7 @@ public class LeftSquareCompartmentConverter extends CompartmentConverter<LeftSqu
}
@Override
public void draw(final LeftSquareCompartment compartment, final Graphics2D graphics, final ConverterParams params) {
public void draw(final LeftSquareCompartment compartment, final Graphics2D graphics, final ConverterParams params) throws DrawingException {
// keep the old values of color and line type
Color oldColor = graphics.getColor();
Stroke oldStroke = graphics.getStroke();
......
......@@ -10,6 +10,7 @@ import java.awt.geom.Point2D;
import lcsb.mapviewer.commands.ColorExtractor;
import lcsb.mapviewer.converter.graphics.ConverterParams;
import lcsb.mapviewer.converter.graphics.DrawingException;
import lcsb.mapviewer.model.graphics.LineType;
import lcsb.mapviewer.model.map.compartment.Compartment;
import lcsb.mapviewer.model.map.compartment.OvalCompartment;
......@@ -47,7 +48,7 @@ public class OvalCompartmentConverter extends CompartmentConverter<OvalCompartme
}
@Override
public void draw(final OvalCompartment compartment, final Graphics2D graphics, final ConverterParams params) {
public void draw(final OvalCompartment compartment, final Graphics2D graphics, final ConverterParams params) throws DrawingException {
// keep the old values of color and line type
Color oldColor = graphics.getColor();
Stroke oldStroke = graphics.getStroke();
......
......@@ -9,6 +9,7 @@ import java.awt.geom.Rectangle2D;
import lcsb.mapviewer.commands.ColorExtractor;
import lcsb.mapviewer.converter.graphics.ConverterParams;
import lcsb.mapviewer.converter.graphics.DrawingException;
import lcsb.mapviewer.model.graphics.LineType;
import lcsb.mapviewer.model.map.compartment.PathwayCompartment;
import lcsb.mapviewer.model.map.layout.ColorSchema;
......@@ -40,7 +41,7 @@ public class PathwayCompartmentConverter extends CompartmentConverter<PathwayCom
private Color backgroundColor = Color.LIGHT_GRAY;
@Override
public void draw(final PathwayCompartment compartment, final Graphics2D graphics, final ConverterParams params) {
public void draw(final PathwayCompartment compartment, final Graphics2D graphics, final ConverterParams params) throws DrawingException {
// keep the old values of colors and line
Color oldColor = graphics.getColor();
Stroke oldStroke = graphics.getStroke();
......
......@@ -11,6 +11,7 @@ import java.awt.geom.Rectangle2D;
import lcsb.mapviewer.commands.ColorExtractor;
import lcsb.mapviewer.converter.graphics.ConverterParams;
import lcsb.mapviewer.converter.graphics.DrawingException;
import lcsb.mapviewer.model.graphics.LineType;
import lcsb.mapviewer.model.map.compartment.RightSquareCompartment;
import lcsb.mapviewer.model.map.layout.ColorSchema;
......@@ -44,7 +45,7 @@ public class RightSquareCompartmentConverter extends CompartmentConverter<RightS
}
@Override
public void draw(final RightSquareCompartment compartment, final Graphics2D graphics, final ConverterParams params) {
public void draw(final RightSquareCompartment compartment, final Graphics2D graphics, final ConverterParams params) throws DrawingException {
// keep the old values of color and line type
Color oldColor = graphics.getColor();
Stroke oldStroke = graphics.getStroke();
......
......@@ -12,6 +12,7 @@ import org.apache.log4j.Logger;
import lcsb.mapviewer.commands.ColorExtractor;
import lcsb.mapviewer.converter.graphics.ConverterParams;
import lcsb.mapviewer.converter.graphics.DrawingException;
import lcsb.mapviewer.model.graphics.LineType;
import lcsb.mapviewer.model.map.compartment.Compartment;
import lcsb.mapviewer.model.map.compartment.SquareCompartment;
......@@ -60,7 +61,7 @@ public class SquareCompartmentConverter extends CompartmentConverter<SquareCompa
}
@Override
public void draw(final SquareCompartment compartment, final Graphics2D graphics, final ConverterParams params) {
public void draw(final SquareCompartment compartment, final Graphics2D graphics, final ConverterParams params) throws DrawingException {
// keep the old values of color and line type
Color oldColor = graphics.getColor();
Stroke oldStroke = graphics.getStroke();
......
......@@ -11,6 +11,7 @@ import java.awt.geom.Rectangle2D;
import lcsb.mapviewer.commands.ColorExtractor;
import lcsb.mapviewer.converter.graphics.ConverterParams;
import lcsb.mapviewer.converter.graphics.DrawingException;
import lcsb.mapviewer.model.graphics.LineType;
import lcsb.mapviewer.model.map.compartment.TopSquareCompartment;
import lcsb.mapviewer.model.map.layout.ColorSchema;
......@@ -44,7 +45,7 @@ public class TopSquareCompartmentConverter extends CompartmentConverter<TopSquar
}
@Override
public void draw(final TopSquareCompartment compartment, final Graphics2D graphics, final ConverterParams params) {
public void draw(final TopSquareCompartment compartment, final Graphics2D graphics, final ConverterParams params) throws DrawingException {
Color oldColor = graphics.getColor();
Stroke oldStroke = graphics.getStroke();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment