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

More code removed.

refs 2589
parent 1f1ca31f
No related branches found
No related tags found
No related merge requests found
......@@ -120,9 +120,6 @@ public final class SpiderChart {
/** Previous Y Coordinate of the cursor */
private int cursorLastY = 0;
/** Needed to use buffering of values (WIP) */
private final boolean doubleBuffering = true;
/** the rendered spider chart image */
private AbstractChartImage finalImage = null;
......@@ -171,11 +168,8 @@ public final class SpiderChart {
/** */
private int originalVirtualWidth = -1;
/** All the plotters to be used for spider chart plotting */
private AbstractPlotter[] plotters = new SpiderChartPlotter[10];
/** no of plotters */
private int plottersCount = 0;
/** The plotters to be used for spider chart plotting. */
private AbstractPlotter plotter;
/** configuration for repainting the chart */
private boolean repaintAll = true;
......@@ -225,9 +219,6 @@ public final class SpiderChart {
/** Width of the chart */
private int width = 0;
/** Scrollable Chart Property */
private boolean withScroll = false;
/** Constructor */
public SpiderChart(final SpiderChartTitle t, final SpiderChartPlotter p) {
this.resetChart(t, p);
......@@ -244,28 +235,23 @@ 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.plottersCount += 1;
public void setPlotter(SpiderChartPlotter p) {
plotter = p;
}
/** Adds the sequence */
public void addSeq(final DataSeq s) {
this.plotters[0].addSeq(s);
plotter.addSeq(s);
}
/** 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) {
lseq.getIcon().dispose();
}
if(plotter != null) {
for(int j = 0; j < plotter.getSeqCount(); j++) {
if(plotter.getSeq(j) instanceof LineDataSeq) {
LineDataSeq lseq = (LineDataSeq)plotter.getSeq(j);
if(lseq.getIcon() != null) {
lseq.getIcon().dispose();
}
}
}
......@@ -438,14 +424,9 @@ public final class SpiderChart {
return this.originalVirtualWidth;
}
/** Getter for all the plotters */
public AbstractPlotter[] getPlotters() {
return this.plotters;
}
/** Getter for the count of the plotters */
public int getPlottersCount() {
return this.plottersCount;
/** Returns the plotter. */
public AbstractPlotter getPlotter() {
return plotter;
}
/** Getter for margin from right */
......@@ -470,7 +451,8 @@ public final class SpiderChart {
/** Getter for the first plotter to be used */
public SpiderChartPlotter getSpiderPlotter() {
return (SpiderChartPlotter)this.plotters[0];
// FIXME: wild cast
return (SpiderChartPlotter)plotter;
}
/** Getter for the tip color */
......@@ -533,11 +515,6 @@ public final class SpiderChart {
return this.autoResize;
}
/** Getter for the configuration to check if double buffering is enabled */
public boolean isDoubleBuffering() {
return this.doubleBuffering;
}
/**
* Getter for the configuration to check if X-axis screen margin will be set
*/
......@@ -574,9 +551,10 @@ public final class SpiderChart {
}
/** Getter for the configuration if the chart has scrolling functionality */
public boolean isWithScroll() {
return this.withScroll;
}
// FIXME: remove scroll support
// public boolean isWithScroll() {
// return this.withScroll;
// }
/** Mouse Click Functionality */
public void mouseClick() {
......@@ -589,7 +567,7 @@ public final class SpiderChart {
/** Mouse Move Functionality */
public void mouseMoved(final int eX, final int eY) {
if(this.plotters[0] == null) {
if(plotter == null) {
return;
}
......@@ -606,39 +584,34 @@ public final class SpiderChart {
this.selectedLabel = null;
this.selectedSeqPoint = -1;
if(this.activateSelection) {
for(final AbstractPlotter plotter : this.plotters) {
if(plotter == null) {
break;
}
for(int k = 0; k < plotter.getSeqCount(); k++) {
final DataSeq d = plotter.getSeq(k);
for(int i = 0; i < d.getHotAreas().size(); i++) {
if(((Polygon)d.getHotAreas().get(i)).contains(this.currentX + this.offsetX,
this.currentY + this.offsetY)) {
boolean triggerEnter = false;
if(previousSelectedObject == null) {
triggerEnter = true;
} else if(previousSelectedObject != d || previousPoint != i) {
this.triggerChartEvent(EVENT_LEAVE_POINT);
triggerEnter = true;
}
this.selectedSeq = d;
this.selectedSeqPoint = i;
if(!triggerEnter) {
break;
}
this.triggerChartEvent(EVENT_ENTER_POINT);
for(int k = 0; k < plotter.getSeqCount(); k++) {
final DataSeq d = plotter.getSeq(k);
for(int i = 0; i < d.getHotAreas().size(); i++) {
if(((Polygon)d.getHotAreas().get(i)).contains(this.currentX + this.offsetX,
this.currentY + this.offsetY)) {
boolean triggerEnter = false;
if(previousSelectedObject == null) {
triggerEnter = true;
} else if(previousSelectedObject != d || previousPoint != i) {
this.triggerChartEvent(EVENT_LEAVE_POINT);
triggerEnter = true;
}
this.selectedSeq = d;
this.selectedSeqPoint = i;
if(!triggerEnter) {
break;
}
this.triggerChartEvent(EVENT_ENTER_POINT);
break;
}
}
}
if(Math.abs(this.currentX - this.cursorLastX) > 2 ||
Math.abs(this.currentY - this.cursorLastY) > 2) {
this.cursorLastX = this.currentX;
this.cursorLastY = this.currentY;
this.triggerChartEvent(EVENT_TIP_UPDATE);
}
}
if(Math.abs(this.currentX - this.cursorLastX) > 2 ||
Math.abs(this.currentY - this.cursorLastY) > 2) {
this.cursorLastX = this.currentX;
this.cursorLastY = this.currentY;
this.triggerChartEvent(EVENT_TIP_UPDATE);
}
if(previousSelectedObject != null && this.selectedSeq == null && this.selectedLabel == null) {
this.triggerChartEvent(EVENT_LEAVE_POINT);
......@@ -649,7 +622,7 @@ public final class SpiderChart {
public void paint(SpiderChartSwtGraphics graphics) {
this.floatingObjects.clear();
if(this.plotters[0] == null || this.plottersCount <= 0) {
if(plotter == null) {
graphics.setColor(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
graphics.drawText("No plotters have been found", 30, 30);
return;
......@@ -661,7 +634,8 @@ public final class SpiderChart {
if(legend != null) {
legend.draw(graphics);
return;
// FIXME: break out
// return;
}
// FIXME: untested parts follow
......@@ -679,21 +653,23 @@ public final class SpiderChart {
if(this.originalVirtualWidth == -1) {
this.originalVirtualWidth = this.virtualWidth;
}
if(!this.withScroll) {
this.repaintAlways = true;
}
// FIXME: remove scroll support
// if(!this.withScroll) {
this.repaintAlways = true;
// }
if(this.repaintAlways) {
this.repaintAll = true;
}
if(this.autoResize) {
if(!this.withScroll) {
this.virtualHeight = this.originalVirtualHeight;
this.virtualWidth = this.originalVirtualWidth;
}
// FIXME: remove scroll support
// if(!this.withScroll) {
this.virtualHeight = this.originalVirtualHeight;
this.virtualWidth = this.originalVirtualWidth;
// }
this.resize();
}
try {
if(this.doubleBuffering && (this.repaintAll || this.finalImage == null)) {
if(this.repaintAll || this.finalImage == null) {
if(this.finalImage != null) {
this.finalImage.dispose();
}
......@@ -707,22 +683,23 @@ public final class SpiderChart {
gScroll = g;
gBack = g;
}
if(this.withScroll) {
if(this.repaintAll || this.chartImage == null) {
if(this.chartImage != null) {
this.chartImage.dispose();
}
this.chartImage = createImage(this.virtualWidth, this.virtualHeight);
}
gScroll = this.chartImage.getGraphics();
if(this.repaintAll || this.backTmpImage == null) {
if(this.backTmpImage != null) {
this.backTmpImage.dispose();
}
this.backTmpImage = createImage(this.virtualWidth, this.virtualHeight);
}
gBack = this.backTmpImage.getGraphics();
}
// FIXME: remove scroll support
// if(this.withScroll) {
// if(this.repaintAll || this.chartImage == null) {
// if(this.chartImage != null) {
// this.chartImage.dispose();
// }
// this.chartImage = createImage(this.virtualWidth, this.virtualHeight);
// }
// gScroll = this.chartImage.getGraphics();
// if(this.repaintAll || this.backTmpImage == null) {
// if(this.backTmpImage != null) {
// this.backTmpImage.dispose();
// }
// this.backTmpImage = createImage(this.virtualWidth, this.virtualHeight);
// }
// gBack = this.backTmpImage.getGraphics();
// }
if(this.repaintAll) {
if(this.backStyle != null) {
this.backStyle.draw(gBack, getBackgroundCanvasColor(), 0, 0, this.virtualWidth,
......@@ -732,37 +709,35 @@ public final class SpiderChart {
this.drawBackImage(gBack);
}
}
if(this.withScroll && (this.backImage != null || this.backStyle != null)) {
if(this.repaintAll) {
gScroll.drawImage(this.backTmpImage, 0, 0, this.virtualWidth, this.virtualHeight,
0, 0, this.virtualWidth, this.virtualHeight);
}
g.drawImage(this.backTmpImage, 0, 0, this.getWidth(), this.getHeight(), this.offsetX,
this.offsetY, this.getWidth() + this.offsetX, this.getHeight() + this.offsetY);
}
if(this.plotters[0].getxScale() != null) {
this.plotters[0].getxScale().setScreenMax(
this.plotters[0].getX() + this.plotters[0].getWidth());
this.plotters[0].getxScale().setScreenMaxMargin(
(int)(this.plotters[0].getxScale().getScreenMax() * (1.0D - this.axisMargin)));
// FIXME: remove scroll support
// if(this.withScroll && (this.backImage != null || this.backStyle != null)) {
// if(this.repaintAll) {
// gScroll.drawImage(this.backTmpImage, 0, 0, this.virtualWidth, this.virtualHeight,
// 0, 0, this.virtualWidth, this.virtualHeight);
// }
// g.drawImage(this.backTmpImage, 0, 0, this.getWidth(), this.getHeight(), this.offsetX,
// this.offsetY, this.getWidth() + this.offsetX, this.getHeight() + this.offsetY);
// }
if(plotter.getxScale() != null) {
plotter.getxScale().setScreenMax(plotter.getX() + plotter.getWidth());
plotter.getxScale().setScreenMaxMargin(
(int)(plotter.getxScale().getScreenMax() * (1.0D - this.axisMargin)));
if(this.fullXAxis) {
this.plotters[0].getxScale().setScreenMaxMargin(
this.plotters[0].getxScale().getScreenMax());
plotter.getxScale().setScreenMaxMargin(plotter.getxScale().getScreenMax());
}
this.plotters[0].getxScale().setScreenMin(this.plotters[0].getX());
plotter.getxScale().setScreenMin(plotter.getX());
}
if(this.plotters[0].getyScale() != null) {
this.plotters[0].getyScale().setScreenMax(
this.plotters[0].getY() + this.plotters[0].getHeight());
this.plotters[0].getyScale().setScreenMaxMargin(
(int)(this.plotters[0].getyScale().getScreenMax() * (1.0D - this.axisMargin)));
this.plotters[0].getyScale().setScreenMin(this.plotters[0].getY());
if(plotter.getyScale() != null) {
plotter.getyScale().setScreenMax(plotter.getY() + plotter.getHeight());
plotter.getyScale().setScreenMaxMargin(
(int)(plotter.getyScale().getScreenMax() * (1.0D - this.axisMargin)));
plotter.getyScale().setScreenMin(plotter.getY());
}
if(this.repaintAll) {
final int plotterBackWidth = this.plotters[0].getWidth();
final int plotterBackHeight = this.plotters[0].getHeight();
this.plotters[0].plotBackground(gScroll, plotterBackWidth, plotterBackHeight,
this.offsetX, this.offsetY);
final int plotterBackWidth = plotter.getWidth();
final int plotterBackHeight = plotter.getHeight();
plotter.plotBackground(gScroll, plotterBackWidth, plotterBackHeight, this.offsetX,
this.offsetY);
}
this.title.setChart(this);
this.title.draw(g);
......@@ -774,24 +749,20 @@ public final class SpiderChart {
this.legend.draw(g);
}
if(this.repaintAll) {
for(int i = 0; i < this.plottersCount; i++) {
this.plotters[i].setChart(this);
this.plotters[i].plot(gScroll);
}
plotter.setChart(this);
plotter.plot(gScroll);
}
if(this.border != null) {
this.border.drawRect(g, 0, 0, this.getWidth() - 1, this.getHeight() - 1);
}
if(this.chartImage != null) {
final int x1 = this.plotters[0].getX();
final int x1 = plotter.getX();
final int x2 = this.plotters[0].getX() + this.plotters[0].getVisibleWidth();
final int x2 = plotter.getX() + plotter.getVisibleWidth();
final int y1 = this.plotters[0].getY() - this.plotters[0].getDepth();
final int y1 = plotter.getY() - plotter.getDepth();
final int y2 =
this.plotters[0].getY() - this.plotters[0].getDepth() +
this.plotters[0].getVisibleHeight();
final int y2 = plotter.getY() - plotter.getDepth() + plotter.getVisibleHeight();
g.drawImage(this.chartImage, x1, y1, x2, y2, x1 + this.offsetX, y1 + this.offsetY, x2 +
this.offsetX, y2 + this.offsetY);
......@@ -852,18 +823,8 @@ public final class SpiderChart {
this.chartListeners.remove(cl);
}
/** Removes all the chart plotters */
public void removeChartPlotters() {
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) {
this.plottersCount = 0;
this.plotters = new SpiderChartPlotter[10];
this.legend = null;
this.title = null;
this.border = null;
......@@ -872,12 +833,11 @@ public final class SpiderChart {
this.selectedSeqPoint = -1;
this.repaintAll = true;
this.floatingObjects.clear();
this.plotters[0] = p;
plotter = p;
this.title = t;
if(this.title == null) {
this.title = new SpiderChartTitle("");
}
this.plottersCount = 1;
}
/** Resizes the chart */
......@@ -890,16 +850,12 @@ public final class SpiderChart {
if(this.virtualHeight < myHeight) {
this.virtualHeight = myHeight;
}
this.plotters[0]
.setVisibleWidth((int)(myWidth * (1.0D - (this.legendMargin + this.leftMargin))));
this.plotters[0]
.setVisibleHeight((int)(myHeight * (1.0D - (this.topMargin + this.bottomMargin))));
this.plotters[0].setX((int)(myWidth * this.leftMargin));
this.plotters[0].setY((int)(myHeight * this.topMargin));
this.plotters[0].setWidth(this.virtualWidth -
(myWidth - this.plotters[0].getVisibleWidth()));
this.plotters[0].setHeight(this.virtualHeight -
(myHeight - this.plotters[0].getVisibleHeight()));
plotter.setVisibleWidth((int)(myWidth * (1.0D - (this.legendMargin + this.leftMargin))));
plotter.setVisibleHeight((int)(myHeight * (1.0D - (this.topMargin + this.bottomMargin))));
plotter.setX((int)(myWidth * this.leftMargin));
plotter.setY((int)(myHeight * this.topMargin));
plotter.setWidth(this.virtualWidth - (myWidth - plotter.getVisibleWidth()));
plotter.setHeight(this.virtualHeight - (myHeight - plotter.getVisibleHeight()));
this.title.setX(0);
this.title.setY(0);
......@@ -912,7 +868,6 @@ public final class SpiderChart {
this.legend.setWidth((int)(myWidth * this.legendMargin));
this.legend.setHeight((int)(myHeight * 0.5D));
}
this.setPlotterSize();
}
/** Setter for the active sequence selection */
......@@ -1053,26 +1008,6 @@ public final class SpiderChart {
this.originalVirtualWidth = originalVirtualWidth;
}
/** Setter for the plotters */
public void setPlotters(final AbstractPlotter[] plotters) {
this.plotters = plotters;
}
/** Setter for the plotters counts */
public void setPlottersCount(final int plottersCount) {
this.plottersCount = plottersCount;
}
/** */
private void setPlotterSize() {
for(int i = 1; i < this.plottersCount; i++) {
this.plotters[i].setX(this.plotters[0].getX());
this.plotters[i].setY(this.plotters[0].getY());
this.plotters[i].setWidth(this.plotters[0].getWidth());
this.plotters[i].setHeight(this.plotters[0].getHeight());
}
}
/** Setter for the configuration to repaint all floating objects */
public void setRepaintAll(final boolean repaintAll) {
this.repaintAll = repaintAll;
......@@ -1140,9 +1075,10 @@ public final class SpiderChart {
* Setter for the configuration to enable scrolling funtionality on the
* chart
*/
public void setWithScroll(final boolean withScroll) {
this.withScroll = withScroll;
}
// FIXME: remove scroll support
// public void setWithScroll(final boolean withScroll) {
// this.withScroll = withScroll;
// }
/** Triggers the chart event */
private void triggerChartEvent(final int event) {
......
......@@ -19,17 +19,12 @@ package org.fortiss.tooling.spiderchart.swt;
import static org.eclipse.swt.SWT.CURSOR_ARROW;
import static org.eclipse.swt.SWT.CURSOR_HAND;
import static org.eclipse.swt.SWT.HORIZONTAL;
import static org.eclipse.swt.SWT.NONE;
import static org.eclipse.swt.SWT.VERTICAL;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Slider;
import org.fortiss.tooling.spiderchart.SpiderChart;
import org.fortiss.tooling.spiderchart.listener.SpiderChartAdapter;
......@@ -43,9 +38,6 @@ import org.fortiss.tooling.spiderchart.listener.SpiderChartAdapter;
*/
public final class SpiderChartViewer extends Composite {
/** allows zoom functionality on the chart */
private boolean allowZoom = true;
/** the actual canvas to be used */
private SpiderChartCanvas canvas = null;
......@@ -72,24 +64,12 @@ public final class SpiderChartViewer extends Composite {
/** Default cursor object */
private Cursor defaultCursor = null;
/** horizontal slider */
private Slider hSlider = null;
/** height of the canvas (used to restore from zoom) */
private int lastHeight = 0;
/** width of the canvas (used to restore from zoom) */
private int lastWidth = 0;
/** tracks last zoom percentage */
private int lastZoom = 0;
/** Maximum Zoom for Spider Chart */
private int maxZoom = 200;
/** Minimum Zoom for Spider Chart */
private int minZoom = 50;
/** Actual height of the canvas */
private int originalHeight = -1;
......@@ -99,46 +79,23 @@ public final class SpiderChartViewer extends Composite {
/** Cursor object in use */
private Cursor pointCursor = null;
/** scrollbar width */
private final int scrollBarWidth = 18;
/** vertical slider */
private Slider vSlider = null;
/** zoom label */
private Label zoom;
/** zoom in button */
private Button zoomInButton;
/** zoom increment value */
private int zoomIncrement = 25;
/** zoom out button */
private Button zoomOutButton;
/** zoom panel composite */
private Composite zoomPanel;
/** Constructor */
public SpiderChartViewer(final Composite parent, final int style) {
public SpiderChartViewer(Composite parent, final int style) {
super(parent, style);
this.canvas = new SpiderChartCanvas(this, NONE);
this.hSlider = new Slider(this, HORIZONTAL);
this.vSlider = new Slider(this, VERTICAL);
this.canvas.setFocus();
canvas = new SpiderChartCanvas(this, NONE);
canvas.setFocus();
this.addControlListener(new ControlListener() {
/** {@inheritDoc} */
@Override
public void controlMoved(final ControlEvent e) {
public void controlMoved(ControlEvent e) {
// Not used
}
/** {@inheritDoc} */
@Override
public void controlResized(final ControlEvent e) {
public void controlResized(ControlEvent e) {
if(SpiderChartViewer.this.canvas.getChart() == null) {
return;
}
......@@ -186,11 +143,6 @@ public final class SpiderChartViewer extends Composite {
return this.defaultCursor;
}
/** getter for horizontal slider */
public Slider gethSlider() {
return this.hSlider;
}
/** getter for height after zoom */
public int getLastHeight() {
return this.lastHeight;
......@@ -201,21 +153,6 @@ public final class SpiderChartViewer extends Composite {
return this.lastWidth;
}
/** getter for last zoom percentage */
public int getLastZoom() {
return this.lastZoom;
}
/** getter for max zoom percentage */
public int getMaxZoom() {
return this.maxZoom;
}
/** getter for min zoom percentage */
public int getMinZoom() {
return this.minZoom;
}
/** getter for original canvas height */
public int getOriginalHeight() {
return this.originalHeight;
......@@ -231,63 +168,6 @@ public final class SpiderChartViewer extends Composite {
return this.pointCursor;
}
/** getter for scrollbar width */
public int getScrollBarWidth() {
return this.scrollBarWidth;
}
/** getter for vertical slider */
public Slider getvSlider() {
return this.vSlider;
}
/** getter for zoom label */
public Label getZoom() {
return this.zoom;
}
/** getter for zoom in button */
public Button getZoomInButton() {
return this.zoomInButton;
}
/** getter for zoom increment value */
public int getZoomIncrement() {
return this.zoomIncrement;
}
/** getter for zoom out button */
public Button getZoomOutButton() {
return this.zoomOutButton;
}
/** getter for zoom panel composite */
public Composite getZoomPanel() {
return this.zoomPanel;
}
/** horizontal scrolling functionality */
private void hSliderScroll() {
// TODO Need to refactor horizontal scrolling
int newBase = 0;
final int newValue = this.hSlider.getSelection();
if(newValue + this.canvas.getChart().getWidth() < this.canvas.getChart().getVirtualWidth()) {
newBase = newValue;
} else {
newBase = this.canvas.getChart().getVirtualWidth() - this.canvas.getChart().getWidth();
}
if(newBase < 0) {
newBase = 0;
}
this.canvas.getChart().setOffsetX(newBase);
this.canvas.redraw();
}
/** getter for configuration of allowing zoom */
public boolean isAllowZoom() {
return this.allowZoom;
}
/**
* getter for configuration of changing pointer on data point mouse hover
*/
......@@ -295,57 +175,6 @@ public final class SpiderChartViewer extends Composite {
return this.changePointer;
}
/** Placing zoom controls on the canvas */
private void placeZoomControls() {
// TODO Need to refactor for ZOOM Controls
int hSliderHeight = 0;
int vSliderWidth = 0;
if(this.canvas.getChart().getVirtualWidth() > 0) {
hSliderHeight = this.scrollBarWidth;
}
if(this.canvas.getChart().getVirtualHeight() > 0) {
vSliderWidth = this.scrollBarWidth;
}
System.out.println("X ==>" + this.getSize().x);
System.out.println("vSliderWidth ==>" + vSliderWidth);
System.out.println("hSliderHeight ==>" + hSliderHeight);
System.out.println("Y ==>" + this.getSize().y);
this.canvas.setSize(this.getSize().x - vSliderWidth, this.getSize().y - hSliderHeight);
this.canvas.setLocation(0, 0);
if(this.allowZoom &&
(this.canvas.getChart().getVirtualHeight() > 0 || this.canvas.getChart()
.getVirtualWidth() > 0)) {
this.zoomPanel.setVisible(true);
this.zoomPanel.setLocation(0, this.canvas.getSize().y);
} else {
this.zoomPanel.setVisible(false);
}
if(this.canvas.getChart().getVirtualWidth() > 0) {
if(this.allowZoom) {
this.hSlider.setLocation(this.zoomPanel.getSize().x, this.canvas.getSize().y);
this.hSlider.setSize(this.getSize().x - vSliderWidth - this.zoomPanel.getSize().x,
hSliderHeight);
} else {
this.hSlider.setSize(this.getSize().x - vSliderWidth, hSliderHeight);
this.hSlider.setLocation(0, this.canvas.getSize().y);
}
this.hSlider.setVisible(true);
this.canvas.getChart().setWithScroll(true);
} else {
this.hSlider.setVisible(false);
}
if(this.canvas.getChart().getVirtualWidth() > 0) {
this.vSlider.setSize(vSliderWidth, this.getSize().y - hSliderHeight);
this.vSlider.setLocation(this.canvas.getSize().x, 0);
this.vSlider.setVisible(true);
this.canvas.getChart().setWithScroll(true);
} else {
this.vSlider.setVisible(false);
}
}
/** Redraws the chart */
public void redrawChart() {
this.canvas.redraw();
......@@ -355,12 +184,6 @@ public final class SpiderChartViewer extends Composite {
private void resetChart() {
this.lastWidth = 0;
this.lastHeight = 0;
this.lastZoom = 0;
}
/** setter for allowing zoom */
public void setAllowZoom(final boolean allowZoom) {
this.allowZoom = allowZoom;
}
/** setter for chart canvas */
......@@ -385,8 +208,6 @@ public final class SpiderChartViewer extends Composite {
this.resetChart();
setCanvasSize();
// this.placeZoomControls();
// this.updateSize();
if(this.changePointer) {
this.canvas.getChart().addChartListener(this.chartAdapter);
}
......@@ -410,11 +231,6 @@ public final class SpiderChartViewer extends Composite {
this.defaultCursor = defaultCursor;
}
/** setter for horizontal slider */
public void sethSlider(final Slider hSlider) {
this.hSlider = hSlider;
}
/** setter for last height after zoom */
public void setLastHeight(final int lastHeight) {
this.lastHeight = lastHeight;
......@@ -425,21 +241,6 @@ public final class SpiderChartViewer extends Composite {
this.lastWidth = lastWidth;
}
/** setter for last zoom percentage */
public void setLastZoom(final int lastZoom) {
this.lastZoom = lastZoom;
}
/** setter for max zoom percentage */
public void setMaxZoom(final int maxZoom) {
this.maxZoom = maxZoom;
}
/** setter for min zoom percentage */
public void setMinZoom(final int minZoom) {
this.minZoom = minZoom;
}
/** setter for original height of the canvas */
public void setOriginalHeight(final int originalHeight) {
this.originalHeight = originalHeight;
......@@ -454,119 +255,4 @@ public final class SpiderChartViewer extends Composite {
public void setPointCursor(final Cursor pointCursor) {
this.pointCursor = pointCursor;
}
/** setter for vertical slider */
public void setvSlider(final Slider vSlider) {
this.vSlider = vSlider;
}
/** setter for zoom label */
public void setZoom(final Label zoom) {
this.zoom = zoom;
}
/** setter for zoom in button */
public void setZoomInButton(final Button zoomInButton) {
this.zoomInButton = zoomInButton;
}
/** setter for zoom increment value */
public void setZoomIncrement(final int zoomIncrement) {
this.zoomIncrement = zoomIncrement;
}
/** setter for zoom out button */
public void setZoomOutButton(final Button zoomOutButton) {
this.zoomOutButton = zoomOutButton;
}
/** setter for zoom panel composite */
public void setZoomPanel(final Composite zoomPanel) {
this.zoomPanel = zoomPanel;
}
/** 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) {
this.canvas.getChart().setSize(this.getSize().x, this.getSize().y);
this.lastWidth = this.getSize().x;
this.lastHeight = this.getSize().y;
this.lastZoom = this.currentZoom;
if(this.canvas.getChart().isWithScroll()) {
if(this.allowZoom) {
if(this.originalHeight > 0) {
this.canvas.getChart().setVirtualHeight(
this.originalHeight * this.currentZoom / 100);
} else {
this.canvas.getChart().setVirtualHeight(0);
}
if(this.originalWidth > 0) {
this.canvas.getChart().setVirtualWidth(
this.originalWidth * this.currentZoom / 100);
} else {
this.canvas.getChart().setVirtualWidth(0);
}
}
int w = 1 + this.getSize().x;
if(this.originalHeight > 0) {
w -= this.vSlider.getSize().x;
}
int h = 1 + this.getSize().y;
if(this.originalWidth > 0) {
h -= this.hSlider.getSize().y;
}
this.canvas.getChart().setRepaintAll(true);
this.canvas.getChart().setSize(w, h);
}
}
}
/** vertical sliding functionality */
private void vSliderScroll() {
// TODO Need to refactor vertical scrolling
int newBase = 0;
final int newValue = this.vSlider.getSelection();
if(newValue + this.canvas.getChart().getHeight() < this.canvas.getChart()
.getVirtualHeight()) {
newBase = newValue;
} else {
newBase =
this.canvas.getChart().getVirtualHeight() - this.canvas.getChart().getHeight();
}
if(newBase < 0) {
newBase = 0;
}
this.canvas.getChart().setOffsetY(newBase);
this.canvas.redraw();
}
/** zooms in */
private void zoomIn() {
if(this.currentZoom + this.zoomIncrement < this.maxZoom) {
this.currentZoom += this.zoomIncrement;
} else {
this.currentZoom = this.maxZoom;
}
this.zoomUpdated();
}
/** zooms out */
private void zoomOut() {
if(this.currentZoom - this.zoomIncrement > this.minZoom) {
this.currentZoom -= this.zoomIncrement;
} else {
this.currentZoom = this.minZoom;
}
this.zoomUpdated();
}
/** zoom updated */
private void zoomUpdated() {
this.zoom.setText("" + this.currentZoom + " %");
// this.updateSize();
this.canvas.redraw();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment