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

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