From 631174da10898e119ef98c374e11a36542d35f6c Mon Sep 17 00:00:00 2001 From: Johannes Eder <eder@fortiss.org> Date: Fri, 4 Mar 2016 15:00:01 +0000 Subject: [PATCH] --- .../tooling/spiderchart/SpiderChart.java | 1109 ----------------- .../spiderchart/SpiderChartComponent.java | 31 - .../api/annotations/DataPoints.java | 34 - .../api/annotations/SpiderChartPlot.java | 49 - .../api/annotations/package-info.java | 16 - .../SpiderChartAnnotationProcessor.java | 124 -- .../annotations/processor/package-info.java | 16 - .../spiderchart/builder/AxesConfigurer.java | 134 -- .../spiderchart/builder/AxisDataBuilder.java | 67 - .../builder/SpiderChartBuilder.java | 103 -- .../SpiderChartConfigurationBuilder.java | 95 -- .../spiderchart/builder/model/AxisData.java | 47 - .../builder/model/package-info.java | 16 - .../spiderchart/builder/package-info.java | 16 - .../tooling/spiderchart/example/IPhone.java | 32 - .../tooling/spiderchart/example/Nexus.java | 32 - .../tooling/spiderchart/example/Sample.java | 124 -- .../spiderchart/example/package-info.java | 16 - .../spiderchart/gc/AbstractChartColor.java | 131 -- .../spiderchart/gc/AbstractChartFont.java | 25 - .../spiderchart/gc/AbstractChartGraphics.java | 293 ----- .../spiderchart/gc/AbstractChartImage.java | 39 - .../gc/AbstractGraphicsSupplier.java | 90 -- .../fortiss/tooling/spiderchart/gc/Fonts.java | 39 - .../fortiss/tooling/spiderchart/gc/Point.java | 38 - .../tooling/spiderchart/gc/Polygon.java | 65 - .../tooling/spiderchart/gc/package-info.java | 16 - .../gc/swt/SpiderChartSwtColor.java | 303 ----- .../gc/swt/SpiderChartSwtFont.java | 69 - .../gc/swt/SpiderChartSwtGraphics.java | 572 --------- .../gc/swt/SpiderChartSwtImage.java | 146 --- .../gc/swt/SwtGraphicsProvider.java | 42 - .../spiderchart/gc/swt/package-info.java | 16 - .../spiderchart/label/SpiderChartLabel.java | 407 ------ .../label/api/IFloatingObject.java | 39 - .../spiderchart/label/api/package-info.java | 16 - .../spiderchart/label/package-info.java | 16 - .../spiderchart/legend/SpiderChartLegend.java | 378 ------ .../spiderchart/legend/package-info.java | 16 - .../listener/ISpiderChartListener.java | 44 - .../listener/SpiderChartAdapter.java | 33 - .../spiderchart/listener/package-info.java | 16 - .../tooling/spiderchart/package-info.java | 16 - .../spiderchart/plotter/AbstractPlotter.java | 335 ----- .../spiderchart/plotter/package-info.java | 16 - .../plotter/spider/SpiderChartPlotter.java | 715 ----------- .../plotter/spider/package-info.java | 16 - .../spiderchart/scale/SpiderChartScale.java | 169 --- .../spiderchart/scale/package-info.java | 16 - .../tooling/spiderchart/sequence/DataSeq.java | 205 --- .../spiderchart/sequence/LineDataSeq.java | 243 ---- .../spiderchart/sequence/package-info.java | 16 - .../tooling/spiderchart/style/FillStyle.java | 194 --- .../tooling/spiderchart/style/LineStyle.java | 225 ---- .../spiderchart/style/package-info.java | 16 - .../spiderchart/swt/SpiderChartCanvas.java | 138 -- .../spiderchart/swt/SpiderChartViewer.java | 568 --------- .../tooling/spiderchart/swt/package-info.java | 16 - .../spiderchart/title/SpiderChartTitle.java | 88 -- .../spiderchart/title/package-info.java | 16 - .../tooling/spiderchart/util/ChartUtil.java | 68 - .../spiderchart/util/package-info.java | 16 - 62 files changed, 8002 deletions(-) delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/SpiderChart.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/SpiderChartComponent.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/api/annotations/DataPoints.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/api/annotations/SpiderChartPlot.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/api/annotations/package-info.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/api/annotations/processor/SpiderChartAnnotationProcessor.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/api/annotations/processor/package-info.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/builder/AxesConfigurer.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/builder/AxisDataBuilder.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/builder/SpiderChartBuilder.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/builder/SpiderChartConfigurationBuilder.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/builder/model/AxisData.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/builder/model/package-info.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/builder/package-info.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/example/IPhone.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/example/Nexus.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/example/Sample.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/example/package-info.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/AbstractChartColor.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/AbstractChartFont.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/AbstractChartGraphics.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/AbstractChartImage.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/AbstractGraphicsSupplier.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/Fonts.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/Point.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/Polygon.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/package-info.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/swt/SpiderChartSwtColor.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/swt/SpiderChartSwtFont.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/swt/SpiderChartSwtGraphics.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/swt/SpiderChartSwtImage.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/swt/SwtGraphicsProvider.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/swt/package-info.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/label/SpiderChartLabel.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/label/api/IFloatingObject.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/label/api/package-info.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/label/package-info.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/legend/SpiderChartLegend.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/legend/package-info.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/listener/ISpiderChartListener.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/listener/SpiderChartAdapter.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/listener/package-info.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/package-info.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/plotter/AbstractPlotter.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/plotter/package-info.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/plotter/spider/SpiderChartPlotter.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/plotter/spider/package-info.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/scale/SpiderChartScale.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/scale/package-info.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/sequence/DataSeq.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/sequence/LineDataSeq.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/sequence/package-info.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/style/FillStyle.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/style/LineStyle.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/style/package-info.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/swt/SpiderChartCanvas.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/swt/SpiderChartViewer.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/swt/package-info.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/title/SpiderChartTitle.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/title/package-info.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/util/ChartUtil.java delete mode 100644 org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/util/package-info.java diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/SpiderChart.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/SpiderChart.java deleted file mode 100644 index f4389cdae..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/SpiderChart.java +++ /dev/null @@ -1,1109 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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; - -import static org.fortiss.tooling.spiderchart.gc.AbstractChartColor.AQUA; -import static org.fortiss.tooling.spiderchart.gc.AbstractChartColor.BLACK; -import static org.fortiss.tooling.spiderchart.gc.AbstractChartColor.RED; -import static org.fortiss.tooling.spiderchart.gc.AbstractChartColor.YELLOW; -import static org.fortiss.tooling.spiderchart.gc.AbstractChartFont.PLAIN; -import static org.fortiss.tooling.spiderchart.gc.AbstractGraphicsSupplier.createImage; -import static org.fortiss.tooling.spiderchart.gc.AbstractGraphicsSupplier.getColor; -import static org.fortiss.tooling.spiderchart.gc.AbstractGraphicsSupplier.getFont; -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_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_TIP_UPDATE; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; - -import org.fortiss.tooling.spiderchart.gc.AbstractChartColor; -import org.fortiss.tooling.spiderchart.gc.AbstractChartFont; -import org.fortiss.tooling.spiderchart.gc.AbstractChartGraphics; -import org.fortiss.tooling.spiderchart.gc.AbstractChartImage; -import org.fortiss.tooling.spiderchart.gc.Polygon; -import org.fortiss.tooling.spiderchart.label.SpiderChartLabel; -import org.fortiss.tooling.spiderchart.label.api.IFloatingObject; -import org.fortiss.tooling.spiderchart.legend.SpiderChartLegend; -import org.fortiss.tooling.spiderchart.listener.ISpiderChartListener; -import org.fortiss.tooling.spiderchart.plotter.AbstractPlotter; -import org.fortiss.tooling.spiderchart.plotter.spider.SpiderChartPlotter; -import org.fortiss.tooling.spiderchart.sequence.DataSeq; -import org.fortiss.tooling.spiderchart.sequence.LineDataSeq; -import org.fortiss.tooling.spiderchart.style.FillStyle; -import org.fortiss.tooling.spiderchart.style.LineStyle; -import org.fortiss.tooling.spiderchart.title.SpiderChartTitle; - -/** - * Actual Spider Chart - * - * @author AMIT KUMAR MONDAL - * - */ -public final class SpiderChart { - - /** - * Background Worker Thread to refresh chart - * - * @author AMIT KUMAR MONDAL - * - */ - private final class SpiderChartWorker implements Runnable { - - /** */ - @SuppressWarnings("unused") - private SpiderChart chart = null; - - /** */ - private boolean stop = false; - - /** Constructor */ - private SpiderChartWorker() { - } - - /** {@inheritDoc} */ - @Override - public void run() { - while (!this.stop) { - try { - Thread.sleep(SpiderChart.this.msecs); - } catch (final Exception e) { - e.printStackTrace(); - } - if (this.stop) { - break; - } - } - } - } - - /** */ - private static String numberLocale; - - public static String getNumberLocale() { - return numberLocale; - } - - public static void setNumberLocale(final String numberLocale) { - SpiderChart.numberLocale = numberLocale; - } - - /** */ - private boolean activateSelection = false; - - /** Used to trigger thread automatically to build the Spider Chart */ - private boolean autoRebuild = true; - - /** Auto Sizeable Property */ - private boolean autoResize = true; - - /** */ - private double axisMargin = 0.0625D; - - /** */ - private String backgroundCanvasColor = AQUA; - - /** Spider Chart Back Image */ - private AbstractChartImage backImage; - - /** */ - private FillStyle backStyle = new FillStyle(getColor(AQUA)); - - /** */ - private AbstractChartImage backTmpImage = null; - - /** */ - private LineStyle border = null; - - /** */ - private final double bottomMargin = 0.125D; - - /** Spider Chart Image */ - private AbstractChartImage chartImage = null; - - /** */ - private final List<ISpiderChartListener> chartListeners = new CopyOnWriteArrayList<>(); - - /** */ - private int currentX; - - /** */ - private int currentY; - - /** */ - private int cursorLastX = 0; - - /** */ - private int cursorLastY = 0; - - /** */ - private SpiderChartWorker deamon = null; - - /** */ - private final boolean doubleBuffering = true; - - /** */ - private AbstractChartImage finalImage = null; - - /** */ - private final List<IFloatingObject> floatingObjects = new ArrayList<>(); - - /** */ - private final boolean fullXAxis = false; - - /** */ - private int height = 0; - - /** */ - private int lastHeight = -1; - - /** */ - private int lastWidth = -1; - - /** Chart Left Margin */ - private final double leftMargin = 0.125D; - - /** Spider Chart Legend */ - private SpiderChartLegend legend; - - /** Spider Chart Legend Margin */ - private final double legendMargin = 0.2D; - - /** */ - private int minimumHeight = 0; - - /** */ - private int minimumWidth = 0; - - /** */ - private long msecs = 2000L; - - /** */ - private int offsetX = 0; - - /** */ - private int offsetY = 0; - - /** */ - private int originalVirtualHeight = -1; - - /** */ - private int originalVirtualWidth = -1; - - /** */ - private AbstractPlotter[] plotters = new SpiderChartPlotter[10]; - - /** */ - private int plottersCount = 0; - - /** */ - private boolean repaintAll = true; - - /** */ - private boolean repaintAlways = true; - - /** */ - private final double rightMargin = 0.125D; - - /** */ - private SpiderChartLabel selectedLabel = null; - - /** */ - private DataSeq selectedSeq = null; - - /** */ - private int selectedSeqPoint = -1; - - /** Show Tips on the Spider Chart Points */ - private boolean showTips = false; - - /** */ - private boolean stopped = false; - - /** Spider Chart Tip Background Color */ - private final AbstractChartColor tipColor = getColor(YELLOW); - - /** Spider Chart Tip Font */ - private final AbstractChartFont tipFont = getFont(SERIF, PLAIN, 10); - - /** Spider Chart Tip Font Color */ - private final AbstractChartColor tipFontColor = getColor(BLACK); - - /** Spider Chart Title */ - private SpiderChartTitle title; - - /** */ - private final double topMargin = 0.125D; - - /** */ - private int virtualHeight = 0; - - /** */ - private int virtualWidth = 0; - - /** */ - private int width = 0; - - /** Scrollable Property */ - private boolean withScroll = false; - - /** Constructor */ - public SpiderChart(final SpiderChartTitle t, final SpiderChartPlotter p) { - this.resetChart(t, p); - } - - /** */ - public void addChartListener(final ISpiderChartListener cl) { - this.chartListeners.add(cl); - } - - /** */ - public void addFloationgObject(final IFloatingObject obj) { - this.floatingObjects.add(obj); - } - - /** */ - public void addPlotter(final SpiderChartPlotter p) { - this.plotters[this.plottersCount] = p; - this.plotters[this.plottersCount].setxScale(this.plotters[0] - .getxScale()); - this.plotters[this.plottersCount].setyScale(this.plotters[0] - .getyScale()); - this.plottersCount += 1; - } - - /** */ - public void addSeq(final DataSeq s) { - this.plotters[0].addSeq(s); - } - - /** */ - public void dispose() { - for (int i = 0; i < this.plottersCount; i++) { - if (this.plotters[i] != null) { - for (int j = 0; j < this.plotters[i].getSeqCount(); j++) { - if (this.plotters[i].getSeq(j) instanceof LineDataSeq) { - final LineDataSeq lseq = (LineDataSeq) this.plotters[i] - .getSeq(j); - if (lseq.getIcon() != null) { - lseq.getIcon().dispose(); - } - } - } - } - } - if (this.chartImage != null) { - this.chartImage.dispose(); - } - if (this.finalImage != null) { - this.finalImage.dispose(); - } - if (this.backTmpImage != null) { - this.backTmpImage.dispose(); - } - if (this.backImage != null) { - this.backImage.dispose(); - } - this.stopWorker(); - } - - /** */ - private void drawBackImage(final AbstractChartGraphics g) { - final int imageW = this.backImage.getWidth(); - final int imageH = this.backImage.getHeight(); - if ((imageW == -1) || (imageH == -1)) { - return; - } - for (int j = 0; j <= this.virtualWidth; j += imageW) { - for (int i = 0; i <= this.virtualHeight; i += imageH) { - g.drawImage(this.backImage, j, i); - } - } - } - - public double getAxisMargin() { - return this.axisMargin; - } - - public String getBackgroundCanvasColor() { - return this.backgroundCanvasColor; - } - - public AbstractChartImage getBackImage() { - return this.backImage; - } - - public FillStyle getBackStyle() { - return this.backStyle; - } - - public AbstractChartImage getBackTmpImage() { - return this.backTmpImage; - } - - public LineStyle getBorder() { - return this.border; - } - - public double getBottomMargin() { - return this.bottomMargin; - } - - public AbstractChartImage getChartImage() { - return this.chartImage; - } - - public List<ISpiderChartListener> getChartListeners() { - return this.chartListeners; - } - - public int getCurrentX() { - return this.currentX; - } - - public int getCurrentY() { - return this.currentY; - } - - public int getCursorLastX() { - return this.cursorLastX; - } - - public int getCursorLastY() { - return this.cursorLastY; - } - - public SpiderChartWorker getDeamon() { - return this.deamon; - } - - public AbstractChartImage getFinalImage() { - return this.finalImage; - } - - public List<IFloatingObject> getFloatingObjects() { - return this.floatingObjects; - } - - /** */ - public int getHeight() { - return this.height; - } - - public int getLastHeight() { - return this.lastHeight; - } - - public int getLastWidth() { - return this.lastWidth; - } - - public double getLeftMargin() { - return this.leftMargin; - } - - public SpiderChartLegend getLegend() { - return this.legend; - } - - public double getLegendMargin() { - return this.legendMargin; - } - - public int getMinimumHeight() { - return this.minimumHeight; - } - - public int getMinimumWidth() { - return this.minimumWidth; - } - - public long getMsecs() { - return this.msecs; - } - - public int getOffsetX() { - return this.offsetX; - } - - public int getOffsetY() { - return this.offsetY; - } - - public int getOriginalVirtualHeight() { - return this.originalVirtualHeight; - } - - public int getOriginalVirtualWidth() { - return this.originalVirtualWidth; - } - - public AbstractPlotter[] getPlotters() { - return this.plotters; - } - - public int getPlottersCount() { - return this.plottersCount; - } - - public double getRightMargin() { - return this.rightMargin; - } - - public SpiderChartLabel getSelectedLabel() { - return this.selectedLabel; - } - - public DataSeq getSelectedSeq() { - return this.selectedSeq; - } - - public int getSelectedSeqPoint() { - return this.selectedSeqPoint; - } - - /** */ - public SpiderChartPlotter getSpiderPlotter() { - return (SpiderChartPlotter) this.plotters[0]; - } - - public AbstractChartColor getTipColor() { - return this.tipColor; - } - - public AbstractChartFont getTipFont() { - return this.tipFont; - } - - public AbstractChartColor getTipFontColor() { - return this.tipFontColor; - } - - public SpiderChartTitle getTitle() { - return this.title; - } - - public double getTopMargin() { - return this.topMargin; - } - - public int getVirtualHeight() { - return this.virtualHeight; - } - - public int getVirtualWidth() { - return this.virtualWidth; - } - - /** */ - public int getWidth() { - return this.width; - } - - public boolean isActivateSelection() { - return this.activateSelection; - } - - public boolean isAutoRebuild() { - return this.autoRebuild; - } - - public boolean isAutoResize() { - return this.autoResize; - } - - public boolean isDoubleBuffering() { - return this.doubleBuffering; - } - - public boolean isFullXAxis() { - return this.fullXAxis; - } - - public boolean isRepaintAll() { - return this.repaintAll; - } - - public boolean isRepaintAlways() { - return this.repaintAlways; - } - - public boolean isShowTips() { - return this.showTips; - } - - public boolean isStopped() { - return this.stopped; - } - - public boolean isWithScroll() { - return this.withScroll; - } - - /** */ - public void mouseClick() { - if (((this.selectedSeq != null) && (this.selectedSeqPoint >= 0)) - || (this.selectedLabel != null)) { - this.triggerChartEvent(EVENT_POINT_CLICKED); - return; - } - this.triggerChartEvent(EVENT_CHART_CLICKED); - } - - /** */ - public void mouseMoved(final int eX, final int eY) { - if (this.plotters[0] == null) { - return; - } - - this.currentX = eX; - this.currentY = eY; - - Object previousSelectedObject = this.selectedSeq; - final int previousPoint = this.selectedSeqPoint; - - if ((this.selectedSeq == null) && (this.selectedLabel != null)) { - previousSelectedObject = this.selectedLabel; - } - this.selectedSeq = null; - this.selectedLabel = null; - this.selectedSeqPoint = -1; - if (this.activateSelection) { - for (final AbstractPlotter plotter : this.plotters) { - if (plotter == null) { - break; - } - for (int k = 0; k < plotter.getSeqCount(); k++) { - final DataSeq d = plotter.getSeq(k); - for (int i = 0; i < d.getHotAreas().size(); i++) { - if (((Polygon) d.getHotAreas().get(i)).contains( - this.currentX + this.offsetX, this.currentY - + this.offsetY)) { - boolean triggerEnter = false; - if (previousSelectedObject == null) { - triggerEnter = true; - } else if ((previousSelectedObject != d) - || (previousPoint != i)) { - this.triggerChartEvent(EVENT_LEAVE_POINT); - triggerEnter = true; - } - this.selectedSeq = d; - this.selectedSeqPoint = i; - if (!triggerEnter) { - break; - } - this.triggerChartEvent(EVENT_ENTER_POINT); - break; - } - } - } - } - if ((Math.abs(this.currentX - this.cursorLastX) > 2) - || (Math.abs(this.currentY - this.cursorLastY) > 2)) { - this.cursorLastX = this.currentX; - this.cursorLastY = this.currentY; - this.triggerChartEvent(EVENT_TIP_UPDATE); - } - } - if ((previousSelectedObject != null) && (this.selectedSeq == null) - && (this.selectedLabel == null)) { - this.triggerChartEvent(EVENT_LEAVE_POINT); - } - } - - /** */ - public void paint(final AbstractChartGraphics pg) { - this.floatingObjects.clear(); - - if ((this.plotters[0] == null) || (this.plottersCount <= 0)) { - pg.setColor(getColor(RED)); - pg.drawText("No plotters have been found", 30, 30); - return; - } - AbstractChartGraphics gScroll = pg; - AbstractChartGraphics gBack = pg; - AbstractChartGraphics g = pg; - if ((this.lastWidth != this.width) || (this.lastHeight != this.height)) { - this.repaintAll = true; - this.lastWidth = this.width; - this.lastHeight = this.height; - } - if (this.originalVirtualHeight == -1) { - this.originalVirtualHeight = this.virtualHeight; - } - if (this.originalVirtualWidth == -1) { - this.originalVirtualWidth = this.virtualWidth; - } - if (!this.withScroll) { - this.repaintAlways = true; - } - if (this.repaintAlways) { - this.repaintAll = true; - } - if (this.autoResize) { - if (!this.withScroll) { - this.virtualHeight = this.originalVirtualHeight; - this.virtualWidth = this.originalVirtualWidth; - } - this.resize(); - } - try { - if (this.doubleBuffering - && (this.repaintAll || (this.finalImage == null))) { - if (this.finalImage != null) { - this.finalImage.dispose(); - } - this.finalImage = createImage(this.getWidth(), this.getHeight()); - } - } catch (final Exception e) { - e.printStackTrace(); - } - if (this.finalImage != null) { - g = this.finalImage.getGraphics(); - gScroll = g; - gBack = g; - } - if (this.withScroll) { - if (this.repaintAll || (this.chartImage == null)) { - if (this.chartImage != null) { - this.chartImage.dispose(); - } - this.chartImage = createImage(this.virtualWidth, - this.virtualHeight); - } - gScroll = this.chartImage.getGraphics(); - if (this.repaintAll || (this.backTmpImage == null)) { - if (this.backTmpImage != null) { - this.backTmpImage.dispose(); - } - this.backTmpImage = createImage(this.virtualWidth, - this.virtualHeight); - } - gBack = this.backTmpImage.getGraphics(); - } - if (this.repaintAll) { - if ((this.backStyle != null) - && (this.backgroundCanvasColor != null)) { - this.backStyle.draw(gBack, this.backgroundCanvasColor, 0, 0, - this.virtualWidth, this.virtualHeight); - } - if (this.backImage != null) { - this.drawBackImage(gBack); - } - } - if (this.withScroll - && ((this.backImage != null) || (this.backStyle != null))) { - if (this.repaintAll) { - gScroll.drawImage(this.backTmpImage, 0, 0, this.virtualWidth, - this.virtualHeight, 0, 0, this.virtualWidth, - this.virtualHeight); - } - g.drawImage(this.backTmpImage, 0, 0, this.getWidth(), - this.getHeight(), this.offsetX, this.offsetY, - this.getWidth() + this.offsetX, this.getHeight() - + this.offsetY); - } - if (this.plotters[0].getxScale() != null) { - this.plotters[0].getxScale().setScreenMax( - this.plotters[0].x + this.plotters[0].width); - this.plotters[0] - .getxScale() - .setScreenMaxMargin( - (int) (this.plotters[0].getxScale().getScreenMax() * (1.0D - this.axisMargin))); - if (this.fullXAxis) { - this.plotters[0].getxScale().setScreenMaxMargin( - this.plotters[0].getxScale().getScreenMax()); - } - this.plotters[0].getxScale().setScreenMin(this.plotters[0].x); - } - if (this.plotters[0].getyScale() != null) { - this.plotters[0].getyScale().setScreenMax( - this.plotters[0].y + this.plotters[0].height); - this.plotters[0] - .getyScale() - .setScreenMaxMargin( - (int) (this.plotters[0].getyScale().getScreenMax() * (1.0D - this.axisMargin))); - this.plotters[0].getyScale().setScreenMin(this.plotters[0].y); - } - if (this.repaintAll) { - final int plotterBackWidth = this.plotters[0].width; - final int plotterBackHeight = this.plotters[0].height; - this.plotters[0].plotBackground(gScroll, plotterBackWidth, - plotterBackHeight, this.offsetX, this.offsetY); - } - this.title.chart = this; - this.title.draw(g); - if ((this.legend == null)) { - this.legend = new SpiderChartLegend(); - } - if (this.legend != null) { - this.legend.chart = this; - this.legend.draw(g); - } - if (this.repaintAll) { - for (int i = 0; i < this.plottersCount; i++) { - this.plotters[i].chart = this; - this.plotters[i].plot(gScroll); - } - } - if (this.border != null) { - this.border.drawRect(g, 0, 0, this.getWidth() - 1, - this.getHeight() - 1); - } - if (this.chartImage != null) { - final int x1 = this.plotters[0].x; - - final int x2 = this.plotters[0].x - + this.plotters[0].getVisibleWidth(); - - final int y1 = this.plotters[0].y - this.plotters[0].getDepth(); - - final int y2 = (this.plotters[0].y - this.plotters[0].getDepth()) - + this.plotters[0].getVisibleHeight(); - - g.drawImage(this.chartImage, x1, y1, x2, y2, x1 + this.offsetX, y1 - + this.offsetY, x2 + this.offsetX, y2 + this.offsetY); - } - if (this.chartListeners != null) { - for (int i = 0; i < this.chartListeners.size(); i++) { - this.chartListeners.get(i).onPaintUserExit(this, g); - } - } - - this.paintTips(g); - if (this.finalImage != null) { - pg.drawImage(this.finalImage, 0, 0, this.getWidth(), - this.getHeight(), 0, 0, this.getWidth(), this.getHeight()); - } - this.repaintAll = false; - if (gScroll != pg) { - gScroll.dispose(); - } - if (gBack != pg) { - gBack.dispose(); - } - if (g != pg) { - g.dispose(); - } - } - - /** */ - private void paintTips(final AbstractChartGraphics g) { - // TODO (AKM) To be implemented properly: Tips Functionality - if (this.showTips && (this.selectedLabel != null)) { - this.selectedLabel.getTip(); - } - } - - /** */ - public void placeFloatingObject(final IFloatingObject obj) { - } - - /** */ - public void removeAllChartListener() { - this.chartListeners.clear(); - } - - /** */ - public void removeChartListener(final ISpiderChartListener cl) { - this.chartListeners.remove(cl); - } - - /** */ - public void removeChartPlotters() { - for (int i = 0; i < this.plottersCount; i++) { - this.plotters[i] = null; - } - this.plottersCount = 0; - } - - /** */ - protected void resetChart(final SpiderChartTitle t, - final SpiderChartPlotter p) { - this.plottersCount = 0; - this.plotters = new SpiderChartPlotter[10]; - this.legend = null; - this.title = null; - this.border = null; - this.backStyle = null; - this.selectedSeq = null; - this.selectedSeqPoint = -1; - this.repaintAll = true; - this.floatingObjects.clear(); - this.plotters[0] = p; - this.title = t; - if (this.title == null) { - this.title = new SpiderChartTitle(); - this.title.setText(""); - } - this.plottersCount = 1; - } - - /** */ - private void resize() { - final int myHeight = this.getHeight(); - final int myWidth = this.getWidth(); - if (this.virtualWidth < myWidth) { - this.virtualWidth = myWidth; - } - if (this.virtualHeight < myHeight) { - this.virtualHeight = myHeight; - } - this.plotters[0] - .setVisibleWidth((int) (myWidth * (1.0D - (this.legendMargin + this.leftMargin)))); - this.plotters[0] - .setVisibleHeight((int) (myHeight * (1.0D - (this.topMargin + this.bottomMargin)))); - - this.plotters[0].x = (int) (myWidth * this.leftMargin); - this.plotters[0].y = (int) (myHeight * this.topMargin); - this.plotters[0].width = this.virtualWidth - - (myWidth - this.plotters[0].getVisibleWidth()); - this.plotters[0].height = this.virtualHeight - - (myHeight - this.plotters[0].getVisibleHeight()); - - this.title.x = 0; - this.title.y = 0; - this.title.height = (int) (myHeight * this.topMargin); - this.title.width = myWidth; - if (this.legend != null) { - this.legend.x = (int) (myWidth * (1.0D - this.legendMargin)); - this.legend.width = (int) (myWidth * this.legendMargin); - this.legend.y = (int) (myHeight * this.topMargin); - this.legend.height = (int) (myHeight * 0.5D); - } - this.setPlotterSize(); - } - - public void setActivateSelection(final boolean activateSelection) { - this.activateSelection = activateSelection; - } - - public void setAutoRebuild(final boolean autoRebuild) { - this.autoRebuild = autoRebuild; - } - - public void setAutoResize(final boolean autoResize) { - this.autoResize = autoResize; - } - - public void setAxisMargin(final double axisMargin) { - this.axisMargin = axisMargin; - } - - public void setBackgroundCanvasColor(final String backgroundCanvasColor) { - this.backgroundCanvasColor = backgroundCanvasColor; - } - - public void setBackImage(final AbstractChartImage backImage) { - this.backImage = backImage; - } - - public void setBackStyle(final FillStyle backStyle) { - this.backStyle = backStyle; - } - - public void setBackTmpImage(final AbstractChartImage backTmpImage) { - this.backTmpImage = backTmpImage; - } - - public void setBorder(final LineStyle border) { - this.border = border; - } - - public void setChartImage(final AbstractChartImage chartImage) { - this.chartImage = chartImage; - } - - public void setCurrentX(final int currentX) { - this.currentX = currentX; - } - - public void setCurrentY(final int currentY) { - this.currentY = currentY; - } - - public void setCursorLastX(final int cursorLastX) { - this.cursorLastX = cursorLastX; - } - - public void setCursorLastY(final int cursorLastY) { - this.cursorLastY = cursorLastY; - } - - public void setDeamon(final SpiderChartWorker deamon) { - this.deamon = deamon; - } - - public void setFinalImage(final AbstractChartImage finalImage) { - this.finalImage = finalImage; - } - - /** */ - public void setHeight(final int h) { - if (h > this.minimumHeight) { - this.height = h; - } - } - - public void setLastHeight(final int lastHeight) { - this.lastHeight = lastHeight; - } - - public void setLastWidth(final int lastWidth) { - this.lastWidth = lastWidth; - } - - public void setLegend(final SpiderChartLegend legend) { - this.legend = legend; - } - - public void setMinimumHeight(final int minimumHeight) { - this.minimumHeight = minimumHeight; - } - - /** */ - public void setMinimumSize(final int w, final int h) { - this.minimumWidth = w; - this.minimumHeight = h; - } - - public void setMinimumWidth(final int minimumWidth) { - this.minimumWidth = minimumWidth; - } - - public void setMsecs(final long msecs) { - this.msecs = msecs; - } - - public void setOffsetX(final int offsetX) { - this.offsetX = offsetX; - } - - public void setOffsetY(final int offsetY) { - this.offsetY = offsetY; - } - - public void setOriginalVirtualHeight(final int originalVirtualHeight) { - this.originalVirtualHeight = originalVirtualHeight; - } - - public void setOriginalVirtualWidth(final int originalVirtualWidth) { - this.originalVirtualWidth = originalVirtualWidth; - } - - public void setPlotters(final AbstractPlotter[] plotters) { - this.plotters = plotters; - } - - public void setPlottersCount(final int plottersCount) { - this.plottersCount = plottersCount; - } - - /** */ - private void setPlotterSize() { - for (int i = 1; i < this.plottersCount; i++) { - this.plotters[i].x = this.plotters[0].x; - this.plotters[i].y = this.plotters[0].y; - this.plotters[i].width = this.plotters[0].width; - this.plotters[i].height = this.plotters[0].height; - } - } - - public void setRepaintAll(final boolean repaintAll) { - this.repaintAll = repaintAll; - } - - public void setRepaintAlways(final boolean repaintAlways) { - this.repaintAlways = repaintAlways; - } - - public void setSelectedLabel(final SpiderChartLabel selectedLabel) { - this.selectedLabel = selectedLabel; - } - - public void setSelectedSeq(final DataSeq selectedSeq) { - this.selectedSeq = selectedSeq; - } - - public void setSelectedSeqPoint(final int selectedSeqPoint) { - this.selectedSeqPoint = selectedSeqPoint; - } - - public void setShowTips(final boolean showTips) { - this.showTips = showTips; - } - - /** */ - public void setSize(final int w, final int h) { - this.setWidth(w); - this.setHeight(h); - } - - public void setStopped(final boolean stopped) { - this.stopped = stopped; - } - - public void setTitle(final SpiderChartTitle title) { - this.title = title; - } - - public void setVirtualHeight(final int virtualHeight) { - this.virtualHeight = virtualHeight; - } - - public void setVirtualWidth(final int virtualWidth) { - this.virtualWidth = virtualWidth; - } - - /** */ - public void setWidth(final int w) { - if (w > this.minimumWidth) { - this.width = w; - } - } - - public void setWithScroll(final boolean withScroll) { - this.withScroll = withScroll; - } - - /** */ - public void startWorker() { - this.stopped = false; - this.deamon = new SpiderChartWorker(); - this.deamon.chart = this; - new Thread(this.deamon).start(); - } - - /** */ - public void stopWorker() { - this.stopped = true; - if (this.deamon != null) { - this.deamon.stop = true; - } - this.deamon = null; - } - - /** */ - private void triggerChartEvent(final int event) { - for (int i = 0; i < this.chartListeners.size(); i++) { - this.chartListeners.get(i).onChartEvent(this, event); - } - } -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/SpiderChartComponent.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/SpiderChartComponent.java deleted file mode 100644 index 7f64c33b0..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/SpiderChartComponent.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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; - -public abstract class SpiderChartComponent { - - /** */ - protected SpiderChart chart; - /** */ - protected int height; - /** */ - protected int width; - /** */ - protected int x; - /** */ - protected int y; - -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/api/annotations/DataPoints.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/api/annotations/DataPoints.java deleted file mode 100644 index 8378e0d66..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/api/annotations/DataPoints.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.api.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Used to annotate POJO's method returning primitive array of double values - * contributing to Spider Chart Data - * - * @author AMIT KUMAR MONDAL - * - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(value = ElementType.METHOD) -public @interface DataPoints { - -} \ No newline at end of file diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/api/annotations/SpiderChartPlot.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/api/annotations/SpiderChartPlot.java deleted file mode 100644 index 9375ece57..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/api/annotations/SpiderChartPlot.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.api.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.fortiss.tooling.spiderchart.gc.AbstractChartColor; - -/** - * Used to annotate POJO contributing to Spider Chart Data - * - * @author AMIT KUMAR MONDAL - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(value = ElementType.TYPE) -public @interface SpiderChartPlot { - - /** - * Spider Chart Area Color - * - * @return color the name of the color - * @see AbstractChartColor - */ - String areaColor(); - - /** - * Spider Chart Legend Text - * - * @return name name of the legend to be used - */ - String name(); - -} \ No newline at end of file diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/api/annotations/package-info.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/api/annotations/package-info.java deleted file mode 100644 index e82d838de..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/api/annotations/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.api.annotations; \ No newline at end of file diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/api/annotations/processor/SpiderChartAnnotationProcessor.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/api/annotations/processor/SpiderChartAnnotationProcessor.java deleted file mode 100644 index bc1afd443..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/api/annotations/processor/SpiderChartAnnotationProcessor.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.api.annotations.processor; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Optional; - -import org.fortiss.tooling.spiderchart.api.annotations.DataPoints; -import org.fortiss.tooling.spiderchart.api.annotations.SpiderChartPlot; - -public final class SpiderChartAnnotationProcessor { - - /** - * Checks if {@link DataPoints} annotation is present on the given object's - * method - */ - private static boolean checkMethodAnnotation(final Object object) { - for (final Method m : object.getClass().getMethods()) { - if (m.getAnnotation(DataPoints.class) != null) { - return true; - } - - } - return false; - } - - /** - * Checks if {@link SpiderChartPlot} annotation is present on the given - * objects class - */ - private static boolean checkTypeAnnotation(final Object object) { - return object.getClass().isAnnotationPresent(SpiderChartPlot.class); - } - - /** - * Returns area color of the provided Spider Chart Object - */ - public static String getAreaColor(final Object object) { - reportOnNull(object); - if (!(checkTypeAnnotation(object) && checkMethodAnnotation(object))) { - throw new RuntimeException( - "The provided Spider Chart object's class is not annotated with both the SpiderChartPlot and DataPoints annotations"); - } else { - final String areaColor = object.getClass() - .getAnnotation(SpiderChartPlot.class).areaColor(); - return areaColor; - } - } - - /** - * Returns data points of the provided Spider Chart Object - */ - public static double[] getDataPoints(final Object object) { - reportOnNull(object); - if (!(checkTypeAnnotation(object) && checkMethodAnnotation(object))) { - throw new RuntimeException( - "The provided Spider Chart object's class is not annotated with both the SpiderChartPlot and DataPoints annotations"); - } else { - for (final Method m : object.getClass().getMethods()) { - final DataPoints dataPoints = m.getAnnotation(DataPoints.class); - try { - if (dataPoints != null) { - final Object invokedResult = m.invoke(object, - (Object[]) null); - if (invokedResult instanceof double[]) { - return ((double[]) invokedResult); - } else { - throw new RuntimeException( - "Spider Chart annotated method doesn't return primitive double array"); - } - } - } catch (IllegalAccessException | IllegalArgumentException - | InvocationTargetException e) { - e.printStackTrace(); - } - } - } - return null; - } - - /** - * Returns legend of the provided Spider Chart Object - */ - public static String getLegend(final Object object) { - reportOnNull(object); - if (!(checkTypeAnnotation(object) && checkMethodAnnotation(object))) { - throw new RuntimeException( - "The provided Spider Chart object's class is not annotated with both the SpiderChartPlot and DataPoints annotations"); - } else { - final String legend = object.getClass() - .getAnnotation(SpiderChartPlot.class).name(); - return legend; - } - } - - /** - * Throws exception in case object provided is null - */ - private static void reportOnNull(final Object object) { - Optional.ofNullable(object).orElseThrow( - () -> new IllegalArgumentException("Provided Object is null")); - } - - /** - * Constructor - */ - private SpiderChartAnnotationProcessor() { - } - -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/api/annotations/processor/package-info.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/api/annotations/processor/package-info.java deleted file mode 100644 index 151110fae..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/api/annotations/processor/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.api.annotations.processor; \ No newline at end of file diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/builder/AxesConfigurer.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/builder/AxesConfigurer.java deleted file mode 100644 index b2111e3ed..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/builder/AxesConfigurer.java +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.builder; - -import static org.fortiss.tooling.spiderchart.util.ChartUtil.toDoublePrimitiveArray; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public final class AxesConfigurer { - - public static class Builder { - - /** */ - private final List<Double> maxScales; - /** */ - private final List<Double> minScales; - /** */ - private final List<String> scalesNames; - - /** */ - private final List<Object> scalingLabelFormats; - - /** Constructor */ - public Builder() { - this.maxScales = new ArrayList<>(); - this.minScales = new ArrayList<>(); - this.scalesNames = new ArrayList<>(); - this.scalingLabelFormats = new ArrayList<>(); - } - - /** */ - public <E extends Enum<E>> Builder addAxis(final String name, - final Class<E> value) { - final double[] doubleValues = new double[value.getEnumConstants().length]; - int i = 0; - for (final Enum<E> enumVal : value.getEnumConstants()) { - doubleValues[i++] = enumVal.ordinal(); - } - Arrays.sort(doubleValues); - this.maxScales.add(doubleValues[doubleValues.length - 1] + 1); - this.minScales.add(doubleValues[0]); - this.scalesNames.add(name); - this.scalingLabelFormats.add(value); - return this; - } - - /** */ - public Builder addAxis(final String name, final double maxScale, - final double minScale) { - this.maxScales.add(maxScale); - this.minScales.add(minScale); - this.scalesNames.add(name); - this.scalingLabelFormats.add("#.#"); - return this; - } - - /** */ - public Builder addAxis(final String name, final double maxScale, - final double minScale, final Object scalingLabelFormat) { - this.scalingLabelFormats.add(scalingLabelFormat); - this.maxScales.add(maxScale); - this.minScales.add(minScale); - this.scalesNames.add(name); - return this; - } - - /** */ - public AxesConfigurer build() { - return new AxesConfigurer(this.maxScales, this.minScales, - this.scalesNames, this.scalingLabelFormats); - } - - } - - /** */ - private final List<Double> maxScales; - /** */ - private final List<Double> minScales; - /** */ - private final List<String> scalesNames; - - /** */ - private final List<Object> scalingLabelFormats; - - /** Constructor */ - private AxesConfigurer(final List<Double> maxScales, - final List<Double> minScales, final List<String> scalesNames, - final List<Object> scalingLabelFormats) { - super(); - this.maxScales = maxScales; - this.minScales = minScales; - this.scalesNames = scalesNames; - this.scalingLabelFormats = scalingLabelFormats; - } - - /** */ - public String[] axesNames() { - final String[] axesNames = new String[this.scalesNames.size()]; - return this.scalesNames.toArray(axesNames); - } - - /** */ - public Object[] axesScalingLabelFormats() { - return this.scalingLabelFormats.toArray(); - } - - /** */ - public double[] maxScales() { - final Double[] maxScales = new Double[this.maxScales.size()]; - return toDoublePrimitiveArray(this.maxScales.toArray(maxScales)); - } - - /** */ - public double[] minScales() { - final Double[] minScales = new Double[this.minScales.size()]; - return toDoublePrimitiveArray(this.minScales.toArray(minScales)); - } - -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/builder/AxisDataBuilder.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/builder/AxisDataBuilder.java deleted file mode 100644 index 4ce18d0f1..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/builder/AxisDataBuilder.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.builder; - -import static java.util.Objects.requireNonNull; -import static org.fortiss.tooling.spiderchart.api.annotations.processor.SpiderChartAnnotationProcessor.getAreaColor; -import static org.fortiss.tooling.spiderchart.api.annotations.processor.SpiderChartAnnotationProcessor.getDataPoints; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.function.Supplier; - -import org.fortiss.tooling.spiderchart.SpiderChart; -import org.fortiss.tooling.spiderchart.builder.model.AxisData; - -public final class AxisDataBuilder { - - /** */ - private final List<AxisData> axesData = new ArrayList<>(); - - /** */ - private final AxisData axisData; - - /** */ - private final SpiderChart chart; - - /** Constructor */ - public AxisDataBuilder(final SpiderChart chart) { - requireNonNull(chart); - - this.axisData = new AxisData(); - this.chart = chart; - } - - /** */ - private void done() { - this.chart.addSeq(this.axisData.getData()); - } - - /** */ - public void inject(final Supplier<Object> drawableData) { - requireNonNull(drawableData); - final Object data = drawableData.get(); - final Optional<double[]> values = Optional.of(getDataPoints(data)); - final Optional<String> areaColor = Optional.of(getAreaColor(data)); - - this.axisData.setData(values.orElseGet(() -> new double[] { 0 }), - areaColor.orElse("RED")); - this.axesData.add(this.axisData); - this.done(); - } - -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/builder/SpiderChartBuilder.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/builder/SpiderChartBuilder.java deleted file mode 100644 index b76acebec..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/builder/SpiderChartBuilder.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.builder; - -import static java.util.Objects.requireNonNull; -import static org.fortiss.tooling.spiderchart.gc.AbstractChartColor.ANTIQUEWHITE; -import static org.fortiss.tooling.spiderchart.gc.AbstractChartColor.YELLOW; -import static org.fortiss.tooling.spiderchart.gc.AbstractGraphicsSupplier.getColor; -import static org.fortiss.tooling.spiderchart.style.FillStyle.GRADIENT_VERTICAL; - -import java.util.function.Consumer; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.fortiss.tooling.spiderchart.SpiderChart; -import org.fortiss.tooling.spiderchart.style.FillStyle; -import org.fortiss.tooling.spiderchart.swt.SpiderChartViewer; - -public final class SpiderChartBuilder { - - /** */ - private static SpiderChartConfigurationBuilder chartConfiguration; - /** */ - private static SpiderChartBuilder chartViewerBuilder; - - /** */ - public static SpiderChartBuilder config(final Composite parent, - final Consumer<SpiderChartConfigurationBuilder> settings) { - requireNonNull(parent); - requireNonNull(settings); - chartConfiguration = new SpiderChartConfigurationBuilder(); - settings.accept(chartConfiguration); - chartViewerBuilder = new SpiderChartBuilder(parent); - return chartViewerBuilder; - } - - /** */ - private SpiderChart chart; - /** */ - private final SpiderChartViewer chartViewer; - - /** Constructor */ - public SpiderChartBuilder(final Composite parent) { - requireNonNull(parent); - this.chartViewer = new SpiderChartViewer(parent, SWT.NONE); - this.prepareChartViewer(parent); - } - - /** */ - public SpiderChartBuilder data( - final Consumer<AxisDataBuilder> dataBuilderConsumer) { - requireNonNull(dataBuilderConsumer); - final AxisDataBuilder dataBuilder = new AxisDataBuilder(this.chart); - dataBuilderConsumer.accept(dataBuilder); - this.chartViewer.setChart(this.chart); - return this; - } - - /** */ - private void prepareChartViewer(final Composite parent) { - this.chartViewer.setLayoutData(new GridData(GridData.FILL, - GridData.FILL, true, true)); - this.chartViewer.setBounds(parent.getShell().getClientArea().x, parent - .getShell().getClientArea().y, parent.getShell() - .getClientArea().width, - parent.getShell().getClientArea().height - 10); - this.chartViewer.setChangePointer(true); - this.chartViewer.setAllowZoom(true); - - // Some chart related default configurations - this.chart = new SpiderChart(chartConfiguration.getTitle(), - chartConfiguration.getPlotter()); - this.chart.setBackStyle(new FillStyle(getColor(YELLOW))); - this.chart.setBackgroundCanvasColor(ANTIQUEWHITE); - this.chart.getBackStyle().setGradientType(GRADIENT_VERTICAL); - this.chart.setLegend(chartConfiguration.getLegend()); - this.chart.setRepaintAll(true); - this.chart.setActivateSelection(true); - } - - /** */ - public SpiderChartViewer viewer( - final Consumer<SpiderChartBuilder> chartBuilderConsumer) { - requireNonNull(chartBuilderConsumer); - chartBuilderConsumer.accept(chartViewerBuilder); - return chartViewerBuilder.chartViewer; - } - -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/builder/SpiderChartConfigurationBuilder.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/builder/SpiderChartConfigurationBuilder.java deleted file mode 100644 index 801fc01f7..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/builder/SpiderChartConfigurationBuilder.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.builder; - -import static java.util.Objects.requireNonNull; -import static org.fortiss.tooling.spiderchart.gc.AbstractChartColor.BLACK; -import static org.fortiss.tooling.spiderchart.gc.AbstractChartColor.BLUE; -import static org.fortiss.tooling.spiderchart.gc.AbstractChartColor.PALEGREEN; -import static org.fortiss.tooling.spiderchart.gc.AbstractChartColor.TELA; -import static org.fortiss.tooling.spiderchart.gc.AbstractChartColor.WHITE; -import static org.fortiss.tooling.spiderchart.gc.AbstractChartFont.PLAIN; -import static org.fortiss.tooling.spiderchart.gc.AbstractGraphicsSupplier.getColor; -import static org.fortiss.tooling.spiderchart.gc.AbstractGraphicsSupplier.getFont; -import static org.fortiss.tooling.spiderchart.gc.Fonts.ARIAL; -import static org.fortiss.tooling.spiderchart.style.LineStyle.NORMAL_LINE; - -import java.util.function.Consumer; - -import org.fortiss.tooling.spiderchart.legend.SpiderChartLegend; -import org.fortiss.tooling.spiderchart.plotter.spider.SpiderChartPlotter; -import org.fortiss.tooling.spiderchart.style.FillStyle; -import org.fortiss.tooling.spiderchart.style.LineStyle; -import org.fortiss.tooling.spiderchart.title.SpiderChartTitle; - -public final class SpiderChartConfigurationBuilder { - - /** */ - private SpiderChartLegend legend; - /** */ - private SpiderChartPlotter plotter; - /** */ - private SpiderChartTitle title; - - /** */ - public SpiderChartLegend getLegend() { - return this.legend; - } - - /** */ - public SpiderChartPlotter getPlotter() { - return this.plotter; - } - - /** */ - public SpiderChartTitle getTitle() { - return this.title; - } - - /** */ - public SpiderChartConfigurationBuilder legend( - final Consumer<SpiderChartLegend> legendBuilder) { - this.legend = new SpiderChartLegend(); - this.legend.setBackground(new FillStyle(getColor(WHITE))); - this.legend.setBorder(new LineStyle(1, getColor(BLACK), NORMAL_LINE)); - legendBuilder.accept(this.legend); - return this; - } - - /** */ - public SpiderChartConfigurationBuilder plotter( - final Consumer<SpiderChartPlotter> plotter) { - requireNonNull(plotter); - this.plotter = new SpiderChartPlotter(); - this.plotter.setBackStyle(new FillStyle(getColor(PALEGREEN))); - this.plotter - .setGridStyle(new LineStyle(1, getColor(TELA), NORMAL_LINE)); - this.plotter.setGridFont(getFont(ARIAL, PLAIN, 10)); - this.plotter.setGridFontColor(getColor(BLUE)); - plotter.accept(this.plotter); - return this; - } - - /** */ - public SpiderChartConfigurationBuilder title( - final Consumer<SpiderChartTitle> titleBuilder) { - requireNonNull(titleBuilder); - this.title = new SpiderChartTitle(); - titleBuilder.accept(this.title); - return this; - } - -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/builder/model/AxisData.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/builder/model/AxisData.java deleted file mode 100644 index fc5a71484..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/builder/model/AxisData.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.builder.model; - -import static org.fortiss.tooling.spiderchart.gc.AbstractChartFont.BOLD; -import static org.fortiss.tooling.spiderchart.gc.AbstractGraphicsSupplier.getColor; -import static org.fortiss.tooling.spiderchart.gc.AbstractGraphicsSupplier.getFont; -import static org.fortiss.tooling.spiderchart.gc.Fonts.VERDANA; -import static org.fortiss.tooling.spiderchart.style.LineStyle.NORMAL_LINE; - -import org.fortiss.tooling.spiderchart.sequence.LineDataSeq; -import org.fortiss.tooling.spiderchart.style.FillStyle; -import org.fortiss.tooling.spiderchart.style.LineStyle; - -public final class AxisData { - - /** */ - private LineDataSeq data; - - /** */ - public LineDataSeq getData() { - return this.data; - } - - /** */ - public void setData(final double[] dataValues, final String color) { - this.data = new LineDataSeq(dataValues, new LineStyle(2, - getColor(color), NORMAL_LINE)); - this.data.setDrawPoint(true); - this.data.setValueFont(getFont(VERDANA, BOLD, 12)); - this.data.setFillStyle(new FillStyle(getColor(color), 0.5f)); - } - -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/builder/model/package-info.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/builder/model/package-info.java deleted file mode 100644 index 64a5cdfbe..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/builder/model/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.builder.model; \ No newline at end of file diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/builder/package-info.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/builder/package-info.java deleted file mode 100644 index 579a811a4..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/builder/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.builder; \ No newline at end of file diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/example/IPhone.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/example/IPhone.java deleted file mode 100644 index 370d94b43..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/example/IPhone.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.example; - -import static org.fortiss.tooling.spiderchart.gc.AbstractChartColor.DARKORCHID; - -import org.fortiss.tooling.spiderchart.api.annotations.DataPoints; -import org.fortiss.tooling.spiderchart.api.annotations.SpiderChartPlot; - -@SpiderChartPlot(name = "iPhone 6", areaColor = DARKORCHID) -public final class IPhone { - - @DataPoints - public double[] dataPoints() { - final double[] data = { 4, 3.5, 4, 4.6, 5 }; - return data; - } - -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/example/Nexus.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/example/Nexus.java deleted file mode 100644 index 2ca8da7ed..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/example/Nexus.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.example; - -import static org.fortiss.tooling.spiderchart.gc.AbstractChartColor.OLIVE; - -import org.fortiss.tooling.spiderchart.api.annotations.DataPoints; -import org.fortiss.tooling.spiderchart.api.annotations.SpiderChartPlot; - -@SpiderChartPlot(name = "Nexus 6", areaColor = OLIVE) -public final class Nexus { - - @DataPoints - public double[] dataPoints() { - final double[] data = { 4, 3, 3, 4.1, 3 }; - return data; - } - -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/example/Sample.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/example/Sample.java deleted file mode 100644 index edad017f4..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/example/Sample.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.example; - -import java.util.function.Supplier; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.fortiss.tooling.spiderchart.builder.AxesConfigurer; -import org.fortiss.tooling.spiderchart.builder.SpiderChartBuilder; -import org.fortiss.tooling.spiderchart.sequence.LineDataSeq; -import org.fortiss.tooling.spiderchart.swt.SpiderChartViewer; - -public final class Sample { - - private enum Brand { - COMMUNAL, INTERNATIONAL, LOCAL, OUT_OF_MARKET, STANDARD - } - - private static SpiderChartViewer viewer; - - private static void buildSpiderChart(final Shell shell) { - final Supplier<Object> iPhoneData = IPhone::new; - final Supplier<Object> nexusData = Nexus::new; - - viewer = SpiderChartBuilder - .config(shell, - settings -> { - settings.title( - title -> title - .setText("Smartphone Comparison Scale")) - .legend(legend -> { - legend.addItem(iPhoneData); - legend.addItem(nexusData); - }) - .plotter( - plotter -> { - final AxesConfigurer configuration = new AxesConfigurer.Builder() - .addAxis("Battery", 5, - 0) - .addAxis("Camera", 5, 0) - .addAxis("Display", 5, - 0) - .addAxis("Memory", 5, 0) - .addAxis("Brand", 5, 0) - .build(); - plotter.use(configuration); - }); - }).viewer( - chart -> { - chart.data( - firstData -> firstData.inject(iPhoneData)) - .data(secondData -> secondData - .inject(nexusData)); - }); - - // Updating the chart with new parameters - Display.getDefault() - .asyncExec(() -> { - // changing values in runtime - final LineDataSeq iPhoneDataSequence = LineDataSeq.of( - iPhoneData.get(), 2.0, 4.2, 4.1, 42.8, 3.7, - Brand.INTERNATIONAL); - // Set the first sequence - viewer.getChart().getSpiderPlotter() - .setSeq(0, iPhoneDataSequence); - - // changing axes in runtime - final AxesConfigurer configuration = new AxesConfigurer.Builder() - .addAxis("Battery", 5, 0) - .addAxis("Screen", 5, 0) - .addAxis("Display", 5, 0) - .addAxis("Memory", 50, 0) - .addAxis("Sound", 5, 0) - .addAxis("Brand", Brand.class).build(); - - final LineDataSeq nexusDataSequence = LineDataSeq.of( - nexusData.get(), 2.4, 3.2, 2.1, 23.8, 1.7, - Brand.LOCAL); - - // Set the second sequence - viewer.getChart().getSpiderPlotter() - .setSeq(1, nexusDataSequence); - viewer.getChart().getSpiderPlotter().use(configuration); - viewer.getChart().getSpiderPlotter() - .setMarkScalesOnEveryAxis(true); - }); - } - - public static void main(final String[] args) { - final Display display = new Display(); - final Shell shell = new Shell(display, SWT.DIALOG_TRIM); - shell.setSize(800, 750); - - buildSpiderChart(shell); - shell.open(); - - while (!shell.isDisposed()) { - if (!display.readAndDispatch()) { - display.sleep(); - } - } - - viewer.getChart().stopWorker(); - viewer.getChart().dispose(); - - display.dispose(); - } - -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/example/package-info.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/example/package-info.java deleted file mode 100644 index db1f3e8fb..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/example/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.example; \ No newline at end of file diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/AbstractChartColor.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/AbstractChartColor.java deleted file mode 100644 index 4a805f82a..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/AbstractChartColor.java +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.gc; - -public abstract class AbstractChartColor { - - public static final String ALICEBLUE = "ALICEBLUE"; - public static final String ANTIQUEWHITE = "ANTIQUEWHITE"; - public static final String AQUA = "AQUA"; - public static final String AQUAMARINE = "AQUAMARINE"; - public static final String AZURE = "AZURE"; - public static final String BEIGE = "BEIGE"; - public static final String BLACK = "BLACK"; - public static final String BLUE = "BLUE"; - public static final String BLUEVIOLET = "BLUEVIOLET"; - public static final String BORLYWOOD = "BORLYWOOD"; - public static final String BROWN = "BROWN"; - public static final String CORAL = "CORAL"; - public static final String CYAN = "CYAN"; - public static final String DARKGOLGENROD = "DARKGOLGENROD"; - public static final String DARKGRAY = "DARKGRAY"; - public static final String DARKGREEN = "DARKGREEN"; - public static final String DARKOLIVEGREEN = "DARKOLIVEGREEN"; - public static final String DARKORANGE = "DARKORANGE"; - public static final String DARKORCHID = "DARKORCHID"; - public static final String DARKSALMON = "DARKSALMON"; - public static final String DARKTURQUOISE = "DARKTURQUOISE"; - public static final String DARKVIOLET = "DARKVIOLET"; - public static final String DEEPPINK = "DEEPPINK"; - public static final String DEEPSKYBLUE = "DEEPSKYBLUE"; - public static final String FORESTGREEN = "FORESTGREEN"; - public static final String FUCHSIA = "FUCHSIA"; - public static final String GOLD = "GOLD"; - public static final String GOLDENROD = "GOLDENROD"; - public static final String GRAY = "GRAY"; - public static final String GREEN = "GREEN"; - public static final String GREENYELLOW = "GREENYELLOW"; - public static final String HOTPINK = "HOTPINK"; - public static final String INDIANRED = "INDIANRED"; - public static final String IVORY = "IVORY"; - public static final String KHALI = "KHALI"; - public static final String LAVENDER = "LAVENDER"; - public static final String LAWNGREEN = "LAWNGREEN"; - public static final String LIGHTBLUE = "LIGHTBLUE"; - public static final String LIGHTCORAL = "LIGHTCORAL"; - public static final String LIGHTCYAN = "LIGHTCYAN"; - public static final String LIGHTGRAY = "LIGHTGRAY"; - public static final String LIGHTPINK = "LIGHTPINK"; - public static final String LIGHTSALMON = "LIGHTSALMON"; - public static final String LIGHTSKYBLUE = "LIGHTSKYBLUE"; - public static final String LIGHTYELLOW = "LIGHTYELLOW"; - public static final String LIME = "LIME"; - public static final String LIMEGREEN = "LIMEGREEN"; - public static final String MAGENTA = "MAGENTA"; - public static final String MAROON = "MAROON"; - public static final String MEDIUMBLUE = "MEDIUMBLUE"; - public static final String MEDIUMPURPLE = "MEDIUMPURPLE"; - public static final String MIDNIGHTBLUE = "MIDNIGHTBLUE"; - public static final String NAVY = "NAVY"; - public static final String OLIVE = "OLIVE"; - public static final String ORANGE = "ORANGE"; - public static final String ORANGERED = "ORANGERED"; - public static final String ORCHID = "ORCHID"; - public static final String PALEGREEN = "PALEGREEN"; - public static final String PALETURQUOISE = "PALETURQUOISE"; - public static final String PALEVIOLETRED = "PALEVIOLETRED"; - public static final String PINK = "PINK"; - public static final String PLUM = "PLUM"; - public static final String PURPLE = "PURPLE"; - public static final String RED = "RED"; - public static final String SALMON = "SALMON"; - public static final String SEAGREEN = "SEAGREEN"; - public static final String SIENNA = "SIENNA"; - public static final String SKYBLUE = "SKYBLUE"; - public static final String SPRINGGREEN = "SPRINGGREEN"; - public static final String TELA = "TELA"; - public static final String TURQUOISE = "TURQUOISE"; - public static final String VIOLET = "VIOLET"; - public static final String WHITE = "WHITE"; - public static final String YELLOW = "YELLOW"; - public static final String YELLOWGREEN = "YELLOWGREEN"; - - /** */ - public AbstractChartColor brighter() { - return null; - } - - /** */ - public AbstractChartColor darker() { - return null; - } - - /** */ - public int getBlue() { - return 0; - } - - /** */ - public int getGreen() { - return 0; - } - - /** */ - public int getRed() { - return 0; - } - - /** */ - public int getRGB() { - return (this.getRed() * 256 * 256) + (this.getGreen() * 256) - + this.getBlue(); - } - - /** */ - public String getRGBString() { - return Integer.toHexString(this.getRGB()); - } -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/AbstractChartFont.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/AbstractChartFont.java deleted file mode 100644 index 3f021a4d1..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/AbstractChartFont.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.gc; - -public abstract class AbstractChartFont { - - public static int BOLD = 1; - public static int BOLD_ITALIC = 3; - public static int ITALIC = 2; - public static int PLAIN = 0; - -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/AbstractChartGraphics.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/AbstractChartGraphics.java deleted file mode 100644 index f0628d0ea..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/AbstractChartGraphics.java +++ /dev/null @@ -1,293 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.gc; - -public abstract class AbstractChartGraphics { - - /** */ - public static int ROTATE_CENTER = 0; - /** */ - public static int ROTATE_LEFTTOP = 1; - /** */ - public static int STROKE_DASHED = 3; - /** */ - public static int STROKE_DOTTED = 2; - /** */ - public static int STROKE_NORMAL = 1; - /** */ - protected int lineStyle = STROKE_NORMAL; - /** */ - protected int lineWidth = 1; - /** */ - protected AbstractChartImage textureImage = null; - - /** */ - public void createFadeArea(final AbstractChartColor colorFrom, - final AbstractChartColor colorUntil, final int x, final int y, - final int w, final int h, final boolean vertical, - final boolean cyclic) { - } - - /** */ - public void dispose() { - } - - /** */ - public void drawArc(final int x, final int y, final int w, final int h, - final int a1, final int a2) { - } - - /** */ - public void drawImage(final AbstractChartImage image, final int x, - final int y) { - } - - /** */ - public void drawImage(final AbstractChartImage image, final int x1Dest, - final int y1Dest, final int x2Dest, final int y2Dest, - final int x1Source, final int y1Source, final int x2Source, - final int y2Source) { - } - - /** */ - public void drawLine(final int x1, final int y1, final int x2, final int y2) { - } - - /** */ - public void drawLineWithStyle(final int x1, final int y1, final int x2, - final int y2) { - if (this.lineStyle == STROKE_NORMAL) { - this.drawSimpleLine(x1, y1, x2, y2); - } else { - int segment = 10; - int segmentspace = 10; - if (this.lineStyle == STROKE_DOTTED) { - segment = 1; - segmentspace = 5; - } - final int h = Math.abs(y2 - y1); - final int w = Math.abs(x2 - x1); - if ((h == 0) && (w == 0)) { - return; - } - final double hipo = Math.sqrt((h * h) + (w * w)); - - final double Cos = w / hipo; - final double Sin = h / hipo; - - int Xslope = 1; - int Yslope = 1; - if (x2 < x1) { - Xslope = -1; - } - if (y2 < y1) { - Yslope = -1; - } - int subx1 = 0; - int suby1 = 0; - int subx2 = 0; - int suby2 = 0; - int subsegment = 0; - for (;;) { - suby2 = (int) (Sin * (subsegment + segment)) * Yslope; - subx2 = (int) (Cos * (subsegment + segment)) * Xslope; - suby1 = (int) (Sin * subsegment) * Yslope; - subx1 = (int) (Cos * subsegment) * Xslope; - if ((w < Math.abs(subx1)) || (h < Math.abs(suby1))) { - break; - } - if (w < Math.abs(subx2)) { - subx2 = w * Xslope; - } - if (h < Math.abs(suby2)) { - suby2 = h * Yslope; - } - this.drawSimpleLine(x1 + subx1, y1 + suby1, x1 + subx2, y1 - + suby2); - - subsegment = subsegment + segment + segmentspace; - } - } - } - - /** */ - public void drawPolygon(final int[] x1, final int[] y1, final int count) { - } - - /** */ - public void drawRect(final int x1, final int y1, final int w, final int h) { - this.drawLineWithStyle(x1, y1, x1, y1 + h); - this.drawLineWithStyle(x1, y1, x1 + w, y1); - this.drawLineWithStyle(x1, y1 + h, x1 + w, y1 + h); - this.drawLineWithStyle(x1 + w, y1, x1 + w, y1 + h); - } - - /** */ - public boolean drawRotatedText(final AbstractChartFont descFont, - final AbstractChartColor descColor, final String txt, - final int angle, final int x, final int y, final boolean b) { - return false; - } - - /** */ - public void drawRoundedRect(final int x1, final int y1, final int w, - final int h) { - this.drawRect(x1, y1, w, h); - } - - /** */ - protected void drawSimpleLine(final int x1, final int y1, final int x2, - final int y2) { - int pixelsWidth = 1; - - pixelsWidth = this.lineWidth * 1; - if (pixelsWidth < 1) { - pixelsWidth = 1; - } - this.drawLine(x1, y1, x2, y2); - if (pixelsWidth == 1) { - return; - } - if (pixelsWidth > 1) { - int xwidth = 0; - int ywidth = 0; - - final int h = Math.abs(y2 - y1); - final int w = Math.abs(x2 - x1); - - final double hipo = Math.sqrt((h * h) + (w * w)); - - final double Cos = w / hipo; - - xwidth = 1; - ywidth = 0; - if (Cos > Math.cos(1.0471666666666668D)) { - xwidth = 0; - ywidth = 1; - } - if (Cos > Math.cos(0.5235833333333334D)) { - xwidth = 0; - ywidth = 1; - } - int side = 1; - int distanceToCenter = 0; - for (int i = 2; i <= pixelsWidth; i++) { - if (side == 1) { - distanceToCenter++; - } - this.drawLine(x1 + (side * xwidth * distanceToCenter), y1 - + (side * ywidth * distanceToCenter), x2 - + (side * xwidth * distanceToCenter), y2 - + (side * ywidth * distanceToCenter)); - side *= -1; - } - } - } - - /** */ - public void drawText(final String s, final int x, final int y) { - } - - /** */ - public void fillArc(final int x, final int y, final int w, final int h, - final int a1, final int a2) { - } - - /** */ - public void fillPolygon(final int[] x1, final int[] y1, final int count) { - } - - /** */ - public void fillRect(final int x1, final int y1, final int w, final int h) { - } - - /** */ - public void fillRoundRect(final int x1, final int y1, final int w, - final int h) { - this.fillRect(x1, y1, w, h); - } - - /** */ - public Object getAlphaComposite() { - return null; - } - - /** */ - public AbstractChartColor getColor() { - return null; - } - - /** */ - public AbstractChartFont getFont() { - return null; - } - - /** */ - public int getFontHeight() { - return this.getFontHeight(null); - } - - /** */ - public int getFontHeight(final AbstractChartFont font) { - return 0; - } - - /** */ - public int getFontWidth(final AbstractChartFont font, final String s) { - return 0; - } - - /** */ - public int getFontWidth(final String s) { - return this.getFontWidth(null, s); - } - - /** */ - public void paintRotatedImage(final AbstractChartImage srcImage, - final int angle, final int x, final int y, final int alginment) { - } - - /** */ - public void setAlpha(final float a) { - } - - /** */ - public void setAlphaComposite(final Object a) { - } - - /** */ - public void setColor(final AbstractChartColor color) { - } - - /** */ - public void setFont(final AbstractChartFont font) { - } - - /** */ - public void setLineStyle(final int style) { - this.lineStyle = style; - } - - /** */ - public void setLineWidth(final int w) { - this.lineWidth = w; - } - - /** */ - public void setTexture(final AbstractChartImage image) { - this.textureImage = image; - } -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/AbstractChartImage.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/AbstractChartImage.java deleted file mode 100644 index 72f3d6912..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/AbstractChartImage.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.gc; - -public abstract class AbstractChartImage { - - /** */ - public void dispose() { - } - - /** */ - public AbstractChartGraphics getGraphics() { - return null; - } - - /** */ - public int getHeight() { - return 0; - } - - /** */ - public int getWidth() { - return 0; - } - -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/AbstractGraphicsSupplier.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/AbstractGraphicsSupplier.java deleted file mode 100644 index ea4194dac..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/AbstractGraphicsSupplier.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.gc; - -import static org.fortiss.tooling.spiderchart.gc.swt.SwtGraphicsProvider.startUIThread; - -import org.fortiss.tooling.spiderchart.gc.swt.SpiderChartSwtColor; -import org.fortiss.tooling.spiderchart.gc.swt.SpiderChartSwtFont; -import org.fortiss.tooling.spiderchart.gc.swt.SpiderChartSwtGraphics; -import org.fortiss.tooling.spiderchart.gc.swt.SpiderChartSwtImage; - -public final class AbstractGraphicsSupplier { - - /** */ - public static AbstractChartImage createImage(final int w, final int h) { - return new SpiderChartSwtImage(w, h); - } - - /** */ - public static AbstractChartImage createTransparentImage(final int w, - final int h, final AbstractChartColor transparent) { - return new SpiderChartSwtImage(w, h, transparent); - } - - /** */ - public static AbstractChartColor getColor(final int red, final int green, - final int blue) { - return new SpiderChartSwtColor(red, green, blue); - } - - /** */ - public static AbstractChartColor getColor(final String c) { - return new SpiderChartSwtColor(c); - } - - /** */ - public static AbstractChartColor getColorFromObject(final Object o) { - return new SpiderChartSwtColor(o); - } - - /** */ - public static AbstractChartFont getFont(final Fonts fonts, final int style, - final int size) { - return new SpiderChartSwtFont(fonts.getFontName(), style, size); - } - - /** */ - public static AbstractChartFont getFontFromObject(final Object o) { - return new SpiderChartSwtFont(o); - } - - /** */ - public static AbstractChartGraphics getGraphics(final Object o) { - return new SpiderChartSwtGraphics(o); - } - - /** */ - public static AbstractChartImage getImage(final Object o) { - try { - return new SpiderChartSwtImage(o); - } catch (final Exception e) { - e.printStackTrace(); - } - return null; - } - - /** */ - public static void startUiThread(final Runnable r) { - startUIThread(r); - } - - /** - * Constructor - */ - private AbstractGraphicsSupplier() { - } -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/Fonts.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/Fonts.java deleted file mode 100644 index 228782fd4..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/Fonts.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.gc; - -public enum Fonts { - ARIAL("Arial"), SERIF("Serif"), VERDANA("Verdana"); - - /** */ - private final String fontName; - - /** - * Constructor - */ - private Fonts(final String name) { - this.fontName = name; - } - - /** - * Retrieves font text - * - * @return - */ - public String getFontName() { - return this.fontName; - } -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/Point.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/Point.java deleted file mode 100644 index dcf5bdae3..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/Point.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.gc; - -public final class Point { - - /** */ - private final int x; - /** */ - private final int y; - - /** Constructor */ - public Point(final int x1, final int y1) { - this.x = x1; - this.y = y1; - } - - public int getX() { - return this.x; - } - - public int getY() { - return this.y; - } -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/Polygon.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/Polygon.java deleted file mode 100644 index 649337eba..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/Polygon.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.gc; - -import java.util.ArrayList; -import java.util.List; - -public final class Polygon { - - /** */ - private final List<Point> points; - - /** - * Constructor - */ - public Polygon() { - this.points = new ArrayList<>(); - } - - /** */ - public void addPoint(final int x, final int y) { - this.points.add(new Point(x, y)); - } - - /** */ - public boolean contains(final int x, final int y) { - int i = 0; - int j = 0; - boolean c = false; - - i = 0; - for (j = this.points.size() - 1; i < this.points.size(); j = i++) { - if (((this.getY(i) <= y) && (y < this.getY(j))) - || ((this.getY(j) <= y) && (y < this.getY(i)) && (x < ((((this - .getX(j) - this.getX(i)) * (y - this.getY(i))) / (this - .getY(j) - this.getY(i))) + this.getX(i))))) { - c = !c; - } - } - return c; - } - - /** */ - public int getX(final int i) { - return this.points.get(i).getX(); - } - - /** */ - public int getY(final int i) { - return this.points.get(i).getY(); - } -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/package-info.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/package-info.java deleted file mode 100644 index 04e6252d0..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.gc; \ No newline at end of file diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/swt/SpiderChartSwtColor.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/swt/SpiderChartSwtColor.java deleted file mode 100644 index 76b248b67..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/swt/SpiderChartSwtColor.java +++ /dev/null @@ -1,303 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.gc.swt; - -import org.eclipse.swt.graphics.Color; -import org.fortiss.tooling.spiderchart.gc.AbstractChartColor; - -public final class SpiderChartSwtColor extends AbstractChartColor { - - /** */ - private int blue = 0; - /** */ - private int green = 0; - /** */ - private int red = 0; - - /** Constructor */ - public SpiderChartSwtColor(final int iRed, final int iGreen, final int iBlue) { - this.setRGB(iRed, iGreen, iBlue); - } - - /** Constructor */ - public SpiderChartSwtColor(final Object c) { - if (c instanceof String) { - this.setFromString((String) c); - } else { - this.red = ((Color) c).getRed(); - this.green = ((Color) c).getGreen(); - this.blue = ((Color) c).getBlue(); - } - } - - /** {@inheritDoc} */ - @Override - public AbstractChartColor brighter() { - final int percent = 10; - final int rr = this.red; - final int gg = this.green; - final int bb = this.blue; - final int r = rr + (percent * (rr / 100)); - final int g = gg + (percent * (gg / 100)); - final int b = bb + (percent * (bb / 100)); - return new SpiderChartSwtColor(Math.min(r, 255), Math.min(g, 255), - Math.min(b, 255)); - } - - /** {@inheritDoc} */ - @Override - public AbstractChartColor darker() { - final int percent = 10; - final int rr = this.red; - final int gg = this.green; - final int bb = this.blue; - final int r = rr - (percent * (rr / 100)); - final int g = gg - (percent * (gg / 100)); - final int b = bb - (percent * (bb / 100)); - - return new SpiderChartSwtColor(Math.min(r, 255), Math.min(g, 255), - Math.min(b, 255)); - } - - /** {@inheritDoc} */ - @Override - public int getBlue() { - return this.blue; - } - - /** {@inheritDoc} */ - public Color getColor() { - return new Color(SwtGraphicsProvider.getDisplay(), this.red, - this.green, this.blue); - } - - /** {@inheritDoc} */ - @Override - public int getGreen() { - return this.green; - } - - /** {@inheritDoc} */ - @Override - public int getRed() { - return this.red; - } - - /** String to RGB */ - private void setFromString(String c) { - c = c.toUpperCase(); - if (c.compareTo("") == 0) { - this.setRGB(0, 0, 0); - return; - } - if (c.compareTo(RED) == 0) { - this.setRGB(255, 0, 0); - } else if (c.compareTo(BLACK) == 0) { - this.setRGB(0, 0, 0); - } else if (c.compareTo(BLUE) == 0) { - this.setRGB(0, 0, 255); - } else if (c.compareTo(CYAN) == 0) { - this.setRGB(0, 255, 255); - } else if (c.compareTo(DARKGRAY) == 0) { - this.setRGB(70, 70, 70); - } else if (c.compareTo(GRAY) == 0) { - this.setRGB(128, 128, 128); - } else if (c.compareTo(GREEN) == 0) { - this.setRGB(0, 255, 0); - } else if (c.compareTo(LIGHTGRAY) == 0) { - this.setRGB(192, 192, 192); - } else if (c.compareTo(MAGENTA) == 0) { - this.setRGB(255, 0, 128); - } else if (c.compareTo(ORANGE) == 0) { - this.setRGB(255, 128, 0); - } else if (c.compareTo(PINK) == 0) { - this.setRGB(255, 0, 255); - } else if (c.compareTo(WHITE) == 0) { - this.setRGB(255, 255, 255); - } else if (c.compareTo(YELLOW) == 0) { - this.setRGB(255, 255, 0); - } else if (c.compareTo(LIME) == 0) { - this.setRGB(65280); - } else if (c.compareTo(OLIVE) == 0) { - this.setRGB(8421376); - } else if (c.compareTo(MAROON) == 0) { - this.setRGB(8388608); - } else if (c.compareTo(NAVY) == 0) { - this.setRGB(128); - } else if (c.compareTo(PURPLE) == 0) { - this.setRGB(8388736); - } else if (c.compareTo(TELA) == 0) { - this.setRGB(32896); - } else if (c.compareTo(FUCHSIA) == 0) { - this.setRGB(16711935); - } else if (c.compareTo(AQUA) == 0) { - this.setRGB(65535); - } else if (c.compareTo(ALICEBLUE) == 0) { - this.setRGB(15792383); - } else if (c.compareTo(ANTIQUEWHITE) == 0) { - this.setRGB(16444375); - } else if (c.compareTo(AQUAMARINE) == 0) { - this.setRGB(8388564); - } else if (c.compareTo(AZURE) == 0) { - this.setRGB(15794175); - } else if (c.compareTo(BEIGE) == 0) { - this.setRGB(16119260); - } else if (c.compareTo(BLUEVIOLET) == 0) { - this.setRGB(9055202); - } else if (c.compareTo(BROWN) == 0) { - this.setRGB(10824234); - } else if (c.compareTo(BORLYWOOD) == 0) { - this.setRGB(14596231); - } else if (c.compareTo(CORAL) == 0) { - this.setRGB(16744272); - } else if (c.compareTo(CYAN) == 0) { - this.setRGB(65535); - } else if (c.compareTo(DARKGOLGENROD) == 0) { - this.setRGB(12092939); - } else if (c.compareTo(DARKGREEN) == 0) { - this.setRGB(25600); - } else if (c.compareTo(DARKOLIVEGREEN) == 0) { - this.setRGB(5597999); - } else if (c.compareTo(DARKORANGE) == 0) { - this.setRGB(16747520); - } else if (c.compareTo(DARKORCHID) == 0) { - this.setRGB(10040012); - } else if (c.compareTo(DARKSALMON) == 0) { - this.setRGB(15308410); - } else if (c.compareTo(DARKTURQUOISE) == 0) { - this.setRGB(52945); - } else if (c.compareTo(DARKVIOLET) == 0) { - this.setRGB(9699539); - } else if (c.compareTo(DEEPPINK) == 0) { - this.setRGB(16716947); - } else if (c.compareTo(DEEPSKYBLUE) == 0) { - this.setRGB(49151); - } else if (c.compareTo(FORESTGREEN) == 0) { - this.setRGB(2263842); - } else if (c.compareTo(GOLD) == 0) { - this.setRGB(16766720); - } else if (c.compareTo(GOLDENROD) == 0) { - this.setRGB(14329120); - } else if (c.compareTo(GREENYELLOW) == 0) { - this.setRGB(11403055); - } else if (c.compareTo(HOTPINK) == 0) { - this.setRGB(16738740); - } else if (c.compareTo(INDIANRED) == 0) { - this.setRGB(13458524); - } else if (c.compareTo(IVORY) == 0) { - this.setRGB(16777200); - } else if (c.compareTo(KHALI) == 0) { - this.setRGB(15787660); - } else if (c.compareTo(LAVENDER) == 0) { - this.setRGB(15132410); - } else if (c.compareTo(LAWNGREEN) == 0) { - this.setRGB(8190976); - } else if (c.compareTo(LIGHTBLUE) == 0) { - this.setRGB(11393254); - } else if (c.compareTo(LIGHTCORAL) == 0) { - this.setRGB(15761536); - } else if (c.compareTo(LIGHTCYAN) == 0) { - this.setRGB(14745599); - } else if (c.compareTo(LIGHTGRAY) == 0) { - this.setRGB(13882323); - } else if (c.compareTo(LIGHTPINK) == 0) { - this.setRGB(16758465); - } else if (c.compareTo(LIGHTSALMON) == 0) { - this.setRGB(16752762); - } else if (c.compareTo(LIGHTSKYBLUE) == 0) { - this.setRGB(8900346); - } else if (c.compareTo(LIGHTYELLOW) == 0) { - this.setRGB(16777184); - } else if (c.compareTo(LIMEGREEN) == 0) { - this.setRGB(3329330); - } else if (c.compareTo(MAGENTA) == 0) { - this.setRGB(16711935); - } else if (c.compareTo(MEDIUMBLUE) == 0) { - this.setRGB(205); - } else if (c.compareTo(MEDIUMPURPLE) == 0) { - this.setRGB(9662683); - } else if (c.compareTo(MIDNIGHTBLUE) == 0) { - this.setRGB(1644912); - } else if (c.compareTo(ORANGE) == 0) { - this.setRGB(16753920); - } else if (c.compareTo(ORANGERED) == 0) { - this.setRGB(16729344); - } else if (c.compareTo(ORCHID) == 0) { - this.setRGB(14315734); - } else if (c.compareTo(PALEGREEN) == 0) { - this.setRGB(10025880); - } else if (c.compareTo(PALETURQUOISE) == 0) { - this.setRGB(11529966); - } else if (c.compareTo(PALEVIOLETRED) == 0) { - this.setRGB(14381203); - } else if (c.compareTo(PINK) == 0) { - this.setRGB(16761035); - } else if (c.compareTo(PLUM) == 0) { - this.setRGB(14524637); - } else if (c.compareTo(PURPLE) == 0) { - this.setRGB(10494192); - } else if (c.compareTo(SALMON) == 0) { - this.setRGB(16416882); - } else if (c.compareTo(SEAGREEN) == 0) { - this.setRGB(3050327); - } else if (c.compareTo(SIENNA) == 0) { - this.setRGB(10506797); - } else if (c.compareTo(SKYBLUE) == 0) { - this.setRGB(8900331); - } else if (c.compareTo(SPRINGGREEN) == 0) { - this.setRGB(65407); - } else if (c.compareTo(TURQUOISE) == 0) { - this.setRGB(4251856); - } else if (c.compareTo(VIOLET) == 0) { - this.setRGB(15631086); - } else if (c.compareTo(YELLOWGREEN) == 0) { - this.setRGB(10145074); - } else { - try { - int rgb = 0; - c = c.toUpperCase(); - if (c.startsWith("0X")) { - rgb = Integer.parseInt(c.substring(2), 16); - } else if (c.startsWith("X")) { - rgb = Integer.parseInt(c.substring(1), 16); - } else { - rgb = Integer.parseInt(c); - } - final int r = (rgb >> 16) & 0xFF; - final int g = (rgb >> 8) & 0xFF; - final int b = rgb & 0xFF; - this.setRGB(r, g, b); - } catch (final Exception e) { - e.printStackTrace(); - this.setRGB(0, 0, 0); - } - } - } - - /** */ - private void setRGB(final int rgb) { - this.red = (rgb >> 16) & 0xFF; - this.green = (rgb >> 8) & 0xFF; - this.blue = rgb & 0xFF; - } - - /** */ - private void setRGB(final int iRed, final int iGreen, final int iBlue) { - this.red = iRed; - this.green = iGreen; - this.blue = iBlue; - } -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/swt/SpiderChartSwtFont.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/swt/SpiderChartSwtFont.java deleted file mode 100644 index dca9e9aa0..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/swt/SpiderChartSwtFont.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.gc.swt; - -import org.eclipse.swt.graphics.Font; -import org.fortiss.tooling.spiderchart.gc.AbstractChartFont; - -public final class SpiderChartSwtFont extends AbstractChartFont { - - /** */ - private String fontName = ""; - /** */ - private int fontSize = 10; - /** */ - private int fontStyle = PLAIN; - - /** Constructor */ - public SpiderChartSwtFont(final Object f) { - this.fontName = ((Font) f).getFontData()[0].getName(); - final int s = ((Font) f).getFontData()[0].getStyle(); - this.fontStyle = PLAIN; - if ((s & 0x1) == 1) { - this.fontStyle = BOLD; - } - if ((s & 0x2) == 2) { - this.fontStyle = ITALIC; - } - if ((s & 0x3) == 3) { - this.fontStyle = BOLD_ITALIC; - } - this.fontSize = ((Font) f).getFontData()[0].getHeight(); - } - - /** Constructor */ - public SpiderChartSwtFont(final String name, final int style, final int size) { - this.fontName = name; - this.fontSize = size; - this.fontStyle = style; - } - - /** */ - protected Font getFont() { - int s = 0; - if (this.fontStyle == BOLD) { - s = 1; - } - if (this.fontStyle == ITALIC) { - s = 2; - } - if (this.fontStyle == BOLD_ITALIC) { - s = 3; - } - return new Font(SwtGraphicsProvider.getDisplay(), this.fontName, - this.fontSize, s); - } -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/swt/SpiderChartSwtGraphics.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/swt/SpiderChartSwtGraphics.java deleted file mode 100644 index 836d8fc7c..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/swt/SpiderChartSwtGraphics.java +++ /dev/null @@ -1,572 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.gc.swt; - -import static org.fortiss.tooling.spiderchart.gc.AbstractGraphicsSupplier.getImage; - -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.ImageData; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.graphics.Rectangle; -import org.fortiss.tooling.spiderchart.gc.AbstractChartColor; -import org.fortiss.tooling.spiderchart.gc.AbstractChartFont; -import org.fortiss.tooling.spiderchart.gc.AbstractChartGraphics; -import org.fortiss.tooling.spiderchart.gc.AbstractChartImage; - -public final class SpiderChartSwtGraphics extends AbstractChartGraphics { - /** */ - private float alphaValue = 1.0F; - /** */ - private Color currentColor; - /** */ - private Font currentFont; - /** */ - private GC graphics; - /** */ - private Image imageForTransparentFilling = null; - /** */ - private Image srcImage; - /** */ - private Color transparent = null; - - /** Constructor */ - public SpiderChartSwtGraphics(final Object g) { - this.graphics = (GC) g; - } - - /** {@inheritDoc} */ - @Override - public void createFadeArea(final AbstractChartColor colorFrom, - final AbstractChartColor colorUntil, final int x, final int y, - final int w, final int h, final boolean vertical, - final boolean cyclic) { - final Color fore = ((SpiderChartSwtColor) colorFrom).getColor(); - final Color back = ((SpiderChartSwtColor) colorUntil).getColor(); - - this.graphics.setForeground(fore); - this.graphics.setBackground(back); - - this.graphics.fillGradientRectangle(x, y, w, h, vertical); - if (this.currentColor != null) { - this.graphics.setForeground(this.currentColor); - this.graphics.setBackground(this.currentColor); - } - fore.dispose(); - back.dispose(); - } - - /** {@inheritDoc} */ - @Override - public void dispose() { - this.disposeCurrentColor(); - this.disposeCurrentFont(); - if ((this.graphics != null) && !this.graphics.isDisposed()) { - this.graphics.dispose(); - } - this.graphics = null; - } - - /** */ - private void disposeCurrentColor() { - if ((this.currentColor != null) && !this.currentColor.isDisposed()) { - this.currentColor.dispose(); - } - this.currentColor = null; - } - - /** */ - private void disposeCurrentFont() { - if ((this.currentFont != null) && !this.currentFont.isDisposed()) { - this.currentFont.dispose(); - } - this.currentFont = null; - } - - /** {@inheritDoc} */ - @Override - public void drawArc(final int x, final int y, final int w, final int h, - final int a1, final int a2) { - this.graphics.drawArc(x, y, w, h, a1, a2); - } - - /** {@inheritDoc} */ - @Override - public void drawImage(final AbstractChartImage image, final int x, - final int y) { - if (image == null) { - return; - } - if (((SpiderChartSwtImage) image).getImage() == null) { - return; - } - this.graphics.drawImage(((SpiderChartSwtImage) image).getImage(), x, y); - } - - /** {@inheritDoc} */ - @Override - public void drawImage(final AbstractChartImage image, final int x1Dest, - final int y1Dest, final int x2Dest, final int y2Dest, - final int x1Source, final int y1Source, final int x2Source, - final int y2Source) { - if (image == null) { - return; - } - if (((SpiderChartSwtImage) image).getImage() == null) { - return; - } - this.graphics.drawImage(((SpiderChartSwtImage) image).getImage(), - x1Source, y1Source, x2Source - x1Source, y2Source - y1Source, - x1Dest, y1Dest, x2Dest - x1Dest, y2Dest - y1Dest); - } - - /** {@inheritDoc} */ - @Override - public void drawLine(final int x1, final int y1, final int x2, final int y2) { - this.graphics.drawLine(x1, y1, x2, y2); - } - - /** {@inheritDoc} */ - @Override - public void drawPolygon(final int[] x1, final int[] y1, final int count) { - final int[] points = new int[count * 2]; - int j = 0; - for (int i = 0; i < count; i++) { - points[j++] = x1[i]; - points[j++] = y1[i]; - } - this.graphics.drawPolygon(points); - } - - /** {@inheritDoc} */ - @Override - public void drawRect(final int x1, final int y1, final int w, final int h) { - super.drawRect(x1, y1, w, h); - } - - /** {@inheritDoc} */ - @Override - public boolean drawRotatedText(final AbstractChartFont descFont, - final AbstractChartColor descColor, final String txt, - final int angle, final int x, final int y, final boolean b) { - this.setFont(descFont); - this.setColor(descColor); - - final int h = this.getFontHeight(); - final int w = this.getFontWidth(txt); - int size = w; - int toCenterX = 0; - int toCenterY = 0; - if (h > w) { - size = h; - toCenterX = (size - w) / 2; - } else { - toCenterY = (size - h) / 2; - } - Image tmpImage = new Image(SwtGraphicsProvider.getDisplay(), size, size); - final ImageData imageData = tmpImage.getImageData(); - tmpImage.dispose(); - - Color transparent = null; - if ((descColor.getRed() == 255) && (descColor.getBlue() == 255) - && (descColor.getGreen() == 255)) { - transparent = new Color(SwtGraphicsProvider.getDisplay(), 0, 0, 0); - imageData.transparentPixel = imageData.palette.getPixel(new RGB(0, - 0, 0)); - } else { - transparent = new Color(SwtGraphicsProvider.getDisplay(), 255, 255, - 255); - imageData.transparentPixel = imageData.palette.getPixel(new RGB( - 255, 255, 255)); - } - tmpImage = new Image(SwtGraphicsProvider.getDisplay(), imageData); - - final GC g = new GC(tmpImage); - final Color c = ((SpiderChartSwtColor) descColor).getColor(); - final Font f = ((SpiderChartSwtFont) descFont).getFont(); - - g.setForeground(transparent); - g.setBackground(transparent); - g.fillRectangle(0, 0, size, size); - - g.setFont(f); - g.setForeground(c); - g.drawText(txt, toCenterX, toCenterY, true); - - g.dispose(); - c.dispose(); - f.dispose(); - - final AbstractChartImage tmpChartImage = getImage(tmpImage); - this.paintRotatedImage(tmpChartImage, angle, x - ((w - h) / 2), y + 4, - ROTATE_CENTER); - - tmpChartImage.dispose(); - tmpImage.dispose(); - - return true; - } - - /** {@inheritDoc} */ - @Override - public void drawText(final String s, final int x, final int y) { - this.graphics.drawString(s, x, y - - this.graphics.getFontMetrics().getHeight(), true); - } - - /** {@inheritDoc} */ - @Override - public void fillArc(final int x, final int y, final int w, final int h, - final int a1, final int a2) { - final GC g = this.getGraphicForFilling(); - g.fillArc(x, y, w, h, a1, a2); - this.processFilling(g); - } - - /** {@inheritDoc} */ - @Override - public void fillPolygon(final int[] x1, final int[] y1, final int count) { - final int[] points = new int[count * 2]; - int j = 0; - for (int i = 0; i < count; i++) { - points[j++] = x1[i]; - points[j++] = y1[i]; - } - final GC g = this.getGraphicForFilling(); - g.fillPolygon(points); - this.processFilling(g); - } - - /** {@inheritDoc} */ - @Override - public void fillRect(final int x1, final int y1, final int w, final int h) { - final GC g = this.getGraphicForFilling(); - g.fillRectangle(new Rectangle(x1, y1, w, h)); - this.processFilling(g); - } - - /** {@inheritDoc} */ - @Override - public Object getAlphaComposite() { - return new Float(this.alphaValue); - } - - public float getAlphaValue() { - return this.alphaValue; - } - - /** {@inheritDoc} */ - @Override - public AbstractChartColor getColor() { - return new SpiderChartSwtColor(this.currentColor); - } - - public Color getCurrentColor() { - return this.currentColor; - } - - public Font getCurrentFont() { - return this.currentFont; - } - - /** {@inheritDoc} */ - @Override - public AbstractChartFont getFont() { - return new SpiderChartSwtFont(this.currentFont); - } - - /** {@inheritDoc} */ - @Override - public int getFontHeight(final AbstractChartFont font) { - final Font tmpFont = this.currentFont; - this.currentFont = null; - if (font != null) { - this.setFont(font); - } - final int result = this.graphics.getFontMetrics().getHeight(); - - this.disposeCurrentFont(); - this.currentFont = tmpFont; - - return result; - } - - /** {@inheritDoc} */ - @Override - public int getFontWidth(final AbstractChartFont font, final String s) { - final Font tmpFont = this.currentFont; - this.currentFont = null; - if (font != null) { - this.setFont(font); - } - int result = 0; - - result = this.graphics.textExtent(s).x; - - this.disposeCurrentFont(); - this.currentFont = tmpFont; - - return result; - } - - /** {@inheritDoc} */ - protected GC getGraphicForFilling() { - if ((this.alphaValue >= 1.0F) || (this.srcImage == null)) { - this.imageForTransparentFilling = null; - return this.graphics; - } - this.transparent = null; - if ((this.currentColor.getRed() == 255) - && (this.currentColor.getBlue() == 255) - && (this.currentColor.getGreen() == 255)) { - this.transparent = new Color(SwtGraphicsProvider.getDisplay(), 0, - 0, 0); - } else { - this.transparent = new Color(SwtGraphicsProvider.getDisplay(), 255, - 255, 255); - } - final RGB[] rgbs = new RGB['Ä€']; - rgbs[0] = this.transparent.getRGB(); - for (int i = 1; i <= 255; i++) { - rgbs[i] = this.currentColor.getRGB(); - } - final ImageData imageData = new ImageData( - this.srcImage.getBounds().width, - this.srcImage.getBounds().height, - this.srcImage.getImageData().depth, - this.srcImage.getImageData().palette); - - this.imageForTransparentFilling = new Image( - SwtGraphicsProvider.getDisplay(), imageData); - - final GC g = new GC(this.imageForTransparentFilling); - - g.setForeground(this.transparent); - g.setBackground(this.transparent); - g.fillRectangle(0, 0, this.srcImage.getBounds().width, - this.srcImage.getBounds().height); - - g.setForeground(this.currentColor); - g.setBackground(this.currentColor); - - return g; - } - - public GC getGraphics() { - return this.graphics; - } - - public Image getImageForTransparentFilling() { - return this.imageForTransparentFilling; - } - - public Image getSrcImage() { - return this.srcImage; - } - - public Color getTransparent() { - return this.transparent; - } - - /** {@inheritDoc} */ - @Override - public void paintRotatedImage(AbstractChartImage srcImage, final int angle, - final int x, final int y, final int alignment) { - Image srcSwtImage = ((SpiderChartSwtImage) srcImage).getImage(); - int size = srcSwtImage.getImageData().width; - int h = srcSwtImage.getImageData().height; - int w = srcSwtImage.getImageData().width; - final int originalH = h; - if (h != w) { - srcImage = ((SpiderChartSwtImage) srcImage).forRotation(); - srcSwtImage = ((SpiderChartSwtImage) srcImage).getImage(); - - size = srcSwtImage.getImageData().width; - h = srcSwtImage.getImageData().height; - w = srcSwtImage.getImageData().width; - } - final ImageData srcData = srcSwtImage.getImageData(); - final ImageData destData = new ImageData(size, size, srcData.depth, - srcData.palette); - destData.transparentPixel = srcData.transparentPixel; - if (destData.transparentPixel != -1) { - for (int i = 0; i < size; i++) { - for (int j = 0; j < size; j++) { - destData.setPixel(i, j, destData.transparentPixel); - } - } - } - for (int i = 0; i < size; i++) { - for (int j = 0; j < size; j++) { - final int x2 = this.rotateX(i - (size / 2), j - (size / 2), - -angle) + (size / 2); - final int y2 = this.rotateY(i - (size / 2), j - (size / 2), - -angle) + (size / 2); - - if ((x2 < size) && (y2 < size) && (x2 >= 0) && (y2 >= 0)) { - destData.setPixel(i, j, srcData.getPixel(x2, y2)); - } - } - } - final Image destImage = new Image(SwtGraphicsProvider.getDisplay(), - destData); - if (alignment == ROTATE_LEFTTOP) { - if (angle == 90) { - this.graphics.drawImage(destImage, x - (w - originalH), y); - } else if (angle == -90) { - this.graphics.drawImage(destImage, x, y); - } - } else if (angle == 90) { - this.graphics.drawImage(destImage, x, y); - } else if (angle == -90) { - this.graphics.drawImage(destImage, x, y); - } - destImage.dispose(); - } - - /** */ - protected void processFilling(final GC g) { - if (g != this.graphics) { - g.dispose(); - - final ImageData imageData = this.imageForTransparentFilling - .getImageData(); - for (int i = 0; i < this.srcImage.getBounds().width; i++) { - for (int j = 0; j < this.srcImage.getBounds().height; j++) { - final RGB rgb = imageData.palette.getRGB(imageData - .getPixel(i, j)); - if ((rgb.red == this.transparent.getRed()) - && (rgb.green == this.transparent.getGreen()) - && (rgb.blue == this.transparent.getBlue())) { - imageData.setAlpha(i, j, 0); - } else { - imageData.setAlpha(i, j, - (int) (this.alphaValue * 255.0F)); - } - } - } - this.transparent.dispose(); - this.imageForTransparentFilling.dispose(); - - this.imageForTransparentFilling = new Image( - SwtGraphicsProvider.getDisplay(), imageData); - - this.graphics.drawImage(this.imageForTransparentFilling, 0, 0); - this.imageForTransparentFilling.dispose(); - this.imageForTransparentFilling = null; - } - } - - /** */ - private int rotateX(final int x, final int y, final int angle) { - if (angle == 90) { - return y * -1; - } - if (angle == -90) { - return y * 1; - } - return (int) ((x * Math.cos(Math.toRadians(angle))) - (y * Math - .sin(Math.toRadians(angle)))); - } - - /** */ - private int rotateY(final int x, final int y, final int angle) { - if (angle == 90) { - return x * 1; - } - if (angle == -90) { - return x * -1; - } - return (int) ((x * Math.sin(Math.toRadians(angle))) + (y * Math - .cos(Math.toRadians(angle)))); - } - - /** {@inheritDoc} */ - @Override - public void setAlpha(final float a) { - this.alphaValue = a; - } - - /** {@inheritDoc} */ - @Override - public void setAlphaComposite(final Object a) { - if (a instanceof Float) { - this.alphaValue = ((Float) a).floatValue(); - } - } - - public void setAlphaValue(final float alphaValue) { - this.alphaValue = alphaValue; - } - - /** {@inheritDoc} */ - @Override - public void setColor(final AbstractChartColor color) { - this.disposeCurrentColor(); - this.currentColor = ((SpiderChartSwtColor) color).getColor(); - - this.graphics.setForeground(this.currentColor); - this.graphics.setBackground(this.currentColor); - } - - public void setCurrentColor(final Color currentColor) { - this.currentColor = currentColor; - } - - public void setCurrentFont(final Font currentFont) { - this.currentFont = currentFont; - } - - /** {@inheritDoc} */ - @Override - public void setFont(final AbstractChartFont font) { - this.disposeCurrentFont(); - this.currentFont = ((SpiderChartSwtFont) font).getFont(); - - this.graphics.setFont(this.currentFont); - } - - public void setGraphics(final GC graphics) { - this.graphics = graphics; - } - - public void setImageForTransparentFilling( - final Image imageForTransparentFilling) { - this.imageForTransparentFilling = imageForTransparentFilling; - } - - /** {@inheritDoc} */ - @Override - public void setLineStyle(final int style) { - super.setLineStyle(style); - } - - /** {@inheritDoc} */ - @Override - public void setLineWidth(final int w) { - super.setLineWidth(w); - } - - public void setSrcImage(final Image srcImage) { - this.srcImage = srcImage; - } - - public void setTransparent(final Color transparent) { - this.transparent = transparent; - } -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/swt/SpiderChartSwtImage.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/swt/SpiderChartSwtImage.java deleted file mode 100644 index 4f9f5b93e..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/swt/SpiderChartSwtImage.java +++ /dev/null @@ -1,146 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.gc.swt; - -import static org.fortiss.tooling.spiderchart.gc.swt.SwtGraphicsProvider.getDisplay; - -import java.io.InputStream; - -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.ImageData; -import org.fortiss.tooling.spiderchart.gc.AbstractChartColor; -import org.fortiss.tooling.spiderchart.gc.AbstractChartGraphics; -import org.fortiss.tooling.spiderchart.gc.AbstractChartImage; - -public final class SpiderChartSwtImage extends AbstractChartImage { - - /** */ - private Image image = null; - /** */ - private AbstractChartColor transparentColor = null; - - /** Constructor */ - public SpiderChartSwtImage(final int w, final int h) { - this.image = new Image(getDisplay(), w, h); - } - - /** Constructor */ - public SpiderChartSwtImage(final int w, final int h, - final AbstractChartColor transparent) { - this.transparentColor = transparent; - final Color trans = ((SpiderChartSwtColor) transparent).getColor(); - final Image tmpImage = new Image(SwtGraphicsProvider.getDisplay(), w, h); - final ImageData imageData = tmpImage.getImageData(); - tmpImage.dispose(); - imageData.transparentPixel = imageData.palette.getPixel(trans.getRGB()); - - this.image = new Image(getDisplay(), imageData); - - final GC g = new GC(this.image); - g.setForeground(trans); - g.setBackground(trans); - g.fillRectangle(0, 0, w, h); - - g.dispose(); - trans.dispose(); - } - - /** Constructor */ - public SpiderChartSwtImage(final Object o) { - try { - if (o instanceof String) { - final InputStream is = SpiderChartSwtImage.class - .getClassLoader().getResourceAsStream((String) o); - if (is != null) { - this.image = new Image(getDisplay(), is); - return; - } - this.image = new Image(getDisplay(), (String) o); - } else if (o instanceof Image) { - this.image = (Image) o; - } else if (o instanceof InputStream) { - this.image = new Image(getDisplay(), (InputStream) o); - } else { - throw new Exception("Class not supported"); - } - } catch (final Exception e) { - e.printStackTrace(); - } - } - - /** {@inheritDoc} */ - @Override - public void dispose() { - if ((this.image != null) && !this.image.isDisposed()) { - this.image.dispose(); - } - this.image = null; - } - - /** */ - protected SpiderChartSwtImage forRotation() { - final int h = this.getHeight(); - final int w = this.getWidth(); - - SpiderChartSwtImage dest = null; - if (w > h) { - dest = new SpiderChartSwtImage(w, w, this.transparentColor); - } else if (h > w) { - dest = new SpiderChartSwtImage(h, h, this.transparentColor); - } else { - return this; - } - final AbstractChartGraphics g = dest.getGraphics(); - g.drawImage(this, 0, 0); - g.dispose(); - - return dest; - } - - /** {@inheritDoc} */ - @Override - public AbstractChartGraphics getGraphics() { - final SpiderChartSwtGraphics g = new SpiderChartSwtGraphics(new GC( - this.image)); - g.setSrcImage(this.image); - return g; - } - - /** {@inheritDoc} */ - @Override - public int getHeight() { - if (this.image == null) { - return 0; - } - return this.image.getBounds().height; - } - - public Image getImage() { - return this.image; - } - - /** {@inheritDoc} */ - @Override - public int getWidth() { - if (this.image == null) { - return 0; - } - return this.image.getBounds().width; - } - -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/swt/SwtGraphicsProvider.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/swt/SwtGraphicsProvider.java deleted file mode 100644 index 19af61574..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/swt/SwtGraphicsProvider.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.gc.swt; - -import org.eclipse.swt.graphics.Device; -import org.eclipse.swt.widgets.Display; - -public final class SwtGraphicsProvider { - - /** */ - private static Device display = null; - - /** */ - public synchronized static Device getDisplay() { - if (display == null) { - display = Display.getCurrent(); - } - return display; - } - - /** */ - public static void startUIThread(final Runnable r) { - ((Display) getDisplay()).syncExec(r); - } - - /** Constructor */ - private SwtGraphicsProvider() { - } -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/swt/package-info.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/swt/package-info.java deleted file mode 100644 index 51746e9ab..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/gc/swt/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.gc.swt; \ No newline at end of file diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/label/SpiderChartLabel.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/label/SpiderChartLabel.java deleted file mode 100644 index 87ad4725e..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/label/SpiderChartLabel.java +++ /dev/null @@ -1,407 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.label; - -import org.fortiss.tooling.spiderchart.SpiderChart; -import org.fortiss.tooling.spiderchart.gc.AbstractChartColor; -import org.fortiss.tooling.spiderchart.gc.AbstractChartGraphics; -import org.fortiss.tooling.spiderchart.gc.Polygon; -import org.fortiss.tooling.spiderchart.label.api.IFloatingObject; -import org.fortiss.tooling.spiderchart.style.FillStyle; -import org.fortiss.tooling.spiderchart.style.LineStyle; - -public final class SpiderChartLabel implements IFloatingObject { - - /** */ - protected static int ALIGN_CENTER = 1; - /** */ - protected static int ALIGN_LEFT = 0; - /** */ - protected static int ALIGN_RIGHT = 2; - /** */ - protected static int BORDER_OVAL = 2; - /** */ - protected static int BORDER_RECT = 0; - /** */ - protected static int BORDER_ROUNDRECT = 1; - /** */ - private int align = ALIGN_LEFT; - /** */ - private int anchorX = 0; - - /** */ - private int anchorY = 0; - - /** */ - private FillStyle background = null; - - /** */ - private LineStyle border = null; - - /** */ - private int borderShape = BORDER_RECT; - - /** */ - private SpiderChart chart = null; - - /** */ - private Polygon clickableArea = null; - - /** */ - private boolean ignorePosition = false; - - /** */ - private LineStyle lineToAnchor = null; - - /** */ - private final int[] lineWidths = new int[100]; - - /** */ - private int marginX = 2; - - /** */ - private int marginY = 2; - - /** */ - private String name = ""; - - /** */ - protected int positionX = 0; - - /** */ - protected int positionY = 0; - - /** */ - private int requiredHeight = 0; - - /** */ - private int requiredWidth = 0; - - /** */ - private String sFormat = ""; - - /** */ - private String tip = ""; - - /** Constructor */ - public SpiderChartLabel(String pformat, final String pvalue, - final boolean pvertical, final boolean pCenter) { - if (pformat.length() == 0) { - pformat = pvalue; - } - this.sFormat = pformat; - } - - public int getAlign() { - return this.align; - } - - public int getAnchorX() { - return this.anchorX; - } - - public int getAnchorY() { - return this.anchorY; - } - - public FillStyle getBackground() { - return this.background; - } - - public LineStyle getBorder() { - return this.border; - } - - public int getBorderShape() { - return this.borderShape; - } - - public SpiderChart getChart() { - return this.chart; - } - - public Polygon getClickableArea() { - return this.clickableArea; - } - - public LineStyle getLineToAnchor() { - return this.lineToAnchor; - } - - public int[] getLineWidths() { - return this.lineWidths; - } - - public int getMarginX() { - return this.marginX; - } - - public int getMarginY() { - return this.marginY; - } - - /** */ - public String getName() { - return this.name; - } - - /** {@inheritDoc} */ - @Override - public Polygon getObjectBounds() { - final Polygon pol = new Polygon(); - pol.addPoint(this.positionX, this.positionY); - pol.addPoint(this.positionX + this.requiredWidth, this.positionY); - pol.addPoint(this.positionX + this.requiredWidth, this.positionY - + this.requiredHeight); - pol.addPoint(this.positionX, this.positionY + this.requiredHeight); - return pol; - } - - public int getPositionX() { - return this.positionX; - } - - public int getPositionY() { - return this.positionY; - } - - public int getRequiredHeight() { - return this.requiredHeight; - } - - public int getRequiredWidth() { - return this.requiredWidth; - } - - public String getsFormat() { - return this.sFormat; - } - - /** */ - public String getTip() { - return this.tip; - } - - /** {@inheritDoc} */ - @Override - public int getX() { - return this.positionX; - } - - /** {@inheritDoc} */ - @Override - public int getY() { - return this.positionY; - } - - /** */ - public void initialize(final AbstractChartGraphics g, final SpiderChart c) { - this.chart = c; - } - - public boolean isIgnorePosition() { - return this.ignorePosition; - } - - /** */ - public void paint(final AbstractChartGraphics g, final int x, final int y, - final int width, final int height) { - if (this.chart != null) { - this.chart.placeFloatingObject(this); - this.chart.addFloationgObject(this); - } - this.render(g); - } - - /** */ - protected void render(final AbstractChartGraphics graphics) { - final AbstractChartGraphics g = graphics; - if ((this.lineToAnchor != null)) { - if (this.anchorY > this.positionY) { - if (this.anchorX <= this.positionX) { - this.lineToAnchor.draw(graphics, this.anchorX, - this.anchorY, this.positionX, - (this.positionY + this.requiredHeight) - 1); - } else { - this.lineToAnchor.draw(graphics, this.anchorX, - this.anchorY, this.positionX + this.requiredWidth, - (this.positionY + this.requiredHeight) - 1); - } - } else if (this.anchorX <= this.positionX) { - this.lineToAnchor.draw(graphics, this.anchorX, this.anchorY, - this.positionX, this.positionY); - } else { - this.lineToAnchor.draw(graphics, this.anchorX, this.anchorY, - this.positionX + this.requiredWidth, this.positionY); - } - } - int x = this.positionX; - int lineStart = 0; - if (this.background != null) { - final AbstractChartColor c = g.getColor(); - if (this.borderShape == BORDER_RECT) { - this.background.draw(g, this.positionX, this.positionY, - (this.positionX + this.requiredWidth) - 1, - (this.positionY + this.requiredHeight) - 1); - } - if (this.borderShape == BORDER_ROUNDRECT) { - this.background.drawRoundRect(g, this.positionX, - this.positionY, - (this.positionX + this.requiredWidth) - 1, - (this.positionY + this.requiredHeight) - 1); - } - if (this.borderShape == BORDER_OVAL) { - this.background - .drawArc( - g, - (int) (this.positionX - (this.requiredWidth * 0.1D)), - (int) (this.positionY - (this.requiredHeight * 0.1D)), - (int) ((this.requiredWidth + (this.requiredWidth * 0.2D)) - 1.0D), - (int) ((this.requiredHeight + (this.requiredHeight * 0.3D)) - 1.0D), - 0, 360); - } - g.setColor(c); - } - if (this.align == ALIGN_CENTER) { - x += (this.requiredWidth - (this.marginX * 2) - this.lineWidths[0]) / 2; - } - if (this.align == ALIGN_RIGHT) { - x += this.requiredWidth - (this.marginX * 2) - this.lineWidths[0]; - } - lineStart = x + this.marginX; - - x = lineStart; - - if (this.border != null) { - if (this.borderShape == BORDER_RECT) { - this.border.drawRect(g, this.positionX, this.positionY, - (this.positionX + this.requiredWidth) - 1, - (this.positionY + this.requiredHeight) - 1); - } - if (this.borderShape == BORDER_ROUNDRECT) { - this.border.drawRoundRect(g, this.positionX, this.positionY, - (this.positionX + this.requiredWidth) - 1, - (this.positionY + this.requiredHeight) - 1); - } - if (this.borderShape == BORDER_OVAL) { - this.border - .drawArc( - g, - (int) (this.positionX - (this.requiredWidth * 0.1D)), - (int) (this.positionY - (this.requiredHeight * 0.1D)), - (int) ((this.requiredWidth + (this.requiredWidth * 0.2D)) - 1.0D), - (int) ((this.requiredHeight + (this.requiredHeight * 0.3D)) - 1.0D), - 0, 360); - } - } - this.clickableArea = new Polygon(); - this.clickableArea.addPoint(this.positionX, this.positionY); - this.clickableArea.addPoint(this.positionX, - (this.positionY + this.requiredHeight) - 1); - this.clickableArea.addPoint((this.positionX + this.requiredWidth) - 1, - (this.positionY + this.requiredHeight) - 1); - this.clickableArea.addPoint((this.positionX + this.requiredWidth) - 1, - this.positionY); - } - - public void setAlign(final int align) { - this.align = align; - } - - public void setAnchorX(final int anchorX) { - this.anchorX = anchorX; - } - - public void setAnchorY(final int anchorY) { - this.anchorY = anchorY; - } - - public void setBackground(final FillStyle background) { - this.background = background; - } - - public void setBorder(final LineStyle border) { - this.border = border; - } - - public void setBorderShape(final int borderShape) { - this.borderShape = borderShape; - } - - public void setChart(final SpiderChart chart) { - this.chart = chart; - } - - public void setClickableArea(final Polygon clickableArea) { - this.clickableArea = clickableArea; - } - - public void setIgnorePosition(final boolean ignorePosition) { - this.ignorePosition = ignorePosition; - } - - public void setLineToAnchor(final LineStyle lineToAnchor) { - this.lineToAnchor = lineToAnchor; - } - - public void setMarginX(final int marginX) { - this.marginX = marginX; - } - - public void setMarginY(final int marginY) { - this.marginY = marginY; - } - - public void setName(final String name) { - this.name = name; - } - - public void setPositionX(final int positionX) { - this.positionX = positionX; - } - - public void setPositionY(final int positionY) { - this.positionY = positionY; - } - - public void setRequiredHeight(final int requiredHeight) { - this.requiredHeight = requiredHeight; - } - - public void setRequiredWidth(final int requiredWidth) { - this.requiredWidth = requiredWidth; - } - - public void setsFormat(final String sFormat) { - this.sFormat = sFormat; - } - - public void setTip(final String tip) { - this.tip = tip; - } - - /** {@inheritDoc} */ - @Override - public void setX(final int x) { - this.positionX = x; - } - - /** {@inheritDoc} */ - @Override - public void setY(final int y) { - this.positionY = y; - } -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/label/api/IFloatingObject.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/label/api/IFloatingObject.java deleted file mode 100644 index 6420ff72a..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/label/api/IFloatingObject.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.label.api; - -import org.fortiss.tooling.spiderchart.gc.Polygon; - -public interface IFloatingObject { - - /** */ - public static final String LAYER_ID = ""; - - /** */ - public abstract Polygon getObjectBounds(); - - /** */ - public abstract int getX(); - - /** */ - public abstract int getY(); - - /** */ - public abstract void setX(int paramInt); - - /** */ - public abstract void setY(int paramInt); -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/label/api/package-info.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/label/api/package-info.java deleted file mode 100644 index d82185a9a..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/label/api/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.label.api; \ No newline at end of file diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/label/package-info.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/label/package-info.java deleted file mode 100644 index 84624bb8f..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/label/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.label; \ No newline at end of file diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/legend/SpiderChartLegend.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/legend/SpiderChartLegend.java deleted file mode 100644 index 1459197ed..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/legend/SpiderChartLegend.java +++ /dev/null @@ -1,378 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.legend; - -import static org.fortiss.tooling.spiderchart.api.annotations.processor.SpiderChartAnnotationProcessor.getAreaColor; -import static org.fortiss.tooling.spiderchart.api.annotations.processor.SpiderChartAnnotationProcessor.getLegend; -import static org.fortiss.tooling.spiderchart.gc.AbstractChartColor.BLACK; -import static org.fortiss.tooling.spiderchart.gc.AbstractChartFont.PLAIN; -import static org.fortiss.tooling.spiderchart.gc.AbstractGraphicsSupplier.getColor; -import static org.fortiss.tooling.spiderchart.gc.AbstractGraphicsSupplier.getFont; -import static org.fortiss.tooling.spiderchart.gc.Fonts.VERDANA; -import static org.fortiss.tooling.spiderchart.style.LineStyle.NORMAL_LINE; - -import java.util.ArrayList; -import java.util.List; -import java.util.function.Supplier; - -import org.fortiss.tooling.spiderchart.SpiderChartComponent; -import org.fortiss.tooling.spiderchart.gc.AbstractChartColor; -import org.fortiss.tooling.spiderchart.gc.AbstractChartFont; -import org.fortiss.tooling.spiderchart.gc.AbstractChartGraphics; -import org.fortiss.tooling.spiderchart.gc.AbstractChartImage; -import org.fortiss.tooling.spiderchart.label.SpiderChartLabel; -import org.fortiss.tooling.spiderchart.style.FillStyle; -import org.fortiss.tooling.spiderchart.style.LineStyle; - -public final class SpiderChartLegend extends SpiderChartComponent { - - /** Legend Background Style */ - private FillStyle background; - - /** Legend Border Line Style */ - private LineStyle border; - - /** Legend Color */ - private AbstractChartColor color = getColor(BLACK); - - /** Legend Font */ - private AbstractChartFont font = getFont(VERDANA, PLAIN, 10); - - /** */ - private final List<Object> items = new ArrayList<>(); - - /** Legend Label */ - private String legendLabel = ""; - - /** Legend Margin */ - private int legendMargin = 10; - - /** Legend Offset Used to position the legend on vertical basis */ - private int legendOffset = 250; - - /** */ - private final List<String> names = new ArrayList<>(); - - /** Legend Title */ - private String title = null; - - /** */ - private boolean verticalLayout = true; - - /** Constructor */ - public SpiderChartLegend() { - if (this.title != null) { - this.addItem(this.title, null); - } - } - - /** */ - public void addItem(final String name, final Object icon) { - this.items.add(icon); - this.names.add(name); - } - - /** */ - public void addItem(final Supplier<Object> pojo) { - final Object data = pojo.get(); - final LineStyle ls = LineStyle.of(1, getColor(getAreaColor(data)), - NORMAL_LINE); - this.addItem(getLegend(data), ls); - } - - /** */ - public void draw(final AbstractChartGraphics g) { - if ((this.legendLabel != null) && (this.legendLabel.length() > 0)) { - final SpiderChartLabel cl = new SpiderChartLabel(this.legendLabel, - "", false, true); - cl.initialize(g, this.chart); - cl.paint(g, this.x, this.y, this.width, this.height); - return; - } - if (this.verticalLayout) { - this.drawVertical(g); - } else { - this.drawHorizontal(g); - } - } - - /** */ - public void drawHorizontal(final AbstractChartGraphics g) { - g.setFont(this.font); - - int textWidth = 0; - int iconWidth = 0; - int totalWidth = 0; - int iconHeight = 0; - int w = 0; - int h = 0; - final int textHeight = g.getFontHeight(); - final int iconSeparator = 3; - final int textSeparator = 5; - for (final Object element : this.names) { - final String s = (String) element; - w = g.getFontWidth(s); - if (w > textWidth) { - textWidth = w; - } - } - totalWidth = (textWidth + textSeparator) * this.names.size(); - for (final Object o : this.items) { - w = 0; - h = 0; - if (o instanceof LineStyle) { - w = 10; - h = 10; - } - if (o instanceof FillStyle) { - w = 10; - h = 10; - } - if (o instanceof AbstractChartImage) { - w = ((AbstractChartImage) o).getWidth(); - h = ((AbstractChartImage) o).getHeight(); - } - if (w > iconWidth) { - iconWidth = w; - } - if (h > iconHeight) { - iconHeight = h; - } - } - totalWidth += (iconWidth + iconSeparator) * this.names.size(); - - int itemHeight = textHeight; - if (iconHeight > itemHeight) { - itemHeight = iconHeight; - } - int toCenterX = (this.width - totalWidth) / 2; - int toCenterY = (this.height - itemHeight) / 2; - if (toCenterY < 0) { - toCenterY = 0; - } - if (toCenterX < 0) { - toCenterX = 0; - } - final int legendX1 = this.x + toCenterX; - final int legendY1 = this.y + toCenterY; - final int legendX2 = this.x + toCenterX + totalWidth; - final int legendY2 = this.y + toCenterY + itemHeight; - if (this.background != null) { - this.background.draw(g, legendX1 - this.legendMargin, legendY1 - - this.legendMargin, legendX2 + this.legendMargin, legendY2 - + this.legendMargin); - } - if (this.border != null) { - this.border.drawRect(g, legendX1 - this.legendMargin, legendY1 - - this.legendMargin, legendX2 + this.legendMargin, legendY2 - + this.legendMargin); - } - int offset = 0; - for (int i = 1; i <= this.names.size(); i++) { - g.setColor(this.color); - g.drawText(this.names.get(i - 1), toCenterX + offset + iconWidth - + iconSeparator + this.x, toCenterY + this.y + itemHeight); - offset = offset + iconWidth + iconSeparator + textWidth - + textSeparator; - } - offset = 0; - for (int i = 1; i <= this.names.size(); i++) { - final Object icon = this.items.get(i - 1); - if (icon instanceof AbstractChartImage) { - g.drawImage((AbstractChartImage) icon, toCenterX + this.x - + offset, toCenterY + this.y); - } - if (icon instanceof LineStyle) { - final LineStyle l = (LineStyle) icon; - l.draw(g, toCenterX + this.x + offset, toCenterY + this.y - + (iconHeight / 2), - ((toCenterX + this.x + iconWidth) - 2) + offset, - toCenterY + this.y + (iconHeight / 2)); - } - if (icon instanceof FillStyle) { - final int sidelentgh = iconWidth / 2; - - final FillStyle f = (FillStyle) icon; - f.draw(g, toCenterX + this.x + offset, toCenterY + this.y, - toCenterX + this.x + offset + sidelentgh, toCenterY - + this.y + sidelentgh); - } - offset = offset + iconWidth + iconSeparator + textWidth - + textSeparator; - } - } - - /** */ - public void drawVertical(final AbstractChartGraphics g) { - g.setFont(this.font); - - int textWidth = 0; - int iconWidth = 0; - int iconHeight = 0; - int w = 0; - int h = 0; - final int textHeight = g.getFontHeight(); - for (final Object element : this.names) { - final String s = (String) element; - w = g.getFontWidth(s); - if (w > textWidth) { - textWidth = w; - } - } - for (final Object o : this.items) { - w = 0; - h = 0; - if (o instanceof LineStyle) { - w = 10; - h = 10; - } - if (w > iconWidth) { - iconWidth = w; - } - if (h > iconHeight) { - iconHeight = h; - } - } - int itemHeight = textHeight; - if (iconHeight > itemHeight) { - itemHeight = iconHeight; - } - int toCenterX = (this.width - (iconWidth + textWidth)) / 2; - int toCenterY = (this.height - (this.names.size() * itemHeight)) / 2; - if (toCenterY < 0) { - toCenterY = 0; - } - if (toCenterX < 0) { - toCenterX = 0; - } - final int legendX1 = this.x + toCenterX; - final int legendY1 = this.y + toCenterY; - final int legendX2 = this.x + toCenterX + iconWidth + textWidth; - final int legendY2 = this.y + toCenterY - + (this.names.size() * itemHeight); - final int x1 = legendX1 - this.legendMargin; - final int y1 = legendY1 - this.legendMargin; - final int x2 = legendX2 + this.legendMargin; - final int y2 = legendY2 + this.legendMargin; - - if (this.background != null) { - this.background.draw(g, x1, y1 + this.legendOffset, x2, y2 - + this.legendOffset); - } - if (this.border != null) { - this.border.drawRect(g, x1, y1 + this.legendOffset, x2, y2 - + this.legendOffset); - } - for (int i = 1; i <= this.names.size(); i++) { - g.setColor(this.color); - g.drawText(this.names.get(i - 1), toCenterX + iconWidth + this.x, - toCenterY + this.y + (i * itemHeight) + this.legendOffset); - } - for (int i = 1; i <= this.names.size(); i++) { - final Object icon = this.items.get(i - 1); - if (icon instanceof LineStyle) { - final LineStyle l = (LineStyle) icon; - l.setWidth(10); - l.draw(g, toCenterX + this.x, toCenterY + this.y - + (iconHeight / 2) - + (((i - 1) * itemHeight) + this.legendOffset), - (toCenterX + this.x + iconWidth) - 2, toCenterY - + this.y + (iconHeight / 2) - + ((i - 1) * itemHeight) + this.legendOffset); - } - } - } - - public FillStyle getBackground() { - return this.background; - } - - public LineStyle getBorder() { - return this.border; - } - - public AbstractChartColor getChartColor() { - return this.color; - } - - public AbstractChartFont getChartFont() { - return this.font; - } - - public List<Object> getItems() { - return this.items; - } - - public String getLegendLabel() { - return this.legendLabel; - } - - public int getLegendMargin() { - return this.legendMargin; - } - - public int getLegendOffset() { - return this.legendOffset; - } - - public List<String> getNames() { - return this.names; - } - - public String getTitle() { - return this.title; - } - - public boolean isVerticalLayout() { - return this.verticalLayout; - } - - public void setBackground(final FillStyle background) { - this.background = background; - } - - public void setBorder(final LineStyle border) { - this.border = border; - } - - public void setColor(final AbstractChartColor color) { - this.color = color; - } - - public void setFont(final AbstractChartFont font) { - this.font = font; - } - - public void setLegendLabel(final String legendLabel) { - this.legendLabel = legendLabel; - } - - public void setLegendMargin(final int legendMargin) { - this.legendMargin = legendMargin; - } - - public void setLegendOffset(final int legendOffset) { - this.legendOffset = legendOffset; - } - - public void setTitle(final String title) { - this.title = title; - } - - public void setVerticalLayout(final boolean verticalLayout) { - this.verticalLayout = verticalLayout; - } -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/legend/package-info.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/legend/package-info.java deleted file mode 100644 index 4ad1e1856..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/legend/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.legend; \ No newline at end of file diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/listener/ISpiderChartListener.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/listener/ISpiderChartListener.java deleted file mode 100644 index d931a5715..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/listener/ISpiderChartListener.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.listener; - -import org.fortiss.tooling.spiderchart.SpiderChart; -import org.fortiss.tooling.spiderchart.gc.AbstractChartGraphics; - -public interface ISpiderChartListener { - - /** To be fired on clicking on chart canvas */ - public static final int EVENT_CHART_CLICKED = 6; - - /** To be fired on selecting data point */ - public static final int EVENT_ENTER_POINT = 2; - - /** To be fired on leaving data point */ - public static final int EVENT_LEAVE_POINT = 3; - - /** To be fired on clicking on data point */ - public static final int EVENT_POINT_CLICKED = 5; - - /** To be fired on tip shell update */ - public static final int EVENT_TIP_UPDATE = 4; - - /** */ - public abstract void onChartEvent(SpiderChart paramChart, int paramInt); - - /** */ - public abstract void onPaintUserExit(SpiderChart paramChart, - AbstractChartGraphics paramChartGraphics); -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/listener/SpiderChartAdapter.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/listener/SpiderChartAdapter.java deleted file mode 100644 index da985d961..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/listener/SpiderChartAdapter.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.listener; - -import org.fortiss.tooling.spiderchart.SpiderChart; -import org.fortiss.tooling.spiderchart.gc.AbstractChartGraphics; - -public class SpiderChartAdapter implements ISpiderChartListener { - - /** {@inheritDoc} */ - @Override - public void onChartEvent(final SpiderChart c, final int type) { - } - - /** {@inheritDoc} */ - @Override - public void onPaintUserExit(final SpiderChart c, - final AbstractChartGraphics g) { - } -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/listener/package-info.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/listener/package-info.java deleted file mode 100644 index aabaf8d64..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/listener/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.listener; \ No newline at end of file diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/package-info.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/package-info.java deleted file mode 100644 index 5118a6025..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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; \ No newline at end of file diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/plotter/AbstractPlotter.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/plotter/AbstractPlotter.java deleted file mode 100644 index 0d037013b..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/plotter/AbstractPlotter.java +++ /dev/null @@ -1,335 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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 java.util.ArrayList; -import java.util.List; - -import org.fortiss.tooling.spiderchart.SpiderChartComponent; -import org.fortiss.tooling.spiderchart.gc.AbstractChartGraphics; -import org.fortiss.tooling.spiderchart.gc.AbstractChartImage; -import org.fortiss.tooling.spiderchart.scale.SpiderChartScale; -import org.fortiss.tooling.spiderchart.sequence.DataSeq; -import org.fortiss.tooling.spiderchart.style.FillStyle; - -/** - * Base class used to create spider chart plotters - * - * @author AMIT KUMAR MONDAL - * - */ -public abstract class AbstractPlotter extends SpiderChartComponent { - - /** Spider Chart Background Image */ - private AbstractChartImage backgroundImage; - - /** */ - private FillStyle backgroundStyle = null; - - /** */ - private int depth = 0; - - /** */ - private List<DataSeq> seq = new ArrayList<>(); - - /** */ - private int visibleHeight = 0; - - /** */ - private int visibleWidth = 0; - - /** */ - private SpiderChartScale xScale; - - /** */ - private SpiderChartScale yScale; - - /** */ - public void addSeq(final DataSeq s) { - this.replaceSeq(-1, s); - } - - /** */ - 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; - } - } - } - } - - /** */ - 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; - } - } - } - } - - /** */ - protected SpiderChartScale getActiveXScale(final DataSeq s) { - final SpiderChartScale scale = this.xScale; - return scale; - } - - /** */ - protected SpiderChartScale getActiveYScale(final DataSeq s) { - final SpiderChartScale scale = this.yScale; - return scale; - } - - /** - * @return the backgroundImage - */ - public AbstractChartImage getBackgroundImage() { - return this.backgroundImage; - } - - /** - * @return the backgroundStyle - */ - public FillStyle getBackgroundStyle() { - return this.backgroundStyle; - } - - /** - * @return the depth - */ - public int getDepth() { - return this.depth; - } - - /** - * @return the seq - */ - public List<DataSeq> getSeq() { - return this.seq; - } - - /** */ - public DataSeq getSeq(final int p) { - return this.seq.get(p); - } - - /** */ - public int getSeqCount() { - return this.seq.size(); - } - - /** - * @return the visibleHeight - */ - public int getVisibleHeight() { - return this.visibleHeight; - } - - /** - * @return the visibleWidth - */ - public int getVisibleWidth() { - return this.visibleWidth; - } - - /** - * @return the xScale - */ - public SpiderChartScale getxScale() { - return this.xScale; - } - - /** - * @return the yScale - */ - public SpiderChartScale getyScale() { - return this.yScale; - } - - /** */ - public void plot(final AbstractChartGraphics g) { - for (int i = 0; i < this.seq.size(); i++) { - final DataSeq s = this.seq.get(i); - this.plot(g, s, i); - } - } - - /** */ - protected void plot(final AbstractChartGraphics g, final DataSeq s, - final int serieSec) { - } - - /** */ - public void plotBackground(final AbstractChartGraphics g, final int bw, - final int bh, final int offsetX, final int offsetY) { - if (this.backgroundStyle != null) { - this.backgroundStyle.draw(g, this.x, this.y, this.x + bw, this.y - + bh); - } - if (this.backgroundImage != null) { - final int w = this.backgroundImage.getWidth(); - final int h = this.backgroundImage.getHeight(); - if ((w > -1) && (h > -1)) { - int toCenterX = (bw - w) / 2; - if (toCenterX < 0) { - toCenterX = 0; - } - int toCenterY = (bh - h) / 2; - if (toCenterY < 0) { - toCenterY = 0; - } - g.drawImage(this.backgroundImage, toCenterX + this.x, this.y - + toCenterY); - } - } - } - - /** */ - public void replaceSeq(final int p, final DataSeq s) { - final SpiderChartScale tmpScaleX = this.getActiveXScale(s); - this.getActiveYScale(s); - if (p >= this.seq.size()) { - return; - } - if ((this.seq.size() > 3)) { - return; - } - if (p == -1) { - this.seq.add(s); - } else { - this.seq.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 < this.seq.size(); si++) { - final DataSeq ser = this.seq.get(si); - } - } - if (XValue >= tmpScaleX.getMax()) { - this.calculateMax(tmpScaleX, XValue); - } - if (XValue < tmpScaleX.getMin()) { - this.calculateMin(tmpScaleX, XValue); - } - if (!fixedLimits) { - if (YValue > this.yScale.getMax()) { - this.calculateMax(this.yScale, YValue); - } - if (YValue < this.yScale.getMin()) { - this.calculateMin(this.yScale, YValue); - } - } - } - } - } - } - - /** - * @param backgroundImage - * the backgroundImage to set - */ - public void setBackgroundImage(final AbstractChartImage backgroundImage) { - this.backgroundImage = backgroundImage; - } - - /** - * @param backgroundStyle - * the backgroundStyle to set - */ - public void setBackgroundStyle(final FillStyle backgroundStyle) { - this.backgroundStyle = backgroundStyle; - } - - /** - * @param depth - * the depth to set - */ - public void setDepth(final int depth) { - this.depth = depth; - } - - /** */ - public void setSeq(final int p, final DataSeq s) { - if (p < this.seq.size()) { - this.seq.set(p, s); - } - } - - /** - * @param seq - * the seq to set - */ - public void setSeq(final List<DataSeq> seq) { - this.seq = 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; - } -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/plotter/package-info.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/plotter/package-info.java deleted file mode 100644 index c0964802e..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/plotter/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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; \ No newline at end of file diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/plotter/spider/SpiderChartPlotter.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/plotter/spider/SpiderChartPlotter.java deleted file mode 100644 index 8aa4a9c9f..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/plotter/spider/SpiderChartPlotter.java +++ /dev/null @@ -1,715 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.spider; - -import static java.util.Objects.requireNonNull; -import static org.fortiss.tooling.spiderchart.gc.AbstractChartColor.BLACK; -import static org.fortiss.tooling.spiderchart.gc.AbstractChartFont.PLAIN; -import static org.fortiss.tooling.spiderchart.gc.AbstractGraphicsSupplier.getColor; -import static org.fortiss.tooling.spiderchart.gc.AbstractGraphicsSupplier.getFont; -import static org.fortiss.tooling.spiderchart.gc.Fonts.VERDANA; -import static org.fortiss.tooling.spiderchart.util.ChartUtil.enumConstants; - -import java.text.DecimalFormat; -import java.util.Arrays; - -import org.fortiss.tooling.spiderchart.builder.AxesConfigurer; -import org.fortiss.tooling.spiderchart.gc.AbstractChartColor; -import org.fortiss.tooling.spiderchart.gc.AbstractChartFont; -import org.fortiss.tooling.spiderchart.gc.AbstractChartGraphics; -import org.fortiss.tooling.spiderchart.gc.Polygon; -import org.fortiss.tooling.spiderchart.plotter.AbstractPlotter; -import org.fortiss.tooling.spiderchart.sequence.DataSeq; -import org.fortiss.tooling.spiderchart.sequence.LineDataSeq; -import org.fortiss.tooling.spiderchart.style.FillStyle; -import org.fortiss.tooling.spiderchart.style.LineStyle; - -/** - * Used to plot spider chart - * - * @author AMIT KUMAR MONDAL - */ -public final class SpiderChartPlotter extends AbstractPlotter { - - /** - * Spider Chart axes names - */ - private String[] axesFactors; - - /** - * Spider Chart Axes Factor Color - */ - private AbstractChartColor axisFactorColor = getColor(BLACK); - - /** - * Spider Chart Axis Factor Colors (in case you need to set different colors - * for different axes) - */ - private AbstractChartColor[] axisFactorColors; - - /** - * Spider Chart Axes Factor Text Font - */ - private AbstractChartFont axisFactorFont = getFont(VERDANA, PLAIN, 11); - - /** - * Spider Chart Polygon Area Background Style - */ - private FillStyle backStyle; - - /** - * Spider Chart Border Style - */ - private LineStyle border = new LineStyle(0.2F, getColor(BLACK), 1); - - /** - * Spider Chart Radius - */ - private double chartRadius = 0.9D; - - /** - * Spider Chart would be surrounded by an enclosing circle - */ - private boolean drawCircle = false; - - /** - * Spider Chart Font for Grid Label - */ - private AbstractChartFont gridFont; - - /** - * Spider Chart Font Color for Grid Label - */ - private AbstractChartColor gridFontColor = getColor(BLACK); - - /** - * Spider Chart Grid Style - */ - private LineStyle gridStyle; - - /** Mark Scales on Every Axis */ - private boolean markScalesOnEveryAxis = false; - - /** - * Spider Chart Scaling Factors (Maximum Values) - */ - private double[] maxScaleFactors; - - /** - * Spider Chart Scaling Factors (Minimum Values) - */ - private double[] minScaleFactors; - - /** */ - private AbstractChartColor[] pointColors = null; - - /** */ - private double[] pointColorScale = null; - - /** - * Spider Chart Scaling Divisions - */ - private int scalingDivisions = 5; - - /** - * Spider Chart Scaling Label Format - */ - private Object[] scalingLabelFormat; - - /** - * Constructor - */ - public SpiderChartPlotter() { - } - - /** - * @return the axesFactors - */ - public String[] getAxesFactors() { - return this.axesFactors; - } - - /** - * @return the axisFactorColor - */ - public AbstractChartColor getAxisFactorColor() { - return this.axisFactorColor; - } - - /** - * @return the axisFactorColors - */ - public AbstractChartColor[] getAxisFactorColors() { - return this.axisFactorColors; - } - - /** - * @return the axisFactorFont - */ - public AbstractChartFont getAxisFactorFont() { - return this.axisFactorFont; - } - - /** - * @return the backStyle - */ - public FillStyle getBackStyle() { - return this.backStyle; - } - - /** - * @return the border - */ - public LineStyle getBorder() { - return this.border; - } - - /** - * @return the chartRadius - */ - public double getChartRadius() { - return this.chartRadius; - } - - /** - * @return the gridFont - */ - public AbstractChartFont getGridFont() { - return this.gridFont; - } - - /** - * @return the gridFontColor - */ - public AbstractChartColor getGridFontColor() { - return this.gridFontColor; - } - - /** - * @return the gridStyle - */ - public LineStyle getGridStyle() { - return this.gridStyle; - } - - /** - * @return the maxScaleFactors - */ - public double[] getMaxScaleFactors() { - return this.maxScaleFactors; - } - - /** - * @return the minScaleFactors - */ - public double[] getMinScaleFactors() { - return this.minScaleFactors; - } - - /** - * @return the pointColors - */ - public AbstractChartColor[] getPointColors() { - return this.pointColors; - } - - /** - * @return the pointColorScale - */ - public double[] getPointColorScale() { - return this.pointColorScale; - } - - /** - * @return the scalingDivisions - */ - public int getScalingDivisions() { - return this.scalingDivisions; - } - - /** - * @return the scalingLabelFormat - */ - public Object[] getScalingLabelFormat() { - return this.scalingLabelFormat; - } - - /** - * @return the drawCircle - */ - public boolean isDrawCircle() { - return this.drawCircle; - } - - /** - * @return the markScalesOnEveryAxis - */ - public boolean isMarkScalesOnEveryAxis() { - return this.markScalesOnEveryAxis; - } - - /** {@inheritDoc} **/ - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - protected void plot(final AbstractChartGraphics g, final DataSeq s, - final int seqSec) { - LineDataSeq p = null; - if (s instanceof LineDataSeq) { - p = (LineDataSeq) s; - } - s.getHotAreas().clear(); - - final double count = p.getyData().size(); - - final int[] xs = new int[(int) count]; - final int[] ys = new int[(int) count]; - - int radi = 0; - radi = this.width; - if (this.height < radi) { - radi = this.height; - } - radi = (int) (radi * this.chartRadius); - - final int toCenterX = (this.width - radi) / 2; - final int toCenterY = (this.height - radi) / 2; - - final int PieCenterX = toCenterX + this.x + (radi / 2); - final int PieCenterY = toCenterY + this.y + (radi / 2); - double angle; - if ((seqSec == 0) || (seqSec >= (this.getSeq().size() - 1))) { - if ((seqSec == 0) && (this.backStyle != null) && this.drawCircle) { - this.backStyle.drawArc(g, toCenterX + this.x, toCenterY - + this.y, radi, radi, 0, 360); - } - if ((seqSec == 0) && (this.backStyle != null) && !this.drawCircle) { - for (int i = 0; i < count; i++) { - angle = (360.0D / count) * i; - - angle += 90.0D; - if (angle > 360.0D) { - angle -= 360.0D; - } - final double radian = 0.01745277777777778D * angle; - final double Sin = Math.sin(radian); - final double Cos = Math.cos(radian); - int relativeY = (int) (Sin * (radi / 2)); - final int relativeX = (int) (Cos * (radi / 2)); - relativeY *= -1; - - xs[i] = PieCenterX + relativeX; - ys[i] = PieCenterY + relativeY; - } - this.backStyle.drawPolygon(g, xs, ys, (int) count); - } - if ((seqSec == (this.getSeq().size() - 1)) && (this.border != null)) { - if (this.drawCircle) { - this.border.drawArc(g, toCenterX + this.x, toCenterY - + this.y, radi, radi, 0, 360); - } - for (int i = 0; i < count; i++) { - angle = (360.0D / count) * i; - - angle += 90.0D; - if (angle > 360.0D) { - angle -= 360.0D; - } - final double radian = 0.01745277777777778D * angle; - final double Sin = Math.sin(radian); - final double Cos = Math.cos(radian); - int relativeY = (int) (Sin * (radi / 2)); - final int relativeX = (int) (Cos * (radi / 2)); - relativeY *= -1; - - this.border.draw(g, PieCenterX, PieCenterY, PieCenterX - + relativeX, PieCenterY + relativeY); - } - } - if ((seqSec == 0) && (this.axisFactorFont != null)) { - g.setFont(this.axisFactorFont); - for (int i = 0; i < count; i++) { - g.setColor(this.axisFactorColor); - if ((this.axisFactorColors != null) - && (this.axisFactorColors.length > i)) { - g.setColor(this.axisFactorColors[i]); - } - angle = (360.0D / count) * i; - - angle += 90.0D; - if (angle > 360.0D) { - angle -= 360.0D; - } - final int tmpradi = (int) ((radi * 1.1D) / 2.0D); - int correction = 0; - if ((angle > 120.0D) && (angle < 240.0D)) { - correction = g.getFontWidth(this.axesFactors[i]); - } - final double radian = 0.01745277777777778D * angle; - final double sin = Math.sin(radian); - final double cos = Math.cos(radian); - int relativeY = (int) (sin * tmpradi); - final int relativeX = (int) (cos * tmpradi); - relativeY *= -1; - if (this.axesFactors.length > i) { - g.drawText(this.axesFactors[i], - (PieCenterX + relativeX) - correction, - PieCenterY + relativeY); - } - } - } - } - for (int i = 0; i < count; i++) { - angle = (360.0D / count) * i; - - angle += 90.0D; - if (angle > 360.0D) { - angle -= 360.0D; - } - int tmpradi = 0; - - double min = 0.0D; - double max = 100.0D; - if (this.minScaleFactors.length >= (i + 1)) { - min = this.minScaleFactors[i]; - } - if (this.maxScaleFactors.length >= (i + 1)) { - max = this.maxScaleFactors[i]; - } - tmpradi = (int) (((((Double) p.getElementY(i)).doubleValue() - min) * 100.0D) / (max - min)); - tmpradi = (tmpradi * radi) / 100; - - final double radian = 0.01745277777777778D * angle; - final double Sin = Math.sin(radian); - final double Cos = Math.cos(radian); - int relativeY = (int) (Sin * (tmpradi / 2)); - final int relativeX = (int) (Cos * (tmpradi / 2)); - relativeY *= -1; - xs[i] = PieCenterX + relativeX; - ys[i] = PieCenterY + relativeY; - } - if (p.getStyle() != null) { - p.getStyle().drawPolygon(g, xs, ys, (int) count); - } - if (p.getFillStyle() != null) { - p.getFillStyle().drawPolygon(g, xs, ys, (int) count); - } - int kl = 0; - for (int i = 0; i < count; i++) { - final Polygon po = new Polygon(); - po.addPoint(xs[i] - 3, ys[i] - 3); - po.addPoint(xs[i] - 3, ys[i] + 3); - po.addPoint(xs[i] + 3, ys[i] + 3); - po.addPoint(xs[i] + 3, ys[i] - 3); - s.getHotAreas().add(po); - double YValue; - if (p.isDrawPoint()) { - AbstractChartColor c = p.getPointColor(); - YValue = ((Double) p.getElementY(i)).doubleValue(); - if ((this.pointColors != null) - && (this.pointColorScale != null)) { - if (this.pointColors.length > 0) { - c = this.pointColors[0]; - } - for (int j = 1; j < this.pointColors.length; j++) { - if (this.pointColorScale.length >= j) { - if (this.pointColorScale[j - 1] > YValue) { - break; - } - c = this.pointColors[j]; - } - } - } - g.setColor(c); - if (p.getIcon() == null) { - g.fillRect(xs[i] - 3, ys[i] - 3, 6, 6); - } else { - g.drawImage(p.getIcon(), xs[i] - 4, ys[i] - 4); - } - } - if (p.getValueFont() != null) { - g.setColor(p.getValueColor()); - g.setFont(p.getValueFont()); - - YValue = ((Double) p.getElementY(i)).doubleValue(); - - String txt = p.doubleToString(new Double(YValue)); - - if (YValue == (int) YValue) { - txt = new Integer((int) YValue).toString(); - } - if (p.getLabelTemplate().length() > 0) { - txt = p.getLabelTemplate(); - } - if ((p.getDataLabels() != null) - && (p.getDataLabels().length > i)) { - txt = p.getDataLabels()[i]; - } - g.drawText(txt, xs[i] + 7, ys[i]); - } - } - if (this.gridStyle != null) { - final double maxValues[] = new double[xs.length]; - final double minValues[] = new double[20]; - if (this.minScaleFactors.length >= 1) { - for (int j = 0; j < xs.length; j++) { - minValues[j] = this.minScaleFactors[j]; - } - } - if (this.maxScaleFactors.length >= 1) { - for (int j = 0; j < xs.length; j++) { - maxValues[j] = this.maxScaleFactors[j]; - } - } - final int tickInterval = 100 / this.scalingDivisions; - final double[] tickIntervalAbsValues = new double[xs.length]; - - for (int j = 0; j < xs.length; j++) { - tickIntervalAbsValues[j] = (maxValues[j] - minValues[j]) - / this.scalingDivisions; - } - - int tickAt = 0; - final double[] tickAtAbsValues = new double[xs.length]; - for (int j = 0; j < this.scalingDivisions; j++) { - tickAt += tickInterval; - for (int k = 0; k < xs.length; k++) { - tickAtAbsValues[k] += tickIntervalAbsValues[k]; - } - for (int i = 0; i < count; i++) { - angle = (360.0D / count) * i; - - angle += 90.0D; - if (angle > 360.0D) { - angle -= 360.0D; - } - final int tmpradi = (radi * tickAt) / 100; - final double radian = 0.01745277777777778D * angle; - final double Sin = Math.sin(radian); - final double Cos = Math.cos(radian); - int relativeY = (int) (Sin * (tmpradi / 2)); - final int relativeX = (int) (Cos * (tmpradi / 2)); - relativeY *= -1; - - xs[i] = PieCenterX + relativeX; - ys[i] = PieCenterY + relativeY; - } - if (seqSec >= (this.getSeq().size() - 1)) { - this.gridStyle.drawPolygon(g, xs, ys, (int) count); - } - if ((seqSec >= (this.getSeq().size() - 1)) - && (this.gridFont != null)) { - g.setColor(this.gridFontColor); - g.setFont(this.gridFont); - - final double[] tickValues = new double[xs.length]; - final String[] values = new String[xs.length]; - - for (int i = 0; i < tickValues.length; i++) { - tickValues[i] = tickAtAbsValues[i]; - values[i] = "" + tickValues[i]; - - if (this.scalingLabelFormat.length > 0) { - final Object scalingLabel = this.scalingLabelFormat[i]; - DecimalFormat df = null; - if (scalingLabel instanceof String) { - df = new DecimalFormat( - (String) this.scalingLabelFormat[i]); - values[i] = df - .format(new Double(tickValues[i])); - } - if (scalingLabel instanceof Class<?>) { - if (((Class<?>) scalingLabel).isEnum()) { - try { - values[i] = (String) enumConstants( - (Class<Enum>) scalingLabel) - .get(kl++); - } catch (final Exception e) { - } - } - } - } - } - - if (this.markScalesOnEveryAxis) { - for (int k = 0; k < xs.length; k++) { - g.drawText("" + values[k], - xs[k] - 3 - g.getFontWidth("" + values[k]), - ys[k]); - } - } else { - g.drawText("" + values[0], - xs[0] - 3 - g.getFontWidth("" + values[0]), - ys[0]); - } - - } - } - } - } - - /** - * @param axesFactors - * the axesFactors to set - */ - public void setAxesFactors(final String[] axesFactors) { - this.axesFactors = axesFactors; - } - - /** - * @param axisFactorColor - * the axisFactorColor to set - */ - public void setAxisFactorColor(final AbstractChartColor axisFactorColor) { - this.axisFactorColor = axisFactorColor; - } - - /** - * @param axisFactorColors - * the axisFactorColors to set - */ - public void setAxisFactorColors(final AbstractChartColor[] axisFactorColors) { - this.axisFactorColors = axisFactorColors; - } - - /** - * @param axisFactorFont - * the axisFactorFont to set - */ - public void setAxisFactorFont(final AbstractChartFont axisFactorFont) { - this.axisFactorFont = axisFactorFont; - } - - /** - * @param backStyle - * the backStyle to set - */ - public void setBackStyle(final FillStyle backStyle) { - this.backStyle = backStyle; - } - - /** - * @param border - * the border to set - */ - public void setBorder(final LineStyle border) { - this.border = border; - } - - /** - * @param chartRadius - * the chartRadius to set - */ - public void setChartRadius(final double chartRadius) { - this.chartRadius = chartRadius; - } - - /** - * @param drawCircle - * the drawCircle to set - */ - public void setDrawCircle(final boolean drawCircle) { - this.drawCircle = drawCircle; - } - - /** - * @param gridFont - * the gridFont to set - */ - public void setGridFont(final AbstractChartFont gridFont) { - this.gridFont = gridFont; - } - - /** - * @param gridFontColor - * the gridFontColor to set - */ - public void setGridFontColor(final AbstractChartColor gridFontColor) { - this.gridFontColor = gridFontColor; - } - - /** - * @param gridStyle - * the gridStyle to set - */ - public void setGridStyle(final LineStyle gridStyle) { - this.gridStyle = gridStyle; - } - - /** - * @param markScalesOnEveryAxis - * the markScalesOnEveryAxis to set - */ - public void setMarkScalesOnEveryAxis(final boolean markScalesOnEveryAxis) { - this.markScalesOnEveryAxis = markScalesOnEveryAxis; - } - - /** - * @param maxScaleFactors - * the maxScaleFactors to set - */ - public void setMaxScaleFactors(final double[] maxScaleFactors) { - this.maxScaleFactors = maxScaleFactors; - } - - /** - * @param minScaleFactors - * the minScaleFactors to set - */ - public void setMinScaleFactors(final double[] minScaleFactors) { - this.minScaleFactors = minScaleFactors; - } - - /** - * @param pointColors - * the pointColors to set - */ - public void setPointColors(final AbstractChartColor[] pointColors) { - this.pointColors = pointColors; - } - - /** - * @param pointColorScale - * the pointColorScale to set - */ - public void setPointColorScale(final double[] pointColorScale) { - this.pointColorScale = pointColorScale; - } - - /** - * @param scalingDivisions - * the scalingDivisions to set - */ - public void setScalingDivisions(final int scalingDivisions) { - this.scalingDivisions = scalingDivisions; - } - - /** - * @param scalingLabelFormat - * the scalingLabelFormat to set - */ - public void setScalingLabelFormat(final Object... scalingLabelFormat) { - this.scalingLabelFormat = Arrays.asList(scalingLabelFormat).toArray(); - } - - /** */ - public void use(final AxesConfigurer configurer) { - requireNonNull(configurer); - this.maxScaleFactors = configurer.maxScales(); - this.minScaleFactors = configurer.minScales(); - this.axesFactors = configurer.axesNames(); - this.scalingLabelFormat = configurer.axesScalingLabelFormats(); - } -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/plotter/spider/package-info.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/plotter/spider/package-info.java deleted file mode 100644 index 29eb3e428..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/plotter/spider/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.spider; \ No newline at end of file diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/scale/SpiderChartScale.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/scale/SpiderChartScale.java deleted file mode 100644 index 702796a4d..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/scale/SpiderChartScale.java +++ /dev/null @@ -1,169 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.scale; - -public final class SpiderChartScale { - - /** */ - private boolean exactMaxValue = false; - /** */ - private boolean exactMinValue = false; - /** */ - private double max = -99999.0D; - /** */ - private double min = 99999.0D; - /** */ - private double[] preferred_MaxMin_values = { -1000000.0D, -500000.0D, - -100000.0D, -50000.0D, -10000.0D, -5000.0D, -1000.0D, -500.0D, - -250.0D, -100.0D, -50.0D, -35.0D, -5.0D, -1.0D, -0.5D, -0.1D, 0.0D, - 0.1D, 0.5D, 1.0D, 5.0D, 10.0D, 25.0D, 50.0D, 100.0D, 250.0D, - 500.0D, 1000.0D, 5000.0D, 10000.0D, 50000.0D, 100000.0D, 500000.0D, - 1000000.0D }; - /** */ - private int screenMax; - /** */ - private int screenMaxMargin; - /** */ - private int screenMin; - - /** Constructor */ - public SpiderChartScale(final int max, final int min) { - this.max = max; - this.min = min; - } - - /** - * @return the max - */ - public double getMax() { - return this.max; - } - - /** - * @return the min - */ - public double getMin() { - return this.min; - } - - /** - * @return the preferred_MaxMin_values - */ - public double[] getPreferred_MaxMin_values() { - return this.preferred_MaxMin_values; - } - - /** - * @return the screenMax - */ - public int getScreenMax() { - return this.screenMax; - } - - /** - * @return the screenMaxMargin - */ - public int getScreenMaxMargin() { - return this.screenMaxMargin; - } - - /** - * @return the screenMin - */ - public int getScreenMin() { - return this.screenMin; - } - - /** - * @return the exactMaxValue - */ - public boolean isExactMaxValue() { - return this.exactMaxValue; - } - - /** - * @return the exactMinValue - */ - public boolean isExactMinValue() { - return this.exactMinValue; - } - - /** - * @param exactMaxValue - * the exactMaxValue to set - */ - public void setExactMaxValue(final boolean exactMaxValue) { - this.exactMaxValue = exactMaxValue; - } - - /** - * @param exactMinValue - * the exactMinValue to set - */ - public void setExactMinValue(final boolean exactMinValue) { - this.exactMinValue = exactMinValue; - } - - /** - * @param max - * the max to set - */ - public void setMax(final double max) { - this.max = max; - } - - /** - * @param min - * the min to set - */ - public void setMin(final double min) { - this.min = min; - } - - /** - * @param preferred_MaxMin_values - * the preferred_MaxMin_values to set - */ - public void setPreferred_MaxMin_values( - final double[] preferred_MaxMin_values) { - this.preferred_MaxMin_values = preferred_MaxMin_values; - } - - /** - * @param screenMax - * the screenMax to set - */ - public void setScreenMax(final int screenMax) { - this.screenMax = screenMax; - } - - /** - * @param screenMaxMargin - * the screenMaxMargin to set - */ - public void setScreenMaxMargin(final int screenMaxMargin) { - this.screenMaxMargin = screenMaxMargin; - } - - /** - * @param screenMin - * the screenMin to set - */ - public void setScreenMin(final int screenMin) { - this.screenMin = screenMin; - } - -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/scale/package-info.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/scale/package-info.java deleted file mode 100644 index a8f67df54..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/scale/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.scale; \ No newline at end of file diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/sequence/DataSeq.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/sequence/DataSeq.java deleted file mode 100644 index 29aa32e8b..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/sequence/DataSeq.java +++ /dev/null @@ -1,205 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.sequence; - -import static java.text.NumberFormat.getNumberInstance; - -import java.text.DecimalFormat; -import java.text.NumberFormat; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; - -import org.fortiss.tooling.spiderchart.SpiderChart; - -public class DataSeq { - - /** */ - private String[] dataLabels; - /** */ - private List<Object> hotAreas = new ArrayList<>(); - /** */ - private String labelTemplate = ""; - /** */ - private String name = ""; - /** */ - private String[] tips = new String[0]; - /** */ - private String valueFormat = "######.##"; - /** */ - private List<Double> xData = new ArrayList<>(); - /** */ - private List<Double> yData = new ArrayList<>(); - - /** - * Constructor - */ - public DataSeq() { - } - - /** Constructor */ - public DataSeq(final double[] y) { - if (y == null) { - return; - } - for (int i = 0; i < y.length; i++) { - this.addData(new Double(i), new Double(y[i])); - } - } - - /** Constructor */ - public DataSeq(final double[] x, final double[] y) { - for (int i = 0; i < x.length; i++) { - this.addData(new Double(x[i]), new Double(y[i])); - } - } - - /** Constructor */ - public DataSeq(final double[] y, final int startingXValue) { - for (int i = 0; i < y.length; i++) { - this.addData(new Double(startingXValue + i), new Double(y[i])); - } - } - - /** Constructor */ - public DataSeq(final Double[] y) { - if (y == null) { - return; - } - for (int i = 0; i < y.length; i++) { - this.addData(new Double(i), y[i]); - } - } - - /** Constructor */ - public DataSeq(final Double[] x, final Double[] y) { - for (int i = 0; i < x.length; i++) { - this.addData(x[i], y[i]); - } - } - - /** Constructor */ - public DataSeq(final Double[] y, final int startingXValue) { - for (int i = 0; i < y.length; i++) { - this.addData(new Double(startingXValue + i), y[i]); - } - } - - /** Constructor */ - public void addData(final Object x, final Object y) { - this.xData.add((Double) x); - this.yData.add((Double) y); - } - - /** */ - public String doubleToString(final Double d) { - if (this.valueFormat.compareTo("") == 0) { - return d.toString(); - } - DecimalFormat df = null; - if (SpiderChart.getNumberLocale() == null) { - df = new DecimalFormat(this.valueFormat); - } else { - final NumberFormat nf = getNumberInstance(new Locale( - SpiderChart.getNumberLocale(), "")); - df = (DecimalFormat) nf; - - df.applyPattern(this.valueFormat); - } - df = new DecimalFormat(this.valueFormat); - return df.format(d.doubleValue()); - } - - public String[] getDataLabels() { - return this.dataLabels; - } - - /** */ - public Object getElementX(final int i) { - return this.xData.get(i); - } - - /** */ - public Object getElementY(final int i) { - return this.yData.get(i); - } - - public List<Object> getHotAreas() { - return this.hotAreas; - } - - public String getLabelTemplate() { - return this.labelTemplate; - } - - public String getName() { - return this.name; - } - - /** */ - public int getSize() { - return this.xData.size(); - } - - public String[] getTips() { - return this.tips; - } - - public String getValueFormat() { - return this.valueFormat; - } - - public List<Double> getxData() { - return this.xData; - } - - public List<Double> getyData() { - return this.yData; - } - - public void setDataLabels(final String[] dataLabels) { - this.dataLabels = dataLabels; - } - - public void setHotAreas(final List<Object> hotAreas) { - this.hotAreas = hotAreas; - } - - public void setLabelTemplate(final String labelTemplate) { - this.labelTemplate = labelTemplate; - } - - public void setName(final String name) { - this.name = name; - } - - public void setTips(final String[] tips) { - this.tips = tips; - } - - public void setValueFormat(final String valueFormat) { - this.valueFormat = valueFormat; - } - - public void setxData(final List<Double> xData) { - this.xData = xData; - } - - public void setyData(final List<Double> yData) { - this.yData = yData; - } - -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/sequence/LineDataSeq.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/sequence/LineDataSeq.java deleted file mode 100644 index 620091d16..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/sequence/LineDataSeq.java +++ /dev/null @@ -1,243 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.sequence; - -import static org.fortiss.tooling.spiderchart.api.annotations.processor.SpiderChartAnnotationProcessor.getAreaColor; -import static org.fortiss.tooling.spiderchart.gc.AbstractChartColor.BLACK; -import static org.fortiss.tooling.spiderchart.gc.AbstractChartFont.BOLD; -import static org.fortiss.tooling.spiderchart.gc.AbstractGraphicsSupplier.getColor; -import static org.fortiss.tooling.spiderchart.gc.AbstractGraphicsSupplier.getFont; -import static org.fortiss.tooling.spiderchart.gc.Fonts.VERDANA; -import static org.fortiss.tooling.spiderchart.style.LineStyle.NORMAL_LINE; -import static org.fortiss.tooling.spiderchart.util.ChartUtil.wrapValues; - -import org.fortiss.tooling.spiderchart.gc.AbstractChartColor; -import org.fortiss.tooling.spiderchart.gc.AbstractChartFont; -import org.fortiss.tooling.spiderchart.gc.AbstractChartImage; -import org.fortiss.tooling.spiderchart.style.FillStyle; -import org.fortiss.tooling.spiderchart.style.LineStyle; - -public final class LineDataSeq extends DataSeq { - - /** */ - private static final int STARTING_X_VALUE = 0; - - /** - * Static Factory to create instance of {@link LineDataSeq} - */ - public static LineDataSeq of(final LineStyle style, final double... values) { - return new LineDataSeq(values, style); - } - - /** - * Static Factory to create instance of {@link LineDataSeq} - */ - public static <E extends Enum<E>> LineDataSeq of( - final Object oldObjectToCopyData, final Object... values) { - final double[] wrappedValues = wrapValues(values); - final LineDataSeq seq = new LineDataSeq(wrappedValues, new LineStyle(2, - getColor(getAreaColor(oldObjectToCopyData)), NORMAL_LINE)); - seq.valueFont = getFont(VERDANA, BOLD, 12); - seq.fillStyle = new FillStyle( - getColor(getAreaColor(oldObjectToCopyData)), 0.5f); - seq.drawPoint = true; - return seq; - } - - /** */ - private boolean drawPoint = false; - /** */ - private FillStyle fillStyle = null; - /** */ - private AbstractChartImage icon = null; - /** */ - private int lineType = 0; - /** */ - private AbstractChartColor pointColor = getColor(BLACK); - /** */ - private LineStyle style = null; - /** */ - private AbstractChartColor valueColor = getColor(BLACK); - /** */ - private AbstractChartFont valueFont = null; - - /** */ - private LineStyle vstyle = null; - - /** Constructor */ - public LineDataSeq(final double[] x, final double[] y, final LineStyle s) { - super(x, y); - this.style = s; - } - - /** Constructor */ - public LineDataSeq(final double[] y, final LineStyle s) { - super(y, STARTING_X_VALUE); - this.style = s; - } - - /** Constructor */ - public LineDataSeq(final Double[] x, final Double[] y, final LineStyle s) { - super(x, y); - this.style = s; - } - - /** Constructor */ - public LineDataSeq(final Double[] y, final LineStyle s) { - super(y, STARTING_X_VALUE); - this.style = s; - } - - /** Constructor */ - public LineDataSeq(final LineStyle s) { - this.style = s; - } - - /** - * @return the fillStyle - */ - public FillStyle getFillStyle() { - return this.fillStyle; - } - - /** - * @return the icon - */ - public AbstractChartImage getIcon() { - return this.icon; - } - - /** - * @return the lineType - */ - public int getLineType() { - return this.lineType; - } - - /** - * @return the pointColor - */ - public AbstractChartColor getPointColor() { - return this.pointColor; - } - - /** - * @return the style - */ - public LineStyle getStyle() { - return this.style; - } - - /** - * @return the valueColor - */ - public AbstractChartColor getValueColor() { - return this.valueColor; - } - - /** - * @return the valueFont - */ - public AbstractChartFont getValueFont() { - return this.valueFont; - } - - /** - * @return the vstyle - */ - public LineStyle getVstyle() { - return this.vstyle; - } - - /** - * @return the drawPoint - */ - public boolean isDrawPoint() { - return this.drawPoint; - } - - /** - * @param drawPoint - * the drawPoint to set - */ - public void setDrawPoint(final boolean drawPoint) { - this.drawPoint = drawPoint; - } - - /** - * @param fillStyle - * the fillStyle to set - */ - public void setFillStyle(final FillStyle fillStyle) { - this.fillStyle = fillStyle; - } - - /** - * @param icon - * the icon to set - */ - public void setIcon(final AbstractChartImage icon) { - this.icon = icon; - } - - /** - * @param lineType - * the lineType to set - */ - public void setLineType(final int lineType) { - this.lineType = lineType; - } - - /** - * @param pointColor - * the pointColor to set - */ - public void setPointColor(final AbstractChartColor pointColor) { - this.pointColor = pointColor; - } - - /** - * @param style - * the style to set - */ - public void setStyle(final LineStyle style) { - this.style = style; - } - - /** - * @param valueColor - * the valueColor to set - */ - public void setValueColor(final AbstractChartColor valueColor) { - this.valueColor = valueColor; - } - - /** - * @param valueFont - * the valueFont to set - */ - public void setValueFont(final AbstractChartFont valueFont) { - this.valueFont = valueFont; - } - - /** - * @param vstyle - * the vstyle to set - */ - public void setVstyle(final LineStyle vstyle) { - this.vstyle = vstyle; - } -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/sequence/package-info.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/sequence/package-info.java deleted file mode 100644 index 51e2a814b..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/sequence/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.sequence; \ No newline at end of file diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/style/FillStyle.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/style/FillStyle.java deleted file mode 100644 index bc3ebfd00..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/style/FillStyle.java +++ /dev/null @@ -1,194 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.style; - -import static org.fortiss.tooling.spiderchart.gc.AbstractChartColor.AZURE; -import static org.fortiss.tooling.spiderchart.gc.AbstractChartColor.WHITE; -import static org.fortiss.tooling.spiderchart.gc.AbstractGraphicsSupplier.getColor; - -import org.fortiss.tooling.spiderchart.gc.AbstractChartColor; -import org.fortiss.tooling.spiderchart.gc.AbstractChartGraphics; -import org.fortiss.tooling.spiderchart.gc.AbstractChartImage; - -public final class FillStyle { - - /** */ - public static final int GRADIENT_HORIZONTAL = 1; - /** */ - public static final int GRADIENT_VERTICAL = 2; - /** */ - public static final int NO_GRADIENT = 0; - /** */ - private float alphaValue = 1.0F; - /** */ - private final AbstractChartColor color; - /** Spider Chart Canvas Background Color */ - private AbstractChartColor colorFrom = getColor(AZURE); - /** */ - private final AbstractChartColor colorUntil = getColor(WHITE); - /** */ - private Object composite = null; - /** */ - private final boolean gradientCyclic = false; - /** */ - private int gradientType = NO_GRADIENT; - /** */ - private AbstractChartImage textureImage = null; - - /** Constructor */ - public FillStyle(final AbstractChartColor c) { - this.color = c; - } - - /** Constructor */ - public FillStyle(final AbstractChartColor c, final float f) { - this.color = c; - this.alphaValue = f; - } - - /** Constructor */ - public FillStyle(final AbstractChartImage i) { - this.textureImage = i; - this.color = getColor(WHITE); - } - - /** */ - public void draw(final AbstractChartGraphics g, int x1, int y1, int x2, - int y2) { - if (x1 > x2) { - final int xtmp = x2; - x2 = x1; - x1 = xtmp; - } - if (y1 > y2) { - final int ytmp = y2; - y2 = y1; - y1 = ytmp; - } - g.setTexture(this.textureImage); - g.setColor(this.color); - if (this.gradientType != NO_GRADIENT) { - g.createFadeArea(this.colorFrom, this.colorUntil, x1, y1, x2 - x1, - y2 - y1, this.gradientType == GRADIENT_VERTICAL, - this.gradientCyclic); - } else { - this.setAlpha(g); - g.fillRect(x1, y1, x2 - x1, y2 - y1); - this.resetAlpha(g); - } - } - - /** */ - public void draw(final AbstractChartGraphics g, - final String backgroundCanvasColor, int x1, int y1, int x2, int y2) { - if (x1 > x2) { - final int xtmp = x2; - x2 = x1; - x1 = xtmp; - } - if (y1 > y2) { - final int ytmp = y2; - y2 = y1; - y1 = ytmp; - } - g.setTexture(this.textureImage); - g.setColor(this.color); - if (this.gradientType != NO_GRADIENT) { - this.colorFrom = getColor(backgroundCanvasColor); - g.createFadeArea(this.colorFrom, this.colorUntil, x1, y1, x2 - x1, - y2 - y1, this.gradientType == GRADIENT_VERTICAL, - this.gradientCyclic); - } else { - this.setAlpha(g); - g.fillRect(x1, y1, x2 - x1, y2 - y1); - this.resetAlpha(g); - } - } - - /** */ - public void drawArc(final AbstractChartGraphics g, final int x, - final int y, final int w, final int h, final int a1, final int a2) { - g.setTexture(this.textureImage); - g.setColor(this.color); - this.setAlpha(g); - g.fillArc(x, y, w, h, a1, a2); - this.resetAlpha(g); - } - - /** */ - public void drawPolygon(final AbstractChartGraphics g, final int[] x1, - final int[] y1, final int num) { - g.setTexture(this.textureImage); - g.setColor(this.color); - this.setAlpha(g); - g.fillPolygon(x1, y1, num); - this.resetAlpha(g); - } - - /** */ - public void drawRoundRect(final AbstractChartGraphics g, final int x1, - final int y1, final int x2, final int y2) { - g.setTexture(this.textureImage); - g.setColor(this.color); - this.setAlpha(g); - g.fillRoundRect(x1, y1, x2 - x1, y2 - y1); - this.resetAlpha(g); - } - - /** - * @return the gradientType - */ - public int getGradientType() { - return this.gradientType; - } - - /** */ - private void resetAlpha(final AbstractChartGraphics g) { - if (this.composite != null) { - g.setAlphaComposite(this.composite); - } - this.composite = null; - } - - /** */ - private void setAlpha(final AbstractChartGraphics g) { - if (this.alphaValue != 1.0F) { - this.composite = g.getAlphaComposite(); - g.setAlpha(this.alphaValue); - } - } - - /** - * @param gradientType - * the gradientType to set - */ - public void setGradientType(final int gradientType) { - this.gradientType = gradientType; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - if (this.gradientType != NO_GRADIENT) { - return this.colorFrom.getRGBString() + ";" - + this.colorUntil.getRGBString(); - } - if (this.alphaValue != 1.0F) { - return this.color.getRGBString() + "|" + this.alphaValue; - } - return this.color.getRGBString(); - } -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/style/LineStyle.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/style/LineStyle.java deleted file mode 100644 index 53c62d0c9..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/style/LineStyle.java +++ /dev/null @@ -1,225 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.style; - -import static org.fortiss.tooling.spiderchart.gc.AbstractChartGraphics.STROKE_DASHED; -import static org.fortiss.tooling.spiderchart.gc.AbstractChartGraphics.STROKE_DOTTED; -import static org.fortiss.tooling.spiderchart.gc.AbstractChartGraphics.STROKE_NORMAL; - -import org.fortiss.tooling.spiderchart.gc.AbstractChartColor; -import org.fortiss.tooling.spiderchart.gc.AbstractChartGraphics; - -public final class LineStyle { - - /** */ - public static final int DASHED_LINE = 2; - /** */ - public static final int DOTS_LINE = 3; - /** */ - public static final int NORMAL_LINE = 1; - - /** */ - public static LineStyle of(final float w, final AbstractChartColor c, - final int t) { - return new LineStyle(w, c, t); - } - - /** */ - private float alphaValue = 1.0F; - /** */ - private AbstractChartColor color; - - /** */ - private int lineType; - - /** */ - private float lineWidth; - - /** */ - public LineStyle(final float w, final AbstractChartColor c, final int t) { - this.lineType = t; - this.lineWidth = w; - this.color = c; - } - - /** */ - public LineStyle(final float w, final AbstractChartColor c, final int t, - final float alpha) { - this(w, c, t); - } - - /** */ - public void draw(final AbstractChartGraphics g, final int x1, final int y1, - final int x2, final int y2) { - this.setGraphicsProperties(g); - g.drawLineWithStyle(x1, y1, x2, y2); - } - - /** */ - public void drawArc(final AbstractChartGraphics g, final int x, - final int y, final int w, final int h, final int a1, final int a2) { - this.setGraphicsProperties(g); - - g.drawArc(x, y, w, h, a1, a2); - } - - /** */ - public void drawOpenPolygon(final AbstractChartGraphics g, final int[] x, - final int[] y, final int c) { - for (int i = 1; i < c; i++) { - this.draw(g, x[i - 1], y[i - 1], x[i], y[i]); - } - } - - /** */ - public void drawPolygon(final AbstractChartGraphics g, final int[] x, - final int[] y, final int c) { - for (int i = 1; i < c; i++) { - this.draw(g, x[i - 1], y[i - 1], x[i], y[i]); - } - this.draw(g, x[0], y[0], x[c - 1], y[c - 1]); - } - - /** */ - public void drawRect(final AbstractChartGraphics g, final int x1, - final int y1, final int x2, final int y2) { - int iX = x1; - int iY = y1; - int w = x2 - x1; - int h = y2 - y1; - if (w < 0) { - w *= -1; - iX = x2; - } - if (h < 0) { - h *= -1; - iY = y2; - } - this.setGraphicsProperties(g); - g.drawRect(iX, iY, w, h); - } - - /** */ - public void drawRoundRect(final AbstractChartGraphics g, final int x1, - final int y1, final int x2, final int y2) { - int iX = x1; - int iY = y1; - int w = x2 - x1; - int h = y2 - y1; - if (w < 0) { - w *= -1; - iX = x2; - } - if (h < 0) { - h *= -1; - iY = y2; - } - this.setGraphicsProperties(g); - g.drawRoundedRect(iX, iY, w, h); - } - - /** - * @return the alphaValue - */ - public float getAlphaValue() { - return this.alphaValue; - } - - /** */ - public AbstractChartColor getColor() { - return this.color; - } - - /** - * @return the lineType - */ - public int getLineType() { - return this.lineType; - } - - /** - * @return the lWidth - */ - public float getlWidth() { - return this.lineWidth; - } - - /** */ - public int getType() { - return this.lineType; - } - - /** */ - public float getWidth() { - return this.lineWidth; - } - - /** - * @param alphaValue - * the alphaValue to set - */ - public void setAlphaValue(final float alphaValue) { - this.alphaValue = alphaValue; - } - - /** */ - public void setColor(final AbstractChartColor c) { - this.color = c; - } - - /** */ - protected void setGraphicsProperties(final AbstractChartGraphics g) { - g.setColor(this.color); - int tmp = (int) this.lineWidth; - if ((tmp == 0) && (this.lineWidth > 0.0F)) { - tmp = 1; - } - g.setLineWidth(tmp); - g.setLineStyle(STROKE_NORMAL); - if (this.lineType == 2) { - g.setLineStyle(STROKE_DASHED); - } - if (this.lineType == 3) { - g.setLineStyle(STROKE_DOTTED); - } - } - - /** - * @param lineType - * the lineType to set - */ - public void setLineType(final int lineType) { - this.lineType = lineType; - } - - /** - * @param lWidth - * the lWidth to set - */ - public void setlWidth(final float lWidth) { - this.lineWidth = lWidth; - } - - /** */ - public void setType(final int t) { - this.lineType = t; - } - - /** */ - public void setWidth(final float f) { - this.lineWidth = f; - } -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/style/package-info.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/style/package-info.java deleted file mode 100644 index 875dd68a6..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/style/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.style; \ No newline at end of file diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/swt/SpiderChartCanvas.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/swt/SpiderChartCanvas.java deleted file mode 100644 index 0b65dbe0e..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/swt/SpiderChartCanvas.java +++ /dev/null @@ -1,138 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.swt; - -import static org.eclipse.swt.SWT.CTRL; -import static org.fortiss.tooling.spiderchart.gc.AbstractGraphicsSupplier.getGraphics; -import static org.fortiss.tooling.spiderchart.gc.AbstractGraphicsSupplier.startUiThread; - -import org.eclipse.swt.events.ControlEvent; -import org.eclipse.swt.events.ControlListener; -import org.eclipse.swt.events.MouseAdapter; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.MouseMoveListener; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.widgets.Canvas; -import org.eclipse.swt.widgets.Composite; -import org.fortiss.tooling.spiderchart.SpiderChart; -import org.fortiss.tooling.spiderchart.gc.AbstractChartGraphics; -import org.fortiss.tooling.spiderchart.listener.ISpiderChartListener; - -public final class SpiderChartCanvas extends Canvas implements - ISpiderChartListener { - - /** */ - private SpiderChart chart = null; - - /** Constructor */ - public SpiderChartCanvas(final Composite parent, final int style) { - super(parent, style | CTRL); - - this.addPaintListener(e -> SpiderChartCanvas.this.paintChart(e)); - final MouseMoveListener mouseMove = e -> SpiderChartCanvas.this - .mouseMoved(e); - this.addMouseMoveListener(mouseMove); - - final MouseAdapter mouseAdapter = new MouseAdapter() { - /** {@inheritDoc} */ - @Override - public void mouseDown(final MouseEvent e) { - SpiderChartCanvas.this.mouseClick(); - } - }; - this.addMouseListener(mouseAdapter); - - this.addControlListener(new ControlListener() { - /** {@inheritDoc} */ - @Override - public void controlMoved(final ControlEvent e) { - } - - /** {@inheritDoc} */ - @Override - public void controlResized(final ControlEvent e) { - SpiderChartCanvas.this.resizeChart(); - } - }); - } - - /** */ - public SpiderChart getChart() { - return this.chart; - } - - /** */ - private void mouseClick() { - if (this.chart != null) { - this.chart.mouseClick(); - } - } - - /** */ - private void mouseMoved(final MouseEvent e) { - if (this.chart != null) { - this.chart.mouseMoved(e.x, e.y); - } - } - - /** {@inheritDoc} */ - @Override - public void onChartEvent(final SpiderChart c, final int type) { - if (type == 4) { - this.redraw(); - } - if (type == 1) { - startUiThread(() -> { - if (!SpiderChartCanvas.this.isDisposed()) { - SpiderChartCanvas.this.redraw(); - } - }); - } - } - - /** {@inheritDoc} */ - @Override - public void onPaintUserExit(final SpiderChart c, - final AbstractChartGraphics g) { - } - - /** */ - protected void paintChart(final PaintEvent e) { - try { - this.resizeChart(); - final AbstractChartGraphics g = getGraphics(e.gc); - this.chart.paint(g); - g.dispose(); - } catch (final Exception err) { - err.printStackTrace(); - } - } - - /** */ - protected void resizeChart() { - this.chart.setWidth(this.getSize().x + 1); - this.chart.setHeight(this.getSize().y + 1); - } - - /** */ - public void setChart(final SpiderChart c) { - if (this.chart != null) { - this.chart.removeChartListener(this); - } - this.chart = c; - this.chart.addChartListener(this); - } -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/swt/SpiderChartViewer.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/swt/SpiderChartViewer.java deleted file mode 100644 index ee6c4776e..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/swt/SpiderChartViewer.java +++ /dev/null @@ -1,568 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.swt; - -import static org.eclipse.swt.SWT.CURSOR_ARROW; -import static org.eclipse.swt.SWT.CURSOR_HAND; -import static org.eclipse.swt.SWT.HORIZONTAL; -import static org.eclipse.swt.SWT.NONE; -import static org.eclipse.swt.SWT.VERTICAL; - -import org.eclipse.swt.events.ControlEvent; -import org.eclipse.swt.events.ControlListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Cursor; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Slider; -import org.fortiss.tooling.spiderchart.SpiderChart; -import org.fortiss.tooling.spiderchart.listener.SpiderChartAdapter; - -public final class SpiderChartViewer extends Composite { - - /** */ - private boolean allowZoom = true; - /** */ - private SpiderChartCanvas canvas = null; - /** */ - private boolean changePointer = true; - /** */ - private final SpiderChartAdapter chartAdapter = new SpiderChartAdapter() { - /** {@inheritDoc} */ - @Override - public void onChartEvent(final SpiderChart c, final int type) { - if (type == 2) { - SpiderChartViewer.this.canvas - .setCursor(SpiderChartViewer.this.pointCursor); - } - if (type == 3) { - SpiderChartViewer.this.canvas - .setCursor(SpiderChartViewer.this.defaultCursor); - } - } - }; - /** */ - private int currentZoom = 100; - /** */ - private Cursor defaultCursor = null; - /** */ - private Slider hSlider = null; - /** */ - private int lastHeight = 0; - /** */ - private int lastWidth = 0; - /** */ - private int lastZoom = 0; - /** Maximum Zoom for Spider Chart */ - private int maxZoom = 200; - /** Minimum Zoom for Spider Chart */ - private int minZoom = 50; - /** */ - private int originalHeight = -1; - /** */ - private int originalWidth = -1; - /** */ - private Cursor pointCursor = null; - /** */ - private final int scrollBarWidth = 18; - /** */ - private Slider vSlider = null; - /** */ - private Label zoom; - /** */ - private Button zoomInButton; - /** */ - private int zoomIncrement = 25; - - /** */ - private Button zoomOutButton; - - /** */ - private Composite zoomPanel; - - /** Constructor */ - public SpiderChartViewer(final Composite parent, final int style) { - super(parent, style); - - this.canvas = new SpiderChartCanvas(this, NONE); - this.hSlider = new Slider(this, HORIZONTAL); - this.vSlider = new Slider(this, VERTICAL); - this.canvas.setFocus(); - - this.zoomPanel = new Composite(this, NONE); - this.zoomPanel.setSize(90, this.scrollBarWidth); - this.zoomInButton = new Button(this.zoomPanel, NONE); - this.zoomInButton.setLocation(0, 0); - this.zoomInButton.setText("Maximize"); - - this.zoomInButton.setSize(25, this.scrollBarWidth); - this.zoomOutButton = new Button(this.zoomPanel, NONE); - this.zoomOutButton.setLocation(26, 0); - this.zoomOutButton.setSize(25, this.scrollBarWidth); - this.zoomOutButton.setText("Minimize"); - this.zoom = new Label(this.zoomPanel, 16777216); - this.zoom.setLocation(52, 0); - this.zoom.setSize(38, this.scrollBarWidth); - - this.zoom.setText("" + this.currentZoom + " %"); - - this.zoomOutButton.addSelectionListener(new SelectionListener() { - /** {@inheritDoc} */ - @Override - public void widgetDefaultSelected(final SelectionEvent e) { - } - - /** {@inheritDoc} */ - @Override - public void widgetSelected(final SelectionEvent e) { - SpiderChartViewer.this.zoomOut(); - } - }); - this.zoomInButton.addSelectionListener(new SelectionListener() { - /** {@inheritDoc} */ - @Override - public void widgetDefaultSelected(final SelectionEvent e) { - } - - /** {@inheritDoc} */ - @Override - public void widgetSelected(final SelectionEvent e) { - SpiderChartViewer.this.zoomIn(); - } - }); - this.hSlider.addSelectionListener(new SelectionListener() { - /** {@inheritDoc} */ - @Override - public void widgetDefaultSelected(final SelectionEvent e) { - } - - /** {@inheritDoc} */ - @Override - public void widgetSelected(final SelectionEvent e) { - if (SpiderChartViewer.this.canvas.getChart() == null) { - return; - } - SpiderChartViewer.this.hSliderScroll(); - } - }); - this.vSlider.addSelectionListener(new SelectionListener() { - /** {@inheritDoc} */ - @Override - public void widgetDefaultSelected(final SelectionEvent e) { - } - - /** {@inheritDoc} */ - @Override - public void widgetSelected(final SelectionEvent e) { - if (SpiderChartViewer.this.canvas.getChart() == null) { - return; - } - SpiderChartViewer.this.vSliderScroll(); - } - }); - this.addControlListener(new ControlListener() { - /** {@inheritDoc} */ - @Override - public void controlMoved(final ControlEvent e) { - } - - /** {@inheritDoc} */ - @Override - public void controlResized(final ControlEvent e) { - if (SpiderChartViewer.this.canvas.getChart() == null) { - return; - } - SpiderChartViewer.this.placeZoomControls(); - SpiderChartViewer.this.updateSize(); - } - }); - this.defaultCursor = new Cursor(parent.getDisplay(), CURSOR_ARROW); - this.pointCursor = new Cursor(parent.getDisplay(), CURSOR_HAND); - } - - /** {@inheritDoc} */ - @Override - public void dispose() { - super.dispose(); - if ((this.pointCursor != null) && !this.pointCursor.isDisposed()) { - this.pointCursor.dispose(); - } - if ((this.defaultCursor != null) && !this.defaultCursor.isDisposed()) { - this.defaultCursor.dispose(); - } - } - - public SpiderChartCanvas getCanvas() { - return this.canvas; - } - - /** */ - public SpiderChart getChart() { - return this.canvas.getChart(); - } - - public SpiderChartAdapter getChartAdapter() { - return this.chartAdapter; - } - - public int getCurrentZoom() { - return this.currentZoom; - } - - public Cursor getDefaultCursor() { - return this.defaultCursor; - } - - public Slider gethSlider() { - return this.hSlider; - } - - public int getLastHeight() { - return this.lastHeight; - } - - public int getLastWidth() { - return this.lastWidth; - } - - public int getLastZoom() { - return this.lastZoom; - } - - public int getMaxZoom() { - return this.maxZoom; - } - - public int getMinZoom() { - return this.minZoom; - } - - public int getOriginalHeight() { - return this.originalHeight; - } - - public int getOriginalWidth() { - return this.originalWidth; - } - - public Cursor getPointCursor() { - return this.pointCursor; - } - - public int getScrollBarWidth() { - return this.scrollBarWidth; - } - - public Slider getvSlider() { - return this.vSlider; - } - - public Label getZoom() { - return this.zoom; - } - - public Button getZoomInButton() { - return this.zoomInButton; - } - - public int getZoomIncrement() { - return this.zoomIncrement; - } - - public Button getZoomOutButton() { - return this.zoomOutButton; - } - - public Composite getZoomPanel() { - return this.zoomPanel; - } - - /** */ - private void hSliderScroll() { - // TODO Need to refactor horizontal scrolling - int newBase = 0; - final int newValue = this.hSlider.getSelection(); - if ((newValue + this.canvas.getChart().getWidth()) < this.canvas - .getChart().getVirtualWidth()) { - newBase = newValue; - } else { - newBase = this.canvas.getChart().getVirtualWidth() - - this.canvas.getChart().getWidth(); - } - if (newBase < 0) { - newBase = 0; - } - this.canvas.getChart().setOffsetX(newBase); - this.canvas.redraw(); - } - - public boolean isAllowZoom() { - return this.allowZoom; - } - - public boolean isChangePointer() { - return this.changePointer; - } - - /** */ - private void placeZoomControls() { - // TODO Need to refactor for ZOOM Controls - int hSliderHeight = 0; - int vSliderWidth = 0; - - if (this.canvas.getChart().getVirtualWidth() > 0) { - hSliderHeight = this.scrollBarWidth; - } - if (this.canvas.getChart().getVirtualHeight() > 0) { - vSliderWidth = this.scrollBarWidth; - } - this.canvas.setSize(this.getSize().x - vSliderWidth, this.getSize().y - - hSliderHeight); - - this.canvas.setLocation(0, 0); - if (this.allowZoom - && ((this.canvas.getChart().getVirtualHeight() > 0) || (this.canvas - .getChart().getVirtualWidth() > 0))) { - this.zoomPanel.setVisible(true); - this.zoomPanel.setLocation(0, this.canvas.getSize().y); - } else { - this.zoomPanel.setVisible(false); - } - if (this.canvas.getChart().getVirtualWidth() > 0) { - if (this.allowZoom) { - this.hSlider.setLocation(this.zoomPanel.getSize().x, - this.canvas.getSize().y); - this.hSlider.setSize(this.getSize().x - vSliderWidth - - this.zoomPanel.getSize().x, hSliderHeight); - } else { - this.hSlider.setSize(this.getSize().x - vSliderWidth, - hSliderHeight); - this.hSlider.setLocation(0, this.canvas.getSize().y); - } - this.hSlider.setVisible(true); - this.canvas.getChart().setWithScroll(true); - } else { - this.hSlider.setVisible(false); - } - if (this.canvas.getChart().getVirtualWidth() > 0) { - this.vSlider - .setSize(vSliderWidth, this.getSize().y - hSliderHeight); - this.vSlider.setLocation(this.canvas.getSize().x, 0); - this.vSlider.setVisible(true); - this.canvas.getChart().setWithScroll(true); - } else { - this.vSlider.setVisible(false); - } - } - - /** */ - public void redrawChart() { - this.canvas.redraw(); - } - - /** */ - private void resetChart() { - this.lastWidth = 0; - this.lastHeight = 0; - this.lastZoom = 0; - } - - public void setAllowZoom(final boolean allowZoom) { - this.allowZoom = allowZoom; - } - - public void setCanvas(final SpiderChartCanvas canvas) { - this.canvas = canvas; - } - - public void setChangePointer(final boolean changePointer) { - this.changePointer = changePointer; - } - - /** */ - public void setChart(final SpiderChart c) { - if (this.canvas.getChart() != null) { - this.canvas.getChart().removeChartListener(this.chartAdapter); - } - this.canvas.setChart(c); - - this.originalHeight = this.canvas.getChart().getVirtualHeight(); - this.originalWidth = this.canvas.getChart().getVirtualWidth(); - - this.resetChart(); - this.placeZoomControls(); - this.updateSize(); - if (this.changePointer) { - this.canvas.getChart().addChartListener(this.chartAdapter); - } - } - - public void setCurrentZoom(final int currentZoom) { - this.currentZoom = currentZoom; - } - - public void setDefaultCursor(final Cursor defaultCursor) { - this.defaultCursor = defaultCursor; - } - - public void sethSlider(final Slider hSlider) { - this.hSlider = hSlider; - } - - public void setLastHeight(final int lastHeight) { - this.lastHeight = lastHeight; - } - - public void setLastWidth(final int lastWidth) { - this.lastWidth = lastWidth; - } - - public void setLastZoom(final int lastZoom) { - this.lastZoom = lastZoom; - } - - public void setMaxZoom(final int maxZoom) { - this.maxZoom = maxZoom; - } - - public void setMinZoom(final int minZoom) { - this.minZoom = minZoom; - } - - public void setOriginalHeight(final int originalHeight) { - this.originalHeight = originalHeight; - } - - public void setOriginalWidth(final int originalWidth) { - this.originalWidth = originalWidth; - } - - public void setPointCursor(final Cursor pointCursor) { - this.pointCursor = pointCursor; - } - - public void setvSlider(final Slider vSlider) { - this.vSlider = vSlider; - } - - public void setZoom(final Label zoom) { - this.zoom = zoom; - } - - public void setZoomInButton(final Button zoomInButton) { - this.zoomInButton = zoomInButton; - } - - public void setZoomIncrement(final int zoomIncrement) { - this.zoomIncrement = zoomIncrement; - } - - public void setZoomOutButton(final Button zoomOutButton) { - this.zoomOutButton = zoomOutButton; - } - - public void setZoomPanel(final Composite zoomPanel) { - this.zoomPanel = zoomPanel; - } - - /** */ - private void updateSize() { - this.canvas.getChart().setRepaintAll(true); - if ((this.lastWidth != this.getSize().x) - || (this.lastHeight != this.getSize().y) - || (this.lastZoom != this.currentZoom)) { - this.canvas.getChart().setSize(this.getSize().x, this.getSize().y); - this.lastWidth = this.getSize().x; - this.lastHeight = this.getSize().y; - this.lastZoom = this.currentZoom; - if (this.canvas.getChart().isWithScroll()) { - if (this.allowZoom) { - if (this.originalHeight > 0) { - this.canvas.getChart().setVirtualHeight( - (this.originalHeight * this.currentZoom) / 100); - } else { - this.canvas.getChart().setVirtualHeight(0); - } - if (this.originalWidth > 0) { - this.canvas.getChart().setVirtualWidth( - (this.originalWidth * this.currentZoom) / 100); - } else { - this.canvas.getChart().setVirtualWidth(0); - } - } - int w = 1 + this.getSize().x; - if (this.originalHeight > 0) { - w -= this.vSlider.getSize().x; - } - int h = 1 + this.getSize().y; - if (this.originalWidth > 0) { - h -= this.hSlider.getSize().y; - } - this.canvas.getChart().setRepaintAll(true); - - this.canvas.getChart().setSize(w, h); - } - } - } - - /** */ - private void vSliderScroll() { - // TODO Need to refactor vertical scrolling - int newBase = 0; - final int newValue = this.vSlider.getSelection(); - if ((newValue + this.canvas.getChart().getHeight()) < this.canvas - .getChart().getVirtualHeight()) { - newBase = newValue; - } else { - newBase = this.canvas.getChart().getVirtualHeight() - - this.canvas.getChart().getHeight(); - } - if (newBase < 0) { - newBase = 0; - } - this.canvas.getChart().setOffsetY(newBase); - this.canvas.redraw(); - } - - /** */ - private void zoomIn() { - if ((this.currentZoom + this.zoomIncrement) < this.maxZoom) { - this.currentZoom += this.zoomIncrement; - } else { - this.currentZoom = this.maxZoom; - } - this.zoomUpdated(); - } - - /** */ - private void zoomOut() { - if ((this.currentZoom - this.zoomIncrement) > this.minZoom) { - this.currentZoom -= this.zoomIncrement; - } else { - this.currentZoom = this.minZoom; - } - this.zoomUpdated(); - } - - /** */ - private void zoomUpdated() { - this.zoom.setText("" + this.currentZoom + " %"); - this.updateSize(); - this.canvas.redraw(); - } -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/swt/package-info.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/swt/package-info.java deleted file mode 100644 index 420b56961..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/swt/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.swt; \ No newline at end of file diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/title/SpiderChartTitle.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/title/SpiderChartTitle.java deleted file mode 100644 index 950f8f7cc..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/title/SpiderChartTitle.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.title; - -import static org.fortiss.tooling.spiderchart.gc.AbstractChartColor.BLUE; -import static org.fortiss.tooling.spiderchart.gc.AbstractChartFont.PLAIN; -import static org.fortiss.tooling.spiderchart.gc.AbstractGraphicsSupplier.getColor; -import static org.fortiss.tooling.spiderchart.gc.AbstractGraphicsSupplier.getFont; -import static org.fortiss.tooling.spiderchart.gc.Fonts.VERDANA; - -import org.fortiss.tooling.spiderchart.SpiderChartComponent; -import org.fortiss.tooling.spiderchart.gc.AbstractChartColor; -import org.fortiss.tooling.spiderchart.gc.AbstractChartFont; -import org.fortiss.tooling.spiderchart.gc.AbstractChartGraphics; - -public final class SpiderChartTitle extends SpiderChartComponent { - - /** Title Color */ - private AbstractChartColor color = getColor(BLUE); - /** Title Font */ - private AbstractChartFont font = getFont(VERDANA, PLAIN, 14); - /** Title Text */ - private String text; - - /** Constructor */ - public SpiderChartTitle() { - } - - /** */ - public void draw(final AbstractChartGraphics g) { - g.setColor(this.color); - g.setFont(this.font); - final String[] txt = new String[3]; - - txt[0] = this.text; - for (int i = 0; i < 3; i++) { - if (txt[i] != null) { - int toCenterX = (this.width - g.getFontWidth(null, txt[i])) / 2; - if (toCenterX < 0) { - toCenterX = 0; - } - int toCenterY = (this.height - g.getFontHeight()) / 2; - if (toCenterY < 0) { - toCenterY = 0; - } - g.drawText(txt[i], this.x + toCenterX, - this.y + toCenterY + (g.getFontHeight() * (i + 1))); - } - } - } - - public AbstractChartColor getChartColor() { - return this.color; - } - - public AbstractChartFont getChartFont() { - return this.font; - } - - public String getText() { - return this.text; - } - - public void setColor(final AbstractChartColor color) { - this.color = color; - } - - public void setFont(final AbstractChartFont font) { - this.font = font; - } - - public void setText(final String text) { - this.text = text; - } -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/title/package-info.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/title/package-info.java deleted file mode 100644 index b917a45fd..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/title/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.title; \ No newline at end of file diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/util/ChartUtil.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/util/ChartUtil.java deleted file mode 100644 index 4be80c7ad..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/util/ChartUtil.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.util; - -import java.util.Arrays; -import java.util.List; - -public final class ChartUtil { - - /** - * Returns the array of string represented constants of any Enum - */ - public static <E extends Enum<E>> List<String> enumConstants( - final Class<E> value) { - final String[] constants = new String[value.getEnumConstants().length]; - int i = 0; - for (final Enum<E> enumVal : value.getEnumConstants()) { - constants[i++] = enumVal.name(); - } - return Arrays.asList(constants); - } - - /** */ - public static double[] toDoublePrimitiveArray(final Double[] wrappedArray) { - final double[] array = new double[wrappedArray.length]; - for (int i = 0; i < wrappedArray.length; i++) { - array[i] = wrappedArray[i].intValue(); - } - return array; - } - - /** */ - public static double[] wrapValues(final Object[] values) { - final double[] wrappedValues = new double[values.length]; - - int i = 0; - for (final Object value : values) { - if (value instanceof Double) { - wrappedValues[i++] = (double) value; - } - if (value instanceof Enum<?>) { - final Enum<?> enumConst = (Enum<?>) value; - wrappedValues[i++] = enumConst.ordinal() + 1; - } - } - return wrappedValues; - } - - /** - * Constructor - */ - private ChartUtil() { - } - -} diff --git a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/util/package-info.java b/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/util/package-info.java deleted file mode 100644 index 5d4fb74a4..000000000 --- a/org.fortiss.tooling.spiderchart.ui/src/org/fortiss/tooling/spiderchart/util/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Amit Kumar Mondal - * - * 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.util; \ No newline at end of file -- GitLab