forked from nus-cs2103-AY1920S1/addressbook-level3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #136 from jonathantjendana/branch-ui
Redesigned UI
- Loading branch information
Showing
14 changed files
with
366 additions
and
492 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package seedu.moneygowhere.ui; | ||
|
||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
|
||
import javafx.fxml.FXML; | ||
import javafx.scene.chart.CategoryAxis; | ||
import javafx.scene.chart.LineChart; | ||
import javafx.scene.chart.NumberAxis; | ||
import javafx.scene.chart.XYChart; | ||
import javafx.scene.control.Tooltip; | ||
import javafx.scene.layout.Region; | ||
import javafx.scene.layout.StackPane; | ||
|
||
/** | ||
* Tab containing the spending graph. | ||
*/ | ||
public class GraphPanel extends UiPart<Region> { | ||
private static final String FXML = "PlaceholderPanel.fxml"; | ||
|
||
@FXML | ||
private StackPane panePlaceholder; | ||
|
||
public GraphPanel(LinkedHashMap<String, Double> graphData) { | ||
super(FXML); | ||
CategoryAxis xAxis = new CategoryAxis(); | ||
xAxis.setLabel("Date"); | ||
NumberAxis yAxis = new NumberAxis(); | ||
yAxis.setLabel("Amount spent ($)"); | ||
LineChart<String, Number> spendingChart = new LineChart<>(xAxis, yAxis); | ||
|
||
spendingChart.setTitle("Graph"); | ||
|
||
XYChart.Series<String, Number> series = new XYChart.Series<>(); | ||
series.setName("Spending"); | ||
for (Map.Entry<String, Double> i : graphData.entrySet()) { | ||
XYChart.Data<String, Number> dataToAdd = new XYChart.Data<>(i.getKey().toString(), | ||
Math.round(i.getValue())); | ||
series.getData().add(dataToAdd); | ||
} | ||
spendingChart.getData().add(series); | ||
|
||
for (XYChart.Series<String, Number> s : spendingChart.getData()) { | ||
for (XYChart.Data<String, Number> d : s.getData()) { | ||
Tooltip.install(d.getNode(), new Tooltip( | ||
"Date: \t" + d.getXValue() + "\n" | ||
+ "Spending: \t$" + d.getYValue() + ".00")); | ||
|
||
//Adding class on hover | ||
d.getNode().setOnMouseEntered(event -> d.getNode().getStyleClass().add("onHover")); | ||
|
||
//Removing class on exit | ||
d.getNode().setOnMouseExited(event -> d.getNode().getStyleClass().remove("onHover")); | ||
} | ||
} | ||
panePlaceholder.getChildren().add(spendingChart); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package seedu.moneygowhere.ui; | ||
|
||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
|
||
import javafx.collections.FXCollections; | ||
import javafx.collections.ObservableList; | ||
import javafx.fxml.FXML; | ||
import javafx.scene.chart.PieChart; | ||
import javafx.scene.layout.Region; | ||
import javafx.scene.layout.StackPane; | ||
|
||
/** | ||
* Tab containing the spending graph. | ||
*/ | ||
public class StatsPanel extends UiPart<Region> { | ||
private static final String FXML = "PlaceholderPanel.fxml"; | ||
|
||
@FXML | ||
private StackPane panePlaceholder; | ||
|
||
public StatsPanel(LinkedHashMap<String, Double> statsData) { | ||
super(FXML); | ||
|
||
ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList(); | ||
|
||
for (Map.Entry<String, Double> i : statsData.entrySet()) { | ||
pieChartData.add(new PieChart.Data(i.getKey() + String.format(" ($%.2f)", i.getValue()), | ||
Math.round(i.getValue()))); | ||
} | ||
PieChart pieChart = new PieChart(pieChartData); | ||
if (pieChartData.size() == 0) { | ||
pieChart.setTitle("No data to show"); | ||
} else { | ||
pieChart.setTitle("Statistics"); | ||
} | ||
pieChart.setLegendVisible(false); | ||
|
||
panePlaceholder.getChildren().add(pieChart); | ||
} | ||
|
||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.