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
00053 using System;
00054 using System.Drawing;
00055
00056 namespace NPlot
00057 {
00058
00062 public class VerticalLine : IPlot
00063 {
00064
00069 public VerticalLine( double abscissaValue )
00070 {
00071 this.value_ = abscissaValue;
00072 }
00073
00074
00080 public VerticalLine( double abscissaValue, Color color )
00081 {
00082 this.value_ = abscissaValue;
00083 this.pen_ = new Pen( color );
00084 }
00085
00086
00092 public VerticalLine( double abscissaValue, Pen pen )
00093 {
00094 this.value_ = abscissaValue;
00095 this.pen_ = pen;
00096 }
00097
00103 public void DrawInLegend(System.Drawing.Graphics g, System.Drawing.Rectangle startEnd)
00104 {
00105 g.DrawLine( pen_, startEnd.Left, (startEnd.Top + startEnd.Bottom)/2,
00106 startEnd.Right, (startEnd.Top + startEnd.Bottom)/2 );
00107 }
00108
00109
00113 public string Label
00114 {
00115 get
00116 {
00117 return label_;
00118 }
00119 set
00120 {
00121 this.label_ = value;
00122 }
00123 }
00124
00125 private string label_ = "";
00126
00127
00131 public bool ShowInLegend
00132 {
00133 get
00134 {
00135 return showInLegend_;
00136 }
00137 set
00138 {
00139 this.showInLegend_ = value;
00140 }
00141 }
00142 private bool showInLegend_ = false;
00143
00148 public Axis SuggestXAxis()
00149 {
00150 return new LinearAxis( value_, value_ );
00151 }
00152
00153
00158 public Axis SuggestYAxis()
00159 {
00160 return null;
00161 }
00162
00163
00172 public void WriteData(System.Text.StringBuilder sb, RectangleD region, bool onlyInRegion)
00173 {
00174
00175
00176 if (value_ > region.X+region.Width || value_ < region.X)
00177 {
00178 if (onlyInRegion)
00179 {
00180 return;
00181 }
00182 }
00183
00184 sb.Append( "Label: " );
00185 sb.Append( this.Label );
00186 sb.Append( "\r\n" );
00187 sb.Append( value_.ToString() );
00188 sb.Append( "\r\n" );
00189
00190 }
00191
00192
00199 public void Draw(System.Drawing.Graphics g, PhysicalAxis xAxis, PhysicalAxis yAxis)
00200 {
00201 int yMin = yAxis.PhysicalMin.Y;
00202 int yMax = yAxis.PhysicalMax.Y;
00203
00204 yMin -= pixelIndent_;
00205 yMax += pixelIndent_;
00206
00207 float length = Math.Abs(yMax - yMin);
00208 float lengthDiff = length - length*scale_;
00209 float indentAmount = lengthDiff/2;
00210
00211 yMin -= (int)indentAmount;
00212 yMax += (int)indentAmount;
00213
00214 int xPos = (int)xAxis.WorldToPhysical( value_, false ).X;
00215
00216 g.DrawLine( pen_, new System.Drawing.Point( xPos, yMin ), new System.Drawing.Point( xPos, yMax ) );
00217
00218
00219 }
00220
00221
00225 public double AbscissaValue
00226 {
00227 get
00228 {
00229 return value_;
00230 }
00231 set
00232 {
00233 value_ = value;
00234 }
00235 }
00236
00240 public Pen Pen
00241 {
00242 get
00243 {
00244 return pen_;
00245 }
00246 set
00247 {
00248 pen_ = value;
00249 }
00250 }
00251
00252
00253 private double value_;
00254 private Pen pen_ = new Pen( Color.Black );
00255
00256
00260 public int PixelIndent
00261 {
00262 get
00263 {
00264 return pixelIndent_;
00265 }
00266 set
00267 {
00268 pixelIndent_ = value;
00269 }
00270 }
00271 private int pixelIndent_ = 0;
00272
00273
00278 public float LengthScale
00279 {
00280 get
00281 {
00282 return scale_;
00283 }
00284 set
00285 {
00286 scale_ = value;
00287 }
00288 }
00289 private float scale_ = 1.0f;
00290
00291
00292 }
00293 }