Package net.alteiar.beans.map.size

Examples of net.alteiar.beans.map.size.MapElementSize


  public MapElementSize getRadius() {
    return this.radius;
  }

  public void setRadius(MapElementSize radius) {
    MapElementSize oldValue = this.radius;
    if (notifyRemote(PROP_RADIUS_PROPERTY, oldValue, radius)) {
      this.radius = radius;
      notifyLocal(PROP_RADIUS_PROPERTY, oldValue, radius);
    }
  }
View Full Code Here


  public MapElementSize getWidth() {
    return width;
  }

  public void setWidth(MapElementSize width) {
    MapElementSize oldValue = this.width;
    if (notifyRemote(PROP_WIDTH_PROPERTY, oldValue, width)) {
      this.width = width;
      notifyLocal(PROP_WIDTH_PROPERTY, oldValue, width);
    }
  }
View Full Code Here

  public MapElementSize getHeight() {
    return height;
  }

  public void setHeight(MapElementSize height) {
    MapElementSize oldValue = this.height;
    if (notifyRemote(PROP_HEIGHT_PROPERTY, oldValue, height)) {
      this.height = height;
      notifyLocal(PROP_HEIGHT_PROPERTY, oldValue, height);
    }
  }
View Full Code Here

    this.add(comboBoxUnite);
  }

  private MapElementSize getMapElementSize(String value)
      throws NumberFormatException {
    MapElementSize element = null;

    Double size = Double.valueOf(value);

    switch (UnityType.values()[comboBoxUnite.getSelectedIndex()]) {
    case PIXEL:
View Full Code Here

    };
    battle.addPropertyChangeListener(listener);

    Point position = new Point(5, 5);
    Color color = Color.GREEN;
    MapElementSize width = new MapElementSizeMeter(6.0);
    MapElementSize height = new MapElementSizePixel(42.0);

    RectangleElement rectangle = new RectangleElement(position, color,
        width, height);

    Collection<UniqueID> elementsOnMap = battle.getElements();
View Full Code Here

  @Test(timeout = 5000)
  public void testMapElement() {
    Long waitingTime = 1000L;

    MapElementSize width = new MapElementSizePixel(20.0);
    MapElementSize height = new MapElementSizePixel(20.0);
    Point position = new Point(0, 0);

    RectangleElement targetRectangle = new RectangleElement(position,
        Color.RED, width, height);
View Full Code Here

  @Test(timeout = 5000)
  public void testMapElementMove() {
    Long waitingTime = 1000L;

    MapElementSize width = new MapElementSizePixel(20.0);
    MapElementSize height = new MapElementSizePixel(20.0);
    Point position = new Point(0, 0);

    RectangleElement targetRectangle = new RectangleElement(position,
        Color.RED, width, height);
View Full Code Here

  @Test(timeout = 5000)
  public void testRectangleSelection() {
    MapBean battle = getBattle();

    MapElementSize width = new MapElementSizePixel(20.0);
    MapElementSize height = new MapElementSizePixel(20.0);
    Point position = new Point(5, 5);

    RectangleElement targetRectangle = new RectangleElement(position,
        Color.RED, width, height);
    MapElementFactory.buildMapElement(targetRectangle, battle);
View Full Code Here

  @Test(timeout = 5000)
  public void testRectangle() {
    MapBean battle = getBattle();

    MapElementSize width = new MapElementSizePixel(20.0);
    MapElementSize height = new MapElementSizePixel(20.0);
    Point position = new Point(5, 5);

    RectangleElement targetRectangle = new RectangleElement(position,
        Color.RED, width, height);
    MapElementFactory.buildMapElement(targetRectangle, battle);

    RectangleElement rectangle = CampaignClient.getInstance().getBean(
        targetRectangle.getId(), 300L);

    assertEquals("The position should be equals", position,
        rectangle.getPosition());
    assertEquals("The color should be equals", Color.RED,
        rectangle.getColor());
    assertEquals("The angle should be equals", Double.valueOf(0),
        rectangle.getAngle());
    assertEquals("The width should be equals", width.getPixels(battle
        .getScale()), rectangle.getWidth().getPixels(battle.getScale()));
    assertEquals("The height should be equals", height.getPixels(battle
        .getScale()), rectangle.getHeight()
        .getPixels(battle.getScale()));

    MapElementSize newWidth = new MapElementSizeSquare(2.0);
    MapElementSize newHeight = new MapElementSizeSquare(3.0);
    rectangle.setWidth(newWidth);
    rectangle.setHeight(newHeight);
    sleep();
    assertEquals("The width should be equals", newWidth.getPixels(battle
        .getScale()), rectangle.getWidth().getPixels(battle.getScale()));
    assertEquals("The height should be equals", newHeight.getPixels(battle
        .getScale()), rectangle.getHeight()
        .getPixels(battle.getScale()));

    BufferedImage realImg = new BufferedImage(200, 200,
        BufferedImage.TYPE_INT_ARGB);
View Full Code Here

  public void testCircle() {
    Long waitingTime = 1000L;
    MapBean battle = CampaignClient.getInstance().getBean(battleId,
        waitingTime);

    MapElementSize circleRadius = new MapElementSizePixel(20.0);
    Point position = new Point(5, 5);

    CircleElement circleClient = new CircleElement(position, Color.RED,
        circleRadius);
    MapElementFactory.buildMapElement(circleClient, battle);

    circleClient = CampaignClient.getInstance().getBean(
        circleClient.getId(), 300L);

    assertEquals("The position should be equals", position,
        circleClient.getPosition());
    assertEquals("The color should be equals", Color.RED,
        circleClient.getColor());
    assertEquals("The angle should be equals", Double.valueOf(0),
        circleClient.getAngle());
    assertEquals("The radius should be equals",
        circleRadius.getPixels(battle.getScale()), circleClient
            .getRadius().getPixels(battle.getScale()));

    assertEquals("The width and the height should be equals",
        circleClient.getWidthPixels(), circleClient.getHeightPixels());

    BufferedImage imgGenerated = new BufferedImage(1000, 1000,
        BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = (Graphics2D) imgGenerated.getGraphics();
    circleClient.draw(g2, 1.0, true);
    g2.dispose();

    BufferedImage imgExpected = new BufferedImage(1000, 1000,
        BufferedImage.TYPE_INT_ARGB);
    g2 = (Graphics2D) imgExpected.getGraphics();
    circleClient.draw(g2, 1.0, true);
    g2.dispose();

    try {
      assertTrue("images should be same",
          compareImage(imgExpected, imgGenerated));
    } catch (IOException e) {
      fail("fail to compare images");
    }

    Double angle = 25.0;
    Boolean isHidden = !circleClient.isHiddenForPlayer();
    Point newPosition = new Point(12, 12);
    circleClient.setHiddenForPlayer(isHidden);
    circleClient.setPosition(newPosition);
    circleClient.setAngle(angle);

    waitForChange(circleClient, "getPosition", newPosition);
    waitForChange(circleClient, "getAngle", angle);
    waitForChange(circleClient, "isHiddenForPlayer", isHidden);
    waitForChange(circleClient, "getPosition", newPosition);
    waitForChange(circleClient, "getPosition", newPosition);

    assertEquals("The position should be equals", newPosition,
        circleClient.getPosition());
    assertEquals("The color should be equals", angle,
        circleClient.getAngle());
    assertEquals("The angle should be equals", isHidden,
        circleClient.isHiddenForPlayer());

    assertTrue("the circle not contain point (5,5)",
        !circleClient.contain(new Point(5, 5)));

    assertTrue("the circle contain point (32,32)",
        circleClient.contain(new Point(32, 32)));

    MapElementSize newCircleRadius = new MapElementSizeMeter(1.5);
    circleClient.setRadius(newCircleRadius);
    sleep();
    assertEquals("radius should be equals",
        newCircleRadius.getPixels(battle.getScale()), circleClient
            .getRadius().getPixels(battle.getScale()));

    Color color = Color.BLUE;
    circleClient.setColor(color);
    sleep();
View Full Code Here

TOP

Related Classes of net.alteiar.beans.map.size.MapElementSize

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.