private static boolean noSourceProductsAvailable(List<ProductLocation> productLocations) { final Map<String, Product> productList = new HashMap<String, Product>(); for (ProductLocation productLocation : productLocations) { productList.putAll(productLocation.getProducts(ProgressMonitor.NULL)); } return productList.isEmpty(); }
private static Product getFirstReprojectedSourceProduct(List<ProductLocation> productLocations) { final ProductLocation firstLocation = productLocations.get(0); return firstLocation.getProducts(ProgressMonitor.NULL).values().iterator().next(); }
@Override public List<Band> getBandsForProductLocation(ProductLocation location) { final List<Band> bands = new ArrayList<Band>(); Map<String, Product> products = location.getProducts(ProgressMonitor.NULL); for (Product product : products.values()) { String timeString = formatTimeString(product); // TODO relies on one timecoding per product... thats not good (mz, ts, 2010-07-12) for (Band band : tsProduct.getBands()) { if (band.getName().endsWith(timeString)) { bands.add(band); } } } return bands; }
private List<Product> getCompatibleProducts() { List<Product> result = new ArrayList<Product>(); for (ProductLocation productLocation : timeSeries.getProductLocations()) { for (Product product : productLocation.getProducts(ProgressMonitor.NULL).values()) { for (String variable : timeSeries.getEoVariables()) { if (timeSeries.isProductCompatible(product, variable)) { if (timeSeries.isEoVariableSelected(variable)) { result.add(product); } } } } } return result; }
private List<Product> getAllProducts(ProgressMonitor pm) { List<Product> result = new ArrayList<Product>(); pm.beginTask("Scanning product locations ...", productLocationList.size()); try { for (ProductLocation productLocation : productLocationList) { if (pm.isCanceled()) { break; } for (Product product : productLocation.getProducts(ProgressMonitor.NULL).values()) { result.add(product); } pm.worked(1); } } finally { pm.done(); } return result; }
@SuppressWarnings({"MethodWithMoreThanThreeNegations"}) private boolean allProductsOnSameGrid() { Product refProduct = null; final List<ProductLocation> productLocations = getAssistantModel().getProductLocationsModel().getProductLocations(); for (ProductLocation productLocation : productLocations) { for (Product product : productLocation.getProducts(ProgressMonitor.NULL).values()) { if (refProduct != null) { if (product != null && !refProduct.isCompatibleProduct(product, 0.1E-4f)) { return false; } } else { if (product != null) { refProduct = product; } } } } return true; }
private void reprojectSourceProducts(ProgressMonitor pm) { final ProductLocationsPaneModel productLocationsModel = getAssistantModel().getProductLocationsModel(); final List<ProductLocation> productLocations = productLocationsModel.getProductLocations(); pm.beginTask("Reprojecting...", productLocations.size()); for (ProductLocation productLocation : productLocations) { final Map<String, Product> products = productLocation.getProducts(ProgressMonitor.NULL); final Product crsReferenceProduct = getCrsReferenceProduct(); for (Map.Entry<String, Product> productEntry : products.entrySet()) { final Product product = productEntry.getValue(); if (!product.isCompatibleProduct(crsReferenceProduct, 0.1E-4f)) { Product reprojectedProduct = createProjectedProduct(product, crsReferenceProduct); productEntry.setValue(reprojectedProduct); } } pm.worked(1); } pm.done(); }
@Override protected JComponent createCrsComponent() { collocateProductSelector = new SourceProductSelector(getAppContext(), "Product:"); List<Product> products = new ArrayList<Product>(); for (ProductLocation productLocation : assistantModel.getProductLocationsModel().getProductLocations()) { for (Product product : productLocation.getProducts(ProgressMonitor.NULL).values()) { products.add(product); } } collocateProductSelector.setProductFilter(new CollocateProductFilter(products)); collocateProductSelector.addSelectionChangeListener(new AbstractSelectionChangeListener() { @Override public void selectionChanged(SelectionChangeEvent event) { fireCrsChanged(); } }); final JPanel panel = new JPanel(new BorderLayout(2, 2)); panel.add(collocateProductSelector.getProductNameComboBox(), BorderLayout.CENTER); panel.add(collocateProductSelector.getProductFileChooserButton(), BorderLayout.EAST); panel.addPropertyChangeListener("enabled", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { collocateProductSelector.getProductNameComboBox().setEnabled(panel.isEnabled()); collocateProductSelector.getProductFileChooserButton().setEnabled(panel.isEnabled()); final boolean collocate = getRadioButton().isSelected(); getCrsUI().firePropertyChange("collocate", !collocate, collocate); } }); return panel; }
List<String> variables = getEoVariables(); final Map<String, Product> products = productLocation.getProducts(ProgressMonitor.NULL); for (Map.Entry<String, Product> productEntry : products.entrySet()) { final Product product = productEntry.getValue();
private Variable[] getVariables(ProductLocationsPaneModel locationsModel, ProgressMonitor pm) { try { pm.beginTask("Scanning product locations...", locationsModel.getSize()); for (int i = 0; i < locationsModel.getSize(); i++) { final ProductLocation location = locationsModel.getElementAt(i); location.loadProducts(new SubProgressMonitor(pm, 1)); final Collection<Product> products = location.getProducts(ProgressMonitor.NULL).values(); if (!products.isEmpty()) { final Product product = products.iterator().next(); final String[] bandNames = product.getBandNames(); final Variable[] variables = new Variable[bandNames.length]; for (int j = 0; j < bandNames.length; j++) { variables[j] = new Variable(bandNames[j]); } location.closeProducts(); // @todo se - ?? return variables ?? - really a shortcut after the first product? // in this case only the variables of the first product are returned. return variables; } else { location.closeProducts(); } } } finally { pm.done(); } return new Variable[0]; }
@Override public void removeProductLocation(ProductLocation productLocation) { // remove metadata final MetadataElement timeSeriesRootElement = tsProduct.getMetadataRoot().getElement(TIME_SERIES_ROOT_NAME); MetadataElement productLocationsElement = timeSeriesRootElement.getElement(PRODUCT_LOCATIONS); removeAttributeWithValue(PL_PATH, productLocation.getPath(), productLocationsElement); // remove variables for this productLocation updateAutoGrouping(); // TODO ??? final Band[] bands = tsProduct.getBands(); final MetadataElement sourceProductPaths = timeSeriesRootElement.getElement(SOURCE_PRODUCT_PATHS); for (Map.Entry<String, Product> productEntry : productLocation.getProducts(ProgressMonitor.NULL).entrySet()) { final Product product = productEntry.getValue(); removeAttributeWithValue(PL_PATH, productEntry.getKey(), sourceProductPaths); String timeString = formatTimeString(product); productTimeMap.remove(timeString); for (Band band : bands) { if (band.getName().endsWith(timeString)) { tsProduct.removeBand(band); } } } productLocation.closeProducts(); productLocationList.remove(productLocation); fireChangeEvent(new TimeSeriesChangeEvent(TimeSeriesChangeEvent.PROPERTY_PRODUCT_LOCATIONS, productLocationList, this)); }