public static void main(String[] args) throws Exception { final JFrame jFrame = new JFrame("Output parameter Definition Form"); Container contentPane = jFrame.getContentPane(); if (args.length == 0) { throw new IllegalArgumentException("Missing argument to product file."); } Product sourceProduct = ProductIO.readProduct(args[0]); CoordinateReferenceSystem targetCrs = CRS.decode("EPSG:32632"); OutputGeometryFormModel model = new OutputGeometryFormModel(sourceProduct, targetCrs); OutputGeometryForm form = new OutputGeometryForm(model); contentPane.add(form); jFrame.setSize(400, 600); jFrame.setLocationRelativeTo(null); jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { jFrame.setVisible(true); } }); } }
public OutputGeometryForm(OutputGeometryFormModel model) { context = new BindingContext(model.getPropertySet()); createUI(); }
@Override protected void onReset() { // final Product collocationProduct = collocationCrsUI.getCollocationProduct(); ImageGeometry imageGeometry; //if (collocationCrsUI.getRadioButton().isSelected() && collocationProduct != null) { // imageGeometry = ImageGeometry.createCollocationTargetGeometry(sourceProduct, collocationProduct); // } else { imageGeometry = ImageGeometry.createTargetGeometry(sourceProduct, crs, null, null, null, null, null, null, null, null, null); //} outputGeometryFormModel.resetToDefaults(imageGeometry); } }
public OutputGeometryFormModel(PropertySet sourcePropertySet) { init(null, null, getFitProductSize(sourcePropertySet), getReferencePixelLocation(sourcePropertySet), sourcePropertySet); }
public OutputGeometryFormModel(OutputGeometryFormModel formModel) { init(formModel.sourceProduct, formModel.targetCrs, formModel.fitProductSize, formModel.referencePixelLocation, formModel.getPropertySet()); }
private void updateCRS() { final Product sourceProduct = getSourceProduct(); try { if (sourceProduct != null) { crs = crsSelectionPanel.getCrs(ProductUtils.getCenterGeoPos(sourceProduct)); infoForm.setCenterPos(ProductUtils.getCenterGeoPos(sourceProduct)); if (outputGeometryModel != null) { outputGeometryModel.setSourceProduct(sourceProduct); } if (crs != null) { infoForm.setCrsInfoText(crs.getName().getCode(), crs.toString()); } else { infoForm.setCrsErrorText("No valid 'Coordinate Reference System' selected."); } } else { infoForm.setCrsErrorText("No source product selected."); crs = null; } } catch (FactoryException e) { infoForm.setCrsErrorText(e.getMessage()); crs = null; } if (outputGeometryModel != null) { outputGeometryModel.setTargetCrs(crs); } updateOutputParameterState(); }
void prepareHide() { sourceProductSelector.releaseProducts(); crsSelectionPanel.prepareHide(); if (outputGeometryModel != null) { outputGeometryModel.setSourceProduct(null); } }
private void updateCRS() { final Product sourceProduct = getSourceProduct(); try { if (sourceProduct != null) { crs = crsSelectionPanel.getCrs(ProductUtils.getCenterGeoPos(sourceProduct)); if (crs != null) { infoForm.setCrsInfoText(crs.getName().getCode(), crs.toString()); } else { infoForm.setCrsErrorText("No valid 'Coordinate Reference System' selected."); } } else { infoForm.setCrsErrorText("No source product selected."); crs = null; } } catch (FactoryException e) { infoForm.setCrsErrorText(e.getMessage()); crs = null; } if (outputGeometryModel != null) { outputGeometryModel.setTargetCrs(crs); } updateOutputParameterState(); }
private OutputGeometryFormModel(Product sourceProduct, ImageGeometry imageGeometry) { init(sourceProduct, imageGeometry.getMapCrs(), FIT_PRODUCT_SIZE_DEFAULT, REFERENCE_PIXEL_DEFAULT, PropertyContainer.createObjectBacked(imageGeometry)); }
private void init(Product sourceProduct, CoordinateReferenceSystem targetCrs, boolean fitProductSize, int referencePixelLocation, PropertySet sourcePropertySet) { this.sourceProduct = sourceProduct; this.targetCrs = targetCrs; this.fitProductSize = fitProductSize; this.referencePixelLocation = referencePixelLocation; this.propertyContainer = PropertyContainer.createValueBacked(ImageGeometry.class); configurePropertyContainer(propertyContainer); Property[] properties = sourcePropertySet.getProperties(); for (Property property : properties) { if (propertyContainer.isPropertyDefined(property.getName())) { propertyContainer.setValue(property.getName(), property.getValue()); } } }
@Override public void selectionChanged(SelectionChangeEvent event) { final Product sourceProduct = getSourceProduct(); updateTargetProductName(sourceProduct); GeoPos centerGeoPos = null; if (sourceProduct != null) { centerGeoPos = ProductUtils.getCenterGeoPos(sourceProduct); } infoForm.setCenterPos(centerGeoPos); if (outputGeometryModel != null) { outputGeometryModel.setSourceProduct(sourceProduct); } updateCRS(); } });
PropertySet container = outputGeometryModel.getPropertySet(); paramMap.put("referencePixelX", container.getValue("referencePixelX")); paramMap.put("referencePixelY", container.getValue("referencePixelY"));
workCopy = new OutputGeometryFormModel(outputGeometryModel); } else { final Product collocationProduct = collocationCrsUI.getCollocationProduct(); if (collocationCrsUI.getRadioButton().isSelected() && collocationProduct != null) { workCopy = new OutputGeometryFormModel(sourceProduct, collocationProduct); } else { workCopy = new OutputGeometryFormModel(sourceProduct, crs);
@Override protected void onReset() { final Product collocationProduct = collocationCrsUI.getCollocationProduct(); ImageGeometry imageGeometry; if (collocationCrsUI.getRadioButton().isSelected() && collocationProduct != null) { imageGeometry = ImageGeometry.createCollocationTargetGeometry(sourceProduct, collocationProduct); } else { imageGeometry = ImageGeometry.createTargetGeometry(sourceProduct, crs, null, null, null, null, null, null, null, null, null); } outputGeometryFormModel.resetToDefaults(imageGeometry); } }
PropertySet container = outputGeometryModel.getPropertySet(); parameterMap.put("referencePixelX", container.getValue("referencePixelX")); parameterMap.put("referencePixelY", container.getValue("referencePixelY"));
workCopy = new OutputGeometryFormModel(outputGeometryModel); } else { workCopy = new OutputGeometryFormModel(sourceProduct, crs);
private void updateProductSize() { int width = 0; int height = 0; final Product sourceProduct = getSourceProduct(); if (sourceProduct != null && crs != null) { if (!preserveResolutionCheckBox.isSelected() && outputGeometryModel != null) { PropertySet container = outputGeometryModel.getPropertySet(); width = container.getValue("width"); height = container.getValue("height"); } else { ImageGeometry iGeometry; // final Product collocationProduct = collocationCrsUI.getCollocationProduct(); // if (collocationCrsUI.getRadioButton().isSelected() && collocationProduct != null) { // iGeometry = ImageGeometry.createCollocationTargetGeometry(sourceProduct, collocationProduct); // } else { iGeometry = ImageGeometry.createTargetGeometry(sourceProduct, crs, null, null, null, null, null, null, null, null, null); // } Rectangle imageRect = iGeometry.getImageRect(); width = imageRect.width; height = imageRect.height; } } infoForm.setWidth(width); infoForm.setHeight(height); }
outputGeometryModel = new OutputGeometryFormModel(propertySet); reprojectionContainer.setValue(Model.PRESERVE_RESOLUTION, false); } else {
private void updateProductSize() { int width = 0; int height = 0; final Product sourceProduct = getSourceProduct(); if (sourceProduct != null && crs != null) { if (!reprojectionModel.preserveResolution && outputGeometryModel != null) { PropertySet container = outputGeometryModel.getPropertySet(); width = container.getValue("width"); height = container.getValue("height"); } else { ImageGeometry iGeometry; final Product collocationProduct = collocationCrsUI.getCollocationProduct(); if (collocationCrsUI.getRadioButton().isSelected() && collocationProduct != null) { iGeometry = ImageGeometry.createCollocationTargetGeometry(sourceProduct, collocationProduct); } else { iGeometry = ImageGeometry.createTargetGeometry(sourceProduct, crs, null, null, null, null, null, null, null, null, null); } Rectangle imageRect = iGeometry.getImageRect(); width = imageRect.width; height = imageRect.height; } } infoForm.setWidth(width); infoForm.setHeight(height); }