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

pathway color is used for font

parent a99b3291
No related branches found
Tags v17.1.3
2 merge requests!630WIP: Resolve "The privileges of a new user are not saved in some cases",!423Resolve "Allow to control the background and font of areas drawn from text areas in CellDesigner "layers""
......@@ -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);
}
}
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