001: /*
002: * ============================================================================
003: * GNU Lesser General Public License
004: * ============================================================================
005: *
006: * JasperReports - Free Java report-generating library.
007: * Copyright (C) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com
008: *
009: * This library is free software; you can redistribute it and/or
010: * modify it under the terms of the GNU Lesser General Public
011: * License as published by the Free Software Foundation; either
012: * version 2.1 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: * Lesser General Public License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library; if not, write to the Free Software
021: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
022: *
023: * JasperSoft Corporation
024: * 303 Second Street, Suite 450 North
025: * San Francisco, CA 94107
026: * http://www.jaspersoft.com
027: */
028: package net.sf.jasperreports.engine.base;
029:
030: import java.awt.Color;
031: import java.io.IOException;
032: import java.io.ObjectInputStream;
033:
034: import net.sf.jasperreports.engine.JRAnchor;
035: import net.sf.jasperreports.engine.JRBox;
036: import net.sf.jasperreports.engine.JRConstants;
037: import net.sf.jasperreports.engine.JRDefaultStyleProvider;
038: import net.sf.jasperreports.engine.JRElement;
039: import net.sf.jasperreports.engine.JRGraphicElement;
040: import net.sf.jasperreports.engine.JRHyperlink;
041: import net.sf.jasperreports.engine.JRHyperlinkHelper;
042: import net.sf.jasperreports.engine.JRImage;
043: import net.sf.jasperreports.engine.JRPrintHyperlinkParameter;
044: import net.sf.jasperreports.engine.JRPrintHyperlinkParameters;
045: import net.sf.jasperreports.engine.JRPrintImage;
046: import net.sf.jasperreports.engine.JRRenderable;
047: import net.sf.jasperreports.engine.util.JRStyleResolver;
048:
049: /**
050: * @author Teodor Danciu (teodord@users.sourceforge.net)
051: * @version $Id: JRBasePrintImage.java 1729 2007-05-29 12:45:24Z teodord $
052: */
053: public class JRBasePrintImage extends JRBasePrintGraphicElement
054: implements JRPrintImage {
055:
056: /**
057: *
058: */
059: private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
060:
061: /**
062: *
063: */
064: protected JRRenderable renderer = null;
065: protected Byte scaleImage = null;
066: protected Boolean isUsingCache = Boolean.TRUE;
067: protected Byte horizontalAlignment = null;
068: protected Byte verticalAlignment = null;
069: protected boolean isLazy = false;
070: protected byte onErrorType = JRImage.ON_ERROR_TYPE_ERROR;
071: //protected JRBox box = null;
072: protected String anchorName = null;
073: protected byte hyperlinkType = JRHyperlink.HYPERLINK_TYPE_NULL;
074: private String linkType;
075: protected byte hyperlinkTarget = JRHyperlink.HYPERLINK_TARGET_SELF;
076: protected String hyperlinkReference = null;
077: protected String hyperlinkAnchor = null;
078: protected Integer hyperlinkPage = null;
079: protected String hyperlinkTooltip;
080: protected JRPrintHyperlinkParameters hyperlinkParameters;
081:
082: /**
083: * The bookmark level for the anchor associated with this field.
084: * @see JRAnchor#getBookmarkLevel()
085: */
086: protected int bookmarkLevel = JRAnchor.NO_BOOKMARK;
087:
088: /**
089: *
090: */
091: protected Byte border;
092: protected Byte topBorder = null;
093: protected Byte leftBorder = null;
094: protected Byte bottomBorder = null;
095: protected Byte rightBorder = null;
096: protected Color borderColor = null;
097: protected Color topBorderColor = null;
098: protected Color leftBorderColor = null;
099: protected Color bottomBorderColor = null;
100: protected Color rightBorderColor = null;
101: protected Integer padding;
102: protected Integer topPadding = null;
103: protected Integer leftPadding = null;
104: protected Integer bottomPadding = null;
105: protected Integer rightPadding = null;
106:
107: /**
108: *
109: */
110: public JRBasePrintImage(JRDefaultStyleProvider defaultStyleProvider) {
111: super (defaultStyleProvider);
112: }
113:
114: /**
115: *
116: */
117: public byte getMode() {
118: return JRStyleResolver
119: .getMode(this , JRElement.MODE_TRANSPARENT);
120: }
121:
122: /**
123: *
124: */
125: public byte getPen() {
126: return JRStyleResolver.getPen(this , JRGraphicElement.PEN_NONE);
127: }
128:
129: /**
130: *
131: */
132: public JRRenderable getRenderer() {
133: return renderer;
134: }
135:
136: /**
137: *
138: */
139: public void setRenderer(JRRenderable renderer) {
140: this .renderer = renderer;
141: }
142:
143: /**
144: *
145: */
146: public byte getScaleImage() {
147: return JRStyleResolver.getScaleImage(this );
148: }
149:
150: /**
151: *
152: */
153: public Byte getOwnScaleImage() {
154: return scaleImage;
155: }
156:
157: /**
158: *
159: */
160: public void setScaleImage(byte scaleImage) {
161: this .scaleImage = new Byte(scaleImage);
162: }
163:
164: /**
165: *
166: */
167: public void setScaleImage(Byte scaleImage) {
168: this .scaleImage = scaleImage;
169: }
170:
171: /**
172: *
173: */
174: public boolean isUsingCache() {
175: return isUsingCache == null ? true : isUsingCache
176: .booleanValue();
177: }
178:
179: /**
180: *
181: */
182: public void setUsingCache(boolean isUsingCache) {
183: this .isUsingCache = (isUsingCache ? Boolean.TRUE
184: : Boolean.FALSE);
185: }
186:
187: /**
188: *
189: */
190: public byte getHorizontalAlignment() {
191: return JRStyleResolver.getHorizontalAlignment(this );
192: }
193:
194: /**
195: *
196: */
197: public Byte getOwnHorizontalAlignment() {
198: return horizontalAlignment;
199: }
200:
201: /**
202: *
203: */
204: public void setHorizontalAlignment(byte horizontalAlignment) {
205: this .horizontalAlignment = new Byte(horizontalAlignment);
206: }
207:
208: /**
209: *
210: */
211: public void setHorizontalAlignment(Byte horizontalAlignment) {
212: this .horizontalAlignment = horizontalAlignment;
213: }
214:
215: /**
216: *
217: */
218: public byte getVerticalAlignment() {
219: return JRStyleResolver.getVerticalAlignment(this );
220: }
221:
222: /**
223: *
224: */
225: public Byte getOwnVerticalAlignment() {
226: return verticalAlignment;
227: }
228:
229: /**
230: *
231: */
232: public void setVerticalAlignment(byte verticalAlignment) {
233: this .verticalAlignment = new Byte(verticalAlignment);
234: }
235:
236: /**
237: *
238: */
239: public void setVerticalAlignment(Byte verticalAlignment) {
240: this .verticalAlignment = verticalAlignment;
241: }
242:
243: /**
244: *
245: */
246: public boolean isLazy() {
247: return isLazy;
248: }
249:
250: /**
251: *
252: */
253: public void setLazy(boolean isLazy) {
254: this .isLazy = isLazy;
255: }
256:
257: /**
258: *
259: */
260: public byte getOnErrorType() {
261: return onErrorType;
262: }
263:
264: /**
265: *
266: */
267: public void setOnErrorType(byte onErrorType) {
268: this .onErrorType = onErrorType;
269: }
270:
271: /**
272: * @deprecated
273: */
274: public JRBox getBox() {
275: return this ;
276: }
277:
278: /**
279: * @deprecated
280: */
281: public void setBox(JRBox box) {
282: border = box.getOwnBorder();
283: topBorder = box.getOwnTopBorder();
284: leftBorder = box.getOwnLeftBorder();
285: bottomBorder = box.getOwnBottomBorder();
286: rightBorder = box.getOwnRightBorder();
287: borderColor = box.getOwnBorderColor();
288: topBorderColor = box.getOwnTopBorderColor();
289: leftBorderColor = box.getOwnLeftBorderColor();
290: bottomBorderColor = box.getOwnBottomBorderColor();
291: rightBorderColor = box.getOwnRightBorderColor();
292: padding = box.getOwnPadding();
293: topPadding = box.getOwnTopPadding();
294: leftPadding = box.getOwnLeftPadding();
295: bottomPadding = box.getOwnBottomPadding();
296: rightPadding = box.getOwnRightPadding();
297: }
298:
299: /**
300: *
301: */
302: public String getAnchorName() {
303: return anchorName;
304: }
305:
306: /**
307: *
308: */
309: public void setAnchorName(String anchorName) {
310: this .anchorName = anchorName;
311: }
312:
313: /**
314: *
315: */
316: public byte getHyperlinkType() {
317: return JRHyperlinkHelper.getHyperlinkType(getLinkType());
318: }
319:
320: /**
321: *
322: */
323: public void setHyperlinkType(byte hyperlinkType) {
324: setLinkType(JRHyperlinkHelper.getLinkType(hyperlinkType));
325: }
326:
327: /**
328: *
329: */
330: public byte getHyperlinkTarget() {
331: return hyperlinkTarget;
332: }
333:
334: /**
335: *
336: */
337: public void setHyperlinkTarget(byte hyperlinkTarget) {
338: this .hyperlinkTarget = hyperlinkTarget;
339: }
340:
341: /**
342: *
343: */
344: public String getHyperlinkReference() {
345: return hyperlinkReference;
346: }
347:
348: /**
349: *
350: */
351: public void setHyperlinkReference(String hyperlinkReference) {
352: this .hyperlinkReference = hyperlinkReference;
353: }
354:
355: /**
356: *
357: */
358: public String getHyperlinkAnchor() {
359: return hyperlinkAnchor;
360: }
361:
362: /**
363: *
364: */
365: public void setHyperlinkAnchor(String hyperlinkAnchor) {
366: this .hyperlinkAnchor = hyperlinkAnchor;
367: }
368:
369: /**
370: *
371: */
372: public Integer getHyperlinkPage() {
373: return hyperlinkPage;
374: }
375:
376: /**
377: *
378: */
379: public void setHyperlinkPage(Integer hyperlinkPage) {
380: this .hyperlinkPage = hyperlinkPage;
381: }
382:
383: /**
384: *
385: */
386: public void setHyperlinkPage(String hyperlinkPage) {
387: this .hyperlinkPage = new Integer(hyperlinkPage);
388: }
389:
390: public int getBookmarkLevel() {
391: return bookmarkLevel;
392: }
393:
394: public void setBookmarkLevel(int bookmarkLevel) {
395: this .bookmarkLevel = bookmarkLevel;
396: }
397:
398: /**
399: *
400: */
401: public byte getBorder() {
402: return JRStyleResolver.getBorder(this );
403: }
404:
405: public Byte getOwnBorder() {
406: return border;
407: }
408:
409: /**
410: *
411: */
412: public void setBorder(byte border) {
413: this .border = new Byte(border);
414: }
415:
416: /**
417: *
418: */
419: public Color getBorderColor() {
420: return JRStyleResolver.getBorderColor(this , getForecolor());
421: }
422:
423: public Color getOwnBorderColor() {
424: return borderColor;
425: }
426:
427: /**
428: *
429: */
430: public void setBorderColor(Color borderColor) {
431: this .borderColor = borderColor;
432: }
433:
434: /**
435: *
436: */
437: public int getPadding() {
438: return JRStyleResolver.getPadding(this );
439: }
440:
441: public Integer getOwnPadding() {
442: return padding;
443: }
444:
445: /**
446: *
447: */
448: public void setPadding(int padding) {
449: this .padding = new Integer(padding);
450: }
451:
452: /**
453: *
454: */
455: public byte getTopBorder() {
456: return JRStyleResolver.getTopBorder(this );
457: }
458:
459: /**
460: *
461: */
462: public Byte getOwnTopBorder() {
463: return topBorder;
464: }
465:
466: /**
467: *
468: */
469: public void setTopBorder(byte topBorder) {
470: this .topBorder = new Byte(topBorder);
471: }
472:
473: /**
474: *
475: */
476: public Color getTopBorderColor() {
477: return JRStyleResolver.getTopBorderColor(this , getForecolor());
478: }
479:
480: /**
481: *
482: */
483: public Color getOwnTopBorderColor() {
484: return topBorderColor;
485: }
486:
487: /**
488: *
489: */
490: public void setTopBorderColor(Color topBorderColor) {
491: this .topBorderColor = topBorderColor;
492: }
493:
494: /**
495: *
496: */
497: public int getTopPadding() {
498: return JRStyleResolver.getTopPadding(this );
499: }
500:
501: /**
502: *
503: */
504: public Integer getOwnTopPadding() {
505: return topPadding;
506: }
507:
508: /**
509: *
510: */
511: public void setTopPadding(int topPadding) {
512: this .topPadding = new Integer(topPadding);
513: }
514:
515: /**
516: *
517: */
518: public byte getLeftBorder() {
519: return JRStyleResolver.getLeftBorder(this );
520: }
521:
522: /**
523: *
524: */
525: public Byte getOwnLeftBorder() {
526: return leftBorder;
527: }
528:
529: /**
530: *
531: */
532: public void setLeftBorder(byte leftBorder) {
533: this .leftBorder = new Byte(leftBorder);
534: }
535:
536: /**
537: *
538: */
539: public Color getLeftBorderColor() {
540: return JRStyleResolver.getLeftBorderColor(this , getForecolor());
541: }
542:
543: /**
544: *
545: */
546: public Color getOwnLeftBorderColor() {
547: return leftBorderColor;
548: }
549:
550: /**
551: *
552: */
553: public void setLeftBorderColor(Color leftBorderColor) {
554: this .leftBorderColor = leftBorderColor;
555: }
556:
557: /**
558: *
559: */
560: public int getLeftPadding() {
561: return JRStyleResolver.getLeftPadding(this );
562: }
563:
564: /**
565: *
566: */
567: public Integer getOwnLeftPadding() {
568: return leftPadding;
569: }
570:
571: /**
572: *
573: */
574: public void setLeftPadding(int leftPadding) {
575: this .leftPadding = new Integer(leftPadding);
576: }
577:
578: /**
579: *
580: */
581: public byte getBottomBorder() {
582: return JRStyleResolver.getBottomBorder(this );
583: }
584:
585: /**
586: *
587: */
588: public Byte getOwnBottomBorder() {
589: return bottomBorder;
590: }
591:
592: /**
593: *
594: */
595: public void setBottomBorder(byte bottomBorder) {
596: this .bottomBorder = new Byte(bottomBorder);
597: }
598:
599: /**
600: *
601: */
602: public Color getBottomBorderColor() {
603: return JRStyleResolver.getBottomBorderColor(this ,
604: getForecolor());
605: }
606:
607: /**
608: *
609: */
610: public Color getOwnBottomBorderColor() {
611: return bottomBorderColor;
612: }
613:
614: /**
615: *
616: */
617: public void setBottomBorderColor(Color bottomBorderColor) {
618: this .bottomBorderColor = bottomBorderColor;
619: }
620:
621: /**
622: *
623: */
624: public int getBottomPadding() {
625: return JRStyleResolver.getBottomPadding(this );
626: }
627:
628: /**
629: *
630: */
631: public Integer getOwnBottomPadding() {
632: return bottomPadding;
633: }
634:
635: /**
636: *
637: */
638: public void setBottomPadding(int bottomPadding) {
639: this .bottomPadding = new Integer(bottomPadding);
640: }
641:
642: /**
643: *
644: */
645: public byte getRightBorder() {
646: return JRStyleResolver.getRightBorder(this );
647: }
648:
649: /**
650: *
651: */
652: public Byte getOwnRightBorder() {
653: return rightBorder;
654: }
655:
656: /**
657: *
658: */
659: public void setRightBorder(byte rightBorder) {
660: this .rightBorder = new Byte(rightBorder);
661: }
662:
663: /**
664: *
665: */
666: public Color getRightBorderColor() {
667: return JRStyleResolver
668: .getRightBorderColor(this , getForecolor());
669: }
670:
671: /**
672: *
673: */
674: public Color getOwnRightBorderColor() {
675: return rightBorderColor;
676: }
677:
678: /**
679: *
680: */
681: public void setRightBorderColor(Color rightBorderColor) {
682: this .rightBorderColor = rightBorderColor;
683: }
684:
685: /**
686: *
687: */
688: public int getRightPadding() {
689: return JRStyleResolver.getRightPadding(this );
690: }
691:
692: /**
693: *
694: */
695: public Integer getOwnRightPadding() {
696: return rightPadding;
697: }
698:
699: /**
700: *
701: */
702: public void setRightPadding(int rightPadding) {
703: this .rightPadding = new Integer(rightPadding);
704: }
705:
706: /**
707: *
708: */
709: public void setBorder(Byte border) {
710: this .border = border;
711: }
712:
713: /**
714: *
715: */
716: public void setPadding(Integer padding) {
717: this .padding = padding;
718: }
719:
720: /**
721: *
722: */
723: public void setTopBorder(Byte topBorder) {
724: this .topBorder = topBorder;
725: }
726:
727: /**
728: *
729: */
730: public void setTopPadding(Integer topPadding) {
731: this .topPadding = topPadding;
732: }
733:
734: /**
735: *
736: */
737: public void setLeftBorder(Byte leftBorder) {
738: this .leftBorder = leftBorder;
739: }
740:
741: /**
742: *
743: */
744: public void setLeftPadding(Integer leftPadding) {
745: this .leftPadding = leftPadding;
746: }
747:
748: /**
749: *
750: */
751: public void setBottomBorder(Byte bottomBorder) {
752: this .bottomBorder = bottomBorder;
753: }
754:
755: /**
756: *
757: */
758: public void setBottomPadding(Integer bottomPadding) {
759: this .bottomPadding = bottomPadding;
760: }
761:
762: /**
763: *
764: */
765: public void setRightBorder(Byte rightBorder) {
766: this .rightBorder = rightBorder;
767: }
768:
769: /**
770: *
771: */
772: public void setRightPadding(Integer rightPadding) {
773: this .rightPadding = rightPadding;
774: }
775:
776: public JRPrintHyperlinkParameters getHyperlinkParameters() {
777: return hyperlinkParameters;
778: }
779:
780: public void setHyperlinkParameters(
781: JRPrintHyperlinkParameters hyperlinkParameters) {
782: this .hyperlinkParameters = hyperlinkParameters;
783: }
784:
785: /**
786: * Adds a custom hyperlink parameter.
787: *
788: * @param parameter the parameter to add
789: * @see #getHyperlinkParameters()
790: * @see JRPrintHyperlinkParameters#addParameter(JRPrintHyperlinkParameter)
791: */
792: public void addHyperlinkParameter(
793: JRPrintHyperlinkParameter parameter) {
794: if (hyperlinkParameters == null) {
795: hyperlinkParameters = new JRPrintHyperlinkParameters();
796: }
797: hyperlinkParameters.addParameter(parameter);
798: }
799:
800: public String getLinkType() {
801: return linkType;
802: }
803:
804: public void setLinkType(String linkType) {
805: this .linkType = linkType;
806: }
807:
808: private void readObject(ObjectInputStream in) throws IOException,
809: ClassNotFoundException {
810: in.defaultReadObject();
811: normalizeLinkType();
812: }
813:
814: protected void normalizeLinkType() {
815: if (linkType == null) {
816: linkType = JRHyperlinkHelper.getLinkType(hyperlinkType);
817: }
818: hyperlinkType = JRHyperlink.HYPERLINK_TYPE_NULL;
819: }
820:
821: public String getHyperlinkTooltip() {
822: return hyperlinkTooltip;
823: }
824:
825: public void setHyperlinkTooltip(String hyperlinkTooltip) {
826: this.hyperlinkTooltip = hyperlinkTooltip;
827: }
828:
829: }
|