예제 #1
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);
            }
        }
예제 #2
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);
            }
        }
예제 #3
0
 public override void ScaleStrokeWidth(float scaleFactor, sbyte zoomLevel)
 {
     if (this.stroke != null)
     {
         IPaint zlPaint = graphicFactory.CreatePaint(this.stroke);
         zlPaint.StrokeWidth     = this.strokeWidth * scaleFactor;
         this.strokes[zoomLevel] = zlPaint;
     }
 }
예제 #4
0
        private IPaint getStrokePaint(sbyte zoomLevel)
        {
            IPaint paint = strokes[zoomLevel];

            if (paint == null)
            {
                paint = this.stroke;
            }
            return(paint);
        }
예제 #5
0
        private IPaint getFillPaint(sbyte zoomLevel)
        {
            IPaint paint = fills[zoomLevel];

            if (paint == null)
            {
                paint = this.fill;
            }
            return(paint);
        }
예제 #6
0
        public override void ScaleStrokeWidth(float scaleFactor, sbyte zoomLevel)
        {
            if (this.stroke != null)
            {
                IPaint s = graphicFactory.CreatePaint(stroke);
                s.StrokeWidth      = this.strokeWidth * scaleFactor;
                strokes[zoomLevel] = s;
            }

            this.dyScaled[zoomLevel] = this.dy * scaleFactor;
        }
예제 #7
0
        public override void ScaleTextSize(float scaleFactor, sbyte zoomLevel)
        {
            IPaint zlPaint = graphicFactory.CreatePaint(this.fill);

            zlPaint.TextSize      = this.fontSize * scaleFactor;
            this.fills[zoomLevel] = zlPaint;

            IPaint zlStroke = graphicFactory.CreatePaint(this.stroke);

            zlStroke.TextSize       = this.fontSize * scaleFactor;
            this.strokes[zoomLevel] = zlStroke;
        }
예제 #8
0
 public override void ScaleStrokeWidth(float scaleFactor, sbyte zoomLevel)
 {
     if (this.scaleRadius)
     {
         this.renderRadiusScaled[zoomLevel] = this.radius * scaleFactor;
         if (this.stroke != null)
         {
             IPaint s = graphicFactory.CreatePaint(stroke);
             s.StrokeWidth      = this.strokeWidth * scaleFactor;
             strokes[zoomLevel] = s;
         }
     }
 }
예제 #9
0
        public override void ScaleTextSize(float scaleFactor, sbyte zoomLevel)
        {
            IPaint f = graphicFactory.CreatePaint(this.fill);

            f.TextSize            = this.fontSize * scaleFactor;
            this.fills[zoomLevel] = f;

            IPaint s = graphicFactory.CreatePaint(this.stroke);

            s.TextSize = this.fontSize * scaleFactor;
            this.strokes[zoomLevel] = s;

            this.dyScaled[zoomLevel] = this.dy * scaleFactor;
        }
예제 #10
0
        public Line(IGraphicFactory graphicFactory, DisplayModel displayModel, string elementName, XmlReader reader, int level, string relativePathPrefix) : base(graphicFactory, displayModel)
        {
            this.level = level;
            this.relativePathPrefix = relativePathPrefix;

            this.stroke            = graphicFactory.CreatePaint();
            this.stroke.Color      = Color.Green.ToARGB();
            this.stroke.Style      = Style.Stroke;
            this.stroke.StrokeCap  = Cap.Round;
            this.stroke.StrokeJoin = Join.Round;
            this.strokes           = new Dictionary <sbyte?, IPaint>();
            this.dyScaled          = new Dictionary <sbyte?, float?>();

            ExtractValues(graphicFactory, displayModel, elementName, reader, relativePathPrefix);
        }
예제 #11
0
        public PathText(IGraphicFactory graphicFactory, DisplayModel displayModel, string elementName, XmlReader reader) : base(graphicFactory, displayModel)
        {
            this.fill           = graphicFactory.CreatePaint();
            this.fill.Color     = Color.Black.ToARGB();
            this.fill.Style     = Style.Fill;
            this.fill.TextAlign = Align.Center;
            this.fills          = new Dictionary <sbyte?, IPaint>();

            this.stroke           = graphicFactory.CreatePaint();
            this.stroke.Color     = Color.Black.ToARGB();
            this.stroke.Style     = Style.Stroke;
            this.stroke.TextAlign = Align.Center;
            this.strokes          = new Dictionary <sbyte?, IPaint>();
            this.dyScaled         = new Dictionary <sbyte?, float?>();
            this.display          = Display.Ifspace;

            ExtractValues(graphicFactory, displayModel, elementName, reader);
        }
예제 #12
0
        public Area(IGraphicFactory graphicFactory, DisplayModel displayModel, string elementName, XmlReader reader, int level, string relativePathPrefix) : base(graphicFactory, displayModel)
        {
            this.level = level;
            this.relativePathPrefix = relativePathPrefix;

            this.fill           = graphicFactory.CreatePaint();
            this.fill.Color     = Color.Transparent.ToARGB();
            this.fill.Style     = Style.Fill;
            this.fill.StrokeCap = Cap.Round;

            this.stroke           = graphicFactory.CreatePaint();
            this.stroke.Color     = Color.Transparent.ToARGB();
            this.stroke.Style     = Style.Stroke;
            this.stroke.StrokeCap = Cap.Round;

            this.strokes = new Dictionary <sbyte?, IPaint>();

            ExtractValues(elementName, reader);
        }
예제 #13
0
        public Circle(IGraphicFactory graphicFactory, DisplayModel displayModel, string elementName, XmlReader reader, int level) : base(graphicFactory, displayModel)
        {
            this.level = level;

            this.fill       = graphicFactory.CreatePaint();
            this.fill.Color = Color.Transparent.ToARGB();
            this.fill.Style = Style.Fill;
            this.fills      = new Dictionary <sbyte?, IPaint>();

            this.stroke             = graphicFactory.CreatePaint();
            this.stroke.Color       = Color.Transparent.ToARGB();
            this.stroke.Style       = Style.Stroke;
            this.strokes            = new Dictionary <sbyte?, IPaint>();
            this.renderRadiusScaled = new Dictionary <sbyte?, float?>();

            ExtractValues(graphicFactory, displayModel, elementName, reader);


            if (!this.scaleRadius)
            {
                this.renderRadius       = this.radius;
                this.stroke.StrokeWidth = this.strokeWidth;
            }
        }
예제 #14
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;
        }