1 48 49 package org.krysalis.jcharts.imageMap; 50 51 52 import java.io.Serializable ; 53 import java.awt.geom.Point2D ; 54 55 56 60 public abstract class ImageMapArea implements Serializable 61 { 62 int[] x; 64 int[] y; 65 66 private double value; 67 private String xAxisLabel; 68 private String legendLabel; 69 70 71 78 ImageMapArea( int numberOfPoints, double value, String xAxisLabel, String legendLabel ) 79 { 80 this.x=new int[ numberOfPoints ]; 81 this.y=new int[ numberOfPoints ]; 82 83 this.value=value; 84 this.xAxisLabel=xAxisLabel; 85 this.legendLabel=legendLabel; 86 } 87 88 89 95 ImageMapArea( int numberOfPoints, Point2D.Double point, String legendLabel ) 96 { 97 this.x=new int[ numberOfPoints ]; 98 this.y=new int[ numberOfPoints ]; 99 100 this.value= point.getY(); 101 this.xAxisLabel= Double.toString( point.getX() ); 102 this.legendLabel=legendLabel; 103 } 104 105 106 110 abstract AreaShape getAreaShape(); 111 112 113 118 public final int getNumberOfCoordinates() 119 { 120 return this.x.length; 121 } 122 123 124 130 public final int getXCoordinate( int index ) 131 { 132 return this.x[ index ]; 133 } 134 135 136 142 public final int getYCoordinate( int index ) 143 { 144 return this.y[ index ]; 145 } 146 147 148 153 public final double getValue() 154 { 155 return this.value; 156 } 157 158 159 165 public final String getXAxisLabel() 166 { 167 return this.xAxisLabel; 168 } 169 170 171 177 public final String getLengendLabel() 178 { 179 return this.legendLabel; 180 } 181 182 183 189 protected void getCoordinates( StringBuffer html ) 190 { 191 for( int i=0; i < this.x.length; i++ ) 192 { 193 html.append( this.x[ i ] + "," + this.y[ i ] ); 194 if( i + 1 != this.x.length ) 195 { 196 html.append( "," ); 197 } 198 } 199 } 200 201 202 211 public final String toHTML( String mapElementAttributes ) 212 { 213 StringBuffer html=new StringBuffer ( 250 ); 214 215 html.append( "<area" ); 216 html.append( " shape=\"" + this.getAreaShape().getValue() + "\"" ); 217 218 html.append( " coords=\"" ); 219 this.getCoordinates( html ); 220 html.append( "\" " ); 221 222 html.append( mapElementAttributes ); 223 html.append( ">\n" ); 224 225 return html.toString(); 226 } 227 } 228 | Popular Tags |