本文整理匯總了Java中com.lowagie.text.Element.ALIGN_LEFT屬性的典型用法代碼示例。如果您正苦於以下問題:Java Element.ALIGN_LEFT屬性的具體用法?Java Element.ALIGN_LEFT怎麽用?Java Element.ALIGN_LEFT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類com.lowagie.text.Element
的用法示例。
在下文中一共展示了Element.ALIGN_LEFT屬性的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: drawLine
/**
* Draws a horizontal line.
* @param canvas the canvas to draw on
* @param leftX the left x coordinate
* @param rightX the right x coordindate
* @param y the y coordinate
*/
public void drawLine(PdfContentByte canvas, float leftX, float rightX, float y) {
float w;
if (getPercentage() < 0)
w = -getPercentage();
else
w = (rightX - leftX) * getPercentage() / 100.0f;
float s;
switch (getAlignment()) {
case Element.ALIGN_LEFT:
s = 0;
break;
case Element.ALIGN_RIGHT:
s = rightX - leftX - w;
break;
default:
s = (rightX - leftX - w) / 2;
break;
}
canvas.setLineWidth(getLineWidth());
if (getLineColor() != null)
canvas.setColorStroke(getLineColor());
canvas.moveTo(s + leftX, y + offset);
canvas.lineTo(s + w + leftX, y + offset);
canvas.stroke();
}
示例2: indentLeft
/**
* Returns the left indentation of the line taking the alignment of the line into account.
*
* @return a value
*/
float indentLeft() {
if (isRTL) {
switch (alignment) {
case Element.ALIGN_LEFT:
return left + width;
case Element.ALIGN_CENTER:
return left + (width / 2f);
default:
return left;
}
}
else if (this.getSeparatorCount() == 0) {
switch (alignment) {
case Element.ALIGN_RIGHT:
return left + width;
case Element.ALIGN_CENTER:
return left + (width / 2f);
}
}
return left;
}
示例3: setToDefaults
public void setToDefaults() {
styleName = "";
styleNr = 0;
alignment = Element.ALIGN_LEFT;
justificationPercentage = 0;
firstLineIndent = 0;
leftIndent = 0;
rightIndent = 0;
adustRightIndent = 0;
mirrorIndent = 0;
overrideWidowControl = -1;
AutoSpaceBetweenDBCEnglish = 0;
AutoSpaceBetweenDBCNumbers = 0;
noCharacterWrapping = 0;
noWordWrapping = 0;
noOverflowPeriodComma = 0;
}
示例4: getAlignment
/**
* Translates the alignment value.
*
* @param alignment the alignment value
* @return the translated value
*/
public static String getAlignment(int alignment) {
switch(alignment) {
case Element.ALIGN_LEFT:
return HtmlTags.ALIGN_LEFT;
case Element.ALIGN_CENTER:
return HtmlTags.ALIGN_CENTER;
case Element.ALIGN_RIGHT:
return HtmlTags.ALIGN_RIGHT;
case Element.ALIGN_JUSTIFIED:
case Element.ALIGN_JUSTIFIED_ALL:
return HtmlTags.ALIGN_JUSTIFIED;
case Element.ALIGN_TOP:
return HtmlTags.ALIGN_TOP;
case Element.ALIGN_MIDDLE:
return HtmlTags.ALIGN_MIDDLE;
case Element.ALIGN_BOTTOM:
return HtmlTags.ALIGN_BOTTOM;
case Element.ALIGN_BASELINE:
return HtmlTags.ALIGN_BASELINE;
default:
return "";
}
}
示例5: resetAlignment
/**
* Resets the alignment of this line.
* <P>
* The alignment of the last line of for instance a <CODE>Paragraph</CODE>
* that has to be justified, has to be reset to <VAR>ALIGN_LEFT</VAR>.
*/
public void resetAlignment() {
if (alignment == Element.ALIGN_JUSTIFIED) {
alignment = Element.ALIGN_LEFT;
}
}
示例6: writeListBeginning
/**
* Writes the initialization part of the RtfList
*
* @param result The <code>OutputStream</code> to write to
* @throws IOException On i/o errors.
*/
public void writeListBeginning(final OutputStream result) throws IOException {
result.write(RtfParagraph.PARAGRAPH_DEFAULTS);
if(this.inTable) {
result.write(RtfParagraph.IN_TABLE);
}
switch (this.alignment) {
case Element.ALIGN_LEFT:
result.write(RtfParagraphStyle.ALIGN_LEFT);
break;
case Element.ALIGN_RIGHT:
result.write(RtfParagraphStyle.ALIGN_RIGHT);
break;
case Element.ALIGN_CENTER:
result.write(RtfParagraphStyle.ALIGN_CENTER);
break;
case Element.ALIGN_JUSTIFIED:
case Element.ALIGN_JUSTIFIED_ALL:
result.write(RtfParagraphStyle.ALIGN_JUSTIFY);
break;
}
writeIndentation(result);
result.write(RtfFont.FONT_SIZE);
result.write(intToByteArray(fontNumber.getFontSize() * 2));
if(this.symbolIndent > 0) {
result.write(LIST_LEVEL_SYMBOL_INDENT);
result.write(intToByteArray(this.leftIndent));
}
}
示例7: showTextAligned
/**
* Shows a line of text. Only the first line is written.
*
* @param canvas where the text is to be written to
* @param alignment the alignment. It is not influenced by the run direction
* @param phrase the <CODE>Phrase</CODE> with the text
* @param x the x reference position
* @param y the y reference position
* @param rotation the rotation to be applied in degrees counterclockwise
* @param runDirection the run direction
* @param arabicOptions the options for the arabic shaping
*/
public static void showTextAligned(PdfContentByte canvas, int alignment, Phrase phrase, float x, float y, float rotation, int runDirection, int arabicOptions) {
if (alignment != Element.ALIGN_LEFT && alignment != Element.ALIGN_CENTER
&& alignment != Element.ALIGN_RIGHT)
alignment = Element.ALIGN_LEFT;
canvas.saveState();
ColumnText ct = new ColumnText(canvas);
float lly = -1;
float ury = 2;
float llx;
float urx;
switch (alignment) {
case Element.ALIGN_LEFT:
llx = 0;
urx = 20000;
break;
case Element.ALIGN_RIGHT:
llx = -20000;
urx = 0;
break;
default:
llx = -20000;
urx = 20000;
break;
}
if (rotation == 0) {
llx += x;
lly += y;
urx += x;
ury += y;
}
else {
double alpha = rotation * Math.PI / 180.0;
float cos = (float)Math.cos(alpha);
float sin = (float)Math.sin(alpha);
canvas.concatCTM(cos, sin, -sin, cos, x, y);
}
ct.setSimpleColumn(phrase, llx, lly, urx, ury, 2, alignment);
if (runDirection == PdfWriter.RUN_DIRECTION_RTL) {
if (alignment == Element.ALIGN_LEFT)
alignment = Element.ALIGN_RIGHT;
else if (alignment == Element.ALIGN_RIGHT)
alignment = Element.ALIGN_LEFT;
}
ct.setAlignment(alignment);
ct.setArabicOptions(arabicOptions);
ct.setRunDirection(runDirection);
try {
ct.go();
}
catch (DocumentException e) {
throw new ExceptionConverter(e);
}
canvas.restoreState();
}
示例8: writeParagraphSettings
/**
* Writes the settings of this RtfParagraphStyle.
*
* @param result The <code>OutputStream</code> to write to.
* @throws IOException On i/o errors.
*/
private void writeParagraphSettings(final OutputStream result) throws IOException {
if(this.keepTogether) {
result.write(RtfParagraphStyle.KEEP_TOGETHER);
}
if(this.keepTogetherWithNext) {
result.write(RtfParagraphStyle.KEEP_TOGETHER_WITH_NEXT);
}
switch (alignment) {
case Element.ALIGN_LEFT:
result.write(RtfParagraphStyle.ALIGN_LEFT);
break;
case Element.ALIGN_RIGHT:
result.write(RtfParagraphStyle.ALIGN_RIGHT);
break;
case Element.ALIGN_CENTER:
result.write(RtfParagraphStyle.ALIGN_CENTER);
break;
case Element.ALIGN_JUSTIFIED:
case Element.ALIGN_JUSTIFIED_ALL:
result.write(RtfParagraphStyle.ALIGN_JUSTIFY);
break;
}
result.write(FIRST_LINE_INDENT);
result.write(intToByteArray(this.firstLineIndent));
result.write(RtfParagraphStyle.INDENT_LEFT);
result.write(intToByteArray(indentLeft));
result.write(RtfParagraphStyle.INDENT_RIGHT);
result.write(intToByteArray(indentRight));
if(this.spacingBefore > 0) {
result.write(RtfParagraphStyle.SPACING_BEFORE);
result.write(intToByteArray(this.spacingBefore));
}
if(this.spacingAfter > 0) {
result.write(RtfParagraphStyle.SPACING_AFTER);
result.write(intToByteArray(this.spacingAfter));
}
if(this.lineLeading > 0) {
result.write(RtfParagraph.LINE_SPACING);
result.write(intToByteArray(this.lineLeading));
}
}
示例9: writeRowDefinition
/**
* Writes the row definition/settings.
*
* @param result The <code>OutputStream</code> to write the definitions to.
*/
private void writeRowDefinition(final OutputStream result) throws IOException {
result.write(ROW_BEGIN);
this.document.outputDebugLinebreak(result);
result.write(ROW_WIDTH_STYLE);
result.write(ROW_WIDTH);
result.write(intToByteArray(this.width));
if(this.parentTable.getCellsFitToPage()) {
result.write(ROW_KEEP_TOGETHER);
}
if(this.rowNumber <= this.parentTable.getHeaderRows()) {
result.write(ROW_HEADER_ROW);
}
switch (this.parentTable.getAlignment()) {
case Element.ALIGN_LEFT:
result.write(ROW_ALIGN_LEFT);
break;
case Element.ALIGN_RIGHT:
result.write(ROW_ALIGN_RIGHT);
break;
case Element.ALIGN_CENTER:
result.write(ROW_ALIGN_CENTER);
break;
case Element.ALIGN_JUSTIFIED:
case Element.ALIGN_JUSTIFIED_ALL:
result.write(ROW_ALIGN_JUSTIFIED);
break;
}
result.write(ROW_GRAPH);
RtfBorderGroup borders =this.parentTable.getBorders();
if(borders != null) {
borders.writeContent(result);
}
if(this.parentTable.getCellSpacing() > 0) {
result.write(ROW_CELL_SPACING_LEFT);
result.write(intToByteArray((int) (this.parentTable.getCellSpacing() / 2)));
result.write(ROW_CELL_SPACING_LEFT_STYLE);
result.write(ROW_CELL_SPACING_TOP);
result.write(intToByteArray((int) (this.parentTable.getCellSpacing() / 2)));
result.write(ROW_CELL_SPACING_TOP_STYLE);
result.write(ROW_CELL_SPACING_RIGHT);
result.write(intToByteArray((int) (this.parentTable.getCellSpacing() / 2)));
result.write(ROW_CELL_SPACING_RIGHT_STYLE);
result.write(ROW_CELL_SPACING_BOTTOM);
result.write(intToByteArray((int) (this.parentTable.getCellSpacing() / 2)));
result.write(ROW_CELL_SPACING_BOTTOM_STYLE);
}
result.write(ROW_CELL_PADDING_LEFT);
result.write(intToByteArray((int) (this.parentTable.getCellPadding() / 2)));
result.write(ROW_CELL_PADDING_RIGHT);
result.write(intToByteArray((int) (this.parentTable.getCellPadding() / 2)));
result.write(ROW_CELL_PADDING_LEFT_STYLE);
result.write(ROW_CELL_PADDING_RIGHT_STYLE);
this.document.outputDebugLinebreak(result);
for(int i = 0; i < this.cells.size(); i++) {
RtfCell rtfCell = (RtfCell) this.cells.get(i);
rtfCell.writeDefinition(result);
}
}
示例10: initialize
/**
*
*/
public void initialize(
JRPdfExporter pdfExporter,
PdfContentByte pdfContentByte,
JRPrintText text, JRStyledText styledText,
int offsetX,
int offsetY
)
{
this.pdfExporter = pdfExporter;
this.pdfContentByte = pdfContentByte;
horizontalAlignment = Element.ALIGN_LEFT;
leftOffsetFactor = 0f;
rightOffsetFactor = 0f;
//FIXMETAB 0.2f was a fair approximation
switch (text.getHorizontalTextAlign())
{
case JUSTIFIED :
{
horizontalAlignment = Element.ALIGN_JUSTIFIED_ALL;
leftOffsetFactor = 0f;
rightOffsetFactor = 0f;
break;
}
case RIGHT :
{
if (text.getRunDirectionValue() == RunDirectionEnum.LTR)
{
horizontalAlignment = Element.ALIGN_RIGHT;
}
else
{
horizontalAlignment = Element.ALIGN_LEFT;
}
leftOffsetFactor = -0.2f;
rightOffsetFactor = 0f;
break;
}
case CENTER :
{
horizontalAlignment = Element.ALIGN_CENTER;
leftOffsetFactor = -0.1f;
rightOffsetFactor = 0.1f;
break;
}
case LEFT :
default :
{
if (text.getRunDirectionValue() == RunDirectionEnum.LTR)
{
horizontalAlignment = Element.ALIGN_LEFT;
}
else
{
horizontalAlignment = Element.ALIGN_RIGHT;
}
leftOffsetFactor = 0f;
rightOffsetFactor = 0.2f;
break;
}
}
super.initialize(text, styledText, offsetX, offsetY);
}