1 28 package net.sf.jasperreports.charts.util; 29 30 import java.util.ArrayList ; 31 import java.util.Iterator ; 32 import java.util.List ; 33 34 import net.sf.jasperreports.engine.JRConstants; 35 36 import org.jfree.data.xy.AbstractXYZDataset; 37 import org.jfree.data.xy.XYZDataset; 38 39 43 public class DefaultXYZDataset extends AbstractXYZDataset implements XYZDataset 44 { 45 private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID; 46 47 50 List dataset = null; 51 52 55 public DefaultXYZDataset() 56 { 57 dataset = new ArrayList (); 58 } 59 60 63 public void addValue( Comparable series, Number xValue, Number yValue, Number zValue ){ 64 boolean found = false; 65 for( Iterator it = dataset.iterator(); it.hasNext(); ){ 66 XYZElement element = (XYZElement)it.next(); 67 if( element.getSeries().equals( series )){ 68 element.addElement( xValue, yValue, zValue ); 69 found = true; 70 } 71 } 72 73 if( !found ){ 74 XYZElement element = new XYZElement(); 75 element.setSeries( series ); 76 element.addElement( xValue, yValue, zValue ); 77 78 dataset.add( element ); 79 } 80 } 81 82 85 public int getSeriesCount() { 86 int retVal = 0; 87 if( dataset != null ){ 88 retVal = dataset.size(); 89 } 90 91 return retVal; 92 } 93 94 97 public Number getZ(int series, int index ) { 98 Number retVal = null; 99 if( dataset != null ){ 100 if( series < getSeriesCount() ){ 101 XYZElement element = (XYZElement)dataset.get( series ); 102 retVal = element.getZElement( index ); 103 } 104 } 105 return retVal; 106 } 107 108 111 public int getItemCount(int series ) { 112 int retVal = 0; 113 if( dataset != null ){ 114 if( series < getSeriesCount() ){ 115 XYZElement element = (XYZElement)dataset.get( series ); 116 retVal = element.getCount(); 117 } 118 } 119 return retVal; 120 } 121 122 125 public Number getX(int series, int index ) { 126 Number retVal = null; 127 if( dataset != null ){ 128 if( series < getSeriesCount() ){ 129 XYZElement element = (XYZElement)dataset.get( series ); 130 retVal = element.getXElement( index ); 131 } 132 } 133 return retVal; 134 } 135 136 139 public Number getY(int series, int index ) { 140 Number retVal = null; 141 if( dataset != null ){ 142 if( series < getSeriesCount() ){ 143 XYZElement element = (XYZElement)dataset.get( series ); 144 retVal = element.getYElement( index ); 145 } 146 } 147 return retVal; 148 } 149 150 153 public Comparable getSeriesKey(int index) { 154 String retVal = null; 155 if( dataset != null ){ 156 if( index < getSeriesCount() ){ 157 XYZElement element = (XYZElement)dataset.get( index ); 158 retVal = element.getSeries().toString(); 159 } 160 } 161 return retVal; 162 } 163 164 } 165 | Popular Tags |