Skip to content

Commit cc87ad1

Browse files
ChidiebereChidiebere
authored andcommitted
Merge remote-tracking branch 'origin/master'
2 parents 6822f81 + 6d8423a commit cc87ad1

4 files changed

Lines changed: 63 additions & 75 deletions

File tree

‎TournamentAppJavaFX/src/com/solutioninventors/tournament/GUI/controller/CommonMethods.java‎

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
/**
2-
*@Author: Oguejiofor Chidiebere
2+
*@Author: Oguejiofor Chinedu Knight
33
*CommonMethods.java
44
*30 Sep. 2017
55
*10:05:21 pm
66
*/
77
package com.solutioninventors.tournament.GUI.controller;
88

99
import java.io.File;
10-
import java.io.FileInputStream;
11-
import java.io.FileNotFoundException;
1210
import java.io.IOException;
11+
import java.io.InputStream;
1312
import java.net.URISyntaxException;
14-
import java.net.URL;
1513

1614
import com.solutioninventors.tournament.GUI.utility.ConfirmBox;
1715
import com.solutioninventors.tournament.GUI.utility.Paths;
@@ -38,23 +36,17 @@
3836
public class CommonMethods {
3937

4038
private Tournament tournament;
41-
URL logoURL = getClass().getResource(Paths.images + "logo.png");
39+
InputStream logoURL = getClass().getResourceAsStream(Paths.images + "logo.png");
4240

43-
public Font[] loadfonts() {
44-
URL url1 = getClass().getResource(Paths.fonts + "twcenmt.ttf");
45-
URL url2 = getClass().getResource(Paths.fonts + "TwCenMTCondensed.ttf");
46-
URL url3 = getClass().getResource(Paths.fonts + "Pristina.ttf");
41+
public Font[] loadfonts() {
42+
InputStream url1 = getClass().getResourceAsStream(Paths.fonts + "twcenmt.ttf");
43+
InputStream url2 = getClass().getResourceAsStream(Paths.fonts + "TwCenMTCondensed.ttf");
44+
InputStream url3 = getClass().getResourceAsStream(Paths.fonts + "Pristina.ttf");
4745
final Font font[] = new Font[3];
48-
try {
49-
50-
font[0] = Font.loadFont(new FileInputStream(new File(url1.toURI())), 19);
46+
font[0] = Font.loadFont(url1, 19);
5147

52-
font[1] = Font.loadFont(new FileInputStream(new File(url2.toURI())), 19);
53-
font[2] = Font.loadFont(new FileInputStream(new File(url3.toURI())), 19);
54-
} catch (FileNotFoundException | URISyntaxException e) {
55-
// TODO Auto-generated catch block
56-
e.printStackTrace();
57-
}
48+
font[1] = Font.loadFont(url2, 19);
49+
font[2] = Font.loadFont(url3, 19);
5850
return font;
5951
}
6052

@@ -64,7 +56,7 @@ public void about() throws IOException, URISyntaxException {
6456
Parent root = FXMLLoader.load(getClass().getResource(Paths.viewpath + "About.fxml"));
6557
Scene scene = new Scene(root);
6658

67-
aboutStage.getIcons().add(new Image(new FileInputStream(new File(logoURL.toURI()))));
59+
aboutStage.getIcons().add(new Image(logoURL));
6860
aboutStage.setResizable(false);
6961
aboutStage.sizeToScene();
7062
aboutStage.setScene(scene);
@@ -78,7 +70,7 @@ public void help() throws IOException, URISyntaxException {
7870
helpStage.initModality(Modality.APPLICATION_MODAL);
7971
Parent root = FXMLLoader.load(getClass().getResource(Paths.viewpath + "Help.fxml"));
8072
Scene scene = new Scene(root);
81-
helpStage.getIcons().add(new Image(new FileInputStream(new File(logoURL.toURI()))));
73+
helpStage.getIcons().add(new Image(logoURL));
8274
helpStage.setResizable(false);
8375
helpStage.setScene(scene);
8476
helpStage.sizeToScene();
@@ -120,7 +112,7 @@ public void opentournament(MouseEvent event) throws URISyntaxException {
120112
FRSCIScreenController ic = (FRSCIScreenController) loader.getController();
121113
ic.setTournament(tournament);
122114
ic.init();
123-
window.getIcons().add(new Image(new FileInputStream(new File(logoURL.toURI()))));
115+
window.getIcons().add(new Image(logoURL));
124116
Scene scene = new Scene(root);
125117

126118
window.setOnCloseRequest(e -> {
@@ -137,7 +129,7 @@ public void opentournament(MouseEvent event) throws URISyntaxException {
137129

138130
} catch (IOException e) {
139131
e.printStackTrace();
140-
} catch (TournamentEndedException e) { // TODO Auto-generated catch block
132+
} catch (TournamentEndedException e) {
141133
e.printStackTrace();
142134
} catch (FileIsOpenException e) {
143135
ErrorMessage("File Open","Cannot open the same file");
@@ -189,16 +181,15 @@ public void ErrorMessage(String err, String message) {
189181
ErrorController er = (ErrorController) loader.getController();
190182
er.setMessage(err, message);
191183
Scene scene = new Scene(root);
192-
errorWindow.getIcons().add(new Image(new FileInputStream(new File(logoURL.toURI()))));
184+
errorWindow.getIcons().add(new Image(logoURL));
193185
errorWindow.setResizable(false);
194186
errorWindow.sizeToScene();
195187
scene.getStylesheets().add(getClass().getResource(Paths.css + "commonStyle.css").toExternalForm());
196188
errorWindow.setScene(scene);
197189
errorWindow.show();
198190
errorWindow.setTitle(err);
199191

200-
} catch (IOException | URISyntaxException e) {
201-
// TODO Auto-generated catch block
192+
} catch (IOException e) {
202193
e.printStackTrace();
203194
}
204195
}

‎TournamentAppJavaFX/src/com/solutioninventors/tournament/GUI/controller/InputCompetitorController.java‎

Lines changed: 44 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,22 @@
22
* @author Chinedu Oguejiofor
33
*10 Aug. 2017
44
* 3:23:29 pm
5-
*/
5+
*//*
66
package com.solutioninventors.tournament.GUI.controller;
77
88
import java.io.File;
99
import java.io.FileInputStream;
1010
import java.io.FileNotFoundException;
1111
import java.io.IOException;
12+
import java.io.InputStream;
1213
import java.net.MalformedURLException;
1314
import java.net.URISyntaxException;
1415
import java.net.URL;
1516
import java.util.Arrays;
1617
import java.util.List;
1718
19+
import org.apache.commons.io.FileUtils;
20+
1821
import com.solutioninventors.tournament.GUI.utility.ConfirmBox;
1922
import com.solutioninventors.tournament.GUI.utility.Paths;
2023
import com.solutioninventors.tournament.exceptions.InvalidBreakerException;
@@ -65,8 +68,8 @@ public class InputCompetitorController {
6568
private Font font[] = new Font[3];
6669
private Stage window;
6770
68-
private URL url1 = getClass().getResource(Paths.images + "clickme.PNG");
69-
private URL url2 = getClass().getResource(Paths.images + "nologo.jpg");
71+
private InputStream url1 = getClass().getResourceAsStream(Paths.images + "clickme.PNG");
72+
private InputStream url2 = getClass().getResourceAsStream(Paths.images + "nologo.jpg");
7073
private Image image;
7174
// shared variables
7275
private String TournamentName;
@@ -182,43 +185,38 @@ public void setMultiStageTournament(String tn, Boolean goalScored, int rud, int
182185
}
183186
184187
public void loadcomponents() {
185-
// this was used to set the default no logo image
186-
try {
187-
image = new Image(new FileInputStream(new File(url1.toURI())));
188-
189-
comps = new Competitor[noOfCompetitors];
190-
file = new File[noOfCompetitors];
191-
imageTracker = new int[noOfCompetitors];
192-
Arrays.fill(imageTracker, -1);
193-
for (int i = 0; i < txtArray.size(); i++) {
194-
txtArray.get(i).setText(null);
195-
}
196-
/*for (int i = 0; i < comps.length; i++) {
197-
comps[i] = new Competitor("Player " + String.valueOf(i + 1), new File(url1.toURI()));
198-
}
199-
fo
200-
*/
201-
btnPrevious.setVisible(false);
202-
btnNext.setVisible(noOfCompetitors <= 4 ? false : true);
203-
204-
if (TournamentType == TournamentTypes.CHALLENGE) {
205-
comps[0] = new Competitor("Champion", new File(url1.toURI()));
206-
comps[1] = new Competitor("Challenger", new File(url1.toURI()));
207-
txtArray.get(0).setPromptText("Champion");
208-
txtArray.get(1).setPromptText("Challenger");
209-
for (int i = 2; i < 4; i++) {
210-
txtArray.get(i).setVisible(false);
211-
imgArray.get(i).setVisible(false);
212-
SNArray.get(i).setVisible(false);
213-
}
214-
endValue = 2;
215-
} else if (noOfCompetitors == 3) {
216-
txtArray.get(3).setVisible(false);
217-
imgArray.get(3).setVisible(false);
218-
SNArray.get(3).setVisible(false);
188+
image = new Image(url1);
189+
190+
comps = new Competitor[noOfCompetitors];
191+
file = new File[noOfCompetitors];
192+
imageTracker = new int[noOfCompetitors];
193+
Arrays.fill(imageTracker, -1);
194+
for (int i = 0; i < txtArray.size(); i++) {
195+
txtArray.get(i).setText(null);
196+
}
197+
for (int i = 0; i < comps.length; i++) {
198+
comps[i] = new Competitor("Player " + String.valueOf(i + 1), new File(url1.toURI()));
199+
}
200+
fo
201+
202+
btnPrevious.setVisible(false);
203+
btnNext.setVisible(noOfCompetitors <= 4 ? false : true);
204+
205+
if (TournamentType == TournamentTypes.CHALLENGE) {
206+
comps[0] = new Competitor("Champion", new File(url1.toString()));
207+
comps[1] = new Competitor("Challenger", new File(url1.toString()));
208+
txtArray.get(0).setPromptText("Champion");
209+
txtArray.get(1).setPromptText("Challenger");
210+
for (int i = 2; i < 4; i++) {
211+
txtArray.get(i).setVisible(false);
212+
imgArray.get(i).setVisible(false);
213+
SNArray.get(i).setVisible(false);
219214
}
220-
} catch (FileNotFoundException | URISyntaxException e) {
221-
e.printStackTrace();
215+
endValue = 2;
216+
} else if (noOfCompetitors == 3) {
217+
txtArray.get(3).setVisible(false);
218+
imgArray.get(3).setVisible(false);
219+
SNArray.get(3).setVisible(false);
222220
}
223221
224222
if (goalScored) {
@@ -239,7 +237,7 @@ public void cancel(ActionEvent event) {
239237
}
240238
241239
@FXML
242-
public void previous(ActionEvent event) throws MalformedURLException, URISyntaxException {
240+
public void previous(ActionEvent event) throws URISyntaxException, IOException {
243241
btnNext.setVisible(true);
244242
btnPrevious.setVisible(startValue - 4 == 0 ? false : true);
245243
for (int i = startValue; i < endValue; i++) {
@@ -248,7 +246,11 @@ public void previous(ActionEvent event) throws MalformedURLException, URISyntaxE
248246
if (file[i] != null) {
249247
file[i] = file[i];
250248
} else {
251-
file[i] = new File(url1.toURI());
249+
File tempFile = null;
250+
FileUtils.copyInputStreamToFile(url1,tempFile);
251+
252+
//file[i] = new File(url1.toURI());
253+
//file[i] =
252254
imageTracker[i] = i;//track the location in which Click to add image is used
253255
}
254256
comps[i] = new Competitor(tempCompName, file[i]);
@@ -553,3 +555,4 @@ public void changeimage4(ActionEvent e) throws MalformedURLException {
553555
changeImage4(null);
554556
}
555557
}// end class
558+
*/

‎TournamentAppJavaFX/src/com/solutioninventors/tournament/GUI/utility/GUITest.java‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33
*/
44
package com.solutioninventors.tournament.GUI.utility;
55

6-
import java.io.File;
7-
import java.io.FileInputStream;
8-
import java.net.URL;
9-
10-
import com.solutioninventors.tournament.GUI.controller.WelcomeScreenController;
6+
import java.io.InputStream;
117

128
import javafx.application.Application;
139
import javafx.fxml.FXMLLoader;
@@ -30,8 +26,8 @@ public void start(Stage primaryStage) {
3026
Parent root = loader.load(getClass().getResource(Paths.viewpath + "WelcomeScreen.fxml").openStream());
3127
Scene scene = new Scene(root);
3228
window = primaryStage;
33-
URL url1 = getClass().getResource(Paths.images + "logo.png");
34-
window.getIcons().add(new Image(new FileInputStream(new File(url1.toURI()))));
29+
InputStream url1 = getClass().getResourceAsStream(Paths.images + "logo.png");
30+
window.getIcons().add(new Image(url1));
3531
window.centerOnScreen();
3632
window.setScene(scene);
3733
window.sizeToScene();
@@ -42,8 +38,6 @@ public void start(Stage primaryStage) {
4238
});
4339
scene.getStylesheets().add(getClass().getResource(Paths.css + "welcomeScreen.css").toExternalForm());
4440
primaryStage.setTitle("Tournament APP");
45-
//WelcomeScreenController ic = (WelcomeScreenController) loader.getController();
46-
//ic.load();
4741
primaryStage.show();
4842
} catch (Exception e) {
4943
e.printStackTrace();
Binary file not shown.

0 commit comments

Comments
 (0)