public Circle(GraphicFactory graphicFactory, DisplayModel displayModel, String elementName, XmlPullParser pullParser, int level) throws XmlPullParserException { super(graphicFactory, displayModel); this.level = level; this.fill = graphicFactory.createPaint(); this.fill.setColor(Color.TRANSPARENT); this.fill.setStyle(Style.FILL); this.fills = new HashMap<>(); this.stroke = graphicFactory.createPaint(); this.stroke.setColor(Color.TRANSPARENT); this.stroke.setStyle(Style.STROKE); this.strokes = new HashMap<>(); this.renderRadiusScaled = new HashMap<>(); extractValues(graphicFactory, displayModel, elementName, pullParser); if (!this.scaleRadius) { this.renderRadius = this.radius; this.stroke.setStrokeWidth(this.strokeWidth); } }
public PathText(GraphicFactory graphicFactory, DisplayModel displayModel, String elementName, XmlPullParser pullParser) throws XmlPullParserException { super(graphicFactory, displayModel); this.fill = graphicFactory.createPaint(); this.fill.setColor(Color.BLACK); this.fill.setStyle(Style.FILL); this.fill.setTextAlign(Align.CENTER); this.fills = new HashMap<>(); this.rotate = true; this.repeat = true; this.stroke = graphicFactory.createPaint(); this.stroke.setColor(Color.BLACK); this.stroke.setStyle(Style.STROKE); this.stroke.setTextAlign(Align.CENTER); this.strokes = new HashMap<>(); this.dyScaled = new HashMap<>(); this.display = Display.IFSPACE; extractValues(graphicFactory, displayModel, elementName, pullParser); }
public Line(GraphicFactory graphicFactory, DisplayModel displayModel, String elementName, XmlPullParser pullParser, int level, String relativePathPrefix) throws IOException, XmlPullParserException { super(graphicFactory, displayModel); this.level = level; this.relativePathPrefix = relativePathPrefix; this.stroke = graphicFactory.createPaint(); this.stroke.setColor(Color.BLACK); this.stroke.setStyle(Style.STROKE); this.stroke.setStrokeCap(Cap.ROUND); this.stroke.setStrokeJoin(Join.ROUND); this.strokes = new HashMap<>(); this.dyScaled = new HashMap<>(); extractValues(graphicFactory, displayModel, elementName, pullParser); }
public Area(GraphicFactory graphicFactory, DisplayModel displayModel, String elementName, XmlPullParser pullParser, int level, String relativePathPrefix) throws IOException, XmlPullParserException { super(graphicFactory, displayModel); this.level = level; this.relativePathPrefix = relativePathPrefix; this.fill = graphicFactory.createPaint(); this.fill.setColor(Color.TRANSPARENT); this.fill.setStyle(Style.FILL); this.fill.setStrokeCap(Cap.ROUND); this.stroke = graphicFactory.createPaint(); this.stroke.setColor(Color.TRANSPARENT); this.stroke.setStyle(Style.STROKE); this.stroke.setStrokeCap(Cap.ROUND); this.strokes = new HashMap<>(); extractValues(elementName, pullParser); }
@Override public void draw(Canvas canvas, Point origin, Matrix matrix, Filter filter) { Point adjustedStart = xy.offset(-origin.x, -origin.y); Point adjustedEnd = end.offset(-origin.x, -origin.y); if (this.paintBack != null) { int color = this.paintBack.getColor(); if (filter != Filter.NONE) { this.paintBack.setColor(GraphicUtils.filterColor(color, filter)); } canvas.drawTextRotated(text, (int) (adjustedStart.x), (int) (adjustedStart.y), (int) (adjustedEnd.x), (int) (adjustedEnd.y), this.paintBack); if (filter != Filter.NONE) { this.paintBack.setColor(color); } } int color = this.paintFront.getColor(); if (filter != Filter.NONE) { this.paintFront.setColor(GraphicUtils.filterColor(color, filter)); } canvas.drawTextRotated(text, (int) (adjustedStart.x), (int) (adjustedStart.y), (int) (adjustedEnd.x), (int) (adjustedEnd.y), this.paintFront); if (filter != Filter.NONE) { this.paintFront.setColor(color); } }
private void extractValues(GraphicFactory graphicFactory, DisplayModel displayModel, String elementName, XmlPullParser pullParser) throws XmlPullParserException { for (int i = 0; i < pullParser.getAttributeCount(); ++i) { String name = pullParser.getAttributeName(i); String value = pullParser.getAttributeValue(i); if (RADIUS.equals(name) || R.equals(name)) { this.radius = XmlUtils.parseNonNegativeFloat(name, value) * displayModel.getScaleFactor(); } else if (CAT.equals(name)) { this.category = value; } else if (FILL.equals(name)) { this.fill.setColor(XmlUtils.getColor(graphicFactory, value, displayModel.getThemeCallback())); } else if (SCALE_RADIUS.equals(name)) { this.scaleRadius = Boolean.parseBoolean(value); } else if (STROKE.equals(name)) { this.stroke.setColor(XmlUtils.getColor(graphicFactory, value, displayModel.getThemeCallback())); } else if (STROKE_WIDTH.equals(name)) { this.strokeWidth = XmlUtils.parseNonNegativeFloat(name, value) * displayModel.getScaleFactor(); } else { throw XmlUtils.createXmlPullParserException(elementName, name, value, i); } } XmlUtils.checkMandatoryAttribute(elementName, RADIUS, this.radius); }
private static Paint createLineBack(GraphicFactory graphicFactory, DisplayModel displayModel) { Paint paint = graphicFactory.createPaint(); paint.setColor(Color.WHITE); paint.setStrokeWidth(4 * displayModel.getScaleFactor()); paint.setStyle(Style.STROKE); return paint; }
private static Paint createTextFront(GraphicFactory graphicFactory, DisplayModel displayModel) { Paint paint = graphicFactory.createPaint(); paint.setColor(Color.BLUE); paint.setTypeface(FontFamily.DEFAULT, FontStyle.BOLD); paint.setTextSize(12 * displayModel.getScaleFactor()); return paint; }
private static Paint createPaintFront(GraphicFactory graphicFactory, DisplayModel displayModel) { Paint paint = graphicFactory.createPaint(); paint.setColor(Color.RED); paint.setTypeface(FontFamily.DEFAULT, FontStyle.BOLD); paint.setTextSize(25 * displayModel.getScaleFactor()); return paint; }
private static Paint createPaintFront(GraphicFactory graphicFactory, DisplayModel displayModel) { Paint paint = graphicFactory.createPaint(); paint.setColor(Color.RED); paint.setStrokeWidth(2 * displayModel.getScaleFactor()); paint.setStyle(Style.STROKE); return paint; }
private static Paint createLineFront(GraphicFactory graphicFactory, DisplayModel displayModel) { Paint paint = graphicFactory.createPaint(); paint.setColor(Color.BLUE); paint.setStrokeWidth(2 * displayModel.getScaleFactor()); paint.setStyle(Style.STROKE); return paint; }
private Paint createScaleBarPaint(Color color, float strokeWidth, Style style) { Paint paint = this.graphicFactory.createPaint(); paint.setColor(color); paint.setStrokeWidth(strokeWidth * this.scale); paint.setStyle(style); paint.setStrokeCap(Cap.SQUARE); return paint; }
private static Paint createPaintBack(GraphicFactory graphicFactory, DisplayModel displayModel) { Paint paint = graphicFactory.createPaint(); paint.setColor(Color.WHITE); paint.setStrokeWidth(4 * displayModel.getScaleFactor()); paint.setStyle(Style.STROKE); return paint; }
private static Paint createPaintFront(GraphicFactory graphicFactory, DisplayModel displayModel) { Paint paint = graphicFactory.createPaint(); paint.setColor(Color.RED); paint.setTypeface(FontFamily.DEFAULT, FontStyle.BOLD); paint.setTextSize(12 * displayModel.getScaleFactor()); return paint; }
private void extractValues(String elementName, XmlPullParser pullParser) throws IOException, XmlPullParserException { for (int i = 0; i < pullParser.getAttributeCount(); ++i) { String name = pullParser.getAttributeName(i); String value = pullParser.getAttributeValue(i); if (SRC.equals(name)) { this.src = value; } else if (CAT.equals(name)) { this.category = value; } else if (FILL.equals(name)) { this.fill.setColor(XmlUtils.getColor(graphicFactory, value, displayModel.getThemeCallback())); } else if (SCALE.equals(name)) { this.scale = scaleFromValue(value); } else if (STROKE.equals(name)) { this.stroke.setColor(XmlUtils.getColor(graphicFactory, value, displayModel.getThemeCallback())); } else if (STROKE_WIDTH.equals(name)) { this.strokeWidth = XmlUtils.parseNonNegativeFloat(name, value) * displayModel.getScaleFactor(); } else if (SYMBOL_HEIGHT.equals(name)) { this.height = XmlUtils.parseNonNegativeInteger(name, value) * displayModel.getScaleFactor(); } else if (SYMBOL_PERCENT.equals(name)) { this.percent = XmlUtils.parseNonNegativeInteger(name, value); } else if (SYMBOL_SCALING.equals(name)) { // no-op } else if (SYMBOL_WIDTH.equals(name)) { this.width = XmlUtils.parseNonNegativeInteger(name, value) * displayModel.getScaleFactor(); } else { throw XmlUtils.createXmlPullParserException(elementName, name, value, i); } } }
private Paint createTextPaint(Color color, float strokeWidth, Style style) { Paint paint = this.graphicFactory.createPaint(); paint.setColor(color); paint.setStrokeWidth(strokeWidth * this.scale); paint.setStyle(style); paint.setTypeface(FontFamily.DEFAULT, FontStyle.BOLD); paint.setTextSize(12 * this.scale); return paint; }
private static Paint createTextBack(GraphicFactory graphicFactory, DisplayModel displayModel) { Paint paint = graphicFactory.createPaint(); paint.setColor(Color.WHITE); paint.setTypeface(FontFamily.DEFAULT, FontStyle.BOLD); paint.setTextSize(12 * displayModel.getScaleFactor()); paint.setStrokeWidth(4 * displayModel.getScaleFactor()); paint.setStyle(Style.STROKE); return paint; }
private static Paint createPaintBack(GraphicFactory graphicFactory, DisplayModel displayModel) { Paint paint = graphicFactory.createPaint(); paint.setColor(Color.WHITE); paint.setTypeface(FontFamily.DEFAULT, FontStyle.BOLD); paint.setTextSize(25 * displayModel.getScaleFactor()); paint.setStrokeWidth(2 * displayModel.getScaleFactor()); paint.setStyle(Style.STROKE); return paint; }
private static Paint createPaintBack(GraphicFactory graphicFactory, DisplayModel displayModel) { Paint paint = graphicFactory.createPaint(); paint.setColor(Color.WHITE); paint.setTypeface(FontFamily.DEFAULT, FontStyle.BOLD); paint.setTextSize(12 * displayModel.getScaleFactor()); paint.setStrokeWidth(2 * displayModel.getScaleFactor()); paint.setStyle(Style.STROKE); return paint; }
@Test public void isTransparentTest() { Paint paint = new AwtPaint(); Assert.assertFalse(paint.isTransparent()); paint.setColor(Color.TRANSPARENT); Assert.assertTrue(paint.isTransparent()); Bitmap bitmap = org.mapsforge.map.awt.graphics.AwtGraphicFactory.INSTANCE.createBitmap(1, 1); paint.setBitmapShader(bitmap); Assert.assertFalse(paint.isTransparent()); } }