コード例 #1
0
  /**
   * Creates new PropertiesDialog.
   *
   * @param app parent frame
   */
  public PropertiesDialog(Application app) {
    super(app.getFrame(), false);
    this.app = app;
    kernel = app.getKernel();

    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    setResizable(true);

    addWindowListener(this);
    geoTree = new JTreeGeoElements();
    geoTree.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseEntered(MouseEvent e) {
            // some textfields are updated when they lose focus
            // give them a chance to do that before we change the selection
            requestFocusInWindow();
          }
        });
    geoTree.addTreeSelectionListener(this);
    geoTree.addKeyListener(this);

    // build GUI
    initGUI();
  }
コード例 #2
0
  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"));
  }
コード例 #3
0
ファイル: MyXMLio.java プロジェクト: geogebra/geogebra-old
  public void writeImageToStream(OutputStream os, String fileName, BufferedImage img) {
    // if we get here we need to save the image from the memory
    try {
      // try to write image using the format of the filename extension
      int pos = fileName.lastIndexOf('.');
      String ext = fileName.substring(pos + 1).toLowerCase(Locale.US);
      if (ext.equals("jpg") || ext.equals("jpeg")) ext = "JPG";
      else ext = "PNG";

      // circumvent security issues by disabling disk-based caching
      if (app.isApplet()) {
        javax.imageio.ImageIO.setUseCache(false);
      }

      ImageIO.write(img, ext, os);

      // restore caching to prevent side-effects
      if (app.isApplet()) {
        javax.imageio.ImageIO.setUseCache(true);
      }
    } catch (Exception e) {
      Application.debug(e.getMessage());
      try {
        // if this did not work save image as png
        ImageIO.write(img, "png", os);
      } catch (Exception ex) {
        Application.debug(ex.getMessage());
        return;
      }
    }
  }
コード例 #4
0
ファイル: AlgebraView.java プロジェクト: avilleret/geogebra
  /** 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;
    }
  }
コード例 #5
0
ファイル: ButtonDialog.java プロジェクト: kovzol/geogebra
  public void actionPerformed(ActionEvent e) {
    Object source = e.getSource();
    Application.debug(tfScript.getText());
    if (source == btApply) {
      Construction cons = app.getKernel().getConstruction();
      button = textField ? app.getKernel().textfield(null, linkedGeo) : new GeoButton(cons);
      button.setEuclidianVisible(true);
      button.setAbsoluteScreenLoc(x, y);

      button.setLabel(null);
      button.setClickScript(tfScript.getText(), true);

      // set caption text
      String strCaption = tfCaption.getText().trim();
      if (strCaption.length() > 0) {
        button.setCaption(strCaption);
      }

      button.setEuclidianVisible(true);
      button.setLabelVisible(true);
      button.updateRepaint();

      geoResult = button;
      setVisible(false);

      app.getKernel().storeUndoInfo();
    } else if (source == btCancel) {
      geoResult = null;
      setVisible(false);
    }
  }
コード例 #6
0
  /**
   * Parses given String str and tries to evaluate it to a GeoImplicitPoly object. Returns null if
   * something went wrong.
   *
   * @param str
   * @boolean showErrors if false, only stacktraces are printed
   * @return implicit polygon or null
   */
  public GeoElement evaluateToGeoElement(String str, boolean showErrors) {
    boolean oldMacroMode = cons.isSuppressLabelsActive();
    cons.setSuppressLabelCreation(true);

    GeoElement geo = null;
    try {
      ValidExpression ve = parser.parseGeoGebraExpression(str);
      GeoElement[] temp = processValidExpression(ve);
      geo = temp[0];
    } catch (CircularDefinitionException e) {
      Application.debug("CircularDefinition");
      app.showError("CircularDefinition");
    } catch (Exception e) {
      e.printStackTrace();
      if (showErrors) app.showError("InvalidInput", str);
    } catch (MyError e) {
      e.printStackTrace();
      if (showErrors) app.showError(e);
    } catch (Error e) {
      e.printStackTrace();
      if (showErrors) app.showError("InvalidInput", str);
    }

    cons.setSuppressLabelCreation(oldMacroMode);
    return geo;
  }
コード例 #7
0
  /**
   * @param command command name in local language
   * @return syntax description of command as html text or null
   */
  private String getCmdSyntax(String command) {
    if (command == null || command.length() == 0) return null;

    // try macro first
    Macro macro = app.getKernel().getMacro(command);
    if (macro != null) {
      return macro.toString();
    }

    // translate command to internal name and get syntax description
    // note: the translation ignores the case of command
    String internalCmd = app.translateCommand(command);
    // String key = internalCmd + "Syntax";
    // String syntax = app.getCommand(key);
    String syntax;
    if (isCASInput) {
      syntax = app.getCommandSyntaxCAS(internalCmd);
    } else {
      syntax = app.getCommandSyntax(internalCmd);
    }

    // check if we really found syntax information
    // if (key.equals(syntax)) return null;
    if (syntax.indexOf(app.syntaxStr) == -1) return null;

    // build html tooltip
    syntax = syntax.replaceAll("<", "&lt;");
    syntax = syntax.replaceAll(">", "&gt;");
    syntax = syntax.replaceAll("\n", "<br>");
    StringBuilder sb = new StringBuilder();
    sb.append("<html>");
    sb.append(syntax);
    sb.append("</html>");
    return sb.toString();
  }
コード例 #8
0
  /*
   * Take a list of commands and return all possible syntaxes
   * for these commands
   */
  private List<String> getSyntaxes(List<String> commands) {
    if (commands == null) {
      return null;
    }
    ArrayList<String> syntaxes = new ArrayList<String>();
    for (String cmd : commands) {

      String cmdInt = app.getInternalCommand(cmd);

      String syntaxString;
      if (isCASInput) {
        syntaxString = app.getCommandSyntaxCAS(cmdInt);
      } else {
        syntaxString = app.getCommandSyntax(cmdInt);
      }
      if (syntaxString.endsWith(isCASInput ? app.syntaxCAS : app.syntaxStr)) {

        // command not found, check for macros
        Macro macro = isCASInput ? null : app.getKernel().getMacro(cmd);
        if (macro != null) {
          syntaxes.add(macro.toString());
        } else {
          // syntaxes.add(cmdInt + "[]");
          Application.debug("Can't find syntax for: " + cmd);
        }

        continue;
      }
      for (String syntax : syntaxString.split("\\n")) {
        syntaxes.add(syntax);
      }
    }
    return syntaxes;
  }
コード例 #9
0
 public void windowGainedFocus(WindowEvent arg0) {
   // make sure this dialog is the current selection listener
   if (app.getMode() != EuclidianConstants.MODE_SELECTION_LISTENER
       || app.getCurrentSelectionListener() != this) {
     app.setSelectionListenerMode(this);
     selectionChanged();
   }
 }
コード例 #10
0
 public void setUseJavaFontsForLaTeX(Application app, boolean b) {
   if (b != app.useJavaFontsForLaTeX) {
     app.useJavaFontsForLaTeX = b;
     String serifFont = b ? "Serif" : null;
     String sansSerifFont = b ? "Sans Serif" : null;
     TeXFormula.registerExternalFont(Character.UnicodeBlock.BASIC_LATIN, sansSerifFont, serifFont);
     JLaTeXMathCache.clearCache();
     app.getKernel().notifyRepaint();
   }
 }
コード例 #11
0
  /** 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);
    }
  }
コード例 #12
0
  /** handles selection change */
  private void selectionChanged() {
    updateSelectedGeos(geoTree.getSelectionPaths());

    Object[] geos = selectionList.toArray();
    propPanel.updateSelection(geos);
    // Util.addKeyListenerToAll(propPanel, this);

    // update selection of application too
    if (app.getMode() == EuclidianConstants.MODE_SELECTION_LISTENER)
      app.setSelectedGeos(selectionList);
  }
コード例 #13
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();
  }
コード例 #14
0
  /**
   * for AlgebraView changes in the tree selection and redefine dialog
   *
   * @return changed geo
   */
  public GeoElement changeGeoElementNoExceptionHandling(
      GeoElement geo, ValidExpression newValue, boolean redefineIndependent, boolean storeUndoInfo)
      throws Exception {
    String oldLabel, newLabel;
    GeoElement[] result;

    try {
      oldLabel = geo.getLabel();
      newLabel = newValue.getLabel();

      if (newLabel == null) {
        newLabel = oldLabel;
        newValue.setLabel(newLabel);
      }

      // make sure that points stay points and vectors stay vectors
      if (newValue instanceof ExpressionNode) {
        ExpressionNode n = (ExpressionNode) newValue;
        if (geo.isGeoPoint()) n.setForcePoint();
        else if (geo.isGeoVector()) n.setForceVector();
        else if (geo.isGeoFunction()) n.setForceFunction();
      }

      if (newLabel.equals(oldLabel)) {
        // try to overwrite
        result = processValidExpression(newValue, redefineIndependent);
        if (result != null && storeUndoInfo) app.storeUndoInfo();
        return result[0];
      } else if (cons.isFreeLabel(newLabel)) {
        newValue.setLabel(oldLabel);
        // rename to oldLabel to enable overwriting
        result = processValidExpression(newValue, redefineIndependent);
        result[0].setLabel(newLabel); // now we rename
        if (storeUndoInfo) app.storeUndoInfo();
        return result[0];
      } else {
        String str[] = {"NameUsed", newLabel};
        throw new MyError(app, str);
      }
    } catch (CircularDefinitionException e) {
      Application.debug("CircularDefinition");
      throw e;
    } catch (Exception e) {
      e.printStackTrace();
      throw new Exception(app.getError("InvalidInput") + ":\n" + newValue);
    } catch (MyError e) {
      e.printStackTrace();
      throw new Exception(e.getLocalizedMessage());
    } catch (Error e) {
      e.printStackTrace();
      throw new Exception(app.getError("InvalidInput") + ":\n" + newValue);
    }
  }
コード例 #15
0
ファイル: MidiSound.java プロジェクト: aliali555/geogebra
  /*
   * Uses the sequencer to play a Midi sequence from a .mid file
   * or a .txt file containing a JFugue string.
   */
  public void playMidiFile(String filePath) {

    try {

      if (filePath.equals("")) {
        // launch a file chooser (just for testing)
        final JFileChooser fc = new JFileChooser();
        int returnVal = fc.showOpenDialog(app.getMainComponent());
        if (returnVal == JFileChooser.APPROVE_OPTION) {
          filePath = fc.getSelectedFile().getAbsolutePath();
        }
      }

      String ext = filePath.substring(filePath.lastIndexOf(".") + 1);
      if (ext.equals("mid")) {
        // Load new sequence from .mid file
        tickPosition = 0;
        sequence = MidiSystem.getSequence(new File(filePath));
        playSequence(sequence, tickPosition);
      } else if (ext.equals("txt")) {
        playJFugueFromFile(new File(filePath));
      } else if (ext.equals("gm")) {
        loadSoundBank(new File(filePath));
      }

    } catch (IOException e) {
      e.printStackTrace();
    } catch (InvalidMidiDataException e) {
      e.printStackTrace();
    }
  }
コード例 #16
0
  private List<String> resetCompletions() {
    String text = getText();
    updateCurrentWord(false);
    completions = null;
    if (isEqualsRequired && !text.startsWith("=")) return null;

    boolean korean = app.getLocale().getLanguage().equals("ko");

    //    start autocompletion only for words with at least two characters
    if (korean) {
      if (Korean.flattenKorean(curWord.toString()).length() < 2) {
        completions = null;
        return null;
      }
    } else {
      if (curWord.length() < 2) {
        completions = null;
        return null;
      }
    }
    cmdPrefix = curWord.toString();

    if (korean) completions = dict.getCompletionsKorean(cmdPrefix);
    else completions = dict.getCompletions(cmdPrefix);

    completions = getSyntaxes(completions);
    return completions;
  }
コード例 #17
0
  private void updateListItems(double from, double to, double step) {
    if (isEmpty) return;

    double currentVal = from;
    int i = 0;

    while ((step > 0 && currentVal <= to + Kernel.MIN_PRECISION)
        || (step < 0 && currentVal >= to - Kernel.MIN_PRECISION)) {
      GeoElement listElement = list.get(i);

      // check we haven't run out of memory
      if (app.freeMemoryIsCritical()) {
        long mem = app.freeMemory();
        list.clearCache();
        kernel.initUndoInfo(); // clear all undo info
        Application.debug("AlgoSequence aborted: free memory reached " + mem);
        return;
      }

      // set local var value
      updateLocalVar(currentVal);

      // copy expression value to listElement
      // if it's undefined, just copy the undefined property
      if (expression.isDefined()) listElement.set(expression);
      else listElement.setUndefined();
      listElement.update();

      currentVal += step;
      if (kernel.isInteger(currentVal)) {
        currentVal = Math.round(currentVal);
      }
      i++;
    }
  }
コード例 #18
0
ファイル: AlgebraView.java プロジェクト: avilleret/geogebra
  public void setShowAuxiliaryObjects(boolean flag) {

    app.showAuxiliaryObjects = flag;

    cancelEditing();

    if (flag) {
      clearView();

      switch (getTreeMode()) {
        case DEPENDENCY:
          model.insertNodeInto(auxiliaryNode, rootDependency, rootDependency.getChildCount());
          break;
      }

      kernel.notifyAddAll(this);
    } else {
      // if we're listing the auxiliary objects in a single leaf we can
      // just remove that leaf, but for type-based categorization those
      // auxiliary nodes might be scattered across the whole tree,
      // therefore we just rebuild the tree
      switch (getTreeMode()) {
        case DEPENDENCY:
          if (auxiliaryNode.getParent() != null) {
            model.removeNodeFromParent(auxiliaryNode);
          }
          break;
        default:
          clearView();
          kernel.notifyAddAll(this);
      }
    }
  }
コード例 #19
0
ファイル: MidiSound.java プロジェクト: aliali555/geogebra
  public boolean initialize() {

    boolean success = true;

    try {
      sequencer = MidiSystem.getSequencer();
      sequencer.addMetaEventListener(this);

      if (synthesizer == null) {
        if ((synthesizer = MidiSystem.getSynthesizer()) == null) {
          Application.debug("getSynthesizer() failed!");
          return false;
        }

        Soundbank sb = synthesizer.getDefaultSoundbank();
        if (sb != null) {
          instruments = synthesizer.getDefaultSoundbank().getInstruments();
          synthesizer.loadInstrument(instruments[0]);
        }

        channels = synthesizer.getChannels();
      }
    } catch (MidiUnavailableException e) {
      e.printStackTrace();
      return false;
    } catch (Exception e) {
      e.printStackTrace();
      return false;
    }

    return success;
  }
コード例 #20
0
  private ArrayList<?> updateSelectedGeos(TreePath[] selPath) {
    selectionList.clear();

    if (selPath != null) {
      // add all selected paths
      for (int i = 0; i < selPath.length; i++) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) selPath[i].getLastPathComponent();

        if (node == node.getRoot()) {
          // root: add all objects
          selectionList.clear();
          selectionList.addAll(app.getKernel().getConstruction().getGeoSetLabelOrder());
          i = selPath.length;
        } else if (node.getParent() == node.getRoot()) {
          // type node: select all children
          for (int k = 0; k < node.getChildCount(); k++) {
            DefaultMutableTreeNode child = (DefaultMutableTreeNode) node.getChildAt(k);
            selectionList.add(child.getUserObject());
          }
        } else {
          // GeoElement
          selectionList.add(node.getUserObject());
        }
      }
    }

    return selectionList;
  }
コード例 #21
0
  /** shows this dialog and select GeoElement geo at screen position location */
  public void setVisibleWithGeos(ArrayList<GeoElement> geos) {
    kernel.clearJustCreatedGeosInViews();

    setViewActive(true);

    if (kernel.getConstruction().getGeoSetConstructionOrder().size() < MAX_GEOS_FOR_EXPAND_ALL)
      geoTree.expandAll();
    else geoTree.collapseAll();

    geoTree.setSelected(geos, false);
    if (!isShowing()) {
      // pack and center on first showing
      if (firstTime) {
        pack();
        setLocationRelativeTo(app.getMainComponent());
        firstTime = false;
      }

      // ensure min size
      Dimension dim = getSize();
      if (dim.width < MIN_WIDTH) {
        dim.width = MIN_WIDTH;
        setSize(dim);
      }
      if (dim.height < MIN_HEIGHT) {
        dim.height = MIN_HEIGHT;
        setSize(dim);
      }

      super.setVisible(true);
    }
  }
コード例 #22
0
ファイル: OptionsPanel.java プロジェクト: kovzol/geogebra
  private void doTextFieldActionPerformed(JTextField source) {
    if (isUpdating) return;
    try {
      String inputText = source.getText().trim();
      NumberValue nv;
      nv = app.getKernel().getAlgebraProcessor().evaluateToNumeric(inputText, false);
      double value = nv.getDouble();

      if (source == fldXMin) {
        settings.xMin = value;
        firePropertyChange("settings", true, false);
      } else if (source == fldXMax) {
        settings.xMax = value;
        firePropertyChange("settings", true, false);
      } else if (source == fldYMax) {
        settings.yMax = value;
        firePropertyChange("settings", true, false);
      } else if (source == fldYMin) {
        settings.yMin = value;
        firePropertyChange("settings", true, false);
      } else if (source == fldXInterval) {
        settings.xAxesInterval = value;
        firePropertyChange("settings", true, false);
      } else if (source == fldYInterval) {
        settings.yAxesInterval = value;
        firePropertyChange("settings", true, false);
      }

    } catch (NumberFormatException e) {
      e.printStackTrace();
    }
  }
コード例 #23
0
ファイル: AlgebraView.java プロジェクト: avilleret/geogebra
 public void updateFonts() {
   Font font = app.getPlainFont();
   setFont(font);
   editor.setFont(font);
   renderer.setFont(font);
   editTF.setFont(font);
 }
コード例 #24
0
ファイル: MyXMLio.java プロジェクト: geogebra/geogebra-old
  /** 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();
  }
コード例 #25
0
ファイル: AlgoLocus.java プロジェクト: tomasp8/geogebra
  /**
   * Calls Pcopy.updateCascade() to compute Qcopy. For non-continous constructions caching of
   * previous paramater positions is used.
   */
  private void pcopyUpdateCascade() {
    countUpdates++;

    if (continuous) {
      // CONTINOUS construction
      // don't use caching for continuous constructions:
      // the same position of Pcopy can have different results for Qcopy
      Pcopy.updateCascade();
    } else {
      // NON-CONTINOUS construction
      // check if the path parameter's resulting Qcopy is already in cache
      double param = Pcopy.getPathParameter().t;
      Point2D.Double cachedPoint = getCachedPoint(param);

      if (cachedPoint == null) {
        // measure time needed for update of construction
        long startTime = System.currentTimeMillis();

        // result not in cache: update Pcopy to compute Qcopy
        Pcopy.updateCascade();

        long updateTime = System.currentTimeMillis() - startTime;

        // if it takes too much time to calculate a single step, we stop
        if (updateTime > MAX_TIME_FOR_ONE_STEP) {
          Application.debug("AlgoLocus: max time exceeded " + updateTime);
          maxTimeExceeded = true;
        }

        // cache value of Qcopy
        putCachedPoint(param, Qcopy);
      } else {
        // use cached result to set Qcopy
        Qcopy.setCoords(cachedPoint.x, cachedPoint.y, 1.0);
        useCache++;
      }
    }

    //    	if (Qcopy.isDefined() && !Qcopy.isInfinite()) {
    //    		if (!foundDefined)
    //    			System.out.print(locus.label + " FIRST DEFINED param: " + Pcopy.getPathParameter().t);
    //    		else
    //    			System.out.print(locus.label + " param: " + Pcopy.getPathParameter().t);
    //        	System.out.println(", Qcopy: " + Qcopy);
    //    	} else {
    //    		System.out.print(locus.label + " param: " + Pcopy.getPathParameter().t);
    //        	System.out.println(", Qcopy: NOT DEFINED");
    //    	}

    // check found defined
    if (!foundDefined && Qcopy.isDefined() && !Qcopy.isInfinite()) {
      pathMover.init(Pcopy);
      PstartPos.set((GeoElement) Pcopy);
      QstartPos.set((GeoElement) Qcopy);
      foundDefined = true;

      // insert first point
      insertPoint(Qcopy.inhomX, Qcopy.inhomY, false);
    }
  }
コード例 #26
0
  /** Initializes Maxima. */
  public synchronized void initialize() {
    if (ggbMaxima != null) // this should never happen :)
    throw new IllegalStateException();

    MaximaConfiguration configuration = casParser.getKernel().getApplication().maximaConfiguration;

    if (configuration == null) configuration = JacomaxAutoConfigurator.guessMaximaConfiguration();

    MaximaProcessLauncher launcher = new MaximaProcessLauncher(configuration);
    ggbMaxima = launcher.launchInteractiveProcess();
    try {
      initMyMaximaFunctions();
      //			System.out.println(ggbMaxima.executeCall("1+2;"));

      int[] version = determineMaximaVersion();
      StringBuilder v = new StringBuilder("Maxima ");
      for (int i = 0; i < version.length; ++i) {
        v.append(version[i]);
        v.append('.');
      }
      Application.setCASVersionString(v.toString());

      // There are problems with Maxima versions < 5.22. See ticket #295
      if (version[0] < 5 || (version[0] == 5 && version[1] < 22))
        throw new MaximaVersionUnsupportedExecption(version);

    } catch (MaximaTimeoutException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
コード例 #27
0
ファイル: DataPanel.java プロジェクト: Serabe/geogebra
  private void populateDataTable(ArrayList<GeoElement> dataArray) {

    if (dataArray == null || dataArray.size() < 1) {
      return;
    }

    TableModel dataModel = null;
    GeoPoint2 geo = null;
    String[] titles = statDialog.getDataTitles();

    switch (statDialog.getMode()) {
      case StatDialog.MODE_ONEVAR:
        dataModel = new DefaultTableModel(dataArray.size(), 1);
        for (int row = 0; row < dataArray.size(); ++row) {
          dataModel.setValueAt(dataArray.get(row).toDefinedValueString(), row, 0);
        }

        dataTable.setModel(dataModel);
        dataTable.getColumnModel().getColumn(0).setHeaderValue(titles[0]);

        updateSelectionList(dataArray);

        break;

      case StatDialog.MODE_REGRESSION:
        dataModel = new DefaultTableModel(dataArray.size(), 2);
        for (int row = 0; row < dataArray.size(); ++row) {
          dataModel.setValueAt(((GeoPoint2) (dataArray.get(row))).getInhomX(), row, 0);
          dataModel.setValueAt(((GeoPoint2) (dataArray.get(row))).getInhomY(), row, 1);
        }

        dataTable.setModel(dataModel);
        dataTable
            .getColumnModel()
            .getColumn(0)
            .setHeaderValue(app.getMenu("Column.X") + ": " + titles[0]);
        dataTable
            .getColumnModel()
            .getColumn(1)
            .setHeaderValue(app.getMenu("Column.Y") + ": " + titles[1]);

        updateSelectionList(dataArray);

        break;
    }
  }
コード例 #28
0
ファイル: EditMenu.java プロジェクト: Serabe/geogebra
  public EditMenu(Application app) {
    super(app, app.getMenu("Edit"));

    initActions();
    initItems();

    update();
  }
コード例 #29
0
ファイル: ButtonDialog.java プロジェクト: kovzol/geogebra
  /**
   * Creates a dialog to create a new GeoNumeric for a slider.
   *
   * @param x, y: location of slider in screen coords
   */
  public ButtonDialog(Application app, int x, int y, boolean textField) {
    super(app.getFrame(), false);
    this.app = app;
    this.textField = textField;
    addWindowListener(this);
    this.x = x;
    this.y = y;
    // create temp geos that may be returned as result
    // Construction cons = app.getKernel().getConstruction();
    // button = textField ? new GeoTextField(cons) : new GeoButton(cons);
    // button.setEuclidianVisible(true);
    // button.setAbsoluteScreenLoc(x, y);

    createGUI();
    pack();
    setLocationRelativeTo(app.getMainComponent());
  }
コード例 #30
0
  /**
   * for AlgebraView changes in the tree selection and redefine dialog
   *
   * @return changed geo
   */
  public GeoElement changeGeoElementNoExceptionHandling(
      GeoElement geo, String newValue, boolean redefineIndependent, boolean storeUndoInfo)
      throws Exception {

    try {
      ValidExpression ve = parser.parseGeoGebraExpression(newValue);
      return changeGeoElementNoExceptionHandling(geo, ve, redefineIndependent, storeUndoInfo);
    } catch (Exception e) {
      e.printStackTrace();
      throw new Exception(app.getError("InvalidInput") + ":\n" + newValue);
    } catch (MyError e) {
      e.printStackTrace();
      throw new Exception(e.getLocalizedMessage());
    } catch (Error e) {
      e.printStackTrace();
      throw new Exception(app.getError("InvalidInput") + ":\n" + newValue);
    }
  }