font.setStyle(exp);
/** * Utility method to capture the default font in one place. * * @return */ static Font createDefault(FilterFactory filterFactory) { Font font = new FontImpl(); try { font.setSize(filterFactory.literal(Integer.valueOf(10))); font.setStyle(filterFactory.literal("normal")); font.setWeight(filterFactory.literal("normal")); font.setFontFamily(filterFactory.literal("Serif")); } catch (org.geotools.filter.IllegalFilterException ife) { throw new RuntimeException("Error creating default", ife); } return font; }
@Override public void handle(YamlObject<?> obj, YamlParseContext context) { sym.setFont(font); YamlMap map = obj.map(); if (map.has("font-family")) { font.setFontFamily(Util.expression(map.str("font-family"), factory)); } if (map.has("font-size")) { font.setSize(Util.expression(map.str("font-size"), factory)); } if (map.has("font-style")) { font.setStyle(Util.expression(map.str("font-style"), factory)); } if (map.has("font-weight")) { font.setWeight(Util.expression(map.str("font-weight"), factory)); } } }
/** Revert to original. */ public void revertToOriginal() { if (this.font != null) { this.font.getFamily().clear(); this.font.getFamily().addAll(originalFontName); this.font.setWeight(originalFontWeight); this.font.setStyle(originalFontStyle); this.font.setSize(originalFontSize); } }
public class HeaderAndFooter extends PdfPageEventHelper { private Font footerFont; public HeaderAndFooter() { super(); footerFont = getFontObj(BaseColor.LIGHT_GRAY, 15); footerFont.setStyle(Font.ITALIC); } @Override public void onEndPage(PdfWriter writer, Document document) { PdfContentByte cb = writer.getDirectContent(); ColumnText.showTextAligned(cb, Element.ALIGN_CENTER, new Phrase(String.format("Page %d", writer.getPageNumber()),footerFont), (document.left() + document.right())/2 , document.bottom()-20, 0); } }
/** * Utility method to capture the default font in one place. * @return */ static Font createDefault( FilterFactory filterFactory ) { Font font = new FontImpl(); try { font.setSize(filterFactory.literal( new Integer(10))); font.setStyle(filterFactory.literal("normal")); font.setWeight(filterFactory.literal("normal")); font.setFontFamily(filterFactory.literal("Serif")); } catch (org.geotools.filter.IllegalFilterException ife) { throw new RuntimeException("Error creating default", ife); } return font; }
/** * Extract font. * * @return the font */ private Font extractFont() { Expression fontFamily = fieldConfigVisitor.getExpression(FieldIdEnum.FONT_FAMILY); List<Expression> fontFamilyList = new ArrayList<>(); if (fontFamily != null) { fontFamilyList.add(fontFamily); } Font font = getStyleFactory().getDefaultFont(); font.getFamily().clear(); font.getFamily().addAll(fontFamilyList); Expression fontSize = fieldConfigVisitor.getExpression(FieldIdEnum.FONT_SIZE); Expression fontStyle = fieldConfigVisitor.getExpression(FieldIdEnum.FONT_STYLE); Expression fontWeight = fieldConfigVisitor.getExpression(FieldIdEnum.FONT_WEIGHT); font.setStyle(fontStyle); font.setWeight(fontWeight); font.setSize(fontSize); return font; }
/** * Sets the font. * * @param newFont the new font */ public void setFont(Font newFont) { if (newFont != null) { this.font = styleFactory.getDefaultFont(); font.getFamily().clear(); font.getFamily().addAll(newFont.getFamily()); font.setStyle(newFont.getStyle()); font.setWeight(newFont.getWeight()); font.setSize(newFont.getSize()); setOriginalData(newFont); } }
/** * Update font. * * @param fontData the font data */ public void updateFont(Font fontData) { if ((fontData != null) && (font != null)) { if (!fontData.getFamily().isEmpty() && (!(fontData.getFamily().equals(font.getFamily())))) { font.getFamily().clear(); font.getFamily().addAll(fontData.getFamily()); } if ((fontData.getWeight() != null) && (!(fontData.getWeight().equals(font.getWeight())))) { font.setWeight(fontData.getWeight()); } if ((fontData.getStyle() != null) && (!(fontData.getStyle().equals(font.getStyle())))) { font.setStyle(fontData.getStyle()); } if ((fontData.getSize() != null) && (!(fontData.getSize().equals(font.getSize())))) { font.setSize(fontData.getSize()); } } }
localFont.setStyle(ff.literal(this.font.getStyle()));
@Override public void handle(YamlObject<?> obj, YamlParseContext context) { sym.setFont(font); YamlMap map = obj.map(); if (map.has("font-family")) { font.setFontFamily(Util.expression(map.str("font-family"), factory)); } if (map.has("font-size")) { font.setSize(Util.expression(map.str("font-size"), factory)); } if (map.has("font-style")) { font.setStyle(Util.expression(map.str("font-style"), factory)); } if (map.has("font-weight")) { font.setWeight(Util.expression(map.str("font-weight"), factory)); } } }