ADD::added local produce and public transport sections to the extra activities section
added the panes and designated buttons ADD::added placeholder methods for communicating adding the activities to the server
This commit is contained in:
@@ -31,6 +31,10 @@ public class ExtraActivityController {
|
||||
@FXML
|
||||
private AnchorPane solarPanelPane;
|
||||
@FXML
|
||||
private AnchorPane localProducePane;
|
||||
@FXML
|
||||
private AnchorPane publicTransportPane;
|
||||
@FXML
|
||||
private Button displayVeganMealButton;
|
||||
@FXML
|
||||
private Button displayBikeButton;
|
||||
@@ -38,6 +42,10 @@ public class ExtraActivityController {
|
||||
private Button displayTemperatureButton;
|
||||
@FXML
|
||||
private Button displaySolarPanelButton;
|
||||
@FXML
|
||||
private Button displayLocalProduceButton;
|
||||
@FXML
|
||||
private Button displayPublicTransportButton;
|
||||
|
||||
@FXML
|
||||
private Button addVeganMealButton;
|
||||
@@ -48,6 +56,10 @@ public class ExtraActivityController {
|
||||
@FXML
|
||||
private Button addSolarPanelsButton;
|
||||
@FXML
|
||||
private Button addLocalProduceButton;
|
||||
@FXML
|
||||
private Button addPublicTransportButton;
|
||||
@FXML
|
||||
private Slider bikeSlider;
|
||||
@FXML
|
||||
private Label bikeLabel;
|
||||
@@ -59,6 +71,11 @@ public class ExtraActivityController {
|
||||
private Slider solarPanelsSlider;
|
||||
@FXML
|
||||
private Label solarPanelsLabel;
|
||||
@FXML
|
||||
private Label publicTransportLabel;
|
||||
@FXML
|
||||
private Slider publicTransportSlider;
|
||||
|
||||
|
||||
/**
|
||||
* initializes the sliders and labels before loading.
|
||||
@@ -68,16 +85,21 @@ public class ExtraActivityController {
|
||||
coupleSliderToLabel(bikeSlider, bikeLabel, " km", false);
|
||||
coupleSliderToLabel(temperatureSlider, temperatureLabel, " Degrees", true);
|
||||
coupleSliderToLabel(solarPanelsSlider, solarPanelsLabel, "", true);
|
||||
coupleSliderToLabel(publicTransportSlider, publicTransportLabel, " km", false);
|
||||
|
||||
addVeganMealButton.setSkin(new ActivityButtonSkin(addVeganMealButton));
|
||||
addBikeButton.setSkin(new ActivityButtonSkin(addBikeButton));
|
||||
addTemperatureButton.setSkin(new ActivityButtonSkin(addTemperatureButton));
|
||||
addSolarPanelsButton.setSkin(new ActivityButtonSkin(addSolarPanelsButton));
|
||||
addLocalProduceButton.setSkin(new ActivityButtonSkin(addLocalProduceButton));
|
||||
addPublicTransportButton.setSkin(new ActivityButtonSkin(addPublicTransportButton));
|
||||
|
||||
displayVeganMealButton.setSkin(new TranslateButtonSkin(displayVeganMealButton));
|
||||
displayBikeButton.setSkin(new TranslateButtonSkin(displayBikeButton));
|
||||
displayTemperatureButton.setSkin(new TranslateButtonSkin(displayTemperatureButton));
|
||||
displaySolarPanelButton.setSkin(new TranslateButtonSkin(displaySolarPanelButton));
|
||||
displayLocalProduceButton.setSkin(new TranslateButtonSkin(displayLocalProduceButton));
|
||||
displayPublicTransportButton.setSkin(new TranslateButtonSkin(displayPublicTransportButton));
|
||||
|
||||
}
|
||||
|
||||
@@ -90,7 +112,7 @@ public class ExtraActivityController {
|
||||
* @param string the string to be placed after the outputted value of the slider
|
||||
* @param snapToTicks whether the slider should snap to ticks or not
|
||||
*/
|
||||
public void coupleSliderToLabel(Slider slider, Label label, String string,
|
||||
private void coupleSliderToLabel(Slider slider, Label label, String string,
|
||||
boolean snapToTicks) {
|
||||
slider.setSnapToTicks(snapToTicks);
|
||||
slider.valueProperty().addListener(new ChangeListener<Number>() {
|
||||
@@ -112,6 +134,8 @@ public class ExtraActivityController {
|
||||
bikePane.setVisible(false);
|
||||
temperaturePane.setVisible(false);
|
||||
solarPanelPane.setVisible(false);
|
||||
localProducePane.setVisible(false);
|
||||
publicTransportPane.setVisible(false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,6 +148,8 @@ public class ExtraActivityController {
|
||||
bikePane.setVisible(true);
|
||||
temperaturePane.setVisible(false);
|
||||
solarPanelPane.setVisible(false);
|
||||
localProducePane.setVisible(false);
|
||||
publicTransportPane.setVisible(false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,6 +162,8 @@ public class ExtraActivityController {
|
||||
bikePane.setVisible(false);
|
||||
temperaturePane.setVisible(true);
|
||||
solarPanelPane.setVisible(false);
|
||||
localProducePane.setVisible(false);
|
||||
publicTransportPane.setVisible(false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,14 +176,90 @@ public class ExtraActivityController {
|
||||
bikePane.setVisible(false);
|
||||
temperaturePane.setVisible(false);
|
||||
solarPanelPane.setVisible(true);
|
||||
localProducePane.setVisible(false);
|
||||
publicTransportPane.setVisible(false);
|
||||
}
|
||||
|
||||
public class TranslateButtonSkin extends ButtonSkin {
|
||||
/**
|
||||
* displays the local produce section.
|
||||
* @param event the click of the designated button
|
||||
*/
|
||||
public void displayLocalProduce(ActionEvent event) {
|
||||
veganMealPane.setVisible(false);
|
||||
bikePane.setVisible(false);
|
||||
temperaturePane.setVisible(false);
|
||||
solarPanelPane.setVisible(false);
|
||||
localProducePane.setVisible(true);
|
||||
publicTransportPane.setVisible(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* displays the public transport section.
|
||||
* @param event the click of the designated button
|
||||
*/
|
||||
public void displayPublicTransport(ActionEvent event) {
|
||||
veganMealPane.setVisible(false);
|
||||
bikePane.setVisible(false);
|
||||
temperaturePane.setVisible(false);
|
||||
solarPanelPane.setVisible(false);
|
||||
localProducePane.setVisible(false);
|
||||
publicTransportPane.setVisible(true);
|
||||
}
|
||||
|
||||
public void confirmVeganMeal(ActionEvent event) {
|
||||
System.out.println("confirm adding vegetarian meal");
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the activity of buying local produce to the user's account.
|
||||
* @param event the click of the 'add activity' button in the designated section
|
||||
*/
|
||||
public void confirmLocalProduce(ActionEvent event) {
|
||||
System.out.println("confirm adding buying local produce");
|
||||
userService.updateExtraInput(userService.currentUser.getName(),
|
||||
"local_produce", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* adds the activity of using your bike instead of your car to the user's account.
|
||||
* @param event the click of the 'add activity' button in the designated section
|
||||
*/
|
||||
public void confirmBike(ActionEvent event) {
|
||||
System.out.println("confirm adding using bike instead of car");
|
||||
userService.updateExtraInput(userService.currentUser.getName(),
|
||||
"bike", true);
|
||||
}
|
||||
|
||||
public void confirmPublicTransport(ActionEvent event) {
|
||||
System.out.println("confirm adding using public transport instead of car");
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the activity of lowering the home temperature to the user's account.
|
||||
* @param event the click of the 'add activity' button in the designated section
|
||||
*/
|
||||
public void confirmTemperature(ActionEvent event) {
|
||||
System.out.println("confirm adding lowering home temperature");
|
||||
userService.updateExtraInput(userService.currentUser.getName(),
|
||||
"temperature", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the activity of buying solar panels to the user's account.
|
||||
* @param event the click of the 'add activity' button in the designated section
|
||||
*/
|
||||
public void confirmSolarPanels(ActionEvent event) {
|
||||
System.out.println("confirm adding buying solar panels");
|
||||
userService.updateExtraInput(userService.currentUser.getName(),
|
||||
"solar_panels", true);
|
||||
}
|
||||
|
||||
private class TranslateButtonSkin extends ButtonSkin {
|
||||
/**
|
||||
* button skin that sets a translate animation on entering and exiting the button.
|
||||
* @param button the button to set the animation for
|
||||
*/
|
||||
public TranslateButtonSkin(Button button) {
|
||||
private TranslateButtonSkin(Button button) {
|
||||
super(button);
|
||||
|
||||
TranslateTransition transEnter = new TranslateTransition(Duration.millis(50));
|
||||
@@ -175,7 +279,7 @@ public class ExtraActivityController {
|
||||
private class ActivityButtonSkin extends ButtonSkin {
|
||||
/**
|
||||
* button skin for the 'add activity' buttons.
|
||||
* adds scale animations on entering, clicking and extiting the button
|
||||
* adds scale animations on entering, clicking and exiting the button
|
||||
* @param button the button to set the skin of
|
||||
*/
|
||||
private ActivityButtonSkin(Button button) {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<children>
|
||||
<AnchorPane prefHeight="611.0" prefWidth="107.0">
|
||||
<children>
|
||||
<Button fx:id="displayVeganMealButton" contentDisplay="TOP" layoutX="14.0" layoutY="143.0" mnemonicParsing="false" onAction="#displayVeganMeal" prefHeight="70.0" prefWidth="82.0" styleClass="navButton">
|
||||
<Button fx:id="displayVeganMealButton" contentDisplay="TOP" layoutX="14.0" layoutY="62.0" mnemonicParsing="false" onAction="#displayVeganMeal" prefHeight="70.0" prefWidth="82.0" styleClass="navButton">
|
||||
<graphic>
|
||||
<ImageView fitHeight="45.0" fitWidth="45.0" pickOnBounds="true" preserveRatio="true" styleClass="navButton">
|
||||
<image>
|
||||
@@ -23,6 +23,15 @@
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button fx:id="displayLocalProduceButton" contentDisplay="TOP" layoutX="14.0" layoutY="143.0" mnemonicParsing="false" onAction="#displayLocalProduce" prefHeight="70.0" prefWidth="82.0" styleClass="navButton">
|
||||
<graphic>
|
||||
<ImageView fitHeight="45.0" fitWidth="45.0" pickOnBounds="true" preserveRatio="true" styleClass="navButton">
|
||||
<image>
|
||||
<Image url="@../icons/localProduce.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button fx:id="displayBikeButton" contentDisplay="TOP" layoutX="14.0" layoutY="224.0" mnemonicParsing="false" onAction="#displayBike" prefHeight="70.0" prefWidth="82.0" styleClass="navButton">
|
||||
<graphic>
|
||||
<ImageView fitHeight="45.0" fitWidth="48.0" pickOnBounds="true" preserveRatio="true">
|
||||
@@ -31,16 +40,7 @@
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic></Button>
|
||||
<Button fx:id="displayTemperatureButton" contentDisplay="TOP" layoutX="14.0" layoutY="305.0" mnemonicParsing="false" onAction="#displayTemperature" prefHeight="70.0" prefWidth="82.0" styleClass="navButton">
|
||||
<graphic>
|
||||
<ImageView fitHeight="45.0" fitWidth="48.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@../icons/icons8-temperature-inside-64.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button fx:id="displaySolarPanelButton" contentDisplay="TOP" layoutX="14.0" layoutY="386.0" mnemonicParsing="false" onAction="#displaySolarPanel" prefHeight="70.0" prefWidth="82.0" styleClass="navButton">
|
||||
<Button fx:id="displaySolarPanelButton" contentDisplay="TOP" layoutX="14.0" layoutY="467.0" mnemonicParsing="false" onAction="#displaySolarPanel" prefHeight="70.0" prefWidth="82.0" styleClass="navButton">
|
||||
<graphic>
|
||||
<ImageView fitHeight="45.0" fitWidth="48.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
@@ -49,9 +49,27 @@
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button fx:id="displayTemperatureButton" contentDisplay="TOP" layoutX="14.0" layoutY="386.0" mnemonicParsing="false" onAction="#displayTemperature" prefHeight="70.0" prefWidth="82.0" styleClass="navButton">
|
||||
<graphic>
|
||||
<ImageView fitHeight="45.0" fitWidth="48.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@../icons/icons8-temperature-inside-64.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button fx:id="displayPublicTransportButton" contentDisplay="TOP" layoutX="14.0" layoutY="305.0" mnemonicParsing="false" onAction="#displayPublicTransport" prefHeight="70.0" prefWidth="82.0" styleClass="navButton">
|
||||
<graphic>
|
||||
<ImageView fitHeight="45.0" fitWidth="45.0" pickOnBounds="true" preserveRatio="true" styleClass="navButton">
|
||||
<image>
|
||||
<Image url="@../icons/publicTransport.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
<AnchorPane fx:id="veganMealPane" layoutX="107.0" prefHeight="611.0" prefWidth="713.0" visible="false">
|
||||
<AnchorPane fx:id="veganMealPane" layoutX="107.0" prefHeight="611.0" prefWidth="713.0">
|
||||
<children>
|
||||
<Line fx:id="line1" endX="79.0" layoutX="465.0" layoutY="7.0" stroke="#545b54" />
|
||||
<Text layoutX="248.0" layoutY="56.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Eating a vegetarian meal">
|
||||
@@ -59,7 +77,7 @@
|
||||
<Font size="20.0" />
|
||||
</font>
|
||||
</Text>
|
||||
<Button fx:id="addVeganMealButton" contentDisplay="TOP" layoutX="267.0" layoutY="226.0" mnemonicParsing="false" prefHeight="150.0" prefWidth="180.0" style="-fx-background-color: transparent;" text="Add activity!" textFill="#23652b">
|
||||
<Button fx:id="addVeganMealButton" contentDisplay="TOP" layoutX="267.0" layoutY="226.0" mnemonicParsing="false" onAction="#confirmVeganMeal" prefHeight="150.0" prefWidth="180.0" style="-fx-background-color: transparent;" text="Add activity!" textFill="#23652b">
|
||||
<graphic>
|
||||
<ImageView fitHeight="116.0" fitWidth="156.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
@@ -87,7 +105,7 @@
|
||||
<Font size="18.0" />
|
||||
</font>
|
||||
</Text>
|
||||
<Button fx:id="addBikeButton" contentDisplay="TOP" layoutX="267.0" layoutY="351.0" mnemonicParsing="false" prefHeight="150.0" prefWidth="180.0" style="-fx-background-color: transparent;" text="Add activity!" textFill="#23652b">
|
||||
<Button fx:id="addBikeButton" contentDisplay="TOP" layoutX="267.0" layoutY="351.0" mnemonicParsing="false" onAction="#confirmBike" prefHeight="150.0" prefWidth="180.0" style="-fx-background-color: transparent;" text="Add activity!" textFill="#23652b">
|
||||
<font>
|
||||
<Font name="System Bold Italic" size="18.0" />
|
||||
</font>
|
||||
@@ -133,7 +151,7 @@
|
||||
</Label>
|
||||
</children>
|
||||
</HBox>
|
||||
<Button fx:id="addTemperatureButton" contentDisplay="TOP" layoutX="267.0" layoutY="353.0" mnemonicParsing="false" prefHeight="150.0" prefWidth="180.0" style="-fx-background-color: transparent;" text="Add activity!" textFill="#23652b">
|
||||
<Button fx:id="addTemperatureButton" contentDisplay="TOP" layoutX="267.0" layoutY="353.0" mnemonicParsing="false" onAction="#confirmTemperature" prefHeight="150.0" prefWidth="180.0" style="-fx-background-color: transparent;" text="Add activity!" textFill="#23652b">
|
||||
<font>
|
||||
<Font name="System Bold Italic" size="18.0" />
|
||||
</font>
|
||||
@@ -147,7 +165,7 @@
|
||||
</Button>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
<AnchorPane fx:id="solarPanelPane" layoutX="107.0" prefHeight="611.0" prefWidth="713.0">
|
||||
<AnchorPane fx:id="solarPanelPane" layoutX="107.0" prefHeight="611.0" prefWidth="713.0" visible="false">
|
||||
<children>
|
||||
<Line fx:id="line4" endX="79.0" layoutX="465.0" layoutY="7.0" stroke="#545b54" />
|
||||
<Text layoutX="262.0" layoutY="56.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Installing solar panels">
|
||||
@@ -170,7 +188,7 @@
|
||||
</children>
|
||||
</HBox>
|
||||
<Slider fx:id="solarPanelsSlider" blockIncrement="1.0" layoutX="187.0" layoutY="274.0" majorTickUnit="1.0" max="10.0" min="1.0" minorTickCount="0" prefHeight="24.0" prefWidth="338.0" showTickLabels="true" showTickMarks="true" />
|
||||
<Button fx:id="addSolarPanelsButton" contentDisplay="TOP" layoutX="267.0" layoutY="378.0" mnemonicParsing="false" prefHeight="150.0" prefWidth="180.0" style="-fx-background-color: transparent;" text="Add activity!" textFill="#23652b">
|
||||
<Button fx:id="addSolarPanelsButton" contentDisplay="TOP" layoutX="267.0" layoutY="378.0" mnemonicParsing="false" onAction="#confirmSolarPanels" prefHeight="150.0" prefWidth="180.0" style="-fx-background-color: transparent;" text="Add activity!" textFill="#23652b">
|
||||
<font>
|
||||
<Font name="System Bold Italic" size="18.0" />
|
||||
</font>
|
||||
@@ -184,5 +202,64 @@
|
||||
</Button>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
<AnchorPane fx:id="localProducePane" layoutX="107.0" prefHeight="611.0" prefWidth="713.0" visible="false">
|
||||
<children>
|
||||
<Line fx:id="line11" endX="79.0" layoutX="465.0" layoutY="7.0" stroke="#545b54" />
|
||||
<Text layoutX="264.0" layoutY="56.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Buying local produce">
|
||||
<font>
|
||||
<Font size="20.0" />
|
||||
</font>
|
||||
</Text>
|
||||
<Button fx:id="addLocalProduceButton" contentDisplay="TOP" layoutX="267.0" layoutY="226.0" mnemonicParsing="false" onAction="#confirmLocalProduce" prefHeight="150.0" prefWidth="180.0" style="-fx-background-color: transparent;" text="Add activity!" textFill="#23652b">
|
||||
<font>
|
||||
<Font name="System Bold Italic" size="18.0" />
|
||||
</font>
|
||||
<graphic>
|
||||
<ImageView fitHeight="116.0" fitWidth="156.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@../icons/addActivity1.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
<AnchorPane fx:id="publicTransportPane" layoutX="107.0" prefHeight="611.0" prefWidth="713.0" visible="false">
|
||||
<children>
|
||||
<Line fx:id="line21" endX="79.0" layoutX="465.0" layoutY="7.0" stroke="#545b54" />
|
||||
<Text layoutX="153.0" layoutY="56.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Using your public transport instead of your car">
|
||||
<font>
|
||||
<Font size="20.0" />
|
||||
</font>
|
||||
</Text>
|
||||
<Slider fx:id="publicTransportSlider" layoutX="144.0" layoutY="271.0" majorTickUnit="20.0" max="200.0" minorTickCount="0" prefHeight="24.0" prefWidth="427.0" showTickLabels="true" showTickMarks="true" />
|
||||
<Text fill="#727272" layoutX="151.0" layoutY="145.0" strokeType="OUTSIDE" strokeWidth="0.0" text="How many km did you travel using public transport that you would have traveled with your car?" textAlignment="CENTER">
|
||||
<font>
|
||||
<Font size="18.0" />
|
||||
</font>
|
||||
</Text>
|
||||
<Button fx:id="addPublicTransportButton" contentDisplay="TOP" layoutX="267.0" layoutY="351.0" mnemonicParsing="false" onAction="#confirmPublicTransport" prefHeight="150.0" prefWidth="180.0" style="-fx-background-color: transparent;" text="Add activity!" textFill="#23652b">
|
||||
<font>
|
||||
<Font name="System Bold Italic" size="18.0" />
|
||||
</font>
|
||||
<graphic>
|
||||
<ImageView fitHeight="116.0" fitWidth="156.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@../icons/addActivity1.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
<HBox alignment="CENTER" layoutX="305.0" layoutY="204.0" prefHeight="36.0" prefWidth="107.0" styleClass="textHolder">
|
||||
<children>
|
||||
<Label fx:id="publicTransportLabel" text="0 km">
|
||||
<font>
|
||||
<Font size="17.0" />
|
||||
</font>
|
||||
</Label>
|
||||
</children>
|
||||
</HBox>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
|
||||
BIN
src/Client/src/main/resources/icons/localProduce.png
Normal file
BIN
src/Client/src/main/resources/icons/localProduce.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.5 KiB |
BIN
src/Client/src/main/resources/icons/publicTransport.png
Normal file
BIN
src/Client/src/main/resources/icons/publicTransport.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.1 KiB |
Reference in New Issue
Block a user