Search in sources :

Example 1 with RuleRenderOptions

use of com.sldeditor.ui.render.RuleRenderOptions in project sldeditor by robward-scisys.

the class RuleRenderVisitorTest method testRuleRenderVisitor.

/**
 * Test rule render visitor.
 */
@Test
public void testRuleRenderVisitor() {
    StyledLayerDescriptor sld = createSLD();
    StyledLayer styledLayer = sld.layers().get(0);
    if (styledLayer instanceof NamedLayerImpl) {
        NamedLayerImpl namedLayerImpl = (NamedLayerImpl) styledLayer;
        Style style = namedLayerImpl.styles().get(0);
        FeatureTypeStyle ftsToRender = style.featureTypeStyles().get(0);
        // Just find matching feature type style
        int symbolIndex = 0;
        RuleRenderVisitor visitor = new RuleRenderVisitor(ftsToRender, null, symbolIndex, new RuleRenderOptions());
        style.accept(visitor);
        Style copy = (Style) visitor.getCopy();
        Rule ruleToRender = ftsToRender.rules().get(0);
        Rule actualRule = copy.featureTypeStyles().get(0).rules().get(0);
        // Filters should be null
        assertNull(actualRule.getFilter());
        assertEquals(ruleToRender.symbolizers(), actualRule.symbolizers());
        // Now try and find 2nd rule, 2nd symbolizer
        ruleToRender = ftsToRender.rules().get(1);
        symbolIndex = 1;
        visitor = new RuleRenderVisitor(ftsToRender, ruleToRender, symbolIndex, new RuleRenderOptions());
        style.accept(visitor);
        copy = (Style) visitor.getCopy();
        assertEquals(1, copy.featureTypeStyles().get(0).rules().size());
        actualRule = copy.featureTypeStyles().get(0).rules().get(0);
        assertNull(actualRule.getFilter());
        assertEquals(1, actualRule.symbolizers().size());
        assertEquals(ruleToRender.symbolizers().get(1), actualRule.symbolizers().get(0));
    }
}
Also used : RuleRenderOptions(com.sldeditor.ui.render.RuleRenderOptions) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) RuleRenderVisitor(com.sldeditor.render.RuleRenderVisitor) StyledLayer(org.geotools.styling.StyledLayer) NamedLayerImpl(org.geotools.styling.NamedLayerImpl) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) Test(org.junit.jupiter.api.Test)

Example 2 with RuleRenderOptions

use of com.sldeditor.ui.render.RuleRenderOptions in project sldeditor by robward-scisys.

the class RuleRenderOptionsTest method test.

@Test
public void test() {
    RuleRenderOptions options = new RuleRenderOptions();
    assertTrue(options.isTransformationApplied() == false);
    options.setApplyTransformation(true);
    assertTrue(options.isTransformationApplied() == true);
}
Also used : RuleRenderOptions(com.sldeditor.ui.render.RuleRenderOptions) Test(org.junit.jupiter.api.Test)

Example 3 with RuleRenderOptions

use of com.sldeditor.ui.render.RuleRenderOptions in project sldeditor by robward-scisys.

the class RenderOptionsPanel method populate.

/**
 * Populate.
 */
private void populate() {
    RuleRenderOptions options = this.renderSymbol.getRuleRenderOptions();
    applyTransformationCheckBox.setSelected(options.isTransformationApplied());
}
Also used : RuleRenderOptions(com.sldeditor.ui.render.RuleRenderOptions)

Example 4 with RuleRenderOptions

use of com.sldeditor.ui.render.RuleRenderOptions in project sldeditor by robward-scisys.

the class RenderOptionsPanel method createUI.

/**
 * Creates the ui.
 */
private void createUI() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    applyTransformationCheckBox = new JCheckBox(Localisation.getString(RenderOptionsPanel.class, "RenderOptionsPanel.applyTransformation"));
    applyTransformationCheckBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            RuleRenderOptions options = renderSymbol.getRuleRenderOptions();
            options.setApplyTransformation(applyTransformationCheckBox.isSelected());
            updateSymbols();
        }
    });
// Hide for now
// add(applyTransformationCheckBox);
}
Also used : JCheckBox(javax.swing.JCheckBox) RuleRenderOptions(com.sldeditor.ui.render.RuleRenderOptions) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout)

Aggregations

RuleRenderOptions (com.sldeditor.ui.render.RuleRenderOptions)4 Test (org.junit.jupiter.api.Test)2 RuleRenderVisitor (com.sldeditor.render.RuleRenderVisitor)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 BoxLayout (javax.swing.BoxLayout)1 JCheckBox (javax.swing.JCheckBox)1 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)1 NamedLayerImpl (org.geotools.styling.NamedLayerImpl)1 Rule (org.geotools.styling.Rule)1 Style (org.geotools.styling.Style)1 StyledLayer (org.geotools.styling.StyledLayer)1 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)1