KickJava   Java API By Example, From Geeks To Geeks.

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


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

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.io.File JavaDoc;
40 import java.net.MalformedURLException JavaDoc;
41 import java.net.URL JavaDoc;
42
43 import net.sf.jasperreports.engine.JRException;
44 import net.sf.jasperreports.engine.util.JRImageLoader;
45
46 public class ImageReportElement extends GraphicReportElement implements ImageObserver, HyperLinkableReportElement, BoxElement
47 {
48       
49     static public final String JavaDoc SCALE = "SCALE";
50     static public final String JavaDoc VERTICAL_ALIGN = "VERTICAL_ALIGN";
51     static public final String JavaDoc HORIZONTAL_ALIGN = "HORIZONTAL_ALIGN";
52     static public final String JavaDoc USING_CACHE = "USING_CACHE";
53     
54     static public final String JavaDoc DEFAULT_SCALE = "FillFrame";
55     static public final String JavaDoc DEFAULT_VERTICAL_ALIGN = "Top";
56     static public final String JavaDoc DEFAULT_HORIZONTAL_ALIGN = "Left";
57     static public final boolean DEFAULT_USING_CACHE = false;
58     
59     private java.util.List JavaDoc linkParameters = new java.util.ArrayList JavaDoc();
60     
61     private Image img=null;
62     static private Image defimg=null;
63     private String JavaDoc imageExpression;
64     private String JavaDoc imageClass;
65     //private String scaleImage;
66
private String JavaDoc hyperlinkType="None";
67     private String JavaDoc evaluationTime="Now";
68     private String JavaDoc evaluationGroup="";
69     
70     //private String verticalAlignment="Top";
71
//private String horizontalAlignment="Left";
72

73     private String JavaDoc anchorNameExpression="";
74     private String JavaDoc hyperlinkReferenceExpression="";
75     private String JavaDoc hyperlinkAnchorExpression="";
76     private String JavaDoc hyperlinkPageExpression="";
77         
78         private String JavaDoc onErrorType = "Error";
79         
80         private int bookmarkLevel = 0;
81         
82     //private boolean isUsingCache;
83
private boolean isLazy=false;
84     private File JavaDoc reportDirectory = null;
85     private boolean triedToLoadImg = false;
86     
87     private Box box = null;
88     
89     public ImageReportElement(int x, int y, int width, int height)
90     {
91         super(x,y, Math.abs(width), Math.abs(height));
92                 //setGraphicElementPen("Thin");
93
//this.bgcolor = Color.WHITE;
94
//this.fgcolor = Color.BLACK;
95
setKey("image");
96                 
97                 if (defimg == null)
98                 {
99                     // Load default image...
100
defimg = Misc.loadImageFromResources("it/businesslogic/ireport/icons/layout/img.gif");
101                 }
102                 
103                 img = null;
104         //isUsingCache=false;
105
imageExpression="";
106         imageClass="java.lang.String";
107         //scaleImage="FillFrame";
108
//graphicElementPen = "None";
109
this.hyperlinkType = "None";
110                 this.anchorNameExpression = "";
111                 box = new Box();
112     }
113         
114
115     
116         /*
117     public void drawObject(Graphics2D g,double zoom_factor, int x_shift_origin, int y_shift_origin)
118     {
119                 position.x -= 10;
120         position.y -= 10;
121         x_shift_origin -= 10;
122         y_shift_origin -= 10;
123         
124         this.zoom_factor = zoom_factor;
125                 
126                 g.setColor( bgcolor );
127                 if (!getTransparent().equalsIgnoreCase("Transparent"))
128                     g.fillRect( getZoomedDim(position.x)-x_shift_origin,
129                 getZoomedDim(position.y)-y_shift_origin,
130                 getZoomedDim(width),
131                 getZoomedDim(height));
132                 g.setColor( this.fgcolor );
133                               
134         position.x += 10;
135         position.y += 10;
136         x_shift_origin += 10;
137         y_shift_origin += 10;
138                 
139                 drawGraphicsElement(g,this.getGraphicElementPen(), zoom_factor, x_shift_origin,y_shift_origin, 0);
140     }*/

141         
142         public void drawObject(Graphics2D g, double zoom_factor, int x_shift_origin, int y_shift_origin)
143     {
144                 
145                 position.x += -10 + box.getLeftPadding();
146         position.y += -10 + box.getTopPadding();
147                 width = width - box.getLeftPadding() - box.getRightPadding();
148                 height = height - box.getTopPadding() - box.getBottomPadding();
149
150         x_shift_origin -= 10;
151         y_shift_origin -= 10;
152                 
153         this.zoom_factor = zoom_factor;
154         Image imgx = img;
155                 
156         if (imgx==null)
157         {
158                     // Try to load the image from imageExpression...
159

160             String JavaDoc fname = imageExpression;
161             
162             if(!triedToLoadImg && imageClass.equals("java.lang.String") && fname.length()>3 && fname.charAt(0)=='\"' &&
163             fname.charAt(fname.length()-1 ) == '\"'){
164                 
165                 // Could be a file...
166
fname = Misc.string_replace("\\","\\\\",fname);
167                 fname = Misc.string_replace("","\"",fname);
168                 
169                 //first try read image from file
170
File JavaDoc file = new File JavaDoc(fname);
171                 if(!file.isAbsolute() && reportDirectory != null){
172                     file = new File JavaDoc(reportDirectory, fname);
173                 }
174                 if(file.exists()){
175                     img = Misc.loadImageFromFile(file.getAbsolutePath());
176                 }else{
177                     
178                     try{
179                                                 
180                         img = JRImageLoader.loadImage(JRImageLoader.loadImageDataFromURL( MainFrame.getMainInstance().getReportClassLoader().getResource( fname )));
181                     }catch(Exception JavaDoc jrex){
182                                         }
183                                 }
184             
185                 imgx = img;
186                 triedToLoadImg = true;//try only once
187
}
188                         
189             if (imgx==null)
190                  imgx=defimg;
191         }
192
193                 g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
194                 g.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
195                 
196         if (imgx != null)
197         {
198                     int imageWidth = imgx.getWidth(this);
199                     int imageHeight = imgx.getHeight(this);
200                     /*
201             if (imgx instanceof Image)
202             {
203                 ((Image)imgx).setTransparent(true);
204             }
205                      */

206             
207             //
208

209                     Java2DUtil.setClip(g,getZoomedDim(position.x) - x_shift_origin,
210                                getZoomedDim(position.y) - y_shift_origin,
211                                 getZoomedDim(width), getZoomedDim(height));
212
213                     
214             if (getScaleImage().equalsIgnoreCase("RetainShape"))
215             {
216                 if (imageWidth <= width && imageHeight<= height)
217                 {
218                     Rectangle destination = new Rectangle(-x_shift_origin+ getZoomedDim( position.x) ,-y_shift_origin+getZoomedDim(position.y), getZoomedDim( imageWidth), getZoomedDim( imageHeight));
219                     Rectangle source = new Rectangle(0,0,imageWidth,imageHeight);
220                     // Calculate y shift based on hAlign...
221
int elem_height = getZoomedDim(this.height);
222                     elem_height -= getZoomedDim( imageHeight);
223                     if (getVerticalAlignment().equals("Middle")) destination.y += elem_height/2;
224                     else if (getVerticalAlignment().equals("Bottom")) destination.y += elem_height;
225                     
226                     // Calculate x shift based on hAlign...
227
int elem_width = getZoomedDim(this.width);
228                     elem_width -= getZoomedDim( imageWidth);
229                     if (getHorizontalAlignment().equals("Center")) destination.x += elem_width/2;
230                     else if (getHorizontalAlignment().equals("Right")) destination.x += elem_width;
231                     
232                                         
233                     g.drawImage( imgx,destination.x, destination.y, destination.x+destination.width, destination.y+destination.height,
234                                                         source.x,source.y,source.width,source.height,
235                                                         null,this);
236                                         
237                 }
238                 else if (width>0 && height>0)// Resize based on minor x/WIDTH... e y/HEIGHT
239
{
240                     if ((double)((double)imageWidth/(double)width)> (double)((double)imageHeight/(double)height))
241                     {
242                         
243                         Rectangle source = new Rectangle(0,0,imageWidth,imageHeight);
244                         Rectangle destination = new Rectangle(-x_shift_origin+ getZoomedDim( position.x) ,-y_shift_origin+getZoomedDim(position.y),getZoomedDim(width) ,getZoomedDim(Math.min( (imageHeight*width)/imageWidth, height)) );
245                         
246                         // Calculate y shift based on hAlign...
247
int elem_height = getZoomedDim(this.height);
248                         elem_height -= getZoomedDim(Math.min( (imageHeight*width)/imageWidth, height));
249                         if (getVerticalAlignment().equals("Middle")) destination.y += elem_height/2;
250                         else if (getVerticalAlignment().equals("Bottom")) destination.y += elem_height;
251                         
252                                                
253                         g.drawImage( imgx,destination.x, destination.y, destination.x+destination.width, destination.y+destination.height,
254                                                         source.x,source.y,source.width,source.height,
255                                                         null,this);
256                                                 
257                                         }
258                     else
259                     {
260                         Rectangle source = new Rectangle(0,0,imageWidth,imageHeight);
261                         Rectangle destination = new Rectangle(-x_shift_origin+ getZoomedDim( position.x) ,-y_shift_origin+getZoomedDim(position.y), getZoomedDim( Math.min( (imageWidth*height)/imageHeight, width)) ,getZoomedDim( height) );
262                         
263                         // Calculate x shift based on hAlign...
264
int elem_width = getZoomedDim(this.width);
265                         elem_width -= getZoomedDim( Math.min( (imageWidth*height)/imageHeight, width));
266                         if (getHorizontalAlignment().equals("Center")) destination.x += elem_width/2;
267                         else if (getHorizontalAlignment().equals("Right")) destination.x += elem_width;
268                             
269                         
270                         g.drawImage( imgx,destination.x, destination.y, destination.x+destination.width, destination.y+destination.height,
271                                                         source.x,source.y,source.width,source.height,
272                                                         null,this);
273                                                  
274                     }
275                 }
276                 
277             }
278             else if (getScaleImage().equalsIgnoreCase("FillFrame"))
279             {
280                             
281                 g.drawImage(imgx, getZoomedDim(position.x)-x_shift_origin,
282                                             getZoomedDim(position.y)-y_shift_origin,
283                                             getZoomedDim(position.x+width)-x_shift_origin,
284                                             getZoomedDim(position.y+height)-y_shift_origin,
285                                             0,0,imageWidth,imageHeight,null,this);
286
287                                 //-x_shift_origin+ getZoomedDim( position.x-10)+10 ,-y_shift_origin+getZoomedDim(position.y)+10, getZoomedDim( this.width), getZoomedDim( this.height),
288

289                                 
290             }
291             else
292             {
293                 Rectangle destination = new Rectangle(-x_shift_origin+ getZoomedDim( position.x) ,-y_shift_origin+getZoomedDim(position.y),getZoomedDim( Math.min(imageWidth, width)),getZoomedDim( Math.min(imageHeight, height)));
294                 Rectangle source = new Rectangle(0,0,Math.min( imageWidth, width) ,Math.min(imageHeight, height));
295
296                 // Calculate y shift based on hAlign...
297
int elem_height = getZoomedDim( height);
298                 elem_height -= getZoomedDim( imageHeight );
299                 if (getVerticalAlignment().equals("Middle")) {
300                     destination.y += elem_height/2;
301                     if (destination.y<--y_shift_origin+getZoomedDim(position.y)+10 )
302                     {
303                         source.y += -y_shift_origin+getZoomedDim(position.y)+10-destination.y;
304                         destination.y = -y_shift_origin+getZoomedDim(position.y)+10;
305                     }
306                 }
307                 else if (getVerticalAlignment().equals("Bottom")) {
308                     destination.y += elem_height;
309                     if (destination.y<-y_shift_origin+getZoomedDim(position.y)+10 )
310                     {
311                         source.y += -y_shift_origin+getZoomedDim(position.y)+10-destination.y;
312                         destination.y = -y_shift_origin+getZoomedDim(position.y)+10;
313                     }
314                 }
315                 
316                 // Calculate x shift based on hAlign...
317
int elem_width = getZoomedDim( width);
318                 elem_width -= getZoomedDim( imageWidth );
319                 if (getHorizontalAlignment().equals("Center")) {
320                     destination.x += elem_width/2;
321                     if (destination.x<-x_shift_origin+ getZoomedDim( position.x-10)+10 )
322                     {
323                         source.x += -x_shift_origin+ getZoomedDim( position.x-10)+10-destination.x;
324                         destination.x = -x_shift_origin+ getZoomedDim( position.x-10)+10;
325                     }
326                 }
327                 else if (getHorizontalAlignment().equals("Right")) {
328                     destination.x += elem_width;
329                     if (destination.x<-x_shift_origin+ getZoomedDim( position.x-10)+10 )
330                     {
331                         source.x += -x_shift_origin+ getZoomedDim( position.x-10)+10-destination.x;
332                         destination.x = -x_shift_origin+ getZoomedDim( position.x-10)+10;
333                     }
334                 }
335                     
336                 g.drawImage( imgx,destination.x, destination.y, destination.x+destination.width, destination.y+destination.height,
337                                                         source.x,source.y,source.width,source.height,
338                                                         null,this);
339             }
340                     
341                         Java2DUtil.resetClip(g);
342         }
343                 
344                 
345                 if (it.businesslogic.ireport.gui.MainFrame.getMainInstance().getProperties().getProperty("Antialias","true").equals("false"))
346                 {
347                     g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
348                     g.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
349                 }
350                 //position.x += 10;
351
//position.y += 10;
352

353                 position.x += 10 - box.getLeftPadding();
354         position.y += 10 - box.getTopPadding();
355                 width = width + box.getLeftPadding() + box.getRightPadding();
356                 height = height + box.getTopPadding() + box.getBottomPadding();
357
358                 
359         x_shift_origin += 10;
360         y_shift_origin += 10;
361                 
362                 super.drawBorder((Graphics2D)g, zoom_factor, x_shift_origin,y_shift_origin);
363         drawGraphicsElement((Graphics2D)g,this.getGraphicElementPen(), zoom_factor, x_shift_origin,y_shift_origin);
364                 drawBorder( g, zoom_factor, x_shift_origin,y_shift_origin,getBox());
365     }
366     
367         
368     public ReportElement cloneMe()
369     {
370     ImageReportElement newReportElement = new ImageReportElement(position.x, position.y, width, height);
371     copyBaseReportElement(newReportElement, this);
372     return newReportElement;
373     }
374         
375     public void copyBaseReportElement(ReportElement destination, ReportElement source)
376         {
377                 super.copyBaseReportElement(destination, source);
378                 
379                 if (destination instanceof ImageReportElement &&
380                     source instanceof ImageReportElement )
381                 {
382                     destination.setPropertyValue(SCALE, source.getPropertyValue(SCALE));
383                     destination.setPropertyValue(VERTICAL_ALIGN, source.getPropertyValue(VERTICAL_ALIGN));
384                     destination.setPropertyValue(HORIZONTAL_ALIGN, source.getPropertyValue(HORIZONTAL_ALIGN));
385                     destination.setPropertyValue(USING_CACHE, source.getPropertyValue(USING_CACHE));
386
387                     ((ImageReportElement)destination).setEvaluationGroup( new String JavaDoc( ((ImageReportElement)source).getEvaluationGroup() ));
388                     ((ImageReportElement)destination).setEvaluationTime( new String JavaDoc( ((ImageReportElement)source).getEvaluationTime() ));
389                     //((ImageReportElement)destination).setHorizontalAlignment( new String( ((ImageReportElement)source).getHorizontalAlignment() ));
390
((ImageReportElement)destination).setImageClass( new String JavaDoc( ((ImageReportElement)source).getImageClass() ));
391                     ((ImageReportElement)destination).setImageExpression( new String JavaDoc( ((ImageReportElement)source).getImageExpression() ));
392                     //((ImageReportElement)destination).setIsUsingCache( ((ImageReportElement)source).isIsUsingCache());
393
//((ImageReportElement)destination).setScaleImage( new String( ((ImageReportElement)source).getScaleImage() ));
394
//((ImageReportElement)destination).setVerticalAlignment( new String( ((ImageReportElement)source).getVerticalAlignment() ));
395
((ImageReportElement)destination).setReportDirectory( ((ImageReportElement)source).getReportDirectory() );
396
397                     ((HyperLinkableReportElement)destination).setAnchorNameExpression(new String JavaDoc( ((HyperLinkableReportElement)source).getAnchorNameExpression() ));
398                     ((HyperLinkableReportElement)destination).setHyperlinkAnchorExpression(new String JavaDoc( ((HyperLinkableReportElement)source).getHyperlinkAnchorExpression() ));
399                     ((HyperLinkableReportElement)destination).setHyperlinkPageExpression(new String JavaDoc( ((HyperLinkableReportElement)source).getHyperlinkPageExpression() ));
400                     ((HyperLinkableReportElement)destination).setHyperlinkReferenceExpression(new String JavaDoc( ((HyperLinkableReportElement)source).getHyperlinkReferenceExpression() ));
401                     ((HyperLinkableReportElement)destination).setHyperlinkType(new String JavaDoc( ((HyperLinkableReportElement)source).getHyperlinkType() ));
402                 }
403         }
404     
405     public void drawGraphicsElement(Graphics2D g, String JavaDoc pen, double zoom_factor, int x_shift_origin, int y_shift_origin)
406     {
407         
408         Stroke stroke = getPenStroke( pen,zoom_factor );
409         g.setColor( getFgcolor());
410                 
411         this.zoom_factor = zoom_factor;
412         if (stroke==null || pen.equalsIgnoreCase("None")) return;
413         
414         position.x -= 10;
415         position.y -= 10;
416         x_shift_origin -= 10;
417         y_shift_origin -= 10;
418                 
419                 Stroke oldStroke = g.getStroke();
420                 g.setStroke(stroke);
421         g.drawRect(
422                     getZoomedDim(position.x)-x_shift_origin,
423             getZoomedDim(position.y)-y_shift_origin,
424                     getZoomedDim(width),getZoomedDim(height));
425
426         position.x += 10;
427         position.y += 10;
428                 
429                 g.setStroke(oldStroke);
430         }
431         
432         /** Getter for property horizontalAlignment.
433          * @return Value of property horizontalAlignment.
434          *
435          */

436         public java.lang.String JavaDoc getHorizontalAlignment() {
437             if (getPropertyValue( HORIZONTAL_ALIGN) == null)
438            {
439                 // Look for a fgcolor in the stylesheet...
440
if (getStyle() != null)
441                 {
442                    return getStyle().getAttributeString( getStyle().ATTRIBUTE_hAlign, DEFAULT_HORIZONTAL_ALIGN, true);
443                 }
444             }
445             return getStringValue( HORIZONTAL_ALIGN, DEFAULT_HORIZONTAL_ALIGN );
446         }
447         
448         /** Setter for property horizontalAlignment.
449          * @param horizontalAlignment New value of property horizontalAlignment.
450          *
451          */

452         public void setHorizontalAlignment(java.lang.String JavaDoc horizontalAlignment) {
453              setPropertyValue( HORIZONTAL_ALIGN, horizontalAlignment );
454         }
455         
456         /** Getter for property imageClass.
457          * @return Value of property imageClass.
458          *
459          */

460         public java.lang.String JavaDoc getImageClass() {
461             return imageClass;
462         }
463         
464         /** Setter for property imageClass.
465          * @param imageClass New value of property imageClass.
466          *
467          */

468         public void setImageClass(java.lang.String JavaDoc imageClass) {
469             this.imageClass = imageClass;
470         }
471         
472         /** Getter for property verticalAlignment.
473          * @return Value of property verticalAlignment.
474          *
475          */

476         public java.lang.String JavaDoc getVerticalAlignment() {
477             if (getPropertyValue( VERTICAL_ALIGN) == null)
478            {
479                 // Look for a fgcolor in the stylesheet...
480
if (getStyle() != null)
481                 {
482                    return getStyle().getAttributeString( getStyle().ATTRIBUTE_vAlign, DEFAULT_VERTICAL_ALIGN, true);
483                 }
484             }
485             return getStringValue( VERTICAL_ALIGN, DEFAULT_VERTICAL_ALIGN );
486         }
487         
488         /** Setter for property verticalAlignment.
489          * @param verticalAlignment New value of property verticalAlignment.
490          *
491          */

492         public void setVerticalAlignment(java.lang.String JavaDoc verticalAlignment) {
493             setPropertyValue( VERTICAL_ALIGN, verticalAlignment );
494         }
495         
496         /** Getter for property evaluationGroup.
497          * @return Value of property evaluationGroup.
498          *
499          */

500         public java.lang.String JavaDoc getEvaluationGroup() {
501             return evaluationGroup;
502         }
503         
504         /** Setter for property evaluationGroup.
505          * @param evaluationGroup New value of property evaluationGroup.
506          *
507          */

508         public void setEvaluationGroup(java.lang.String JavaDoc evaluationGroup) {
509             this.evaluationGroup = evaluationGroup;
510         }
511         
512         /** Getter for property imageExpression.
513          * @return Value of property imageExpression.
514          *
515          */

516         public java.lang.String JavaDoc getImageExpression() {
517             return imageExpression;
518         }
519         
520         /** Setter for property imageExpression.
521          * @param imageExpression New value of property imageExpression.
522          *
523          */

524         public void setImageExpression(java.lang.String JavaDoc imageExpression) {
525             this.imageExpression = imageExpression;
526             this.triedToLoadImg = false;
527         }
528         
529         /** Getter for property evaluationTime.
530          * @return Value of property evaluationTime.
531          *
532          */

533         public java.lang.String JavaDoc getEvaluationTime() {
534             return evaluationTime;
535         }
536         
537         /** Setter for property evaluationTime.
538          * @param evaluationTime New value of property evaluationTime.
539          *
540          */

541         public void setEvaluationTime(java.lang.String JavaDoc evaluationTime) {
542             this.evaluationTime = evaluationTime;
543         }
544         
545         /** Getter for property img.
546          * @return Value of property img.
547          *
548          */

549         public java.awt.Image JavaDoc getImg() {
550             return img;
551         }
552         
553         public java.awt.Image JavaDoc getImgDef() {
554             return defimg;
555         }
556         
557         /** Setter for property img.
558          * @param img New value of property img.
559          *
560          */

561         public void setImg(java.awt.Image JavaDoc img) {
562             this.img = img;
563         }
564         
565         /** Getter for property hyperlinkType.
566          * @return Value of property hyperlinkType.
567          *
568          */

569         public java.lang.String JavaDoc getHyperlinkType() {
570             return hyperlinkType;
571         }
572         
573         /** Setter for property hyperlinkType.
574          * @param hyperlinkType New value of property hyperlinkType.
575          *
576          */

577         public void setHyperlinkType(java.lang.String JavaDoc hyperlinkType) {
578             this.hyperlinkType = hyperlinkType;
579         }
580         
581         /** Getter for property anchorNameExpression.
582          * @return Value of property anchorNameExpression.
583          *
584          */

585         public java.lang.String JavaDoc getAnchorNameExpression() {
586             return anchorNameExpression;
587         }
588         
589         /** Setter for property anchorNameExpression.
590          * @param anchorNameExpression New value of property anchorNameExpression.
591          *
592          */

593         public void setAnchorNameExpression(java.lang.String JavaDoc anchorNameExpression) {
594             this.anchorNameExpression = anchorNameExpression;
595         }
596         
597         /** Getter for property scaleImage.
598          * @return Value of property scaleImage.
599          *
600          */

601         public java.lang.String JavaDoc getScaleImage() {
602             if (getPropertyValue( SCALE) == null)
603            {
604                 // Look for a fgcolor in the stylesheet...
605
if (getStyle() != null)
606                 {
607                    return getStyle().getAttributeString( getStyle().ATTRIBUTE_scaleImage, DEFAULT_SCALE, true);
608                 }
609             }
610             return getStringValue( SCALE, DEFAULT_SCALE );
611         }
612         
613         /** Setter for property scaleImage.
614          * @param scaleImage New value of property scaleImage.
615          *
616          */

617         public void setScaleImage(java.lang.String JavaDoc scaleImage) {
618             setPropertyValue( SCALE, scaleImage );
619         }
620         
621         /** Getter for property hyperlinkReferenceExpression.
622          * @return Value of property hyperlinkReferenceExpression.
623          *
624          */

625         public java.lang.String JavaDoc getHyperlinkReferenceExpression() {
626             return hyperlinkReferenceExpression;
627         }
628         
629         /** Setter for property hyperlinkReferenceExpression.
630          * @param hyperlinkReferenceExpression New value of property hyperlinkReferenceExpression.
631          *
632          */

633         public void setHyperlinkReferenceExpression(java.lang.String JavaDoc hyperlinkReferenceExpression) {
634             this.hyperlinkReferenceExpression = hyperlinkReferenceExpression;
635         }
636         
637         /** Getter for property hyperlinkAnchorExpression.
638          * @return Value of property hyperlinkAnchorExpression.
639          *
640          */

641         public java.lang.String JavaDoc getHyperlinkAnchorExpression() {
642             return hyperlinkAnchorExpression;
643         }
644         
645         /** Setter for property hyperlinkAnchorExpression.
646          * @param hyperlinkAnchorExpression New value of property hyperlinkAnchorExpression.
647          *
648          */

649         public void setHyperlinkAnchorExpression(java.lang.String JavaDoc hyperlinkAnchorExpression) {
650             this.hyperlinkAnchorExpression = hyperlinkAnchorExpression;
651         }
652         
653         /** Getter for property hyperlinkPageExpression.
654          * @return Value of property hyperlinkPageExpression.
655          *
656          */

657         public java.lang.String JavaDoc getHyperlinkPageExpression() {
658             return hyperlinkPageExpression;
659         }
660         
661         /** Setter for property hyperlinkPageExpression.
662          * @param hyperlinkPageExpression New value of property hyperlinkPageExpression.
663          *
664          */

665         public void setHyperlinkPageExpression(java.lang.String JavaDoc hyperlinkPageExpression) {
666             this.hyperlinkPageExpression = hyperlinkPageExpression;
667         }
668         
669         /** This method is called when information about an image which was
670          * previously requested using an asynchronous interface becomes
671          * available. Asynchronous interfaces are method calls such as
672          * getWidth(ImageObserver) and drawImage(img, x, y, ImageObserver)
673          * which take an ImageObserver object as an argument. Those methods
674          * register the caller as interested either in information about
675          * the overall image itself (in the case of getWidth(ImageObserver))
676          * or about an output version of an image (in the case of the
677          * drawImage(img, x, y, [w, h,] ImageObserver) call).
678          *
679          * <p>This method
680          * should return true if further updates are needed or false if the
681          * required information has been acquired. The image which was being
682          * tracked is passed in using the img argument. Various constants
683          * are combined to form the infoflags argument which indicates what
684          * information about the image is now available. The interpretation
685          * of the x, y, width, and height arguments depends on the contents
686          * of the infoflags argument.
687          * <p>
688          * The <code>infoflags</code> argument should be the bitwise inclusive
689          * <b>OR</b> of the following flags: <code>WIDTH</code>,
690          * <code>HEIGHT</code>, <code>PROPERTIES</code>, <code>SOMEBITS</code>,
691          * <code>FRAMEBITS</code>, <code>ALLBITS</code>, <code>ERROR</code>,
692          * <code>ABORT</code>.
693          *
694          * @param img the image being observed.
695          * @param infoflags the bitwise inclusive OR of the following
696          * flags: <code>WIDTH</code>, <code>HEIGHT</code>,
697          * <code>PROPERTIES</code>, <code>SOMEBITS</code>,
698          * <code>FRAMEBITS</code>, <code>ALLBITS</code>,
699          * <code>ERROR</code>, <code>ABORT</code>.
700          * @param x the <i>x</i> coordinate.
701          * @param y the <i>y</i> coordinate.
702          * @param width the width.
703          * @param height the height.
704          * @return <code>false</code> if the infoflags indicate that the
705          * image is completely loaded; <code>true</code> otherwise.
706          *
707          * @see #WIDTH
708          * @see #HEIGHT
709          * @see #PROPERTIES
710          * @see #SOMEBITS
711          * @see #FRAMEBITS
712          * @see #ALLBITS
713          * @see #ERROR
714          * @see #ABORT
715          * @see Image#getWidth
716          * @see Image#getHeight
717          * @see java.awt.Graphics#drawImage
718          *
719          */

720         public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) {
721             return true;
722         }
723         
724         public static void setImgDef(Image defImg)
725         {
726             defimg = defImg;
727         }
728         
729         /** Getter for property isUsingCache.
730          * @return Value of property isUsingCache.
731          *
732          */

733         public boolean isIsUsingCache() {
734
735             return getBooleanValue( USING_CACHE, DEFAULT_USING_CACHE );
736         }
737         
738         /** Setter for property isUsingCache.
739          * @param isUsingCache New value of property isUsingCache.
740          *
741          */

742         public void setIsUsingCache(boolean isUsingCache) {
743             setPropertyValue( USING_CACHE, new Boolean JavaDoc( isUsingCache ) );
744         }
745         
746     /**
747      * @return
748      */

749     public File JavaDoc getReportDirectory() {
750         return reportDirectory;
751     }
752
753     /**
754      * @param directory
755      */

756     public void setReportDirectory(File JavaDoc directory) {
757         reportDirectory = directory;
758     }
759         
760         protected String JavaDoc hyperlinkTarget = "Self";
761     /** Getter for property hyperlinkTarget.
762          * @return Value of property hyperlinkTarget.
763          *
764          */

765         public java.lang.String JavaDoc getHyperlinkTarget(){ return hyperlinkTarget; }
766         
767         /** Setter for property hyperlinkTarget.
768          * @param hyperlinkTarget New value of property hyperlinkTarget.
769          *
770          */

771         public void setHyperlinkTarget(java.lang.String JavaDoc hyperlinkTarget) { this.hyperlinkTarget = hyperlinkTarget; }
772         
773             public Box getBox() {
774         return box;
775     }
776
777     public void setBox(Box box) {
778         this.box = box;
779     }
780
781     public boolean isIsLazy() {
782         return isLazy;
783     }
784
785     public void setIsLazy(boolean isLazy) {
786         this.isLazy = isLazy;
787     }
788
789     public int getBookmarkLevel() {
790         return bookmarkLevel;
791     }
792
793     public void setBookmarkLevel(int bookmarkLevel) {
794         this.bookmarkLevel = bookmarkLevel;
795     }
796
797     public String JavaDoc getOnErrorType() {
798         return onErrorType;
799     }
800
801     public void setOnErrorType(String JavaDoc onErrorType) {
802         this.onErrorType = onErrorType;
803     }
804
805     
806     public void setStyle(Style style) {
807      
808         super.setStyle(style);
809         
810         if (style != null)
811         {
812             //this.setHorizontalAlignment(style.getAttributeString( style.ATTRIBUTE_hAlign, getHorizontalAlignment(), true));
813
//this.setVerticalAlignment( style.getAttributeString( style.ATTRIBUTE_vAlign, getVerticalAlignment(), true));
814

815             //this.setScaleImage( style.getAttributeString( style.ATTRIBUTE_scaleImage, getScaleImage(), true));
816

817             // BOX
818
if (style.getAttributeString(style.ATTRIBUTE_border, null, true) != null)
819                 this.getBox().setBorder( style.getAttributeString(style.ATTRIBUTE_border, null, true) );
820             if (style.getAttributeColor(style.ATTRIBUTE_borderColor, null, true) != null)
821                 this.getBox().setBorderColor( style.getAttributeColor(style.ATTRIBUTE_borderColor, null, true));
822             if (style.getAttributeString(style.ATTRIBUTE_padding, null, true) != null)
823                 this.getBox().setPadding( Integer.parseInt( style.getAttributeString(style.ATTRIBUTE_padding, null, true) ));
824             
825             if (style.getAttributeString(style.ATTRIBUTE_topBorder, null, true) != null)
826                 this.getBox().setTopBorder( style.getAttributeString(style.ATTRIBUTE_topBorder, null, true) );
827             if (style.getAttributeColor(style.ATTRIBUTE_topBorderColor, null, true) != null)
828                 this.getBox().setTopBorderColor( style.getAttributeColor(style.ATTRIBUTE_topBorderColor, null, true));
829             if (style.getAttributeString(style.ATTRIBUTE_topPadding, null, true) != null)
830                 this.getBox().setTopPadding( Integer.parseInt( style.getAttributeString(style.ATTRIBUTE_topPadding, null, true) ));
831             
832             if (style.getAttributeString(style.ATTRIBUTE_leftBorder, null, true) != null)
833                 this.getBox().setLeftBorder( style.getAttributeString(style.ATTRIBUTE_leftBorder, null, true) );
834             if (style.getAttributeColor(style.ATTRIBUTE_leftBorderColor, null, true) != null)
835                 this.getBox().setLeftBorderColor( style.getAttributeColor(style.ATTRIBUTE_leftBorderColor, null, true));
836             if (style.getAttributeString(style.ATTRIBUTE_leftPadding, null, true) != null)
837                 this.getBox().setLeftPadding( Integer.parseInt( style.getAttributeString(style.ATTRIBUTE_leftPadding, null, true) ));
838             
839             if (style.getAttributeString(style.ATTRIBUTE_rightBorder, null, true) != null)
840                 this.getBox().setRightBorder( style.getAttributeString(style.ATTRIBUTE_rightBorder, null, true) );
841             if (style.getAttributeColor(style.ATTRIBUTE_rightBorderColor, null, true) != null)
842                 this.getBox().setRightBorderColor( style.getAttributeColor(style.ATTRIBUTE_rightBorderColor, null, true));
843             if (style.getAttributeString(style.ATTRIBUTE_rightPadding, null, true) != null)
844                 this.getBox().setRightPadding( Integer.parseInt( style.getAttributeString(style.ATTRIBUTE_rightPadding, null, true) ));
845             
846             if (style.getAttributeString(style.ATTRIBUTE_bottomBorder, null, true) != null)
847                 this.getBox().setBottomBorder( style.getAttributeString(style.ATTRIBUTE_bottomBorder, null, true) );
848             if (style.getAttributeColor(style.ATTRIBUTE_bottomBorderColor, null, true) != null)
849                 this.getBox().setBottomBorderColor( style.getAttributeColor(style.ATTRIBUTE_bottomBorderColor, null, true));
850             if (style.getAttributeString(style.ATTRIBUTE_bottomPadding, null, true) != null)
851                 this.getBox().setBottomPadding( Integer.parseInt( style.getAttributeString(style.ATTRIBUTE_bottomPadding, null, true) ));
852             
853         }
854      }
855
856     public java.util.List JavaDoc getLinkParameters() {
857         return linkParameters;
858     }
859
860     public void setLinkParameters(java.util.List JavaDoc linkParameters) {
861         this.linkParameters = linkParameters;
862     }
863     
864 }
865
Popular Tags