Search in sources :

Example 31 with StyleWrapper

use of com.sldeditor.common.data.StyleWrapper in project sldeditor by robward-scisys.

the class RenderSymbolTest method createSLD.

/**
 * Creates the sld.
 *
 * @return the styled layer descriptor
 */
private StyledLayerDescriptor createSLD() {
    String sldContents = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" + "<StyledLayerDescriptor version=\"1.0.0\" " + "    xsi:schemaLocation=\"http://www.opengis.net/sld StyledLayerDescriptor.xsd\" " + "    xmlns=\"http://www.opengis.net/sld\" " + "    xmlns:ogc=\"http://www.opengis.net/ogc\" " + "    xmlns:xlink=\"http://www.w3.org/1999/xlink\" " + "    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" + "  <NamedLayer>" + "    <Name>Attribute-based point</Name>" + "    <UserStyle>" + "      <Title>GeoServer SLD Cook Book: Attribute-based point</Title>" + "      <FeatureTypeStyle>" + "        <Rule>" + "          <Name>SmallPop</Name>" + "          <Title>1 to 50000</Title>" + "          <ogc:Filter>" + "            <ogc:PropertyIsLessThan>" + "              <ogc:PropertyName>pop</ogc:PropertyName>" + "              <ogc:Literal>50000</ogc:Literal>" + "            </ogc:PropertyIsLessThan>" + "          </ogc:Filter>" + "          <PointSymbolizer>" + "            <Graphic>" + "              <Mark>" + "                <WellKnownName>star</WellKnownName>" + "                <Fill>" + "                  <CssParameter name=\"fill\">#0033CC</CssParameter>" + "                </Fill>" + "              </Mark>" + "              <Rotation>" + "                <ogc:PropertyName>angle</ogc:PropertyName>" + "              </Rotation>" + "              <Size>" + "                <ogc:PropertyName>size</ogc:PropertyName>" + "              </Size>" + "            </Graphic>" + "          </PointSymbolizer>" + "        </Rule>" + "        <Rule>" + "          <Name>MediumPop</Name>" + "          <Title>50000 to 500000</Title>" + "          <ogc:Filter>" + "            <ogc:PropertyIsLessThan>" + "              <ogc:PropertyName>pop</ogc:PropertyName>" + "              <ogc:Literal>500000</ogc:Literal>" + "            </ogc:PropertyIsLessThan>" + "          </ogc:Filter>" + "          <PointSymbolizer>" + "            <Graphic>" + "              <Mark>" + "                <WellKnownName>star</WellKnownName>" + "                <Fill>" + "                  <CssParameter name=\"fill\">#0033CC</CssParameter>" + "                </Fill>" + "              </Mark>" + "              <Rotation>" + "                <ogc:PropertyName>angle</ogc:PropertyName>" + "              </Rotation>" + "              <Size>" + "                <ogc:PropertyName>size</ogc:PropertyName>" + "              </Size>" + "            </Graphic>" + "          </PointSymbolizer>" + "          <PointSymbolizer>" + "            <Graphic>" + "              <Mark>" + "                <WellKnownName>circle</WellKnownName>" + "                <Fill>" + "                  <CssParameter name=\"fill\">#123456</CssParameter>" + "                </Fill>" + "              </Mark>" + "              <Rotation>" + "                <ogc:PropertyName>angle</ogc:PropertyName>" + "              </Rotation>" + "              <Size>" + "                <ogc:PropertyName>size</ogc:PropertyName>" + "              </Size>" + "            </Graphic>" + "          </PointSymbolizer>" + "        </Rule>" + "        <Rule>" + "          <Name>LargePop</Name>" + "          <Title>500000 to 900000</Title>" + "          <ogc:Filter>" + "            <ogc:PropertyIsLessThan>" + "              <ogc:PropertyName>pop</ogc:PropertyName>" + "              <ogc:Literal>900000</ogc:Literal>" + "            </ogc:PropertyIsLessThan>" + "          </ogc:Filter>" + "          <PointSymbolizer>" + "            <Graphic>" + "              <Mark>" + "                <WellKnownName>star</WellKnownName>" + "                <Fill>" + "                  <CssParameter name=\"fill\">#0033CC</CssParameter>" + "                </Fill>" + "              </Mark>" + "              <Rotation>" + "                <ogc:PropertyName>angle</ogc:PropertyName>" + "              </Rotation>" + "              <Size>" + "                <ogc:PropertyName>size</ogc:PropertyName>" + "              </Size>" + "            </Graphic>" + "          </PointSymbolizer>" + "        </Rule>" + "      </FeatureTypeStyle>" + "    </UserStyle>" + "  </NamedLayer>" + "</StyledLayerDescriptor>";
    SLDData sldData = new SLDData(new StyleWrapper(null, "test.sld"), sldContents);
    sldData.setDataSourceProperties(DataSourceConnectorFactory.getNoDataSource());
    StyledLayerDescriptor sld = SLDUtils.createSLDFromString(sldData);
    return sld;
}
Also used : SLDData(com.sldeditor.common.data.SLDData) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) StyleWrapper(com.sldeditor.common.data.StyleWrapper)

Example 32 with StyleWrapper

use of com.sldeditor.common.data.StyleWrapper in project sldeditor by robward-scisys.

the class RuleRenderVisitorTest method createSLD.

/**
 * Creates the sld.
 *
 * @return the styled layer descriptor
 */
private StyledLayerDescriptor createSLD() {
    String sldContents = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" + "<StyledLayerDescriptor version=\"1.0.0\" " + "    xsi:schemaLocation=\"http://www.opengis.net/sld StyledLayerDescriptor.xsd\" " + "    xmlns=\"http://www.opengis.net/sld\" " + "    xmlns:ogc=\"http://www.opengis.net/ogc\" " + "    xmlns:xlink=\"http://www.w3.org/1999/xlink\" " + "    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" + "  <NamedLayer>" + "    <Name>Attribute-based point</Name>" + "    <UserStyle>" + "      <Title>GeoServer SLD Cook Book: Attribute-based point</Title>" + "      <FeatureTypeStyle>" + "        <Rule>" + "          <Name>SmallPop</Name>" + "          <Title>1 to 50000</Title>" + "          <ogc:Filter>" + "            <ogc:PropertyIsLessThan>" + "              <ogc:PropertyName>pop</ogc:PropertyName>" + "              <ogc:Literal>50000</ogc:Literal>" + "            </ogc:PropertyIsLessThan>" + "          </ogc:Filter>" + "          <PointSymbolizer>" + "            <Graphic>" + "              <Mark>" + "                <WellKnownName>star</WellKnownName>" + "                <Fill>" + "                  <CssParameter name=\"fill\">#0033CC</CssParameter>" + "                </Fill>" + "              </Mark>" + "              <Rotation>" + "                <ogc:PropertyName>angle</ogc:PropertyName>" + "              </Rotation>" + "              <Size>" + "                <ogc:PropertyName>size</ogc:PropertyName>" + "              </Size>" + "            </Graphic>" + "          </PointSymbolizer>" + "        </Rule>" + "        <Rule>" + "          <Name>MediumPop</Name>" + "          <Title>50000 to 500000</Title>" + "          <ogc:Filter>" + "            <ogc:PropertyIsLessThan>" + "              <ogc:PropertyName>pop</ogc:PropertyName>" + "              <ogc:Literal>500000</ogc:Literal>" + "            </ogc:PropertyIsLessThan>" + "          </ogc:Filter>" + "          <PointSymbolizer>" + "            <Graphic>" + "              <Mark>" + "                <WellKnownName>star</WellKnownName>" + "                <Fill>" + "                  <CssParameter name=\"fill\">#0033CC</CssParameter>" + "                </Fill>" + "              </Mark>" + "              <Rotation>" + "                <ogc:PropertyName>angle</ogc:PropertyName>" + "              </Rotation>" + "              <Size>" + "                <ogc:PropertyName>size</ogc:PropertyName>" + "              </Size>" + "            </Graphic>" + "          </PointSymbolizer>" + "          <PointSymbolizer>" + "            <Graphic>" + "              <Mark>" + "                <WellKnownName>circle</WellKnownName>" + "                <Fill>" + "                  <CssParameter name=\"fill\">#123456</CssParameter>" + "                </Fill>" + "              </Mark>" + "              <Rotation>" + "                <ogc:PropertyName>angle</ogc:PropertyName>" + "              </Rotation>" + "              <Size>" + "                <ogc:PropertyName>size</ogc:PropertyName>" + "              </Size>" + "            </Graphic>" + "          </PointSymbolizer>" + "        </Rule>" + "        <Rule>" + "          <Name>LargePop</Name>" + "          <Title>500000 to 900000</Title>" + "          <ogc:Filter>" + "            <ogc:PropertyIsLessThan>" + "              <ogc:PropertyName>pop</ogc:PropertyName>" + "              <ogc:Literal>900000</ogc:Literal>" + "            </ogc:PropertyIsLessThan>" + "          </ogc:Filter>" + "          <PointSymbolizer>" + "            <Graphic>" + "              <Mark>" + "                <WellKnownName>star</WellKnownName>" + "                <Fill>" + "                  <CssParameter name=\"fill\">#0033CC</CssParameter>" + "                </Fill>" + "              </Mark>" + "              <Rotation>" + "                <ogc:PropertyName>angle</ogc:PropertyName>" + "              </Rotation>" + "              <Size>" + "                <ogc:PropertyName>size</ogc:PropertyName>" + "              </Size>" + "            </Graphic>" + "          </PointSymbolizer>" + "        </Rule>" + "      </FeatureTypeStyle>" + "    </UserStyle>" + "  </NamedLayer>" + "</StyledLayerDescriptor>";
    SLDData sldData = new SLDData(new StyleWrapper(null, "test.sld"), sldContents);
    sldData.setDataSourceProperties(DataSourceConnectorFactory.getNoDataSource());
    StyledLayerDescriptor sld = SLDUtils.createSLDFromString(sldData);
    return sld;
}
Also used : SLDData(com.sldeditor.common.data.SLDData) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) StyleWrapper(com.sldeditor.common.data.StyleWrapper)

Example 33 with StyleWrapper

use of com.sldeditor.common.data.StyleWrapper in project sldeditor by robward-scisys.

the class GeoServerReadProgress method refreshWorkspace.

/**
 * Refresh workspace.
 *
 * @param connection the connection
 * @param workspaceNode the workspace node
 */
private void refreshWorkspace(GeoServerConnection connection, GeoServerWorkspaceNode workspaceNode) {
    workspaceNode.removeAllChildren();
    Map<String, List<StyleWrapper>> styleMap = geoServerStyleMap.get(connection);
    List<StyleWrapper> styleList = styleMap.get(workspaceNode.getWorkspaceName());
    for (StyleWrapper styleWrapper : styleList) {
        GeoServerStyleNode childNode = new GeoServerStyleNode(this.handler, connection, styleWrapper);
        // It is key to invoke this on the TreeModel, and NOT DefaultMutableTreeNode
        treeModel.insertNodeInto(childNode, workspaceNode, workspaceNode.getChildCount());
    }
    treeModel.reload(workspaceNode);
}
Also used : StyleWrapper(com.sldeditor.common.data.StyleWrapper) List(java.util.List) GeoServerStyleNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerStyleNode)

Example 34 with StyleWrapper

use of com.sldeditor.common.data.StyleWrapper in project sldeditor by robward-scisys.

the class GeoServerClient method updateLayerStyles.

/**
 * Update layer styles.
 *
 * @param layer the original layer
 * @return true, if successful
 */
@Override
public boolean updateLayerStyles(GeoServerLayer layer) {
    if (layer == null) {
        return false;
    }
    StyleWrapper updatedStyle = layer.getStyle();
    boolean ok = false;
    GeoServerRESTManager manager = GeoServerRESTManagerFactory.getManager(connection);
    GeoServerRESTPublisher publisher = manager.getPublisher();
    if (publisher != null) {
        GSLayerEncoder layerEncoder = new GSLayerEncoder();
        String defaultStyle;
        if (isDefaultWorkspace(updatedStyle.getWorkspace())) {
            defaultStyle = updatedStyle.getStyle();
        } else {
            defaultStyle = updatedStyle.getWorkspace() + ":" + updatedStyle.getStyle();
        }
        layerEncoder.setDefaultStyle(defaultStyle);
        ok = publisher.configureLayer(layer.getLayerWorkspace(), layer.getLayerName(), layerEncoder);
    }
    return ok;
}
Also used : StyleWrapper(com.sldeditor.common.data.StyleWrapper) GeoServerRESTPublisher(it.geosolutions.geoserver.rest.GeoServerRESTPublisher) GSLayerEncoder(it.geosolutions.geoserver.rest.encoder.GSLayerEncoder) GeoServerRESTManager(it.geosolutions.geoserver.rest.GeoServerRESTManager)

Example 35 with StyleWrapper

use of com.sldeditor.common.data.StyleWrapper in project sldeditor by robward-scisys.

the class GeoServerClient method parseStyleInDefaultWorkspace.

/**
 * Parses the style in default workspace.
 *
 * @param reader the reader
 * @param count the count
 * @param styleList the style list
 * @return the int
 */
private int parseStyleInDefaultWorkspace(GeoServerRESTReader reader, int count, List<StyleWrapper> styleList) {
    // Read styles not in a workspace
    RESTStyleList geoServerStyleList = reader.getStyles();
    for (String style : geoServerStyleList.getNames()) {
        StyleWrapper newStyleWrapper = new StyleWrapper(DEFAULT_WORKSPACE_NAME, style);
        styleList.add(newStyleWrapper);
        if (parentObj != null) {
            parentObj.readStylesProgress(connection, count, count);
        }
        count++;
    }
    return count;
}
Also used : StyleWrapper(com.sldeditor.common.data.StyleWrapper) RESTStyleList(it.geosolutions.geoserver.rest.decoder.RESTStyleList)

Aggregations

StyleWrapper (com.sldeditor.common.data.StyleWrapper)59 SLDData (com.sldeditor.common.data.SLDData)35 Test (org.junit.Test)31 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)15 File (java.io.File)14 SLDDataInterface (com.sldeditor.common.SLDDataInterface)12 ArrayList (java.util.ArrayList)12 GeoServerConnection (com.sldeditor.common.data.GeoServerConnection)10 SLDFileHandlerTest (com.sldeditor.test.unit.extension.filesystem.file.sld.SLDFileHandlerTest)9 List (java.util.List)9 GeoServerLayer (com.sldeditor.common.data.GeoServerLayer)8 IOException (java.io.IOException)8 GeoServerInput (com.sldeditor.extension.filesystem.geoserver.GeoServerInput)7 SLDWriterInterface (com.sldeditor.common.output.SLDWriterInterface)5 GeoServerStyleNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerStyleNode)5 GeoServerWorkspaceNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode)5 HashMap (java.util.HashMap)5 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)5 SLDEditorFile (com.sldeditor.datasource.SLDEditorFile)4 NamedLayer (org.geotools.styling.NamedLayer)4