From dadce474a6be10bbc7eadde6be2211cf98ef689a Mon Sep 17 00:00:00 2001 From: Dworkowski Florian Date: Fri, 6 Nov 2015 14:32:52 +0100 Subject: [PATCH] Startup --- config/plugins.properties | 1 + devices/mic-high.properties | 11 ++++ devices/mic-low.properties | 11 ++++ plugins/Image.form | 61 ++++++++++++++++++ plugins/Image.java | 125 ++++++++++++++++++++++++++++++++++++ 5 files changed, 209 insertions(+) create mode 100644 config/plugins.properties create mode 100644 devices/mic-high.properties create mode 100644 devices/mic-low.properties create mode 100644 plugins/Image.form create mode 100644 plugins/Image.java diff --git a/config/plugins.properties b/config/plugins.properties new file mode 100644 index 0000000..c2e8ba0 --- /dev/null +++ b/config/plugins.properties @@ -0,0 +1 @@ +./home/plugins/Image.java=enabled diff --git a/devices/mic-high.properties b/devices/mic-high.properties new file mode 100644 index 0000000..a5c32df --- /dev/null +++ b/devices/mic-high.properties @@ -0,0 +1,11 @@ +#Fri Nov 06 14:32:51 CET 2015 +flipHorizontally=false +flipVertically=false +grayscale=false +invert=false +pollingBackground=false +pollingInterval=0 +rescaleFactor=1.0 +rescaleOffset=0.0 +rotation=0.0 +scale=1.0 diff --git a/devices/mic-low.properties b/devices/mic-low.properties new file mode 100644 index 0000000..a5c32df --- /dev/null +++ b/devices/mic-low.properties @@ -0,0 +1,11 @@ +#Fri Nov 06 14:32:51 CET 2015 +flipHorizontally=false +flipVertically=false +grayscale=false +invert=false +pollingBackground=false +pollingInterval=0 +rescaleFactor=1.0 +rescaleOffset=0.0 +rotation=0.0 +scale=1.0 diff --git a/plugins/Image.form b/plugins/Image.form new file mode 100644 index 0000000..73fff2b --- /dev/null +++ b/plugins/Image.form @@ -0,0 +1,61 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/plugins/Image.java b/plugins/Image.java new file mode 100644 index 0000000..3bc42a0 --- /dev/null +++ b/plugins/Image.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2014 Paul Scherrer Institute. All rights reserved. + */ + +import ch.psi.pshell.imaging.Overlay; +import ch.psi.pshell.imaging.Overlays; +import ch.psi.pshell.imaging.Pen; +import ch.psi.pshell.imaging.Renderer; +import ch.psi.pshell.imaging.RendererListener; +import ch.psi.pshell.imaging.Source; +import ch.psi.pshell.ui.Panel; +import ch.psi.utils.State; +import java.awt.Color; +import java.awt.Point; + +/** + * + */ +public class Image extends Panel { + public Image() { + initComponents(); + } + + //Overridable callbacks + @Override + public void onInitialize(int runCount) { + + final Overlay overlay = new Overlays.Rect(new Pen(Color.RED), new Point(10,10), new Point(50,50)); + renderer.addOverlay(overlay); + overlay.setMovable(true); + overlay.setSolid(false); + + renderer.addListener(new RendererListener() { + public void onMouseDragged(Renderer renderer, Point p) { + //sendOutput(p.toString()); + System.out.println((p.x - renderer.getImageSize().width/2) + " - " + (p.y - renderer.getImageSize().height/2)); + } + + public void onMoveFinished(Renderer renderer, Overlay ov) { + if (ov == overlay){ + System.out.println(ov.getPosition().toString()); + } + } + } ); + + } + + @Override + public void onStateChange(State state, State former) { + + } + + @Override + public void onExecutedFile(String fileName, Object result) { + } + + + //Callback to perform update - in event thread + @Override + protected void doUpdate() { + } + + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + renderer = new ch.psi.pshell.imaging.Renderer(); + jButton1 = new javax.swing.JButton(); + + renderer.setAutoscrolls(true); + renderer.setDeviceName("mic"); + renderer.setMode(ch.psi.pshell.imaging.RendererMode.Fixed); + renderer.setShowStatus(false); + + jButton1.setText("Wait click"); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, 392, Short.MAX_VALUE) + .addGap(18, 18, 18) + .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGap(5, 5, 5)) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jButton1) + .addContainerGap(307, Short.MAX_VALUE)) + ); + }// //GEN-END:initComponents + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + try{ + new Thread(()->{ + try { + Point p = renderer.waitClick(10000); + System.out.println(p); + } catch (Exception ex) { + } + jButton1.setEnabled(true); + + }).start(); + jButton1.setEnabled(false); + } catch (Exception ex){ + showException(ex); + } + }//GEN-LAST:event_jButton1ActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private ch.psi.pshell.imaging.Renderer renderer; + // End of variables declaration//GEN-END:variables +}