Created
January 25, 2015 23:11
-
-
Save fge/f25c1f74e00693b0c176 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| callGraph.setCellValueFactory( | |
| param -> new SimpleObjectProperty<RuleMatchingStats>() | |
| { | |
| @Override | |
| public RuleMatchingStats get() | |
| { | |
| return param.getValue(); | |
| } | |
| } | |
| ); | |
| callGraph.setCellFactory( | |
| param -> new TableCell<RuleMatchingStats, RuleMatchingStats>() | |
| { | |
| @Override | |
| protected void updateItem(final RuleMatchingStats item, | |
| final boolean empty) | |
| { | |
| super.updateItem(item, empty); | |
| setText(null); | |
| if (empty) { | |
| setGraphic(null); | |
| return; | |
| } | |
| final ReadOnlyDoubleProperty property = param | |
| .widthProperty(); | |
| final int nonEmptyMatches = item.getNonEmptyMatches(); | |
| final int emptyMatches = item.getEmptyMatches(); | |
| final int failedMatches = item.getFailures(); | |
| final int total = nonEmptyMatches + emptyMatches | |
| + failedMatches; | |
| final double nonEmptyRatio | |
| = (double) nonEmptyMatches / total; | |
| final double emptyRatio | |
| = (double) emptyMatches / total; | |
| final double failureRatio | |
| = (double) failedMatches / total; | |
| // FIXME: unfortunately I cannot use Rectangle::new... | |
| // If I do, the rectangle is not visible :/ | |
| final Supplier<Rectangle> supplier | |
| = () -> new Rectangle(0.0, 20.0); | |
| final HBox hbox = new HBox(); | |
| final ObservableList<Node> nodes = hbox.getChildren(); | |
| DoubleExpression expr; | |
| Rectangle r; | |
| r = supplier.get(); | |
| expr = property.multiply(nonEmptyRatio); | |
| r.widthProperty().bind(expr); | |
| r.setStyle("-fx-fill: CHART_COLOR_3"); | |
| nodes.add(r); | |
| r = supplier.get(); | |
| expr = property.multiply(emptyRatio); | |
| r.widthProperty().bind(expr); | |
| r.setStyle("-fx-fill: CHART_COLOR_2"); | |
| nodes.add(r); | |
| r = supplier.get(); | |
| expr = property.multiply(failureRatio); | |
| r.widthProperty().bind(expr); | |
| r.setStyle("-fx-fill: CHART_COLOR_1"); | |
| nodes.add(r); | |
| setGraphic(hbox); | |
| } | |
| } | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment