예제 #1
0
  private void init() {
    input = new JTextField[nInputs];

    double[] rowWeights =
        new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
    rowWeights[nInputs + 2] = 1.0;

    GridBagLayout gbl_functionPanel = new GridBagLayout();
    gbl_functionPanel.columnWidths = new int[] {5, 0, 50, 50, 30, 25, 5, 0};
    gbl_functionPanel.rowHeights = new int[] {10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10};
    gbl_functionPanel.columnWeights =
        new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
    gbl_functionPanel.rowWeights = rowWeights;
    this.setLayout(gbl_functionPanel);

    // Function input field.
    for (int i = 0; i < nInputs; i++) {
      // Creation.
      input[i] = new JTextField();
      GridBagConstraints gbc_stdFuncInput = new GridBagConstraints();
      gbc_stdFuncInput.gridwidth = 4;
      gbc_stdFuncInput.insets = new Insets(0, 0, 5, 5);
      gbc_stdFuncInput.fill = GridBagConstraints.HORIZONTAL;
      gbc_stdFuncInput.anchor = GridBagConstraints.NORTH;
      gbc_stdFuncInput.gridx = 2;
      gbc_stdFuncInput.gridy = i + 1;

      // Setup.
      GuiUtil.setupUndoListener(input[i]);
      setupInputListeners(input[i]);
      this.add(input[i], gbc_stdFuncInput);
    }

    // Labels for the input fields
    String[] labelNames = labelNames();
    for (int i = 0; i < labelNames.length; i++) {
      GridBagConstraints gbc_FuncLabel = new GridBagConstraints();
      gbc_FuncLabel.gridwidth = 1;
      gbc_FuncLabel.insets = new Insets(0, 0, 5, 5);
      gbc_FuncLabel.fill = GridBagConstraints.HORIZONTAL;
      gbc_FuncLabel.anchor = GridBagConstraints.CENTER;
      gbc_FuncLabel.gridx = 1;
      gbc_FuncLabel.gridy = i + 1;

      JLabel label = new JLabel(labelNames[i]);
      this.add(label, gbc_FuncLabel);
    }

    // OptionPanel.
    mainOP = new JPanel();
    mainOP.setBorder(BorderFactory.createEtchedBorder());
    GridBagConstraints gbc_mainOP = new GridBagConstraints();
    gbc_mainOP.fill = GridBagConstraints.BOTH;
    gbc_mainOP.gridwidth = 5;
    gbc_mainOP.insets = new Insets(0, 0, 5, 5);
    gbc_mainOP.gridx = 1;
    gbc_mainOP.gridy = nInputs + 1;
    this.add(mainOP, gbc_mainOP);

    gridOP = getGridOptionPanel();
    gridOP.addFunctionListener(createGridOptionPanelListener());
    apperanceOP = new AppearanceOptionPanel(colorList, map);
    mainOP.setLayout(new BoxLayout(mainOP, BoxLayout.Y_AXIS));
    mainOP.add((Component) gridOP);
    mainOP.add(apperanceOP);

    // The standard function list
    outerFuncTab = new JPanel();
    funcPanelWrapper = new JScrollPane(outerFuncTab);
    funcPanelWrapper.setBorder(BorderFactory.createEtchedBorder());
    funcPanelWrapper.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    funcPanelWrapper.setMinimumSize(new Dimension(310, 500));
    GridBagConstraints gbc_funcPanelWrapper = new GridBagConstraints();
    gbc_funcPanelWrapper.fill = GridBagConstraints.BOTH;
    gbc_funcPanelWrapper.gridwidth = 5;
    gbc_funcPanelWrapper.insets = new Insets(0, 0, 5, 5);
    gbc_funcPanelWrapper.gridx = 1;
    gbc_funcPanelWrapper.gridy = nInputs + 2;
    ;
    this.add(funcPanelWrapper, gbc_funcPanelWrapper);

    GridBagLayout gbl_stdFuncPanel = new GridBagLayout();
    gbl_stdFuncPanel.columnWidths = new int[] {0, 0};
    gbl_stdFuncPanel.rowHeights = new int[] {0, 0};
    gbl_stdFuncPanel.columnWeights = new double[] {1.0, Double.MIN_VALUE};
    gbl_stdFuncPanel.rowWeights = new double[] {1.0, Double.MIN_VALUE};
    outerFuncTab.setLayout(gbl_stdFuncPanel);

    innerFuncTab = new JPanel();
    GridBagConstraints gbc_innerFuncPanel = new GridBagConstraints();
    gbc_innerFuncPanel.anchor = GridBagConstraints.NORTH;
    gbc_innerFuncPanel.fill = GridBagConstraints.HORIZONTAL;
    gbc_innerFuncPanel.gridx = 0;
    gbc_innerFuncPanel.gridy = 0;
    outerFuncTab.add(innerFuncTab, gbc_innerFuncPanel);
    innerFuncTab.setLayout(new BoxLayout(innerFuncTab, BoxLayout.Y_AXIS));
  }
예제 #2
0
 public void updateReferences(Function f) throws IllegalExpressionException {
   gridOP.updateFuncReference(f);
   apperanceOP.updateFuncReference(f);
 }