1 22 package info.monitorenter.gui.chart.traces.painters; 23 24 import info.monitorenter.gui.chart.Chart2D; 25 26 import java.awt.Graphics2D ; 27 import java.util.Iterator ; 28 import java.util.LinkedList ; 29 import java.util.List ; 30 31 49 public class TracePainterFill extends ATracePainter { 50 51 55 private Chart2D m_chart; 56 57 58 private List m_xPoints; 59 60 61 private List m_yPoints; 62 63 70 public TracePainterFill(final Chart2D chart) { 71 this.m_chart = chart; 72 } 73 74 77 public void discontinue() { 78 this.endPaintIteration(); 79 this.startPaintIteration(); 80 } 81 82 85 public void endPaintIteration() { 86 if (this.m_graphics != null) { 87 88 int[] x = new int[this.m_xPoints.size() + 4]; 89 x[0] = this.m_chart.getXChartStart(); 90 Iterator it = this.m_xPoints.iterator(); 91 int count = 1; 92 while (it.hasNext()) { 93 x[count] = ((Integer ) it.next()).intValue(); 94 count++; 95 } 96 x[count] = this.m_lastX; 97 x[count + 1] = this.m_lastX; 99 x[count + 2] = this.m_chart.getXChartStart(); 101 102 int[] y = new int[this.m_yPoints.size() + 4]; 103 y[0] = this.m_chart.getYChartStart(); 104 it = this.m_yPoints.iterator(); 105 count = 1; 106 while (it.hasNext()) { 107 y[count] = ((Integer ) it.next()).intValue(); 108 count++; 109 } 110 y[count] = this.m_lastY; 111 y[count + 1] = this.m_chart.getYChartStart(); 113 y[count + 2] = this.m_chart.getYChartStart(); 115 116 this.m_graphics.fillPolygon(x, y, x.length); 117 } 118 } 119 120 124 public void paintPoint(final int absoluteX, final int absoluteY, final int nextX, 125 final int nextY, final Graphics2D g) { 126 127 this.m_xPoints.add(new Integer (absoluteX)); 128 this.m_yPoints.add(new Integer (absoluteY)); 129 this.m_lastX = nextX; 131 this.m_lastY = nextY; 132 if (this.m_graphics == null) { 133 this.m_graphics = g; 134 } 135 } 136 137 140 public void startPaintIteration() { 141 this.m_xPoints = new LinkedList (); 142 this.m_yPoints = new LinkedList (); 143 this.m_graphics = null; 144 } 145 } 146 | Popular Tags |