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(); }
public String getInfo(int x, int y, int maxNbInfo) { Point2D.Double wgs84 = new Point2D.Double(); transformer.map2wgs84(x, y, wgs84); Point2D.Double wgs84Precision = new Point2D.Double(); transformer.map2wgs84(x + 5, y, wgs84Precision); int longitude = CoordUtils.fromWGS84Rad(wgs84.x); int latitude = CoordUtils.fromWGS84Rad(wgs84.y); int precision = Math.max( Math.abs(longitude - CoordUtils.fromWGS84Rad(wgs84Precision.x)), Math.abs(latitude - CoordUtils.fromWGS84Rad(wgs84Precision.y))); try { FindObjectByPositionListener listener = new FindObjectByPositionListener(longitude, latitude, precision); int resolution = getResolution(transformer); map.readMapForDrawing( longitude, longitude, latitude, latitude, resolution, ObjectKind.ALL, listener); List<FoundObject> founds = listener.getFounds(); if (founds.isEmpty()) return null; StringBuilder buffer = new StringBuilder("<html>\n<ul>\n"); for (int i = founds.size() - 1; i >= Math.max(0, founds.size() - maxNbInfo); i--) { FoundObject found = founds.get(i); buffer.append(" <li>"); found.toDebugHtml(buffer); buffer.append("</li>\n"); } buffer.append("</ul>\n</html>\n"); return buffer.toString(); } catch (IOException e) { e.printStackTrace(); return null; } }