Search in sources :

Example 1 with DataSourceInterface

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

the class FieldConfigDSPropertiesTest method testUndoAction.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigDSProperties#undoAction(com.sldeditor.common.undo.UndoInterface)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigDSProperties#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 */
@Test
public void testUndoAction() {
    boolean valueOnly = true;
    TestDataSource testDataSource = new TestDataSource();
    @SuppressWarnings("unused") DataSourceInterface dataSource = DataSourceFactory.createDataSource(testDataSource);
    FieldConfigDSProperties field = new FieldConfigDSProperties(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
    field.dataSourceLoaded(GeometryTypeEnum.POLYGON, false);
    assertNull(field.getStringValue());
    // Now create the ui
    field.createUI();
    String expectedValue1 = "Date_2";
    field.populateField(expectedValue1);
    String expectedValue2 = "String_3";
    field.populateField(expectedValue2);
    UndoManager.getInstance().undo();
    String actualValueString = field.getStringValue();
    assertTrue(expectedValue1.compareTo(actualValueString) == 0);
    UndoManager.getInstance().redo();
    actualValueString = field.getStringValue();
    assertTrue(expectedValue2.compareTo(actualValueString) == 0);
    // Increase the code coverage
    field.undoAction(null);
    field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, Double.valueOf(0), Double.valueOf(23)));
    field.redoAction(null);
    field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, Double.valueOf(0), Double.valueOf(54)));
    DataSourceFactory.reset();
}
Also used : DataSourceInterface(com.sldeditor.datasource.DataSourceInterface) CreateDataSourceInterface(com.sldeditor.datasource.impl.CreateDataSourceInterface) UndoEvent(com.sldeditor.common.undo.UndoEvent) FieldConfigDSProperties(com.sldeditor.ui.detail.config.FieldConfigDSProperties) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 2 with DataSourceInterface

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

the class DefaultSymbols method createArrow.

/**
 * Creates the arrow.
 *
 * @param angleFunction the angle function
 * @param locationFunction the location function
 * @param markerSymbol the marker symbol
 * @param isSourceArrow the is source arrow
 * @return the point symbolizer
 */
private static PointSymbolizer createArrow(FunctionName angleFunction, FunctionName locationFunction, String markerSymbol, boolean isSourceArrow) {
    String name = isSourceArrow ? Localisation.getString(SLDTreeTools.class, "TreeItem.sourceArrow") : Localisation.getString(SLDTreeTools.class, "TreeItem.destArrow");
    PointSymbolizer pointSymbolizer = createDefaultPointSymbolizer();
    pointSymbolizer.setName(name);
    Graphic graphic = pointSymbolizer.getGraphic();
    graphic.setSize(ff.literal(DEFAULT_ARROW_SIZE));
    List<GraphicalSymbol> graphicalSymbolList = graphic.graphicalSymbols();
    MarkImpl mark = (MarkImpl) graphicalSymbolList.get(0);
    Expression wellKnownName = ff.literal(markerSymbol);
    mark.setWellKnownName(wellKnownName);
    mark.getFill().setColor(ff.literal(DEFAULT_COLOUR));
    // Arrow rotation
    List<Expression> rotationArgumentList = new ArrayList<Expression>();
    String geometryFieldName = "geom";
    DataSourceInterface dsInfo = DataSourceFactory.getDataSource();
    if (dsInfo != null) {
        geometryFieldName = dsInfo.getGeometryFieldName();
    }
    rotationArgumentList.add(ff.property(geometryFieldName));
    Expression rotation = FunctionManager.getInstance().createExpression(angleFunction, rotationArgumentList);
    if (isSourceArrow) {
        graphic.setRotation(ff.add(ff.literal(DEGREES_180), rotation));
    } else {
        graphic.setRotation(rotation);
    }
    AnchorPoint anchorPoint = styleFactory.anchorPoint(ff.literal(0.5), ff.literal(0.5));
    graphic.setAnchorPoint(anchorPoint);
    // Set location of the arrow head
    List<Expression> endPointArgumentList = new ArrayList<Expression>();
    endPointArgumentList.add(ff.property(geometryFieldName));
    Expression geometry = FunctionManager.getInstance().createExpression(locationFunction, endPointArgumentList);
    pointSymbolizer.setGeometry(geometry);
    return pointSymbolizer;
}
Also used : DataSourceInterface(com.sldeditor.datasource.DataSourceInterface) PointSymbolizer(org.geotools.styling.PointSymbolizer) AnchorPoint(org.geotools.styling.AnchorPoint) Expression(org.opengis.filter.expression.Expression) Graphic(org.geotools.styling.Graphic) GraphicalSymbol(org.opengis.style.GraphicalSymbol) ArrayList(java.util.ArrayList) MarkImpl(org.geotools.styling.MarkImpl) SLDTreeTools(com.sldeditor.ui.tree.SLDTreeTools)

Example 3 with DataSourceInterface

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

the class FilterPanelv2 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 4 with DataSourceInterface

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

the class FilterPanelv2 method closeDialog.

/**
 * Close dialog.
 *
 * @param okButton the ok button
 */
private void closeDialog(boolean okButton) {
    okButtonPressed = okButton;
    DataSourceInterface dataSource = DataSourceFactory.getDataSource();
    if (dataSource != null) {
        dataSource.removeListener(this);
    }
    setVisible(false);
}
Also used : DataSourceInterface(com.sldeditor.datasource.DataSourceInterface)

Example 5 with DataSourceInterface

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

the class VectorTool method setDataSource.

/**
 * Sets the data source.
 *
 * @param featureClassNode the new data source
 */
protected void setDataSource(DatabaseFeatureClassNode featureClassNode) {
    DatabaseClientInterface dbClient = DatabaseConnectionManager.getInstance().getConnectionMap().get(featureClassNode.getConnectionData());
    if (dbClient != null) {
        ConsoleManager.getInstance().information(this, String.format("%s : %s", Localisation.getString(VectorTool.class, "VectorTool.setDataSource"), featureClassNode.toString()));
        // Vector file
        DataSourcePropertiesInterface dsProperties = SLDEditorFile.getInstance().getDataSource();
        DataSourceConnectorInterface dsc = DataSourceConnectorFactory.getDataSource(dbClient.getClass());
        dsProperties = dsc.getDataSourceProperties(dbClient.getDBConnectionParams());
        dsProperties.setFilename(featureClassNode.toString());
        SLDEditorFile.getInstance().setDataSource(dsProperties);
        DataSourceInterface dataSource = DataSourceFactory.createDataSource(null);
        if (dataSource != null) {
            dataSource.connect(featureClassNode.toString(), SLDEditorFile.getInstance(), CheckAttributeFactory.getCheckList());
        }
    }
}
Also used : DataSourceInterface(com.sldeditor.datasource.DataSourceInterface) DatabaseClientInterface(com.sldeditor.extension.filesystem.database.client.DatabaseClientInterface) DataSourceConnectorInterface(com.sldeditor.common.DataSourceConnectorInterface) DataSourcePropertiesInterface(com.sldeditor.common.DataSourcePropertiesInterface)

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