Package net.alteiar.beans.map.filter

Examples of net.alteiar.beans.map.filter.ManualMapFilter


      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,
View Full Code Here


    UniqueID filterId = getMapInfo().getMap().getFilter();
    return CampaignClient.getInstance().getBean(filterId);
  }

  private void showPolygon(List<Point> cwPts) {
    ManualMapFilter filter = getMapFilter();
    int[] x = new int[cwPts.size()];
    int[] y = new int[cwPts.size()];

    for (int i = 0; i < cwPts.size(); i++) {
      x[i] = cwPts.get(i).x;
      y[i] = cwPts.get(i).y;
    }

    filter.showPolygon(new Polygon(x, y, cwPts.size()));
  }
View Full Code Here

    filter.showPolygon(new Polygon(x, y, cwPts.size()));
  }

  private void hidePolygon(List<Point> cwPts) {
    ManualMapFilter filter = getMapFilter();
    int[] x = new int[cwPts.size()];
    int[] y = new int[cwPts.size()];

    for (int i = 0; i < cwPts.size(); i++) {
      x[i] = cwPts.get(i).x;
      y[i] = cwPts.get(i).y;
    }

    filter.hidePolygon(new Polygon(x, y, cwPts.size()));
  }
View Full Code Here

          MapFilter newFilter = null;

          FilterAdapter adapter = panel.getSelectedValue();

          if (MANUAL_MAP_FILTER.equals(adapter.getName())) {
            newFilter = new ManualMapFilter(map.getId());
          } else if (AUTOMATIC_MAP_FILTER.equals(adapter.getName())) {
            newFilter = new CharacterMapFilter(map);
          } else if (NO_MAP_FILTER.equals(adapter.getName())) {
            newFilter = new NoMapFilter();
          }
View Full Code Here

TOP

Related Classes of net.alteiar.beans.map.filter.ManualMapFilter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.