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

transparency is using the same color as solid filling

parent d2c7f5cb
No related branches found
No related tags found
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""
......@@ -67,7 +67,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
......
......@@ -51,7 +51,8 @@ public class PathwayCompartmentConverter extends CompartmentConverter<PathwayCom
// fill the background
boolean fill = !isTransparent(compartment, params);
if (!fill) {
backgroundColor = new Color(0, 0, 0, getAlphaLevel());
backgroundColor = new Color(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue(),
getAlphaLevel());
}
graphics.setColor(backgroundColor);
graphics.fill(shape);
......
......@@ -4,14 +4,16 @@ import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import lcsb.mapviewer.converter.graphics.bioEntity.element.compartment.PathwayCompartmentConverterTest;
import lcsb.mapviewer.converter.graphics.bioEntity.element.species.AllSpeciesConverterTests;
import lcsb.mapviewer.converter.graphics.bioEntity.reaction.AllReactionTests;
@RunWith(Suite.class)
@SuiteClasses({ //
AllSpeciesConverterTests.class, //
AllReactionTests.class, //
BioEntityConverterImplTest.class//
AllSpeciesConverterTests.class, //
AllReactionTests.class, //
BioEntityConverterImplTest.class, //
PathwayCompartmentConverterTest.class,//
})
public class AllBioEntityTests {
......
package lcsb.mapviewer.converter.graphics.bioEntity.element.compartment;
import static org.junit.Assert.assertEquals;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import lcsb.mapviewer.commands.ColorExtractor;
import lcsb.mapviewer.common.geometry.ColorParser;
import lcsb.mapviewer.converter.graphics.ConverterParams;
import lcsb.mapviewer.model.map.compartment.PathwayCompartment;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.model.ModelFullIndexed;
public class PathwayCompartmentConverterTest {
ColorExtractor colorExtractor = new ColorExtractor(Color.RED, Color.GREEN, Color.BLUE);
PathwayCompartmentConverter converter = new PathwayCompartmentConverter(colorExtractor);
@Test
public void testDrawSolid() throws Exception {
int size = 600;
try {
Model model = new ModelFullIndexed(null);
BufferedImage bi = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics = Mockito.spy(bi.createGraphics());
PathwayCompartment pathway = new PathwayCompartment("id");
pathway.setX(10);
pathway.setY(10);
pathway.setWidth(100);
pathway.setHeight(200);
pathway.setColor(Color.BLUE);
pathway.setTransparencyLevel("12");
model.addElement(pathway);
converter.draw(pathway, graphics, new ConverterParams().nested(true));
Mockito.verify(graphics).setColor(Color.BLUE);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testDrawTransparent() throws Exception {
int size = 600;
try {
Model model = new ModelFullIndexed(null);
BufferedImage bi = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics = Mockito.spy(bi.createGraphics());
PathwayCompartment pathway = new PathwayCompartment("id");
pathway.setX(10);
pathway.setY(10);
pathway.setWidth(100);
pathway.setHeight(200);
pathway.setColor(Color.BLUE);
model.addElement(pathway);
converter.draw(pathway, graphics, new ConverterParams().nested(true));
ArgumentCaptor<Color> argument = ArgumentCaptor.forClass(Color.class);
Mockito.verify(graphics, Mockito.atLeastOnce()).setColor(argument.capture());
//alpha will be different
String blueHtml = new ColorParser().colorToHtml(Color.BLUE);
String usedColorHtml = new ColorParser().colorToHtml(argument.getAllValues().get(0));
assertEquals(blueHtml, usedColorHtml);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
}
mock-maker-inline
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