當前位置: 首頁>>代碼示例>>Java>>正文


Java Element.ALIGN_CENTER屬性代碼示例

本文整理匯總了Java中com.lowagie.text.Element.ALIGN_CENTER屬性的典型用法代碼示例。如果您正苦於以下問題:Java Element.ALIGN_CENTER屬性的具體用法?Java Element.ALIGN_CENTER怎麽用?Java Element.ALIGN_CENTER使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在com.lowagie.text.Element的用法示例。


在下文中一共展示了Element.ALIGN_CENTER屬性的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: Barcode39

/** Creates a new Barcode39.
 */    
public Barcode39() {
    try {
        x = 0.8f;
        n = 2;
        font = BaseFont.createFont("Helvetica", "winansi", false);
        size = 8;
        baseline = size;
        barHeight = size * 3;
        textAlignment = Element.ALIGN_CENTER;
        generateChecksum = false;
        checksumText = false;
        startStopText = true;
        extended = false;
    }
    catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:20,代碼來源:Barcode39.java

示例2: BarcodeInter25

/** Creates new BarcodeInter25 */
public BarcodeInter25() {
    try {
        x = 0.8f;
        n = 2;
        font = BaseFont.createFont("Helvetica", "winansi", false);
        size = 8;
        baseline = size;
        barHeight = size * 3;
        textAlignment = Element.ALIGN_CENTER;
        generateChecksum = false;
        checksumText = false;
    }
    catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:17,代碼來源:BarcodeInter25.java

示例3: BarcodeCodabar

/** Creates a new BarcodeCodabar.
 */    
public BarcodeCodabar() {
    try {
        x = 0.8f;
        n = 2;
        font = BaseFont.createFont("Helvetica", "winansi", false);
        size = 8;
        baseline = size;
        barHeight = size * 3;
        textAlignment = Element.ALIGN_CENTER;
        generateChecksum = false;
        checksumText = false;
        startStopText = false;
        codeType = CODABAR;
    }
    catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:20,代碼來源:BarcodeCodabar.java

示例4: 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;
}
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:27,代碼來源:PdfLine.java

示例5: 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 "";
       }
   }
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:30,代碼來源:HtmlEncoder.java

示例6: Barcode128

/** Creates new Barcode128 */
public Barcode128() {
    try {
        x = 0.8f;
        font = BaseFont.createFont("Helvetica", "winansi", false);
        size = 8;
        baseline = size;
        barHeight = size * 3;
        textAlignment = Element.ALIGN_CENTER;
        codeType = CODE128;
    }
    catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:15,代碼來源:Barcode128.java

示例7: 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));
    }
}
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:34,代碼來源:RtfListLevel.java

示例8: 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();
}
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:66,代碼來源:ColumnText.java

示例9: getTextField

/**
 * Gets a new text field.
 * @throws IOException on error
 * @throws DocumentException on error
 * @return a new text field
 */    
public PdfFormField getTextField() throws IOException, DocumentException {
    if (maxCharacterLength <= 0)
        options &= ~COMB;
    if ((options & COMB) != 0)
        options &= ~MULTILINE;
    PdfFormField field = PdfFormField.createTextField(writer, false, false, maxCharacterLength);
    field.setWidget(box, PdfAnnotation.HIGHLIGHT_INVERT);
    switch (alignment) {
        case Element.ALIGN_CENTER:
            field.setQuadding(PdfFormField.Q_CENTER);
            break;
        case Element.ALIGN_RIGHT:
            field.setQuadding(PdfFormField.Q_RIGHT);
            break;
    }
    if (rotation != 0)
        field.setMKRotation(rotation);
    if (fieldName != null) {
        field.setFieldName(fieldName);
        if (!"".equals(text))
        	field.setValueAsString(text);
        if (defaultText != null)
            field.setDefaultValueAsString(defaultText);
        if ((options & READ_ONLY) != 0)
            field.setFieldFlags(PdfFormField.FF_READ_ONLY);
        if ((options & REQUIRED) != 0)
            field.setFieldFlags(PdfFormField.FF_REQUIRED);
        if ((options & MULTILINE) != 0)
            field.setFieldFlags(PdfFormField.FF_MULTILINE);
        if ((options & DO_NOT_SCROLL) != 0)
            field.setFieldFlags(PdfFormField.FF_DONOTSCROLL);
        if ((options & PASSWORD) != 0)
            field.setFieldFlags(PdfFormField.FF_PASSWORD);
        if ((options & FILE_SELECTION) != 0)
            field.setFieldFlags(PdfFormField.FF_FILESELECT);
        if ((options & DO_NOT_SPELL_CHECK) != 0)
            field.setFieldFlags(PdfFormField.FF_DONOTSPELLCHECK);
        if ((options & COMB) != 0)
            field.setFieldFlags(PdfFormField.FF_COMB);
    }
    field.setBorderStyle(new PdfBorderDictionary(borderWidth, borderStyle, new PdfDashPattern(3)));
    PdfAppearance tp = getAppearance();
    field.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, tp);
    PdfAppearance da = (PdfAppearance)tp.getDuplicate();
    da.setFontAndSize(getRealFont(), fontSize);
    if (textColor == null)
        da.setGrayFill(0);
    else
        da.setColorFill(textColor);
    field.setDefaultAppearanceString(da);
    if (borderColor != null)
        field.setMKBorderColor(borderColor);
    if (backgroundColor != null)
        field.setMKBackgroundColor(backgroundColor);
    switch (visibility) {
        case HIDDEN:
            field.setFlags(PdfAnnotation.FLAGS_PRINT | PdfAnnotation.FLAGS_HIDDEN);
            break;
        case VISIBLE_BUT_DOES_NOT_PRINT:
            break;
        case HIDDEN_BUT_PRINTABLE:
            field.setFlags(PdfAnnotation.FLAGS_PRINT | PdfAnnotation.FLAGS_NOVIEW);
            break;
        default:
            field.setFlags(PdfAnnotation.FLAGS_PRINT);
            break;
    }
    return field;
}
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:75,代碼來源:TextField.java

示例10: 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));
    }            
}
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:47,代碼來源:RtfParagraphStyle.java

示例11: writeDefinition

/**
* Write the cell definition part of this RtfCell
*/
  public void writeDefinition(final OutputStream result) throws IOException 
  {
      if(this.mergeType == MERGE_VERT_PARENT) {
          result.write(DocWriter.getISOBytes("\\clvmgf"));
      } else if(this.mergeType == MERGE_VERT_CHILD) {
          result.write(DocWriter.getISOBytes("\\clvmrg"));
      }
      switch (verticalAlignment) {
          case Element.ALIGN_BOTTOM:
              result.write(DocWriter.getISOBytes("\\clvertalb"));
              break;
          case Element.ALIGN_CENTER:
          case Element.ALIGN_MIDDLE:
              result.write(DocWriter.getISOBytes("\\clvertalc"));
              break;
          case Element.ALIGN_TOP:
              result.write(DocWriter.getISOBytes("\\clvertalt"));
              break;
      }
      this.borders.writeContent(result);

      if(this.backgroundColor != null) {
          result.write(DocWriter.getISOBytes("\\clcbpat"));
          result.write(intToByteArray(this.backgroundColor.getColorNumber()));
      }
      this.document.outputDebugLinebreak(result);
      
      result.write(DocWriter.getISOBytes("\\clftsWidth3"));
      this.document.outputDebugLinebreak(result);
      
      result.write(DocWriter.getISOBytes("\\clwWidth"));
      result.write(intToByteArray(this.cellWidth));
      this.document.outputDebugLinebreak(result);
      
      if(this.cellPadding > 0) {
          result.write(DocWriter.getISOBytes("\\clpadl"));
          result.write(intToByteArray(this.cellPadding / 2));
          result.write(DocWriter.getISOBytes("\\clpadt"));
          result.write(intToByteArray(this.cellPadding / 2));
          result.write(DocWriter.getISOBytes("\\clpadr"));
          result.write(intToByteArray(this.cellPadding / 2));
          result.write(DocWriter.getISOBytes("\\clpadb"));
          result.write(intToByteArray(this.cellPadding / 2));
          result.write(DocWriter.getISOBytes("\\clpadfl3"));
          result.write(DocWriter.getISOBytes("\\clpadft3"));
          result.write(DocWriter.getISOBytes("\\clpadfr3"));
          result.write(DocWriter.getISOBytes("\\clpadfb3"));
      }
      result.write(DocWriter.getISOBytes("\\cellx"));
      result.write(intToByteArray(this.cellRight));
  }
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:54,代碼來源:RtfCell.java

示例12: 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);
    }    	
}
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:67,代碼來源:RtfRow.java

示例13: 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);
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:68,代碼來源:AbstractPdfTextRenderer.java


注:本文中的com.lowagie.text.Element.ALIGN_CENTER屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。