Replace tabs with spaces
This commit is contained in:
@@ -27,13 +27,13 @@ import wiiusej.wiiusejevents.physicalevents.NunchukEvent;
|
||||
*/
|
||||
public class AccelerationExpansionEventPanel extends AccelerationPanel {
|
||||
|
||||
@Override
|
||||
public RawAcceleration getRawAccelerationValue(GenericEvent e) {
|
||||
if (e instanceof NunchukEvent) {
|
||||
return ((NunchukEvent) e).getNunchukMotionSensingEvent()
|
||||
.getRawAcceleration();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public RawAcceleration getRawAccelerationValue(GenericEvent e) {
|
||||
if (e instanceof NunchukEvent) {
|
||||
return ((NunchukEvent) e).getNunchukMotionSensingEvent()
|
||||
.getRawAcceleration();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -48,256 +48,256 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
|
||||
* @author guiguito
|
||||
*/
|
||||
public abstract class AccelerationPanel extends javax.swing.JPanel implements
|
||||
WiimoteListener {
|
||||
WiimoteListener {
|
||||
|
||||
private Image mImage;// image for double buffering
|
||||
private Color xColor = Color.RED;
|
||||
private Color yColor = Color.GREEN;
|
||||
private Color zColor = Color.BLUE;
|
||||
private Color backgroundColor = Color.WHITE;
|
||||
private Color lineColor = Color.BLACK;
|
||||
private ArrayList<RawAcceleration> values = new ArrayList<RawAcceleration>();
|
||||
private Image mImage;// image for double buffering
|
||||
private Color xColor = Color.RED;
|
||||
private Color yColor = Color.GREEN;
|
||||
private Color zColor = Color.BLUE;
|
||||
private Color backgroundColor = Color.WHITE;
|
||||
private Color lineColor = Color.BLACK;
|
||||
private ArrayList<RawAcceleration> values = new ArrayList<RawAcceleration>();
|
||||
|
||||
/** Creates new form AccelerationPanel */
|
||||
public AccelerationPanel() {
|
||||
initComponents();
|
||||
}
|
||||
/** Creates new form AccelerationPanel */
|
||||
public AccelerationPanel() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor used to choose the colors used by the AccelerationPanel.
|
||||
*
|
||||
* @param bgColor
|
||||
* background color.
|
||||
* @param xColor
|
||||
* x color.
|
||||
* @param yColor
|
||||
* y color.
|
||||
* @param zColor
|
||||
* z color.
|
||||
* @param lColor
|
||||
* line color.
|
||||
*/
|
||||
public AccelerationPanel(Color bgColor, Color xColor, Color yColor,
|
||||
Color zColor, Color lColor) {
|
||||
backgroundColor = bgColor;
|
||||
this.xColor = xColor;
|
||||
this.yColor = yColor;
|
||||
this.zColor = zColor;
|
||||
lineColor = lColor;
|
||||
initComponents();
|
||||
}
|
||||
/**
|
||||
* Constructor used to choose the colors used by the AccelerationPanel.
|
||||
*
|
||||
* @param bgColor
|
||||
* background color.
|
||||
* @param xColor
|
||||
* x color.
|
||||
* @param yColor
|
||||
* y color.
|
||||
* @param zColor
|
||||
* z color.
|
||||
* @param lColor
|
||||
* line color.
|
||||
*/
|
||||
public AccelerationPanel(Color bgColor, Color xColor, Color yColor,
|
||||
Color zColor, Color lColor) {
|
||||
backgroundColor = bgColor;
|
||||
this.xColor = xColor;
|
||||
this.yColor = yColor;
|
||||
this.zColor = zColor;
|
||||
lineColor = lColor;
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Dimension d = getSize();
|
||||
checkOffScreenImage();
|
||||
Graphics offG = mImage.getGraphics();
|
||||
offG.setColor(backgroundColor);
|
||||
offG.fillRect(0, 0, d.width, d.height);
|
||||
Graphics2D g2 = (Graphics2D) mImage.getGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Dimension d = getSize();
|
||||
checkOffScreenImage();
|
||||
Graphics offG = mImage.getGraphics();
|
||||
offG.setColor(backgroundColor);
|
||||
offG.fillRect(0, 0, d.width, d.height);
|
||||
Graphics2D g2 = (Graphics2D) mImage.getGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
// draw medium line
|
||||
int yLine = getHeight() - 25;
|
||||
// draw medium line
|
||||
int yLine = getHeight() - 25;
|
||||
|
||||
g2.setPaint(lineColor);
|
||||
g2.drawLine(0, yLine, getWidth(), yLine);
|
||||
g2.setPaint(lineColor);
|
||||
g2.drawLine(0, yLine, getWidth(), yLine);
|
||||
|
||||
RawAcceleration[] valuesArray = values.toArray(new RawAcceleration[0]);
|
||||
RawAcceleration[] valuesArray = values.toArray(new RawAcceleration[0]);
|
||||
|
||||
double unit = yLine / 255.0;
|
||||
int previousX = 0;
|
||||
int previousY = 0;
|
||||
int previousZ = 0;
|
||||
// draw curves
|
||||
for (int i = 0; i < valuesArray.length && i < getWidth(); i++) {
|
||||
RawAcceleration acceleration = valuesArray[i];
|
||||
// draw X
|
||||
g2.setPaint(xColor);
|
||||
int yDelta = (int) Math.round(unit * acceleration.getX());
|
||||
int y = -1 * yDelta + yLine;
|
||||
g2.drawLine(i - 1, previousX, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousX = y;
|
||||
// draw Y
|
||||
g2.setPaint(yColor);
|
||||
yDelta = (int) Math.round(unit * acceleration.getY());
|
||||
y = -1 * yDelta + yLine;
|
||||
g2.drawLine(i - 1, previousY, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousY = y;
|
||||
// draw Z
|
||||
g2.setPaint(zColor);
|
||||
yDelta = (int) Math.round(unit * acceleration.getZ());
|
||||
y = -1 * yDelta + yLine;
|
||||
g2.drawLine(i - 1, previousZ, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousZ = y;
|
||||
}
|
||||
double unit = yLine / 255.0;
|
||||
int previousX = 0;
|
||||
int previousY = 0;
|
||||
int previousZ = 0;
|
||||
// draw curves
|
||||
for (int i = 0; i < valuesArray.length && i < getWidth(); i++) {
|
||||
RawAcceleration acceleration = valuesArray[i];
|
||||
// draw X
|
||||
g2.setPaint(xColor);
|
||||
int yDelta = (int) Math.round(unit * acceleration.getX());
|
||||
int y = -1 * yDelta + yLine;
|
||||
g2.drawLine(i - 1, previousX, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousX = y;
|
||||
// draw Y
|
||||
g2.setPaint(yColor);
|
||||
yDelta = (int) Math.round(unit * acceleration.getY());
|
||||
y = -1 * yDelta + yLine;
|
||||
g2.drawLine(i - 1, previousY, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousY = y;
|
||||
// draw Z
|
||||
g2.setPaint(zColor);
|
||||
yDelta = (int) Math.round(unit * acceleration.getZ());
|
||||
y = -1 * yDelta + yLine;
|
||||
g2.drawLine(i - 1, previousZ, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousZ = y;
|
||||
}
|
||||
|
||||
// draw legend
|
||||
g2.setPaint(xColor);
|
||||
g2.drawLine(5, getHeight() - 10, 25, getHeight() - 10);
|
||||
g2.setPaint(yColor);
|
||||
g2.drawLine(60, getHeight() - 10, 80, getHeight() - 10);
|
||||
g2.setPaint(zColor);
|
||||
g2.drawLine(120, getHeight() - 10, 140, getHeight() - 10);
|
||||
// draw legend
|
||||
g2.setPaint(xColor);
|
||||
g2.drawLine(5, getHeight() - 10, 25, getHeight() - 10);
|
||||
g2.setPaint(yColor);
|
||||
g2.drawLine(60, getHeight() - 10, 80, getHeight() - 10);
|
||||
g2.setPaint(zColor);
|
||||
g2.drawLine(120, getHeight() - 10, 140, getHeight() - 10);
|
||||
|
||||
g2.setPaint(lineColor);
|
||||
g2.drawString("X", 30, getHeight() - 5);
|
||||
g2.drawString("Y", 85, getHeight() - 5);
|
||||
g2.drawString("Z", 145, getHeight() - 5);
|
||||
g2.drawString("0", 2, yLine - 5);
|
||||
g2.drawString("255", 2, 15);
|
||||
// put offscreen image on the screen
|
||||
g.drawImage(mImage, 0, 0, null);
|
||||
}
|
||||
g2.setPaint(lineColor);
|
||||
g2.drawString("X", 30, getHeight() - 5);
|
||||
g2.drawString("Y", 85, getHeight() - 5);
|
||||
g2.drawString("Z", 145, getHeight() - 5);
|
||||
g2.drawString("0", 2, yLine - 5);
|
||||
g2.drawString("255", 2, 15);
|
||||
// put offscreen image on the screen
|
||||
g.drawImage(mImage, 0, 0, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* check if the mImage variable has been initialized. If it's not the case
|
||||
* it initializes it with the dimensions of the panel. mImage is for double
|
||||
* buffering.
|
||||
*/
|
||||
private void checkOffScreenImage() {
|
||||
Dimension d = getSize();
|
||||
if (mImage == null || mImage.getWidth(null) != d.width
|
||||
|| mImage.getHeight(null) != d.height) {
|
||||
mImage = createImage(d.width, d.height);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* check if the mImage variable has been initialized. If it's not the case
|
||||
* it initializes it with the dimensions of the panel. mImage is for double
|
||||
* buffering.
|
||||
*/
|
||||
private void checkOffScreenImage() {
|
||||
Dimension d = getSize();
|
||||
if (mImage == null || mImage.getWidth(null) != d.width
|
||||
|| mImage.getHeight(null) != d.height) {
|
||||
mImage = createImage(d.width, d.height);
|
||||
}
|
||||
}
|
||||
|
||||
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onIrEvent(IREvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onIrEvent(IREvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||
draw(arg0);
|
||||
}
|
||||
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||
draw(arg0);
|
||||
}
|
||||
|
||||
public void onExpansionEvent(ExpansionEvent arg0) {
|
||||
draw(arg0);
|
||||
}
|
||||
public void onExpansionEvent(ExpansionEvent arg0) {
|
||||
draw(arg0);
|
||||
}
|
||||
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||
// Clear points.
|
||||
values.clear();
|
||||
repaint();
|
||||
}
|
||||
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||
// Clear points.
|
||||
values.clear();
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerInsertedEvent(
|
||||
ClassicControllerInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onClassicControllerInsertedEvent(
|
||||
ClassicControllerInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerRemovedEvent(
|
||||
ClassicControllerRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onClassicControllerRemovedEvent(
|
||||
ClassicControllerRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
private void draw(GenericEvent arg0) {
|
||||
if (values.size() >= getWidth()) {
|
||||
// if there are as many values as pixels in the width
|
||||
// clear points
|
||||
values.clear();
|
||||
}
|
||||
RawAcceleration rawAcceleration = getRawAccelerationValue(arg0);
|
||||
if (rawAcceleration != null)
|
||||
values.add(rawAcceleration);
|
||||
repaint();
|
||||
}
|
||||
private void draw(GenericEvent arg0) {
|
||||
if (values.size() >= getWidth()) {
|
||||
// if there are as many values as pixels in the width
|
||||
// clear points
|
||||
values.clear();
|
||||
}
|
||||
RawAcceleration rawAcceleration = getRawAccelerationValue(arg0);
|
||||
if (rawAcceleration != null)
|
||||
values.add(rawAcceleration);
|
||||
repaint();
|
||||
}
|
||||
|
||||
public abstract RawAcceleration getRawAccelerationValue(GenericEvent e);
|
||||
public abstract RawAcceleration getRawAccelerationValue(GenericEvent e);
|
||||
|
||||
public Color getBackgroundColor() {
|
||||
return backgroundColor;
|
||||
}
|
||||
public Color getBackgroundColor() {
|
||||
return backgroundColor;
|
||||
}
|
||||
|
||||
public Color getLineColor() {
|
||||
return lineColor;
|
||||
}
|
||||
public Color getLineColor() {
|
||||
return lineColor;
|
||||
}
|
||||
|
||||
public Color getXColor() {
|
||||
return xColor;
|
||||
}
|
||||
public Color getXColor() {
|
||||
return xColor;
|
||||
}
|
||||
|
||||
public Color getYColor() {
|
||||
return yColor;
|
||||
}
|
||||
public Color getYColor() {
|
||||
return yColor;
|
||||
}
|
||||
|
||||
public Color getZColor() {
|
||||
return zColor;
|
||||
}
|
||||
public Color getZColor() {
|
||||
return zColor;
|
||||
}
|
||||
|
||||
public void setBackgroundColor(Color backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
public void setBackgroundColor(Color backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
public void setLineColor(Color lineColor) {
|
||||
this.lineColor = lineColor;
|
||||
}
|
||||
public void setLineColor(Color lineColor) {
|
||||
this.lineColor = lineColor;
|
||||
}
|
||||
|
||||
public void setXColor(Color xColor) {
|
||||
this.xColor = xColor;
|
||||
}
|
||||
public void setXColor(Color xColor) {
|
||||
this.xColor = xColor;
|
||||
}
|
||||
|
||||
public void setYColor(Color yColor) {
|
||||
this.yColor = yColor;
|
||||
}
|
||||
public void setYColor(Color yColor) {
|
||||
this.yColor = yColor;
|
||||
}
|
||||
|
||||
public void setZColor(Color zColor) {
|
||||
this.zColor = zColor;
|
||||
}
|
||||
public void setZColor(Color zColor) {
|
||||
this.zColor = zColor;
|
||||
}
|
||||
|
||||
public void clearView() {
|
||||
values.clear();
|
||||
repaint();
|
||||
}
|
||||
public void clearView() {
|
||||
values.clear();
|
||||
repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated
|
||||
// Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
// <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
|
||||
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
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
||||
@@ -26,12 +26,12 @@ import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
*/
|
||||
public class AccelerationWiimoteEventPanel extends AccelerationPanel {
|
||||
|
||||
@Override
|
||||
public RawAcceleration getRawAccelerationValue(GenericEvent e) {
|
||||
if (e instanceof MotionSensingEvent) {
|
||||
return ((MotionSensingEvent) e).getRawAcceleration();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public RawAcceleration getRawAccelerationValue(GenericEvent e) {
|
||||
if (e instanceof MotionSensingEvent) {
|
||||
return ((MotionSensingEvent) e).getRawAcceleration();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -47,336 +47,336 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
|
||||
* @author guiguito
|
||||
*/
|
||||
public class ButtonsEventPanel extends javax.swing.JPanel implements
|
||||
WiimoteListener {
|
||||
WiimoteListener {
|
||||
|
||||
private Image mImage;// image for double buffering
|
||||
private Image wiimoteImage;// image for double buffering
|
||||
private WiimoteButtonsEvent buttons;
|
||||
private Color pressedColor = Color.RED;
|
||||
private Color heldColor = Color.ORANGE;
|
||||
private Color releasedColor = Color.YELLOW;
|
||||
private Shape shape = new java.awt.geom.Ellipse2D.Double(0, 0, 13, 13);
|
||||
private Image mImage;// image for double buffering
|
||||
private Image wiimoteImage;// image for double buffering
|
||||
private WiimoteButtonsEvent buttons;
|
||||
private Color pressedColor = Color.RED;
|
||||
private Color heldColor = Color.ORANGE;
|
||||
private Color releasedColor = Color.YELLOW;
|
||||
private Shape shape = new java.awt.geom.Ellipse2D.Double(0, 0, 13, 13);
|
||||
|
||||
/**
|
||||
* Default constructor. Red : button just pressed. Orange : button held.
|
||||
* Yellow : button just released.
|
||||
*/
|
||||
public ButtonsEventPanel() {
|
||||
Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit();
|
||||
java.net.URL url = ButtonsEventPanel.class
|
||||
.getResource("/img/wiimote.png");
|
||||
wiimoteImage = toolkit.createImage(url);
|
||||
initComponents();
|
||||
}
|
||||
/**
|
||||
* Default constructor. Red : button just pressed. Orange : button held.
|
||||
* Yellow : button just released.
|
||||
*/
|
||||
public ButtonsEventPanel() {
|
||||
Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit();
|
||||
java.net.URL url = ButtonsEventPanel.class
|
||||
.getResource("/img/wiimote.png");
|
||||
wiimoteImage = toolkit.createImage(url);
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor used to set colors and shape used.
|
||||
*
|
||||
* @param pressColor
|
||||
* color of a button just pressed.
|
||||
* @param hColor
|
||||
* color of a button held.
|
||||
* @param relColor
|
||||
* color of a button just released.
|
||||
* @param sh
|
||||
* shape draw on the buttons.
|
||||
*/
|
||||
public ButtonsEventPanel(Color pressColor, Color hColor, Color relColor,
|
||||
Shape sh) {
|
||||
pressedColor = pressColor;
|
||||
heldColor = hColor;
|
||||
releasedColor = relColor;
|
||||
shape = sh;
|
||||
Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit();
|
||||
wiimoteImage = toolkit.createImage("img\\wiimote.png");
|
||||
initComponents();
|
||||
}
|
||||
/**
|
||||
* Constructor used to set colors and shape used.
|
||||
*
|
||||
* @param pressColor
|
||||
* color of a button just pressed.
|
||||
* @param hColor
|
||||
* color of a button held.
|
||||
* @param relColor
|
||||
* color of a button just released.
|
||||
* @param sh
|
||||
* shape draw on the buttons.
|
||||
*/
|
||||
public ButtonsEventPanel(Color pressColor, Color hColor, Color relColor,
|
||||
Shape sh) {
|
||||
pressedColor = pressColor;
|
||||
heldColor = hColor;
|
||||
releasedColor = relColor;
|
||||
shape = sh;
|
||||
Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit();
|
||||
wiimoteImage = toolkit.createImage("img\\wiimote.png");
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Dimension d = getSize();
|
||||
checkOffScreenImage();
|
||||
Graphics offG = mImage.getGraphics();
|
||||
// offG.setColor(backgroundColor);
|
||||
offG.fillRect(0, 0, d.width, d.height);
|
||||
Graphics2D g2 = (Graphics2D) mImage.getGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Dimension d = getSize();
|
||||
checkOffScreenImage();
|
||||
Graphics offG = mImage.getGraphics();
|
||||
// offG.setColor(backgroundColor);
|
||||
offG.fillRect(0, 0, d.width, d.height);
|
||||
Graphics2D g2 = (Graphics2D) mImage.getGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
// draw buttons pushed
|
||||
g2.drawImage(wiimoteImage, 0, 0, this);
|
||||
g2.setTransform(new AffineTransform());
|
||||
// draw buttons pushed
|
||||
g2.drawImage(wiimoteImage, 0, 0, this);
|
||||
g2.setTransform(new AffineTransform());
|
||||
|
||||
if (buttons != null) {
|
||||
/* button ONE */
|
||||
if (buttons.isButtonOneJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 53, 353);
|
||||
}
|
||||
if (buttons.isButtonOneHeld()) {
|
||||
drawFunction(g2, heldColor, 53, 353);
|
||||
}
|
||||
if (buttons.isButtonOneJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 53, 353);
|
||||
}
|
||||
if (buttons != null) {
|
||||
/* button ONE */
|
||||
if (buttons.isButtonOneJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 53, 353);
|
||||
}
|
||||
if (buttons.isButtonOneHeld()) {
|
||||
drawFunction(g2, heldColor, 53, 353);
|
||||
}
|
||||
if (buttons.isButtonOneJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 53, 353);
|
||||
}
|
||||
|
||||
/* button TWO */
|
||||
if (buttons.isButtonTwoJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 53, 395);
|
||||
}
|
||||
if (buttons.isButtonTwoHeld()) {
|
||||
drawFunction(g2, heldColor, 53, 395);
|
||||
}
|
||||
if (buttons.isButtonTwoJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 53, 395);
|
||||
}
|
||||
/* button TWO */
|
||||
if (buttons.isButtonTwoJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 53, 395);
|
||||
}
|
||||
if (buttons.isButtonTwoHeld()) {
|
||||
drawFunction(g2, heldColor, 53, 395);
|
||||
}
|
||||
if (buttons.isButtonTwoJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 53, 395);
|
||||
}
|
||||
|
||||
/* button A */
|
||||
if (buttons.isButtonAJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 53, 150);
|
||||
}
|
||||
if (buttons.isButtonAHeld()) {
|
||||
drawFunction(g2, heldColor, 53, 150);
|
||||
}
|
||||
if (buttons.isButtonAJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 53, 150);
|
||||
}
|
||||
/* button A */
|
||||
if (buttons.isButtonAJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 53, 150);
|
||||
}
|
||||
if (buttons.isButtonAHeld()) {
|
||||
drawFunction(g2, heldColor, 53, 150);
|
||||
}
|
||||
if (buttons.isButtonAJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 53, 150);
|
||||
}
|
||||
|
||||
/* button B */
|
||||
if (buttons.isButtonBJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 16, 149);
|
||||
}
|
||||
if (buttons.isButtonBHeld()) {
|
||||
drawFunction(g2, heldColor, 16, 149);
|
||||
}
|
||||
if (buttons.isButtonBJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 16, 149);
|
||||
}
|
||||
/* button B */
|
||||
if (buttons.isButtonBJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 16, 149);
|
||||
}
|
||||
if (buttons.isButtonBHeld()) {
|
||||
drawFunction(g2, heldColor, 16, 149);
|
||||
}
|
||||
if (buttons.isButtonBJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 16, 149);
|
||||
}
|
||||
|
||||
/* button LEFT */
|
||||
if (buttons.isButtonLeftJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 33, 77);
|
||||
}
|
||||
if (buttons.isButtonLeftHeld()) {
|
||||
drawFunction(g2, heldColor, 33, 77);
|
||||
}
|
||||
if (buttons.isButtonLeftJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 33, 77);
|
||||
}
|
||||
/* button LEFT */
|
||||
if (buttons.isButtonLeftJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 33, 77);
|
||||
}
|
||||
if (buttons.isButtonLeftHeld()) {
|
||||
drawFunction(g2, heldColor, 33, 77);
|
||||
}
|
||||
if (buttons.isButtonLeftJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 33, 77);
|
||||
}
|
||||
|
||||
/* button RIGHT */
|
||||
if (buttons.isButtonRightJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 73, 77);
|
||||
}
|
||||
if (buttons.isButtonRightHeld()) {
|
||||
drawFunction(g2, heldColor, 73, 77);
|
||||
}
|
||||
if (buttons.isButtonRightJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 73, 77);
|
||||
}
|
||||
/* button RIGHT */
|
||||
if (buttons.isButtonRightJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 73, 77);
|
||||
}
|
||||
if (buttons.isButtonRightHeld()) {
|
||||
drawFunction(g2, heldColor, 73, 77);
|
||||
}
|
||||
if (buttons.isButtonRightJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 73, 77);
|
||||
}
|
||||
|
||||
/* button UP */
|
||||
if (buttons.isButtonUpJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 54, 60);
|
||||
}
|
||||
if (buttons.isButtonUpHeld()) {
|
||||
drawFunction(g2, heldColor, 54, 60);
|
||||
}
|
||||
if (buttons.isButtonUpJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 54, 60);
|
||||
}
|
||||
/* button UP */
|
||||
if (buttons.isButtonUpJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 54, 60);
|
||||
}
|
||||
if (buttons.isButtonUpHeld()) {
|
||||
drawFunction(g2, heldColor, 54, 60);
|
||||
}
|
||||
if (buttons.isButtonUpJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 54, 60);
|
||||
}
|
||||
|
||||
/* button DOWN */
|
||||
if (buttons.isButtonDownJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 54, 97);
|
||||
}
|
||||
if (buttons.isButtonDownHeld()) {
|
||||
drawFunction(g2, heldColor, 54, 97);
|
||||
}
|
||||
if (buttons.isButtonDownJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 54, 97);
|
||||
}
|
||||
/* button DOWN */
|
||||
if (buttons.isButtonDownJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 54, 97);
|
||||
}
|
||||
if (buttons.isButtonDownHeld()) {
|
||||
drawFunction(g2, heldColor, 54, 97);
|
||||
}
|
||||
if (buttons.isButtonDownJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 54, 97);
|
||||
}
|
||||
|
||||
/* button MINUS */
|
||||
if (buttons.isButtonMinusJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 20, 230);
|
||||
}
|
||||
if (buttons.isButtonMinusHeld()) {
|
||||
drawFunction(g2, heldColor, 20, 230);
|
||||
}
|
||||
if (buttons.isButtonMinusJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 20, 230);
|
||||
}
|
||||
/* button MINUS */
|
||||
if (buttons.isButtonMinusJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 20, 230);
|
||||
}
|
||||
if (buttons.isButtonMinusHeld()) {
|
||||
drawFunction(g2, heldColor, 20, 230);
|
||||
}
|
||||
if (buttons.isButtonMinusJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 20, 230);
|
||||
}
|
||||
|
||||
/* button PLUS */
|
||||
if (buttons.isButtonPlusJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 86, 230);
|
||||
}
|
||||
if (buttons.isButtonPlusHeld()) {
|
||||
drawFunction(g2, heldColor, 86, 230);
|
||||
}
|
||||
if (buttons.isButtonPlusJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 86, 230);
|
||||
}
|
||||
/* button PLUS */
|
||||
if (buttons.isButtonPlusJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 86, 230);
|
||||
}
|
||||
if (buttons.isButtonPlusHeld()) {
|
||||
drawFunction(g2, heldColor, 86, 230);
|
||||
}
|
||||
if (buttons.isButtonPlusJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 86, 230);
|
||||
}
|
||||
|
||||
/* button HOME */
|
||||
if (buttons.isButtonHomeJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 53, 230);
|
||||
}
|
||||
if (buttons.isButtonHomeHeld()) {
|
||||
drawFunction(g2, heldColor, 53, 230);
|
||||
}
|
||||
if (buttons.isButtonHomeJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 53, 230);
|
||||
}
|
||||
/* button HOME */
|
||||
if (buttons.isButtonHomeJustPressed()) {
|
||||
drawFunction(g2, pressedColor, 53, 230);
|
||||
}
|
||||
if (buttons.isButtonHomeHeld()) {
|
||||
drawFunction(g2, heldColor, 53, 230);
|
||||
}
|
||||
if (buttons.isButtonHomeJustReleased()) {
|
||||
drawFunction(g2, releasedColor, 53, 230);
|
||||
}
|
||||
|
||||
buttons = null;
|
||||
}
|
||||
buttons = null;
|
||||
}
|
||||
|
||||
// put offscreen image on the screen
|
||||
g.drawImage(mImage, 0, 0, null);
|
||||
}
|
||||
// put offscreen image on the screen
|
||||
g.drawImage(mImage, 0, 0, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function used to factorize code.
|
||||
*
|
||||
* @param g2
|
||||
* where to draw a shape.
|
||||
* @param col
|
||||
* color to use.
|
||||
* @param x
|
||||
* x coordinates.
|
||||
* @param y
|
||||
* y coordinates.
|
||||
*/
|
||||
private void drawFunction(Graphics2D g2, Color col, int x, int y) {
|
||||
g2.setPaint(col);
|
||||
g2.translate(x, y);
|
||||
g2.draw(shape);
|
||||
g2.fill(shape);
|
||||
g2.setTransform(new AffineTransform());
|
||||
}
|
||||
/**
|
||||
* Function used to factorize code.
|
||||
*
|
||||
* @param g2
|
||||
* where to draw a shape.
|
||||
* @param col
|
||||
* color to use.
|
||||
* @param x
|
||||
* x coordinates.
|
||||
* @param y
|
||||
* y coordinates.
|
||||
*/
|
||||
private void drawFunction(Graphics2D g2, Color col, int x, int y) {
|
||||
g2.setPaint(col);
|
||||
g2.translate(x, y);
|
||||
g2.draw(shape);
|
||||
g2.fill(shape);
|
||||
g2.setTransform(new AffineTransform());
|
||||
}
|
||||
|
||||
/**
|
||||
* check if the mImage variable has been initialized. If it's not the case
|
||||
* it initializes it with the dimensions of the panel. mImage is for double
|
||||
* buffering.
|
||||
*/
|
||||
private void checkOffScreenImage() {
|
||||
Dimension d = getSize();
|
||||
if (mImage == null || mImage.getWidth(null) != d.width
|
||||
|| mImage.getHeight(null) != d.height) {
|
||||
mImage = createImage(d.width, d.height);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* check if the mImage variable has been initialized. If it's not the case
|
||||
* it initializes it with the dimensions of the panel. mImage is for double
|
||||
* buffering.
|
||||
*/
|
||||
private void checkOffScreenImage() {
|
||||
Dimension d = getSize();
|
||||
if (mImage == null || mImage.getWidth(null) != d.width
|
||||
|| mImage.getHeight(null) != d.height) {
|
||||
mImage = createImage(d.width, d.height);
|
||||
}
|
||||
}
|
||||
|
||||
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||
setSize(wiimoteImage.getWidth(this), wiimoteImage.getHeight(this));
|
||||
buttons = arg0;
|
||||
repaint();
|
||||
}
|
||||
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||
setSize(wiimoteImage.getWidth(this), wiimoteImage.getHeight(this));
|
||||
buttons = arg0;
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void onIrEvent(IREvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onIrEvent(IREvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onExpansionEvent(ExpansionEvent e) {
|
||||
// nothing
|
||||
}
|
||||
public void onExpansionEvent(ExpansionEvent e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||
clearView();
|
||||
}
|
||||
}
|
||||
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent e) {
|
||||
// nothing
|
||||
}
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent e) {
|
||||
// nothing
|
||||
}
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerInsertedEvent(
|
||||
ClassicControllerInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onClassicControllerInsertedEvent(
|
||||
ClassicControllerInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerRemovedEvent(
|
||||
ClassicControllerRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onClassicControllerRemovedEvent(
|
||||
ClassicControllerRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public Color getHeldColor() {
|
||||
return heldColor;
|
||||
}
|
||||
public Color getHeldColor() {
|
||||
return heldColor;
|
||||
}
|
||||
|
||||
public Color getPressedColor() {
|
||||
return pressedColor;
|
||||
}
|
||||
public Color getPressedColor() {
|
||||
return pressedColor;
|
||||
}
|
||||
|
||||
public Color getReleasedColor() {
|
||||
return releasedColor;
|
||||
}
|
||||
public Color getReleasedColor() {
|
||||
return releasedColor;
|
||||
}
|
||||
|
||||
public Shape getShape() {
|
||||
return shape;
|
||||
}
|
||||
public Shape getShape() {
|
||||
return shape;
|
||||
}
|
||||
|
||||
public void setHeldColor(Color heldColor) {
|
||||
this.heldColor = heldColor;
|
||||
}
|
||||
public void setHeldColor(Color heldColor) {
|
||||
this.heldColor = heldColor;
|
||||
}
|
||||
|
||||
public void setPressedColor(Color pressedColor) {
|
||||
this.pressedColor = pressedColor;
|
||||
}
|
||||
public void setPressedColor(Color pressedColor) {
|
||||
this.pressedColor = pressedColor;
|
||||
}
|
||||
|
||||
public void setReleasedColor(Color releasedColor) {
|
||||
this.releasedColor = releasedColor;
|
||||
}
|
||||
public void setReleasedColor(Color releasedColor) {
|
||||
this.releasedColor = releasedColor;
|
||||
}
|
||||
|
||||
public void setShape(Shape shape) {
|
||||
this.shape = shape;
|
||||
}
|
||||
public void setShape(Shape shape) {
|
||||
this.shape = shape;
|
||||
}
|
||||
|
||||
public void clearView() {
|
||||
buttons = null;
|
||||
repaint();
|
||||
}
|
||||
public void clearView() {
|
||||
buttons = null;
|
||||
repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated
|
||||
// Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
// <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
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
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
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
||||
@@ -47,258 +47,258 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
|
||||
* @author guiguito
|
||||
*/
|
||||
public abstract class GForcePanel extends javax.swing.JPanel implements
|
||||
WiimoteListener {
|
||||
WiimoteListener {
|
||||
|
||||
private Image mImage;// image for double buffering
|
||||
private Color xColor = Color.RED;
|
||||
private Color yColor = Color.GREEN;
|
||||
private Color zColor = Color.BLUE;
|
||||
private Color backgroundColor = Color.WHITE;
|
||||
private Color lineColor = Color.BLACK;
|
||||
private ArrayList<GForce> values = new ArrayList<GForce>();
|
||||
private Image mImage;// image for double buffering
|
||||
private Color xColor = Color.RED;
|
||||
private Color yColor = Color.GREEN;
|
||||
private Color zColor = Color.BLUE;
|
||||
private Color backgroundColor = Color.WHITE;
|
||||
private Color lineColor = Color.BLACK;
|
||||
private ArrayList<GForce> values = new ArrayList<GForce>();
|
||||
|
||||
/**
|
||||
* Default constructor of the AccelerationPanel.
|
||||
*/
|
||||
public GForcePanel() {
|
||||
initComponents();
|
||||
}
|
||||
/**
|
||||
* Default constructor of the AccelerationPanel.
|
||||
*/
|
||||
public GForcePanel() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor used to choose the colors used by the AccelerationPanel.
|
||||
*
|
||||
* @param bgColor
|
||||
* background color.
|
||||
* @param xxColor
|
||||
* color of the acceleration on X axis.
|
||||
* @param yyColor
|
||||
* color of the acceleration on Y axis.
|
||||
* @param zzColor
|
||||
* color of the acceleration on Z axis.
|
||||
* @param lColor
|
||||
* line color.
|
||||
*/
|
||||
public GForcePanel(Color bgColor, Color xxColor, Color yyColor,
|
||||
Color zzColor, Color lColor) {
|
||||
backgroundColor = bgColor;
|
||||
xColor = xxColor;
|
||||
yColor = yyColor;
|
||||
zColor = zzColor;
|
||||
lineColor = lColor;
|
||||
initComponents();
|
||||
}
|
||||
/**
|
||||
* Constructor used to choose the colors used by the AccelerationPanel.
|
||||
*
|
||||
* @param bgColor
|
||||
* background color.
|
||||
* @param xxColor
|
||||
* color of the acceleration on X axis.
|
||||
* @param yyColor
|
||||
* color of the acceleration on Y axis.
|
||||
* @param zzColor
|
||||
* color of the acceleration on Z axis.
|
||||
* @param lColor
|
||||
* line color.
|
||||
*/
|
||||
public GForcePanel(Color bgColor, Color xxColor, Color yyColor,
|
||||
Color zzColor, Color lColor) {
|
||||
backgroundColor = bgColor;
|
||||
xColor = xxColor;
|
||||
yColor = yyColor;
|
||||
zColor = zzColor;
|
||||
lineColor = lColor;
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Dimension d = getSize();
|
||||
checkOffScreenImage();
|
||||
Graphics offG = mImage.getGraphics();
|
||||
offG.setColor(backgroundColor);
|
||||
offG.fillRect(0, 0, d.width, d.height);
|
||||
Graphics2D g2 = (Graphics2D) mImage.getGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Dimension d = getSize();
|
||||
checkOffScreenImage();
|
||||
Graphics offG = mImage.getGraphics();
|
||||
offG.setColor(backgroundColor);
|
||||
offG.fillRect(0, 0, d.width, d.height);
|
||||
Graphics2D g2 = (Graphics2D) mImage.getGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
// draw medium line
|
||||
double yMiddleFloat = getHeight() / 2.0;
|
||||
int yMiddle = (int) Math.round(yMiddleFloat);
|
||||
// draw medium line
|
||||
double yMiddleFloat = getHeight() / 2.0;
|
||||
int yMiddle = (int) Math.round(yMiddleFloat);
|
||||
|
||||
g2.setPaint(lineColor);
|
||||
g2.drawLine(0, yMiddle, getWidth(), yMiddle);
|
||||
g2.setPaint(lineColor);
|
||||
g2.drawLine(0, yMiddle, getWidth(), yMiddle);
|
||||
|
||||
GForce[] valuesArray = values.toArray(new GForce[0]);
|
||||
double unit = yMiddleFloat / 5.0;
|
||||
int previousX = 0;
|
||||
int previousY = 0;
|
||||
int previousZ = 0;
|
||||
// draw curves
|
||||
for (int i = 0; i < valuesArray.length && i < getWidth(); i++) {
|
||||
GForce gforce = valuesArray[i];
|
||||
// draw X
|
||||
g2.setPaint(xColor);
|
||||
int yDelta = (int) Math.round(unit * gforce.getX());
|
||||
int y = -1 * yDelta + yMiddle;
|
||||
g2.drawLine(i - 1, previousX, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousX = y;
|
||||
// draw Y
|
||||
g2.setPaint(yColor);
|
||||
yDelta = (int) Math.round(unit * gforce.getY());
|
||||
y = -1 * yDelta + yMiddle;
|
||||
g2.drawLine(i - 1, previousY, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousY = y;
|
||||
// draw Z
|
||||
g2.setPaint(zColor);
|
||||
yDelta = (int) Math.round(unit * gforce.getZ());
|
||||
y = -1 * yDelta + yMiddle;
|
||||
g2.drawLine(i - 1, previousZ, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousZ = y;
|
||||
}
|
||||
GForce[] valuesArray = values.toArray(new GForce[0]);
|
||||
double unit = yMiddleFloat / 5.0;
|
||||
int previousX = 0;
|
||||
int previousY = 0;
|
||||
int previousZ = 0;
|
||||
// draw curves
|
||||
for (int i = 0; i < valuesArray.length && i < getWidth(); i++) {
|
||||
GForce gforce = valuesArray[i];
|
||||
// draw X
|
||||
g2.setPaint(xColor);
|
||||
int yDelta = (int) Math.round(unit * gforce.getX());
|
||||
int y = -1 * yDelta + yMiddle;
|
||||
g2.drawLine(i - 1, previousX, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousX = y;
|
||||
// draw Y
|
||||
g2.setPaint(yColor);
|
||||
yDelta = (int) Math.round(unit * gforce.getY());
|
||||
y = -1 * yDelta + yMiddle;
|
||||
g2.drawLine(i - 1, previousY, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousY = y;
|
||||
// draw Z
|
||||
g2.setPaint(zColor);
|
||||
yDelta = (int) Math.round(unit * gforce.getZ());
|
||||
y = -1 * yDelta + yMiddle;
|
||||
g2.drawLine(i - 1, previousZ, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousZ = y;
|
||||
}
|
||||
|
||||
// draw legend
|
||||
g2.setPaint(xColor);
|
||||
g2.drawLine(5, getHeight() - 10, 25, getHeight() - 10);
|
||||
g2.setPaint(yColor);
|
||||
g2.drawLine(60, getHeight() - 10, 80, getHeight() - 10);
|
||||
g2.setPaint(zColor);
|
||||
g2.drawLine(120, getHeight() - 10, 140, getHeight() - 10);
|
||||
// draw legend
|
||||
g2.setPaint(xColor);
|
||||
g2.drawLine(5, getHeight() - 10, 25, getHeight() - 10);
|
||||
g2.setPaint(yColor);
|
||||
g2.drawLine(60, getHeight() - 10, 80, getHeight() - 10);
|
||||
g2.setPaint(zColor);
|
||||
g2.drawLine(120, getHeight() - 10, 140, getHeight() - 10);
|
||||
|
||||
g2.setPaint(lineColor);
|
||||
g2.drawString("X", 30, getHeight() - 5);
|
||||
g2.drawString("Y", 85, getHeight() - 5);
|
||||
g2.drawString("Z", 145, getHeight() - 5);
|
||||
g2.drawString("0", 2, yMiddle - 5);
|
||||
g2.drawString("5", 2, 10);
|
||||
g2.drawString("-5", 2, getHeight() - 15);
|
||||
// put offscreen image on the screen
|
||||
g.drawImage(mImage, 0, 0, null);
|
||||
}
|
||||
g2.setPaint(lineColor);
|
||||
g2.drawString("X", 30, getHeight() - 5);
|
||||
g2.drawString("Y", 85, getHeight() - 5);
|
||||
g2.drawString("Z", 145, getHeight() - 5);
|
||||
g2.drawString("0", 2, yMiddle - 5);
|
||||
g2.drawString("5", 2, 10);
|
||||
g2.drawString("-5", 2, getHeight() - 15);
|
||||
// put offscreen image on the screen
|
||||
g.drawImage(mImage, 0, 0, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* check if the mImage variable has been initialized. If it's not the case
|
||||
* it initializes it with the dimensions of the panel. mImage is for double
|
||||
* buffering.
|
||||
*/
|
||||
private void checkOffScreenImage() {
|
||||
Dimension d = getSize();
|
||||
if (mImage == null || mImage.getWidth(null) != d.width
|
||||
|| mImage.getHeight(null) != d.height) {
|
||||
mImage = createImage(d.width, d.height);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* check if the mImage variable has been initialized. If it's not the case
|
||||
* it initializes it with the dimensions of the panel. mImage is for double
|
||||
* buffering.
|
||||
*/
|
||||
private void checkOffScreenImage() {
|
||||
Dimension d = getSize();
|
||||
if (mImage == null || mImage.getWidth(null) != d.width
|
||||
|| mImage.getHeight(null) != d.height) {
|
||||
mImage = createImage(d.width, d.height);
|
||||
}
|
||||
}
|
||||
|
||||
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onIrEvent(IREvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onIrEvent(IREvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||
draw(arg0);
|
||||
}
|
||||
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||
draw(arg0);
|
||||
}
|
||||
|
||||
public void onExpansionEvent(ExpansionEvent arg0) {
|
||||
draw(arg0);
|
||||
}
|
||||
public void onExpansionEvent(ExpansionEvent arg0) {
|
||||
draw(arg0);
|
||||
}
|
||||
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||
// Clear points.
|
||||
values.clear();
|
||||
repaint();
|
||||
}
|
||||
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||
// Clear points.
|
||||
values.clear();
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerInsertedEvent(
|
||||
ClassicControllerInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onClassicControllerInsertedEvent(
|
||||
ClassicControllerInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerRemovedEvent(
|
||||
ClassicControllerRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onClassicControllerRemovedEvent(
|
||||
ClassicControllerRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
private void draw(GenericEvent arg0) {
|
||||
if (values.size() >= getWidth()) {
|
||||
// if there are as many values as pixels in the width
|
||||
// clear points
|
||||
values.clear();
|
||||
}
|
||||
GForce gforce = getGForceValue(arg0);
|
||||
if (gforce != null)
|
||||
values.add(gforce);
|
||||
repaint();
|
||||
}
|
||||
private void draw(GenericEvent arg0) {
|
||||
if (values.size() >= getWidth()) {
|
||||
// if there are as many values as pixels in the width
|
||||
// clear points
|
||||
values.clear();
|
||||
}
|
||||
GForce gforce = getGForceValue(arg0);
|
||||
if (gforce != null)
|
||||
values.add(gforce);
|
||||
repaint();
|
||||
}
|
||||
|
||||
public abstract GForce getGForceValue(GenericEvent e);
|
||||
public abstract GForce getGForceValue(GenericEvent e);
|
||||
|
||||
public Color getBackgroundColor() {
|
||||
return backgroundColor;
|
||||
}
|
||||
public Color getBackgroundColor() {
|
||||
return backgroundColor;
|
||||
}
|
||||
|
||||
public Color getLineColor() {
|
||||
return lineColor;
|
||||
}
|
||||
public Color getLineColor() {
|
||||
return lineColor;
|
||||
}
|
||||
|
||||
public Color getXColor() {
|
||||
return xColor;
|
||||
}
|
||||
public Color getXColor() {
|
||||
return xColor;
|
||||
}
|
||||
|
||||
public Color getYColor() {
|
||||
return yColor;
|
||||
}
|
||||
public Color getYColor() {
|
||||
return yColor;
|
||||
}
|
||||
|
||||
public Color getZColor() {
|
||||
return zColor;
|
||||
}
|
||||
public Color getZColor() {
|
||||
return zColor;
|
||||
}
|
||||
|
||||
public void setBackgroundColor(Color backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
public void setBackgroundColor(Color backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
public void setLineColor(Color lineColor) {
|
||||
this.lineColor = lineColor;
|
||||
}
|
||||
public void setLineColor(Color lineColor) {
|
||||
this.lineColor = lineColor;
|
||||
}
|
||||
|
||||
public void setXColor(Color xColor) {
|
||||
this.xColor = xColor;
|
||||
}
|
||||
public void setXColor(Color xColor) {
|
||||
this.xColor = xColor;
|
||||
}
|
||||
|
||||
public void setYColor(Color yColor) {
|
||||
this.yColor = yColor;
|
||||
}
|
||||
public void setYColor(Color yColor) {
|
||||
this.yColor = yColor;
|
||||
}
|
||||
|
||||
public void setZColor(Color zColor) {
|
||||
this.zColor = zColor;
|
||||
}
|
||||
public void setZColor(Color zColor) {
|
||||
this.zColor = zColor;
|
||||
}
|
||||
|
||||
public void clearView() {
|
||||
values.clear();
|
||||
repaint();
|
||||
}
|
||||
public void clearView() {
|
||||
values.clear();
|
||||
repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated
|
||||
// Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
// <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
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
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
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
||||
@@ -27,11 +27,11 @@ import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
*/
|
||||
public class GForceWiimoteEventPanel extends GForcePanel {
|
||||
|
||||
@Override
|
||||
public GForce getGForceValue(GenericEvent e) {
|
||||
if (e instanceof MotionSensingEvent) {
|
||||
return ((MotionSensingEvent) e).getGforce();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public GForce getGForceValue(GenericEvent e) {
|
||||
if (e instanceof MotionSensingEvent) {
|
||||
return ((MotionSensingEvent) e).getGforce();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,230 +46,230 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
|
||||
*/
|
||||
public class IRPanel extends javax.swing.JPanel implements WiimoteListener {
|
||||
|
||||
private static int MAX_NB_POINTS = 4;
|
||||
private Color color = Color.YELLOW;
|
||||
private Color backgroundColor = Color.BLACK;
|
||||
private Color borderColor = Color.BLUE;
|
||||
private Shape shape;
|
||||
private Image mImage;// image for double buffering
|
||||
private int[] xCoordinates;
|
||||
private int[] yCoordinates;
|
||||
private int nbPoints = -1;
|
||||
private static int MAX_NB_POINTS = 4;
|
||||
private Color color = Color.YELLOW;
|
||||
private Color backgroundColor = Color.BLACK;
|
||||
private Color borderColor = Color.BLUE;
|
||||
private Shape shape;
|
||||
private Image mImage;// image for double buffering
|
||||
private int[] xCoordinates;
|
||||
private int[] yCoordinates;
|
||||
private int nbPoints = -1;
|
||||
|
||||
/**
|
||||
* Default constructor for IR Panel. Background color : black. IR sources
|
||||
* color : yellow. Border color of IR sources : blue. Shape of the IR
|
||||
* sources : circle with a diameter of 10.
|
||||
*/
|
||||
public IRPanel() {
|
||||
shape = new java.awt.geom.Ellipse2D.Double(0, 0, 10, 10);
|
||||
initArrays();
|
||||
initComponents();
|
||||
}
|
||||
/**
|
||||
* Default constructor for IR Panel. Background color : black. IR sources
|
||||
* color : yellow. Border color of IR sources : blue. Shape of the IR
|
||||
* sources : circle with a diameter of 10.
|
||||
*/
|
||||
public IRPanel() {
|
||||
shape = new java.awt.geom.Ellipse2D.Double(0, 0, 10, 10);
|
||||
initArrays();
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor used to parameterize the IR panel.
|
||||
*
|
||||
* @param bgColor
|
||||
* color.
|
||||
* @param ptColor
|
||||
* IR sources color.
|
||||
* @param bdColor
|
||||
* border color of IR sources.
|
||||
* @param sh
|
||||
* Shape of the IR sources.
|
||||
*/
|
||||
public IRPanel(Color bgColor, Color ptColor, Color bdColor, Shape sh) {
|
||||
backgroundColor = bgColor;
|
||||
color = ptColor;
|
||||
borderColor = bdColor;
|
||||
shape = sh;
|
||||
initArrays();
|
||||
initComponents();
|
||||
}
|
||||
/**
|
||||
* Constructor used to parameterize the IR panel.
|
||||
*
|
||||
* @param bgColor
|
||||
* color.
|
||||
* @param ptColor
|
||||
* IR sources color.
|
||||
* @param bdColor
|
||||
* border color of IR sources.
|
||||
* @param sh
|
||||
* Shape of the IR sources.
|
||||
*/
|
||||
public IRPanel(Color bgColor, Color ptColor, Color bdColor, Shape sh) {
|
||||
backgroundColor = bgColor;
|
||||
color = ptColor;
|
||||
borderColor = bdColor;
|
||||
shape = sh;
|
||||
initArrays();
|
||||
initComponents();
|
||||
}
|
||||
|
||||
private void initArrays() {
|
||||
xCoordinates = new int[MAX_NB_POINTS];
|
||||
yCoordinates = new int[MAX_NB_POINTS];
|
||||
for (int i = 0; i < MAX_NB_POINTS; i++) {
|
||||
xCoordinates[i] = -1;
|
||||
yCoordinates[i] = -1;
|
||||
}
|
||||
}
|
||||
private void initArrays() {
|
||||
xCoordinates = new int[MAX_NB_POINTS];
|
||||
yCoordinates = new int[MAX_NB_POINTS];
|
||||
for (int i = 0; i < MAX_NB_POINTS; i++) {
|
||||
xCoordinates[i] = -1;
|
||||
yCoordinates[i] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Dimension d = getSize();
|
||||
checkOffScreenImage();
|
||||
Graphics offG = mImage.getGraphics();
|
||||
offG.setColor(backgroundColor);
|
||||
offG.fillRect(0, 0, d.width, d.height);
|
||||
Graphics2D g2 = (Graphics2D) mImage.getGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Dimension d = getSize();
|
||||
checkOffScreenImage();
|
||||
Graphics offG = mImage.getGraphics();
|
||||
offG.setColor(backgroundColor);
|
||||
offG.fillRect(0, 0, d.width, d.height);
|
||||
Graphics2D g2 = (Graphics2D) mImage.getGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
// draw points
|
||||
int i = 0;
|
||||
while (i < nbPoints) {
|
||||
double x = xCoordinates[i];
|
||||
double y = yCoordinates[i];
|
||||
// draw points
|
||||
int i = 0;
|
||||
while (i < nbPoints) {
|
||||
double x = xCoordinates[i];
|
||||
double y = yCoordinates[i];
|
||||
|
||||
long xx = getWidth() - Math.round((double) getWidth() * x / 1024.0);
|
||||
long yy = getHeight()
|
||||
- Math.round((double) getHeight() * y / 768.0);
|
||||
g2.translate(xx, yy);
|
||||
long xx = getWidth() - Math.round((double) getWidth() * x / 1024.0);
|
||||
long yy = getHeight()
|
||||
- Math.round((double) getHeight() * y / 768.0);
|
||||
g2.translate(xx, yy);
|
||||
|
||||
g2.setPaint(borderColor);
|
||||
g2.draw(shape);
|
||||
g2.setPaint(color);
|
||||
g2.fill(shape);
|
||||
g2.setPaint(borderColor);
|
||||
g2.draw(shape);
|
||||
g2.setPaint(color);
|
||||
g2.fill(shape);
|
||||
|
||||
g2.setTransform(new AffineTransform());
|
||||
i++;
|
||||
}
|
||||
// put offscreen image on the screen
|
||||
g.drawImage(mImage, 0, 0, null);
|
||||
}
|
||||
g2.setTransform(new AffineTransform());
|
||||
i++;
|
||||
}
|
||||
// put offscreen image on the screen
|
||||
g.drawImage(mImage, 0, 0, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* check if the mImage variable has been initialized. If it's not the case
|
||||
* it initializes it with the dimensions of the panel. mImage is for double
|
||||
* buffering.
|
||||
*/
|
||||
private void checkOffScreenImage() {
|
||||
Dimension d = getSize();
|
||||
if (mImage == null || mImage.getWidth(null) != d.width
|
||||
|| mImage.getHeight(null) != d.height) {
|
||||
mImage = createImage(d.width, d.height);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* check if the mImage variable has been initialized. If it's not the case
|
||||
* it initializes it with the dimensions of the panel. mImage is for double
|
||||
* buffering.
|
||||
*/
|
||||
private void checkOffScreenImage() {
|
||||
Dimension d = getSize();
|
||||
if (mImage == null || mImage.getWidth(null) != d.width
|
||||
|| mImage.getHeight(null) != d.height) {
|
||||
mImage = createImage(d.width, d.height);
|
||||
}
|
||||
}
|
||||
|
||||
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||
// nothing
|
||||
repaint();
|
||||
}
|
||||
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||
// nothing
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void onIrEvent(IREvent arg0) {
|
||||
// transfer points
|
||||
wiiusej.values.IRSource[] points = arg0.getIRPoints();
|
||||
nbPoints = points.length;
|
||||
for (int i = 0; i < points.length; i++) {
|
||||
xCoordinates[i] = (int) points[i].getRx();
|
||||
yCoordinates[i] = (int) points[i].getRy();
|
||||
}
|
||||
for (int i = points.length; i < MAX_NB_POINTS; i++) {
|
||||
xCoordinates[i] = -1;
|
||||
yCoordinates[i] = -1;
|
||||
}
|
||||
public void onIrEvent(IREvent arg0) {
|
||||
// transfer points
|
||||
wiiusej.values.IRSource[] points = arg0.getIRPoints();
|
||||
nbPoints = points.length;
|
||||
for (int i = 0; i < points.length; i++) {
|
||||
xCoordinates[i] = (int) points[i].getRx();
|
||||
yCoordinates[i] = (int) points[i].getRy();
|
||||
}
|
||||
for (int i = points.length; i < MAX_NB_POINTS; i++) {
|
||||
xCoordinates[i] = -1;
|
||||
yCoordinates[i] = -1;
|
||||
}
|
||||
|
||||
// redraw panel
|
||||
repaint();
|
||||
}
|
||||
// redraw panel
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onExpansionEvent(ExpansionEvent e) {
|
||||
// nothing
|
||||
}
|
||||
public void onExpansionEvent(ExpansionEvent e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||
// clear previous points
|
||||
for (int i = 0; i < MAX_NB_POINTS; i++) {
|
||||
xCoordinates[i] = -1;
|
||||
yCoordinates[i] = -1;
|
||||
}
|
||||
// redraw panel
|
||||
repaint();
|
||||
}
|
||||
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||
// clear previous points
|
||||
for (int i = 0; i < MAX_NB_POINTS; i++) {
|
||||
xCoordinates[i] = -1;
|
||||
yCoordinates[i] = -1;
|
||||
}
|
||||
// redraw panel
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent e) {
|
||||
// nothing
|
||||
}
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent e) {
|
||||
// nothing
|
||||
}
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerInsertedEvent(
|
||||
ClassicControllerInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onClassicControllerInsertedEvent(
|
||||
ClassicControllerInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerRemovedEvent(
|
||||
ClassicControllerRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onClassicControllerRemovedEvent(
|
||||
ClassicControllerRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public Color getBackgroundColor() {
|
||||
return backgroundColor;
|
||||
}
|
||||
public Color getBackgroundColor() {
|
||||
return backgroundColor;
|
||||
}
|
||||
|
||||
public Color getBorderColor() {
|
||||
return borderColor;
|
||||
}
|
||||
public Color getBorderColor() {
|
||||
return borderColor;
|
||||
}
|
||||
|
||||
public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public Shape getShape() {
|
||||
return shape;
|
||||
}
|
||||
public Shape getShape() {
|
||||
return shape;
|
||||
}
|
||||
|
||||
public void setBackgroundColor(Color backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
public void setBackgroundColor(Color backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
public void setBorderColor(Color borderColor) {
|
||||
this.borderColor = borderColor;
|
||||
}
|
||||
public void setBorderColor(Color borderColor) {
|
||||
this.borderColor = borderColor;
|
||||
}
|
||||
|
||||
public void setColor(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
public void setColor(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public void setShape(Shape shape) {
|
||||
this.shape = shape;
|
||||
}
|
||||
public void setShape(Shape shape) {
|
||||
this.shape = shape;
|
||||
}
|
||||
|
||||
public void clearView() {
|
||||
initArrays();
|
||||
repaint();
|
||||
}
|
||||
public void clearView() {
|
||||
initArrays();
|
||||
repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated
|
||||
// Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
// <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
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
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
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
||||
@@ -45,204 +45,204 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
|
||||
* @author guiguito
|
||||
*/
|
||||
public abstract class JoystickEventPanel extends javax.swing.JPanel implements
|
||||
WiimoteListener {
|
||||
WiimoteListener {
|
||||
|
||||
private Image mImage;// image for double buffering
|
||||
private Color backgroundColor = Color.BLACK;
|
||||
private Color borderColor = Color.RED;
|
||||
private Color pointColor = Color.RED;
|
||||
private Shape shape = new java.awt.geom.Ellipse2D.Double(0, 0, 30, 30);
|
||||
private JoystickEvent lastJoystickEvent = null;
|
||||
private Image mImage;// image for double buffering
|
||||
private Color backgroundColor = Color.BLACK;
|
||||
private Color borderColor = Color.RED;
|
||||
private Color pointColor = Color.RED;
|
||||
private Shape shape = new java.awt.geom.Ellipse2D.Double(0, 0, 30, 30);
|
||||
private JoystickEvent lastJoystickEvent = null;
|
||||
|
||||
/** Creates new form JoystickPanel */
|
||||
public JoystickEventPanel() {
|
||||
initComponents();
|
||||
}
|
||||
/** Creates new form JoystickPanel */
|
||||
public JoystickEventPanel() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor used to choose the colors used by the JoystickPanel.
|
||||
*
|
||||
* @param bgColor
|
||||
* background color.
|
||||
* @param pColor
|
||||
* point color.
|
||||
* @param bdColor
|
||||
* border color for the shape.
|
||||
* @param sh
|
||||
* shape of what is drawn.
|
||||
*/
|
||||
public JoystickEventPanel(Color bgColor, Color pColor, Color bdColor,
|
||||
Shape sh) {
|
||||
backgroundColor = bgColor;
|
||||
pointColor = pColor;
|
||||
shape = sh;
|
||||
borderColor = bdColor;
|
||||
initComponents();
|
||||
}
|
||||
/**
|
||||
* Constructor used to choose the colors used by the JoystickPanel.
|
||||
*
|
||||
* @param bgColor
|
||||
* background color.
|
||||
* @param pColor
|
||||
* point color.
|
||||
* @param bdColor
|
||||
* border color for the shape.
|
||||
* @param sh
|
||||
* shape of what is drawn.
|
||||
*/
|
||||
public JoystickEventPanel(Color bgColor, Color pColor, Color bdColor,
|
||||
Shape sh) {
|
||||
backgroundColor = bgColor;
|
||||
pointColor = pColor;
|
||||
shape = sh;
|
||||
borderColor = bdColor;
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Dimension d = getSize();
|
||||
checkOffScreenImage();
|
||||
Graphics offG = mImage.getGraphics();
|
||||
offG.setColor(backgroundColor);
|
||||
offG.fillRect(0, 0, d.width, d.height);
|
||||
Graphics2D g2 = (Graphics2D) mImage.getGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2.setTransform(new AffineTransform());
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Dimension d = getSize();
|
||||
checkOffScreenImage();
|
||||
Graphics offG = mImage.getGraphics();
|
||||
offG.setColor(backgroundColor);
|
||||
offG.fillRect(0, 0, d.width, d.height);
|
||||
Graphics2D g2 = (Graphics2D) mImage.getGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2.setTransform(new AffineTransform());
|
||||
|
||||
// compute center
|
||||
int xCenter = (int) Math.round(d.getWidth() / 2.0);
|
||||
int yCenter = (int) Math.round(d.getHeight() / 2.0);
|
||||
// compute center
|
||||
int xCenter = (int) Math.round(d.getWidth() / 2.0);
|
||||
int yCenter = (int) Math.round(d.getHeight() / 2.0);
|
||||
|
||||
// compute coordinates
|
||||
if (lastJoystickEvent != null) {
|
||||
double xAng = Math.sin(lastJoystickEvent.getAngle() * Math.PI
|
||||
/ 180.0)
|
||||
* lastJoystickEvent.getMagnitude();
|
||||
double yAng = Math.cos(lastJoystickEvent.getAngle() * Math.PI
|
||||
/ 180.0)
|
||||
* lastJoystickEvent.getMagnitude();
|
||||
int halfWidth = (int) Math.round(shape.getBounds().getWidth() / 2);
|
||||
int halHeight = (int) Math.round(shape.getBounds().getHeight() / 2);
|
||||
int xAmplitude = (int) Math.round(xCenter - shape.getBounds().getWidth());
|
||||
int yAmplitude = (int) Math.round(xCenter - shape.getBounds().getHeight());
|
||||
int xShift = (int) Math.round(xAng * xAmplitude);
|
||||
int yShift = (int) Math.round(yAng * yAmplitude);
|
||||
int x = xCenter + xShift - halfWidth;
|
||||
int y = yCenter - yShift - halHeight;
|
||||
// shape
|
||||
g2.translate(x, y);
|
||||
g2.setPaint(borderColor);
|
||||
g2.draw(shape);
|
||||
g2.setPaint(pointColor);
|
||||
g2.fill(shape);
|
||||
}
|
||||
// put offscreen image on the screen
|
||||
g.drawImage(mImage, 0, 0, null);
|
||||
}
|
||||
// compute coordinates
|
||||
if (lastJoystickEvent != null) {
|
||||
double xAng = Math.sin(lastJoystickEvent.getAngle() * Math.PI
|
||||
/ 180.0)
|
||||
* lastJoystickEvent.getMagnitude();
|
||||
double yAng = Math.cos(lastJoystickEvent.getAngle() * Math.PI
|
||||
/ 180.0)
|
||||
* lastJoystickEvent.getMagnitude();
|
||||
int halfWidth = (int) Math.round(shape.getBounds().getWidth() / 2);
|
||||
int halHeight = (int) Math.round(shape.getBounds().getHeight() / 2);
|
||||
int xAmplitude = (int) Math.round(xCenter - shape.getBounds().getWidth());
|
||||
int yAmplitude = (int) Math.round(xCenter - shape.getBounds().getHeight());
|
||||
int xShift = (int) Math.round(xAng * xAmplitude);
|
||||
int yShift = (int) Math.round(yAng * yAmplitude);
|
||||
int x = xCenter + xShift - halfWidth;
|
||||
int y = yCenter - yShift - halHeight;
|
||||
// shape
|
||||
g2.translate(x, y);
|
||||
g2.setPaint(borderColor);
|
||||
g2.draw(shape);
|
||||
g2.setPaint(pointColor);
|
||||
g2.fill(shape);
|
||||
}
|
||||
// put offscreen image on the screen
|
||||
g.drawImage(mImage, 0, 0, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* check if the mImage variable has been initialized. If it's not the case
|
||||
* it initializes it with the dimensions of the panel. mImage is for double
|
||||
* buffering.
|
||||
*/
|
||||
private void checkOffScreenImage() {
|
||||
Dimension d = getSize();
|
||||
if (mImage == null || mImage.getWidth(null) != d.width
|
||||
|| mImage.getHeight(null) != d.height) {
|
||||
mImage = createImage(d.width, d.height);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* check if the mImage variable has been initialized. If it's not the case
|
||||
* it initializes it with the dimensions of the panel. mImage is for double
|
||||
* buffering.
|
||||
*/
|
||||
private void checkOffScreenImage() {
|
||||
Dimension d = getSize();
|
||||
if (mImage == null || mImage.getWidth(null) != d.width
|
||||
|| mImage.getHeight(null) != d.height) {
|
||||
mImage = createImage(d.width, d.height);
|
||||
}
|
||||
}
|
||||
|
||||
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onIrEvent(IREvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onIrEvent(IREvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onExpansionEvent(ExpansionEvent arg0) {
|
||||
JoystickEvent joy = getJoystickEvent(arg0);
|
||||
if (joy != null) {
|
||||
lastJoystickEvent = joy;
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
public void onExpansionEvent(ExpansionEvent arg0) {
|
||||
JoystickEvent joy = getJoystickEvent(arg0);
|
||||
if (joy != null) {
|
||||
lastJoystickEvent = joy;
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerInsertedEvent(
|
||||
ClassicControllerInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onClassicControllerInsertedEvent(
|
||||
ClassicControllerInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerRemovedEvent(
|
||||
ClassicControllerRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onClassicControllerRemovedEvent(
|
||||
ClassicControllerRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public Color getBackgroundColor() {
|
||||
return backgroundColor;
|
||||
}
|
||||
public Color getBackgroundColor() {
|
||||
return backgroundColor;
|
||||
}
|
||||
|
||||
public Color getPointColor() {
|
||||
return pointColor;
|
||||
}
|
||||
public Color getPointColor() {
|
||||
return pointColor;
|
||||
}
|
||||
|
||||
public Color getBorderColor() {
|
||||
return borderColor;
|
||||
}
|
||||
public Color getBorderColor() {
|
||||
return borderColor;
|
||||
}
|
||||
|
||||
public Shape getShape() {
|
||||
return shape;
|
||||
}
|
||||
public Shape getShape() {
|
||||
return shape;
|
||||
}
|
||||
|
||||
public void setBackgroundColor(Color backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
public void setBackgroundColor(Color backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
public void setPointColor(Color pointColor) {
|
||||
this.pointColor = pointColor;
|
||||
}
|
||||
public void setPointColor(Color pointColor) {
|
||||
this.pointColor = pointColor;
|
||||
}
|
||||
|
||||
public void setBorderColor(Color borderColor) {
|
||||
this.borderColor = borderColor;
|
||||
}
|
||||
public void setBorderColor(Color borderColor) {
|
||||
this.borderColor = borderColor;
|
||||
}
|
||||
|
||||
public void setShape(Shape shape) {
|
||||
this.shape = shape;
|
||||
}
|
||||
public void setShape(Shape shape) {
|
||||
this.shape = shape;
|
||||
}
|
||||
|
||||
public abstract JoystickEvent getJoystickEvent(ExpansionEvent e);
|
||||
public abstract JoystickEvent getJoystickEvent(ExpansionEvent e);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated
|
||||
// Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
// <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
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
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
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
||||
@@ -28,11 +28,11 @@ import wiiusej.wiiusejevents.physicalevents.NunchukEvent;
|
||||
*/
|
||||
public class NunchukJoystickEventPanel extends JoystickEventPanel {
|
||||
|
||||
@Override
|
||||
public JoystickEvent getJoystickEvent(ExpansionEvent e) {
|
||||
if (e instanceof NunchukEvent) {
|
||||
return ((NunchukEvent) e).getNunchukJoystickEvent();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public JoystickEvent getJoystickEvent(ExpansionEvent e) {
|
||||
if (e instanceof NunchukEvent) {
|
||||
return ((NunchukEvent) e).getNunchukJoystickEvent();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@ import wiiusej.wiiusejevents.physicalevents.NunchukEvent;
|
||||
*/
|
||||
public class OrientationExpansionEventPanel extends OrientationPanel {
|
||||
|
||||
@Override
|
||||
public Orientation getOrientationValue(GenericEvent e) {
|
||||
if (e instanceof NunchukEvent) {
|
||||
return ((NunchukEvent) e).getNunchukMotionSensingEvent()
|
||||
.getOrientation();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Orientation getOrientationValue(GenericEvent e) {
|
||||
if (e instanceof NunchukEvent) {
|
||||
return ((NunchukEvent) e).getNunchukMotionSensingEvent()
|
||||
.getOrientation();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,259 +47,259 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
|
||||
* @author guiguito
|
||||
*/
|
||||
public abstract class OrientationPanel extends javax.swing.JPanel implements
|
||||
WiimoteListener {
|
||||
WiimoteListener {
|
||||
|
||||
private Image mImage;// image for double buffering
|
||||
private Color rollColor = Color.RED;
|
||||
private Color pitchColor = Color.GREEN;
|
||||
private Color yawColor = Color.BLUE;
|
||||
private Color backgroundColor = Color.WHITE;
|
||||
private Color lineColor = Color.BLACK;
|
||||
private ArrayList<Orientation> values = new ArrayList<Orientation>();
|
||||
private Image mImage;// image for double buffering
|
||||
private Color rollColor = Color.RED;
|
||||
private Color pitchColor = Color.GREEN;
|
||||
private Color yawColor = Color.BLUE;
|
||||
private Color backgroundColor = Color.WHITE;
|
||||
private Color lineColor = Color.BLACK;
|
||||
private ArrayList<Orientation> values = new ArrayList<Orientation>();
|
||||
|
||||
/**
|
||||
* Default constructor. Background color : White. Roll color : Red. Pitch
|
||||
* color : Green. Yaw color : Blue.
|
||||
*/
|
||||
public OrientationPanel() {
|
||||
initComponents();
|
||||
}
|
||||
/**
|
||||
* Default constructor. Background color : White. Roll color : Red. Pitch
|
||||
* color : Green. Yaw color : Blue.
|
||||
*/
|
||||
public OrientationPanel() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor used to choose the colors used by the OrientationPanel.
|
||||
*
|
||||
* @param bgColor
|
||||
* background color.
|
||||
* @param rColor
|
||||
* roll color.
|
||||
* @param pColor
|
||||
* pitch color.
|
||||
* @param yColor
|
||||
* yaw color.
|
||||
* @param lColor
|
||||
* line color.
|
||||
*/
|
||||
public OrientationPanel(Color bgColor, Color rColor, Color pColor,
|
||||
Color yColor, Color lColor) {
|
||||
backgroundColor = bgColor;
|
||||
rollColor = rColor;
|
||||
pitchColor = pColor;
|
||||
yawColor = yColor;
|
||||
lineColor = lColor;
|
||||
initComponents();
|
||||
}
|
||||
/**
|
||||
* Constructor used to choose the colors used by the OrientationPanel.
|
||||
*
|
||||
* @param bgColor
|
||||
* background color.
|
||||
* @param rColor
|
||||
* roll color.
|
||||
* @param pColor
|
||||
* pitch color.
|
||||
* @param yColor
|
||||
* yaw color.
|
||||
* @param lColor
|
||||
* line color.
|
||||
*/
|
||||
public OrientationPanel(Color bgColor, Color rColor, Color pColor,
|
||||
Color yColor, Color lColor) {
|
||||
backgroundColor = bgColor;
|
||||
rollColor = rColor;
|
||||
pitchColor = pColor;
|
||||
yawColor = yColor;
|
||||
lineColor = lColor;
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Dimension d = getSize();
|
||||
checkOffScreenImage();
|
||||
Graphics offG = mImage.getGraphics();
|
||||
offG.setColor(backgroundColor);
|
||||
offG.fillRect(0, 0, d.width, d.height);
|
||||
Graphics2D g2 = (Graphics2D) mImage.getGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Dimension d = getSize();
|
||||
checkOffScreenImage();
|
||||
Graphics offG = mImage.getGraphics();
|
||||
offG.setColor(backgroundColor);
|
||||
offG.fillRect(0, 0, d.width, d.height);
|
||||
Graphics2D g2 = (Graphics2D) mImage.getGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
// draw medium line
|
||||
double yMiddleFloat = getHeight() / 2.0;
|
||||
int yMiddle = (int) Math.round(yMiddleFloat);
|
||||
// draw medium line
|
||||
double yMiddleFloat = getHeight() / 2.0;
|
||||
int yMiddle = (int) Math.round(yMiddleFloat);
|
||||
|
||||
g2.setPaint(lineColor);
|
||||
g2.drawLine(0, yMiddle, getWidth(), yMiddle);
|
||||
g2.setPaint(lineColor);
|
||||
g2.drawLine(0, yMiddle, getWidth(), yMiddle);
|
||||
|
||||
Orientation[] valuesArray = values.toArray(new Orientation[0]);
|
||||
double unit = yMiddleFloat / 180.0;
|
||||
int previousRoll = 0;
|
||||
int previousPitch = 0;
|
||||
int previousYaw = 0;
|
||||
// draw curves
|
||||
for (int i = 0; i < valuesArray.length && i < getWidth(); i++) {
|
||||
Orientation orientation = valuesArray[i];
|
||||
// draw roll
|
||||
g2.setPaint(rollColor);
|
||||
int yDelta = (int) Math.round(unit * orientation.getRoll());
|
||||
int y = -1 * yDelta + yMiddle;
|
||||
g2.drawLine(i - 1, previousRoll, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousRoll = y;
|
||||
// draw pitch
|
||||
g2.setPaint(pitchColor);
|
||||
yDelta = (int) Math.round(unit * orientation.getPitch());
|
||||
y = -1 * yDelta + yMiddle;
|
||||
g2.drawLine(i - 1, previousPitch, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousPitch = y;
|
||||
// draw yaw
|
||||
g2.setPaint(yawColor);
|
||||
yDelta = (int) Math.round(unit * orientation.getYaw());
|
||||
y = -1 * yDelta + yMiddle;
|
||||
g2.drawLine(i - 1, previousYaw, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousYaw = y;
|
||||
}
|
||||
Orientation[] valuesArray = values.toArray(new Orientation[0]);
|
||||
double unit = yMiddleFloat / 180.0;
|
||||
int previousRoll = 0;
|
||||
int previousPitch = 0;
|
||||
int previousYaw = 0;
|
||||
// draw curves
|
||||
for (int i = 0; i < valuesArray.length && i < getWidth(); i++) {
|
||||
Orientation orientation = valuesArray[i];
|
||||
// draw roll
|
||||
g2.setPaint(rollColor);
|
||||
int yDelta = (int) Math.round(unit * orientation.getRoll());
|
||||
int y = -1 * yDelta + yMiddle;
|
||||
g2.drawLine(i - 1, previousRoll, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousRoll = y;
|
||||
// draw pitch
|
||||
g2.setPaint(pitchColor);
|
||||
yDelta = (int) Math.round(unit * orientation.getPitch());
|
||||
y = -1 * yDelta + yMiddle;
|
||||
g2.drawLine(i - 1, previousPitch, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousPitch = y;
|
||||
// draw yaw
|
||||
g2.setPaint(yawColor);
|
||||
yDelta = (int) Math.round(unit * orientation.getYaw());
|
||||
y = -1 * yDelta + yMiddle;
|
||||
g2.drawLine(i - 1, previousYaw, i, y);
|
||||
g2.setTransform(new AffineTransform());
|
||||
previousYaw = y;
|
||||
}
|
||||
|
||||
// draw legend
|
||||
g2.setPaint(rollColor);
|
||||
g2.drawLine(5, getHeight() - 10, 25, getHeight() - 10);
|
||||
g2.setPaint(pitchColor);
|
||||
g2.drawLine(60, getHeight() - 10, 80, getHeight() - 10);
|
||||
g2.setPaint(yawColor);
|
||||
g2.drawLine(120, getHeight() - 10, 140, getHeight() - 10);
|
||||
// draw legend
|
||||
g2.setPaint(rollColor);
|
||||
g2.drawLine(5, getHeight() - 10, 25, getHeight() - 10);
|
||||
g2.setPaint(pitchColor);
|
||||
g2.drawLine(60, getHeight() - 10, 80, getHeight() - 10);
|
||||
g2.setPaint(yawColor);
|
||||
g2.drawLine(120, getHeight() - 10, 140, getHeight() - 10);
|
||||
|
||||
g2.setPaint(lineColor);
|
||||
g2.drawString("Roll", 30, getHeight() - 5);
|
||||
g2.drawString("Pitch", 85, getHeight() - 5);
|
||||
g2.drawString("Yaw", 145, getHeight() - 5);
|
||||
g2.drawString("0", 2, yMiddle - 5);
|
||||
g2.drawString("180", 2, 10);
|
||||
g2.drawString("-180", 2, getHeight() - 15);
|
||||
// put offscreen image on the screen
|
||||
g.drawImage(mImage, 0, 0, null);
|
||||
}
|
||||
g2.setPaint(lineColor);
|
||||
g2.drawString("Roll", 30, getHeight() - 5);
|
||||
g2.drawString("Pitch", 85, getHeight() - 5);
|
||||
g2.drawString("Yaw", 145, getHeight() - 5);
|
||||
g2.drawString("0", 2, yMiddle - 5);
|
||||
g2.drawString("180", 2, 10);
|
||||
g2.drawString("-180", 2, getHeight() - 15);
|
||||
// put offscreen image on the screen
|
||||
g.drawImage(mImage, 0, 0, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* check if the mImage variable has been initialized. If it's not the case
|
||||
* it initializes it with the dimensions of the panel. mImage is for double
|
||||
* buffering.
|
||||
*/
|
||||
private void checkOffScreenImage() {
|
||||
Dimension d = getSize();
|
||||
if (mImage == null || mImage.getWidth(null) != d.width
|
||||
|| mImage.getHeight(null) != d.height) {
|
||||
mImage = createImage(d.width, d.height);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* check if the mImage variable has been initialized. If it's not the case
|
||||
* it initializes it with the dimensions of the panel. mImage is for double
|
||||
* buffering.
|
||||
*/
|
||||
private void checkOffScreenImage() {
|
||||
Dimension d = getSize();
|
||||
if (mImage == null || mImage.getWidth(null) != d.width
|
||||
|| mImage.getHeight(null) != d.height) {
|
||||
mImage = createImage(d.width, d.height);
|
||||
}
|
||||
}
|
||||
|
||||
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onIrEvent(IREvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onIrEvent(IREvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||
draw(arg0);
|
||||
}
|
||||
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||
draw(arg0);
|
||||
}
|
||||
|
||||
public void onExpansionEvent(ExpansionEvent arg0) {
|
||||
draw(arg0);
|
||||
}
|
||||
public void onExpansionEvent(ExpansionEvent arg0) {
|
||||
draw(arg0);
|
||||
}
|
||||
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||
// Clear points.
|
||||
values.clear();
|
||||
repaint();
|
||||
}
|
||||
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||
// Clear points.
|
||||
values.clear();
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerInsertedEvent(
|
||||
ClassicControllerInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onClassicControllerInsertedEvent(
|
||||
ClassicControllerInsertedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onClassicControllerRemovedEvent(
|
||||
ClassicControllerRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
public void onClassicControllerRemovedEvent(
|
||||
ClassicControllerRemovedEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
private void draw(GenericEvent arg0) {
|
||||
if (values.size() >= getWidth()) {
|
||||
// if there are as many values as pixels in the width
|
||||
// clear points
|
||||
values.clear();
|
||||
}
|
||||
Orientation orientation = getOrientationValue(arg0);
|
||||
if (orientation != null)
|
||||
values.add(orientation);
|
||||
repaint();
|
||||
}
|
||||
private void draw(GenericEvent arg0) {
|
||||
if (values.size() >= getWidth()) {
|
||||
// if there are as many values as pixels in the width
|
||||
// clear points
|
||||
values.clear();
|
||||
}
|
||||
Orientation orientation = getOrientationValue(arg0);
|
||||
if (orientation != null)
|
||||
values.add(orientation);
|
||||
repaint();
|
||||
}
|
||||
|
||||
public abstract Orientation getOrientationValue(GenericEvent e);
|
||||
public abstract Orientation getOrientationValue(GenericEvent e);
|
||||
|
||||
public Color getBackgroundColor() {
|
||||
return backgroundColor;
|
||||
}
|
||||
public Color getBackgroundColor() {
|
||||
return backgroundColor;
|
||||
}
|
||||
|
||||
public Color getLineColor() {
|
||||
return lineColor;
|
||||
}
|
||||
public Color getLineColor() {
|
||||
return lineColor;
|
||||
}
|
||||
|
||||
public Color getPitchColor() {
|
||||
return pitchColor;
|
||||
}
|
||||
public Color getPitchColor() {
|
||||
return pitchColor;
|
||||
}
|
||||
|
||||
public Color getRollColor() {
|
||||
return rollColor;
|
||||
}
|
||||
public Color getRollColor() {
|
||||
return rollColor;
|
||||
}
|
||||
|
||||
public Color getYawColor() {
|
||||
return yawColor;
|
||||
}
|
||||
public Color getYawColor() {
|
||||
return yawColor;
|
||||
}
|
||||
|
||||
public void setBackgroundColor(Color backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
public void setBackgroundColor(Color backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
public void setLineColor(Color lineColor) {
|
||||
this.lineColor = lineColor;
|
||||
}
|
||||
public void setLineColor(Color lineColor) {
|
||||
this.lineColor = lineColor;
|
||||
}
|
||||
|
||||
public void setPitchColor(Color pitchColor) {
|
||||
this.pitchColor = pitchColor;
|
||||
}
|
||||
public void setPitchColor(Color pitchColor) {
|
||||
this.pitchColor = pitchColor;
|
||||
}
|
||||
|
||||
public void setRollColor(Color rollColor) {
|
||||
this.rollColor = rollColor;
|
||||
}
|
||||
public void setRollColor(Color rollColor) {
|
||||
this.rollColor = rollColor;
|
||||
}
|
||||
|
||||
public void setYawColor(Color yawColor) {
|
||||
this.yawColor = yawColor;
|
||||
}
|
||||
public void setYawColor(Color yawColor) {
|
||||
this.yawColor = yawColor;
|
||||
}
|
||||
|
||||
public void clearView() {
|
||||
values.clear();
|
||||
repaint();
|
||||
}
|
||||
public void clearView() {
|
||||
values.clear();
|
||||
repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated
|
||||
// Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
// <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
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
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
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@ import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
*/
|
||||
public class OrientationWiimoteEventPanel extends OrientationPanel {
|
||||
|
||||
@Override
|
||||
public Orientation getOrientationValue(GenericEvent e) {
|
||||
if (e instanceof MotionSensingEvent) {
|
||||
return ((MotionSensingEvent) e).getOrientation();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Orientation getOrientationValue(GenericEvent e) {
|
||||
if (e instanceof MotionSensingEvent) {
|
||||
return ((MotionSensingEvent) e).getOrientation();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user