font.setSize(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); } }
/** * Update font size. * * @param updatedFontSize the font size to update tp */ public void updateFontSize(int updatedFontSize) { if (font != null) { Expression fontSize = font.getSize(); if (!(String.valueOf(updatedFontSize).equals(fontSize.toString()))) { if (fontSize instanceof LiteralExpressionImpl) { int updatedSize = Double.valueOf(fontSize.toString()).intValue() + updatedFontSize; // Make sure we don't get negative sized fonts! if (updatedSize < 1) { updatedSize = 1; } Expression exp = ff.literal(updatedSize); font.setSize(exp); } else if ((fontSize instanceof FunctionExpression) || (fontSize instanceof MathExpressionImpl) || (fontSize instanceof ConstantExpression) || (fontSize instanceof AttributeExpressionImpl)) { Expression updatedSize = ff.add(fontSize, ff.literal(updatedFontSize)); font.setSize(updatedSize); } } } } }
font.setSize(rescale(font.getSize()));
font.setSize(rescale(font.getSize(), uom));
f1.setSize(16);
/** * 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.setSize(ff.literal(this.font.getSize()));
@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)); } } }
font.setSize(rescale(font.getSize()));
font.setSize(rescale(font.getSize(), mapScale, uom)); copy.setFonts(fonts);