use of com.revolsys.swing.map.layer.Project in project com.revolsys.open by revolsys.
the class GriddedElevationModelLayer method zoomToLayer.
@Override
public void zoomToLayer() {
final Project project = getProject();
final GeometryFactory geometryFactory = project.getGeometryFactory();
final BoundingBox layerBoundingBox = getBoundingBox();
final BoundingBox boundingBox = //
layerBoundingBox.convert(geometryFactory).expandPercent(//
0.1).clipToCoordinateSystem();
project.setViewBoundingBox(boundingBox);
}
use of com.revolsys.swing.map.layer.Project in project com.revolsys.open by revolsys.
the class FileDropTargetListener method drop.
@Override
@SuppressWarnings("unchecked")
public void drop(final DropTargetDropEvent event) {
try {
final Transferable tr = event.getTransferable();
final List<File> files = new ArrayList<>();
if (tr.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
event.acceptDrop(DnDConstants.ACTION_COPY);
files.addAll((List<File>) tr.getTransferData(DataFlavor.javaFileListFlavor));
} else {
final DataFlavor[] flavors = tr.getTransferDataFlavors();
boolean handled = false;
for (final DataFlavor flavor : flavors) {
if (flavor.isRepresentationClassReader()) {
event.acceptDrop(DnDConstants.ACTION_COPY);
final BufferedReader reader = new BufferedReader(flavor.getReaderForText(tr));
handled = true;
String fileName = null;
while ((fileName = reader.readLine()) != null) {
try {
// kde seems to append a 0 char to the end of the reader
if (!ZERO_CHAR_STRING.equals(fileName)) {
final URI uri = new URI(fileName);
if (uri.isAbsolute()) {
final File file = new File(uri);
files.add(file);
}
}
} catch (final URISyntaxException e) {
LOG.error("Drag and Drop file " + fileName + " not valid", e);
}
}
}
}
if (!handled) {
event.rejectDrop();
return;
}
}
final Project project = Project.get();
Invoke.background("Open Files", () -> project.openFiles(files));
event.getDropTargetContext().dropComplete(true);
} catch (final Throwable e) {
LOG.error("Unable to drop", e);
}
}
use of com.revolsys.swing.map.layer.Project in project com.revolsys.open by revolsys.
the class AbstractOverlay method getSnapLayers.
protected List<AbstractRecordLayer> getSnapLayers() {
final Project project = getProject();
final MapPanel map = getMap();
final double scale = map.getScale();
return AbstractRecordLayer.getVisibleLayers(project, scale);
}
use of com.revolsys.swing.map.layer.Project in project com.revolsys.open by revolsys.
the class LayerRendererOverlaySwingWorker method handleBackground.
@Override
protected Void handleBackground() {
try {
final Layer layer = this.overlay.getLayer();
if (layer != null) {
final Project project = this.overlay.getProject();
final int imageWidth = this.referencedImage.getImageWidth();
final int imageHeight = this.referencedImage.getImageHeight();
if (imageWidth > 0 && imageHeight > 0 && project != null) {
final BoundingBox boundingBox = this.referencedImage.getBoundingBox();
try (final ImageViewport viewport = new ImageViewport(project, imageWidth, imageHeight, boundingBox)) {
if (layer != null && layer.isExists() && layer.isVisible()) {
final LayerRenderer<Layer> renderer = layer.getRenderer();
if (renderer != null) {
renderer.render(viewport, this);
}
}
if (!isCancelled()) {
final BufferedImage image = viewport.getImage();
this.referencedImage.setRenderedImage(image);
}
}
}
}
return null;
} catch (final Throwable t) {
if (!isCancelled()) {
Logs.error(this, "Unable to paint", t);
}
return null;
}
}
use of com.revolsys.swing.map.layer.Project in project com.revolsys.open by revolsys.
the class EditRecordGeometryOverlay method getSnapLayers.
@Override
protected List<AbstractRecordLayer> getSnapLayers() {
final Project project = getProject();
final double scale = project.getMapPanel().getScale();
final Set<AbstractRecordLayer> layers = new LinkedHashSet<>();
boolean snapAll = false;
if (isOverlayAction(ACTION_ADD_GEOMETRY)) {
snapAll = addSnapLayers(layers, project, this.addLayer, scale);
} else {
for (final CloseLocation location : getMouseOverLocations()) {
final AbstractRecordLayer layer = location.getLayer();
snapAll |= addSnapLayers(layers, project, layer, scale);
}
}
if (snapAll) {
final List<AbstractRecordLayer> visibleDescendants = project.getVisibleDescendants(AbstractRecordLayer.class, scale);
return visibleDescendants;
}
return new ArrayList<>(layers);
}
Aggregations