Package net.alteiar.beans.map.elements

Examples of net.alteiar.beans.map.elements.RectangleElement


    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();
    assertTrue("The map shouldn't have any element",
        elementsOnMap.isEmpty());

    MapElementFactory.buildMapElement(rectangle, battle);

    // wait for the element to be in the element list
    while (elementsOnMap.isEmpty()) {
      sleep(10);
      elementsOnMap = battle.getElements();
    }

    assertEquals("The map should have 1 element", 1, elementsOnMap.size());
    assertEquals("The rectangle id should be the same", rectangle.getId(),
        elementsOnMap.iterator().next());

    assertEquals(
        "The map should have at least 1 element at the position (6,6)",
        1, battle.getElementsAt(new Point(6, 6)).size());
View Full Code Here


    return panelSize.getMapElementSize(1);
  }

  @Override
  public RectangleElement buildMapElement(Point position) {
    return new RectangleElement(position, getSelectedColor(),
        getElementSizeWidth(), getElementSizeHeight());
  }
View Full Code Here

    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);

    MapElementFactory.buildMapElement(targetRectangle, getBattle());

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

    assertEquals("center should be at (10, 10)", new Point(10, 10),
        rectangle.getCenterPosition());
    assertEquals("The battle id should be the same as the map id",
        battleId, rectangle.getMapId());

    // Change battle link
    UniqueID newBattleId = null;
    try {
      newBattleId = TestMap.createBattle("new battle",
          TestMap.getDefaultImage());
    } catch (IOException e) {
      fail("fail to create battle");
    }

    rectangle.setMapId(newBattleId);
    waitForChange(rectangle, "getMapId", newBattleId);

    CampaignClient.getInstance().removeBean(rectangle);
    sleep();
    assertEquals("the bean should have been removed", null, CampaignClient
View Full Code Here

    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);

    MapElementFactory.buildMapElement(targetRectangle, getBattle());

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

    assertEquals("position should be " + position, position,
        rectangle.getPosition());

    Point tempPos = new Point(12, 12);
    rectangle.moveTo(tempPos);
    assertEquals("position should be " + tempPos, tempPos,
        rectangle.getPosition());

    rectangle.undoMove();
    assertEquals("position should be " + position, position,
        rectangle.getPosition());

    rectangle.moveTo(tempPos);
    assertEquals("position should be " + tempPos, tempPos,
        rectangle.getPosition());

    rectangle.applyMove();
    sleep();
    assertEquals("position should be " + tempPos, tempPos,
        rectangle.getPosition());

    rectangle.undoMove();
    assertEquals("position should be " + tempPos, tempPos,
        rectangle.getPosition());
  }
View Full Code Here

    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);

    assertTrue("rectangle should be hidden for players",
        rectangle.isHiddenForPlayer());

    assertTrue("rectangle should'nt be selected", !rectangle.getSelected());

    rectangle.setHiddenForPlayer(false);
    rectangle.setSelected(true);
    waitForChange(rectangle, "isHiddenForPlayer", false);
    waitForChange(rectangle, "getSelected", true);

    BufferedImage realImg = new BufferedImage(200, 200,
        BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = realImg.createGraphics();
    rectangle.draw(g2, 1.0, true);
    g2.dispose();

    BufferedImage targetImg = new BufferedImage(200, 200,
        BufferedImage.TYPE_INT_ARGB);
    g2 = targetImg.createGraphics();
    rectangle.draw(g2, 1.0, true);
    g2.dispose();

    try {
      assertTrue("images should be same",
          compareImage(targetImg, realImg));
View Full Code Here

    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);
    Graphics2D g2 = realImg.createGraphics();
    rectangle.draw(g2, 1.0, true);
    g2.dispose();

    targetRectangle.setWidth(newWidth);
    targetRectangle.setHeight(newHeight);

    BufferedImage targetImg = new BufferedImage(200, 200,
        BufferedImage.TYPE_INT_ARGB);
    g2 = targetImg.createGraphics();
    rectangle.draw(g2, 1.0, true);
    g2.dispose();

    try {
      assertTrue("images should be same",
          compareImage(targetImg, realImg));
View Full Code Here

    return panelSize.getMapElementSize(1);
  }

  @Override
  public RectangleElement buildMapElement(Point position) {
    return new RectangleElement(position, getSelectedColor(),
        getElementSizeWidth(), getElementSizeHeight());
  }
View Full Code Here

    add(panelHeight, gbc_panel_1);
  }

  @Override
  protected void mapElementChanged() {
    RectangleElement rectangle = getMapElement();
    panelWidth.setElementSizeAt(0, rectangle.getWidth());
    panelHeight.setElementSizeAt(0, rectangle.getHeight());
  }
View Full Code Here

    return "La hauteur ou la largueur est invalide";
  }

  @Override
  public void applyModification() {
    RectangleElement characterElement = getMapElement();
    characterElement.setWidth(panelWidth.getMapElementSize(0));
    characterElement.setHeight(panelHeight.getMapElementSize(0));
  }
View Full Code Here

    add(panelHeight, gbc_panel_1);
  }

  @Override
  protected void mapElementChanged() {
    RectangleElement rectangle = getMapElement();
    panelWidth.setElementSizeAt(0, rectangle.getWidth());
    panelHeight.setElementSizeAt(0, rectangle.getHeight());
  }
View Full Code Here

TOP

Related Classes of net.alteiar.beans.map.elements.RectangleElement

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.