当前位置: 首页>>代码示例>>Java>>正文


Java Font.BOLDWEIGHT_BOLD属性代码示例

本文整理汇总了Java中org.apache.poi.ss.usermodel.Font.BOLDWEIGHT_BOLD属性的典型用法代码示例。如果您正苦于以下问题:Java Font.BOLDWEIGHT_BOLD属性的具体用法?Java Font.BOLDWEIGHT_BOLD怎么用?Java Font.BOLDWEIGHT_BOLD使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.poi.ss.usermodel.Font的用法示例。


在下文中一共展示了Font.BOLDWEIGHT_BOLD属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fontStyle

private void fontStyle(Font font) {
    if (font.getBoldweight() >= Font.BOLDWEIGHT_BOLD)
        out.format("  font-weight: bold;%n");
    if (font.getItalic())
        out.format("  font-style: italic;%n");
    out.format("  font-family: %s;%n", font.getFontName());

    int fontheight = font.getFontHeightInPoints();
    if (fontheight == 9) {
        fontheight = 10;
    }
    out.format("  font-size: %dpt;%n", fontheight);
    helper.styleColor(out, "color", getColor(font));
}
 
开发者ID:rushingpig,项目名称:poix,代码行数:14,代码来源:StylerHelper.java

示例2: poiFontWeightFromBirt

/**
 * Object a POI font weight from a BIRT string.
 * @param fontWeight
 * The font weight as understood by BIRT.
 * @return
 * One of the Font.BOLDWEIGHT_* constants.
 */
public short poiFontWeightFromBirt(String fontWeight) {
	if(fontWeight == null) {
		return 0;
	}
	if("bold".equals(fontWeight)) {
		return Font.BOLDWEIGHT_BOLD;
	}
	return Font.BOLDWEIGHT_NORMAL;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:16,代码来源:StyleManagerUtils.java

示例3: poiStyle2Netxilia

public static Styles poiStyle2Netxilia(CellStyle poiStyle, Font font, HSSFPalette palette,
		NetxiliaStyleResolver styleResolver) {
	List<Style> entries = new ArrayList<Style>();

	if (!poiStyle.getWrapText()) {
		entries.add(DefaultStyle.nowrap.getStyle());
	}
	// font
	if (font.getItalic()) {
		entries.add(DefaultStyle.italic.getStyle());
	}
	if (font.getStrikeout()) {
		entries.add(DefaultStyle.strikeout.getStyle());
	}
	if (font.getBoldweight() == Font.BOLDWEIGHT_BOLD) {
		entries.add(DefaultStyle.bold.getStyle());
	}
	if (font.getUnderline() != Font.U_NONE) {
		entries.add(DefaultStyle.underline.getStyle());
	}
	// borders
	if (poiStyle.getBorderBottom() != CellStyle.BORDER_NONE) {
		entries.add(DefaultStyle.borderBottom.getStyle());
	}
	if (poiStyle.getBorderLeft() != CellStyle.BORDER_NONE) {
		entries.add(DefaultStyle.borderLeft.getStyle());
	}
	if (poiStyle.getBorderTop() != CellStyle.BORDER_NONE) {
		entries.add(DefaultStyle.borderTop.getStyle());
	}
	if (poiStyle.getBorderRight() != CellStyle.BORDER_NONE) {
		entries.add(DefaultStyle.borderRight.getStyle());
	}
	// align
	switch (poiStyle.getAlignment()) {
	case CellStyle.ALIGN_LEFT:
		entries.add(DefaultStyle.alignLeft.getStyle());
		break;
	case CellStyle.ALIGN_RIGHT:
		entries.add(DefaultStyle.alignRight.getStyle());
		break;
	case CellStyle.ALIGN_CENTER:
		entries.add(DefaultStyle.alignCenter.getStyle());
		break;
	case CellStyle.ALIGN_JUSTIFY:
		entries.add(DefaultStyle.alignJustify.getStyle());
		break;
	}
	if (font != null && font.getColor() != 0) {
		HSSFColor poiForeground = palette.getColor(font.getColor());
		if (poiForeground != null && poiForeground != HSSFColor.AUTOMATIC.getInstance()) {
			Style foregroundDef = styleResolver.approximateForeground(poiForeground.getTriplet()[0],
					poiForeground.getTriplet()[1], poiForeground.getTriplet()[2]);
			if (foregroundDef != null) {
				entries.add(foregroundDef);
			}
		}
	}

	if (poiStyle.getFillForegroundColor() != 0) {
		HSSFColor poiBackground = palette.getColor(poiStyle.getFillForegroundColor());
		if (poiBackground != null && poiBackground != HSSFColor.AUTOMATIC.getInstance()) {
			Style backgroundDef = styleResolver.approximateBackground(poiBackground.getTriplet()[0],
					poiBackground.getTriplet()[1], poiBackground.getTriplet()[2]);
			if (backgroundDef != null) {
				entries.add(backgroundDef);
			}
		}
	}
	return entries.size() > 0 ? Styles.styles(entries) : null;
}
 
开发者ID:netxilia,项目名称:netxilia,代码行数:71,代码来源:PoiUtils.java

示例4: netxiliaStyle2Poi

public static CellStyle netxiliaStyle2Poi(Styles nxStyle, Workbook workbook, CellStyle poiStyle) {
	if (nxStyle == null) {
		return poiStyle;
	}
	poiStyle.setWrapText(nxStyle.contains(DefaultStyle.nowrap.getStyle()));

	// font
	short bold = nxStyle.contains(DefaultStyle.bold.getStyle()) ? Font.BOLDWEIGHT_BOLD : Font.BOLDWEIGHT_NORMAL;
	byte underline = nxStyle.contains(DefaultStyle.underline.getStyle()) ? Font.U_SINGLE : Font.U_NONE;
	boolean italic = nxStyle.contains(DefaultStyle.italic.getStyle());
	boolean strikeout = nxStyle.contains(DefaultStyle.strikeout.getStyle());
	Font defaultFont = workbook.getFontAt(poiStyle.getFontIndex());
	Font font = workbook.findFont(bold, defaultFont.getColor(), defaultFont.getFontHeight(),
			defaultFont.getFontName(), italic, strikeout, defaultFont.getTypeOffset(), underline);
	if (font == null) {
		font = workbook.createFont();
		font.setBoldweight(bold);
		font.setItalic(italic);
		font.setUnderline(underline);
		font.setStrikeout(strikeout);
	}
	poiStyle.setFont(font);

	// borders
	if (nxStyle.contains(DefaultStyle.borderLeft.getStyle())) {
		poiStyle.setBorderLeft(CellStyle.BORDER_THIN);
	}
	if (nxStyle.contains(DefaultStyle.borderRight.getStyle())) {
		poiStyle.setBorderRight(CellStyle.BORDER_THIN);
	}
	if (nxStyle.contains(DefaultStyle.borderTop.getStyle())) {
		poiStyle.setBorderTop(CellStyle.BORDER_THIN);
	}
	if (nxStyle.contains(DefaultStyle.borderBottom.getStyle())) {
		poiStyle.setBorderBottom(CellStyle.BORDER_THIN);
	}

	// align
	if (nxStyle.contains(DefaultStyle.alignLeft.getStyle())) {
		poiStyle.setAlignment(CellStyle.ALIGN_LEFT);
	} else if (nxStyle.contains(DefaultStyle.alignRight.getStyle())) {
		poiStyle.setAlignment(CellStyle.ALIGN_RIGHT);
	} else if (nxStyle.contains(DefaultStyle.alignCenter.getStyle())) {
		poiStyle.setAlignment(CellStyle.ALIGN_CENTER);
	} else if (nxStyle.contains(DefaultStyle.alignJustify.getStyle())) {
		poiStyle.setAlignment(CellStyle.ALIGN_JUSTIFY);
	}

	return poiStyle;
}
 
开发者ID:netxilia,项目名称:netxilia,代码行数:50,代码来源:PoiUtils.java

示例5: decorateComponent

public static void decorateComponent(Cell cell, JComponent renderingComponent, JComponent defaultRenderer) {
    CellStyle style = cell.getCellStyle();

    // Background neither the index or the color works for XSSF cells
    Color backgroundColor = CellUtils.poiToAwtColor(style.getFillBackgroundColorColor());
    if (backgroundColor != null) {
        renderingComponent.setBackground(backgroundColor);
    } else {
        renderingComponent.setBackground(defaultRenderer.getBackground());
    }

    // Font and forground
    short fontIndex = style.getFontIndex();
    if (fontIndex > 0) {
        Font xlsFont = cell.getSheet().getWorkbook().getFontAt(fontIndex);
        java.awt.Font font = java.awt.Font.decode(xlsFont.getFontName());
        font = font.deriveFont((float) xlsFont.getFontHeightInPoints());
        font = font.deriveFont(java.awt.Font.PLAIN);
        if (xlsFont.getItalic()) {
            font = font.deriveFont(java.awt.Font.ITALIC);
        }
        if (xlsFont.getBoldweight() == Font.BOLDWEIGHT_BOLD) {
            font = font.deriveFont(java.awt.Font.BOLD);
        }
        if (xlsFont.getUnderline() > Font.U_NONE) {
            // no underline in fonts
        }
        short fontColorIndex = xlsFont.getColor();
        Color fontColor = CellUtils.shortToColor(fontColorIndex);
        if (fontColor != null) {
            renderingComponent.setForeground(fontColor);
        } else {
            renderingComponent.setForeground(defaultRenderer.getForeground());
        }
        renderingComponent.setFont(font);
    } else {
        renderingComponent.setForeground(defaultRenderer.getForeground());
        renderingComponent.setFont(defaultRenderer.getFont());
    }

    // Borders
    // At the moment done in renderer but should be done with a JLayer to paint over the grid
    renderingComponent.setBorder(new CellBorder(cell));

    if (cell.getCellComment() != null) {
        renderingComponent.setToolTipText(cell.getCellComment().getString().getString());
    }
}
 
开发者ID:foxerfly,项目名称:Joeffice,代码行数:48,代码来源:CellRenderer.java

示例6: addFontAttributes

/**
 * Add font details to an AttributedString.
 * @param attrString
 * The AttributedString to modify.
 * @param font
 * The font to take attributes from.
 * @param startIdx
 * The index of the first character to be attributed (inclusive).
 * @param endIdx
 * The index of the last character to be attributed (inclusive). 
 */
protected void addFontAttributes( AttributedString attrString, Font font, int startIdx, int endIdx) {
	attrString.addAttribute(TextAttribute.FAMILY, font.getFontName(), startIdx, endIdx);
	attrString.addAttribute(TextAttribute.SIZE, (float)font.getFontHeightInPoints(), startIdx, endIdx);
       if (font.getBoldweight() == Font.BOLDWEIGHT_BOLD) attrString.addAttribute(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD, startIdx, endIdx);
       if (font.getItalic() ) attrString.addAttribute(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE, startIdx, endIdx);
       if (font.getUnderline() == Font.U_SINGLE ) attrString.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON, startIdx, endIdx);
}
 
开发者ID:eclipse,项目名称:birt,代码行数:18,代码来源:StyleManagerUtils.java


注:本文中的org.apache.poi.ss.usermodel.Font.BOLDWEIGHT_BOLD属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。