private FilePlacement parsePlacement() {
    Object selectedProjection = this.projectionCombo.getSelectedItem();

    if (!(selectedProjection instanceof Projection)) {
      JOptionPane.showMessageDialog(Main.parent, tr("Please set a projection."));
      return null;
    }

    FilePlacement placement = new FilePlacement();

    placement.projection = (Projection) this.projectionCombo.getSelectedItem();

    try {
      placement.setPdfBounds(
          Double.parseDouble(this.minXField.getText()),
          Double.parseDouble(this.minYField.getText()),
          Double.parseDouble(this.maxXField.getText()),
          Double.parseDouble(this.maxYField.getText()));
      placement.setEastNorthBounds(
          Double.parseDouble(this.minEastField.getText()),
          Double.parseDouble(this.minNorthField.getText()),
          Double.parseDouble(this.maxEastField.getText()),
          Double.parseDouble(this.maxNorthField.getText()));
    } catch (Exception e) {
      JOptionPane.showMessageDialog(Main.parent, tr("Could not parse numbers. Please check."));
      return null;
    }

    return placement;
  }
  private void showPressed() {

    FilePlacement placement = preparePlacement();
    if (placement == null) {
      return;
    }

    // zoom to new location
    Main.map.mapView.zoomTo(placement.getWorldBounds(this.data));
    Main.map.repaint();
  }
  private EastNorth getSelectedCoor() {
    Collection<OsmPrimitive> selected = Main.main.getCurrentDataSet().getSelected();

    if (selected.size() != 1 || !(selected.iterator().next() instanceof Node)) {
      JOptionPane.showMessageDialog(Main.parent, tr("Please select exactly one node."));
      return null;
    }

    LatLon ll = ((Node) selected.iterator().next()).getCoor();
    FilePlacement pl = new FilePlacement();
    return pl.reverseTransform(ll);
  }
  private FilePlacement preparePlacement() {
    FilePlacement placement = this.parsePlacement();
    if (placement == null) {
      return null;
    }

    String transformError = placement.prepareTransform();
    if (transformError != null) {
      JOptionPane.showMessageDialog(Main.parent, transformError);
      return null;
    }

    this.savePlacement(placement);

    return placement;
  }
 private void savePlacement(FilePlacement pl) {
   // load saved transformation
   File propertiesFile = new File(fileName.getAbsoluteFile() + ".placement");
   try {
     Properties p = pl.toProperties();
     p.store(new FileOutputStream(propertiesFile), "PDF file placement on OSM");
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
  private FilePlacement loadPlacement() {
    FilePlacement pl = null;
    // load saved transformation
    File propertiesFile = new File(fileName.getAbsoluteFile() + ".placement");
    try {

      if (propertiesFile.exists()) {
        pl = new FilePlacement();
        Properties p = new Properties();
        p.load(new FileInputStream(propertiesFile));
        pl.fromProperties(p);
      }
    } catch (Exception e) {
      pl = null;
      e.printStackTrace();
    }

    return pl;
  }
 private void placeLayer(OsmDataLayer _layer, FilePlacement placement) {
   this.removeLayer();
   this.layer = _layer;
   Main.main.addLayer(this.layer);
   Main.map.mapView.zoomTo(placement.getWorldBounds(this.data));
 }