1 32 33 package it.businesslogic.ireport; 34 import it.businesslogic.ireport.gui.*; 35 import it.businesslogic.ireport.util.*; 36 import java.awt.*; 37 import java.awt.image.*; 38 import java.awt.geom.*; 39 40 public class RectangleReportElement extends GraphicReportElement { 41 42 46 public static final String RADIUS = "RADIUS"; 47 48 52 public static final int DEFAULT_RADIUS = 0; 53 54 public RectangleReportElement (int x, int y, int width, int height) { 55 super (x,y, width, height); 56 setKey ("rectangle"); 60 } 61 62 public RectangleReportElement (int x, int y, int width, int height, int radius) { 63 this (x,y,width,height); 64 this.setPropertyValue(RADIUS, ""+radius); 65 } 68 69 public void drawObject (Graphics2D g,double zoom_factor, int x_shift_origin, int y_shift_origin) { 70 position.x -= 10; 71 position.y -= 10; 72 x_shift_origin -= 10; 73 y_shift_origin -= 10; 74 75 this.zoom_factor = zoom_factor; 76 77 g.setColor ( getBgcolor() ); 78 if (!getTransparent ().equalsIgnoreCase ("Transparent")) 79 g.fillRoundRect ( getZoomedDim (position.x)-x_shift_origin, 80 getZoomedDim (position.y)-y_shift_origin, 81 getZoomedDim (width), 82 getZoomedDim (height), 83 (int)(2*this.getRadius()*zoom_factor), 84 (int)(2*this.getRadius()*zoom_factor)); 85 g.setColor ( getFgcolor()); 86 87 position.x += 10; 88 position.y += 10; 89 x_shift_origin += 10; 90 y_shift_origin += 10; 91 92 drawGraphicsElement (g,this.getGraphicElementPen (), zoom_factor, x_shift_origin,y_shift_origin, (int)(2*this.getRadius()*zoom_factor)); 93 } 94 95 public ReportElement cloneMe () { 96 RectangleReportElement newReportElement = new RectangleReportElement (position.x, position.y, width, height); 97 copyBaseReportElement (newReportElement, this); 98 return newReportElement; 99 } 100 101 public void drawGraphicsElement (Graphics2D g, String pen, double zoom_factor, int x_shift_origin, int y_shift_origin) { 102 103 Stroke stroke = getPenStroke ( pen,zoom_factor ); 104 g.setColor ( getFgcolor() ); 105 106 this.zoom_factor = zoom_factor; 107 if (stroke==null || pen.equalsIgnoreCase ("None")) return; 108 109 position.x -= 10; 110 position.y -= 10; 111 x_shift_origin -= 10; 112 y_shift_origin -= 10; 113 114 Stroke oldStroke = g.getStroke (); 115 g.setStroke (stroke); 116 g.drawRoundRect ( 117 getZoomedDim (position.x)-x_shift_origin, 118 getZoomedDim (position.y)-y_shift_origin, 119 getZoomedDim (width),getZoomedDim (height), 120 (int)(2*this.getRadius()*zoom_factor), 121 (int)(2*this.getRadius()*zoom_factor)); 122 123 position.x += 10; 124 position.y += 10; 125 126 g.setStroke (oldStroke); 127 } 128 129 133 public int getRadius () { 134 if (getPropertyValue(RADIUS) == null) 135 { 136 if (getStyle() != null) 138 { 139 return getStyle().getAttributeInteger( getStyle().ATTRIBUTE_radius, DEFAULT_RADIUS, true); 140 } 141 } 142 return getIntValue(RADIUS, DEFAULT_RADIUS ); 143 } 144 145 149 public void setRadius (int radius) { 150 setPropertyValue(RADIUS, radius+""); 151 } 152 153 public void copyBaseReportElement (ReportElement destination, ReportElement source) { 154 super.copyBaseReportElement (destination, source); 155 156 if (destination instanceof RectangleReportElement && 157 source instanceof RectangleReportElement ) { 158 destination.setPropertyValue(RADIUS, source.getPropertyValue(RADIUS)); 160 } 161 } 162 163 public void setStyle(Style style) { 164 165 super.setStyle(style); 166 } 167 168 } 169 | Popular Tags |