예제 #1
0
 /**
  * Gets called when clicking the save button. Puts data back into Worker and fires
  * ListSelectionEvent in Worker, so that the 3D View is updated.
  */
 public void save() {
   short[] tmpFrame = frame;
   changedStateSinceSave = false;
   short reihe = 0;
   for (int j = 0; j < 8; j++) {
     for (int i = 0; i < 8; i++) {
       reihe += ((short) Math.pow(2, i)) * ledStatus[i][j];
     }
     tmpFrame[(8 * (li + 1) + j) - 8] = reihe;
     reihe = 0;
   }
   frame = tmpFrame;
   worker.getAnimation(animI).getFrame(frameI).setData(frame);
   ListSelectionEvent layerChanged =
       new ListSelectionEvent(
           LedFrame.frameList,
           LedFrame.frameList.getSelectedIndex(),
           LedFrame.frameList.getSelectedIndex(),
           false);
   LedFrame.valueChanged(layerChanged);
   dispose();
 }
예제 #2
0
  /**
   * Create a new layer editor.
   *
   * @param animIndex Current animation
   * @param frameIndex Current frame
   * @param layerIndex Layer to edit
   * @param work the cubeWorker containing the data
   * @param LEDframe Used to call valueChanged, to trigger 3D View update
   */
  public layerEditFrame(
      int animIndex, int frameIndex, int layerIndex, cubeWorker work, Frame LEDframe) {
    // Frame-Initialisierung
    super("Layer Edit");
    worker = work;
    LedFrame = LEDframe;
    animI = animIndex;
    frameI = frameIndex;
    // frame = byteToShortArray(worker.getFrame(animIndex, frameIndex));
    frame = worker.getAnimation(animIndex).getFrame(frameIndex).getData();
    li = layerIndex;
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    int frameWidth = 180;
    int frameHeight = 230;
    setSize(frameWidth, frameHeight);
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (d.width - getSize().width) / 2;
    int y = (d.height - getSize().height) / 2;
    setLocation(x, y);
    setResizable(false);
    Container cp = getContentPane();
    cp.setLayout(null);

    for (int i = 0; i < 8; i++) {
      for (int j = 0; j < 8; j++) {
        final int finalI = i;
        final int finalJ = j;
        ledPanels[i][j] = new JButton(on);
        ledPanels[i][j].setBounds((i * 20) + 5, (j * 20) + 5, 15, 15);
        ledPanels[i][j].addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent evt) {
                btnClicked(finalI, finalJ);
              }
            });
        ledPanels[i][j].setVisible(true);
        cp.add(ledPanels[i][j]);
      }
    }
    loadData();
    JButton saveBtn = new JButton("Save");
    JButton cancelBtn = new JButton("Cancel");

    saveBtn.setBounds(5, 170, 70, 25);
    saveBtn.setFont(new Font("Dialog", Font.PLAIN, 13));
    cp.add(saveBtn);
    cancelBtn.setBounds(80, 170, 80, 25);
    cancelBtn.setFont(new Font("Dialog", Font.PLAIN, 13));
    cp.add(cancelBtn);
    setVisible(true);

    saveBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            save();
          }
        });

    cancelBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            cancel();
          }
        });

    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent evt) {
            if (changedStateSinceSave) {
              saveExitDialog();
            }
            dispose();
          }
        });
  }