1 32 33 package it.businesslogic.ireport; 34 35 import it.businesslogic.ireport.chart.Chart; 36 import java.awt.*; 37 import java.util.Vector ; 38 42 public class ChartReportElement2 extends ReportElement implements BoxElement, java.awt.image.ImageObserver , HyperLinkableReportElement { 43 44 private Box box = null; 45 private Chart chart = null; 46 private String evaluationTime="Now"; 47 private String evaluationGroup=""; 48 49 50 public ChartReportElement2(int x, int y, int width, int height) 51 { 52 super(x,y,width,height); 53 setBox(new Box()); 54 55 } 56 57 public Box getBox() { 58 return box; 59 } 60 61 public void setBox(Box box) { 62 this.box = box; 63 } 64 65 public Chart getChart() { 66 return chart; 67 } 68 69 public void setChart(Chart chart) { 70 this.chart = chart; 71 } 72 73 public void drawObject(Graphics2D g,double zoom_factor, int x_shift_origin, int y_shift_origin) 74 { 75 position.x += -10 + box.getLeftPadding(); 76 position.y += -10 + box.getTopPadding(); 77 width = width - box.getLeftPadding() - box.getRightPadding(); 78 height = height - box.getTopPadding() - box.getBottomPadding(); 79 80 x_shift_origin -= 10; 81 y_shift_origin -= 10; 82 83 this.zoom_factor = zoom_factor; 84 Image imgx = getChart().getChartImage(); 85 86 g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 87 g.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE); 88 89 if (imgx != null) 90 { 91 int imageWidth = imgx.getWidth(this); 92 int imageHeight = imgx.getHeight(this); 93 99 100 102 103 g.drawImage(imgx, getZoomedDim(position.x)-x_shift_origin, 104 getZoomedDim(position.y)-y_shift_origin, 105 getZoomedDim(position.x+width)-x_shift_origin, 106 getZoomedDim(position.y+height)-y_shift_origin, 107 0,0,imageWidth,imageHeight,null,this); 108 109 111 } 112 113 if (it.businesslogic.ireport.gui.MainFrame.getMainInstance().getProperties().getProperty("Antialias","true").equals("false")) 114 { 115 g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); 116 g.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE); 117 } 118 121 position.x += 10 - box.getLeftPadding(); 122 position.y += 10 - box.getTopPadding(); 123 width = width + box.getLeftPadding() + box.getRightPadding(); 124 height = height + box.getTopPadding() + box.getBottomPadding(); 125 126 127 x_shift_origin += 10; 128 y_shift_origin += 10; 129 130 super.drawBorder((Graphics2D)g, zoom_factor, x_shift_origin,y_shift_origin); 131 drawBorder( g, zoom_factor, x_shift_origin,y_shift_origin,getBox()); 132 } 133 134 public String getEvaluationTime() { 135 return evaluationTime; 136 } 137 138 public void setEvaluationTime(String evaluationTime) { 139 this.evaluationTime = evaluationTime; 140 } 141 142 public String getEvaluationGroup() { 143 return evaluationGroup; 144 } 145 146 public void setEvaluationGroup(String evaluationGroup) { 147 this.evaluationGroup = evaluationGroup; 148 } 149 150 public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) { 151 return true; 152 } 153 154 public ReportElement cloneMe() 155 { 156 ChartReportElement2 newReportElement = new ChartReportElement2(position.x, position.y, width, height); 157 copyBaseReportElement(newReportElement, this); 158 return newReportElement; 159 } 160 161 public void copyBaseReportElement(ReportElement destination, ReportElement source) 162 { 163 super.copyBaseReportElement(destination, source); 164 165 if (destination instanceof ChartReportElement2 && 166 source instanceof ChartReportElement2 ) 167 { 168 ((ChartReportElement2)destination).setBox( ((ChartReportElement2)source).getBox().cloneMe() ); 169 ((ChartReportElement2)destination).setChart( ((ChartReportElement2)source).getChart().cloneMe() ); 170 ((ChartReportElement2)destination).setEvaluationGroup( ((ChartReportElement2)source).getEvaluationGroup() ); 171 ((ChartReportElement2)destination).setEvaluationTime( ((ChartReportElement2)source).getEvaluationTime() ); 172 } 173 } 174 175 public String getAnchorNameExpression() { 176 return getChart().getAnchorNameExpression(); 177 } 178 179 public String getHyperlinkAnchorExpression() { 180 return getChart().getHyperlinkAnchorExpression(); 181 } 182 183 public String getHyperlinkPageExpression() { 184 return getChart().getHyperlinkPageExpression(); 185 } 186 187 public String getHyperlinkReferenceExpression() { 188 return getChart().getHyperlinkReferenceExpression(); 189 } 190 191 public String getHyperlinkTarget() { 192 return getChart().getHyperlinkTarget(); 193 } 194 195 public String getHyperlinkType() { 196 return getChart().getHyperlinkType(); 197 } 198 199 public void setAnchorNameExpression(String anchorNameExpression) { 200 getChart().setAnchorNameExpression(anchorNameExpression); 201 } 202 203 public void setHyperlinkAnchorExpression(String hyperlinkAnchorExpression) { 204 getChart().setHyperlinkAnchorExpression(hyperlinkAnchorExpression); 205 } 206 207 public void setHyperlinkPageExpression(String hyperlinkPageExpression) { 208 getChart().setHyperlinkPageExpression(hyperlinkPageExpression); 209 } 210 211 public void setHyperlinkReferenceExpression(String hyperlinkReferenceExpression) { 212 getChart().setHyperlinkReferenceExpression(hyperlinkReferenceExpression); 213 } 214 215 public void setHyperlinkTarget(String hyperlinkTarget) { 216 getChart().setHyperlinkTarget(hyperlinkTarget); 217 } 218 219 public void setHyperlinkType(String hyperlinkType) { 220 getChart().setHyperlinkType(hyperlinkType); 221 } 222 223 public int getBookmarkLevel() { 224 return getChart().getBookmarkLevel(); 225 } 226 227 public void setBookmarkLevel(int bookmarkLevel) { 228 getChart().setBookmarkLevel(bookmarkLevel); 229 } 230 231 public void setStyle(Style style) { 232 233 super.setStyle(style); 234 235 if (style != null) 236 { 237 if (style.getAttributeString(style.ATTRIBUTE_border, null, true) != null) 239 this.getBox().setBorder( style.getAttributeString(style.ATTRIBUTE_border, null, true) ); 240 if (style.getAttributeColor(style.ATTRIBUTE_borderColor, null, true) != null) 241 this.getBox().setBorderColor( style.getAttributeColor(style.ATTRIBUTE_borderColor, null, true)); 242 if (style.getAttributeString(style.ATTRIBUTE_padding, null, true) != null) 243 this.getBox().setPadding( Integer.parseInt( style.getAttributeString(style.ATTRIBUTE_padding, null, true) )); 244 245 if (style.getAttributeString(style.ATTRIBUTE_topBorder, null, true) != null) 246 this.getBox().setTopBorder( style.getAttributeString(style.ATTRIBUTE_topBorder, null, true) ); 247 if (style.getAttributeColor(style.ATTRIBUTE_topBorderColor, null, true) != null) 248 this.getBox().setTopBorderColor( style.getAttributeColor(style.ATTRIBUTE_topBorderColor, null, true)); 249 if (style.getAttributeString(style.ATTRIBUTE_topPadding, null, true) != null) 250 this.getBox().setTopPadding( Integer.parseInt( style.getAttributeString(style.ATTRIBUTE_topPadding, null, true) )); 251 252 if (style.getAttributeString(style.ATTRIBUTE_leftBorder, null, true) != null) 253 this.getBox().setLeftBorder( style.getAttributeString(style.ATTRIBUTE_leftBorder, null, true) ); 254 if (style.getAttributeColor(style.ATTRIBUTE_leftBorderColor, null, true) != null) 255 this.getBox().setLeftBorderColor( style.getAttributeColor(style.ATTRIBUTE_leftBorderColor, null, true)); 256 if (style.getAttributeString(style.ATTRIBUTE_leftPadding, null, true) != null) 257 this.getBox().setLeftPadding( Integer.parseInt( style.getAttributeString(style.ATTRIBUTE_leftPadding, null, true) )); 258 259 if (style.getAttributeString(style.ATTRIBUTE_rightBorder, null, true) != null) 260 this.getBox().setRightBorder( style.getAttributeString(style.ATTRIBUTE_rightBorder, null, true) ); 261 if (style.getAttributeColor(style.ATTRIBUTE_rightBorderColor, null, true) != null) 262 this.getBox().setRightBorderColor( style.getAttributeColor(style.ATTRIBUTE_rightBorderColor, null, true)); 263 if (style.getAttributeString(style.ATTRIBUTE_rightPadding, null, true) != null) 264 this.getBox().setRightPadding( Integer.parseInt( style.getAttributeString(style.ATTRIBUTE_rightPadding, null, true) )); 265 266 if (style.getAttributeString(style.ATTRIBUTE_bottomBorder, null, true) != null) 267 this.getBox().setBottomBorder( style.getAttributeString(style.ATTRIBUTE_bottomBorder, null, true) ); 268 if (style.getAttributeColor(style.ATTRIBUTE_bottomBorderColor, null, true) != null) 269 this.getBox().setBottomBorderColor( style.getAttributeColor(style.ATTRIBUTE_bottomBorderColor, null, true)); 270 if (style.getAttributeString(style.ATTRIBUTE_bottomPadding, null, true) != null) 271 this.getBox().setBottomPadding( Integer.parseInt( style.getAttributeString(style.ATTRIBUTE_bottomPadding, null, true) )); 272 273 } 274 } 275 276 public java.util.List getLinkParameters() { 277 return getChart().getLinkParameters(); 278 } 279 280 public void setLinkParameters(java.util.List linkParameters) { 281 getChart().setLinkParameters(linkParameters); 282 } 283 284 } 285 | Popular Tags |