org.geotools.styling.Font类的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(263)

本文整理了Java中org.geotools.styling.Font类的一些代码示例,展示了Font类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Font类的具体详情如下:
包路径:org.geotools.styling.Font
类名称:Font

Font介绍

[英]A system-independent object for holding SLD font information. This holds information on the text font to use in text processing. Font-family, font-style, font-weight and font-size.
[中]与系统无关的对象,用于保存SLD字体信息。它保存有关文本处理中使用的文本字体的信息。字体系列、字体样式、字体重量和字体大小。

代码示例

代码示例来源:origin: geotools/geotools

  1. public FontBuilder reset(Font font) {
  2. if (font == null) {
  3. return reset();
  4. }
  5. this.families = font.getFamily() != null ? font.getFamily() : new ArrayList<Expression>();
  6. this.size = font.getSize();
  7. this.style = font.getStyle();
  8. this.weight = font.getWeight();
  9. unset = false;
  10. return this;
  11. }

代码示例来源:origin: geotools/geotools

  1. @SuppressWarnings("deprecation")
  2. @Test
  3. public void font() throws Exception {
  4. List<Expression> family = new ArrayList<Expression>();
  5. family.add(ff.literal("ariel"));
  6. family.add(ff.literal("Helvetica"));
  7. family.add(ff.literal("sanserif"));
  8. Expression style = ff.literal("noraml");
  9. Expression weight = ff.literal("normal");
  10. Expression size = ff.literal(12);
  11. Font font = sf.font(family, style, weight, size);
  12. assertEquals(family, font.getFamily());
  13. assertEquals(style, font.getStyle()); // oblique or italic
  14. assertEquals(weight, font.getWeight()); // bold or normal
  15. assertEquals(size, font.getSize());
  16. assertSame(font.getFontStyle(), font.getStyle());
  17. assertSame(font.getFontFamily(), family.get(0));
  18. assertSame(font.getFontWeight(), font.getWeight());
  19. assertSame(font.getFontSize(), font.getSize());
  20. FontImpl cast = FontImpl.cast(font);
  21. assertSame(cast, font);
  22. }

代码示例来源:origin: geotools/geotools

  1. font.getFamily().set(0, exp);
  2. familyFound = true;
  3. } else {
  4. font.getFamily().add(exp);
  5. font.setStyle(exp);
  6. font.setWeight(exp);
  7. font.setSize(exp);

代码示例来源:origin: geotools/geotools

  1. public FontBuilder reset() {
  2. Font df = sf.getDefaultFont();
  3. this.families = new ArrayList<Expression>();
  4. this.size = df.getSize();
  5. this.style = df.getStyle();
  6. this.weight = df.getWeight();
  7. return this;
  8. }

代码示例来源:origin: geotools/geotools

  1. @Override
  2. protected void encode(Font font) {
  3. putName("font-family", font.getFontFamily());
  4. put("font-size", font.getSize());
  5. putName("font-style", font.getStyle());
  6. putName("font-weight", font.getWeight());
  7. }
  8. }

代码示例来源:origin: robward-scisys/sldeditor

  1. /**
  2. * Sets the font.
  3. *
  4. * @param newFont the new font
  5. */
  6. public void setFont(Font newFont) {
  7. if (newFont != null) {
  8. this.font = styleFactory.getDefaultFont();
  9. font.getFamily().clear();
  10. font.getFamily().addAll(newFont.getFamily());
  11. font.setStyle(newFont.getStyle());
  12. font.setWeight(newFont.getWeight());
  13. font.setSize(newFont.getSize());
  14. setOriginalData(newFont);
  15. }
  16. }

代码示例来源:origin: org.geotools/gt-widgets-swing-pending

  1. public void setEdited(Font font){
  2. this.font = font;
  3. if(font != null){
  4. guiFamily.setExpression(font.getFontFamily());
  5. guiSize.setExpression(font.getFontSize());
  6. guiStyle.setExpression(font.getFontStyle());
  7. guiWeight.setExpression(font.getFontWeight());
  8. }
  9. }

代码示例来源:origin: geotools/geotools

  1. /**
  2. * Utility method to capture the default font in one place.
  3. *
  4. * @return
  5. */
  6. static Font createDefault(FilterFactory filterFactory) {
  7. Font font = new FontImpl();
  8. try {
  9. font.setSize(filterFactory.literal(Integer.valueOf(10)));
  10. font.setStyle(filterFactory.literal("normal"));
  11. font.setWeight(filterFactory.literal("normal"));
  12. font.setFontFamily(filterFactory.literal("Serif"));
  13. } catch (org.geotools.filter.IllegalFilterException ife) {
  14. throw new RuntimeException("Error creating default", ife);
  15. }
  16. return font;
  17. }

代码示例来源:origin: geotools/geotools

  1. font.setSize(rescale(font.getSize()));

代码示例来源:origin: geotools/geotools

  1. private java.awt.Font styleFont(
  2. Object feature, Font curr, java.awt.Font javaFont, TextSymbolizer symbolizer) {
  3. String reqStyle = evalToString(curr.getFontStyle(), feature, null);
  4. String reqWeight = evalToString(curr.getFontWeight(), feature, null);
  5. float size = evalToFloat(curr.getSize(), feature, 10);

代码示例来源:origin: geotools/geotools

  1. if (firstFontFamily) {
  2. font.getFamily().clear();
  3. firstFontFamily = false;
  4. font.getFamily().add(parseCssParameter(child));
  5. } else if (res.equalsIgnoreCase("font-style")) {
  6. font.setFontStyle(parseCssParameter(child));
  7. } else if (res.equalsIgnoreCase("font-size")) {
  8. font.setFontSize(parseCssParameter(child));
  9. } else if (res.equalsIgnoreCase("font-weight")) {
  10. font.setFontWeight(parseCssParameter(child));

代码示例来源:origin: geotools/geotools

  1. int textSize = getPositiveValue(font.getSize());
  2. int delta = -1;
  3. if (text.getLabelPlacement() instanceof PointPlacement) {

代码示例来源:origin: geotools/geotools

  1. for (Expression family : curr.getFamily()) {
  2. String requestedFont = evalToString(family, feature, null);
  3. java.awt.Font javaFont = FontCache.getDefaultInstance().getFont(requestedFont);

代码示例来源:origin: robward-scisys/sldeditor

  1. /**
  2. * Checks if font weight set.
  3. *
  4. * @return true, if is font name set
  5. */
  6. public boolean isFontWeightSet() {
  7. return ((font != null) && (font.getWeight() != null));
  8. }

代码示例来源:origin: robward-scisys/sldeditor

  1. /**
  2. * Checks if font style set.
  3. *
  4. * @return true, if is font name set
  5. */
  6. public boolean isFontStyleSet() {
  7. return ((font != null) && (font.getStyle() != null));
  8. }

代码示例来源:origin: org.geotools/gt-widgets-swing-pending

  1. @Override
  2. public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
  3. JLabel lbl = (JLabel) super.getTableCellRendererComponent(table, text, isSelected, hasFocus, row, column);
  4. Font f = (Font) value;
  5. java.awt.Font font = new java.awt.Font(f.getFontFamily().toString(), java.awt.Font.PLAIN, 12);
  6. lbl.setFont(font);
  7. return lbl;
  8. }
  9. }

代码示例来源:origin: stackoverflow.com

  1. public class HeaderAndFooter extends PdfPageEventHelper {
  2. private Font footerFont;
  3. public HeaderAndFooter() {
  4. super();
  5. footerFont = getFontObj(BaseColor.LIGHT_GRAY, 15);
  6. footerFont.setStyle(Font.ITALIC);
  7. }
  8. @Override
  9. public void onEndPage(PdfWriter writer, Document document) {
  10. PdfContentByte cb = writer.getDirectContent();
  11. ColumnText.showTextAligned(cb, Element.ALIGN_CENTER, new Phrase(String.format("Page %d", writer.getPageNumber()),footerFont), (document.left() + document.right())/2 , document.bottom()-20, 0);
  12. }
  13. }

代码示例来源:origin: stackoverflow.com

  1. f1.setSize(16);

代码示例来源:origin: robward-scisys/sldeditor

  1. /**
  2. * Update font.
  3. *
  4. * @param fontData the font data
  5. */
  6. public void updateFont(Font fontData) {
  7. if ((fontData != null) && (font != null)) {
  8. if (!fontData.getFamily().isEmpty()
  9. && (!(fontData.getFamily().equals(font.getFamily())))) {
  10. font.getFamily().clear();
  11. font.getFamily().addAll(fontData.getFamily());
  12. }
  13. if ((fontData.getWeight() != null)
  14. && (!(fontData.getWeight().equals(font.getWeight())))) {
  15. font.setWeight(fontData.getWeight());
  16. }
  17. if ((fontData.getStyle() != null) && (!(fontData.getStyle().equals(font.getStyle())))) {
  18. font.setStyle(fontData.getStyle());
  19. }
  20. if ((fontData.getSize() != null) && (!(fontData.getSize().equals(font.getSize())))) {
  21. font.setSize(fontData.getSize());
  22. }
  23. }
  24. }

代码示例来源:origin: org.geotools/gt-main

  1. /** Null safe copy of a single font */
  2. protected Font copy(Font font) {
  3. if( font == null) return font;
  4. Expression fontFamily = copy( font.getFontFamily() );
  5. Expression fontStyle = copy( font.getFontStyle() );
  6. Expression fontWeight = copy( font.getFontWeight() );
  7. Expression fontSize = copy( font.getFontSize() );
  8. Font copy = sf.createFont(fontFamily, fontStyle, fontWeight, fontSize);
  9. return copy;
  10. }

相关文章