/** * Create a new board * * @param c */ public Board(Game c) { // add leap motion controller leapAdapter = new SensorAdapter(c); sensorListener = new SensorListener(leapAdapter); shootListener = new ShootListener(leapAdapter); leapController = new Controller(); leapController.addListener(sensorListener); leapController.addListener(shootListener); addKeyListener(new KeyboardAdapter(c, this)); this.menu = new Menu(this, c); setFocusable(true); setDoubleBuffered(true); this.c = c; c.setPlayer(ItemFactory.createPlayer()); c.setBackground(ItemFactory.createBackground()); }
public RotatableCanvas(Object parent, AlignViewport av, Controller c, Vector points, int npoint) { this.parent = parent; this.points = points; this.npoint = npoint; this.controller = c; this.av = av; controller.addListener(this); prefsize = getPreferredSize(); orig = new float[npoint][3]; for (int i = 0; i < npoint; i++) { SequencePoint sp = (SequencePoint) points.elementAt(i); for (int j = 0; j < 3; j++) { orig[i][j] = sp.coord[j]; } } // Initialize the matrices to identity for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { if (i != j) { idmat.addElement(i, j, 0); objmat.addElement(i, j, 0); rotmat.addElement(i, j, 0); } else { idmat.addElement(i, j, 0); objmat.addElement(i, j, 0); rotmat.addElement(i, j, 0); } } } axes = new float[3][3]; initAxes(); findCentre(); findWidth(); scale = findScale(); // System.out.println("Scale factor = " + scale); addMouseListener(this); addKeyListener(this); if (getParent() != null) { getParent().addKeyListener(this); } addMouseMotionListener(this); // Add rubberband rubberband = new RubberbandRectangle(this); rubberband.setActive(true); rubberband.addListener(this); }