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 import java.awt.font.*; 40 import java.util.*; 41 import java.util.List ; 42 import java.text.AttributedCharacterIterator ; 43 import java.text.AttributedString ; 44 45 public class FrameReportElement extends ReportElement implements BoxElement { 46 47 private Box box = null; 48 49 public FrameReportElement(int x, int y, int width, int height) 50 { 51 super(x,y,width,height); 52 setBox(new Box()); 57 setKey("frame"); 58 transparentDefault = "Transparent"; 60 } 61 62 public void drawObject(Graphics2D g,double zoom_factor, int x_shift_origin, int y_shift_origin) 63 { 64 position.x -= 10; 65 position.y -= 10; 66 x_shift_origin -= 10; 67 y_shift_origin -= 10; 68 69 this.zoom_factor = zoom_factor; 70 71 g.setColor ( getBgcolor() ); 72 if (!getTransparent().equalsIgnoreCase ("Transparent")) 73 g.fillRoundRect ( getZoomedDim (position.x)-x_shift_origin, 74 getZoomedDim (position.y)-y_shift_origin, 75 getZoomedDim (width), 76 getZoomedDim (height), 77 0, 78 0); 79 g.setColor ( getFgcolor() ); 80 81 position.x += 10; 82 position.y += 10; 83 x_shift_origin += 10; 84 y_shift_origin += 10; 85 86 drawBorder( g, zoom_factor, x_shift_origin,y_shift_origin); 87 drawBorder( g, zoom_factor, x_shift_origin,y_shift_origin,getBox()); 88 } 90 91 public ReportElement cloneMe () { 92 FrameReportElement newReportElement = new FrameReportElement (position.x, position.y, width, height); 93 copyBaseReportElement (newReportElement, this); 94 return newReportElement; 95 } 96 97 public void copyBaseReportElement(ReportElement destination, ReportElement source) 98 { 99 super.copyBaseReportElement(destination, source); 100 101 if (destination instanceof BoxElement && source instanceof BoxElement ) 102 { 103 ((BoxElement)destination).setBox( ((BoxElement)source).getBox().cloneMe() ); 104 } 105 } 106 107 public Box getBox() { 108 return box; 109 } 110 111 public void setBox(Box box) { 112 this.box = box; 113 } 114 115 public void setStyle(Style style) { 116 117 super.setStyle(style); 118 119 if (style != null) 120 { 121 if (style.getAttributeString(style.ATTRIBUTE_border, null, true) != null) 123 this.getBox().setBorder( style.getAttributeString(style.ATTRIBUTE_border, null, true) ); 124 if (style.getAttributeColor(style.ATTRIBUTE_borderColor, null, true) != null) 125 this.getBox().setBorderColor( style.getAttributeColor(style.ATTRIBUTE_borderColor, null, true)); 126 if (style.getAttributeString(style.ATTRIBUTE_padding, null, true) != null) 127 this.getBox().setPadding( Integer.parseInt( style.getAttributeString(style.ATTRIBUTE_padding, null, true) )); 128 129 if (style.getAttributeString(style.ATTRIBUTE_topBorder, null, true) != null) 130 this.getBox().setTopBorder( style.getAttributeString(style.ATTRIBUTE_topBorder, null, true) ); 131 if (style.getAttributeColor(style.ATTRIBUTE_topBorderColor, null, true) != null) 132 this.getBox().setTopBorderColor( style.getAttributeColor(style.ATTRIBUTE_topBorderColor, null, true)); 133 if (style.getAttributeString(style.ATTRIBUTE_topPadding, null, true) != null) 134 this.getBox().setTopPadding( Integer.parseInt( style.getAttributeString(style.ATTRIBUTE_topPadding, null, true) )); 135 136 if (style.getAttributeString(style.ATTRIBUTE_leftBorder, null, true) != null) 137 this.getBox().setLeftBorder( style.getAttributeString(style.ATTRIBUTE_leftBorder, null, true) ); 138 if (style.getAttributeColor(style.ATTRIBUTE_leftBorderColor, null, true) != null) 139 this.getBox().setLeftBorderColor( style.getAttributeColor(style.ATTRIBUTE_leftBorderColor, null, true)); 140 if (style.getAttributeString(style.ATTRIBUTE_leftPadding, null, true) != null) 141 this.getBox().setLeftPadding( Integer.parseInt( style.getAttributeString(style.ATTRIBUTE_leftPadding, null, true) )); 142 143 if (style.getAttributeString(style.ATTRIBUTE_rightBorder, null, true) != null) 144 this.getBox().setRightBorder( style.getAttributeString(style.ATTRIBUTE_rightBorder, null, true) ); 145 if (style.getAttributeColor(style.ATTRIBUTE_rightBorderColor, null, true) != null) 146 this.getBox().setRightBorderColor( style.getAttributeColor(style.ATTRIBUTE_rightBorderColor, null, true)); 147 if (style.getAttributeString(style.ATTRIBUTE_rightPadding, null, true) != null) 148 this.getBox().setRightPadding( Integer.parseInt( style.getAttributeString(style.ATTRIBUTE_rightPadding, null, true) )); 149 150 if (style.getAttributeString(style.ATTRIBUTE_bottomBorder, null, true) != null) 151 this.getBox().setBottomBorder( style.getAttributeString(style.ATTRIBUTE_bottomBorder, null, true) ); 152 if (style.getAttributeColor(style.ATTRIBUTE_bottomBorderColor, null, true) != null) 153 this.getBox().setBottomBorderColor( style.getAttributeColor(style.ATTRIBUTE_bottomBorderColor, null, true)); 154 if (style.getAttributeString(style.ATTRIBUTE_bottomPadding, null, true) != null) 155 this.getBox().setBottomPadding( Integer.parseInt( style.getAttributeString(style.ATTRIBUTE_bottomPadding, null, true) )); 156 157 } 158 } 159 160 } 161 | Popular Tags |