本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}