//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 21JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * draw a pline. * @param mapPen the pen used to draw the polyline * @param pline the polyline object. */ private void DrawPline(MapPen mapPen, GeoPolyline pline) { ArrayList clippedPts = _sutherlandHodgman.ClipPline(pline.GetPoints()); GeoPoint[] screenPts = FromLatLngToMapPixel(clippedPts); if (screenPts.Length > 1) { { int penWidth = mapPen.Width; if (mapPen.Pattern > 62) { penWidth = mapPen.Width * 2; } Pen pen = new Pen(new Color(mapPen.Color, false), penWidth); SharedGraphics2D.SetDefaultPen(pen); int[] xpoints = new int[screenPts.Length]; int[] ypoints = new int[screenPts.Length]; for (int i = 0; i < screenPts.Length; i++) { xpoints[i] = (int)screenPts[i].X; ypoints[i] = (int)screenPts[i].Y; } Polyline polyline = new Polyline { Xpoints = xpoints, Ypoints = ypoints, NumOfPoints = xpoints.Length }; SharedGraphics2D.DrawPolyline(null, polyline); } } }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 21JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * draw a region. * @param mapPen pen for the border of the region. * @param mapBrush brush to fill the region. * @param region the polygon object. */ private void DrawRegion(MapPen mapPen, MapBrush mapBrush, GeoPolygon region) { Pen pen = new Pen(new Color(mapPen.Color, false), mapPen.Width); TextureBrush brush = GetImagePatternBrush(mapBrush); ArrayList clippedPts = _sutherlandHodgman.ClipRegion(region.GetPoints()); GeoPoint[] screenPts = FromLatLngToMapPixel(clippedPts); if (screenPts.Length > 2) { { int[] xpoints = new int[screenPts.Length]; int[] ypoints = new int[screenPts.Length]; for (int i = 0; i < screenPts.Length; i++) { xpoints[i] = (int)screenPts[i].X; ypoints[i] = (int)screenPts[i].Y; } Polygon polygon = new Polygon { Xpoints = xpoints, Ypoints = ypoints, NumOfNpoints = xpoints.Length }; if (mapBrush.Pattern == 2) { SharedGraphics2D.SetPenAndBrush(pen, brush); SharedGraphics2D.DrawPolygon(null, polygon); SharedGraphics2D.FillPolygon(null, polygon); } else { SharedGraphics2D.SetDefaultPen(pen); SharedGraphics2D.DrawPolygon(null, polygon); } } } }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 21JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * draw a region. * @param mapPen pen for the border of the region. * @param mapBrush brush to fill the region. * @param region the polygon object. */ private void DrawRegion(MapPen mapPen, MapBrush mapBrush, GeoPolygon region) { Pen pen = new Pen(new Color(mapPen.Color,false), mapPen.Width); TextureBrush brush = GetImagePatternBrush(mapBrush); ArrayList clippedPts = _sutherlandHodgman.ClipRegion(region.GetPoints()); GeoPoint[] screenPts = FromLatLngToMapPixel(clippedPts); if (screenPts.Length > 2) { { int[] xpoints = new int[screenPts.Length]; int[] ypoints = new int[screenPts.Length]; for (int i = 0; i < screenPts.Length; i++) { xpoints[i] = (int)screenPts[i].X; ypoints[i] = (int)screenPts[i].Y; } Polygon polygon = new Polygon { Xpoints = xpoints, Ypoints = ypoints, NumOfNpoints = xpoints.Length }; if (mapBrush.Pattern == 2) { SharedGraphics2D.SetPenAndBrush(pen, brush); SharedGraphics2D.DrawPolygon(null, polygon); SharedGraphics2D.FillPolygon(null, polygon); } else { SharedGraphics2D.SetDefaultPen(pen); SharedGraphics2D.DrawPolygon(null, polygon); } } } }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 21JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * draw a pline. * @param mapPen the pen used to draw the polyline * @param pline the polyline object. */ private void DrawPline(MapPen mapPen, GeoPolyline pline) { ArrayList clippedPts = _sutherlandHodgman.ClipPline(pline.GetPoints()); GeoPoint[] screenPts = FromLatLngToMapPixel(clippedPts); if (screenPts.Length > 1) { { int penWidth = mapPen.Width; if (mapPen.Pattern > 62) { penWidth = mapPen.Width * 2; } Pen pen = new Pen(new Color(mapPen.Color,false), penWidth); SharedGraphics2D.SetDefaultPen(pen); int[] xpoints = new int[screenPts.Length]; int[] ypoints = new int[screenPts.Length]; for (int i = 0; i < screenPts.Length; i++) { xpoints[i] = (int)screenPts[i].X; ypoints[i] = (int)screenPts[i].Y; } Polyline polyline = new Polyline { Xpoints = xpoints, Ypoints = ypoints, NumOfPoints = xpoints.Length }; SharedGraphics2D.DrawPolyline(null, polyline); } } }
public static void SetParameters(Pen pen, IImage start, IImage middle, IImage end) { if (pen != null) { RoutePen = pen; } if (start != null) { StartIcon = start; } if (middle != null) { MiddleIcon = middle; } if (end != null) { EndIcon = end; } }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 18JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// public static void SetParameter(int field, Object value) { switch (field) { case ROUTE_START_ICON: if (value is IImage) { StartIcon = (IImage)value; } break; case ROUTE_MIDDLE_ICON: if (value is IImage) { MiddleIcon = (IImage)value; } break; case ROUTE_END_ICON: if (value is IImage) { EndIcon = (IImage)value; } break; case ROUTE_DRAW_PEN: if (value is Pen) { RoutePen = (Pen)value; } break; } }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 18JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Constrcutor. */ public MapDirectionRenderer() { if (MapConfiguration.RoutePen != null) { RoutePen = MapConfiguration.RoutePen; } else { RoutePen = new Pen(new Color(0x7F00FF00, false), 4); } if (MapConfiguration.StartIcon != null) { StartIcon = MapConfiguration.StartIcon; } else { StartIcon = ROUTE_ICONS[0]; } if (MapConfiguration.EndIcon != null) { EndIcon = MapConfiguration.EndIcon; } else { EndIcon = ROUTE_ICONS[0]; } if (MapConfiguration.MiddleIcon != null) { MiddleIcon = MapConfiguration.MiddleIcon; } else { MiddleIcon = ROUTE_ICONS[1]; } _mapDirectionLayer = new MapDirectionLayer(MapLayer.MAP_TILE_WIDTH, MapLayer.MAP_TILE_WIDTH); _mapTileImage = MapLayer.GetAbstractGraphicsFactory() .CreateImage(MapLayer.MAP_TILE_WIDTH, MapLayer.MAP_TILE_WIDTH); _mapTileGraphics = _mapTileImage.GetGraphics(); }