示例#1
0
  /** set labels on the tree */
  protected void setTreeLabels() {
    switch (getTreeMode()) {
      case DEPENDENCY:
        indNode.setUserObject(app.getPlain("FreeObjects"));
        model.nodeChanged(indNode);

        depNode.setUserObject(app.getPlain("DependentObjects"));
        model.nodeChanged(depNode);

        auxiliaryNode.setUserObject(app.getPlain("AuxiliaryObjects"));
        model.nodeChanged(auxiliaryNode);
        break;
      case TYPE:
        DefaultMutableTreeNode node;
        for (String key : typeNodesMap.keySet()) {
          node = typeNodesMap.get(key);
          node.setUserObject(app.getPlain(key));
          model.nodeChanged(node);
        }
        break;
      case LAYER:
        for (Integer key : layerNodesMap.keySet()) {
          node = layerNodesMap.get(key);
          node.setUserObject(app.getPlain("LayerA", key.toString()) + "TODO" + key);
          model.nodeChanged(node);
        }
        break;
      case ORDER:
        model.nodeChanged(rootOrder);
        break;
    }
  }
示例#2
0
  /**
   * Update the labels of this dialog.
   *
   * <p>TODO Create "Apply Defaults" phrase (F.S.)
   */
  public void setLabels() {
    setTitle(app.getPlain("Properties"));
    geoTree.root.setUserObject(app.getPlain("Objects"));

    delButton.setText(app.getPlain("Delete"));
    closeButton.setText(app.getMenu("Close"));
    defaultsButton.setText(app.getMenu("ApplyDefaults"));

    geoTree.setLabels();
    propPanel.setLabels();
  }
示例#3
0
  /** Returns I2G representation of construction. Intergeo File Format. (Yves Kreis) */
  public String getFullI2G() {
    StringBuilder sb = new StringBuilder();
    // addXMLHeader(sb);

    sb.append(
        "<!--\n\tIntergeo File Format Version "
            + GeoGebra.I2G_FILE_FORMAT
            + "\n\twritten by "
            + app.getPlain("ApplicationName")
            + " "
            + GeoGebra.VERSION_STRING
            + " ("
            + GeoGebra.BUILD_DATE
            + ")\n-->\n");

    sb.append("<construction>\n");

    // save construction
    cons.getConstructionI2G(sb, Construction.CONSTRUCTION);

    StringBuilder display = new StringBuilder();
    cons.getConstructionI2G(display, Construction.DISPLAY);
    if (!display.toString().equals("")) {
      sb.append("\t<display>\n");
      sb.append(display.toString());
      sb.append("\t</display>\n");
    }

    sb.append("</construction>\n");

    return sb.toString();
  }
  public void setLabels() {

    // TODO --- finish set labels

    // tab titles
    tabbedPane.setTitleAt(0, app.getMenu("Properties.Basic"));
    tabbedPane.setTitleAt(1, app.getPlain("xAxis"));
    tabbedPane.setTitleAt(2, app.getPlain("yAxis"));
    tabbedPane.setTitleAt(3, app.getMenu("Grid"));

    // window dimension panel
    dimLabel[0].setText("X " + app.getPlain("min") + ":");
    dimLabel[1].setText("X " + app.getPlain("max") + ":");
    dimLabel[2].setText("Y " + app.getPlain("min") + ":");
    dimLabel[3].setText("Y " + app.getPlain("max") + ":");
    axesRatioLabel.setText(app.getPlain("xAxis") + " : " + app.getPlain("yAxis") + " = ");
    //	dimPanelTitle = "ttt";

    cbView.removeActionListener(this);
    cbView.removeAllItems();
    cbView.addItem(app.getPlain("DrawingPad"));
    cbView.addItem(app.getPlain("DrawingPad2"));
    cbView.removeActionListener(this);

    cbShowMouseCoords.setText(app.getMenu("ShowMouseCoordinates"));
  }
示例#5
0
  /** Update the labels of the components (e.g. if the language changed). */
  public void setLabels() {
    setTitle(app.getMenu("Settings"));

    closeButton.setText(app.getMenu("Close"));
    saveButton.setText(app.getMenu("Settings.Save"));

    tabbedPane.setTitleAt(TAB_DEFAULTS, app.getPlain("Defaults"));
    tabbedPane.setTitleAt(TAB_EUCLIDIAN, app.getPlain("DrawingPad"));
    tabbedPane.setTitleAt(TAB_SPREADSHEET, app.getPlain("Spreadsheet"));
    tabbedPane.setTitleAt(TAB_CAS, app.getMenu("CAS"));
    tabbedPane.setTitleAt(TAB_ADVANCED, app.getMenu("Advanced"));

    euclidianPanel.setLabels();
    defaultsPanel.setLabels();
    spreadsheetPanel.setLabels();
    casPanel.setLabels();
    advancedPanel.setLabels();
  }
  /** shows dialog with syntax info cmd is the internal command name */
  private void showCommandHelp(String cmd) {
    // show help for current command (current word)
    String help = app.getCommandSyntax(cmd);

    // show help if available
    if (help != null) {
      app.showError(new MyError(app, app.getPlain("Syntax") + ":\n" + help, cmd));
    } else {
      app.getGuiManager().openCommandHelp(null);
    }
  }
示例#7
0
  public void setLabels() {

    // titled borders
    classesPanel.setBorder(BorderFactory.createTitledBorder(app.getMenu("Classes")));
    showPanel.setBorder(BorderFactory.createTitledBorder(app.getMenu("Show")));
    freqPanel.setBorder(BorderFactory.createTitledBorder(app.getMenu("FrequencyType")));
    dimPanel.setBorder(BorderFactory.createTitledBorder(app.getPlain("Dimensions")));

    // histogram options
    ckManual.setText(app.getMenu("SetClasssesManually"));
    lblFreqType.setText(app.getMenu("FrequencyType") + ":");

    rbFreq.setText(app.getMenu("Count"));
    rbNormalized.setText(app.getMenu("Normalized"));
    rbRelative.setText(app.getMenu("Relative"));

    ckCumulative.setText(app.getMenu("Cumulative"));
    lblOverlay.setText(app.getMenu("Overlay"));
    ckOverlayNormal.setText(app.getMenu("NormalCurve"));
    ckOverlayPolygon.setText(app.getMenu("FrequencyPolygon"));
    ckShowFrequencyTable.setText(app.getMenu("FrequencyTable"));

    lblClassRule.setText(app.getMenu("ClassRule") + ":");
    rbRightRule.setText(app.getMenu("RightClassRule"));
    rbLeftRule.setText(app.getMenu("LeftClassRule"));

    // graph options
    ckAutoWindow.setText(app.getMenu("AutoDimension"));
    ckShowGrid.setText(app.getPlain("ShowGrid"));
    lblXMin.setText(app.getPlain("xmin") + ":");
    lblXMax.setText(app.getPlain("xmax") + ":");
    lblYMin.setText(app.getPlain("ymin") + ":");
    lblYMax.setText(app.getPlain("ymax") + ":");

    lblXInterval.setText(app.getPlain("xstep") + ":");
    lblYInterval.setText(app.getPlain("ystep") + ":");

    ckShowLines.setText(app.getMenu("LineGraph"));

    repaint();
  }
  /*
   * attempt to give Syntax help for when eg "Radius[ <Conic> ]" is typed
   * see CommandProcessor.argErr() for similar error
   */
  public void showError(Exception e) {
    if (e instanceof MyException) {
      updateCurrentWord(true);
      int err = ((MyException) e).getErrorType();
      if (err == MyException.INVALID_INPUT) {
        String command = app.getReverseCommand(getCurrentWord());
        if (command != null) {

          app.showError(
              new MyError(
                  app,
                  app.getError("InvalidInput")
                      + "\n\n"
                      + app.getPlain("Syntax")
                      + ":\n"
                      + app.getCommandSyntax(command),
                  getCurrentWord()));
          return;
        }
      }
    }
    // can't work out anything better, just show "Invalid Input"
    app.showError(e.getLocalizedMessage());
  }
示例#9
0
  public static final String[][] basicSymbolsMap(Application app) {

    String[][] array = {
      {"\u03B1", app.getPlain("GreekCharacterA", "\u03B1")}, // lowercaseGreekALPHA
      {"\u03B2", app.getPlain("GreekCharacterA", "\u03B2")}, // lowercaseGreekBETA
      {"\u03B3", app.getPlain("GreekCharacterA", "\u03B3")}, // lowercaseGreekGAMMA
      {"\u03B4", app.getPlain("GreekCharacterA", "\u03B4")}, // lowercaseGreekDELTA
      {"\u03B5", app.getPlain("GreekCharacterA", "\u03B5")}, // lowercaseGreekEPSILON
      {"\u03B6", app.getPlain("GreekCharacterA", "\u03B6")}, // lowercaseGreekZETA
      {"\u03B7", app.getPlain("GreekCharacterA", "\u03B7")}, // lowercaseGreekETA
      {"\u03B8", app.getPlain("GreekCharacterA", "\u03B8")}, // lowercaseGreekTHETA
      //	{ "\u03B9" , app.getMenu("Symbol.GreekCharacter" ) + ":  " +   "\u03B9"},
      // //lowercaseGreekIOTA
      {"\u03BA", app.getPlain("GreekCharacterA", "\u03BA")}, // lowercaseGreekKAPPA
      {"\u03BB", app.getPlain("GreekCharacterA", "\u03BB")}, // lowercaseGreekLAMDA
      {"\u03BC", app.getPlain("GreekCharacterA", "\u03BC")}, // lowercaseGreekMU
      //	{ "\u03BD" , app.getMenu("Symbol.GreekCharacter" ) + ":  " +   "\u03BD"},
      // //lowercaseGreekNU
      {"\u03BE", app.getPlain("GreekCharacterA", "\u03BE")}, // lowercaseGreekXI
      //	{ "\u03BF" , app.getMenu("Symbol.GreekCharacter" ) + ":  " +   "\u03BF"},
      // //lowercaseGreekOMICRON
      //	{ "\u03C0" , app.getMenu("Symbol.GreekCharacter" ) + ":  " +   "\u03C0"},
      // //lowercaseGreekPI
      {"\u03C1", app.getPlain("GreekCharacterA", "\u03C1")}, // lowercaseGreekRHO
      //	{ "\u03C2" , app.getMenu("Symbol.GreekCharacter" ) + ":  " +   "\u03C2"},
      // //lowercaseGreekFINALSIGMA
      {"\u03C3", app.getPlain("GreekCharacterA", "\u03C3")}, // lowercaseGreekSIGMA
      {"\u03C4", app.getPlain("GreekCharacterA", "\u03C4")}, // lowercaseGreekTAU
      //	{ "\u03C5" , app.getMenu("Symbol.GreekCharacter" ) + ":  " +   "\u03C5"},
      // //lowercaseGreekUPSILON
      {
        "\u03C6", app.getPlain("GreekCharacterA", "\u03C6")
      }, // lowercaseGreekPHI (\varPhi the "loopy" phi)
      {
        "\u03D5", app.getPlain("GreekCharacterA", "\u03D5")
      }, // lowercaseGreekPHI \phi the "straight" math phi
      {"\u03C7", app.getPlain("GreekCharacterA", "\u03C7")}, // lowercaseGreekCHI
      {"\u03C8", app.getPlain("GreekCharacterA", "\u03C8")}, // lowercaseGreekPSI
      {"\u03C9", app.getPlain("GreekCharacterA", "\u03C9")}, // lowercaseGreekOMEGA
      {"\u0393", app.getPlain("GreekCharacterA", "\u0393")}, // uppercaseGreekGAMMA
      {"\u0394", app.getPlain("GreekCharacterA", "\u0394")}, // uppercaseGreekDELTA
      {"\u0398", app.getPlain("GreekCharacterA", "\u0398")}, // uppercaseGreekTHETA
      // removed - too similar to logical 'and'
      // { "\u039b" , app.getPlain("GreekCharacterA", "\u039b" ) },  //uppercaseGreekLAMBDA
      {"\u039e", app.getPlain("GreekCharacterA", "\u039e")}, // uppercaseGreekXI
      {"\u03a0", app.getPlain("GreekCharacterA", "\u03a0")}, // uppercaseGreekPI
      {"\u03a3", app.getPlain("GreekCharacterA", "\u03a3")}, // uppercaseGreekSIGMA
      {"\u03a6", app.getPlain("GreekCharacterA", "\u03a6")}, // uppercaseGreekPHI
      // { "\u03a8" , app.getPlain("GreekCharacterA", "\u03a8" ) },  //uppercaseGreekPSI
      {"\u03a9", app.getPlain("GreekCharacterA", "\u03a9")}, // uppercaseGreekOMEGA
      {"\u221e", app.getMenu("Symbol.Infinity")},
      {ExpressionNode.strVECTORPRODUCT, app.getMenu("Symbol.VectorProduct")},
      {ExpressionNode.strEQUAL_BOOLEAN, app.getMenu("Symbol.BooleanEqual")},
      {ExpressionNode.strNOT_EQUAL, app.getMenu("Symbol.NotEqual")},
      {ExpressionNode.strLESS_EQUAL, app.getMenu("Symbol.LessThanEqualTo")},
      {ExpressionNode.strGREATER_EQUAL, app.getMenu("Symbol.GreaterThanEqualTo")},
      {ExpressionNode.strNOT, app.getMenu("Symbol.Negation")},
      {ExpressionNode.strAND, app.getMenu("Symbol.And")},
      {ExpressionNode.strOR, app.getMenu("Symbol.Or")},
      {ExpressionNode.strPARALLEL, app.getMenu("Symbol.Parallel")},
      {ExpressionNode.strPERPENDICULAR, app.getMenu("Symbol.Perpendicular")},
      {ExpressionNode.strIS_ELEMENT_OF, app.getMenu("Symbol.ElementOf")},
      {ExpressionNode.strIS_SUBSET_OF, app.getMenu("Symbol.Subset")},
      {ExpressionNode.strIS_SUBSET_OF_STRICT, app.getMenu("Symbol.StrictSubset")},
      // { "\u2220" , app.getMenu("Symbol.Angle" )},
      {"\u2221", app.getMenu("Symbol.AngleMeasure")},
      {Unicode.Superscript_2 + "", app.getMenu("Symbol.Square")}, // exponents^2
      {Unicode.Superscript_3 + "", app.getMenu("Symbol.Cube")}, // exponents^3
      {Unicode.degree, app.getMenu("Symbol.Degree")}, // degree
      {Unicode.IMAGINARY, Unicode.IMAGINARY}, // sqrt(-1)
      {Unicode.PI_STRING, Unicode.PI_STRING}, // pi
      {Unicode.EULER_STRING, Unicode.EULER_STRING}, // e
      {Unicode.NBSP, app.getMenu("Symbol.NBSP")}, // e
    };

    return array;
  };
  /**
   * Creates new ZoomMenu
   *
   * @param app
   * @param px
   * @param py
   */
  public ContextMenuGraphicsWindow(Application app, double px, double py) {
    this(app);

    iconZoom = app.getImageIcon("zoom16.gif");

    // zoom point
    this.px = px;
    this.py = py;

    EuclidianViewInterfaceCommon ev = app.getActiveEuclidianView();
    if (ev.getEuclidianViewNo() == 2) {
      setTitle("<html>" + app.getPlain("DrawingPad2") + "</html>");
    } else {
      setTitle("<html>" + app.getPlain("DrawingPad") + "</html>");
    }

    addAxesAndGridCheckBoxes();

    addSeparator();

    // zoom for both axes
    JMenu zoomMenu = new JMenu(app.getMenu("Zoom"));
    zoomMenu.setIcon(iconZoom);
    zoomMenu.setBackground(getBackground());
    addZoomItems(zoomMenu);
    add(zoomMenu);

    // zoom for y-axis
    JMenu yaxisMenu = new JMenu(app.getPlain("xAxis") + " : " + app.getPlain("yAxis"));
    yaxisMenu.setIcon(app.getEmptyIcon());
    yaxisMenu.setBackground(getBackground());
    addAxesRatioItems(yaxisMenu);
    add(yaxisMenu);

    JMenuItem miShowAllObjectsView = new JMenuItem(app.getPlain("ShowAllObjects"));
    miShowAllObjectsView.setIcon(app.getEmptyIcon());
    miShowAllObjectsView.setActionCommand("showAllObjects");
    miShowAllObjectsView.addActionListener(this);
    miShowAllObjectsView.setBackground(bgColor);
    add(miShowAllObjectsView);

    JMenuItem miStandardView = new JMenuItem(app.getPlain("StandardView"));
    setMenuShortCutAccelerator(miStandardView, 'M');
    miStandardView.setIcon(app.getEmptyIcon());
    miStandardView.setActionCommand("standardView");
    miStandardView.addActionListener(this);
    miStandardView.setBackground(bgColor);
    add(miStandardView);

    addSeparator();
    if (!ev.isZoomable()) {
      zoomMenu.setEnabled(false);
      yaxisMenu.setEnabled(false);
      miShowAllObjectsView.setEnabled(false);
      miStandardView.setEnabled(false);
    }

    if (ev.isUnitAxesRatio()) {
      yaxisMenu.setEnabled(false);
    }

    addMiProperties();
  }
示例#11
0
  private void createGUI() {
    setTitle(textField ? app.getPlain("TextField") : app.getPlain("Button"));
    setResizable(false);

    // create caption panel
    JLabel captionLabel = new JLabel(app.getMenu("Button.Caption") + ":");
    String initString = button == null ? "" : button.getCaption();
    InputPanel ip = new InputPanel(initString, app, 1, 15, true);
    tfCaption = ip.getTextComponent();
    if (tfCaption instanceof AutoCompleteTextField) {
      AutoCompleteTextField atf = (AutoCompleteTextField) tfCaption;
      atf.setAutoComplete(false);
    }

    captionLabel.setLabelFor(tfCaption);
    JPanel captionPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    captionPanel.add(captionLabel);
    captionPanel.add(ip);

    // combo box to link GeoElement to TextField
    comboModel = new DefaultComboBoxModel();
    TreeSet sortedSet = app.getKernel().getConstruction().getGeoSetNameDescriptionOrder();

    final JComboBox cbAdd = new JComboBox(comboModel);

    if (textField) {
      // lists for combo boxes to select input and output objects
      // fill combobox models
      Iterator it = sortedSet.iterator();
      comboModel.addElement(null);
      FontMetrics fm = getFontMetrics(getFont());
      int width = (int) cbAdd.getPreferredSize().getWidth();
      while (it.hasNext()) {
        GeoElement geo = (GeoElement) it.next();
        if (!geo.isGeoImage() && !(geo.isGeoButton()) && !(geo.isGeoBoolean())) {
          comboModel.addElement(geo);
          String str = geo.toString();
          if (width < fm.stringWidth(str)) width = fm.stringWidth(str);
        }
      }

      // make sure it's not too wide (eg long GeoList)
      Dimension size =
          new Dimension(
              Math.min(app.getScreenSize().width / 2, width), cbAdd.getPreferredSize().height);
      cbAdd.setMaximumSize(size);
      cbAdd.setPreferredSize(size);

      if (comboModel.getSize() > 1) {

        // listener for the combobox
        MyComboBoxListener ac =
            new MyComboBoxListener() {
              public void doActionPerformed(Object source) {
                GeoElement geo = (GeoElement) cbAdd.getSelectedItem();
                // if (geo == null)
                // {
                //
                //	return;
                // }

                linkedGeo = geo;
                // ((GeoTextField)button).setLinkedGeo(geo);

                cbAdd.removeActionListener(this);

                // cbAdd.setSelectedItem(null);
                cbAdd.addActionListener(this);
              }
            };
        cbAdd.addActionListener(ac);
        cbAdd.addMouseListener(ac);

        captionPanel.add(cbAdd);
      }
    }

    // create script panel
    JLabel scriptLabel = new JLabel(app.getPlain("Script") + ":");
    initString = (button == null) ? "" : button.getClickScript();
    InputPanel ip2 = new InputPanel(initString, app, 10, 40, false);
    tfScript = ip2.getTextComponent();
    if (tfScript instanceof AutoCompleteTextField) {
      AutoCompleteTextField atf = (AutoCompleteTextField) tfScript;
      atf.setAutoComplete(false);
    }

    scriptLabel.setLabelFor(tfScript);
    JPanel scriptPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    scriptPanel.add(scriptLabel);
    scriptPanel.add(ip2);

    JPanel linkedPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    JLabel linkedLabel = new JLabel(app.getPlain("LinkedObject") + ":");
    linkedPanel.add(linkedLabel);
    linkedPanel.add(cbAdd);

    // buttons
    btApply = new JButton(app.getPlain("Apply"));
    btApply.setActionCommand("Apply");
    btApply.addActionListener(this);
    btCancel = new JButton(app.getPlain("Cancel"));
    btCancel.setActionCommand("Cancel");
    btCancel.addActionListener(this);
    btPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    btPanel.add(btApply);
    btPanel.add(btCancel);

    // Create the JOptionPane.
    optionPane = new JPanel(new BorderLayout(5, 5));

    // create object list
    optionPane.add(captionPanel, BorderLayout.NORTH);
    if (textField) optionPane.add(linkedPanel, BorderLayout.CENTER);
    else optionPane.add(scriptPanel, BorderLayout.CENTER);
    optionPane.add(btPanel, BorderLayout.SOUTH);
    optionPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    // Make this dialog display it.
    setContentPane(optionPane);

    /*

    inputPanel = new InputPanel("ggbApplet.evalCommand('A=(3,4)');", app, 10, 50, false, true, false );
    inputPanel2 = new InputPanel("function func() {\n}", app, 10, 50, false, true, false );

    JPanel centerPanel = new JPanel(new BorderLayout());

    centerPanel.add(inputPanel, BorderLayout.CENTER);
    centerPanel.add(inputPanel2, BorderLayout.SOUTH);
    getContentPane().add(centerPanel, BorderLayout.CENTER);
    //centerOnScreen();

    setContentPane(centerPanel);
    pack();
    setLocationRelativeTo(app.getFrame());	*/
  }
  private JPanel buildGridPanel() {

    int hgap = 5;
    int vgap = 5;

    // ==================================================
    // create sub panels

    // -------------------------------------
    // show grid panel
    JPanel showGridPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, hgap, vgap));
    cbShowGrid = new JCheckBox(app.getPlain("Show") + " " + app.getMenu("Grid"));
    cbShowGrid.addActionListener(this);
    showGridPanel.add(cbShowGrid, BorderLayout.NORTH);

    // -------------------------------------
    // grid type panel

    JPanel typePanel = new JPanel(new FlowLayout(FlowLayout.LEFT, hgap, vgap));
    typePanel.setBorder(BorderFactory.createTitledBorder((app.getPlain("GridType"))));

    // type
    String[] gridTypeLabel = new String[3];
    gridTypeLabel[EuclidianView.GRID_CARTESIAN] = app.getMenu("Cartesian");
    gridTypeLabel[EuclidianView.GRID_ISOMETRIC] = app.getMenu("Isometric");
    gridTypeLabel[EuclidianView.GRID_POLAR] = app.getMenu("Polar");
    cbGridType = new JComboBox(gridTypeLabel);
    cbGridType.addActionListener(this);
    typePanel.add(cbGridType);

    // tick intervals
    JPanel tickPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, hgap, vgap));
    cbGridManualTick = new JCheckBox(app.getPlain("TickDistance") + ":");
    ncbGridTickX = new NumberComboBox(app);
    ncbGridTickY = new NumberComboBox(app);

    cbGridManualTick.addActionListener(this);
    ncbGridTickX.addItemListener(this);
    ncbGridTickY.addItemListener(this);

    // angleStep intervals for polar grid lines
    String PI_STRING = "\u03c0";
    String[] angleOptions = {
      PI_STRING + "/12", PI_STRING + "/6", PI_STRING + "/4", PI_STRING + "/3", PI_STRING + "/2",
    };

    cbGridTickAngle = new JComboBox(angleOptions);
    cbGridTickAngle.addItemListener(this);
    tickPanel.add(cbGridManualTick);

    gridLabel1 = new JLabel("x:");
    gridLabel1.setLabelFor(ncbGridTickX);
    tickPanel.add(gridLabel1);
    tickPanel.add(ncbGridTickX);

    gridLabel2 = new JLabel("y:");
    gridLabel2.setLabelFor(ncbGridTickY);
    tickPanel.add(gridLabel2);
    tickPanel.add(ncbGridTickY);

    gridLabel3 = new JLabel("\u0398" + ":"); // Theta
    gridLabel3.setLabelFor(cbGridTickAngle);
    tickPanel.add(gridLabel3);
    tickPanel.add(cbGridTickAngle);

    typePanel.add(tickPanel);

    // -------------------------------------
    // style panel
    JPanel stylePanel = new JPanel(new FlowLayout(FlowLayout.LEFT, hgap, vgap));
    stylePanel.setBorder(BorderFactory.createTitledBorder((app.getPlain("LineStyle"))));

    // line style
    DashListRenderer renderer = new DashListRenderer();
    renderer.setPreferredSize(new Dimension(130, app.getFontSize() + 6));
    cbGridStyle = new JComboBox(EuclidianView.getLineTypes());
    cbGridStyle.setRenderer(renderer);
    cbGridStyle.addActionListener(this);
    stylePanel.add(cbGridStyle);

    // color
    JLabel lblColor = new JLabel(app.getPlain("Color") + ":");
    lblColor.setLabelFor(btGridColor);
    // bold
    cbBoldGrid = new JCheckBox(app.getMenu("Bold"));
    cbBoldGrid.addActionListener(this);

    stylePanel.add(lblColor);
    stylePanel.add(btGridColor);
    stylePanel.add(cbBoldGrid);

    // ==================================================
    // create grid panel and add all the sub panels

    JPanel northPanel = new JPanel();
    northPanel.setLayout(new BoxLayout(northPanel, BoxLayout.Y_AXIS));
    northPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    northPanel.add(showGridPanel);
    northPanel.add(Box.createRigidArea(new Dimension(0, 16)));
    northPanel.add(typePanel);
    northPanel.add(Box.createRigidArea(new Dimension(0, 16)));
    northPanel.add(stylePanel);

    JPanel gridPanel = new JPanel(new BorderLayout());
    gridPanel.add(northPanel, BorderLayout.NORTH);

    return gridPanel;
  }
  private JPanel buildBasicPanel() {

    JLabel label;

    // ===================================
    // create sub panels

    // -------------------------------------
    // window dimensions panel

    dimLabel = new JLabel[4]; // "Xmin", "Xmax" etc.
    for (int i = 0; i < 4; i++) dimLabel[i] = new JLabel("");

    JPanel xDimPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 5));
    tfMinX = new MyTextField(app.getGuiManager(), 8);
    tfMaxX = new MyTextField(app.getGuiManager(), 8);
    tfMinX.addActionListener(this);
    tfMaxX.addActionListener(this);
    tfMinX.addFocusListener(this);
    tfMaxX.addFocusListener(this);

    xDimPanel.add(dimLabel[0]);
    xDimPanel.add(tfMinX);
    xDimPanel.add(dimLabel[1]);
    xDimPanel.add(tfMaxX);

    JPanel yDimPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 5));
    tfMinY = new MyTextField(app.getGuiManager(), 8);
    tfMaxY = new MyTextField(app.getGuiManager(), 8);
    tfMinY.addActionListener(this);
    tfMaxY.addActionListener(this);
    tfMinY.addFocusListener(this);
    tfMaxY.addFocusListener(this);

    yDimPanel.add(dimLabel[2]);
    yDimPanel.add(tfMinY);
    yDimPanel.add(dimLabel[3]);
    yDimPanel.add(tfMaxY);

    JPanel axesRatioPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 5));
    tfAxesRatioX = new MyTextField(app.getGuiManager(), 6);
    tfAxesRatioY = new MyTextField(app.getGuiManager(), 6);
    tfAxesRatioX.addActionListener(this);
    tfAxesRatioY.addActionListener(this);
    tfAxesRatioX.addFocusListener(this);
    tfAxesRatioY.addFocusListener(this);
    axesRatioLabel = new JLabel("");
    axesRatioPanel.add(axesRatioLabel);
    axesRatioPanel.add(tfAxesRatioX);
    axesRatioPanel.add(new JLabel(" : "));
    axesRatioPanel.add(tfAxesRatioY);

    dimPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 5));
    dimPanel.setLayout(new BoxLayout(dimPanel, BoxLayout.Y_AXIS));
    dimPanel.add(xDimPanel);
    dimPanel.add(yDimPanel);
    dimPanel.add(axesRatioPanel);
    dimPanel.setBorder(BorderFactory.createTitledBorder(app.getPlain("Dimensions")));

    // -------------------------------------
    // axes options panel
    JPanel axesOptionsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 5));
    axesOptionsPanel.setBorder(BorderFactory.createTitledBorder(app.getMenu("Axes")));

    // show axes
    cbShowAxes = new JCheckBox(app.getMenu(app.getPlain("Show") + " " + "Axes"));
    axesOptionsPanel.add(cbShowAxes);
    axesOptionsPanel.add(Box.createRigidArea(new Dimension(10, 0)));

    // color
    label = new JLabel(app.getPlain("Color") + ":");
    label.setLabelFor(btAxesColor);
    axesOptionsPanel.add(label);
    axesOptionsPanel.add(btAxesColor);
    axesOptionsPanel.add(Box.createRigidArea(new Dimension(10, 0)));

    // axes style
    cbAxesStyle = new JComboBox();
    label = new JLabel(app.getPlain("LineStyle") + ":");
    label.setLabelFor(cbAxesStyle);
    cbAxesStyle.addItem("\u2014"); // line
    cbAxesStyle.addItem("\u2192"); // arrow
    cbAxesStyle.addItem("\u2014" + " " + app.getPlain("Bold")); // bold line
    cbAxesStyle.addItem("\u2192" + " " + app.getPlain("Bold")); // bold arrow
    cbAxesStyle.setEditable(false);
    axesOptionsPanel.add(label);
    axesOptionsPanel.add(cbAxesStyle);

    // -------------------------------------
    // background color panel
    JPanel bgPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 5));
    label = new JLabel(app.getPlain("BackgroundColor") + ":");
    bgPanel.add(label);
    bgPanel.add(btBackgroundColor);
    label.setLabelFor(btBackgroundColor);

    cbShowMouseCoords = new JCheckBox();
    cbShowMouseCoords.addActionListener(this);
    bgPanel.add(cbShowMouseCoords);

    // ==========================================
    // create basic panel and add all sub panels

    JPanel northPanel = new JPanel();
    northPanel.setLayout(new BoxLayout(northPanel, BoxLayout.Y_AXIS));
    northPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 2, 5));

    northPanel.add(dimPanel);
    northPanel.add(Box.createRigidArea(new Dimension(0, 16)));
    northPanel.add(axesOptionsPanel);
    northPanel.add(Box.createRigidArea(new Dimension(0, 16)));
    northPanel.add(bgPanel);

    // use a BorderLayout to keep sub panels together
    JPanel basicPanel = new JPanel(new BorderLayout());
    basicPanel.add(northPanel, BorderLayout.NORTH);

    return basicPanel;
  }
  public void keyPressed(KeyEvent e) {
    int keyCode = e.getKeyCode();

    // we don't want to trap AltGr
    // as it is used eg for entering {[}] is some locales
    // NB e.isAltGraphDown() doesn't work
    if (e.isAltDown() && e.isControlDown()) return;

    // swallow eg ctrl-a ctrl-b ctrl-p on Mac
    if (Application.MAC_OS && e.isControlDown()) e.consume();

    ctrlC = false;

    switch (keyCode) {
      case KeyEvent.VK_Z:
      case KeyEvent.VK_Y:
        if (Application.isControlDown(e)) {
          app.getGlobalKeyDispatcher().handleGeneralKeys(e);
          e.consume();
        }
        break;

      case KeyEvent.VK_0:
      case KeyEvent.VK_1:
      case KeyEvent.VK_2:
      case KeyEvent.VK_3:
      case KeyEvent.VK_4:
      case KeyEvent.VK_5:
      case KeyEvent.VK_6:
      case KeyEvent.VK_7:
      case KeyEvent.VK_8:
      case KeyEvent.VK_9:
        if (Application.isControlDown(e) && e.isShiftDown())
          app.getGlobalKeyDispatcher().handleGeneralKeys(e);
        break;

        // process input
      case KeyEvent.VK_C:
        if (Application.isControlDown(e)) // workaround for MAC_OS
        {
          ctrlC = true;
        }

        break;

      case KeyEvent.VK_ESCAPE:
        if (!handleEscapeKey) {
          break;
        }

        Component comp = SwingUtilities.getRoot(this);
        if (comp instanceof JDialog) {
          ((JDialog) comp).setVisible(false);
          return;
        }

        setText(null);
        break;

      case KeyEvent.VK_LEFT_PARENTHESIS:
        break;

      case KeyEvent.VK_UP:
        if (!handleEscapeKey) {
          break;
        }
        if (historyPopup == null) {
          String text = getPreviousInput();
          if (text != null) setText(text);
        } else if (!historyPopup.isDownPopup()) {
          historyPopup.showPopup();
        }
        break;

      case KeyEvent.VK_DOWN:
        if (!handleEscapeKey) {
          break;
        }
        if (historyPopup != null && historyPopup.isDownPopup()) historyPopup.showPopup();
        else setText(getNextInput());
        break;

      case KeyEvent.VK_F9:
        // needed for applets
        if (app.isApplet()) app.getGlobalKeyDispatcher().handleGeneralKeys(e);
        break;

      case KeyEvent.VK_RIGHT:
        if (moveToNextArgument(false)) {
          e.consume();
        }
        break;

      case KeyEvent.VK_TAB:
        if (moveToNextArgument(true)) {
          e.consume();
        }
        break;

      case KeyEvent.VK_F1:
        if (autoComplete) {
          if (getText().equals("")) {

            Object[] options = {app.getPlain("OK"), app.getPlain("ShowOnlineHelp")};
            int n =
                JOptionPane.showOptionDialog(
                    app.getMainComponent(),
                    app.getPlain("InputFieldHelp"),
                    app.getPlain("ApplicationName") + " - " + app.getMenu("Help"),
                    JOptionPane.YES_NO_OPTION,
                    JOptionPane.QUESTION_MESSAGE,
                    null, // do not use a custom Icon
                    options, // the titles of buttons
                    options[0]); // default button title

            if (n == 1) app.getGuiManager().openHelp(Application.WIKI_MANUAL);

          } else {
            int pos = getCaretPosition();
            while (pos > 0 && getText().charAt(pos - 1) == '[') {
              pos--;
            }
            String word = getWordAtPos(getText(), pos);
            String lowerCurWord = word.toLowerCase();
            String closest = dict.lookup(lowerCurWord);

            if (closest != null) // && lowerCurWord.equals(closest.toLowerCase()))		
            showCommandHelp(app.getInternalCommand(closest));
            else app.getGuiManager().openHelp(Application.WIKI_MANUAL);
          }
        } else app.getGuiManager().openHelp(Application.WIKI_MANUAL);

        e.consume();
        break;
      default:
    }
  }
示例#15
0
  protected void createGUI() {
    setTitle(app.getPlain("Substitute") + " - " + app.getCommand("Row") + " " + (editRow + 1));
    setResizable(true);

    GeoCasCell cell = casView.getConsoleTable().getGeoCasCell(editRow);

    HashSet<GeoElement> vars = cell.getInputVE().getVariables();
    Vector<String> row;
    if (vars != null) {
      data = new Vector<Vector<String>>(vars.size() + 1);
      Iterator<GeoElement> iter = vars.iterator();
      while (iter.hasNext()) {
        row = new Vector<String>(2);
        GeoElement var = iter.next();
        String nextVar = var.getLabel();
        int i = 0;
        for (i = 0; i < data.size(); i++) {
          if (data.get(i).firstElement().compareTo(nextVar) >= 0) {
            break;
          }
        }
        if (i == data.size() || !data.get(i).firstElement().equals(nextVar)) {
          row.add(nextVar);
          row.add("");
          data.insertElementAt(row, i);
        }
      }
    } else {
      data = new Vector<Vector<String>>(1);
    }
    row = new Vector<String>(2);
    row.add("");
    row.add("");
    data.add(row);

    Vector<String> header = new Vector<String>();
    header.add(app.getPlain("OldExpression"));
    header.add(app.getPlain("NewExpression"));
    replaceTable = new JTable(data, header);
    replaceTable.setDefaultEditor(Object.class, new MathTextCellEditor());
    replaceTable.getTableHeader().setReorderingAllowed(false);
    double fontFactor = Math.max(1, app.getGUIFontSize() / DEFAULT_FONT_SIZE);
    replaceTable.setRowHeight((int) (DEFAULT_TABLE_CELL_HEIGHT * fontFactor));

    replaceTable.setPreferredScrollableViewportSize(
        new Dimension(
            (int) (DEFAULT_TABLE_WIDTH * fontFactor), (int) (DEFAULT_TABLE_HEIGHT * fontFactor)));
    scrollPane = new JScrollPane(replaceTable);

    captionPanel = new JPanel(new BorderLayout(5, 0));

    captionPanel.add(scrollPane, BorderLayout.CENTER);

    replaceTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    replaceTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {

              public void valueChanged(ListSelectionEvent e) {
                addRow(false);
              }
            });

    replaceTable.addKeyListener(
        new KeyAdapter() {
          public void keyTyped(KeyEvent e) {
            if (e.getKeyChar() != KeyEvent.CHAR_UNDEFINED && e.getKeyChar() != '\t') addRow(true);
          }
        });

    // buttons
    btEval = new JButton("=");
    btEval.setToolTipText(app.getCommandTooltip("Evaluate"));
    btEval.setActionCommand("Evaluate");
    btEval.addActionListener(this);

    btNumeric = new JButton("\u2248");
    btNumeric.setToolTipText(app.getCommandTooltip("Numeric"));
    btNumeric.setActionCommand("Numeric");
    btNumeric.addActionListener(this);

    btSub = new JButton(app.getPlain("\u2713"));
    btSub.setToolTipText(app.getCommandTooltip("Substitute"));
    btSub.setActionCommand("Substitute");
    btSub.addActionListener(this);

    btPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));

    btPanel.add(btEval);
    btPanel.add(btNumeric);
    btPanel.add(btSub);

    // Create the JOptionPane.
    optionPane = new JPanel(new BorderLayout(5, 5));

    // create object list
    optionPane.add(captionPanel, BorderLayout.CENTER);

    optionPane.add(btPanel, BorderLayout.SOUTH);
    optionPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    // Make this dialog display it.
    setContentPane(optionPane);
  }