Esempio n. 1
0
  public AutoCompleteDictionary getDictionary() {
    if (this.dict == null) {

      this.dict = component.isForCAS() ? app.getCommandDictionaryCAS() : app.getCommandDictionary();
    }
    return dict;
  }
Esempio n. 2
0
  @Override
  public void onClick(ClickEvent event) {
    Object source = event.getSource();
    App.debug("source is: " + source);

    if (source == btnOK) {
      App.debug("btnOk");
      returnOption = GOptionPane.OK_OPTION;
      close();
    }

    if (source == btnCancel) {
      App.debug("btnCancel");
      returnOption = GOptionPane.CANCEL_OPTION;
      close();
    }

    if (optionButtons == null) {
      return;
    }

    for (int i = 0; i < optionButtons.length; i++) {
      if (source == optionButtons[i]) {
        returnOption = i;
        close();
      }
    }
  }
Esempio n. 3
0
  protected final void setOptionPanelRegardingFocus(boolean updateEuclidianTab) {

    if (stayInCurrentPanelWithObjects()) return;

    OptionType type = getFocusedViewType();

    if (type != null) {
      if (type == OptionType.EUCLIDIAN || type == OptionType.EUCLIDIAN2) {

        if (app.getActiveEuclidianView()
            .getEuclidianController()
            .checkBoxOrTextfieldOrButtonJustHitted()) {
          // hit check box or text field : does nothing
          return;
        }

        // ev clicked
        setOptionPanelWithoutCheck(type);
        if (updateEuclidianTab) {
          setSelectedTab(type);
        }

      } else setOptionPanel(type);

      // here necessary no object is selected
      updateObjectPanelSelection(app.getSelectionManager().getSelectedGeos());
    }
  }
Esempio n. 4
0
  /**
   * acts when mouse has been released in euclidian controller
   *
   * @param creatorMode says if euclidian view is in creator mode (ie not move mode)
   */
  public void mouseReleasedForPropertiesView(boolean creatorMode) {

    GeoElement geo;
    if (objectPanel == null) {
      geo = null;
    } else {
      geo = objectPanel.consumeGeoAdded();
    }

    if (app.getSelectionManager().selectedGeosSize() > 0) {
      // selected geo is the most important
      updatePropertiesViewCheckConstants(app.getSelectionManager().getSelectedGeos());
    } else if (geo != null) { // last created geo
      if (creatorMode) { // if euclidian view is e.g. in move mode, then
        // geo was created by a script, so just show
        // object properties
        ArrayList<GeoElement> geos = new ArrayList<GeoElement>();
        geos.add(geo);
        setOptionPanel(OptionType.OBJECTS, geos);
      } else {
        setOptionPanel(OptionType.OBJECTS, null);
      }
    } else { // focus
      updateSelectedTab(Construction.Constants.NOT);
      setOptionPanelRegardingFocus(true);
      // updatePropertiesView();
    }
  }
Esempio n. 5
0
 public double getMaxSuggestionsHeight() {
   double ret = (app.getHeight() / 2);
   if (component != null) {
     ret =
         Math.max(
             29,
             Math.min(
                 ret,
                 app.getHeight()
                     + ((AppW) app).getAbsTop()
                     - component.getAbsoluteTop()
                     - component.toWidget().getOffsetHeight()
                     - ((AppW) app).getAppletFrame().getKeyboardHeight()));
   }
   return ret;
 }
Esempio n. 6
0
  public static String getImageURL(int mode, AppW app) {

    //		String modeText = app.getKernel().getModeText(mode);
    //		// bugfix for Turkish locale added Locale.US
    //		String iconName = "mode_" +StringUtil.toLowerCase(modeText)
    //				+ "_32";
    //

    // macro
    if (mode >= EuclidianConstants.MACRO_MODE_ID_OFFSET) {
      int macroID = mode - EuclidianConstants.MACRO_MODE_ID_OFFSET;
      try {
        Macro macro = app.getKernel().getMacro(macroID);
        String iconName = macro.getIconFileName();
        if (iconName == null || iconName.length() == 0) {
          // default icon
          return safeURI(myIconResourceBundle.mode_tool_32());
        }
        // use image as icon
        Image img = new NoDragImage(app.getImageManager().getExternalImageSrc(iconName), 32);
        return img.getUrl();
      } catch (Exception e) {
        App.debug("macro does not exist: ID = " + macroID);
        return "";
      }
    }

    return safeURI(getImageURLNotMacro(mode));
  }
Esempio n. 7
0
  protected void drawOnCanvas(org.geogebra.common.awt.GGraphics2D g2, String text) {
    App app = view.getApplication();
    setPreferredSize(getPreferredSize());

    GFont vFont = view.getFont();
    setLabelFont(app.getFontCanDisplay(text, false, vFont.getStyle(), getLabelFontSize()));

    g2.setFont(getLabelFont());
    g2.setStroke(EuclidianStatic.getDefaultStroke());

    g2.setPaint(geo.getObjectColor());

    if (geo.isVisible()) {

      drawWidget(g2);
    }
  }
Esempio n. 8
0
 private void showDialog(boolean autoComplete) {
   loc = app.getLocalization();
   updateGUI();
   center();
   if (inputField != null) {
     inputField.setAutoComplete(autoComplete);
   }
   show();
 }
 private static Icon loadIcon(String iconImage) {
   URL iconUrl =
       FileChooserCompletionListCellRenderer.class.getResource(ICON_LOCATION + iconImage);
   if (iconUrl == null) {
     App.debug("Could not load icon: " + iconImage);
     return new ImageIcon();
   }
   return new ImageIcon(iconUrl);
 }
Esempio n. 10
0
 protected GDimension drawLatex(
     GGraphics2D g2, GeoElement geo0, GFont font, String text, int x, int y) {
   App app = view.getApplication();
   return app.getDrawEquation()
       .drawEquation(
           app,
           geo0,
           g2,
           x,
           y,
           text,
           font,
           false,
           geo.getObjectColor(),
           geo.getBackgroundColor(),
           false,
           false,
           null);
 };
Esempio n. 11
0
  /**
   * Sets and shows the option panel for the given option type
   *
   * @param type type
   */
  public final void setOptionPanel(OptionType type) {

    ArrayList<GeoElement> geos = removeAllConstants(app.getSelectionManager().getSelectedGeos());

    if (type == OptionType.OBJECTS) { // ensure that at least one geo is
      // selected
      if (geos.size() == 0) {
        GeoElement geo = app.getSelectionManager().setFirstGeoSelectedForPropertiesView();
        if (geo == null) {
          // does nothing: stay in same panel
          return;
        }

        // add this first geo
        geos.add(geo);
      }
    }

    setOptionPanel(type, geos);
  }
Esempio n. 12
0
  /**
   * Brings up a new ExerciseBuilderDialog
   *
   * @param app application
   */
  public ExerciseBuilderDialog(App app) {
    super(false, false, null, ((AppW) app).getPanel());

    this.app = (AppW) app;
    // exerciseBuilderHandler = new ExerciseBuilderDOMHandler();
    exercise = app.getKernel().getExercise();
    if (exercise.isEmpty()) {
      exercise.initStandardExercise();
    }
    createGUI();
  }
Esempio n. 13
0
  // http://stackoverflow.com/questions/13789063/get-sound-from-a-url-with-java
  private void playMP3(final String url) {

    try {

      // Create the JavaFX Panel for the WebView
      JFXPanel fxPanel = new JFXPanel();
      fxPanel.setLocation(new Point(0, 0));

      // Initialize the webView in a JavaFX-Thread
      Platform.runLater(
          new Runnable() {
            public void run() {
              MediaPlayer player = new MediaPlayer(new Media(url));
              player.play();
            }
          });

      if (true) return;

      AudioInputStream in = AudioSystem.getAudioInputStream(new URL(url));
      AudioFormat baseFormat = in.getFormat();
      AudioFormat decodedFormat =
          new AudioFormat(
              AudioFormat.Encoding.PCM_SIGNED,
              baseFormat.getSampleRate(),
              16,
              baseFormat.getChannels(),
              baseFormat.getChannels() * 2,
              baseFormat.getSampleRate(),
              false);
      AudioInputStream din = AudioSystem.getAudioInputStream(decodedFormat, in);
      DataLine.Info info = new DataLine.Info(SourceDataLine.class, decodedFormat);
      SourceDataLine line = (SourceDataLine) AudioSystem.getLine(info);
      if (line != null) {
        line.open(decodedFormat);
        byte[] data = new byte[4096];
        // Start
        line.start();

        int nBytesRead;
        while ((nBytesRead = din.read(data, 0, data.length)) != -1) {
          line.write(data, 0, nBytesRead);
        }
        // Stop
        line.drain();
        line.stop();
        line.close();
        din.close();
      }
    } catch (Exception e) {
      App.debug("playing MP3 failed " + url + " " + e.toString());
    }
  }
Esempio n. 14
0
  /**
   * @param app
   * @param type Option panel type
   * @return true if given Option panel is showing (or is instantiated but hidden)
   */
  public static boolean isOptionPanelAvailable(App app, OptionType type) {

    boolean isAvailable = true;

    switch (type) {
      case EUCLIDIAN:
        isAvailable = app.getGuiManager().showView(App.VIEW_EUCLIDIAN);
        break;
      case EUCLIDIAN2:
        isAvailable = app.getGuiManager().showView(App.VIEW_EUCLIDIAN2);
        break;
      case EUCLIDIAN_FOR_PLANE:
        isAvailable = app.hasEuclidianViewForPlaneVisible();
        break;
      case EUCLIDIAN3D:
        isAvailable = app.getGuiManager().showView(App.VIEW_EUCLIDIAN3D);
        break;
      case SPREADSHEET:
        isAvailable = app.getGuiManager().showView(App.VIEW_SPREADSHEET);
        break;
      case CAS:
        isAvailable = app.getGuiManager().showView(App.VIEW_CAS);
        break;
      case OBJECTS:
        // always available
        break;
    }
    return isAvailable;
  }
Esempio n. 15
0
  public List<String> resetCompletions() {
    updateCurrentWord(false);
    completions = null;
    // if (isEqualsRequired && !text.startsWith("="))
    // return null;

    boolean korean = false;
    if (app.getLocalization() != null) {
      korean = "ko".equals(app.getLocalization().getLanguage());
    }

    // start autocompletion only for words with at least two characters
    // maybe this was also done in the Web case in MathQuillGGB, but
    // it should not do harm to check it twice...
    if (!InputHelper.needsAutocomplete(curWord, app.getKernel())) {
      completions = null;
      return null;
    }

    String cmdPrefix = curWord.toString();

    if (korean) {
      completions = getDictionary().getCompletionsKorean(cmdPrefix);
    } else {
      completions = getDictionary().getCompletions(cmdPrefix);
    }

    List<String> commandCompletions = getSyntaxes(completions);

    // Start with the built-in function completions
    completions = app.getParserFunctions().getCompletions(cmdPrefix);
    // Then add the command completions
    if (completions.isEmpty()) {
      completions = commandCompletions;
    } else if (commandCompletions != null) {
      completions.addAll(commandCompletions);
    }
    return completions;
  }
Esempio n. 16
0
  /**
   * @param renderer GL renderer
   * @param polygon polygon
   * @param pt polygon triangulation
   * @param vertices vertices of the polygon
   * @param verticesLength vertices length (may <> vertices.length due to cache)
   */
  public static final void drawPolygon(
      Renderer renderer,
      GeoPolygon polygon,
      PolygonTriangulation pt,
      Coords[] vertices,
      int verticesLength) {

    Coords n = polygon.getMainDirection();

    pt.clear();

    try {
      // simplify the polygon and check if there are at least 3 points
      // left
      if (pt.updatePoints() > 2) {

        // check if the polygon is convex
        Convexity convexity = pt.checkIsConvex();
        if (convexity != Convexity.NOT) {
          boolean reverse =
              polygon.getReverseNormalForDrawing() ^ (convexity == Convexity.CLOCKWISE);
          renderer.getGeometryManager().drawPolygonConvex(n, vertices, verticesLength, reverse);
        } else {
          // set intersections (if needed) and divide the polygon into
          // non self-intersecting polygons
          pt.setIntersections();

          // convert the set of polygons to triangle fans
          pt.triangulate();

          // compute 3D coords for intersections
          Coords[] verticesWithIntersections =
              pt.getCompleteVertices(vertices, polygon.getCoordSys(), verticesLength);

          // draw the triangle fans
          renderer
              .getGeometryManager()
              .drawTriangleFans(
                  n, verticesWithIntersections, pt.getMaxPointIndex(), pt.getTriangleFans());
        }
      }
    } catch (Exception e) {
      App.debug(e.getMessage());
      e.printStackTrace();
    }
  }
Esempio n. 17
0
 public boolean popupSuggestions() {
   // sub, or query is the same as the current word,
   // so moved from method parameter to automatism
   // updateCurrentWord(true);// although true would be nicer here
   updateCurrentWord(false); // compatibility should be preserved
   if (curWord != null && curWord.length() > 0 && !"sqrt".equals(curWord.toString())) {
     // for length check we also need flattenKorean
     if (!InputHelper.needsAutocomplete(this.curWord, app.getKernel())) {
       // if there is only one letter typed,
       // for any reason, this method should
       // hide the suggestions instead!
       hideSuggestions();
     } else {
       popup.requestSuggestions(
           new SuggestOracle.Request(this.curWord.toString(), querylimit), popupCallback);
     }
   } else {
     hideSuggestions();
   }
   return true;
 }
Esempio n. 18
0
  @Override
  public void focusGained(View v, Element el) {
    super.focusGained(v, el);
    focusedView = v;
    GeoGebraFrameW.useFocusedBorder(getArticleElement(), frame);

    // we really need to set it to true
    switch (v.getViewID()) {
      case App.VIEW_ALGEBRA:
      case App.VIEW_EUCLIDIAN:
      case App.VIEW_EUCLIDIAN2:
        this.getGlobalKeyDispatcher().setFocusedIfNotTab();
        break;
      default:
        if (App.isView3D(v.getViewID())
            || ((v.getViewID() >= App.VIEW_EUCLIDIAN_FOR_PLANE_START)
                && (v.getViewID() <= App.VIEW_EUCLIDIAN_FOR_PLANE_END))) {
          this.getGlobalKeyDispatcher().setFocusedIfNotTab();
        }
    }
  }
Esempio n. 19
0
  // ============================================================
  // Event Handlers
  // ============================================================
  //
  public void actionPerformed(Object source) {
    if (source instanceof AutoCompleteTextFieldW) {
      doTextFieldActionPerformed(source);
    } else if (source == minus || source == plus || source == none) {
      minus.setValue(source == minus);
      none.setValue(source == none);
      plus.setValue(source == plus);
      App.debug("[Data]  - 0 + has pressed");
      if (source == minus) {
        getModel().getSettings().setStemAdjust(-1);
      }
      if (source == none) {
        getModel().getSettings().setStemAdjust(0);
      }
      if (source == plus) {
        getModel().getSettings().setStemAdjust(1);
      }
      getModel().updatePlot(true);
    } else if (source == btnOptions) {
      optionsPanel.setPanel(getModel().getSelectedPlot());
      optionsPanel.setVisible(btnOptions.isSelected());
      resize();

    } else if (source == btnExport) {
    } else if (source == lbDisplayType) {
      int idx = lbDisplayType.getSelectedIndex();
      if (idx != -1) {
        PlotType t = plotTypes.get(idx);
        getModel().setSelectedPlot(t);
        getModel().updatePlot(true);
      }

      if (optionsPanel.isVisible()) {
        optionsPanel.setPanel(getModel().getSelectedPlot());
        resize();
      }
    }
  }
Esempio n. 20
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);
      Localization loc = app.getLocalization();
      String syntaxString;
      if (component.isForCAS()) {
        syntaxString = app.getLocalization().getCommandSyntaxCAS(cmdInt);
      } else {
        syntaxString =
            app.getExam() == null
                ? loc.getCommandSyntax(cmdInt)
                : app.getExam().getSyntax(cmdInt, loc, app.getSettings());
      }
      if (syntaxString != null) {
        if (syntaxString.endsWith(
            component.isForCAS() ? Localization.syntaxCAS : Localization.syntaxStr)) {

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

          continue;
        }
        for (String syntax : syntaxString.split("\\n")) {
          syntaxes.add(syntax);
        }
      }
    }
    return syntaxes;
  }
Esempio n. 21
0
  protected void close() {
    // if hide is called before the callback the callback can create another
    // Message (without being hidden instantanousely)!
    hide();

    if (requiresReturnValue) {
      if (returnOption == GOptionPane.CANCEL_OPTION) {
        returnValue = initialSelectionValue;
      } else {
        returnValue = inputField.getText();
      }
    }

    if (returnHandler != null) {
      App.debug("option: " + returnOption + "  value: " + returnValue);
      String[] dialogResult = {returnOption + "", returnValue};
      returnHandler.callback(dialogResult);
    }

    // return the focus to the input field calling this dialog
    if (caller != null) caller.setFocus(true);
    caller = null;
  }
Esempio n. 22
0
  private void updateButtonPanel() {

    buttonPanel.clear();

    switch (optionType) {
      case GOptionPane.CUSTOM_OPTION:
        optionButtons = new Button[optionNames.length];
        for (int i = optionNames.length - 1; i >= 0; i--) {
          optionButtons[i] = new Button(optionNames[i]);
          optionButtons[i].addClickHandler(this);

          // Styling of cancel button should be different
          if (optionNames[i].equals(app.getMenu("Cancel"))) {
            optionButtons[i].addStyleName("cancelBtn");
          }

          buttonPanel.add(optionButtons[i]);
        }
        break;

      case GOptionPane.OK_OPTION:
      case GOptionPane.DEFAULT_OPTION:
        buttonPanel.add(btnOK);
        setLabels();
        break;

      case GOptionPane.OK_CANCEL_OPTION:
        buttonPanel.add(btnOK);
        buttonPanel.add(btnCancel);
        setLabels();
        break;

      default:
        buttonPanel.add(btnOK);
        setLabels();
    }
  }
Esempio n. 23
0
    public void checkCursorKeys(KeyDownEvent e) {

      String text = autoCompleteTextField.getText(); // ?// (String)
      // delegate.getCellEditorValue();

      int keyCode = e.getNativeKeyCode();
      // Application.debug(e+"");
      switch (keyCode) {
        case KeyCodes.KEY_UP:
          if (isSuggesting()) {
            return;
          }
          if (isFormulaBarListener) return;

          // Application.debug("UP");
          stopCellEditing(0, -1, false);
          // ?//e.consume();
          tabReturnCol = -1;
          break;

        case KeyCodes.KEY_TAB:
          if (isFormulaBarListener) return;
          App.debug(" tab");
          // Application.debug("RIGHT");
          // shift-tab moves left
          // tab moves right
          if (tabReturnCol == -1) tabReturnCol = column;
          stopCellEditing(e.isShiftKeyDown() ? -1 : 1, 0, false);
          e.preventDefault();
          break;

        case KeyCodes.KEY_ENTER:
          if (isSuggesting()) {
            return;
          }

          // if incomplete command entered, want to move the cursor to
          // between []
          int bracketsIndex = text.indexOf("[]");
          if (bracketsIndex == -1) {

            if (tabReturnCol != -1) {
              int colOffset = tabReturnCol - column;
              stopCellEditing(colOffset, 1, true);
            } else {

              // TODO: in desktop this works with column, row + 1
              String cellBelowStr = GeoElementSpreadsheet.getSpreadsheetCellName(column, row + 1);
              GeoElement cellBelow = kernel.getConstruction().lookupLabel(cellBelowStr);

              boolean moveDown = cellBelow == null || !cellBelow.isFixed();

              // don't move down to cell below after <Enter> if it's
              // fixed
              stopCellEditing(0, moveDown ? 1 : 0, moveDown);
            }
          } else {
            autoCompleteTextField.setCaretPosition(bracketsIndex + 1);
            // ?//e.consume();
          }

          tabReturnCol = -1;
          break;

        case KeyCodes.KEY_DOWN:
          if (isSuggesting()) {
            return;
          }

          if (isFormulaBarListener) {
            // ?//e.consume();
            return;
          }
          // Application.debug("DOWN");
          stopCellEditing(0, 1, false);
          tabReturnCol = -1;
          break;

        case KeyCodes.KEY_LEFT:
          if (isFormulaBarListener) return;
          // Application.debug("LEFT");
          // Allow left/right keys to exit cell for easier data entry
          if (getCaretPosition() == 0) {
            stopCellEditing(-1, 0, false);
          }
          tabReturnCol = -1;
          break;

        case KeyCodes.KEY_RIGHT:
          if (isFormulaBarListener) return;
          // Application.debug("RIGHT");
          // Allow left/right keys to exit cell for easier data entry
          if (getCaretPosition() == text.length()) {
            stopCellEditing(1, 0, false);
          }

          tabReturnCol = -1;
          break;

        case KeyCodes.KEY_PAGEDOWN:
        case KeyCodes.KEY_PAGEUP:
          e.preventDefault();
          // ?//e.consume();
          tabReturnCol = -1;
          break;

          // An F1 keypress causes the focus to be lost, so we
          // need to set 'editing' to false to prevent the focusLost()
          // method from calling stopCellEditing()
          // ?//case KeyEvent.VK_F1:
          // ?// editing = false;
          // ?// break;

      }
    }
 @Override
 public boolean hasFocus() {
   App.debug("unimplemented");
   return false;
 }
Esempio n. 25
0
 private static void status(String status) {
   App.debug(status);
 }
Esempio n. 26
0
  @Override
  public boolean hit(Hitting hitting) {

    if (waitForReset) { // prevent NPE
      return false;
    }

    if (getGeoElement().getAlphaValue() < EuclidianController.MIN_VISIBLE_ALPHA_VALUE) {
      return false;
    }

    GeoPolygon poly = (GeoPolygon) getGeoElement();

    if (poly.getCoordSys() == null) {
      App.debug("" + poly);
      return false;
    }

    // project hitting origin on polygon plane
    if (globalCoords == null) {
      globalCoords = new Coords(4);
      inPlaneCoords = new Coords(4);
    }

    if (hitting.isSphere()) {
      hitting.origin.projectPlane(poly.getCoordSys().getMatrixOrthonormal(), globalCoords);

      if (hittingPointForOutline == null) {
        hittingPointForOutline = new GeoPoint3D(poly.getConstruction());
        hittingPointForOutline.setWillingCoordsUndefined();
        hittingPointForOutline.setWillingDirectionUndefined();
      }

      // try outline
      hittingPointForOutline.setCoords(globalCoords);
      poly.pointChanged(hittingPointForOutline);
      Coords p3d = hittingPointForOutline.getInhomCoordsInD3();

      if (project == null) {
        project = Coords.createInhomCoorsInD3();
      }

      double d = p3d.distance(hitting.origin);
      double scale = getView3D().getScale();
      if (d * scale <= poly.getLineThickness() + hitting.getThreshold()) {
        setZPick(-d, -d);
        setPickingType(PickingType.POINT_OR_CURVE);
        return true;
      }

      // try inside
      hittingPointForOutline.setCoords(globalCoords);
      hittingPointForOutline.setRegion(poly);
      poly.pointChangedForRegion(hittingPointForOutline);
      p3d = hittingPointForOutline.getInhomCoordsInD3();
      d = p3d.distance(hitting.origin);
      if (d * scale <= hitting.getThreshold()) {
        setZPick(-d, -d);
        setPickingType(PickingType.SURFACE);
        return true;
      }

    } else {
      hitting.origin.projectPlaneThruVIfPossible(
          poly.getCoordSys().getMatrixOrthonormal(),
          hitting.direction,
          globalCoords,
          inPlaneCoords);

      if (!hitting.isInsideClipping(globalCoords)) {
        return false;
      }

      boolean ret = false;

      // check if hitting projection hits the polygon
      if (poly.isInRegion(inPlaneCoords.getX(), inPlaneCoords.getY())) {
        double parameterOnHitting = inPlaneCoords.getZ(); // TODO use
        // other for
        // non-parallel
        // projection
        // :
        // -hitting.origin.distance(project[0]);
        setZPick(parameterOnHitting, parameterOnHitting);
        setPickingType(PickingType.SURFACE);
        ret = true;
      }

      // check if hitting is on path
      if (!poly.wasInitLabelsCalled()) {

        if (hittingPointForOutline == null) {
          hittingPointForOutline = new GeoPoint3D(poly.getConstruction());
        }
        hittingPointForOutline.setCoords(globalCoords);
        poly.pointChanged(hittingPointForOutline);
        Coords p3d = hittingPointForOutline.getInhomCoordsInD3();

        if (hitting.isInsideClipping(p3d)) {
          if (project == null) {
            project = Coords.createInhomCoorsInD3();
          }
          p3d.projectLine(
              hitting.origin,
              hitting.direction,
              project,
              parameters); // check distance to hitting line
          double d = p3d.distance(project);
          double scale = getView3D().getScale();
          if (d * scale <= poly.getLineThickness() + hitting.getThreshold()) {
            double z = -parameters[0];
            double dz = poly.getLineThickness() / scale;
            setZPick(z + dz, z - dz);
            setPickingType(PickingType.POINT_OR_CURVE);
            return true;
          }
        }
      }

      return ret;
    }

    return false;
  }
Esempio n. 27
0
  private void initActions() {

    if (app.isExam()) {
      addItem(
          MainMenu.getMenuBarHtml(
              GuiResources.INSTANCE.menu_icon_sign_out().getSafeUri().asString(),
              app.getMenu("Close"),
              true),
          true,
          new MenuCommand(app) {

            @Override
            public void doExecute() {
              // set Firefox dom.allow_scripts_to_close_windows in about:config to true to make this
              // work
              String[] optionNames = {app.getMenu("Cancel"), app.getMenu("Exit")};

              app.getGuiManager()
                  .getOptionPane()
                  .showOptionDialog(
                      app,
                      app.getMenu("ExitExamConfirm"),
                      app.getMenu("ExitExamConfirmTitle"),
                      GOptionPane.CUSTOM_OPTION,
                      GOptionPane.WARNING_MESSAGE,
                      null,
                      optionNames,
                      new AsyncOperation() {
                        @Override
                        public void callback(Object obj) {
                          String[] dialogResult = (String[]) obj;
                          if ("1".equals(dialogResult[0])) {
                            exitExam();
                          }
                        }
                      });
            }
          });
      return;
    }

    // this is enabled always
    addItem(
        MainMenu.getMenuBarHtml(
            GuiResources.INSTANCE.menu_icon_file_new().getSafeUri().asString(),
            app.getMenu("New"),
            true),
        true,
        new MenuCommand(app) {

          @Override
          public void doExecute() {
            ((DialogManagerW) app.getDialogManager()).getSaveDialog().showIfNeeded(newConstruction);
          }
        });

    // open menu is always visible in menu

    addItem(
        MainMenu.getMenuBarHtml(
            GuiResources.INSTANCE.menu_icon_file_open().getSafeUri().asString(),
            app.getPlain("Open"),
            true),
        true,
        new MenuCommand(app) {

          @Override
          public void doExecute() {
            app.openSearch(null);
            if (FileMenuW.this.onFileOpen != null) {
              FileMenuW.this.onFileOpen.run();
            }
          }
        });

    if (app.getLAF().undoRedoSupported()) {
      addItem(
          MainMenu.getMenuBarHtml(
              GuiResources.INSTANCE.menu_icon_file_save().getSafeUri().asString(),
              app.getMenu("Save"),
              true),
          true,
          new MenuCommand(app) {

            @Override
            public void doExecute() {
              app.getGuiManager().save();
            }
          });
    }

    // this is enabled always
    uploadToGGT =
        addItem(
            MainMenu.getMenuBarHtml(
                GuiResources.INSTANCE.menu_icon_file_share().getSafeUri().asString(),
                app.getMenu("Share"),
                true),
            true,
            new MenuCommand(app) {

              @Override
              public void doExecute() {
                if (!nativeShareSupported()) {
                  app.uploadToGeoGebraTube();
                } else {
                  app.getGgbApi()
                      .getBase64(
                          true,
                          new StringHandler() {

                            @Override
                            public void handle(String s) {
                              String title = app.getKernel().getConstruction().getTitle();
                              nativeShare(s, "".equals(title) ? "construction" : title);
                            }
                          });
                }
              }
            });
    App.debug("HAS EXPORT" + app.getLAF().exportSupported());
    if (app.getLAF().exportSupported()) {
      addItem(
          MainMenu.getMenuBarHtml(
              GuiResources.INSTANCE.menu_icons_file_export().getSafeUri().asString(),
              app.getMenu("Export"),
              true),
          true,
          new ExportMenuW(app));
    }

    app.getNetworkOperation().getView().add(this);

    if (!app.getNetworkOperation().isOnline()) {
      render(false);
    }
  }
Esempio n. 28
0
 public void removeFrequencyTable() {
   App.debug("removeFrequencyTable");
   plotPanelSouth.remove(spFrequencyTable);
   plotPanel.updateSize();
   resize(false);
 }
Esempio n. 29
0
 public void setTableFromGeoFrequencyTable(AlgoFrequencyTable parentAlgorithm, boolean b) {
   App.debug("setTableFromGeoFrequencyTable");
   frequencyTable.setTableFromGeoFrequencyTable(parentAlgorithm, b);
   resize(false);
 }
 @Override
 public boolean isShowing() {
   App.debug("unimplemented");
   return false;
 }