diff --git a/devices/CurrentCamera.properties b/devices/CurrentCamera.properties index 86acd6b..3ef7a30 100644 --- a/devices/CurrentCamera.properties +++ b/devices/CurrentCamera.properties @@ -1,12 +1,12 @@ -#Wed Sep 21 11:42:31 CEST 2016 +#Wed Sep 21 15:08:07 CEST 2016 colormap=Grayscale colormapAutomatic=true colormapMax=0.0 colormapMin=0.0 -flipHorizontally=true -flipVertically=true +flipHorizontally=false +flipVertically=false grayscale=false -imageHeight=1628 +imageHeight=1024 imageWidth=1280 invert=false rescaleFactor=1.0 @@ -18,9 +18,9 @@ roiY=0 rotation=0.0 rotationCrop=true scale=1.0 -spatialCalOffsetX=-685.0 -spatialCalOffsetY=-874.0 -spatialCalScaleX=14.146772767462423 -spatialCalScaleY=12.708498808578236 +spatialCalOffsetX=NaN +spatialCalOffsetY=NaN +spatialCalScaleX=NaN +spatialCalScaleY=NaN spatialCalUnits=mm transpose=false diff --git a/plugins/CamerasSimple.form b/plugins/Cameras.form similarity index 98% rename from plugins/CamerasSimple.form rename to plugins/Cameras.form index 28ac2d5..f0d2e57 100644 --- a/plugins/CamerasSimple.form +++ b/plugins/Cameras.form @@ -19,13 +19,13 @@ - + - + diff --git a/plugins/CamerasSimple.java b/plugins/Cameras.java similarity index 66% rename from plugins/CamerasSimple.java rename to plugins/Cameras.java index adad60d..69fde93 100644 --- a/plugins/CamerasSimple.java +++ b/plugins/Cameras.java @@ -14,7 +14,7 @@ import ch.psi.utils.IO; import ch.psi.utils.swing.SwingUtils; import ch.psi.utils.swing.TextEditor; import ch.psi.pshell.epics.PsiCamera; -//import ch.psi.pshell.epics.Camtool; +import ch.psi.pshell.epics.Camtool; import ch.psi.pshell.core.JsonSerializer; import ch.psi.pshell.device.Device; import ch.psi.pshell.epics.ArraySource; @@ -28,9 +28,7 @@ import ch.psi.pshell.imaging.Overlay; import ch.psi.pshell.imaging.Overlays; import ch.psi.pshell.imaging.Overlays.Text; import ch.psi.pshell.imaging.Pen; -import static ch.psi.pshell.imaging.Renderer.PEN_ERROR_TEXT; import ch.psi.pshell.imaging.Renderer.Profile; -import static ch.psi.pshell.imaging.RendererMenu.PEN_MARKER; import ch.psi.pshell.imaging.Source; import ch.psi.pshell.imaging.Utils; import ch.psi.pshell.scripting.InterpreterResult; @@ -61,12 +59,11 @@ import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; /** * */ -public class CamerasSimple extends Panel { +public class Cameras extends Panel { - public CamerasSimple() { + public Cameras() { initComponents(); renderer.setPersistenceFile(Paths.get(getController().getSetup().getContextPath(), "Renderer_Cameras.bin")); - renderer.setProfileFactor(4); setPersistedComponents(new Component[]{checkCamtool}); comboCameras.setEnabled(false); if (App.hasArgument("poll")) { @@ -117,7 +114,7 @@ public class CamerasSimple extends Panel { fitOv = null; } else { Overlay[] profile = renderer.getProfileOverlays(); - profile = ((profile != null) && (profile.length==4)) ? getFitOverlays(bi) : null; + profile = ((profile != null) && (profile.length==4)) ? getFitOverlays(data) : null; renderer.updateOverlays(profile, fitOv); fitOv = profile; } @@ -361,7 +358,7 @@ public class CamerasSimple extends Panel { //System.out.println(bi.getWidth() + " - " + bi.getHeight()); if (!renderer.isPaused() && buttonFit.isSelected()){ Overlay[] profile = renderer.getProfileOverlays(); - profile = ((profile != null) && (profile.length==4)) ? getFitOverlays(bi) : null; + profile = ((profile != null) && (profile.length==4)) ? getFitOverlays(data) : null; renderer.updateOverlays(profile, fitOv); fitOv = profile; } @@ -375,7 +372,7 @@ public class CamerasSimple extends Panel { } catch (Exception ex) { if (renderer.getDevice()==null){ renderer.setZoom(1.0); - renderer.addOverlay(new Text(PEN_ERROR_TEXT, ex.toString(), new Font("Verdana", Font.PLAIN, 12), new Point(20, 20))); + renderer.addOverlay(new Text(renderer.getPenErrorText(), ex.toString(), new Font("Verdana", Font.PLAIN, 12), new Point(20, 20))); } } finally { checkReticle(); @@ -402,359 +399,147 @@ public class CamerasSimple extends Panel { try { ((Source)getDevice("image")).initialize(); } catch (IOException ex) { - Logger.getLogger(ScreenPanel.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(Cameras.class.getName()).log(Level.SEVERE, null, ex); } catch (InterruptedException ex) { - Logger.getLogger(ScreenPanel.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(Cameras.class.getName()).log(Level.SEVERE, null, ex); } } } Pen fitPen = new Pen(new Color(192, 105, 0), 1); Pen crossPen = new Pen(new Color(192, 105, 0), 1); - Overlay[] getFitOverlays(BufferedImage img){ + + Overlay[] getFitOverlays(Data data) { Overlays.Polyline hpoly = null; - Overlays.Polyline vpoly = null; - Double xMean = null; Double xSigma = null; - Double yMean = null; Double ySigma = null; - Profile profile = renderer.getProfile(); - if ((profile != Profile.None) && (img != null)) { - img = Utils.grayscale(img); - if (profile.hasVertical()) { - try { - double[] sum = (double[]) Convert.toDouble(Utils.integrateVertically(img)); - int[] x = Arr.indexesInt(sum.length); - DescriptiveStatistics stats = new DescriptiveStatistics(sum); - double min = stats.getMin(); - for (int i=0; i< sum.length; i++){ - sum[i] = sum[i] - min; - } - double[] gaussian = fitGaussian(sum, x); - if (gaussian!=null){ -// System.out.println("Norm: " + gaussian[0] + " Mean: " + gaussian[1] + " Sigma: " + gaussian[2]+ " Min: " + min); - //Only aknowledge beam fully inside the image and peak over 3% of min - if ((gaussian[2] < sum.length * 0.45) && (gaussian[0] > min * 0.03)){ - xMean = gaussian[1]; - xSigma = gaussian[2]; - gaussian[0]+=min; - double[] fit = getFitFunction(gaussian, x); - int[] y = new int[x.length]; - for (int i = 0; i < x.length; i++) { - y[i] = (int) (img.getHeight() - 1 - (((double) fit[i]) / 255 / renderer.getProfileFactor())); - } - vpoly = new Overlays.Polyline(fitPen, x, y); - } - } else { - //System.out.println("Fit failure"); - } - - } catch (Exception ex) { - ex.printStackTrace(); - } - } - if (profile.hasHorizontal()) { - try { - double[] sum = (double[]) Convert.toDouble(Utils.integrateHorizontally(img)); - int[] x = Arr.indexesInt(sum.length); - DescriptiveStatistics stats = new DescriptiveStatistics(sum); - double min = stats.getMin(); - for (int i=0; i< sum.length; i++){ - sum[i] = sum[i] - min; - } - double[] gaussian = fitGaussian(sum, x); - if (gaussian!=null){ - //Only aknowledge beam fully inside the image and peak over 3% of min - if ((gaussian[2] < sum.length * 0.45) && (gaussian[0] > min * 0.03)){ - yMean = gaussian[1]; - ySigma = gaussian[2]; - gaussian[0]+=min; - double[] fit = getFitFunction(gaussian, x); + Overlays.Polyline vpoly = null; + Double xMean = null; + Double xSigma = null; + Double yMean = null; + Double ySigma = null; + if (data != null) { + //img = Utils.grayscale(img); + int profileSize = Math.min(data.getWidth(), data.getHeight())/4; - int[] y = new int[x.length]; - for (int i = 0; i < x.length; i++) { - y[i] = (int) (((double) fit[i]) / 255 / renderer.getProfileFactor()); - } - hpoly = new Overlays.Polyline(fitPen, y, x); - } - } - - } catch (Exception ex) { - ex.printStackTrace(); - } - } - Overlays.Crosshairs cross= null; - if ((xMean!=null) && (yMean!=null)){ - cross = new Overlays.Crosshairs(crossPen, - new Point(xMean.intValue(), yMean.intValue()), - new Dimension(2*xSigma.intValue(),2*ySigma.intValue())); - } - return new Overlay[]{hpoly, vpoly, cross}; - } - return null; - } - - -double[] fitGaussianScript(int[] y, int[] x){ - ScriptManager sm = Controller.getInstance().getScriptManager(); - ArrayProperties pY = ArrayProperties.get(y); - sm.setVar("y", y); - sm.setVar("x", x); - InterpreterResult r = sm.eval("r = fit_gaussians(y, x, [" + pY.maxIndex+ ",])"); - if (r.exception != null){ - r.exception .printStackTrace(); - } else { - List ret = (List) sm.getVar("r"); - if ((ret!=null) && (ret.size()==1)&& (ret.get(0) instanceof List) && (((List)(ret.get(0))).size()==3)){ - double norm = (Double) ((List)ret.get(0)).get(0); - double mean = (Double) ((List)ret.get(0)).get(1); - double sigma = (Double) ((List)ret.get(0)).get(2); - return new double[]{norm, mean, sigma}; - } - } - return null; - } - -double[]fitGaussian(double[] y, int[] x){ - try{ - ArrayProperties pY = ArrayProperties.get(y); - GaussianCurveFitter fitter = GaussianCurveFitter.create().withStartPoint(new double[]{(pY.max-pY.min)/2,x[pY.maxIndex],1.0}).withMaxIterations(1000); - ArrayListvalues = new ArrayList<>(); - for (int i=0; i< y.length; i++){ - values.add(new WeightedObservedPoint(1.0, x[i], y[i])); - } - return fitter.fit(values); - } catch (Exception ex){ - return null; - } - - } - - - - double[] getFitFunction(double[] pars, int[] x){ - double[] fit = new double[x.length]; - Gaussian g = new Gaussian(pars[0], pars[1], pars[2]); - for (int i=0; i< x.length; i++){ - fit[i] = g.value(x[i]); - } - return fit; - } - -public class Camtool extends ArraySource { - - final String prefix; - final String dataPrefix; - final boolean latch; - - final public ChannelInteger channelRun; - final public ChannelInteger channelLatch; - final public ChannelDouble channelTimestamp; - final public ChannelDoubleArray origin; - final public ChannelDouble posX, posY; - final public ChannelDoubleArray profileX, profileY; - final public ChannelIntegerArray shape; - final public ChannelInteger roiEnabled; - final public ChannelIntegerArray roiShape; - final public ChannelInteger bgEnable, bgCapture, bgCaptureRemain; - final public ChannelDouble calOffX, calOffY, calScaleX, calScaleY; - - public Camtool(String name, String prefix) { - this(name, prefix, false); - } - - public Camtool(String name, String prefix, boolean latch) { - //super(name, prefix + (latch ? ":latch" : ":pipeline") + (roi ? ".roi.output" : ".image")); - super(name, prefix + (latch ? ":latch" : ":pipeline") + ".roi.output"); - this.prefix = prefix + ":"; - this.latch = latch; - dataPrefix = this.prefix + (latch ? "latch" : "pipeline") + "."; - - channelRun = new ChannelInteger(name + " run", this.prefix + "camera.run"); - channelLatch = new ChannelInteger(name + " latch", this.prefix + "latch.capture"); - channelTimestamp = new ChannelDouble(name + " timestamp", dataPrefix + "timestamp"); - channelTimestamp.setMonitored(true); - //posX = new ChannelDouble(name + " com x", dataPrefix + "x_stats.com"); - //posY = new ChannelDouble(name + " com y", dataPrefix + "y_stats.com"); - posX = new ChannelDouble(name + " com x", dataPrefix + "x_stats.com_egu"); - posY = new ChannelDouble(name + " com y", dataPrefix + "y_stats.com_egu"); - profileX = new ChannelDoubleArray(name + " profile x", dataPrefix + "profile.x"); - profileY = new ChannelDoubleArray(name + " profile y", dataPrefix + "profile.y"); - //shape = new ChannelIntegerArray(name + " shape", dataPrefix + (roi ? "roi.output.shape" : "image.shape")); - shape = new ChannelIntegerArray(name + " shape", dataPrefix + ("image.shape")); - roiShape = new ChannelIntegerArray(name + " roi shape", dataPrefix + "roi.roi"); - roiEnabled = new ChannelInteger(name + " roi enabled", dataPrefix + "roi.enabled"); - //origin = new ChannelDoubleArray(name + " origin X", roi ? (dataPrefix + "roi.origin_out") : (prefix + "origin")); - origin = new ChannelDoubleArray(name + " origin X", dataPrefix + "roi.origin_out"); - bgEnable = new ChannelInteger(name + " bg enable", this.prefix + "pipeline.bg.enabled"); - bgCapture = new ChannelInteger(name + " bg capture", this.prefix + "pipeline.bg.capture"); - bgCaptureRemain = new ChannelInteger(name + " bg capture remain", this.prefix + "pipeline.bg.capture_remain"); - calOffX = new ChannelDouble(name + " cal off x", this.prefix + "pipeline.egu.eoff_x"); - calOffY = new ChannelDouble(name + " cal off y", this.prefix + "pipeline.egu.eoff_y"); - calScaleX = new ChannelDouble(name + " cal scale x", this.prefix + "pipeline.egu.eslo_x"); - calScaleY = new ChannelDouble(name + " cal scale y", this.prefix + "pipeline.egu.eslo_y"); - } - - @Override - public void doSetMonitored(boolean value) { - super.doSetMonitored(value); - getDevice().setMonitored(value); - } - - @Override - public void doUpdate() throws IOException, InterruptedException { - super.doUpdate(); - getDevice().update(); - } - - void safeInitialize(Device dev, int timeout) throws IOException, InterruptedException { - for (int retries = 0; retries < 10; retries++) { try { - dev.initialize(); - break; - } catch (IOException ex) { - if (retries == 9) { - throw ex; + double[] sum = (double[]) Convert.toDouble(data.integrateVertically()); + int[] x = Arr.indexesInt(sum.length); + DescriptiveStatistics stats = new DescriptiveStatistics(sum); + double min = stats.getMin(); + for (int i = 0; i < sum.length; i++) { + sum[i] = sum[i] - min; } - Thread.sleep(timeout / 10); - } - } - } - - @Override - protected void doInitialize() throws IOException, InterruptedException { - try { - channelRun.initialize(); - channelLatch.initialize(); - if (latch) { - start(); - latch(); - } - safeInitialize(channelTimestamp, 2000); - posX.initialize(); - posY.initialize(); - profileX.initialize(); - profileY.initialize(); - shape.initialize(); - roiShape.initialize(); - roiEnabled.initialize(); - origin.initialize(); - bgEnable.initialize(); - bgCapture.initialize(); - bgCaptureRemain.initialize(); - try { - calOffX.initialize(); - calOffY.initialize(); - calScaleX.initialize(); - calScaleY.initialize(); + double[] gaussian = fitGaussian(sum, x); + if (gaussian != null) { + if ((gaussian[2] < sum.length * 0.45) && (gaussian[0] > min * 0.03)) { + double maxPlot = gaussian[0]; + xMean = gaussian[1]; + xSigma = gaussian[2]; + gaussian[0] += min; + double[] fit = getFitFunction(gaussian, x); + int[] y = new int[x.length]; + for (int i = 0; i < x.length; i++) { + y[i] = (int) (data.getHeight() - 1 - ((fit[i] / maxPlot) * profileSize)); + } + vpoly = new Overlays.Polyline(fitPen, x, y); + } + } } catch (Exception ex) { ex.printStackTrace(); } - - if (roiEnabled.read()>0){ - int[] s = roiShape.read(); - //for (int x : s) System.out.println(x); - getConfig().imageHeight = s[3]; - getConfig().imageWidth = s[2]; - } else { - int[] s = shape.read(); - //for (int x : s){ System.out.println(x);} - getConfig().imageHeight = s[0]; - getConfig().imageWidth = s[1]; - } - - getConfig().save(); - getDevice().setSize(getConfig().imageHeight * getConfig().imageWidth); - super.doInitialize(); - //System.out.println(((int[])(getDevice().read())).length); - } catch (InterruptedException ex) { - throw ex; - } catch (Exception ex) { - ex.printStackTrace(); - throw new IOException(ex); - } - } - int numImages = 1; - - public int getNumImages() { - return numImages; - } - - public void setNumImages(int value) { - numImages = value; - } - - double grabTimeout = 3.0; - - public double getGrabTimeout() { - return grabTimeout; - } - - public void setGrabTimeou(double value) { - grabTimeout = value; - } - - public void capture() throws IOException, InterruptedException { - int retries = 3; - while (true) { try { - double timestamp = channelTimestamp.read(); - if (latch) { - channelLatch.write(1); - } else { - channelRun.write(1); + double[] sum = (double[]) Convert.toDouble(data.integrateHorizontally()); + int[] x = Arr.indexesInt(sum.length); + DescriptiveStatistics stats = new DescriptiveStatistics(sum); + double min = stats.getMin(); + for (int i = 0; i < sum.length; i++) { + sum[i] = sum[i] - min; } - long start = System.currentTimeMillis(); - while (true) { - double val = channelTimestamp.read(); - if (timestamp != val) { - return; + + double[] gaussian = fitGaussian(sum, x); + if (gaussian != null) { + //Only aknowledge beam fully inside the image and peak over 3% of min + if ((gaussian[2] < sum.length * 0.45) && (gaussian[0] > min * 0.03)) { + double maxPlot = gaussian[0]; + yMean = gaussian[1]; + ySigma = gaussian[2]; + gaussian[0] += min; + double[] fit = getFitFunction(gaussian, x); + + int[] y = new int[x.length]; + for (int i = 0; i < x.length; i++) { + y[i] = (int) ((fit[i] / maxPlot) * profileSize); + } + hpoly = new Overlays.Polyline(fitPen, y, x); } - if ((System.currentTimeMillis() - start) > grabTimeout) { - throw new IOException("Frame timeout"); - } - Thread.sleep(5); - } - } catch (IOException ex) { - retries--; - if (--retries <= 0) { - throw ex; } + + } catch (Exception ex) { + ex.printStackTrace(); + } + + Overlays.Crosshairs cross = null; + Overlays.Text text = null; + if ((xMean != null) && (yMean != null)) { + cross = new Overlays.Crosshairs(crossPen, + new Point(xMean.intValue(), yMean.intValue()), + new Dimension(2 * xSigma.intValue(), 2 * ySigma.intValue())); + + text = new Overlays.Text(fitPen, + String.format("x = %f \n y = %f" , data.getX((int) Math.round(xMean)), data.getY((int) Math.round(yMean))), + new Font(Font.MONOSPACED, 0, 14), new Point(20,20)); + } + + return new Overlay[]{hpoly, vpoly, cross, text}; + } + return null; + } + + double[] fitGaussianScript(int[] y, int[] x) { + ScriptManager sm = Controller.getInstance().getScriptManager(); + ArrayProperties pY = ArrayProperties.get(y); + sm.setVar("y", y); + sm.setVar("x", x); + InterpreterResult r = sm.eval("r = fit_gaussians(y, x, [" + pY.maxIndex + ",])"); + if (r.exception != null) { + r.exception.printStackTrace(); + } else { + List ret = (List) sm.getVar("r"); + if ((ret != null) && (ret.size() == 1) && (ret.get(0) instanceof List) && (((List) (ret.get(0))).size() == 3)) { + double norm = (Double) ((List) ret.get(0)).get(0); + double mean = (Double) ((List) ret.get(0)).get(1); + double sigma = (Double) ((List) ret.get(0)).get(2); + return new double[]{norm, mean, sigma}; } } + return null; } - public void start() throws IOException, InterruptedException { - channelRun.write(-1); - } - - public void stop() throws IOException, InterruptedException { - channelRun.write(0); - } - - public void grabSingle() throws IOException, InterruptedException { - channelRun.write(1); - } - - public void latch() throws IOException, InterruptedException { - channelLatch.write(1); - } - - public void enableBackground(boolean value) throws IOException, InterruptedException { - bgEnable.write(value ? 1 : 0); - } - - public void captureBackground(int images) throws IOException, InterruptedException { - start(); - bgCapture.write(images); - Thread.sleep(200); - while (bgCaptureRemain.read() > 0) { - Thread.sleep(10); + double[] fitGaussian(double[] y, int[] x) { + try { + ArrayProperties pY = ArrayProperties.get(y); + GaussianCurveFitter fitter = GaussianCurveFitter.create().withStartPoint(new double[]{(pY.max - pY.min) / 2, x[pY.maxIndex], 1.0}).withMaxIterations(1000); + ArrayList values = new ArrayList<>(); + for (int i = 0; i < y.length; i++) { + values.add(new WeightedObservedPoint(1.0, x[i], y[i])); + } + return fitter.fit(values); + } catch (Exception ex) { + return null; } + } -} - + double[] getFitFunction(double[] pars, int[] x) { + double[] fit = new double[x.length]; + Gaussian g = new Gaussian(pars[0], pars[1], pars[2]); + for (int i = 0; i < x.length; i++) { + fit[i] = g.value(x[i]); + } + return fit; + } + //////// @SuppressWarnings("unchecked") @@ -860,13 +645,13 @@ public class Camtool extends ArraySource { .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(renderer, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(renderer, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 650, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(checkCamtool) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(comboCameras, 0, 170, Short.MAX_VALUE) + .addComponent(comboCameras, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(buttonConfig) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) @@ -993,7 +778,7 @@ public class Camtool extends ArraySource { Dimension d = renderer.getImageSize(); Point p = (d == null) ? new Point(renderer.getWidth() / 2, renderer.getHeight() / 2) : new Point(d.width / 2, d.height / 2); Overlay ov = null; - marker = new Overlays.Crosshairs(PEN_MARKER, p, new Dimension(100, 100)); + marker = new Overlays.Crosshairs(renderer.getPenMarker(), p, new Dimension(100, 100)); marker.setMovable(true); } else { marker = null; diff --git a/plugins/ScreenPanel.form b/plugins/ScreenPanel.form index 4047de7..e991e65 100644 --- a/plugins/ScreenPanel.form +++ b/plugins/ScreenPanel.form @@ -10,6 +10,8 @@ + + @@ -57,36 +59,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + @@ -96,127 +73,197 @@ - - - - - - - - + - + - - - - - - - - + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -249,7 +296,7 @@ - + @@ -607,7 +654,6 @@ - diff --git a/plugins/ScreenPanel.java b/plugins/ScreenPanel.java index 5d109fc..0f2e6b9 100644 --- a/plugins/ScreenPanel.java +++ b/plugins/ScreenPanel.java @@ -418,7 +418,6 @@ public class ScreenPanel extends Panel { } catch (Exception ex) { comboScreen.setModel(new DefaultComboBoxModel()); - //ex.printStackTrace(); System.err.println(ex.getMessage()); screen = null; } @@ -436,7 +435,6 @@ public class ScreenPanel extends Panel { comboFilter.setSelectedItem(filter.read()); } catch (Exception ex) { comboFilter.setModel(new DefaultComboBoxModel()); - //ex.printStackTrace(); System.err.println(ex.getMessage()); filter = null; } @@ -1001,20 +999,23 @@ public class ScreenPanel extends Panel { buttonGroup2 = new javax.swing.ButtonGroup(); buttonGroup3 = new javax.swing.ButtonGroup(); buttonGroup4 = new javax.swing.ButtonGroup(); + jProgressBar1 = new javax.swing.JProgressBar(); jPanel1 = new javax.swing.JPanel(); + jPanel7 = new javax.swing.JPanel(); + buttonMarker = new javax.swing.JToggleButton(); buttonGrabBackground = new javax.swing.JButton(); - renderer = new ch.psi.pshell.imaging.Renderer(); - textState = new javax.swing.JTextField(); buttonSave = new javax.swing.JToggleButton(); - buttonPause = new javax.swing.JToggleButton(); - jLabel2 = new javax.swing.JLabel(); buttonFit = new javax.swing.JToggleButton(); + buttonReticle = new javax.swing.JToggleButton(); + buttonPause = new javax.swing.JToggleButton(); + jPanel6 = new javax.swing.JPanel(); + textState = new javax.swing.JTextField(); + jLabel2 = new javax.swing.JLabel(); comboCameras = new javax.swing.JComboBox(); buttonSetup = new javax.swing.JButton(); - buttonMarker = new javax.swing.JToggleButton(); jLabel1 = new javax.swing.JLabel(); buttonConfig = new javax.swing.JButton(); - buttonReticle = new javax.swing.JToggleButton(); + renderer = new ch.psi.pshell.imaging.Renderer(); jPanel4 = new javax.swing.JPanel(); jPanel3 = new javax.swing.JPanel(); buttonZoomFit = new javax.swing.JRadioButton(); @@ -1047,6 +1048,13 @@ public class ScreenPanel extends Panel { setPreferredSize(new java.awt.Dimension(873, 600)); + buttonMarker.setText("Marker"); + buttonMarker.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonMarkerActionPerformed(evt); + } + }); + buttonGrabBackground.setText("Grab Background"); buttonGrabBackground.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -1054,11 +1062,6 @@ public class ScreenPanel extends Panel { } }); - textState.setEditable(false); - textState.setHorizontalAlignment(javax.swing.JTextField.CENTER); - textState.setDisabledTextColor(new java.awt.Color(0, 0, 0)); - textState.setEnabled(false); - buttonSave.setText("Save Snapshot"); buttonSave.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -1066,6 +1069,22 @@ public class ScreenPanel extends Panel { } }); + buttonFit.setSelected(true); + buttonFit.setText("Fit"); + buttonFit.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonFitActionPerformed(evt); + } + }); + + buttonReticle.setSelected(true); + buttonReticle.setText("Reticle"); + buttonReticle.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonReticleActionPerformed(evt); + } + }); + buttonPause.setText("Pause"); buttonPause.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -1073,15 +1092,50 @@ public class ScreenPanel extends Panel { } }); - jLabel2.setText("State:"); + javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7); + jPanel7.setLayout(jPanel7Layout); + jPanel7Layout.setHorizontalGroup( + jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel7Layout.createSequentialGroup() + .addGap(0, 0, 0) + .addComponent(buttonPause) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonMarker) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonFit) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonReticle) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonGrabBackground) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonSave) + .addGap(0, 0, 0)) + ); - buttonFit.setSelected(true); - buttonFit.setText("Fit"); - buttonFit.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - buttonFitActionPerformed(evt); - } - }); + jPanel7Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonFit, buttonMarker, buttonPause, buttonReticle}); + + jPanel7Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonGrabBackground, buttonSave}); + + jPanel7Layout.setVerticalGroup( + jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel7Layout.createSequentialGroup() + .addGap(0, 0, 0) + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(buttonPause) + .addComponent(buttonFit) + .addComponent(buttonMarker) + .addComponent(buttonSave) + .addComponent(buttonReticle) + .addComponent(buttonGrabBackground)) + .addGap(0, 0, 0)) + ); + + textState.setEditable(false); + textState.setHorizontalAlignment(javax.swing.JTextField.CENTER); + textState.setDisabledTextColor(new java.awt.Color(0, 0, 0)); + textState.setEnabled(false); + + jLabel2.setText("State:"); comboCameras.setMaximumRowCount(30); comboCameras.addActionListener(new java.awt.event.ActionListener() { @@ -1097,13 +1151,6 @@ public class ScreenPanel extends Panel { } }); - buttonMarker.setText("Marker"); - buttonMarker.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - buttonMarkerActionPerformed(evt); - } - }); - jLabel1.setText("Camera:"); buttonConfig.setText("Config"); @@ -1113,80 +1160,66 @@ public class ScreenPanel extends Panel { } }); - buttonReticle.setSelected(true); - buttonReticle.setText("Reticle"); - buttonReticle.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - buttonReticleActionPerformed(evt); - } - }); - - javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); - jPanel1.setLayout(jPanel1Layout); - jPanel1Layout.setHorizontalGroup( - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createSequentialGroup() + javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6); + jPanel6.setLayout(jPanel6Layout); + jPanel6Layout.setHorizontalGroup( + jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel6Layout.createSequentialGroup() .addGap(0, 0, 0) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(renderer, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() - .addComponent(jLabel1) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(comboCameras, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(buttonConfig) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(buttonSetup) - .addGap(50, 50, 50) - .addComponent(jLabel2) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(textState, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() - .addComponent(buttonPause) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(buttonMarker) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(buttonFit) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(buttonReticle) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(buttonGrabBackground) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(buttonSave))) - .addContainerGap()) + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(comboCameras, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonConfig) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonSetup) + .addGap(50, 50, 50) + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(textState, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, 0)) ); - jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonConfig, buttonSetup}); + jPanel6Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonConfig, buttonSetup}); - jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonFit, buttonMarker, buttonPause, buttonReticle}); - - jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonGrabBackground, buttonSave}); - - jPanel1Layout.setVerticalGroup( - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createSequentialGroup() - .addContainerGap() - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + jPanel6Layout.setVerticalGroup( + jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel6Layout.createSequentialGroup() + .addGap(0, 0, 0) + .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(comboCameras, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2) .addComponent(textState, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(buttonConfig) .addComponent(buttonSetup)) - .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) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(buttonPause) - .addComponent(buttonFit) - .addComponent(buttonMarker) - .addComponent(buttonSave) - .addComponent(buttonReticle) - .addComponent(buttonGrabBackground)) - .addContainerGap()) + .addGap(0, 0, 0)) ); - jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {comboCameras, textState}); + jPanel6Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {comboCameras, textState}); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, 500, Short.MAX_VALUE) + .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) + .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap()) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .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) + .addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, 122, 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) + .addContainerGap()) + ); jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Zoom")); @@ -1412,7 +1445,6 @@ public class ScreenPanel extends Panel { jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Source")); buttonGroup4.add(buttonCamtool); - buttonCamtool.setSelected(true); buttonCamtool.setText("Camtool"); buttonCamtool.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -1535,7 +1567,7 @@ public class ScreenPanel extends Panel { .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel2, 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(65, Short.MAX_VALUE)) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); @@ -1854,6 +1886,9 @@ public class ScreenPanel extends Panel { private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel4; private javax.swing.JPanel jPanel5; + private javax.swing.JPanel jPanel6; + private javax.swing.JPanel jPanel7; + private javax.swing.JProgressBar jProgressBar1; private javax.swing.JPanel panelScreen; private javax.swing.JPanel panelScreen1; private ch.psi.pshell.imaging.Renderer renderer;