Skip to content
Snippets Groups Projects
Commit be4be9f4 authored by Florian Hölzl's avatar Florian Hölzl
Browse files

Spider chart axis plotting started.

refs 2589
parent e215c463
Branches
Tags
No related merge requests found
Showing
with 386 additions and 481 deletions
...@@ -21,10 +21,7 @@ import static org.fortiss.tooling.spiderchart.gc.AbstractGraphicsSupplier.create ...@@ -21,10 +21,7 @@ import static org.fortiss.tooling.spiderchart.gc.AbstractGraphicsSupplier.create
import static org.fortiss.tooling.spiderchart.gc.AbstractGraphicsSupplier.getFont; import static org.fortiss.tooling.spiderchart.gc.AbstractGraphicsSupplier.getFont;
import static org.fortiss.tooling.spiderchart.gc.Fonts.SERIF; import static org.fortiss.tooling.spiderchart.gc.Fonts.SERIF;
import static org.fortiss.tooling.spiderchart.listener.ISpiderChartListener.EVENT_CHART_CLICKED; import static org.fortiss.tooling.spiderchart.listener.ISpiderChartListener.EVENT_CHART_CLICKED;
import static org.fortiss.tooling.spiderchart.listener.ISpiderChartListener.EVENT_ENTER_POINT;
import static org.fortiss.tooling.spiderchart.listener.ISpiderChartListener.EVENT_LEAVE_POINT;
import static org.fortiss.tooling.spiderchart.listener.ISpiderChartListener.EVENT_POINT_CLICKED; import static org.fortiss.tooling.spiderchart.listener.ISpiderChartListener.EVENT_POINT_CLICKED;
import static org.fortiss.tooling.spiderchart.listener.ISpiderChartListener.EVENT_TIP_UPDATE;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -35,13 +32,11 @@ import org.eclipse.swt.graphics.Color; ...@@ -35,13 +32,11 @@ import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
import org.fortiss.tooling.spiderchart.gc.AbstractChartImage; import org.fortiss.tooling.spiderchart.gc.AbstractChartImage;
import org.fortiss.tooling.spiderchart.gc.Polygon;
import org.fortiss.tooling.spiderchart.gc.swt.SpiderChartSwtGraphics; import org.fortiss.tooling.spiderchart.gc.swt.SpiderChartSwtGraphics;
import org.fortiss.tooling.spiderchart.label.SpiderChartLabel; import org.fortiss.tooling.spiderchart.label.SpiderChartLabel;
import org.fortiss.tooling.spiderchart.label.api.IFloatingObject; import org.fortiss.tooling.spiderchart.label.api.IFloatingObject;
import org.fortiss.tooling.spiderchart.listener.ISpiderChartListener; import org.fortiss.tooling.spiderchart.listener.ISpiderChartListener;
import org.fortiss.tooling.spiderchart.model.DataSeries; import org.fortiss.tooling.spiderchart.model.DataSeries;
import org.fortiss.tooling.spiderchart.plotter.AbstractPlotter;
import org.fortiss.tooling.spiderchart.plotter.SpiderChartLegend; import org.fortiss.tooling.spiderchart.plotter.SpiderChartLegend;
import org.fortiss.tooling.spiderchart.plotter.SpiderChartPlotter; import org.fortiss.tooling.spiderchart.plotter.SpiderChartPlotter;
import org.fortiss.tooling.spiderchart.plotter.SpiderChartTitle; import org.fortiss.tooling.spiderchart.plotter.SpiderChartTitle;
...@@ -57,7 +52,7 @@ import org.fortiss.tooling.spiderchart.style.LineStyle; ...@@ -57,7 +52,7 @@ import org.fortiss.tooling.spiderchart.style.LineStyle;
* @version $Rev$ * @version $Rev$
* @ConQAT.Rating GREEN Hash: 13207B1B51F8F60D2122999D2EDB0603 * @ConQAT.Rating GREEN Hash: 13207B1B51F8F60D2122999D2EDB0603
*/ */
public final class SpiderChart { public final class SpiderChartOld {
/** the localized string for numbers */ /** the localized string for numbers */
private static String numberLocale; private static String numberLocale;
...@@ -69,7 +64,7 @@ public final class SpiderChart { ...@@ -69,7 +64,7 @@ public final class SpiderChart {
/** Setter for number locale */ /** Setter for number locale */
public static void setNumberLocale(final String numberLocale) { public static void setNumberLocale(final String numberLocale) {
SpiderChart.numberLocale = numberLocale; SpiderChartOld.numberLocale = numberLocale;
} }
/** The flag to be used to enable selection of data points */ /** The flag to be used to enable selection of data points */
...@@ -160,7 +155,7 @@ public final class SpiderChart { ...@@ -160,7 +155,7 @@ public final class SpiderChart {
private int originalVirtualWidth = -1; private int originalVirtualWidth = -1;
/** The plotters to be used for spider chart plotting. */ /** The plotters to be used for spider chart plotting. */
private AbstractPlotter plotter; private SpiderChartPlotter plotter;
/** Right Margin */ /** Right Margin */
private final double rightMargin = 0.125D; private final double rightMargin = 0.125D;
...@@ -205,7 +200,7 @@ public final class SpiderChart { ...@@ -205,7 +200,7 @@ public final class SpiderChart {
private int width = 0; private int width = 0;
/** Constructor */ /** Constructor */
public SpiderChart(final SpiderChartTitle t, final SpiderChartPlotter p) { public SpiderChartOld(final SpiderChartTitle t, final SpiderChartPlotter p) {
this.resetChart(t, p); this.resetChart(t, p);
} }
...@@ -381,7 +376,7 @@ public final class SpiderChart { ...@@ -381,7 +376,7 @@ public final class SpiderChart {
} }
/** Returns the plotter. */ /** Returns the plotter. */
public AbstractPlotter getPlotter() { public SpiderChartPlotter getPlotter() {
return plotter; return plotter;
} }
...@@ -489,55 +484,57 @@ public final class SpiderChart { ...@@ -489,55 +484,57 @@ public final class SpiderChart {
/** Mouse Move Functionality */ /** Mouse Move Functionality */
public void mouseMoved(final int eX, final int eY) { public void mouseMoved(final int eX, final int eY) {
if(plotter == null) { // FIXME: mouse motion feature currently disabled
return; // if(plotter == null) {
} // return;
// }
this.currentX = eX; //
this.currentY = eY; // this.currentX = eX;
// this.currentY = eY;
Object previousSelectedObject = this.selectedSeq; //
final int previousPoint = this.selectedSeqPoint; // Object previousSelectedObject = this.selectedSeq;
// final int previousPoint = this.selectedSeqPoint;
if(this.selectedSeq == null && this.selectedLabel != null) { //
previousSelectedObject = this.selectedLabel; // if(this.selectedSeq == null && this.selectedLabel != null) {
} // previousSelectedObject = this.selectedLabel;
this.selectedSeq = null; // }
this.selectedLabel = null; // this.selectedSeq = null;
this.selectedSeqPoint = -1; // this.selectedLabel = null;
if(this.activateSelection) { // this.selectedSeqPoint = -1;
List<DataSequence> sList = plotter.getData(); // if(this.activateSelection) {
for(DataSequence d : sList) { // List<DataSequence> sList = plotter.getData();
for(int i = 0; i < d.getHotAreas().size(); i++) { // for(DataSequence d : sList) {
if(((Polygon)d.getHotAreas().get(i)).contains(this.currentX + this.offsetX, // for(int i = 0; i < d.getHotAreas().size(); i++) {
this.currentY + this.offsetY)) { // if(((Polygon)d.getHotAreas().get(i)).contains(this.currentX + this.offsetX,
boolean triggerEnter = false; // this.currentY + this.offsetY)) {
if(previousSelectedObject == null) { // boolean triggerEnter = false;
triggerEnter = true; // if(previousSelectedObject == null) {
} else if(previousSelectedObject != d || previousPoint != i) { // triggerEnter = true;
this.triggerChartEvent(EVENT_LEAVE_POINT); // } else if(previousSelectedObject != d || previousPoint != i) {
triggerEnter = true; // this.triggerChartEvent(EVENT_LEAVE_POINT);
} // triggerEnter = true;
this.selectedSeq = d; // }
this.selectedSeqPoint = i; // this.selectedSeq = d;
if(!triggerEnter) { // this.selectedSeqPoint = i;
break; // if(!triggerEnter) {
} // break;
this.triggerChartEvent(EVENT_ENTER_POINT); // }
break; // this.triggerChartEvent(EVENT_ENTER_POINT);
} // break;
} // }
} // }
} // }
if(Math.abs(this.currentX - this.cursorLastX) > 2 || // }
Math.abs(this.currentY - this.cursorLastY) > 2) { // if(Math.abs(this.currentX - this.cursorLastX) > 2 ||
this.cursorLastX = this.currentX; // Math.abs(this.currentY - this.cursorLastY) > 2) {
this.cursorLastY = this.currentY; // this.cursorLastX = this.currentX;
this.triggerChartEvent(EVENT_TIP_UPDATE); // this.cursorLastY = this.currentY;
} // this.triggerChartEvent(EVENT_TIP_UPDATE);
if(previousSelectedObject != null && this.selectedSeq == null && this.selectedLabel == null) { // }
this.triggerChartEvent(EVENT_LEAVE_POINT); // if(previousSelectedObject != null && this.selectedSeq == null && this.selectedLabel ==
} // null) {
// this.triggerChartEvent(EVENT_LEAVE_POINT);
// }
} }
/** Paints the chart */ /** Paints the chart */
...@@ -553,10 +550,9 @@ public final class SpiderChart { ...@@ -553,10 +550,9 @@ public final class SpiderChart {
resize(); resize();
if(plotter != null) { if(plotter != null) {
plotter.setChart(this);
plotter.plotBackground(graphics); plotter.plotBackground(graphics);
plotter.plotAxes(graphics);
plotter.plot(graphics); plotter.plot(graphics);
// plotter.plot(graphics);
// FIXME: break out // FIXME: break out
// return; // return;
} }
...@@ -596,34 +592,31 @@ public final class SpiderChart { ...@@ -596,34 +592,31 @@ public final class SpiderChart {
this.backStyle.draw(gBack, getBackgroundCanvasColor(), 0, 0, this.virtualWidth, this.backStyle.draw(gBack, getBackgroundCanvasColor(), 0, 0, this.virtualWidth,
this.virtualHeight); this.virtualHeight);
} }
if(plotter.getxScale() != null) { // FIXME: scale feature disabled
plotter.getxScale().setScreenMax(plotter.getX() + plotter.getWidth()); // if(plotter.getxScale() != null) {
plotter.getxScale().setScreenMaxMargin( // plotter.getxScale().setScreenMax(plotter.getX() + plotter.getWidth());
(int)(plotter.getxScale().getScreenMax() * (1.0D - this.axisMargin))); // plotter.getxScale().setScreenMaxMargin(
if(this.fullXAxis) { // (int)(plotter.getxScale().getScreenMax() * (1.0D - this.axisMargin)));
plotter.getxScale().setScreenMaxMargin(plotter.getxScale().getScreenMax()); // if(this.fullXAxis) {
} // plotter.getxScale().setScreenMaxMargin(plotter.getxScale().getScreenMax());
plotter.getxScale().setScreenMin(plotter.getX()); // }
} // plotter.getxScale().setScreenMin(plotter.getX());
if(plotter.getyScale() != null) { // }
plotter.getyScale().setScreenMax(plotter.getY() + plotter.getHeight()); // if(plotter.getyScale() != null) {
plotter.getyScale().setScreenMaxMargin( // plotter.getyScale().setScreenMax(plotter.getY() + plotter.getHeight());
(int)(plotter.getyScale().getScreenMax() * (1.0D - this.axisMargin))); // plotter.getyScale().setScreenMaxMargin(
plotter.getyScale().setScreenMin(plotter.getY()); // (int)(plotter.getyScale().getScreenMax() * (1.0D - this.axisMargin)));
} // plotter.getyScale().setScreenMin(plotter.getY());
// }
plotter.plotBackground(gScroll); plotter.plotBackground(gScroll);
plotter.setChart(this);
plotter.plot(gScroll); plotter.plot(gScroll);
if(this.border != null) { if(this.border != null) {
this.border.drawRect(g, 0, 0, this.getWidth() - 1, this.getHeight() - 1); this.border.drawRect(g, 0, 0, this.getWidth() - 1, this.getHeight() - 1);
} }
if(this.chartImage != null) { if(this.chartImage != null) {
final int x1 = plotter.getX(); final int x1 = plotter.getX();
final int x2 = plotter.getX() + plotter.getVisibleWidth(); final int x2 = plotter.getX() + plotter.getVisibleWidth();
final int y1 = plotter.getY() - plotter.getDepth(); final int y1 = plotter.getY() - plotter.getDepth();
final int y2 = plotter.getY() - plotter.getDepth() + plotter.getVisibleHeight(); final int y2 = plotter.getY() - plotter.getDepth() + plotter.getVisibleHeight();
g.drawImage(this.chartImage, x1, y1, x2, y2, x1 + this.offsetX, y1 + this.offsetY, x2 + g.drawImage(this.chartImage, x1, y1, x2, y2, x1 + this.offsetX, y1 + this.offsetY, x2 +
...@@ -681,9 +674,6 @@ public final class SpiderChart { ...@@ -681,9 +674,6 @@ public final class SpiderChart {
this.floatingObjects.clear(); this.floatingObjects.clear();
plotter = p; plotter = p;
this.title = t; this.title = t;
if(this.title == null) {
this.title = new SpiderChartTitle("");
}
} }
/** Resizes the chart */ /** Resizes the chart */
......
...@@ -23,7 +23,7 @@ import static org.fortiss.tooling.spiderchart.style.FillStyle.GRADIENT_VERTICAL; ...@@ -23,7 +23,7 @@ import static org.fortiss.tooling.spiderchart.style.FillStyle.GRADIENT_VERTICAL;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.fortiss.tooling.spiderchart.SpiderChart; import org.fortiss.tooling.spiderchart.SpiderChartOld;
import org.fortiss.tooling.spiderchart.plotter.SpiderChartLegend; import org.fortiss.tooling.spiderchart.plotter.SpiderChartLegend;
import org.fortiss.tooling.spiderchart.plotter.SpiderChartPlotter; import org.fortiss.tooling.spiderchart.plotter.SpiderChartPlotter;
import org.fortiss.tooling.spiderchart.plotter.SpiderChartTitle; import org.fortiss.tooling.spiderchart.plotter.SpiderChartTitle;
...@@ -62,7 +62,7 @@ public final class SpiderChartBuilder { ...@@ -62,7 +62,7 @@ public final class SpiderChartBuilder {
public SpiderChartViewer createViewer(Composite parent) { public SpiderChartViewer createViewer(Composite parent) {
requireNonNull(parent); requireNonNull(parent);
// Some chart related default configurations // Some chart related default configurations
SpiderChart chart = new SpiderChart(title, plotter); SpiderChartOld chart = new SpiderChartOld(title, plotter);
chart.setBackStyle(new FillStyle(SWT.COLOR_YELLOW)); chart.setBackStyle(new FillStyle(SWT.COLOR_YELLOW));
chart.setBackgroundCanvasColor(SWT.COLOR_WHITE); chart.setBackgroundCanvasColor(SWT.COLOR_WHITE);
chart.getBackStyle().setGradientType(GRADIENT_VERTICAL); chart.getBackStyle().setGradientType(GRADIENT_VERTICAL);
......
...@@ -17,6 +17,8 @@ $Id$ ...@@ -17,6 +17,8 @@ $Id$
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.tooling.spiderchart.example; package org.fortiss.tooling.spiderchart.example;
import static org.fortiss.tooling.spiderchart.style.LineStyle.SOLID_BLACK_1PT;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
...@@ -72,18 +74,23 @@ public final class Sample { ...@@ -72,18 +74,23 @@ public final class Sample {
iPhoneData.setPoint(screen, 3.8); iPhoneData.setPoint(screen, 3.8);
spiderChart.addData(iPhoneData); spiderChart.addData(iPhoneData);
SpiderChartTitle title = new SpiderChartTitle("Smartphone Comparison Scale"); SpiderChartTitle title = new SpiderChartTitle("Smartphone Comparison Scale", spiderChart);
title.setSwtForegroundColor(SWT.COLOR_DARK_BLUE); title.setSwtForegroundColor(SWT.COLOR_DARK_BLUE);
SpiderChartLegend legend = new SpiderChartLegend(); SpiderChartLegend legend = new SpiderChartLegend(spiderChart);
legend.addItem(iPhoneData, SWT.COLOR_GREEN); legend.addItem(iPhoneData, SWT.COLOR_GREEN);
legend.setOffset(320); legend.setOffset(320);
legend.setVerticalLayout(true); legend.setVerticalLayout(true);
legend.setSwtBackgroundColor(SWT.COLOR_WHITE); legend.setSwtBackgroundColor(SWT.COLOR_WHITE);
legend.setSwtForegroundColor(SWT.COLOR_BLUE); legend.setSwtForegroundColor(SWT.COLOR_BLUE);
SpiderChartPlotter plotter = new SpiderChartPlotter(); SpiderChartPlotter plotter = new SpiderChartPlotter(spiderChart);
plotter.use(spiderChart); plotter.setAxisStyle(battery, SOLID_BLACK_1PT);
plotter.setAxisStyle(camera, SOLID_BLACK_1PT);
plotter.setAxisStyle(display, SOLID_BLACK_1PT);
plotter.setAxisStyle(memory, SOLID_BLACK_1PT);
plotter.setAxisStyle(brand, SOLID_BLACK_1PT);
plotter.setAxisStyle(screen, SOLID_BLACK_1PT);
SpiderChartBuilder scBuilder = new SpiderChartBuilder(title, legend, plotter); SpiderChartBuilder scBuilder = new SpiderChartBuilder(title, legend, plotter);
viewer = scBuilder.createViewer(shell); viewer = scBuilder.createViewer(shell);
......
...@@ -17,7 +17,6 @@ $Id$ ...@@ -17,7 +17,6 @@ $Id$
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.tooling.spiderchart.label; package org.fortiss.tooling.spiderchart.label;
import org.fortiss.tooling.spiderchart.SpiderChart;
import org.fortiss.tooling.spiderchart.gc.Polygon; import org.fortiss.tooling.spiderchart.gc.Polygon;
import org.fortiss.tooling.spiderchart.gc.swt.SpiderChartSwtGraphics; import org.fortiss.tooling.spiderchart.gc.swt.SpiderChartSwtGraphics;
import org.fortiss.tooling.spiderchart.label.api.IFloatingObject; import org.fortiss.tooling.spiderchart.label.api.IFloatingObject;
...@@ -63,9 +62,6 @@ public final class SpiderChartLabel implements IFloatingObject { ...@@ -63,9 +62,6 @@ public final class SpiderChartLabel implements IFloatingObject {
/** */ /** */
private int borderShape = BORDER_RECT; private int borderShape = BORDER_RECT;
/** */
private SpiderChart chart = null;
/** */ /** */
private Polygon clickableArea = null; private Polygon clickableArea = null;
...@@ -149,11 +145,6 @@ public final class SpiderChartLabel implements IFloatingObject { ...@@ -149,11 +145,6 @@ public final class SpiderChartLabel implements IFloatingObject {
return this.borderShape; return this.borderShape;
} }
/** */
public SpiderChart getChart() {
return this.chart;
}
/** */ /** */
public Polygon getClickableArea() { public Polygon getClickableArea() {
return this.clickableArea; return this.clickableArea;
...@@ -237,13 +228,6 @@ public final class SpiderChartLabel implements IFloatingObject { ...@@ -237,13 +228,6 @@ public final class SpiderChartLabel implements IFloatingObject {
return this.positionY; return this.positionY;
} }
/**
* @param g
*/
public void initialize(SpiderChartSwtGraphics g, SpiderChart c) {
this.chart = c;
}
/** */ /** */
public boolean isIgnorePosition() { public boolean isIgnorePosition() {
return this.ignorePosition; return this.ignorePosition;
...@@ -256,10 +240,6 @@ public final class SpiderChartLabel implements IFloatingObject { ...@@ -256,10 +240,6 @@ public final class SpiderChartLabel implements IFloatingObject {
* @param height * @param height
*/ */
public void paint(SpiderChartSwtGraphics g, int x, int y, int width, int height) { public void paint(SpiderChartSwtGraphics g, int x, int y, int width, int height) {
if(this.chart != null) {
this.chart.placeFloatingObject(this);
this.chart.addFloationgObject(this);
}
this.render(g); this.render(g);
} }
...@@ -367,11 +347,6 @@ public final class SpiderChartLabel implements IFloatingObject { ...@@ -367,11 +347,6 @@ public final class SpiderChartLabel implements IFloatingObject {
this.borderShape = borderShape; this.borderShape = borderShape;
} }
/** */
public void setChart(final SpiderChart chart) {
this.chart = chart;
}
/** */ /** */
public void setClickableArea(final Polygon clickableArea) { public void setClickableArea(final Polygon clickableArea) {
this.clickableArea = clickableArea; this.clickableArea = clickableArea;
......
...@@ -17,7 +17,7 @@ $Id$ ...@@ -17,7 +17,7 @@ $Id$
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.tooling.spiderchart.listener; package org.fortiss.tooling.spiderchart.listener;
import org.fortiss.tooling.spiderchart.SpiderChart; import org.fortiss.tooling.spiderchart.SpiderChartOld;
import org.fortiss.tooling.spiderchart.gc.swt.SpiderChartSwtGraphics; import org.fortiss.tooling.spiderchart.gc.swt.SpiderChartSwtGraphics;
/** /**
...@@ -46,9 +46,9 @@ public interface ISpiderChartListener { ...@@ -46,9 +46,9 @@ public interface ISpiderChartListener {
public static final int EVENT_TIP_UPDATE = 4; public static final int EVENT_TIP_UPDATE = 4;
/** */ /** */
public abstract void onChartEvent(SpiderChart paramChart, int paramInt); public abstract void onChartEvent(SpiderChartOld paramChart, int paramInt);
/** */ /** */
public abstract void onPaintUserExit(SpiderChart paramChart, public abstract void onPaintUserExit(SpiderChartOld paramChart,
SpiderChartSwtGraphics paramChartGraphics); SpiderChartSwtGraphics paramChartGraphics);
} }
...@@ -17,7 +17,7 @@ $Id$ ...@@ -17,7 +17,7 @@ $Id$
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.tooling.spiderchart.listener; package org.fortiss.tooling.spiderchart.listener;
import org.fortiss.tooling.spiderchart.SpiderChart; import org.fortiss.tooling.spiderchart.SpiderChartOld;
import org.fortiss.tooling.spiderchart.gc.swt.SpiderChartSwtGraphics; import org.fortiss.tooling.spiderchart.gc.swt.SpiderChartSwtGraphics;
/** /**
...@@ -32,13 +32,13 @@ public class SpiderChartAdapter implements ISpiderChartListener { ...@@ -32,13 +32,13 @@ public class SpiderChartAdapter implements ISpiderChartListener {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void onChartEvent(SpiderChart c, int type) { public void onChartEvent(SpiderChartOld c, int type) {
// //
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void onPaintUserExit(SpiderChart c, SpiderChartSwtGraphics g) { public void onPaintUserExit(SpiderChartOld c, SpiderChartSwtGraphics g) {
// //
} }
} }
...@@ -17,6 +17,8 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ ...@@ -17,6 +17,8 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.tooling.spiderchart.model; package org.fortiss.tooling.spiderchart.model;
import static org.conqat.lib.commons.collections.CollectionUtils.asUnmodifiable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -32,27 +34,47 @@ public final class SpiderChart { ...@@ -32,27 +34,47 @@ public final class SpiderChart {
/** The axes contained in this chart. */ /** The axes contained in this chart. */
private List<Axis> axes = new ArrayList<Axis>(); private List<Axis> axes = new ArrayList<Axis>();
/** The data sets contained in this chart. */ /** The data sets contained in this chart. */
private List<DataSeries> data = new ArrayList<DataSeries>(); private List<DataSeries> dataSeries = new ArrayList<DataSeries>();
/** Adds the given data series. */
public void addData(DataSeries d) { public void addData(DataSeries d) {
data.add(d); dataSeries.add(d);
} }
/** Adds the given axis. */
public void addAxis(Axis a) { public void addAxis(Axis a) {
axes.add(a); axes.add(a);
} }
/**
* Validates the chart by checking if all data series provide a non-null value for each axis and
* that this value is within the axis minimum an maximum values..
*/
public boolean checkDataValidity() { public boolean checkDataValidity() {
for(DataSeries d : data) { for(DataSeries d : dataSeries) {
for(Axis a : axes) { for(Axis a : axes) {
if(d.getAxisValue(a) == null) { if(d.getAxisValue(a) == null) {
return false; return false;
} }
Double v = d.getAxisValue(a);
if(v < a.getMinimumValue() || v > a.getMaximumValue()) {
return false;
}
} }
} }
return true; return true;
} }
/** Returns the unmodifiable list of axes. */
public List<Axis> getAxes() {
return asUnmodifiable(axes);
}
/** Returns the unmodifiable list of data series. */
public List<DataSeries> getDataSeries() {
return asUnmodifiable(dataSeries);
}
/** */ /** */
public double[] maxScales() { public double[] maxScales() {
double[] result = new double[axes.size()]; double[] result = new double[axes.size()];
......
/*--------------------------------------------------------------------------+
$Id$
| |
| Copyright 2016 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.spiderchart.plotter;
import static org.conqat.lib.commons.collections.CollectionUtils.asUnmodifiable;
import java.util.ArrayList;
import java.util.List;
import org.fortiss.tooling.spiderchart.gc.AbstractChartImage;
import org.fortiss.tooling.spiderchart.gc.swt.SpiderChartSwtGraphics;
import org.fortiss.tooling.spiderchart.model.DataSeries;
import org.fortiss.tooling.spiderchart.scale.SpiderChartScale;
import org.fortiss.tooling.spiderchart.sequence.DataSequence;
/**
* Base class used to create spider chart plotters
*
* @author mondal
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 13207B1B51F8F60D2122999D2EDB0603
*/
public abstract class AbstractPlotter extends SpiderChartComponentBase {
/** Spider Chart Background Image */
private AbstractChartImage backgroundImage;
/** depth of the component */
private int depth = 0;
/** The list of data sequences. */
protected List<DataSequence> data = new ArrayList<DataSequence>();
/** visible height on the canvas */
private int visibleHeight = 0;
/** visible width on the canvas */
private int visibleWidth = 0;
/** x-axis scaling */
private SpiderChartScale xScale;
/** y-axis scaling */
private SpiderChartScale yScale;
/** Adds sequence to the plotter */
public void addSeq(DataSeries data) {
replaceSeq(-1, data);
}
/** calculates the max values in the provided scale */
private void calculateMax(final SpiderChartScale s, final double m) {
if(!s.isExactMaxValue()) {
s.setMax(m);
return;
}
final double[] value = s.getPreferred_MaxMin_values();
if(value != null && value.length > 0) {
for(final double preferred_MaxMin_value : value) {
if(preferred_MaxMin_value >= m) {
s.setMax(preferred_MaxMin_value);
break;
}
}
}
}
/** calculates the min values in the provided scale */
private void calculateMin(final SpiderChartScale s, final double m) {
if(!s.isExactMinValue()) {
s.setMin(m);
return;
}
final double[] value = s.getPreferred_MaxMin_values();
if(value != null && value.length > 0) {
for(int j = value.length - 1; j > 0; j--) {
if(value[j] <= m) {
s.setMin(value[j]);
break;
}
}
}
}
/**
* returns the active x scaling
*
* @param s
* the data sequence
*/
protected SpiderChartScale getActiveXScale() {
return xScale;
}
/**
* returns the active y scaling
*
* @param s
* the data sequence
*/
protected SpiderChartScale getActiveYScale() {
return yScale;
}
/**
* @return the backgroundImage
*/
public AbstractChartImage getBackgroundImage() {
return backgroundImage;
}
/**
* @return the depth
*/
public int getDepth() {
return depth;
}
/**
* @return the visibleHeight
*/
public int getVisibleHeight() {
return visibleHeight;
}
/**
* @return the visibleWidth
*/
public int getVisibleWidth() {
return visibleWidth;
}
/**
* @return the xScale
*/
public SpiderChartScale getxScale() {
return xScale;
}
/**
* @return the yScale
*/
public SpiderChartScale getyScale() {
return yScale;
}
/** plots the values */
public void plot(SpiderChartSwtGraphics g) {
for(int i = 0; i < data.size(); i++) {
plotSequence(g, data.get(i), i);
}
}
/**
* plots the values
*
* @param g
* the abstract graphics
* @param s
* the data sequence
* @param serieSec
* the series section
*/
protected abstract void plotSequence(SpiderChartSwtGraphics g, DataSequence s, int serieSec);
/**
* plots the background of the plotting canvas
*/
public void plotBackground(SpiderChartSwtGraphics graphics) {
if(getBackgroundFillStyle() != null) {
getBackgroundFillStyle().draw(graphics, x, y, x + getWidth(), y + getHeight());
}
if(backgroundImage != null) {
final int w = backgroundImage.getWidth();
final int h = backgroundImage.getHeight();
if(w > -1 && h > -1) {
int toCenterX = (getWidth() - w) / 2;
if(toCenterX < 0) {
toCenterX = 0;
}
int toCenterY = (getHeight() - h) / 2;
if(toCenterY < 0) {
toCenterY = 0;
}
graphics.drawImage(backgroundImage, toCenterX + x, y + toCenterY);
}
}
}
/** replaces a sequence with the provided one */
@SuppressWarnings("cast")
public void replaceSeq(int p, DataSeries d) {
final SpiderChartScale tmpScaleX = getActiveXScale();
getActiveYScale();
if(p >= data.size()) {
return;
}
if(data.size() > 3) {
return;
}
// FIXME: TODO: continue HERE
// if(p == -1) {
// data.add(new LineDataSequence(d.get, s));
// } else {
// data.set(p, s);
// }
// final boolean fixedLimits = false;
// final boolean cumulative = false;
// if(!(this instanceof AbstractPlotter)) {
// for(int i = 0; i < s.getSize(); i++) {
// if(s.getElementY(i) != null) {
// final double XValue = ((Double)s.getElementX(i)).doubleValue();
// double YValue = ((Double)s.getElementY(i)).doubleValue();
// if(cumulative) {
// YValue = 0.0D;
// for(int si = 0; si < data.size(); si++) {
// final DataSequence ser = data.get(si);
// }
// }
// if(XValue >= tmpScaleX.getMax()) {
// calculateMax(tmpScaleX, XValue);
// }
// if(XValue < tmpScaleX.getMin()) {
// calculateMin(tmpScaleX, XValue);
// }
// if(!fixedLimits) {
// if(YValue > yScale.getMax()) {
// calculateMax(yScale, YValue);
// }
// if(YValue < yScale.getMin()) {
// calculateMin(yScale, YValue);
// }
// }
// }
// }
// }
}
/**
* @param backgroundImage
* the backgroundImage to set
*/
public void setBackgroundImage(final AbstractChartImage backgroundImage) {
this.backgroundImage = backgroundImage;
}
/**
* @param depth
* the depth to set
*/
public void setDepth(final int depth) {
this.depth = depth;
}
/** */
public void setSeq(final int p, final DataSequence s) {
if(p < data.size()) {
data.set(p, s);
}
}
/**
* @param seq
* the seq to set
*/
public void setSeq(final List<DataSequence> seq) {
this.data = seq;
}
/**
* @param visibleHeight
* the visibleHeight to set
*/
public void setVisibleHeight(final int visibleHeight) {
this.visibleHeight = visibleHeight;
}
/**
* @param visibleWidth
* the visibleWidth to set
*/
public void setVisibleWidth(final int visibleWidth) {
this.visibleWidth = visibleWidth;
}
/**
* @param xScale
* the xScale to set
*/
public void setxScale(final SpiderChartScale xScale) {
this.xScale = xScale;
}
/**
* @param yScale
* the yScale to set
*/
public void setyScale(final SpiderChartScale yScale) {
this.yScale = yScale;
}
/** Disposes the plotter's resources. */
public void dispose() {
for(DataSequence ds : data) {
ds.dispose();
}
}
/** Returns data. */
public List<DataSequence> getData() {
return asUnmodifiable(data);
}
}
...@@ -22,7 +22,7 @@ import org.eclipse.swt.graphics.Color; ...@@ -22,7 +22,7 @@ import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
import org.fortiss.tooling.spiderchart.SpiderChart; import org.fortiss.tooling.spiderchart.model.SpiderChart;
import org.fortiss.tooling.spiderchart.style.FillStyle; import org.fortiss.tooling.spiderchart.style.FillStyle;
import org.fortiss.tooling.spiderchart.style.LineStyle; import org.fortiss.tooling.spiderchart.style.LineStyle;
...@@ -38,7 +38,7 @@ import org.fortiss.tooling.spiderchart.style.LineStyle; ...@@ -38,7 +38,7 @@ import org.fortiss.tooling.spiderchart.style.LineStyle;
public abstract class SpiderChartComponentBase { public abstract class SpiderChartComponentBase {
/** The spider chart this component belongs to. */ /** The spider chart this component belongs to. */
protected SpiderChart chart; protected final SpiderChart chart;
/** The height of the component. */ /** The height of the component. */
protected int height; protected int height;
...@@ -67,6 +67,11 @@ public abstract class SpiderChartComponentBase { ...@@ -67,6 +67,11 @@ public abstract class SpiderChartComponentBase {
/** The font data. */ /** The font data. */
private FontData fontData = new FontData("Verdana", 10, SWT.NORMAL); private FontData fontData = new FontData("Verdana", 10, SWT.NORMAL);
/** Constructor. */
public SpiderChartComponentBase(SpiderChart chart) {
this.chart = chart;
}
/** Sets the background color. */ /** Sets the background color. */
public final void setSwtBackgroundColor(int swtBackgroundColor) { public final void setSwtBackgroundColor(int swtBackgroundColor) {
this.swtBackgroundColor = swtBackgroundColor; this.swtBackgroundColor = swtBackgroundColor;
...@@ -94,12 +99,6 @@ public abstract class SpiderChartComponentBase { ...@@ -94,12 +99,6 @@ public abstract class SpiderChartComponentBase {
fontData.setStyle(swtFontStyle); fontData.setStyle(swtFontStyle);
} }
/** Sets chart. */
@Deprecated
public void setChart(SpiderChart chart) {
this.chart = chart;
}
/** Sets x. */ /** Sets x. */
public void setX(int x) { public void setX(int x) {
this.x = x; this.x = x;
......
...@@ -27,6 +27,7 @@ import org.eclipse.swt.graphics.Font; ...@@ -27,6 +27,7 @@ import org.eclipse.swt.graphics.Font;
import org.fortiss.tooling.spiderchart.gc.swt.SpiderChartSwtGraphics; import org.fortiss.tooling.spiderchart.gc.swt.SpiderChartSwtGraphics;
import org.fortiss.tooling.spiderchart.label.SpiderChartLabel; import org.fortiss.tooling.spiderchart.label.SpiderChartLabel;
import org.fortiss.tooling.spiderchart.model.DataSeries; import org.fortiss.tooling.spiderchart.model.DataSeries;
import org.fortiss.tooling.spiderchart.model.SpiderChart;
import org.fortiss.tooling.spiderchart.style.LineStyle; import org.fortiss.tooling.spiderchart.style.LineStyle;
/** /**
...@@ -39,6 +40,11 @@ import org.fortiss.tooling.spiderchart.style.LineStyle; ...@@ -39,6 +40,11 @@ import org.fortiss.tooling.spiderchart.style.LineStyle;
*/ */
public final class SpiderChartLegend extends SpiderChartComponentBase { public final class SpiderChartLegend extends SpiderChartComponentBase {
/** Constructor. */
public SpiderChartLegend(SpiderChart chart) {
super(chart);
}
/** The items in the legend. */ /** The items in the legend. */
private final List<Pair<DataSeries, LineStyle>> items = new ArrayList<>(); private final List<Pair<DataSeries, LineStyle>> items = new ArrayList<>();
...@@ -63,7 +69,6 @@ public final class SpiderChartLegend extends SpiderChartComponentBase { ...@@ -63,7 +69,6 @@ public final class SpiderChartLegend extends SpiderChartComponentBase {
public void draw(SpiderChartSwtGraphics g) { public void draw(SpiderChartSwtGraphics g) {
if(labelText != null && labelText.length() > 0) { if(labelText != null && labelText.length() > 0) {
SpiderChartLabel cl = new SpiderChartLabel(labelText, "", false, true); SpiderChartLabel cl = new SpiderChartLabel(labelText, "", false, true);
cl.initialize(g, chart);
cl.paint(g, x, y, width, height); cl.paint(g, x, y, width, height);
return; return;
} }
......
...@@ -22,16 +22,24 @@ import static org.fortiss.tooling.spiderchart.gc.Fonts.VERDANA; ...@@ -22,16 +22,24 @@ import static org.fortiss.tooling.spiderchart.gc.Fonts.VERDANA;
import static org.fortiss.tooling.spiderchart.util.ChartUtil.enumConstants; import static org.fortiss.tooling.spiderchart.util.ChartUtil.enumConstants;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
import org.fortiss.tooling.spiderchart.gc.AbstractChartImage;
import org.fortiss.tooling.spiderchart.gc.Polygon; import org.fortiss.tooling.spiderchart.gc.Polygon;
import org.fortiss.tooling.spiderchart.gc.swt.SpiderChartSwtGraphics; import org.fortiss.tooling.spiderchart.gc.swt.SpiderChartSwtGraphics;
import org.fortiss.tooling.spiderchart.model.Axis;
import org.fortiss.tooling.spiderchart.model.DataSeries;
import org.fortiss.tooling.spiderchart.model.SpiderChart; import org.fortiss.tooling.spiderchart.model.SpiderChart;
import org.fortiss.tooling.spiderchart.scale.SpiderChartScale;
import org.fortiss.tooling.spiderchart.sequence.DataSequence; import org.fortiss.tooling.spiderchart.sequence.DataSequence;
import org.fortiss.tooling.spiderchart.sequence.LineDataSequence; import org.fortiss.tooling.spiderchart.sequence.LineDataSequence;
import org.fortiss.tooling.spiderchart.style.FillStyle; import org.fortiss.tooling.spiderchart.style.FillStyle;
...@@ -45,8 +53,125 @@ import org.fortiss.tooling.spiderchart.style.LineStyle; ...@@ -45,8 +53,125 @@ import org.fortiss.tooling.spiderchart.style.LineStyle;
* @version $Rev$ * @version $Rev$
* @ConQAT.Rating GREEN Hash: 13207B1B51F8F60D2122999D2EDB0603 * @ConQAT.Rating GREEN Hash: 13207B1B51F8F60D2122999D2EDB0603
*/ */
public final class SpiderChartPlotter extends AbstractPlotter { public final class SpiderChartPlotter extends SpiderChartComponentBase {
/** The map for style information of axes. */
private Map<Axis, LineStyle> axisStyle = new HashMap<Axis, LineStyle>();
/** The map for style information of data series. */
private Map<DataSeries, LineStyle> dataSeriesStyle = new HashMap<DataSeries, LineStyle>();
/** Spider Chart Background Image */
private AbstractChartImage backgroundImage;
/** The relative chart margin. The default is 10%. */
private double relativeMargin = 0.9;
/** depth of the component */
private int depth = 0;
/** The list of data sequences. */
protected List<DataSequence> data = new ArrayList<DataSequence>();
/** Adds sequence to the plotter */
public void addSeq(DataSeries data) {
replaceSeq(-1, data);
}
/** calculates the max values in the provided scale */
private void calculateMax(final SpiderChartScale s, final double m) {
if(!s.isExactMaxValue()) {
s.setMax(m);
return;
}
final double[] value = s.getPreferred_MaxMin_values();
if(value != null && value.length > 0) {
for(final double preferred_MaxMin_value : value) {
if(preferred_MaxMin_value >= m) {
s.setMax(preferred_MaxMin_value);
break;
}
}
}
}
/** calculates the min values in the provided scale */
private void calculateMin(final SpiderChartScale s, final double m) {
if(!s.isExactMinValue()) {
s.setMin(m);
return;
}
final double[] value = s.getPreferred_MaxMin_values();
if(value != null && value.length > 0) {
for(int j = value.length - 1; j > 0; j--) {
if(value[j] <= m) {
s.setMin(value[j]);
break;
}
}
}
}
/** replaces a sequence with the provided one */
@SuppressWarnings("cast")
public void replaceSeq(int p, DataSeries d) {
SpiderChartScale tmpScaleX = xScale;
// FIXME: ???
// getActiveYScale();
if(p >= data.size()) {
return;
}
if(data.size() > 3) {
return;
}
// FIXME: below
// if(p == -1) {
// data.add(new LineDataSequence(d.get, s));
// } else {
// data.set(p, s);
// }
// final boolean fixedLimits = false;
// final boolean cumulative = false;
// if(!(this instanceof SpiderChartPlotter)) {
// for(int i = 0; i < s.getSize(); i++) {
// if(s.getElementY(i) != null) {
// final double XValue = ((Double)s.getElementX(i)).doubleValue();
// double YValue = ((Double)s.getElementY(i)).doubleValue();
// if(cumulative) {
// YValue = 0.0D;
// for(int si = 0; si < data.size(); si++) {
// final DataSequence ser = data.get(si);
// }
// }
// if(XValue >= tmpScaleX.getMax()) {
// calculateMax(tmpScaleX, XValue);
// }
// if(XValue < tmpScaleX.getMin()) {
// calculateMin(tmpScaleX, XValue);
// }
// if(!fixedLimits) {
// if(YValue > yScale.getMax()) {
// calculateMax(yScale, YValue);
// }
// if(YValue < yScale.getMin()) {
// calculateMin(yScale, YValue);
// }
// }
// }
// }
// }
}
/** visible height on the canvas */
private int visibleHeight = 0;
/** visible width on the canvas */
private int visibleWidth = 0;
/** x-axis scaling */
private SpiderChartScale xScale;
/** y-axis scaling */
private SpiderChartScale yScale;
/** /**
* axes names * axes names
*/ */
...@@ -132,6 +257,11 @@ public final class SpiderChartPlotter extends AbstractPlotter { ...@@ -132,6 +257,11 @@ public final class SpiderChartPlotter extends AbstractPlotter {
*/ */
private Object[] scalingLabelFormat; private Object[] scalingLabelFormat;
/** Constructor. */
public SpiderChartPlotter(SpiderChart chart) {
super(chart);
}
/** /**
* @return the axesFactors * @return the axesFactors
*/ */
...@@ -237,9 +367,7 @@ public final class SpiderChartPlotter extends AbstractPlotter { ...@@ -237,9 +367,7 @@ public final class SpiderChartPlotter extends AbstractPlotter {
return markScalesOnEveryAxis; return markScalesOnEveryAxis;
} }
/** {@inheritDoc} **/
@SuppressWarnings({"unchecked", "rawtypes"}) @SuppressWarnings({"unchecked", "rawtypes"})
@Override
protected void plotSequence(SpiderChartSwtGraphics graphics, DataSequence seq, protected void plotSequence(SpiderChartSwtGraphics graphics, DataSequence seq,
int sequenceNumber) { int sequenceNumber) {
if(!(seq instanceof LineDataSequence)) { if(!(seq instanceof LineDataSequence)) {
...@@ -679,4 +807,106 @@ public final class SpiderChartPlotter extends AbstractPlotter { ...@@ -679,4 +807,106 @@ public final class SpiderChartPlotter extends AbstractPlotter {
private Color systemColor(int swtColor) { private Color systemColor(int swtColor) {
return Display.getCurrent().getSystemColor(swtColor); return Display.getCurrent().getSystemColor(swtColor);
} }
/** Disposes the plotter's resources. */
public void dispose() {
for(DataSequence ds : data) {
ds.dispose();
}
}
/** plots the values */
public void plot(SpiderChartSwtGraphics g) {
for(int i = 0; i < data.size(); i++) {
plotSequence(g, data.get(i), i);
}
}
/**
* plots the background of the plotting canvas
*/
public void plotBackground(SpiderChartSwtGraphics graphics) {
if(getBackgroundFillStyle() != null) {
getBackgroundFillStyle().draw(graphics, x, y, x + getWidth(), y + getHeight());
}
if(backgroundImage != null) {
final int w = backgroundImage.getWidth();
final int h = backgroundImage.getHeight();
if(w > -1 && h > -1) {
int toCenterX = (getWidth() - w) / 2;
if(toCenterX < 0) {
toCenterX = 0;
}
int toCenterY = (getHeight() - h) / 2;
if(toCenterY < 0) {
toCenterY = 0;
}
graphics.drawImage(backgroundImage, toCenterX + x, y + toCenterY);
}
}
}
/** Returns depth. */
public int getDepth() {
return depth;
}
/** Returns visible width. */
public int getVisibleWidth() {
return visibleWidth;
}
/** Sets visible width. */
public void setVisibleWidth(int visibleWidth) {
this.visibleWidth = visibleWidth;
}
/** Returns visible height. */
public int getVisibleHeight() {
return visibleHeight;
}
/** Sets visible height. */
public void setVisibleHeight(int visibleHeight) {
this.visibleHeight = visibleHeight;
}
/** Plots the axes of the spider chart. */
public void plotAxes(SpiderChartSwtGraphics graphics) {
List<Axis> axes = chart.getAxes();
int size = axes.size();
double segmentDegree = 360.0 / size;
double angleDegree = 90.0;
int halfWidth = getWidth() / 2;
int halfHeight = getHeight() / 2;
int centerX = getX() + halfWidth;
int centerY = getY() + halfHeight;
int wExtent = (int)(relativeMargin * halfWidth);
int hExtent = (int)(relativeMargin * halfHeight);
int extent = Math.min(wExtent, hExtent);
for(int i = 0; i < size; i++) {
Axis axis = axes.get(i);
double angleRad = Math.PI * angleDegree / 180.0;
int outerX = centerX + (int)(Math.cos(angleRad) * extent);
int outerY = centerY + (int)(Math.sin(angleRad) * extent);
LineStyle style = axisStyle.get(axis);
style.draw(graphics, centerX, centerY, outerX, outerY);
angleDegree = (angleDegree + segmentDegree) % 360.0;
}
}
/** Sets the style for the given axis. */
public void setAxisStyle(Axis axis, LineStyle style) {
axisStyle.put(axis, style);
}
/** Sets the style for the given data series. */
public void setDataSeriesStyle(DataSeries dataSeries, LineStyle style) {
dataSeriesStyle.put(dataSeries, style);
}
} }
...@@ -17,9 +17,12 @@ $Id$ ...@@ -17,9 +17,12 @@ $Id$
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.tooling.spiderchart.plotter; package org.fortiss.tooling.spiderchart.plotter;
import static java.util.Objects.requireNonNull;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Font;
import org.fortiss.tooling.spiderchart.gc.swt.SpiderChartSwtGraphics; import org.fortiss.tooling.spiderchart.gc.swt.SpiderChartSwtGraphics;
import org.fortiss.tooling.spiderchart.model.SpiderChart;
/** /**
* Class representing the spider charts title. * Class representing the spider charts title.
...@@ -36,8 +39,9 @@ public final class SpiderChartTitle extends SpiderChartComponentBase { ...@@ -36,8 +39,9 @@ public final class SpiderChartTitle extends SpiderChartComponentBase {
private String text; private String text;
/** Constructor */ /** Constructor */
public SpiderChartTitle(String text) { public SpiderChartTitle(String text, SpiderChart chart) {
this.text = text; super(chart);
this.text = requireNonNull(text);
setSwtForegroundColor(SWT.COLOR_BLACK); setSwtForegroundColor(SWT.COLOR_BLACK);
setFontName("Verdana", 14, SWT.NORMAL); setFontName("Verdana", 14, SWT.NORMAL);
} }
......
...@@ -25,7 +25,7 @@ import java.util.ArrayList; ...@@ -25,7 +25,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import org.fortiss.tooling.spiderchart.SpiderChart; import org.fortiss.tooling.spiderchart.SpiderChartOld;
/** /**
* Class representing sequence of points to be used for plotting * Class representing sequence of points to be used for plotting
...@@ -127,11 +127,11 @@ public abstract class DataSequence { ...@@ -127,11 +127,11 @@ public abstract class DataSequence {
return d.toString(); return d.toString();
} }
DecimalFormat df = null; DecimalFormat df = null;
if(SpiderChart.getNumberLocale() == null) { if(SpiderChartOld.getNumberLocale() == null) {
df = new DecimalFormat(this.valueFormat); df = new DecimalFormat(this.valueFormat);
} else { } else {
final NumberFormat nf = final NumberFormat nf =
getNumberInstance(new Locale(SpiderChart.getNumberLocale(), "")); getNumberInstance(new Locale(SpiderChartOld.getNumberLocale(), ""));
df = (DecimalFormat)nf; df = (DecimalFormat)nf;
df.applyPattern(this.valueFormat); df.applyPattern(this.valueFormat);
......
...@@ -17,6 +17,7 @@ $Id$ ...@@ -17,6 +17,7 @@ $Id$
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.tooling.spiderchart.style; package org.fortiss.tooling.spiderchart.style;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
import org.fortiss.tooling.spiderchart.gc.swt.SpiderChartSwtGraphics; import org.fortiss.tooling.spiderchart.gc.swt.SpiderChartSwtGraphics;
...@@ -38,6 +39,9 @@ public final class LineStyle { ...@@ -38,6 +39,9 @@ public final class LineStyle {
/** */ /** */
public static final int NORMAL_LINE = 1; public static final int NORMAL_LINE = 1;
/** Solid, black line with width of one point. */
public static final LineStyle SOLID_BLACK_1PT = new LineStyle(1, SWT.COLOR_BLACK, NORMAL_LINE);
/** Factory method to create line */ /** Factory method to create line */
public static LineStyle of(float w, int swtColor, int t) { public static LineStyle of(float w, int swtColor, int t) {
return new LineStyle(w, swtColor, t); return new LineStyle(w, swtColor, t);
......
...@@ -29,7 +29,7 @@ import org.eclipse.swt.events.MouseMoveListener; ...@@ -29,7 +29,7 @@ import org.eclipse.swt.events.MouseMoveListener;
import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.fortiss.tooling.spiderchart.SpiderChart; import org.fortiss.tooling.spiderchart.SpiderChartOld;
import org.fortiss.tooling.spiderchart.gc.swt.SpiderChartSwtGraphics; import org.fortiss.tooling.spiderchart.gc.swt.SpiderChartSwtGraphics;
import org.fortiss.tooling.spiderchart.listener.ISpiderChartListener; import org.fortiss.tooling.spiderchart.listener.ISpiderChartListener;
...@@ -44,7 +44,7 @@ import org.fortiss.tooling.spiderchart.listener.ISpiderChartListener; ...@@ -44,7 +44,7 @@ import org.fortiss.tooling.spiderchart.listener.ISpiderChartListener;
public final class SpiderChartCanvas extends Canvas implements ISpiderChartListener { public final class SpiderChartCanvas extends Canvas implements ISpiderChartListener {
/** Actual Spider Chart Ref */ /** Actual Spider Chart Ref */
private SpiderChart chart = null; private SpiderChartOld chart = null;
/** Constructor */ /** Constructor */
public SpiderChartCanvas(final Composite parent, final int style) { public SpiderChartCanvas(final Composite parent, final int style) {
...@@ -79,7 +79,7 @@ public final class SpiderChartCanvas extends Canvas implements ISpiderChartListe ...@@ -79,7 +79,7 @@ public final class SpiderChartCanvas extends Canvas implements ISpiderChartListe
} }
/** Returns the spider chart */ /** Returns the spider chart */
public SpiderChart getChart() { public SpiderChartOld getChart() {
return this.chart; return this.chart;
} }
...@@ -99,7 +99,7 @@ public final class SpiderChartCanvas extends Canvas implements ISpiderChartListe ...@@ -99,7 +99,7 @@ public final class SpiderChartCanvas extends Canvas implements ISpiderChartListe
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void onChartEvent(final SpiderChart c, final int type) { public void onChartEvent(final SpiderChartOld c, final int type) {
if(type == 4) { if(type == 4) {
this.redraw(); this.redraw();
} }
...@@ -114,7 +114,7 @@ public final class SpiderChartCanvas extends Canvas implements ISpiderChartListe ...@@ -114,7 +114,7 @@ public final class SpiderChartCanvas extends Canvas implements ISpiderChartListe
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void onPaintUserExit(SpiderChart c, SpiderChartSwtGraphics g) { public void onPaintUserExit(SpiderChartOld c, SpiderChartSwtGraphics g) {
// Not used // Not used
} }
...@@ -137,7 +137,7 @@ public final class SpiderChartCanvas extends Canvas implements ISpiderChartListe ...@@ -137,7 +137,7 @@ public final class SpiderChartCanvas extends Canvas implements ISpiderChartListe
} }
/** Setter for Spider Chart */ /** Setter for Spider Chart */
public void setChart(final SpiderChart c) { public void setChart(final SpiderChartOld c) {
if(this.chart != null) { if(this.chart != null) {
this.chart.removeChartListener(this); this.chart.removeChartListener(this);
} }
......
...@@ -25,7 +25,7 @@ import org.eclipse.swt.events.ControlEvent; ...@@ -25,7 +25,7 @@ import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener; import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.graphics.Cursor; import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.fortiss.tooling.spiderchart.SpiderChart; import org.fortiss.tooling.spiderchart.SpiderChartOld;
import org.fortiss.tooling.spiderchart.listener.SpiderChartAdapter; import org.fortiss.tooling.spiderchart.listener.SpiderChartAdapter;
/** /**
...@@ -48,7 +48,7 @@ public final class SpiderChartViewer extends Composite { ...@@ -48,7 +48,7 @@ public final class SpiderChartViewer extends Composite {
private final SpiderChartAdapter chartAdapter = new SpiderChartAdapter() { private final SpiderChartAdapter chartAdapter = new SpiderChartAdapter() {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void onChartEvent(final SpiderChart c, final int type) { public void onChartEvent(final SpiderChartOld c, final int type) {
if(type == 2) { if(type == 2) {
SpiderChartViewer.this.canvas.setCursor(SpiderChartViewer.this.pointCursor); SpiderChartViewer.this.canvas.setCursor(SpiderChartViewer.this.pointCursor);
} }
...@@ -124,7 +124,7 @@ public final class SpiderChartViewer extends Composite { ...@@ -124,7 +124,7 @@ public final class SpiderChartViewer extends Composite {
} }
/** getter for the chart in use */ /** getter for the chart in use */
public SpiderChart getChart() { public SpiderChartOld getChart() {
return this.canvas.getChart(); return this.canvas.getChart();
} }
...@@ -197,7 +197,7 @@ public final class SpiderChartViewer extends Composite { ...@@ -197,7 +197,7 @@ public final class SpiderChartViewer extends Composite {
} }
/** setter for chart instance */ /** setter for chart instance */
public void setChart(final SpiderChart c) { public void setChart(final SpiderChartOld c) {
if(this.canvas.getChart() != null) { if(this.canvas.getChart() != null) {
this.canvas.getChart().removeChartListener(this.chartAdapter); this.canvas.getChart().removeChartListener(this.chartAdapter);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment