Package org.geotools.styling

Examples of org.geotools.styling.Rule


                    boolean doElse = true;
                    SimpleFeature feature = reader.next();

                    // applicable rules
                    for (Iterator it = ruleList.iterator(); it.hasNext();) {
                        Rule r = (Rule) it.next();
                        LOGGER.finer(new StringBuffer("applying rule: ")
                                .append(r.toString()).toString());

                        Filter filter = r.getFilter();

                        if ((filter == null) || filter.evaluate(feature)) {
                            doElse = false;
                            LOGGER.finer("processing raster-result Symobolizer ...");

                            Symbolizer[] symbolizers = r.getSymbolizers();

                            processRasterSymbolizers(feature, symbolizers,
                                    order);
                            layerCounter++;
                        }
                    }

                    if (doElse) {
                        // rules with an else filter
                        LOGGER.finer("rules with an else filter");

                        for (Iterator it = elseRuleList.iterator(); it
                                .hasNext();) {
                            Rule r = (Rule) it.next();
                            Symbolizer[] symbolizers = r.getSymbolizers();
                            LOGGER.finer("processing raster-result Symobolizer ...");

                            processRasterSymbolizers(feature, symbolizers,
                                    order);
                            layerCounter++;
View Full Code Here


    private void populateRuleLists(Rule[] rules, List ruleList,
            List elseRuleList, boolean ignoreScale) {
        final int rulesLength = rules.length;

        for (int j = 0; j < rulesLength; j++) {
            Rule r = rules[j];

            if (ignoreScale) {
                if (r.hasElseFilter()) {
                    elseRuleList.add(r);
                } else {
                    ruleList.add(r);
                }
            } else {
                if (isWithinScale(r)) {
                    if (r.hasElseFilter()) {
                        elseRuleList.add(r);
                    } else {
                        ruleList.add(r);
                    }
                }
View Full Code Here

        //process the rules, keep track of the need to apply an else filters
        boolean match = false;
        boolean hasElseFilter = false;

        for (int i = 0; i < rules.length; i++) {
            Rule rule = rules[i];
            LOGGER.finer(new StringBuffer("Applying rule: ").append(
                    rule.toString()).toString());

            //does this rule have an else filter
            if (rule.hasElseFilter()) {
                hasElseFilter = true;

                continue;
            }

            //is this rule within scale?
            if (!isWithInScale(rule, scaleDenominator)) {
                continue;
            }

            //does this rule have a filter which applies to the feature
            Filter filter = rule.getFilter();

            if ((filter == null) || filter.evaluate(feature)) {
                match = true;

                filtered.add(rule);
            }
        }

        //if no rules mached the feautre, re-run through the rules applying
        // any else filters
        if (!match && hasElseFilter) {
            //loop through again and apply all the else rules
            for (int i = 0; i < rules.length; i++) {
                Rule rule = rules[i];

                //is this rule within scale?
                if (!isWithInScale(rule, scaleDenominator)) {
                    continue;
                }

                if (rule.hasElseFilter()) {
                    filtered.add(rule);
                }
            }
        }
View Full Code Here

                // get applicable rules at the current scale
                Rule[] ftsRules = fts.getRules();
                for (int j = 0; j < ftsRules.length; j++) {
                    // getting rule
                    Rule r = ftsRules[j];

                    if (KMLUtils.isWithInScale(r, 1)) {
                        if (r.hasElseFilter()) {
                            result[ELSE_RULES].add(r);
                        } else {
                            result[RULES].add(r);
                        }
                    }
View Full Code Here

        if (rules[RULES].size() == 0 || rules[ELSE_RULES].size() > 0)
            return Filter.INCLUDE;

        List filters = new ArrayList();
        for (Iterator it = rules[RULES].iterator(); it.hasNext();) {
            Rule rule = (Rule) it.next();
            // if there is a single rule asking for all filters, we have to
            // return everything that the original filter returned already
            if (rule.getFilter() == null
                    || Filter.INCLUDE.equals(rule.getFilter()))
                return Filter.INCLUDE;
            else
                filters.add(rule.getFilter());
        }

        FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);
        return ff.or(filters);
    }
View Full Code Here

    public void testUserSpecifiedRule() throws Exception {
        //load a style with 3 rules
        Style multipleRulesStyle = getCatalog().getStyleByName(MockData.ROAD_SEGMENTS.getLocalPart()).getStyle();
        assertNotNull(multipleRulesStyle);
       
        Rule rule = multipleRulesStyle.getFeatureTypeStyles()[0].getRules()[0];
        LOGGER.info("testing single rule " + rule.getName() + " from style "
            + multipleRulesStyle.getName());

        GetLegendGraphicRequest req = new GetLegendGraphicRequest(getWMS());
        FeatureTypeInfo ftInfo = getCatalog().getFeatureTypeByName(MockData.ROAD_SEGMENTS.getNamespaceURI(), MockData.ROAD_SEGMENTS.getLocalPart());
        req.setLayer(ftInfo.getFeatureType());
        req.setStyle(multipleRulesStyle);
        req.setRule(rule);
        req.setLegendOptions(new HashMap());

        final int HEIGHT_HINT = 30;
        req.setHeight(HEIGHT_HINT);

        //use default values for the rest of parameters
        this.legendProducer.produceLegendGraphic(req);

        BufferedImage legend = this.legendProducer.getLegendGraphic();

        //was the legend painted?
        assertNotBlank("testUserSpecifiedRule", legend, LegendUtils.DEFAULT_BG_COLOR);

        //was created only one rule?
        String errMsg = "expected just one legend of height " + HEIGHT_HINT + ", for the rule "
            + rule.getName();
        int resultLegendCount = legend.getHeight() / HEIGHT_HINT;
        assertEquals(errMsg, 1, resultLegendCount);
    }
View Full Code Here

        //process the rules, keep track of the need to apply an else filters
        boolean match = false;
        boolean hasElseFilter = false;

        for (int i = 0; i < rules.length; i++) {
            Rule rule = rules[i];
            LOGGER.finer(new StringBuffer("Applying rule: ").append(rule.toString()).toString());

            //does this rule have an else filter
            if (rule.hasElseFilter()) {
                hasElseFilter = true;

                continue;
            }
            double scaleDenominator;
      try {
        scaleDenominator = RendererUtilities.calculateScale(mapContext.getAreaOfInterest(), mapContext.getMapWidth(), mapContext.getMapHeight(),100);
     
              //is this rule within scale?
              if ( !EncodeHTMLImageMap.isWithInScale(rule,scaleDenominator)) {
                continue;
              }
            } catch (TransformException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (FactoryException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
           
            //does this rule have a filter which applies to the feature
            Filter filter = rule.getFilter();

            if ((filter == null) || filter.evaluate(feature)) {
                match = true;

                filtered.add(rule);
            }
        }

        //if no rules mached the feautre, re-run through the rules applying
        // any else filters
        if (!match && hasElseFilter) {
            //loop through again and apply all the else rules
            for (int i = 0; i < rules.length; i++) {
                Rule rule = rules[i];

                if (rule.hasElseFilter()) {
                    filtered.add(rule);
                }
            }
        }
View Full Code Here

                    totalWidth = (int) Math.ceil(Math.max(img.getWidth(), totalWidth));
                    rowHeights[i] = img.getHeight();
                    totalHeight += img.getHeight();
                } else {

                    Rule rule = rules[i];
   
                    //What's the label on this rule?  We prefer to use
                    //the 'title' if it's available, but fall-back to 'name'
                    labels[i] = rule.getTitle();
                    if (labels[i] == null) labels[i] = rule.getName();
                    if (labels[i] == null) labels[i] = "";
                   
                    Graphics2D g = img.createGraphics();
                    g.setFont(labelFont);
   
View Full Code Here

    public void visit(org.geotools.styling.TextSymbolizer ts) {
        pages.push(null);
    }

    public void visit(Rule rule) {
        Rule copy = null;

        Filter filterCopy = null;

        if (rule.getFilter() != null) {
            Filter filter = rule.getFilter();
            filterCopy = copy(filter);
        }

        // modified to deal with null copies that should be skipped
        List<Symbolizer> symArray = new ArrayList<Symbolizer>();
        for (Symbolizer sym : rule.symbolizers()) {
            Symbolizer symcopy = copy(sym);
            if (symcopy != null)
                symArray.add(symcopy);
        }
        Symbolizer[] symsCopy = (Symbolizer[]) symArray.toArray(new Symbolizer[symArray.size()]);

        Graphic[] legendCopy = rule.getLegendGraphic();
        for (int i = 0; i < legendCopy.length; i++) {
            legendCopy[i] = copy(legendCopy[i]);
        }

        Description descCopy = rule.getDescription();
        descCopy = copy(descCopy);

        copy = new StyleFactoryImpl().createRule(symsCopy, descCopy, legendCopy, rule.getName(),
                filterCopy, rule.isElseFilter(), rule.getMaxScaleDenominator(), rule
                        .getMinScaleDenominator());

        if (STRICT && !copy.equals(rule)) {
            throw new IllegalStateException("Was unable to duplicate provided Rule:" + rule);
        }
        pages.push(copy);
    }
View Full Code Here

      for (int i = 0; i < ftStyles.length; i++) {
          FeatureTypeStyle fts = ftStyles[i];
          Rule[] rules = fts.getRules();
 
          for (int j = 0; j < rules.length; j++) {
              Rule r = rules[j];
 
              if (isWithInScale(r, scaleDenominator)) {
                  ruleList.add(r);
 
                  /*
 
View Full Code Here

TOP

Related Classes of org.geotools.styling.Rule

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.