diff --git a/devices/CurrentCamera.properties b/devices/CurrentCamera.properties index c6a0163..8106071 100644 --- a/devices/CurrentCamera.properties +++ b/devices/CurrentCamera.properties @@ -1,16 +1,16 @@ -#Mon Jun 12 08:32:43 CEST 2017 +#Mon Jun 12 09:33:46 CEST 2017 colormap=Flame -colormapAutomatic=false -colormapMax=739.0 +colormapAutomatic=true +colormapMax=137.0 colormapMin=0.0 flipHorizontally=false flipVertically=false grayscale=false -imageHeight=2148 -imageWidth=2272 +imageHeight=2160 +imageWidth=1936 invert=false -regionStartX=129 -regionStartY=7 +regionStartX=321 +regionStartY=1 rescaleFactor=1.0 rescaleOffset=0.0 roiHeight=-1 diff --git a/plugins/ScreenPanel.form b/plugins/ScreenPanel.form index d97c43e..8069174 100644 --- a/plugins/ScreenPanel.form +++ b/plugins/ScreenPanel.form @@ -74,7 +74,7 @@ - + @@ -305,7 +305,7 @@ - + @@ -357,7 +357,7 @@ - + @@ -466,32 +466,31 @@ - + - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + @@ -499,41 +498,71 @@ - + - - - - - - - - - - - - - - - - - - - + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -550,16 +579,22 @@ - + + + + + + + + + + + + - - - - - @@ -588,128 +623,11 @@ - + - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -892,14 +810,30 @@ - - + + + + + + + + + + + + + + + + + + - - + + - + @@ -913,6 +847,17 @@ + + + + + + + + + + + @@ -930,9 +875,8 @@ - + - @@ -949,6 +893,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/ScreenPanel.java b/plugins/ScreenPanel.java index f44564f..43b71c6 100644 --- a/plugins/ScreenPanel.java +++ b/plugins/ScreenPanel.java @@ -62,6 +62,7 @@ import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.image.BufferedImage; import java.io.FileInputStream; +import java.lang.reflect.Array; import java.net.ServerSocket; import java.nio.file.Files; import java.nio.file.Path; @@ -115,11 +116,12 @@ public class ScreenPanel extends Panel { Overlay[] userOv; Overlay[] fitOv; Overlay[] profileOv; - Overlay errorOverlay; + Overlay errorOverlay; boolean requestCameraListUpdate; Integer localServerPort; Process privateServer; String serverUrl; + boolean goodRegion; Double getCamtoolDouble(String name) { return (Double) Convert.toDouble(((Camtool) camera).getValue(name)); @@ -128,27 +130,43 @@ public class ScreenPanel extends Panel { double[] getCamtoolDoubleArray(String name) { return (double[]) Convert.toDouble(((Camtool) camera).getValue(name)); } - - class Frame { - - Frame(Data data) { - this.data = data; + + class ImageData { + ImageData(){ if (camera instanceof Camtool) { - xMean = getCamtoolDouble("x_fit_mean"); - yMean = getCamtoolDouble("y_fit_mean"); - xSigma = getCamtoolDouble("x_fit_standard_deviation"); - ySigma = getCamtoolDouble("y_fit_standard_deviation"); + String prefix = goodRegion ? "gr_" : ""; + xMean = getCamtoolDouble(prefix + "x_fit_mean"); + yMean = getCamtoolDouble(prefix + "y_fit_mean"); + xSigma = getCamtoolDouble(prefix + "x_fit_standard_deviation"); + ySigma = getCamtoolDouble(prefix + "y_fit_standard_deviation"); + x_fit_gauss_function = getCamtoolDoubleArray(prefix +"x_fit_gauss_function"); + y_fit_gauss_function = getCamtoolDoubleArray(prefix +"y_fit_gauss_function"); + x_profile = getCamtoolDoubleArray("x_profile"); + y_profile = getCamtoolDoubleArray("y_profile"); xCom = getCamtoolDouble("x_center_of_mass"); yCom = getCamtoolDouble("y_center_of_mass"); xRms = getCamtoolDouble("x_rms"); - yRms = getCamtoolDouble("y_rms"); - x_profile = getCamtoolDoubleArray("x_profile"); - x_fit_gauss_function = getCamtoolDoubleArray("x_fit_gauss_function"); - y_profile = getCamtoolDoubleArray("y_profile"); - y_fit_gauss_function = getCamtoolDoubleArray("y_fit_gauss_function"); - } + yRms = getCamtoolDouble("y_rms"); + if (goodRegion){ + double[] gX2 = new double[x_profile.length]; + Arrays.fill(gX2, Double.NaN); + try{ + double x = getCamtoolDoubleArray("gr_x_axis")[0]; + System.arraycopy(x_fit_gauss_function, 0, gX2, (int) ((renderer.getCalibration() != null) ? renderer.getCalibration().convertToImageX(x): x), x_fit_gauss_function.length); + } catch (Exception ex){ + } + x_fit_gauss_function = gX2; + double[] gY2 = new double[y_profile.length]; + Arrays.fill(gY2, Double.NaN); + try{ + double y = getCamtoolDoubleArray("gr_y_axis")[0]; + System.arraycopy(y_fit_gauss_function, 0, gY2, (int) ((renderer.getCalibration() != null) ? renderer.getCalibration().convertToImageY(y): y), y_fit_gauss_function.length); + } catch (Exception ex){ + } + y_fit_gauss_function = gY2; + } + } } - Data data; Double xMean; Double yMean; Double xCom; @@ -160,7 +178,15 @@ public class ScreenPanel extends Panel { double[] x_profile; double[] x_fit_gauss_function; double[] y_profile; - double[] y_fit_gauss_function; + double[] y_fit_gauss_function; + } + + class Frame extends ImageData{ + + Frame(Data data) { + this.data = data; + } + Data data; } final ArrayList imageBuffer = new ArrayList(); @@ -169,9 +195,15 @@ public class ScreenPanel extends Panel { public ScreenPanel() { initComponents(); + spinnerThreshold.setVisible(false); + spinnerGrThreshold.setVisible(false); labelGrThreshold.setVisible(false); + spinnerGrScale.setVisible(false); labelGrScale.setVisible(false); + //spinnerMin.setVisible(false); labelMin.setVisible(false); + //spinnerMax.setVisible(false); labelMax.setVisible(false); renderer.setPersistenceFile(Paths.get(getContext().getSetup().getContextPath(), "Renderer_Cameras.bin")); setPersistedComponents(new Component[]{buttonCamtool, buttonDirect}); comboCameras.setEnabled(false); + SwingUtils.setEnumCombo(comboColormap, Colormap.class); if (App.hasArgument("poll")) { try { polling = Integer.valueOf(App.getArgumentValue("poll")); @@ -546,6 +578,7 @@ public class ScreenPanel extends Panel { userOv = fo; } } + @Override public void onStateChange(State state, State former) { @@ -567,9 +600,6 @@ public class ScreenPanel extends Panel { System.out.println("Setting camera: " + cameraName + " [" + (buttonCamtool.isSelected() ? "camtool" : "direct") + "]"); parseUserOverlays(); errorOverlay = null; - checkBackground.setEnabled(false); - spinnerThreshold.setEnabled(false); - checkThreshold.setEnabled(false); if (dataTableDialog!=null){ dataTableDialog.dispose(); @@ -582,8 +612,10 @@ public class ScreenPanel extends Panel { calibrationDialolg = null; } + boolean was_camtool = false; if (camera != null) { //camera.removeAllListeners(); + was_camtool = camera instanceof Camtool; camera.close(); camera = null; } @@ -598,8 +630,16 @@ public class ScreenPanel extends Panel { boolean changed = !String.valueOf(cameraName).equals(this.cameraName); this.cameraName = cameraName; - + + if (changed || buttonDirect.isSelected()) { + spinnerThreshold.setVisible(false); + spinnerGrThreshold.setVisible(false); labelGrThreshold.setVisible(false); + spinnerGrScale.setVisible(false); labelGrScale.setVisible(false); + checkThreshold.setEnabled(false); + checkGoodRegion.setEnabled(false); + } if (changed) { + checkBackground.setEnabled(false); if ((devicesInitTask != null) && (devicesInitTask.isAlive())) { devicesInitTask.interrupt(); } @@ -637,27 +677,36 @@ public class ScreenPanel extends Panel { camera.initialize(); camera.assertInitialized(); System.out.println("Camera initialization OK"); - if (camera instanceof Camtool) { - //Managing no background exception. Can be done in a better way? - checkBackground.setEnabled(true); - if (changed) { - ((Camtool) camera).startPipeline(cameraName, null); + if (camera instanceof Camtool) { + //Managing no background exception. Can be done in a better way? +// if (changed) { + ((Camtool) camera).startPipeline(cameraName, null); updateCamtoolControls(); - } else { - ((Camtool) camera).startPipeline(cameraName, null, checkBackground.isSelected(), null, checkThreshold.isSelected() ? (Double) spinnerThreshold.getValue() : null, null); - } - spinnerThreshold.setEnabled(true); +// } else { +// ((Camtool) camera).startPipeline(cameraName, null, checkBackground.isSelected(), null, null, null); +// } + // HashMap gr = null; + // if (goodRegion){ + // gr = new HashMap<>(); + // gr.put("threshold", spinnerGrThreshold.getValue()); + // gr.put("gfscale", spinnerGrScale.getValue()); + // } + // ((Camtool) camera).startPipeline(cameraName, null, checkBackground.isSelected(), null, checkThreshold.isSelected() ? (Double) spinnerThreshold.getValue() : null, gr); + //} + checkThreshold.setEnabled(true); + checkGoodRegion.setEnabled(true); ((Camtool) camera).startReceiver(); - } else { - checkBackground.setEnabled(true); - checkBackground.setSelected(false); + } else { + checkThreshold.setSelected(false); + checkGoodRegion.setSelected(false); if (polling <= 0) { camera.setMonitored(true); } else { camera.setPolling(polling); } + camera.setBackgroundEnabled(checkBackground.isSelected()); } buttonReticle.setEnabled(camera.getConfig().isCalibrated()); @@ -727,7 +776,7 @@ public class ScreenPanel extends Panel { onTimer(); } onChangeColormap(null); - + checkBackground.setEnabled(true); if (changed) { comboScreen.setModel(new DefaultComboBoxModel()); comboFilter.setModel(new DefaultComboBoxModel()); @@ -840,26 +889,7 @@ public class ScreenPanel extends Panel { try { if ((camera != null) && (camera instanceof ColormapSource)) { ColormapSourceConfig config = ((ColormapSource) camera).getConfig(); - switch (config.colormap) { - case Grayscale: - buttonGrayscale.setSelected(true); - break; - case Rainbow: - buttonRainbow.setSelected(true); - break; - case Temperature: - buttonTemperature.setSelected(true); - break; - case Flame: - buttonFlame.setSelected(true); - break; - case Inverted: - buttonInverted.setSelected(true); - break; - default: - buttonGroup2.clearSelection(); - - } + comboColormap.setSelectedItem(config.colormap); if (config.isDefaultColormap()) { buttonFullRange.setSelected(true); } else if (config.colormapAutomatic) { @@ -868,6 +898,8 @@ public class ScreenPanel extends Panel { buttonManual.setSelected(true); } + //spinnerMin.setVisible(buttonManual.isSelected()); labelMin.setVisible(spinnerMin.isVisible()); + //spinnerMax.setVisible(buttonManual.isSelected()); labelMax.setVisible(spinnerMax.isVisible()); spinnerMin.setEnabled(buttonManual.isSelected()); spinnerMax.setEnabled(buttonManual.isSelected()); spinnerMin.setValue(Double.isNaN(config.colormapMin) ? 0 : Math.min(Math.max((int) config.colormapMin, 0), 65535)); @@ -884,14 +916,23 @@ public class ScreenPanel extends Panel { void updateCamtoolControls() { if ((camera != null) && (camera instanceof Camtool)) { updatingCamtoolControls = true; - try { + try { checkBackground.setSelected(((Camtool) camera).getBackgroundSubtraction()); Double threshold = ((Camtool) camera).getThreshold(); checkThreshold.setSelected(threshold != null); - spinnerThreshold.setValue((threshold == null) ? 0 : threshold); - + spinnerThreshold.setValue((threshold == null) ? 0 : threshold); + Map gr = ((Camtool) camera).getGoodRegion(); + checkGoodRegion.setSelected(gr != null); + if (gr != null){ + spinnerGrThreshold.setValue(gr.get("threshold")); + spinnerGrScale.setValue(gr.get("gfscale")); + } } catch (Exception ex) { } + goodRegion = checkGoodRegion.isSelected(); + spinnerThreshold.setVisible(checkThreshold.isSelected()); + spinnerGrThreshold.setVisible(goodRegion); labelGrThreshold.setVisible(spinnerGrThreshold.isVisible()); + spinnerGrScale.setVisible(goodRegion); labelGrScale.setVisible(spinnerGrScale.isVisible()); updatingCamtoolControls = false; } } @@ -968,39 +1009,27 @@ public class ScreenPanel extends Panel { int profileSize = renderer.getProfileSize(); if ((useCamtoolStats) && (camera instanceof Camtool)) { try { + ImageData id = null; if (renderer.isPaused()) { synchronized (imageBuffer) { for (Frame f : imageBuffer) { if (f.data == data) { - xMean = f.xMean; - xSigma = f.xSigma; - yMean = f.yMean; - ySigma = f.ySigma; - pX = f.x_profile; - gX = f.x_fit_gauss_function; - pY = f.y_profile; - gY = f.y_fit_gauss_function; - xCom = f.xCom; - xRms = f.xRms; - yCom = f.yCom; - yRms = f.yRms; + id = f; + break; } } } } else { - xMean = getCamtoolDouble("x_fit_mean"); - yMean = getCamtoolDouble("y_fit_mean"); - xSigma = getCamtoolDouble("x_fit_standard_deviation"); - ySigma = getCamtoolDouble("y_fit_standard_deviation"); - xCom = getCamtoolDouble("x_center_of_mass"); - yCom = getCamtoolDouble("y_center_of_mass"); - xRms = getCamtoolDouble("x_rms"); - yRms = getCamtoolDouble("y_rms"); - pX = getCamtoolDoubleArray("x_profile"); - gX = getCamtoolDoubleArray("x_fit_gauss_function"); - pY = getCamtoolDoubleArray("y_profile"); - gY = getCamtoolDoubleArray("y_fit_gauss_function"); + id = new ImageData(); } + if (id==null){ + return null; + } + xMean = id.xMean; xSigma = id.xSigma;yMean = id.yMean;ySigma = id.ySigma; + gX = id.x_fit_gauss_function; gY = id.y_fit_gauss_function; + pX = id.x_profile; pY = id.y_profile; + xCom = id.xCom; xRms = id.xRms; yCom = id.yCom; yRms = id.yRms; + profileSize /= 4; if (pX != null) { int[] x = Arr.indexesInt(pX.length); @@ -1013,16 +1042,23 @@ public class ScreenPanel extends Panel { double rangePlot = max - min; for (int i = 0; i < x.length; i++) { - if (gX != null) { - y[i] = (int) (height - 1 - (((gX[i] - minPlot) / rangePlot) * profileSize)); + if (gX != null) { + y[i] = (int) (height - 1 - (((gX[i] - minPlot) / rangePlot) * profileSize)); } p[i] = (int) (height - 1 - (((pX[i] - minPlot) / rangePlot) * profileSize)); } + + if (goodRegion){ + for (int i = 0; i < x.length; i++) { + y[i] = (Double.isNaN(gX[i])) ? 100000 : y[i]; + } + } + vgaussian = new Overlays.Polyline(penFit, x, y); vprofile = new Overlays.Polyline(renderer.getPenProfile(), x, p); } - if (pX != null) { + if (pY != null) { int[] y = Arr.indexesInt(pY.length); int[] x = new int[pY.length]; int[] p = new int[pY.length]; @@ -1035,10 +1071,16 @@ public class ScreenPanel extends Panel { for (int i = 0; i < x.length; i++) { if (gY != null) { - x[i] = (int) (((gY[i] - minPlot) / rangePlot) * profileSize); + x[i] = (int) (((gY[i] - minPlot) / rangePlot) * profileSize); } p[i] = (int) (((pY[i] - minPlot) / rangePlot) * profileSize); } + + if (goodRegion){ + for (int i = 0; i < x.length; i++) { + x[i] = (Double.isNaN(gY[i])) ? -1 :x[i]; + } + } hgaussian = new Overlays.Polyline(penFit, x, y); hprofile = new Overlays.Polyline(renderer.getPenProfile(), p, y); } @@ -1188,6 +1230,20 @@ public class ScreenPanel extends Panel { cross = new Overlays.Crosshairs(penCross, center, new Dimension(Math.abs(2 * xSigma.intValue()), 2 * Math.abs(ySigma.intValue()))); } fOv = new Overlay[]{hgaussian, vgaussian, cross, textFit}; + + if (goodRegion){ + try{ + double[] x = getCamtoolDoubleArray("gr_x_axis"); double[] y = getCamtoolDoubleArray("gr_y_axis"); + double x1 = x[0]; double x2 = x[x.length-1]; double y1 = y[0]; double y2 = y[y.length-1]; + Overlays.Rect goodRegionOv = new Overlays.Rect(new Pen(penFit.getColor(), 0, Pen.LineStyle.dotted)); + goodRegionOv.setCalibration(renderer.getCalibration()); + goodRegionOv.setAbsolutePosition(new PointDouble(x1, y1)); + goodRegionOv.setAbsoluteSize(new DimensionDouble(x2-x1, y2-y1)); + fOv = Arr.append(fOv, goodRegionOv); + } catch (Exception ex){ + } + } + } return new Overlay[][]{pOv, fOv}; } @@ -1684,8 +1740,6 @@ public class ScreenPanel extends Panel { dataTableDialog.requestFocus(); return; } - List ids = new ArrayList(((Camtool)camera).getValue().getIdentifiers()); - Collections.sort(ids); //String msg = String.join("\n", ids); //SwingUtils.showMessage(getTopLevel(), "Image Data", msg); dataTableModel = new DefaultTableModel(new Object[0][2], new String[]{"Name", "Value"}) { @@ -1696,9 +1750,6 @@ public class ScreenPanel extends Panel { return false; } }; - for (String id : ids){ - dataTableModel.addRow(new Object[]{id, ""}); - } updateImageData(); StreamValue val = ((Camtool)camera).getStream().take(); JTable dataTable = new JTable(dataTableModel); @@ -1724,22 +1775,28 @@ public class ScreenPanel extends Panel { } void updateImageData(){ - if (dataTableModel!=null){ - if (camera instanceof Camtool){ - for (int i = 0 ; i< dataTableModel.getRowCount(); i++){ - String id = String.valueOf(dataTableModel.getValueAt(i, 0)); - Object obj = ((Camtool)camera).getValue(id); - if (obj!=null){ - if (obj.getClass().isArray()){ - obj = obj.getClass().getName(); - } else if (obj instanceof Double){ - obj = Convert.roundDouble((Double) obj, 1); - } else if (obj instanceof Float){ - obj = Convert.roundDouble((Float) obj, 1); - } - } - dataTableModel.setValueAt(String.valueOf(obj), i, 1); - } + if ((dataTableModel!=null)&&(camera instanceof Camtool)){ + List ids = new ArrayList(((Camtool)camera).getValue().getIdentifiers()); + if (ids.size() != dataTableModel.getRowCount()){ + dataTableModel.setNumRows(0); + Collections.sort(ids); + for (String id : ids){ + dataTableModel.addRow(new Object[]{id, ""}); + } + } + for (int i = 0 ; i< dataTableModel.getRowCount(); i++){ + String id = String.valueOf(dataTableModel.getValueAt(i, 0)); + Object obj = ((Camtool)camera).getValue(id); + if (obj!=null){ + if (obj.getClass().isArray()){ + obj = obj.getClass().getComponentType().getSimpleName() + "[" + Array.getLength(obj) + "]"; + } else if (obj instanceof Double){ + obj = Convert.roundDouble((Double) obj, 1); + } else if (obj instanceof Float){ + obj = Convert.roundDouble((Float) obj, 1); + } + } + dataTableModel.setValueAt(String.valueOf(obj), i, 1); } } } @@ -1781,20 +1838,17 @@ public class ScreenPanel extends Panel { buttonZoom05 = new javax.swing.JRadioButton(); buttonZoom2 = new javax.swing.JRadioButton(); jPanel2 = new javax.swing.JPanel(); - buttonFullRange = new javax.swing.JRadioButton(); - buttonManual = new javax.swing.JRadioButton(); + checkHistogram = new javax.swing.JCheckBox(); + comboColormap = new javax.swing.JComboBox(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); + buttonFullRange = new javax.swing.JRadioButton(); + buttonManual = new javax.swing.JRadioButton(); + buttonAutomatic = new javax.swing.JRadioButton(); + labelMin = new javax.swing.JLabel(); spinnerMin = new javax.swing.JSpinner(); spinnerMax = new javax.swing.JSpinner(); - buttonAutomatic = new javax.swing.JRadioButton(); - checkHistogram = new javax.swing.JCheckBox(); - jPanel8 = new javax.swing.JPanel(); - buttonInverted = new javax.swing.JRadioButton(); - buttonFlame = new javax.swing.JRadioButton(); - buttonTemperature = new javax.swing.JRadioButton(); - buttonRainbow = new javax.swing.JRadioButton(); - buttonGrayscale = new javax.swing.JRadioButton(); + labelMax = new javax.swing.JLabel(); jPanel5 = new javax.swing.JPanel(); buttonCamtool = new javax.swing.JRadioButton(); buttonDirect = new javax.swing.JRadioButton(); @@ -1809,6 +1863,11 @@ public class ScreenPanel extends Panel { checkThreshold = new javax.swing.JCheckBox(); spinnerThreshold = new javax.swing.JSpinner(); checkBackground = new javax.swing.JCheckBox(); + checkGoodRegion = new javax.swing.JCheckBox(); + spinnerGrScale = new javax.swing.JSpinner(); + spinnerGrThreshold = new javax.swing.JSpinner(); + labelGrThreshold = new javax.swing.JLabel(); + labelGrScale = new javax.swing.JLabel(); setPreferredSize(new java.awt.Dimension(873, 600)); @@ -1999,7 +2058,7 @@ public class ScreenPanel extends Panel { .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) @@ -2071,7 +2130,7 @@ public class ScreenPanel extends Panel { .addComponent(buttonZoom025) .addComponent(buttonZoom05) .addComponent(buttonZoom2)) - .addGap(47, 47, 47)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -2093,8 +2152,27 @@ public class ScreenPanel extends Panel { jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Colormap")); + checkHistogram.setText("Histogram"); + checkHistogram.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + checkHistogramActionPerformed(evt); + } + }); + + comboColormap.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + onChangeColormap(evt); + } + }); + + jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel3.setText("Type:"); + + jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel4.setText("Range:"); + buttonGroup3.add(buttonFullRange); - buttonFullRange.setText("Full range"); + buttonFullRange.setText("Full"); buttonFullRange.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { onChangeColormap(evt); @@ -2109,9 +2187,15 @@ public class ScreenPanel extends Panel { } }); - jLabel3.setText("Min:"); + buttonGroup3.add(buttonAutomatic); + buttonAutomatic.setText("Automatic"); + buttonAutomatic.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + onChangeColormap(evt); + } + }); - jLabel4.setText("Max:"); + labelMin.setText("Min:"); spinnerMin.setModel(new javax.swing.SpinnerNumberModel(0, 0, 65535, 1)); spinnerMin.setEnabled(false); @@ -2131,148 +2215,63 @@ public class ScreenPanel extends Panel { } }); - buttonGroup3.add(buttonAutomatic); - buttonAutomatic.setText("Automatic"); - buttonAutomatic.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - onChangeColormap(evt); - } - }); - - checkHistogram.setText("Histogram"); - checkHistogram.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - checkHistogramActionPerformed(evt); - } - }); - - buttonGroup2.add(buttonInverted); - buttonInverted.setText("Inverted"); - buttonInverted.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - onChangeColormap(evt); - } - }); - - buttonGroup2.add(buttonFlame); - buttonFlame.setText("Flame"); - buttonFlame.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - onChangeColormap(evt); - } - }); - - buttonGroup2.add(buttonTemperature); - buttonTemperature.setText("Temperature"); - buttonTemperature.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - onChangeColormap(evt); - } - }); - - buttonGroup2.add(buttonRainbow); - buttonRainbow.setText("Rainbow"); - buttonRainbow.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - onChangeColormap(evt); - } - }); - - buttonGroup2.add(buttonGrayscale); - buttonGrayscale.setText("Grayscale"); - buttonGrayscale.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - onChangeColormap(evt); - } - }); - - javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8); - jPanel8.setLayout(jPanel8Layout); - jPanel8Layout.setHorizontalGroup( - jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel8Layout.createSequentialGroup() - .addContainerGap() - .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel8Layout.createSequentialGroup() - .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(buttonGrayscale) - .addComponent(buttonInverted)) - .addGap(20, 20, 20)) - .addComponent(buttonFlame)) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(buttonTemperature) - .addComponent(buttonRainbow))) - .addGap(0, 0, 0)) - ); - jPanel8Layout.setVerticalGroup( - jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel8Layout.createSequentialGroup() - .addGap(0, 0, 0) - .addComponent(buttonGrayscale) - .addGap(0, 0, 0) - .addComponent(buttonInverted) - .addGap(0, 0, 0) - .addComponent(buttonFlame) - .addGap(0, 0, 0) - .addComponent(buttonRainbow) - .addGap(0, 0, 0) - .addComponent(buttonTemperature) - .addGap(0, 0, 0)) - ); + labelMax.setText("Max:"); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() - .addContainerGap() + .addGap(4, 4, 4) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel2Layout.createSequentialGroup() - .addComponent(checkHistogram) - .addGap(0, 0, Short.MAX_VALUE)) - .addGroup(jPanel2Layout.createSequentialGroup() - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(buttonAutomatic) - .addComponent(buttonFullRange) - .addComponent(buttonManual) - .addGroup(jPanel2Layout.createSequentialGroup() - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel4) - .addComponent(jLabel3)) - .addGap(2, 2, 2) - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(spinnerMin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(spinnerMax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addComponent(jLabel3) + .addComponent(jLabel4)) + .addGap(4, 4, 4) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(buttonAutomatic) + .addComponent(buttonFullRange) + .addComponent(buttonManual) + .addComponent(comboColormap, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() + .addComponent(labelMax) + .addGap(2, 2, 2) + .addComponent(spinnerMax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() + .addComponent(labelMin) + .addGap(2, 2, 2) + .addComponent(spinnerMin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(checkHistogram, javax.swing.GroupLayout.Alignment.TRAILING)) .addContainerGap()) ); jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerMax, spinnerMin}); + jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel3, jLabel4}); + jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel2Layout.createSequentialGroup() + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() .addGap(4, 4, 4) - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addGroup(jPanel2Layout.createSequentialGroup() - .addComponent(buttonAutomatic) - .addGap(0, 0, 0) - .addComponent(buttonFullRange) - .addGap(0, 0, 0) - .addComponent(buttonManual) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel3) - .addComponent(spinnerMin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel4) - .addComponent(spinnerMax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) - .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(checkHistogram)) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(comboColormap, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel3) + .addComponent(checkHistogram)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(buttonAutomatic) + .addComponent(jLabel4)) + .addGap(0, 0, 0) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(labelMin) + .addComponent(spinnerMin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(buttonFullRange)) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(buttonManual) + .addComponent(labelMax) + .addComponent(spinnerMax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) ); jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Source")); @@ -2386,8 +2385,7 @@ public class ScreenPanel extends Panel { } }); - spinnerThreshold.setModel(new javax.swing.SpinnerNumberModel(0.0d, 0.0d, 65535.0d, 1.0d)); - spinnerThreshold.setEnabled(false); + spinnerThreshold.setModel(new javax.swing.SpinnerNumberModel(0.0d, 0.0d, 99999.0d, 1.0d)); spinnerThreshold.setPreferredSize(new java.awt.Dimension(77, 20)); spinnerThreshold.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { @@ -2402,6 +2400,33 @@ public class ScreenPanel extends Panel { } }); + checkGoodRegion.setText("Good Region"); + checkGoodRegion.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + checkGoodRegionActionPerformed(evt); + } + }); + + spinnerGrScale.setModel(new javax.swing.SpinnerNumberModel(3.0d, 0.01d, 100.0d, 1.0d)); + spinnerGrScale.setPreferredSize(new java.awt.Dimension(77, 20)); + spinnerGrScale.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + spinnerGrThresholdonChange(evt); + } + }); + + spinnerGrThreshold.setModel(new javax.swing.SpinnerNumberModel(0.5d, 0.04d, 1.0d, 0.1d)); + spinnerGrThreshold.setPreferredSize(new java.awt.Dimension(77, 20)); + spinnerGrThreshold.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + spinnerGrThresholdonChange(evt); + } + }); + + labelGrThreshold.setText("Threshold:"); + + labelGrScale.setText("Scale:"); + javax.swing.GroupLayout panelScreen2Layout = new javax.swing.GroupLayout(panelScreen2); panelScreen2.setLayout(panelScreen2Layout); panelScreen2Layout.setHorizontalGroup( @@ -2409,13 +2434,29 @@ public class ScreenPanel extends Panel { .addGroup(panelScreen2Layout.createSequentialGroup() .addContainerGap() .addGroup(panelScreen2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(checkBackground) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelScreen2Layout.createSequentialGroup() + .addComponent(checkGoodRegion) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(labelGrScale) + .addGap(2, 2, 2) + .addComponent(spinnerGrScale, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelScreen2Layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(labelGrThreshold) + .addGap(2, 2, 2) + .addComponent(spinnerGrThreshold, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(panelScreen2Layout.createSequentialGroup() + .addComponent(checkBackground) + .addGap(0, 0, Short.MAX_VALUE)) .addGroup(panelScreen2Layout.createSequentialGroup() .addComponent(checkThreshold) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(spinnerThreshold, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap()) ); + + panelScreen2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerGrScale, spinnerGrThreshold, spinnerThreshold}); + panelScreen2Layout.setVerticalGroup( panelScreen2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelScreen2Layout.createSequentialGroup() @@ -2425,6 +2466,15 @@ public class ScreenPanel extends Panel { .addGroup(panelScreen2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(checkThreshold) .addComponent(spinnerThreshold, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(2, 2, 2) + .addGroup(panelScreen2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(checkGoodRegion) + .addComponent(spinnerGrScale, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(labelGrScale)) + .addGap(2, 2, 2) + .addGroup(panelScreen2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(spinnerGrThreshold, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(labelGrThreshold)) .addContainerGap()) ); @@ -2442,7 +2492,7 @@ public class ScreenPanel extends Panel { .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(pauseSelection, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .addComponent(panelScreen2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addContainerGap()) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jPanel4Layout.setVerticalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -2687,23 +2737,23 @@ public class ScreenPanel extends Panel { private void onChangeColormap(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onChangeColormap try { - if ((camera != null) && (camera instanceof ColormapSource) && !updatingColormap) { + if ((camera != null) && (camera instanceof ColormapSource) && !updatingColormap) { ColormapSource source = (ColormapSource) camera; Color colorReticule = new Color(16, 16, 16); Color colorMarker = new Color(128, 128, 128); - if (buttonGrayscale.isSelected() || buttonInverted.isSelected()) { - colorReticule = new Color(0, 192, 0); - colorMarker = new Color(64, 255, 64); - source.getConfig().colormap = buttonGrayscale.isSelected() ? Colormap.Grayscale : Colormap.Inverted; - } else if (buttonFlame.isSelected()) { - colorReticule = new Color(0, 192, 0); - colorMarker = new Color(64, 255, 64); - source.getConfig().colormap = Colormap.Flame; - } else if (buttonTemperature.isSelected()) { - source.getConfig().colormap = Colormap.Temperature; - } else if (buttonRainbow.isSelected()) { - source.getConfig().colormap = Colormap.Rainbow; + source.getConfig().colormap = (Colormap)comboColormap.getSelectedItem(); + switch (source.getConfig().colormap){ + case Grayscale: + case Inverted: + colorReticule = new Color(0, 192, 0); + colorMarker = new Color(64, 255, 64); + break; + case Flame: + colorReticule = new Color(0, 192, 0); + colorMarker = new Color(64, 255, 64); + break; } + renderer.setPenReticle(new Pen(colorReticule)); renderer.setPenProfile(new Pen(colorReticule, 0)); renderer.setPenMarker(new Pen(colorMarker, 2)); @@ -2713,14 +2763,15 @@ public class ScreenPanel extends Panel { source.getConfig().colormapMin = buttonFullRange.isSelected() ? Double.NaN : (Integer) spinnerMin.getValue(); source.getConfig().colormapMax = buttonFullRange.isSelected() ? Double.NaN : (Integer) spinnerMax.getValue(); source.getConfig().save(); - source.refresh(); + source.refresh(); if (buttonPause.isSelected()) { updatePause(); } + updateColormap(); } } catch (Exception ex) { showException(ex); - } + } }//GEN-LAST:event_onChangeColormap private void onChangeColormapRange(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_onChangeColormapRange @@ -2826,36 +2877,34 @@ public class ScreenPanel extends Panel { }//GEN-LAST:event_buttonZoom2ActionPerformed private void spinnerThresholdonChange(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerThresholdonChange - if (updatingCamtoolControls) { - return; - } - try { - if ((camera instanceof Camtool) && (((Camtool) camera).isPipelineStarted())) { - ((Camtool) camera).setThreshold((Double) spinnerThreshold.getValue()); + if (!updatingCamtoolControls) { + try { + if ((camera instanceof Camtool) && (((Camtool) camera).isPipelineStarted())) { + ((Camtool) camera).setThreshold((Double) spinnerThreshold.getValue()); + } + } catch (Exception ex) { + showException(ex); + updateCamtoolControls(); } - } catch (Exception ex) { - showException(ex); - updateCamtoolControls(); } }//GEN-LAST:event_spinnerThresholdonChange private void checkBackgroundActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkBackgroundActionPerformed if (camera instanceof Camtool){ - if (updatingCamtoolControls) { - return; - } - try { - if (((Camtool) camera).isPipelineStarted()) { - ((Camtool) camera).setBackgroundSubtraction(checkBackground.isSelected()); - } - } catch (Exception ex) { - showException(ex); - updateCamtoolControls(); - //There is a bug in camtool: it will flag bg extraction as on: - updatingCamtoolControls = true; - checkBackground.setSelected(false); - updatingCamtoolControls = false; + if (!updatingCamtoolControls) { + try { + if (((Camtool) camera).isPipelineStarted()) { + ((Camtool) camera).setBackgroundSubtraction(checkBackground.isSelected()); + } + } catch (Exception ex) { + showException(ex); + updateCamtoolControls(); + //There is a bug in camtool: it will flag bg extraction as on: + updatingCamtoolControls = true; + checkBackground.setSelected(false); + updatingCamtoolControls = false; + } } } else { camera.setBackgroundEnabled(checkBackground.isSelected()); @@ -2863,17 +2912,16 @@ public class ScreenPanel extends Panel { }//GEN-LAST:event_checkBackgroundActionPerformed private void checkThresholdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkThresholdActionPerformed - if (updatingCamtoolControls) { - return; - } - try { - if ((camera instanceof Camtool) && (((Camtool) camera).isPipelineStarted())) { - spinnerThreshold.setEnabled(checkThreshold.isSelected()); - ((Camtool) camera).setThreshold(checkThreshold.isSelected() ? (Double) spinnerThreshold.getValue() : null); + if (!updatingCamtoolControls) { + try { + if ((camera instanceof Camtool) && (((Camtool) camera).isPipelineStarted())) { + spinnerThreshold.setVisible(checkThreshold.isSelected()); + ((Camtool) camera).setThreshold(checkThreshold.isSelected() ? (Double) spinnerThreshold.getValue() : null); + } + } catch (Exception ex) { + showException(ex); + updateCamtoolControls(); } - } catch (Exception ex) { - showException(ex); - updateCamtoolControls(); } }//GEN-LAST:event_checkThresholdActionPerformed @@ -2909,6 +2957,39 @@ public class ScreenPanel extends Panel { } }//GEN-LAST:event_buttonProfileActionPerformed + private void checkGoodRegionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkGoodRegionActionPerformed + if (!updatingCamtoolControls) { + try { + if ((camera instanceof Camtool) && (((Camtool) camera).isPipelineStarted())) { + spinnerGrScale.setVisible(checkGoodRegion.isSelected()); labelGrScale.setVisible(spinnerGrScale.isVisible()); + spinnerGrThreshold.setVisible(checkGoodRegion.isSelected()); labelGrThreshold.setVisible(spinnerGrThreshold.isVisible()); + if (checkGoodRegion.isSelected()){ + ((Camtool) camera).setGoodRegion( (Double)spinnerGrThreshold.getValue(), (Double)spinnerGrScale.getValue() ); + } else { + ((Camtool) camera).setGoodRegion(null); + } + goodRegion = checkGoodRegion.isSelected(); + } + } catch (Exception ex) { + showException(ex); + updateCamtoolControls(); + } + } + }//GEN-LAST:event_checkGoodRegionActionPerformed + + private void spinnerGrThresholdonChange(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerGrThresholdonChange + if (!updatingCamtoolControls) { + try { + if ((camera instanceof Camtool) && (((Camtool) camera).isPipelineStarted())) { + ((Camtool) camera).setGoodRegion( (Double)spinnerGrThreshold.getValue(), (Double)spinnerGrScale.getValue() ); + } + } catch (Exception ex) { + showException(ex); + updateCamtoolControls(); + } + } + }//GEN-LAST:event_spinnerGrThresholdonChange + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton buttonArgs; private javax.swing.JRadioButton buttonAutomatic; @@ -2916,24 +2997,19 @@ public class ScreenPanel extends Panel { private javax.swing.JButton buttonConfig; private javax.swing.JRadioButton buttonDirect; private javax.swing.JToggleButton buttonFit; - private javax.swing.JRadioButton buttonFlame; private javax.swing.JRadioButton buttonFullRange; private javax.swing.JButton buttonGrabBackground; - private javax.swing.JRadioButton buttonGrayscale; private javax.swing.ButtonGroup buttonGroup1; private javax.swing.ButtonGroup buttonGroup2; private javax.swing.ButtonGroup buttonGroup3; private javax.swing.ButtonGroup buttonGroup4; - private javax.swing.JRadioButton buttonInverted; private javax.swing.JRadioButton buttonManual; private javax.swing.JToggleButton buttonMarker; private javax.swing.JToggleButton buttonPause; private javax.swing.JToggleButton buttonProfile; - private javax.swing.JRadioButton buttonRainbow; private javax.swing.JToggleButton buttonReticle; private javax.swing.JToggleButton buttonSave; private javax.swing.JButton buttonStop; - private javax.swing.JRadioButton buttonTemperature; private javax.swing.JRadioButton buttonZoom025; private javax.swing.JRadioButton buttonZoom05; private javax.swing.JRadioButton buttonZoom2; @@ -2941,9 +3017,11 @@ public class ScreenPanel extends Panel { private javax.swing.JRadioButton buttonZoomNormal; private javax.swing.JRadioButton buttonZoomStretch; private javax.swing.JCheckBox checkBackground; + private javax.swing.JCheckBox checkGoodRegion; private javax.swing.JCheckBox checkHistogram; private javax.swing.JCheckBox checkThreshold; private javax.swing.JComboBox comboCameras; + private javax.swing.JComboBox comboColormap; private javax.swing.JComboBox comboFilter; private javax.swing.JComboBox comboScreen; private javax.swing.JLabel jLabel1; @@ -2957,13 +3035,18 @@ public class ScreenPanel extends Panel { private javax.swing.JPanel jPanel5; private javax.swing.JPanel jPanel6; private javax.swing.JPanel jPanel7; - private javax.swing.JPanel jPanel8; private javax.swing.JProgressBar jProgressBar1; + private javax.swing.JLabel labelGrScale; + private javax.swing.JLabel labelGrThreshold; + private javax.swing.JLabel labelMax; + private javax.swing.JLabel labelMin; private javax.swing.JPanel panelScreen; private javax.swing.JPanel panelScreen1; private javax.swing.JPanel panelScreen2; private ch.psi.pshell.swing.ValueSelection pauseSelection; private ch.psi.pshell.imaging.Renderer renderer; + private javax.swing.JSpinner spinnerGrScale; + private javax.swing.JSpinner spinnerGrThreshold; private javax.swing.JSpinner spinnerMax; private javax.swing.JSpinner spinnerMin; private javax.swing.JSpinner spinnerThreshold; diff --git a/plugins/ScreenPanelDev.java b/plugins/ScreenPanelBack.java similarity index 86% rename from plugins/ScreenPanelDev.java rename to plugins/ScreenPanelBack.java index 0509a45..2440023 100644 --- a/plugins/ScreenPanelDev.java +++ b/plugins/ScreenPanelBack.java @@ -1,3 +1,5 @@ +package ScreenPanelBack; + /* * Copyright (c) 2014 Paul Scherrer Institute. All rights reserved. */ @@ -62,7 +64,6 @@ import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.image.BufferedImage; import java.io.FileInputStream; -import java.lang.reflect.Array; import java.net.ServerSocket; import java.nio.file.Files; import java.nio.file.Path; @@ -97,7 +98,7 @@ import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; /** * */ -public class ScreenPanelDev extends Panel { +public class ScreenPanel extends Panel { final String CAMERA_DEVICE_NAME = "CurrentCamera"; boolean useCamtoolStats = true; @@ -116,12 +117,11 @@ public class ScreenPanelDev extends Panel { Overlay[] userOv; Overlay[] fitOv; Overlay[] profileOv; - Overlay errorOverlay; + Overlay errorOverlay; boolean requestCameraListUpdate; Integer localServerPort; Process privateServer; String serverUrl; - boolean goodRegion; Double getCamtoolDouble(String name) { return (Double) Convert.toDouble(((Camtool) camera).getValue(name)); @@ -130,43 +130,27 @@ public class ScreenPanelDev extends Panel { double[] getCamtoolDoubleArray(String name) { return (double[]) Convert.toDouble(((Camtool) camera).getValue(name)); } - - class ImageData { - ImageData(){ + + class Frame { + + Frame(Data data) { + this.data = data; if (camera instanceof Camtool) { - String prefix = goodRegion ? "gr_" : ""; - xMean = getCamtoolDouble(prefix + "x_fit_mean"); - yMean = getCamtoolDouble(prefix + "y_fit_mean"); - xSigma = getCamtoolDouble(prefix + "x_fit_standard_deviation"); - ySigma = getCamtoolDouble(prefix + "y_fit_standard_deviation"); - x_fit_gauss_function = getCamtoolDoubleArray(prefix +"x_fit_gauss_function"); - y_fit_gauss_function = getCamtoolDoubleArray(prefix +"y_fit_gauss_function"); - x_profile = getCamtoolDoubleArray("x_profile"); - y_profile = getCamtoolDoubleArray("y_profile"); + xMean = getCamtoolDouble("x_fit_mean"); + yMean = getCamtoolDouble("y_fit_mean"); + xSigma = getCamtoolDouble("x_fit_standard_deviation"); + ySigma = getCamtoolDouble("y_fit_standard_deviation"); xCom = getCamtoolDouble("x_center_of_mass"); yCom = getCamtoolDouble("y_center_of_mass"); xRms = getCamtoolDouble("x_rms"); - yRms = getCamtoolDouble("y_rms"); - if (goodRegion){ - double[] gX2 = new double[x_profile.length]; - Arrays.fill(gX2, Double.NaN); - try{ - double x = getCamtoolDoubleArray("gr_x_axis")[0]; - System.arraycopy(x_fit_gauss_function, 0, gX2, (int) ((renderer.getCalibration() != null) ? renderer.getCalibration().convertToImageX(x): x), x_fit_gauss_function.length); - } catch (Exception ex){ - } - x_fit_gauss_function = gX2; - double[] gY2 = new double[y_profile.length]; - Arrays.fill(gY2, Double.NaN); - try{ - double y = getCamtoolDoubleArray("gr_y_axis")[0]; - System.arraycopy(y_fit_gauss_function, 0, gY2, (int) ((renderer.getCalibration() != null) ? renderer.getCalibration().convertToImageY(y): y), y_fit_gauss_function.length); - } catch (Exception ex){ - } - y_fit_gauss_function = gY2; - } - } + yRms = getCamtoolDouble("y_rms"); + x_profile = getCamtoolDoubleArray("x_profile"); + x_fit_gauss_function = getCamtoolDoubleArray("x_fit_gauss_function"); + y_profile = getCamtoolDoubleArray("y_profile"); + y_fit_gauss_function = getCamtoolDoubleArray("y_fit_gauss_function"); + } } + Data data; Double xMean; Double yMean; Double xCom; @@ -178,32 +162,18 @@ public class ScreenPanelDev extends Panel { double[] x_profile; double[] x_fit_gauss_function; double[] y_profile; - double[] y_fit_gauss_function; - } - - class Frame extends ImageData{ - - Frame(Data data) { - this.data = data; - } - Data data; + double[] y_fit_gauss_function; } final ArrayList imageBuffer = new ArrayList(); int imageBufferLenght = 0; Text imageBufferOverlay; - public ScreenPanelDev() { + public ScreenPanel() { initComponents(); - spinnerThreshold.setVisible(false); - spinnerGrThreshold.setVisible(false); labelGrThreshold.setVisible(false); - spinnerGrScale.setVisible(false); labelGrScale.setVisible(false); - //spinnerMin.setVisible(false); labelMin.setVisible(false); - //spinnerMax.setVisible(false); labelMax.setVisible(false); renderer.setPersistenceFile(Paths.get(getContext().getSetup().getContextPath(), "Renderer_Cameras.bin")); setPersistedComponents(new Component[]{buttonCamtool, buttonDirect}); comboCameras.setEnabled(false); - SwingUtils.setEnumCombo(comboColormap, Colormap.class); if (App.hasArgument("poll")) { try { polling = Integer.valueOf(App.getArgumentValue("poll")); @@ -578,7 +548,6 @@ public class ScreenPanelDev extends Panel { userOv = fo; } } - @Override public void onStateChange(State state, State former) { @@ -600,6 +569,9 @@ public class ScreenPanelDev extends Panel { System.out.println("Setting camera: " + cameraName + " [" + (buttonCamtool.isSelected() ? "camtool" : "direct") + "]"); parseUserOverlays(); errorOverlay = null; + checkBackground.setEnabled(false); + spinnerThreshold.setEnabled(false); + checkThreshold.setEnabled(false); if (dataTableDialog!=null){ dataTableDialog.dispose(); @@ -612,10 +584,8 @@ public class ScreenPanelDev extends Panel { calibrationDialolg = null; } - boolean was_camtool = false; if (camera != null) { //camera.removeAllListeners(); - was_camtool = camera instanceof Camtool; camera.close(); camera = null; } @@ -630,16 +600,8 @@ public class ScreenPanelDev extends Panel { boolean changed = !String.valueOf(cameraName).equals(this.cameraName); this.cameraName = cameraName; - - if (changed || buttonDirect.isSelected()) { - spinnerThreshold.setVisible(false); - spinnerGrThreshold.setVisible(false); labelGrThreshold.setVisible(false); - spinnerGrScale.setVisible(false); labelGrScale.setVisible(false); - checkThreshold.setEnabled(false); - checkGoodRegion.setEnabled(false); - } + if (changed) { - checkBackground.setEnabled(false); if ((devicesInitTask != null) && (devicesInitTask.isAlive())) { devicesInitTask.interrupt(); } @@ -677,36 +639,27 @@ public class ScreenPanelDev extends Panel { camera.initialize(); camera.assertInitialized(); System.out.println("Camera initialization OK"); - if (camera instanceof Camtool) { - //Managing no background exception. Can be done in a better way? + if (camera instanceof Camtool) { + //Managing no background exception. Can be done in a better way? + checkBackground.setEnabled(true); if (changed) { - ((Camtool) camera).startPipeline(cameraName, null); + ((Camtool) camera).startPipeline(cameraName, null); updateCamtoolControls(); - } else { - ((Camtool) camera).startPipeline(cameraName, null, checkBackground.isSelected(), null, null, null); + } else { + ((Camtool) camera).startPipeline(cameraName, null, checkBackground.isSelected(), null, checkThreshold.isSelected() ? (Double) spinnerThreshold.getValue() : null, null); } - // HashMap gr = null; - // if (goodRegion){ - // gr = new HashMap<>(); - // gr.put("threshold", spinnerGrThreshold.getValue()); - // gr.put("gfscale", spinnerGrScale.getValue()); - // } - // ((Camtool) camera).startPipeline(cameraName, null, checkBackground.isSelected(), null, checkThreshold.isSelected() ? (Double) spinnerThreshold.getValue() : null, gr); - //} - + spinnerThreshold.setEnabled(true); checkThreshold.setEnabled(true); - checkGoodRegion.setEnabled(true); ((Camtool) camera).startReceiver(); - } else { - checkThreshold.setSelected(false); - checkGoodRegion.setSelected(false); + } else { + checkBackground.setEnabled(true); + checkBackground.setSelected(false); if (polling <= 0) { camera.setMonitored(true); } else { camera.setPolling(polling); } - camera.setBackgroundEnabled(checkBackground.isSelected()); } buttonReticle.setEnabled(camera.getConfig().isCalibrated()); @@ -776,7 +729,7 @@ public class ScreenPanelDev extends Panel { onTimer(); } onChangeColormap(null); - checkBackground.setEnabled(true); + if (changed) { comboScreen.setModel(new DefaultComboBoxModel()); comboFilter.setModel(new DefaultComboBoxModel()); @@ -889,7 +842,26 @@ public class ScreenPanelDev extends Panel { try { if ((camera != null) && (camera instanceof ColormapSource)) { ColormapSourceConfig config = ((ColormapSource) camera).getConfig(); - comboColormap.setSelectedItem(config.colormap); + switch (config.colormap) { + case Grayscale: + buttonGrayscale.setSelected(true); + break; + case Rainbow: + buttonRainbow.setSelected(true); + break; + case Temperature: + buttonTemperature.setSelected(true); + break; + case Flame: + buttonFlame.setSelected(true); + break; + case Inverted: + buttonInverted.setSelected(true); + break; + default: + buttonGroup2.clearSelection(); + + } if (config.isDefaultColormap()) { buttonFullRange.setSelected(true); } else if (config.colormapAutomatic) { @@ -898,8 +870,6 @@ public class ScreenPanelDev extends Panel { buttonManual.setSelected(true); } - //spinnerMin.setVisible(buttonManual.isSelected()); labelMin.setVisible(spinnerMin.isVisible()); - //spinnerMax.setVisible(buttonManual.isSelected()); labelMax.setVisible(spinnerMax.isVisible()); spinnerMin.setEnabled(buttonManual.isSelected()); spinnerMax.setEnabled(buttonManual.isSelected()); spinnerMin.setValue(Double.isNaN(config.colormapMin) ? 0 : Math.min(Math.max((int) config.colormapMin, 0), 65535)); @@ -916,23 +886,14 @@ public class ScreenPanelDev extends Panel { void updateCamtoolControls() { if ((camera != null) && (camera instanceof Camtool)) { updatingCamtoolControls = true; - try { + try { checkBackground.setSelected(((Camtool) camera).getBackgroundSubtraction()); Double threshold = ((Camtool) camera).getThreshold(); checkThreshold.setSelected(threshold != null); - spinnerThreshold.setValue((threshold == null) ? 0 : threshold); - Map gr = ((Camtool) camera).getGoodRegion(); - checkGoodRegion.setSelected(gr != null); - if (gr != null){ - spinnerGrThreshold.setValue(gr.get("threshold")); - spinnerGrScale.setValue(gr.get("gfscale")); - } + spinnerThreshold.setValue((threshold == null) ? 0 : threshold); + } catch (Exception ex) { } - goodRegion = checkGoodRegion.isSelected(); - spinnerThreshold.setVisible(checkThreshold.isSelected()); - spinnerGrThreshold.setVisible(goodRegion); labelGrThreshold.setVisible(spinnerGrThreshold.isVisible()); - spinnerGrScale.setVisible(goodRegion); labelGrScale.setVisible(spinnerGrScale.isVisible()); updatingCamtoolControls = false; } } @@ -966,9 +927,9 @@ public class ScreenPanelDev extends Panel { try { ((Source) getDevice("image")).initialize(); } catch (IOException ex) { - Logger.getLogger(ScreenPanelDev.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(ScreenPanel.class.getName()).log(Level.SEVERE, null, ex); } catch (InterruptedException ex) { - Logger.getLogger(ScreenPanelDev.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(ScreenPanel.class.getName()).log(Level.SEVERE, null, ex); } } if (renderer.isPaused() != buttonPause.isSelected()) { @@ -1009,27 +970,39 @@ public class ScreenPanelDev extends Panel { int profileSize = renderer.getProfileSize(); if ((useCamtoolStats) && (camera instanceof Camtool)) { try { - ImageData id = null; if (renderer.isPaused()) { synchronized (imageBuffer) { for (Frame f : imageBuffer) { if (f.data == data) { - id = f; - break; + xMean = f.xMean; + xSigma = f.xSigma; + yMean = f.yMean; + ySigma = f.ySigma; + pX = f.x_profile; + gX = f.x_fit_gauss_function; + pY = f.y_profile; + gY = f.y_fit_gauss_function; + xCom = f.xCom; + xRms = f.xRms; + yCom = f.yCom; + yRms = f.yRms; } } } } else { - id = new ImageData(); + xMean = getCamtoolDouble("x_fit_mean"); + yMean = getCamtoolDouble("y_fit_mean"); + xSigma = getCamtoolDouble("x_fit_standard_deviation"); + ySigma = getCamtoolDouble("y_fit_standard_deviation"); + xCom = getCamtoolDouble("x_center_of_mass"); + yCom = getCamtoolDouble("y_center_of_mass"); + xRms = getCamtoolDouble("x_rms"); + yRms = getCamtoolDouble("y_rms"); + pX = getCamtoolDoubleArray("x_profile"); + gX = getCamtoolDoubleArray("x_fit_gauss_function"); + pY = getCamtoolDoubleArray("y_profile"); + gY = getCamtoolDoubleArray("y_fit_gauss_function"); } - if (id==null){ - return null; - } - xMean = id.xMean; xSigma = id.xSigma;yMean = id.yMean;ySigma = id.ySigma; - gX = id.x_fit_gauss_function; gY = id.y_fit_gauss_function; - pX = id.x_profile; pY = id.y_profile; - xCom = id.xCom; xRms = id.xRms; yCom = id.yCom; yRms = id.yRms; - profileSize /= 4; if (pX != null) { int[] x = Arr.indexesInt(pX.length); @@ -1042,23 +1015,16 @@ public class ScreenPanelDev extends Panel { double rangePlot = max - min; for (int i = 0; i < x.length; i++) { - if (gX != null) { - y[i] = (int) (height - 1 - (((gX[i] - minPlot) / rangePlot) * profileSize)); + if (gX != null) { + y[i] = (int) (height - 1 - (((gX[i] - minPlot) / rangePlot) * profileSize)); } p[i] = (int) (height - 1 - (((pX[i] - minPlot) / rangePlot) * profileSize)); } - - if (goodRegion){ - for (int i = 0; i < x.length; i++) { - y[i] = (Double.isNaN(gX[i])) ? 100000 : y[i]; - } - } - vgaussian = new Overlays.Polyline(penFit, x, y); vprofile = new Overlays.Polyline(renderer.getPenProfile(), x, p); } - if (pY != null) { + if (pX != null) { int[] y = Arr.indexesInt(pY.length); int[] x = new int[pY.length]; int[] p = new int[pY.length]; @@ -1071,16 +1037,10 @@ public class ScreenPanelDev extends Panel { for (int i = 0; i < x.length; i++) { if (gY != null) { - x[i] = (int) (((gY[i] - minPlot) / rangePlot) * profileSize); + x[i] = (int) (((gY[i] - minPlot) / rangePlot) * profileSize); } p[i] = (int) (((pY[i] - minPlot) / rangePlot) * profileSize); } - - if (goodRegion){ - for (int i = 0; i < x.length; i++) { - x[i] = (Double.isNaN(gY[i])) ? -1 :x[i]; - } - } hgaussian = new Overlays.Polyline(penFit, x, y); hprofile = new Overlays.Polyline(renderer.getPenProfile(), p, y); } @@ -1230,20 +1190,6 @@ public class ScreenPanelDev extends Panel { cross = new Overlays.Crosshairs(penCross, center, new Dimension(Math.abs(2 * xSigma.intValue()), 2 * Math.abs(ySigma.intValue()))); } fOv = new Overlay[]{hgaussian, vgaussian, cross, textFit}; - - if (goodRegion){ - try{ - double[] x = getCamtoolDoubleArray("gr_x_axis"); double[] y = getCamtoolDoubleArray("gr_y_axis"); - double x1 = x[0]; double x2 = x[x.length-1]; double y1 = y[0]; double y2 = y[y.length-1]; - Overlays.Rect goodRegionOv = new Overlays.Rect(new Pen(penFit.getColor(), 0, Pen.LineStyle.dotted)); - goodRegionOv.setCalibration(renderer.getCalibration()); - goodRegionOv.setAbsolutePosition(new PointDouble(x1, y1)); - goodRegionOv.setAbsoluteSize(new DimensionDouble(x2-x1, y2-y1)); - fOv = Arr.append(fOv, goodRegionOv); - } catch (Exception ex){ - } - } - } return new Overlay[][]{pOv, fOv}; } @@ -1710,11 +1656,11 @@ public class ScreenPanelDev extends Panel { c.put("reference_marker_height", Double.valueOf(textHeight.getText())); } ((Camtool) camera).setCalibration(cameraName, c); - Logger.getLogger(ScreenPanelDev.class.getName()).warning("Updated " + cameraName + " calibration: " + x1 + ", "+ x2 + ", " + y1 + ", " + y2); + Logger.getLogger(ScreenPanel.class.getName()).warning("Updated " + cameraName + " calibration: " + x1 + ", "+ x2 + ", " + y1 + ", " + y2); } } } catch (IOException ex) { - Logger.getLogger(ScreenPanelDev.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(ScreenPanel.class.getName()).log(Level.SEVERE, null, ex); } } } @@ -1740,6 +1686,8 @@ public class ScreenPanelDev extends Panel { dataTableDialog.requestFocus(); return; } + List ids = new ArrayList(((Camtool)camera).getValue().getIdentifiers()); + Collections.sort(ids); //String msg = String.join("\n", ids); //SwingUtils.showMessage(getTopLevel(), "Image Data", msg); dataTableModel = new DefaultTableModel(new Object[0][2], new String[]{"Name", "Value"}) { @@ -1750,6 +1698,9 @@ public class ScreenPanelDev extends Panel { return false; } }; + for (String id : ids){ + dataTableModel.addRow(new Object[]{id, ""}); + } updateImageData(); StreamValue val = ((Camtool)camera).getStream().take(); JTable dataTable = new JTable(dataTableModel); @@ -1775,28 +1726,22 @@ public class ScreenPanelDev extends Panel { } void updateImageData(){ - if ((dataTableModel!=null)&&(camera instanceof Camtool)){ - List ids = new ArrayList(((Camtool)camera).getValue().getIdentifiers()); - if (ids.size() != dataTableModel.getRowCount()){ - dataTableModel.setNumRows(0); - Collections.sort(ids); - for (String id : ids){ - dataTableModel.addRow(new Object[]{id, ""}); - } - } - for (int i = 0 ; i< dataTableModel.getRowCount(); i++){ - String id = String.valueOf(dataTableModel.getValueAt(i, 0)); - Object obj = ((Camtool)camera).getValue(id); - if (obj!=null){ - if (obj.getClass().isArray()){ - obj = obj.getClass().getComponentType().getSimpleName() + "[" + Array.getLength(obj) + "]"; - } else if (obj instanceof Double){ - obj = Convert.roundDouble((Double) obj, 1); - } else if (obj instanceof Float){ - obj = Convert.roundDouble((Float) obj, 1); - } - } - dataTableModel.setValueAt(String.valueOf(obj), i, 1); + if (dataTableModel!=null){ + if (camera instanceof Camtool){ + for (int i = 0 ; i< dataTableModel.getRowCount(); i++){ + String id = String.valueOf(dataTableModel.getValueAt(i, 0)); + Object obj = ((Camtool)camera).getValue(id); + if (obj!=null){ + if (obj.getClass().isArray()){ + obj = obj.getClass().getName(); + } else if (obj instanceof Double){ + obj = Convert.roundDouble((Double) obj, 1); + } else if (obj instanceof Float){ + obj = Convert.roundDouble((Float) obj, 1); + } + } + dataTableModel.setValueAt(String.valueOf(obj), i, 1); + } } } } @@ -1838,17 +1783,20 @@ public class ScreenPanelDev extends Panel { buttonZoom05 = new javax.swing.JRadioButton(); buttonZoom2 = new javax.swing.JRadioButton(); jPanel2 = new javax.swing.JPanel(); - checkHistogram = new javax.swing.JCheckBox(); - comboColormap = new javax.swing.JComboBox(); - jLabel3 = new javax.swing.JLabel(); - jLabel4 = new javax.swing.JLabel(); buttonFullRange = new javax.swing.JRadioButton(); buttonManual = new javax.swing.JRadioButton(); - buttonAutomatic = new javax.swing.JRadioButton(); - labelMin = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + jLabel4 = new javax.swing.JLabel(); spinnerMin = new javax.swing.JSpinner(); spinnerMax = new javax.swing.JSpinner(); - labelMax = new javax.swing.JLabel(); + buttonAutomatic = new javax.swing.JRadioButton(); + checkHistogram = new javax.swing.JCheckBox(); + jPanel8 = new javax.swing.JPanel(); + buttonInverted = new javax.swing.JRadioButton(); + buttonFlame = new javax.swing.JRadioButton(); + buttonTemperature = new javax.swing.JRadioButton(); + buttonRainbow = new javax.swing.JRadioButton(); + buttonGrayscale = new javax.swing.JRadioButton(); jPanel5 = new javax.swing.JPanel(); buttonCamtool = new javax.swing.JRadioButton(); buttonDirect = new javax.swing.JRadioButton(); @@ -1863,11 +1811,6 @@ public class ScreenPanelDev extends Panel { checkThreshold = new javax.swing.JCheckBox(); spinnerThreshold = new javax.swing.JSpinner(); checkBackground = new javax.swing.JCheckBox(); - checkGoodRegion = new javax.swing.JCheckBox(); - spinnerGrScale = new javax.swing.JSpinner(); - spinnerGrThreshold = new javax.swing.JSpinner(); - labelGrThreshold = new javax.swing.JLabel(); - labelGrScale = new javax.swing.JLabel(); setPreferredSize(new java.awt.Dimension(873, 600)); @@ -2058,7 +2001,7 @@ public class ScreenPanelDev extends Panel { .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) @@ -2130,7 +2073,7 @@ public class ScreenPanelDev extends Panel { .addComponent(buttonZoom025) .addComponent(buttonZoom05) .addComponent(buttonZoom2)) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGap(47, 47, 47)) ); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -2152,27 +2095,8 @@ public class ScreenPanelDev extends Panel { jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Colormap")); - checkHistogram.setText("Histogram"); - checkHistogram.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - checkHistogramActionPerformed(evt); - } - }); - - comboColormap.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - onChangeColormap(evt); - } - }); - - jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); - jLabel3.setText("Type:"); - - jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); - jLabel4.setText("Range:"); - buttonGroup3.add(buttonFullRange); - buttonFullRange.setText("Full"); + buttonFullRange.setText("Full range"); buttonFullRange.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { onChangeColormap(evt); @@ -2187,15 +2111,9 @@ public class ScreenPanelDev extends Panel { } }); - buttonGroup3.add(buttonAutomatic); - buttonAutomatic.setText("Automatic"); - buttonAutomatic.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - onChangeColormap(evt); - } - }); + jLabel3.setText("Min:"); - labelMin.setText("Min:"); + jLabel4.setText("Max:"); spinnerMin.setModel(new javax.swing.SpinnerNumberModel(0, 0, 65535, 1)); spinnerMin.setEnabled(false); @@ -2215,63 +2133,148 @@ public class ScreenPanelDev extends Panel { } }); - labelMax.setText("Max:"); + buttonGroup3.add(buttonAutomatic); + buttonAutomatic.setText("Automatic"); + buttonAutomatic.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + onChangeColormap(evt); + } + }); + + checkHistogram.setText("Histogram"); + checkHistogram.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + checkHistogramActionPerformed(evt); + } + }); + + buttonGroup2.add(buttonInverted); + buttonInverted.setText("Inverted"); + buttonInverted.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + onChangeColormap(evt); + } + }); + + buttonGroup2.add(buttonFlame); + buttonFlame.setText("Flame"); + buttonFlame.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + onChangeColormap(evt); + } + }); + + buttonGroup2.add(buttonTemperature); + buttonTemperature.setText("Temperature"); + buttonTemperature.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + onChangeColormap(evt); + } + }); + + buttonGroup2.add(buttonRainbow); + buttonRainbow.setText("Rainbow"); + buttonRainbow.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + onChangeColormap(evt); + } + }); + + buttonGroup2.add(buttonGrayscale); + buttonGrayscale.setText("Grayscale"); + buttonGrayscale.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + onChangeColormap(evt); + } + }); + + javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8); + jPanel8.setLayout(jPanel8Layout); + jPanel8Layout.setHorizontalGroup( + jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel8Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel8Layout.createSequentialGroup() + .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(buttonGrayscale) + .addComponent(buttonInverted)) + .addGap(20, 20, 20)) + .addComponent(buttonFlame)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(buttonTemperature) + .addComponent(buttonRainbow))) + .addGap(0, 0, 0)) + ); + jPanel8Layout.setVerticalGroup( + jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel8Layout.createSequentialGroup() + .addGap(0, 0, 0) + .addComponent(buttonGrayscale) + .addGap(0, 0, 0) + .addComponent(buttonInverted) + .addGap(0, 0, 0) + .addComponent(buttonFlame) + .addGap(0, 0, 0) + .addComponent(buttonRainbow) + .addGap(0, 0, 0) + .addComponent(buttonTemperature) + .addGap(0, 0, 0)) + ); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() - .addGap(4, 4, 4) + .addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel3) - .addComponent(jLabel4)) - .addGap(4, 4, 4) - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(buttonAutomatic) - .addComponent(buttonFullRange) - .addComponent(buttonManual) - .addComponent(comboColormap, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() - .addComponent(labelMax) - .addGap(2, 2, 2) - .addComponent(spinnerMax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() - .addComponent(labelMin) - .addGap(2, 2, 2) - .addComponent(spinnerMin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addComponent(checkHistogram, javax.swing.GroupLayout.Alignment.TRAILING)) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(checkHistogram) + .addGap(0, 0, Short.MAX_VALUE)) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(buttonAutomatic) + .addComponent(buttonFullRange) + .addComponent(buttonManual) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel4) + .addComponent(jLabel3)) + .addGap(2, 2, 2) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(spinnerMin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(spinnerMax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) ); jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerMax, spinnerMin}); - jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel3, jLabel4}); - jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() + .addGroup(jPanel2Layout.createSequentialGroup() .addGap(4, 4, 4) - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(comboColormap, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel3) - .addComponent(checkHistogram)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(buttonAutomatic) - .addComponent(jLabel4)) - .addGap(0, 0, 0) - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) - .addComponent(labelMin) - .addComponent(spinnerMin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(buttonFullRange)) - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) - .addComponent(buttonManual) - .addComponent(labelMax) - .addComponent(spinnerMax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addContainerGap()) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(buttonAutomatic) + .addGap(0, 0, 0) + .addComponent(buttonFullRange) + .addGap(0, 0, 0) + .addComponent(buttonManual) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3) + .addComponent(spinnerMin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel4) + .addComponent(spinnerMax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(checkHistogram)) ); jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Source")); @@ -2385,7 +2388,8 @@ public class ScreenPanelDev extends Panel { } }); - spinnerThreshold.setModel(new javax.swing.SpinnerNumberModel(0.0d, 0.0d, 99999.0d, 1.0d)); + spinnerThreshold.setModel(new javax.swing.SpinnerNumberModel(0.0d, 0.0d, 65535.0d, 1.0d)); + spinnerThreshold.setEnabled(false); spinnerThreshold.setPreferredSize(new java.awt.Dimension(77, 20)); spinnerThreshold.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { @@ -2400,33 +2404,6 @@ public class ScreenPanelDev extends Panel { } }); - checkGoodRegion.setText("Good Region"); - checkGoodRegion.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - checkGoodRegionActionPerformed(evt); - } - }); - - spinnerGrScale.setModel(new javax.swing.SpinnerNumberModel(3.0d, 0.01d, 100.0d, 1.0d)); - spinnerGrScale.setPreferredSize(new java.awt.Dimension(77, 20)); - spinnerGrScale.addChangeListener(new javax.swing.event.ChangeListener() { - public void stateChanged(javax.swing.event.ChangeEvent evt) { - spinnerGrThresholdonChange(evt); - } - }); - - spinnerGrThreshold.setModel(new javax.swing.SpinnerNumberModel(0.5d, 0.04d, 1.0d, 0.1d)); - spinnerGrThreshold.setPreferredSize(new java.awt.Dimension(77, 20)); - spinnerGrThreshold.addChangeListener(new javax.swing.event.ChangeListener() { - public void stateChanged(javax.swing.event.ChangeEvent evt) { - spinnerGrThresholdonChange(evt); - } - }); - - labelGrThreshold.setText("Threshold:"); - - labelGrScale.setText("Scale:"); - javax.swing.GroupLayout panelScreen2Layout = new javax.swing.GroupLayout(panelScreen2); panelScreen2.setLayout(panelScreen2Layout); panelScreen2Layout.setHorizontalGroup( @@ -2434,29 +2411,13 @@ public class ScreenPanelDev extends Panel { .addGroup(panelScreen2Layout.createSequentialGroup() .addContainerGap() .addGroup(panelScreen2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelScreen2Layout.createSequentialGroup() - .addComponent(checkGoodRegion) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(labelGrScale) - .addGap(2, 2, 2) - .addComponent(spinnerGrScale, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelScreen2Layout.createSequentialGroup() - .addGap(0, 0, Short.MAX_VALUE) - .addComponent(labelGrThreshold) - .addGap(2, 2, 2) - .addComponent(spinnerGrThreshold, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(panelScreen2Layout.createSequentialGroup() - .addComponent(checkBackground) - .addGap(0, 0, Short.MAX_VALUE)) + .addComponent(checkBackground) .addGroup(panelScreen2Layout.createSequentialGroup() .addComponent(checkThreshold) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(spinnerThreshold, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) - .addContainerGap()) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); - - panelScreen2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerGrScale, spinnerGrThreshold, spinnerThreshold}); - panelScreen2Layout.setVerticalGroup( panelScreen2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelScreen2Layout.createSequentialGroup() @@ -2466,15 +2427,6 @@ public class ScreenPanelDev extends Panel { .addGroup(panelScreen2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(checkThreshold) .addComponent(spinnerThreshold, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(2, 2, 2) - .addGroup(panelScreen2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(checkGoodRegion) - .addComponent(spinnerGrScale, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(labelGrScale)) - .addGap(2, 2, 2) - .addGroup(panelScreen2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(spinnerGrThreshold, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(labelGrThreshold)) .addContainerGap()) ); @@ -2485,14 +2437,14 @@ public class ScreenPanelDev extends Panel { .addGroup(jPanel4Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) - .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, 0, Short.MAX_VALUE) - .addComponent(panelScreen, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 0, Short.MAX_VALUE) - .addComponent(panelScreen1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 0, Short.MAX_VALUE) - .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 0, Short.MAX_VALUE) + .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(panelScreen, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(panelScreen1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(pauseSelection, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) - .addComponent(panelScreen2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 0, Short.MAX_VALUE)) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addComponent(panelScreen2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap()) ); jPanel4Layout.setVerticalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -2737,23 +2689,23 @@ public class ScreenPanelDev extends Panel { private void onChangeColormap(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onChangeColormap try { - if ((camera != null) && (camera instanceof ColormapSource) && !updatingColormap) { + if ((camera != null) && (camera instanceof ColormapSource) && !updatingColormap) { ColormapSource source = (ColormapSource) camera; Color colorReticule = new Color(16, 16, 16); Color colorMarker = new Color(128, 128, 128); - source.getConfig().colormap = (Colormap)comboColormap.getSelectedItem(); - switch (source.getConfig().colormap){ - case Grayscale: - case Inverted: - colorReticule = new Color(0, 192, 0); - colorMarker = new Color(64, 255, 64); - break; - case Flame: - colorReticule = new Color(0, 192, 0); - colorMarker = new Color(64, 255, 64); - break; + if (buttonGrayscale.isSelected() || buttonInverted.isSelected()) { + colorReticule = new Color(0, 192, 0); + colorMarker = new Color(64, 255, 64); + source.getConfig().colormap = buttonGrayscale.isSelected() ? Colormap.Grayscale : Colormap.Inverted; + } else if (buttonFlame.isSelected()) { + colorReticule = new Color(0, 192, 0); + colorMarker = new Color(64, 255, 64); + source.getConfig().colormap = Colormap.Flame; + } else if (buttonTemperature.isSelected()) { + source.getConfig().colormap = Colormap.Temperature; + } else if (buttonRainbow.isSelected()) { + source.getConfig().colormap = Colormap.Rainbow; } - renderer.setPenReticle(new Pen(colorReticule)); renderer.setPenProfile(new Pen(colorReticule, 0)); renderer.setPenMarker(new Pen(colorMarker, 2)); @@ -2763,15 +2715,14 @@ public class ScreenPanelDev extends Panel { source.getConfig().colormapMin = buttonFullRange.isSelected() ? Double.NaN : (Integer) spinnerMin.getValue(); source.getConfig().colormapMax = buttonFullRange.isSelected() ? Double.NaN : (Integer) spinnerMax.getValue(); source.getConfig().save(); - source.refresh(); + source.refresh(); if (buttonPause.isSelected()) { updatePause(); } - updateColormap(); } } catch (Exception ex) { showException(ex); - } + } }//GEN-LAST:event_onChangeColormap private void onChangeColormapRange(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_onChangeColormapRange @@ -2877,34 +2828,36 @@ public class ScreenPanelDev extends Panel { }//GEN-LAST:event_buttonZoom2ActionPerformed private void spinnerThresholdonChange(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerThresholdonChange - if (!updatingCamtoolControls) { - try { - if ((camera instanceof Camtool) && (((Camtool) camera).isPipelineStarted())) { - ((Camtool) camera).setThreshold((Double) spinnerThreshold.getValue()); - } - } catch (Exception ex) { - showException(ex); - updateCamtoolControls(); + if (updatingCamtoolControls) { + return; + } + try { + if ((camera instanceof Camtool) && (((Camtool) camera).isPipelineStarted())) { + ((Camtool) camera).setThreshold((Double) spinnerThreshold.getValue()); } + } catch (Exception ex) { + showException(ex); + updateCamtoolControls(); } }//GEN-LAST:event_spinnerThresholdonChange private void checkBackgroundActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkBackgroundActionPerformed if (camera instanceof Camtool){ - if (!updatingCamtoolControls) { - try { - if (((Camtool) camera).isPipelineStarted()) { - ((Camtool) camera).setBackgroundSubtraction(checkBackground.isSelected()); - } - } catch (Exception ex) { - showException(ex); - updateCamtoolControls(); - //There is a bug in camtool: it will flag bg extraction as on: - updatingCamtoolControls = true; - checkBackground.setSelected(false); - updatingCamtoolControls = false; - + if (updatingCamtoolControls) { + return; + } + try { + if (((Camtool) camera).isPipelineStarted()) { + ((Camtool) camera).setBackgroundSubtraction(checkBackground.isSelected()); } + } catch (Exception ex) { + showException(ex); + updateCamtoolControls(); + //There is a bug in camtool: it will flag bg extraction as on: + updatingCamtoolControls = true; + checkBackground.setSelected(false); + updatingCamtoolControls = false; + } } else { camera.setBackgroundEnabled(checkBackground.isSelected()); @@ -2912,16 +2865,17 @@ public class ScreenPanelDev extends Panel { }//GEN-LAST:event_checkBackgroundActionPerformed private void checkThresholdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkThresholdActionPerformed - if (!updatingCamtoolControls) { - try { - if ((camera instanceof Camtool) && (((Camtool) camera).isPipelineStarted())) { - spinnerThreshold.setVisible(checkThreshold.isSelected()); - ((Camtool) camera).setThreshold(checkThreshold.isSelected() ? (Double) spinnerThreshold.getValue() : null); - } - } catch (Exception ex) { - showException(ex); - updateCamtoolControls(); + if (updatingCamtoolControls) { + return; + } + try { + if ((camera instanceof Camtool) && (((Camtool) camera).isPipelineStarted())) { + spinnerThreshold.setEnabled(checkThreshold.isSelected()); + ((Camtool) camera).setThreshold(checkThreshold.isSelected() ? (Double) spinnerThreshold.getValue() : null); } + } catch (Exception ex) { + showException(ex); + updateCamtoolControls(); } }//GEN-LAST:event_checkThresholdActionPerformed @@ -2957,39 +2911,6 @@ public class ScreenPanelDev extends Panel { } }//GEN-LAST:event_buttonProfileActionPerformed - private void checkGoodRegionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkGoodRegionActionPerformed - if (!updatingCamtoolControls) { - try { - if ((camera instanceof Camtool) && (((Camtool) camera).isPipelineStarted())) { - spinnerGrScale.setVisible(checkGoodRegion.isSelected()); labelGrScale.setVisible(spinnerGrScale.isVisible()); - spinnerGrThreshold.setVisible(checkGoodRegion.isSelected()); labelGrThreshold.setVisible(spinnerGrThreshold.isVisible()); - if (checkGoodRegion.isSelected()){ - ((Camtool) camera).setGoodRegion( (Double)spinnerGrThreshold.getValue(), (Double)spinnerGrScale.getValue() ); - } else { - ((Camtool) camera).setGoodRegion(null); - } - goodRegion = checkGoodRegion.isSelected(); - } - } catch (Exception ex) { - showException(ex); - updateCamtoolControls(); - } - } - }//GEN-LAST:event_checkGoodRegionActionPerformed - - private void spinnerGrThresholdonChange(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerGrThresholdonChange - if (!updatingCamtoolControls) { - try { - if ((camera instanceof Camtool) && (((Camtool) camera).isPipelineStarted())) { - ((Camtool) camera).setGoodRegion( (Double)spinnerGrThreshold.getValue(), (Double)spinnerGrScale.getValue() ); - } - } catch (Exception ex) { - showException(ex); - updateCamtoolControls(); - } - } - }//GEN-LAST:event_spinnerGrThresholdonChange - // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton buttonArgs; private javax.swing.JRadioButton buttonAutomatic; @@ -2997,19 +2918,24 @@ public class ScreenPanelDev extends Panel { private javax.swing.JButton buttonConfig; private javax.swing.JRadioButton buttonDirect; private javax.swing.JToggleButton buttonFit; + private javax.swing.JRadioButton buttonFlame; private javax.swing.JRadioButton buttonFullRange; private javax.swing.JButton buttonGrabBackground; + private javax.swing.JRadioButton buttonGrayscale; private javax.swing.ButtonGroup buttonGroup1; private javax.swing.ButtonGroup buttonGroup2; private javax.swing.ButtonGroup buttonGroup3; private javax.swing.ButtonGroup buttonGroup4; + private javax.swing.JRadioButton buttonInverted; private javax.swing.JRadioButton buttonManual; private javax.swing.JToggleButton buttonMarker; private javax.swing.JToggleButton buttonPause; private javax.swing.JToggleButton buttonProfile; + private javax.swing.JRadioButton buttonRainbow; private javax.swing.JToggleButton buttonReticle; private javax.swing.JToggleButton buttonSave; private javax.swing.JButton buttonStop; + private javax.swing.JRadioButton buttonTemperature; private javax.swing.JRadioButton buttonZoom025; private javax.swing.JRadioButton buttonZoom05; private javax.swing.JRadioButton buttonZoom2; @@ -3017,11 +2943,9 @@ public class ScreenPanelDev extends Panel { private javax.swing.JRadioButton buttonZoomNormal; private javax.swing.JRadioButton buttonZoomStretch; private javax.swing.JCheckBox checkBackground; - private javax.swing.JCheckBox checkGoodRegion; private javax.swing.JCheckBox checkHistogram; private javax.swing.JCheckBox checkThreshold; private javax.swing.JComboBox comboCameras; - private javax.swing.JComboBox comboColormap; private javax.swing.JComboBox comboFilter; private javax.swing.JComboBox comboScreen; private javax.swing.JLabel jLabel1; @@ -3035,18 +2959,13 @@ public class ScreenPanelDev extends Panel { private javax.swing.JPanel jPanel5; private javax.swing.JPanel jPanel6; private javax.swing.JPanel jPanel7; + private javax.swing.JPanel jPanel8; private javax.swing.JProgressBar jProgressBar1; - private javax.swing.JLabel labelGrScale; - private javax.swing.JLabel labelGrThreshold; - private javax.swing.JLabel labelMax; - private javax.swing.JLabel labelMin; private javax.swing.JPanel panelScreen; private javax.swing.JPanel panelScreen1; private javax.swing.JPanel panelScreen2; private ch.psi.pshell.swing.ValueSelection pauseSelection; private ch.psi.pshell.imaging.Renderer renderer; - private javax.swing.JSpinner spinnerGrScale; - private javax.swing.JSpinner spinnerGrThreshold; private javax.swing.JSpinner spinnerMax; private javax.swing.JSpinner spinnerMin; private javax.swing.JSpinner spinnerThreshold; diff --git a/plugins/ScreenPanelDev.form b/plugins/ScreenPanelDev.form deleted file mode 100644 index 1f6a4ec..0000000 --- a/plugins/ScreenPanelDev.form +++ /dev/null @@ -1,945 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/script/RFscan/SchottkyScan.py b/script/RFscan/SchottkyScan.py index 98b70fb..d573e35 100644 --- a/script/RFscan/SchottkyScan.py +++ b/script/RFscan/SchottkyScan.py @@ -21,7 +21,7 @@ bphase.config.resolution = 1.0 bphase.config.save() bphase.initialize() st = Stream("Schottky", dispatcher) -q = st.addScalar("Charge", "SINEG01-DICT215:B1_CHARGE", 1, 0) +q = st.addScalar("Charge", "SINEG01-DICT215:B1_CHARGE", 1, 0) st.initialize() st.start() rphase = Channel("SINEG01-RSYS:GET-VSUM-PHASE", type = 'd', alias = 'RF phase') @@ -37,17 +37,20 @@ try: rfphase = [val.mean for val in r.getReadable(1)] rfphaserms = [val.stdev for val in r.getReadable(1)] finally: - bphase.write(phase0) + bphase.write(bphase0) bphase.close() st.close() q.close() rphase.close() #Setting the return value +print "MAX CHARGE = " , max(charge) index_max = charge.index(max(charge)) +print "INDEX = " , index_max rphase_ref = rfphase[index_max] - 80 +bphase_ref = bphase[index_max] - 80 -set_return(rphase_ref) +set_return([rphase_ref, bphase_ref]) # save the entry in the logbook #if get_option("Generated data file:\n" + get_exec_pars().path +"\n\n" + "Save to ELOG?", "YesNo") == "Yes": diff --git a/script/RFscan/phase_scan_caqtdm.py b/script/RFscan/phase_scan_caqtdm.py index 6035cca..5501c0d 100644 --- a/script/RFscan/phase_scan_caqtdm.py +++ b/script/RFscan/phase_scan_caqtdm.py @@ -81,8 +81,8 @@ amplitude_scale = fit_amplitude / Ampl power_scale = Power / math.pow(Ampl,2) caput(station + "-RSYS:SET-VSUM-PHASE-OFFSET-BASE", phase_offset) -caput(station + "-RSYS:SET-VSUM-AMPLT-SCALE", amplitude_scale) -caput(station + "-RSYS:SET-VOLT-POWER-SCALE", power_scale) +#caput(station + "-RSYS:SET-VSUM-AMPLT-SCALE", amplitude_scale) +#caput(station + "-RSYS:SET-VOLT-POWER-SCALE", power_scale) #title="Phase scan "+str(station) #message=("Energy Gain: %0.3f" % energy_gain + "MeV\n" +