Search in sources :

Example 1 with MarkerStyle

use of com.revolsys.swing.map.layer.record.style.MarkerStyle in project com.revolsys.open by revolsys.

the class WikipediaBoundingBoxLayerWorker method newLayer.

public static BoundingBoxRecordLayer newLayer(final Map<String, ? extends Object> config) {
    final GeometryFactory wgs84 = GeometryFactory.floating3d(4326);
    final BoundingBoxRecordLayer layer1 = new BoundingBoxRecordLayer("wikipedia", "Wikipedia Articles", WikipediaBoundingBoxLayerWorker.class, wgs84);
    final BufferedImage image = Icons.getImage("wikipedia");
    final ImageMarker marker = new ImageMarker(image);
    final MarkerStyle style = new MarkerStyle();
    style.setMarker(marker);
    layer1.setRenderer(new MarkerStyleRenderer(layer1, style));
    final BoundingBoxRecordLayer layer = layer1;
    layer.setProperties(config);
    return layer;
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) MarkerStyleRenderer(com.revolsys.swing.map.layer.record.renderer.MarkerStyleRenderer) MarkerStyle(com.revolsys.swing.map.layer.record.style.MarkerStyle) BufferedImage(java.awt.image.BufferedImage) BoundingBoxRecordLayer(com.revolsys.swing.map.layer.record.BoundingBoxRecordLayer) ImageMarker(com.revolsys.swing.map.layer.record.style.marker.ImageMarker)

Example 2 with MarkerStyle

use of com.revolsys.swing.map.layer.record.style.MarkerStyle in project com.revolsys.open by revolsys.

the class EditRecordGeometryOverlay method paintComponent.

@Override
public void paintComponent(final Viewport2D viewport, final Graphics2D graphics) {
    final GeometryFactory geometryFactory2dFloating = getViewportGeometryFactory2d();
    graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    if (isOverlayAction(ACTION_MOVE_GEOMETRY) && this.moveGeometryStart != null) {
        try (BaseCloseable transformCloseable = viewport.setUseModelCoordinates(graphics, true)) {
            for (final CloseLocation location : this.moveGeometryLocations) {
                Geometry geometry = location.getGeometry();
                final GeometryFactory geometryFactory = location.getGeometryFactory();
                final Point from = this.moveGeometryStart.convertGeometry(geometryFactory);
                final Point to = this.moveGeometryEnd.convertGeometry(geometryFactory);
                final double deltaX = to.getX() - from.getX();
                final double deltaY = to.getY() - from.getY();
                geometry = geometry.edit(editor -> editor.move(deltaX, deltaY));
                GEOMETRY_RENDERER.paintSelected(viewport, graphics, geometryFactory2dFloating, geometry);
                GEOMETRY_VERTEX_RENDERER.paintSelected(viewport, graphics, geometryFactory2dFloating, geometry);
            }
        }
    } else if (this.addGeometryEditor != null) {
        try (BaseCloseable transformCloseable = viewport.setUseModelCoordinates(graphics, true)) {
            graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            final Geometry addGeometry = this.addGeometryEditor.getCurrentGeometry();
            GEOMETRY_RENDERER.paintSelected(viewport, graphics, geometryFactory2dFloating, addGeometry);
            GEOMETRY_VERTEX_RENDERER.paintSelected(viewport, graphics, geometryFactory2dFloating, addGeometry);
        }
    }
    if (this.moveGeometryStart == null) {
        final List<CloseLocation> mouseOverLocations = getMouseOverLocations();
        try (BaseCloseable transformCloseable = viewport.setUseModelCoordinates(graphics, true)) {
            for (final CloseLocation location : mouseOverLocations) {
                final Geometry geometry = location.getGeometry();
                GEOMETRY_RENDERER.paintSelected(viewport, graphics, geometryFactory2dFloating, geometry);
            }
        }
        for (final CloseLocation location : mouseOverLocations) {
            final Geometry geometry = location.getGeometry();
            GEOMETRY_VERTEX_RENDERER.paintSelected(viewport, graphics, geometryFactory2dFloating, geometry);
            if (!isOverlayAction(ACTION_MOVE_GEOMETRY) && !this.addGeometryEditVerticesStart && !this.editGeometryVerticesStart) {
                final Vertex vertex = location.getVertex();
                if (vertex == null) {
                    final MarkerStyle style = MarkerStyle.marker("xLine", 9, WebColors.Blue, 3, WebColors.Blue);
                    final double orientation = location.getSegment().getOrientaton();
                    final Point pointOnLine = location.getViewportPoint();
                    MarkerStyleRenderer.renderMarker(viewport, graphics, pointOnLine, style, orientation);
                } else {
                    GEOMETRY_CLOSE_VERTEX_RENDERER.paintSelected(viewport, graphics, geometryFactory2dFloating, vertex);
                }
            }
        }
    }
    drawXorGeometry(graphics);
}
Also used : CloseLocation(com.revolsys.swing.map.overlay.CloseLocation) Geometry(com.revolsys.geometry.model.Geometry) LineSegment(com.revolsys.geometry.model.segment.LineSegment) Arrays(java.util.Arrays) Icons(com.revolsys.swing.Icons) ElevationModelLayer(com.revolsys.swing.map.layer.elevation.ElevationModelLayer) Point2D(java.awt.geom.Point2D) FieldDefinition(com.revolsys.record.schema.FieldDefinition) CloseLocation(com.revolsys.swing.map.overlay.CloseLocation) SwingUtil(com.revolsys.swing.SwingUtil) Cursor(java.awt.Cursor) RenderingHints(java.awt.RenderingHints) VertexStyleRenderer(com.revolsys.swing.map.overlay.VertexStyleRenderer) Layer(com.revolsys.swing.map.layer.Layer) SetVertexUndoEdit(com.revolsys.swing.map.overlay.record.geometryeditor.SetVertexUndoEdit) Viewport2D(com.revolsys.swing.map.Viewport2D) Map(java.util.Map) BaseCloseable(com.revolsys.io.BaseCloseable) InsertVertexUndoEdit(com.revolsys.swing.map.overlay.record.geometryeditor.InsertVertexUndoEdit) MouseListener(java.awt.event.MouseListener) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) UndoableEdit(javax.swing.undo.UndoableEdit) GeometryDataType(com.revolsys.geometry.model.GeometryDataType) ZoomOverlay(com.revolsys.swing.map.overlay.ZoomOverlay) Collection(java.util.Collection) Project(com.revolsys.swing.map.layer.Project) Set(java.util.Set) Maps(com.revolsys.collection.map.Maps) KeyEvent(java.awt.event.KeyEvent) DeleteVertexUndoEdit(com.revolsys.swing.map.overlay.record.geometryeditor.DeleteVertexUndoEdit) Logs(com.revolsys.logging.Logs) AddGeometryCompleteAction(com.revolsys.swing.map.overlay.AddGeometryCompleteAction) AppendVertexUndoEdit(com.revolsys.swing.map.overlay.record.geometryeditor.AppendVertexUndoEdit) MultipleUndo(com.revolsys.swing.undo.MultipleUndo) List(java.util.List) MarkerStyle(com.revolsys.swing.map.layer.record.style.MarkerStyle) PropertyChangeListener(java.beans.PropertyChangeListener) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) AbstractUndoableEdit(com.revolsys.swing.undo.AbstractUndoableEdit) GeometryEditor(com.revolsys.geometry.model.editor.GeometryEditor) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) Toolkit(java.awt.Toolkit) Point(com.revolsys.geometry.model.Point) AbstractLayer(com.revolsys.swing.map.layer.AbstractLayer) InputEvent(java.awt.event.InputEvent) ActionListener(java.awt.event.ActionListener) LineString(com.revolsys.geometry.model.LineString) RecordDefinition(com.revolsys.record.schema.RecordDefinition) LayerRecordMenu(com.revolsys.swing.map.layer.record.LayerRecordMenu) ArrayList(java.util.ArrayList) WebColors(com.revolsys.awt.WebColors) Graphics2D(java.awt.Graphics2D) Vertex(com.revolsys.geometry.model.vertex.Vertex) PropertyChangeEvent(java.beans.PropertyChangeEvent) LinkedHashSet(java.util.LinkedHashSet) MapPanel(com.revolsys.swing.map.MapPanel) MoveGeometryUndoEdit(com.revolsys.swing.map.overlay.record.geometryeditor.MoveGeometryUndoEdit) JOptionPane(javax.swing.JOptionPane) ActionEvent(java.awt.event.ActionEvent) DataTypes(com.revolsys.datatype.DataTypes) MouseEvent(java.awt.event.MouseEvent) MarkerStyleRenderer(com.revolsys.swing.map.layer.record.renderer.MarkerStyleRenderer) TreeMap(java.util.TreeMap) MouseMotionListener(java.awt.event.MouseMotionListener) AbstractOverlay(com.revolsys.swing.map.overlay.AbstractOverlay) LayerGroup(com.revolsys.swing.map.layer.LayerGroup) DataType(com.revolsys.datatype.DataType) Geometry(com.revolsys.geometry.model.Geometry) Collections(java.util.Collections) BoundingBox(com.revolsys.geometry.model.BoundingBox) Vertex(com.revolsys.geometry.model.vertex.Vertex) BaseCloseable(com.revolsys.io.BaseCloseable) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) Point(com.revolsys.geometry.model.Point) MarkerStyle(com.revolsys.swing.map.layer.record.style.MarkerStyle)

Example 3 with MarkerStyle

use of com.revolsys.swing.map.layer.record.style.MarkerStyle in project com.revolsys.open by revolsys.

the class MarkerStyleRenderer method renderMarkers.

public static void renderMarkers(final Viewport2D viewport, final Graphics2D graphics, LineString line, final MarkerStyle styleFirst, final MarkerStyle styleLast, final MarkerStyle styleVertex) {
    if (line != null) {
        final GeometryFactory geometryFactory = viewport.getGeometryFactory2dFloating();
        line = line.convertGeometry(geometryFactory);
        for (final Vertex vertex : line.vertices()) {
            MarkerStyle style;
            if (vertex.isFrom()) {
                style = styleFirst;
            } else if (vertex.isTo()) {
                style = styleLast;
            } else {
                style = styleVertex;
            }
            final double orientation = vertex.getOrientaton();
            renderMarker(viewport, graphics, vertex, style, orientation);
        }
    }
}
Also used : Vertex(com.revolsys.geometry.model.vertex.Vertex) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) MarkerStyle(com.revolsys.swing.map.layer.record.style.MarkerStyle)

Example 4 with MarkerStyle

use of com.revolsys.swing.map.layer.record.style.MarkerStyle in project com.revolsys.open by revolsys.

the class GeoNamesBoundingBoxLayerWorker method newLayer.

public static BoundingBoxRecordLayer newLayer(final Map<String, ? extends Object> config) {
    final GeometryFactory wgs84 = GeometryFactory.floating3d(4326);
    final BoundingBoxRecordLayer layer = new BoundingBoxRecordLayer("geoname", "Geo Names", GeoNamesBoundingBoxLayerWorker.class, wgs84);
    final BufferedImage image = Icons.getImage("world");
    final ImageMarker marker = new ImageMarker(image);
    final MarkerStyle style = new MarkerStyle();
    style.setMarker(marker);
    layer.setRenderer(new MarkerStyleRenderer(layer, style));
    layer.setProperties(config);
    return layer;
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) MarkerStyleRenderer(com.revolsys.swing.map.layer.record.renderer.MarkerStyleRenderer) MarkerStyle(com.revolsys.swing.map.layer.record.style.MarkerStyle) BufferedImage(java.awt.image.BufferedImage) BoundingBoxRecordLayer(com.revolsys.swing.map.layer.record.BoundingBoxRecordLayer) ImageMarker(com.revolsys.swing.map.layer.record.style.marker.ImageMarker)

Example 5 with MarkerStyle

use of com.revolsys.swing.map.layer.record.style.MarkerStyle in project com.revolsys.open by revolsys.

the class ArcGisRestServerRecordLayer method newSimpleMarkerRenderer.

private AbstractRecordLayerRenderer newSimpleMarkerRenderer(final MapEx symbol) {
    String markerName = symbol.getString("style", "esriSMSCirlce");
    markerName = markerName.replace("esriSMS", "").toLowerCase();
    final double markerSize = symbol.getDouble("size", 10);
    final Color markerFill = getColor(symbol);
    Color markerColor = new Color(0, 0, 0, 0);
    final MapEx outline = symbol.getValue("outline");
    double lineWidth = 0;
    if (outline != null) {
        markerColor = getColor(outline);
        lineWidth = outline.getDouble("width", lineWidth);
    }
    final MarkerStyle markerStyle = MarkerStyle.marker(markerName, markerSize, markerColor, lineWidth, markerFill);
    return new MarkerStyleRenderer(this, markerStyle);
}
Also used : MapEx(com.revolsys.collection.map.MapEx) Color(java.awt.Color) MarkerStyleRenderer(com.revolsys.swing.map.layer.record.renderer.MarkerStyleRenderer) MarkerStyle(com.revolsys.swing.map.layer.record.style.MarkerStyle)

Aggregations

MarkerStyle (com.revolsys.swing.map.layer.record.style.MarkerStyle)7 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)4 MarkerStyleRenderer (com.revolsys.swing.map.layer.record.renderer.MarkerStyleRenderer)4 Vertex (com.revolsys.geometry.model.vertex.Vertex)2 BoundingBoxRecordLayer (com.revolsys.swing.map.layer.record.BoundingBoxRecordLayer)2 ImageMarker (com.revolsys.swing.map.layer.record.style.marker.ImageMarker)2 WebColors (com.revolsys.awt.WebColors)1 MapEx (com.revolsys.collection.map.MapEx)1 Maps (com.revolsys.collection.map.Maps)1 DataType (com.revolsys.datatype.DataType)1 DataTypes (com.revolsys.datatype.DataTypes)1 BoundingBox (com.revolsys.geometry.model.BoundingBox)1 Geometry (com.revolsys.geometry.model.Geometry)1 GeometryDataType (com.revolsys.geometry.model.GeometryDataType)1 LineString (com.revolsys.geometry.model.LineString)1 Point (com.revolsys.geometry.model.Point)1 GeometryEditor (com.revolsys.geometry.model.editor.GeometryEditor)1 LineSegment (com.revolsys.geometry.model.segment.LineSegment)1 BaseCloseable (com.revolsys.io.BaseCloseable)1 Logs (com.revolsys.logging.Logs)1