Exemplo n.º 1
0
  /** Initializes this dialog. */
  private void initDialog() {
    setMinimumSize(new Dimension(640, 480));

    final JComponent settingsPane = createSettingsPane();
    final JComponent previewPane = createPreviewPane();

    final JPanel contentPane = new JPanel(new GridBagLayout());
    contentPane.add(
        settingsPane,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.NORTH,
            GridBagConstraints.NONE,
            new Insets(2, 0, 2, 0),
            0,
            0));
    contentPane.add(
        previewPane,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTH,
            GridBagConstraints.BOTH,
            new Insets(2, 0, 2, 0),
            0,
            0));

    final JButton runAnalysisButton = ToolUtils.createRunAnalysisButton(this);
    this.runAnalysisAction = (RestorableAction) runAnalysisButton.getAction();

    final JButton exportButton = ToolUtils.createExportButton(this);
    this.exportAction = exportButton.getAction();
    this.exportAction.setEnabled(false);

    final JButton closeButton = ToolUtils.createCloseButton();
    this.closeAction = closeButton.getAction();

    final JComponent buttons =
        SwingComponentUtils.createButtonPane(runAnalysisButton, exportButton, closeButton);

    SwingComponentUtils.setupWindowContentPane(this, contentPane, buttons, runAnalysisButton);
  }
Exemplo n.º 2
0
  /** HashedEntityId. */
  @Test
  public void testHashedParserLoop() throws Exception {
    final EntityIdFactory factory =
        EntityIdFactory.getFactory((RowKeyFormat) mHashedLayout.getDesc().getKeysFormat());
    final EntityId eid = factory.getEntityId("hashedRowKey");

    assertEquals(eid, ToolUtils.createEntityIdFromUserInputs(eid.toShellString(), mHashedLayout));
  }
Exemplo n.º 3
0
  /** RawEntityId. */
  @Test
  public void testRawParserLoop() throws Exception {
    final EntityIdFactory factory =
        EntityIdFactory.getFactory((RowKeyFormat) mRawLayout.getDesc().getKeysFormat());
    final EntityId eid = factory.getEntityIdFromHBaseRowKey(Bytes.toBytes("rawRowKey"));

    assertEquals(eid, ToolUtils.createEntityIdFromUserInputs(eid.toShellString(), mRawLayout));
  }
Exemplo n.º 4
0
  /** HBaseEntityId. */
  @Test
  public void testHBaseEIDtoRawEID() throws Exception {
    final EntityIdFactory factory =
        EntityIdFactory.getFactory((RowKeyFormat) mRawLayout.getDesc().getKeysFormat());
    final EntityId reid = factory.getEntityId("rawEID");
    final EntityId hbeid = HBaseEntityId.fromHBaseRowKey(reid.getHBaseRowKey());

    assertEquals(reid, ToolUtils.createEntityIdFromUserInputs(hbeid.toShellString(), mRawLayout));
  }
Exemplo n.º 5
0
  @Test
  public void testEmptyString() throws IOException {
    final EntityIdFactory factory =
        EntityIdFactory.getFactory((RowKeyFormat2) mFormattedLayout.getDesc().getKeysFormat());
    final EntityId eid = factory.getEntityId("", "", "", null, null);

    assertEquals(
        eid, ToolUtils.createEntityIdFromUserInputs("['', '', '', null, null]", mFormattedLayout));
  }
Exemplo n.º 6
0
  @Test
  public void testTooFewComponents() throws IOException {
    final EntityIdFactory factory =
        EntityIdFactory.getFactory((RowKeyFormat2) mFormattedLayout.getDesc().getKeysFormat());
    final EntityId eid = factory.getEntityId("dummy", "str1", "str2", 5, null);

    assertEquals(
        eid,
        ToolUtils.createEntityIdFromUserInputs("['dummy', 'str1', 'str2', 5]", mFormattedLayout));
  }
Exemplo n.º 7
0
  @Test
  public void testHBaseEIDtoFormattedEID() throws Exception {
    final EntityIdFactory factory =
        EntityIdFactory.getFactory((RowKeyFormat2) mFormattedLayout.getDesc().getKeysFormat());
    final EntityId feid = factory.getEntityId("dummy", "str1", "str2", 5, 10);
    final EntityId hbeid = HBaseEntityId.fromHBaseRowKey(feid.getHBaseRowKey());

    assertEquals(
        feid, ToolUtils.createEntityIdFromUserInputs(hbeid.toShellString(), mFormattedLayout));
  }
Exemplo n.º 8
0
 /** FormattedEntityId. */
 @Test
 public void testTooLargeInt() throws Exception {
   try {
     ToolUtils.createEntityIdFromUserInputs(
         "['dummy', 'str1', 'str2', 2147483648, 10]", mFormattedLayout);
     fail("Should fail with EntityIdException.");
   } catch (EntityIdException eie) {
     assertEquals(
         "Invalid type for component 2147483648 at index 3 in kijiRowKey", eie.getMessage());
   }
 }
Exemplo n.º 9
0
  @Test
  public void testNonNullFollowsNull() throws IOException {

    try {
      ToolUtils.createEntityIdFromUserInputs(
          "['dummy', 'str1', 'str2', null, 5]", mFormattedLayout);
      fail("Should fail with EntityIdException.");
    } catch (EntityIdException eie) {
      assertEquals("Non null component follows null component", eie.getMessage());
    }
  }
Exemplo n.º 10
0
  @Test
  public void testTooLargeLong() throws Exception {

    try {
      ToolUtils.createEntityIdFromUserInputs(
          "['dummy', 'str1', 'str2', 5, 9223372036854775808]", mFormattedLayout);
      fail("Should fail with EntityIdException.");
    } catch (IOException ioe) {
      assertEquals(
          "Invalid JSON value: '9223372036854775808', expecting string, " + "int, long, or null.",
          ioe.getMessage());
    }
  }
Exemplo n.º 11
0
  @Test
  public void testASCIIChars() throws Exception {
    final EntityIdFactory factory =
        EntityIdFactory.getFactory((RowKeyFormat2) mFormattedLayout.getDesc().getKeysFormat());

    for (byte b = 32; b < 127; b++) {
      for (byte b2 = 32; b2 < 127; b2++) {
        final EntityId eid =
            factory.getEntityId(
                String.format("dumm%sy", new String(new byte[] {b, b2}, "Utf-8")),
                "str1",
                "str2",
                5,
                10L);

        assertEquals(
            eid, ToolUtils.createEntityIdFromUserInputs(eid.toShellString(), mFormattedLayout));
      }
    }
  }
  private void modifyHeight(
      Terrain terrain, Vector3f worldLoc, float radius, float height, Meshes mesh) {

    int radiusStepsX = (int) (radius / ((Node) terrain).getLocalScale().x);
    int radiusStepsZ = (int) (radius / ((Node) terrain).getLocalScale().z);

    float xStepAmount = ((Node) terrain).getLocalScale().x;
    float zStepAmount = ((Node) terrain).getLocalScale().z;

    List<Vector2f> locs = new ArrayList<Vector2f>();
    List<Float> heights = new ArrayList<Float>();

    for (int z = -radiusStepsZ; z < radiusStepsZ; z++) {
      for (int x = -radiusStepsX; x < radiusStepsX; x++) {

        float locX = worldLoc.x + (x * xStepAmount);
        float locZ = worldLoc.z + (z * zStepAmount);

        // see if it is in the radius of the tool
        if (ToolUtils.isInMesh(locX - worldLoc.x, locZ - worldLoc.z, radius, mesh)) {

          Vector2f terrainLoc = new Vector2f(locX, locZ);
          // adjust height based on radius of the tool
          float center = terrain.getHeightmapHeight(terrainLoc);
          float left = terrain.getHeightmapHeight(new Vector2f(terrainLoc.x - 1, terrainLoc.y));
          float right = terrain.getHeightmapHeight(new Vector2f(terrainLoc.x + 1, terrainLoc.y));
          float up = terrain.getHeightmapHeight(new Vector2f(terrainLoc.x, terrainLoc.y + 1));
          float down = terrain.getHeightmapHeight(new Vector2f(terrainLoc.x, terrainLoc.y - 1));
          int count = 1;
          float amount = center;
          if (!isNaN(left)) {
            amount += left;
            count++;
          }
          if (!isNaN(right)) {
            amount += right;
            count++;
          }
          if (!isNaN(up)) {
            amount += up;
            count++;
          }
          if (!isNaN(down)) {
            amount += down;
            count++;
          }

          amount /= count; // take average

          // weigh it
          float diff = amount - center;
          diff *= height;

          locs.add(terrainLoc);
          heights.add(diff);
        }
      }
    }

    undoLocs = locs;
    undoHeights = heights;

    // do the actual height adjustment
    terrain.adjustHeight(locs, heights);

    ((Node) terrain).updateModelBound(); // or else we won't collide with it where we just edited
  }