private void saveButtonActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_saveButtonActionPerformed ConfigKeeper keeper = ConfigManager.getKeeper(); int delay = (int) delaySpinner.getValue(); int baseScale = baseScaleSlider.getValue(); int maxScale = maxScaleSlider.getValue(); int minNeighbors = (int) minNeighborsSpinner.getValue(); float increment = (incrementSlider.getValue()) / 100f; float scaleMultiplier_inc = (scaleMultiplier_incSlider.getValue()) / 100f; boolean doCannyPruning = doCannyPruningCheckBox.isSelected(); LinkedList<String> XMLfiles = new LinkedList<>(); LinkedList<Color> colors = new LinkedList<>(); Component[] cPanels = shapePanel.getComponents(); for (Component p : cPanels) { CascadePanel panel = (CascadePanel) p; if (panel.isActive()) { XMLfiles.add(panel.getName()); colors.add(panel.getColor()); } } keeper.setConfigs( null, delay, baseScale, maxScale, scaleMultiplier_inc, increment, minNeighbors, doCannyPruning, XMLfiles, colors); ConfigManager.saveKeeper(); Webcam webcam = (Webcam) webcamBox.getSelectedItem(); if (!webcam.isOpen()) { parent.initCam(webcam); } else { parent.setWorkingConfigs(); } setVisible(false); } // GEN-LAST:event_saveButtonActionPerformed
private void readOptions(ConfigKeeper keeper) { baseScaleSlider.setValue(keeper.getBaseScale()); maxScaleSlider.setValue(keeper.getMaxScale()); minNeighborsSpinner.setValue(keeper.getMinNeighbors()); float v = (keeper.getIncrement() * 100); incrementSlider.setValue((int) v); scaleMultiplier_incSlider.setValue((int) (keeper.getScaleMultiplier_inc() * 100)); doCannyPruningCheckBox.setSelected(keeper.getDoCannyPruning()); delaySpinner.setValue(keeper.getDelay()); webcamBox.removeAllItems(); for (Webcam cam : Webcam.getWebcams()) { webcamBox.addItem(cam); } shapePanel.removeAll(); LinkedList<String> availableXMLs = ConfigManager.getAvailableXMLs(); LinkedList<String> cascades = keeper.getXMLFiles(); int k = 0; for (String XML : availableXMLs) { if (cascades.contains(XML)) { Color color = keeper.getColors().get(k); CascadePanel cascadePanel = new CascadePanel(XML, color, true); shapePanel.add(cascadePanel); k++; } else { CascadePanel cascadePanel = new CascadePanel(XML, Color.GRAY, false); shapePanel.add(cascadePanel); } } shapeScrollPane.revalidate(); }