Commit 4c70aff2 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

raise warnings when necessary

parent c358fb5c
Pipeline #29002 passed with stage
in 16 minutes and 23 seconds
......@@ -17,6 +17,8 @@ minerva (15.1.0) unstable; urgency=medium
exported to SBGN PD (#1302)
* Small improvement: Unknown Transition Reaction is exported to GPML as
CONVERSION (#1300)
* Small improvement: when uploading complex map with images warnings are
raised if images are not referenced in coords.txt file (#1308)
* Bug fix: export to image from selected polygon contained all elements
inside rectangle bounded by the polygon coordinates (#1096)
* Bug fix: continuous refreshing list of project when uploading/removing
......
package lcsb.mapviewer.converter;
import java.awt.*;
import java.awt.Polygon;
import java.awt.geom.Area;
import java.awt.geom.Point2D;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.*;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
......@@ -350,6 +349,30 @@ public class OverviewParser {
}
}
if (images.size() > 1) {
Set<OverviewImage> usedImages = new HashSet<>();
Set<OverviewImage> childImages = new HashSet<>();
for (OverviewImage image : images) {
if (image.getLinks().size() > 0) {
usedImages.add(image);
}
for (OverviewLink link : image.getLinks()) {
if (link instanceof OverviewImageLink) {
usedImages.add(((OverviewImageLink) link).getLinkedOverviewImage());
childImages.add(((OverviewImageLink) link).getLinkedOverviewImage());
}
}
}
for (OverviewImage image : images) {
if (!usedImages.contains(image)) {
logger.warn("Image is not referenced in coordinates file: " + image.getFilename());
}
}
if (images.size() > childImages.size() + 1) {
logger.warn("In coords.txt, more than one image can be the starting one for 'Show overview',"
+ " picking at random.");
}
}
}
/**
......
......@@ -230,4 +230,33 @@ public class OverviewParserTest extends ConverterTestFunctions {
assertEquals(1, oi2.getLinks().size());
}
@Test
public void testParseValidComplexCoordinatesWithExtraImages() throws Exception {
String invalidCoordinates = FileUtils.readFileToString(new File("testFiles/coordinates.txt"), "UTF-8");
Set<Model> models = createValidTestMapModel();
List<OverviewImage> images = new ArrayList<>();
OverviewImage oi = new OverviewImage();
oi.setFilename("test.png");
oi.setWidth(1000);
oi.setHeight(1000);
images.add(oi);
OverviewImage oi2 = new OverviewImage();
oi2.setFilename("test2.png");
oi2.setWidth(1000);
oi2.setHeight(1000);
images.add(oi2);
OverviewImage oi3 = new OverviewImage();
oi3.setFilename("test2.png");
oi3.setWidth(1000);
oi3.setHeight(1000);
images.add(oi3);
parser.processCoordinates(models, images, invalidCoordinates);
assertEquals(2, super.getWarnings().size());
}
}
......@@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.*;
import org.mockito.Mockito;
import lcsb.mapviewer.ModelTestFunctions;
import lcsb.mapviewer.common.exception.NotImplementedException;
......@@ -33,21 +34,12 @@ public class OverviewLinkComparatorTest extends ModelTestFunctions {
@Test(expected = NotImplementedException.class)
public void testInvalid() throws Exception {
class Tmp extends OverviewLink {
private static final long serialVersionUID = 1L;
@Override
public OverviewLink copy() {
return null;
}
}
;
OverviewLinkComparator omlc = new OverviewLinkComparator();
OverviewLink oml = new Tmp();
OverviewLink oml2 = new Tmp();
OverviewLink oml = Mockito.mock(OverviewLink.class);
omlc.compare(oml, oml2);
omlc.compare(oml, oml);
}
@Test
......
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