mil.nga.geopackage.style.Color Java Examples
The following examples show how to use
mil.nga.geopackage.style.Color.
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: StyleUtils.java From geopackage-android-map with MIT License | 6 votes |
/** * Set the style into the polygon options * * @param polygonOptions polygon options * @param style style row * @param density display density: {@link android.util.DisplayMetrics#density} * @return true if style was set into the polygon options */ public static boolean setStyle(PolygonOptions polygonOptions, StyleRow style, float density) { if (style != null) { Color color = style.getColorOrDefault(); polygonOptions.strokeColor(color.getColorWithAlpha()); double width = style.getWidthOrDefault(); polygonOptions.strokeWidth((float) width * density); Color fillColor = style.getFillColor(); if (fillColor != null) { polygonOptions.fillColor(fillColor.getColorWithAlpha()); } } return style != null; }
Example #2
Source File: StyleUtils.java From geopackage-android-map with MIT License | 5 votes |
/** * Set the style into the marker options * * @param markerOptions marker options * @param style style row * @return true if style was set into the marker options */ public static boolean setStyle(MarkerOptions markerOptions, StyleRow style) { boolean styleSet = false; if (style != null) { Color color = style.getColorOrDefault(); float hue = color.getHue(); markerOptions.icon(BitmapDescriptorFactory.defaultMarker(hue)); styleSet = true; } return styleSet; }
Example #3
Source File: StyleRow.java From geopackage-android with MIT License | 5 votes |
/** * Set the color * * @param color color */ public void setColor(Color color) { String hex = null; Double opacity = null; if (color != null) { hex = color.getColorHexShorthand(); opacity = new Double(color.getOpacity()); } setColor(hex); setOpacity(opacity); }
Example #4
Source File: StyleRow.java From geopackage-android with MIT License | 5 votes |
/** * Set the color * * @param color color */ public void setFillColor(Color color) { String hex = null; Double opacity = null; if (color != null) { hex = color.getColorHexShorthand(); opacity = new Double(color.getOpacity()); } setFillColor(hex); setFillOpacity(opacity); }
Example #5
Source File: StyleRow.java From geopackage-java with MIT License | 5 votes |
/** * Set the color * * @param color * color */ public void setColor(Color color) { String hex = null; Double opacity = null; if (color != null) { hex = color.getColorHexShorthand(); opacity = new Double(color.getOpacity()); } setColor(hex); setOpacity(opacity); }
Example #6
Source File: StyleRow.java From geopackage-java with MIT License | 5 votes |
/** * Set the color * * @param color * color */ public void setFillColor(Color color) { String hex = null; Double opacity = null; if (color != null) { hex = color.getColorHexShorthand(); opacity = new Double(color.getOpacity()); } setFillColor(hex); setFillOpacity(opacity); }
Example #7
Source File: FeatureTiles.java From geopackage-android with MIT License | 4 votes |
/** * Get the style paint from cache, or create and cache it * * @param style style row * @param drawType draw type * @return paint */ private Paint getStylePaint(StyleRow style, FeatureDrawType drawType) { Paint paint = featurePaintCache.getPaint(style, drawType); if (paint == null) { Color color = null; Style paintStyle = null; Float strokeWidth = null; switch (drawType) { case CIRCLE: color = style.getColorOrDefault(); paintStyle = Style.FILL; break; case STROKE: color = style.getColorOrDefault(); paintStyle = Style.STROKE; strokeWidth = this.density * (float) style.getWidthOrDefault(); break; case FILL: color = style.getFillColor(); paintStyle = Style.FILL; strokeWidth = this.density * (float) style.getWidthOrDefault(); break; default: throw new GeoPackageException("Unsupported Draw Type: " + drawType); } Paint stylePaint = new Paint(); stylePaint.setAntiAlias(true); stylePaint.setStyle(paintStyle); stylePaint.setColor(color.getColorWithAlpha()); if (strokeWidth != null) { stylePaint.setStrokeWidth(strokeWidth); } synchronized (featurePaintCache) { paint = featurePaintCache.getPaint(style, drawType); if (paint == null) { featurePaintCache.setPaint(style, drawType, stylePaint); paint = stylePaint; } } } return paint; }
Example #8
Source File: GeoPackageExample.java From geopackage-android with MIT License | 4 votes |
private static void createFeatureStyleExtension(GeoPackage geoPackage) throws IOException, NameNotFoundException { List<StyleRow> styles = new ArrayList<>(); StyleRow style1 = new StyleRow(); style1.setName("Green"); style1.setDescription("Green Style"); style1.setColor(ColorConstants.GREEN); style1.setWidth(2.0); styles.add(style1); StyleRow style2 = new StyleRow(); style2.setName("Blue with Red Fill"); style2.setDescription("Blue with Red Fill Style"); style2.setColor(new Color(ColorConstants.BLUE)); style2.setFillColor(new Color(255, 0, 0, .4f)); styles.add(style2); StyleRow style3 = new StyleRow(); style3.setName("Orange"); style3.setDescription("Orange Style"); style3.setColor(new Color(0xFFA500)); style3.setWidth(6.5); styles.add(style3); StyleRow style4 = new StyleRow(); style4.setName("Violet with Yellow Fill"); style4.setDescription("Violet with Yellow Fill Style"); style4.setColor(new Color(138, 43, 226)); style4.setWidth(4.1); style4.setFillColor(new Color(new float[]{61, .89f, .72f}, .3f)); styles.add(style4); List<IconRow> icons = new ArrayList<>(); TestUtils.copyAssetFileToInternalStorage(geoPackage.getContext(), TestUtils.getTestContext(geoPackage.getContext()), "building.png"); IconRow icon1 = new IconRow(); icon1.setName("Building"); icon1.setDescription("Building Icon"); icon1.setData(BitmapFactory.decodeFile( TestUtils.getAssetFileInternalStorageLocation(geoPackage.getContext(), "building.png")), Bitmap.CompressFormat.PNG); icon1.setContentType("image/png"); icon1.setWidth(32.0); icon1.setAnchorU(0.5); icon1.setAnchorV(1.0); icons.add(icon1); TestUtils.copyAssetFileToInternalStorage(geoPackage.getContext(), TestUtils.getTestContext(geoPackage.getContext()), "college.png"); IconRow icon2 = new IconRow(); icon2.setName("College"); icon2.setDescription("College Icon"); icon2.setData(BitmapFactory.decodeFile( TestUtils.getAssetFileInternalStorageLocation(geoPackage.getContext(), "college.png")), Bitmap.CompressFormat.PNG); icon2.setContentType("image/png"); icon2.setWidth(32.0); icon2.setHeight(44.0); icons.add(icon2); TestUtils.copyAssetFileToInternalStorage(geoPackage.getContext(), TestUtils.getTestContext(geoPackage.getContext()), "tractor.png"); IconRow icon3 = new IconRow(); icon3.setName("Tractor"); icon3.setDescription("Tractor Icon"); icon3.setData(BitmapFactory.decodeFile( TestUtils.getAssetFileInternalStorageLocation(geoPackage.getContext(), "tractor.png")), Bitmap.CompressFormat.PNG); icon3.setContentType("image/png"); icon3.setAnchorV(1.0); icons.add(icon3); createFeatureStylesGeometry1(geoPackage, styles, icons); createFeatureStylesGeometry2(geoPackage, styles, icons); }
Example #9
Source File: GeoPackageExample.java From geopackage-java with MIT License | 4 votes |
private static void createFeatureStyleExtension(GeoPackage geoPackage) throws IOException { List<StyleRow> styles = new ArrayList<>(); StyleRow style1 = new StyleRow(); style1.setName("Green"); style1.setDescription("Green Style"); style1.setColor(ColorConstants.GREEN); style1.setWidth(2.0); styles.add(style1); StyleRow style2 = new StyleRow(); style2.setName("Blue with Red Fill"); style2.setDescription("Blue with Red Fill Style"); style2.setColor(new Color(ColorConstants.BLUE)); style2.setFillColor(new Color(255, 0, 0, .4f)); styles.add(style2); StyleRow style3 = new StyleRow(); style3.setName("Orange"); style3.setDescription("Orange Style"); style3.setColor(new Color(0xFFA500)); style3.setWidth(6.5); styles.add(style3); StyleRow style4 = new StyleRow(); style4.setName("Violet with Yellow Fill"); style4.setDescription("Violet with Yellow Fill Style"); style4.setColor(new Color(138, 43, 226)); style4.setWidth(4.1); style4.setFillColor(new Color(new float[] { 61, .89f, .72f }, .3f)); styles.add(style4); List<IconRow> icons = new ArrayList<>(); IconRow icon1 = new IconRow(); icon1.setName("Building"); icon1.setDescription("Building Icon"); icon1.setData(GeoPackageIOUtils .fileBytes(TestUtils.getTestFile("building.png"))); icon1.setContentType("image/png"); icon1.setWidth(32.0); icon1.setAnchorU(0.5); icon1.setAnchorV(1.0); icons.add(icon1); IconRow icon2 = new IconRow(); icon2.setName("College"); icon2.setDescription("College Icon"); icon2.setData(GeoPackageIOUtils .fileBytes(TestUtils.getTestFile("college.png"))); icon2.setContentType("image/png"); icon2.setWidth(32.0); icon2.setHeight(44.0); icons.add(icon2); IconRow icon3 = new IconRow(); icon3.setName("Tractor"); icon3.setDescription("Tractor Icon"); icon3.setData(GeoPackageIOUtils .fileBytes(TestUtils.getTestFile("tractor.png"))); icon3.setContentType("image/png"); icon3.setAnchorV(1.0); icons.add(icon3); createFeatureStylesGeometry1(geoPackage, styles, icons); createFeatureStylesGeometry2(geoPackage, styles, icons); }
Example #10
Source File: StyleUtils.java From geopackage-android-map with MIT License | 3 votes |
/** * Set the style into the polyline options * * @param polylineOptions polyline options * @param style style row * @param density display density: {@link android.util.DisplayMetrics#density} * @return true if style was set into the polyline options */ public static boolean setStyle(PolylineOptions polylineOptions, StyleRow style, float density) { if (style != null) { Color color = style.getColorOrDefault(); polylineOptions.color(color.getColorWithAlpha()); double width = style.getWidthOrDefault(); polylineOptions.width((float) width * density); } return style != null; }
Example #11
Source File: StyleRow.java From geopackage-android with MIT License | 2 votes |
/** * Get the style color * * @return color */ public Color getColor() { return createColor(getHexColor(), getOpacity()); }
Example #12
Source File: StyleRow.java From geopackage-android with MIT License | 2 votes |
/** * Get the style fill color * * @return fill color */ public Color getFillColor() { return createColor(getFillHexColor(), getFillOpacity()); }
Example #13
Source File: StyleRow.java From geopackage-java with MIT License | 2 votes |
/** * Get the style color * * @return color */ public Color getColor() { return createColor(getHexColor(), getOpacity()); }
Example #14
Source File: StyleRow.java From geopackage-java with MIT License | 2 votes |
/** * Get the style fill color * * @return fill color */ public Color getFillColor() { return createColor(getFillHexColor(), getFillOpacity()); }