assertEquals("height should be same", height, expectedHeight);
// Test filter
double compareZoomFactor = 2.75;
ManualMapFilter filter = new ManualMapFilter(battleId);
filter.showPolygon(new Polygon(new int[] { 5, 25, 25, 5 },
new int[] { 5, 5, 25, 25 }, 4));
filter.hidePolygon(new Polygon(new int[] { 5, 25, 25, 5 },
new int[] { 5, 5, 25, 25 }, 4));
CampaignClient.getInstance().addBean(filter);
UniqueID filterId = filter.getId();
mapFiltered.setFilter(filterId);
filter = CampaignClient.getInstance()
.getBean(filterId, waitingTime);
BufferedImage filteredImage = new BufferedImage(
(int) (mapFiltered.getWidth() * compareZoomFactor),
(int) (mapFiltered.getHeight() * compareZoomFactor),
BufferedImage.TYPE_INT_ARGB);
BufferedImage targetFilteredImage = new BufferedImage(
(int) (mapFiltered.getWidth() * 2.75),
(int) (mapFiltered.getHeight() * 2.75),
BufferedImage.TYPE_INT_ARGB);
ManualMapFilter targetFilter = new ManualMapFilter(battleId);
Graphics2D g = (Graphics2D) filteredImage.getGraphics();
mapFiltered.drawBackground(g);
mapFiltered.drawFilter(g, true);
g.dispose();
g = (Graphics2D) targetFilteredImage.getGraphics();
AffineTransform transform = new AffineTransform();
transform.scale(2.75, 2.75);
g.drawImage(targetImages, transform, null);
targetFilter.draw(g, 2.75, true);
g.dispose();
assertTrue("Images filter should be same",
compareImage(filteredImage, targetFilteredImage));
// Change filter
Polygon showPolygon = new Polygon(new int[] { 15, 50, 50, 15 },
new int[] { 15, 15, 50, 50 }, 4);
filter.showPolygon(showPolygon);
targetFilter.showPolygon(showPolygon);
sleep();
BufferedImage filteredShowImage = new BufferedImage(
(int) (mapFiltered.getWidth() * 0.75),
(int) (mapFiltered.getHeight() * 0.75),
BufferedImage.TYPE_INT_ARGB);
BufferedImage targetFilteredShowImage = new BufferedImage(
(int) (mapFiltered.getWidth() * 0.75),
(int) (mapFiltered.getHeight() * 0.75),
BufferedImage.TYPE_INT_ARGB);
g = (Graphics2D) filteredShowImage.getGraphics();
mapFiltered.drawBackground(g);
mapFiltered.drawFilter(g, true);
g.dispose();
g = (Graphics2D) targetFilteredShowImage.getGraphics();
transform = new AffineTransform();
transform.scale(0.75, 0.75);
g.drawImage(targetImages, transform, null);
targetFilter.draw(g, 0.75, true);
g.dispose();
assertTrue("Images filter should be same",
compareImage(filteredShowImage, targetFilteredShowImage));
// Compare with previous filter, should have changed
filteredShowImage = new BufferedImage(
(int) (mapFiltered.getWidth() * compareZoomFactor),
(int) (mapFiltered.getHeight() * compareZoomFactor),
BufferedImage.TYPE_INT_ARGB);
g = (Graphics2D) filteredShowImage.getGraphics();
mapFiltered.drawBackground(g);
mapFiltered.drawFilter(g, true);
g.dispose();
assertTrue("Images filter should not be same",
!compareImage(filteredShowImage, filteredImage));
// Change filter
Polygon hidePolygon = new Polygon(new int[] { 15, 20, 20, 15 },
new int[] { 15, 15, 20, 20 }, 4);
filter.hidePolygon(hidePolygon);
targetFilter.hidePolygon(hidePolygon);
sleep();
BufferedImage filteredShowHideImage = new BufferedImage(
mapFiltered.getWidth() * 1, mapFiltered.getHeight() * 1,
BufferedImage.TYPE_INT_ARGB);
BufferedImage targetFilteredShowHideImage = new BufferedImage(
mapFiltered.getWidth() * 1, mapFiltered.getHeight() * 1,
BufferedImage.TYPE_INT_ARGB);
g = (Graphics2D) filteredShowHideImage.getGraphics();
mapFiltered.drawBackground(g);
mapFiltered.drawFilter(g, true);
g.dispose();
g = (Graphics2D) targetFilteredShowHideImage.getGraphics();
transform = new AffineTransform();
transform.scale(1, 1);
g.drawImage(targetImages, transform, null);
targetFilter.draw(g, 1, true);
g.dispose();
assertTrue(
"Images filter should be same",
compareImage(filteredShowHideImage,