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 using System.Collections;
00055
00056 namespace NPlot
00057 {
00058
00066 public class PiAxis : Axis
00067 {
00068
00073 public override object Clone()
00074 {
00075 PiAxis a = new PiAxis();
00076
00077 if (this.GetType() != a.GetType())
00078 {
00079 throw new NPlotException( "Error. Clone method is not defined in derived type." );
00080 }
00081 DoClone( this, a );
00082 return a;
00083 }
00084
00085
00091 protected static void DoClone( PiAxis b, PiAxis a )
00092 {
00093 Axis.DoClone( b, a );
00094 }
00095
00096
00100 private void Init()
00101 {
00102 }
00103
00104
00110 public PiAxis( Axis a )
00111 : base( a )
00112 {
00113 Init();
00114 }
00115
00116
00120 public PiAxis()
00121 : base()
00122 {
00123 Init();
00124 }
00125
00126
00132 public PiAxis( double worldMin, double worldMax )
00133 : base( worldMin, worldMax )
00134 {
00135 Init();
00136 }
00137
00138
00148 protected override void DrawTicks(
00149 Graphics g,
00150 Point physicalMin,
00151 Point physicalMax,
00152 out object labelOffset,
00153 out object boundingBox )
00154 {
00155 Point tLabelOffset;
00156 Rectangle tBoundingBox;
00157
00158 labelOffset = this.getDefaultLabelOffset( physicalMin, physicalMax );
00159 boundingBox = null;
00160
00161 int start = (int)Math.Ceiling( this.WorldMin / Math.PI );
00162 int end = (int)Math.Floor( this.WorldMax / Math.PI );
00163
00164
00165 if ( end - start < 0 || end - start > 30 )
00166 {
00167 return;
00168 }
00169
00170 for (int i=start; i<=end; ++i)
00171 {
00172 string label = i.ToString() + "Pi";
00173
00174 if (i == 0)
00175 label = "0";
00176 else if (i == 1)
00177 label = "Pi";
00178
00179 this.DrawTick( g, i*Math.PI, this.LargeTickSize,
00180 label,
00181 new Point(0,0),
00182 physicalMin, physicalMax,
00183 out tLabelOffset, out tBoundingBox );
00184
00185 Axis.UpdateOffsetAndBounds(
00186 ref labelOffset, ref boundingBox,
00187 tLabelOffset, tBoundingBox );
00188 }
00189
00190 }
00191
00192
00202 internal override void WorldTickPositions_FirstPass(
00203 Point physicalMin,
00204 Point physicalMax,
00205 out ArrayList largeTickPositions,
00206 out ArrayList smallTickPositions
00207 )
00208 {
00209 smallTickPositions = null;
00210 largeTickPositions = new ArrayList();
00211
00212 int start = (int)Math.Ceiling( this.WorldMin / Math.PI );
00213 int end = (int)Math.Floor( this.WorldMax / Math.PI );
00214
00215
00216 if ( end - start < 0 || end - start > 30 )
00217 {
00218 return;
00219 }
00220
00221 for (int i=start; i<end; ++i)
00222 {
00223 largeTickPositions.Add( i*Math.PI );
00224 }
00225
00226 }
00227
00228
00229 }
00230 }