Exemple #1
0
  public SimpleWhiteboard(MultitouchFramework mf, GraphicsWrapper gw) {
    multitouchFramework = mf;
    this.gw = gw;
    multitouchFramework.setPreferredWindowSize(
        Constant.INITIAL_WINDOW_WIDTH, Constant.INITIAL_WINDOW_HEIGHT);

    userContexts = new UserContext[Constant.NUM_USERS];
    for (int j = 0; j < Constant.NUM_USERS; ++j) {
      userContexts[j] = new UserContext(drawing);
    }
    // initialize the positions of the palettes
    if (Constant.NUM_USERS == 1) {
      userContexts[0].setPositionOfCenterOfPalette(
          Constant.INITIAL_WINDOW_WIDTH / 2, Constant.INITIAL_WINDOW_HEIGHT / 2);
    } else {
      // Compute a circular layout of the palettes
      float radius = Math.min(Constant.INITIAL_WINDOW_WIDTH, Constant.INITIAL_WINDOW_HEIGHT) / 4;
      for (int j = 0; j < Constant.NUM_USERS; ++j) {
        float angleInRadians = (float) (2 * Math.PI * j / Constant.NUM_USERS);
        userContexts[j].setPositionOfCenterOfPalette(
            Constant.INITIAL_WINDOW_WIDTH / 2 + (float) (radius * Math.cos(angleInRadians)),
            Constant.INITIAL_WINDOW_HEIGHT / 2 + (float) (radius * Math.sin(angleInRadians)));
      }
    }

    gw.setFontHeight(Constant.TEXT_HEIGHT);

    gw.frame(new AlignedRectangle2D(new Point2D(-100, -100), new Point2D(100, 100)), true);
  }
Exemple #2
0
 public void actionPerformed(ActionEvent e) {
   Object source = e.getSource();
   if (source == testMenuItem1) {
     System.out.println("testMenuItem1 has been selected");
   } else if (source == testMenuItem2) {
     System.out.println("testMenuItem2 has been selected");
   } else if (source == frameAllButton) {
     gw.frame(drawing.getBoundingRectangle(), true);
     multitouchFramework.requestRedraw();
   } else if (source == testButton1) {
     System.out.println("testButton1 has been selected");
   } else if (source == testButton2) {
     System.out.println("testButton2 has been selected");
   }
 }
Exemple #3
0
  public synchronized void processMultitouchInputEvent(int id, float x, float y, int type) {
    // System.out.println("event: "+id+", "+x+", "+y+", "+type);

    int indexOfUserContext = findIndexOfUserContextForMultitouchInputEvent(id, x, y);

    boolean doOtherUserContextsHaveCursors = false;
    for (int j = 0; j < Constant.NUM_USERS; ++j) {
      if (j != indexOfUserContext && userContexts[j].hasCursors()) {
        doOtherUserContextsHaveCursors = true;
        break;
      }
    }

    boolean redrawRequested =
        userContexts[indexOfUserContext].processMultitouchInputEvent(
            id, x, y, type, gw, doOtherUserContextsHaveCursors);
    if (redrawRequested) multitouchFramework.requestRedraw();
  }