public void CreateGdiVectorRendererTest()
 {
     GdiVectorRenderer renderer = new GdiVectorRenderer();
     Assert.AreEqual(new Matrix2D(), renderer.RenderTransform);
     Assert.AreEqual(StyleRenderingMode.Default, renderer.StyleRenderingMode);
     renderer.Dispose();
 }
Exemplo n.º 2
0
        public void CreateGdiVectorRendererTest()
        {
            GdiVectorRenderer renderer = new GdiVectorRenderer();

            Assert.AreEqual(new Matrix2D(), renderer.RenderTransform);
            Assert.AreEqual(StyleRenderingMode.Default, renderer.StyleRenderingMode);
            renderer.Dispose();
        }
Exemplo n.º 3
0
 public void CreatingBasicGeometryRenderer2DWithGdiVectorRendererSucceeds()
 {
     using (GdiVectorRenderer vectorRenderer = new GdiVectorRenderer())
     {
         BasicGeometryRenderer2D <GdiRenderObject> geometryRenderer
             = new BasicGeometryRenderer2D <GdiRenderObject>(vectorRenderer);
     }
 }
 public void CreatingBasicGeometryRenderer2DWithGdiVectorRendererSucceeds()
 {
     using (GdiVectorRenderer vectorRenderer = new GdiVectorRenderer())
     {
         BasicGeometryRenderer2D<GdiRenderObject> geometryRenderer
             = new BasicGeometryRenderer2D<GdiRenderObject>(vectorRenderer);
     }
 }
Exemplo n.º 5
0
        public void RenderPathOutlineTest()
        {
            GdiVectorRenderer renderer = new GdiVectorRenderer();

            Point2D[] points = new Point2D[]
            { new Point2D(1, 0), new Point2D(0, 1), new Point2D(-1, 0), new Point2D(0, -1) };

            Path2D path = new Path2D(points, true);

            StylePen outline   = new StylePen(new SolidStyleBrush(StyleColor.Blue), 1);
            StylePen highlight = new StylePen(new SolidStyleBrush(StyleColor.Red), 1);
            StylePen selected  = new StylePen(new SolidStyleBrush(StyleColor.Green), 1);

            IEnumerable <GdiRenderObject> renderObjects = renderer.RenderPaths(
                new Path2D[] { path }, outline, highlight, selected, RenderState.Normal);

            IEnumerator <GdiRenderObject> enumertor = renderObjects.GetEnumerator();

            enumertor.MoveNext();
            GdiRenderObject ro = enumertor.Current;

            Assert.AreEqual(RenderState.Normal, ro.State);
            Assert.IsInstanceOfType(typeof(SolidBrush), ro.Fill);
            Assert.IsNotNull(ro.GdiPath);
            Assert.AreEqual(4, ro.GdiPath.PointCount);
            Assert.AreEqual(new RectangleF(-1, -1, 2, 2), ro.GdiPath.GetBounds());

            PathData data = ro.GdiPath.PathData;

            for (Int32 i = 0; i < 4; i++)
            {
                Assert.AreEqual(points[i].X, data.Points[i].X, _e);
                Assert.AreEqual(points[i].Y, data.Points[i].Y, _e);
            }

            Assert.AreEqual(0, data.Types[0]);
            Assert.AreEqual(1, data.Types[1]);
            Assert.AreEqual(1, data.Types[2]);
            Assert.AreEqual(129, data.Types[3]);

            Pen expectedOutline   = new Pen(Brushes.Blue, 1.0f);
            Pen expectedHighlight = new Pen(Brushes.Red, 1.0f);
            Pen expectedSelected  = new Pen(Brushes.Green, 1.0f);

            Assert.IsTrue(pensAreEqual(expectedOutline, ro.Outline));
            Assert.IsTrue(pensAreEqual(expectedHighlight, ro.HighlightOutline));
            Assert.IsTrue(pensAreEqual(expectedSelected, ro.SelectOutline));

            expectedOutline.Dispose();
            expectedHighlight.Dispose();
            expectedSelected.Dispose();
            renderer.Dispose();
        }
        public void RenderPathOutlineTest()
        {
            GdiVectorRenderer renderer = new GdiVectorRenderer();

            Point2D[] points = new Point2D[]
                {new Point2D(1, 0), new Point2D(0, 1), new Point2D(-1, 0), new Point2D(0, -1)};

            Path2D path = new Path2D(points, true);

            StylePen outline = new StylePen(new SolidStyleBrush(StyleColor.Blue), 1);
            StylePen highlight = new StylePen(new SolidStyleBrush(StyleColor.Red), 1);
            StylePen selected = new StylePen(new SolidStyleBrush(StyleColor.Green), 1);

            IEnumerable<GdiRenderObject> renderObjects = renderer.RenderPaths(
                new Path2D[] {path}, outline, highlight, selected, RenderState.Normal);

            IEnumerator<GdiRenderObject> enumertor = renderObjects.GetEnumerator();
            enumertor.MoveNext();
            GdiRenderObject ro = enumertor.Current;

            Assert.AreEqual(RenderState.Normal, ro.State);
            Assert.IsInstanceOfType(typeof (SolidBrush), ro.Fill);
            Assert.IsNotNull(ro.GdiPath);
            Assert.AreEqual(4, ro.GdiPath.PointCount);
            Assert.AreEqual(new RectangleF(-1, -1, 2, 2), ro.GdiPath.GetBounds());

            PathData data = ro.GdiPath.PathData;

            for (Int32 i = 0; i < 4; i++)
            {
                Assert.AreEqual(points[i].X, data.Points[i].X, _e);
                Assert.AreEqual(points[i].Y, data.Points[i].Y, _e);
            }

            Assert.AreEqual(0, data.Types[0]);
            Assert.AreEqual(1, data.Types[1]);
            Assert.AreEqual(1, data.Types[2]);
            Assert.AreEqual(129, data.Types[3]);

            Pen expectedOutline = new Pen(Brushes.Blue, 1.0f);
            Pen expectedHighlight = new Pen(Brushes.Red, 1.0f);
            Pen expectedSelected = new Pen(Brushes.Green, 1.0f);

            Assert.IsTrue(pensAreEqual(expectedOutline, ro.Outline));
            Assert.IsTrue(pensAreEqual(expectedHighlight, ro.HighlightOutline));
            Assert.IsTrue(pensAreEqual(expectedSelected, ro.SelectOutline));

            expectedOutline.Dispose();
            expectedHighlight.Dispose();
            expectedSelected.Dispose();
            renderer.Dispose();
        }
Exemplo n.º 7
0
        public void RenderingPointsGeometriesWithGdiVectorRendererProducesCorrectGdiBitmaps()
        {
            using (GdiVectorRenderer vectorRenderer = new GdiVectorRenderer())
            {
                BasicGeometryRenderer2D <GdiRenderObject> geometryRenderer
                    = new BasicGeometryRenderer2D <GdiRenderObject>(vectorRenderer);

                FeatureProvider provider = DataSourceHelper.CreateFeatureDatasource(_geoFactory);

                FeatureQueryExpression query
                    = FeatureQueryExpression.Intersects(provider.GetExtents());

                foreach (IFeatureDataRecord record in provider.ExecuteFeatureQuery(query))
                {
                    IEnumerable <GdiRenderObject> renderedObjects = geometryRenderer.RenderFeature(record);

                    Int32 geoIndex = 0;

                    foreach (GdiRenderObject ro in renderedObjects)
                    {
                        IGeometry g = record.Geometry;

                        if (g is IMultiPoint)
                        {
                            IMultiPoint mp = g as IMultiPoint;
                            Assert.AreEqual(mp[geoIndex][Ordinates.X], ro.Bounds.Location.X, _e);
                            Assert.AreEqual(mp[geoIndex][Ordinates.Y], ro.Bounds.Location.Y, _e);
                            geoIndex++;
                        }
                        else if (g is IPoint)
                        {
                            IPoint p = g as IPoint;
                            Assert.AreEqual(p[Ordinates.X], ro.Bounds.Location.X, _e);
                            Assert.AreEqual(p[Ordinates.Y], ro.Bounds.Location.Y, _e);
                        }
                    }
                }
            }
        }
Exemplo n.º 8
0
        public void RenderingPolygonsWithGdiVectorRendererProducesCorrectGdiPaths()
        {
            using (GdiVectorRenderer vectorRenderer = new GdiVectorRenderer())
            {
                BasicGeometryRenderer2D <GdiRenderObject> geometryRenderer
                    = new BasicGeometryRenderer2D <GdiRenderObject>(vectorRenderer);

                FeatureProvider provider = DataSourceHelper.CreateFeatureDatasource(_geoFactory);

                FeatureQueryExpression query
                    = FeatureQueryExpression.Intersects(provider.GetExtents());

                foreach (IFeatureDataRecord record in provider.ExecuteFeatureQuery(query))
                {
                    IEnumerable <GdiRenderObject> renderedObjects
                        = geometryRenderer.RenderFeature(record);

                    foreach (GdiRenderObject ro in renderedObjects)
                    {
                        IGeometry g = record.Geometry;

                        if (g is IPolygon)
                        {
                            IPolygon p = g as IPolygon;
                            using (GraphicsPathIterator iter = new GraphicsPathIterator(ro.GdiPath))
                            {
                                Int32   start, end;
                                Boolean isClosed;
                                iter.NextSubpath(out start, out end, out isClosed);

                                Assert.IsTrue(isClosed);
                                Assert.AreEqual(p.ExteriorRing.Coordinates.Count, end - start + 1);

                                for (Int32 vertexIndex = 0;
                                     vertexIndex < p.ExteriorRing.Coordinates.Count;
                                     vertexIndex++)
                                {
                                    ICoordinate v        = (ICoordinate)p.ExteriorRing.Coordinates[vertexIndex];
                                    PointF      gdiPoint = ro.GdiPath.PathPoints[vertexIndex + start];
                                    Assert.AreEqual(v[Ordinates.X], gdiPoint.X);
                                    Assert.AreEqual(v[Ordinates.Y], gdiPoint.Y);
                                }

                                foreach (ILineString interiorRing in p.InteriorRings)
                                {
                                    iter.NextSubpath(out start, out end, out isClosed);
                                    Assert.IsTrue(isClosed);
                                    Assert.AreEqual(interiorRing.PointCount, end - start + 1);

                                    for (Int32 vertexIndex = 0;
                                         vertexIndex < interiorRing.PointCount;
                                         vertexIndex++)
                                    {
                                        ICoordinate v        = interiorRing.Coordinates[vertexIndex];
                                        PointF      gdiPoint = ro.GdiPath.PathPoints[vertexIndex + start];
                                        Assert.AreEqual(v[Ordinates.X], gdiPoint.X);
                                        Assert.AreEqual(v[Ordinates.Y], gdiPoint.Y);
                                    }
                                }
                            }
                        }
                        else if (g is IMultiPolygon)
                        {
                            IMultiPolygon mp = g as IMultiPolygon;

                            using (GraphicsPathIterator iter = new GraphicsPathIterator(ro.GdiPath))
                            {
                                foreach (IPolygon p in (IEnumerable <IPolygon>)mp)
                                {
                                    Int32   start, end;
                                    Boolean isClosed;
                                    iter.NextSubpath(out start, out end, out isClosed);

                                    Assert.IsTrue(isClosed);
                                    Int32 exteriorPointCount = p.ExteriorRing.PointCount;
                                    Assert.AreEqual(exteriorPointCount, end - start + 1);

                                    for (Int32 vertexIndex = 0;
                                         vertexIndex < exteriorPointCount;
                                         vertexIndex++)
                                    {
                                        ICoordinate v        = p.ExteriorRing.Coordinates[vertexIndex];
                                        PointF      gdiPoint = ro.GdiPath.PathPoints[vertexIndex + start];
                                        Assert.AreEqual(v[Ordinates.X], gdiPoint.X);
                                        Assert.AreEqual(v[Ordinates.Y], gdiPoint.Y);
                                    }

                                    foreach (ILineString interiorRing in p.InteriorRings)
                                    {
                                        iter.NextSubpath(out start, out end, out isClosed);
                                        Assert.IsTrue(isClosed);
                                        Assert.AreEqual(interiorRing.PointCount, end - start + 1);

                                        for (Int32 vertexIndex = 0;
                                             vertexIndex < interiorRing.PointCount;
                                             vertexIndex++)
                                        {
                                            ICoordinate v        = interiorRing.Coordinates[vertexIndex];
                                            PointF      gdiPoint = ro.GdiPath.PathPoints[vertexIndex + start];
                                            Assert.AreEqual(v[Ordinates.X], gdiPoint.X);
                                            Assert.AreEqual(v[Ordinates.Y], gdiPoint.Y);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 9
0
        public void RenderingLinesWithGdiVectorRendererProducesCorrectGdiPaths()
        {
            using (GdiVectorRenderer vectorRenderer = new GdiVectorRenderer())
            {
                BasicGeometryRenderer2D <GdiRenderObject> geometryRenderer
                    = new BasicGeometryRenderer2D <GdiRenderObject>(vectorRenderer);

                FeatureProvider provider = DataSourceHelper.CreateFeatureDatasource(_geoFactory);

                FeatureQueryExpression query
                    = FeatureQueryExpression.Intersects(provider.GetExtents());

                foreach (IFeatureDataRecord record in provider.ExecuteFeatureQuery(query))
                {
                    IEnumerable <GdiRenderObject> renderedObjects = geometryRenderer.RenderFeature(record);

                    Int32     geoIndex = 0;
                    IGeometry g        = record.Geometry;

                    foreach (GdiRenderObject ro in renderedObjects)
                    {
                        using (GraphicsPathIterator iter = new GraphicsPathIterator(ro.GdiPath))
                        {
                            Int32   start, end;
                            Boolean isClosed;
                            iter.NextSubpath(out start, out end, out isClosed);

                            if (g is ILineString)
                            {
                                Assert.IsFalse(isClosed);
                                ILineString ls = g as ILineString;
                                Assert.AreEqual(1, iter.SubpathCount);
                                for (Int32 vertexIndex = 0; vertexIndex < ls.Coordinates.Count; vertexIndex++)
                                {
                                    ICoordinate v        = (ICoordinate)ls.Coordinates[vertexIndex];
                                    PointF      gdiPoint = ro.GdiPath.PathPoints[vertexIndex + start];
                                    Assert.AreEqual(v[Ordinates.X], gdiPoint.X);
                                    Assert.AreEqual(v[Ordinates.Y], gdiPoint.Y);
                                }
                            }
                            else if (g is IMultiLineString)
                            {
                                Assert.IsFalse(isClosed);
                                IMultiLineString mls = g as IMultiLineString;
                                Assert.AreEqual(mls.Count, iter.SubpathCount);
                                foreach (ILineString lineString in (IEnumerable <ILineString>)mls)
                                {
                                    for (Int32 vertexIndex = 0; vertexIndex < lineString.Coordinates.Count; vertexIndex++)
                                    {
                                        ICoordinate v        = (ICoordinate)lineString.Coordinates[vertexIndex];
                                        PointF      gdiPoint = ro.GdiPath.PathPoints[vertexIndex + start];
                                        Assert.AreEqual(v[Ordinates.X], gdiPoint.X);
                                        Assert.AreEqual(v[Ordinates.Y], gdiPoint.Y);
                                    }

                                    iter.NextSubpath(out start, out end, out isClosed);
                                }
                            }
                        }
                    }
                }
            }
        }
        public void RenderingPolygonsWithGdiVectorRendererProducesCorrectGdiPaths()
        {
            using (GdiVectorRenderer vectorRenderer = new GdiVectorRenderer())
            {
                BasicGeometryRenderer2D<GdiRenderObject> geometryRenderer
                    = new BasicGeometryRenderer2D<GdiRenderObject>(vectorRenderer);

                FeatureProvider provider = DataSourceHelper.CreateFeatureDatasource(_geoFactory);

                FeatureQueryExpression query 
                    = FeatureQueryExpression.Intersects(provider.GetExtents());

                foreach (IFeatureDataRecord record in provider.ExecuteFeatureQuery(query))
                {
                    IEnumerable<GdiRenderObject> renderedObjects 
                        = geometryRenderer.RenderFeature(record);

                    foreach (GdiRenderObject ro in renderedObjects)
                    {
                        IGeometry g = record.Geometry;

                        if (g is IPolygon)
                        {
                            IPolygon p = g as IPolygon;
                            using (GraphicsPathIterator iter = new GraphicsPathIterator(ro.GdiPath))
                            {
                                Int32 start, end;
                                Boolean isClosed;
                                iter.NextSubpath(out start, out end, out isClosed);

                                Assert.IsTrue(isClosed);
                                Assert.AreEqual(p.ExteriorRing.Coordinates.Count, end - start + 1);

                                for (Int32 vertexIndex = 0; 
                                     vertexIndex < p.ExteriorRing.Coordinates.Count; 
                                     vertexIndex++)
                                {
                                    ICoordinate v = (ICoordinate)p.ExteriorRing.Coordinates[vertexIndex];
                                    PointF gdiPoint = ro.GdiPath.PathPoints[vertexIndex + start];
                                    Assert.AreEqual(v[Ordinates.X], gdiPoint.X);
                                    Assert.AreEqual(v[Ordinates.Y], gdiPoint.Y);
                                }

                                foreach (ILineString interiorRing in p.InteriorRings)
                                {
                                    iter.NextSubpath(out start, out end, out isClosed);
                                    Assert.IsTrue(isClosed);
                                    Assert.AreEqual(interiorRing.PointCount, end - start + 1);

                                    for (Int32 vertexIndex = 0;
                                         vertexIndex < interiorRing.PointCount;
                                         vertexIndex++)
                                    {
                                        ICoordinate v = interiorRing.Coordinates[vertexIndex];
                                        PointF gdiPoint = ro.GdiPath.PathPoints[vertexIndex + start];
                                        Assert.AreEqual(v[Ordinates.X], gdiPoint.X);
                                        Assert.AreEqual(v[Ordinates.Y], gdiPoint.Y);
                                    }
                                }
                            }
                        }
                        else if (g is IMultiPolygon)
                        {
                            IMultiPolygon mp = g as IMultiPolygon;

                            using (GraphicsPathIterator iter = new GraphicsPathIterator(ro.GdiPath))
                            {
                                foreach (IPolygon p in (IEnumerable<IPolygon>)mp)
                                {
                                    Int32 start, end;
                                    Boolean isClosed;
                                    iter.NextSubpath(out start, out end, out isClosed);

                                    Assert.IsTrue(isClosed);
                                    Int32 exteriorPointCount = p.ExteriorRing.PointCount;
                                    Assert.AreEqual(exteriorPointCount, end - start + 1);

                                    for (Int32 vertexIndex = 0; 
                                         vertexIndex < exteriorPointCount; 
                                         vertexIndex++)
                                    {
                                        ICoordinate v = p.ExteriorRing.Coordinates[vertexIndex];
                                        PointF gdiPoint = ro.GdiPath.PathPoints[vertexIndex + start];
                                        Assert.AreEqual(v[Ordinates.X], gdiPoint.X);
                                        Assert.AreEqual(v[Ordinates.Y], gdiPoint.Y);
                                    }

                                    foreach (ILineString interiorRing in p.InteriorRings)
                                    {
                                        iter.NextSubpath(out start, out end, out isClosed);
                                        Assert.IsTrue(isClosed);
                                        Assert.AreEqual(interiorRing.PointCount, end - start + 1);

                                        for (Int32 vertexIndex = 0;
                                             vertexIndex < interiorRing.PointCount;
                                             vertexIndex++)
                                        {
                                            ICoordinate v = interiorRing.Coordinates[vertexIndex];
                                            PointF gdiPoint = ro.GdiPath.PathPoints[vertexIndex + start];
                                            Assert.AreEqual(v[Ordinates.X], gdiPoint.X);
                                            Assert.AreEqual(v[Ordinates.Y], gdiPoint.Y);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        public void RenderingPointsGeometriesWithGdiVectorRendererProducesCorrectGdiBitmaps()
        {
            using (GdiVectorRenderer vectorRenderer = new GdiVectorRenderer())
            {
                BasicGeometryRenderer2D<GdiRenderObject> geometryRenderer
                    = new BasicGeometryRenderer2D<GdiRenderObject>(vectorRenderer);

                FeatureProvider provider = DataSourceHelper.CreateFeatureDatasource(_geoFactory);

                FeatureQueryExpression query
                    = FeatureQueryExpression.Intersects(provider.GetExtents());

                foreach (IFeatureDataRecord record in provider.ExecuteFeatureQuery(query))
                {
                    IEnumerable<GdiRenderObject> renderedObjects = geometryRenderer.RenderFeature(record);

                    Int32 geoIndex = 0;

                    foreach (GdiRenderObject ro in renderedObjects)
                    {
                        IGeometry g = record.Geometry;

                        if (g is IMultiPoint)
                        {
                            IMultiPoint mp = g as IMultiPoint;
                            Assert.AreEqual(mp[geoIndex][Ordinates.X], ro.Bounds.Location.X, _e);
                            Assert.AreEqual(mp[geoIndex][Ordinates.Y], ro.Bounds.Location.Y, _e);
                            geoIndex++;
                        }
                        else if (g is IPoint)
                        {
                            IPoint p = g as IPoint;
                            Assert.AreEqual(p[Ordinates.X], ro.Bounds.Location.X, _e);
                            Assert.AreEqual(p[Ordinates.Y], ro.Bounds.Location.Y, _e);
                        }
                    }
                }
            }
        }
        public void RenderingLinesWithGdiVectorRendererProducesCorrectGdiPaths()
        {
            using (GdiVectorRenderer vectorRenderer = new GdiVectorRenderer())
            {
                BasicGeometryRenderer2D<GdiRenderObject> geometryRenderer
                    = new BasicGeometryRenderer2D<GdiRenderObject>(vectorRenderer);

                FeatureProvider provider = DataSourceHelper.CreateFeatureDatasource(_geoFactory);

                FeatureQueryExpression query
                    = FeatureQueryExpression.Intersects(provider.GetExtents());

                foreach (IFeatureDataRecord record in provider.ExecuteFeatureQuery(query))
                {
                    IEnumerable<GdiRenderObject> renderedObjects = geometryRenderer.RenderFeature(record);

                    Int32 geoIndex = 0;
                    IGeometry g = record.Geometry;

                    foreach (GdiRenderObject ro in renderedObjects)
                    {
                        using (GraphicsPathIterator iter = new GraphicsPathIterator(ro.GdiPath))
                        {
                            Int32 start, end;
                            Boolean isClosed;
                            iter.NextSubpath(out start, out end, out isClosed);

                            if (g is ILineString)
                            {
                                Assert.IsFalse(isClosed);
                                ILineString ls = g as ILineString;
                                Assert.AreEqual(1, iter.SubpathCount);
                                for (Int32 vertexIndex = 0; vertexIndex < ls.Coordinates.Count; vertexIndex++)
                                {
                                    ICoordinate v = (ICoordinate)ls.Coordinates[vertexIndex];
                                    PointF gdiPoint = ro.GdiPath.PathPoints[vertexIndex + start];
                                    Assert.AreEqual(v[Ordinates.X], gdiPoint.X);
                                    Assert.AreEqual(v[Ordinates.Y], gdiPoint.Y);
                                }
                            }
                            else if (g is IMultiLineString)
                            {
                                Assert.IsFalse(isClosed);
                                IMultiLineString mls = g as IMultiLineString;
                                Assert.AreEqual(mls.Count, iter.SubpathCount);
                                foreach (ILineString lineString in (IEnumerable<ILineString>)mls)
                                {
                                    for (Int32 vertexIndex = 0; vertexIndex < lineString.Coordinates.Count; vertexIndex++)
                                    {
                                        ICoordinate v = (ICoordinate)lineString.Coordinates[vertexIndex];
                                        PointF gdiPoint = ro.GdiPath.PathPoints[vertexIndex + start];
                                        Assert.AreEqual(v[Ordinates.X], gdiPoint.X);
                                        Assert.AreEqual(v[Ordinates.Y], gdiPoint.Y);
                                    }

                                    iter.NextSubpath(out start, out end, out isClosed);
                                }
                            }
                        }
                    }
                }
            }
        }