Package ca.nengo.config.ui

Examples of ca.nengo.config.ui.MatrixEditor


     */

    final float[][] matrix = (float[][]) o;

    // Create Matrix Editor
    final MatrixEditor matrixEditor;
    {

      float[][] copy = new float[matrix.length][];
      for (int i = 0; i < matrix.length; i++) {
        copy[i] = new float[matrix[i].length];
        System.arraycopy(matrix[i], 0, copy[i], 0, matrix[i].length);
      }
      matrixEditor = new MatrixEditor(copy, false, false);
    }

    // Setup config listener's proxy
    {
      configListener.setProxy(new ConfigurationChangeListener.EditorProxy() {
        public Object getValue() {
          return matrixEditor.getMatrix();
        }
      });
    }
    return matrixEditor;
  }
View Full Code Here


  @Override
  public final Component getEditor(Object o,
      final ConfigurationChangeListener configListener,
      final JComponent parent) {

    final MatrixEditor matrixEditor = CreateMatrixEditor(o, configListener);

    // Create asynchronous modal dialog to edit the matrix
    //
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        final Container parentContainer = parent.getRootPane().getParent();

        final JDialog dialog = createDialog(parentContainer, matrixEditor);

        // Create buttons
        //
        // The matrix editor will not use the configListener as a
        // listener, but
        // conversely notify it of changes. This is because the Config
        // listener only support
        // one type of "save" event.
        //
        JButton okButton, cancelButton;
        {
          matrixEditor.getControlPanel().add(new JSeparator(JSeparator.VERTICAL));

          okButton = new JButton("Save Changes");
          matrixEditor.getControlPanel().add(okButton);
          okButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {
              matrixEditor.finishEditing();
              configListener.commitChanges();
              dialog.setVisible(false);
            }
          });

          cancelButton = new JButton("Cancel");
          matrixEditor.getControlPanel().add(cancelButton);
          cancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {
              configListener.cancelChanges();
              dialog.setVisible(false);
            }
          });
        }

        // Set preferred size
        {
          int desiredWidth = Math.min(matrixEditor.getColumnCount() * 70 + 100, 1024);
          desiredWidth = Math.max(desiredWidth, 600);

          int desiredHeight = Math.min(matrixEditor.getRowCount() * 30 + 150, 768);
          dialog.setPreferredSize(new Dimension(desiredWidth, desiredHeight));
        }

        dialog.pack();
        if (parentContainer != null) {
View Full Code Here

  }

  @Override
  public MatrixEditor CreateMatrixEditor(Object o,
      ConfigurationChangeListener configListener) {
    final MatrixEditor matrixEditor;
    {
      float[] copy;
      {
        float[] vector = (float[]) o;
        copy = new float[vector.length];
        System.arraycopy(vector, 0, copy, 0, vector.length);
      }

      matrixEditor = new MatrixEditor(new float[][] { copy }, true, false);

      configListener
          .setProxy(new ConfigurationChangeListener.EditorProxy() {
            public Object getValue() {
              return matrixEditor.getMatrix()[0];
            }
          });

      return matrixEditor;
    }
View Full Code Here

TOP

Related Classes of ca.nengo.config.ui.MatrixEditor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.