81 lines
2.4 KiB
Java
81 lines
2.4 KiB
Java
/*
|
|
* Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
|
|
*/
|
|
package ch.psi.mxsc;
|
|
|
|
import ch.psi.pshell.device.Device;
|
|
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.Rectangle;
|
|
|
|
/**
|
|
*
|
|
*/
|
|
public class PuckPanel extends DevicePanel {
|
|
/**
|
|
* Creates new form BasePlatePanel
|
|
*/
|
|
PuckGraphics puckGraphics;
|
|
public PuckPanel() {
|
|
initComponents();
|
|
}
|
|
|
|
@Override
|
|
public Puck getDevice(){
|
|
return (Puck) super.getDevice();
|
|
}
|
|
|
|
@Override
|
|
public void setDevice(Device device){
|
|
super.setDevice(device);
|
|
puckGraphics = new PuckGraphics((Puck)device, null);
|
|
}
|
|
|
|
/**
|
|
* 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 (puckGraphics!=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);
|
|
puckGraphics.draw(g2d, plotRect, true, false, true);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
|
// End of variables declaration//GEN-END:variables
|
|
}
|