Search in sources :

Example 11 with DataSourceInterface

use of com.sldeditor.datasource.DataSourceInterface in project sldeditor by robward-scisys.

the class ExpressionPanelv2 method dataSourceLoaded.

/**
 * Data source loaded.
 *
 * @param geometryType the geometry type
 * @param isConnectedToDataSourceFlag the is connected to data source flag
 */
@Override
public void dataSourceLoaded(GeometryTypeEnum geometryType, boolean isConnectedToDataSourceFlag) {
    DataSourceInterface dataSource = DataSourceFactory.getDataSource();
    propertyPanel.dataSourceLoaded(dataSource);
    expressionPanel.dataSourceLoaded(dataSource);
}
Also used : DataSourceInterface(com.sldeditor.datasource.DataSourceInterface)

Example 12 with DataSourceInterface

use of com.sldeditor.datasource.DataSourceInterface in project sldeditor by robward-scisys.

the class UserLayerDetails method updateSymbol.

/**
 * Update symbol.
 *
 * @param changedField the changed field
 */
private void updateSymbol(FieldIdEnum changedField) {
    if (!Controller.getInstance().isPopulating()) {
        UserLayer userLayer = getStyleFactory().createUserLayer();
        String name = fieldConfigVisitor.getText(FieldIdEnum.NAME);
        userLayer.setName(name);
        // Feature type constraints
        List<FeatureTypeConstraint> ftcList = fieldConfigVisitor.getFeatureTypeConstraint(FieldIdEnum.LAYER_FEATURE_CONSTRAINTS);
        if ((ftcList != null) && !ftcList.isEmpty()) {
            FeatureTypeConstraint[] ftcArray = new FeatureTypeConstraint[ftcList.size()];
            userLayer.setLayerFeatureConstraints(ftcList.toArray(ftcArray));
        }
        // Source
        GroupConfigInterface group = getGroup(GroupIdEnum.USER_LAYER_SOURCE);
        if (group != null) {
            MultiOptionGroup userLayerSourceGroup = (MultiOptionGroup) group;
            OptionGroup selectedOption = userLayerSourceGroup.getSelectedOptionGroup();
            switch(selectedOption.getId()) {
                case REMOTE_OWS_OPTION:
                    {
                        RemoteOWS remoteOWS = new RemoteOWSImpl();
                        String service = fieldConfigVisitor.getText(FieldIdEnum.REMOTE_OWS_SERVICE);
                        remoteOWS.setService(service);
                        String onlineResource = fieldConfigVisitor.getText(FieldIdEnum.REMOTE_OWS_ONLINERESOURCE);
                        remoteOWS.setOnlineResource(onlineResource);
                        userLayer.setRemoteOWS(remoteOWS);
                    }
                    break;
                case INLINE_FEATURE_OPTION:
                    {
                        String inlineFeatures = fieldConfigVisitor.getText(FieldIdEnum.INLINE_FEATURE);
                        if ((inlineFeatures != null) && (!inlineFeatures.isEmpty())) {
                            InlineFeatureUtils.setInlineFeatures(userLayer, inlineFeatures);
                        }
                    }
                    break;
                default:
                    break;
            }
        }
        StyledLayer existingStyledLayer = SelectedSymbol.getInstance().getStyledLayer();
        if (existingStyledLayer instanceof UserLayerImpl) {
            UserLayerImpl existingUserLayer = (UserLayerImpl) existingStyledLayer;
            for (Style style : existingUserLayer.userStyles()) {
                userLayer.addUserStyle(style);
            }
        }
        SelectedSymbol.getInstance().replaceStyledLayer(userLayer);
        // reduces creation of datasources
        if (changedField != null) {
            if (changedField == FieldIdEnum.INLINE_FEATURE) {
                DataSourceInterface dataSource = DataSourceFactory.getDataSource();
                if (dataSource != null) {
                    dataSource.updateUserLayers();
                }
            }
        }
        this.fireUpdateSymbol();
    }
}
Also used : RemoteOWS(org.geotools.styling.RemoteOWS) StyledLayer(org.geotools.styling.StyledLayer) RemoteOWSImpl(org.geotools.styling.RemoteOWSImpl) DataSourceInterface(com.sldeditor.datasource.DataSourceInterface) FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint) OptionGroup(com.sldeditor.ui.detail.config.base.OptionGroup) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup) UserLayerImpl(org.geotools.styling.UserLayerImpl) Style(org.geotools.styling.Style) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) UserLayer(org.geotools.styling.UserLayer) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup)

Example 13 with DataSourceInterface

use of com.sldeditor.datasource.DataSourceInterface in project sldeditor by robward-scisys.

the class FieldConfigDSProperties method dataSourceLoaded.

/*
     * (non-Javadoc)
     * 
     * @see
     * com.sldeditor.datasource.DataSourceUpdatedInterface#dataSourceLoaded(com.sldeditor.datasource
     * .impl.GeometryTypeEnum, boolean)
     */
@Override
public void dataSourceLoaded(GeometryTypeEnum geometryType, boolean isConnectedToDataSourceFlag) {
    DataSourceInterface dataSource = DataSourceFactory.getDataSource();
    attributeNameList = dataSource.getAllAttributes(false);
    populateAttributeComboBox();
}
Also used : DataSourceInterface(com.sldeditor.datasource.DataSourceInterface)

Example 14 with DataSourceInterface

use of com.sldeditor.datasource.DataSourceInterface in project sldeditor by robward-scisys.

the class RenderPanelImpl method renderRasterMap.

/**
 * Render raster map.
 *
 * @param imageSize the image size
 * @param style the style
 * @param dpi the dpi
 */
private void renderRasterMap(Rectangle imageSize, Style style, int dpi) {
    DataSourceInterface dataSource = DataSourceFactory.getDataSource();
    AbstractGridCoverage2DReader gridCoverage = dataSource.getGridCoverageReader();
    if (gridCoverage == null) {
        validSymbol = false;
    }
    GridReaderLayer rasterLayer = null;
    MapViewport viewport = null;
    List<Layer> layerList = new ArrayList<Layer>();
    if (style != null) {
        rasterLayer = new GridReaderLayer(gridCoverage, style);
        layerList.add(rasterLayer);
        viewport = new MapViewport(rasterLayer.getBounds());
    }
    boolean hasGeometry = true;
    MapContent map = new MapContent();
    map.addLayers(layerList);
    map.setViewport(viewport);
    try {
        Map<Object, Object> hints = new HashMap<Object, Object>();
        if (OVERRIDE_DPI) {
            hints.put(StreamingRenderer.DPI_KEY, dpi);
        }
        // This ensures all the labelling is cleared
        hints.put(StreamingRenderer.LABEL_CACHE_KEY, new LabelCacheImpl());
        renderer.setRendererHints(hints);
        renderer.setMapContent(map);
        BufferedImage image = new BufferedImage(imageSize.width, imageSize.height, BufferedImage.TYPE_INT_ARGB);
        Graphics2D graphics = image.createGraphics();
        if (useAntiAlias) {
            graphics.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
        }
        try {
            if (!hasGeometry) {
                graphics.setColor(Color.BLACK);
                int y = imageSize.height / 2;
                Font font = new Font(Font.SERIF, Font.BOLD, 14);
                graphics.setFont(font);
                graphics.drawString(Localisation.getString(RenderPanelImpl.class, "RenderPanelImpl.error1"), 10, y - 14);
            } else {
                if (rasterLayer != null) {
                    ReferencedEnvelope bounds = rasterLayer.getBounds();
                    renderer.paint(graphics, imageSize, bounds);
                }
                this.bImage = image;
            }
        } finally {
            graphics.dispose();
        }
    } finally {
        map.dispose();
    }
}
Also used : MapContent(org.geotools.map.MapContent) HashMap(java.util.HashMap) AbstractGridCoverage2DReader(org.geotools.coverage.grid.io.AbstractGridCoverage2DReader) ArrayList(java.util.ArrayList) LabelCacheImpl(org.geotools.renderer.label.LabelCacheImpl) GridReaderLayer(org.geotools.map.GridReaderLayer) FeatureLayer(org.geotools.map.FeatureLayer) Layer(org.geotools.map.Layer) BufferedImage(java.awt.image.BufferedImage) RenderingHints(java.awt.RenderingHints) Font(java.awt.Font) Graphics2D(java.awt.Graphics2D) DataSourceInterface(com.sldeditor.datasource.DataSourceInterface) GridReaderLayer(org.geotools.map.GridReaderLayer) ReferencedEnvelope(org.geotools.geometry.jts.ReferencedEnvelope) MapViewport(org.geotools.map.MapViewport)

Example 15 with DataSourceInterface

use of com.sldeditor.datasource.DataSourceInterface in project sldeditor by robward-scisys.

the class RenderPanelImpl method createFeature.

/**
 * Creates the feature.
 */
private void createFeature() {
    if (geometryType == GeometryTypeEnum.UNKNOWN) {
        dataLoaded = false;
    } else {
        DataSourceInterface dataSource = DataSourceFactory.getDataSource();
        if (geometryType == GeometryTypeEnum.RASTER) {
            dataLoaded = (dataSource.getGridCoverageReader() != null);
        } else {
            featureList = dataSource.getExampleFeatureSource();
            dataLoaded = true;
        }
    }
}
Also used : DataSourceInterface(com.sldeditor.datasource.DataSourceInterface)

Aggregations

DataSourceInterface (com.sldeditor.datasource.DataSourceInterface)24 Test (org.junit.Test)7 CreateDataSourceInterface (com.sldeditor.datasource.impl.CreateDataSourceInterface)6 ArrayList (java.util.ArrayList)6 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)5 SLDEditorFile (com.sldeditor.datasource.SLDEditorFile)4 File (java.io.File)4 DataSourceConnectorInterface (com.sldeditor.common.DataSourceConnectorInterface)3 DataSourcePropertiesInterface (com.sldeditor.common.DataSourcePropertiesInterface)3 FieldConfigGeometryField (com.sldeditor.ui.detail.config.FieldConfigGeometryField)3 HashMap (java.util.HashMap)3 UndoEvent (com.sldeditor.common.undo.UndoEvent)2 CheckAttributeInterface (com.sldeditor.datasource.checks.CheckAttributeInterface)2 FileTreeNode (com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode)2 FieldConfigDSProperties (com.sldeditor.ui.detail.config.FieldConfigDSProperties)2 WindowEvent (java.awt.event.WindowEvent)2 FileInputStream (java.io.FileInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2