Package ketUI

Source Code of ketUI.OperandMenuFrame

/*
* Copyright (C) 2011  Alasdair C. Hamilton
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>
*/

package ketUI;

import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.border.*;


import geom.Position;
import ket.MathCollection;
import ket.Selection;
import ket.display.ImageTools;
import ket.math.Argument;
import ket.math.Branch;
import ket.math.Equation;
import ket.math.Function;
import ket.math.Symbol;
import ket.math.SymbolicFunction;
import ket.math.Token;
import ket.math.purpose.Word;
import ketUI.chord.Chord;
import ketUI.chord.KeyboardEventHandler;
import ketUI.modes.AddMode;
import ketUI.modes.DocumentState;
import ketUI.modes.NormalMode;
import ketUI.responder.MouseResponder;
import ket.math.State;
import ket.math.purpose.IntegerValue;

class OperandMenuFrame extends ButtonMenu {
  Vector<State> options;
  public OperandMenuFrame(Document document, JButton source) {
    super(document);
    options = new Vector<State>(Arrays.asList(
          new IntegerValue(0), new IntegerValue(1), new IntegerValue(2), new IntegerValue(10),
          new Word("a"), new Word("x"), new Word("y"), new Word("z")));
    options.addAll(Symbol.DEFAULT_OPERAND_SYMBOLS);
    setupUserInterface(source, 4, 4, 200, 100, "Replace selection with a symbol."); // column x row
    setHold(true);
  }

  @Override
  public void buttonSetup() {
    for (State s : options) {
      JButton button = new JButton(s.toUnicode());
      button.setFocusable(false);
      button.addActionListener(this);
      button.setToolTipText(s.getFullName());
      add(button);
    }
  }

  @Override
  public void replaceByText(String text) {
    for (State s : options) {
      if (s.toUnicode().equals(text)) {
        getSelection().replace(new Token(s));
      }
    }
  }
}
TOP

Related Classes of ketUI.OperandMenuFrame

TOP
Copyright © 2018 www.massapi.com. 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.