Commit fa31a7e3 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

font color is used when drawing species text

parent b18f699d
......@@ -424,7 +424,8 @@ public abstract class SpeciesConverter<T extends Species> extends ElementConvert
String text = getText(species);
Font oldFont = graphics.getFont();
Font font = getFont(species, params);
graphics.setColor(Color.BLACK);
Color oldColor = graphics.getColor();
graphics.setColor(species.getFontColor());
graphics.setFont(font);
Point2D point = species.getCenter();
......@@ -437,6 +438,7 @@ public abstract class SpeciesConverter<T extends Species> extends ElementConvert
}
drawText(point, text, graphics, true, true);
graphics.setFont(oldFont);
graphics.setColor(oldColor);
}
/**
......
......@@ -3,8 +3,7 @@ package lcsb.mapviewer.converter.graphics.bioEntity.element.species;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.*;
import java.awt.*;
import java.awt.geom.Point2D;
......@@ -18,6 +17,7 @@ import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.*;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import lcsb.mapviewer.commands.ColorExtractor;
......@@ -158,6 +158,27 @@ public class SpeciesConverterTest extends GraphicsTestFunctions {
verify(converter, times(1)).drawResidue(any(), any(), anyBoolean());
}
@Test
public void testDrawText() throws Exception {
BufferedImage bi = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics = Mockito.spy(bi.createGraphics());
graphics.setColor(Color.YELLOW);
GenericProtein protein = new GenericProtein("i");
protein.setFontColor(Color.PINK);
ProteinConverter converter = Mockito.spy(new ProteinConverter(colorExtractor));
converter.drawText(protein, graphics, new ConverterParams());
assertEquals(Color.YELLOW, graphics.getColor());
ArgumentCaptor<Color> argument = ArgumentCaptor.forClass(Color.class);
Mockito.verify(graphics, atLeastOnce()).setColor(argument.capture());
List<Color> values = removeAlpha(argument.getAllValues());
assertTrue("Font colour wasn't used", values.contains(Color.PINK));
}
@Test
public void testDrawBindingRegion() throws Exception {
BufferedImage bi = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB);
......
Supports Markdown
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