Java Code Examples for org.geotools.styling.StyleBuilder#createFont()
The following examples show how to use
org.geotools.styling.StyleBuilder#createFont() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FieldConfigPopulationTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * 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, false)); 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); }
Example 2
Source File: FieldConfigFont.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * 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); }
Example 3
Source File: FieldConfigFontPreview.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * 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); }
Example 4
Source File: FieldConfigFontTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * 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, false)); 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.populateExpression(Integer.valueOf(1)); field.populateExpression(expectedValue); 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); }
Example 5
Source File: FieldConfigFontPreviewTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * 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, false)); 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((Font) null); 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()); FilterFactory ff = CommonFactoryFinder.getFilterFactory(); Font f5 = styleBuilder.createFont(expectedValue, false, false, 24.0); f5.setWeight(null); field.populateField(f5); assertEquals(field.getStringValue(), ""); Font f6 = styleBuilder.createFont(expectedValue, false, false, 24.0); f6.setSize(ff.literal("24")); field.populateField(f6); assertNotNull(field.getStringValue()); Font f7 = styleBuilder.createFont(expectedValue, false, false, 24.0); f7.setSize(ff.property("property")); field.populateField(f7); assertNotNull(field.getStringValue()); }