You've already forked lazarus-ccr
lazstats: Refactor AutoCorUnit and related units. Add autocorr.laz test file (not available in OpenStat).
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7429 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
413
applications/lazstats/data/autocorr.laz
Normal file
413
applications/lazstats/data/autocorr.laz
Normal file
@ -0,0 +1,413 @@
|
||||
201
|
||||
1
|
||||
VAR
|
||||
VARIABLE 1
|
||||
5
|
||||
F
|
||||
3
|
||||
99999
|
||||
L
|
||||
Case 0
|
||||
VAR
|
||||
Case 1
|
||||
5.310
|
||||
Case 2
|
||||
5.267
|
||||
Case 3
|
||||
5.936
|
||||
Case 4
|
||||
6.032
|
||||
Case 5
|
||||
6.048
|
||||
Case 6
|
||||
6.188
|
||||
Case 7
|
||||
6.038
|
||||
Case 8
|
||||
6.344
|
||||
Case 9
|
||||
6.176
|
||||
Case 10
|
||||
5.780
|
||||
Case 11
|
||||
5.678
|
||||
Case 12
|
||||
5.843
|
||||
Case 13
|
||||
5.342
|
||||
Case 14
|
||||
5.373
|
||||
Case 15
|
||||
4.798
|
||||
Case 16
|
||||
4.622
|
||||
Case 17
|
||||
4.634
|
||||
Case 18
|
||||
4.267
|
||||
Case 19
|
||||
4.504
|
||||
Case 20
|
||||
4.424
|
||||
Case 21
|
||||
4.452
|
||||
Case 22
|
||||
4.597
|
||||
Case 23
|
||||
4.353
|
||||
Case 24
|
||||
4.671
|
||||
Case 25
|
||||
4.908
|
||||
Case 26
|
||||
5.095
|
||||
Case 27
|
||||
5.257
|
||||
Case 28
|
||||
5.558
|
||||
Case 29
|
||||
6.128
|
||||
Case 30
|
||||
6.144
|
||||
Case 31
|
||||
6.409
|
||||
Case 32
|
||||
6.453
|
||||
Case 33
|
||||
6.309
|
||||
Case 34
|
||||
5.981
|
||||
Case 35
|
||||
6.042
|
||||
Case 36
|
||||
5.932
|
||||
Case 37
|
||||
5.751
|
||||
Case 38
|
||||
5.196
|
||||
Case 39
|
||||
5.145
|
||||
Case 40
|
||||
4.971
|
||||
Case 41
|
||||
4.605
|
||||
Case 42
|
||||
4.381
|
||||
Case 43
|
||||
4.451
|
||||
Case 44
|
||||
4.055
|
||||
Case 45
|
||||
4.309
|
||||
Case 46
|
||||
4.369
|
||||
Case 47
|
||||
4.504
|
||||
Case 48
|
||||
4.506
|
||||
Case 49
|
||||
4.559
|
||||
Case 50
|
||||
5.049
|
||||
Case 51
|
||||
5.398
|
||||
Case 52
|
||||
5.608
|
||||
Case 53
|
||||
5.800
|
||||
Case 54
|
||||
5.969
|
||||
Case 55
|
||||
5.867
|
||||
Case 56
|
||||
6.154
|
||||
Case 57
|
||||
6.482
|
||||
Case 58
|
||||
6.322
|
||||
Case 59
|
||||
6.040
|
||||
Case 60
|
||||
5.911
|
||||
Case 61
|
||||
6.066
|
||||
Case 62
|
||||
5.908
|
||||
Case 63
|
||||
5.582
|
||||
Case 64
|
||||
4.985
|
||||
Case 65
|
||||
5.156
|
||||
Case 66
|
||||
4.549
|
||||
Case 67
|
||||
4.322
|
||||
Case 68
|
||||
4.140
|
||||
Case 69
|
||||
4.434
|
||||
Case 70
|
||||
4.338
|
||||
Case 71
|
||||
4.221
|
||||
Case 72
|
||||
4.578
|
||||
Case 73
|
||||
4.251
|
||||
Case 74
|
||||
4.788
|
||||
Case 75
|
||||
5.083
|
||||
Case 76
|
||||
5.303
|
||||
Case 77
|
||||
5.276
|
||||
Case 78
|
||||
5.581
|
||||
Case 79
|
||||
5.848
|
||||
Case 80
|
||||
5.998
|
||||
Case 81
|
||||
6.140
|
||||
Case 82
|
||||
5.992
|
||||
Case 83
|
||||
6.409
|
||||
Case 84
|
||||
6.418
|
||||
Case 85
|
||||
6.141
|
||||
Case 86
|
||||
5.908
|
||||
Case 87
|
||||
5.765
|
||||
Case 88
|
||||
5.354
|
||||
Case 89
|
||||
5.033
|
||||
Case 90
|
||||
5.083
|
||||
Case 91
|
||||
4.878
|
||||
Case 92
|
||||
4.467
|
||||
Case 93
|
||||
4.612
|
||||
Case 94
|
||||
4.471
|
||||
Case 95
|
||||
4.242
|
||||
Case 96
|
||||
4.446
|
||||
Case 97
|
||||
4.431
|
||||
Case 98
|
||||
4.566
|
||||
Case 99
|
||||
4.520
|
||||
Case 100
|
||||
4.705
|
||||
Case 101
|
||||
4.914
|
||||
Case 102
|
||||
5.541
|
||||
Case 103
|
||||
5.745
|
||||
Case 104
|
||||
5.667
|
||||
Case 105
|
||||
5.834
|
||||
Case 106
|
||||
6.185
|
||||
Case 107
|
||||
6.406
|
||||
Case 108
|
||||
6.450
|
||||
Case 109
|
||||
6.122
|
||||
Case 110
|
||||
5.892
|
||||
Case 111
|
||||
5.977
|
||||
Case 112
|
||||
5.928
|
||||
Case 113
|
||||
5.383
|
||||
Case 114
|
||||
5.450
|
||||
Case 115
|
||||
4.973
|
||||
Case 116
|
||||
4.682
|
||||
Case 117
|
||||
4.536
|
||||
Case 118
|
||||
4.454
|
||||
Case 119
|
||||
4.121
|
||||
Case 120
|
||||
4.398
|
||||
Case 121
|
||||
4.503
|
||||
Case 122
|
||||
4.348
|
||||
Case 123
|
||||
4.337
|
||||
Case 124
|
||||
4.801
|
||||
Case 125
|
||||
4.817
|
||||
Case 126
|
||||
5.178
|
||||
Case 127
|
||||
5.490
|
||||
Case 128
|
||||
5.407
|
||||
Case 129
|
||||
5.738
|
||||
Case 130
|
||||
6.070
|
||||
Case 131
|
||||
5.940
|
||||
Case 132
|
||||
6.188
|
||||
Case 133
|
||||
6.025
|
||||
Case 134
|
||||
6.315
|
||||
Case 135
|
||||
5.917
|
||||
Case 136
|
||||
6.080
|
||||
Case 137
|
||||
6.022
|
||||
Case 138
|
||||
5.508
|
||||
Case 139
|
||||
5.186
|
||||
Case 140
|
||||
5.293
|
||||
Case 141
|
||||
4.847
|
||||
Case 142
|
||||
4.838
|
||||
Case 143
|
||||
4.535
|
||||
Case 144
|
||||
4.166
|
||||
Case 145
|
||||
4.372
|
||||
Case 146
|
||||
4.137
|
||||
Case 147
|
||||
4.353
|
||||
Case 148
|
||||
4.280
|
||||
Case 149
|
||||
4.777
|
||||
Case 150
|
||||
5.013
|
||||
Case 151
|
||||
4.952
|
||||
Case 152
|
||||
5.371
|
||||
Case 153
|
||||
5.794
|
||||
Case 154
|
||||
5.607
|
||||
Case 155
|
||||
5.792
|
||||
Case 156
|
||||
5.889
|
||||
Case 157
|
||||
6.159
|
||||
Case 158
|
||||
6.239
|
||||
Case 159
|
||||
6.460
|
||||
Case 160
|
||||
6.363
|
||||
Case 161
|
||||
5.937
|
||||
Case 162
|
||||
5.828
|
||||
Case 163
|
||||
5.520
|
||||
Case 164
|
||||
5.447
|
||||
Case 165
|
||||
5.154
|
||||
Case 166
|
||||
4.690
|
||||
Case 167
|
||||
4.484
|
||||
Case 168
|
||||
4.556
|
||||
Case 169
|
||||
4.183
|
||||
Case 170
|
||||
4.373
|
||||
Case 171
|
||||
4.363
|
||||
Case 172
|
||||
4.084
|
||||
Case 173
|
||||
4.563
|
||||
Case 174
|
||||
4.707
|
||||
Case 175
|
||||
4.892
|
||||
Case 176
|
||||
5.194
|
||||
Case 177
|
||||
5.477
|
||||
Case 178
|
||||
5.350
|
||||
Case 179
|
||||
5.683
|
||||
Case 180
|
||||
6.034
|
||||
Case 181
|
||||
6.036
|
||||
Case 182
|
||||
6.386
|
||||
Case 183
|
||||
6.436
|
||||
Case 184
|
||||
6.004
|
||||
Case 185
|
||||
5.921
|
||||
Case 186
|
||||
6.016
|
||||
Case 187
|
||||
5.762
|
||||
Case 188
|
||||
5.481
|
||||
Case 189
|
||||
5.496
|
||||
Case 190
|
||||
5.102
|
||||
Case 191
|
||||
4.648
|
||||
Case 192
|
||||
4.600
|
||||
Case 193
|
||||
4.444
|
||||
Case 194
|
||||
4.411
|
||||
Case 195
|
||||
4.097
|
||||
Case 196
|
||||
4.492
|
||||
Case 197
|
||||
4.300
|
||||
Case 198
|
||||
4.326
|
||||
Case 199
|
||||
4.400
|
||||
Case 200
|
||||
4.879
|
||||
Case 201
|
||||
4.868
|
2535
applications/lazstats/data/polydif.laz
Normal file
2535
applications/lazstats/data/polydif.laz
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -1,7 +1,7 @@
|
||||
object AutoCorrFrm: TAutoCorrFrm
|
||||
Left = 456
|
||||
Height = 459
|
||||
Top = 163
|
||||
Top = 145
|
||||
Width = 684
|
||||
AutoSize = True
|
||||
Caption = 'Autocorrelation'
|
||||
@ -35,8 +35,10 @@ object AutoCorrFrm: TAutoCorrFrm
|
||||
Width = 99
|
||||
BorderSpacing.Left = 16
|
||||
Caption = 'A Grid Column'
|
||||
Checked = True
|
||||
OnClick = ColBtnClick
|
||||
TabOrder = 0
|
||||
TabStop = True
|
||||
end
|
||||
object RowBtn: TRadioButton
|
||||
AnchorSideLeft.Control = ColBtn
|
||||
@ -138,86 +140,67 @@ object AutoCorrFrm: TAutoCorrFrm
|
||||
end
|
||||
end
|
||||
object ResetBtn: TButton
|
||||
AnchorSideRight.Control = CancelBtn
|
||||
AnchorSideRight.Control = ComputeBtn
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 387
|
||||
Left = 475
|
||||
Height = 25
|
||||
Top = 426
|
||||
Width = 54
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 12
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 12
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
Caption = 'Reset'
|
||||
OnClick = ResetBtnClick
|
||||
TabOrder = 5
|
||||
end
|
||||
object CancelBtn: TButton
|
||||
AnchorSideRight.Control = ComputeBtn
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 453
|
||||
Height = 25
|
||||
Top = 426
|
||||
Width = 62
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 12
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 12
|
||||
BorderSpacing.Bottom = 8
|
||||
Caption = 'Cancel'
|
||||
ModalResult = 2
|
||||
TabOrder = 6
|
||||
end
|
||||
object ComputeBtn: TButton
|
||||
AnchorSideRight.Control = ReturnBtn
|
||||
AnchorSideRight.Control = CloseBtn
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 527
|
||||
Left = 537
|
||||
Height = 25
|
||||
Top = 426
|
||||
Width = 76
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 12
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 12
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
Caption = 'Compute'
|
||||
ModalResult = 1
|
||||
OnClick = ComputeBtnClick
|
||||
TabOrder = 7
|
||||
TabOrder = 6
|
||||
end
|
||||
object ReturnBtn: TButton
|
||||
object CloseBtn: TButton
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 615
|
||||
Left = 621
|
||||
Height = 25
|
||||
Top = 426
|
||||
Width = 61
|
||||
Width = 55
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 12
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
Caption = 'Return'
|
||||
ModalResult = 1
|
||||
OnClick = ReturnBtnClick
|
||||
TabOrder = 8
|
||||
Caption = 'Close'
|
||||
ModalResult = 11
|
||||
OnClick = CloseBtnClick
|
||||
TabOrder = 7
|
||||
end
|
||||
object HelpBtn: TButton
|
||||
Tag = 104
|
||||
AnchorSideRight.Control = ResetBtn
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 324
|
||||
Left = 416
|
||||
Height = 25
|
||||
Top = 426
|
||||
Width = 51
|
||||
@ -225,7 +208,7 @@ object AutoCorrFrm: TAutoCorrFrm
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 12
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
Caption = 'Help'
|
||||
OnClick = HelpBtnClick
|
||||
@ -235,7 +218,7 @@ object AutoCorrFrm: TAutoCorrFrm
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = ReturnBtn
|
||||
AnchorSideBottom.Control = CloseBtn
|
||||
Left = 0
|
||||
Height = 8
|
||||
Top = 410
|
||||
@ -383,6 +366,7 @@ object AutoCorrFrm: TAutoCorrFrm
|
||||
BorderSpacing.Right = 8
|
||||
Constraints.MinHeight = 220
|
||||
ItemHeight = 0
|
||||
OnSelectionChange = VarListSelectionChange
|
||||
TabOrder = 0
|
||||
end
|
||||
object InBtn: TBitBtn
|
||||
@ -500,6 +484,7 @@ object AutoCorrFrm: TAutoCorrFrm
|
||||
Anchors = [akLeft, akRight, akBottom]
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Bottom = 12
|
||||
ReadOnly = True
|
||||
TabOrder = 3
|
||||
Text = 'DepVarEdit'
|
||||
end
|
||||
@ -659,31 +644,31 @@ object AutoCorrFrm: TAutoCorrFrm
|
||||
Left = 12
|
||||
Height = 19
|
||||
Top = 6
|
||||
Width = 142
|
||||
Caption = 'Correlogram'
|
||||
Width = 148
|
||||
Caption = 'Plot correlogram'
|
||||
TabOrder = 0
|
||||
end
|
||||
object StatsChk: TCheckBox
|
||||
Left = 12
|
||||
Height = 19
|
||||
Top = 27
|
||||
Width = 142
|
||||
Caption = 'Statistics'
|
||||
Width = 148
|
||||
Caption = 'Print statistics'
|
||||
TabOrder = 1
|
||||
end
|
||||
object RMatChk: TCheckBox
|
||||
Left = 12
|
||||
Height = 19
|
||||
Top = 48
|
||||
Width = 142
|
||||
Caption = 'Print correlation Mat.'
|
||||
Width = 148
|
||||
Caption = 'Print correlation matrix'
|
||||
TabOrder = 2
|
||||
end
|
||||
object PartialsChk: TCheckBox
|
||||
Left = 12
|
||||
Height = 19
|
||||
Top = 69
|
||||
Width = 142
|
||||
Width = 148
|
||||
Caption = 'Partial autocorrelations'
|
||||
TabOrder = 3
|
||||
end
|
||||
@ -691,16 +676,16 @@ object AutoCorrFrm: TAutoCorrFrm
|
||||
Left = 12
|
||||
Height = 19
|
||||
Top = 90
|
||||
Width = 142
|
||||
Caption = 'Yule-Walker Coef.s'
|
||||
Width = 148
|
||||
Caption = 'Yule-Walker coefficients'
|
||||
TabOrder = 4
|
||||
end
|
||||
object ResidChk: TCheckBox
|
||||
Left = 12
|
||||
Height = 19
|
||||
Top = 111
|
||||
Width = 142
|
||||
Caption = 'Residual Plot'
|
||||
Width = 148
|
||||
Caption = 'Residual plot'
|
||||
TabOrder = 5
|
||||
end
|
||||
end
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -51,168 +51,168 @@ procedure TAutoPlotFrm.FormShow(Sender: TObject);
|
||||
begin
|
||||
Image1.Canvas.Brush.Color := clWhite;
|
||||
Image1.Canvas.FillRect(0, 0, Image1.Width, Image1.Height);
|
||||
// AutoPlotFrm.Image1.Canvas.Clear;
|
||||
AutoPlot(self);
|
||||
end;
|
||||
|
||||
procedure TAutoPlotFrm.PrintBtnClick(Sender: TObject);
|
||||
var r : Trect;
|
||||
var
|
||||
R: Trect;
|
||||
begin
|
||||
with Printer do
|
||||
begin
|
||||
Printer.Orientation := poPortrait;
|
||||
r := Rect(20,20,printer.pagewidth-20,printer.pageheight div 2 + 20);
|
||||
BeginDoc;
|
||||
Canvas.StretchDraw(r,Image1.Picture.BitMap);
|
||||
EndDoc;
|
||||
end;
|
||||
with Printer do
|
||||
begin
|
||||
Orientation := poPortrait;
|
||||
R := Rect(20,20, PageWidth-20, PageHeight div 2 + 20);
|
||||
BeginDoc;
|
||||
try
|
||||
Canvas.StretchDraw(R, Image1.Picture.BitMap);
|
||||
finally
|
||||
EndDoc;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TAutoPlotFrm.AutoPlot(Sender: TObject);
|
||||
var
|
||||
topmarg, botmarg, leftmarg, rightmarg, verthi, horizlong : integer;
|
||||
i, X, Y, middle, yincrement, xincrement, labelheight : integer;
|
||||
labelstring : string;
|
||||
labelstr : string;
|
||||
corstep, yprop, scaley : double;
|
||||
|
||||
topmarg, botmarg, leftmarg, rightmarg, verthi, horizlong: integer;
|
||||
i, X, Y, middle, yincrement, xincrement, labelheight: integer;
|
||||
labelstring: string;
|
||||
corstep, yprop, scaley: double;
|
||||
begin
|
||||
height := Image1.Canvas.Height;
|
||||
width := Image1.Canvas.Width;
|
||||
middle := height div 2;
|
||||
topmarg := height div 10;
|
||||
verthi := height - (2 * topmarg);
|
||||
botmarg := topmarg + verthi;
|
||||
leftmarg := width div 10;
|
||||
horizlong := width - 2 * leftmarg;
|
||||
rightmarg := leftmarg + horizlong;
|
||||
yincrement := verthi div 20;
|
||||
xincrement := horizlong div npoints;
|
||||
height := Image1.Canvas.Height;
|
||||
width := Image1.Canvas.Width;
|
||||
middle := height div 2;
|
||||
topmarg := height div 10;
|
||||
verthi := height - 3 * topmarg;
|
||||
botmarg := topmarg + verthi;
|
||||
leftmarg := width div 10;
|
||||
horizlong := width - 2 * leftmarg;
|
||||
rightmarg := leftmarg + horizlong;
|
||||
yincrement := verthi div 20;
|
||||
xincrement := horizlong div npoints;
|
||||
|
||||
// AutoPlotFrm.Show;
|
||||
Image1.Canvas.Pen.Color := clBlack;
|
||||
Image1.Canvas.Pen.Color := clBlack;
|
||||
Image1.Canvas.Font.Color := clBlack;
|
||||
|
||||
// print title at top, centered
|
||||
labelstring := 'Autocorrelations analysis for :';
|
||||
labelstring := labelstring + DepVarEdit;
|
||||
X := (leftmarg + horizlong div 2) - (Image1.Canvas.TextWidth(labelstring) div 2);
|
||||
Y := 1;
|
||||
Image1.Canvas.TextOut(X,Y,labelstring);
|
||||
// print title at top, centered
|
||||
labelstring := 'Autocorrelations analysis for ' + DepVarEdit;
|
||||
X := leftmarg + (horizlong - Image1.Canvas.TextWidth(labelstring)) div 2;
|
||||
Y := 1;
|
||||
Image1.Canvas.TextOut(X, Y, labelstring);
|
||||
|
||||
// draw middle (zero correlation) axis
|
||||
Y := middle;
|
||||
Image1.Canvas.MoveTo(leftmarg,Y);
|
||||
X := rightmarg;
|
||||
Image1.Canvas.LineTo(X,Y);
|
||||
// draw middle (zero correlation) axis
|
||||
Image1.Canvas.Pen.Color := clBlack;
|
||||
Image1.Canvas.Line(leftmarg, middle, rightmarg, middle);
|
||||
|
||||
// draw right axis
|
||||
X := leftmarg;
|
||||
// draw left axis
|
||||
Image1.Canvas.Pen.Color := clBlack;
|
||||
Image1.Canvas.Line(leftmarg, topmarg, leftmarg, botmarg);
|
||||
|
||||
// correlation scale to left of vertical axis
|
||||
corstep := 1.0;
|
||||
for i := 0 to 20 do
|
||||
begin
|
||||
Y := topmarg + i * yincrement;
|
||||
labelstring := Format('%4.2f -', [corstep]);
|
||||
X := leftmarg - Image1.Canvas.TextWidth(labelstring);
|
||||
Image1.Canvas.TextOut(X, Y, labelstring);
|
||||
corstep := corstep - 0.1;
|
||||
end;
|
||||
|
||||
// Make legend axis on bottom
|
||||
Image1.Canvas.Pen.Color := clBlack;
|
||||
Y := botmarg;
|
||||
Image1.Canvas.Line(leftmarg, Y, rightmarg, Y);
|
||||
|
||||
Y := botmarg;
|
||||
for i := 0 to npoints do
|
||||
begin
|
||||
X := leftmarg + xincrement * i;
|
||||
labelstring := '|';
|
||||
Image1.Canvas.TextOut(X, Y, labelstring);
|
||||
labelstring := IntToStr(i);
|
||||
Y := Y + 5;
|
||||
if odd(i) then
|
||||
Image1.Canvas.TextOut(X, Y, labelstring);
|
||||
Y := botmarg;
|
||||
Image1.Canvas.MoveTo(X,Y);
|
||||
Y := topmarg;
|
||||
Image1.Canvas.LineTo(X,Y);
|
||||
end;
|
||||
|
||||
// correlation scale to left of vertical axis
|
||||
corstep := 1.0;
|
||||
for i := 0 to 20 do
|
||||
begin
|
||||
Y := topmarg + (i * yincrement);
|
||||
labelstr := format('%4.2f -',[corstep]);
|
||||
labelstring := labelstr;
|
||||
X := leftmarg - Image1.Canvas.TextWidth(labelstring);
|
||||
Image1.Canvas.TextOut(X,Y,labelstring);
|
||||
corstep := corstep - 0.1;
|
||||
end;
|
||||
labelstring := 'LAG VALUE';
|
||||
X := leftmarg + (horizlong - Image1.Canvas.TextWidth(labelstring) div 2);
|
||||
Y := botmarg + Image1.Canvas.TextHeight(labelstring) + 10;
|
||||
Image1.Canvas.TextOut(X, Y, labelstring);
|
||||
|
||||
// Make legend axis on bottom
|
||||
X := leftmarg;
|
||||
Y := botmarg;
|
||||
Image1.Canvas.MoveTo(X,Y);
|
||||
X := rightmarg;
|
||||
Image1.Canvas.LineTo(X,Y);
|
||||
for i := 0 to npoints do
|
||||
begin
|
||||
X := leftmarg + (xincrement * i);
|
||||
labelstring := '|';
|
||||
Image1.Canvas.TextOut(X,Y,labelstring);
|
||||
labelstring := IntToStr(i);
|
||||
Y := Y + 5;
|
||||
if (i mod 2) = 1 then Image1.Canvas.TextOut(X,Y,labelstring);
|
||||
Y := botmarg;
|
||||
end;
|
||||
labelstring := 'LAG VALUE';
|
||||
X := (leftmarg + horizlong div 2) - (Image1.Canvas.TextWidth(labelstring) div 2);
|
||||
Y := botmarg + Image1.Canvas.TextHeight(labelstring);
|
||||
Image1.Canvas.TextOut(X,Y,labelstring);
|
||||
// Plot lines from correlation to correlation
|
||||
Image1.Canvas.Pen.Color := clRed;
|
||||
for i := 0 to npoints - 1 do
|
||||
begin
|
||||
yprop := (1.0 - correlations[i]) / 2.0;
|
||||
scaley := yprop * verthi;
|
||||
X := leftmarg + round(xincrement * i);
|
||||
Y := topmarg + round(scaley);
|
||||
if (i = 0)then
|
||||
Image1.Canvas.MoveTo(X, Y)
|
||||
else
|
||||
Image1.Canvas.LineTo(X, Y);
|
||||
Image1.Canvas.Ellipse(X-3, Y-3, X+3, Y+3);
|
||||
end;
|
||||
|
||||
// Plot lines from correlation to correlation
|
||||
Image1.Canvas.Pen.Color := clRed;
|
||||
// Plot partial correlations
|
||||
if PlotPartCors then
|
||||
begin
|
||||
Image1.Canvas.Pen.Color := clBlue;
|
||||
for i := 0 to npoints - 1 do
|
||||
begin
|
||||
yprop := (1.0 - correlations[i]) / 2.0;
|
||||
scaley := yprop * verthi;
|
||||
X := leftmarg + round(xincrement * i);
|
||||
Y := topmarg + round(scaley);
|
||||
if (i = 0)then Image1.Canvas.MoveTo(X,Y)
|
||||
else Canvas.LineTo(X,Y);
|
||||
Image1.Canvas.Ellipse(X-3,Y-3,X+3,Y+3);
|
||||
yprop := (1.0 - partcors[i]) / 2.0;
|
||||
scaley := yprop * verthi;
|
||||
X := leftmarg + round(xincrement * i);
|
||||
Y := topmarg + round(scaley);
|
||||
if (i = 0) then
|
||||
Image1.Canvas.MoveTo(X,Y)
|
||||
else
|
||||
Image1.Canvas.LineTo(X,Y);
|
||||
Image1.Canvas.Ellipse(X-3, Y-3, X+3, Y+3);
|
||||
end;
|
||||
end;
|
||||
|
||||
// Plot partial correlations
|
||||
if PlotPartCors then
|
||||
begin
|
||||
Image1.Canvas.Pen.Color := clBlue;
|
||||
for i := 0 to npoints - 1 do
|
||||
begin
|
||||
yprop := (1.0 - partcors[i]) / 2.0;
|
||||
scaley := yprop * verthi;
|
||||
X := leftmarg + round(xincrement * i);
|
||||
Y := topmarg + round(scaley);
|
||||
if (i = 0) then Image1.Canvas.MoveTo(X,Y)
|
||||
else Image1.Canvas.LineTo(X,Y);
|
||||
Image1.Canvas.Ellipse(X-3,Y-3,X+3,Y+3);
|
||||
end;
|
||||
end;
|
||||
|
||||
// Plot lines for upper and lower 95% confidence levels
|
||||
if PlotLimits then
|
||||
begin
|
||||
Image1.Canvas.Pen.Color := clGreen;
|
||||
yprop := (1.0 - uplimit) / 2.0;
|
||||
scaley := yprop * verthi;
|
||||
Y := topmarg + round(scaley);
|
||||
Image1.Canvas.MoveTo(leftmarg,Y);
|
||||
X := rightmarg;
|
||||
Image1.Canvas.LineTo(X,Y);
|
||||
yprop := (1.0 - lowlimit) / 2.0;
|
||||
scaley := yprop * verthi;
|
||||
Y := topmarg + round(scaley);
|
||||
Image1.Canvas.MoveTo(leftmarg,Y);
|
||||
X := rightmarg;
|
||||
Image1.Canvas.LineTo(X,Y);
|
||||
end;
|
||||
|
||||
// Show legend at right
|
||||
// Plot lines for upper and lower 95% confidence levels
|
||||
if PlotLimits then
|
||||
begin
|
||||
Image1.Canvas.Pen.Color := clGreen;
|
||||
yprop := (1.0 - uplimit) / 2.0;
|
||||
scaley := yprop * verthi;
|
||||
Y := topmarg + round(scaley);
|
||||
Image1.Canvas.MoveTo(leftmarg,Y);
|
||||
X := rightmarg;
|
||||
labelstring := 'Correlations';
|
||||
labelheight := Image1.Canvas.TextHeight(labelstring);
|
||||
Y := 5 * labelheight;
|
||||
Image1.Canvas.Font.Color := clRed;
|
||||
Image1.Canvas.TextOut(X,Y,labelstring);
|
||||
if PlotPartCors then
|
||||
begin
|
||||
labelstring := 'Partials';
|
||||
Y := 6 * labelheight;
|
||||
Image1.Canvas.Font.Color := clBlue;
|
||||
Image1.Canvas.TextOut(X,Y,labelstring);
|
||||
end;
|
||||
if PlotLimits then
|
||||
begin
|
||||
Y := 7 * labelheight;
|
||||
labelstring := '95% C.I.';
|
||||
Image1.Canvas.Font.Color := clGreen;
|
||||
Image1.Canvas.TextOut(X,Y,labelstring);
|
||||
end;
|
||||
Image1.Canvas.LineTo(X, Y);
|
||||
yprop := (1.0 - lowlimit) / 2.0;
|
||||
scaley := yprop * verthi;
|
||||
Y := topmarg + round(scaley);
|
||||
Image1.Canvas.MoveTo(leftmarg, Y);
|
||||
X := rightmarg;
|
||||
Image1.Canvas.LineTo(X,Y);
|
||||
end;
|
||||
|
||||
// Show legend at right
|
||||
X := rightmarg;
|
||||
labelstring := 'Correlations';
|
||||
labelheight := Image1.Canvas.TextHeight(labelstring);
|
||||
Y := 5 * labelheight;
|
||||
Image1.Canvas.Font.Color := clRed;
|
||||
Image1.Canvas.TextOut(X, Y, labelstring);
|
||||
if PlotPartCors then
|
||||
begin
|
||||
labelstring := 'Partials';
|
||||
Y := 6 * labelheight;
|
||||
Image1.Canvas.Font.Color := clBlue;
|
||||
Image1.Canvas.TextOut(X, Y, labelstring);
|
||||
end;
|
||||
if PlotLimits then
|
||||
begin
|
||||
Y := 7 * labelheight;
|
||||
labelstring := '95% C.I.';
|
||||
Image1.Canvas.Font.Color := clGreen;
|
||||
Image1.Canvas.TextOut(X, Y, labelstring);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TAutoPlotFrm.FormActivate(Sender: TObject);
|
||||
|
@ -2,29 +2,30 @@ object DifferenceFrm: TDifferenceFrm
|
||||
Left = 611
|
||||
Height = 115
|
||||
Top = 292
|
||||
Width = 318
|
||||
Width = 308
|
||||
AutoSize = True
|
||||
BorderStyle = bsDialog
|
||||
Caption = 'Differencing Specification'
|
||||
ClientHeight = 115
|
||||
ClientWidth = 318
|
||||
ClientWidth = 308
|
||||
OnActivate = FormActivate
|
||||
OnShow = FormShow
|
||||
Position = poMainFormCenter
|
||||
LCLVersion = '2.1.0.0'
|
||||
object CancelBtn: TButton
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
AnchorSideTop.Control = Bevel1
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 128
|
||||
AnchorSideRight.Control = OKBtn
|
||||
Left = 188
|
||||
Height = 25
|
||||
Top = 78
|
||||
Width = 62
|
||||
Anchors = [akTop, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 12
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 12
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
Caption = 'Cancel'
|
||||
ModalResult = 2
|
||||
@ -35,16 +36,20 @@ object DifferenceFrm: TDifferenceFrm
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = Bevel1
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 202
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 258
|
||||
Height = 25
|
||||
Top = 78
|
||||
Width = 42
|
||||
Anchors = [akTop, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 16
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
Caption = 'OK'
|
||||
ModalResult = 1
|
||||
OnClick = OKBtnClick
|
||||
TabOrder = 3
|
||||
end
|
||||
object HelpBtn: TButton
|
||||
@ -52,13 +57,13 @@ object DifferenceFrm: TDifferenceFrm
|
||||
AnchorSideTop.Control = Bevel1
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = CancelBtn
|
||||
Left = 65
|
||||
Left = 129
|
||||
Height = 25
|
||||
Top = 78
|
||||
Width = 51
|
||||
Anchors = [akTop, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 16
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
Caption = 'Help'
|
||||
@ -69,14 +74,14 @@ object DifferenceFrm: TDifferenceFrm
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
AnchorSideTop.Control = Owner
|
||||
Left = 68
|
||||
Left = 63
|
||||
Height = 50
|
||||
Top = 8
|
||||
Width = 183
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 12
|
||||
BorderSpacing.Left = 24
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 12
|
||||
BorderSpacing.Right = 24
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 50
|
||||
ClientWidth = 183
|
||||
@ -118,7 +123,7 @@ object DifferenceFrm: TDifferenceFrm
|
||||
Alignment = taRightJustify
|
||||
Anchors = [akTop, akRight]
|
||||
TabOrder = 0
|
||||
Text = '1'
|
||||
Text = 'LagEdit'
|
||||
end
|
||||
object OrderEdit: TEdit
|
||||
AnchorSideTop.Control = LagEdit
|
||||
@ -133,7 +138,7 @@ object DifferenceFrm: TDifferenceFrm
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.Top = 4
|
||||
TabOrder = 1
|
||||
Text = '1'
|
||||
Text = 'OrderEdit'
|
||||
end
|
||||
end
|
||||
object Bevel1: TBevel
|
||||
@ -145,7 +150,7 @@ object DifferenceFrm: TDifferenceFrm
|
||||
Left = 0
|
||||
Height = 8
|
||||
Top = 62
|
||||
Width = 318
|
||||
Width = 308
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Top = 4
|
||||
Shape = bsBottomLine
|
||||
|
@ -25,8 +25,10 @@ type
|
||||
procedure FormActivate(Sender: TObject);
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure HelpBtnClick(Sender: TObject);
|
||||
procedure OKBtnClick(Sender: TObject);
|
||||
private
|
||||
{ private declarations }
|
||||
function Validate(out AMsg: String; out AControl: TWinControl): boolean;
|
||||
public
|
||||
{ public declarations }
|
||||
end;
|
||||
@ -53,8 +55,8 @@ end;
|
||||
|
||||
procedure TDifferenceFrm.FormShow(Sender: TObject);
|
||||
begin
|
||||
LagEdit.Text := '1';
|
||||
OrderEdit.Text := '1';
|
||||
LagEdit.Text := '1';
|
||||
OrderEdit.Text := '1';
|
||||
end;
|
||||
|
||||
procedure TDifferenceFrm.HelpBtnClick(Sender: TObject);
|
||||
@ -64,6 +66,54 @@ begin
|
||||
ContextHelpForm.HelpMessage((Sender as TButton).tag);
|
||||
end;
|
||||
|
||||
procedure TDifferenceFrm.OKBtnClick(Sender: TObject);
|
||||
var
|
||||
msg: String;
|
||||
C: TWinControl;
|
||||
begin
|
||||
if not Validate(msg, C) then
|
||||
begin
|
||||
C.SetFocus;
|
||||
MessageDlg(msg, mtError, [mbOK], 0);
|
||||
ModalResult := mrNone;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TDifferenceFrm.Validate(out AMsg: String; out AControl: TWinControl): Boolean;
|
||||
var
|
||||
n: Integer;
|
||||
begin
|
||||
Result := false;
|
||||
if LagEdit.Text = '' then
|
||||
begin
|
||||
AMsg := 'Input required.';
|
||||
AControl := LagEdit;
|
||||
exit;
|
||||
end;
|
||||
if not TryStrToInt(LagEdit.Text, n) or (n < 0) then
|
||||
begin
|
||||
AMsg := 'Non-negative integer value required.';
|
||||
AControl := LagEdit;
|
||||
exit;
|
||||
end;
|
||||
|
||||
if OrderEdit.Text = '' then
|
||||
begin
|
||||
AMsg := 'Input required.';
|
||||
AControl := OrderEdit;
|
||||
exit;
|
||||
end;
|
||||
if not TryStrToInt(OrderEdit.Text, n) or (n < 0) then
|
||||
begin
|
||||
AMsg := 'Non-negative integer value required.';
|
||||
AControl := OrderEdit;
|
||||
exit;
|
||||
end;
|
||||
|
||||
Result := true;
|
||||
end;
|
||||
|
||||
|
||||
initialization
|
||||
{$I differenceunit.lrs}
|
||||
|
||||
|
@ -9,27 +9,27 @@ object ExpSmoothFrm: TExpSmoothFrm
|
||||
ClientHeight = 131
|
||||
ClientWidth = 352
|
||||
OnActivate = FormActivate
|
||||
OnShow = FormShow
|
||||
Position = poMainFormCenter
|
||||
LCLVersion = '2.1.0.0'
|
||||
object Label1: TLabel
|
||||
AnchorSideTop.Control = AlphaEdit
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Control = AlphaEdit
|
||||
Left = 101
|
||||
Left = 115
|
||||
Height = 15
|
||||
Top = 12
|
||||
Width = 45
|
||||
Width = 31
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.Left = 16
|
||||
BorderSpacing.Right = 8
|
||||
Caption = 'Alpha = '
|
||||
Caption = 'Alpha'
|
||||
ParentColor = False
|
||||
end
|
||||
object Label2: TLabel
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideLeft.Control = AlphaScroll
|
||||
AnchorSideTop.Control = AlphaScroll
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 8
|
||||
Left = 24
|
||||
Height = 15
|
||||
Top = 66
|
||||
Width = 15
|
||||
@ -41,9 +41,9 @@ object ExpSmoothFrm: TExpSmoothFrm
|
||||
object Label3: TLabel
|
||||
AnchorSideTop.Control = AlphaScroll
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Control = AlphaScroll
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 329
|
||||
Left = 313
|
||||
Height = 15
|
||||
Top = 66
|
||||
Width = 15
|
||||
@ -63,6 +63,7 @@ object ExpSmoothFrm: TExpSmoothFrm
|
||||
Width = 44
|
||||
Alignment = taRightJustify
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 16
|
||||
TabOrder = 0
|
||||
Text = '0.99'
|
||||
end
|
||||
@ -72,17 +73,18 @@ object ExpSmoothFrm: TExpSmoothFrm
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 8
|
||||
Left = 16
|
||||
Height = 23
|
||||
Top = 39
|
||||
Width = 336
|
||||
Width = 320
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Left = 16
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 8
|
||||
Max = 1
|
||||
BorderSpacing.Right = 16
|
||||
Max = 99
|
||||
Min = 1
|
||||
PageSize = 0
|
||||
Position = 1
|
||||
Position = 99
|
||||
TabOrder = 1
|
||||
OnChange = AlphaScrollChange
|
||||
end
|
||||
@ -90,12 +92,13 @@ object ExpSmoothFrm: TExpSmoothFrm
|
||||
AnchorSideTop.Control = Bevel1
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = OKBtn
|
||||
Left = 228
|
||||
Left = 220
|
||||
Height = 25
|
||||
Top = 97
|
||||
Width = 62
|
||||
Anchors = [akTop, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 16
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 12
|
||||
BorderSpacing.Bottom = 8
|
||||
@ -108,17 +111,18 @@ object ExpSmoothFrm: TExpSmoothFrm
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 302
|
||||
Left = 294
|
||||
Height = 25
|
||||
Top = 97
|
||||
Width = 42
|
||||
Anchors = [akTop, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Right = 16
|
||||
BorderSpacing.Bottom = 8
|
||||
Caption = 'OK'
|
||||
ModalResult = 1
|
||||
OnClick = OKBtnClick
|
||||
TabOrder = 3
|
||||
end
|
||||
object Bevel1: TBevel
|
||||
|
@ -23,13 +23,15 @@ type
|
||||
AlphaScroll: TScrollBar;
|
||||
procedure AlphaScrollChange(Sender: TObject);
|
||||
procedure FormActivate(Sender: TObject);
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure OKBtnClick(Sender: TObject);
|
||||
private
|
||||
{ private declarations }
|
||||
FAlpha: Double;
|
||||
procedure SetAlpha(AValue: Double);
|
||||
public
|
||||
{ public declarations }
|
||||
alpha : double;
|
||||
end;
|
||||
property Alpha: Double read FAlpha write SetAlpha;
|
||||
end;
|
||||
|
||||
var
|
||||
ExpSmoothFrm: TExpSmoothFrm;
|
||||
@ -47,17 +49,34 @@ begin
|
||||
CancelBtn.Constraints.MinWidth := OKBtn.Constraints.MinWidth;
|
||||
end;
|
||||
|
||||
procedure TExpSmoothFrm.FormShow(Sender: TObject);
|
||||
procedure TExpSmoothFrm.OKBtnClick(Sender: TObject);
|
||||
begin
|
||||
AlphaEdit.Text := '0.99';
|
||||
AlphaScroll.Position := 99;
|
||||
alpha := 0.99;
|
||||
if AlphaEdit.Text = '' then
|
||||
begin
|
||||
AlphaEdit.SetFocus;
|
||||
MessageDlg('Alpha cannot be empty.', mtError, [mbOK], 0);
|
||||
ModalResult := mrNone;
|
||||
end else
|
||||
if not TryStrToFloat(AlphaEdit.Text, FAlpha) or (FAlpha < 0.0) or (FAlpha > 1.0) then
|
||||
begin
|
||||
AlphaEdit.SetFocus;
|
||||
MessageDlg('Alpha must be > 0 and < 1', mtError, [mbOK], 0);
|
||||
ModalResult := mrNone;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TExpSmoothFrm.SetAlpha(AValue: Double);
|
||||
begin
|
||||
if (AValue = FAlpha) then exit;
|
||||
FAlpha := AValue;
|
||||
AlphaScroll.Position := Round(100 * FAlpha);
|
||||
AlphaEdit.Text := FormatFloat('0.00', FAlpha);
|
||||
end;
|
||||
|
||||
procedure TExpSmoothFrm.AlphaScrollChange(Sender: TObject);
|
||||
begin
|
||||
AlphaEdit.Text := FloatToStr(AlphaScroll.Position / 100.0);
|
||||
alpha := AlphaScroll.Position / 100.0;
|
||||
FAlpha := AlphaScroll.Position / 100.0;
|
||||
AlphaEdit.Text := FormatFloat('0.00', FAlpha);
|
||||
end;
|
||||
|
||||
|
||||
|
@ -2,11 +2,11 @@ object FFTFrm: TFFTFrm
|
||||
Left = 648
|
||||
Height = 127
|
||||
Top = 346
|
||||
Width = 305
|
||||
Width = 224
|
||||
BorderStyle = bsDialog
|
||||
Caption = 'Fourier Transform Form'
|
||||
ClientHeight = 127
|
||||
ClientWidth = 305
|
||||
ClientWidth = 224
|
||||
OnActivate = FormActivate
|
||||
Position = poMainFormCenter
|
||||
LCLVersion = '2.1.0.0'
|
||||
@ -14,7 +14,7 @@ object FFTFrm: TFFTFrm
|
||||
AnchorSideTop.Control = Bevel1
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = OKBtn
|
||||
Left = 177
|
||||
Left = 96
|
||||
Height = 25
|
||||
Top = 93
|
||||
Width = 62
|
||||
@ -32,7 +32,7 @@ object FFTFrm: TFFTFrm
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 251
|
||||
Left = 170
|
||||
Height = 25
|
||||
Top = 93
|
||||
Width = 42
|
||||
@ -43,6 +43,7 @@ object FFTFrm: TFFTFrm
|
||||
BorderSpacing.Bottom = 8
|
||||
Caption = 'OK'
|
||||
ModalResult = 1
|
||||
OnClick = OKBtnClick
|
||||
TabOrder = 2
|
||||
end
|
||||
object Memo1: TLabel
|
||||
@ -53,7 +54,7 @@ object FFTFrm: TFFTFrm
|
||||
Left = 8
|
||||
Height = 30
|
||||
Top = 8
|
||||
Width = 289
|
||||
Width = 208
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
@ -64,17 +65,16 @@ object FFTFrm: TFFTFrm
|
||||
end
|
||||
object Panel1: TPanel
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
AnchorSideTop.Control = Memo1
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 66
|
||||
Left = 24
|
||||
Height = 23
|
||||
Top = 50
|
||||
Width = 172
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 64
|
||||
BorderSpacing.Left = 24
|
||||
BorderSpacing.Top = 12
|
||||
BorderSpacing.Right = 64
|
||||
BorderSpacing.Right = 24
|
||||
BorderSpacing.Bottom = 4
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 23
|
||||
@ -115,7 +115,7 @@ object FFTFrm: TFFTFrm
|
||||
Left = 0
|
||||
Height = 8
|
||||
Top = 77
|
||||
Width = 305
|
||||
Width = 224
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
Shape = bsBottomLine
|
||||
end
|
||||
|
@ -21,6 +21,7 @@ type
|
||||
Label1: TLabel;
|
||||
Panel1: TPanel;
|
||||
procedure FormActivate(Sender: TObject);
|
||||
procedure OKBtnClick(Sender: TObject);
|
||||
private
|
||||
{ private declarations }
|
||||
public
|
||||
@ -46,6 +47,24 @@ begin
|
||||
OKBtn.Constraints.MinWidth := w;
|
||||
end;
|
||||
|
||||
procedure TFFTFrm.OKBtnClick(Sender: TObject);
|
||||
var
|
||||
n: Integer;
|
||||
begin
|
||||
if NptsEdit.Text = '' then
|
||||
begin
|
||||
NptsEdit.SetFocus;
|
||||
MessageDlg('Number of points not specified.', mtError, [mbOK], 0);
|
||||
ModalResult := mrNone;
|
||||
end else
|
||||
if not TryStrToInt(NptsEdit.Text, n) or (n <= 0) then
|
||||
begin
|
||||
NptsEdit.SetFocus;
|
||||
MessageDlg('Number of points must be a valid and positive integer.', mtError, [mbOK], 0);
|
||||
ModalResult := mrNone;
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
{$I fftunit.lrs}
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
object MoveAvgFrm: TMoveAvgFrm
|
||||
Left = 434
|
||||
Height = 307
|
||||
Height = 292
|
||||
Top = 163
|
||||
Width = 372
|
||||
Caption = 'Moving Average Specification Form'
|
||||
ClientHeight = 307
|
||||
ClientHeight = 292
|
||||
ClientWidth = 372
|
||||
OnActivate = FormActivate
|
||||
OnShow = FormShow
|
||||
Position = poMainFormCenter
|
||||
LCLVersion = '2.1.0.0'
|
||||
@ -43,7 +44,7 @@ object MoveAvgFrm: TMoveAvgFrm
|
||||
Top = 13
|
||||
Width = 118
|
||||
Alignment = taRightJustify
|
||||
OnKeyPress = OrderEditKeyPress
|
||||
OnEditingDone = OrderEditEditingDone
|
||||
TabOrder = 0
|
||||
Text = 'OrderEdit'
|
||||
end
|
||||
@ -58,19 +59,18 @@ object MoveAvgFrm: TMoveAvgFrm
|
||||
Width = 118
|
||||
Alignment = taRightJustify
|
||||
BorderSpacing.Left = 8
|
||||
OnKeyPress = ThetaEditKeyPress
|
||||
TabOrder = 1
|
||||
Text = 'ThetaEdit'
|
||||
end
|
||||
object ThetaList: TListBox
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideRight.Control = Panel1
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = OKBtn
|
||||
Left = 8
|
||||
Height = 219
|
||||
Height = 171
|
||||
Top = 80
|
||||
Width = 286
|
||||
Width = 356
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Right = 8
|
||||
@ -79,76 +79,79 @@ object MoveAvgFrm: TMoveAvgFrm
|
||||
OnClick = ThetaListClick
|
||||
TabOrder = 2
|
||||
end
|
||||
object Panel1: TPanel
|
||||
object OKBtn: TButton
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 302
|
||||
Height = 157
|
||||
Top = 142
|
||||
Width = 62
|
||||
Left = 322
|
||||
Height = 25
|
||||
Top = 259
|
||||
Width = 42
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
BevelOuter = bvNone
|
||||
ChildSizing.VerticalSpacing = 8
|
||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||
ClientHeight = 157
|
||||
ClientWidth = 62
|
||||
Caption = 'OK'
|
||||
ModalResult = 1
|
||||
OnClick = OKBtnClick
|
||||
TabOrder = 3
|
||||
object HelpBtn: TButton
|
||||
Tag = 132
|
||||
Left = 0
|
||||
Height = 25
|
||||
Top = 0
|
||||
Width = 62
|
||||
AutoSize = True
|
||||
Caption = 'Help'
|
||||
OnClick = HelpBtnClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object ResetBtn: TButton
|
||||
Left = 0
|
||||
Height = 25
|
||||
Top = 33
|
||||
Width = 62
|
||||
AutoSize = True
|
||||
Caption = 'Reset'
|
||||
OnClick = ResetBtnClick
|
||||
TabOrder = 1
|
||||
end
|
||||
object CancelBtn: TButton
|
||||
Left = 0
|
||||
Height = 25
|
||||
Top = 66
|
||||
Width = 62
|
||||
AutoSize = True
|
||||
Caption = 'Cancel'
|
||||
ModalResult = 2
|
||||
TabOrder = 2
|
||||
end
|
||||
object ApplyBtn: TButton
|
||||
Left = 0
|
||||
Height = 25
|
||||
Top = 99
|
||||
Width = 62
|
||||
AutoSize = True
|
||||
Caption = 'Apply'
|
||||
OnClick = ApplyBtnClick
|
||||
TabOrder = 3
|
||||
end
|
||||
object OKBtn: TButton
|
||||
Left = 0
|
||||
Height = 25
|
||||
Top = 132
|
||||
Width = 62
|
||||
AutoSize = True
|
||||
Caption = 'OK'
|
||||
ModalResult = 1
|
||||
TabOrder = 4
|
||||
end
|
||||
end
|
||||
object CancelBtn: TButton
|
||||
AnchorSideTop.Control = OKBtn
|
||||
AnchorSideRight.Control = OKBtn
|
||||
Left = 252
|
||||
Height = 25
|
||||
Top = 259
|
||||
Width = 62
|
||||
Anchors = [akTop, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Right = 8
|
||||
Caption = 'Cancel'
|
||||
ModalResult = 2
|
||||
TabOrder = 4
|
||||
end
|
||||
object ApplyBtn: TButton
|
||||
AnchorSideTop.Control = OKBtn
|
||||
AnchorSideRight.Control = CancelBtn
|
||||
Left = 187
|
||||
Height = 25
|
||||
Top = 259
|
||||
Width = 57
|
||||
Anchors = [akTop, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Right = 8
|
||||
Caption = 'Apply'
|
||||
OnClick = ApplyBtnClick
|
||||
TabOrder = 5
|
||||
end
|
||||
object ResetBtn: TButton
|
||||
AnchorSideTop.Control = OKBtn
|
||||
AnchorSideRight.Control = ApplyBtn
|
||||
Left = 125
|
||||
Height = 25
|
||||
Top = 259
|
||||
Width = 54
|
||||
Anchors = [akTop, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Right = 8
|
||||
Caption = 'Reset'
|
||||
OnClick = ResetBtnClick
|
||||
TabOrder = 6
|
||||
end
|
||||
object HelpBtn: TButton
|
||||
Tag = 132
|
||||
AnchorSideTop.Control = OKBtn
|
||||
AnchorSideRight.Control = ResetBtn
|
||||
Left = 66
|
||||
Height = 25
|
||||
Top = 259
|
||||
Width = 51
|
||||
Anchors = [akTop, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Right = 8
|
||||
Caption = 'Help'
|
||||
OnClick = HelpBtnClick
|
||||
TabOrder = 7
|
||||
end
|
||||
end
|
||||
|
@ -15,7 +15,6 @@ type
|
||||
|
||||
TMoveAvgFrm = class(TForm)
|
||||
HelpBtn: TButton;
|
||||
Panel1: TPanel;
|
||||
ResetBtn: TButton;
|
||||
CancelBtn: TButton;
|
||||
ApplyBtn: TButton;
|
||||
@ -26,17 +25,20 @@ type
|
||||
OrderEdit: TEdit;
|
||||
Label1: TLabel;
|
||||
procedure ApplyBtnClick(Sender: TObject);
|
||||
procedure FormActivate(Sender: TObject);
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure HelpBtnClick(Sender: TObject);
|
||||
procedure OrderEditKeyPress(Sender: TObject; var Key: char);
|
||||
procedure OKBtnClick(Sender: TObject);
|
||||
procedure OrderEditEditingDone(Sender: TObject);
|
||||
procedure ResetBtnClick(Sender: TObject);
|
||||
procedure ThetaEditKeyPress(Sender: TObject; var Key: char);
|
||||
procedure ThetaEditEditingDone(Sender: TObject);
|
||||
procedure ThetaListClick(Sender: TObject);
|
||||
private
|
||||
{ private declarations }
|
||||
function Validate(out AMsg: String; out AControl: TWinControl): Boolean;
|
||||
public
|
||||
{ public declarations }
|
||||
W : array[0..20] of double;
|
||||
W: array[0..20] of double;
|
||||
order : integer;
|
||||
currentindex : integer;
|
||||
|
||||
@ -47,42 +49,59 @@ var
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
Math;
|
||||
|
||||
{ TMoveAvgFrm }
|
||||
|
||||
procedure TMoveAvgFrm.ResetBtnClick(Sender: TObject);
|
||||
VAR i : integer;
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
OrderEdit.Text := '';
|
||||
ThetaEdit.Text := '';
|
||||
ThetaList.Clear;
|
||||
currentindex := 0;
|
||||
for i := 0 to 20 do W[i] := 1.0;
|
||||
OrderEdit.Text := '';
|
||||
ThetaEdit.Text := '';
|
||||
ThetaList.Clear;
|
||||
CurrentIndex := 0;
|
||||
for i := 0 to 20 do W[i] := 1.0;
|
||||
end;
|
||||
|
||||
procedure TMoveAvgFrm.ThetaEditEditingDone(Sender: TObject);
|
||||
var
|
||||
cellString: String;
|
||||
begin
|
||||
if CurrentIndex < 1 then
|
||||
exit;
|
||||
cellString := Format('Theta(%d) = %s', [currentIndex + 1, ThetaEdit.Text]);
|
||||
ThetaList.Items[CurrentIndex] := cellString;
|
||||
W[currentIndex + 1] := StrToFloat(ThetaEdit.Text);
|
||||
end;
|
||||
(*
|
||||
procedure TMoveAvgFrm.ThetaEditKeyPress(Sender: TObject; var Key: char);
|
||||
var cellstring : string;
|
||||
|
||||
var
|
||||
cellstring: string;
|
||||
begin
|
||||
if currentindex < 1 then exit;
|
||||
if ord(Key) <> 13 then exit;
|
||||
cellstring := 'Theta(' + IntToStr(currentindex + 1) + ') = ';
|
||||
cellstring := cellstring + ThetaEdit.Text;
|
||||
W[currentindex + 1] := StrToFloat(ThetaEdit.Text);
|
||||
end;
|
||||
if currentindex < 1 then exit;
|
||||
if ord(Key) <> 13 then exit;
|
||||
cellstring := 'Theta(' + IntToStr(currentindex + 1) + ') = ' + ThetaEdit.Text;
|
||||
W[currentindex + 1] := StrToFloat(ThetaEdit.Text);
|
||||
end; *)
|
||||
|
||||
procedure TMoveAvgFrm.ThetaListClick(Sender: TObject);
|
||||
VAR index : integer;
|
||||
var
|
||||
index: integer;
|
||||
begin
|
||||
index := ThetaList.ItemIndex;
|
||||
if index < 0 then exit;
|
||||
index := ThetaList.ItemIndex;
|
||||
if index >= 0 then
|
||||
begin
|
||||
currentindex := index;
|
||||
ThetaEdit.Text := '1.0';
|
||||
ThetaEdit.SetFocus;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMoveAvgFrm.FormShow(Sender: TObject);
|
||||
begin
|
||||
ResetBtnClick(self);
|
||||
ResetBtnClick(self);
|
||||
end;
|
||||
|
||||
procedure TMoveAvgFrm.HelpBtnClick(Sender: TObject);
|
||||
@ -92,38 +111,108 @@ begin
|
||||
ContextHelpForm.HelpMessage((Sender as TButton).tag);
|
||||
end;
|
||||
|
||||
procedure TMoveAvgFrm.ApplyBtnClick(Sender: TObject);
|
||||
procedure TMoveAvgFrm.OKBtnClick(Sender: TObject);
|
||||
var
|
||||
sum : double;
|
||||
i : integer;
|
||||
cellstring : string;
|
||||
|
||||
msg: String;
|
||||
C: TWinControl;
|
||||
begin
|
||||
ThetaList.Clear;
|
||||
sum := W[0];
|
||||
for i := 1 to order do sum := sum + (2.0 * W[i]);
|
||||
for i := 0 to order do
|
||||
begin
|
||||
W[i] := W[i] / sum;
|
||||
cellstring := 'Theta(' + IntToStr(i+1) + ') = ';
|
||||
cellstring := cellstring + FloatToStr(W[i]);
|
||||
ThetaList.Items.Add(cellstring);
|
||||
end;
|
||||
if not Validate(msg, C) then
|
||||
begin
|
||||
C.SetFocus;
|
||||
MessageDlg(msg, mtError, [mbOK], 0);
|
||||
ModalResult := mrNone;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMoveAvgFrm.OrderEditKeyPress(Sender: TObject; var Key: char);
|
||||
VAR cellstring : string;
|
||||
i : integer;
|
||||
|
||||
procedure TMoveAvgFrm.ApplyBtnClick(Sender: TObject);
|
||||
var
|
||||
sum: double;
|
||||
i: integer;
|
||||
cellstring: string;
|
||||
begin
|
||||
if ord(Key) <> 13 then exit;
|
||||
ThetaList.Clear;
|
||||
sum := W[0];
|
||||
for i := 1 to order do
|
||||
sum := sum + 2.0 * W[i];
|
||||
for i := 0 to order do
|
||||
begin
|
||||
W[i] := W[i] / sum;
|
||||
cellstring := 'Theta(' + IntToStr(i+1) + ') = ' + FloatToStr(W[i]);
|
||||
ThetaList.Items.Add(cellstring);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMoveAvgFrm.FormActivate(Sender: TObject);
|
||||
var
|
||||
wid: Integer;
|
||||
begin
|
||||
wid := MaxValue([HelpBtn.Width, ResetBtn.Width, ApplyBtn.Width, CancelBtn.Width, OKBtn.Width]);
|
||||
HelpBtn.Constraints.MinWidth := wid;
|
||||
ResetBtn.Constraints.MinWidth := wid;
|
||||
ApplyBtn.Constraints.MinWidth := wid;
|
||||
CancelBtn.Constraints.MinWidth := wid;
|
||||
OKBtn.Constraints.MinWidth := wid;
|
||||
end;
|
||||
|
||||
procedure TMoveAvgFrm.OrderEditEditingDone(Sender: TObject);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
ThetaList.Items.BeginUpdate;
|
||||
try
|
||||
ThetaList.Clear;
|
||||
order := StrToInt(OrderEdit.Text);
|
||||
for i := 1 to order do
|
||||
begin
|
||||
cellstring := 'Theta(' + IntToStr(i) + ')';
|
||||
ThetaList.Items.Add(cellstring);
|
||||
end;
|
||||
Order := StrToInt(orderEdit.Text);
|
||||
for i := 1 to Order do
|
||||
ThetaList.Items.Add('Theta(' + IntToStr(i) + ')');
|
||||
finally
|
||||
ThetaList.Items.EndUpdate;
|
||||
end;
|
||||
end;
|
||||
|
||||
(*
|
||||
procedure TMoveAvgFrm.OrderEditKeyPress(Sender: TObject; var Key: char);
|
||||
var
|
||||
cellstring: string;
|
||||
i: integer;
|
||||
begin
|
||||
if ord(Key) <> 13 then exit;
|
||||
ThetaList.Clear;
|
||||
order := StrToInt(OrderEdit.Text);
|
||||
for i := 1 to order do
|
||||
begin
|
||||
cellstring := 'Theta(' + IntToStr(i) + ')';
|
||||
ThetaList.Items.Add(cellstring);
|
||||
end;
|
||||
end;
|
||||
*)
|
||||
|
||||
function TMoveAvgFrm.Validate(out AMsg: String; out AControl: TWinControl): Boolean;
|
||||
var
|
||||
n: Integer;
|
||||
begin
|
||||
Result := false;
|
||||
|
||||
if OrderEdit.Text = '' then
|
||||
begin
|
||||
AControl := OrderEdit;
|
||||
AMsg := 'Input required.';
|
||||
exit;
|
||||
end;
|
||||
if not TryStrToInt(OrderEdit.Text, n) or (n < 0) then
|
||||
begin
|
||||
AControl := OrderEdit;
|
||||
AMsg := 'Non-negative integer value required.';
|
||||
exit;
|
||||
end;
|
||||
|
||||
if ThetaEdit.Text <> '' then
|
||||
begin
|
||||
AControl := ThetaEdit;
|
||||
AMsg := 'Please press ENTER to add this input.';
|
||||
exit;
|
||||
end;
|
||||
|
||||
Result := true;
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
@ -45,6 +45,7 @@ object PolynomialFrm: TPolynomialFrm
|
||||
BorderSpacing.Bottom = 8
|
||||
Caption = 'OK'
|
||||
ModalResult = 1
|
||||
OnClick = OKBtnClick
|
||||
TabOrder = 3
|
||||
end
|
||||
object HelpBtn: TButton
|
||||
|
@ -24,6 +24,7 @@ type
|
||||
procedure FormActivate(Sender: TObject);
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure HelpBtnClick(Sender: TObject);
|
||||
procedure OKBtnClick(Sender: TObject);
|
||||
private
|
||||
{ private declarations }
|
||||
public
|
||||
@ -62,6 +63,24 @@ begin
|
||||
ContextHelpForm.HelpMessage((Sender as TButton).tag);
|
||||
end;
|
||||
|
||||
procedure TPolynomialFrm.OKBtnClick(Sender: TObject);
|
||||
var
|
||||
n: Integer;
|
||||
begin
|
||||
if PolyEdit.Text = '' then
|
||||
begin
|
||||
PolyEdit.SetFocus;
|
||||
MessageDlg('Polynomial order not specified.', mtError, [mbOK], 0);
|
||||
ModalResult := mrNone;
|
||||
end else
|
||||
if not TryStrToInt(PolyEdit.Text, n) or (n < 0) then
|
||||
begin
|
||||
PolyEdit.SetFocus;
|
||||
MessageDlg('Polynomial order must be a valid integer > 0', mtError, [mbOK], 0);
|
||||
ModalResult := mrNone;
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
{$I polynomialunit.lrs}
|
||||
|
||||
|
@ -63,12 +63,15 @@ const
|
||||
|
||||
procedure DisplayReport(AReport: TStrings);
|
||||
begin
|
||||
if OutputFrm = nil then
|
||||
OutputFrm := TOutputFrm.Create(Application)
|
||||
else
|
||||
OutputFrm.Clear;
|
||||
OutputFrm.AddLines(AReport);
|
||||
OutputFrm.ShowModal;
|
||||
if AReport.Count > 0 then
|
||||
begin
|
||||
if OutputFrm = nil then
|
||||
OutputFrm := TOutputFrm.Create(Application)
|
||||
else
|
||||
OutputFrm.Clear;
|
||||
OutputFrm.AddLines(AReport);
|
||||
OutputFrm.ShowModal;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
@ -89,11 +89,14 @@ const
|
||||
);
|
||||
|
||||
DIVIDER = '===========================================================================';
|
||||
DIVIDER_SMALL = '---------------------------------------------------------------------------';
|
||||
|
||||
GRAPH_BACK_COLOR = clCream;
|
||||
GRAPH_WALL_COLOR = clGray;
|
||||
GRAPH_FLOOR_COLOR = clLtGray;
|
||||
|
||||
TWO_PI = 2.0 * PI;
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
||||
|
Reference in New Issue
Block a user