Java Code Examples for mil.nga.geopackage.extension.style.StyleRow#getWidthOrDefault()
The following examples show how to use
mil.nga.geopackage.extension.style.StyleRow#getWidthOrDefault() .
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: FeatureTiles.java From geopackage-android with MIT License | 4 votes |
/** * Call after making changes to the point icon, point radius, or paint stroke widths. * Determines the pixel overlap between tiles */ public void calculateDrawOverlap() { if (pointIcon != null) { heightOverlap = this.density * pointIcon.getHeight(); widthOverlap = this.density * pointIcon.getWidth(); } else { heightOverlap = this.density * pointRadius; widthOverlap = this.density * pointRadius; } float linePaintHalfStroke = this.density * lineStrokeWidth / 2.0f; heightOverlap = Math.max(heightOverlap, linePaintHalfStroke); widthOverlap = Math.max(widthOverlap, linePaintHalfStroke); float polygonPaintHalfStroke = this.density * polygonStrokeWidth / 2.0f; heightOverlap = Math.max(heightOverlap, polygonPaintHalfStroke); widthOverlap = Math.max(widthOverlap, polygonPaintHalfStroke); if (featureTableStyles != null && featureTableStyles.has()) { // Style Rows Set<Long> styleRowIds = new HashSet<>(); List<Long> tableStyleIds = featureTableStyles.getAllTableStyleIds(); if (tableStyleIds != null) { styleRowIds.addAll(tableStyleIds); } List<Long> styleIds = featureTableStyles.getAllStyleIds(); if (styleIds != null) { styleRowIds.addAll(styleIds); } StyleDao styleDao = featureTableStyles.getStyleDao(); for (long styleRowId : styleRowIds) { StyleRow styleRow = styleDao.getRow(styleDao.queryForIdRow(styleRowId)); float styleHalfWidth = this.density * (float) (styleRow.getWidthOrDefault() / 2.0f); widthOverlap = Math.max(widthOverlap, styleHalfWidth); heightOverlap = Math.max(heightOverlap, styleHalfWidth); } // Icon Rows Set<Long> iconRowIds = new HashSet<>(); List<Long> tableIconIds = featureTableStyles.getAllTableIconIds(); if (tableIconIds != null) { iconRowIds.addAll(tableIconIds); } List<Long> iconIds = featureTableStyles.getAllIconIds(); if (iconIds != null) { iconRowIds.addAll(iconIds); } IconDao iconDao = featureTableStyles.getIconDao(); for (long iconRowId : iconRowIds) { IconRow iconRow = iconDao.getRow(iconDao.queryForIdRow(iconRowId)); double[] iconDimensions = iconRow.getDerivedDimensions(); float iconWidth = this.density * (float) Math.ceil(iconDimensions[0]); float iconHeight = this.density * (float) Math.ceil(iconDimensions[1]); widthOverlap = Math.max(widthOverlap, iconWidth); heightOverlap = Math.max(heightOverlap, iconHeight); } } }
Example 3
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 4
Source File: FeatureTiles.java From geopackage-java with MIT License | 4 votes |
/** * Call after making changes to the point icon, point radius, or paint * stroke widths. Determines the pixel overlap between tiles */ public void calculateDrawOverlap() { if (pointIcon != null) { heightOverlap = this.scale * pointIcon.getHeight(); widthOverlap = this.scale * pointIcon.getWidth(); } else { heightOverlap = this.scale * pointRadius; widthOverlap = this.scale * pointRadius; } float linePaintHalfStroke = this.scale * lineStrokeWidth / 2.0f; heightOverlap = Math.max(heightOverlap, linePaintHalfStroke); widthOverlap = Math.max(widthOverlap, linePaintHalfStroke); float polygonPaintHalfStroke = this.scale * polygonStrokeWidth / 2.0f; heightOverlap = Math.max(heightOverlap, polygonPaintHalfStroke); widthOverlap = Math.max(widthOverlap, polygonPaintHalfStroke); if (featureTableStyles != null && featureTableStyles.has()) { // Style Rows Set<Long> styleRowIds = new HashSet<>(); List<Long> tableStyleIds = featureTableStyles.getAllTableStyleIds(); if (tableStyleIds != null) { styleRowIds.addAll(tableStyleIds); } List<Long> styleIds = featureTableStyles.getAllStyleIds(); if (styleIds != null) { styleRowIds.addAll(styleIds); } StyleDao styleDao = featureTableStyles.getStyleDao(); for (long styleRowId : styleRowIds) { StyleRow styleRow = styleDao .getRow(styleDao.queryForIdRow(styleRowId)); float styleHalfWidth = this.scale * (float) (styleRow.getWidthOrDefault() / 2.0f); widthOverlap = Math.max(widthOverlap, styleHalfWidth); heightOverlap = Math.max(heightOverlap, styleHalfWidth); } // Icon Rows Set<Long> iconRowIds = new HashSet<>(); List<Long> tableIconIds = featureTableStyles.getAllTableIconIds(); if (tableIconIds != null) { iconRowIds.addAll(tableIconIds); } List<Long> iconIds = featureTableStyles.getAllIconIds(); if (iconIds != null) { iconRowIds.addAll(iconIds); } IconDao iconDao = featureTableStyles.getIconDao(); for (long iconRowId : iconRowIds) { IconRow iconRow = iconDao .getRow(iconDao.queryForIdRow(iconRowId)); double[] iconDimensions = iconRow.getDerivedDimensions(); float iconWidth = this.scale * (float) Math.ceil(iconDimensions[0]); float iconHeight = this.scale * (float) Math.ceil(iconDimensions[1]); widthOverlap = Math.max(widthOverlap, iconWidth); heightOverlap = Math.max(heightOverlap, iconHeight); } } }
Example 5
Source File: FeatureTiles.java From geopackage-java 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) { mil.nga.geopackage.style.Color color = null; Float strokeWidth = null; switch (drawType) { case CIRCLE: color = style.getColorOrDefault(); break; case STROKE: color = style.getColorOrDefault(); strokeWidth = this.scale * (float) style.getWidthOrDefault(); break; case FILL: color = style.getFillColor(); strokeWidth = this.scale * (float) style.getWidthOrDefault(); break; default: throw new GeoPackageException( "Unsupported Draw Type: " + drawType); } Paint stylePaint = new Paint(); stylePaint.setColor(new Color(color.getColorWithAlpha(), true)); 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 6
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; }