public OpenCVFilterThresholdGUI( String boundFilterName, String boundServiceName, GUIService myService) { super(boundFilterName, boundServiceName, myService); lowThreshold.setName("lowThreshold"); highThreshold.setName("highThreshold"); lowThreshold.addChangeListener(change); highThreshold.addChangeListener(change); GridBagConstraints gc2 = new GridBagConstraints(); TitledBorder title; JPanel j = new JPanel(new GridBagLayout()); title = BorderFactory.createTitledBorder("threshold"); j.setBorder(title); gc.gridx = 0; gc.gridy = 0; j.add(new JLabel("low"), gc); ++gc.gridx; j.add(lowThreshold, gc); ++gc.gridx; j.add(lowThreshold.value, gc); ++gc.gridy; gc.gridx = 0; j.add(new JLabel("high"), gc); ++gc.gridx; j.add(highThreshold, gc); ++gc.gridx; j.add(highThreshold.value, gc); display.add(j, gc2); gc2.gridy = 1; gc2.gridx = 0; j = new JPanel(new GridBagLayout()); title = BorderFactory.createTitledBorder("type"); j.setBorder(title); // j.add(apertureSize); // j.add(apertureSize.value); j.add(type); display.add(j, gc2); }
@Override public void stateChanged(ChangeEvent e) { OpenCVFilterCanny bf = (OpenCVFilterCanny) boundFilter.filter; JSlider2 slider = (JSlider2) e.getSource(); if (slider.getName().equals("lowThreshold")) { bf.lowThreshold = slider.getValue(); } else if (slider.getName().equals("lowThreshold")) { bf.highThreshold = slider.getValue(); } slider.value.setText("" + slider.getValue()); setFilterState(bf); }