本文整理汇总了Java中org.apache.poi.ss.usermodel.Font.getBoldweight方法的典型用法代码示例。如果您正苦于以下问题:Java Font.getBoldweight方法的具体用法?Java Font.getBoldweight怎么用?Java Font.getBoldweight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.poi.ss.usermodel.Font
的用法示例。
在下文中一共展示了Font.getBoldweight方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fontStyle
import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
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));
}
示例2: findFont
import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
private static Font findFont(Workbook workbook, Font font)
{
int numFonts = workbook.getNumberOfFonts();
for (short i = 0; i < numFonts; i++)
{
Font f = workbook.getFontAt(i);
if (f.getBoldweight() == font.getBoldweight() &&
f.getItalic() == font.getItalic() &&
f.getColor() == font.getColor() &&
f.getFontHeight() == font.getFontHeight() &&
f.getUnderline() == font.getUnderline() &&
f.getFontName().equals(font.getFontName()) &&
f.getTypeOffset() == font.getTypeOffset()
)
{
if (!(font instanceof XSSFFont && f instanceof XSSFFont) ||
((XSSFFont) font).getXSSFColor().getARGBHex().equals(((XSSFFont) f).getXSSFColor().getARGBHex()))
{
if (DEBUG)
System.err.println(" Found existing, matching Font!");
return f;
}
}
}
if (DEBUG)
System.err.println(" Did NOT find existing, matching Font!");
return null;
}
示例3: poiStyle2Netxilia
import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
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;
}
示例4: findCellStyle
import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
/**
* Find a <code>CellStyle</code> with all the same attributes as the given
* <code>CellStyle</code> but with the given font index.
* @param workbook The <code>Workbook</code>.
* @param cellStyle The <code>CellStyle</code> to find.
* @param font The <code>Font</code> to find.
* @return The <code>CellStyle</code> from the <code>Workbook</code> if
* found, or <code>null</code> if not found.
*/
private static CellStyle findCellStyle(Workbook workbook, CellStyle cellStyle, Font font)
{
int numCellStyles = workbook.getNumCellStyles();
for (short i = 0; i < numCellStyles; i++)
{
CellStyle cs = workbook.getCellStyleAt(i);
Font f = workbook.getFontAt(cs.getFontIndex());
if (cs.getFillForegroundColor() == cellStyle.getFillForegroundColor() &&
cs.getFillBackgroundColor() == cellStyle.getFillBackgroundColor() &&
cs.getDataFormat() == cellStyle.getDataFormat() &&
cs.getAlignment() == cellStyle.getAlignment() &&
cs.getBorderBottom() == cellStyle.getBorderBottom() &&
cs.getBorderLeft() == cellStyle.getBorderLeft() &&
cs.getBorderRight() == cellStyle.getBorderRight() &&
cs.getBorderTop() == cellStyle.getBorderTop() &&
cs.getFillPattern() == cellStyle.getFillPattern() &&
cs.getWrapText() == cellStyle.getWrapText() &&
cs.getRotation() == cellStyle.getRotation() &&
cs.getBottomBorderColor() == cellStyle.getBottomBorderColor() &&
cs.getTopBorderColor() == cellStyle.getTopBorderColor() &&
cs.getLeftBorderColor() == cellStyle.getLeftBorderColor() &&
cs.getRightBorderColor() == cellStyle.getRightBorderColor() &&
cs.getVerticalAlignment() == cellStyle.getVerticalAlignment() &&
cs.getIndention() == cellStyle.getIndention() &&
cs.getLocked() == cellStyle.getLocked() &&
cs.getHidden() == cellStyle.getHidden() &&
f.getBoldweight() == font.getBoldweight() &&
f.getItalic() == font.getItalic() &&
f.getColor() == font.getColor() &&
f.getFontHeight() == font.getFontHeight() &&
f.getUnderline() == font.getUnderline() &&
f.getFontName().equals(font.getFontName()) &&
f.getTypeOffset() == font.getTypeOffset()
)
{
if (!(font instanceof XSSFFont && f instanceof XSSFFont) ||
((XSSFFont) font).getXSSFColor().getARGBHex().equals(((XSSFFont) f).getXSSFColor().getARGBHex()))
{
if (DEBUG)
System.err.println(" Found existing, matching CellStyle with the Font!");
return cs;
}
}
}
if (DEBUG)
System.err.println(" Did NOT find existing, matching CellStyle with the Font!");
return null;
}
示例5: decorateComponent
import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
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());
}
}
示例6: get
import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
@Override
public Object get(Column column, Cell cell, Font font) {
return (long) font.getBoldweight();
}
示例7: addFontAttributes
import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
/**
* 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);
}