KickJava   Java API By Example, From Geeks To Geeks.

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


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  * CrosstabReportElement.java
28  *
29  * Created on 28 febbraio 2003, 22.53
30  *
31  */

32
33 package it.businesslogic.ireport;
34 import it.businesslogic.ireport.chart.Dataset;
35 import it.businesslogic.ireport.crosstab.CrosstabCell;
36 import it.businesslogic.ireport.crosstab.CrosstabColumnGroup;
37 import it.businesslogic.ireport.crosstab.CrosstabGroup;
38 import it.businesslogic.ireport.crosstab.CrosstabRowGroup;
39 import it.businesslogic.ireport.crosstab.Measure;
40 import it.businesslogic.ireport.gui.MainFrame;
41 import it.businesslogic.ireport.gui.event.CrosstabLayoutChangedEvent;
42 import it.businesslogic.ireport.util.*;
43 import java.awt.*;
44 import java.util.*;
45
46 public class CrosstabReportElement extends ReportElement {
47     
48     
49         private Report report = null;
50     
51         private boolean repeatColumnHeaders = true;
52         private boolean repeatRowHeaders = true;
53         private int columnBreakOffset = 10;
54         private Vector crosstabParameters=null;
55         private String JavaDoc parametersMapExpression="";
56         
57         
58         // Crosstab properties...
59
private boolean useDataset = false;
60         private Dataset dataset = null;
61         private boolean preSorted = false;
62         private Vector measures=null;
63         
64         private Vector rowGroups= new Vector();
65         private Vector columnGroups= new Vector();
66         private Vector elements= new Vector();
67         
68         private Vector cells = new Vector();
69         
70         public static Image img=null;
71     
72     public CrosstabReportElement(int x, int y, int width, int height)
73     {
74         super(x, y, width, height);
75             setKey("crosstab");
76                 
77                 dataset = new Dataset();
78                 crosstabParameters = new Vector();
79                 measures = new Vector();
80                 
81                 if (img == null)
82                       img = Misc.loadBufferedImageFromResources(new java.awt.Panel JavaDoc() ,"it/businesslogic/ireport/icons/crosstabTool1.png");
83     }
84         
85         public void drawObject(Graphics2D g,double zoom_factor, int x_shift_origin, int y_shift_origin)
86     {
87            
88                 position.x -= 10;
89         position.y -= 10;
90         x_shift_origin -= 10;
91         y_shift_origin -= 10;
92         
93         this.zoom_factor = zoom_factor;
94                 
95                 Color ccc = new Color(204,204,204,150);
96                 
97                 g.setColor( ccc );
98                 Paint paint=g.getPaint();
99                 g.setPaint( new GradientPaint( getZoomedDim(position.x)-x_shift_origin,
100                             getZoomedDim(position.y)-y_shift_origin,
101                             ccc, getZoomedDim(position.x)-x_shift_origin+getZoomedDim(width),
102                             getZoomedDim(position.x)-x_shift_origin + getZoomedDim(height), ccc.brighter() ) );
103
104                 g.fillRect( getZoomedDim(position.x)-x_shift_origin,
105                 getZoomedDim(position.y)-y_shift_origin,
106                 getZoomedDim(width),
107                 getZoomedDim(height));
108                 g.setPaint(paint);
109                 
110         position.x += 10;
111         position.y += 10;
112         x_shift_origin += 10;
113         y_shift_origin += 10;
114                 
115                 drawGraphicsElement(g,zoom_factor, x_shift_origin,y_shift_origin);
116     }
117         
118     public void drawGraphicsElement(Graphics2D g, double zoom_factor, int x_shift_origin, int y_shift_origin)
119     {
120                 drawGraphicsElement(g,"Thin", zoom_factor, x_shift_origin,y_shift_origin);
121                 int correction = 0; //(zoom_factor <= 1) ? -1 : 0;
122

123         position.x -= 10;
124         position.y -= 10;
125         x_shift_origin -= 10;
126         y_shift_origin -= 10;
127                 
128                 
129                 if (img != null)
130                 {/*
131                     g.drawImage(img,
132                         getZoomedDim(position.x)-x_shift_origin,
133                         getZoomedDim(position.y)-y_shift_origin,
134                         getZoomedDim(width)+correction,getZoomedDim(height)+correction, null);
135                 */

136                     int imageWidth = img.getWidth(null);
137                     int imageHeight = img.getHeight(null);
138                     /*
139             if (imgx instanceof Image)
140             {
141                 ((Image)imgx).setTransparent(true);
142             }
143                      */

144             
145             //
146
if (imageWidth < width && imageHeight< height)
147             {
148                 Rectangle destination = new Rectangle(getZoomedDim(position.x)-x_shift_origin,
149                                                                       getZoomedDim(position.y)-y_shift_origin,getZoomedDim( imageWidth), getZoomedDim( imageHeight-1));
150                 Rectangle source = new Rectangle(0,0,imageWidth,imageHeight);
151                 // Calculate y shift based on hAlign...
152
int elem_height = getZoomedDim(this.height);
153                 elem_height -= getZoomedDim( imageHeight);
154                 // Calculate x shift based on hAlign...
155
int elem_width = getZoomedDim(this.width);
156                 elem_width -= getZoomedDim( imageWidth);
157                 g.drawImage( img,destination.x+1, destination.y+1, destination.x+destination.width+1, destination.y+destination.height+1,
158                                                        source.x,source.y,source.width,source.height,
159                                                        null,null);
160             }
161             else if (width>0 && height>0)// Resize based on minor x/WIDTH... e y/HEIGHT
162
{
163                 if ((double)((double)imageWidth/(double)width)> (double)((double)imageHeight/(double)height))
164                 {
165                     
166                     Rectangle source = new Rectangle(0,0,imageWidth,imageHeight);
167                     Rectangle destination = new Rectangle(getZoomedDim(position.x)-x_shift_origin,
168                                                                       getZoomedDim(position.y)-y_shift_origin,getZoomedDim(width) ,getZoomedDim(Math.min( (imageHeight*width)/imageWidth, height-1)) );
169                     
170                     // Calculate y shift based on hAlign...
171
int elem_height = getZoomedDim(this.height);
172                     elem_height -= getZoomedDim(Math.min( (imageHeight*width)/imageWidth, height));
173                         
174                     g.drawImage( img,destination.x+1, destination.y+1, destination.x+destination.width, destination.y+destination.height,
175                                                         source.x,source.y,source.width,source.height,
176                                                         null,null);
177                     }
178                     else
179                     {
180                         Rectangle source = new Rectangle(0,0,imageWidth,imageHeight);
181                         Rectangle destination = new Rectangle(getZoomedDim(position.x)-x_shift_origin,
182                                                                       getZoomedDim(position.y)-y_shift_origin, getZoomedDim( Math.min( (imageWidth*height)/imageHeight, width)) ,getZoomedDim( height-1) );
183                         
184                         // Calculate x shift based on hAlign...
185
int elem_width = getZoomedDim(this.width);
186                         elem_width -= getZoomedDim( Math.min( (imageWidth*height)/imageHeight, width));
187                     
188                         g.drawImage( img,destination.x+1, destination.y+1, destination.x+destination.width, destination.y+destination.height,
189                                                         source.x,source.y,source.width,source.height,
190                                                         null,null);
191                     }
192                                 }
193                         }
194                 position.x += 10;
195         position.y += 10;
196         }
197         
198     
199         
200         
201         public ReportElement cloneMe()
202     {
203     CrosstabReportElement newReportElement = new CrosstabReportElement(position.x, position.y, width, height);
204     copyBaseReportElement(newReportElement, this);
205     return newReportElement;
206     }
207         
208     public void copyBaseReportElement(ReportElement destination, ReportElement source)
209         {
210                 super.copyBaseReportElement(destination, source);
211                 
212                 if (destination instanceof CrosstabReportElement &&
213                     source instanceof CrosstabReportElement )
214                 {
215                     
216                     /*
217                     ((SubReportElement)destination).setIsUsingCache( ((SubReportElement)source).isIsUsingCache());
218                     ((SubReportElement)destination).setParametersMapExpression( new String( ((SubReportElement)source).getParametersMapExpression() ));
219                     ((SubReportElement)destination).setSubreportExpression ( new String( ((SubReportElement)source).getSubreportExpression() ));
220                     ((SubReportElement)destination).setSubreportExpressionClass( new String( ((SubReportElement)source).getSubreportExpressionClass() ));
221                     ((SubReportElement)destination).setUseConnection( ((SubReportElement)source).isUseConnection() );
222                     if ( ((SubReportElement)destination).isUseConnection())
223                         ((SubReportElement)destination).setConnectionExpression( new String( ((SubReportElement)source).getConnectionExpression() ));
224                     else
225                         ((SubReportElement)destination).setDataSourceExpression( new String( ((SubReportElement)source).getDataSourceExpression() ));
226                     
227                     Enumeration e = ((SubReportElement)source).getSubreportParameters().elements();
228                     while (e.hasMoreElements())
229                     {
230             JRSubreportParameter jp = (JRSubreportParameter)e.nextElement();
231             ((SubReportElement)destination).getSubreportParameters().addElement(jp.cloneMe());
232                     }
233                      */

234                 }
235         }
236
237     public boolean isRepeatColumnHeaders() {
238         return repeatColumnHeaders;
239     }
240
241     public void setRepeatColumnHeaders(boolean repeatColumnHeaders) {
242         if (this.repeatColumnHeaders == repeatColumnHeaders) return;
243         this.columnBreakOffset = columnBreakOffset;
244         notifyChange();
245     }
246
247     public boolean isRepeatRowHeaders() {
248         return repeatRowHeaders;
249     }
250
251     public int getColumnBreakOffset() {
252         return columnBreakOffset;
253     }
254
255     public Vector getCrosstabParameters() {
256         return crosstabParameters;
257     }
258
259     public String JavaDoc getParametersMapExpression() {
260         return parametersMapExpression;
261     }
262
263     public void setParametersMapExpression(String JavaDoc parametersMapExpression) {
264
265         if ((this.parametersMapExpression == null) ? parametersMapExpression == null : this.parametersMapExpression.equals(parametersMapExpression)) return;
266         this.parametersMapExpression = parametersMapExpression;
267         notifyChange();
268     }
269
270     public void setColumnBreakOffset(int columnBreakOffset) {
271         if (this.columnBreakOffset == columnBreakOffset) return;
272         this.columnBreakOffset = columnBreakOffset;
273         notifyChange();
274     }
275
276     public void setRepeatRowHeaders(boolean repeatRowHeaders) {
277         if (this.repeatRowHeaders == repeatRowHeaders) return;
278         this.repeatRowHeaders = repeatRowHeaders;
279         notifyChange();
280     }
281
282     public Dataset getDataset() {
283         return dataset;
284     }
285
286     public void setDataset(Dataset dataset) {
287         if (this.dataset == dataset) return;
288         this.dataset = dataset;
289         notifyChange();
290     }
291
292     public boolean isUseDataset() {
293         return useDataset;
294     }
295
296     public void setUseDataset(boolean useDataset) {
297         if (this.useDataset == useDataset) return;
298         this.useDataset = useDataset;
299         notifyChange();
300     }
301
302     public boolean isPreSorted() {
303         return preSorted;
304     }
305
306     public void setPreSorted(boolean preSorted) {
307         if (this.preSorted == preSorted) return;
308         this.preSorted = preSorted;
309         notifyChange();
310
311     }
312
313     public Vector getMeasures() {
314         return measures;
315     }
316
317     public void setMeasures(Vector measures) {
318         this.measures = measures;
319     }
320
321     public Vector getRowGroups() {
322         return rowGroups;
323     }
324
325     public void setRowGroups(Vector rowGroups) {
326         this.rowGroups = rowGroups;
327     }
328
329     public Vector getColumnGroups() {
330         return columnGroups;
331     }
332
333     public void setColumnGroups(Vector columnGroups) {
334         this.columnGroups = columnGroups;
335     }
336
337     public Vector getElements() {
338         return elements;
339     }
340
341     public void setElements(Vector elements) {
342         this.elements = elements;
343     }
344
345     public Vector getCells() {
346         return cells;
347     }
348
349     public void setCells(Vector cells) {
350         this.cells = cells;
351     }
352
353     /**
354      * Utility field used by event firing mechanism.
355      */

356     private javax.swing.event.EventListenerList JavaDoc listenerList = null;
357
358     /**
359      * Registers CrosstabLayoutChangedListener to receive events.
360      * @param listener The listener to register.
361      */

362     public synchronized void addCrosstabLayoutChangedListener(it.businesslogic.ireport.gui.event.CrosstabLayoutChangedListener listener) {
363
364         if (listenerList == null ) {
365             listenerList = new javax.swing.event.EventListenerList JavaDoc();
366         }
367         listenerList.add (it.businesslogic.ireport.gui.event.CrosstabLayoutChangedListener.class, listener);
368     }
369
370     /**
371      * Removes CrosstabLayoutChangedListener from the list of listeners.
372      * @param listener The listener to remove.
373      */

374     public synchronized void removeCrosstabLayoutChangedListener(it.businesslogic.ireport.gui.event.CrosstabLayoutChangedListener listener) {
375
376         listenerList.remove (it.businesslogic.ireport.gui.event.CrosstabLayoutChangedListener.class, listener);
377     }
378
379     /**
380      * Notifies all registered listeners about the event.
381      *
382      * @param event The event to be fired
383      */

384     public void fireCrosstabLayoutChangedListenerCrosstabLayoutChanged(it.businesslogic.ireport.gui.event.CrosstabLayoutChangedEvent event) {
385
386         if (listenerList == null) return;
387         Object JavaDoc[] listeners = listenerList.getListenerList ();
388         for (int i = listeners.length - 2; i >= 0; i -= 2) {
389             if (listeners[i]==it.businesslogic.ireport.gui.event.CrosstabLayoutChangedListener.class) {
390                 ((it.businesslogic.ireport.gui.event.CrosstabLayoutChangedListener)listeners[i+1]).crosstabLayoutChanged (event);
391             }
392         }
393     }
394     
395     /**
396      * Notifies all registered listeners about the event.
397      *
398      * @param event The event to be fired
399      */

400     public void fireCrosstabMeasureChangedListenerCrosstabLayoutChanged(it.businesslogic.ireport.gui.event.CrosstabLayoutChangedEvent event) {
401
402         if (listenerList == null) return;
403         Object JavaDoc[] listeners = listenerList.getListenerList ();
404         for (int i = listeners.length - 2; i >= 0; i -= 2) {
405             if (listeners[i]==it.businesslogic.ireport.gui.event.CrosstabLayoutChangedListener.class) {
406                 ((it.businesslogic.ireport.gui.event.CrosstabLayoutChangedListener)listeners[i+1]).crosstabMeasureChanged(event);
407             }
408         }
409     }
410     
411     /**
412      * Add safetly a groups from a CrosstabRowGroup and fires a CrosstabLayoutChangedEvent.
413      */

414     public void addGroup(CrosstabRowGroup group)
415     {
416         CrosstabCell headerCell = new CrosstabCell();
417         headerCell.setName(group.getName()+" header");
418         headerCell.setType(CrosstabCell.HEADER_CELL);
419         headerCell.setWidth( group.getWidth() );
420         //if (!group.isHasHeader()) headerCell.setHeight(0);
421
group.setHeaderCell(headerCell);
422         
423         CrosstabCell totalHeaderCell = new CrosstabCell();
424         totalHeaderCell.setName(group.getName()+" total header");
425         totalHeaderCell.setType(CrosstabCell.HEADER_CELL);
426         totalHeaderCell.setWidth( group.getWidth() );
427         if (group.getTotalPosition().equals("None"))
428         {
429             totalHeaderCell.setHeight(0);
430         }
431         else
432         {
433             totalHeaderCell.setHeight(30);
434         }
435         group.setTotalCell(totalHeaderCell);
436         
437         //intln("set total height to " +totalHeaderCell.getHeight() + " position total: '" + group.getTotalPosition()+"'");
438

439         this.getCells().add( group.getHeaderCell());
440         this.getCells().add( group.getTotalCell());
441         
442         // We have to add a default cell... Detail / Column...
443
CrosstabCell cell = new CrosstabCell();
444         cell.setType( cell.DETAIL_CELL);
445         cell.setParent( this );
446         cell.setName(null);
447         cell.setRowTotalGroup(group.getName());
448         if (group.getTotalPosition().equals("None")) cell.setHeight(0);
449         else cell.setHeight(30);
450         
451         this.getCells().add(cell);
452         
453         this.getRowGroups().add(group);
454         
455         fireCrosstabLayoutChangedListenerCrosstabLayoutChanged(new CrosstabLayoutChangedEvent(this, this));
456         notifyChange();
457     }
458     
459     /**
460      * Add safetly a groups from a CrosstabColumnGroup and fires a CrosstabLayoutChangedEvent.
461      */

462     public void addGroup(CrosstabColumnGroup group)
463     {
464         CrosstabCell headerCell = new CrosstabCell();
465         headerCell.setName(group.getName()+" header");
466         headerCell.setType(CrosstabCell.HEADER_CELL);
467         headerCell.setParent( this );
468         headerCell.setHeight( group.getHeight());
469         group.setHeaderCell(headerCell);
470         
471         CrosstabCell totalHeaderCell = new CrosstabCell();
472         totalHeaderCell.setName(group.getName()+" total header");
473         totalHeaderCell.setType(CrosstabCell.HEADER_CELL);
474         totalHeaderCell.setParent( this );
475         totalHeaderCell.setHeight( group.getHeight() );
476         if (group.getTotalPosition().equals("None")) totalHeaderCell.setWidth(0);
477         else totalHeaderCell.setWidth(30);
478         group.setTotalCell(totalHeaderCell);
479         
480         this.getCells().add( group.getHeaderCell());
481         this.getCells().add( group.getTotalCell());
482         
483         // We have to add a default cell... Detail / Column...
484
CrosstabCell cell = new CrosstabCell();
485         cell.setType( cell.DETAIL_CELL);
486         cell.setParent( this );
487         cell.setColumnTotalGroup(group.getName());
488         if (group.getTotalPosition().equals("None")) cell.setWidth(0);
489         else cell.setWidth(30);
490         this.getCells().add(cell);
491         
492         this.getColumnGroups().add(group);
493         
494         fireCrosstabLayoutChangedListenerCrosstabLayoutChanged(new CrosstabLayoutChangedEvent(this, this));
495         notifyChange();
496     }
497        
498     /**
499      * Remove safetly a set of groups from a Crosstab and fires a CrosstabLayoutChangedEvent.
500      */

501     public void removeGroups(Collection groups)
502     {
503         Iterator i_groups = groups.iterator();
504         while (i_groups.hasNext())
505         {
506             CrosstabGroup group = (CrosstabGroup)i_groups.next();
507             
508             removeCell(group.getHeaderCell());
509             removeCell( group.getTotalCell() );
510             
511             for (int i = 0; i < getCells().size(); ++i)
512             {
513                 CrosstabCell cell = (CrosstabCell)getCells().elementAt(i);
514                 if (cell.getColumnTotalGroup().equals(group.getName()) ||
515                     cell.getRowTotalGroup().equals( group.getName()))
516                 {
517                     i -= removeCell(cell) ? 1 : 0;
518                 }
519             }
520             
521             if (group instanceof CrosstabRowGroup) this.getRowGroups().remove(group);
522             if (group instanceof CrosstabColumnGroup) this.getColumnGroups().remove(group);
523         }
524         fireCrosstabLayoutChangedListenerCrosstabLayoutChanged(new CrosstabLayoutChangedEvent(this, this));
525         notifyChange();
526     }
527     
528     /**
529      * Remove safetly a group from a Crosstab and fires a CrosstabLayoutChangedEvent.
530      */

531     public void removeGroup(CrosstabGroup group)
532     {
533         if (group == null) return;
534         ArrayList v = new ArrayList();
535         v.add(group);
536         removeGroups(v);
537         notifyChange();
538     }
539     
540     public void addMeasure(Measure measure)
541     {
542         getMeasures().addElement( measure );
543         fireCrosstabMeasureChangedListenerCrosstabLayoutChanged(new CrosstabLayoutChangedEvent(this, this));
544         notifyChange();
545     }
546     
547     public void measureModified(Measure measure)
548     {
549         fireCrosstabMeasureChangedListenerCrosstabLayoutChanged(new CrosstabLayoutChangedEvent(this, this));
550         notifyChange();
551     }
552     
553     public void removeMeasure(Measure measure)
554     {
555         getMeasures().removeElement( measure );
556         fireCrosstabMeasureChangedListenerCrosstabLayoutChanged(new CrosstabLayoutChangedEvent(this, this));
557         notifyChange();
558     }
559     
560     
561     public void modifyGroup(String JavaDoc oldGroupName, CrosstabRowGroup group)
562     {
563         
564         group.getHeaderCell().setWidth(group.getWidth());
565         group.getTotalCell().setWidth(group.getWidth());
566         
567         if (!group.isHasHeader())
568         {
569             for (int i=0; i <getElements().size(); ++i)
570             {
571                 ReportElement re = (ReportElement)getElements().elementAt(i);
572                 if (re.getCell() == group.getHeaderCell())
573                 {
574                     i -= getElements().remove(re) ? 1 : 0;
575                 }
576                 group.getHeaderCell().setBox(new Box());
577                 group.getHeaderCell().setBackcolor(null);
578             }
579         }
580         
581         
582         if (!group.isHasTotal())
583         {
584             group.getTotalCell().setHeight(0);
585         }
586         else if (group.getTotalCell().getHeight() == 0)
587         {
588             group.getTotalCell().setHeight(30);
589         }
590         
591         // 1. Rename all cells...
592
Iterator i = getCells().iterator();
593         while (i.hasNext())
594         {
595             CrosstabCell cell = (CrosstabCell)i.next();
596             if (cell.getRowTotalGroup().equals( oldGroupName))
597             {
598                 cell.setRowTotalGroup(group.getName());
599                 if (!group.isHasTotal())
600                 {
601                     cell.setHeight(0);
602                     // Remove all cell elements..
603
for (int t=0; t <getElements().size(); ++t)
604                     {
605                         ReportElement re = (ReportElement)getElements().elementAt(t);
606                         if (re.getCell() == cell)
607                         {
608                             t -= getElements().remove(re) ? 1 : 0;
609                         }
610                     }
611                 }
612                 else if (cell.getHeight() == 0)
613                 {
614                     cell.setHeight(30);
615                 }
616             }
617         }
618         
619         fireCrosstabLayoutChangedListenerCrosstabLayoutChanged(new CrosstabLayoutChangedEvent(this, this));
620         notifyChange();
621     }
622     
623     public void modifyGroup(String JavaDoc oldGroupName, CrosstabColumnGroup group)
624     {
625         
626         group.getHeaderCell().setHeight(group.getHeight());
627         group.getTotalCell().setHeight(group.getHeight());
628         
629         if (!group.isHasHeader())
630         {
631             for (int i=0; i <getElements().size(); ++i)
632             {
633                 ReportElement re = (ReportElement)getElements().elementAt(i);
634                 if (re.getCell() == group.getHeaderCell())
635                 {
636                     i -= getElements().remove(re) ? 1 : 0;
637                 }
638                 group.getHeaderCell().setBox(new Box());
639                 group.getHeaderCell().setBackcolor(null);
640             }
641         }
642         
643         
644         if (!group.isHasTotal())
645         {
646             group.getTotalCell().setWidth(0);
647         }
648         else if (group.getTotalCell().getWidth() == 0)
649         {
650             group.getTotalCell().setWidth(30);
651         }
652         
653         // 1. Rename all cells...
654
Iterator i = getCells().iterator();
655         while (i.hasNext())
656         {
657             CrosstabCell cell = (CrosstabCell)i.next();
658             if (cell.getColumnTotalGroup().equals( oldGroupName))
659             {
660                 cell.setColumnTotalGroup(group.getName());
661                 if (!group.isHasTotal())
662                 {
663                     cell.setWidth(0);
664                     // Remove all cell elements..
665
for (int t=0; t <getElements().size(); ++t)
666                     {
667                         ReportElement re = (ReportElement)getElements().elementAt(t);
668                         if (re.getCell() == cell)
669                         {
670                             t -= getElements().remove(re) ? 1 : 0;
671                         }
672                     }
673                 }
674                 else if (cell.getWidth() == 0)
675                 {
676                     cell.setWidth(30);
677                 }
678             }
679         }
680         
681         fireCrosstabLayoutChangedListenerCrosstabLayoutChanged(new CrosstabLayoutChangedEvent(this, this));
682         notifyChange();
683     }
684     
685     
686     /**
687      * This method remove the cell and all contained elements
688      */

689     private boolean removeCell(CrosstabCell cell)
690     {
691         for (int i=0; i <getElements().size(); ++i)
692         {
693             ReportElement re = (ReportElement)getElements().elementAt(i);
694             if (re.getCell() == cell)
695             {
696                 i -= getElements().remove(re) ? 1 : 0;
697             }
698         }
699         notifyChange();
700         return getCells().remove(cell);
701     }
702     
703     public Point trasform(Point delta, int type)
704     {
705         Point point = super.trasform(delta, type);
706         
707         try {
708             
709             if (MainFrame.getMainInstance().getActiveReportFrame() != null)
710             {
711                 MainFrame.getMainInstance().getActiveReportFrame().getCrosstabEditor(this).getPanelEditor().updateGrid();
712             }
713          } catch (Exception JavaDoc ex)
714          {
715          }
716         
717         return point;
718     }
719
720     public Report getReport() {
721         return report;
722     }
723
724     public void setReport(Report report) {
725         this.report = report;
726     }
727     
728     public void notifyChange()
729     {
730         if (getReport() != null)
731         {
732             getReport().incrementReportChanges();
733         }
734     }
735     
736     
737 }
738
Popular Tags