00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 using System;
00053 using System.Drawing;
00054
00055 namespace NPlot
00056 {
00057
00061 public class BarPlot : BasePlot, IPlot, IDrawable
00062 {
00063
00067 public BarPlot()
00068 {
00069 }
00070
00071
00075 public object OrdinateDataTop
00076 {
00077 get
00078 {
00079 return this.ordinateDataTop_;
00080 }
00081 set
00082 {
00083 this.ordinateDataTop_ = value;
00084 }
00085 }
00086 private object ordinateDataTop_ = null;
00087
00088
00092 public object OrdinateDataBottom
00093 {
00094 get
00095 {
00096 return this.ordinateDataBottom_;
00097 }
00098 set
00099 {
00100 this.ordinateDataBottom_ = value;
00101 }
00102 }
00103 private object ordinateDataBottom_ = null;
00104
00105
00109 public object AbscissaData
00110 {
00111 get
00112 {
00113 return this.abscissaData_;
00114 }
00115 set
00116 {
00117 this.abscissaData_ = value;
00118 }
00119 }
00120 private object abscissaData_ = null;
00121
00122
00129 public void Draw( Graphics g, PhysicalAxis xAxis, PhysicalAxis yAxis )
00130 {
00131 SequenceAdapter dataTop =
00132 new SequenceAdapter( this.DataSource, this.DataMember, this.OrdinateDataTop, this.AbscissaData );
00133
00134 SequenceAdapter dataBottom =
00135 new SequenceAdapter( this.DataSource, this.DataMember, this.OrdinateDataBottom, this.AbscissaData );
00136
00137 ITransform2D t = Transform2D.GetTransformer( xAxis, yAxis );
00138
00139 for (int i=0; i<dataTop.Count; ++i)
00140 {
00141 PointF physicalBottom = t.Transform( dataBottom[i] );
00142 PointF physicalTop = t.Transform( dataTop[i] );
00143
00144 Rectangle r = new Rectangle( (int)physicalBottom.X - 4, (int)physicalTop.Y,
00145 8, (int)(physicalBottom.Y - physicalTop.Y) );
00146
00147 g.FillRectangle( this.rectangleBrush_.Get(r), r );
00148 g.DrawRectangle( borderPen_, r );
00149
00150 }
00151
00152 }
00153
00158 public Axis SuggestXAxis()
00159 {
00160 SequenceAdapter dataBottom_ =
00161 new SequenceAdapter( this.DataSource, this.DataMember, this.OrdinateDataBottom, this.AbscissaData );
00162
00163 SequenceAdapter dataTop_ =
00164 new SequenceAdapter( this.DataSource, this.DataMember, this.OrdinateDataTop, this.AbscissaData );
00165
00166 return dataBottom_.SuggestXAxis();
00167 }
00168
00169
00174 public Axis SuggestYAxis()
00175 {
00176 SequenceAdapter dataBottom_ =
00177 new SequenceAdapter( this.DataSource, this.DataMember, this.OrdinateDataBottom, this.AbscissaData );
00178
00179 SequenceAdapter dataTop_ =
00180 new SequenceAdapter( this.DataSource, this.DataMember, this.OrdinateDataTop, this.AbscissaData );
00181
00182 return dataTop_.SuggestYAxis();
00183 }
00184
00185
00191 public virtual void DrawInLegend(Graphics g, Rectangle startEnd)
00192 {
00193 int smallerHeight = (int)(startEnd.Height * 0.5f);
00194 int heightToRemove = (int)(startEnd.Height * 0.5f);
00195 Rectangle newRectangle = new Rectangle( startEnd.Left, startEnd.Top + smallerHeight / 2, startEnd.Width, smallerHeight );
00196 g.FillRectangle( rectangleBrush_.Get( newRectangle ), newRectangle );
00197 g.DrawRectangle( borderPen_, newRectangle );
00198 }
00199
00203 public System.Drawing.Pen BorderPen
00204 {
00205 get
00206 {
00207 return borderPen_;
00208 }
00209 set
00210 {
00211 borderPen_ = value;
00212 }
00213 }
00214 private System.Drawing.Pen borderPen_ = new Pen(Color.Black);
00215
00216
00220 public System.Drawing.Color BorderColor
00221 {
00222 set
00223 {
00224 if (borderPen_ != null)
00225 {
00226 borderPen_.Color = value;
00227 }
00228 else
00229 {
00230 borderPen_ = new Pen(value);
00231 }
00232 }
00233 get
00234 {
00235 return borderPen_.Color;
00236 }
00237 }
00238
00239
00243 public IRectangleBrush FillBrush
00244 {
00245 get
00246 {
00247 return rectangleBrush_;
00248 }
00249 set
00250 {
00251 rectangleBrush_ = value;
00252 }
00253
00254 }
00255 private IRectangleBrush rectangleBrush_ = new RectangleBrushes.Solid( Color.LightGray );
00256
00257
00258
00266 public void WriteData( System.Text.StringBuilder sb, RectangleD region, bool onlyInRegion )
00267 {
00268 sb.Append( "Write data not implemented yet for BarPlot\r\n" );
00269 }
00270
00271
00272 }
00273
00274 }