This commit is contained in:
73
src/main/java/ch/psi/mxsc/PuckPanel.java
Normal file
73
src/main/java/ch/psi/mxsc/PuckPanel.java
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
|
||||
*/
|
||||
package ch.psi.mxsc;
|
||||
|
||||
import ch.psi.pshell.swing.DevicePanel;
|
||||
import ch.psi.utils.State;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class PuckPanel extends DevicePanel {
|
||||
/**
|
||||
* Creates new form BasePlatePanel
|
||||
*/
|
||||
public PuckPanel() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Puck getDevice(){
|
||||
return (Puck) super.getDevice();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form. WARNING: Do NOT
|
||||
* modify this code. The content of this method is always regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 400, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 300, Short.MAX_VALUE)
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
@Override
|
||||
protected void onDeviceStateChanged(State state, State former) {
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
super.paint(g);
|
||||
if (getDevice()!=null){
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
Dimension size = getSize();
|
||||
if ((size.width > 10) && (size.height > 10)) {
|
||||
int border = 5;
|
||||
Rectangle plotRect = new Rectangle(border, border, size.width - 2*border, size.height - 2*border);
|
||||
getDevice().draw(g2d, plotRect, true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
Reference in New Issue
Block a user