use of com.revolsys.swing.map.layer.Project in project com.revolsys.open by revolsys.
the class SinglePage method print.
@Override
public int print(final Graphics graphics, final PageFormat pageFormat, final int pageIndex) throws PrinterException {
if (pageIndex == 0) {
setGraphics((Graphics2D) graphics);
final int translateX = (int) pageFormat.getImageableX();
final int translateY = (int) pageFormat.getImageableY();
graphics.translate(translateX - 1, translateY - 1);
final Project project = getProject();
final MapPanel mapPanel = project.getMapPanel();
final Layer baseMapLayer = mapPanel.getBaseMapLayer();
render(baseMapLayer);
render(project);
return PAGE_EXISTS;
} else {
return NO_SUCH_PAGE;
}
}
use of com.revolsys.swing.map.layer.Project in project com.revolsys.open by revolsys.
the class SaveAsPdf method save.
public static void save() {
final Project project = Project.get();
final String directory = "/Users/paustin/Downloads/";
final File file = new File(directory, project.getName() + ".pdf");
try {
final PDDocument document = new PDDocument();
final Viewport2D viewport = project.getViewport();
BoundingBox boundingBox = viewport.getBoundingBox();
final int width = viewport.getViewWidthPixels();
final int height = viewport.getViewHeightPixels();
final int srid = boundingBox.getCoordinateSystemId();
if (srid == 3857) {
boundingBox = boundingBox.convert(boundingBox.getGeometryFactory().getGeographicGeometryFactory());
}
final PDRectangle pageSize = new PDRectangle(width, height);
final PDPage page = new PDPage(pageSize);
try (PdfViewport pdfViewport = new PdfViewport(document, page, project, width, height, boundingBox)) {
final LayerRenderer<? extends Layer> renderer = project.getRenderer();
renderer.render(pdfViewport);
}
document.addPage(page);
final PDDocumentCatalog catalog = document.getDocumentCatalog();
final PDMetadata metadata = new PDMetadata(document);
catalog.setMetadata(metadata);
// jempbox version
final XMPMetadata xmp = new XMPMetadata();
final XMPSchemaDublinCore xmpSchema = new XMPSchemaDublinCore(xmp);
xmp.addSchema(xmpSchema);
xmpSchema.setAbout("");
metadata.importXMPMetadata(xmp);
document.save(file);
} catch (final Throwable e) {
Logs.error(SaveAsPdf.class, "Unable to create PDF " + file, e);
}
}
use of com.revolsys.swing.map.layer.Project in project com.revolsys.open by revolsys.
the class SelectRecordsOverlay method refreshImageSelected.
private GeoreferencedImage refreshImageSelected() {
final Viewport2D viewport = getViewport();
if (viewport != null) {
final int width = viewport.getViewWidthPixels();
final int height = viewport.getViewHeightPixels();
if (width > 0 && height > 0) {
try (final ImageViewport imageViewport = new ImageViewport(viewport, BufferedImage.TYPE_INT_ARGB_PRE);
BaseCloseable transformCloseable = imageViewport.setUseModelCoordinates(true)) {
final Graphics2D graphics = imageViewport.getGraphics();
final Project project = getProject();
refreshImageRenderer(imageViewport, project);
refreshImageSelectedAndHighlighted(imageViewport, graphics, project);
return imageViewport.getGeoreferencedImage();
}
}
}
return null;
}
use of com.revolsys.swing.map.layer.Project in project com.revolsys.open by revolsys.
the class MapPanel method addZoomBookmark.
public void addZoomBookmark() {
final BoundingBox boundingBox = getBoundingBox();
if (!boundingBox.isEmpty()) {
final String name = JOptionPane.showInputDialog(this, "Enter bookmark name", "Add Zoom Bookmark", JOptionPane.QUESTION_MESSAGE);
if (Property.hasValue(name)) {
final Project project = getProject();
project.addZoomBookmark(name, boundingBox);
}
}
}
use of com.revolsys.swing.map.layer.Project in project com.revolsys.open by revolsys.
the class MapPanel method showZoomBookmarkMenu.
public void showZoomBookmarkMenu() {
final BaseJPopupMenu menu = new BaseJPopupMenu();
menu.addMenuItem("Add Bookmark", "add", this::addZoomBookmark);
menu.addSeparator();
final Project project = getProject();
for (final Entry<String, BoundingBox> entry : project.getZoomBookmarks().entrySet()) {
final String name = entry.getKey();
final BoundingBox boundingBox = entry.getValue();
menu.addMenuItem("Zoom to " + name, "magnifier", () -> zoomToBoundingBox(boundingBox));
}
menu.showMenu(this.zoomBookmarkButton, 0, 20);
}
Aggregations