Skip to content
Snippets Groups Projects
Commit 248d89e6 authored by Robert Goldmann's avatar Robert Goldmann
Browse files

Fixed #176 - chart full legend add delimiter lines

parent 4419ff40
No related branches found
No related tags found
1 merge request!213merge v1_6_0 into master
...@@ -18,6 +18,7 @@ import javafx.scene.layout.Priority; ...@@ -18,6 +18,7 @@ import javafx.scene.layout.Priority;
import javafx.scene.layout.Region; import javafx.scene.layout.Region;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.transform.Transform; import javafx.scene.transform.Transform;
import javafx.stage.Modality; import javafx.stage.Modality;
import javafx.stage.Stage; import javafx.stage.Stage;
...@@ -35,6 +36,7 @@ public class CategoriesChart extends VBox implements ChartExportable ...@@ -35,6 +36,7 @@ public class CategoriesChart extends VBox implements ChartExportable
private LegendType legendType; private LegendType legendType;
private final double CHART_HEIGHT = 200; private final double CHART_HEIGHT = 200;
private final double FULL_LEGEND_ITEM_HEIGHT = 40; private final double FULL_LEGEND_ITEM_HEIGHT = 40;
private final double DELIMITER_HEIGHT = 21;
public CategoriesChart(String titleIncomes, String titlePayments, ArrayList<CategoryInOutSum> categoryInOutSums, String currency, LegendType legendType) public CategoriesChart(String titleIncomes, String titlePayments, ArrayList<CategoryInOutSum> categoryInOutSums, String currency, LegendType legendType)
{ {
...@@ -176,7 +178,7 @@ public class CategoriesChart extends VBox implements ChartExportable ...@@ -176,7 +178,7 @@ public class CategoriesChart extends VBox implements ChartExportable
double totalOut = getTotal(categoryInOutSums, false); double totalOut = getTotal(categoryInOutSums, false);
HBox hboxLegend = new HBox(); HBox hboxLegend = new HBox();
hboxLegend.setSpacing(10); hboxLegend.setSpacing(0);
VBox vboxCircles = new VBox(); VBox vboxCircles = new VBox();
vboxCircles.setSpacing(10); vboxCircles.setSpacing(10);
...@@ -195,6 +197,7 @@ public class CategoriesChart extends VBox implements ChartExportable ...@@ -195,6 +197,7 @@ public class CategoriesChart extends VBox implements ChartExportable
Label labelHeaderName = new Label(Localization.getString(Strings.TITLE_CATEGORIES)); Label labelHeaderName = new Label(Localization.getString(Strings.TITLE_CATEGORIES));
labelHeaderName.setStyle("-fx-font-weight: bold; -fx-underline: true;"); labelHeaderName.setStyle("-fx-font-weight: bold; -fx-underline: true;");
labelHeaderName.setMinHeight(20); labelHeaderName.setMinHeight(20);
labelHeaderName.setPadding(new Insets(0, 0, 0, 10));
vboxNames.getChildren().add(labelHeaderName); vboxNames.getChildren().add(labelHeaderName);
Label labelHeaderIn = new Label(Localization.getString(Strings.TITLE_INCOMES)); Label labelHeaderIn = new Label(Localization.getString(Strings.TITLE_INCOMES));
...@@ -218,6 +221,7 @@ public class CategoriesChart extends VBox implements ChartExportable ...@@ -218,6 +221,7 @@ public class CategoriesChart extends VBox implements ChartExportable
Label labelName = new Label(currentItem.getName()); Label labelName = new Label(currentItem.getName());
labelName.setStyle("-fx-font-weight: bold;"); labelName.setStyle("-fx-font-weight: bold;");
labelName.setMinHeight(20); labelName.setMinHeight(20);
labelName.setPadding(new Insets(0, 0, 0, 10));
vboxNames.getChildren().add(labelName); vboxNames.getChildren().add(labelName);
String percentageIn = totalIn != 0 ? Helpers.NUMBER_FORMAT.format(Math.abs((currentItem.getBudgetIN() / totalIn))) : "0,00"; String percentageIn = totalIn != 0 ? Helpers.NUMBER_FORMAT.format(Math.abs((currentItem.getBudgetIN() / totalIn))) : "0,00";
...@@ -231,6 +235,12 @@ public class CategoriesChart extends VBox implements ChartExportable ...@@ -231,6 +235,12 @@ public class CategoriesChart extends VBox implements ChartExportable
labelOutSum.setStyle("-fx-font-weight: bold;"); labelOutSum.setStyle("-fx-font-weight: bold;");
labelOutSum.setMinHeight(20); labelOutSum.setMinHeight(20);
vboxOut.getChildren().add(labelOutSum); vboxOut.getChildren().add(labelOutSum);
//add delimiters
vboxCircles.getChildren().add(generateNewSeparator());
vboxNames.getChildren().add(generateNewSeparator());
vboxIn.getChildren().add(generateNewSeparator());
vboxOut.getChildren().add(generateNewSeparator());
} }
hboxLegend.getChildren().add(vboxCircles); hboxLegend.getChildren().add(vboxCircles);
...@@ -263,6 +273,17 @@ public class CategoriesChart extends VBox implements ChartExportable ...@@ -263,6 +273,17 @@ public class CategoriesChart extends VBox implements ChartExportable
return legendItem; return legendItem;
} }
private Label generateNewSeparator()
{
Label separator = new Label();
separator.setStyle("-fx-background-color: #212121; -fx-padding: 0;");
separator.setFont(new Font(1));
separator.setMinHeight(1);
separator.setMaxHeight(1);
separator.setMaxWidth(Double.MAX_VALUE);
return separator;
}
private double getTotal(ArrayList<CategoryInOutSum> categoryInOutSums, boolean useIncomes) private double getTotal(ArrayList<CategoryInOutSum> categoryInOutSums, boolean useIncomes)
{ {
double total = 0; double total = 0;
...@@ -321,6 +342,6 @@ public class CategoriesChart extends VBox implements ChartExportable ...@@ -321,6 +342,6 @@ public class CategoriesChart extends VBox implements ChartExportable
@Override @Override
public double getSuggestedHeight() public double getSuggestedHeight()
{ {
return CHART_HEIGHT + categoryInOutSums.size() * FULL_LEGEND_ITEM_HEIGHT + 50; return CHART_HEIGHT + categoryInOutSums.size() * (FULL_LEGEND_ITEM_HEIGHT + DELIMITER_HEIGHT) + 50;
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment