From bd3a9d9558b96972d29d6a6f6902c98f3f445492 Mon Sep 17 00:00:00 2001 From: Amit Kumar Mondal <mondal@fortiss.org> Date: Fri, 18 Mar 2016 11:48:12 +0000 Subject: [PATCH] Added Required Comments to remove warnings --- .../tooling/spiderchart/SpiderChart.java | 282 +++++++++--------- .../api/annotations/DataPoints.java | 4 +- .../SpiderChartAnnotationProcessor.java | 50 ++-- .../spiderchart/builder/AxesConfigurer.java | 29 +- .../builder/SpiderChartBuilder.java | 25 +- .../tooling/spiderchart/example/IPhone.java | 3 +- .../tooling/spiderchart/example/Nexus.java | 3 +- .../tooling/spiderchart/example/Sample.java | 89 +++--- .../spiderchart/gc/AbstractChartColor.java | 4 +- .../spiderchart/gc/AbstractChartFont.java | 1 + .../spiderchart/gc/AbstractChartGraphics.java | 110 +++---- .../spiderchart/gc/AbstractChartImage.java | 1 + .../fortiss/tooling/spiderchart/gc/Fonts.java | 3 +- .../gc/swt/SpiderChartSwtColor.java | 191 ++++++------ .../gc/swt/SpiderChartSwtGraphics.java | 240 ++++++++------- .../gc/swt/SpiderChartSwtImage.java | 39 ++- .../spiderchart/label/SpiderChartLabel.java | 138 ++++----- .../label/api/IFloatingObject.java | 8 + .../listener/ISpiderChartListener.java | 8 + .../listener/SpiderChartAdapter.java | 5 +- .../spiderchart/plotter/AbstractPlotter.java | 108 ++++--- .../plotter/spider/SpiderChartPlotter.java | 255 ++++++++-------- .../tooling/spiderchart/style/LineStyle.java | 57 ++-- .../spiderchart/swt/SpiderChartCanvas.java | 25 +- .../spiderchart/swt/SpiderChartViewer.java | 100 +++---- 25 files changed, 892 insertions(+), 886 deletions(-) diff --git a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/SpiderChart.java b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/SpiderChart.java index f7bd67f98..5ac0f3916 100644 --- a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/SpiderChart.java +++ b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/SpiderChart.java @@ -80,13 +80,13 @@ public final class SpiderChart { /** {@inheritDoc} */ @Override public void run() { - while (!this.stop) { + while(!this.stop) { try { Thread.sleep(SpiderChart.this.msecs); - } catch (final Exception e) { + } catch(final Exception e) { e.printStackTrace(); } - if (this.stop) { + if(this.stop) { break; } } @@ -283,10 +283,8 @@ public final class SpiderChart { /** Adds the plotter */ 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.plotters[this.plottersCount].setxScale(this.plotters[0].getxScale()); + this.plotters[this.plottersCount].setyScale(this.plotters[0].getyScale()); this.plottersCount += 1; } @@ -297,29 +295,28 @@ public final class SpiderChart { /** Disposes the spider chart */ 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) { + 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) { + if(this.chartImage != null) { this.chartImage.dispose(); } - if (this.finalImage != null) { + if(this.finalImage != null) { this.finalImage.dispose(); } - if (this.backTmpImage != null) { + if(this.backTmpImage != null) { this.backTmpImage.dispose(); } - if (this.backImage != null) { + if(this.backImage != null) { this.backImage.dispose(); } this.stopWorker(); @@ -329,11 +326,11 @@ public final class SpiderChart { private void drawBackImage(final AbstractChartGraphics g) { final int imageW = this.backImage.getWidth(); final int imageH = this.backImage.getHeight(); - if (imageW == -1 || imageH == -1) { + if(imageW == -1 || imageH == -1) { return; } - for (int j = 0; j <= this.virtualWidth; j += imageW) { - for (int i = 0; i <= this.virtualHeight; i += imageH) { + for(int j = 0; j <= this.virtualWidth; j += imageW) { + for(int i = 0; i <= this.virtualHeight; i += imageH) { g.drawImage(this.backImage, j, i); } } @@ -516,7 +513,7 @@ public final class SpiderChart { /** Getter for the first plotter to be used */ public SpiderChartPlotter getSpiderPlotter() { - return (SpiderChartPlotter) this.plotters[0]; + return (SpiderChartPlotter)this.plotters[0]; } /** Getter for the tip color */ @@ -626,8 +623,7 @@ public final class SpiderChart { /** Mouse Click Functionality */ public void mouseClick() { - if (this.selectedSeq != null && this.selectedSeqPoint >= 0 - || this.selectedLabel != null) { + if(this.selectedSeq != null && this.selectedSeqPoint >= 0 || this.selectedLabel != null) { this.triggerChartEvent(EVENT_POINT_CLICKED); return; } @@ -636,7 +632,7 @@ public final class SpiderChart { /** Mouse Move Functionality */ public void mouseMoved(final int eX, final int eY) { - if (this.plotters[0] == null) { + if(this.plotters[0] == null) { return; } @@ -646,34 +642,32 @@ public final class SpiderChart { Object previousSelectedObject = this.selectedSeq; final int previousPoint = this.selectedSeqPoint; - if (this.selectedSeq == null && this.selectedLabel != null) { + 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) { + if(this.activateSelection) { + for(final AbstractPlotter plotter : this.plotters) { + if(plotter == null) { break; } - for (int k = 0; k < plotter.getSeqCount(); k++) { + 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)) { + 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) { + if(previousSelectedObject == null) { triggerEnter = true; - } else if (previousSelectedObject != d - || previousPoint != i) { + } else if(previousSelectedObject != d || previousPoint != i) { this.triggerChartEvent(EVENT_LEAVE_POINT); triggerEnter = true; } this.selectedSeq = d; this.selectedSeqPoint = i; - if (!triggerEnter) { + if(!triggerEnter) { break; } this.triggerChartEvent(EVENT_ENTER_POINT); @@ -682,15 +676,14 @@ public final class SpiderChart { } } } - if (Math.abs(this.currentX - this.cursorLastX) > 2 - || Math.abs(this.currentY - this.cursorLastY) > 2) { + 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) { + if(previousSelectedObject != null && this.selectedSeq == null && this.selectedLabel == null) { this.triggerChartEvent(EVENT_LEAVE_POINT); } } @@ -699,7 +692,7 @@ public final class SpiderChart { public void paint(final AbstractChartGraphics pg) { this.floatingObjects.clear(); - if (this.plotters[0] == null || this.plottersCount <= 0) { + if(this.plotters[0] == null || this.plottersCount <= 0) { pg.setColor(getColor(RED)); pg.drawText("No plotters have been found", 30, 30); return; @@ -707,179 +700,176 @@ public final class SpiderChart { AbstractChartGraphics gScroll = pg; AbstractChartGraphics gBack = pg; AbstractChartGraphics g = pg; - if (this.lastWidth != this.width || this.lastHeight != this.height) { + if(this.lastWidth != this.width || this.lastHeight != this.height) { this.repaintAll = true; this.lastWidth = this.width; this.lastHeight = this.height; } - if (this.originalVirtualHeight == -1) { + if(this.originalVirtualHeight == -1) { this.originalVirtualHeight = this.virtualHeight; } - if (this.originalVirtualWidth == -1) { + if(this.originalVirtualWidth == -1) { this.originalVirtualWidth = this.virtualWidth; } - if (!this.withScroll) { + if(!this.withScroll) { this.repaintAlways = true; } - if (this.repaintAlways) { + if(this.repaintAlways) { this.repaintAll = true; } - if (this.autoResize) { - if (!this.withScroll) { + 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) { + 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) { + } catch(final Exception e) { e.printStackTrace(); } - if (this.finalImage != null) { + 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) { + if(this.withScroll) { + if(this.repaintAll || this.chartImage == null) { + if(this.chartImage != null) { this.chartImage.dispose(); } - this.chartImage = createImage(this.virtualWidth, - this.virtualHeight); + this.chartImage = createImage(this.virtualWidth, this.virtualHeight); } gScroll = this.chartImage.getGraphics(); - if (this.repaintAll || this.backTmpImage == null) { - if (this.backTmpImage != null) { + if(this.repaintAll || this.backTmpImage == null) { + if(this.backTmpImage != null) { this.backTmpImage.dispose(); } - this.backTmpImage = createImage(this.virtualWidth, - this.virtualHeight); + 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.repaintAll) { + if(this.backStyle != null && this.backgroundCanvasColor != null) { + this.backStyle.draw(gBack, this.backgroundCanvasColor, 0, 0, this.virtualWidth, + this.virtualHeight); } - if (this.backImage != null) { + 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); + 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); + 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) { + 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))); + 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) { + 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.plotters[0].plotBackground(gScroll, plotterBackWidth, plotterBackHeight, + this.offsetX, this.offsetY); } this.title.chart = this; this.title.draw(g); - if (this.legend == null) { + if(this.legend == null) { this.legend = new SpiderChartLegend(); } - if (this.legend != null) { + if(this.legend != null) { this.legend.chart = this; this.legend.draw(g); } - if (this.repaintAll) { - for (int i = 0; i < this.plottersCount; i++) { + 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.border != null) { + this.border.drawRect(g, 0, 0, this.getWidth() - 1, this.getHeight() - 1); } - if (this.chartImage != null) { + if(this.chartImage != null) { final int x1 = this.plotters[0].x; - final int x2 = this.plotters[0].x - + this.plotters[0].getVisibleWidth(); + 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(); + 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); + 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++) { + 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()); + 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) { + if(gScroll != pg) { gScroll.dispose(); } - if (gBack != pg) { + if(gBack != pg) { gBack.dispose(); } - if (g != pg) { + if(g != pg) { g.dispose(); } } - /** Paints the tips */ + /** + * Paints the tips + * + * @param g + * Chart Graphics to paint + */ private void paintTips(final AbstractChartGraphics g) { // TODO (AKM) To be implemented properly: Tips Functionality - if (this.showTips && this.selectedLabel != null) { + if(this.showTips && this.selectedLabel != null) { this.selectedLabel.getTip(); } } - /** Places the defined floating object */ + /** + * Places the defined floating object + * + * @param obj + * the floating object to place + */ public void placeFloatingObject(final IFloatingObject obj) { + // To be implemented } /** Removes all registered listeners */ @@ -894,15 +884,14 @@ public final class SpiderChart { /** Removes all the chart plotters */ public void removeChartPlotters() { - for (int i = 0; i < this.plottersCount; i++) { + for(int i = 0; i < this.plottersCount; i++) { this.plotters[i] = null; } this.plottersCount = 0; } /** Release the used resources */ - protected void resetChart(final SpiderChartTitle t, - final SpiderChartPlotter p) { + protected void resetChart(final SpiderChartTitle t, final SpiderChartPlotter p) { this.plottersCount = 0; this.plotters = new SpiderChartPlotter[10]; this.legend = null; @@ -915,7 +904,7 @@ public final class SpiderChart { this.floatingObjects.clear(); this.plotters[0] = p; this.title = t; - if (this.title == null) { + if(this.title == null) { this.title = new SpiderChartTitle(); this.title.setText(""); } @@ -926,33 +915,32 @@ public final class SpiderChart { private void resize() { final int myHeight = this.getHeight(); final int myWidth = this.getWidth(); - if (this.virtualWidth < myWidth) { + if(this.virtualWidth < myWidth) { this.virtualWidth = myWidth; } - if (this.virtualHeight < myHeight) { + if(this.virtualHeight < myHeight) { this.virtualHeight = myHeight; } this.plotters[0] - .setVisibleWidth((int) (myWidth * (1.0D - (this.legendMargin + this.leftMargin)))); + .setVisibleWidth((int)(myWidth * (1.0D - (this.legendMargin + this.leftMargin)))); this.plotters[0] - .setVisibleHeight((int) (myHeight * (1.0D - (this.topMargin + this.bottomMargin)))); + .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.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.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); + 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(); } @@ -1039,7 +1027,7 @@ public final class SpiderChart { /** Setter for the height of the chart */ public void setHeight(final int h) { - if (h > this.minimumHeight) { + if(h > this.minimumHeight) { this.height = h; } } @@ -1112,7 +1100,7 @@ public final class SpiderChart { /** */ private void setPlotterSize() { - for (int i = 1; i < this.plottersCount; i++) { + 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; @@ -1178,7 +1166,7 @@ public final class SpiderChart { /** Setter for the width of the chart */ public void setWidth(final int w) { - if (w > this.minimumWidth) { + if(w > this.minimumWidth) { this.width = w; } } @@ -1202,7 +1190,7 @@ public final class SpiderChart { /** Stops the execution of the chart refresh deamon */ public void stopWorker() { this.stopped = true; - if (this.deamon != null) { + if(this.deamon != null) { this.deamon.stop = true; } this.deamon = null; @@ -1210,7 +1198,7 @@ public final class SpiderChart { /** Triggers the chart event */ private void triggerChartEvent(final int event) { - for (int i = 0; i < this.chartListeners.size(); i++) { + for(int i = 0; i < this.chartListeners.size(); i++) { this.chartListeners.get(i).onChartEvent(this, event); } } diff --git a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/api/annotations/DataPoints.java b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/api/annotations/DataPoints.java index 9e665d113..526141ea3 100644 --- a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/api/annotations/DataPoints.java +++ b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/api/annotations/DataPoints.java @@ -32,5 +32,5 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Target(value = ElementType.METHOD) public @interface DataPoints { - -} \ No newline at end of file + // +} diff --git a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/api/annotations/processor/SpiderChartAnnotationProcessor.java b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/api/annotations/processor/SpiderChartAnnotationProcessor.java index b3e713034..f0dd2b248 100644 --- a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/api/annotations/processor/SpiderChartAnnotationProcessor.java +++ b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/api/annotations/processor/SpiderChartAnnotationProcessor.java @@ -37,8 +37,8 @@ public final class SpiderChartAnnotationProcessor { * method */ private static boolean checkMethodAnnotation(final Object object) { - for (final Method m : object.getClass().getMethods()) { - if (m.getAnnotation(DataPoints.class) != null) { + for(final Method m : object.getClass().getMethods()) { + if(m.getAnnotation(DataPoints.class) != null) { return true; } @@ -59,14 +59,12 @@ public final class SpiderChartAnnotationProcessor { */ public static String getAreaColor(final Object object) { reportOnNull(object); - if (!(checkTypeAnnotation(object) && checkMethodAnnotation(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; } + final String areaColor = object.getClass().getAnnotation(SpiderChartPlot.class).areaColor(); + return areaColor; } /** @@ -74,27 +72,23 @@ public final class SpiderChartAnnotationProcessor { */ public static double[] getDataPoints(final Object object) { reportOnNull(object); - if (!(checkTypeAnnotation(object) && checkMethodAnnotation(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"); - } + } + 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; } - } catch (IllegalAccessException | IllegalArgumentException - | InvocationTargetException e) { - e.printStackTrace(); + throw new RuntimeException( + "Spider Chart annotated method doesn't return primitive double array"); } + } catch(IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); } } return null; @@ -105,14 +99,12 @@ public final class SpiderChartAnnotationProcessor { */ public static String getLegend(final Object object) { reportOnNull(object); - if (!(checkTypeAnnotation(object) && checkMethodAnnotation(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; } + final String legend = object.getClass().getAnnotation(SpiderChartPlot.class).name(); + return legend; } /** diff --git a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/builder/AxesConfigurer.java b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/builder/AxesConfigurer.java index 2ddbd3bb4..1066de338 100644 --- a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/builder/AxesConfigurer.java +++ b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/builder/AxesConfigurer.java @@ -31,6 +31,14 @@ import java.util.List; */ public final class AxesConfigurer { + /** + * Builder class to prepare axis + * + * @author AMIT + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ public static class Builder { /** Maximum Scales */ @@ -63,11 +71,10 @@ public final class AxesConfigurer { * use its constants as labels * @return the Builder object for method chaining */ - public <E extends Enum<E>> Builder addAxis(final String name, - final Class<E> value) { + 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()) { + for(final Enum<E> enumVal : value.getEnumConstants()) { doubleValues[i++] = enumVal.ordinal(); } Arrays.sort(doubleValues); @@ -89,8 +96,7 @@ public final class AxesConfigurer { * minimum scale of axis * @return the Builder object for method chaining */ - public Builder addAxis(final String name, final double maxScale, - final double minScale) { + public Builder addAxis(final String name, final double maxScale, final double minScale) { this.maxScales.add(maxScale); this.minScales.add(minScale); this.scalesNames.add(name); @@ -111,8 +117,8 @@ public final class AxesConfigurer { * the scaling label format * @return the Builder object for method chaining */ - public Builder addAxis(final String name, final double maxScale, - final double minScale, final Object scalingLabelFormat) { + 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); @@ -122,8 +128,8 @@ public final class AxesConfigurer { /** Builder */ public AxesConfigurer build() { - return new AxesConfigurer(this.maxScales, this.minScales, - this.scalesNames, this.scalingLabelFormats); + return new AxesConfigurer(this.maxScales, this.minScales, this.scalesNames, + this.scalingLabelFormats); } } @@ -139,9 +145,8 @@ public final class AxesConfigurer { private final List<Object> scalingLabelFormats; /** Constructor */ - private AxesConfigurer(final List<Double> maxScales, - final List<Double> minScales, final List<String> scalesNames, - final List<Object> scalingLabelFormats) { + 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; diff --git a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/builder/SpiderChartBuilder.java b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/builder/SpiderChartBuilder.java index 363722317..2196345f8 100644 --- a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/builder/SpiderChartBuilder.java +++ b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/builder/SpiderChartBuilder.java @@ -71,8 +71,7 @@ public final class SpiderChartBuilder { } /** The datapoints provider */ - public SpiderChartBuilder data( - final Consumer<AxisDataBuilder> dataBuilderConsumer) { + public SpiderChartBuilder data(final Consumer<AxisDataBuilder> dataBuilderConsumer) { requireNonNull(dataBuilderConsumer); final AxisDataBuilder dataBuilder = new AxisDataBuilder(this.chart); dataBuilderConsumer.accept(dataBuilder); @@ -82,16 +81,14 @@ public final class SpiderChartBuilder { /** Configuration for the spider chart */ 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.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); // Some chart related default configurations - this.chart = new SpiderChart(chartConfiguration.getTitle(), - chartConfiguration.getPlotter()); + 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); @@ -101,11 +98,15 @@ public final class SpiderChartBuilder { } /** Builds the viewer */ - public SpiderChartViewer viewer( - final Consumer<SpiderChartBuilder> chartBuilderConsumer) { + public SpiderChartViewer viewer(final Consumer<SpiderChartBuilder> chartBuilderConsumer) { requireNonNull(chartBuilderConsumer); chartBuilderConsumer.accept(chartViewerBuilder); return chartViewerBuilder.chartViewer; } + /** Builds the viewer if values are already provided to the plotter using line data sequence */ + public SpiderChartViewer viewer() { + return chartViewerBuilder.chartViewer; + } + } diff --git a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/example/IPhone.java b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/example/IPhone.java index 724f4ff1c..7e5737fd1 100644 --- a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/example/IPhone.java +++ b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/example/IPhone.java @@ -22,12 +22,13 @@ 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; +@SuppressWarnings("javadoc") @SpiderChartPlot(name = "iPhone 6", areaColor = DARKORCHID) public final class IPhone { @DataPoints public double[] dataPoints() { - final double[] data = { 4, 3.5, 4, 4.6, 5 }; + final double[] data = {4, 3.5, 4, 4.6, 5}; return data; } diff --git a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/example/Nexus.java b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/example/Nexus.java index 4a534b732..7e096d20c 100644 --- a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/example/Nexus.java +++ b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/example/Nexus.java @@ -22,12 +22,13 @@ 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; +@SuppressWarnings("javadoc") @SpiderChartPlot(name = "Nexus 6", areaColor = OLIVE) public final class Nexus { @DataPoints public double[] dataPoints() { - final double[] data = { 4, 3, 3, 4.1, 3 }; + final double[] data = {4, 3, 3, 4.1, 3}; return data; } diff --git a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/example/Sample.java b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/example/Sample.java index 4b4c07354..7c6557f6a 100644 --- a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/example/Sample.java +++ b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/example/Sample.java @@ -27,6 +27,7 @@ import org.fortiss.tooling.spiderchart.builder.SpiderChartBuilder; import org.fortiss.tooling.spiderchart.sequence.LineDataSeq; import org.fortiss.tooling.spiderchart.swt.SpiderChartViewer; +@SuppressWarnings("javadoc") public final class Sample { private enum Brand { @@ -39,68 +40,56 @@ public final class Sample { final Supplier<Object> iPhoneData = IPhone::new; final Supplier<Object> nexusData = Nexus::new; - viewer = SpiderChartBuilder - .config(shell, + viewer = + SpiderChartBuilder.config( + shell, settings -> { - settings.title( - title -> title - .setText("Smartphone Comparison Scale")) + 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) + 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(); + .addAxis("Brand", 5, 0).build(); plotter.use(configuration); }); }).viewer( - chart -> { - chart.data( - firstData -> firstData.inject(iPhoneData)) - .data(secondData -> secondData - .inject(nexusData)); - }); + chart -> { + chart.data(firstData -> firstData.inject(iPhoneData)).data( + secondData -> secondData.inject(nexusData)); + }); // Updating the chart with new parameters - Display.getDefault() - .asyncExec(() -> { + 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); - }); + 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) { @@ -111,8 +100,8 @@ public final class Sample { buildSpiderChart(shell); shell.open(); - while (!shell.isDisposed()) { - if (!display.readAndDispatch()) { + while(!shell.isDisposed()) { + if(!display.readAndDispatch()) { display.sleep(); } } diff --git a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/AbstractChartColor.java b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/AbstractChartColor.java index 25fd8ee14..395fb7a0e 100644 --- a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/AbstractChartColor.java +++ b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/AbstractChartColor.java @@ -23,6 +23,7 @@ package org.fortiss.tooling.spiderchart.gc; * @author AMIT KUMAR MONDAL * */ +@SuppressWarnings("javadoc") public abstract class AbstractChartColor { public static final String ALICEBLUE = "ALICEBLUE"; @@ -128,8 +129,7 @@ public abstract class AbstractChartColor { /** Getter for the RGB */ public int getRGB() { - return this.getRed() * 256 * 256 + this.getGreen() * 256 - + this.getBlue(); + return this.getRed() * 256 * 256 + this.getGreen() * 256 + this.getBlue(); } /** Getter for the RGB in Hex */ diff --git a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/AbstractChartFont.java b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/AbstractChartFont.java index 5f97fe632..8d8535b18 100644 --- a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/AbstractChartFont.java +++ b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/AbstractChartFont.java @@ -23,6 +23,7 @@ package org.fortiss.tooling.spiderchart.gc; * @author AMIT KUMAR MONDAL * */ +@SuppressWarnings("javadoc") public abstract class AbstractChartFont { public static int BOLD = 1; diff --git a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/AbstractChartGraphics.java b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/AbstractChartGraphics.java index a372d03e6..aacb6f735 100644 --- a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/AbstractChartGraphics.java +++ b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/AbstractChartGraphics.java @@ -23,6 +23,7 @@ package org.fortiss.tooling.spiderchart.gc; * @author AMIT KUMAR MONDAL * */ +@SuppressWarnings({"unused"}) public abstract class AbstractChartGraphics { /** */ @@ -44,51 +45,53 @@ public abstract class AbstractChartGraphics { /** Creates fade area */ 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 AbstractChartColor colorUntil, final int x, final int y, final int w, + final int h, final boolean vertical, final boolean cyclic) { + // } /** disposes the resource */ public void dispose() { + // } /** draws the arc as provided as inputs */ - public void drawArc(final int x, final int y, final int w, final int h, - final int a1, final int a2) { + public void drawArc(final int x, final int y, final int w, final int h, final int a1, + final int a2) { + // } /** draws the image */ - public void drawImage(final AbstractChartImage image, final int x, - final int y) { + public void drawImage(final AbstractChartImage image, final int x, final int y) { + // } /** draws the image */ - 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 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) { + // } /** draws the line */ public void drawLine(final int x1, final int y1, final int x2, final int y2) { + // } /** draws the line based on the line style provided */ - public void drawLineWithStyle(final int x1, final int y1, final int x2, - final int y2) { - if (this.lineStyle == STROKE_NORMAL) { + 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) { + 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) { + if(h == 0 && w == 0) { return; } final double hipo = Math.sqrt(h * h + w * w); @@ -98,10 +101,10 @@ public abstract class AbstractChartGraphics { int Xslope = 1; int Yslope = 1; - if (x2 < x1) { + if(x2 < x1) { Xslope = -1; } - if (y2 < y1) { + if(y2 < y1) { Yslope = -1; } int subx1 = 0; @@ -109,22 +112,21 @@ public abstract class AbstractChartGraphics { 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)) { + 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)) { + if(w < Math.abs(subx2)) { subx2 = w * Xslope; } - if (h < Math.abs(suby2)) { + if(h < Math.abs(suby2)) { suby2 = h * Yslope; } - this.drawSimpleLine(x1 + subx1, y1 + suby1, x1 + subx2, y1 - + suby2); + this.drawSimpleLine(x1 + subx1, y1 + suby1, x1 + subx2, y1 + suby2); subsegment = subsegment + segment + segmentspace; } @@ -133,6 +135,7 @@ public abstract class AbstractChartGraphics { /** draws the polygon */ public void drawPolygon(final int[] x1, final int[] y1, final int count) { + // } /** draws the rectangle */ @@ -145,31 +148,29 @@ public abstract class AbstractChartGraphics { /** draws the text as rotated */ public boolean drawRotatedText(final AbstractChartFont descFont, - final AbstractChartColor descColor, final String txt, - final int angle, final int x, final int y, final boolean b) { + final AbstractChartColor descColor, final String txt, final int angle, final int x, + final int y, final boolean b) { return false; } /** draws the rectangle with round corners */ - public void drawRoundedRect(final int x1, final int y1, final int w, - final int h) { + public void drawRoundedRect(final int x1, final int y1, final int w, final int h) { this.drawRect(x1, y1, w, h); } /** draws the simple line */ - protected void drawSimpleLine(final int x1, final int y1, final int x2, - final int y2) { + 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) { + if(pixelsWidth < 1) { pixelsWidth = 1; } this.drawLine(x1, y1, x2, y2); - if (pixelsWidth == 1) { + if(pixelsWidth == 1) { return; } - if (pixelsWidth > 1) { + if(pixelsWidth > 1) { int xwidth = 0; int ywidth = 0; @@ -182,24 +183,23 @@ public abstract class AbstractChartGraphics { xwidth = 1; ywidth = 0; - if (Cos > Math.cos(1.0471666666666668D)) { + if(Cos > Math.cos(1.0471666666666668D)) { xwidth = 0; ywidth = 1; } - if (Cos > Math.cos(0.5235833333333334D)) { + 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) { + 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); + this.drawLine(x1 + side * xwidth * distanceToCenter, y1 + side * ywidth * + distanceToCenter, x2 + side * xwidth * distanceToCenter, y2 + side * + ywidth * distanceToCenter); side *= -1; } } @@ -207,24 +207,27 @@ public abstract class AbstractChartGraphics { /** draws the text at the provided coordinate */ public void drawText(final String s, final int x, final int y) { + // } /** Fills the arc based on the provided inputs */ - public void fillArc(final int x, final int y, final int w, final int h, - final int a1, final int a2) { + public void fillArc(final int x, final int y, final int w, final int h, final int a1, + final int a2) { + // } /** fills the polygon */ public void fillPolygon(final int[] x1, final int[] y1, final int count) { + // } /** fills the rectangle */ public void fillRect(final int x1, final int y1, final int w, final int h) { + // } /** fills the rectangle with round corners */ - public void fillRoundRect(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); } @@ -264,24 +267,29 @@ public abstract class AbstractChartGraphics { } /** paints rotated image */ - public void paintRotatedImage(final AbstractChartImage srcImage, - final int angle, final int x, final int y, final int alginment) { + public void paintRotatedImage(final AbstractChartImage srcImage, final int angle, final int x, + final int y, final int alginment) { + // } /** setter for alpha value */ public void setAlpha(final float a) { + // } /** setter for alpha composite */ public void setAlphaComposite(final Object a) { + // } /** setter for color */ public void setColor(final AbstractChartColor color) { + // } /** setter for font */ public void setFont(final AbstractChartFont font) { + // } /** setter for line style */ diff --git a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/AbstractChartImage.java b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/AbstractChartImage.java index 73c238a4a..00201d4d5 100644 --- a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/AbstractChartImage.java +++ b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/AbstractChartImage.java @@ -27,6 +27,7 @@ public abstract class AbstractChartImage { /** disposes the image */ public void dispose() { + // not used } /** getter for the graphics */ diff --git a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/Fonts.java b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/Fonts.java index f6a35e09e..854f88150 100644 --- a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/Fonts.java +++ b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/Fonts.java @@ -23,6 +23,7 @@ package org.fortiss.tooling.spiderchart.gc; * @author AMIT KUMAR MONDAL * */ +@SuppressWarnings("javadoc") public enum Fonts { ARIAL("Arial"), SERIF("Serif"), VERDANA("Verdana"); @@ -38,8 +39,6 @@ public enum Fonts { /** * Retrieves font text - * - * @return */ public String getFontName() { return this.fontName; diff --git a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/swt/SpiderChartSwtColor.java b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/swt/SpiderChartSwtColor.java index 50bedf813..2abbb8aeb 100644 --- a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/swt/SpiderChartSwtColor.java +++ b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/swt/SpiderChartSwtColor.java @@ -42,12 +42,12 @@ public final class SpiderChartSwtColor extends AbstractChartColor { /** Constructor */ public SpiderChartSwtColor(final Object c) { - if (c instanceof String) { - this.setFromString((String) 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(); + this.red = ((Color)c).getRed(); + this.green = ((Color)c).getGreen(); + this.blue = ((Color)c).getBlue(); } } @@ -61,8 +61,7 @@ public final class SpiderChartSwtColor extends AbstractChartColor { 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)); + return new SpiderChartSwtColor(Math.min(r, 255), Math.min(g, 255), Math.min(b, 255)); } /** {@inheritDoc} */ @@ -76,8 +75,7 @@ public final class SpiderChartSwtColor extends AbstractChartColor { 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)); + return new SpiderChartSwtColor(Math.min(r, 255), Math.min(g, 255), Math.min(b, 255)); } /** {@inheritDoc} */ @@ -86,10 +84,9 @@ public final class SpiderChartSwtColor extends AbstractChartColor { return this.blue; } - /** {@inheritDoc} */ + /** Returns the color */ public Color getColor() { - return new Color(SwtGraphicsProvider.getDisplay(), this.red, - this.green, this.blue); + return new Color(SwtGraphicsProvider.getDisplay(), this.red, this.green, this.blue); } /** {@inheritDoc} */ @@ -107,179 +104,179 @@ public final class SpiderChartSwtColor extends AbstractChartColor { /** String to RGB */ private void setFromString(String c) { c = c.toUpperCase(); - if (c.compareTo("") == 0) { + if(c.compareTo("") == 0) { this.setRGB(0, 0, 0); return; } - if (c.compareTo(RED) == 0) { + if(c.compareTo(RED) == 0) { this.setRGB(255, 0, 0); - } else if (c.compareTo(BLACK) == 0) { + } else if(c.compareTo(BLACK) == 0) { this.setRGB(0, 0, 0); - } else if (c.compareTo(BLUE) == 0) { + } else if(c.compareTo(BLUE) == 0) { this.setRGB(0, 0, 255); - } else if (c.compareTo(CYAN) == 0) { + } else if(c.compareTo(CYAN) == 0) { this.setRGB(0, 255, 255); - } else if (c.compareTo(DARKGRAY) == 0) { + } else if(c.compareTo(DARKGRAY) == 0) { this.setRGB(70, 70, 70); - } else if (c.compareTo(GRAY) == 0) { + } else if(c.compareTo(GRAY) == 0) { this.setRGB(128, 128, 128); - } else if (c.compareTo(GREEN) == 0) { + } else if(c.compareTo(GREEN) == 0) { this.setRGB(0, 255, 0); - } else if (c.compareTo(LIGHTGRAY) == 0) { + } else if(c.compareTo(LIGHTGRAY) == 0) { this.setRGB(192, 192, 192); - } else if (c.compareTo(MAGENTA) == 0) { + } else if(c.compareTo(MAGENTA) == 0) { this.setRGB(255, 0, 128); - } else if (c.compareTo(ORANGE) == 0) { + } else if(c.compareTo(ORANGE) == 0) { this.setRGB(255, 128, 0); - } else if (c.compareTo(PINK) == 0) { + } else if(c.compareTo(PINK) == 0) { this.setRGB(255, 0, 255); - } else if (c.compareTo(WHITE) == 0) { + } else if(c.compareTo(WHITE) == 0) { this.setRGB(255, 255, 255); - } else if (c.compareTo(YELLOW) == 0) { + } else if(c.compareTo(YELLOW) == 0) { this.setRGB(255, 255, 0); - } else if (c.compareTo(LIME) == 0) { + } else if(c.compareTo(LIME) == 0) { this.setRGB(65280); - } else if (c.compareTo(OLIVE) == 0) { + } else if(c.compareTo(OLIVE) == 0) { this.setRGB(8421376); - } else if (c.compareTo(MAROON) == 0) { + } else if(c.compareTo(MAROON) == 0) { this.setRGB(8388608); - } else if (c.compareTo(NAVY) == 0) { + } else if(c.compareTo(NAVY) == 0) { this.setRGB(128); - } else if (c.compareTo(PURPLE) == 0) { + } else if(c.compareTo(PURPLE) == 0) { this.setRGB(8388736); - } else if (c.compareTo(TELA) == 0) { + } else if(c.compareTo(TELA) == 0) { this.setRGB(32896); - } else if (c.compareTo(FUCHSIA) == 0) { + } else if(c.compareTo(FUCHSIA) == 0) { this.setRGB(16711935); - } else if (c.compareTo(AQUA) == 0) { + } else if(c.compareTo(AQUA) == 0) { this.setRGB(65535); - } else if (c.compareTo(ALICEBLUE) == 0) { + } else if(c.compareTo(ALICEBLUE) == 0) { this.setRGB(15792383); - } else if (c.compareTo(ANTIQUEWHITE) == 0) { + } else if(c.compareTo(ANTIQUEWHITE) == 0) { this.setRGB(16444375); - } else if (c.compareTo(AQUAMARINE) == 0) { + } else if(c.compareTo(AQUAMARINE) == 0) { this.setRGB(8388564); - } else if (c.compareTo(AZURE) == 0) { + } else if(c.compareTo(AZURE) == 0) { this.setRGB(15794175); - } else if (c.compareTo(BEIGE) == 0) { + } else if(c.compareTo(BEIGE) == 0) { this.setRGB(16119260); - } else if (c.compareTo(BLUEVIOLET) == 0) { + } else if(c.compareTo(BLUEVIOLET) == 0) { this.setRGB(9055202); - } else if (c.compareTo(BROWN) == 0) { + } else if(c.compareTo(BROWN) == 0) { this.setRGB(10824234); - } else if (c.compareTo(BORLYWOOD) == 0) { + } else if(c.compareTo(BORLYWOOD) == 0) { this.setRGB(14596231); - } else if (c.compareTo(CORAL) == 0) { + } else if(c.compareTo(CORAL) == 0) { this.setRGB(16744272); - } else if (c.compareTo(CYAN) == 0) { + } else if(c.compareTo(CYAN) == 0) { this.setRGB(65535); - } else if (c.compareTo(DARKGOLGENROD) == 0) { + } else if(c.compareTo(DARKGOLGENROD) == 0) { this.setRGB(12092939); - } else if (c.compareTo(DARKGREEN) == 0) { + } else if(c.compareTo(DARKGREEN) == 0) { this.setRGB(25600); - } else if (c.compareTo(DARKOLIVEGREEN) == 0) { + } else if(c.compareTo(DARKOLIVEGREEN) == 0) { this.setRGB(5597999); - } else if (c.compareTo(DARKORANGE) == 0) { + } else if(c.compareTo(DARKORANGE) == 0) { this.setRGB(16747520); - } else if (c.compareTo(DARKORCHID) == 0) { + } else if(c.compareTo(DARKORCHID) == 0) { this.setRGB(10040012); - } else if (c.compareTo(DARKSALMON) == 0) { + } else if(c.compareTo(DARKSALMON) == 0) { this.setRGB(15308410); - } else if (c.compareTo(DARKTURQUOISE) == 0) { + } else if(c.compareTo(DARKTURQUOISE) == 0) { this.setRGB(52945); - } else if (c.compareTo(DARKVIOLET) == 0) { + } else if(c.compareTo(DARKVIOLET) == 0) { this.setRGB(9699539); - } else if (c.compareTo(DEEPPINK) == 0) { + } else if(c.compareTo(DEEPPINK) == 0) { this.setRGB(16716947); - } else if (c.compareTo(DEEPSKYBLUE) == 0) { + } else if(c.compareTo(DEEPSKYBLUE) == 0) { this.setRGB(49151); - } else if (c.compareTo(FORESTGREEN) == 0) { + } else if(c.compareTo(FORESTGREEN) == 0) { this.setRGB(2263842); - } else if (c.compareTo(GOLD) == 0) { + } else if(c.compareTo(GOLD) == 0) { this.setRGB(16766720); - } else if (c.compareTo(GOLDENROD) == 0) { + } else if(c.compareTo(GOLDENROD) == 0) { this.setRGB(14329120); - } else if (c.compareTo(GREENYELLOW) == 0) { + } else if(c.compareTo(GREENYELLOW) == 0) { this.setRGB(11403055); - } else if (c.compareTo(HOTPINK) == 0) { + } else if(c.compareTo(HOTPINK) == 0) { this.setRGB(16738740); - } else if (c.compareTo(INDIANRED) == 0) { + } else if(c.compareTo(INDIANRED) == 0) { this.setRGB(13458524); - } else if (c.compareTo(IVORY) == 0) { + } else if(c.compareTo(IVORY) == 0) { this.setRGB(16777200); - } else if (c.compareTo(KHALI) == 0) { + } else if(c.compareTo(KHALI) == 0) { this.setRGB(15787660); - } else if (c.compareTo(LAVENDER) == 0) { + } else if(c.compareTo(LAVENDER) == 0) { this.setRGB(15132410); - } else if (c.compareTo(LAWNGREEN) == 0) { + } else if(c.compareTo(LAWNGREEN) == 0) { this.setRGB(8190976); - } else if (c.compareTo(LIGHTBLUE) == 0) { + } else if(c.compareTo(LIGHTBLUE) == 0) { this.setRGB(11393254); - } else if (c.compareTo(LIGHTCORAL) == 0) { + } else if(c.compareTo(LIGHTCORAL) == 0) { this.setRGB(15761536); - } else if (c.compareTo(LIGHTCYAN) == 0) { + } else if(c.compareTo(LIGHTCYAN) == 0) { this.setRGB(14745599); - } else if (c.compareTo(LIGHTGRAY) == 0) { + } else if(c.compareTo(LIGHTGRAY) == 0) { this.setRGB(13882323); - } else if (c.compareTo(LIGHTPINK) == 0) { + } else if(c.compareTo(LIGHTPINK) == 0) { this.setRGB(16758465); - } else if (c.compareTo(LIGHTSALMON) == 0) { + } else if(c.compareTo(LIGHTSALMON) == 0) { this.setRGB(16752762); - } else if (c.compareTo(LIGHTSKYBLUE) == 0) { + } else if(c.compareTo(LIGHTSKYBLUE) == 0) { this.setRGB(8900346); - } else if (c.compareTo(LIGHTYELLOW) == 0) { + } else if(c.compareTo(LIGHTYELLOW) == 0) { this.setRGB(16777184); - } else if (c.compareTo(LIMEGREEN) == 0) { + } else if(c.compareTo(LIMEGREEN) == 0) { this.setRGB(3329330); - } else if (c.compareTo(MAGENTA) == 0) { + } else if(c.compareTo(MAGENTA) == 0) { this.setRGB(16711935); - } else if (c.compareTo(MEDIUMBLUE) == 0) { + } else if(c.compareTo(MEDIUMBLUE) == 0) { this.setRGB(205); - } else if (c.compareTo(MEDIUMPURPLE) == 0) { + } else if(c.compareTo(MEDIUMPURPLE) == 0) { this.setRGB(9662683); - } else if (c.compareTo(MIDNIGHTBLUE) == 0) { + } else if(c.compareTo(MIDNIGHTBLUE) == 0) { this.setRGB(1644912); - } else if (c.compareTo(ORANGE) == 0) { + } else if(c.compareTo(ORANGE) == 0) { this.setRGB(16753920); - } else if (c.compareTo(ORANGERED) == 0) { + } else if(c.compareTo(ORANGERED) == 0) { this.setRGB(16729344); - } else if (c.compareTo(ORCHID) == 0) { + } else if(c.compareTo(ORCHID) == 0) { this.setRGB(14315734); - } else if (c.compareTo(PALEGREEN) == 0) { + } else if(c.compareTo(PALEGREEN) == 0) { this.setRGB(10025880); - } else if (c.compareTo(PALETURQUOISE) == 0) { + } else if(c.compareTo(PALETURQUOISE) == 0) { this.setRGB(11529966); - } else if (c.compareTo(PALEVIOLETRED) == 0) { + } else if(c.compareTo(PALEVIOLETRED) == 0) { this.setRGB(14381203); - } else if (c.compareTo(PINK) == 0) { + } else if(c.compareTo(PINK) == 0) { this.setRGB(16761035); - } else if (c.compareTo(PLUM) == 0) { + } else if(c.compareTo(PLUM) == 0) { this.setRGB(14524637); - } else if (c.compareTo(PURPLE) == 0) { + } else if(c.compareTo(PURPLE) == 0) { this.setRGB(10494192); - } else if (c.compareTo(SALMON) == 0) { + } else if(c.compareTo(SALMON) == 0) { this.setRGB(16416882); - } else if (c.compareTo(SEAGREEN) == 0) { + } else if(c.compareTo(SEAGREEN) == 0) { this.setRGB(3050327); - } else if (c.compareTo(SIENNA) == 0) { + } else if(c.compareTo(SIENNA) == 0) { this.setRGB(10506797); - } else if (c.compareTo(SKYBLUE) == 0) { + } else if(c.compareTo(SKYBLUE) == 0) { this.setRGB(8900331); - } else if (c.compareTo(SPRINGGREEN) == 0) { + } else if(c.compareTo(SPRINGGREEN) == 0) { this.setRGB(65407); - } else if (c.compareTo(TURQUOISE) == 0) { + } else if(c.compareTo(TURQUOISE) == 0) { this.setRGB(4251856); - } else if (c.compareTo(VIOLET) == 0) { + } else if(c.compareTo(VIOLET) == 0) { this.setRGB(15631086); - } else if (c.compareTo(YELLOWGREEN) == 0) { + } else if(c.compareTo(YELLOWGREEN) == 0) { this.setRGB(10145074); } else { try { int rgb = 0; c = c.toUpperCase(); - if (c.startsWith("0X")) { + if(c.startsWith("0X")) { rgb = Integer.parseInt(c.substring(2), 16); - } else if (c.startsWith("X")) { + } else if(c.startsWith("X")) { rgb = Integer.parseInt(c.substring(1), 16); } else { rgb = Integer.parseInt(c); @@ -288,7 +285,7 @@ public final class SpiderChartSwtColor extends AbstractChartColor { final int g = rgb >> 8 & 0xFF; final int b = rgb & 0xFF; this.setRGB(r, g, b); - } catch (final Exception e) { + } catch(final Exception e) { e.printStackTrace(); this.setRGB(0, 0, 0); } diff --git a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/swt/SpiderChartSwtGraphics.java b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/swt/SpiderChartSwtGraphics.java index 3cf7bd878..da3b80c2c 100644 --- a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/swt/SpiderChartSwtGraphics.java +++ b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/swt/SpiderChartSwtGraphics.java @@ -55,23 +55,22 @@ public final class SpiderChartSwtGraphics extends AbstractChartGraphics { /** Constructor */ public SpiderChartSwtGraphics(final Object g) { - this.graphics = (GC) 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(); + 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) { + if(this.currentColor != null) { this.graphics.setForeground(this.currentColor); this.graphics.setBackground(this.currentColor); } @@ -84,7 +83,7 @@ public final class SpiderChartSwtGraphics extends AbstractChartGraphics { public void dispose() { this.disposeCurrentColor(); this.disposeCurrentFont(); - if (this.graphics != null && !this.graphics.isDisposed()) { + if(this.graphics != null && !this.graphics.isDisposed()) { this.graphics.dispose(); } this.graphics = null; @@ -92,7 +91,7 @@ public final class SpiderChartSwtGraphics extends AbstractChartGraphics { /** */ private void disposeCurrentColor() { - if (this.currentColor != null && !this.currentColor.isDisposed()) { + if(this.currentColor != null && !this.currentColor.isDisposed()) { this.currentColor.dispose(); } this.currentColor = null; @@ -100,7 +99,7 @@ public final class SpiderChartSwtGraphics extends AbstractChartGraphics { /** */ private void disposeCurrentFont() { - if (this.currentFont != null && !this.currentFont.isDisposed()) { + if(this.currentFont != null && !this.currentFont.isDisposed()) { this.currentFont.dispose(); } this.currentFont = null; @@ -108,39 +107,37 @@ public final class SpiderChartSwtGraphics extends AbstractChartGraphics { /** {@inheritDoc} */ @Override - public void drawArc(final int x, final int y, final int w, final int h, - final int a1, final int a2) { + 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) { + public void drawImage(final AbstractChartImage image, final int x, final int y) { + if(image == null) { return; } - if (((SpiderChartSwtImage) image).getImage() == null) { + if(((SpiderChartSwtImage)image).getImage() == null) { return; } - this.graphics.drawImage(((SpiderChartSwtImage) image).getImage(), x, y); + 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) { + 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) { + if(((SpiderChartSwtImage)image).getImage() == null) { return; } - this.graphics.drawImage(((SpiderChartSwtImage) image).getImage(), - x1Source, y1Source, x2Source - x1Source, y2Source - y1Source, - x1Dest, y1Dest, x2Dest - x1Dest, y2Dest - y1Dest); + this.graphics.drawImage(((SpiderChartSwtImage)image).getImage(), x1Source, y1Source, + x2Source - x1Source, y2Source - y1Source, x1Dest, y1Dest, x2Dest - x1Dest, y2Dest - + y1Dest); } /** {@inheritDoc} */ @@ -154,7 +151,7 @@ public final class SpiderChartSwtGraphics extends AbstractChartGraphics { 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++) { + for(int i = 0; i < count; i++) { points[j++] = x1[i]; points[j++] = y1[i]; } @@ -170,8 +167,8 @@ public final class SpiderChartSwtGraphics extends AbstractChartGraphics { /** {@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) { + final AbstractChartColor descColor, final String txt, final int angle, final int x, + final int y, final boolean b) { this.setFont(descFont); this.setColor(descColor); @@ -180,7 +177,7 @@ public final class SpiderChartSwtGraphics extends AbstractChartGraphics { int size = w; int toCenterX = 0; int toCenterY = 0; - if (h > w) { + if(h > w) { size = h; toCenterX = (size - w) / 2; } else { @@ -191,22 +188,18 @@ public final class SpiderChartSwtGraphics extends AbstractChartGraphics { tmpImage.dispose(); Color transparent = null; - if (descColor.getRed() == 255 && descColor.getBlue() == 255 - && descColor.getGreen() == 255) { + 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)); + 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)); + 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(); + final Color c = ((SpiderChartSwtColor)descColor).getColor(); + final Font f = ((SpiderChartSwtFont)descFont).getFont(); g.setForeground(transparent); g.setBackground(transparent); @@ -221,8 +214,7 @@ public final class SpiderChartSwtGraphics extends AbstractChartGraphics { f.dispose(); final AbstractChartImage tmpChartImage = getImage(tmpImage); - this.paintRotatedImage(tmpChartImage, angle, x - (w - h) / 2, y + 4, - ROTATE_CENTER); + this.paintRotatedImage(tmpChartImage, angle, x - (w - h) / 2, y + 4, ROTATE_CENTER); tmpChartImage.dispose(); tmpImage.dispose(); @@ -233,14 +225,13 @@ public final class SpiderChartSwtGraphics extends AbstractChartGraphics { /** {@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); + 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) { + 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); @@ -251,7 +242,7 @@ public final class SpiderChartSwtGraphics extends AbstractChartGraphics { 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++) { + for(int i = 0; i < count; i++) { points[j++] = x1[i]; points[j++] = y1[i]; } @@ -274,6 +265,9 @@ public final class SpiderChartSwtGraphics extends AbstractChartGraphics { return new Float(this.alphaValue); } + /** + * @return alpha value + */ public float getAlphaValue() { return this.alphaValue; } @@ -284,10 +278,16 @@ public final class SpiderChartSwtGraphics extends AbstractChartGraphics { return new SpiderChartSwtColor(this.currentColor); } + /** + * @return current color + */ public Color getCurrentColor() { return this.currentColor; } + /** + * @return current font + */ public Font getCurrentFont() { return this.currentFont; } @@ -303,7 +303,7 @@ public final class SpiderChartSwtGraphics extends AbstractChartGraphics { public int getFontHeight(final AbstractChartFont font) { final Font tmpFont = this.currentFont; this.currentFont = null; - if (font != null) { + if(font != null) { this.setFont(font); } final int result = this.graphics.getFontMetrics().getHeight(); @@ -319,7 +319,7 @@ public final class SpiderChartSwtGraphics extends AbstractChartGraphics { public int getFontWidth(final AbstractChartFont font, final String s) { final Font tmpFont = this.currentFont; this.currentFont = null; - if (font != null) { + if(font != null) { this.setFont(font); } int result = 0; @@ -332,42 +332,35 @@ public final class SpiderChartSwtGraphics extends AbstractChartGraphics { return result; } - /** {@inheritDoc} */ + /** */ protected GC getGraphicForFilling() { - if (this.alphaValue >= 1.0F || this.srcImage == null) { + 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); + 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); + this.transparent = new Color(SwtGraphicsProvider.getDisplay(), 255, 255, 255); } - final RGB[] rgbs = new RGB['Ä€']; + final RGB[] rgbs = new RGB[256]; rgbs[0] = this.transparent.getRGB(); - for (int i = 1; i <= 255; i++) { + 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); + 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); + 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.fillRectangle(0, 0, this.srcImage.getBounds().width, this.srcImage.getBounds().height); g.setForeground(this.currentColor); g.setBackground(this.currentColor); @@ -375,73 +368,73 @@ public final class SpiderChartSwtGraphics extends AbstractChartGraphics { 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(); + 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(); + 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); + 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++) { + 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) { + 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) { + 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) { + } else if(angle == -90) { this.graphics.drawImage(destImage, x, y); } - } else if (angle == 90) { + } else if(angle == 90) { this.graphics.drawImage(destImage, x, y); - } else if (angle == -90) { + } else if(angle == -90) { this.graphics.drawImage(destImage, x, y); } destImage.dispose(); @@ -449,30 +442,27 @@ public final class SpiderChartSwtGraphics extends AbstractChartGraphics { /** */ protected void processFilling(final GC g) { - if (g != this.graphics) { + 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()) { + 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)); + imageData.setAlpha(i, j, (int)(this.alphaValue * 255.0F)); } } } this.transparent.dispose(); this.imageForTransparentFilling.dispose(); - this.imageForTransparentFilling = new Image( - SwtGraphicsProvider.getDisplay(), imageData); + this.imageForTransparentFilling = + new Image(SwtGraphicsProvider.getDisplay(), imageData); this.graphics.drawImage(this.imageForTransparentFilling, 0, 0); this.imageForTransparentFilling.dispose(); @@ -482,26 +472,24 @@ public final class SpiderChartSwtGraphics extends AbstractChartGraphics { /** */ private int rotateX(final int x, final int y, final int angle) { - if (angle == 90) { + if(angle == 90) { return y * -1; } - if (angle == -90) { + if(angle == -90) { return y * 1; } - return (int) (x * Math.cos(Math.toRadians(angle)) - y - * Math.sin(Math.toRadians(angle))); + 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) { + if(angle == 90) { return x * 1; } - if (angle == -90) { + if(angle == -90) { return x * -1; } - return (int) (x * Math.sin(Math.toRadians(angle)) + y - * Math.cos(Math.toRadians(angle))); + return (int)(x * Math.sin(Math.toRadians(angle)) + y * Math.cos(Math.toRadians(angle))); } /** {@inheritDoc} */ @@ -513,11 +501,12 @@ public final class SpiderChartSwtGraphics extends AbstractChartGraphics { /** {@inheritDoc} */ @Override public void setAlphaComposite(final Object a) { - if (a instanceof Float) { - this.alphaValue = ((Float) a).floatValue(); + if(a instanceof Float) { + this.alphaValue = ((Float)a).floatValue(); } } + /** */ public void setAlphaValue(final float alphaValue) { this.alphaValue = alphaValue; } @@ -526,16 +515,18 @@ public final class SpiderChartSwtGraphics extends AbstractChartGraphics { @Override public void setColor(final AbstractChartColor color) { this.disposeCurrentColor(); - this.currentColor = ((SpiderChartSwtColor) color).getColor(); + 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; } @@ -544,17 +535,18 @@ public final class SpiderChartSwtGraphics extends AbstractChartGraphics { @Override public void setFont(final AbstractChartFont font) { this.disposeCurrentFont(); - this.currentFont = ((SpiderChartSwtFont) font).getFont(); + 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) { + /** */ + public void setImageForTransparentFilling(final Image imageForTransparentFilling) { this.imageForTransparentFilling = imageForTransparentFilling; } @@ -570,10 +562,12 @@ public final class SpiderChartSwtGraphics extends AbstractChartGraphics { 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/trunk/src/org/fortiss/tooling/spiderchart/gc/swt/SpiderChartSwtImage.java b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/swt/SpiderChartSwtImage.java index 154f51800..6ad194737 100644 --- a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/swt/SpiderChartSwtImage.java +++ b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/gc/swt/SpiderChartSwtImage.java @@ -48,10 +48,9 @@ public final class SpiderChartSwtImage extends AbstractChartImage { } /** Constructor */ - public SpiderChartSwtImage(final int w, final int h, - final AbstractChartColor transparent) { + public SpiderChartSwtImage(final int w, final int h, final AbstractChartColor transparent) { this.transparentColor = transparent; - final Color trans = ((SpiderChartSwtColor) transparent).getColor(); + final Color trans = ((SpiderChartSwtColor)transparent).getColor(); final Image tmpImage = new Image(SwtGraphicsProvider.getDisplay(), w, h); final ImageData imageData = tmpImage.getImageData(); tmpImage.dispose(); @@ -71,22 +70,22 @@ public final class SpiderChartSwtImage extends AbstractChartImage { /** Constructor */ public SpiderChartSwtImage(final Object o) { try { - if (o instanceof String) { - final InputStream is = SpiderChartSwtImage.class - .getClassLoader().getResourceAsStream((String) o); - if (is != null) { + 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); + 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) { + } catch(final Exception e) { e.printStackTrace(); } } @@ -94,7 +93,7 @@ public final class SpiderChartSwtImage extends AbstractChartImage { /** {@inheritDoc} */ @Override public void dispose() { - if (this.image != null && !this.image.isDisposed()) { + if(this.image != null && !this.image.isDisposed()) { this.image.dispose(); } this.image = null; @@ -106,9 +105,9 @@ public final class SpiderChartSwtImage extends AbstractChartImage { final int w = this.getWidth(); SpiderChartSwtImage dest = null; - if (w > h) { + if(w > h) { dest = new SpiderChartSwtImage(w, w, this.transparentColor); - } else if (h > w) { + } else if(h > w) { dest = new SpiderChartSwtImage(h, h, this.transparentColor); } else { return this; @@ -123,8 +122,7 @@ public final class SpiderChartSwtImage extends AbstractChartImage { /** {@inheritDoc} */ @Override public AbstractChartGraphics getGraphics() { - final SpiderChartSwtGraphics g = new SpiderChartSwtGraphics(new GC( - this.image)); + final SpiderChartSwtGraphics g = new SpiderChartSwtGraphics(new GC(this.image)); g.setSrcImage(this.image); return g; } @@ -132,12 +130,13 @@ public final class SpiderChartSwtImage extends AbstractChartImage { /** {@inheritDoc} */ @Override public int getHeight() { - if (this.image == null) { + if(this.image == null) { return 0; } return this.image.getBounds().height; } + /** */ public Image getImage() { return this.image; } @@ -145,7 +144,7 @@ public final class SpiderChartSwtImage extends AbstractChartImage { /** {@inheritDoc} */ @Override public int getWidth() { - if (this.image == null) { + if(this.image == null) { return 0; } return this.image.getBounds().width; diff --git a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/label/SpiderChartLabel.java b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/label/SpiderChartLabel.java index e4fbed6ef..41f5d0712 100644 --- a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/label/SpiderChartLabel.java +++ b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/label/SpiderChartLabel.java @@ -104,10 +104,15 @@ public final class SpiderChartLabel implements IFloatingObject { /** */ private String tip = ""; - /** Constructor */ - public SpiderChartLabel(String pformat, final String pvalue, - final boolean pvertical, final boolean pCenter) { - if (pformat.length() == 0) { + /** + * Constructor + * + * @param pvertical + * @param pCenter + */ + public SpiderChartLabel(String pformat, final String pvalue, final boolean pvertical, + final boolean pCenter) { + if(pformat.length() == 0) { pformat = pvalue; } this.sFormat = pformat; @@ -184,8 +189,7 @@ public final class SpiderChartLabel implements IFloatingObject { 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.requiredWidth, this.positionY + this.requiredHeight); pol.addPoint(this.positionX, this.positionY + this.requiredHeight); return pol; } @@ -232,7 +236,9 @@ public final class SpiderChartLabel implements IFloatingObject { return this.positionY; } - /** */ + /** + * @param g + */ public void initialize(final AbstractChartGraphics g, final SpiderChart c) { this.chart = c; } @@ -242,10 +248,15 @@ public final class SpiderChartLabel implements IFloatingObject { 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) { + /** + * @param x + * @param y + * @param width + * @param height + */ + 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); } @@ -255,96 +266,75 @@ public final class SpiderChartLabel implements IFloatingObject { /** */ 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, + 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 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); + 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) { + 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_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_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); + 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) { + if(this.align == ALIGN_CENTER) { x += (this.requiredWidth - this.marginX * 2 - this.lineWidths[0]) / 2; } - if (this.align == ALIGN_RIGHT) { + 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.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_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); + 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); + 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); } /** */ diff --git a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/label/api/IFloatingObject.java b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/label/api/IFloatingObject.java index 40729685e..cfee6f715 100644 --- a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/label/api/IFloatingObject.java +++ b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/label/api/IFloatingObject.java @@ -19,6 +19,14 @@ package org.fortiss.tooling.spiderchart.label.api; import org.fortiss.tooling.spiderchart.gc.Polygon; +/** + * Floating Object Graphics to be used on the chart + * + * @author AMIT + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ public interface IFloatingObject { /** Layer ID to be used to identify the component */ diff --git a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/listener/ISpiderChartListener.java b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/listener/ISpiderChartListener.java index 7905e00b1..cf0f8897f 100644 --- a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/listener/ISpiderChartListener.java +++ b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/listener/ISpiderChartListener.java @@ -20,6 +20,14 @@ package org.fortiss.tooling.spiderchart.listener; import org.fortiss.tooling.spiderchart.SpiderChart; import org.fortiss.tooling.spiderchart.gc.AbstractChartGraphics; +/** + * Spider Chart Listener Events + * + * @author AMIT + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ public interface ISpiderChartListener { /** To be fired on clicking on chart canvas */ diff --git a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/listener/SpiderChartAdapter.java b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/listener/SpiderChartAdapter.java index f6177c9d9..edd7aa379 100644 --- a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/listener/SpiderChartAdapter.java +++ b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/listener/SpiderChartAdapter.java @@ -31,11 +31,12 @@ 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) { + public void onPaintUserExit(final SpiderChart c, final AbstractChartGraphics g) { + // } } diff --git a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/plotter/AbstractPlotter.java b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/plotter/AbstractPlotter.java index ff83cd0b6..19bac0c4d 100644 --- a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/plotter/AbstractPlotter.java +++ b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/plotter/AbstractPlotter.java @@ -66,14 +66,14 @@ public abstract class AbstractPlotter extends SpiderChartComponent { /** calculates the max values in the provided scale */ private void calculateMax(final SpiderChartScale s, final double m) { - if (!s.isExactMaxValue()) { + 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) { + if(value != null && value.length > 0) { + for(final double preferred_MaxMin_value : value) { + if(preferred_MaxMin_value >= m) { s.setMax(preferred_MaxMin_value); break; @@ -84,14 +84,14 @@ public abstract class AbstractPlotter extends SpiderChartComponent { /** calculates the min values in the provided scale */ private void calculateMin(final SpiderChartScale s, final double m) { - if (!s.isExactMinValue()) { + 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) { + if(value != null && value.length > 0) { + for(int j = value.length - 1; j > 0; j--) { + if(value[j] <= m) { s.setMin(value[j]); break; @@ -100,13 +100,23 @@ public abstract class AbstractPlotter extends SpiderChartComponent { } } - /** returns the active x scaling */ + /** + * returns the active x scaling + * + * @param s + * the data sequence + */ protected SpiderChartScale getActiveXScale(final DataSeq s) { final SpiderChartScale scale = this.xScale; return scale; } - /** returns the active y scaling */ + /** + * returns the active y scaling + * + * @param s + * the data sequence + */ protected SpiderChartScale getActiveYScale(final DataSeq s) { final SpiderChartScale scale = this.yScale; return scale; @@ -180,82 +190,94 @@ public abstract class AbstractPlotter extends SpiderChartComponent { /** plots the values */ public void plot(final AbstractChartGraphics g) { - for (int i = 0; i < this.seq.size(); i++) { + for(int i = 0; i < this.seq.size(); i++) { final DataSeq s = this.seq.get(i); this.plot(g, s, i); } } - /** plots the values */ - protected void plot(final AbstractChartGraphics g, final DataSeq s, - final int serieSec) { + /** + * plots the values + * + * @param g + * the abstract graphics + * @param s + * the data sequence + * @param serieSec + * the series section + */ + protected void plot(final AbstractChartGraphics g, final DataSeq s, final int serieSec) { + // } - /** plots the background of the plotting canvas */ - 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); + /** + * plots the background of the plotting canvas + * + * @param offsetX + * @param offsetY + */ + 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) { + if(this.backgroundImage != null) { final int w = this.backgroundImage.getWidth(); final int h = this.backgroundImage.getHeight(); - if (w > -1 && h > -1) { + if(w > -1 && h > -1) { int toCenterX = (bw - w) / 2; - if (toCenterX < 0) { + if(toCenterX < 0) { toCenterX = 0; } int toCenterY = (bh - h) / 2; - if (toCenterY < 0) { + if(toCenterY < 0) { toCenterY = 0; } - g.drawImage(this.backgroundImage, toCenterX + this.x, this.y - + toCenterY); + g.drawImage(this.backgroundImage, toCenterX + this.x, this.y + toCenterY); } } } /** replaces a sequence with the provided one */ + @SuppressWarnings("cast") public void replaceSeq(final int p, final DataSeq s) { final SpiderChartScale tmpScaleX = this.getActiveXScale(s); this.getActiveYScale(s); - if (p >= this.seq.size()) { + if(p >= this.seq.size()) { return; } - if (this.seq.size() > 3) { + if(this.seq.size() > 3) { return; } - if (p == -1) { + 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) { + 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++) { + for(int si = 0; si < this.seq.size(); si++) { final DataSeq ser = this.seq.get(si); } } - if (XValue >= tmpScaleX.getMax()) { + if(XValue >= tmpScaleX.getMax()) { this.calculateMax(tmpScaleX, XValue); } - if (XValue < tmpScaleX.getMin()) { + if(XValue < tmpScaleX.getMin()) { this.calculateMin(tmpScaleX, XValue); } - if (!fixedLimits) { - if (YValue > this.yScale.getMax()) { + if(!fixedLimits) { + if(YValue > this.yScale.getMax()) { this.calculateMax(this.yScale, YValue); } - if (YValue < this.yScale.getMin()) { + if(YValue < this.yScale.getMin()) { this.calculateMin(this.yScale, YValue); } } @@ -290,7 +312,7 @@ public abstract class AbstractPlotter extends SpiderChartComponent { /** */ public void setSeq(final int p, final DataSeq s) { - if (p < this.seq.size()) { + if(p < this.seq.size()) { this.seq.set(p, s); } } diff --git a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/plotter/spider/SpiderChartPlotter.java b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/plotter/spider/SpiderChartPlotter.java index 14b66bf44..568f24e06 100644 --- a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/plotter/spider/SpiderChartPlotter.java +++ b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/plotter/spider/SpiderChartPlotter.java @@ -264,27 +264,29 @@ public final class SpiderChartPlotter extends AbstractPlotter { } /** {@inheritDoc} **/ - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({"unchecked", "rawtypes"}) @Override - protected void plot(final AbstractChartGraphics g, final DataSeq s, - final int seqSec) { + protected void plot(final AbstractChartGraphics g, final DataSeq s, final int seqSec) { LineDataSeq p = null; - if (s instanceof LineDataSeq) { - p = (LineDataSeq) s; + if(s instanceof LineDataSeq) { + p = (LineDataSeq)s; } s.getHotAreas().clear(); + double count = 0; - final double count = p.getyData().size(); + if(p != null) { + count = p.getyData().size(); + } - final int[] xs = new int[(int) count]; - final int[] ys = new int[(int) count]; + final int[] xs = new int[(int)count]; + final int[] ys = new int[(int)count]; int radi = 0; radi = this.width; - if (this.height < radi) { + if(this.height < radi) { radi = this.height; } - radi = (int) (radi * this.chartRadius); + radi = (int)(radi * this.chartRadius); final int toCenterX = (this.width - radi) / 2; final int toCenterY = (this.height - radi) / 2; @@ -292,123 +294,126 @@ public final class SpiderChartPlotter extends AbstractPlotter { 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 || 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++) { + 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) { + 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)); + 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); + 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); + 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++) { + for(int i = 0; i < count; i++) { angle = 360.0D / count * i; angle += 90.0D; - if (angle > 360.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)); + 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); + this.border.draw(g, PieCenterX, PieCenterY, PieCenterX + relativeX, PieCenterY + + relativeY); } } - if (seqSec == 0 && this.axisFactorFont != null) { + if(seqSec == 0 && this.axisFactorFont != null) { g.setFont(this.axisFactorFont); - for (int i = 0; i < count; i++) { + for(int i = 0; i < count; i++) { g.setColor(this.axisFactorColor); - if (this.axisFactorColors != null - && this.axisFactorColors.length > i) { + 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) { + if(angle > 360.0D) { angle -= 360.0D; } - final int tmpradi = (int) (radi * 1.1D / 2.0D); + final int tmpradi = (int)(radi * 1.1D / 2.0D); int correction = 0; - if (angle > 120.0D && angle < 240.0D) { + 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); + 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); + if(this.axesFactors.length > i) { + g.drawText(this.axesFactors[i], PieCenterX + relativeX - correction, + PieCenterY + relativeY); } } } } - for (int i = 0; i < count; i++) { + for(int i = 0; i < count; i++) { angle = 360.0D / count * i; angle += 90.0D; - if (angle > 360.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) { + if(this.minScaleFactors.length >= i + 1) { min = this.minScaleFactors[i]; } - if (this.maxScaleFactors.length >= i + 1) { + if(this.maxScaleFactors.length >= i + 1) { max = this.maxScaleFactors[i]; } - tmpradi = (int) ((((Double) p.getElementY(i)).doubleValue() - min) * 100.0D / (max - min)); + if(p != null) + 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)); + 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); - } + if(p != null) + if(p.getStyle() != null) { + p.getStyle().drawPolygon(g, xs, ys, (int)count); + } + if(p != null) + if(p.getFillStyle() != null) { + p.getFillStyle().drawPolygon(g, xs, ys, (int)count); + } int kl = 0; - for (int i = 0; i < count; i++) { + 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); @@ -416,140 +421,138 @@ public final class SpiderChartPlotter extends AbstractPlotter { 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; + if(p != null) + 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]; } - 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); + } } - 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()); + if(p != null) + if(p.getValueFont() != null) { + g.setColor(p.getValueColor()); + g.setFont(p.getValueFont()); - YValue = ((Double) p.getElementY(i)).doubleValue(); + YValue = ((Double)p.getElementY(i)).doubleValue(); - String txt = p.doubleToString(new Double(YValue)); + 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]; + 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]); } - g.drawText(txt, xs[i] + 7, ys[i]); - } } - if (this.gridStyle != null) { + 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++) { + 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++) { + 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; + 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++) { + for(int j = 0; j < this.scalingDivisions; j++) { tickAt += tickInterval; - for (int k = 0; k < xs.length; k++) { + for(int k = 0; k < xs.length; k++) { tickAtAbsValues[k] += tickIntervalAbsValues[k]; } - for (int i = 0; i < count; i++) { + for(int i = 0; i < count; i++) { angle = 360.0D / count * i; angle += 90.0D; - if (angle > 360.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)); + 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.gridStyle.drawPolygon(g, xs, ys, (int)count); } - if (seqSec >= this.getSeq().size() - 1 && this.gridFont != null) { + 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++) { + for(int i = 0; i < tickValues.length; i++) { tickValues[i] = tickAtAbsValues[i]; values[i] = "" + tickValues[i]; - if (this.scalingLabelFormat.length > 0) { + 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 String) { + df = new DecimalFormat((String)this.scalingLabelFormat[i]); + values[i] = df.format(new Double(tickValues[i])); } - if (scalingLabel instanceof Class<?>) { - if (((Class<?>) scalingLabel).isEnum()) { + if(scalingLabel instanceof Class<?>) { + if(((Class<?>)scalingLabel).isEnum()) { try { - values[i] = (String) enumConstants( - (Class<Enum>) scalingLabel) - .get(kl++); - } catch (final Exception e) { + values[i] = + (String)enumConstants((Class<Enum>)scalingLabel) + .get(kl++); + } catch(final Exception e) { + e.printStackTrace(); } } } } } - if (this.markScalesOnEveryAxis) { - for (int k = 0; k < xs.length; k++) { - g.drawText("" + values[k], - xs[k] - 3 - g.getFontWidth("" + values[k]), + 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]), + g.drawText("" + values[0], xs[0] - 3 - g.getFontWidth("" + values[0]), ys[0]); } diff --git a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/style/LineStyle.java b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/style/LineStyle.java index 43a25ac5f..1d2bec85e 100644 --- a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/style/LineStyle.java +++ b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/style/LineStyle.java @@ -40,8 +40,7 @@ public final class LineStyle { public static final int NORMAL_LINE = 1; /** Factory method to create line */ - public static LineStyle of(final float w, final AbstractChartColor c, - final int t) { + public static LineStyle of(final float w, final AbstractChartColor c, final int t) { return new LineStyle(w, c, t); } @@ -63,56 +62,60 @@ public final class LineStyle { this.color = c; } - /** Constructor */ - public LineStyle(final float w, final AbstractChartColor c, final int t, - final float alpha) { + /** + * Constructor + * + * @param alpha + * alpha value for the line + */ + public LineStyle(final float w, final AbstractChartColor c, final int t, final float alpha) { this(w, c, t); } /** Draws the line */ - public void draw(final AbstractChartGraphics g, final int x1, final int y1, - final int x2, final int y2) { + 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); } /** Draws arc */ - public void drawArc(final AbstractChartGraphics g, final int x, - final int y, final int w, final int h, final int a1, final int a2) { + 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); } /** Draws open ended polygon */ - public void drawOpenPolygon(final AbstractChartGraphics g, final int[] x, - final int[] y, final int c) { - for (int i = 1; i < c; i++) { + 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]); } } /** Draws polygon */ - public void drawPolygon(final AbstractChartGraphics g, final int[] x, - final int[] y, final int c) { - for (int i = 1; i < c; 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]); } /** Draws Rectangle */ - public void drawRect(final AbstractChartGraphics g, final int x1, - final int y1, final int x2, final int y2) { + 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) { + if(w < 0) { w *= -1; iX = x2; } - if (h < 0) { + if(h < 0) { h *= -1; iY = y2; } @@ -121,17 +124,17 @@ public final class LineStyle { } /** Draws Round Rectangle */ - public void drawRoundRect(final AbstractChartGraphics g, final int x1, - final int y1, final int x2, final int y2) { + 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) { + if(w < 0) { w *= -1; iX = x2; } - if (h < 0) { + if(h < 0) { h *= -1; iY = y2; } @@ -191,16 +194,16 @@ public final class LineStyle { /** Setter for the graphics properties */ protected void setGraphicsProperties(final AbstractChartGraphics g) { g.setColor(this.color); - int tmp = (int) this.lineWidth; - if (tmp == 0 && this.lineWidth > 0.0F) { + 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) { + if(this.lineType == 2) { g.setLineStyle(STROKE_DASHED); } - if (this.lineType == 3) { + if(this.lineType == 3) { g.setLineStyle(STROKE_DOTTED); } } diff --git a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/swt/SpiderChartCanvas.java b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/swt/SpiderChartCanvas.java index cdf5b699a..6ef0a2512 100644 --- a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/swt/SpiderChartCanvas.java +++ b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/swt/SpiderChartCanvas.java @@ -39,8 +39,7 @@ import org.fortiss.tooling.spiderchart.listener.ISpiderChartListener; * @author AMIT KUMAR MONDAL * */ -public final class SpiderChartCanvas extends Canvas implements -ISpiderChartListener { +public final class SpiderChartCanvas extends Canvas implements ISpiderChartListener { /** Actual Spider Chart Ref */ private SpiderChart chart = null; @@ -50,8 +49,7 @@ ISpiderChartListener { super(parent, style | CTRL); this.addPaintListener(e -> SpiderChartCanvas.this.paintChart(e)); - final MouseMoveListener mouseMove = e -> SpiderChartCanvas.this - .mouseMoved(e); + final MouseMoveListener mouseMove = e -> SpiderChartCanvas.this.mouseMoved(e); this.addMouseMoveListener(mouseMove); final MouseAdapter mouseAdapter = new MouseAdapter() { @@ -67,6 +65,7 @@ ISpiderChartListener { /** {@inheritDoc} */ @Override public void controlMoved(final ControlEvent e) { + // Not used } /** {@inheritDoc} */ @@ -84,14 +83,14 @@ ISpiderChartListener { /** Mouse Click event */ private void mouseClick() { - if (this.chart != null) { + if(this.chart != null) { this.chart.mouseClick(); } } /** Mouse Moved Event */ private void mouseMoved(final MouseEvent e) { - if (this.chart != null) { + if(this.chart != null) { this.chart.mouseMoved(e.x, e.y); } } @@ -99,12 +98,12 @@ ISpiderChartListener { /** {@inheritDoc} */ @Override public void onChartEvent(final SpiderChart c, final int type) { - if (type == 4) { + if(type == 4) { this.redraw(); } - if (type == 1) { + if(type == 1) { startUiThread(() -> { - if (!SpiderChartCanvas.this.isDisposed()) { + if(!SpiderChartCanvas.this.isDisposed()) { SpiderChartCanvas.this.redraw(); } }); @@ -113,8 +112,8 @@ ISpiderChartListener { /** {@inheritDoc} */ @Override - public void onPaintUserExit(final SpiderChart c, - final AbstractChartGraphics g) { + public void onPaintUserExit(final SpiderChart c, final AbstractChartGraphics g) { + // Not used } /** Draws the Spider Chart */ @@ -124,7 +123,7 @@ ISpiderChartListener { final AbstractChartGraphics g = getGraphics(e.gc); this.chart.paint(g); g.dispose(); - } catch (final Exception err) { + } catch(final Exception err) { err.printStackTrace(); } } @@ -137,7 +136,7 @@ ISpiderChartListener { /** Setter for Spider Chart */ public void setChart(final SpiderChart c) { - if (this.chart != null) { + if(this.chart != null) { this.chart.removeChartListener(this); } this.chart = c; diff --git a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/swt/SpiderChartViewer.java b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/swt/SpiderChartViewer.java index aa79c169e..8c425269d 100644 --- a/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/swt/SpiderChartViewer.java +++ b/org.fortiss.tooling.spiderchart.ui/trunk/src/org/fortiss/tooling/spiderchart/swt/SpiderChartViewer.java @@ -57,13 +57,11 @@ public final class SpiderChartViewer extends Composite { /** {@inheritDoc} */ @Override public void onChartEvent(final SpiderChart c, final int type) { - if (type == 2) { - SpiderChartViewer.this.canvas - .setCursor(SpiderChartViewer.this.pointCursor); + if(type == 2) { + SpiderChartViewer.this.canvas.setCursor(SpiderChartViewer.this.pointCursor); } - if (type == 3) { - SpiderChartViewer.this.canvas - .setCursor(SpiderChartViewer.this.defaultCursor); + if(type == 3) { + SpiderChartViewer.this.canvas.setCursor(SpiderChartViewer.this.defaultCursor); } } }; @@ -152,6 +150,7 @@ public final class SpiderChartViewer extends Composite { /** {@inheritDoc} */ @Override public void widgetDefaultSelected(final SelectionEvent e) { + // Not used } /** {@inheritDoc} */ @@ -164,6 +163,7 @@ public final class SpiderChartViewer extends Composite { /** {@inheritDoc} */ @Override public void widgetDefaultSelected(final SelectionEvent e) { + // Not used } /** {@inheritDoc} */ @@ -176,12 +176,13 @@ public final class SpiderChartViewer extends Composite { /** {@inheritDoc} */ @Override public void widgetDefaultSelected(final SelectionEvent e) { + // Not used } /** {@inheritDoc} */ @Override public void widgetSelected(final SelectionEvent e) { - if (SpiderChartViewer.this.canvas.getChart() == null) { + if(SpiderChartViewer.this.canvas.getChart() == null) { return; } SpiderChartViewer.this.hSliderScroll(); @@ -191,12 +192,13 @@ public final class SpiderChartViewer extends Composite { /** {@inheritDoc} */ @Override public void widgetDefaultSelected(final SelectionEvent e) { + // Not used } /** {@inheritDoc} */ @Override public void widgetSelected(final SelectionEvent e) { - if (SpiderChartViewer.this.canvas.getChart() == null) { + if(SpiderChartViewer.this.canvas.getChart() == null) { return; } SpiderChartViewer.this.vSliderScroll(); @@ -206,12 +208,13 @@ public final class SpiderChartViewer extends Composite { /** {@inheritDoc} */ @Override public void controlMoved(final ControlEvent e) { + // Not used } /** {@inheritDoc} */ @Override public void controlResized(final ControlEvent e) { - if (SpiderChartViewer.this.canvas.getChart() == null) { + if(SpiderChartViewer.this.canvas.getChart() == null) { return; } SpiderChartViewer.this.placeZoomControls(); @@ -226,10 +229,10 @@ public final class SpiderChartViewer extends Composite { @Override public void dispose() { super.dispose(); - if (this.pointCursor != null && !this.pointCursor.isDisposed()) { + if(this.pointCursor != null && !this.pointCursor.isDisposed()) { this.pointCursor.dispose(); } - if (this.defaultCursor != null && !this.defaultCursor.isDisposed()) { + if(this.defaultCursor != null && !this.defaultCursor.isDisposed()) { this.defaultCursor.dispose(); } } @@ -344,14 +347,12 @@ public final class SpiderChartViewer extends Composite { // 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()) { + if(newValue + this.canvas.getChart().getWidth() < this.canvas.getChart().getVirtualWidth()) { newBase = newValue; } else { - newBase = this.canvas.getChart().getVirtualWidth() - - this.canvas.getChart().getWidth(); + newBase = this.canvas.getChart().getVirtualWidth() - this.canvas.getChart().getWidth(); } - if (newBase < 0) { + if(newBase < 0) { newBase = 0; } this.canvas.getChart().setOffsetX(newBase); @@ -376,33 +377,30 @@ public final class SpiderChartViewer extends Composite { int hSliderHeight = 0; int vSliderWidth = 0; - if (this.canvas.getChart().getVirtualWidth() > 0) { + if(this.canvas.getChart().getVirtualWidth() > 0) { hSliderHeight = this.scrollBarWidth; } - if (this.canvas.getChart().getVirtualHeight() > 0) { + if(this.canvas.getChart().getVirtualHeight() > 0) { vSliderWidth = this.scrollBarWidth; } - this.canvas.setSize(this.getSize().x - vSliderWidth, this.getSize().y - - hSliderHeight); + 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)) { + 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, + 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); @@ -410,9 +408,8 @@ public final class SpiderChartViewer extends Composite { } else { this.hSlider.setVisible(false); } - if (this.canvas.getChart().getVirtualWidth() > 0) { - this.vSlider - .setSize(vSliderWidth, this.getSize().y - hSliderHeight); + 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); @@ -450,7 +447,7 @@ public final class SpiderChartViewer extends Composite { /** setter for chart instance */ public void setChart(final SpiderChart c) { - if (this.canvas.getChart() != null) { + if(this.canvas.getChart() != null) { this.canvas.getChart().removeChartListener(this.chartAdapter); } this.canvas.setChart(c); @@ -461,7 +458,7 @@ public final class SpiderChartViewer extends Composite { this.resetChart(); this.placeZoomControls(); this.updateSize(); - if (this.changePointer) { + if(this.changePointer) { this.canvas.getChart().addChartListener(this.chartAdapter); } } @@ -554,22 +551,21 @@ public final class SpiderChartViewer extends Composite { /** updates the canvas size based on scrolling and zoom */ private void updateSize() { this.canvas.getChart().setRepaintAll(true); - if (this.lastWidth != this.getSize().x - || this.lastHeight != this.getSize().y - || this.lastZoom != this.currentZoom) { + 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) { + 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) { + if(this.originalWidth > 0) { this.canvas.getChart().setVirtualWidth( this.originalWidth * this.currentZoom / 100); } else { @@ -577,11 +573,11 @@ public final class SpiderChartViewer extends Composite { } } int w = 1 + this.getSize().x; - if (this.originalHeight > 0) { + if(this.originalHeight > 0) { w -= this.vSlider.getSize().x; } int h = 1 + this.getSize().y; - if (this.originalWidth > 0) { + if(this.originalWidth > 0) { h -= this.hSlider.getSize().y; } this.canvas.getChart().setRepaintAll(true); @@ -596,14 +592,14 @@ public final class SpiderChartViewer extends Composite { // 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()) { + if(newValue + this.canvas.getChart().getHeight() < this.canvas.getChart() + .getVirtualHeight()) { newBase = newValue; } else { - newBase = this.canvas.getChart().getVirtualHeight() - - this.canvas.getChart().getHeight(); + newBase = + this.canvas.getChart().getVirtualHeight() - this.canvas.getChart().getHeight(); } - if (newBase < 0) { + if(newBase < 0) { newBase = 0; } this.canvas.getChart().setOffsetY(newBase); @@ -612,7 +608,7 @@ public final class SpiderChartViewer extends Composite { /** zooms in */ private void zoomIn() { - if (this.currentZoom + this.zoomIncrement < this.maxZoom) { + if(this.currentZoom + this.zoomIncrement < this.maxZoom) { this.currentZoom += this.zoomIncrement; } else { this.currentZoom = this.maxZoom; @@ -622,7 +618,7 @@ public final class SpiderChartViewer extends Composite { /** zooms out */ private void zoomOut() { - if (this.currentZoom - this.zoomIncrement > this.minZoom) { + if(this.currentZoom - this.zoomIncrement > this.minZoom) { this.currentZoom -= this.zoomIncrement; } else { this.currentZoom = this.minZoom; -- GitLab