本文整理汇总了Java中org.opengis.style.Rule类的典型用法代码示例。如果您正苦于以下问题:Java Rule类的具体用法?Java Rule怎么用?Java Rule使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Rule类属于org.opengis.style包,在下文中一共展示了Rule类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: editFilter
import org.opengis.style.Rule; //导入依赖的package包/类
/**
* Edits the filter.
*
* @param filterFieldId the filter field id
*/
protected void editFilter(FieldIdEnum filterFieldId) {
FilterPanelInterface filterPanel = ExpressionPanelFactory.getFilterPanel(null);
String panelTitle = Localisation.getString(RuleDetails.class, "RuleDetails.panelTitle");
filterPanel.configure(panelTitle, Object.class,
SelectedSymbol.getInstance().isRasterSymbol());
Rule rule = SelectedSymbol.getInstance().getRule();
if (rule != null) {
filterPanel.populate(rule.getFilter());
}
if (filterPanel.showDialog()) {
originalFilter = filterPanel.getFilter();
fieldConfigVisitor.populateTextField(filterFieldId, filterPanel.getFilterString());
updateSymbol();
}
}
示例2: isPresent
import org.opengis.style.Rule; //导入依赖的package包/类
/**
* Checks if rule has minimum or maximum scale denominator set.
* Returns false if rule is null.
*
* @param rule the rule
* @return true, if minimum or maximum scale denominator set
*/
public static boolean isPresent(Rule rule) {
if(rule == null)
{
return false;
}
return (!isNotSet(rule.getMinScaleDenominator()) || !isNotSet(rule.getMaxScaleDenominator()));
}
示例3: populateStandardData
import org.opengis.style.Rule; //导入依赖的package包/类
/**
* Populate standard data.
*
* @param rule the rule
*/
protected void populateStandardData(Rule rule) {
StandardData standardData = new StandardData();
if (rule != null) {
standardData.name = rule.getName();
standardData.description = (Description) rule.getDescription();
}
populateStandardData(standardData);
}
示例4: isPresent
import org.opengis.style.Rule; //导入依赖的package包/类
/**
* Checks if rule has minimum or maximum scale denominator set. Returns false if rule is null.
*
* @param rule the rule
* @return true, if minimum or maximum scale denominator set
*/
public static boolean isPresent(Rule rule) {
if (rule == null) {
return false;
}
return (!isNotSet(rule.getMinScaleDenominator())
|| !isNotSet(rule.getMaxScaleDenominator()));
}
示例5: ruleInScale
import org.opengis.style.Rule; //导入依赖的package包/类
/**
* This method evaluates the rule against the current scale denominator.
*
* @param rule the current rule to be checked
* @param currentScaleDenominator the current scale denominator
* @return true if the current rule matches to the current scale denominator, otherwise false
*/
private boolean ruleInScale(Rule rule, double currentScaleDenominator) {
//true if within range or no cale denominator set
boolean inScale = true;
if (rule.getMinScaleDenominator() > 0 && currentScaleDenominator < rule.getMinScaleDenominator()) {
inScale = false;
}
if (rule.getMaxScaleDenominator() < Double.POSITIVE_INFINITY && currentScaleDenominator > rule.getMaxScaleDenominator()) {
inScale = false;
}
return inScale;
}
示例6: populate
import org.opengis.style.Rule; //导入依赖的package包/类
/**
* Populate.
*
* @param selectedSymbol the selected symbol
*/
/*
* (non-Javadoc)
*
* @see com.sldeditor.ui.iface.PopulateDetailsInterface#populate(com.sldeditor.ui.detail.selectedsymbol.SelectedSymbol)
*/
@Override
public void populate(SelectedSymbol selectedSymbol) {
boolean rangeSet = false;
String minScaleText = "";
String maxScaleText = "";
if (selectedSymbol != null) {
Rule rule = selectedSymbol.getRule();
if (rule != null) {
populateStandardData(rule);
originalFilter = rule.getFilter();
String filterString = "";
if (originalFilter != null) {
try {
filterString = CQL.toCQL(originalFilter);
} catch (Exception e) {
// Do nothing
}
}
fieldConfigVisitor.populateTextField(FieldIdEnum.FILTER, filterString);
rangeSet = ScaleUtil.isPresent(rule);
minScaleText = ScaleUtil.getValue(rule.getMinScaleDenominator());
maxScaleText = ScaleUtil.getValue(rule.getMaxScaleDenominator());
fieldConfigVisitor.populateBooleanField(FieldIdEnum.ELSE_FILTER,
rule.isElseFilter());
}
}
fieldConfigVisitor.populateTextField(FieldIdEnum.MINIMUM_SCALE, minScaleText);
fieldConfigVisitor.populateTextField(FieldIdEnum.MAXIMUM_SCALE, maxScaleText);
populateScaleRange(rangeSet);
}
示例7: updateSymbol
import org.opengis.style.Rule; //导入依赖的package包/类
/**
* Update symbol.
*/
private void updateSymbol() {
if (!Controller.getInstance().isPopulating()) {
StandardData standardData = getStandardData();
double minScale = getMinimumValue(fieldConfigManager.get(FieldIdEnum.MINIMUM_SCALE));
double maxScale = getMaximumValue(fieldConfigManager.get(FieldIdEnum.MAXIMUM_SCALE));
//
// Read filter string
//
String filterText = fieldConfigVisitor.getText(FieldIdEnum.FILTER);
Filter filter = originalFilter;
if (originalFilter == null) {
try {
if (!filterText.isEmpty()) {
filter = CQL.toFilter(filterText);
}
} catch (CQLException e) {
filter = originalFilter;
ConsoleManager.getInstance().exception(this, e);
}
}
//
// Use existing symbolizers
//
org.geotools.styling.Rule existingRule = SelectedSymbol.getInstance().getRule();
if (existingRule != null) {
List<org.geotools.styling.Symbolizer> symbolizerList = existingRule.symbolizers();
org.geotools.styling.Symbolizer[] symbolizerArray =
new org.geotools.styling.Symbolizer[symbolizerList
.size()];
int index = 0;
for (org.geotools.styling.Symbolizer symbolizer : symbolizerList) {
symbolizerArray[index] = symbolizer;
index++;
}
//
// Legend
//
GraphicLegend existingLegend = existingRule.getLegend();
Graphic[] legendGraphics = null;
if (existingLegend != null) {
int legendGraphicCount = existingLegend.graphicalSymbols().size();
legendGraphics = new Graphic[legendGraphicCount];
index = 0;
for (GraphicalSymbol graphicalSymbol : existingLegend.graphicalSymbols()) {
legendGraphics[index] = (Graphic) graphicalSymbol;
index++;
}
} else {
legendGraphics = new Graphic[0];
}
//
// Else filter
//
boolean isElseFilter = fieldConfigVisitor.getBoolean(FieldIdEnum.ELSE_FILTER);
//
// Create new rule object
//
Rule rule = getStyleFactory().createRule(symbolizerArray, standardData.description,
legendGraphics, standardData.name, filter, isElseFilter, maxScale,
minScale);
SelectedSymbol.getInstance().replaceRule((org.geotools.styling.Rule) rule);
this.fireUpdateSymbol();
}
}
}
示例8: processSymbolizers
import org.opengis.style.Rule; //导入依赖的package包/类
/**
* All geometries that are generated by this style with the symbolizers are returned by this method. If no
* symbolizer has been defined the original geometry is returned.
*
* @param style the style for the feature containing all rules
* @param feature the feature that should be rendered
* @return all geometries that can be generated by the symbolizers or the original geometry if no symbolizers are defined
*/
private List<Geometry> processSymbolizers(Style style, SimpleFeature feature, double currentScaleDenominator) {
List<Geometry> geometryList = new ArrayList<>();
if (style != null && feature != null) {
for (FeatureTypeStyle featureTypeStyle : style.featureTypeStyles()) {
for (Rule rule : featureTypeStyle.rules()) {
if (ruleInScale(rule, currentScaleDenominator)) {
Filter filter = rule.getFilter();
//If no filter is present or the feature evaluates positive against the filter
if (filter == null || filter.evaluate(feature)) {
Geometry geometry = null;
//If no symbolizers are present, get the default geometry
if (rule.symbolizers() == null || rule.symbolizers().isEmpty()) {
geometry = (Geometry) feature.getDefaultGeometry();
if (geometry != null) {
geometryList.add(geometry);
}
//If symbolizers are present get the geometry from the symbolizers (especially
//if geometric expressions have to be executed
} else {
for (Symbolizer symbolizer : rule.symbolizers()) {
if (symbolizer instanceof AbstractSymbolizer) {
boolean duplicateGeometry = false;
geometry = findGeometry(feature, (AbstractSymbolizer) symbolizer);
//Check for duplicate geometries, e.g. if you use a ordinary wms style with
//foreground and background rendering then the geometries could be duplicate.
for (Geometry geometryInList : geometryList) {
if (geometry.equals(geometryInList)) {
duplicateGeometry = true;
}
}
if (!duplicateGeometry && geometry != null) {
geometryList.add(geometry);
}
}
}
}
}
}
}
}
}
return geometryList;
}