Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* 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 .
*/
/*
* Contributors:
* Eugene D - [email protected]
* Adrian Jackson - [email protected]
* David Taylor - [email protected]
* Lars Kristensen - [email protected]
*/
package net.sf.jasperreports.engine.export.draw;
import java.awt.Graphics2D;
import net.sf.jasperreports.engine.JRCommonText;
import net.sf.jasperreports.engine.JRPrintText;
import net.sf.jasperreports.engine.JRStyledTextAttributeSelector;
import net.sf.jasperreports.engine.export.TextRenderer;
import net.sf.jasperreports.engine.type.ModeEnum;
import net.sf.jasperreports.engine.util.JRStyledText;
/**
* @author Teodor Danciu ([email protected])
* @version $Id: TextDrawer.java 3991 2010-10-12 20:10:55Z lucianc $
*/
public class TextDrawer extends ElementDrawer
{
/**
*
*/
protected TextRenderer textRenderer;
/**
*
*/
public TextDrawer(
TextRenderer textRenderer
)
{
this.textRenderer = textRenderer;
}
/**
*
*/
public void draw(Graphics2D grx, JRPrintText text, int offsetX, int offsetY)
{
JRStyledText styledText = getStyledText(text);
if (styledText == null)
{
return;
}
String allText = styledText.getText();
int x = text.getX() + offsetX;
int y = text.getY() + offsetY;
int width = text.getWidth();
int height = text.getHeight();
int topPadding = text.getLineBox().getTopPadding().intValue();
int leftPadding = text.getLineBox().getLeftPadding().intValue();
int bottomPadding = text.getLineBox().getBottomPadding().intValue();
int rightPadding = text.getLineBox().getRightPadding().intValue();
double angle = 0;
switch (text.getRotationValue())
{
case LEFT :
{
y = text.getY() + offsetY + text.getHeight();
width = text.getHeight();
height = text.getWidth();
int tmpPadding = topPadding;
topPadding = leftPadding;
leftPadding = bottomPadding;
bottomPadding = rightPadding;
rightPadding = tmpPadding;
angle = - Math.PI / 2;
break;
}
case RIGHT :
{
x = text.getX() + offsetX + text.getWidth();
width = text.getHeight();
height = text.getWidth();
int tmpPadding = topPadding;
topPadding = rightPadding;
rightPadding = bottomPadding;
bottomPadding = leftPadding;
leftPadding = tmpPadding;
angle = Math.PI / 2;
break;
}
case UPSIDE_DOWN :
{
int tmpPadding = topPadding;
x = text.getX() + offsetX + text.getWidth();
y = text.getY() + offsetY + text.getHeight();
topPadding = bottomPadding;
bottomPadding = tmpPadding;
tmpPadding = leftPadding;
leftPadding = rightPadding;
rightPadding = tmpPadding;
angle = Math.PI;
break;
}
case NONE :
default :
{
}
}
grx.rotate(angle, x, y);
if (text.getModeValue() == ModeEnum.OPAQUE)
{
grx.setColor(text.getBackcolor());
grx.fillRect(x, y, width, height);
}
// else
// {
// /*
// grx.setColor(text.getForecolor());
// grx.setStroke(new BasicStroke(1));
// grx.drawRect(x, y, width, height);
// */
// }
if (allText.length() > 0)
{
grx.setColor(text.getForecolor());
/* */
textRenderer.render(
grx,
x,
y,
width,
height,
topPadding,
leftPadding,
bottomPadding,
rightPadding,
text.getTextHeight(),
text.getHorizontalAlignmentValue(),
text.getVerticalAlignmentValue(),
text.getLineSpacingFactor(),
text.getLeadingOffset(),
text.getFontSize(),
!JRCommonText.MARKUP_NONE.equals(text.getMarkup()),
styledText,
allText
);
}
grx.rotate(-angle, x, y);
/* */
drawBox(grx, text.getLineBox(), text, offsetX, offsetY);
}
/**
*
*/
protected JRStyledText getStyledText(JRPrintText textElement)
{
return textElement.getStyledText(JRStyledTextAttributeSelector.NO_BACKCOLOR);
}
}