Example #1
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));
  }
  private void createExportMenu() {
    MenuBar menu = new MenuBar(true);
    MenuItem miToGraphich =
        new MenuItem(
            app.getMenu("CopyToGraphics"),
            new Command() {

              public void execute() {
                exportToEV();
              }
            });

    menu.addItem(miToGraphich);

    if (app.getLAF().copyToClipboardSupported()) {
      MenuItem miAsPicture =
          new MenuItem(
              app.getPlain("ExportAsPicture"),
              new Command() {

                public void execute() {
                  exportAsPicture();
                }
              });
      menu.addItem(miAsPicture);
    }

    String image = "<img src=\"" + AppResources.INSTANCE.export().getSafeUri().asString() + "\" >";
    btnExport.addItem(image, true, menu);
  }
 /**
  * If add symbol is clicked, <br>
  * a ToolCreationDialog will be created, if there are no (more) Macros which can be used for the
  * Exercise <br>
  * or a SubMenu like chooser of the tools which can be used for the Exercise will be shown.
  */
 void handleAddClick() {
   if (app.getKernel().getMacroNumber() == 0
       || app.getKernel().getMacroNumber() <= exercise.getParts().size()) {
     newTool();
   } else {
     userAddModes.setVisible(true);
   }
 }
Example #4
0
 public void updateUndoActions() {
   if (undoButton != null) {
     this.undoButton.setEnabled(app.getKernel().undoPossible());
   }
   if (this.redoButton != null) {
     this.redoButton.setEnabled(app.getKernel().redoPossible());
   }
 }
  protected void exportAsPicture() {
    app.getSelectionManager().clearSelectedGeos(true, false);
    app.updateSelection(false);

    app.setWaitCursor();
    app.copyEVtoClipboard(plotPanel);
    app.setDefaultCursor();
  }
 /** @param app {@link AppW} */
 public InputBarHelpPopup(AppW app, AutoCompleteTextFieldW field) {
   super();
   this.addStyleName("helpPopup");
   this.setAutoHideEnabled(true);
   ((InputBarHelpPanelW) app.getGuiManager().getInputHelpPanel()).setInputField(field);
   this.add((Widget) app.getGuiManager().getInputHelpPanel());
   this.addStyleName("GeoGebraPopup");
 }
  public void setLabels() {
    lblShow.setText(app.getLocalization().getPlain("Show"));
    showAuxiliaryObjects.setText(app.getLocalization().getPlain("AuxiliaryObjects"));

    lblSortMode.setText(app.getLocalization().getPlain("SortBy"));
    lblDescriptionMode.setText(app.getLocalization().getMenu("AlgebraDescriptions"));
    updateSortMode();
    updateDescription();
  }
  private void updateSortMode() {
    sortMode.clear();
    for (SortMode mode : supportedModes) {
      sortMode.addItem(app.getPlain(mode.toString()));
    }

    SortMode selectedMode = app.getAlgebraView().getTreeMode();
    sortMode.setSelectedIndex(supportedModes.indexOf(selectedMode));
  }
  /**
   * *************************************** Constructs a ComboStatPanel
   *
   * @param daView daView
   */
  public DataDisplayPanelW(DataAnalysisViewW daView) {

    this.app = daView.getApp();
    this.loc = (LocalizationW) app.getLocalization();
    daModel = daView.getModel();
    setModel(new DataDisplayModel(daModel, this));
    this.daView = daView;
    this.sample = new GeoNumeric(app.getKernel().getConstruction());

    // create the GUI
    createGUI();
  }
  private void updateDescription() {
    // ignoreActions = true;
    String[] modes =
        new String[] {app.getPlain("Value"), app.getPlain("Definition"), app.getPlain("Command")};
    description.clear();

    for (int i = 0; i < modes.length; i++) {
      description.addItem(app.getPlain(modes[i]));
    }

    int descMode = app.getKernel().getAlgebraStyle();
    description.setSelectedIndex(descMode);
    // ignoreActions = false;
  }
  public AnimationSpeedPanelW(AnimationSpeedModel m, final AppW app) {
    super(app.getLocalization(), app.getLocalization().getMenu("AnimationSpeed"));
    this.app = app;
    model = m;
    model.setListener(this);
    setModel(model);
    modeLabel = new Label();

    InputPanelW inputPanel = new InputPanelW(null, app, -1, false);
    tfAnimSpeed = inputPanel.getTextComponent();
    FlowPanel mainPanel = new FlowPanel();
    FlowPanel speedPanel = new FlowPanel();
    FlowPanel repeatPanel = new FlowPanel();
    speedPanel.setStyleName("optionsPanel rows");
    repeatPanel.setStyleName("optionsPanel rows");
    speedPanel.add(getLabel());
    speedPanel.add(tfAnimSpeed);
    repeatPanel.add(modeLabel);
    repeatPanel.add(getListBox());
    // mainPanel.add(LayoutUtil.panelRow(speedPanel, repeatPanel));
    mainPanel.add(LayoutUtilW.panelRowVertical(getLabel(), tfAnimSpeed));
    mainPanel.add(LayoutUtilW.panelRowVertical(modeLabel, getListBox()));
    setWidget(mainPanel);

    tfAnimSpeed.addKeyHandler(
        new KeyHandler() {

          public void keyReleased(KeyEvent e) {
            if (e.isEnterKey()) {
              doActionPerformed();
            }
          }
        });

    tfAnimSpeed.enableGGBKeyboard();

    tfAnimSpeed.addFocusListener(
        new FocusListenerW(this) {

          @Override
          protected void wrapFocusGained() {}

          @Override
          protected void wrapFocusLost() {
            doActionPerformed();
          }
        });
    tfAnimSpeed.requestToShowSymbolButton();
  }
  protected void exportToEV() {
    Integer euclidianViewID = null;
    // if null ID then use EV1 unless shift is down, then use EV2
    if (euclidianViewID == null) {
      euclidianViewID =
          GlobalKeyDispatcherW.getShiftDown()
              ? app.getEuclidianView2(1).getViewID()
              : app.getEuclidianView1().getViewID();
    }

    // do the export
    getModel().exportGeosToEV(euclidianViewID);

    daView.updateOtherDataDisplay(this);
  }
  /**
   * @param assignment the assignment for which the Listbox should set the fraction
   * @param res the result of the assignment for which the Listbox should set the fraction
   * @return a single select ListBox containing all possible fractions as defined in {@link
   *     Assignment#FRACTIONS} setting the fraction for a result in this assignment when they are
   *     changed
   */
  ListBox getFractionsLB(final Assignment assignment, final Result res) {
    final ListBox fractions = new ListBox();
    fractions.setMultipleSelect(false);
    for (int j = 0; j < Assignment.FRACTIONS.length; j++) {
      fractions.addItem(
          app.getKernel().format(Assignment.FRACTIONS[j] * 100, StringTemplate.defaultTemplate));
    }

    fractions.addChangeHandler(
        new ChangeHandler() {

          public void onChange(ChangeEvent event) {
            assignment.setFractionForResult(
                res, Assignment.FRACTIONS[fractions.getSelectedIndex()]);
          }
        });

    fractions.addAttachHandler(
        new Handler() {

          public void onAttachOrDetach(AttachEvent event) {
            fractions.setSelectedIndex(
                Arrays.binarySearch(Assignment.FRACTIONS, assignment.getFractionForResult(res)));
          }
        });

    return fractions;
  }
Example #14
0
  public Widget getTableCellEditorWidget(
      MyTableW table0, Object value0, boolean isSelected, int row0, int column0) {

    table = table0;

    if (value0 instanceof String) { // clicked to type
      value = null;
    } else {
      value = (GeoElement) value0;
    }

    column = column0;
    row = row0;
    String text = "";

    if (value != null) {
      text = getEditorInitString(value);
      int index = text.indexOf("=");
      if ((!value.isGeoText())) {
        if (index == -1) {
          text = "=" + text;
        }
      }
    }

    autoCompleteTextField.setText(text);
    autoCompleteTextField.setFont(app.getFontCanDisplay(text));
    autoCompleteTextField.requestFocus();

    editing = true;

    return autoCompleteTextField;
  }
 @Override
 public void setLabels() {
   super.setLabels();
   Localization loc = app.getLocalization();
   getLabel().setText(loc.getPlain("AnimationSpeed") + ":");
   modeLabel.setText(loc.getPlain("Repeat") + ": ");
 }
 private void doActionPerformed() {
   GeoNumberValue animSpeed =
       app.getKernel().getAlgebraProcessor().evaluateToNumeric(tfAnimSpeed.getText(), false);
   if (animSpeed != null) {
     model.applySpeedChanges(animSpeed);
   }
 }
 public void onChange(ChangeEvent event) {
   Object source = event.getSource();
   if (source == sortMode) {
     int i = sortMode.getSelectedIndex();
     app.getSettings().getAlgebra().setTreeMode(supportedModes.get(i).ordinal());
   }
 }
Example #18
0
  /** handle click on {@link PopupMenuButtonW this button} */
  void handleClick() {
    onClickAction();
    if (EuclidianStyleBarW.CURRENT_POP_UP != myPopup || !app.wasPopupJustClosed()) {
      if (EuclidianStyleBarW.CURRENT_POP_UP != null) {
        EuclidianStyleBarW.CURRENT_POP_UP.hide();
      }
      EuclidianStyleBarW.CURRENT_POP_UP = myPopup;

      app.registerPopup(myPopup);
      myPopup.showRelativeTo(getWidget());
      myPopup.getFocusPanel().getElement().focus();
    } else {
      myPopup.setVisible(false);
      EuclidianStyleBarW.CURRENT_POP_UP = null;
    }
  }
Example #19
0
 /** adds a panel to show the "real" frequency */
 protected void addFrequencyPanel() {
   this.realFreqContainer = new FlowPanel();
   this.realFreqContainer.addStyleName("rowContainer");
   this.realFreqLabel = new Label(app.getMenu(REAL_FREQUENCY) + ": " + this.realFreq);
   this.realFreqContainer.add(this.realFreqLabel);
   this.dataValues.add(this.realFreqContainer);
   setRealFreqVisible(false);
 }
Example #20
0
 /**
  * @param online wether the application is online renders a the online - offline state of the
  *     FileMenu
  */
 public void render(boolean online) {
   uploadToGGT.setEnabled(online);
   if (!online) {
     uploadToGGT.setTitle(app.getMenu("YouAreOffline"));
   } else {
     uploadToGGT.setTitle("");
   }
 }
 public void onClick(ClickEvent e) {
   Element target = e.getNativeEvent().getEventTarget().cast();
   boolean isEditing = assignmentsTable.isVisible();
   if (target == btApply.getElement()) {
     if (isEditing) {
       hide();
       app.getActiveEuclidianView().requestFocusInWindow();
       app.storeUndoInfo();
       app.getKernel().notifyRepaint();
     } else {
       assignmentsTable.setVisible(true);
       checkAssignmentsTable.setVisible(false);
       btTest.setText(app.getPlain("Test"));
       btApply.setText(app.getPlain("OK"));
       hide();
       setGlassEnabled(true);
       center();
     }
   } else if (target == btTest.getElement()) {
     if (isEditing) {
       assignmentsTable.setVisible(false);
       checkAssignmentsTable.setVisible(true);
       check();
       btTest.setText(app.getPlain("Check"));
       btApply.setText(app.getPlain("Back"));
       hide();
       setGlassEnabled(false);
       center();
     } else {
       check();
     }
   }
 }
  private void createGUI() {

    getCaption().setText(app.getMenu("Exercise.CreateNew"));

    setWidget(mainWidget = new VerticalPanel());
    addDomHandlers(mainWidget);
    assignmentsTable = new FlexTable();
    FlexCellFormatter cellFormatter = assignmentsTable.getFlexCellFormatter();
    cellFormatter.setColSpan(0, 1, 2);

    assignmentsTable.setWidget(0, 1, new Label(app.getPlain("Tool")));
    assignmentsTable.setWidget(0, 2, new Label(app.getPlain("HintForCorrect")));
    assignmentsTable.setWidget(0, 3, new Label(app.getPlain("Fraction")));

    createAssignmentsTable();
    checkAssignmentsTable = new FlexTable();
    checkAssignmentsTable.setVisible(false);

    mainWidget.add(assignmentsTable);
    mainWidget.add(checkAssignmentsTable);

    addList = new UnorderedList();
    addDomHandlers(addList);
    // addIcon = new ListItem();
    Image addIcon = new Image(GuiResources.INSTANCE.menu_icon_file_new());
    ListItem addListItem = new ListItem();
    addListItem.addStyleName("toolbar_item");
    addListItem.add(addIcon);
    addList.add(addListItem);

    userAddModes = new ToolbarSubemuW(app, 1);
    userAddModes.addStyleName("toolbar_item");
    userAddModes.setVisible(false);
    for (int i = 0; i < app.getKernel().getMacroNumber(); i++) {
      if (!exercise.usesMacro(i)) {
        ListItem item = userAddModes.addItem(i + EuclidianConstants.MACRO_MODE_ID_OFFSET);
        addDomHandlers(item);
      }
    }
    addList.add(userAddModes);
    mainWidget.add(addList);

    mainWidget.add(bottomWidget = new FlowPanel());
    bottomWidget.setStyleName("DialogButtonPanel");

    btApply = new Button(app.getPlain("OK"));
    btApply.addClickHandler(this);
    btApply.getElement().getStyle().setMargin(3, Style.Unit.PX);

    addCancelButton();

    btTest = new Button(app.getPlain("Test"));
    btTest.addClickHandler(this);
    btTest.getElement().getStyle().setMargin(3, Style.Unit.PX);

    bottomWidget.add(btTest);
    bottomWidget.add(btApply);
    // bottomWidget.add(btCancel);

  }
 /**
  * Handles the remove of an Assignment from the Exercise
  *
  * @param event the original event to determine which row should be removed from Table
  * @param assignment the assignment to remove from the Exercise
  */
 void handleAssignmentDeleteClick(ClickEvent event, Assignment assignment) {
   ListItem item =
       userAddModes.addItem(
           app.getKernel().getMacroID(assignment.getTool())
               + EuclidianConstants.MACRO_MODE_ID_OFFSET);
   addDomHandlers(item);
   exercise.remove(assignment);
   assignmentsTable.removeRow(assignmentsTable.getCellForEvent(event).getRowIndex());
 }
Example #24
0
 @Override
 public void setLabels() {
   updateCaptionLabel();
   // is null for TimeSetting
   if (this.realFreqLabel != null) {
     this.realFreqLabel.setText(app.getMenu(REAL_FREQUENCY) + ": " + this.realFreq);
   }
   updateContent();
 }
 /**
  * @param fileName of user defined tool
  * @return {@link SafeUri} of Icon with fileName
  */
 SafeUri getIconFile(String fileName) {
   if (!fileName.isEmpty()) {
     String imageURL = app.getImageManager().getExternalImageSrc(fileName);
     if (imageURL != null) {
       return UriUtils.fromString(imageURL);
     }
   }
   return ((ImageResource) GGWToolBar.getMyIconResourceBundle().mode_tool_32()).getSafeUri();
 }
Example #26
0
 public void onSliderInput() {
   if (mySlider != null) {
     setSliderValue(mySlider.getValue());
   }
   if (changeEventHandler != null) {
     changeEventHandler.fireActionPerformed(this);
   } else {
     ((EuclidianStyleBarW) app.getActiveEuclidianView().getStyleBar()).fireActionPerformed(this);
   }
   fireActionPerformed();
   updateGUI();
 }
  public void updateStemPlot(String latex) {
    btnOptions.setVisible(false);
    btnExport.setVisible(false);

    String latexStr = DrawEquationWeb.inputLatexCosmetics(latex);
    if (app.has(Feature.JLM_IN_WEB)) {
      DrawEquationWeb.paintOnCanvas(sample, latexStr, latexCanvas, app.getFontSize());

    } else {

      imageContainer.setText("");
      DrawEquationWeb.drawEquationAlgebraView(
          imageContainer.getElement(), "\\mathrm {" + latexStr + "}", true);
    }

    if (hasControlPanel) {
      controlDecks.showWidget(STEM_IDX);
    }

    displayDeckPanel.showWidget(IMAGE_IDX);
  }
  /** Creates a display panel to hold an image, e.g. tabletext */
  private void createImagePanel() {

    imagePanel = new FlowPanel();
    if (app.has(Feature.JLM_IN_WEB)) {
      latexCanvas = Canvas.createIfSupported();
      imagePanel.add(latexCanvas);
    } else {
      imageContainer = new Label();
      imagePanel.add(imageContainer);
    }
    imagePanel.setStyleName("daImagePanel");
  }
Example #29
0
  private void createSymbolTable() {

    Localization loc = app.getLocalization();

    String[][] map = TableSymbols.basicSymbolsMap(loc);

    String[] icons = TableSymbols.basicSymbols(loc, map);
    String[] iconshelp = TableSymbols.basicSymbolsToolTips(loc, map);

    symbolTable = new SymbolTableW(icons, iconshelp);
    add(symbolTable);
    symbolTable.addClickHandler(this);
  }
  public void resize(int offsetWidth, int offsetHeight, boolean update) {
    int w = offsetWidth;
    int h = offsetHeight;

    int width = optionsPanel.isVisible() ? w - optionsPanel.getOffsetWidth() - PLOTPANEL_MARGIN : w;
    int height =
        (frequencyTable.isVisible() ? h - spFrequencyTable.getOffsetHeight() : h)
            - lbDisplayType.getOffsetHeight()
            - PLOTPANEL_MARGIN;

    if (daModel.isRegressionMode()) {
      height -= 2 * lblTitleX.getOffsetHeight();
      height -= lblTitleY.getOffsetHeight();
    }

    if (width < PLOTPANEL_MIN_WIDTH) {
      width = PLOTPANEL_MIN_WIDTH;
    }

    if (height < PLOTPANEL_MIN_HEIGHT) {
      height = PLOTPANEL_MIN_HEIGHT;
    }

    if (oldWidth == width && oldHeight == height) {
      return;
    }

    oldWidth = width;
    oldHeight = height;

    plotPanel.setPreferredSize(new GDimensionW(width, height));
    if (optionsPanel.isVisible()) {
      optionsPanel.resize(height);
    }
    plotPanel.updateSize();
    plotPanel.repaintView();
    plotPanel.getEuclidianController().calculateEnvironment();
    if (update) {
      getModel().updatePlot(false);
    }

    if (app.has(Feature.JLM_IN_WEB)) {
      imagePanel.setPixelSize(width, height);

    } else {
      imageContainer.setPixelSize(width, height);
    }
  }