本文整理汇总了Java中org.geotools.styling.Rule类的典型用法代码示例。如果您正苦于以下问题:Java Rule类的具体用法?Java Rule怎么用?Java Rule使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Rule类属于org.geotools.styling包,在下文中一共展示了Rule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convert
import org.geotools.styling.Rule; //导入依赖的package包/类
@Override
public void convert(Rule rule, JsonElement element, String layerName, int transparency) {
if(element == null) return;
if(rule == null) return;
JsonObject obj = element.getAsJsonObject();
@SuppressWarnings("unused")
int style = getInt(obj, CommonSymbolKeys.STYLE);
List<Symbolizer> symbolizerList = rule.symbolizers();
List<Stroke> strokeList = convert(obj);
Stroke stroke = null;
if(!strokeList.isEmpty())
{
stroke = strokeList.get(0);
}
LineSymbolizer lineSymbolizer = styleFactory.createLineSymbolizer(stroke, null);
symbolizerList.add(lineSymbolizer);
}
示例2: convert
import org.geotools.styling.Rule; //导入依赖的package包/类
@Override
public void convert(Rule rule, JsonElement element, String layerName, int transparency) {
if(element == null) return;
if(rule == null) return;
List<Symbolizer> symbolizerList = rule.symbolizers();
List<Graphic> markerList = convert(element);
if(markerList != null)
{
for(Graphic marker : markerList)
{
PointSymbolizer pointSymbolizer = styleFactory.createPointSymbolizer(marker, null);
symbolizerList.add(pointSymbolizer);
}
}
}
示例3: testIsPresent
import org.geotools.styling.Rule; //导入依赖的package包/类
/**
* Test method for {@link com.sldeditor.common.utils.ScaleUtil#isPresent(org.opengis.style.Rule)}.
*/
@Test
public void testIsPresent() {
assertFalse(ScaleUtil.isPresent(null));
Rule rule = DefaultSymbols.createNewRule();
assertFalse(ScaleUtil.isPresent(rule));
// Set max scale denominator
rule.setMaxScaleDenominator(10000.0);
assertTrue(ScaleUtil.isPresent(rule));
// Set both min and max scale denominator
rule.setMinScaleDenominator(100.0);
assertTrue(ScaleUtil.isPresent(rule));
// Set min scale denominator
rule.setMaxScaleDenominator(0.0);
assertTrue(ScaleUtil.isPresent(rule));
}
示例4: convertSymbols
import org.geotools.styling.Rule; //导入依赖的package包/类
/**
* Convert symbols.
*
* @param rule the rule
* @param layerName the layer name
* @param transparency the transparency
* @param element the element
*/
public void convertSymbols(Rule rule, String layerName, int transparency, JsonElement element) {
if (element == null) return;
JsonObject jsonSymbol = element.getAsJsonObject();
boolean found = false;
for(String symbolType : symbolMap.keySet())
{
JsonElement obj = jsonSymbol.get(symbolType);
if(obj != null)
{
EsriSymbolInterface esriSymbol = symbolMap.get(symbolType);
esriSymbol.convert(rule, obj, layerName, transparency);
found = true;
break;
}
}
if(!found)
{
ConsoleManager.getInstance().error(this, "Unsupported symbol : " + SymbolUtils.extractName(element));
}
}
示例5: getSampleFeatureForRule
import org.geotools.styling.Rule; //导入依赖的package包/类
/**
* Returns a sample feature for the given rule, with the following criteria: - if a sample is
* given in input is returned in output - if a sample is not given in input, scan the rule
* symbolizers to find the one with the max dimensionality, and return a sample for that
* dimensionality.
*
* @param featureType featureType used to create a sample, if none is given as input
* @param sample feature sample to be returned as is in output, if defined
* @param rule rule containing symbolizers to scan for max dimensionality
*
*/
private Feature getSampleFeatureForRule(FeatureType featureType, Feature sample,
final Rule rule) {
Symbolizer[] symbolizers = rule.getSymbolizers();
// if we don't have a sample as input, we need to create a sampleFeature
// looking at the requested symbolizers (we chose the one with the max
// dimensionality and create a congruent sample)
if (sample == null) {
int dimensionality = 1;
for (int sIdx = 0; sIdx < symbolizers.length; sIdx++) {
final Symbolizer symbolizer = symbolizers[sIdx];
if (LineSymbolizer.class.isAssignableFrom(symbolizer.getClass())) {
dimensionality = 2;
}
if (PolygonSymbolizer.class.isAssignableFrom(symbolizer.getClass())) {
dimensionality = 3;
}
}
return createSampleFeature(featureType, dimensionality);
} else {
return sample;
}
}
示例6: shouldRenderSymbol
import org.geotools.styling.Rule; //导入依赖的package包/类
/**
* Should render symbol.
*
* @param style the style
* @param ruleToRender the rule to render
* @return true, if successful
*/
private boolean shouldRenderSymbol(Style style, FeatureTypeStyle ftsToRender,
Rule ruleToRender) {
if (ruleToRender == null) {
return true;
}
for (FeatureTypeStyle fts : style.featureTypeStyles()) {
if (fts == ftsToRender) {
for (Rule rule : fts.rules()) {
if (rule == ruleToRender) {
return true;
}
}
}
}
return false;
}
示例7: getRuleTreeNode
import org.geotools.styling.Rule; //导入依赖的package包/类
/**
* Gets the rule tree node.
*
* @return the rule tree node
*/
private DefaultMutableTreeNode getRuleTreeNode() {
if (symbolTree != null) {
TreePath path = symbolTree.getSelectionPath();
DefaultMutableTreeNode lastNode = (DefaultMutableTreeNode) path.getLastPathComponent();
Object obj = lastNode.getUserObject();
if (obj instanceof Symbolizer) {
return (DefaultMutableTreeNode) lastNode.getParent();
} else if (obj instanceof Rule) {
return (DefaultMutableTreeNode) lastNode;
}
}
return rootNode;
}
示例8: removeRule
import org.geotools.styling.Rule; //导入依赖的package包/类
/**
* Removes the rule.
*
* @param ruleToDelete the rule to delete
*/
public void removeRule(Rule ruleToDelete) {
List<Rule> ruleList = (List<Rule>) this.symbolData.getFeatureTypeStyle().rules();
int indexFound = -1;
int index = 0;
for (Rule rule : ruleList) {
if (rule == ruleToDelete) {
indexFound = index;
break;
} else {
index++;
}
}
if (indexFound > -1) {
ruleList.remove(indexFound);
}
}
示例9: isRasterSymbol
import org.geotools.styling.Rule; //导入依赖的package包/类
/**
* Checks if the selected Style contains a raster symbol.
*
* @return true, if is raster symbol
*/
public boolean isRasterSymbol() {
Style style = getStyle();
if (style != null) {
for (FeatureTypeStyle fts : style.featureTypeStyles()) {
for (Rule rule : fts.rules()) {
for (Symbolizer symbolizer : rule.symbolizers()) {
if (symbolizer instanceof RasterSymbolizer) {
return true;
}
}
}
}
}
return false;
}
示例10: testNotFilter
import org.geotools.styling.Rule; //导入依赖的package包/类
@Test
public void testNotFilter() {
DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();
StyledLayerDescriptor sld = createTestSLD(dummy);
List<Rule> ruleList = getRuleList(sld);
ExtractAttributes extract = new ExtractAttributes();
Rule rule = DefaultSymbols.createNewRule();
// Try with NOT
extract = new ExtractAttributes();
Filter filter = ff.not(ff.greater(ff.literal(42.1), ff.property("dble")));
rule.setFilter(filter);
ruleList.clear();
ruleList.add(rule);
extract.extractDefaultFields(sld);
// Check fields extracted ok
List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
assertEquals(1, actualFieldnameList.size());
DataSourceAttributeData dataSourceField = actualFieldnameList.get(0);
assertEquals(Double.class, dataSourceField.getType());
}
示例11: testMultiComparatorFilter
import org.geotools.styling.Rule; //导入依赖的package包/类
@Test
public void testMultiComparatorFilter() {
DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();
StyledLayerDescriptor sld = createTestSLD(dummy);
List<Rule> ruleList = getRuleList(sld);
Rule rule = DefaultSymbols.createNewRule();
// Try with something complex
Filter filter = ff.and(ff.greater(ff.literal(42), ff.property("int")),
ff.less(ff.literal(12), ff.property("abc")));
rule.setFilter(filter);
ruleList.clear();
ruleList.add(rule);
ExtractAttributes extract = new ExtractAttributes();
extract.extractDefaultFields(sld);
// Check fields extracted ok
List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
assertEquals(2, actualFieldnameList.size());
DataSourceAttributeData dataSourceField = actualFieldnameList.get(0);
assertEquals(Integer.class, dataSourceField.getType());
}
示例12: testBinaryTemporalFilter
import org.geotools.styling.Rule; //导入依赖的package包/类
@Test
public void testBinaryTemporalFilter() {
DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();
StyledLayerDescriptor sld = createTestSLD(dummy);
List<Rule> ruleList = getRuleList(sld);
Rule rule = DefaultSymbols.createNewRule();
// Try begins
Filter filter = ff.begins(ff.property("test"), ff.literal("1234"));
rule.setFilter(filter);
ruleList.clear();
ruleList.add(rule);
ExtractAttributes extract = new ExtractAttributes();
extract.extractDefaultFields(sld);
// Check fields extracted ok
List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
assertEquals(1, actualFieldnameList.size());
DataSourceAttributeData dataSourceField = actualFieldnameList.get(0);
assertEquals(Integer.class, dataSourceField.getType());
}
示例13: testIsNull
import org.geotools.styling.Rule; //导入依赖的package包/类
@Test
public void testIsNull() {
DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();
StyledLayerDescriptor sld = createTestSLD(dummy);
List<Rule> ruleList = getRuleList(sld);
Rule rule = DefaultSymbols.createNewRule();
// Try isNull
Filter filter = ff.isNull(ff.property("test"));
rule.setFilter(filter);
ruleList.clear();
ruleList.add(rule);
ExtractAttributes extract = new ExtractAttributes();
extract.extractDefaultFields(sld);
// Check fields extracted ok
List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
assertEquals(1, actualFieldnameList.size());
DataSourceAttributeData dataSourceField = actualFieldnameList.get(0);
assertEquals(String.class, dataSourceField.getType());
}
示例14: testIsLike
import org.geotools.styling.Rule; //导入依赖的package包/类
@Test
public void testIsLike() {
DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();
StyledLayerDescriptor sld = createTestSLD(dummy);
List<Rule> ruleList = getRuleList(sld);
Rule rule = DefaultSymbols.createNewRule();
// Try isLike
Filter filter = ff.like(ff.property("test"), "abcd1");
rule.setFilter(filter);
ruleList.clear();
ruleList.add(rule);
ExtractAttributes extract = new ExtractAttributes();
extract.extractDefaultFields(sld);
// Check fields extracted ok
List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
assertEquals(1, actualFieldnameList.size());
DataSourceAttributeData dataSourceField = actualFieldnameList.get(0);
assertEquals(String.class, dataSourceField.getType());
}
示例15: testIsBetween
import org.geotools.styling.Rule; //导入依赖的package包/类
@Test
public void testIsBetween() {
DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();
StyledLayerDescriptor sld = createTestSLD(dummy);
List<Rule> ruleList = getRuleList(sld);
Rule rule = DefaultSymbols.createNewRule();
// Try isBetween
Filter filter = ff.between(ff.property("test"), ff.literal("1.23"), ff.literal(4));
rule.setFilter(filter);
ruleList.clear();
ruleList.add(rule);
ExtractAttributes extract = new ExtractAttributes();
extract.extractDefaultFields(sld);
// Check fields extracted ok
List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
assertEquals(1, actualFieldnameList.size());
DataSourceAttributeData dataSourceField = actualFieldnameList.get(0);
assertEquals(Double.class, dataSourceField.getType());
}