本文整理汇总了Java中org.apache.poi.ss.usermodel.Font.U_NONE属性的典型用法代码示例。如果您正苦于以下问题:Java Font.U_NONE属性的具体用法?Java Font.U_NONE怎么用?Java Font.U_NONE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.poi.ss.usermodel.Font
的用法示例。
在下文中一共展示了Font.U_NONE属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPoiFont
PoiFont getPoiFont(com.dua3.utility.text.Font font, TextAttributes attributes) {
String name = String.valueOf(attributes.getOrDefault(TextAttributes.FONT_FAMILY, font.getFamily()));
Object sSize = attributes.get(TextAttributes.FONT_SIZE);
short height = (short) Math.round(sSize == null ? font.getSizeInPoints() : TextUtil.decodeFontSize(sSize.toString()));
final Object sStyle = attributes.get(TextAttributes.FONT_STYLE);
boolean italic = sStyle == null ? font.isItalic() : "italic".equals(sStyle);
final Object sWeight = attributes.get(TextAttributes.FONT_WEIGHT);
boolean bold = sWeight == null ? font.isBold() : "bold".equals(sWeight);
Object sDecoration = attributes.get(TextAttributes.TEXT_DECORATION);
boolean underline = sDecoration == null ? font.isUnderlined() : "underline".equals(sDecoration);
boolean strikethrough = sDecoration == null ? font.isStrikeThrough() : "line-through".equals(sDecoration);
Object sColor = attributes.get(TextAttributes.COLOR);
Color color = sColor == null ? font.getColor() : Color.valueOf(sColor.toString());
// try to find existing font
for (short i = 0; i < poiWorkbook.getNumberOfFonts(); i++) {
Font poiFont = poiWorkbook.getFontAt(i);
if (poiFont.getFontName().equalsIgnoreCase(name)
&& poiFont.getFontHeightInPoints() == height
&& poiFont.getBold() == bold
&& poiFont.getItalic() == italic
&& (poiFont.getUnderline() != Font.U_NONE) == underline
&& poiFont.getStrikeout() == strikethrough
&& getColor(poiFont, Color.BLACK).equals(color)
&& poiFont.getTypeOffset() == Font.SS_NONE) {
return new PoiFont(this, poiFont);
}
}
// if not found, create it
return createFont(font);
}
示例2: 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;
}
示例3: 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;
}
示例4: 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());
}
}