diff --git a/app/gui-javafx/src/main/java/org/applecommander/javafx/DiskUsageView.java b/app/gui-javafx/src/main/java/org/applecommander/javafx/DiskUsageView.java index b73d121c..75d6993e 100644 --- a/app/gui-javafx/src/main/java/org/applecommander/javafx/DiskUsageView.java +++ b/app/gui-javafx/src/main/java/org/applecommander/javafx/DiskUsageView.java @@ -75,7 +75,6 @@ public class DiskUsageView extends StackPane { // Chart view pieChart = new PieChart(); - pieChart.getStylesheets().add(Objects.requireNonNull(getClass().getResource("/css/pie-chart-custom-colors.css")).toExternalForm()); pieChart.setTitle("Disk Usage"); fileStoreWindow.fileStoreSelection().selectedItemProperty().addListener((observable, oldValue, newValue) -> { if (newValue != null) { @@ -132,7 +131,9 @@ public class DiskUsageView extends StackPane { List data = new ArrayList<>(); for (UsageType usageType : UsageType.values()) { int value = counts.getOrDefault(usageType, 0); - data.add(new PieChart.Data(usageType.name(), value)); + if (usageType == UsageType.FREE || value > 0) { + data.add(new PieChart.Data(usageType.name(), value)); + } } pieChart.setData(FXCollections.observableArrayList(data)); } @@ -149,6 +150,8 @@ public class DiskUsageView extends StackPane { UsageType.DIRECTORY, Color.MEDIUMORCHID, UsageType.FILE, Color.GOLDENROD ); + // Summing this independently since we have to loop through all sectors/blocks anyway. + final Map counts = new HashMap<>(); // Iterate DiskUsage based on type diskUsageGrid.setHgap(5); @@ -197,7 +200,9 @@ public class DiskUsageView extends StackPane { int row = 0; int col = 0; for (int b=0; b v == null ? 0 : v + 1); + diskUsageGrid.add(makeSwatch(colors.get(usageType), size), col+1, row+1); col++; if (col >= numberOfColumns) { col = 0; @@ -229,7 +234,9 @@ public class DiskUsageView extends StackPane { } for (int t = 0; t v == null ? 0 : v + 1); + diskUsageGrid.add(makeSwatch(colors.get(usageType), size), t+1, s+1); } } } @@ -237,9 +244,11 @@ public class DiskUsageView extends StackPane { // Legend - note that we work the colors in the same order as the pie chart for consistency! legendBox.getChildren().clear(); for (UsageType usageType : UsageType.values()) { - legendBox.getChildren().addAll(makeSwatch(colors.get(usageType), size), new Label(usageType.name())); - if (usageType == UsageType.FREE) { - legendBox.getChildren().add(new Separator(Orientation.VERTICAL)); + if (usageType == UsageType.FREE || counts.getOrDefault(usageType, 0) > 0) { + legendBox.getChildren().addAll(makeSwatch(colors.get(usageType), size), new Label(usageType.name())); + if (usageType == UsageType.FREE) { + legendBox.getChildren().add(new Separator(Orientation.VERTICAL)); + } } } legendBox.setAlignment(Pos.CENTER); diff --git a/app/gui-javafx/src/main/resources/css/pie-chart-custom-colors.css b/app/gui-javafx/src/main/resources/css/pie-chart-custom-colors.css deleted file mode 100644 index 6d66829e..00000000 --- a/app/gui-javafx/src/main/resources/css/pie-chart-custom-colors.css +++ /dev/null @@ -1,7 +0,0 @@ -.default-color0.chart-pie { -fx-pie-color: lightgreen; } /* FREE */ -.default-color1.chart-pie { -fx-pie-color: lightcoral; } /* USED */ -.default-color2.chart-pie { -fx-pie-color: teal; } /* BOOT */ -.default-color3.chart-pie { -fx-pie-color: steelblue; } /* BITMAP */ -.default-color4.chart-pie { -fx-pie-color: palegoldenrod; } /* SYSTEM */ -.default-color5.chart-pie { -fx-pie-color: mediumorchid; } /* DIRECTORY */ -.default-color6.chart-pie { -fx-pie-color: goldenrod; } /* FILE */