예제 #1
0
      public void update(MouseEvent e) {
        mouseReleased = e.getX();
        Selection currSelection = zoomStack.get(zoomStack.size() - 1);

        if (mousePressed > mouseReleased) {
          selBeginPixel = mouseReleased;
          selEndPixel = mousePressed;
        } else {
          selBeginPixel = mousePressed;
          selEndPixel = mouseReleased;
        }

        if (selBeginPixel < 1) selBeginPixel = 1;

        if (selEndPixel > frameWidth) {
          selEndPixel = frameWidth;
        }

        selBeginSample = (int) Math.floor(selBeginPixel * samplePerPixel);
        selEndSample = (int) Math.floor(selEndPixel * samplePerPixel);

        //				//stopped dragging outside the window.
        //				if(selEndSample > currSelection.endSelInSamples) {
        //
        //				//System.err.println(selEndSample + " " + data.size());
        //					selEndSample = currSelection.endSelInSamples;
        //				}
        //
        //				//stopped dragging outside the window
        //				if(selBeginSample < currSelection.beginSelInSamples)
        //					selBeginSample = currSelection.beginSelInSamples;

        wavePanel.repaint();

        if (!myHelper.isPlaying()) {
          playSelectionBtn.setEnabled(true);

          if (points.size() > zoomStop) {
            zoomInBtn.setEnabled(true);
          }
        }
        if (DEBUG) System.err.println(selBeginSample + " " + selEndSample);
      }
예제 #2
0
 public void mouseMoved(MouseEvent e) {
   mX = e.getX();
   mY = e.getY();
 }
예제 #3
0
 public void mousePressed(MouseEvent e) {
   mousePressed = e.getX();
 }
예제 #4
0
  @Override
  public void mousePressed(MouseEvent e) {
    CustomButton buttonPressed; // Button that was pressed.
    String buttonName; // The name of the button.
    int option; // Option chosen by user.
    User buyer; // User object for buyer
    User seller; // User object for seller
    Item selected_item; // Item object for selected item

    if (help) // if in help mode
    {
      help = false;
      repaint();
      return;
    }

    wasItemSelected(e.getX(), e.getY());
    buttonPressed = CustomButton.wasPressed(e.getX(), e.getY());

    if (buttonPressed == null) // if no button was pressed
    {
      return;
    }

    buttonName = buttonPressed.getName();
    playAudio(-1);

    switch (buttonName) // handle event associated with button name
    {
      case "rightTab":
        currentPage++;
        itemSelected = -1;
        break;

      case "leftTab":
        currentPage--;
        itemSelected = -1;
        break;

      case "buyTab":
        mode = false;
        break;

      case "sellTab":
        mode = true;
        break;

      case "button":
        selected_item = itemsArray[itemSelected];

        option =
            JOptionPane.showConfirmDialog(
                this, ((!mode) ? "Buy " : "Sell ") + "for " + "$" + selected_item.getPrice() + "?");

        if (option == 0 && (!mode)) // if they choose to buy
        {
          buyer = usersArray[0];
          switch (store) // change message based on value of store.
          {
            case 0:
              seller = usersArray[2];
              break;

            case 1:
              seller = usersArray[1];
              break;

            case 2:
              seller = usersArray[3];
              break;

            case 3:
              seller = usersArray[4];
              break;

            default:
              seller = usersArray[1];
          }

          buyItemFromUser(buyer, seller, selected_item);

        } else if (option == 0 && mode) // if they choose to sell
        {
          seller = usersArray[0];

          switch (store) // change message based on value of store.
          {
            case 0:
              buyer = usersArray[2];
              break;

            case 1:
              buyer = usersArray[1];
              break;

            case 2:
              buyer = usersArray[3];
              break;

            case 3:
              buyer = usersArray[4];
              break;

            default:
              buyer = usersArray[1];
          }

          buyItemFromUser(buyer, seller, selected_item);
        }

        itemSelected = -1;
        break;

      case "nextStore":
        if (++store == NUMSTORES) // if we're on the last store, loop around
        {
          store = 0;
        }

        switchStore(store);
        break;

      case "sort":
        // something
        orderToSort =
            JOptionPane.showOptionDialog(
                this,
                "Sort by:",
                "Sort",
                JOptionPane.DEFAULT_OPTION,
                JOptionPane.QUESTION_MESSAGE,
                null,
                SORTOPTIONS,
                null);

        break;

      case "help":
        help = true;
        break;

      default:
    }

    repaint();
  }