PointPlot.cs

Go to the documentation of this file.
00001 /*
00002 NPlot - A charting library for .NET
00003 
00004 PointPlot.cs
00005 Copyright (C) 2003
00006 Matt Howlett, Paolo Pierini
00007 
00008 Redistribution and use of NPlot or parts there-of in source and
00009 binary forms, with or without modification, are permitted provided
00010 that the following conditions are met:
00011 
00012 1. Re-distributions in source form must retain at the head of each
00013    source file the above copyright notice, this list of conditions
00014    and the following disclaimer.
00015 
00016 2. Any product ("the product") that makes use NPlot or parts 
00017    there-of must either:
00018   
00019     (a) allow any user of the product to obtain a complete machine-
00020         readable copy of the corresponding source code for the 
00021         product and the version of NPlot used for a charge no more
00022         than your cost of physically performing source distribution,
00023             on a medium customarily used for software interchange, or:
00024 
00025     (b) reproduce the following text in the documentation, about 
00026         box or other materials intended to be read by human users
00027         of the product that is provided to every human user of the
00028         product: 
00029    
00030               "This product includes software developed as 
00031               part of the NPlot library project available 
00032               from: http://www.nplot.com/" 
00033 
00034         The words "This product" may optionally be replace with 
00035         the actual name of the product.
00036 
00037 ------------------------------------------------------------------------
00038 
00039 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00040 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00041 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00042 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00043 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00044 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00045 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00046 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00047 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00048 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00049 
00050 */
00051 
00052 using System;
00053 using System.Drawing;
00054 
00055 namespace NPlot
00056 {
00057 
00061         public class PointPlot : BaseSequencePlot, ISequencePlot, IPlot
00062         {
00063                 private Marker marker_;
00064 
00068                 public PointPlot()
00069                 {
00070                         marker_ = new Marker();
00071                 }
00072 
00077                 public PointPlot( Marker marker )
00078                 {
00079                         marker_ = marker;
00080                 }
00081 
00082 
00089                 public virtual void Draw( Graphics g, PhysicalAxis xAxis, PhysicalAxis yAxis )
00090                 {
00091                         SequenceAdapter data_ = 
00092                                 new SequenceAdapter( this.DataSource, this.DataMember, this.OrdinateData, this.AbscissaData );
00093 
00094                         for (int i=0; i<data_.Count; ++i)
00095                         {
00096                                 if ( !Double.IsNaN(data_[i].X) && !Double.IsNaN(data_[i].Y) )
00097                                 {
00098                                         PointF xPos = xAxis.WorldToPhysical( data_[i].X, false);
00099                                         PointF yPos = yAxis.WorldToPhysical( data_[i].Y, false);
00100                                         marker_.Draw( g, (int)xPos.X, (int)yPos.Y );
00101                                         if (marker_.DropLine)
00102                                         {
00103                                                 PointD yMin = new PointD( data_[i].X, Math.Max( 0.0f, yAxis.Axis.WorldMin ) );
00104                                                 PointF yStart = yAxis.WorldToPhysical( yMin.Y, false );
00105                                                 g.DrawLine( marker_.Pen, new Point((int)xPos.X,(int)yStart.Y), new Point((int)xPos.X,(int)yPos.Y) );
00106                                         }
00107                                 }
00108                         }
00109                 }
00110 
00111 
00116                 public Axis SuggestXAxis()
00117                 {
00118                         SequenceAdapter data_ = 
00119                                 new SequenceAdapter( this.DataSource, this.DataMember, this.OrdinateData, this.AbscissaData );
00120 
00121                         return data_.SuggestXAxis();
00122                 }
00123 
00124 
00129                 public Axis SuggestYAxis()
00130                 {
00131                         SequenceAdapter data_ = 
00132                                 new SequenceAdapter( this.DataSource, this.DataMember, this.OrdinateData, this.AbscissaData );
00133 
00134                         return data_.SuggestYAxis();
00135                 }
00136 
00137 
00143                 public void DrawInLegend( Graphics g, Rectangle startEnd )
00144                 {
00145                         marker_.Draw( g, (startEnd.Left+startEnd.Right)/2, (startEnd.Top + startEnd.Bottom)/2 );
00146                 }
00147 
00148 
00152                 public Marker Marker
00153                 {
00154                         set
00155                         {
00156                                 marker_ = value;
00157                         }
00158                         get
00159                         {
00160                                 return marker_;
00161                         }
00162                 }
00163 
00164 
00165 
00166         }
00167 }

Generated on Sat Nov 5 01:04:06 2005 for NPlot by  doxygen 1.4.5