KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > it > businesslogic > ireport > ReportElement


1 /*
2  * Copyright (C) 2005 - 2006 JasperSoft Corporation. All rights reserved.
3  * http://www.jaspersoft.com.
4  *
5  * Unless you have purchased a commercial license agreement from JasperSoft,
6  * the following license terms apply:
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as published by
10  * the Free Software Foundation.
11  *
12  * This program is distributed WITHOUT ANY WARRANTY; and without the
13  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
18  * or write to:
19  *
20  * Free Software Foundation, Inc.,
21  * 59 Temple Place - Suite 330,
22  * Boston, MA USA 02111-1307
23  *
24  *
25  *
26  *
27  * ReportElement.java
28  *
29  */

30
31 package it.businesslogic.ireport;
32
33 import it.businesslogic.ireport.crosstab.CrosstabCell;
34 import it.businesslogic.ireport.util.*;
35
36 import java.awt.*;
37 import java.awt.geom.*;
38 import java.awt.image.*;
39
40 import java.util.Iterator JavaDoc;
41 import java.util.Vector JavaDoc;
42
43
44 public class ReportElement extends IReportHashMapBean
45 {
46
47     static int id_gen = 1;
48     
49     private int elementID = 0;
50     
51     /**
52      * Key for element properties handled using the IReportHashMapBean
53      */

54     public static final String JavaDoc BGCOLOR = "BGCOLOR";
55     public static final String JavaDoc FGCOLOR = "FGCOLOR";
56     public static final String JavaDoc MODE = "MODE"; // transparent or opaque...
57
public static final String JavaDoc REMOVE_LINE_WHEN_BLANK = "REMOVE_LINE_WHEN_BLANK";
58     public static final String JavaDoc PRINT_REPEATED_VALUES = "PRINT_REPEATED_VALUES";
59     public static final String JavaDoc PRINT_IN_FIRST_WHOLE_BAND = "DEFAULT_PRINT_IN_FIRST_WHOLE_BAND";
60     public static final String JavaDoc PRINT_WHEN_DETAIL_OVERFLOW = "PRINT_WHEN_DETAIL_OVERFLOW";
61     public static final String JavaDoc POSITION_TYPE = "POSITION_TYPE";
62     
63     /**
64      * Default values. If a value can change for different elements,
65      * it is not listed here (i.e. MODE).
66      */

67     public static final Color DEFAULT_BGCOLOR = Color.WHITE;
68     public static final Color DEFAULT_FGCOLOR = Color.BLACK;
69     public static final boolean DEFAULT_REMOVE_LINE_WHEN_BLANK = false;
70     public static final boolean DEFAULT_PRINT_REPEATED_VALUES = true;
71     public static final boolean DEFAULT_PRINT_IN_FIRST_WHOLE_BAND = false;
72     public static final boolean DEFAULT_PRINT_WHEN_DETAIL_OVERFLOW = false;
73     public static final String JavaDoc DEFAULT_POSITION_TYPE = "FixRelativeToTop";
74     
75     /**
76      * Values that can be overridden by subclasses....
77      */

78     public String JavaDoc transparentDefault = "Opaque";
79     
80     
81     public String JavaDoc name;
82     public Point position;
83     
84     /**
85      * Relative position is used in crosstab editor only
86      **/

87     private Point relativePosition;
88     public int width;
89     public int height;
90     Rectangle bounds;
91     public static BufferedImage hached = null;
92     public Band band;
93     private CrosstabCell cell;
94     
95     public String JavaDoc printWhenExpression = "";
96     //public String positionType = "FixRelativeToTop";
97
//public boolean isPrintRepeatedValues = true;
98
//public boolean isRemoveLineWhenBlank = false;
99
//public boolean isPrintInFirstWholeBand = false;
100
//public boolean isPrintWhenDetailOverflows = false;
101

102     public static Color lightcolor;
103     
104     public String JavaDoc printWhenGroupChanges = "";
105     double zoom_factor = 1.0;
106
107     protected String JavaDoc stretchType;
108     private String JavaDoc elementGroup = "";
109     public Vector JavaDoc intersections = new Vector JavaDoc();
110     
111     private Style style = null;
112     
113     private ReportElement parentElement = null;
114
115     /**
116      * Creates a new ReportElement object.
117      *
118      * @param x DOCUMENT ME!
119      * @param y DOCUMENT ME!
120      * @param width DOCUMENT ME!
121      * @param height DOCUMENT ME!
122      */

123     public ReportElement(int x, int y, int width, int height)
124     {
125         
126         if (hached == null)
127         {
128             hached = Misc.loadBufferedImageFromResources(new java.awt.Panel JavaDoc(),
129                                                          "it/businesslogic/ireport/icons/layout/hached.gif");
130         }
131
132         this.position = new Point(x, y);
133         this.setRelativePosition(new Point(x, y));
134         this.width = Math.abs(width);
135         this.height = Math.abs(height);
136
137         bounds = new Rectangle(position.x, position.y, width, height);
138         name = "element-" + id_gen;
139         setElementID(id_gen);
140         id_gen++;
141         this.hached = hached;
142
143         if (lightcolor == null)
144         {
145             lightcolor = Color.LIGHT_GRAY;
146         }
147
148         stretchType = "NoStretch";
149     }
150
151     /**
152      * DOCUMENT ME!
153      *
154      * @param g DOCUMENT ME!
155      * @param zoom_factor DOCUMENT ME!
156      * @param x_shift_origin DOCUMENT ME!
157      * @param y_shift_origin DOCUMENT ME!
158      */

159     public void drawObject(Graphics2D g, double zoom_factor,
160                            int x_shift_origin, int y_shift_origin)
161     {
162         position.x -= 10;
163         position.y -= 10;
164         x_shift_origin -= 10;
165         y_shift_origin -= 10;
166
167         this.zoom_factor = zoom_factor;
168
169         //g.setPaint( new TexturePaint( red, new Rectangle2D.Double( zoomed_width+10-horizontal_scroll,9-vertical_scroll,9,9)));
170
g.fillRect(getZoomedDim(position.x) - x_shift_origin,
171                    getZoomedDim(position.y) - y_shift_origin,
172                    getZoomedDim(width), getZoomedDim(height));
173
174         //g.drawRect(getZoomedDim(position.x)-x_shift_origin, getZoomedDim(position.y)-y_shift_origin, getZoomedDim(width), getZoomedDim(height));
175
position.x += 10;
176         position.y += 10;
177         x_shift_origin += 10;
178         y_shift_origin += 10;
179
180         drawGraphicsElement(g, "2Point", zoom_factor, x_shift_origin,
181                             y_shift_origin);
182         drawBorder(g, zoom_factor, x_shift_origin, y_shift_origin);
183     }
184
185     /**
186      * DOCUMENT ME!
187      *
188      * @param g DOCUMENT ME!
189      * @param pen DOCUMENT ME!
190      * @param zoom_factor DOCUMENT ME!
191      * @param x_shift_origin DOCUMENT ME!
192      * @param y_shift_origin DOCUMENT ME!
193      */

194     public void drawGraphicsElement(Graphics2D g, String JavaDoc pen,
195                                     double zoom_factor, int x_shift_origin,
196                                     int y_shift_origin)
197     {
198         drawGraphicsElement(g, pen, zoom_factor, x_shift_origin,
199                             y_shift_origin, 0);
200     }
201
202     /**
203      * DOCUMENT ME!
204      *
205      * @param g DOCUMENT ME!
206      * @param pen DOCUMENT ME!
207      * @param zoom_factor DOCUMENT ME!
208      * @param x_shift_origin DOCUMENT ME!
209      * @param y_shift_origin DOCUMENT ME!
210      * @param radius DOCUMENT ME!
211      */

212     public void drawGraphicsElement(Graphics2D g, String JavaDoc pen,
213                                     double zoom_factor, int x_shift_origin,
214                                     int y_shift_origin, int radius)
215     {
216
217         int correction = (zoom_factor <= 1 &&
218                          (pen.equals("Thin") || pen.equals("1Point") ||
219                              pen.equals("Dotted")))
220                              ? -1
221                              : 0;
222         int xy_correction = (zoom_factor <= 1 && pen.equals("Dotted"))
223                                 ? 1
224                                 : 0;
225
226         Stroke stroke = getPenStroke(pen, zoom_factor);
227         g.setColor(this.getFgcolor());
228
229         this.zoom_factor = zoom_factor;
230
231         if (stroke == null || pen.equalsIgnoreCase("None"))
232         {
233
234             return;
235         }
236
237         position.x -= 10;
238         position.y -= 10;
239         x_shift_origin -= 10;
240         y_shift_origin -= 10;
241
242         Stroke oldStroke = g.getStroke();
243         g.setStroke(stroke);
244
245         if (radius != 0)
246         {
247             g.drawRoundRect(
248                     getZoomedDim(position.x) - x_shift_origin +
249                     xy_correction,
250                     getZoomedDim(position.y) - y_shift_origin +
251                     xy_correction, getZoomedDim(width) + correction,
252                     getZoomedDim(height) + correction, getZoomedDim(radius), getZoomedDim(radius));
253         }
254         else
255         {
256             g.drawRect(getZoomedDim(position.x) - x_shift_origin +
257                        xy_correction,
258                        getZoomedDim(position.y) - y_shift_origin +
259                        xy_correction, getZoomedDim(width) + correction,
260                        getZoomedDim(height) + correction);
261         }
262
263         position.x += 10;
264         position.y += 10;
265
266         g.setStroke(oldStroke);
267     }
268
269     /**
270      * DOCUMENT ME!
271      *
272      * @param g DOCUMENT ME!
273      * @param zoom_factor DOCUMENT ME!
274      * @param x_shift_origin DOCUMENT ME!
275      * @param y_shift_origin DOCUMENT ME!
276      */

277     public void drawBorder(Graphics2D g, double zoom_factor,
278                            int x_shift_origin, int y_shift_origin)
279     {
280         drawBorder(g, zoom_factor, x_shift_origin, y_shift_origin, null);
281     }
282
283     /**
284      * DOCUMENT ME!
285      *
286      * @param g DOCUMENT ME!
287      * @param zoom_factor DOCUMENT ME!
288      * @param x_shift_origin DOCUMENT ME!
289      * @param y_shift_origin DOCUMENT ME!
290      * @param box DOCUMENT ME!
291      */

292     public void drawBorder(Graphics2D g, double zoom_factor,
293                            int x_shift_origin, int y_shift_origin, Box box)
294     {
295         this.zoom_factor = zoom_factor;
296
297         int correction = (zoom_factor <= 1)
298                              ? -1
299                              : 0;
300
301         position.x -= 10;
302         position.y -= 10;
303         x_shift_origin -= 10;
304         y_shift_origin -= 10;
305
306         Stroke oldStroke = g.getStroke();
307
308         if (box == null || !insideBand())
309         {
310
311             if (insideBand())
312             {
313                 g.setColor(lightcolor);
314             }
315             else
316             {
317                 g.setColor(Color.RED);
318             }
319
320             g.drawRect(getZoomedDim(position.x) - x_shift_origin,
321                        getZoomedDim(position.y) - y_shift_origin,
322                        getZoomedDim(width) + correction,
323                        getZoomedDim(height) + correction);
324         }
325         else
326         {
327
328             // Left side
329
boolean insideBand = insideBand();
330             int ax = getZoomedDim(position.x) - x_shift_origin;
331             int ay = getZoomedDim(position.y) - y_shift_origin;
332             int bx = ax + getZoomedDim(width) + correction;
333             int by = ay + getZoomedDim(height) + correction;
334
335             Stroke newBoxStroke = null;
336
337             if (box.getLeftBorderColor() != null)
338             {
339                 g.setColor(box.getLeftBorderColor());
340             }
341             else
342             {
343                 g.setColor(lightcolor);
344             }
345
346             if ((newBoxStroke = getPenStroke(box.getLeftBorder(), zoom_factor)) != null)
347             {
348                 g.setStroke(newBoxStroke);
349                 g.drawLine(ax, ay, ax, by);
350             }
351
352             //else g.setStroke(oldStroke);
353
if (box.getTopBorderColor() != null)
354             {
355                 g.setColor(box.getTopBorderColor());
356             }
357             else
358             {
359                 g.setColor(lightcolor);
360             }
361
362             if ((newBoxStroke = getPenStroke(box.getTopBorder(), zoom_factor)) != null)
363             {
364                 g.setStroke(newBoxStroke);
365                 g.drawLine(ax, ay, bx, ay);
366             }
367
368             if (box.getRightBorderColor() != null)
369             {
370                 g.setColor(box.getRightBorderColor());
371             }
372             else
373             {
374                 g.setColor(lightcolor);
375             }
376
377             if ((newBoxStroke = getPenStroke(box.getRightBorder(), zoom_factor)) != null)
378             {
379                 g.setStroke(newBoxStroke);
380                 g.drawLine(bx, ay, bx, by);
381             }
382
383             if (box.getBottomBorderColor() != null)
384             {
385                 g.setColor(box.getBottomBorderColor());
386             }
387             else
388             {
389                 g.setColor(lightcolor);
390             }
391
392             if ((newBoxStroke = getPenStroke(box.getBottomBorder(),
393                                              zoom_factor)) != null)
394             {
395                 g.setStroke(newBoxStroke);
396                 g.drawLine(ax, by, bx, by);
397             }
398
399             g.setStroke(oldStroke);
400         }
401
402         position.x += 10;
403         position.y += 10;
404         x_shift_origin += 10;
405         y_shift_origin += 10;
406     }
407
408     /**
409      * DOCUMENT ME!
410      *
411      * @param g DOCUMENT ME!
412      * @param zoom_factor DOCUMENT ME!
413      * @param x_shift_origin DOCUMENT ME!
414      * @param y_shift_origin DOCUMENT ME!
415      * @param selected DOCUMENT ME!
416      */

417     public void drawCorona(Graphics2D g, double zoom_factor,
418                            int x_shift_origin, int y_shift_origin,
419                            boolean selected)
420     {
421         this.zoom_factor = zoom_factor;
422
423         // draw a corona...
424
position.x -= 10;
425         position.y -= 10;
426         x_shift_origin -= 10;
427         y_shift_origin -= 10;
428
429         Rectangle2D r = new Rectangle2D.Double(
430                                 getZoomedDim(position.x) - 5 -
431                                 x_shift_origin,
432                                 getZoomedDim(position.y) - 5 -
433                                 y_shift_origin, getZoomedDim(width) + 10,
434                                 getZoomedDim(height) + 10);
435
436         Rectangle2D r2 = new Rectangle2D.Double(
437                                  getZoomedDim(position.x) - x_shift_origin,
438                                  getZoomedDim(position.y) - y_shift_origin,
439                                  getZoomedDim(width), getZoomedDim(height));
440         java.awt.geom.Area JavaDoc area = new Area(r);
441         area.exclusiveOr(new Area(r2));
442
443         if (hached == null)
444         {
445             g.fill(area);
446         }
447         else
448         {
449             g.setPaint(new java.awt.TexturePaint JavaDoc(hached,
450                                                  new Rectangle2D.Double(0, 0,
451                                                                         2, 2)));
452             g.fill(area);
453         }
454
455         // draw grips...
456
g.setPaint(Color.BLUE);
457
458         if (!selected)
459         {
460             g.setPaint(Color.GRAY);
461         }
462
463         // checking overlaps slows down the repainting
464
if (intersectsElements())
465         {
466
467             if (enclosesOtherElement())
468             {
469                 g.setPaint(Color.PINK);
470             }
471             else
472             {
473                 g.setPaint(Color.GREEN);
474             }
475
476         }
477
478         if (!insideBand())
479         {
480             g.setPaint(Color.RED);
481         }
482
483         g.fillRect(getZoomedDim(position.x) - 5 - x_shift_origin,
484                    getZoomedDim(position.y) - 5 - y_shift_origin, 5, 5);
485         g.fillRect(getZoomedDim(position.x + width) - x_shift_origin,
486                    getZoomedDim(position.y) - 5 - y_shift_origin, 5, 5);
487         g.fillRect(getZoomedDim(position.x + width) - x_shift_origin,
488                    getZoomedDim(position.y + height) - y_shift_origin, 5, 5);
489         g.fillRect(getZoomedDim(position.x) - 5 - x_shift_origin,
490                    getZoomedDim(position.y + height) - y_shift_origin, 5, 5);
491
492         g.fillRect(getZoomedDim(position.x + (width / 2)) - 2 -
493                    x_shift_origin,
494                    getZoomedDim(position.y) - 5 - y_shift_origin, 5, 5);
495         g.fillRect(getZoomedDim(position.x + (width / 2)) - 2 -
496                    x_shift_origin,
497                    getZoomedDim(position.y + height) - y_shift_origin, 5, 5);
498         g.fillRect(getZoomedDim(position.x) - 5 - x_shift_origin,
499                    getZoomedDim(position.y + (height / 2)) - 2 -
500                    y_shift_origin, 5, 5);
501         g.fillRect(getZoomedDim(position.x + width) - x_shift_origin,
502                    getZoomedDim(position.y + (height / 2)) - 2 -
503                    y_shift_origin, 5, 5);
504
505         position.x += 10;
506         position.y += 10;
507     }
508
509     /**
510      * DOCUMENT ME!
511      *
512      * @return DOCUMENT ME!
513      */

514     public boolean enclosesOtherElement()
515     {
516
517         for (Iterator JavaDoc i = intersections.iterator(); i.hasNext();)
518         {
519
520             ReportElement e = (ReportElement) i.next();
521
522             if (bounds.contains(e.bounds))
523             {
524
525                 return true;
526             }
527         }
528
529         return false;
530     }
531     
532     /**
533      * DOCUMENT ME!
534      *
535      * @return DOCUMENT ME!
536      */

537     public boolean intersectsElements()
538     {
539
540         int oldHeight = 0;
541         boolean result = false;
542
543         // do not stop after you found an intersection
544
// list them all so that
545
// later on you can see whether one is hidden or enclosed by the
546
// current element.
547
Iterator JavaDoc i = null;
548         if (band == null && cell == null) return false;
549         if (band != null) i = band.getParent().getElements().iterator();
550         else i = cell.getParent().getElements().iterator();
551         for (;i.hasNext();)
552         {
553
554             ReportElement e = (ReportElement) i.next();
555
556             // do not compare with 'this' reportElement
557
if (!this.equals(e))
558             {
559                 oldHeight = e.height;
560
561                 // make lines a little heigher,so that they can intersect
562
// with a rectangle
563
if (e.height == 0)
564                 {
565                     e.height = 10;
566                 }
567
568                 if (e.bounds.intersects(bounds))
569                 {
570
571                     // store the intersecting rectangle
572
this.intersections.add(e);
573                     result = true;
574                 }
575
576                 e.height = oldHeight;
577             }
578         }
579
580         return result;
581     }
582
583     /**
584      * DOCUMENT ME!
585      *
586      * @param p DOCUMENT ME!
587      * @return DOCUMENT ME!
588      */

589     public boolean intersects(Point p)
590     {
591
592         Rectangle r = new Rectangle(bounds);
593
594         if (height == 0)
595         {
596             r.height = 10;
597             r.y -= 5;
598         }
599
600         if (width == 0)
601         {
602             r.width = 10;
603             r.x -= 5;
604         }
605
606         return r.intersects(p.x, p.y, 1, 1);
607     }
608
609     /**
610      * DOCUMENT ME!
611      *
612      * @return DOCUMENT ME!
613      */

614     public boolean insideBandReal()
615     {
616         position.x -= 10;
617         position.y -= 10;
618
619         boolean result = insideBand();
620
621         position.x += 10;
622         position.y += 10;
623
624         return result;
625     }
626
627     /**
628      * DOCUMENT ME!
629      *
630      * @return DOCUMENT ME!
631      */

632     public boolean insideBand()
633     {
634
635         if (band == null)
636         {
637             if (cell != null)
638             {
639                 return cell.getBounds().contains( new Rectangle(getPosition().x,getPosition().y,width,height) );
640             }
641             return false;
642         }
643
644         int yband = band.getBandYLocation();
645
646         // lower left corner of element is below the band.
647
if (position.y - yband < 0)
648         {
649
650             return false;
651         }
652
653         // lower left corner of element is left from the left margin
654
if (position.x - band.getParent().getLeftMargin() < 0)
655         {
656
657             return false;
658         }
659
660         // with element on the bottom the element is too high for the band
661
if (position.y - yband + height > band.getHeight())
662         {
663
664             return false;
665         }
666
667         // with element on the left margin, the width is larger than usable width of page.
668
if (position.x - band.getParent().getLeftMargin() + width > band.getUsableWidth())
669         {
670
671             return false;
672         }
673
674         return true;
675     }
676
677     /**
678      * DOCUMENT ME!
679      *
680      * @param r2 DOCUMENT ME!
681      * @return DOCUMENT ME!
682      */

683     public boolean intersects(Rectangle r2)
684     {
685
686         Rectangle r = new Rectangle(bounds);
687
688         if (height == 0)
689         {
690             r.height = 10;
691             r.y -= 5;
692         }
693
694         if (width == 0)
695         {
696             r.width = 10;
697             r.x -= 5;
698         }
699
700         return r.intersects(r2);
701     }
702
703     /**
704      * DOCUMENT ME!
705      *
706      * @param p DOCUMENT ME!
707      */

708     public void setPosition(Point p)
709     {
710
711         if (p == null)
712         {
713
714             return;
715         }
716
717         if (p.x == position.x && p.y == position.y)
718         {
719
720             return;
721         }
722
723         position.x = p.x;
724         position.y = p.y;
725         bounds = new Rectangle(position.x, position.y, width, height);
726     }
727
728     /**
729      * DOCUMENT ME!
730      *
731      * @param delta DOCUMENT ME!
732      * @param type DOCUMENT ME!
733      * @return DOCUMENT ME!
734      */

735     public Point trasform(Point delta, int type)
736     {
737
738         if (delta == null)
739         {
740
741             return null;
742         }
743
744         Point result = new Point(delta);
745         int old_x = 0;
746         int old_y = 0;
747
748         if (type == TransformationType.TRANSFORMATION_MOVE)
749         {
750             position.x += delta.x;
751             position.y += delta.y;
752         }
753         else if (type == TransformationType.TRANSFORMATION_RESIZE_E)
754         {
755             old_x = width;
756             width += delta.x;
757
758             if (width < 0)
759             {
760                 width = 0;
761             }
762
763             result.x = width - old_x;
764         }
765         else if (type == TransformationType.TRANSFORMATION_RESIZE_W)
766         {
767             old_x = width;
768
769             int d = Math.min(delta.x, width);
770             width -= d;
771             position.x += d;
772             result.x = d;
773         }
774         else if (type == TransformationType.TRANSFORMATION_RESIZE_N)
775         {
776
777             int d = Math.min(delta.y, height);
778             height -= d;
779             position.y += d;
780             result.y = d;
781         }
782         else if (type == TransformationType.TRANSFORMATION_RESIZE_S)
783         {
784             old_y = height;
785             height += delta.y;
786
787             if (height < 0)
788             {
789                 height = 0;
790             }
791
792             result.y = height - old_y;
793         }
794         else if (type == TransformationType.TRANSFORMATION_RESIZE_SE)
795         {
796             old_y = height;
797             old_x = width;
798             height += delta.y;
799
800             if (height < 0)
801             {
802                 height = 0;
803             }
804
805             width += delta.x;
806
807             if (width < 0)
808             {
809                 width = 0;
810             }
811
812             result.x = width - old_x;
813             result.y = height - old_y;
814         }
815         else if (type == TransformationType.TRANSFORMATION_RESIZE_SW)
816         {
817             old_y = height;
818             height += delta.y;
819
820             if (height < 0)
821             {
822                 height = 0;
823             }
824
825             int d = Math.min(delta.x, width);
826             width -= d;
827             position.x += d;
828             result.x = d;
829             result.y = height - old_y;
830         }
831         else if (type == TransformationType.TRANSFORMATION_RESIZE_NE)
832         {
833             old_x = width;
834
835             int d = Math.min(delta.y, height);
836             height -= d;
837             position.y += d;
838             width += delta.x;
839
840             if (width < 0)
841             {
842                 width = 0;
843             }
844
845             result.x = width - old_x;
846             result.y = d;
847         }
848         else if (type == TransformationType.TRANSFORMATION_RESIZE_NW)
849         {
850
851             int d = Math.min(delta.y, height);
852             height -= d;
853             position.y += d;
854             result.y = d;
855             d = Math.min(delta.x, width);
856             width -= d;
857             position.x += d;
858             result.x = d;
859         }
860
861         bounds = new Rectangle(position.x, position.y, width, height);
862         
863         if (getCell() != null && type != TransformationType.TRANSFORMATION_RESIZE_SE)
864         {
865            setRelativePosition( new Point(getPosition().x - getCell().getLeft()- 10, getPosition().y - getCell().getTop()- 10));
866         }
867         
868         return result;
869     }
870
871     /**
872      * Try to move the element to another band if the element is placed
873      * entirely within the band.
874      *
875      */

876     public void adjustBand()
877     {
878         if (band == null) return;
879         position.x -= 10;
880         position.y -= 10;
881
882         for (Iterator JavaDoc i = band.getParent().getBands().iterator(); i.hasNext();)
883         {
884
885             Band b = (Band) i.next();
886
887             if (position.y - band.getParent().getBandYLocation(b) >= 0)
888             {
889
890                 if (position.y - band.getParent().getBandYLocation(b) +
891                     height <= b.getHeight())
892                 {
893
894                     // element is within this band.
895
band = b;
896
897                     break;
898                 }
899             }
900         }
901
902         position.x += 10;
903         position.y += 10;
904     }
905
906     
907     public void adjustCell(Vector JavaDoc cells)
908     {
909         if (getCell().getType() == CrosstabCell.NODATA_CELL) return;
910         for (int i=0; i<cells.size(); ++i)
911         {
912             CrosstabCell tmpCell = (CrosstabCell)cells.elementAt(i);
913             if (tmpCell.getType() == CrosstabCell.NODATA_CELL) continue;
914             if ( tmpCell.getBounds().contains( new Point(getPosition().x-10,getPosition().y-10) ) )
915             {
916                 this.setCell( tmpCell );
917                 setRelativePosition(new Point( getPosition().x - getCell().getLeft() - 10, getPosition().y - getCell().getTop() - 10 ));
918                 return;
919             }
920         }
921     }
922     
923     
924     /**
925      * this methos adjust the relativo position respect to the parent cell.
926      * If parent cell is null, nothing is done.
927      * You should call this method after a brute setPosition
928      */

929     public void updateRelativePosition()
930     {
931         if (getCell() == null) return;
932         setRelativePosition(new Point( getPosition().x - getCell().getLeft() - 10, getPosition().y - getCell().getTop() - 10 ));
933     }
934     
935     
936     /*
937      * This method should be called when you modify height, width,
938      * or position manually.
939      */

940
941     /**
942      * DOCUMENT ME!
943      */

944     public void updateBounds()
945     {
946         bounds = new Rectangle(position.x, position.y, width, height);
947     }
948     
949     
950     /**
951      * DOCUMENT ME!
952      *
953      * @param delta DOCUMENT ME!
954      * @param type DOCUMENT ME!
955      * @return DOCUMENT ME!
956      */

957     public Point trasformTest(Point delta, int type)
958     {
959
960         if (delta == null)
961         {
962
963             return null;
964         }
965
966         Point result = new Point(delta);
967         int old_x = 0;
968         int old_y = 0;
969
970         if (type == TransformationType.TRANSFORMATION_MOVE)
971         {
972         }
973         else if (type == TransformationType.TRANSFORMATION_RESIZE_E)
974         {
975             old_x = width;
976             old_x += delta.x;
977
978             if (old_x < 0)
979             {
980                 old_x = 0;
981             }
982
983             result.x = old_x - width;
984         }
985         else if (type == TransformationType.TRANSFORMATION_RESIZE_W)
986         {
987             result.x = Math.min(delta.x, width);
988         }
989         else if (type == TransformationType.TRANSFORMATION_RESIZE_N)
990         {
991             result.y = Math.min(delta.y, height);
992         }
993         else if (type == TransformationType.TRANSFORMATION_RESIZE_S)
994         {
995             old_y = height;
996             old_y += delta.y;
997
998             if (old_y < 0)
999             {
1000                old_y = 0;
1001            }
1002
1003            result.y = old_y - height;
1004        }
1005        else if (type == TransformationType.TRANSFORMATION_RESIZE_SE)
1006        {
1007            old_y = height;
1008            old_x = width;
1009            old_y += delta.y;
1010
1011            if (old_y < 0)
1012            {
1013                old_y = 0;
1014            }
1015
1016            old_x += delta.x;
1017
1018            if (old_x < 0)
1019            {
1020                old_x = 0;
1021            }
1022
1023            result.x = old_x - width;
1024            result.y = old_y - height;
1025        }
1026        else if (type == TransformationType.TRANSFORMATION_RESIZE_SW)
1027        {
1028            old_y = height;
1029            old_y += delta.y;
1030
1031            if (old_y < 0)
1032            {
1033                old_y = 0;
1034            }
1035
1036            result.x = Math.min(delta.x, width);
1037            result.y = old_y - height;
1038        }
1039        else if (type == TransformationType.TRANSFORMATION_RESIZE_NE)
1040        {
1041            old_x = width;
1042            result.y = Math.min(delta.y, height);
1043            old_x += delta.x;
1044
1045            if (old_x < 0)
1046            {
1047                old_x = 0;
1048            }
1049
1050            result.x = old_x - width;
1051        }
1052        else if (type == TransformationType.TRANSFORMATION_RESIZE_NW)
1053        {
1054            result.y = Math.min(delta.y, height);
1055            result.x = Math.min(delta.x, width);
1056        }
1057
1058        return result;
1059    }
1060
1061    /**
1062     * DOCUMENT ME!
1063     *
1064     * @return DOCUMENT ME!
1065     */

1066    public String JavaDoc toString()
1067    {
1068        if (band == null) return ""+name;
1069        else
1070        {
1071            if (getParentElement() == null)
1072            {
1073                return name + " [" +
1074                   (position.x - band.getParent().getRightMargin() - 10) + "," +
1075                   (position.y - band.getBandYLocation() - 10) + "]";
1076            }
1077            else
1078            {
1079                return name + " [" +
1080                   (position.x - getParentElement().getPosition().x) + "," +
1081                   (position.y - getParentElement().getPosition().y) + "]";
1082            }
1083        }
1084    }
1085
1086    /**
1087     * DOCUMENT ME!
1088     *
1089     * @param dim DOCUMENT ME!
1090     * @return DOCUMENT ME!
1091     */

1092    public int getZoomedDim(int dim)
1093    {
1094
1095        if (zoom_factor == 1.0)
1096        {
1097
1098            return dim;
1099        }
1100
1101        //if (((double)dim*(double)zoom_factor)<0.5) return 1;
1102
// Truncate, don't round!!
1103
return (int) ((double) dim * zoom_factor);
1104
1105        //return (int)Math.ceil((double)dim*zoom_factor);
1106
}
1107
1108    /**
1109     * DOCUMENT ME!
1110     *
1111     * @param dim DOCUMENT ME!
1112     * @return DOCUMENT ME!
1113     */

1114    public double getZoomedDim(double dim)
1115    {
1116
1117        if (zoom_factor == 1.0)
1118        {
1119
1120            return dim;
1121        }
1122
1123        //if (((double)dim*(double)zoom_factor)<0.5) return 1;
1124
// Truncate, don't round!!
1125
return ((double) dim * zoom_factor);
1126
1127        //return (int)Math.ceil((double)dim*zoom_factor);
1128
}
1129
1130    /**
1131     * DOCUMENT ME!
1132     *
1133     * @param dim DOCUMENT ME!
1134     * @return DOCUMENT ME!
1135     */

1136    public int getLogicalDim(int dim)
1137    {
1138
1139        if (zoom_factor == 1.0)
1140        {
1141
1142            return dim;
1143        }
1144
1145        //if (Math.abs( ((double)dim/(double)zoom_factor)) < 1 &&
1146
// Math.abs( ((double)dim/(double)zoom_factor)) > 0) return 1;
1147
// Truncate, don't round!!
1148
return (int) ((double) dim / zoom_factor);
1149
1150        //return (int)Math.ceil((double)dim/zoom_factor);
1151
}
1152
1153    /**
1154     * DOCUMENT ME!
1155     *
1156     * @return DOCUMENT ME!
1157     */

1158    public ReportElement cloneMe()
1159    {
1160
1161        ReportElement newReportElement = new ReportElement(position.x,
1162                                                           position.y, width,
1163                                                           height);
1164        newReportElement.name = new String JavaDoc(name);
1165        newReportElement.band = band;
1166        newReportElement.cell = cell;
1167        newReportElement.parentElement = parentElement;
1168        
1169        copyElementPropertiesTo(newReportElement);
1170
1171        return newReportElement;
1172    }
1173
1174    /**
1175     * DOCUMENT ME!
1176     *
1177     * @param newReportElement DOCUMENT ME!
1178     */

1179    public void copyElementPropertiesTo(ReportElement newReportElement)
1180    {
1181        newReportElement.printWhenExpression = printWhenExpression;
1182
1183        newReportElement.setPropertyValue(POSITION_TYPE, this.getPropertyValue(POSITION_TYPE));
1184        newReportElement.setPropertyValue(REMOVE_LINE_WHEN_BLANK, this.getPropertyValue(REMOVE_LINE_WHEN_BLANK));
1185        newReportElement.setPropertyValue(PRINT_REPEATED_VALUES, this.getPropertyValue(PRINT_REPEATED_VALUES) );
1186        newReportElement.setPropertyValue(PRINT_IN_FIRST_WHOLE_BAND, this.getPropertyValue(PRINT_IN_FIRST_WHOLE_BAND));
1187        newReportElement.setPropertyValue(PRINT_WHEN_DETAIL_OVERFLOW, this.getPropertyValue(PRINT_WHEN_DETAIL_OVERFLOW));
1188    }
1189
1190    /**
1191     * DOCUMENT ME!
1192     *
1193     * @param s1 DOCUMENT ME!
1194     * @param s2 DOCUMENT ME!
1195     * @param s3 DOCUMENT ME!
1196     * @return DOCUMENT ME!
1197     */

1198    public static String JavaDoc string_replace(String JavaDoc s1, String JavaDoc s2, String JavaDoc s3)
1199    {
1200
1201        String JavaDoc string = "";
1202        string = "";
1203
1204        if (s2 == null || s3 == null || s2.length() == 0)
1205        {
1206
1207            return s3;
1208        }
1209
1210        int pos_i = 0; // posizione corrente.
1211
int pos_f = 0; // posizione corrente finale
1212

1213        int len = s2.length();
1214
1215        while ((pos_f = s3.indexOf(s2, pos_i)) >= 0)
1216        {
1217            string += s3.substring(pos_i, pos_f) + s1;
1218
1219            //+string.substring(pos+ s2.length());
1220
pos_f = pos_i = pos_f + len;
1221
1222        }
1223
1224        string += s3.substring(pos_i);
1225
1226        return string;
1227    }
1228
1229    /**
1230     * DOCUMENT ME!
1231     *
1232     * @param pen DOCUMENT ME!
1233     * @param zoom_factor DOCUMENT ME!
1234     * @return DOCUMENT ME!
1235     */

1236    public static Stroke getPenStroke(String JavaDoc pen, double zoom_factor)
1237    {
1238
1239        if (pen == null || pen.equals("None"))
1240        {
1241
1242            return null;
1243        }
1244
1245        if (pen.equals("Dotted"))
1246        {
1247
1248            return (Stroke) new BasicStroke((float) (1f * zoom_factor),
1249                                            BasicStroke.CAP_BUTT,
1250                                            BasicStroke.JOIN_BEVEL, 0f,
1251                                            new float[] { 5f, 3f }, 0f);
1252        }
1253        else if (pen.equals("2Point"))
1254        {
1255
1256            return (Stroke) new BasicStroke((float) (2f * zoom_factor));
1257        }
1258        else if (pen.equals("3Point"))
1259        {
1260
1261            return (Stroke) new BasicStroke((float) (3f * zoom_factor));
1262        }
1263        else if (pen.equals("4Point"))
1264        {
1265
1266            return (Stroke) new BasicStroke((float) (4f * zoom_factor));
1267        }
1268        else if (pen.equals("Thin"))
1269        {
1270
1271            return (Stroke) new BasicStroke((float) (1f * zoom_factor));
1272        }
1273        else //if (pen.equals("1Point"))
1274
{
1275
1276            return (Stroke) new BasicStroke((float) (1f * zoom_factor));
1277        }
1278    }
1279
1280    /**
1281     * Getter for property width.
1282     *
1283     * @return Value of property width.
1284     */

1285    public int getWidth()
1286    {
1287
1288        return width;
1289    }
1290
1291    /**
1292     * Setter for property width.
1293     *
1294     * @param width New value of property width.
1295     */

1296    public void setWidth(int width)
1297    {
1298        this.width = width;
1299        updateBounds();
1300    }
1301
1302    /**
1303     * Getter for property height.
1304     *
1305     * @return Value of property height.
1306     */

1307    public int getHeight()
1308    {
1309
1310        return height;
1311    }
1312
1313    /**
1314     * Setter for property height.
1315     *
1316     * @param height New value of property height.
1317     */

1318    public void setHeight(int height)
1319    {
1320        this.height = height;
1321        updateBounds();
1322    }
1323
1324    /**
1325     * Getter for property position.
1326     *
1327     * @return Value of property position.
1328     */

1329    public java.awt.Point JavaDoc getPosition()
1330    {
1331
1332        return position;
1333    }
1334
1335    /**
1336     * Getter for property band.
1337     *
1338     * @return Value of property band.
1339     */

1340    public it.businesslogic.ireport.Band getBand()
1341    {
1342
1343        return band;
1344    }
1345
1346    /**
1347     * Setter for property band.
1348     *
1349     * @param band New value of property band.
1350     */

1351    public void setBand(it.businesslogic.ireport.Band band)
1352    {
1353        this.band = band;
1354    }
1355
1356    /**
1357     * Getter for property transparent.
1358     *
1359     * @return Value of property transparent.
1360     */

1361    public java.lang.String JavaDoc getTransparent()
1362    {
1363
1364        if (getStringValue(MODE, null ) == null)
1365        {
1366            // Look for a fgcolor in the stylesheet...
1367
if (getStyle() != null)
1368            {
1369               return getStyle().getAttributeString( getStyle().ATTRIBUTE_mode, transparentDefault , true);
1370            }
1371        }
1372        return getStringValue(MODE, transparentDefault );
1373    }
1374    
1375    /**
1376     * Setter for property transparent.
1377     *
1378     * @param transparent New value of property transparent.
1379     */

1380    public void setTransparent(java.lang.String JavaDoc transparent)
1381    {
1382        setPropertyValue(MODE,transparent);
1383    }
1384
1385    /**
1386     * Getter for property positionType.
1387     *
1388     * @return Value of property positionType.
1389     */

1390    public java.lang.String JavaDoc getPositionType()
1391    {
1392
1393        return getStringValue(POSITION_TYPE,DEFAULT_POSITION_TYPE);
1394    }
1395
1396    /**
1397     * Setter for property positionType.
1398     *
1399     * @param positionType New value of property positionType.
1400     */

1401    public void setPositionType(java.lang.String JavaDoc positionType)
1402    {
1403        setPropertyValue(POSITION_TYPE,positionType);
1404    }
1405
1406    /**
1407     * Getter for property isPrintInFirstWholeBand.
1408     *
1409     * @return Value of property isPrintInFirstWholeBand.
1410     */

1411    public boolean isIsPrintInFirstWholeBand()
1412    {
1413
1414        return getBooleanValue(PRINT_IN_FIRST_WHOLE_BAND, DEFAULT_PRINT_IN_FIRST_WHOLE_BAND );
1415    }
1416
1417    /**
1418     * Setter for property isPrintInFirstWholeBand.
1419     *
1420     * @param isPrintInFirstWholeBand New value of property
1421     * isPrintInFirstWholeBand.
1422     */

1423    public void setIsPrintInFirstWholeBand(boolean isPrintInFirstWholeBand)
1424    {
1425        setPropertyValue(PRINT_IN_FIRST_WHOLE_BAND, ""+isPrintInFirstWholeBand );
1426    }
1427
1428    /**
1429     * Getter for property printWhenExpression.
1430     *
1431     * @return Value of property printWhenExpression.
1432     */

1433    public java.lang.String JavaDoc getPrintWhenExpression()
1434    {
1435
1436        return printWhenExpression;
1437    }
1438
1439    /**
1440     * Setter for property printWhenExpression.
1441     *
1442     * @param printWhenExpression New value of property printWhenExpression.
1443     */

1444    public void setPrintWhenExpression(java.lang.String JavaDoc printWhenExpression)
1445    {
1446        this.printWhenExpression = printWhenExpression;
1447    }
1448
1449    /**
1450     * Getter for property isPrintRepeatedValues.
1451     *
1452     * @return Value of property isPrintRepeatedValues.
1453     */

1454    public boolean isIsPrintRepeatedValues()
1455    {
1456
1457        return getBooleanValue(PRINT_REPEATED_VALUES, DEFAULT_PRINT_REPEATED_VALUES );
1458    }
1459
1460    /**
1461     * Setter for property isPrintRepeatedValues.
1462     *
1463     * @param isPrintRepeatedValues New value of property
1464     * isPrintRepeatedValues.
1465     */

1466    public void setIsPrintRepeatedValues(boolean isPrintRepeatedValues)
1467    {
1468        setPropertyValue(PRINT_REPEATED_VALUES, ""+isPrintRepeatedValues );
1469    }
1470
1471    /**
1472     * Getter for property fgcolor.
1473     *
1474     * @return Value of property fgcolor.
1475     */

1476    public java.awt.Color JavaDoc getFgcolor()
1477    {
1478        if (getColorValue(FGCOLOR, null ) == null)
1479        {
1480            // Look for a fgcolor in the stylesheet...
1481
if (getStyle() != null)
1482            {
1483               return getStyle().getAttributeColor( getStyle().ATTRIBUTE_forecolor, DEFAULT_FGCOLOR, true);
1484            }
1485        }
1486        return getColorValue(FGCOLOR, DEFAULT_FGCOLOR );
1487    }
1488
1489    /**
1490     * Setter for property fgcolor.
1491     *
1492     * @param fgcolor New value of property fgcolor.
1493     */

1494    public void setFgcolor(java.awt.Color JavaDoc fgcolor)
1495    {
1496        setPropertyValue(FGCOLOR,fgcolor);
1497    }
1498
1499    /**
1500     * Getter for property bgcolor.
1501     *
1502     * @return Value of property bgcolor.
1503     */

1504    public java.awt.Color JavaDoc getBgcolor()
1505    {
1506
1507        if (getColorValue(BGCOLOR, null ) == null)
1508        {
1509            // Look for a fgcolor in the stylesheet...
1510
if (getStyle() != null)
1511            {
1512               return getStyle().getAttributeColor( getStyle().ATTRIBUTE_backcolor, DEFAULT_BGCOLOR, true);
1513            }
1514        }
1515        return getColorValue(BGCOLOR, DEFAULT_BGCOLOR );
1516    }
1517
1518    /**
1519     * Setter for property bgcolor.
1520     *
1521     * @param bgcolor New value of property bgcolor.
1522     */

1523    public void setBgcolor(java.awt.Color JavaDoc bgcolor)
1524    {
1525        setPropertyValue(BGCOLOR,bgcolor);
1526    }
1527
1528    /**
1529     * Getter for property isRemoveLineWhenBlank.
1530     *
1531     * @return Value of property isRemoveLineWhenBlank.
1532     */

1533    public boolean isIsRemoveLineWhenBlank()
1534    {
1535
1536        return getBooleanValue(REMOVE_LINE_WHEN_BLANK, DEFAULT_REMOVE_LINE_WHEN_BLANK );
1537    }
1538
1539    /**
1540     * Setter for property isRemoveLineWhenBlank.
1541     *
1542     * @param isRemoveLineWhenBlank New value of property
1543     * isRemoveLineWhenBlank.
1544     */

1545    public void setIsRemoveLineWhenBlank(boolean isRemoveLineWhenBlank)
1546    {
1547        setPropertyValue(REMOVE_LINE_WHEN_BLANK, ""+isRemoveLineWhenBlank );
1548    }
1549
1550    /**
1551     * Getter for property printWhenGroupChanges.
1552     *
1553     * @return Value of property printWhenGroupChanges.
1554     */

1555    public java.lang.String JavaDoc getPrintWhenGroupChanges()
1556    {
1557
1558        return printWhenGroupChanges;
1559    }
1560
1561    /**
1562     * Setter for property printWhenGroupChanges.
1563     *
1564     * @param printWhenGroupChanges New value of property
1565     * printWhenGroupChanges.
1566     */

1567    public void setPrintWhenGroupChanges(java.lang.String JavaDoc printWhenGroupChanges)
1568    {
1569        this.printWhenGroupChanges = printWhenGroupChanges;
1570    }
1571
1572    /**
1573     * Getter for property name.
1574     *
1575     * @return Value of property name.
1576     */

1577    public java.lang.String JavaDoc getName()
1578    {
1579
1580        return name;
1581    }
1582
1583    /**
1584     * Setter for property name.
1585     *
1586     * @param name New value of property name.
1587     */

1588    public void setName(java.lang.String JavaDoc name)
1589    {
1590        this.name = name;
1591    }
1592
1593    /**
1594     * Getter for property isPrintWhenDetailOverflows.
1595     *
1596     * @return Value of property isPrintWhenDetailOverflows.
1597     */

1598    public boolean isIsPrintWhenDetailOverflows()
1599    {
1600
1601        return getBooleanValue(PRINT_WHEN_DETAIL_OVERFLOW, DEFAULT_PRINT_WHEN_DETAIL_OVERFLOW );
1602    }
1603
1604    /**
1605     * Setter for property isPrintWhenDetailOverflows.
1606     *
1607     * @param isPrintWhenDetailOverflows New value of property
1608     * isPrintWhenDetailOverflows.
1609     */

1610    public void setIsPrintWhenDetailOverflows(boolean isPrintWhenDetailOverflows)
1611    {
1612        setPropertyValue(PRINT_WHEN_DETAIL_OVERFLOW, ""+isPrintWhenDetailOverflows );
1613    }
1614
1615    /**
1616     * DOCUMENT ME!
1617     *
1618     * @param destination DOCUMENT ME!
1619     * @param source DOCUMENT ME!
1620     */

1621    public void copyBaseReportElement(ReportElement destination,
1622                                      ReportElement source)
1623    {
1624
1625        // Canonical report elements....
1626
destination.setName(new String JavaDoc(source.getName()));
1627
1628        destination.setPropertyValue(FGCOLOR, this.getPropertyValue(FGCOLOR));
1629        destination.setPropertyValue(BGCOLOR, this.getPropertyValue(BGCOLOR));
1630        
1631        destination.setBand(source.getBand());
1632        destination.setCell(source.getCell());
1633        destination.setPositionType(new String JavaDoc(source.getPositionType()));
1634        
1635        destination.setPropertyValue(REMOVE_LINE_WHEN_BLANK, this.getPropertyValue(REMOVE_LINE_WHEN_BLANK));
1636        destination.setPropertyValue(PRINT_REPEATED_VALUES, this.getPropertyValue(PRINT_REPEATED_VALUES) );
1637        destination.setPropertyValue(PRINT_IN_FIRST_WHOLE_BAND, this.getPropertyValue(PRINT_IN_FIRST_WHOLE_BAND));
1638        destination.setPropertyValue(PRINT_WHEN_DETAIL_OVERFLOW, this.getPropertyValue(PRINT_WHEN_DETAIL_OVERFLOW));
1639        destination.setPropertyValue(MODE, this.getPropertyValue(MODE));
1640        destination.setStretchType( source.getStretchType());
1641        
1642        destination.setStyle( this.getStyle() );
1643        
1644        destination.setPrintWhenExpression(new String JavaDoc(source.getPrintWhenExpression()));
1645        destination.setPrintWhenGroupChanges(new String JavaDoc(source.getPrintWhenGroupChanges()));
1646
1647    }
1648
1649    /**
1650     * Getter for property key.
1651     *
1652     * @return Value of property key.
1653     */

1654    public java.lang.String JavaDoc getKey()
1655    {
1656
1657        return name;
1658    }
1659
1660    /**
1661     * Setter for property key.
1662     *
1663     * @param key New value of property key.
1664     */

1665    public void setKey(java.lang.String JavaDoc key)
1666    {
1667        this.name = key;
1668    }
1669
1670    /**
1671     * Getter for property stretchType.
1672     *
1673     * @return Value of property stretchType.
1674     */

1675    public java.lang.String JavaDoc getStretchType()
1676    {
1677
1678        return stretchType;
1679    }
1680
1681    /**
1682     * Setter for property stretchType.
1683     *
1684     * @param stretchType New value of property stretchType.
1685     */

1686    public void setStretchType(java.lang.String JavaDoc stretchType)
1687    {
1688        this.stretchType = stretchType;
1689    }
1690
1691    /**
1692     * Getter for property bounds.
1693     *
1694     * @return Value of property bounds.
1695     */

1696    public java.awt.Rectangle JavaDoc getBounds()
1697    {
1698
1699        return bounds;
1700    }
1701
1702    /**
1703     * Setter for property bounds.
1704     *
1705     * @param bounds New value of property bounds.
1706     */

1707    public void setBounds(java.awt.Rectangle JavaDoc bounds)
1708    {
1709        this.position.x = bounds.x;
1710        this.position.y = bounds.y;
1711        this.width = bounds.width;
1712        this.height = bounds.height;
1713        this.updateBounds();
1714    }
1715
1716    /**
1717     * DOCUMENT ME!
1718     *
1719     * @param groupname DOCUMENT ME!
1720     */

1721    public void addToGroup(String JavaDoc groupname)
1722    {
1723
1724        if (getElementGroup() == null || getElementGroup().equals(""))
1725        {
1726            setElementGroup(getElementGroup() + groupname);
1727        }
1728        else
1729        {
1730            setElementGroup(groupname + "." + getElementGroup());
1731        }
1732    }
1733
1734    /**
1735     * DOCUMENT ME!
1736     *
1737     * @param groupname DOCUMENT ME!
1738     */

1739    public void removeFromGroup(String JavaDoc groupname)
1740    {
1741
1742        if (getElementGroup() == null || getElementGroup().equals(""))
1743        {
1744
1745            return;
1746        }
1747
1748        if (getElementGroup().startsWith(groupname))
1749        {
1750            setElementGroup(getElementGroup().substring(groupname.length()));
1751
1752            if (getElementGroup().startsWith("."))
1753            {
1754                setElementGroup(getElementGroup().substring(1));
1755            }
1756        }
1757    }
1758
1759    /**
1760     * DOCUMENT ME!
1761     */

1762    public void removeFromAllGroups()
1763    {
1764        setElementGroup("");
1765    }
1766
1767    public String JavaDoc getElementGroup() {
1768        return elementGroup;
1769    }
1770
1771    public void setElementGroup(String JavaDoc elementGroup) {
1772        this.elementGroup = elementGroup;
1773    }
1774
1775    public ReportElement getParentElement() {
1776        return parentElement;
1777    }
1778
1779    public void setParentElement(ReportElement parentElement) {
1780        this.parentElement = parentElement;
1781    }
1782
1783    public int getElementID() {
1784        return elementID;
1785    }
1786
1787    public void setElementID(int elementID) {
1788        this.elementID = elementID;
1789    }
1790
1791    public Style getStyle() {
1792        return style;
1793    }
1794
1795    public void setStyle(Style style) {
1796        this.style = style;
1797        if (style != null)
1798        {
1799            //this.setBgcolor( style.getAttributeColor( style.ATTRIBUTE_backcolor,getBgcolor(), true) );
1800
//this.setFgcolor( style.getAttributeColor( style.ATTRIBUTE_forecolor,getFgcolor(), true) );
1801
//this.setTransparent( style.getAttributeString( style.ATTRIBUTE_mode, getTransparent(), true) );
1802
}
1803    }
1804
1805    public CrosstabCell getCell() {
1806        return cell;
1807    }
1808
1809    public void setCell(CrosstabCell cell) {
1810        this.cell = cell;
1811    }
1812
1813    public Point getRelativePosition() {
1814        return relativePosition;
1815    }
1816
1817    public void setRelativePosition(Point relativePosition) {
1818        this.relativePosition = relativePosition;
1819    }
1820
1821}
1822
Popular Tags