예제 #1
0
  @Test
  public void LoadFlagFromStringWithFlagOverlayTest() {
    File inner = SaveBasicFlag();

    StringBuilder sb = new StringBuilder();
    sb.append("name=Test\n");
    sb.append("ratio=3:5\n");
    sb.append("gridsize=3:5\n\n");

    sb.append("type=grid\n");
    sb.append("color1=ff0000\n");
    sb.append("color2=ffffff\n");
    sb.append("size1=2\n");
    sb.append("size2=2\n\n");

    sb.append("type=flag\n");
    sb.append(String.format("path=%s\n", inner.getName()));
    sb.append("x=0\n");
    sb.append("y=0\n");
    sb.append("width=2.5\n");
    sb.append("height=1.5\n");

    File file = SaveFlagFile(sb.toString());
    Flag flag = null;

    try {
      flag = FileHandler.LoadFlagFromFile(file);
    } catch (Exception ex) {
      fail(ex.getMessage());
    }

    assertEquals(flag.Ratio.Width, Ratio.Width);
    assertEquals(flag.Ratio.Height, Ratio.Height);
    assertEquals(flag.GridSize.Width, Ratio.Width);
    assertEquals(flag.GridSize.Height, Ratio.Height);

    assertTrue(flag.Division instanceof DivisionGrid);
    assertEquals(Color.RED, flag.Division.Colors[0]);
    assertEquals(Color.WHITE, flag.Division.Colors[1]);
    assertEquals(2, flag.Division.Values[0]);
    assertEquals(2, flag.Division.Values[1]);

    assertEquals(1, flag.Overlays.length);
    assertTrue(flag.Overlays[0] instanceof OverlayFlag);
    OverlayFlag f = (OverlayFlag) flag.Overlays[0];
    assertEquals(0, f.GetDoubleAttribute("X"), 0.001);
    assertEquals(0, f.GetDoubleAttribute("Y"), 0.001);
    assertEquals(2.5, f.GetDoubleAttribute("Width"), 0.001);
    assertEquals(1.5, f.GetDoubleAttribute("Height"), 0.001);

    AssertBasicFlag(f.Flag);
  }
예제 #2
0
  private File SaveBasicFlag() {
    StringBuilder sb = new StringBuilder();
    sb.append("name=Test\n");
    sb.append("ratio=3:5\n");
    sb.append("gridsize=3:5\n\n");

    sb.append("type=grid\n");
    sb.append("color1=ff0000\n");
    sb.append("color2=ffffff\n");
    sb.append("size1=2\n");
    sb.append("size2=2\n\n");

    sb.append("type=star\n");
    sb.append("color=00ff00\n");
    sb.append("x=2.5\n");
    sb.append("y=1.5\n");
    sb.append("size=1\n");
    sb.append("rotation=0\n");
    sb.append("stroke=0\n");
    sb.append("strokecolor=000000\n");
    sb.append("strokecurved=false\n");

    return SaveFlagFile(sb.toString());
  }