CollocationForm extends JPanel { static void adaptResamplingComboBoxModel(DefaultComboBoxModel<ResamplingType> comboBoxModel, boolean isValidPixelExpressionUsed) { if (isValidPixelExpressionUsed) { if (comboBoxModel.getSize() == 5) { comboBoxModel.removeElement(ResamplingType.BICUBIC_CONVOLUTION); comboBoxModel.removeElement(ResamplingType.BISINC_CONVOLUTION); comboBoxModel.removeElement(ResamplingType.CUBIC_CONVOLUTION); comboBoxModel.removeElement(ResamplingType.BILINEAR_INTERPOLATION); comboBoxModel.setSelectedItem(ResamplingType.NEAREST_NEIGHBOUR); } } else { if (comboBoxModel.getSize() == 1) { comboBoxModel.addElement(ResamplingType.BILINEAR_INTERPOLATION); comboBoxModel.addElement(ResamplingType.CUBIC_CONVOLUTION); comboBoxModel.addElement(ResamplingType.BICUBIC_CONVOLUTION); comboBoxModel.addElement(ResamplingType.BISINC_CONVOLUTION); } } } CollocationForm(PropertySet propertySet, TargetProductSelector targetProductSelector, AppContext appContext); void prepareShow(); void prepareHide();  }
@Test public void testAdaptResamplingComboBoxModel() { final Product product = new Product("name", "type", 10, 10); final Band band1 = product.addBand("band1", ProductData.TYPE_INT32); final Band band2 = product.addBand("band2", ProductData.TYPE_INT32); DefaultComboBoxModel<ResamplingType> resamplingComboBoxModel = new DefaultComboBoxModel<>(ResamplingType.values()); boolean validPixelExpressionUsed = CollocationForm.isValidPixelExpressionUsed(product); assertFalse(validPixelExpressionUsed); CollocationForm.adaptResamplingComboBoxModel(resamplingComboBoxModel, validPixelExpressionUsed); assertEquals(5, resamplingComboBoxModel.getSize()); band1.setValidPixelExpression("true"); validPixelExpressionUsed = CollocationForm.isValidPixelExpressionUsed(product); assertTrue(validPixelExpressionUsed); CollocationForm.adaptResamplingComboBoxModel(resamplingComboBoxModel, validPixelExpressionUsed); assertEquals(1, resamplingComboBoxModel.getSize()); assertEquals(ResamplingType.NEAREST_NEIGHBOUR, resamplingComboBoxModel.getSelectedItem()); band1.setValidPixelExpression(null); band2.setValidPixelExpression(" "); validPixelExpressionUsed = CollocationForm.isValidPixelExpressionUsed(product); assertFalse(validPixelExpressionUsed); CollocationForm.adaptResamplingComboBoxModel(resamplingComboBoxModel, validPixelExpressionUsed); assertEquals(5, resamplingComboBoxModel.getSize()); assertEquals(ResamplingType.NEAREST_NEIGHBOUR, resamplingComboBoxModel.getSelectedItem()); }