Esempio n. 1
0
  public void saveMapAs(
      final File selectedFile, FileExporter exporter, MapTransformer<COORD> transformer)
      throws IOException {
    exporter.setup(selectedFile, transformer.getWidth(), transformer.getHeight());
    final Graphics2D g2 = exporter.getG2();

    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setColor(MapPanel.BG_COLOR);
    g2.fillRect(0, 0, transformer.getWidth(), transformer.getHeight());

    Rectangle bbox = transformer.getGarminBoundingBox();
    int minLon = bbox.x;
    int maxLon = bbox.x + bbox.width;
    int minLat = bbox.y;
    int maxLat = bbox.y + bbox.height;
    int resolution = getResolution(minLon, maxLon, transformer.getWidth());
    TransformedMapListener drawer =
        createMapDrawer(new MapConfig(), g2, exporter.getFontSize(), transformer);
    MapListener listener =
        new CoordinateConverterListener<COORD>(
            transformer,
            new ClippingMapListener(0, transformer.getWidth(), 0, transformer.getHeight(), drawer));

    map.readMapForDrawing(minLon, maxLon, minLat, maxLat, resolution, ObjectKind.ALL, listener);
    exporter.finishSave();
  }
Esempio n. 2
0
  public void paintComponent(Graphics g) {
    super.paintComponent(g);
    if (transformer.isSetupDone()) {
      thread.checkSetup(transformer, config);
      Graphics2D g2 = ((Graphics2D) g.create());

      // paint the background
      g2.setColor(MapPanel.BG_COLOR);
      g2.fillRect(0, 0, getWidth(), getHeight());

      MapPanelThread.PaintInfo paintInfo = thread.getPaintInfo(transformer);
      if (paintInfo != null) {
        /*g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
        RenderingHints.VALUE_INTERPOLATION_BILINEAR);*/
        g2.drawImage(paintInfo.image, paintInfo.x, paintInfo.y, paintInfo.w, paintInfo.h, this);
      }
    }
  }