org.geotools.factory.CommonFactoryFinder Java Examples
The following examples show how to use
org.geotools.factory.CommonFactoryFinder.
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: VOGeoServerContrastEnhancementNormalizeGreenTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Creates the channel selection error object. * * @param styleFactory the style factory * @param contrastMethod the contrast method * @return the channel selection */ private ChannelSelection createChannelSelectionError( StyleFactoryImpl styleFactory, ContrastMethod contrastMethod) { ContrastEnhancement contrastEnhancement = (ContrastEnhancement) styleFactory.contrastEnhancement(null, contrastMethod.name()); FilterFactory ff = CommonFactoryFinder.getFilterFactory(); Map<String, Expression> options = contrastEnhancement.getOptions(); options.put("algorithm", ff.literal("TestStretchToMinimumMaximum")); options.put("minValue", ff.literal("1.0")); options.put("maxValue", ff.literal("5.0")); SelectedChannelType channelType = styleFactory.createSelectedChannelType("channel name", contrastEnhancement); SelectedChannelType[] channels = new SelectedChannelType[3]; channels[0] = channelType; channels[1] = channelType; channels[2] = channelType; ChannelSelection channelSelection = styleFactory.createChannelSelection(channels); return channelSelection; }
Example #2
Source File: ExpressionPanelv2Test.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Test method for {@link * com.sldeditor.filter.v2.expression.ExpressionPanelv2#ExpressionPanelv2(java.util.List)}. */ @Test public void testExpressionPanelv2Property() { TestExpressionPanelv2 testObj = new TestExpressionPanelv2(null); assertNull(testObj.getVendorOptionList()); testObj.dataSourceAboutToUnloaded(null); testObj.populate((String) null); testObj.configure("title", String.class, false); testObj.testShowExpressionDialog(null, null); FilterFactory ff = CommonFactoryFinder.getFilterFactory(); Expression expectedExpression = ff.add(ff.property("field"), ff.literal(42)); testObj.populate(expectedExpression); testObj.testShowExpressionDialog(Integer.class, expectedExpression); assertEquals(testObj.getExpression().toString(), testObj.getExpressionString()); testObj.dataSourceLoaded(GeometryTypeEnum.POLYGON, true); testObj.dataApplied(); testObj.testSelection(); }
Example #3
Source File: VOGeoServerTextSymbolizer2Test.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Test method for {@link * com.sldeditor.ui.detail.vendor.geoserver.text.VOGeoServerTextSymbolizer2#getMinimumVersion(java.lang.Object, * java.lang.Object, java.util.List)}. */ @Test public void testGetMinimumVersion() { TextSymbolizerDetails panel = new TextSymbolizerDetails(); VOGeoServerTextSymbolizer2 testObj = new VOGeoServerTextSymbolizer2(panel.getClass()); TextSymbolizer2 symbolizer = null; testObj.updateSymbol(symbolizer); symbolizer = (TextSymbolizer2) DefaultSymbols.createDefaultTextSymbolizer(); FilterFactory ff = CommonFactoryFinder.getFilterFactory(); symbolizer.setSnippet(ff.literal("Test snippet")); List<VendorOptionPresent> vendorOptionsPresentList = null; testObj.getMinimumVersion(symbolizer, "", vendorOptionsPresentList); vendorOptionsPresentList = new ArrayList<VendorOptionPresent>(); testObj.getMinimumVersion(symbolizer, "", vendorOptionsPresentList); }
Example #4
Source File: ArrowUtilsTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Test method for {@link * com.sldeditor.ui.detail.vendor.geoserver.marker.arrow.ArrowUtils#encode(org.opengis.filter.expression.Expression, * org.opengis.filter.expression.Expression, org.opengis.filter.expression.Expression)}. */ @Test public void testEncode() { FilterFactory ff = CommonFactoryFinder.getFilterFactory(null); assertEquals( "extshape://arrow?hr=1.2&t=0.34&ab=0.56", ArrowUtils.encode(ff.literal(1.2), ff.literal(0.34), ff.literal(0.56))); assertEquals( "extshape://arrow?hr=2.0&t=0.34&ab=0.56", ArrowUtils.encode(null, ff.literal(0.34), ff.literal(0.56))); assertEquals( "extshape://arrow?hr=1.2&t=0.2&ab=0.56", ArrowUtils.encode(ff.literal(1.2), null, ff.literal(0.56))); assertEquals( "extshape://arrow?hr=1.2&t=0.34&ab=0.5", ArrowUtils.encode(ff.literal(1.2), ff.literal(0.34), null)); }
Example #5
Source File: FeatureLayerConfigurationPersistencyTest.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings({"deprecation"}) private static Style createStyle() { StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory(null); FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory(null); PolygonSymbolizer symbolizer = styleFactory.createPolygonSymbolizer(); Fill fill = styleFactory.createFill( filterFactory.literal("#FFAA00"), filterFactory.literal(0.5) ); symbolizer.setFill(fill); Rule rule = styleFactory.createRule(); rule.setSymbolizers(new Symbolizer[]{symbolizer}); FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle(); fts.setRules(new Rule[]{rule}); Style style = styleFactory.createStyle(); style.addFeatureTypeStyle(fts); return style; }
Example #6
Source File: ExtentModelTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Test method for {@link * com.sldeditor.ui.detail.config.featuretypeconstraint.ExtentModel#updateExtent(org.geotools.styling.FeatureTypeConstraint)}. */ @Test public void testUpdateExtent() { ExtentModel model = new ExtentModel(null); Extent[] extentArray = null; model.populate(extentArray); extentArray = new Extent[2]; StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory(); extentArray[0] = styleFactory.createExtent("extent 1", "1 1 1 1"); extentArray[1] = styleFactory.createExtent("extent 2", "2 2 2 2"); model.populate(extentArray); FeatureTypeConstraint ftc = styleFactory.createFeatureTypeConstraint("feature type name", Filter.INCLUDE, null); model.updateExtent(null); model.updateExtent(ftc); assertNotNull(ftc.getExtents()); assertEquals(2, ftc.getExtents().length); }
Example #7
Source File: VOGeoServerContrastEnhancementNormalizeGreyTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Creates the channel selection error object. * * @param styleFactory the style factory * @param contrastMethod the contrast method * @return the channel selection */ private ChannelSelection createChannelSelectionError( StyleFactoryImpl styleFactory, ContrastMethod contrastMethod) { ContrastEnhancement contrastEnhancement = (ContrastEnhancement) styleFactory.contrastEnhancement(null, contrastMethod.name()); FilterFactory ff = CommonFactoryFinder.getFilterFactory(); Map<String, Expression> options = contrastEnhancement.getOptions(); options.put("algorithm", ff.literal("TestStretchToMinimumMaximum")); options.put("minValue", ff.literal("1.0")); options.put("maxValue", ff.literal("5.0")); SelectedChannelType channelType = styleFactory.createSelectedChannelType("channel name", contrastEnhancement); SelectedChannelType[] channels = new SelectedChannelType[3]; channels[0] = channelType; channels[1] = channelType; channels[2] = channelType; ChannelSelection channelSelection = styleFactory.createChannelSelection(channels); return channelSelection; }
Example #8
Source File: VOGeoServerContrastEnhancementNormalizeOverallTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Creates the channel selection object. * * @param styleFactory the style factory * @param contrastMethod the contrast method * @return the channel selection */ private ChannelSelection createChannelSelection( StyleFactoryImpl styleFactory, ContrastMethod contrastMethod) { ContrastEnhancement contrastEnhancement = (ContrastEnhancement) styleFactory.contrastEnhancement(null, contrastMethod.name()); FilterFactory ff = CommonFactoryFinder.getFilterFactory(); Map<String, Expression> options = contrastEnhancement.getOptions(); options.put("algorithm", ff.literal("StretchToMinimumMaximum")); options.put("minValue", ff.literal("1")); options.put("maxValue", ff.literal("5")); SelectedChannelType channelType = styleFactory.createSelectedChannelType("channel name", contrastEnhancement); SelectedChannelType[] channels = new SelectedChannelType[3]; channels[0] = channelType; channels[1] = channelType; channels[2] = channelType; ChannelSelection channelSelection = styleFactory.createChannelSelection(channels); return channelSelection; }
Example #9
Source File: VOGeoServerContrastEnhancementNormalizeOverallTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Creates the channel selection error object. * * @param styleFactory the style factory * @param contrastMethod the contrast method * @return the channel selection */ private ChannelSelection createChannelSelectionError( StyleFactoryImpl styleFactory, ContrastMethod contrastMethod) { ContrastEnhancement contrastEnhancement = (ContrastEnhancement) styleFactory.contrastEnhancement(null, contrastMethod.name()); FilterFactory ff = CommonFactoryFinder.getFilterFactory(); Map<String, Expression> options = contrastEnhancement.getOptions(); options.put("algorithm", ff.literal("TestStretchToMinimumMaximum")); options.put("minValue", ff.literal("1.0")); options.put("maxValue", ff.literal("5.0")); SelectedChannelType channelType = styleFactory.createSelectedChannelType("channel name", contrastEnhancement); SelectedChannelType[] channels = new SelectedChannelType[3]; channels[0] = channelType; channels[1] = channelType; channels[2] = channelType; ChannelSelection channelSelection = styleFactory.createChannelSelection(channels); return channelSelection; }
Example #10
Source File: VOGeoServerContrastEnhancementNormalizeGreenTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Creates the channel selection object. * * @param styleFactory the style factory * @param contrastMethod the contrast method * @return the channel selection */ private ChannelSelection createChannelSelection( StyleFactoryImpl styleFactory, ContrastMethod contrastMethod) { ContrastEnhancement contrastEnhancement = (ContrastEnhancement) styleFactory.contrastEnhancement(null, contrastMethod.name()); FilterFactory ff = CommonFactoryFinder.getFilterFactory(); Map<String, Expression> options = contrastEnhancement.getOptions(); options.put("algorithm", ff.literal("StretchToMinimumMaximum")); options.put("minValue", ff.literal("1")); options.put("maxValue", ff.literal("5")); SelectedChannelType channelType = styleFactory.createSelectedChannelType("channel name", contrastEnhancement); SelectedChannelType[] channels = new SelectedChannelType[3]; channels[0] = channelType; channels[1] = channelType; channels[2] = channelType; ChannelSelection channelSelection = styleFactory.createChannelSelection(channels); return channelSelection; }
Example #11
Source File: VOGeoServerContrastEnhancementNormalizeBlueTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Creates the channel selection object. * * @param styleFactory the style factory * @param contrastMethod the contrast method * @return the channel selection */ private ChannelSelection createChannelSelection( StyleFactoryImpl styleFactory, ContrastMethod contrastMethod) { ContrastEnhancement contrastEnhancement = (ContrastEnhancement) styleFactory.contrastEnhancement(null, contrastMethod.name()); FilterFactory ff = CommonFactoryFinder.getFilterFactory(); Map<String, Expression> options = contrastEnhancement.getOptions(); options.put("algorithm", ff.literal("StretchToMinimumMaximum")); options.put("minValue", ff.literal("1")); options.put("maxValue", ff.literal("5")); SelectedChannelType channelType = styleFactory.createSelectedChannelType("channel name", contrastEnhancement); SelectedChannelType[] channels = new SelectedChannelType[3]; channels[0] = channelType; channels[1] = channelType; channels[2] = channelType; ChannelSelection channelSelection = styleFactory.createChannelSelection(channels); return channelSelection; }
Example #12
Source File: SLDUtils.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Creates a StyledLayerDescriptor object containing a SLD by reading the contents of a file. * * @param file the file * @return the styled layer descriptor */ public static StyledLayerDescriptor readSLDFile(File file) { StyledLayerDescriptor sld = null; if (file != null) { StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory(); try { // By using URL here allows external graphics to loaded properly URL url = file.toURI().toURL(); SLDParser styleReader = new SLDParser(styleFactory, url); setResourcelocator(styleReader, file.toURI().toURL()); sld = styleReader.parseSLD(); } catch (IOException e) { ConsoleManager.getInstance().exception(SLDUtils.class, e); } } return sld; }
Example #13
Source File: VOGeoServerContrastEnhancementNormalizeBlueTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Creates the channel selection error object. * * @param styleFactory the style factory * @param contrastMethod the contrast method * @return the channel selection */ private ChannelSelection createChannelSelectionError( StyleFactoryImpl styleFactory, ContrastMethod contrastMethod) { ContrastEnhancement contrastEnhancement = (ContrastEnhancement) styleFactory.contrastEnhancement(null, contrastMethod.name()); FilterFactory ff = CommonFactoryFinder.getFilterFactory(); Map<String, Expression> options = contrastEnhancement.getOptions(); options.put("algorithm", ff.literal("TestStretchToMinimumMaximum")); options.put("minValue", ff.literal("1.0")); options.put("maxValue", ff.literal("5.0")); SelectedChannelType channelType = styleFactory.createSelectedChannelType("channel name", contrastEnhancement); SelectedChannelType[] channels = new SelectedChannelType[3]; channels[0] = channelType; channels[1] = channelType; channels[2] = channelType; ChannelSelection channelSelection = styleFactory.createChannelSelection(channels); return channelSelection; }
Example #14
Source File: StyleGenerator.java From constellation with Apache License 2.0 | 6 votes |
private static Rule makeFillRule() { final FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory(); final StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory(); // create a partially opaque outline stroke final Stroke stroke = styleFactory.createStroke( filterFactory.literal(Color.BLACK), filterFactory.literal(1), filterFactory.literal(.5) ); // create a partially opaque fill Fill fill = styleFactory.createFill( filterFactory.literal(COLORS.next()), filterFactory.literal(.5) ); // setting the geometryPropertyName arg to null signals that we want to draw the default geometry of features final PolygonSymbolizer sym = styleFactory.createPolygonSymbolizer(stroke, fill, null); final Rule rule = styleFactory.createRule(); rule.symbolizers().add(sym); return rule; }
Example #15
Source File: DistributedRenderCallback.java From geowave with Apache License 2.0 | 6 votes |
private static FeatureTypeStyle getDirectRasterStyle( final String geometryPropertyName, final Expression transformation) { final StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory(); final FeatureTypeStyle style = styleFactory.createFeatureTypeStyle(); final Rule rule = styleFactory.createRule(); rule.setName("distributed render - direct raster"); rule.setTitle("Distributed Render - Direct Raster"); final RasterSymbolizer symbolizer = styleFactory.createRasterSymbolizer(); symbolizer.setGeometryPropertyName(geometryPropertyName); rule.symbolizers().add(symbolizer); style.rules().add(rule); style.setTransformation(transformation); return style; }
Example #16
Source File: EnvironmentVariableManagerTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link * com.sldeditor.filter.v2.envvar.EnvironmentVariableManager#getDataType(org.opengis.filter.expression.Expression)}. */ @Test public void testGetDataType() { Class<?> dataType = EnvironmentVariableManager.getInstance().getDataType(null); assertEquals(Object.class, dataType); dataType = EnvironmentVariableManager.getInstance().getDataType(ConstantExpression.TWO); assertEquals(Object.class, dataType); FilterFactory ff = CommonFactoryFinder.getFilterFactory(); Expression literal = ff.literal("wms_width"); dataType = EnvironmentVariableManager.getInstance().getDataType(literal); assertEquals(Integer.class, dataType); }
Example #17
Source File: ColourUtilsTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link * com.sldeditor.common.utils.ColourUtils#getIntColour(org.opengis.filter.expression.Expression)}. */ @Test public void testGetIntColour() { FilterFactory ff = CommonFactoryFinder.getFilterFactory(); Expression colourExpression = ff.literal("#FF00FF"); int colourValue = ColourUtils.getIntColour(colourExpression); assertEquals(0xff00ff, colourValue); colourValue = ColourUtils.getIntColour(null); }
Example #18
Source File: EnvironmentVariablePanelTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link * com.sldeditor.filter.v2.envvar.EnvironmentVariablePanel#EnvironmentVariablePanel(com.sldeditor.filter.v2.expression.ExpressionFilterInterface)}. */ @Test void testEnvironmentVariablePanel() { TestEnvironmentVariablePanel testObj = new TestEnvironmentVariablePanel(null); // Nothing selected testObj.revertButton(); testObj.applyButton(); testObj.dataSourceLoaded(null); TestExpressionFilterInterface receiver = new TestExpressionFilterInterface(); testObj = new TestEnvironmentVariablePanel(receiver); TestDataSourceInterface dataSource = new TestDataSourceInterface(); testObj.dataSourceLoaded(dataSource); assertFalse(receiver.dataAppliedFlag); FilterFactory ff = CommonFactoryFinder.getFilterFactory(); ExpressionNode node = new ExpressionNode(); Expression property = ff.property("Field2"); node.setExpression(property); testObj.setAttribute(property); testObj.applyButton(); assertTrue(receiver.dataAppliedFlag); receiver.dataAppliedFlag = false; testObj.setSelectedNode(node); testObj.applyButton(); assertTrue(receiver.dataAppliedFlag); }
Example #19
Source File: EncodeColourMapTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link * com.sldeditor.ui.detail.config.colourmap.EncodeColourMap#encode(org.geotools.styling.ColorMap)}. * Test method for {@link * com.sldeditor.ui.detail.config.colourmap.EncodeColourMap#encode(java.util.List)}. */ @Test public void testEncodeColorMap() { FilterFactory ff = CommonFactoryFinder.getFilterFactory(); ColorMapEntryImpl entry1 = new ColorMapEntryImpl(); entry1.setColor(ff.literal(COLOUR_1)); entry1.setOpacity(ff.literal(OPACITY_1)); entry1.setQuantity(ff.literal(QUANTITY_1)); ColorMap expectedValue = new ColorMapImpl(); expectedValue.addColorMapEntry(entry1); ColorMapEntryImpl entry2 = new ColorMapEntryImpl(); entry2.setColor(ff.literal(COLOUR_2)); entry2.setLabel(LABEL_2); entry2.setOpacity(ff.literal(OPACITY_2)); entry2.setQuantity(ff.literal(QUANTITY_2)); expectedValue.addColorMapEntry(entry2); XMLColourMapEntry xml1 = new XMLColourMapEntry(); xml1.setColour(COLOUR_1); xml1.setOpacity(OPACITY_1); xml1.setQuantity(42); List<XMLColourMapEntry> xmlList = new ArrayList<XMLColourMapEntry>(); xmlList.add(xml1); XMLColourMapEntry xml2 = new XMLColourMapEntry(); xml2.setColour(COLOUR_2); xml2.setLabel(LABEL_2); xml2.setOpacity(OPACITY_2); xml2.setQuantity(QUANTITY_2); xmlList.add(xml2); String actualValue1 = EncodeColourMap.encode(expectedValue); String actualValue2 = EncodeColourMap.encode(xmlList); assertTrue(actualValue1.compareTo(actualValue2) == 0); }
Example #20
Source File: SymbolizerFilterVisitor.java From geomajas-project-server with GNU Affero General Public License v3.0 | 5 votes |
@Override protected Expression copy(Expression expression) { if (expression instanceof ProcessFunction) { ProcessFunction f = (ProcessFunction) expression; return (ProcessFunction) CommonFactoryFinder.getFilterFactory2() .function( f.getProcessName(), f.getParameters().toArray( new Expression[f.getParameters().size()])); } else { return super.copy(expression); } }
Example #21
Source File: VendorOptionFTSFactoryTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link * com.sldeditor.ui.detail.vendor.geoserver.featuretypestyle.VendorOptionFTSFactory#VendorOptionFTSFactory(java.lang.Class)}. */ @Test public void testVendorOptionFTSFactory() { VendorOptionFTSFactory obj = new VendorOptionFTSFactory(FeatureTypeStyleDetails.class); int expectedNoOfVO = 4; assertEquals(expectedNoOfVO, obj.getVendorOptionList().size()); List<VendorOptionPresent> vendorOptionsPresentList = new ArrayList<VendorOptionPresent>(); StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory(); FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle(); obj.getMinimumVersion(null, fts, vendorOptionsPresentList); assertEquals(0, vendorOptionsPresentList.size()); // Valid string String expectedValue = "exclude,0.12"; fts.getOptions().put(FeatureTypeStyle.COMPOSITE, expectedValue); obj.getMinimumVersion(null, fts, vendorOptionsPresentList); assertEquals(1, vendorOptionsPresentList.size()); assertEquals(expectedNoOfVO, obj.getVendorOptionInfoList().size()); assertEquals(1, obj.getVendorOptionList(VOGeoServerFTSComposite.class.getName()).size()); GraphicPanelFieldManager fieldMgr = new GraphicPanelFieldManager(FeatureTypeStyleDetails.class); obj.getFieldDataManager(fieldMgr); obj.populate(fts); obj.updateSymbol(fts); }
Example #22
Source File: SimpleFilterTest.java From geomajas-project-server with GNU Affero General Public License v3.0 | 5 votes |
@Test public void nullFilter() throws Exception { FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null); Filter filter = ff.isNull(ff.property(PARAM_DATE_ATTR)); Iterator<?> it = layer.getElements(filter, 0, 0); int t = 0; while (it.hasNext()) { Assert.assertTrue("Returned object must be a SimpleFeature", it.next() instanceof SimpleFeature); t++; } Assert.assertEquals(1, t); }
Example #23
Source File: GeoHashGridProcessTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Before public void setup() throws JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); features = TestUtil.createAggregationFeatures(ImmutableList.of( ImmutableMap.of("_aggregation", mapper.writeValueAsBytes(ImmutableMap.of("key",GeoHash.encodeHash(new LatLong(-89.9,-179.9),1),"doc_count",10))), ImmutableMap.of("_aggregation", mapper.writeValueAsBytes(ImmutableMap.of("key",GeoHash.encodeHash(new LatLong(0.1,0.1),1),"doc_count",10))), ImmutableMap.of("_aggregation", mapper.writeValueAsBytes(ImmutableMap.of("key",GeoHash.encodeHash(new LatLong(89.9,179.9),1),"doc_count",10))) )); fineDelta = 0.45; ff = CommonFactoryFinder.getFilterFactory(null); process = new GeoHashGridProcess(); }
Example #24
Source File: MathsExpressionPanelTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link * com.sldeditor.filter.v2.expression.MathsExpressionPanel#MathsExpressionPanel(com.sldeditor.ui.attribute.SubPanelUpdatedInterface)}. */ @Test void testMathsExpressionPanel() { FilterFactory ff = CommonFactoryFinder.getFilterFactory(); MathsExpressionPanel testObj = new MathsExpressionPanel( new SubPanelUpdatedInterface() { @Override public void updateSymbol() {} @Override public void parameterAdded() {} }); // Invalid testObj.setExpression(null); assertEquals(null, testObj.getExpression()); // Add testObj.setExpression(ff.add(null, null)); assertEquals(AddImpl.class, testObj.getExpression().getClass()); assertEquals("Add", testObj.getSelectedItem()); // Subtract testObj.setExpression(ff.subtract(null, null)); assertEquals(SubtractImpl.class, testObj.getExpression().getClass()); // Multiply testObj.setExpression(ff.multiply(null, null)); assertEquals(MultiplyImpl.class, testObj.getExpression().getClass()); // Divide testObj.setExpression(ff.divide(null, null)); assertEquals(DivideImpl.class, testObj.getExpression().getClass()); testObj.setPanelEnabled(true); }
Example #25
Source File: StyleGenerator.java From constellation with Apache License 2.0 | 5 votes |
private static Style createPolygonStyle() { final StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory(); final FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory(); // create a partially opaque outline stroke final Stroke stroke = styleFactory.createStroke( filterFactory.literal(Color.BLACK), filterFactory.literal(1), filterFactory.literal(.5) ); // create a partially opaque fill final Fill fill = styleFactory.createFill( filterFactory.literal(COLORS.next()), filterFactory.literal(.5) ); // setting the geometryPropertyName arg to null signals that we want to draw the default geometry of features final PolygonSymbolizer sym = styleFactory.createPolygonSymbolizer(stroke, fill, null); // make rule final Rule rule = styleFactory.createRule(); rule.symbolizers().add(sym); final FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle(new Rule[]{rule}); final Style style = styleFactory.createStyle(); style.getDescription().setTitle("Polygon Style"); style.featureTypeStyles().add(fts); return style; }
Example #26
Source File: FieldConfigColourMapTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link * com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap#undoAction(com.sldeditor.common.undo.UndoInterface)}. * Test method for {@link * com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap#redoAction(com.sldeditor.common.undo.UndoInterface)}. */ @Test public void testUndoAction() { FieldConfigColourMap field = new FieldConfigColourMap( new FieldConfigCommonData( Geometry.class, FieldIdEnum.NAME, "label", true, false)); field.undoAction(null); field.redoAction(null); field.createUI(); ColorMap expectedValue1 = new ColorMapImpl(); field.populateField(expectedValue1); assertEquals(expectedValue1, field.getColourMap()); FilterFactory ff = CommonFactoryFinder.getFilterFactory(); ColorMap expectedValue2 = new ColorMapImpl(); ColorMapEntryImpl entry = new ColorMapEntryImpl(); entry.setColor(ff.literal("#001122")); expectedValue2.addColorMapEntry(entry); field.populateField(expectedValue2); UndoManager.getInstance().undo(); assertEquals( expectedValue1.getColorMapEntries().length, field.getColourMap().getColorMapEntries().length); UndoManager.getInstance().redo(); assertEquals( expectedValue2.getColorMapEntries().length, field.getColourMap().getColorMapEntries().length); // Increase the code coverage field.undoAction(null); field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new")); field.redoAction(null); field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new")); }
Example #27
Source File: OmsMapsViewer.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
@Execute public void displayMaps() throws Exception { sf = CommonFactoryFinder.getStyleFactory(GeoTools.getDefaultHints()); ff = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints()); sb = new StyleBuilder(sf, ff); final MapContent map = new MapContent(); map.setTitle("Maps Viewer"); addImageMosaic(map); addCoverages(map); addFeatureCollections(map); map.getViewport().setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84); // Create a JMapFrame with a menu to choose the display style for the final JMapFrame frame = new JMapFrame(map); frame.setSize(1800, 1200); frame.enableStatusBar(true); frame.enableTool(JMapFrame.Tool.ZOOM, JMapFrame.Tool.PAN, JMapFrame.Tool.RESET); frame.enableToolBar(true); frame.setVisible(true); frame.addWindowListener(new WindowAdapter(){ public void windowClosing( WindowEvent e ) { frame.setVisible(false); } }); while( frame.isVisible() ) { Thread.sleep(300); } }
Example #28
Source File: ExtentModelTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link * com.sldeditor.ui.detail.config.featuretypeconstraint.ExtentModel#getExtentList()}. Test * method for {@link * com.sldeditor.ui.detail.config.featuretypeconstraint.ExtentModel#removeEntries(int, int)}. * Test method for {@link * com.sldeditor.ui.detail.config.featuretypeconstraint.ExtentModel#populate(org.geotools.styling.Extent[])}. */ @Test public void testGetExtentList() { TestModelUpdate testUpdate = new TestModelUpdate(); StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory(); ExtentModel model = new ExtentModel(testUpdate); Extent[] extentArray = null; model.populate(extentArray); extentArray = new Extent[5]; extentArray[0] = styleFactory.createExtent("extent 1", "1 1 1 1"); extentArray[1] = styleFactory.createExtent("extent 2", "2 2 2 2"); extentArray[2] = styleFactory.createExtent("extent 3", "3 3 3 3"); extentArray[3] = styleFactory.createExtent("extent 4", "4 4 4 4"); extentArray[4] = styleFactory.createExtent("extent 5", "5 5 5 5"); model.populate(extentArray); List<Extent> actualList = model.getExtentList(); assertEquals(5, actualList.size()); assertTrue(actualList.get(2).getName().compareTo("extent 3") == 0); assertFalse(testUpdate.hasExtentUpdatedBeenCalled()); model.removeEntries(-1, 2); assertFalse(testUpdate.hasExtentUpdatedBeenCalled()); model.removeEntries(2, 22); assertFalse(testUpdate.hasExtentUpdatedBeenCalled()); model.removeEntries(22, 2); assertFalse(testUpdate.hasExtentUpdatedBeenCalled()); model.removeEntries(2, 2); assertTrue(testUpdate.hasExtentUpdatedBeenCalled()); actualList = model.getExtentList(); assertEquals(4, actualList.size()); assertTrue(actualList.get(2).getName().compareTo("extent 4") == 0); }
Example #29
Source File: FieldConfigFeatureTypeConstraintTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
@Test public void testUndoActionSuppress() { FieldConfigFeatureTypeConstraint field = new FieldConfigFeatureTypeConstraint( new FieldConfigCommonData( Geometry.class, FieldIdEnum.NAME, "label", true, true)); field.createUI(); StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory(); FeatureTypeConstraint expectedValue1 = styleFactory.createFeatureTypeConstraint("Feature", Filter.INCLUDE, new Extent[0]); List<FeatureTypeConstraint> testValue = new ArrayList<FeatureTypeConstraint>(); testValue.add(expectedValue1); int undoListSize = UndoManager.getInstance().getUndoListSize(); field.populateField(testValue); assertEquals(expectedValue1, field.getFeatureTypeConstraint().get(0)); FeatureTypeConstraint expectedValue2 = styleFactory.createFeatureTypeConstraint("Feature2", Filter.INCLUDE, new Extent[0]); List<FeatureTypeConstraint> testValue2 = new ArrayList<FeatureTypeConstraint>(); testValue2.add(expectedValue1); testValue2.add(expectedValue2); field.populateField(testValue2); field.featureTypeConstraintUpdated(); assertEquals(undoListSize, UndoManager.getInstance().getUndoListSize()); }
Example #30
Source File: FieldConfigFeatureTypeConstraintTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link * com.sldeditor.ui.detail.config.featuretypeconstraint.FieldConfigFeatureTypeConstraint#generateExpression()}. * Test method for {@link * com.sldeditor.ui.detail.config.featuretypeconstraint.FieldConfigFeatureTypeConstraint#populateExpression(java.lang.Object)}. * Test method for {@link * com.sldeditor.ui.detail.config.featuretypeconstraint.FieldConfigFeatureTypeConstraint#setTestValue(com.sldeditor.ui.detail.config.FieldId, * java.util.List)}. Test method for {@link * com.sldeditor.ui.detail.config.featuretypeconstraint.FieldConfigFeatureTypeConstraint#populateField(java.util.List)}. * Test method for {@link * com.sldeditor.ui.detail.config.featuretypeconstraint.FieldConfigFeatureTypeConstraint#getFeatureTypeConstraint()}. */ @Test public void testGenerateExpression() { FieldConfigFeatureTypeConstraint field = new FieldConfigFeatureTypeConstraint( new FieldConfigCommonData( Geometry.class, FieldIdEnum.NAME, "label", true, false)); List<FeatureTypeConstraint> testValue = null; field.populate(null); field.setTestValue(FieldIdEnum.UNKNOWN, testValue); field.populateField(testValue); field.createUI(); assertNull(field.getStringValue()); StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory(); FeatureTypeConstraint expectedValue1 = styleFactory.createFeatureTypeConstraint("Feature", Filter.INCLUDE, new Extent[0]); testValue = new ArrayList<FeatureTypeConstraint>(); testValue.add(expectedValue1); field.populateField(testValue); assertEquals(expectedValue1, field.getFeatureTypeConstraint().get(0)); field.setTestValue(FieldIdEnum.UNKNOWN, testValue); assertEquals(expectedValue1, field.getFeatureTypeConstraint().get(0)); field.populateExpression((String) null); }