/*
* JasperReports - Free Java Reporting Library.
* Copyright (C) 2001 - 2009 Jaspersoft Corporation. All rights reserved.
* http://www.jaspersoft.com
*
* Unless you have purchased a commercial license agreement from Jaspersoft,
* the following license terms apply:
*
* This program is part of JasperReports.
*
* JasperReports is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* JasperReports is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with JasperReports. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.jasperreports.engine.fill;
import java.awt.Color;
import net.sf.jasperreports.engine.JRAnchor;
import net.sf.jasperreports.engine.JRBox;
import net.sf.jasperreports.engine.JRConstants;
import net.sf.jasperreports.engine.JRLineBox;
import net.sf.jasperreports.engine.JRPrintHyperlinkParameters;
import net.sf.jasperreports.engine.JRPrintImage;
import net.sf.jasperreports.engine.JRRenderable;
import net.sf.jasperreports.engine.PrintElementVisitor;
import net.sf.jasperreports.engine.type.HorizontalAlignEnum;
import net.sf.jasperreports.engine.type.HyperlinkTargetEnum;
import net.sf.jasperreports.engine.type.HyperlinkTypeEnum;
import net.sf.jasperreports.engine.type.OnErrorTypeEnum;
import net.sf.jasperreports.engine.type.ScaleImageEnum;
import net.sf.jasperreports.engine.type.VerticalAlignEnum;
import net.sf.jasperreports.engine.util.JRBoxUtil;
import net.sf.jasperreports.engine.util.LineBoxWrapper;
/**
* Implementation of {@link net.sf.jasperreports.engine.JRPrintImage} that uses
* a {@link net.sf.jasperreports.engine.fill.JRTemplateImage} instance to
* store common attributes.
*
* @author Teodor Danciu (teodord@users.sourceforge.net)
* @version $Id: JRTemplatePrintImage.java 3991 2010-10-12 20:10:55Z lucianc $
*/
public class JRTemplatePrintImage extends JRTemplatePrintGraphicElement implements JRPrintImage
{
/**
*
*/
private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
/**
*
*/
private JRRenderable renderer;
private String anchorName;
private String hyperlinkReference;
private String hyperlinkAnchor;
private Integer hyperlinkPage;
private String hyperlinkTooltip;
private JRPrintHyperlinkParameters hyperlinkParameters;
/**
* The bookmark level for the anchor associated with this field.
* @see JRAnchor#getBookmarkLevel()
*/
protected int bookmarkLevel = JRAnchor.NO_BOOKMARK;
/**
* Creates a print image element.
*
* @param image the template image that the element will use
*/
public JRTemplatePrintImage(JRTemplateImage image)
{
super(image);
}
/**
*
*/
public JRRenderable getRenderer()
{
return this.renderer;
}
/**
*
*/
public void setRenderer(JRRenderable renderer)
{
this.renderer = renderer;
}
/**
* @deprecated Replaced by {@link #getScaleImageValue()}.
*/
public byte getScaleImage()
{
return getScaleImageValue().getValue();
}
/**
* @deprecated Replaced by {@link #getOwnScaleImageValue()}.
*/
public Byte getOwnScaleImage()
{
return getOwnScaleImageValue() == null ? null : getOwnScaleImageValue().getValueByte();
}
/**
* @deprecated Replaced by {@link #setScaleImage(ScaleImageEnum)}.
*/
public void setScaleImage(byte scaleImage)
{
throw new UnsupportedOperationException();
}
/**
* @deprecated Replaced by {@link #setScaleImage(ScaleImageEnum)}.
*/
public void setScaleImage(Byte scaleImage)
{
throw new UnsupportedOperationException();
}
/**
*
*/
public ScaleImageEnum getScaleImageValue()
{
return ((JRTemplateImage)this.template).getScaleImageValue();
}
/**
*
*/
public ScaleImageEnum getOwnScaleImageValue()
{
return ((JRTemplateImage)this.template).getOwnScaleImageValue();
}
/**
*
*/
public void setScaleImage(ScaleImageEnum scaleImage)
{
throw new UnsupportedOperationException();
}
/**
*
*/
public boolean isUsingCache()
{
return ((JRTemplateImage)this.template).isUsingCache();
}
/**
*
*/
public void setUsingCache(boolean isUsingCache)
{
}
/**
* @deprecated Replaced by {@link #getHorizontalAlignmentValue()}.
*/
public byte getHorizontalAlignment()
{
return getHorizontalAlignmentValue().getValue();
}
/**
* @deprecated Replaced by {@link #getOwnHorizontalAlignmentValue()}.
*/
public Byte getOwnHorizontalAlignment()
{
return getOwnHorizontalAlignmentValue() == null ? null : getOwnHorizontalAlignmentValue().getValueByte();
}
/**
*
*/
public HorizontalAlignEnum getHorizontalAlignmentValue()
{
return ((JRTemplateImage)this.template).getHorizontalAlignmentValue();
}
/**
*
*/
public HorizontalAlignEnum getOwnHorizontalAlignmentValue()
{
return ((JRTemplateImage)this.template).getOwnHorizontalAlignmentValue();
}
/**
* @deprecated Replaced by {@link #setHorizontalAlignment(HorizontalAlignEnum)}.
*/
public void setHorizontalAlignment(byte horizontalAlignment)
{
throw new UnsupportedOperationException();
}
/**
* @deprecated Replaced by {@link #setHorizontalAlignment(HorizontalAlignEnum)}.
*/
public void setHorizontalAlignment(Byte horizontalAlignment)
{
throw new UnsupportedOperationException();
}
/**
*
*/
public void setHorizontalAlignment(HorizontalAlignEnum horizontalAlignment)
{
throw new UnsupportedOperationException();
}
/**
* @deprecated Replaced by {@link #getVerticalAlignmentValue()}.
*/
public byte getVerticalAlignment()
{
return getVerticalAlignmentValue().getValue();
}
/**
* @deprecated Replaced by {@link #getOwnVerticalAlignmentValue()}.
*/
public Byte getOwnVerticalAlignment()
{
return getOwnVerticalAlignmentValue() == null ? null : getOwnVerticalAlignmentValue().getValueByte();
}
/**
*
*/
public VerticalAlignEnum getVerticalAlignmentValue()
{
return ((JRTemplateImage)this.template).getVerticalAlignmentValue();
}
/**
*
*/
public VerticalAlignEnum getOwnVerticalAlignmentValue()
{
return ((JRTemplateImage)this.template).getOwnVerticalAlignmentValue();
}
/**
* @deprecated Replaced by {@link #setVerticalAlignment(VerticalAlignEnum)}.
*/
public void setVerticalAlignment(byte verticalAlignment)
{
throw new UnsupportedOperationException();
}
/**
* @deprecated Replaced by {@link #setVerticalAlignment(VerticalAlignEnum)}.
*/
public void setVerticalAlignment(Byte verticalAlignment)
{
throw new UnsupportedOperationException();
}
/**
*
*/
public void setVerticalAlignment(VerticalAlignEnum verticalAlignment)
{
throw new UnsupportedOperationException();
}
/**
*
*/
public boolean isLazy()
{
return ((JRTemplateImage)this.template).isLazy();
}
/**
*
*/
public void setLazy(boolean isLazy)
{
}
/**
* @deprecated Replaced by {@link #getOnErrorTypeValue()}.
*/
public byte getOnErrorType()
{
return getOnErrorTypeValue().getValue();
}
/**
* @deprecated Replaced by {@link #setOnErrorType(OnErrorTypeEnum)}.
*/
public void setOnErrorType(byte onErrorType)
{
throw new UnsupportedOperationException();
}
/**
*
*/
public OnErrorTypeEnum getOnErrorTypeValue()
{
return ((JRTemplateImage)this.template).getOnErrorTypeValue();
}
/**
*
*/
public void setOnErrorType(OnErrorTypeEnum onErrorType)
{
throw new UnsupportedOperationException();
}
/**
* @deprecated Replaced by {@link #getLineBox()}
*/
public JRBox getBox()
{
return new LineBoxWrapper(getLineBox());
}
/**
*
*/
public JRLineBox getLineBox()
{
return ((JRTemplateImage)template).getLineBox();
}
/**
* @deprecated Replaced by {@link #getLineBox()}
*/
public void setBox(JRBox box)
{
JRBoxUtil.setBoxToLineBox(box, getLineBox());
}
/**
*
*/
public String getAnchorName()
{
return this.anchorName;
}
/**
*
*/
public void setAnchorName(String anchorName)
{
this.anchorName = anchorName;
}
/**
* @deprecated Replaced by {@link #getHyperlinkTypeValue()}.
*/
public byte getHyperlinkType()
{
return getHyperlinkTypeValue().getValue();
}
/**
*
*/
public HyperlinkTypeEnum getHyperlinkTypeValue()
{
return ((JRTemplateImage)this.template).getHyperlinkTypeValue();
}
/**
* @deprecated Replaced by {@link #setHyperlinkType(HyperlinkTypeEnum)}.
*/
public void setHyperlinkType(byte hyperlinkType)
{
setHyperlinkType(HyperlinkTypeEnum.getByValue(hyperlinkType));
}
/**
*
*/
public void setHyperlinkType(HyperlinkTypeEnum hyperlinkType)
{
throw new UnsupportedOperationException();
}
/**
* @deprecated Replaced by {@link #getHyperlinkTargetValue()}.
*/
public byte getHyperlinkTarget()
{
return getHyperlinkTargetValue().getValue();
}
/**
*
*/
public HyperlinkTargetEnum getHyperlinkTargetValue()
{
return ((JRTemplateImage)this.template).getHyperlinkTargetValue();
}
/**
* @deprecated Replaced by {@link #setHyperlinkTarget(HyperlinkTargetEnum)}.
*/
public void setHyperlinkTarget(byte hyperlinkTarget)
{
setHyperlinkTarget(HyperlinkTargetEnum.getByValue(hyperlinkTarget));
}
/**
*
*/
public void setHyperlinkTarget(HyperlinkTargetEnum hyperlinkTarget)
{
throw new UnsupportedOperationException();
}
/**
*
*/
public String getHyperlinkReference()
{
return this.hyperlinkReference;
}
/**
*
*/
public void setHyperlinkReference(String hyperlinkReference)
{
this.hyperlinkReference = hyperlinkReference;
}
/**
*
*/
public String getHyperlinkAnchor()
{
return this.hyperlinkAnchor;
}
/**
*
*/
public void setHyperlinkAnchor(String hyperlinkAnchor)
{
this.hyperlinkAnchor = hyperlinkAnchor;
}
/**
*
*/
public Integer getHyperlinkPage()
{
return this.hyperlinkPage;
}
/**
*
*/
public void setHyperlinkPage(Integer hyperlinkPage)
{
this.hyperlinkPage = hyperlinkPage;
}
public int getBookmarkLevel()
{
return bookmarkLevel;
}
public void setBookmarkLevel(int bookmarkLevel)
{
this.bookmarkLevel = bookmarkLevel;
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public byte getBorder()
{
return getBox().getBorder();
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public Byte getOwnBorder()
{
return getBox().getOwnBorder();
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public void setBorder(byte border)
{
getBox().setBorder(border);
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public void setBorder(Byte border)
{
getBox().setBorder(border);
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public Color getBorderColor()
{
return getBox().getBorderColor();
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public Color getOwnBorderColor()
{
return getBox().getOwnBorderColor();
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public void setBorderColor(Color borderColor)
{
getBox().setBorderColor(borderColor);
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public int getPadding()
{
return getBox().getPadding();
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public Integer getOwnPadding()
{
return getBox().getOwnPadding();
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public void setPadding(int padding)
{
getBox().setPadding(padding);
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public void setPadding(Integer padding)
{
getBox().setPadding(padding);
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public byte getTopBorder()
{
return getBox().getTopBorder();
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public Byte getOwnTopBorder()
{
return getBox().getOwnTopBorder();
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public void setTopBorder(byte topBorder)
{
getBox().setTopBorder(topBorder);
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public void setTopBorder(Byte topBorder)
{
getBox().setTopBorder(topBorder);
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public Color getTopBorderColor()
{
return getBox().getTopBorderColor();
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public Color getOwnTopBorderColor()
{
return getBox().getOwnTopBorderColor();
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public void setTopBorderColor(Color topBorderColor)
{
getBox().setTopBorderColor(topBorderColor);
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public int getTopPadding()
{
return getBox().getTopPadding();
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public Integer getOwnTopPadding()
{
return getBox().getOwnTopPadding();
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public void setTopPadding(int topPadding)
{
getBox().setTopPadding(topPadding);
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public void setTopPadding(Integer topPadding)
{
getBox().setTopPadding(topPadding);
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public byte getLeftBorder()
{
return getBox().getLeftBorder();
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public Byte getOwnLeftBorder()
{
return getBox().getOwnLeftBorder();
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public void setLeftBorder(byte leftBorder)
{
getBox().setLeftBorder(leftBorder);
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public void setLeftBorder(Byte leftBorder)
{
getBox().setLeftBorder(leftBorder);
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public Color getLeftBorderColor()
{
return getBox().getLeftBorderColor();
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public Color getOwnLeftBorderColor()
{
return getBox().getOwnLeftBorderColor();
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public void setLeftBorderColor(Color leftBorderColor)
{
getBox().setLeftBorderColor(leftBorderColor);
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public int getLeftPadding()
{
return getBox().getLeftPadding();
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public Integer getOwnLeftPadding()
{
return getBox().getOwnLeftPadding();
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public void setLeftPadding(int leftPadding)
{
getBox().setLeftPadding(leftPadding);
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public void setLeftPadding(Integer leftPadding)
{
getBox().setLeftPadding(leftPadding);
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public byte getBottomBorder()
{
return getBox().getBottomBorder();
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public Byte getOwnBottomBorder()
{
return getBox().getOwnBottomBorder();
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public void setBottomBorder(byte bottomBorder)
{
getBox().setBottomBorder(bottomBorder);
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public void setBottomBorder(Byte bottomBorder)
{
getBox().setBottomBorder(bottomBorder);
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public Color getBottomBorderColor()
{
return getBox().getBottomBorderColor();
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public Color getOwnBottomBorderColor()
{
return getBox().getOwnBottomBorderColor();
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public void setBottomBorderColor(Color bottomBorderColor)
{
getBox().setBottomBorderColor(bottomBorderColor);
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public int getBottomPadding()
{
return getBox().getBottomPadding();
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public Integer getOwnBottomPadding()
{
return getBox().getOwnBottomPadding();
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public void setBottomPadding(int bottomPadding)
{
getBox().setBottomPadding(bottomPadding);
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public void setBottomPadding(Integer bottomPadding)
{
getBox().setBottomPadding(bottomPadding);
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public byte getRightBorder()
{
return getBox().getRightBorder();
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public Byte getOwnRightBorder()
{
return getBox().getOwnRightBorder();
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public void setRightBorder(byte rightBorder)
{
getBox().setRightBorder(rightBorder);
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public void setRightBorder(Byte rightBorder)
{
getBox().setRightBorder(rightBorder);
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public Color getRightBorderColor()
{
return getBox().getRightBorderColor();
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public Color getOwnRightBorderColor()
{
return getBox().getOwnRightBorderColor();
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public void setRightBorderColor(Color rightBorderColor)
{
getBox().setRightBorderColor(rightBorderColor);
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public int getRightPadding()
{
return getBox().getRightPadding();
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public Integer getOwnRightPadding()
{
return getBox().getOwnRightPadding();
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public void setRightPadding(int rightPadding)
{
getBox().setRightPadding(rightPadding);
}
/**
* @deprecated Replaced by {@link #getBox()}
*/
public void setRightPadding(Integer rightPadding)
{
getBox().setRightPadding(rightPadding);
}
public JRPrintHyperlinkParameters getHyperlinkParameters()
{
return hyperlinkParameters;
}
public void setHyperlinkParameters(JRPrintHyperlinkParameters parameters)
{
this.hyperlinkParameters = parameters;
}
public String getLinkType()
{
return ((JRTemplateImage) this.template).getLinkType();
}
public void setLinkType(String type)
{
}
public String getLinkTarget()
{
return ((JRTemplateImage) this.template).getLinkTarget();
}
public void setLinkTarget(String target)
{
}
public String getHyperlinkTooltip()
{
return hyperlinkTooltip;
}
public void setHyperlinkTooltip(String hyperlinkTooltip)
{
this.hyperlinkTooltip = hyperlinkTooltip;
}
public <T> void accept(PrintElementVisitor<T> visitor, T arg)
{
visitor.visit(this, arg);
}
}