public void openProductSceneViewRGB(final Product product, final String helpId) { final VisatApp visatApp = VisatApp.getApp(); final RGBImageProfilePane profilePane = new RGBImageProfilePane(visatApp.getPreferences(), product); final String title = visatApp.getAppName() + " - Select RGB-Image Channels"; final boolean ok = profilePane.showDialog(visatApp.getMainFrame(), title, helpId); if (!ok) { return; } final String[] rgbaExpressions = profilePane.getRgbaExpressions(); if (profilePane.getStoreProfileInProduct()) { RGBImageProfile.storeRgbaExpressions(product, rgbaExpressions); } final String sceneName = createSceneName(product, profilePane.getSelectedProfile()); openProductSceneViewRGB(sceneName, product, rgbaExpressions); }
public void addProfiles(RGBImageProfile[] profiles) { for (RGBImageProfile profile : profiles) { addNewProfile(profile); } setRgbaExpressionsFromSelectedProfile(); }
public RGBImageProfile findMatchingProfile(RGBImageProfile profile) { // search in internal profiles first... RGBImageProfile matchingProfile = findMatchingProfile(profile, true); if (matchingProfile == null) { // ...then in non-internal profiles matchingProfile = findMatchingProfile(profile, false); } return matchingProfile; }
private boolean isSelectedProfileModified() { final ProfileItem profileItem = getSelectedProfileItem(); final String[] profileRgbaExpressions = profileItem.getProfile().getRgbaExpressions(); final String[] userRgbaExpressions = getRgbaExpressions(); for (int i = 0; i < profileRgbaExpressions.length; i++) { final String userRgbaExpression = userRgbaExpressions[i]; final String profileRgbaExpression = profileRgbaExpressions[i]; if (!profileRgbaExpression.equals(userRgbaExpression)) { return true; } } return false; }
profileBox.setEditable(false); profileBox.setName("profileBox"); setPrefferedWidth(profileBox, 200); rgbaExprBoxes[i] = createRgbaBox(bandNames); rgbaExprBoxes[i].setName("rgbExprBox_" + i); for (int i = 0; i < n; i++) { c3.gridy = i; addColorComponentRow(p3, c3, i); setLayout(new BorderLayout(10, 10)); add(p1, BorderLayout.NORTH); add(p3, BorderLayout.CENTER); add(storeInProductCheck, BorderLayout.SOUTH); addProfiles(registeredProfiles); if (this.product != null) { final RGBImageProfile productProfile = RGBImageProfile.getCurrentProfile(this.product); if (productProfile.isValid()) { final RGBImageProfile similarProfile = findMatchingProfile(productProfile); if (similarProfile != null) { selectProfile(similarProfile); } else { addNewProfile(productProfile); selectProfile(productProfile); RGBImageProfile profile = findProfileForProductPattern(selectableProfileArray, product); if (profile != null) {
@Test public void testSelectProfile_6() throws Exception { RGBImageProfile[] rgbImageProfiles = new RGBImageProfile[0]; Product product = new Product("some_name_123", "some_type_123", 1, 1); product.setDescription("This is some description text."); RGBImageProfile profile = RGBImageProfilePane.findProfileForProductPattern(rgbImageProfiles, product); assertNull(profile); } }
private void performSaveAs() { File file = promptForSaveFile(); if (file == null) { return; } RGBImageProfile profile = new RGBImageProfile(FileUtils.getFilenameWithoutExtension(file), getRgbaExpressions()); try { profile.store(file); } catch (IOException e) { JOptionPane.showMessageDialog(this, "Failed to save RGB-profile '" + file.getName() + "':\n" + e.getMessage(), "Open RGB-Image Profile", JOptionPane.ERROR_MESSAGE); return; } RGBImageProfileManager.getInstance().addProfile(profile); addNewProfile(profile); }
private void invokeExpressionEditor(final int colorIndex) { final Window window = SwingUtilities.getWindowAncestor(this); final String title = "Edit " + COLOR_COMP_NAMES[colorIndex] + " Expression"; if (product != null) { final ExpressionPane pane; pane = ProductExpressionPane.createGeneralExpressionPane(new Product[]{product}, product, preferences); pane.setCode(getExpression(colorIndex)); int status = pane.showModalDialog(window, title); if (status == ModalDialog.ID_OK) { setExpression(colorIndex, pane.getCode()); } } else { final JTextArea textArea = new JTextArea(8, 48); textArea.setFont(EXPRESSION_FONT); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); textArea.setText(getExpression(colorIndex)); final ModalDialog modalDialog = new ModalDialog(window, title, ModalDialog.ID_OK_CANCEL, ""); final JPanel panel = new JPanel(new BorderLayout(2, 2)); panel.add(new JLabel("Expression:"), BorderLayout.NORTH); panel.add(new JScrollPane(textArea), BorderLayout.CENTER); modalDialog.setContent(panel); final int status = modalDialog.show(); if (status == ModalDialog.ID_OK) { setExpression(colorIndex, textArea.getText()); } } }
private void performOpen() { final BeamFileChooser beamFileChooser = new BeamFileChooser(getProfilesDir()); beamFileChooser.setFileFilter( new BeamFileFilter("RGB-PROFILE", RGBImageProfile.FILENAME_EXTENSION, "RGB-Image Profile Files")); return; addNewProfile(profile);
/** * Gets the selected RGBA expressions as array of 4 strings. * * @return the selected RGBA expressions, never null * * @see #getSelectedProfile() */ public String[] getRgbaExpressions() { return new String[]{ getExpression(0), getExpression(1), getExpression(2), getExpression(3), }; }
@Override protected void initPageUI() { RGBImageProfilePane _profilePane = new RGBImageProfilePane(new PropertyMap()); setPageUI(_profilePane); } }
@Test public void testSelectProfile_1() throws Exception { RGBImageProfile[] rgbImageProfiles = new RGBImageProfile[] { new RGBImageProfile("p1", new String[]{"", "", ""}, new String[]{"matches", "not at", "all"}), new RGBImageProfile("p2", new String[]{"", "", ""}, new String[]{"some_different_type", "*name_*3", null}), new RGBImageProfile("p3", new String[]{"", "", ""}, new String[]{"*me_ty*", "*name_*3", null}), new RGBImageProfile("p4", new String[]{"", "", ""}, new String[]{"*me_ty*", "*name_*3", "*s some*"}), }; Product product = new Product("some_name_123", "some_type_123", 1, 1); product.setDescription("This is some description text."); RGBImageProfile profile = RGBImageProfilePane.findProfileForProductPattern(rgbImageProfiles, product); assertNotNull(profile); assertSame(rgbImageProfiles[3], profile); // all patterns match }
/** * Gets the selected RGB expressions as array of 3 strings. * * @return the selected RGB expressions, never null * * @see #getSelectedProfile() */ public String[] getRgbExpressions() { return new String[]{ getExpression(0), getExpression(1), getExpression(2), }; }
@Test public void testSelectProfile_4() throws Exception { RGBImageProfile[] rgbImageProfiles = new RGBImageProfile[] { new RGBImageProfile("p1", new String[]{"", "", ""}, new String[]{"matches", "not at", "all"}), new RGBImageProfile("p2", new String[]{"", "", ""}, new String[]{"some_different_type", "*name_*3", null}), new RGBImageProfile("p3", new String[]{"", "", ""}, new String[]{"strange type", "*name_*3", null}), new RGBImageProfile("p4", new String[]{"", "", ""}, new String[]{"strange type", "*name_*3", "*s some*"}), }; Product product = new Product("some_name_123", "some_type_123", 1, 1); product.setDescription("This is some description text."); RGBImageProfile profile = RGBImageProfilePane.findProfileForProductPattern(rgbImageProfiles, product); assertNotNull(profile); assertSame(rgbImageProfiles[3], profile); // name and description match }
@Test public void testSelectProfile_3() throws Exception { RGBImageProfile[] rgbImageProfiles = new RGBImageProfile[] { new RGBImageProfile("p1", new String[]{"", "", ""}, new String[]{"matches", "not at", "all"}), new RGBImageProfile("p2", new String[]{"", "", ""}, new String[]{"some_different_type", "*name_*3", null}), new RGBImageProfile("p3", new String[]{"", "", ""}, new String[]{null, "*name_*3", null}), new RGBImageProfile("p4", new String[]{"", "", ""}, new String[]{null, "*name_*3", "*s some*"}), }; Product product = new Product("some_name_123", "some_type_123", 1, 1); product.setDescription("This is some description text."); RGBImageProfile profile = RGBImageProfilePane.findProfileForProductPattern(rgbImageProfiles, product); assertNotNull(profile); assertSame(rgbImageProfiles[3], profile); // name and description match }
@Test public void testSelectProfile_2() throws Exception { RGBImageProfile[] rgbImageProfiles = new RGBImageProfile[] { new RGBImageProfile("p1", new String[]{"", "", ""}, new String[]{"matches", "not at", "all"}), new RGBImageProfile("p2", new String[]{"", "", ""}, new String[]{"some_different_type", "*name_*3", null}), new RGBImageProfile("p3", new String[]{"", "", ""}, new String[]{"*me_ty*", null, null}), new RGBImageProfile("p4", new String[]{"", "", ""}, new String[]{null, "*name_*3", "*s some*"}), }; Product product = new Product("some_name_123", "some_type_123", 1, 1); product.setDescription("This is some description text."); RGBImageProfile profile = RGBImageProfilePane.findProfileForProductPattern(rgbImageProfiles, product); assertNotNull(profile); assertSame(rgbImageProfiles[2], profile); // type matches }
@Test public void testSelectProfile_5() throws Exception { RGBImageProfile[] rgbImageProfiles = new RGBImageProfile[] { new RGBImageProfile("p1", new String[]{"", "", ""}, new String[]{"matches", "not at", "all"}), new RGBImageProfile("p2", new String[]{"", "", ""}, new String[]{"some_different_type", "*name_*3", null}), new RGBImageProfile("p3", new String[]{"", "", ""}, new String[]{"*me_ty*", "*name_*3", null}), new RGBImageProfile("p4", new String[]{"", "", ""}, new String[]{"*me_ty*", "*name_*3", null}), }; Product product = new Product("some_name_123", "some_type_123", 1, 1); product.setDescription("This is some description text."); RGBImageProfile profile = RGBImageProfilePane.findProfileForProductPattern(rgbImageProfiles, product); assertNotNull(profile); assertSame(rgbImageProfiles[2], profile); // equal, so earlier profile is chosen }