public void RenderPointOfInterestCaption(RenderContext renderContext, Display display, int priority, string caption, float horizontalOffset, float verticalOffset, IPaint fill, IPaint stroke, Position position, int maxTextWidth, PointOfInterest poi) { 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)); }
public Caption(IGraphicFactory graphicFactory, DisplayModel displayModel, string elementName, XmlReader reader, IDictionary <string, Symbol> symbols) : base(graphicFactory, displayModel) { this.fill = graphicFactory.CreatePaint(); this.fill.Color = Color.BLACK; this.fill.Style = Style.FILL; this.fills = new Dictionary <sbyte?, IPaint>(); this.stroke = graphicFactory.CreatePaint(); this.stroke.Color = Color.BLACK; this.stroke.Style = Style.STROKE; this.strokes = new Dictionary <sbyte?, IPaint>(); this.dyScaled = new Dictionary <sbyte?, float?>(); this.display = Display.IFSPACE; this.gap = DEFAULT_GAP * displayModel.ScaleFactor; ExtractValues(graphicFactory, displayModel, elementName, reader); if (!string.ReferenceEquals(this.symbolId, null)) { Symbol symbol = symbols[this.symbolId]; if (symbol != null) { this.bitmap = symbol.Bitmap; } } if (this.position == null) { // sensible defaults: below if symbolContainer is present, center if not if (this.bitmap == null) { this.position = Position.CENTER; } else { this.position = Position.BELOW; } } else if (this.position == Position.CENTER || this.position == Position.BELOW || this.position == Position.ABOVE) { this.stroke.TextAlign = Align.CENTER; this.fill.TextAlign = Align.CENTER; } else if (this.position == Position.BELOW_LEFT || this.position == Position.ABOVE_LEFT || this.position == Position.LEFT) { this.stroke.TextAlign = Align.RIGHT; this.fill.TextAlign = Align.RIGHT; } else if (this.position == Position.BELOW_RIGHT || this.position == Position.ABOVE_RIGHT || this.position == Position.RIGHT) { this.stroke.TextAlign = Align.LEFT; this.fill.TextAlign = Align.LEFT; } else { throw new System.ArgumentException("Position invalid"); } this.maxTextWidth = displayModel.MaxTextWidth; }
public void RenderAreaCaption(RenderContext renderContext, Display display, int priority, string caption, float horizontalOffset, float verticalOffset, IPaint fill, IPaint stroke, Position position, int maxTextWidth, PolylineContainer way) { Point centerPoint = way.CenterAbsolute.Offset(horizontalOffset, verticalOffset); renderContext.labels.Add(this.graphicFactory.CreatePointTextContainer(centerPoint, display, priority, caption, fill, stroke, null, position, maxTextWidth)); }
private void ExtractValues(IGraphicFactory graphicFactory, DisplayModel displayModel, string elementName, XmlReader reader) { FontFamily fontFamily = FontFamily.DEFAULT; FontStyle fontStyle = FontStyle.NORMAL; for (int i = 0; i < reader.AttributeCount; ++i) { reader.MoveToAttribute(i); string name = reader.Name; string value = reader.Value; if (K.Equals(name)) { this.textKey = TextKey.getInstance(value); } else if (POSITION.Equals(name)) { this.position = Position.FromString(value); } else if (CAT.Equals(name)) { this.category = value; } else if (DISPLAY.Equals(name)) { this.display = Display.FromString(value); } else if (DY.Equals(name)) { this.dy = float.Parse(value) * displayModel.ScaleFactor; } else if (FONT_FAMILY.Equals(name)) { fontFamily = FontFamily.FromString(value); } else if (FONT_STYLE.Equals(name)) { fontStyle = FontStyle.FromString(value); } else if (FONT_SIZE.Equals(name)) { this.fontSize = XmlUtils.ParseNonNegativeFloat(name, value) * displayModel.ScaleFactor; } else if (FILL.Equals(name)) { this.fill.Color = (Color)XmlUtils.GetColor(graphicFactory, value); } else if (PRIORITY.Equals(name)) { this.priority = int.Parse(value); } else if (STROKE.Equals(name)) { this.stroke.Color = (Color)XmlUtils.GetColor(graphicFactory, value); } else if (STROKE_WIDTH.Equals(name)) { this.stroke.StrokeWidth = XmlUtils.ParseNonNegativeFloat(name, value) * displayModel.ScaleFactor; } else if (SYMBOL_ID.Equals(name)) { this.symbolId = value; } else { throw XmlUtils.CreateXmlReaderException(elementName, name, value, i); } } this.fill.SetTypeface(fontFamily, fontStyle); this.stroke.SetTypeface(fontFamily, fontStyle); XmlUtils.CheckMandatoryAttribute(elementName, K, this.textKey); }