1 22 package info.monitorenter.gui.chart.traces.painters; 23 24 25 import java.awt.Graphics2D ; 26 import java.util.Iterator ; 27 import java.util.LinkedList ; 28 import java.util.List ; 29 30 42 public class TracePainterPolyline extends ATracePainter { 43 44 45 private List m_xPoints; 46 47 48 private List m_yPoints; 49 50 55 public TracePainterPolyline() { 56 } 57 58 61 public void endPaintIteration() { 62 if (this.getGraphics() != null) { 63 64 int[] x = new int[this.m_xPoints.size() + 1]; 65 Iterator it = this.m_xPoints.iterator(); 66 int count = 0; 67 while (it.hasNext()) { 68 x[count] = ((Integer ) it.next()).intValue(); 69 count++; 70 } 71 x[count] = this.getPreviousX(); 72 73 int[] y = new int[this.m_yPoints.size() + 1]; 74 it = this.m_yPoints.iterator(); 75 count = 0; 76 while (it.hasNext()) { 77 y[count] = ((Integer ) it.next()).intValue(); 78 count++; 79 } 80 y[count] = this.getPreviousY(); 81 82 this.getGraphics().drawPolyline(x, y, x.length); 83 } 84 } 85 86 90 public void paintPoint(final int absoluteX, final int absoluteY, final int nextX, 91 final int nextY, final Graphics2D g) { 92 super.paintPoint(absoluteX, absoluteY, nextX, nextY, g); 93 this.m_xPoints.add(new Integer (absoluteX)); 94 this.m_yPoints.add(new Integer (absoluteY)); 95 96 } 97 98 101 public void startPaintIteration() { 102 super.startPaintIteration(); 103 this.m_xPoints = new LinkedList (); 104 this.m_yPoints = new LinkedList (); 105 } 106 107 } 108 | Popular Tags |