当前位置: 首页>>代码示例>>Java>>正文


Java StyleBuilder.createFont方法代码示例

本文整理汇总了Java中org.geotools.styling.StyleBuilder.createFont方法的典型用法代码示例。如果您正苦于以下问题:Java StyleBuilder.createFont方法的具体用法?Java StyleBuilder.createFont怎么用?Java StyleBuilder.createFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.geotools.styling.StyleBuilder的用法示例。


在下文中一共展示了StyleBuilder.createFont方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testFont

import org.geotools.styling.StyleBuilder; //导入方法依赖的package包/类
/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateFontField(com.sldeditor.common.xml.ui.FieldIdEnum, org.geotools.styling.Font)}.
 */
@Test
public void testFont() {

    FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;

    GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);

    FieldConfigFont fontField = new FieldConfigFont(
            new FieldConfigCommonData(Geometry.class, fieldId, "label", true));
    fontField.createUI();
    fieldConfigManager.add(fieldId, fontField);

    FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);

    StyleBuilder styleBuilder = new StyleBuilder();

    Font expectedValue = styleBuilder.createFont(java.awt.Font.decode(null));
    obj.populateFontField(fieldId, expectedValue);

    // This shouldn't work as it does not know about the field
    FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
    obj.populateFontField(wrongFieldEnum, expectedValue);
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:28,代码来源:FieldConfigPopulationTest.java

示例2: populateField

import org.geotools.styling.StyleBuilder; //导入方法依赖的package包/类
/**
 * Populate string field, overridden if necessary.
 *
 * @param value the value
 */
@Override
public void populateField(String value) {
    StyleBuilder styleBuilder = new StyleBuilder();

    Font font = styleBuilder.createFont(defaultValue, DEFAULT_FONT_SIZE);

    populateField(font);
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:14,代码来源:FieldConfigFont.java

示例3: testGetFont

import org.geotools.styling.StyleBuilder; //导入方法依赖的package包/类
/**
 * Test method for {@link com.sldeditor.ui.legend.option.FontUtils#getFont(org.geotools.styling.Font)}.
 */
@Test
public void testGetFont() {
    // Test does:
    // Create a java.awt.Font, convert it to a org.geotools.styling.Font.
    // Using FontUtils, convert it back to java.awt.Font and check that it
    // is the same as the original.
    StyleBuilder sb = new StyleBuilder();

    GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();
    Font[] fonts = e.getAllFonts(); // Get the fonts

    // Plain font
    Font javaFont = new Font(fonts[0].getFamily(), Font.PLAIN, 24);

    org.geotools.styling.Font geoToolsFonts = sb.createFont(javaFont);
    Font actualJavaFont = FontUtils.getFont(geoToolsFonts);
    assertEquals(actualJavaFont, javaFont);

    // Bold font
    javaFont = new Font(fonts[0].getFamily(), Font.BOLD, 18);

    geoToolsFonts = sb.createFont(javaFont);
    actualJavaFont = FontUtils.getFont(geoToolsFonts);
    assertEquals(actualJavaFont, javaFont);

    // Italic font
    javaFont = new Font(fonts[0].getFamily(), Font.ITALIC, 18);

    geoToolsFonts = sb.createFont(javaFont);
    actualJavaFont = FontUtils.getFont(geoToolsFonts);
    assertEquals(actualJavaFont, javaFont);

    // Bold and italic font
    javaFont = new Font(fonts[0].getFamily(), Font.BOLD | Font.ITALIC, 18);

    geoToolsFonts = sb.createFont(javaFont);
    actualJavaFont = FontUtils.getFont(geoToolsFonts);
    assertEquals(actualJavaFont, javaFont);
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:43,代码来源:FontUtilsTest.java

示例4: testGenerateExpression

import org.geotools.styling.StyleBuilder; //导入方法依赖的package包/类
/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.font.FieldConfigFont#generateExpression()}. Test method
 * for
 * {@link com.sldeditor.ui.detail.config.font.FieldConfigFont#populateField(org.geotools.styling.Font)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.font.FieldConfigFont#setTestValue(com.sldeditor.ui.detail.config.FieldId, java.lang.String)}.
 * Test method for {@link com.sldeditor.ui.detail.config.font.FieldConfigFont#getFont()}. Test
 * method for
 * {@link com.sldeditor.ui.detail.config.font.FieldConfigFont#populateExpression(java.lang.Object, org.opengis.filter.expression.Expression)}.
 * Test method for {@link com.sldeditor.ui.detail.config.font.FieldConfigFont#getStringValue()}.
 */
@Test
public void testGenerateExpression() {
    boolean valueOnly = true;
    FieldConfigFont field = new FieldConfigFont(
            new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly));

    field.setTestValue(FieldIdEnum.UNKNOWN, (String) null);
    field.populateField((String) null);
    field.populateField((Font) null);
    field.populateExpression((Font) null);

    String expectedValue = fontFamilies[0];
    field.createUI();
    field.populateField(expectedValue);
    String actualValue = field.getStringValue();
    assertTrue(expectedValue.compareTo(actualValue) == 0);

    field.setTestValue(FieldIdEnum.UNKNOWN, expectedValue);
    actualValue = field.getStringValue();
    assertTrue(expectedValue.compareTo(actualValue) == 0);

    StyleBuilder styleBuilder = new StyleBuilder();

    Font f1 = styleBuilder.createFont(expectedValue, false, true, 24.0);
    field.populateField(f1);
    actualValue = field.getStringValue();
    assertTrue(expectedValue.compareTo(actualValue) == 0);
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:41,代码来源:FieldConfigFontTest.java

示例5: testGenerateExpression

import org.geotools.styling.StyleBuilder; //导入方法依赖的package包/类
/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.font.FieldConfigFontPreview#generateExpression()}. Test
 * method for
 * {@link com.sldeditor.ui.detail.config.font.FieldConfigFontPreview#populateExpression(java.lang.Object, org.opengis.filter.expression.Expression)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.font.FieldConfigFontPreview#populateField(org.geotools.styling.Font)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.font.FieldConfigFontPreview#setTestValue(com.sldeditor.ui.detail.config.FieldId, java.lang.String)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.font.FieldConfigFontPreview#getStringValue()}.
 */
@Test
public void testGenerateExpression() {
    boolean valueOnly = true;
    FieldConfigFontPreview field = new FieldConfigFontPreview(
            new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly));

    field.setTestValue(FieldIdEnum.UNKNOWN, (String) null);
    field.populateField((String) null);
    field.populateField((Font) null);
    field.populateExpression((Font) null);

    String expectedValue = fontFamilies[0];
    field.createUI();
    field.populateField(expectedValue);
    String actualValue = field.getStringValue();
    assertNotNull(actualValue);

    field.setTestValue(FieldIdEnum.UNKNOWN, expectedValue);
    actualValue = field.getStringValue();
    assertNotNull(actualValue);

    StyleBuilder styleBuilder = new StyleBuilder();

    Font f1 = styleBuilder.createFont(expectedValue, false, true, 24.0);
    field.populateField(f1);
    assertNotNull(field.getStringValue());

    Font f2 = styleBuilder.createFont(expectedValue, true, true, 24.0);
    field.populateField(f2);
    assertNotNull(field.getStringValue());

    Font f3 = styleBuilder.createFont(expectedValue, true, false, 24.0);
    field.populateField(f3);
    assertNotNull(field.getStringValue());

    Font f4 = styleBuilder.createFont(expectedValue, false, false, 24.0);
    field.populateField(f4);
    assertNotNull(field.getStringValue());
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:52,代码来源:FieldConfigFontPreviewTest.java


注:本文中的org.geotools.styling.StyleBuilder.createFont方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。