This commit is contained in:
2015-11-06 14:32:52 +01:00
parent cc9c40d26b
commit dadce474a6
5 changed files with 209 additions and 0 deletions

View File

@@ -0,0 +1 @@
./home/plugins/Image.java=enabled

View File

@@ -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

View File

@@ -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

61
plugins/Image.form Normal file
View File

@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="renderer" pref="392" max="32767" attributes="0"/>
<EmptySpace type="separate" min="-2" max="-2" attributes="0"/>
<Component id="jButton1" min="-2" pref="113" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="renderer" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="5" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="307" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="ch.psi.pshell.imaging.Renderer" name="renderer">
<Properties>
<Property name="autoscrolls" type="boolean" value="true"/>
<Property name="deviceName" type="java.lang.String" value="mic"/>
<Property name="mode" type="ch.psi.pshell.imaging.RendererMode" editor="org.netbeans.modules.form.editors.EnumEditor">
<Value id="Fixed"/>
</Property>
<Property name="showStatus" type="boolean" value="false"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="jButton1">
<Properties>
<Property name="text" type="java.lang.String" value="Wait click"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

125
plugins/Image.java Normal file
View File

@@ -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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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))
);
}// </editor-fold>//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
}