Search in sources :

Example 6 with Project

use of com.revolsys.swing.map.layer.Project in project com.revolsys.open by revolsys.

the class ProjectFrame method actionSaveProjectAs.

public void actionSaveProjectAs() {
    final Path path = this.project.saveAllSettingsAs();
    if (path != null) {
        addToRecentProjects(path);
        Invoke.later(() -> {
            final Project project = getProject();
            setTitle(project.getName() + " - " + getFrameTitle());
        });
    }
}
Also used : Path(java.nio.file.Path) TreePath(javax.swing.tree.TreePath) Project(com.revolsys.swing.map.layer.Project)

Example 7 with Project

use of com.revolsys.swing.map.layer.Project in project com.revolsys.open by revolsys.

the class ProjectTreeNode method loadChildrenDo.

@Override
protected List<BaseTreeNode> loadChildrenDo() {
    final List<BaseTreeNode> children = super.loadChildrenDo();
    final Project project = getProject();
    final LayerGroup baseMapLayers = project.getBaseMapLayers();
    final LayerGroupTreeNode baseMapLayersNode = new LayerGroupTreeNode(baseMapLayers);
    children.add(baseMapLayersNode);
    return children;
}
Also used : Project(com.revolsys.swing.map.layer.Project) BaseTreeNode(com.revolsys.swing.tree.BaseTreeNode) LayerGroup(com.revolsys.swing.map.layer.LayerGroup)

Example 8 with Project

use of com.revolsys.swing.map.layer.Project in project com.revolsys.open by revolsys.

the class GridLayer method zoomToSheet.

public void zoomToSheet(final String mapsheet) {
    final Project project = getProject();
    if (project != null) {
        if (Property.hasValue(mapsheet)) {
            final MapPanel map = getMapPanel();
            final RectangularMapGrid grid = getGrid();
            final String gridName = grid.getName();
            try {
                final RectangularMapTile mapTile = grid.getTileByName(mapsheet);
                final BoundingBox boundingBox = mapTile.getBoundingBox();
                project.setViewBoundingBox(boundingBox);
            } catch (final Throwable e) {
                final String message = "Invalid mapsheet " + mapsheet + " for " + gridName;
                JOptionPane.showMessageDialog(map, message);
            } finally {
                final String preferenceName = CaseConverter.toCapitalizedWords(gridName) + "Mapsheet";
                PreferencesUtil.setString(getClass(), preferenceName, mapsheet);
            }
        }
    }
}
Also used : Project(com.revolsys.swing.map.layer.Project) MapPanel(com.revolsys.swing.map.MapPanel) BoundingBox(com.revolsys.geometry.model.BoundingBox) RectangularMapTile(com.revolsys.gis.grid.RectangularMapTile) RectangularMapGrid(com.revolsys.gis.grid.RectangularMapGrid)

Example 9 with Project

use of com.revolsys.swing.map.layer.Project in project com.revolsys.open by revolsys.

the class Print method actionPerformed.

@Override
public void actionPerformed(final ActionEvent event) {
    final Project project = Project.get();
    final Viewport2D viewport = project.getViewport();
    final PrinterJob job = PrinterJob.getPrinterJob();
    final PageFormat format = job.defaultPage();
    format.setOrientation(PageFormat.PORTRAIT);
    final Paper paper = format.getPaper();
    paper.setImageableArea(29, 29, format.getWidth() - 58, format.getHeight() - 58);
    format.setPaper(paper);
    if (this.printService != null) {
        try {
            job.setPrintService(this.printService);
        } catch (final PrinterException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    final BoundingBox boundingBox = viewport.getBoundingBox();
    final MapPageable pageable = new MapPageable(project, boundingBox, format, 20000, 300, 200);
    job.setPageable(pageable);
    final boolean doPrint = job.printDialog();
    if (doPrint) {
        this.printService = job.getPrintService();
        Invoke.background("Print", () -> {
            try {
                job.print();
            } catch (final Exception e) {
                Logs.error(this, "Unable to print", e);
            }
        });
    }
}
Also used : Project(com.revolsys.swing.map.layer.Project) Viewport2D(com.revolsys.swing.map.Viewport2D) PageFormat(java.awt.print.PageFormat) BoundingBox(com.revolsys.geometry.model.BoundingBox) Paper(java.awt.print.Paper) PrinterException(java.awt.print.PrinterException) PrinterException(java.awt.print.PrinterException) PrinterJob(java.awt.print.PrinterJob)

Example 10 with Project

use of com.revolsys.swing.map.layer.Project in project com.revolsys.open by revolsys.

the class SinglePage method print.

public static void print() {
    final Project project = Project.get();
    final Viewport2D viewport = project.getViewport();
    final int viewWidth = viewport.getViewWidthPixels();
    final int viewHeight = viewport.getViewHeightPixels();
    final BoundingBox boundingBox = viewport.getBoundingBox();
    final double scaleForVisible = viewport.getScaleForVisible();
    final PrinterJob job = PrinterJob.getPrinterJob();
    job.setJobName(project.getName());
    final PageFormat format = job.defaultPage();
    final PrintRequestAttributeSet printAttributes = new HashPrintRequestAttributeSet();
    if (boundingBox.getAspectRatio() > 1) {
        format.setOrientation(PageFormat.LANDSCAPE);
    // printAttributes.add(OrientationRequested.LANDSCAPE);
    } else {
        format.setOrientation(PageFormat.PORTRAIT);
    // printAttributes.add(OrientationRequested.PORTRAIT);
    }
    final SinglePage pageable = new SinglePage(project, boundingBox, viewWidth, viewHeight, scaleForVisible);
    job.setPageable(pageable);
    final boolean doPrint = job.printDialog();
    if (doPrint) {
        Invoke.background("Print", () -> {
            try {
                job.print();
            } catch (final PrinterAbortException e) {
            } catch (final Exception e) {
                Logs.error(SinglePage.class, "Unable to print", e);
            }
        });
    }
}
Also used : PrinterAbortException(java.awt.print.PrinterAbortException) PrinterException(java.awt.print.PrinterException) PrinterJob(java.awt.print.PrinterJob) PrintRequestAttributeSet(javax.print.attribute.PrintRequestAttributeSet) HashPrintRequestAttributeSet(javax.print.attribute.HashPrintRequestAttributeSet) Project(com.revolsys.swing.map.layer.Project) Viewport2D(com.revolsys.swing.map.Viewport2D) GraphicsViewport2D(com.revolsys.swing.map.GraphicsViewport2D) PageFormat(java.awt.print.PageFormat) PrinterAbortException(java.awt.print.PrinterAbortException) BoundingBox(com.revolsys.geometry.model.BoundingBox) HashPrintRequestAttributeSet(javax.print.attribute.HashPrintRequestAttributeSet)

Aggregations

Project (com.revolsys.swing.map.layer.Project)28 BoundingBox (com.revolsys.geometry.model.BoundingBox)14 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)6 Viewport2D (com.revolsys.swing.map.Viewport2D)4 MapPanel (com.revolsys.swing.map.MapPanel)3 Point (com.revolsys.geometry.model.Point)2 GeoreferencedImage (com.revolsys.raster.GeoreferencedImage)2 ImageViewport (com.revolsys.swing.map.ImageViewport)2 Layer (com.revolsys.swing.map.layer.Layer)2 LayerGroup (com.revolsys.swing.map.layer.LayerGroup)2 AbstractRecordLayer (com.revolsys.swing.map.layer.record.AbstractRecordLayer)2 PageFormat (java.awt.print.PageFormat)2 PrinterException (java.awt.print.PrinterException)2 PrinterJob (java.awt.print.PrinterJob)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Geometry (com.revolsys.geometry.model.Geometry)1 LineString (com.revolsys.geometry.model.LineString)1 RectangularMapGrid (com.revolsys.gis.grid.RectangularMapGrid)1 RectangularMapTile (com.revolsys.gis.grid.RectangularMapTile)1