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 41 public class LineReportElement extends GraphicReportElement 42 { 43 44 public String direction; 45 46 public LineReportElement(int x, int y, int width, int height) 47 { 48 this(x, y , width, height, "whatever"); 52 53 if (width * height >= 0) { 54 setDirection( "TopDown" ); 55 } else { 56 setDirection( "BottomUp" ); 57 } 58 } 59 60 public LineReportElement(int x, int y, int width, int height, String direction) 61 { 62 super(x, y, Math.abs(width) , Math.abs(height) ); 63 this.direction = direction; 67 setKey("line"); 68 } 69 70 public void drawObject(Graphics2D g,double zoom_factor, int x_shift_origin, int y_shift_origin) 71 { 72 this.zoom_factor = zoom_factor; 73 int height_draw = 0; 74 if (height <= 1) height_draw = 0; 75 else height_draw = height-1; 76 int width_draw = 0; 77 if (width <= 1) width_draw = 0; 78 else width_draw = width-1; 79 80 Point a = new Point( getZoomedDim( position.x-10) +10-x_shift_origin, getZoomedDim( position.y-10) +10-y_shift_origin ); 82 Point b = new Point( getZoomedDim(position.x+width_draw-10)+10-x_shift_origin,getZoomedDim( position.y+height_draw-10)+10-y_shift_origin); 83 84 if (!direction.equalsIgnoreCase("TopDown")) 85 { 86 b.y = getZoomedDim( position.y-10) +10-y_shift_origin; 87 a.y = getZoomedDim( position.y+height-10)+10-y_shift_origin; 88 } 89 90 Stroke stroke = this.getPenStroke( getGraphicElementPen() ,zoom_factor ); 91 if(stroke != null){ 92 Stroke oldStroke = g.getStroke(); 93 g.setStroke(stroke); 94 95 g.setColor( getFgcolor() ); 96 g.drawLine(a.x,a.y,b.x,b.y); 97 g.setStroke(oldStroke); 98 } 99 } 100 101 public ReportElement cloneMe() 102 { 103 LineReportElement newReportElement = new LineReportElement(position.x, position.y, width, height); 104 copyBaseReportElement(newReportElement, this); 105 106 return newReportElement; 107 } 108 109 113 public java.lang.String getDirection() { 114 return direction; 115 } 116 117 121 public void setDirection(java.lang.String direction) { 122 this.direction = direction; 123 } 124 125 public void copyBaseReportElement(ReportElement destination, ReportElement source) 126 { 127 super.copyBaseReportElement(destination, source); 128 129 if (destination instanceof LineReportElement && 130 source instanceof LineReportElement ) 131 { 132 ((LineReportElement)destination).setDirection( new String ( ((LineReportElement)source).getDirection())); 133 } 134 } 135 136 public boolean insideBand() 137 { 138 139 int r_height = (height == 0) ? 1 : height; 140 if (band == null) 141 { 142 143 return false; 144 } 145 146 int yband = band.getBandYLocation(); 147 148 if (position.y - yband + r_height > band.getHeight()) 149 { 150 return false; 151 } 152 return super.insideBand(); 153 } 154 } 155 | Popular Tags |