Пример #1
0
 private void playButtonActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_playButtonActionPerformed
   // change playing state to opposite
   playing = !playing;
   if (client) {
     menu.saveToServer();
     try {
       Thread.sleep(500);
     } catch (InterruptedException ex) {
       Logger.getLogger(VibcompUI.class.getName()).log(Level.SEVERE, null, ex);
     }
   }
 } // GEN-LAST:event_playButtonActionPerformed
Пример #2
0
  @Override
  public void keyPressed(KeyEvent ke) {
    // System.out.println("key pressed:"+ke.getKeyCode());
    if (ke.isControlDown()) {
      if (ke.getKeyCode() == 67) { // Ctrl+c = copy
        menu.copy();
      } else if (ke.getKeyCode() == 88) { // Ctrl+x = cut
        menu.copy();
        menu.delete();
      } else if (ke.getKeyCode() == 86) { // Ctrl+v = paste
        menu.paste();
      } else if (ke.getKeyCode() == 79) { // Ctrl+o = open
        menu.open();
      } else if (ke.getKeyCode() == 83) { // Ctrl+s = save
        menu.save();
      }
    }

    if (ke.getKeyCode() == 38) { // Up key
      for (Bead bead : multiSelect) {
        if (bead.getTrack() > 1) {
          bead.setTrack(bead.getTrack() - 1);
          bead.setLocation(bead.getX(), bead.getY() - beadPlayer1.TRACKHEIGHT);
        }
      }
    } else if (ke.getKeyCode() == 40) { // Down key
      for (Bead bead : multiSelect) {
        if (bead.getTrack() < 8) {
          bead.setTrack(bead.getTrack() + 1);
          bead.setLocation(bead.getX(), bead.getY() + beadPlayer1.TRACKHEIGHT);
        }
      }
    } else if (ke.getKeyCode() == 37) { // Left key
      for (Bead bead : multiSelect) {
        if (bead.getX() > 55) bead.setLocation(bead.getX() - beadPlayer1.BEADHEIGHT, bead.getY());
      }
    } else if (ke.getKeyCode() == 39) { // Right key
      for (Bead bead : multiSelect) {
        if (bead.getX() < 1000) bead.setLocation(bead.getX() + beadPlayer1.BEADHEIGHT, bead.getY());
      }
    } else if (ke.getKeyCode() == 127 || ke.getKeyCode() == 8) { // delete/backspace key
      menu.delete();
    }
  }
Пример #3
0
 private void openButtonActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_openButtonActionPerformed
   menu.open();
 } // GEN-LAST:event_openButtonActionPerformed
Пример #4
0
 private void saveButtonActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_saveButtonActionPerformed
   menu.save();
 } // GEN-LAST:event_saveButtonActionPerformed
Пример #5
0
  private void beadPlayer1MousePressed(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_beadPlayer1MousePressed
    /**
     * 2015-05-13
     *
     * <p>Update note. If a bead is already Connected to something, then the user can "Drag" to move
     * around the note.
     *
     * <p>One can overlap if s/he clicked on "offset margin"
     */
    point1 = evt.getPoint();
    Bead tmpBead = beadPlayer1.getBeadAt(point1.x, point1.y, beadPlayer1.page);

    if (evt.getButton() == MouseEvent.BUTTON1) // Left click
    {
      if (evt.isAltDown()) {
        if (isBeadPanelEmpty()) {
          refreshBeadPanel();
          beadPanelText.setVisible(true);
          activeBead.vibcompUI = this;

          Bead leftPossible = beadPlayer1.getBeadAt(point1.x - 27, point1.y, beadPlayer1.page);
          Bead rightPossible = beadPlayer1.getBeadAt(point1.x + 27, point1.y, beadPlayer1.page);
          if (leftPossible == null) { // If there exists no bead on the point's left
            if (rightPossible == null) {
              beadPlayer1.setBead(point1.x + 80, point1.y, activeBead);
            } else { // There is a bead on its right.
              beadPlayer1.setBead(rightPossible.getX() - 27, point1.y, activeBead);
            }
          } else if (rightPossible == null) { // There is a Bead on the left of clicked position.
            beadPlayer1.setBead(leftPossible.getX() + 80, point1.y, activeBead);
          }
        }
      }
      if (activeBead != null) {
        if (tmpBead == null) { // Create one
          beadPanelText.setVisible(true);
          activeBead.vibcompUI = this;
          Bead leftPossible = beadPlayer1.getBeadAt(point1.x - 27, point1.y, beadPlayer1.page);
          Bead rightPossible = beadPlayer1.getBeadAt(point1.x + 27, point1.y, beadPlayer1.page);
          if (leftPossible == null) { // If there exists no bead on the point's left
            if (rightPossible == null) {
              beadPlayer1.setBead(point1.x, point1.y, activeBead);
            } else { // There is a bead on its right.
              beadPlayer1.setBead(rightPossible.getX() - 27, point1.y, activeBead);
            }
          } else if (rightPossible == null) { // There is a Bead on the left of clicked position.
            beadPlayer1.setBead(leftPossible.getX() + 80, point1.y, activeBead);
          }
        } else { // There already is a bead at the location
          if (!activeBead.playable) {
            remove(activeBead); // Remove bead panel glitch
          } else {
            activeBead = tmpBead;
          }
        }
        // set slider positions
        intensitySlider.setValue(activeBead.getIntensity());
        frequencySlider.setValue(activeBead.getFrequency());

        // multi select
        if (evt.isShiftDown() || shiftOn) {
          if (multiSelect.contains(activeBead)) multiSelect.remove(activeBead);
          else multiSelect.add(activeBead);
        } else {
          multiSelect.clear();
        }
      } else if (beadPlayer1.beads.isEmpty()) {
        JOptionPane.showMessageDialog(
            null,
            "Please click 'New Bead' to create a Bead, then Click on then click on the canvas");
      } else if (activeBead == null && tmpBead != null) {
        activeBead = tmpBead;
      }
    }
    if (evt.getButton() == MouseEvent.BUTTON3
        || evt.getClickCount() == 2) { // Right click or double click
      if (tmpBead != null) {
        if (multiSelect.size() == 1) multiSelect.clear();
        multiSelect.add(tmpBead);
        activeBead = tmpBead;
      }
      menu.show(evt.getComponent(), evt.getX(), evt.getY());
    }
  } // GEN-LAST:event_beadPlayer1MousePressed