Example #1
0
 public void paint(Graphics g) {
   if (pointListener.isListening()) {
     drawGadgets(g);
     drawFingers(g);
   }
   if (gadgetSetup != null) {
     drawSetup(g);
   }
   repaint();
 }
Example #2
0
 /**
  * Draws all the fingers on the graphics object using the normalized points stored in the
  * PointListener
  *
  * @param g Graphics object used for drawing
  */
 public void drawFingers(Graphics g) {
   g.setColor(Color.green);
   Vector fingerPosition = pointListener.getNormalizedFingerPosition();
   if (fingerPosition == null) {
     return;
   }
   float circleX = getWidth() * fingerPosition.getX();
   float circleY = getHeight() * (1 - fingerPosition.getY());
   float radius = getWidth() * FINGER_RADIUS_RATIO;
   drawCircle(g, (int) circleX, (int) circleY, (int) radius);
 }
Example #3
0
 /**
  * Custom method for painting all the current gadgets that the PointListener listens to
  *
  * @param g The graphics object to draw to
  */
 public void drawGadgets(Graphics g) {
   g.setColor(Color.red);
   ArrayList<ScreenGadget> myScreenGadgets = pointListener.getScreenGadgets();
   for (ScreenGadget curGadget : myScreenGadgets) {
     Vector topLeft = curGadget.getNormalizedTopLeft();
     Vector bottomRight = curGadget.getNormalizedBottomRight();
     if (topLeft == null || bottomRight == null) {
       continue;
     }
     float nLX = getWidth() * curGadget.getNormalizedTopLeft().getX();
     // Subtract Y-Coordinate from 1 because (0,0) is top left in application window
     float nLY = getHeight() * (1 - curGadget.getNormalizedTopLeft().getY());
     float nRX = getWidth() * curGadget.getNormalizedBottomRight().getX();
     float nRY = getHeight() * (1 - curGadget.getNormalizedBottomRight().getY());
     g.drawRect((int) nLX, (int) nLY, (int) (nRX - nLX), (int) (nRY - nLY));
   }
 }