Beispiel #1
0
        public override void RenderWay(RenderCallback renderCallback, RenderContext renderContext, PolylineContainer way)
        {
            lock (this)
            {
                if (!bitmapCreated)
                {
                    try
                    {
                        shaderBitmap = CreateBitmap(relativePathPrefix, src);
                    }
                    catch (IOException)
                    {
                        // no-op
                    }
                    bitmapCreated = true;
                }

                IPaint strokePaint = getStrokePaint(renderContext.rendererJob.tile.ZoomLevel);

                if (shaderBitmap != null)
                {
                    strokePaint.BitmapShader      = shaderBitmap;
                    strokePaint.BitmapShaderShift = way.Tile.Origin;
                }

                float dyScale = this.dyScaled[renderContext.rendererJob.tile.ZoomLevel] ?? this.dy;

                renderCallback.RenderWay(renderContext, strokePaint, dyScale, this.level, way);
            }
        }
Beispiel #2
0
        public override void RenderWay(RenderCallback renderCallback, RenderContext renderContext, PolylineContainer way)
        {
            lock (this)
            {
                // this needs to be synchronized as we potentially set a shift in the shader and
                // the shift is particular to the tile when rendered in multi-thread mode
                IPaint fillPaint = getFillPaint(renderContext.rendererJob.tile.ZoomLevel);
                if (shaderBitmap == null && !bitmapInvalid)
                {
                    try
                    {
                        shaderBitmap = CreateBitmap(relativePathPrefix, src);
                        if (shaderBitmap != null)
                        {
                            fillPaint.BitmapShader = shaderBitmap;
                            shaderBitmap.DecrementRefCount();
                        }
                    }
                    catch (IOException)
                    {
                        bitmapInvalid = true;
                    }
                }

                fillPaint.BitmapShaderShift = way.Tile.Origin;

                renderCallback.RenderArea(renderContext, fillPaint, getStrokePaint(renderContext.rendererJob.tile.ZoomLevel), this.level, way);
            }
        }
Beispiel #3
0
        public override void RenderWay(RenderCallback renderCallback, RenderContext renderContext, PolylineContainer way)
        {
            if (Display.Never == this.display)
            {
                return;
            }

            if (this.bitmap == null && !this.bitmapInvalid)
            {
                try
                {
                    this.bitmap = CreateBitmap(relativePathPrefix, src);
                }
                catch (IOException)
                {
                    this.bitmapInvalid = true;
                }
            }

            float dyScale = this.dyScaled[renderContext.rendererJob.tile.ZoomLevel] ?? this.dy;

            if (this.bitmap != null)
            {
                renderCallback.RenderWaySymbol(renderContext, this.display, this.priority, this.bitmap, dyScale, this.alignCenter, this.repeat, this.repeatGap, this.repeatStart, this.rotate, way);
            }
        }
Beispiel #4
0
        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.ToARGB();
            this.fill.Style = Style.Fill;
            this.fills      = new Dictionary <sbyte?, IPaint>();

            this.stroke       = graphicFactory.CreatePaint();
            this.stroke.Color = Color.Black.ToARGB();
            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 == Position.Auto)
            {
                // 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.BelowLeft || this.position == Position.AboveLeft || this.position == Position.Left)
            {
                this.stroke.TextAlign = Align.Right;
                this.fill.TextAlign   = Align.Right;
            }
            else if (this.position == Position.BelowRight || this.position == Position.AboveRight || 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;
        }