Commit 94c32956 authored by Alexander Diewald's avatar Alexander Diewald
Browse files

Merge branch '3452' into 'master'

[3452] Migrate the spiderchart visualization

See merge request af3/af3!344
parents cf2ef474 1e19c528
SpiderChartVisualization.java a829db31b92435ba9b1f3508e246cc79a9c5dfd0 GREEN
SpiderChartVisualization.java f466f737829a8f626b136b2ddc988df8a42a2542 GREEN
......@@ -17,6 +17,7 @@ package org.fortiss.af3.exploration.ui.perspective.visualization.visualizations.
import static org.fortiss.af3.exploration.ui.util.SpiderChartUtils.transformIntoSpiderChart;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
......@@ -26,7 +27,10 @@ import org.fortiss.af3.exploration.ui.perspective.service.IDSEPerspectiveManager
import org.fortiss.af3.exploration.ui.perspective.service.IEventListener;
import org.fortiss.af3.exploration.ui.perspective.visualization.visualizations.IVisualizationView;
import org.fortiss.tooling.base.model.visualization.DataSetCollection;
import org.fortiss.tooling.spiderchart.widget.SpiderChartViewer;
import org.fortiss.tooling.spiderchart.control.SpiderChartViewer;
import javafx.embed.swt.FXCanvas;
import javafx.scene.Scene;
/**
* Spider Chart Visualization View.
......@@ -36,8 +40,10 @@ import org.fortiss.tooling.spiderchart.widget.SpiderChartViewer;
*/
public final class SpiderChartVisualization implements IVisualizationView, IEventListener {
// TODO (3450) The FXCanvas can be removed once the whole visualization view part is
// JavaFX-based
/** The spider chart viewer. */
private SpiderChartViewer viewer;
private FXCanvas viewer;
/** {@inheritDoc} */
@Override
......@@ -45,7 +51,10 @@ public final class SpiderChartVisualization implements IVisualizationView, IEven
DataSetCollection latestGeneratedDSEVisElements =
IDSEPerspectiveManager.INSTANCE.getLatestGeneratedDSEVisElements();
if(latestGeneratedDSEVisElements != null) {
viewer = transformIntoSpiderChart(latestGeneratedDSEVisElements, composite);
viewer = new FXCanvas(composite, SWT.NONE);
SpiderChartViewer chart = transformIntoSpiderChart(latestGeneratedDSEVisElements);
Scene scene = new Scene(chart.getViewerPane());
viewer.setScene(scene);
viewer.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
Rectangle clientArea = composite.getClientArea();
viewer.setBounds(clientArea.x, clientArea.y, clientArea.width, clientArea.height);
......
ExplorationSolutionVisualizationUtils.java 089540ba52f75b4a5024fa2ed7826d906e4ddde0 GREEN
ExplorationUiUtils.java aad4d16990fd642bcaa5d54b3ec0a575f3c5904f GREEN
SpiderChartUtils.java 885d37e537db3b6128c08a4c98247f3a9613d9bf GREEN
SpiderChartUtils.java 0fe92dbfbc71b16a000ab9b5bacb282456771d63 GREEN
......@@ -17,17 +17,15 @@ package org.fortiss.af3.exploration.ui.util;
import static java.lang.Math.max;
import static java.lang.Math.min;
import static javafx.scene.paint.Color.BLUE;
import static javafx.scene.paint.Color.DARKGRAY;
import static javafx.scene.paint.Color.LIGHTGRAY;
import static org.fortiss.af3.schedule.ui.ganttchartview.ScheduleViewColors.getColor;
import static org.fortiss.tooling.base.ui.utils.FontUtils.VERDANA_14PT;
import static org.fortiss.tooling.spiderchart.style.FontStyle.BLACK_VERDANA_10PT;
import static org.fortiss.tooling.spiderchart.style.FontStyle.BLACK_VERDANA_12PT;
import static org.fortiss.tooling.spiderchart.style.FontStyle.BLACK_VERDANA_14PT;
import static org.fortiss.tooling.spiderchart.style.FontStyle.BLACK_VERDANA_8PT;
import static org.fortiss.tooling.spiderchart.style.LineStyle.SOLID_BLACK_1PT;
import static org.fortiss.tooling.spiderchart.util.RGBColorUtils.BLUE;
import static org.fortiss.tooling.spiderchart.util.RGBColorUtils.DARK_GRAY;
import static org.fortiss.tooling.spiderchart.util.RGBColorUtils.LIGHT_GRAY;
import static org.fortiss.tooling.spiderchart.util.RGBColorUtils.getDarkerColor;
import static org.fortiss.tooling.common.ui.javafx.style.FontStyle.BLACK_VERDANA_10PT;
import static org.fortiss.tooling.common.ui.javafx.style.FontStyle.BLACK_VERDANA_12PT;
import static org.fortiss.tooling.common.ui.javafx.style.FontStyle.BLACK_VERDANA_14PT;
import static org.fortiss.tooling.common.ui.javafx.style.FontStyle.BLACK_VERDANA_8PT;
import static org.fortiss.tooling.common.ui.javafx.style.LineStyle.SOLID_BLACK_1PT;
import java.text.DecimalFormat;
import java.util.ArrayList;
......@@ -35,22 +33,23 @@ import java.util.HashMap;
import java.util.List;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Composite;
import org.fortiss.tooling.base.model.visualization.Axis;
import org.fortiss.tooling.base.model.visualization.DataPoint;
import org.fortiss.tooling.base.model.visualization.DataSet;
import org.fortiss.tooling.base.model.visualization.DataSetCollection;
import org.fortiss.tooling.common.ui.javafx.style.FillStyle;
import org.fortiss.tooling.common.ui.javafx.style.FontStyle;
import org.fortiss.tooling.common.ui.javafx.style.LineStyle;
import org.fortiss.tooling.spiderchart.control.SpiderChartViewer;
import org.fortiss.tooling.spiderchart.model.DataSeries;
import org.fortiss.tooling.spiderchart.model.DoubleAxis;
import org.fortiss.tooling.spiderchart.model.SpiderChart;
import org.fortiss.tooling.spiderchart.style.AxisStyle;
import org.fortiss.tooling.spiderchart.style.ChartStyle;
import org.fortiss.tooling.spiderchart.style.DataSeriesStyle;
import org.fortiss.tooling.spiderchart.style.FillStyle;
import org.fortiss.tooling.spiderchart.style.FontStyle;
import org.fortiss.tooling.spiderchart.style.LegendStyle;
import org.fortiss.tooling.spiderchart.style.LineStyle;
import org.fortiss.tooling.spiderchart.widget.SpiderChartViewer;
import javafx.scene.paint.Color;
/**
* Utils for spider chart visualization.
......@@ -159,23 +158,20 @@ public class SpiderChartUtils {
*
* @param dataSetCollection
* {@link DataSetCollection} to visualize.
* @param parent
* {@link Composite} to add the viewer as a child.
* @return The corresponding {@link SpiderChartViewer}.
*/
public static SpiderChartViewer transformIntoSpiderChart(DataSetCollection dataSetCollection,
Composite parent) {
public static SpiderChartViewer transformIntoSpiderChart(DataSetCollection dataSetCollection) {
SpiderChart spiderChart = new SpiderChart();
spiderChart.setTitle(dataSetCollection.getName());
spiderChart.setLegendLabel("Legend");
ChartStyle chartStyle = new ChartStyle(true, true, false);
chartStyle.setTitleStyle(new FontStyle(VERDANA_14PT, getDarkerColor(BLUE)));
LegendStyle legendStyle = new LegendStyle(BLUE, false, 5, BLACK_VERDANA_12PT);
chartStyle.setTitleStyle(new FontStyle("Verdana", 14, BLUE.darker()));
LegendStyle legendStyle = new LegendStyle(false, 5, BLACK_VERDANA_12PT);
chartStyle.setLegendStyle(legendStyle);
chartStyle.setAxisSegments(4);
chartStyle.setBackgroundFillStyle(new FillStyle(LIGHT_GRAY));
chartStyle.setBackgroundLineStyle(new LineStyle(DARK_GRAY));
chartStyle.setBackgroundFillStyle(new FillStyle(LIGHTGRAY));
chartStyle.setBackgroundLineStyle(new LineStyle(DARKGRAY));
HashMap<Axis<Object>, DoubleAxis> modelToVisAxisMapping;
modelToVisAxisMapping = new HashMap<>();
......@@ -203,16 +199,19 @@ public class SpiderChartUtils {
}
dataSeries.setPoint(modelToVisAxisMapping.get(p.getAxis()), value);
}
RGB color = getColor(s.getId()).getRGB();
int alpha = 64;
LineStyle olive1pt = new LineStyle(color);
FillStyle oliveFill = new FillStyle(color, alpha);
DataSeriesStyle style = new DataSeriesStyle(olive1pt, oliveFill, true, true,
BLACK_VERDANA_10PT, 7, new DecimalFormat("#.#"));
// TODO (3450) The RGB-to-Color conversion can be removed once the Gantt-chart (and its
// utility methods) are JavaFX-based
RGB rgb = getColor(s.getId()).getRGB();
Color color = new Color(rgb.red / 255.0, rgb.green / 255.0, rgb.blue / 255.0, 1);
LineStyle line = new LineStyle(color.darker());
FillStyle fill = new FillStyle(color.brighter(), 0.5);
DataSeriesStyle style = new DataSeriesStyle(line, fill, true, true, BLACK_VERDANA_10PT,
7, new DecimalFormat("#.#"));
chartStyle.setDataSeriesStyle(dataSeries, style);
spiderChart.addData(dataSeries);
}
return new SpiderChartViewer(parent, spiderChart, chartStyle);
return new SpiderChartViewer(spiderChart, chartStyle);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment