コード例 #1
0
  private boolean saveBank(boolean inAskForFile) {
    boolean saved = false;

    if (inAskForFile || this.file == null) {
      File tempFile = ControlWindow.getFileForSave(this, "Save", null);

      if (tempFile != null) {
        this.file = tempFile;
      }
    }

    if (this.file != null) {
      FileOutputStream fos = null;

      try {
        fos = new FileOutputStream(this.file);
        this.bank.write(fos);

        setBankModified(false);
        saved = true;
      } catch (Exception inException) {
        ControlWindow.getInstance().showErrorDialog("Error", inException);
      } finally {
        if (fos != null) {
          try {
            fos.close();
          } catch (Exception inException) {
          }
        }
      }
    }

    return saved;
  }
コード例 #2
0
ファイル: ControlFrame.java プロジェクト: PointerLabs/osp
 public void setDefaultValue(int _index) {
   switch (_index) {
     case 0: // title
       String ejsWindow = getProperty("_ejs_window_"); // $NON-NLS-1$
       if (ejsWindow != null) {
         frame.setTitle(ejsWindow);
       } else {
         frame.setTitle(""); // $NON-NLS-1$
       }
       break;
     case 1:
       frame.setResizable(true);
       break;
     case 2: // exit
       if (getProperty("_ejs_") == null) { // $NON-NLS-1$
         frame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
       }
       break;
     case 3:
       removeAction(ControlElement.ACTION, getProperty("onExit")); // $NON-NLS-1$
       break;
     case NAME: // Overrides ControlElement's 'name'
       super.setDefaultValue(ControlWindow.NAME);
       if ((getGroup() != null) && (getGroup().getOwnerFrame() == getComponent())) {
         getGroup().setOwnerFrame(frame);
       }
     default:
       super.setDefaultValue(_index - 4);
       break;
   }
 }
コード例 #3
0
  public T setMouseOver(boolean theFlag) {

    mouseover = theFlag;
    if (!mouseover) {
      isInside = false;
      isInsideGroup = false;
      _myControlWindow.removeMouseOverFor(this);
      for (int i = controllers.size() - 1; i >= 0; i--) {
        controllers.get(i).setMouseOver(false);
      }
    } else {
      // TODO since inside can be either isInside or isInsideGroup, there are 2 options here,
      // which i am not sure how to handle them yet.
      _myControlWindow.setMouseOverController(this);
    }
    return me;
  }
コード例 #4
0
  /** removes the group from controlP5. */
  public void remove() {
    _myControlWindow.removeMouseOverFor(this);
    if (_myParent != null) {
      _myParent.remove(this);
    }
    if (cp5 != null) {
      cp5.remove(this);
    }

    for (int i = controllers.size() - 1; i >= 0; i--) {
      controllers.get(i).remove();
    }
    controllers.clear();
    controllers.clearDrawable();
    controllers = new ControllerList();
    if (this instanceof Tab) {
      _myControlWindow.removeTab((Tab) this);
    }
  }
コード例 #5
0
ファイル: ControlFrame.java プロジェクト: PointerLabs/osp
 // ------------------------------------------------
 // Set and Get the values of the properties
 // ------------------------------------------------
 public void setValue(int _index, Value _value) {
   switch (_index) {
     case 0: // title
       String ejsWindow = getProperty("_ejs_window_"); // $NON-NLS-1$
       if (ejsWindow != null) {
         frame.setTitle(_value.getString() + " " + ejsWindow); // $NON-NLS-1$
       } else {
         frame.setTitle(_value.getString());
       }
       break;
     case 1:
       frame.setResizable(_value.getBoolean());
       break;
     case 2: // exit
       if (getProperty("_ejs_") == null) { // $NON-NLS-1$
         if (_value.getBoolean()) {
           frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         } else {
           frame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
         }
       }
       break;
     case 3: // action
       removeAction(ControlElement.ACTION, getProperty("onExit")); // $NON-NLS-1$
       addAction(ControlElement.ACTION, _value.getString());
       break;
     case NAME: // Overrides ControlElement's 'name'
       super.setValue(ControlWindow.NAME, _value);
       if ((getGroup() != null) && (getGroup().getOwnerFrame() == getComponent())) {
         String replacement = getGroup().getReplaceOwnerName();
         if ((replacement != null) && replacement.equals(_value.getString())) {
           getGroup().setOwnerFrame(getGroup().getReplaceOwnerFrame());
         } else {
           getGroup().setOwnerFrame(frame);
         }
       }
       break;
     default:
       super.setValue(_index - 4, _value);
       break;
   }
 }
コード例 #6
0
  public void mouseClicked(MouseEvent inEvent) {
    if (inEvent.getClickCount() == 2) {
      ControlWindow controlWindow = ControlWindow.getInstance();

      if (controlWindow.getPatchWindow() != null) {
        // close the patch window - will confirm write if dirty
        PatchWindow patchWindow = controlWindow.getPatchWindow();

        // this sets the control window's patch window to null
        // which we'll check for in a second
        patchWindow.setVisible(false);
      }

      if (controlWindow.getPatchWindow() == null) {
        if (!this.bankInProphet) {
          // allow the user to override our flag
          int response =
              ControlWindow.showConfirmDialog(
                  "Confirm",
                  "This bank is not in the Prophet. OK to open patch editing windows anyway?");

          if (response == JOptionPane.YES_OPTION) {
            setBankInProphet(true);
          }
        }

        if (this.bankInProphet) {
          int row = this.table.rowAtPoint(inEvent.getPoint());
          int column = this.table.columnAtPoint(inEvent.getPoint());

          if (row != -1 && column != -1) {
            int patchNumber = (row * kTableColumnCount) + column;

            boolean openEditor = true;

            // send a program change to the selected patch
            try {
              // enable all MIDI parameter options
              ControlWindow.getInstance().sendMidiMessage(Machine.makeEnableParametersMessage());

              // change to the right patch
              ControlWindow.getInstance().sendMidiProgramChange(patchNumber);
            } catch (Exception inException) {
              inException.printStackTrace(System.err);
              openEditor = false;
            }

            // if we had an error sending the midi, confirm the editor window open
            if (!openEditor) {
              int response =
                  JOptionPane.showConfirmDialog(
                      this,
                      "Could not send program change to Prophet. OK to open editor window?",
                      "Confirm",
                      JOptionPane.YES_NO_OPTION);

              openEditor = (response == JOptionPane.YES_OPTION);
            }

            if (openEditor) {
              try {
                Patch patch = this.bank.getPatchCopy(patchNumber);
                PatchWindow patchWindow = new PatchWindow(this, this.document, patch);
                ControlWindow.getInstance().setPatchWindow(patchWindow);
                patchWindow.setLocationRelativeTo(null);
                patchWindow.setVisible(true);
              } catch (Exception inException) {
                inException.printStackTrace(System.err);
                ControlWindow.showErrorDialog("Error", inException);
              }
            }
          }
        }
      }
    }
  }
コード例 #7
0
  public void actionPerformed(ActionEvent inEvent) {
    String actionCommand = inEvent.getActionCommand();

    if (actionCommand.equalsIgnoreCase("KEYBOARD_CLOSE_ACTION")) {
      setVisible(false);

      if (!isVisible()) {
        dispose();
      }
    } else if (actionCommand.equalsIgnoreCase("SAVE")
        || actionCommand.equalsIgnoreCase("SAVE_AS")) {
      boolean askForFile = false;

      if (actionCommand.equalsIgnoreCase("SAVE_AS")) {
        askForFile = true;
      } else {
        if (this.file == null) {
          askForFile = true;
        }
      }

      saveBank(askForFile);
    } else if (actionCommand.equalsIgnoreCase("SEND_BANK")) {
      int response =
          ControlWindow.getInstance()
              .showConfirmDialog("Transmit", "OK to overwrite bank in Prophet?");

      if (response == JOptionPane.YES_OPTION) {
        try {
          ControlWindow.getInstance().sendMidiMessage(Machine.makeBankDumpMessage(this.bank));

          // this bank is now in the Prophet
          setBankInProphet(true);
        } catch (Exception inException) {
          ControlWindow.getInstance().showErrorDialog("Error", inException);
        }
      }
    } else if (actionCommand.equalsIgnoreCase("SEND_PATCH")) {
      int row = this.table.getSelectedRow();
      int column = this.table.getSelectedColumn();

      if (row == -1 || column == -1) {
        ControlWindow.getInstance()
            .showErrorDialog("Error", "Please select a patch location to send.");
      } else {
        int patchNumber = (row * kTableColumnCount) + column;
        Patch patch = this.bank.getPatch(patchNumber);

        StringBuffer buffer = new StringBuffer();
        buffer.append("OK to overwrite patch ");
        buffer.append(patch.getPatchNumber());
        buffer.append(" in Prophet?");

        int response = ControlWindow.getInstance().showConfirmDialog("Transmit", buffer.toString());

        if (response == JOptionPane.YES_OPTION) {
          try {
            ControlWindow.getInstance().sendMidiMessage(Machine.makePatchDumpMessage(patch));
          } catch (Exception inException) {
            ControlWindow.getInstance().showErrorDialog("Error", inException);
          }
        }
      }
    } else if (actionCommand.equalsIgnoreCase("VARY")) {
      int row = this.table.getSelectedRow();
      int column = this.table.getSelectedColumn();

      if (row == -1 || column == -1) {
        ControlWindow.getInstance()
            .showErrorDialog("Error", "Please select a patch location to vary.");
      } else {
        int patchNumber = (row * kTableColumnCount) + column;
        Patch patch = this.bank.getPatchCopy(patchNumber);
        VaryWindow varyWindow = new VaryWindow(patch);
        varyWindow.setLocationRelativeTo(null);
        varyWindow.setVisible(true);
      }
    } else if (actionCommand.equalsIgnoreCase("COPY")) {
      int row = this.table.getSelectedRow();
      int column = this.table.getSelectedColumn();

      if (row == -1 || column == -1) {
        ControlWindow.getInstance()
            .showErrorDialog("Error", "Please select a patch location to copy.");
      } else {
        int patchNumber = (row * kTableColumnCount) + column;
        Patch patch = this.bank.getPatchCopy(patchNumber);
        TransferablePatch transferable = new TransferablePatch(patch);
        Toolkit.getDefaultToolkit().getSystemClipboard().setContents(transferable, this);
      }
    } else if (actionCommand.equalsIgnoreCase("PASTE")) {
      int row = this.table.getSelectedRow();
      int column = this.table.getSelectedColumn();

      if (row == -1 || column == -1) {
        ControlWindow.getInstance()
            .showErrorDialog("Error", "Please select a patch location to paste.");
      } else {
        int patchNumber = (row * kTableColumnCount) + column;

        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        Transferable transferable = clipboard.getContents(this);

        if (transferable != null) {
          DataFlavor flavour = new DataFlavor(Patch.class, "Prophet VS Patch");

          try {
            Object data = transferable.getTransferData(flavour);

            if (data != null && data instanceof Patch) {
              Patch patch = (Patch) data;

              // copy the patch!
              // it might get pasted twice and this is only a reference
              Patch copy = new Patch(patch);

              // override the patch number in the patch
              // so it goes in the right place
              copy.setPatchNumber(patchNumber);
              setPatch(copy);
            }
          } catch (Exception inException) {
            System.err.println(inException);
          }
        }
      }
    } else if (actionCommand.equalsIgnoreCase("SWAP_PASTE")) {
      // this is a nondestructive paste which swaps the selection & paste buffer

      int row = this.table.getSelectedRow();
      int column = this.table.getSelectedColumn();

      if (row == -1 || column == -1) {
        ControlWindow.getInstance()
            .showErrorDialog("Error", "Please select a patch location to swap paste.");
      } else {
        int patchNumber = (row * kTableColumnCount) + column;

        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        Transferable transferable = clipboard.getContents(this);

        if (transferable != null) {
          DataFlavor flavour = new DataFlavor(Patch.class, "Prophet VS Patch");

          try {
            Object data = transferable.getTransferData(flavour);

            if (data != null && data instanceof Patch) {
              Patch pastePatch = (Patch) data;

              // ok now copy the selection into the clipboard
              Patch copyPatch = this.bank.getPatchCopy(patchNumber);
              transferable = new TransferablePatch(copyPatch);
              Toolkit.getDefaultToolkit().getSystemClipboard().setContents(transferable, this);

              // and now paste the saved patch into place
              // override the patch number in the patch
              // so it goes in the right place
              pastePatch.setPatchNumber(patchNumber);
              setPatch(pastePatch);
            }
          } catch (Exception inException) {
            System.err.println(inException);
          }
        }
      }
    }
  }
コード例 #8
0
ファイル: Tooltip.java プロジェクト: poqudrof/Skatolo
  /** @param theWindow */
  void draw(ControlWindow theWindow) {
    // System.out.println(previousPosition+"\t"+currentPosition+"\t"+position);
    if (enabled) {

      if (mode >= Skatolo.WAIT) {

        previousPosition.set(currentPosition);
        currentPosition.set(theWindow.getPointerX(), theWindow.getPointerY(), 0);

        if (controller != null) {
          if (controller.getControlWindow().equals(theWindow)) {
            switch (mode) {
              case (Skatolo.WAIT):
                if (moved()) {
                  startTime = System.nanoTime();
                }

                if (System.nanoTime() > startTime + (delayInMillis * 1000000)) {

                  position.set(currentPosition);
                  alignH = Skatolo.RIGHT;
                  if (position.x
                      > (controller.getControlWindow().papplet().width - (getWidth() + 20))) {
                    position.sub(new PVector(getWidth(), 0, 0));
                    alignH = Skatolo.LEFT;
                  }
                  mode = Skatolo.FADEIN;
                  startTime = System.nanoTime();
                  currentAlpha = 0;
                }
                break;
              case (Skatolo.FADEIN):
                float t1 = System.nanoTime() - startTime;
                currentAlpha = (int) PApplet.map(t1, 0, 200 * 1000000, 0, maxAlpha);
                if (currentAlpha >= 250) {
                  mode = Skatolo.IDLE;
                  currentAlpha = 255;
                }
                break;
              case (Skatolo.IDLE):
                break;
              case (Skatolo.FADEOUT):
                float t2 = System.nanoTime() - startTime;
                currentAlpha = (int) PApplet.map(t2, 0, 200 * 1000000, maxAlpha, 0);
                if (currentAlpha <= 0) {
                  mode = Skatolo.DONE;
                }
                break;
              case (Skatolo.DONE):
                controller = null;
                mode = Skatolo.INACTIVE;
                position.set(-1000, -1000, 0);
            }

            currentAlpha = PApplet.max(0, PApplet.min(currentAlpha, maxAlpha));

            if (mode >= Skatolo.WAIT) {
              currentAlpha = (mode == Skatolo.WAIT) ? 0 : currentAlpha;
              theWindow.graphics().pushMatrix();
              theWindow.graphics().translate(position.x, position.y);
              theWindow.graphics().translate(offset.x, offset.y);
              controllerView.display(theWindow.graphics(), null); // TODO: Warning HERE !
              theWindow.graphics().popMatrix();
            }
            if (mode < Skatolo.FADEOUT) {
              if (moved()) {
                deactivate(0);
              }
            }
          }
        }
      }
    }
  }
コード例 #9
0
 public final T moveTo(ControlWindow theControlWindow, String theTabName) {
   moveTo(null, theControlWindow.getTab(theTabName), theControlWindow);
   return me;
 }
コード例 #10
0
 public T moveTo(ControlWindow theControlWindow) {
   moveTo(null, theControlWindow.getTab("default"), theControlWindow);
   return me;
 }
コード例 #11
0
ファイル: Tooltip.java プロジェクト: ramonrovirosa/MAT_259
  /** @param theWindow */
  void draw(ControlWindow theWindow) {
    if (enabled) {

      if (_myMode >= ControlP5.WAIT) {

        previousPosition.set(currentPosition);
        currentPosition.set(theWindow.mouseX, theWindow.mouseY, 0);

        if (_myController != null) {
          if (_myController.getControlWindow().equals(theWindow)) {
            switch (_myMode) {
              case (ControlP5.WAIT):
                if (moved()) {
                  startTime = System.nanoTime();
                }

                if (System.nanoTime() > startTime + (_myDelayInMillis * 1000000)) {

                  position.set(currentPosition);
                  _myAlignH = ControlP5.RIGHT;
                  if (position.x
                      > (_myController.getControlWindow().papplet().width - (getWidth() + 20))) {
                    position.sub(new PVector(getWidth(), 0, 0));
                    _myAlignH = ControlP5.LEFT;
                  }
                  _myMode = ControlP5.FADEIN;
                  startTime = System.nanoTime();
                  _myAlpha = 0;
                }
                break;
              case (ControlP5.FADEIN):
                float t1 = System.nanoTime() - startTime;
                _myAlpha = (int) PApplet.map(t1, 0, 200 * 1000000, 0, _myMaxAlpha);
                if (_myAlpha >= 250) {
                  _myMode = ControlP5.IDLE;
                  _myAlpha = 255;
                }
                break;
              case (ControlP5.IDLE):
                break;
              case (ControlP5.FADEOUT):
                float t2 = System.nanoTime() - startTime;
                _myAlpha = (int) PApplet.map(t2, 0, 200 * 1000000, _myMaxAlpha, 0);
                if (_myAlpha <= 0) {
                  _myMode = ControlP5.DONE;
                }
                break;
              case (ControlP5.DONE):
                _myController = null;
                _myMode = ControlP5.INACTIVE;
                position.set(-1000, -1000, 0);
            }

            _myAlpha = PApplet.max(0, PApplet.min(_myAlpha, _myMaxAlpha));

            if (_myMode >= ControlP5.WAIT) {
              _myAlpha = (_myMode == ControlP5.WAIT) ? 0 : _myAlpha;
              theWindow.papplet().pushMatrix();
              theWindow.papplet().translate(position.x, position.y);
              theWindow.papplet().translate(offset.x, offset.y);
              _myView.display(theWindow.papplet(), null);
              theWindow.papplet().popMatrix();
            }
            if (_myMode < ControlP5.FADEOUT) {
              if (moved()) {
                deactivate(0);
              }
            }
          }
        }
      }
    }
  }
コード例 #12
0
  /**
   * Constructor.
   *
   * @param sto output marshaller
   */
  public CurrentSavePanel(StarTableOutput sto) {
    super("Current Table", TableSaveChooser.makeFormatBoxModel(sto, false));
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    final JList tablesList = ControlWindow.getInstance().getTablesList();

    /* Ensure displayed table is always the TOPCAT current table. */
    tablesList.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent evt) {
            setDisplayedTable((TopcatModel) tablesList.getSelectedValue());
          }
        });

    /* Ensure that current table characteristics are always up to date. */
    tcListener_ =
        new TopcatListener() {
          public void modelChanged(TopcatEvent evt) {
            TopcatModel tcModel = evt.getModel();
            assert tcModel == tcModel_;
            int code = evt.getCode();
            if (code == TopcatEvent.LABEL) {
              updateNameField(tcModel);
            } else if (code == TopcatEvent.CURRENT_SUBSET) {
              updateRowsField(tcModel);
              updateSubsetField(tcModel);
            } else if (code == TopcatEvent.CURRENT_ORDER) {
              updateOrderField(tcModel);
            }
          }
        };
    colListener_ =
        new TableColumnModelListener() {
          public void columnAdded(TableColumnModelEvent evt) {
            updateColsField(tcModel_);
          }

          public void columnRemoved(TableColumnModelEvent evt) {
            updateColsField(tcModel_);
          }

          public void columnMoved(TableColumnModelEvent evt) {}

          public void columnMarginChanged(ChangeEvent evt) {}

          public void columnSelectionChanged(ListSelectionEvent evt) {}
        };

    /* Place components. */
    setLayout(new BorderLayout());
    LabelledComponentStack stack = new LabelledComponentStack();
    Font inputFont = stack.getInputFont();
    add(stack, BorderLayout.NORTH);
    nameField_ = new JLabel();
    subsetField_ = new JLabel();
    orderField_ = new JLabel();
    colsField_ = new JLabel();
    rowsField_ = new JLabel();
    nameField_.setFont(inputFont);
    subsetField_.setFont(inputFont);
    orderField_.setFont(inputFont);
    colsField_.setFont(inputFont);
    rowsField_.setFont(inputFont);
    stack.addLine("Table", nameField_);
    stack.addLine("Current Subset", subsetField_);
    stack.addLine("Sort Order", orderField_);

    /* I thought this might be a good idea, but probably it's too much
     * information. */
    if (false) {
      stack.addLine("Columns", colsField_);
      stack.addLine("Rows", rowsField_);
    }
    setDisplayedTable((TopcatModel) tablesList.getSelectedValue());
  }
コード例 #13
0
 /**
  * move a canvas to another controlWindow
  *
  * @param theControlWindow
  */
 public void moveTo(ControlWindow theControlWindow) {
   if (_myControlWindow != null) {
     _myControlWindow.removeCanvas(this);
   }
   theControlWindow.addCanvas(this);
 }
コード例 #14
0
ファイル: PAppletWindow.java プロジェクト: JelteF/project_bpm
 /*
  * (non-Javadoc)
  */
 public void windowClosing(WindowEvent e) {
   controlWindow.remove();
   controlWindow._myApplet.stop();
   dispose();
 }
コード例 #15
0
ファイル: PAppletWindow.java プロジェクト: JelteF/project_bpm
 /*
  * (non-Javadoc)
  */
 public void play() {
   controlWindow.isAutoDraw = true;
 }
コード例 #16
0
ファイル: PAppletWindow.java プロジェクト: JelteF/project_bpm
 /*
  * (non-Javadoc)
  */
 public void pause() {
   controlWindow.isAutoDraw = false;
 }