use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class WikipediaBoundingBoxLayerWorker method handleBackground.
@Override
protected List<LayerRecord> handleBackground() {
BoundingBox boundingBox = this.boundingBox;
GeometryFactory geometryFactory = this.geometryFactory;
final CoordinateSystem coordinateSystem = geometryFactory.getCoordinateSystem();
if (coordinateSystem instanceof ProjectedCoordinateSystem) {
final ProjectedCoordinateSystem projCs = (ProjectedCoordinateSystem) coordinateSystem;
geometryFactory = projCs.getGeographicCoordinateSystem().getGeometryFactory();
boundingBox = boundingBox.convert(geometryFactory);
}
final List<LayerRecord> results = (List) this.geoNamesService.getWikipediaArticles(boundingBox);
for (final Record record : results) {
final String title = record.getValue("title");
final String wikipediaUrl = record.getValue("wikipediaUrl");
final String thumbnailImage = record.getValue("thumbnailImg");
final Point point = record.getGeometry();
String text;
if (thumbnailImage != null) {
text = "<html><b>" + title + "</b><br /><img src=\"" + thumbnailImage + "\" /><br /></html>";
} else {
text = "<html><b>" + title + "</b><br /></html>";
}
// if (viewport instanceof ComponentViewport2D) {
// final ComponentViewport2D componentViewport =
// (ComponentViewport2D)viewport;
// componentViewport.addHotSpot(geometryFactory, point, text, "http://"
// + wikipediaUrl);
// }
}
return results;
}
use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class FactorZoomMode method zoom.
/**
* Zoom the map to include the bounding box specified by the model coordinate
* pair.
*
* @param viewport The viewport.
* @param x1 The first x coordinate.
* @param y1 The first y coordinate.
* @param x2 The second x coordinate.
* @param y2 The second y coordinate.
*/
@Override
public void zoom(final ComponentViewport2D viewport, final double x1, final double y1, final double x2, final double y2) {
final double viewWidth = viewport.getViewWidthPixels();
final double viewHeight = viewport.getViewHeightPixels();
final double xc1 = Math.max(Math.min(x1, viewWidth - 1), 0);
final double yc1 = Math.max(Math.min(y1, viewHeight - 1), 0);
final double xc2 = Math.max(Math.min(x2, viewWidth - 1), 0);
final double yc2 = Math.max(Math.min(y2, viewHeight - 1), 0);
final BoundingBox boundingBox = viewport.getBoundingBox(xc1, yc1, xc2, yc2);
viewport.setBoundingBox(boundingBox);
}
use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class FactorZoomMode method zoom.
/**
* Zoom the map so that the specified bounding box is visible.
*
* @param viewport The viewport.
* @param boundingBox The bounding box.
*/
@Override
public void zoom(final ComponentViewport2D viewport, final BoundingBox boundingBox) {
final BoundingBox newBoundingBox = getBoundingBox(viewport, boundingBox);
viewport.setBoundingBox(newBoundingBox);
}
use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class FactorZoomMode method zoomProportional.
/**
* Zoom the map in by the multiplication factor at the view coordinate, with
* the model coordinate being maintained at the same view coordinate.
*
* @param viewport The viewport to zoom.
* @param x The x coordinate.
* @param y The y coordinate.
* @param factor The multiplication factor to zoom by.
*/
private void zoomProportional(final ComponentViewport2D viewport, final double x, final double y, final double factor) {
final double[] ordinates = viewport.toModelCoordinates(x, y);
final double mapX = ordinates[0];
final double mapY = ordinates[1];
final double scale = Math.min(viewport.getScale() * factor, viewport.getMaxScale());
final double width = viewport.getModelWidth(scale);
final double height = viewport.getModelHeight(scale);
final double viewWidth = viewport.getViewWidthPixels();
final double xProportion = x / viewWidth;
final double viewHeight = viewport.getViewHeightPixels();
final double yProportion = (viewHeight - y) / viewHeight;
final GeometryFactory geometryFactory = viewport.getGeometryFactory();
final double x1 = mapX - width * xProportion;
final double y1 = mapY - height * yProportion;
final double x2 = x1 + width;
final double y2 = y1 + height;
final BoundingBox boundingBox = geometryFactory.newBoundingBox(x1, y1, x2, y2);
viewport.setBoundingBox(boundingBox);
}
use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class LayerRendererOverlay method paintComponent.
@Override
public void paintComponent(final Graphics g) {
if (!(this.layer instanceof NullLayer)) {
GeoreferencedImage image;
synchronized (this.loadSync) {
image = this.image;
if ((image == null || this.loadImage) && this.imageWorker == null) {
final BoundingBox boundingBox = this.viewport.getBoundingBox();
final int viewWidthPixels = this.viewport.getViewWidthPixels();
final int viewHeightPixels = this.viewport.getViewHeightPixels();
final GeoreferencedImage loadImage = new BufferedGeoreferencedImage(boundingBox, viewWidthPixels, viewHeightPixels);
this.imageWorker = new LayerRendererOverlaySwingWorker(this, loadImage);
Invoke.worker(this.imageWorker);
}
}
if (image != null) {
render((Graphics2D) g);
}
}
}
Aggregations