Skip to content

Commit

Permalink
Merge pull request #2524 from ControlSystemStudio/CSSTUDIO-1812
Browse files Browse the repository at this point in the history
CSSTUDIO-1812: Fix width of columns in the "Statistics"-tab
  • Loading branch information
abrahamwolk authored Jan 31, 2023
2 parents 19b831b + 5e750a8 commit 86e2788
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleLongProperty;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
Expand Down Expand Up @@ -68,19 +70,19 @@ public class StatisticsTabController implements ModelListener{
@FXML
private TableColumn<ModelItemStatistics, String> displayNameColumn;
@FXML
private TableColumn<ModelItemStatistics, String> countColumn;
private TableColumn<ModelItemStatistics, Long> countColumn;
@FXML
private TableColumn<ModelItemStatistics, String> meanColumn;
private TableColumn<ModelItemStatistics, Double> meanColumn;
@FXML
private TableColumn<ModelItemStatistics, String> medianColumn;
private TableColumn<ModelItemStatistics, Double> medianColumn;
@FXML
private TableColumn<ModelItemStatistics, String> stdDevColumn;
private TableColumn<ModelItemStatistics, Double> stdDevColumn;
@FXML
private TableColumn<ModelItemStatistics, String> minColumn;
private TableColumn<ModelItemStatistics, Double> minColumn;
@FXML
private TableColumn<ModelItemStatistics, String> maxColumn;
private TableColumn<ModelItemStatistics, Double> maxColumn;
@FXML
private TableColumn<ModelItemStatistics, String> sumColumn;
private TableColumn<ModelItemStatistics, Double> sumColumn;

/** @param model Model */
public StatisticsTabController(Model model){
Expand Down Expand Up @@ -163,19 +165,19 @@ public void updateItem(final ColorIndicator colorIndicator, final boolean empty)
});

countColumn.setText(Messages.StatisticsSampleCount);
countColumn.setCellValueFactory(cell -> cell.getValue().getCount());
countColumn.setCellValueFactory(cell -> cell.getValue().getCount().asObject());
meanColumn.setText(Messages.StatisticsMean);
meanColumn.setCellValueFactory(cell -> cell.getValue().getMean());
meanColumn.setCellValueFactory(cell -> cell.getValue().getMean().asObject());
medianColumn.setText(Messages.StatisticsMedian);
medianColumn.setCellValueFactory(cell -> cell.getValue().getMedian());
medianColumn.setCellValueFactory(cell -> cell.getValue().getMedian().asObject());
stdDevColumn.setText(Messages.StatisticsStdDev);
stdDevColumn.setCellValueFactory(cell -> cell.getValue().getStdDev());
stdDevColumn.setCellValueFactory(cell -> cell.getValue().getStdDev().asObject());
minColumn.setText(Messages.StatisticsMin);
minColumn.setCellValueFactory(cell -> cell.getValue().getMin());
minColumn.setCellValueFactory(cell -> cell.getValue().getMin().asObject());
maxColumn.setText(Messages.StatisticsMax);
maxColumn.setCellValueFactory(cell -> cell.getValue().getMax());
maxColumn.setCellValueFactory(cell -> cell.getValue().getMax().asObject());
sumColumn.setText(Messages.StatisticsSum);
sumColumn.setCellValueFactory(cell -> cell.getValue().getSum());
sumColumn.setCellValueFactory(cell -> cell.getValue().getSum().asObject());
}

/** Remove listener */
Expand Down Expand Up @@ -203,13 +205,13 @@ public ColorIndicator(Color color){
* the data model for the table.
*/
private class ModelItemStatistics {
private SimpleStringProperty count = new SimpleStringProperty();
private SimpleStringProperty mean = new SimpleStringProperty();
private SimpleStringProperty median = new SimpleStringProperty();
private SimpleStringProperty stdDev = new SimpleStringProperty();
private SimpleStringProperty min = new SimpleStringProperty();
private SimpleStringProperty max = new SimpleStringProperty();
private SimpleStringProperty sum = new SimpleStringProperty();
private SimpleLongProperty count = new SimpleLongProperty();
private SimpleDoubleProperty mean = new SimpleDoubleProperty(Double.NaN);
private SimpleDoubleProperty median = new SimpleDoubleProperty(Double.NaN);
private SimpleDoubleProperty stdDev = new SimpleDoubleProperty(Double.NaN);
private SimpleDoubleProperty min = new SimpleDoubleProperty(Double.NaN);
private SimpleDoubleProperty max = new SimpleDoubleProperty(Double.NaN);
private SimpleDoubleProperty sum = new SimpleDoubleProperty(Double.NaN);
private SimpleObjectProperty colorIndicator = new SimpleObjectProperty();
private SimpleStringProperty traceName = new SimpleStringProperty();

Expand All @@ -227,25 +229,25 @@ public ModelItemStatistics(ModelItem modelItem){
*/
private void clear(){
Platform.runLater(() -> {
count.set(null);
mean.set(null);
median.set(null);
stdDev.set(null);
min.set(null);
max.set(null);
sum.set(null);
count.set(0);
mean.set(Double.NaN);
median.set(Double.NaN);
stdDev.set(Double.NaN);
min.set(Double.NaN);
max.set(Double.NaN);
sum.set(Double.NaN);
});
}

private void set(DescriptiveStatistics statistics){
Platform.runLater(() -> {
count.set(String.valueOf(statistics.getN()));
mean.set(String.valueOf(statistics.getMean()));
median.set(String.valueOf(statistics.getPercentile(50)));
stdDev.set(String.valueOf(statistics.getStandardDeviation()));
min.set(String.valueOf(statistics.getMin()));
max.set(String.valueOf(statistics.getMax()));
sum.set(String.valueOf(statistics.getSum()));
count.set(statistics.getN());
mean.set(statistics.getMean());
median.set(statistics.getPercentile(50));
stdDev.set(statistics.getStandardDeviation());
min.set(statistics.getMin());
max.set(statistics.getMax());
sum.set(statistics.getSum());
});
}

Expand Down Expand Up @@ -296,31 +298,31 @@ public void setColorIndicator(Color color){
colorIndicator.set(new ColorIndicator(color));
}

public SimpleStringProperty getCount() {
public SimpleLongProperty getCount() {
return count;
}

public SimpleStringProperty getStdDev() {
public SimpleDoubleProperty getStdDev() {
return stdDev;
}

public SimpleStringProperty getMean() {
public SimpleDoubleProperty getMean() {
return mean;
}

public SimpleStringProperty getMedian() {
public SimpleDoubleProperty getMedian() {
return median;
}

public SimpleStringProperty getMin() {
public SimpleDoubleProperty getMin() {
return min;
}

public SimpleStringProperty getMax() {
public SimpleDoubleProperty getMax() {
return max;
}

public SimpleStringProperty getSum() {
public SimpleDoubleProperty getSum() {
return sum;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,28 @@
~ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-->

<GridPane minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.csstudio.trends.databrowser3.ui.properties.StatisticsTabController">
<children>

<ToolBar minHeight="-Infinity" minWidth="-Infinity" prefHeight="40.0" prefWidth="600.0" VBox.vgrow="NEVER">
<items>
<Button fx:id="refreshAll" mnemonicParsing="false" onAction="#refreshAll" text="Refresh All" />
</items>
</ToolBar>
<TableView fx:id="tracesTable" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" GridPane.hgrow="ALWAYS" GridPane.rowIndex="1" VBox.vgrow="ALWAYS">
<columns>
<TableColumn fx:id="indicatorColumn" prefWidth="22.0" />
<TableColumn fx:id="displayNameColumn" prefWidth="130.0" text="Display Name"/>
<TableColumn fx:id="countColumn" prefWidth="100.0" text="Sample Count" />
<TableColumn fx:id="meanColumn" prefWidth="100.0" text="Mean" />
<TableColumn fx:id="medianColumn" prefWidth="100.0" text="Median" />
<TableColumn fx:id="stdDevColumn" prefWidth="100.0" text="Standard Deviation" />
<TableColumn fx:id="minColumn" prefWidth="100.0" text="Min Value" />
<TableColumn fx:id="maxColumn" prefWidth="100.0" text="Max Value" />
<TableColumn fx:id="sumColumn" prefWidth="100.0" text="Sum" />
</columns>
</TableView>
</children>
<columnConstraints>
<ColumnConstraints />
</columnConstraints>
<rowConstraints>
<RowConstraints />
<RowConstraints />
</rowConstraints>
</GridPane>
<VBox xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="org.csstudio.trends.databrowser3.ui.properties.StatisticsTabController">
<children>
<ToolBar prefHeight="40.0" VBox.vgrow="NEVER">
<items>
<Button fx:id="refreshAll" mnemonicParsing="false" onAction="#refreshAll" text="Refresh All"/>
</items>
</ToolBar>
<ScrollPane fitToHeight="true" fitToWidth="true" VBox.vgrow="ALWAYS">
<TableView fx:id="tracesTable">
<columns>
<TableColumn fx:id="indicatorColumn" minWidth="22.0" maxWidth="22.0" prefWidth="22.0"/>
<TableColumn fx:id="displayNameColumn" minWidth="130.0" prefWidth="260.0" text="Display Name"/>
<TableColumn fx:id="countColumn" minWidth="130" prefWidth="130.0" text="Sample Count"/>
<TableColumn fx:id="meanColumn" minWidth="200.0" prefWidth="200.0" text="Mean"/>
<TableColumn fx:id="medianColumn" minWidth="200.0" prefWidth="200.0" text="Median"/>
<TableColumn fx:id="stdDevColumn" minWidth="200.0" prefWidth="200.0" text="Standard Deviation"/>
<TableColumn fx:id="minColumn" minWidth="200.0" prefWidth="200.0" text="Min Value"/>
<TableColumn fx:id="maxColumn" minWidth="200.0" prefWidth="200.0" text="Max Value"/>
<TableColumn fx:id="sumColumn" minWidth="200.0" prefWidth="200.0" text="Sum"/>
</columns>
</TableView>
</ScrollPane>
</children>
</VBox>

0 comments on commit 86e2788

Please sign in to comment.