-
Notifications
You must be signed in to change notification settings - Fork 0
/
Java.pas
102 lines (89 loc) · 2.81 KB
/
Java.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
unit Java;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ActnList, UsesUnit;
type
TfrmMain = class(TForm)
memoSource: TMemo;
btnLoadText: TButton;
dlgFileOpen: TOpenDialog;
alMain: TActionList;
aLoadCode: TAction;
memoCode: TMemo;
memoResult: TMemo;
procedure aLoadCodeExecute(Sender: TObject);
private
tree: ptRec;
procedure CalcMetriks(const fileName: string);
procedure LoadTextAndDecode(const fileName: string);
procedure CreateTreeFromCode(memoCode: TMemo);
procedure CalcAndShowJilbMetrix;
{ Private declarations }
public
{ Public declarations }
end;
var
frmMain: TfrmMain;
implementation
{$R *.dfm}
uses OtherFunctions, ConstrFunctions, Metrix, Tree;
procedure TfrmMain.aLoadCodeExecute(Sender: TObject);
begin
if dlgFileOpen.Execute
then begin
trDeleteTree(tree);
CalcMetriks(dlgFileOpen.Files[0]);
end;
end;
procedure TfrmMain.LoadTextAndDecode(const fileName: string);
var tempStr: string;
begin
memoSource.Lines.BeginUpdate;
memoSource.Lines.Clear;
LoadTextFromFileToMemo(fileName, memoSource);
ofDeleteFiguresFromText(memoSource);
memoSource.Lines.EndUpdate;
tempStr:=memoSource.Lines.Text;
ofDeleteComments(tempStr);
memoCode.Lines.BeginUpdate;
memoCode.Lines.Clear;
memoCode.Lines.Text:=tempStr;
memoCode.Lines.Text:=trim(memoCode.Lines.Text);
memoCode.Lines.EndUpdate;
end;
procedure TfrmMain.CalcAndShowJilbMetrix;
var jilbM: tMetrixRec;
absGran: integer;
begin
jilbM.fCond:=0;
jilbM.fOper:=0;
jilbM.fLevel:=0;
mtrJilb(tree, jilbM);
memoResult.Lines.Add('Ðåçóëüòàòû ìåòðèêè Äæèëáà'+#13#10+'CL = '+IntToStr(jilbM.fCond)+#13#10+'cl = '+ofConvertRealToString(jilbM.fCond/jilbM.fOper)+' ('+IntToStr(jilbM.fCond)+'/'+IntToStr(jilbM.fOper)+')'+#13#10+'CLI = '+IntToStr(jilbM.fLevel)+#13#10+#13#10);
mtrCalcGranichnuy(tree);
absGran:=0;
mtrGran(tree, absGran);
memoResult.Lines.Add('Ðåçóëüòàòû ìåòðèêè ãðàíè÷íûõ çíà÷åíèé'+#13#10+'Àáñîëþòíàÿ ãðàíè÷íàÿ ñëîæíîñòü = '+IntToStr(absGran)+#13#10+'Îòíîñèòåëüíàÿ ãðàíè÷íàÿ ñëîæíîñòü = '+ofConvertRealToString(1-(jilbM.fOper+1)/absGran)+' (1 - ('+IntToStr(jilbM.fOper+2)+'-1)/'+IntToStr(absGran)+')');
end;
procedure TfrmMain.CalcMetriks(const fileName: string);
begin
LoadTextAndDecode(fileName);
CreateTreeFromCode(memoCode);
memoResult.Lines.BeginUpdate;
memoResult.Lines.Clear;
CalcAndShowJilbMetrix;
memoResult.Lines.EndUpdate;
end;
procedure TfrmMain.CreateTreeFromCode(memoCode: TMemo);
var memoPos: integer;
begin
tree:=trCreateRoot;
memoPos:=0;
while (memoPos<memoCode.Lines.Count)
do begin
if cfDecodeString(memoPos, tree, memoCode.Lines)
then inc(memoPos);
end;
end;
end.