Commit 1a7fc855 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

pathway color is used for font

parent a99b3291
......@@ -24,62 +24,65 @@ import lcsb.mapviewer.model.map.species.Species;
*/
public class PathwayCompartmentConverter extends CompartmentConverter<PathwayCompartment> {
/**
* Default constructor.
*
* @param colorExtractor
* Object that helps to convert {@link ColorSchema} values into
* colors when drawing {@link Species}
*/
public PathwayCompartmentConverter(ColorExtractor colorExtractor) {
super(colorExtractor);
}
/**
* Default constructor.
*
* @param colorExtractor
* Object that helps to convert {@link ColorSchema} values into colors
* when drawing {@link Species}
*/
public PathwayCompartmentConverter(ColorExtractor colorExtractor) {
super(colorExtractor);
}
/**
* Background color of drawn compartments.
*/
private Color backgroundColor = Color.LIGHT_GRAY;
/**
* Background color of drawn compartments.
*/
private Color backgroundColor = Color.LIGHT_GRAY;
@Override
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();
@Override
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();
Shape shape = new Rectangle2D.Double(compartment.getX(), compartment.getY(), compartment.getWidth(), compartment.getHeight());
Shape shape = new Rectangle2D.Double(compartment.getX(), compartment.getY(), compartment.getWidth(),
compartment.getHeight());
Color color = compartment.getColor();
Color color = compartment.getColor();
// fill the background
boolean fill = !isTransparent(compartment, params);
if (fill) {
graphics.setColor(backgroundColor);
} else {
Color bgAlphaColor = new Color(0, 0, 0, getAlphaLevel());
graphics.setColor(bgAlphaColor);
}
graphics.fill(shape);
// fill the background
boolean fill = !isTransparent(compartment, params);
if (fill) {
graphics.setColor(backgroundColor);
} else {
Color bgAlphaColor = new Color(0, 0, 0, getAlphaLevel());
graphics.setColor(bgAlphaColor);
}
graphics.fill(shape);
// draw the border
graphics.setColor(color);
graphics.setStroke(LineType.SOLID_BOLD.getStroke());
graphics.draw(shape);
// draw the border
graphics.setColor(color);
graphics.setStroke(LineType.SOLID_BOLD.getStroke());
graphics.draw(shape);
// restore old color and line type
graphics.setColor(oldColor);
graphics.setStroke(oldStroke);
// draw description of the compartment
if (fill) {
Point2D tmpPoint = compartment.getNamePoint();
compartment.setNamePoint(compartment.getCenter());
drawText(compartment, graphics, params);
compartment.setNamePoint(tmpPoint);
} else {
if (!compartment.containsIdenticalSpecies()) {
drawText(compartment, graphics, params);
}
}
// draw description of the compartment
if (fill) {
Point2D tmpPoint = compartment.getNamePoint();
compartment.setNamePoint(compartment.getCenter());
drawText(compartment, graphics, params);
compartment.setNamePoint(tmpPoint);
} else {
if (!compartment.containsIdenticalSpecies()) {
drawText(compartment, graphics, params);
}
}
}
// restore old color and line type
graphics.setColor(oldColor);
graphics.setStroke(oldStroke);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment