This commit is contained in:
gac-S_Changer
2018-07-06 15:42:21 +02:00
parent 86d50a3de0
commit ac65aee710
5 changed files with 129 additions and 51 deletions

View File

@@ -106,7 +106,7 @@ public class BasePlate extends DeviceBase {
}
return null;
}
Sample getSelectedSample(){
if (selectable){
Puck puck = getSelectedPuck();
@@ -121,6 +121,12 @@ public class BasePlate extends DeviceBase {
return null;
}
void resetSelection(){
Puck puck = getSelectedPuck();
if (puck != null){
puck.setSelected(false);
}
}
Sample getLoadedSample(){
for (Puck p:getPucks()){

View File

@@ -4,14 +4,12 @@
package ch.psi.mxsc;
import ch.psi.mxsc.BasePlate.DrawMode;
import ch.psi.pshell.core.Context;
import ch.psi.pshell.imaging.Data;
import ch.psi.pshell.imaging.ImageListener;
import ch.psi.pshell.imaging.Source;
import ch.psi.pshell.swing.DevicePanel;
import ch.psi.utils.State;
import ch.psi.utils.swing.SwingUtils;
import java.awt.Component;
import java.awt.Point;
import java.awt.Dimension;
import java.awt.Graphics;
@@ -33,6 +31,8 @@ public class BasePlatePanel extends DevicePanel {
JPopupMenu samplePopupMenu;
JMenuItem menuLoadSample;
JMenuItem menuUnloadSample;
boolean TOGGLE_SELECTION = false;
/**
* Creates new form BasePlatePanel
*/
@@ -72,6 +72,7 @@ public class BasePlatePanel extends DevicePanel {
horizontal,
vertical,
overlapped,
puck
}
public Mode getMode() {
@@ -159,6 +160,12 @@ public class BasePlatePanel extends DevicePanel {
selectedPuck.draw(g2d, puckPlotRect, true, false, true, null);
}
break;
case puck:
if (selectedPuck!=null){
puckPlotRect = new Rectangle(plotRect.x + borderPuck, plotRect.y + borderPuck, plotRect.width - 2 * borderPuck, plotRect.height - 2 * borderPuck);
selectedPuck.draw(g2d, puckPlotRect, true, true, true, null);
}
break;
}
}
}
@@ -233,7 +240,13 @@ public class BasePlatePanel extends DevicePanel {
} else {
onPuckReleased(e, puck);
}
}
} else {
if (pressed) {
onPlatePressed(e);
} else {
onPlateReleased(e);
}
}
}
} catch (Exception ex) {
Logger.getLogger(BasePlatePanel.class.getName()).log(Level.WARNING, null, ex);
@@ -290,7 +303,11 @@ public class BasePlatePanel extends DevicePanel {
void onSamplePressed(MouseEvent e, Sample sample){
if (getDevice().isSelectable()){
sample.toggleSelected(true);
if (TOGGLE_SELECTION){
sample.toggleSelected(true);
} else {
sample.setSelected(true);
}
repaint();
}
Controller.getInstance().onSamplePressed(sample);
@@ -317,15 +334,31 @@ public class BasePlatePanel extends DevicePanel {
void onPuckPressed(MouseEvent e, Puck puck){
if (getDevice().isSelectable()){
puck.toggleSelected(true);
if (TOGGLE_SELECTION){
puck.toggleSelected(true);
} else {
puck.setSelected(true);
}
repaint();
}
Controller.getInstance().onPuckPressed(puck);
}
void onPuckReleased(MouseEvent e, Puck puck){
Controller.getInstance().onPuckReleased(puck);
}
void onPlatePressed(MouseEvent e){
if (!TOGGLE_SELECTION){
getDevice().resetSelection();
}
Controller.getInstance().onPlatePressed(getDevice());
}
void onPlateReleased(MouseEvent e){
Controller.getInstance().onPlateReleased(getDevice());
}
void onPuckPopupMenu(MouseEvent e, Puck puck){
System.out.println(puck);

View File

@@ -9,10 +9,8 @@ import ch.psi.pshell.core.DevicePoolListener;
import ch.psi.pshell.device.Device;
import ch.psi.pshell.device.DeviceAdapter;
import ch.psi.pshell.device.GenericDevice;
import ch.psi.pshell.device.ProcessVariableBase;
import ch.psi.pshell.device.ReadbackDevice;
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.swing.SwingUtils;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
@@ -212,18 +210,47 @@ public class Controller {
}
}
}
BasePlatePanel puckPanel;
void onPuckPressed(Puck puck){
//getMainFrame().textDetSensors.setText(String.valueOf(puck.getDetection()));
//getMainFrame().textDetImage.setText(String.valueOf(puck.getImageDetection()));
//JPanel panel = new SinglePuckPanel(puck);
//panel.setOpaque(false);
//getMainFrame().setDetail(panel);
if ((puckPanel==null) || (puckPanel != getMainFrame().getDetail())){
puckPanel = new BasePlatePanel();
puckPanel.setMode(BasePlatePanel.Mode.puck);
puckPanel.setDevice((Device) getDevice("BasePlate"));
puckPanel.setEnabled(false); //TODO: Puck cannot be shared between two panels (device store single coordinates foe comparing to click)
getMainFrame().setDetail(puckPanel);
}
}
void onPuckReleased(Puck puck){
if (!puck.isSelected()){
getMainFrame().setDefaultDetail();
puckPanel = null;
}
}
void onSamplePressed(Sample sample){
onPuckPressed(sample.getPuck());
}
void onSampleReleased(Sample sample){
onPuckReleased(sample.getPuck());
}
void onPlatePressed(BasePlate plate){
if (plate.getSelectedPuck() == null){
getMainFrame().setDefaultDetail();
puckPanel = null;
}
}
void onPlateReleased(BasePlate palte){
}
GenericDevice getDevice(String name){
return getMainFrame().getDevice(name);
}

View File

@@ -822,7 +822,7 @@
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Scanner"/>
<TitledBorder title="Datamatrix"/>
</Border>
</Property>
</Properties>
@@ -880,11 +880,17 @@
<Component class="javax.swing.JTextField" name="textSample">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="df" green="d9" red="d6" type="rgb"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textType">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="df" green="d9" red="d6" type="rgb"/>
</Property>
</Properties>
</Component>
</SubComponents>
@@ -1102,7 +1108,7 @@
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="btViewDewar" min="-2" pref="35" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="btViewRT" min="-2" pref="35" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
@@ -1133,7 +1139,7 @@
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Context"/>
<TitledBorder title="Detail"/>
</Border>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
@@ -1144,32 +1150,15 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace pref="99" max="32767" attributes="0"/>
<Component id="jLabel10" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="99" max="32767" attributes="0"/>
</Group>
<EmptySpace min="0" pref="298" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="jLabel10" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
<EmptySpace min="0" pref="191" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel10">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/apple_transparent_white_100x50.png"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

View File

@@ -13,15 +13,19 @@ import ch.psi.pshell.imaging.Source;
import ch.psi.pshell.ui.App;
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.swing.SwingUtils;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.util.logging.Level;
import javax.swing.GroupLayout;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
/**
*
@@ -41,6 +45,7 @@ public class MainPanel extends Panel {
buttonReleasePsys.setVisible(false);
panelViewType.setVisible(false);
panelDetection.setVisible(false);
setDefaultDetail();
}
@Override
@@ -306,6 +311,32 @@ public class MainPanel extends Panel {
recoveryPlugin = getContext().getPluginManager().loadInitializePlugin(getContext().getSetup().expandPath("{plugins}/Recovery.java"));
}
void setDefaultDetail() {
JLabel label = new JLabel();
label.setIcon(new javax.swing.ImageIcon(getClass().getResource("/apple_transparent_white_100x50.png")));
JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout());
panel.add(label);
setDetail(panel);
//setContext(label);
}
void setDetail(Component c) {
panelContext.removeAll();
panelContext.setLayout(new BorderLayout());
//panelContext.setLayout(new GridBagLayout());
panelContext.add(c);
updateUI();
}
Component getDetail() {
return this.getComponent(0);
}
Dimension getDetailSize(){
return panelContext.getSize();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
@@ -387,7 +418,6 @@ public class MainPanel extends Panel {
btViewDewar = new javax.swing.JToggleButton();
btViewRT = new javax.swing.JToggleButton();
panelContext = new javax.swing.JPanel();
jLabel10 = new javax.swing.JLabel();
basePlatePanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Dewar"));
@@ -853,15 +883,17 @@ public class MainPanel extends Panel {
.addGap(0, 0, 0))
);
jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder("Scanner"));
jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder("Datamatrix"));
jLabel11.setText("Puck:");
jLabel13.setText("Sample:");
textSample.setEditable(false);
textSample.setBackground(new java.awt.Color(214, 217, 223));
textType.setEditable(false);
textType.setBackground(new java.awt.Color(214, 217, 223));
javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
jPanel8.setLayout(jPanel8Layout);
@@ -1044,31 +1076,23 @@ public class MainPanel extends Panel {
.addGroup(jPanel12Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btViewDewar, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(btViewRT, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
panelContext.setBorder(javax.swing.BorderFactory.createTitledBorder("Context"));
panelContext.setBorder(javax.swing.BorderFactory.createTitledBorder("Detail"));
panelContext.setPreferredSize(new java.awt.Dimension(300, 95));
jLabel10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/apple_transparent_white_100x50.png"))); // NOI18N
javax.swing.GroupLayout panelContextLayout = new javax.swing.GroupLayout(panelContext);
panelContext.setLayout(panelContextLayout);
panelContextLayout.setHorizontalGroup(
panelContextLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelContextLayout.createSequentialGroup()
.addContainerGap(99, Short.MAX_VALUE)
.addComponent(jLabel10)
.addContainerGap(99, Short.MAX_VALUE))
.addGap(0, 298, Short.MAX_VALUE)
);
panelContextLayout.setVerticalGroup(
panelContextLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelContextLayout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel10)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(0, 191, Short.MAX_VALUE)
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
@@ -1242,7 +1266,6 @@ public class MainPanel extends Panel {
private javax.swing.Box.Filler filler1;
private ch.psi.mxsc.HexiposiPanel hexiposiPanel;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;