Skip to content
Snippets Groups Projects
Commit f731e7d5 authored by Eddie Groh's avatar Eddie Groh
Browse files

Added pie chart example for the metric view

Issue-Ref: 4310
Issue-Url: af3#4310


Signed-off-by: default avatarEddie Groh <groh@fortiss.org>
parent 5cf02524
No related branches found
No related tags found
1 merge request!210Setting up Metric extraction plugin for AF3 : Issue 4310
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.chart.PieChart?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.control.TreeTableView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.StackPane?>
<SplitPane fx:id="metricsSplitPane"
dividerPositions="0.5" maxHeight="1.7976931348623157E308"
maxWidth="1.7976931348623157E308" minHeight="-Infinity"
minWidth="-Infinity" orientation="VERTICAL" prefHeight="400.0"
prefWidth="1035.0" xmlns="http://javafx.com/javafx/13"
xmlns:fx="http://javafx.com/fxml/1">
<SplitPane fx:id="metricsSplitPane" dividerPositions="0.5" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" orientation="VERTICAL" prefHeight="400.0" prefWidth="1035.0" xmlns="http://javafx.com/javafx/20.0.1" xmlns:fx="http://javafx.com/fxml/1">
<items>
<BorderPane maxHeight="-Infinity" minHeight="-Infinity"
prefHeight="25.0" prefWidth="626.0">
<BorderPane maxHeight="-Infinity" minHeight="-Infinity" prefHeight="25.0" prefWidth="626.0">
<center>
<Label fx:id="topLabel" alignment="CENTER"
contentDisplay="CENTER" prefHeight="51.0" prefWidth="500.0"
textAlignment="CENTER" BorderPane.alignment="CENTER" />
<Label fx:id="topLabel" alignment="CENTER" contentDisplay="CENTER" prefHeight="51.0" prefWidth="500.0" textAlignment="CENTER" BorderPane.alignment="CENTER" />
</center>
<left>
<Button fx:id="refreshButton" mnemonicParsing="false"
onAction="#onRefreshMetricsSubmit" text="Refresh Metrics"
BorderPane.alignment="CENTER" />
<Button fx:id="refreshButton" mnemonicParsing="false" onAction="#onRefreshMetricsSubmit" text="Refresh Metrics" BorderPane.alignment="CENTER" />
</left>
</BorderPane>
<BorderPane fx:id="borderPane" maxHeight="-Infinity" minHeight="-Infinity"
prefHeight="200.0" prefWidth="626.0">
</BorderPane>
<SplitPane dividerPositions="0.5" prefHeight="200.0" prefWidth="200.0">
<items>
<PieChart fx:id="pieChart" />
<BorderPane fx:id="borderPane" prefHeight="150.0" prefWidth="200.0" />
</items>
</SplitPane>
</items>
</SplitPane>
......@@ -55,6 +55,7 @@ import org.fortiss.tooling.spiderchart.style.LegendStyle;
import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.chart.PieChart;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.SplitPane;
......@@ -81,10 +82,14 @@ public class MetricsFXController extends CompositeFXControllerBase<SplitPane, No
@FXML
private Label topLabel;
/** The bottom {@link BorderPane} to do stuff */
/** The bottom {@link BorderPane} for the spiderchart */
@FXML
private BorderPane borderPane;
/** a pieChart */
@FXML
private PieChart pieChart;
/** Time format when displaying updating time. */
private final DateTimeFormatter timeFormat = DateTimeFormatter.ofPattern("HH:mm:ss");
......@@ -153,12 +158,25 @@ public class MetricsFXController extends CompositeFXControllerBase<SplitPane, No
var string = provider.getExampleString();
topLabel.setText(string);
SpiderChartViewer viewer =
buildSpiderChart((IModelQualityProvider<IHierarchicElement>)provider);
if(viewer != null) {
if(!provider.getContainedProviders().isEmpty()) {
SpiderChartViewer viewer =
buildSpiderChart((IModelQualityProvider<IHierarchicElement>)provider);
borderPane.setCenter(viewer.getViewerPane());
// Create PieChart and add data
pieChart.getData().clear();
for(var prov : provider.getContainedProviders()) {
PieChart.Data slice = new PieChart.Data(prov.getName(),
((IModelQualityProvider<?>)prov).getExampleValues().get(0));
pieChart.getData().add(slice);
pieChart.setLegendVisible(false);
pieChart.setTitle("");
}
} else {
borderPane.setCenter(null);
pieChart.getData().clear();
}
} else {
......@@ -206,11 +224,7 @@ public class MetricsFXController extends CompositeFXControllerBase<SplitPane, No
DataSeries elementData = new DataSeries("Data");
for(var prov : containedProviders) {
String name = "null!";
if(prov.getName() != null) {
name = prov.getName();
}
DoubleAxis testing = new DoubleAxis(name, 0.0, maxval);
DoubleAxis testing = new DoubleAxis(prov.getName(), 0.0, maxval);
AxisStyle aStyle3Segs = new AxisStyle(SOLID_BLACK_1PT, BLACK_VERDANA_14PT, 3,
BLACK_VERDANA_8PT, new DecimalFormat("#.##"));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment