Search in sources :

Example 21 with ValueComboBoxData

use of com.sldeditor.ui.widgets.ValueComboBoxData in project sldeditor by robward-scisys.

the class CoordManagerTest method testGetInstance.

/**
 * Test method for {@link com.sldeditor.common.coordinate.CoordManager#getInstance()}.
 * Test method for {@link com.sldeditor.common.coordinate.CoordManager#getCRSList()}.
 * Test method for {@link com.sldeditor.common.coordinate.CoordManager#getCRSCode(org.opengis.referencing.crs.CoordinateReferenceSystem)}.
 * Test method for {@link com.sldeditor.common.coordinate.CoordManager#getWGS84()}.
 *
 * @throws NoSuchAuthorityCodeException the no such authority code exception
 * @throws FactoryException the factory exception
 */
@Test
public void testGetInstance() throws NoSuchAuthorityCodeException, FactoryException {
    CoordManager.getInstance().populateCRSList();
    try {
        Thread.sleep(5000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    List<ValueComboBoxData> crsList = CoordManager.getInstance().getCRSList();
    assertTrue(crsList.size() > 0);
    CoordinateReferenceSystem crs = CoordManager.getInstance().getCRS(null);
    assertNull(crs);
    crs = CoordManager.getInstance().getWGS84();
    assertTrue(crs != null);
    String code = CoordManager.getInstance().getCRSCode(null);
    assertTrue(code.compareTo("") == 0);
    code = CoordManager.getInstance().getCRSCode(crs);
    assertTrue(code.compareTo("EPSG:4326") == 0);
    String projectedCRSCode = "EPSG:27700";
    CoordinateReferenceSystem projectedCRS = CRS.decode(projectedCRSCode);
    code = CoordManager.getInstance().getCRSCode(projectedCRS);
    assertTrue(code.compareTo(projectedCRSCode) == 0);
}
Also used : CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData) Test(org.junit.Test)

Example 22 with ValueComboBoxData

use of com.sldeditor.ui.widgets.ValueComboBoxData in project sldeditor by robward-scisys.

the class ColourRampPanel method createTopPanel.

/**
 * Creates the top panel.
 */
private void createTopPanel() {
    final UndoActionInterface undoObj = this;
    JPanel topPanel = new JPanel();
    topPanel.setPreferredSize(new Dimension(BasePanel.FIELD_PANEL_WIDTH, BasePanel.WIDGET_HEIGHT));
    topPanel.setLayout(null);
    panel.add(topPanel, BorderLayout.NORTH);
    List<ValueComboBoxData> dataList = populateColourRamps(false);
    rampComboBox = new ValueComboBox();
    rampComboBox.initialiseSingle(dataList);
    rampComboBox.setBounds(BasePanel.WIDGET_X_START, 0, BasePanel.WIDGET_EXTENDED_WIDTH, BasePanel.WIDGET_HEIGHT);
    topPanel.add(rampComboBox);
    rampComboBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (!isPopulating()) {
                Integer newValueObj = rampComboBox.getSelectedIndex();
                UndoManager.getInstance().addUndoEvent(new UndoEvent(undoObj, FieldIdEnum.COLOUR_RAMP_COLOUR, oldColourRampIndex, newValueObj));
                oldColourRampIndex = newValueObj;
            }
        }
    });
    reverseCheckbox = new JCheckBox(Localisation.getString(ColourRampConfigPanel.class, "ColourRampPanel.reverse"));
    reverseCheckbox.setBounds(rampComboBox.getX() + rampComboBox.getWidth() + 20, 0, BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
    reverseCheckbox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            boolean isSelected = reverseCheckbox.isSelected();
            Boolean oldValueObj = Boolean.valueOf(!isSelected);
            Boolean newValueObj = Boolean.valueOf(isSelected);
            UndoManager.getInstance().addUndoEvent(new UndoEvent(undoObj, FieldIdEnum.COLOUR_RAMP_REVERSE, oldValueObj, newValueObj));
            reverseColourRamp(isSelected);
        }
    });
    topPanel.add(reverseCheckbox);
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) JPanel(javax.swing.JPanel) ActionEvent(java.awt.event.ActionEvent) Dimension(java.awt.Dimension) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData) FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) JCheckBox(javax.swing.JCheckBox) ValueComboBox(com.sldeditor.ui.widgets.ValueComboBox) ActionListener(java.awt.event.ActionListener)

Example 23 with ValueComboBoxData

use of com.sldeditor.ui.widgets.ValueComboBoxData in project sldeditor by robward-scisys.

the class CoordManager method getCRSCode.

/**
 * Gets the CRS code.
 *
 * @param coordinateReferenceSystem the coordinate reference system
 * @return the CRS code
 */
public String getCRSCode(CoordinateReferenceSystem coordinateReferenceSystem) {
    ReferenceIdentifier identifier = null;
    if (coordinateReferenceSystem != null) {
        Set<ReferenceIdentifier> indentifierList = coordinateReferenceSystem.getIdentifiers();
        if (indentifierList != null) {
            if (indentifierList.iterator().hasNext()) {
                identifier = indentifierList.iterator().next();
            }
        }
    }
    String code = NOT_SET_CRS;
    if (identifier != null) {
        ValueComboBoxData data = crsMap.get(identifier.toString());
        if (data != null) {
            code = data.getKey();
        }
    }
    return code;
}
Also used : ReferenceIdentifier(org.opengis.referencing.ReferenceIdentifier) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData)

Example 24 with ValueComboBoxData

use of com.sldeditor.ui.widgets.ValueComboBoxData in project sldeditor by robward-scisys.

the class CoordManager method populateCRSList.

/**
 * Populate crs list.
 */
public void populateCRSList() {
    if (isPopulated()) {
        Runnable runnable = () -> {
            VendorOptionVersion vendorOptionVersion = VendorOptionManager.getInstance().getDefaultVendorOptionVersion();
            ValueComboBoxData notSetValue = new ValueComboBoxData(NOT_SET_CRS, Localisation.getString(CoordManager.class, "common.notSet"), vendorOptionVersion);
            crsDataList.add(notSetValue);
            Hints hints = null;
            for (AuthorityFactory factory : ReferencingFactoryFinder.getCRSAuthorityFactories(hints)) {
                String authorityCode = NOT_SET_CRS;
                Citation citation = factory.getAuthority();
                if (citation != null) {
                    @SuppressWarnings("unchecked") Collection<Identifier> identifierList = (Collection<Identifier>) citation.getIdentifiers();
                    authorityCode = identifierList.iterator().next().getCode();
                }
                Set<String> codeList;
                try {
                    codeList = factory.getAuthorityCodes(CoordinateReferenceSystem.class);
                    for (String code : codeList) {
                        String fullCode = String.format("%s:%s", authorityCode, code);
                        String descriptionText = factory.getDescriptionText(code).toString();
                        String text = String.format("%s - %s", fullCode, descriptionText);
                        ValueComboBoxData value = new ValueComboBoxData(fullCode, text, vendorOptionVersion);
                        crsDataList.add(value);
                        crsMap.put(fullCode, value);
                    }
                } catch (NoSuchAuthorityCodeException e) {
                // ConsoleManager.getInstance().exception(this, e);
                } catch (FactoryException e) {
                    ConsoleManager.getInstance().exception(this, e);
                }
            }
        };
        Thread thread = new Thread(runnable);
        thread.start();
    }
}
Also used : NoSuchAuthorityCodeException(org.opengis.referencing.NoSuchAuthorityCodeException) Set(java.util.Set) Hints(org.geotools.factory.Hints) FactoryException(org.opengis.referencing.FactoryException) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData) Identifier(org.opengis.metadata.Identifier) ReferenceIdentifier(org.opengis.referencing.ReferenceIdentifier) VendorOptionVersion(com.sldeditor.common.vendoroption.VendorOptionVersion) Collection(java.util.Collection) AuthorityFactory(org.opengis.referencing.AuthorityFactory) Citation(org.opengis.metadata.citation.Citation)

Example 25 with ValueComboBoxData

use of com.sldeditor.ui.widgets.ValueComboBoxData in project sldeditor by robward-scisys.

the class StrokeDetails method getStroke.

/**
 * Gets the stroke.
 *
 * @return the stroke
 */
public Stroke getStroke() {
    Expression join = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_LINE_JOIN);
    Expression lineCap = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_LINE_CAP);
    Expression offset = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_OFFSET);
    Expression strokeWidth = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_WIDTH);
    ValueComboBoxData symbolTypeValue = fieldConfigVisitor.getComboBox(FieldIdEnum.STROKE_STYLE);
    Expression symbolType = null;
    if (symbolTypeValue != null) {
        symbolType = getFilterFactory().literal(symbolTypeValue.getKey());
    }
    List<Float> dashList = createDashArray(fieldConfigVisitor.getText(FieldIdEnum.STROKE_DASH_ARRAY));
    float[] dashes = convertDashListToArray(dashList);
    FieldConfigBase fdmFillColour = fieldConfigManager.get(FieldIdEnum.STROKE_FILL_COLOUR);
    FieldConfigColour colourField = (FieldConfigColour) fdmFillColour;
    Expression fillColour = colourField.getColourExpression();
    Expression opacity = fieldConfigVisitor.getExpression(FieldIdEnum.OVERALL_OPACITY);
    boolean isLine = true;
    if (symbolTypeValue != null) {
        isLine = (symbolTypeValue.getKey().compareTo(SOLID_LINE_KEY) == 0);
    }
    boolean fillColourEnabled = isPanelEnabled(GroupIdEnum.FILLCOLOUR);
    boolean strokeColourEnabled = isPanelEnabled(GroupIdEnum.STROKECOLOUR);
    Stroke stroke = null;
    if (isLine) {
        opacity = fieldConfigVisitor.getExpression(FieldIdEnum.LINE_FILL_OPACITY);
        stroke = getStyleFactory().stroke(fillColour, opacity, strokeWidth, join, lineCap, dashes, offset);
    } else {
        stroke = getStyleFactory().getDefaultStroke();
        AnchorPoint anchorPoint = getStyleFactory().anchorPoint(fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_ANCHOR_POINT_H), fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_ANCHOR_POINT_V));
        // default so it doesn't appear in the SLD
        if (DetailsUtilities.isSame(defaultAnchorPoint, anchorPoint)) {
            anchorPoint = null;
        }
        Displacement displacement = getStyleFactory().displacement(fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_DISPLACEMENT_X), fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_DISPLACEMENT_Y));
        // so it doesn't appear in the SLD
        if (DetailsUtilities.isSame(defaultDisplacement, displacement)) {
            displacement = null;
        }
        List<GraphicalSymbol> symbols = symbolTypeFactory.getValue(this.fieldConfigManager, symbolType, fillColourEnabled, strokeColourEnabled, selectedFillPanelId);
        Expression initalGap = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_INITIAL_GAP);
        Expression gap = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_GAP);
        Expression rotation = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_ANGLE);
        Expression symbolSize = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_SIZE);
        GraphicStroke graphicStroke = getStyleFactory().graphicStroke(symbols, opacity, symbolSize, rotation, anchorPoint, displacement, initalGap, gap);
        boolean overallOpacity = symbolTypeFactory.isOverallOpacity(PointSymbolizer.class, selectedFillPanelId);
        if (overallOpacity) {
            stroke.setOpacity(opacity);
        }
        stroke.setGraphicStroke(graphicStroke);
        stroke.setWidth(strokeWidth);
    }
    return stroke;
}
Also used : GraphicStroke(org.opengis.style.GraphicStroke) Stroke(org.geotools.styling.Stroke) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) GraphicalSymbol(org.opengis.style.GraphicalSymbol) GraphicStroke(org.opengis.style.GraphicStroke) Displacement(org.geotools.styling.Displacement) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData) AnchorPoint(org.geotools.styling.AnchorPoint) ConstantExpression(org.geotools.filter.ConstantExpression) Expression(org.opengis.filter.expression.Expression) FieldConfigColour(com.sldeditor.ui.detail.config.FieldConfigColour)

Aggregations

ValueComboBoxData (com.sldeditor.ui.widgets.ValueComboBoxData)39 ArrayList (java.util.ArrayList)13 ValueComboBox (com.sldeditor.ui.widgets.ValueComboBox)8 ActionEvent (java.awt.event.ActionEvent)8 ActionListener (java.awt.event.ActionListener)8 ValueComboBoxDataGroup (com.sldeditor.ui.widgets.ValueComboBoxDataGroup)7 Test (org.junit.Test)7 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)6 JPanel (javax.swing.JPanel)6 UndoEvent (com.sldeditor.common.undo.UndoEvent)5 Dimension (java.awt.Dimension)4 JLabel (javax.swing.JLabel)4 UndoActionInterface (com.sldeditor.common.undo.UndoActionInterface)3 GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)3 FieldConfigMarker (com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker)3 FieldPanel (com.sldeditor.ui.widgets.FieldPanel)3 BorderLayout (java.awt.BorderLayout)3 JCheckBox (javax.swing.JCheckBox)3 Expression (org.opengis.filter.expression.Expression)3 ColourRamp (com.sldeditor.colourramp.ColourRamp)2