Skip to content

Commit

Permalink
The basic structure of the generic GUI has been completed.
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Hertel <victor.hertel@web.de>
  • Loading branch information
vhertel committed Jul 1, 2017
1 parent 411a363 commit 7653f5c
Show file tree
Hide file tree
Showing 6 changed files with 271 additions and 34 deletions.
Expand Up @@ -213,14 +213,87 @@ public static boolean logMod() throws IOException {
if ((! config.getProperty("tabTitle[" + counter + "]").equals(getConfigModValue("tabTitle[" + counter + "]")))) {
logMod = true;
}
if ((! config.getProperty("numberOfControlItems[" + counter + "]").equals(getConfigModValue("numberOfControlItems[" + counter + "]")))) {
logMod = true;
}
if ((! config.getProperty("textArea[" + counter + "]").equals(getConfigModValue("textArea[" + counter + "]")))) {
logMod = true;
}

// Declares necessary parameters
int numberOfControlItems = Integer.parseInt(config.getProperty("numberOfControlItems[" + counter + "]"));
for (int j=1; j<=numberOfControlItems; j++) {
String control = config.getProperty("control[" + counter + "][" + j + "]");

// Checks for type of entered control item
switch (control) {
case "button":
if ((! config.getProperty("bText[" + counter + "][" + j + "]").equals(getConfigModValue("bText[" + counter + "][" + j + "]")))) {
logMod = true;
}
break;
case "textField":
if ((! config.getProperty("promptText[" + counter + "][" + j + "]").equals(getConfigModValue("promptText[" + counter + "][" + j + "]")))) {
logMod = true;
}
break;
case "label":
if ((! config.getProperty("lText[" + counter + "][" + j + "]").equals(getConfigModValue("lText[" + counter + "][" + j + "]")))) {
logMod = true;
}
break;
}
}
}

return logMod;
}




/**
* Method checks if properties of the state panel has been modified.
*
* @return
* @throws java.io.IOException
*/
public static boolean stateMod() throws IOException {

// Stores values from config.properties file into properties object 'configMods'
Properties config = getAllValues();
int numberOfBoxes = Integer.parseInt(config.getProperty("numberOfBoxes"));
boolean stateMod = false;

if (! config.getProperty("numberOfBoxes").equals(getConfigModValue("numberOfBoxes"))) {
stateMod = true;
}

for (int counter=1; counter<=numberOfBoxes; counter++) {
if ((! config.getProperty("boxTitle[" + counter + "]").equals(getConfigModValue("boxTitle[" + counter + "]")))) {
stateMod = true;
}
if ((! config.getProperty("numberOfValues[" + counter + "]").equals(getConfigModValue("numberOfValues[" + counter + "]")))) {
stateMod = true;
}

// Declares necessary parameters
int numberOfValues = Integer.parseInt(config.getProperty("numberOfValues[" + counter + "]"));
for (int j=1; j<=numberOfValues; j++) {
if ((! config.getProperty("keyword[" + counter + "][" + j + "]").equals(getConfigModValue("keyword[" + counter + "][" + j + "]")))) {
stateMod = true;
}
}

}

System.out.println(stateMod);
return stateMod;
}




/**
* Method checks if config.properties has been modified.
*
Expand All @@ -230,7 +303,7 @@ public static boolean logMod() throws IOException {
public static boolean fileMod() throws IOException {
boolean fileMod;

if( !experimentNameMod() && !chartMod() && !logMod() ) {
if( !experimentNameMod() && !chartMod() && !logMod() && !stateMod() ) {
fileMod = false;
} else {
fileMod = true;
Expand Down Expand Up @@ -310,6 +383,10 @@ public static void rebuildGui() throws IOException {
if ( logMod() ) {
GuiBuilder.logBuilder();
}
// Checks if log panel properties has been modified since last compilation
if ( stateMod() ) {
GuiBuilder.currentStateBuilder();
}

} else {
// Checks if config.properties file has been modified
Expand Down
Expand Up @@ -53,7 +53,9 @@ public void start(Stage stage) {
* Checks whether a regeneration of the FXML structure is
* necessary and carries it out in case it is
*/
ConfigHandler.rebuildGui();
//ConfigHandler.rebuildGui();
ConfigHandler.stateMod();
ConfigHandler.updateConfigMod();

// Java Swing GUI
//new MainController(new MainFrame());
Expand Down
Expand Up @@ -87,9 +87,7 @@ public static int[] getGridPosition( int input ) {
* @throws java.io.IOException
*/
public static void chartBuilder() throws IOException {

// Generates GridPane for charts


// Declares necessary parameters
Properties config = ConfigHandler.getAllValues();
int numberOfCharts = Integer.parseInt(config.getProperty("numberOfCharts"));
Expand Down Expand Up @@ -300,22 +298,65 @@ public static void logBuilder() throws FileNotFoundException, IOException {
*/
public static void currentStateBuilder() throws IOException {

// Declares necessary parameters
Properties config = ConfigHandler.getAllValues();
int numberOfBoxes = Integer.parseInt(config.getProperty("numberOfBoxes"));
String fileName = "CurrentStatePanel.fxml";
String filePath = "src/main/resources/fxml/";

// Writes data in CurrentStatePanel.fxml file
PrintWriter writer = new PrintWriter(filePath + fileName);

writer.println("<?import javafx.scene.control.*?> \n"
+ "<?import javafx.scene.layout.*?> \n");
writer.println("<ScrollPane prefHeight=\"200.0\" prefWidth=\"200.0\" BorderPane.alignment=\"CENTER\"> \n"
+ " <content>");
+ " <content> \n"
+ " <VBox prefHeight=\"200.0\" prefWidth=\"100.0\"> \n"
+ " <children>");

/**
* Method is not complete yet
*/
// Generates boxes
for (int counter=1; counter<=numberOfBoxes; counter++) {
writer.println(" <GridPane> \n"
+ " <columnConstraints> \n"
+ " <ColumnConstraints hgrow=\"SOMETIMES\" minWidth=\"10.0\" prefWidth=\"100.0\" /> \n"
+ " <ColumnConstraints hgrow=\"SOMETIMES\" minWidth=\"10.0\" prefWidth=\"100.0\" /> \n"
+ " </columnConstraints> \n"
+ " <rowConstraints>");

// Declares necessary parameters
int numberOfValues = Integer.parseInt(config.getProperty("numberOfValues[" + counter + "]"));
int numberOfRows;

// Sets number of rows depending on required number of control items
if (numberOfValues%2 == 0) {
numberOfRows = numberOfValues/2;
} else {
numberOfRows = (numberOfValues + 1)/2;
}

writer.println(" </content> \n"
// Writes FXML data
for (int i=1; i<=numberOfRows; i++) {
writer.println(" <RowConstraints minHeight=\"10.0\" prefHeight=\"30.0\" vgrow=\"SOMETIMES\" />");
}
writer.println(" </rowConstraints> \n"
+ " <children> \n"
+ " <Label text=\"" + config.getProperty("boxTitle[" + counter + "]") + "\" GridPane.columnIndex=\"0\" GridPane.rowIndex=\"0\" />");

// Writes FXML data of box content
for (int j=1; j<=numberOfValues; j++) {
String keyword = config.getProperty("keyword[" + counter + "][" + j + "]");
writer.println(" <Label text=\"" + keyword + "\" GridPane.columnIndex=\"0\" GridPane.rowIndex=\"" + j + "\" />");
}
writer.println(" </children> \n"
+ " </GridPane>");
}

writer.println(" </children> \n"
+ " </VBox> \n"
+ " </content> \n"
+ "</ScrollPane>");
writer.close();

// Prints status update
System.out.println("Data panel has been updated!");
}
}
Expand Up @@ -78,8 +78,8 @@ y[5] = y-Achse 5
# Log tabs
# Mandatory: YES
# Expected input: boolean
serialPanel = true
iridiumPanel = true
serialPanel = false
iridiumPanel = false
#
# Number of additional tabs in the log panel
# Mandatory: YES
Expand Down Expand Up @@ -111,31 +111,72 @@ numberOfAddTabs = 2
#
# Mandatory: YES
tabTitle[1] = test
tabTitle[2] = Nr. 4
tabTitle[2] = Nr. 2
# Number of control items within the tab
# Mandatory: YES
# Expected input: int
numberOfControlItems[1] = 3
numberOfControlItems[1] = 4
numberOfControlItems[2] = 5
# Textarea
# Mandatory: YES
# Expected input: boolean
textArea[1] = true
textArea[2] = false
textArea[2] = true
# Configurtion of control items
control[1][1] = button
bText[1][1] = Button 1
bText[1][1] = Button
control[1][2] = label
lText[1][2] = Label 1
lText[1][2] = Label
control[1][3] = textField
promptText[1][3] = Prompt Text
control[1][4] = button
bText[1][4] = Hi
control[2][1] = button
bText[2][1] = Button 1
bText[2][1] = Button 2
control[2][2] = label
lText[2][2] = Label 1
control[2][3] = textField
promptText[2][3] = Prompt Text
promptText[2][3] = Prompt
control[2][4] = label
lText[2][4] = Text
control[2][5] = textField
promptText[2][5] = Blabla
promptText[2][5] = Blabla






# STATE PROPERTIES
#
# Number of boxes in the state panel
# Mandatory: YES
# Expected input: int
numberOfBoxes = 2
#
# Parameters have to be passed for the specified number of boxes
# and appropriate to the syntax shown in the example. Keywords and
# values are arranged in rows in a two column grid pane:
# boxTitle[i] = testTitle
# numberOfValues[i] = 3
# keyword[i][j] = 3
# with j = {1,2,3,...} as number keyword in box
# with i = {1,2,3,...} as number of boxes
#
# Mandatory: YES
boxTitle[1] = test
boxTitle[2] = Nr. 5
# Number of values within the box
# Mandatory: YES
# Expected input: int
numberOfValues[1] = 3
numberOfValues[2] = 5
# Configurtion of boxes
keyword[1][1] = button
keyword[1][2] = label
keyword[1][3] = textField
keyword[2][1] = button
keyword[2][2] = label
keyword[2][3] = textField
keyword[2][4] = label
keyword[2][5] = textField
Expand Up @@ -3,23 +3,60 @@
# The structure is fixed and manual interventions
# and modifications are not intended!
-- listing properties --
keyword[2][2]=label
serialPanel=false
keyword[2][5]=textField
boxTitle[1]=test
control[1][1]=button
numberOfControlItems[2]=5
control[1][4]=button
x[3]=x-Achse 3
control[2][3]=textField
numberOfValues[1]=3
promptText[2][3]=Prompt
y[1]=y-Achse 1
bText[1][1]=Button
textArea[2]=true
y[4]=y-Achse 4
numberOfAddTabs=0
chartTitle[1]=Diagram 1
bText[1][4]=Hi
lText[1][2]=Label
lText[2][4]=Text
keyword[1][2]=label
chartTitle[3]=Diagram 3
numberOfBoxes=2
tabTitle[2]=Nr. 2
keyword[2][1]=button
keyword[2][4]=label
numberOfCharts=5
control[1][3]=textField
numberOfControlItems[1]=4
x[2]=x-Achse 2
promptText[1][3]=Prompt Text
x[5]=x-Achse 5
chartTitle[4]=Diagram 4
serialPanel=true
y[2]=y-Achse 2
iridiumPanel=true
y[5]=y-Achse 5
control[2][2]=label
control[2][5]=textField
promptText[2][5]=Blabla
textArea[1]=true
y[3]=y-Achse 3
experimentName=PAPELL
x[3]=x-Achse 3
iridiumPanel=false
keyword[1][1]=button
chartTitle[2]=Diagram 2
tabTitle[1]=test
chartTitle[5]=Diagram 5
y[3]=y-Achse 3
numberOfCharts=5
numberOfAddTabs=2
keyword[2][3]=textField
boxTitle[2]=Nr. 5
control[1][2]=label
x[1]=x-Achse 1
chartTitle[3]=Diagram 3
x[4]=x-Achse 4
control[2][1]=button
control[2][4]=label
numberOfValues[2]=5
y[2]=y-Achse 2
y[5]=y-Achse 5
bText[2][1]=Button 2
lText[2][2]=Label 1
chartTitle[1]=Diagram 1
keyword[1][3]=textField
chartTitle[4]=Diagram 4

0 comments on commit 7653f5c

Please sign in to comment.