1 32 33 package it.businesslogic.ireport; 34 35 import it.businesslogic.ireport.gui.*; 36 import it.businesslogic.ireport.util.*; 37 import java.awt.*; 38 import java.awt.image.*; 39 import java.awt.geom.*; 40 import javax.swing.ImageIcon ; 41 import javax.swing.JPanel ; 42 43 public class BreakReportElement extends ReportElement 44 { 45 46 public static ImageIcon img=null; 47 48 static { 49 img = new ImageIcon ( BreakReportElement.class.getResource("/it/businesslogic/ireport/icons/tree/elements/break.png")); 50 } 51 52 private String type = "Page"; 53 54 public BreakReportElement(int x, int y, int width, int height) 55 { 56 super(x, y, Math.abs(width) , Math.abs(height) ); 57 } 58 59 public BreakReportElement(int x, int y, int width, int height, String type) 60 { 61 super(x, y, Math.abs(width) , Math.abs(height) ); 62 this.type = type; 66 setKey("break"); 67 } 68 69 public void drawObject(Graphics2D g,double zoom_factor, int x_shift_origin, int y_shift_origin) 70 { 71 this.zoom_factor = zoom_factor; 72 int height_draw = 0; 73 if (height <= 1) height_draw = 0; 74 else height_draw = height-1; 75 int width_draw = 0; 76 if (width <= 1) width_draw = 0; 77 else width_draw = width-1; 78 79 int leftX = 0; 80 int rightX = 0; 81 if (this.getBand() != null && this.getBand().getParent() != null) 82 { 83 Report report = this.getBand().getParent(); 84 rightX = (int)(report.getLeftMargin()*zoom_factor); 85 leftX = (int)((report.getWidth() - report.getRightMargin()) *zoom_factor); 86 } 87 88 Point a = new Point( rightX + 10 - x_shift_origin, getZoomedDim( position.y-10) +10-y_shift_origin ); 90 Point b = new Point( leftX + 10 - x_shift_origin, (int)a.getY()); 91 92 93 Stroke stroke = this.getPenStroke( "Dotted" ,1 ); 94 if(stroke != null){ 95 Stroke oldStroke = g.getStroke(); 96 g.setStroke(stroke); 97 98 g.setColor( getFgcolor() ); 99 g.drawLine(a.x,a.y,b.x,b.y); 100 g.setStroke(oldStroke); 101 } 102 103 if (img != null) 104 g.drawImage( img.getImage(),a.x-18, a.y-7, img.getImageObserver()); 105 } 106 107 public ReportElement cloneMe() 108 { 109 BreakReportElement newReportElement = new BreakReportElement(position.x, position.y, width, height); 110 copyBaseReportElement(newReportElement, this); 111 112 return newReportElement; 113 } 114 115 public void copyBaseReportElement(ReportElement destination, ReportElement source) 116 { 117 super.copyBaseReportElement(destination, source); 118 119 if (destination instanceof BreakReportElement && 120 source instanceof BreakReportElement ) 121 { 122 ((BreakReportElement)destination).setType( new String ( ((BreakReportElement)source).getType())); 123 } 124 } 125 126 public boolean insideBand() 127 { 128 129 int r_height = (height == 0) ? 1 : height; 130 if (band == null) 131 { 132 133 return false; 134 } 135 136 int yband = band.getBandYLocation(); 137 138 if (position.y - yband + r_height > band.getHeight()) 139 { 140 return false; 141 } 142 return super.insideBand(); 143 } 144 145 public String getType() { 146 return type; 147 } 148 149 public void setType(String type) { 150 this.type = type; 151 } 152 } 153 | Popular Tags |