-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInfoAlgorithm.java
More file actions
120 lines (111 loc) · 2.94 KB
/
InfoAlgorithm.java
File metadata and controls
120 lines (111 loc) · 2.94 KB
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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* This class is used for displaying the information of the algorithm
*
* @see Fixed
*
* @author Roșca Paul-Teodor
* @version 1.0 (22/12/2020)
*/
public class InfoAlgorithm extends Fixed
{
/**
* The main operation currenlty in the algorithm
*/
private Text operation;
/**
* Secondary information about the main operation
*/
private Text subOperation;
/**
* Specific details of the main operation
*/
private Text details;
/**
* Flag that tells us if the window with the information is visible
*/
private boolean visible;
/**
* Constructor for the window displaying the information of the algorithm.
* <p>
* We only set the colors of the text here
*/
public InfoAlgorithm()
{
operation=new Text(new Color(0,126,255),18);
subOperation=new Text(new Color(255,234,0),18);
details=new Text(new Color(0,126,255),18);
visible=true;
}
/**
* Method that makes the window visible
*/
public void makeVisible()
{
// We make all components visible
getImage().setTransparency(255);
operation.getImage().setTransparency(255);
subOperation.getImage().setTransparency(255);
details.getImage().setTransparency(255);
// And flag the object as visible
visible=true;
}
/**
* Method that makes the window invisible
*/
public void makeInvisible()
{
// We make all components invisible
getImage().setTransparency(0);
operation.getImage().setTransparency(0);
subOperation.getImage().setTransparency(0);
details.getImage().setTransparency(0);
// And flag the object as invisible
visible=false;
}
/**
* Method for setting a component's text
* @param text the component we change
* @param string the new string that we put in the component
*/
private void setInfo(Text text,String string)
{
text.clear();// We clear the previous text
text.addString(string);// We add the new one
if(!visible)// If the window is invisible
text.getImage().setTransparency(0);// We make the new text also invisible
}
public void setOperation(String o)
{
setInfo(operation,o);
}
public void setSubOperation(String so)
{
setInfo(subOperation,so);
}
public void setDetails(String d)
{
setInfo(details,d);
}
/**
* Method for flushing all the components
*/
public void clear()
{
operation.clear();
subOperation.clear();
details.clear();
}
public Text getOperation()
{
return operation;
}
public Text getSubOperation()
{
return subOperation;
}
public Text getDetails()
{
return details;
}
}