mil.nga.geopackage.extension.style.FeatureStyle Java Examples

The following examples show how to use mil.nga.geopackage.extension.style.FeatureStyle. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultFeatureTiles.java    From geopackage-java with MIT License 6 votes vote down vote up
/**
 * Draw the line
 * 
 * @param graphics
 *            feature tile graphics
 * @param line
 *            line path
 * @param featureStyle
 *            feature style
 * @return true if drawn
 */
private boolean drawLine(FeatureTileGraphics graphics, Path2D line,
		FeatureStyle featureStyle) {

	Graphics2D lineGraphics = graphics.getLineGraphics();

	Paint paint = getLinePaint(featureStyle);
	lineGraphics.setColor(paint.getColor());
	lineGraphics.setStroke(paint.getStroke());

	boolean drawn = lineGraphics
			.hit(new java.awt.Rectangle(tileWidth, tileHeight), line, true);
	if (drawn) {
		lineGraphics.draw(line);
	}

	return drawn;
}
 
Example #2
Source File: DefaultFeatureTiles.java    From geopackage-android with MIT License 6 votes vote down vote up
/**
 * Draw the path on the canvas
 *
 * @param canvas       canvas
 * @param path         path
 * @param featureStyle feature style
 */
private boolean drawPolygonPath(FeatureTileCanvas canvas, Path path, FeatureStyle featureStyle) {

    Canvas polygonCanvas = canvas.getPolygonCanvas();

    Paint fillPaint = getPolygonFillPaint(featureStyle);
    if (fillPaint != null) {
        path.setFillType(Path.FillType.EVEN_ODD);
        polygonCanvas.drawPath(path, fillPaint);
    }

    Paint pathPaint = getPolygonPaint(featureStyle);
    polygonCanvas.drawPath(path, pathPaint);

    return true;
}
 
Example #3
Source File: DefaultFeatureTiles.java    From geopackage-java with MIT License 6 votes vote down vote up
/**
 * Draw the polygon
 * 
 * @param graphics
 *            feature tile graphics
 * @param polygon
 *            polygon area
 * @param featureStyle
 *            feature style
 * @return true if drawn
 */
private boolean drawPolygon(FeatureTileGraphics graphics, Area polygon,
		FeatureStyle featureStyle) {

	Graphics2D polygonGraphics = graphics.getPolygonGraphics();

	Paint fillPaint = getPolygonFillPaint(featureStyle);
	if (fillPaint != null) {

		polygonGraphics.setColor(fillPaint.getColor());
		polygonGraphics.fill(polygon);

	}

	Paint paint = getPolygonPaint(featureStyle);
	polygonGraphics.setColor(paint.getColor());
	polygonGraphics.setStroke(paint.getStroke());

	boolean drawn = polygonGraphics.hit(
			new java.awt.Rectangle(tileWidth, tileHeight), polygon, true);
	if (drawn) {
		polygonGraphics.draw(polygon);
	}

	return drawn;
}
 
Example #4
Source File: FeatureTiles.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * Get the point paint for the feature style, or return the default paint
 *
 * @param featureStyle
 *            feature style
 * @return paint
 */
protected Paint getPointPaint(FeatureStyle featureStyle) {

	Paint paint = getFeatureStylePaint(featureStyle,
			FeatureDrawType.CIRCLE);

	if (paint == null) {
		paint = pointPaint;
	}

	return paint;
}
 
Example #5
Source File: FeatureTiles.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * Get the feature style for the feature row and geometry type
 *
 * @param featureRow
 *            feature row
 * @param geometryType
 *            geometry type
 * @return feature style
 */
protected FeatureStyle getFeatureStyle(FeatureRow featureRow,
		GeometryType geometryType) {
	FeatureStyle featureStyle = null;
	if (featureTableStyles != null) {
		featureStyle = featureTableStyles.getFeatureStyle(featureRow,
				geometryType);
	}
	return featureStyle;
}
 
Example #6
Source File: FeatureTiles.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * Get the feature style for the feature row and geometry type
 *
 * @param featureRow
 *            feature row
 * @return feature style
 */
protected FeatureStyle getFeatureStyle(FeatureRow featureRow) {
	FeatureStyle featureStyle = null;
	if (featureTableStyles != null) {
		featureStyle = featureTableStyles.getFeatureStyle(featureRow);
	}
	return featureStyle;
}
 
Example #7
Source File: StyleUtils.java    From geopackage-android-map with MIT License 5 votes vote down vote up
/**
 * Create new polyline options populated with the feature style
 *
 * @param featureStyle feature style
 * @param density      display density: {@link android.util.DisplayMetrics#density}
 * @return polyline options populated with the feature style
 */
public static PolylineOptions createPolylineOptions(FeatureStyle featureStyle, float density) {

    PolylineOptions polylineOptions = new PolylineOptions();
    setFeatureStyle(polylineOptions, featureStyle, density);

    return polylineOptions;
}
 
Example #8
Source File: FeatureTiles.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * Get the line paint for the feature style, or return the default paint
 *
 * @param featureStyle
 *            feature style
 * @return paint
 */
protected Paint getLinePaint(FeatureStyle featureStyle) {

	Paint paint = getFeatureStylePaint(featureStyle,
			FeatureDrawType.STROKE);

	if (paint == null) {
		paint = linePaint;
	}

	return paint;
}
 
Example #9
Source File: StyleUtils.java    From geopackage-android-map with MIT License 5 votes vote down vote up
/**
 * Create new polygon options populated with the feature style
 *
 * @param featureStyle feature style
 * @param density      display density: {@link android.util.DisplayMetrics#density}
 * @return polygon options populated with the feature style
 */
public static PolygonOptions createPolygonOptions(FeatureStyle featureStyle, float density) {

    PolygonOptions polygonOptions = new PolygonOptions();
    setFeatureStyle(polygonOptions, featureStyle, density);

    return polygonOptions;
}
 
Example #10
Source File: FeatureTiles.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * Get the polygon paint for the feature style, or return the default paint
 *
 * @param featureStyle feature style
 * @return paint
 */
protected Paint getPolygonPaint(FeatureStyle featureStyle) {

    Paint paint = getFeatureStylePaint(featureStyle, FeatureDrawType.STROKE);

    if (paint == null) {
        paint = polygonPaint;
    }

    return paint;
}
 
Example #11
Source File: FeatureTiles.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * Get the line paint for the feature style, or return the default paint
 *
 * @param featureStyle feature style
 * @return paint
 */
protected Paint getLinePaint(FeatureStyle featureStyle) {

    Paint paint = getFeatureStylePaint(featureStyle, FeatureDrawType.STROKE);

    if (paint == null) {
        paint = linePaint;
    }

    return paint;
}
 
Example #12
Source File: FeatureTiles.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * Get the point paint for the feature style, or return the default paint
 *
 * @param featureStyle feature style
 * @return paint
 */
protected Paint getPointPaint(FeatureStyle featureStyle) {

    Paint paint = getFeatureStylePaint(featureStyle, FeatureDrawType.CIRCLE);

    if (paint == null) {
        paint = pointPaint;
    }

    return paint;
}
 
Example #13
Source File: FeatureTiles.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * Get the feature style for the feature row and geometry type
 *
 * @param featureRow   feature row
 * @param geometryType geometry type
 * @return feature style
 */
protected FeatureStyle getFeatureStyle(FeatureRow featureRow, GeometryType geometryType) {
    FeatureStyle featureStyle = null;
    if (featureTableStyles != null) {
        featureStyle = featureTableStyles.getFeatureStyle(featureRow, geometryType);
    }
    return featureStyle;
}
 
Example #14
Source File: FeatureTiles.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * Get the feature style for the feature row and geometry type
 *
 * @param featureRow feature row
 * @return feature style
 */
protected FeatureStyle getFeatureStyle(FeatureRow featureRow) {
    FeatureStyle featureStyle = null;
    if (featureTableStyles != null) {
        featureStyle = featureTableStyles.getFeatureStyle(featureRow);
    }
    return featureStyle;
}
 
Example #15
Source File: FeatureTiles.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * Get the polygon paint for the feature style, or return the default paint
 *
 * @param featureStyle
 *            feature style
 * @return paint
 */
protected Paint getPolygonPaint(FeatureStyle featureStyle) {

	Paint paint = getFeatureStylePaint(featureStyle,
			FeatureDrawType.STROKE);

	if (paint == null) {
		paint = polygonPaint;
	}

	return paint;
}
 
Example #16
Source File: FeatureTiles.java    From geopackage-java with MIT License 4 votes vote down vote up
/**
 * Get the feature style paint from cache, or create and cache it
 *
 * @param featureStyle
 *            feature style
 * @param drawType
 *            draw type
 * @return feature style paint
 */
private Paint getFeatureStylePaint(FeatureStyle featureStyle,
		FeatureDrawType drawType) {

	Paint paint = null;

	if (featureStyle != null) {

		StyleRow style = featureStyle.getStyle();

		if (style != null && style.hasColor()) {

			paint = getStylePaint(style, drawType);

		}
	}

	return paint;
}
 
Example #17
Source File: FeatureTiles.java    From geopackage-android with MIT License 4 votes vote down vote up
/**
 * Get the feature style paint from cache, or create and cache it
 *
 * @param featureStyle feature style
 * @param drawType     draw type
 * @return feature style paint
 */
private Paint getFeatureStylePaint(FeatureStyle featureStyle, FeatureDrawType drawType) {

    Paint paint = null;

    if (featureStyle != null) {

        StyleRow style = featureStyle.getStyle();

        if (style != null && style.hasColor()) {

            paint = getStylePaint(style, drawType);

        }
    }

    return paint;
}
 
Example #18
Source File: DefaultFeatureTiles.java    From geopackage-android with MIT License 4 votes vote down vote up
/**
 * Draw the geometry on the canvas
 *
 * @param simplifyTolerance simplify tolerance in meters
 * @param boundingBox       bounding box
 * @param transform         projection transform
 * @param canvas            feature tile canvas
 * @param featureRow        feature row
 * @param geometry          feature geometry
 * @return true if drawn
 */
private boolean drawShape(double simplifyTolerance, BoundingBox boundingBox, ProjectionTransform transform, FeatureTileCanvas canvas, FeatureRow featureRow, Geometry geometry) {

    boolean drawn = false;

    GeometryType geometryType = geometry.getGeometryType();
    FeatureStyle featureStyle = getFeatureStyle(featureRow, geometryType);

    switch (geometryType) {

        case POINT:
            Point point = (Point) geometry;
            drawn = drawPoint(boundingBox, transform, canvas, point, featureStyle);
            break;
        case LINESTRING:
        case CIRCULARSTRING:
            LineString lineString = (LineString) geometry;
            Path linePath = new Path();
            addLineString(simplifyTolerance, boundingBox, transform, linePath, lineString);
            drawn = drawLinePath(canvas, linePath, featureStyle);
            break;
        case POLYGON:
        case TRIANGLE:
            Polygon polygon = (Polygon) geometry;
            Path polygonPath = new Path();
            addPolygon(simplifyTolerance, boundingBox, transform, polygonPath, polygon);
            drawn = drawPolygonPath(canvas, polygonPath, featureStyle);
            break;
        case MULTIPOINT:
            MultiPoint multiPoint = (MultiPoint) geometry;
            for (Point pointFromMulti : multiPoint.getPoints()) {
                drawn = drawPoint(boundingBox, transform, canvas, pointFromMulti, featureStyle) || drawn;
            }
            break;
        case MULTILINESTRING:
            MultiLineString multiLineString = (MultiLineString) geometry;
            Path multiLinePath = new Path();
            for (LineString lineStringFromMulti : multiLineString.getLineStrings()) {
                addLineString(simplifyTolerance, boundingBox, transform, multiLinePath, lineStringFromMulti);
            }
            drawn = drawLinePath(canvas, multiLinePath, featureStyle);
            break;
        case MULTIPOLYGON:
            MultiPolygon multiPolygon = (MultiPolygon) geometry;
            Path multiPolygonPath = new Path();
            for (Polygon polygonFromMulti : multiPolygon.getPolygons()) {
                addPolygon(simplifyTolerance, boundingBox, transform, multiPolygonPath, polygonFromMulti);
            }
            drawn = drawPolygonPath(canvas, multiPolygonPath, featureStyle);
            break;
        case COMPOUNDCURVE:
            CompoundCurve compoundCurve = (CompoundCurve) geometry;
            Path compoundCurvePath = new Path();
            for (LineString lineStringFromCompoundCurve : compoundCurve.getLineStrings()) {
                addLineString(simplifyTolerance, boundingBox, transform, compoundCurvePath, lineStringFromCompoundCurve);
            }
            drawn = drawLinePath(canvas, compoundCurvePath, featureStyle);
            break;
        case POLYHEDRALSURFACE:
        case TIN:
            PolyhedralSurface polyhedralSurface = (PolyhedralSurface) geometry;
            Path polyhedralSurfacePath = new Path();
            for (Polygon polygonFromPolyhedralSurface : polyhedralSurface.getPolygons()) {
                addPolygon(simplifyTolerance, boundingBox, transform, polyhedralSurfacePath, polygonFromPolyhedralSurface);
            }
            drawn = drawPolygonPath(canvas, polyhedralSurfacePath, featureStyle);
            break;
        case GEOMETRYCOLLECTION:
            @SuppressWarnings("unchecked")
            GeometryCollection<Geometry> geometryCollection = (GeometryCollection) geometry;
            List<Geometry> geometries = geometryCollection.getGeometries();
            for (Geometry geometryFromCollection : geometries) {
                drawn = drawShape(simplifyTolerance, boundingBox, transform, canvas, featureRow, geometryFromCollection) || drawn;
            }
            break;
        default:
            throw new GeoPackageException("Unsupported Geometry Type: "
                    + geometry.getGeometryType().getName());
    }

    return drawn;
}
 
Example #19
Source File: StyleUtils.java    From geopackage-android-map with MIT License 4 votes vote down vote up
/**
 * Set the feature style (icon or style) into the marker options
 *
 * @param markerOptions marker options
 * @param featureStyle  feature style
 * @param density       display density: {@link android.util.DisplayMetrics#density}
 * @param iconCache     icon cache
 * @return true if icon or style was set into the marker options
 */
public static boolean setFeatureStyle(MarkerOptions markerOptions, FeatureStyle featureStyle, float density, IconCache iconCache) {

    boolean featureStyleSet = false;

    if (featureStyle != null) {

        featureStyleSet = setIcon(markerOptions, featureStyle.getIcon(), density, iconCache);

        if (!featureStyleSet) {

            featureStyleSet = setStyle(markerOptions, featureStyle.getStyle());

        }

    }

    return featureStyleSet;
}
 
Example #20
Source File: DefaultFeatureTiles.java    From geopackage-android with MIT License 3 votes vote down vote up
/**
 * Draw the line path on the canvas
 *
 * @param canvas       canvas
 * @param path         path
 * @param featureStyle feature style
 * @return true if drawn
 */
private boolean drawLinePath(FeatureTileCanvas canvas, Path path, FeatureStyle featureStyle) {

    Canvas lineCanvas = canvas.getLineCanvas();

    Paint pathPaint = getLinePaint(featureStyle);
    lineCanvas.drawPath(path, pathPaint);

    return true;
}
 
Example #21
Source File: FeatureTiles.java    From geopackage-java with MIT License 3 votes vote down vote up
/**
 * Get the polygon fill paint for the feature style, or return the default
 * paint
 *
 * @param featureStyle
 *            feature style
 * @return paint
 */
protected Paint getPolygonFillPaint(FeatureStyle featureStyle) {

	Paint paint = null;

	boolean hasStyleColor = false;

	if (featureStyle != null) {

		StyleRow style = featureStyle.getStyle();

		if (style != null) {

			if (style.hasFillColor()) {
				paint = getStylePaint(style, FeatureDrawType.FILL);
			} else {
				hasStyleColor = style.hasColor();
			}

		}

	}

	if (paint == null && !hasStyleColor && fillPolygon) {
		paint = polygonFillPaint;
	}

	return paint;
}
 
Example #22
Source File: StyleUtils.java    From geopackage-android-map with MIT License 3 votes vote down vote up
/**
 * Create new marker options populated with the feature style (icon or style)
 *
 * @param featureStyle feature style
 * @param density      display density: {@link android.util.DisplayMetrics#density}
 * @param iconCache    icon cache
 * @return marker options populated with the feature style
 */
public static MarkerOptions createMarkerOptions(FeatureStyle featureStyle, float density, IconCache iconCache) {

    MarkerOptions markerOptions = new MarkerOptions();
    setFeatureStyle(markerOptions, featureStyle, density, iconCache);

    return markerOptions;
}
 
Example #23
Source File: StyleUtils.java    From geopackage-android-map with MIT License 3 votes vote down vote up
/**
 * Set the feature style into the polyline options
 *
 * @param polylineOptions polyline options
 * @param featureStyle    feature style
 * @param density         display density: {@link android.util.DisplayMetrics#density}
 * @return true if style was set into the polyline options
 */
public static boolean setFeatureStyle(PolylineOptions polylineOptions, FeatureStyle featureStyle, float density) {

    boolean featureStyleSet = false;

    if (featureStyle != null) {

        featureStyleSet = setStyle(polylineOptions, featureStyle.getStyle(), density);

    }

    return featureStyleSet;
}
 
Example #24
Source File: DefaultFeatureTiles.java    From geopackage-java with MIT License 3 votes vote down vote up
/**
 * Draw a Polygon
 * 
 * @param simplifyTolerance
 *            simplify tolerance in meters
 * @param boundingBox
 *            bounding box
 * @param transform
 *            projection transform
 * @param graphics
 *            feature tile graphics
 * @param polygon
 *            polygon
 * @param featureStyle
 *            feature style
 * @return true if drawn
 */
private boolean drawPolygon(double simplifyTolerance,
		BoundingBox boundingBox, ProjectionTransform transform,
		FeatureTileGraphics graphics, Polygon polygon,
		FeatureStyle featureStyle) {
	Area polygonArea = getArea(simplifyTolerance, boundingBox, transform,
			polygon);
	return drawPolygon(graphics, polygonArea, featureStyle);
}
 
Example #25
Source File: DefaultFeatureTiles.java    From geopackage-java with MIT License 3 votes vote down vote up
/**
 * Draw a LineString
 * 
 * @param simplifyTolerance
 *            simplify tolerance in meters
 * @param boundingBox
 *            bounding box
 * @param transform
 *            projection transform
 * @param graphics
 *            feature tile graphics
 * @param lineString
 *            line string
 * @param featureStyle
 *            feature style
 * @return true if drawn
 */
private boolean drawLineString(double simplifyTolerance,
		BoundingBox boundingBox, ProjectionTransform transform,
		FeatureTileGraphics graphics, LineString lineString,
		FeatureStyle featureStyle) {
	Path2D path = getPath(simplifyTolerance, boundingBox, transform,
			lineString);
	return drawLine(graphics, path, featureStyle);
}
 
Example #26
Source File: StyleUtils.java    From geopackage-android-map with MIT License 3 votes vote down vote up
/**
 * Set the feature style into the polygon options
 *
 * @param polygonOptions polygon options
 * @param featureStyle   feature style
 * @param density        display density: {@link android.util.DisplayMetrics#density}
 * @return true if style was set into the polygon options
 */
public static boolean setFeatureStyle(PolygonOptions polygonOptions, FeatureStyle featureStyle, float density) {

    boolean featureStyleSet = false;

    if (featureStyle != null) {

        featureStyleSet = setStyle(polygonOptions, featureStyle.getStyle(), density);

    }

    return featureStyleSet;
}
 
Example #27
Source File: FeatureTiles.java    From geopackage-android with MIT License 3 votes vote down vote up
/**
 * Get the polygon fill paint for the feature style, or return the default paint
 *
 * @param featureStyle feature style
 * @return paint
 */
protected Paint getPolygonFillPaint(FeatureStyle featureStyle) {

    Paint paint = null;

    boolean hasStyleColor = false;

    if (featureStyle != null) {

        StyleRow style = featureStyle.getStyle();

        if (style != null) {

            if (style.hasFillColor()) {
                paint = getStylePaint(style, FeatureDrawType.FILL);
            } else {
                hasStyleColor = style.hasColor();
            }

        }

    }

    if (paint == null && !hasStyleColor && fillPolygon) {
        paint = polygonFillPaint;
    }

    return paint;
}
 
Example #28
Source File: StyleCache.java    From geopackage-android-map with MIT License 2 votes vote down vote up
/**
 * Create new marker options populated with the feature style (icon or style)
 *
 * @param featureStyle feature style
 * @return marker options populated with the feature style
 */
public MarkerOptions createMarkerOptions(FeatureStyle featureStyle) {
    return StyleUtils.createMarkerOptions(featureStyle, density, iconCache);
}
 
Example #29
Source File: StyleCache.java    From geopackage-android-map with MIT License 2 votes vote down vote up
/**
 * Set the feature style (icon or style) into the marker options
 *
 * @param markerOptions marker options
 * @param featureStyle  feature style
 * @return true if icon or style was set into the marker options
 */
public boolean setFeatureStyle(MarkerOptions markerOptions, FeatureStyle featureStyle) {
    return StyleUtils.setFeatureStyle(markerOptions, featureStyle, density, iconCache);
}
 
Example #30
Source File: StyleCache.java    From geopackage-android-map with MIT License 2 votes vote down vote up
/**
 * Create new polyline options populated with the feature style
 *
 * @param featureStyle feature style
 * @return polyline options populated with the feature style
 */
public PolylineOptions createPolylineOptions(FeatureStyle featureStyle) {
    return StyleUtils.createPolylineOptions(featureStyle, density);
}