@Override public void scaleStrokeWidth(float scaleFactor, byte zoomLevel) { if (this.scaleRadius) { this.renderRadiusScaled.put(zoomLevel, this.radius * scaleFactor); if (this.stroke != null) { Paint paint = graphicFactory.createPaint(stroke); paint.setStrokeWidth(this.strokeWidth * scaleFactor); strokes.put(zoomLevel, paint); } } }
public MapScaleBar(IMapViewPosition mapViewPosition, MapViewDimension mapViewDimension, DisplayModel displayModel, GraphicFactory graphicFactory, int width, int height) { this.mapViewPosition = mapViewPosition; this.mapViewDimension = mapViewDimension; this.displayModel = displayModel; this.graphicFactory = graphicFactory; this.mapScaleBitmap = graphicFactory.createBitmap(width, height); this.scaleBarPosition = DEFAULT_SCALE_BAR_POSITION; this.mapScaleCanvas = graphicFactory.createCanvas(); this.mapScaleCanvas.setBitmap(this.mapScaleBitmap); this.distanceUnitAdapter = MetricUnitAdapter.INSTANCE; this.visible = true; this.redrawNeeded = true; }
public RenderThemeBuilder(GraphicFactory graphicFactory, DisplayModel displayModel, String elementName, XmlPullParser pullParser) throws XmlPullParserException { this.displayModel = displayModel; this.baseStrokeWidth = 1f; this.baseTextSize = 1f; this.mapBackground = graphicFactory.createColor(Color.WHITE); extractValues(graphicFactory, elementName, pullParser); }
public CanvasRasterer(GraphicFactory graphicFactory) { this.canvas = graphicFactory.createCanvas(); this.path = graphicFactory.createPath(); this.symbolMatrix = graphicFactory.createMatrix(); }
public static ResourceBitmap createBitmap(GraphicFactory graphicFactory, DisplayModel displayModel, String relativePathPrefix, String src, int width, int height, int percent) throws IOException { if (src == null || src.length() == 0) { // no image source defined return null; } InputStream inputStream = createInputStream(graphicFactory, relativePathPrefix, src); try { String absoluteName = getAbsoluteName(relativePathPrefix, src); // we need to hash with the width/height included as the same symbol could be required // in a different size and must be cached with a size-specific hash int hash = new StringBuilder().append(absoluteName).append(width).append(height).append(percent).toString().hashCode(); if (src.toLowerCase(Locale.ENGLISH).endsWith(".svg")) { try { return graphicFactory.renderSvg(inputStream, displayModel.getScaleFactor(), width, height, percent, hash); } catch (IOException e) { throw new IOException("SVG render failed " + src, e); } } try { return graphicFactory.createResourceBitmap(inputStream, displayModel.getScaleFactor(), width, height, percent, hash); } catch (IOException e) { throw new IOException("Reading bitmap file failed " + src, e); } } finally { inputStream.close(); } }
@Test public void drawTest() { for (int tileSize : TILE_SIZES) { Polygon polygon = new Polygon(null, null, GRAPHIC_FACTORY); polygon.setDisplayModel(new FixedTileSizeDisplayModel(tileSize)); BoundingBox boundingBox = new BoundingBox(-1, -1, 1, 1); Canvas canvas = GRAPHIC_FACTORY.createCanvas(); canvas.setBitmap(GRAPHIC_FACTORY.createBitmap(tileSize, tileSize)); Point point = new Point(0, 0); polygon.draw(boundingBox, (byte) 0, canvas, point); List<LatLong> latLongs = new ArrayList<>(); latLongs.add(new LatLong(0, 0)); latLongs.add(new LatLong(1, 1)); polygon.setPoints(latLongs); polygon.draw(boundingBox, (byte) 0, canvas, point); polygon.setPaintFill(GRAPHIC_FACTORY.createPaint()); polygon.setPaintStroke(GRAPHIC_FACTORY.createPaint()); polygon.draw(boundingBox, (byte) 0, canvas, point); } }
@Override public synchronized TileBitmap get(Job key) { File file = this.findFile(key); if (file == null) { return null; } InputStream inputStream = null; try { inputStream = new FileInputStream(file); return this.graphicFactory.createTileBitmap(inputStream, key.tile.tileSize, key.hasAlpha); } catch (CorruptedInputStreamException e) { // this can happen, at least on Android, when the input stream // is somehow corrupted, returning null ensures it will be loaded // from another source return null; } catch (IOException e) { return null; } finally { IOUtils.closeQuietly(inputStream); } }
public synchronized void setDimension(Dimension dimension) { if (this.dimension != null && this.dimension.equals(dimension)) { return; } this.dimension = dimension; destroyBitmaps(); if (dimension.width > 0 && dimension.height > 0) { this.odBitmap = this.graphicFactory.createBitmap(dimension.width, dimension.height, IS_TRANSPARENT); this.lmBitmap = this.graphicFactory.createBitmap(dimension.width, dimension.height, IS_TRANSPARENT); } } }
public LabelLayer(GraphicFactory graphicFactory, LabelStore labelStore) { this.labelStore = labelStore; this.matrix = graphicFactory.createMatrix(); this.lastLabelStoreVersion = -1; }
private void mergePaddingOnBitmap(HillshadingBitmap fresh, HgtFileInfo neighbor, HillshadingBitmap.Border border) { int padding = fresh.getPadding(); if (padding < 1) return; if (neighbor != null) { Future<HillshadingBitmap> neighborUnmergedFuture = neighbor.getUnmergedAsMergePartner(); if (neighborUnmergedFuture != null) { try { HillshadingBitmap other = neighborUnmergedFuture.get(); Canvas copyCanvas = graphicsFactory.createCanvas(); mergeSameSized(fresh, other, border, padding, copyCanvas); } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); } } } } }
markerIcon = GRAPHIC_FACTORY.createResourceBitmap(MapsforgeMapView.class.getResourceAsStream("marker.png"), -1); waypointIcon = GRAPHIC_FACTORY.createResourceBitmap(MapsforgeMapView.class.getResourceAsStream("waypoint.png"), -1); } catch (IOException e) { log.severe("Cannot create marker and waypoint icon: " + e);
@Override public void renderPointOfInterestCaption(final RenderContext renderContext, Display display, int priority, String caption, float horizontalOffset, float verticalOffset, Paint fill, Paint stroke, Position position, int maxTextWidth, PointOfInterest poi) { if (renderLabels) { Point poiPosition = MercatorProjection.getPixelAbsolute(poi.position, renderContext.rendererJob.tile.mapSize); renderContext.labels.add(this.graphicFactory.createPointTextContainer(poiPosition.offset(horizontalOffset, verticalOffset), display, priority, caption, fill, stroke, null, position, maxTextWidth)); } }
float y = (float) (MercatorProjection.latitudeToPixelY(latLong.latitude, mapSize) - topLeftPoint.y); Path path = this.graphicFactory.createPath(); path.moveTo(x, y);
public HillshadingBitmap calculate() { ShadingAlgorithm.RawShadingResult raw = algorithm.transformToByteBuffer(hgtFileInfo, HgtCache.this.interpolatorOverlap ? 1 : 0); // is this really necessary? Maybe, if some downscaling is filtered and rounding is not as expected raw.fillPadding(); return graphicsFactory.createMonoBitmap(raw.width, raw.height, raw.bytes, raw.padding, hgtFileInfo); } }
@Test public void drawTest() { for (int tileSize : TILE_SIZES) { Polyline polyline = new Polyline(null, GRAPHIC_FACTORY); polyline.setDisplayModel(new FixedTileSizeDisplayModel(tileSize)); BoundingBox boundingBox = new BoundingBox(-1, -1, 1, 1); Canvas canvas = GRAPHIC_FACTORY.createCanvas(); canvas.setBitmap(GRAPHIC_FACTORY.createBitmap(tileSize, tileSize)); Point point = new Point(0, 0); polyline.draw(boundingBox, (byte) 0, canvas, point); List<LatLong> latLongs = new ArrayList<>(); latLongs.add(new LatLong(0, 0)); latLongs.add(new LatLong(1, 1)); polyline.setPoints(latLongs); polyline.draw(boundingBox, (byte) 0, canvas, point); polyline.setPaintStroke(GRAPHIC_FACTORY.createPaint()); polyline.draw(boundingBox, (byte) 0, canvas, point); } }
/** * Draws a bitmap just with outside colour, used for bitmaps outside of map area. * * @param renderContext the RenderContext * @return bitmap drawn in single colour. */ private TileBitmap createBackgroundBitmap(RenderContext renderContext) { TileBitmap bitmap = this.graphicFactory.createTileBitmap(renderContext.rendererJob.tile.tileSize, renderContext.rendererJob.hasAlpha); renderContext.canvasRasterer.setCanvasBitmap(bitmap); if (!renderContext.rendererJob.hasAlpha) { renderContext.canvasRasterer.fill(renderContext.renderTheme.getMapBackgroundOutside()); } return bitmap; }
public CanvasRasterer(GraphicFactory graphicFactory) { this.canvas = graphicFactory.createCanvas(); this.path = graphicFactory.createPath(); this.symbolMatrix = graphicFactory.createMatrix(); }
Bitmap create() { if (dimension.width > 0 && dimension.height > 0) { Bitmap bitmap = factory.createBitmap(dimension.width, dimension.height, isTransparent); bitmap.setBackgroundColor(color); return bitmap; } return null; } }
public static ResourceBitmap createBitmap(GraphicFactory graphicFactory, DisplayModel displayModel, String relativePathPrefix, String src, int width, int height, int percent) throws IOException { if (src == null || src.length() == 0) { // no image source defined return null; } InputStream inputStream = createInputStream(graphicFactory, relativePathPrefix, src); try { String absoluteName = getAbsoluteName(relativePathPrefix, src); // we need to hash with the width/height included as the same symbol could be required // in a different size and must be cached with a size-specific hash int hash = new StringBuilder().append(absoluteName).append(width).append(height).append(percent).toString().hashCode(); if (src.toLowerCase(Locale.ENGLISH).endsWith(".svg")) { try { return graphicFactory.renderSvg(inputStream, displayModel.getScaleFactor(), width, height, percent, hash); } catch (IOException e) { throw new IOException("SVG render failed " + src, e); } } try { return graphicFactory.createResourceBitmap(inputStream, absoluteName.hashCode()); } catch (IOException e) { throw new IOException("Reading bitmap file failed " + src, e); } } finally { inputStream.close(); } }
public FrameBuffer(FrameBufferModel frameBufferModel, DisplayModel displayModel, GraphicFactory graphicFactory) { this.frameBufferModel = frameBufferModel; this.displayModel = displayModel; this.graphicFactory = graphicFactory; this.matrix = graphicFactory.createMatrix(); }