-
Notifications
You must be signed in to change notification settings - Fork 0
/
Programer Documentation.rtf
138 lines (93 loc) · 7.55 KB
/
Programer Documentation.rtf
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
{\rtf1\ansi\deff0\nouicompat{\fonttbl{\f0\fnil\fcharset0 Calibri;}{\f1\fmodern JetBrains Mono;}}
{\colortbl ;\red204\green120\blue50;\red169\green183\blue198;\red255\green198\blue109;}
{\*\generator Riched20 10.0.19041}\viewkind4\uc1
\pard\sa200\sl276\slmult1\qc\f0\fs24\lang9 Programmer Documentation\par
\pard\sl276\slmult1\fs22 The Program is structured in following way:\par
Menu is mainly UI part setting up the environment for the user. Class CanvasPanel is main overlooking class. Classes Point, Points and Matrix are for constructing new instances. Then there are classes Interpolation and Export which take care of what they are named after. Finally class Global, which holds data used in whole program.\par
\par
\pard\box\brdrdash\brdrw0 \sl276\slmult1\cf1\f1\fs20 public class \cf2 Menu \cf1 implements \cf2 Runnable\par
\pard\sl276\slmult1\cf0\f0\fs22 Menu initializes menu with JFrame, adding to it JPanel with buttons and label. Class implements Runnable, by overriding the method run. Each of previously stated has its own function which is taken into detailes below.\par
\par
\pard\box\brdrdash\brdrw0 \sl276\slmult1\cf1\f1\fs20 private void \cf3 initGUI\cf2 ()\par
\pard\sl276\slmult1\cf0\f0\fs22 Firstly creates JFrame and sets its bounds adaptively to users screen resolution. Afterwards adds close operation, appends JPanel and sets visibility to true.\par
\par
\pard\box\brdrdash\brdrw0 \sl276\slmult1\cf1\f1\fs20 private \cf2 JPanel \cf3 setupPanel\cf2 ()\par
\pard\sl276\slmult1\cf0\f0\fs22 Creates new JPanel with no layout and sets background color, then adds name by creating new JLabel and to it all three buttons which are all appended to the panel before returning it from the function.\par
\par
\pard\box\brdrdash\brdrw0 \sl276\slmult1\cf1\f1\fs20 private \cf2 JButton \cf3 createButton\cf2 (String name\cf1 , int \cf2 buttonCount)\par
\pard\sl276\slmult1\cf0\f0\fs22 Firstly creates new JButton. After creating intial parameters, such as bounds, border, background, font, foreground, then is added ActionListener, with a switch case deciding functionality - exiting, showing user documentation or starting drawing itself. At the end there is also another MouseListener added, which covers responsibility for user interaction, with highlighting buttons, while hovered over.\par
\par
\pard\box\brdrdash\brdrw0 \sl276\slmult1\cf1\f1\fs20 private \cf2 String \cf3 getUserDoc\cf2 ()\par
\pard\sl276\slmult1\cf0\f0\fs22 Returns user documentation as a string from a file in rtf format.\par
\par
\pard\box\brdrdash\brdrw0 \sl276\slmult1\cf1\f1\fs20 private void \cf3 startDrawing\cf2 ()\par
\pard\sl276\slmult1\cf0\f0\fs22 Creates new JFrame, replaces old one and adds new JPanel on new JFrame representing Canvas. Also creates new Points as global holder for all points added by a user.\par
\par
\pard\box\brdrdash\brdrw0 \sl276\slmult1\cf1\f1\fs20 private \cf2 CanvasPanel \cf3 createCanvas\cf2 ()\par
\pard\sl276\slmult1\cf0\f0\fs22 Similarly to setupPanel() this method creates a JPanel which it returns at the end with all appropriate modulations such as setting colors, adding buttons with label and adding functionality to them.\par
\par
\par
\par
\pard\box\brdrdash\brdrw0 \sl276\slmult1\cf1\f1\fs20 public class \cf2 CanvasPanel \cf1 extends \cf2 JPanel\par
\pard\sl276\slmult1\cf0\f0\fs22 Class CanvasPanel extends JPanel by overriding the method paintComponent. Its hierarchy is straigth forward:\par
1) Creates default x and y axis with black color for orientation for a user.\par
2) Draws all points from user inputs.\par
3) Draws function representing interpolation to through all points given above, by drawing a line for each 5 pixels.\par
\par
\par
\par
\pard\box\brdrdash\brdrw0 \sl276\slmult1\cf1\f1\fs20 public class \cf2 ClickListener \cf1 extends \cf2 MouseAdapter\cf0\f0\fs22\par
\pard\sl276\slmult1 Class ClickListener extends MouseAdapter by overriding the method mousePressed. Its implemention changes point clicked on screen to true in global points according to position of a mouse. Then creates a new Point representing above stated click, add him to points for interpolation and repaints canvas.\par
\par
\par
\pard\box\brdrdash\brdrw0 \sl276\slmult1\cf1\f1\fs20 public class \cf2 Export\par
\pard\sl276\slmult1\cf0\f0\fs22 Overlooks exporting function to svg.\par
\par
\pard\box\brdrdash\brdrw0 \sl276\slmult1\cf1\f1\fs20 public static void \cf3 export\cf2 (\cf1 int\cf2 [] points)\cf0\f0\fs22\par
\pard\sl276\slmult1 Method export reads text from template, which is split by a special character. Then to this splitted part are inserted points from graph. Finally this text is written to a file in svg format.\par
\par
\pard\box\brdrdash\brdrw0 \sl276\slmult1\cf1\f1\fs20 private static \cf2 String \cf3 createPointsSVG\cf2 (\cf1 int\cf2 [] points)\par
\pard\sl276\slmult1\cf0\f0\fs22 Helping function using Stringbuilder for returning precise Xs and their functional values to the export.\par
\par
\par
\pard\box\brdrdash\brdrw0 \sl276\slmult1\cf1\f1\fs20 public class \cf2 Interpolation\cf0\f0\fs22\par
\pard\sl276\slmult1 Overlooks interpolating points with a function.\par
\par
\pard\box\brdrdash\brdrw0 \sl276\slmult1\cf1\f1\fs20 public static int\cf2 [] \cf3 interpolate\cf2 ()\par
\pard\sl276\slmult1\cf0\f0\fs22 Method interpolate returns functional values for all x values. This is done by creating Matrix with dimenstion of the number of interpolating points. Matrix is then filled by the desired points and solved in class Matrix.\par
\par
\par
\pard\box\brdrdash\brdrw0 \sl276\slmult1\cf1\f1\fs20 public class \cf2 Matrix\par
\pard\sl276\slmult1\cf0\f0\fs22 Class representing Matrices with functions for using them for interpolation.\par
\par
\pard\box\brdrdash\brdrw0 \sl276\slmult1\cf1\f1\fs20 public void \cf3 fillMatrix\cf2 (List<Point> interpolPoints)\par
\pard\sl276\slmult1\cf0\f0\fs22 Adds points from argument to the matrix.\par
\par
\pard\box\brdrdash\brdrw0 \sl276\slmult1\cf1\f1\fs20 public double\cf2 [] \cf3 solve\cf2 ()\par
\pard\sl276\slmult1\cf0\f0\fs22 Solves the matrix by Gaussian elimination. \par
Firstly finds pivot row and swaps it current row.\par
Secondly checks singlularity or almost singularity of matrix.\par
Thirdly substracts by pivot*alpha to get zero for all rows below pivot row.\par
Finally back substitution for aquiring final solution of given matrix.\par
\par
\par
\pard\box\brdrdash\brdrw0 \sl276\slmult1\cf1\f1\fs20 public class \cf2 Point\par
\pard\sl276\slmult1\cf0\f0\fs22 Represents object Point. Stores coordinations X and Y, with boolean if it has been clicked on.\par
\par
\pard\box\brdrdash\brdrw0 \sl276\slmult1\cf1\f1\fs20 public class \cf2 Points\par
\pard\sl276\slmult1\cf0\f0\fs22 Holder for all points by having Point[][] field.\par
\par
\pard\box\brdrdash\brdrw0 \sl276\slmult1\cf1\f1\fs20 public class \cf2 Colors\par
\pard\sl276\slmult1\cf0\f0\fs22 Holder for static Colors used in whole program.\par
\par
\pard\box\brdrdash\brdrw0 \sl276\slmult1\cf1\f1\fs20 public class \cf2 Global\par
\pard\sl276\slmult1\cf0\f0\fs22 Global holder for static data used throughout whole program: Screen Width and Height, Points, Points for interpolation and Last Functional values of points.\par
\par
\par
\par
\pard\box\brdrdash\brdrw0 \sl276\slmult1\cf1\f1\fs20 public class \cf2 RoundedBorder \cf1 implements \cf2 Border\par
\pard\sl276\slmult1\cf0\f0\fs22 Class RoundedBoredes implements interface Border which is used in program for smoothing corners of buttons to circles, which are used for desired user interface.\par
\par
\par
}