Esempio n. 1
0
 /**
  * Updates the panel's text or the grids second settable dimension.
  *
  * @param toPanel true = from grid to panel, false = from panel to grid
  * @param grid
  */
 private void updateSecondDimension(Grid grid, boolean toPanel) {
   if (grid.getCapabilities().isSecondDimensionAdjustmentSupported()) {
     if (toPanel) {
       // truncate to 3 decimal places
       double secondDim = Math.round(grid.getSecondDimension() * 1000.0) / 1000.0;
       gridSecondDimension.setText(Double.toString(secondDim));
     } else { // toGrid
       double newMajDiameter = getDouble(gridSecondDimension.getText(), 0);
       grid.setSecondDimension(newMajDiameter);
     }
   }
 }
Esempio n. 2
0
  private void copyControlPanelToGrid() {
    Zone zone = renderer.getZone();
    Grid grid = zone.getGrid();

    updateSecondDimension(grid, false);
    grid.setSize(Math.max((Integer) gridSizeSpinner.getValue(), Grid.MIN_GRID_SIZE));
    updateSecondDimension(grid, true);
    grid.setOffset(getInt(gridOffsetXTextField, 0), getInt(gridOffsetYTextField, 0));
    zone.setGridColor(colorWell.getColor().getRGB());

    renderer.repaint();
  }
Esempio n. 3
0
  private void copyGridToControlPanel() {
    Zone zone = renderer.getZone();

    Grid grid = zone.getGrid();

    updateSecondDimension(grid, true);
    gridSizeSpinner.setValue(grid.getSize());
    gridOffsetXTextField.setText(Integer.toString(grid.getOffsetX()));
    gridOffsetYTextField.setText(Integer.toString(grid.getOffsetY()));
    colorWell.setColor(new Color(zone.getGridColor()));

    resetZoomSlider();
  }
Esempio n. 4
0
  /*
   * (non-Javadoc)
   *
   * @see maptool.client.Tool#attachTo(maptool.client.ZoneRenderer)
   */
  @Override
  protected void attachTo(ZoneRenderer renderer) {
    oldShowGrid = AppState.isShowGrid();
    AppState.setShowGrid(true);

    Grid grid = renderer.getZone().getGrid();

    boolean showSecond =
        grid.getCapabilities().isSecondDimensionAdjustmentSupported() ? true : false;
    gridSecondDimension.setVisible(showSecond);
    gridSecondDimensionLabel.setVisible(showSecond);

    MapTool.getFrame().showControlPanel(controlPanel);
    renderer.repaint();

    super.attachTo(renderer);

    copyGridToControlPanel();
  }