Search in sources :

Example 96 with BoundingBox

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;
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) ProjectedCoordinateSystem(com.revolsys.geometry.cs.ProjectedCoordinateSystem) CoordinateSystem(com.revolsys.geometry.cs.CoordinateSystem) BoundingBox(com.revolsys.geometry.model.BoundingBox) ProjectedCoordinateSystem(com.revolsys.geometry.cs.ProjectedCoordinateSystem) List(java.util.List) Record(com.revolsys.record.Record) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) Point(com.revolsys.geometry.model.Point)

Example 97 with BoundingBox

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);
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox)

Example 98 with 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);
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox)

Example 99 with BoundingBox

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);
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) BoundingBox(com.revolsys.geometry.model.BoundingBox)

Example 100 with 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);
        }
    }
}
Also used : NullLayer(com.revolsys.swing.map.layer.NullLayer) BoundingBox(com.revolsys.geometry.model.BoundingBox) GeoreferencedImage(com.revolsys.raster.GeoreferencedImage) BufferedGeoreferencedImage(com.revolsys.raster.BufferedGeoreferencedImage) BufferedGeoreferencedImage(com.revolsys.raster.BufferedGeoreferencedImage)

Aggregations

BoundingBox (com.revolsys.geometry.model.BoundingBox)307 Point (com.revolsys.geometry.model.Point)83 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)76 ArrayList (java.util.ArrayList)45 Geometry (com.revolsys.geometry.model.Geometry)41 LineString (com.revolsys.geometry.model.LineString)26 List (java.util.List)26 BoundingBoxDoubleXY (com.revolsys.geometry.model.impl.BoundingBoxDoubleXY)19 Polygon (com.revolsys.geometry.model.Polygon)14 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)14 Project (com.revolsys.swing.map.layer.Project)14 CreateListVisitor (com.revolsys.visitor.CreateListVisitor)12 CoordinateSystem (com.revolsys.geometry.cs.CoordinateSystem)11 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)11 Edge (com.revolsys.geometry.graph.Edge)10 HashMap (java.util.HashMap)10 Record (com.revolsys.record.Record)9 Graphics2D (java.awt.Graphics2D)9 MapEx (com.revolsys.collection.map.MapEx)8 LinearRing (com.revolsys.geometry.model.LinearRing)8