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());
});
}
}
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;
}
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);
}
}
}
}
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);
}
});
}
}
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);
}
});
}
}
Aggregations