Search in sources :

Example 1 with GeometryStyle

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

the class GeometryStyleRenderer method newIcon.

@Override
public Icon newIcon() {
    final AbstractRecordLayer layer = getLayer();
    if (layer == null) {
        return ICON;
    } else {
        final GeometryStyle geometryStyle = getStyle();
        Shape shape = null;
        final DataType geometryDataType = layer.getGeometryType();
        if (DataTypes.POINT.equals(geometryDataType) || DataTypes.MULTI_POINT.equals(geometryDataType)) {
            return this.style.getMarker().newIcon(geometryStyle);
        } else if (DataTypes.LINE_STRING.equals(geometryDataType) || DataTypes.MULTI_LINE_STRING.equals(geometryDataType)) {
            shape = GeometryStylePreview.getLineShape(16);
        } else if (DataTypes.POLYGON.equals(geometryDataType) || DataTypes.MULTI_POLYGON.equals(geometryDataType)) {
            shape = getPolygonShape();
        } else {
            return ICON;
        }
        final BufferedImage image = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
        final Graphics2D graphics = image.createGraphics();
        graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        if (DataTypes.POLYGON.equals(geometryDataType) || DataTypes.MULTI_POLYGON.equals(geometryDataType)) {
            graphics.setPaint(geometryStyle.getPolygonFill());
            graphics.fill(shape);
        }
        final Color color = geometryStyle.getLineColor();
        graphics.setColor(color);
        graphics.draw(shape);
        graphics.dispose();
        return new ImageIcon(image);
    }
}
Also used : ImageIcon(javax.swing.ImageIcon) GeometryStyle(com.revolsys.swing.map.layer.record.style.GeometryStyle) Shape(java.awt.Shape) Color(java.awt.Color) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) DataType(com.revolsys.datatype.DataType) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D)

Example 2 with GeometryStyle

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

the class ArcGisRestServerRecordLayer method newSimpleLineStyle.

private GeometryStyle newSimpleLineStyle(final MapEx symbol) {
    final double lineWidth = symbol.getDouble("width", 1.0);
    final Color lineColor = getColor(symbol);
    final GeometryStyle style = GeometryStyle.line(lineColor, lineWidth);
    final String dashStyle = symbol.getString("style");
    if (LINE_STYLE_PATTERNS.containsKey(dashStyle)) {
        final List<Double> dashArray = LINE_STYLE_PATTERNS.get(dashStyle);
        if (dashArray == null) {
            style.setLineWidth(Quantities.getQuantity(0, CustomUnits.PIXEL));
        } else if (!dashArray.isEmpty()) {
            style.setLineDashArray(dashArray);
        }
    }
    return style;
}
Also used : GeometryStyle(com.revolsys.swing.map.layer.record.style.GeometryStyle) Color(java.awt.Color)

Example 3 with GeometryStyle

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

the class ArcGisRestServerRecordLayer method newSimpleFillRenderer.

private AbstractRecordLayerRenderer newSimpleFillRenderer(final MapEx symbol) {
    final MapEx outline = symbol.getValue("outline");
    final GeometryStyle style;
    if (outline == null) {
        style = new GeometryStyle();
        style.setLineWidth(Quantities.getQuantity(0, CustomUnits.PIXEL));
    } else {
        style = newSimpleLineStyle(outline);
    }
    final Color fillColor = getColor(symbol);
    style.setPolygonFill(fillColor);
    return new GeometryStyleRenderer(this, style);
}
Also used : GeometryStyleRenderer(com.revolsys.swing.map.layer.record.renderer.GeometryStyleRenderer) GeometryStyle(com.revolsys.swing.map.layer.record.style.GeometryStyle) MapEx(com.revolsys.collection.map.MapEx) Color(java.awt.Color)

Example 4 with GeometryStyle

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

the class GridLayerRenderer method newIcon.

public Icon newIcon() {
    final GeometryStyle geometryStyle = getGeometryStyle();
    final BufferedImage image = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
    final Graphics2D graphics = image.createGraphics();
    this.textStyle.drawTextIcon(graphics, 8);
    final Color color = geometryStyle.getLineColor();
    graphics.setColor(color);
    graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    final Shape shape = new Rectangle2D.Double(0, 0, 15, 15);
    graphics.draw(shape);
    graphics.dispose();
    return new ImageIcon(image);
}
Also used : ImageIcon(javax.swing.ImageIcon) GeometryStyle(com.revolsys.swing.map.layer.record.style.GeometryStyle) Shape(java.awt.Shape) Color(java.awt.Color) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D)

Aggregations

GeometryStyle (com.revolsys.swing.map.layer.record.style.GeometryStyle)4 Color (java.awt.Color)4 Graphics2D (java.awt.Graphics2D)2 Shape (java.awt.Shape)2 BufferedImage (java.awt.image.BufferedImage)2 ImageIcon (javax.swing.ImageIcon)2 MapEx (com.revolsys.collection.map.MapEx)1 DataType (com.revolsys.datatype.DataType)1 AbstractRecordLayer (com.revolsys.swing.map.layer.record.AbstractRecordLayer)1 GeometryStyleRenderer (com.revolsys.swing.map.layer.record.renderer.GeometryStyleRenderer)1