Example #1
0
  /** Update all elements in the title bar. */
  public void updateTitleBar() {

    // The view is in the main window
    if (frame == null) {
      closeButton.setVisible(!isMaximized());
      windowButton.setVisible(false); // !isMaximized());
      unwindowButton.setVisible(false);
      unwindowButton2.setVisible(false);
      maximizeButton.setVisible(isMaximized());
      titleLabel.setVisible(true);

    } else {
      closeButton.setVisible(false);
      unwindowButton.setVisible(true);
      unwindowButton2.setVisible(true);
      windowButton.setVisible(false);
      maximizeButton.setVisible(false);
      titleLabel.setVisible(false);
    }

    if (isMaximized()) {
      maximizeButton.setIcon(app.getScaledIcon("view-unmaximize.png"));
    } else {
      maximizeButton.setIcon(app.getScaledIcon("view-maximize.png"));
    }

    updateLabels();
  }
Example #2
0
  /** Update the panel. */
  public void updatePanel() {

    // load content if panel was hidden till now
    if (component == null && isVisible()) {
      component = loadComponent();
      add(component, BorderLayout.CENTER);

      if (isStyleBarVisible()) {
        setStyleBar();
      }

      // load toolbar if this panel has one
      if (hasToolbar()) {
        toolbar = new ToolbarD(app, this);

        if (isOpenInFrame()) {
          toolbarContainer = new ToolbarContainer(app, false);
          toolbarContainer.addToolbar(toolbar);
          toolbarContainer.buildGui();
          toolbarContainer.setActiveToolbar(getViewId());
          toolbarPanel.add(toolbarContainer, BorderLayout.CENTER);
        }
      }

      // euclidian view uses the general toolbar
      if (this instanceof EuclidianDockPanelAbstract) {
        // TODO implement..
      }
    }

    // make panels visible if necessary
    if (isVisible()) {

      if (isStyleBarVisible()) {
        setStyleBar();
      }

      // display toolbar panel if the dock panel is open in a frame
      if (hasToolbar()) {
        toolbarPanel.setVisible(frame != null);
      }
    }

    // if this is the last dock panel don't display the title bar, otherwise
    // take the user's configuration into consideration

    titlePanel.setVisible(
        app.getSettings().getLayout().showTitleBar()
            && !(isAlone && !isMaximized())
            && !app.isApplet()
            && (!isOpenInFrame()));

    // update stylebar visibility
    setShowStyleBar(isStyleBarVisible());
    updateStyleBarVisibility();

    // update the title bar if necessary
    updateTitleBarIfNecessary();
  }
Example #3
0
 /** Update fonts. */
 public void updateFonts() {
   if (hasFocus && dockManager.hasFullFocusSystem()) {
     titleLabel.setFont(app.getBoldFont());
   } else {
     titleLabel.setFont(app.getPlainFont());
   }
   updateIcons();
 }
Example #4
0
 @Override
 public void setVisible(boolean visible) {
   if (this.visible != visible) {
     this.visible = visible;
     if (app.getGuiManager() != null) {
       app.getGuiManager().updatePropertiesViewStylebar();
     }
   }
 }
Example #5
0
 private void setLocation() {
   if (app.getGuiManager().showView(App.VIEW_DATA_ANALYSIS)) {
     setLocationRelativeTo(
         ((DataAnalysisViewD) app.getGuiManager().getDataAnalysisView())
             .getDataAnalysisViewComponent());
   } else {
     setLocationRelativeTo(app.getMainComponent());
   }
 }
Example #6
0
 /** sets the active toolbar */
 protected void setActiveToolBar() {
   if (hasToolbar()) {
     ((GuiManagerD) app.getGuiManager()).getToolbarPanel().setActiveToolbar(toolbar);
   } else {
     ((GuiManagerD) app.getGuiManager()).getToolbarPanel().setActiveToolbar(-1);
   }
   // switching the view may cause shrinking of help panel,
   // we need an update here
   ((GuiManagerD) app.getGuiManager()).getToolbarPanel().validate();
   ((GuiManagerD) app.getGuiManager()).getToolbarPanel().updateHelpText();
 }
 @Override
 protected void setActiveToolBar() {
   // use the focused euclidian view for active toolbar
   if (dockManager.getFocusedEuclidianPanel() == null
       || !dockManager.getFocusedEuclidianPanel().hasToolbar()) {
     ((GuiManagerD) app.getGuiManager()).getToolbarPanel().setActiveToolbar(-1);
   } else {
     ((GuiManagerD) app.getGuiManager())
         .getToolbarPanel()
         .setActiveToolbar(dockManager.getFocusedEuclidianPanel().getToolbar());
   }
 }
Example #8
0
  public void actionPerformed(ActionEvent e) {
    Object source = e.getSource();

    if (source == btnOK) {
      dataSourcePanel.applySettings();
      app.getGuiManager().setShowView(true, App.VIEW_DATA_ANALYSIS);
      app.setMoveMode();
      setVisible(false);

    } else if (source == btnCancel) {
      app.setMoveMode();
      setVisible(false);
    }
  }
Example #9
0
  /**
   * ***************************************** Constructs the dialog
   *
   * @param app
   * @param mode
   */
  public DataSourceDialog(AppD app, int mode) {

    // non-modal dialog
    super(app.getFrame(), app.getMenu(""), false);

    this.app = app;
    this.mode = mode;
    addWindowFocusListener(this);
    createGUI();

    this.setResizable(true);
    pack();
    setLocation();
  }
Example #10
0
 private void updateToggleStyleBarButtons() {
   if (toggleStyleBarButton != null) {
     if (showStyleBar) {
       toggleStyleBarButton.setIcon(app.getScaledIcon("triangle_down.png"));
       // toggleStyleBarButton.setRolloverIcon(app.getScaledIcon("triangle-down-rollover.png"));
     } else {
       toggleStyleBarButton.setIcon(app.getScaledIcon("triangle_right.png"));
       // toggleStyleBarButton.setRolloverIcon(app.getScaledIcon("triangle-right-rollover.png"));
     }
   }
   if (toggleStyleBarButton2 != null) {
     toggleStyleBarButton2.setIcon(toggleStyleBarButton.getIcon());
     // toggleStyleBarButton2.setRolloverIcon(toggleStyleBarButton.getRolloverIcon());
   }
 }
Example #11
0
  /** Display this panel in an external window. */
  public void windowPanel() {

    // try to hide the panel
    if (dockManager.hide(this, false)) {

      // move the toolbar from the main window to the panel
      if (hasToolbar()) {
        if (toolbarContainer == null) {
          toolbarContainer = new ToolbarContainer(app, false);
        }

        toolbarContainer.addToolbar(toolbar);
        toolbarContainer.buildGui();
        toolbarContainer.setActiveToolbar(getViewId());
        toolbarPanel.add(toolbarContainer, BorderLayout.CENTER);

        ToolbarContainer mainContainer = ((GuiManagerD) app.getGuiManager()).getToolbarPanel();
        mainContainer.removeToolbar(toolbar);
        mainContainer.updateToolbarPanel();
      }

      setVisible(true);
      createFrame();
    }
  }
Example #12
0
  private void setRegressionLabels() {

    for (Regression r : Regression.values()) {

      regressionLabels[r.ordinal()] = app.getMenu(r.getLabel());
    }
  }
  private void doActionPerformed(Object source) {

    // ========================================
    // layout options

    if (source == cbShowFormulaBar) {
      settings().setShowFormulaBar(cbShowFormulaBar.isSelected());
    }

    if (source == cbShowGrid) {
      settings().setShowGrid(cbShowGrid.isSelected());
    } else if (source == cbShowRowHeader) {
      settings().setShowRowHeader(cbShowRowHeader.isSelected());
    } else if (source == cbShowColumnHeader) {
      settings().setShowColumnHeader(cbShowColumnHeader.isSelected());
    } else if (source == cbShowHScrollbar) {
      settings().setShowHScrollBar(cbShowHScrollbar.isSelected());
    } else if (source == cbShowVScrollbar) {
      settings().setShowVScrollBar(cbShowVScrollbar.isSelected());
    } else if (source == cbAllowSpecialEditor) {
      settings().setAllowSpecialEditor(cbAllowSpecialEditor.isSelected());
    } else if (source == cbAllowToolTips) {
      settings().setAllowToolTips(cbAllowToolTips.isSelected());
    } else if (source == cbPrependCommands) {
      settings().setEqualsRequired(cbPrependCommands.isSelected());
    } else if (source == cbEnableAutoComplete) {
      settings().setEnableAutoComplete(cbEnableAutoComplete.isSelected());
    } else if (source == cbShowNavigation) {
      app.toggleShowConstructionProtocolNavigation(App.VIEW_SPREADSHEET);
    }

    updateGUI();
  }
Example #14
0
  private void initGUI() {

    removeAll();

    ImageIcon kbdIcon = app.getScaledIcon("cas-keyboard.png");

    iconHeight = kbdIcon.getIconHeight();
    iconDimension = new Dimension(iconHeight, iconHeight);
    btnShowKeyboard = new MyToggleButton(kbdIcon, iconHeight);

    createTextButtons();

    add(btnUseAsText);
    add(btnTextColor);
    add(btnBold);
    add(btnItalic);

    btnShowKeyboard.addActionListener(this);
    add(btnShowKeyboard);
    // add(btnTextSize); //TODO: Fix text size

    popupBtnList = newPopupBtnList();
    toggleBtnList = newToggleBtnList();

    updateStyleBar();
  }
Example #15
0
  @BeforeClass
  public static void setupCas() {
    app = new AppD(new CommandLineArguments(new String[] {"--giac"}), new JFrame(), false);
    // Set language to something else than English to test automatic translation.
    app.setLanguage(Locale.GERMANY);
    // app.fillCasCommandDict();

    kernel = app.getKernel();
    cas = kernel.getGeoGebraCAS();
    logger = new CASTestLogger();
    // Setting the general timeout to 13 seconds. Feel free to change this.
    kernel.getApplication().getSettings().getCasSettings().setTimeoutMilliseconds(13000);

    try {
      Log.debug("CAS: loading testcases");
      String json = readFileAsString("../web/war/__giac.js");
      Log.debug("CAS: parsing testcases");
      Log.debug("CAS: testcases parsed");
      JSONArray testsJSON = new JSONArray(json.substring("var __giac = ".length()));
      Assert.assertNotSame(0, testsJSON.length());
      int i = 1;
      while (i < testsJSON.length()) {

        JSONObject test = testsJSON.getJSONObject(i);
        i++;
        String cat = "general";
        if (test.has("cat")) {
          cat = test.getString("cat");
        }
        if (!testcases.containsKey(cat)) {
          /*System.out.println("@Test");
          System.out.println("public void test"+cat+"(){");
          System.out.println("	testCat(\""+cat+"\");");
          System.out.println("}\n");*/

          testcases.put(cat, new HashMap<String, String>());
        }
        if (test.has("round")) {
          testcases.get(cat).put(test.getString("cmd"), test.getString("round"));
        } else {
          testcases.get(cat).put(test.getString("cmd"), test.getString("result"));
        }
      }
    } catch (Throwable e) {
      e.printStackTrace();
    }
  }
  private void initGUI() {

    wrappedPanel.removeAll();
    wrappedPanel.setLayout(new BorderLayout());
    wrappedPanel.add(new JScrollPane(buildLayoutOptionsPanel()), BorderLayout.CENTER);

    app.setComponentOrientation(wrappedPanel);
  }
Example #17
0
  /**
   * Mark this panel as focused. When gaining focus the panel will automatically request focus for
   * its parent frame.
   *
   * @remark The focus system implemented here has nothing to do with swings focus system, therefore
   *     Swings focus methods won't work.
   * @param hasFocus has the focus
   * @param updatePropertiesView update properties view
   */
  public void setFocus(boolean hasFocus, boolean updatePropertiesView) {

    if (hasFocus && updatePropertiesView) {
      ((GuiManagerD) app.getGuiManager()).updatePropertiesView();
    }

    setFocus(hasFocus);
  }
  @Override
  protected JComponent loadComponent() {
    JScrollPane scrollPane = new JScrollPane((Component) app.getGuiManager().getAlgebraView());
    scrollPane.setBorder(BorderFactory.createEmptyBorder());
    scrollPane.setBackground(Color.white);

    return scrollPane;
  }
Example #19
0
 /** @return If the style bar should be visible. */
 protected boolean isStyleBarVisible() {
   if (id == App.VIEW_EUCLIDIAN || id == App.VIEW_EUCLIDIAN2 || id == App.VIEW_ALGEBRA) {
     if (!app.getSettings().getLayout().isAllowingStyleBar()) {
       return false;
     }
   }
   return (showStyleBar || !titlePanel.isVisible());
 }
  /**
   * Helper bar.
   *
   * @param cpView construction protocol view
   * @param app application
   */
  public ConstructionProtocolStyleBar(ConstructionProtocolViewD cpView, AppD app) {
    this.cpView = cpView;
    this.app = app;
    this.loc = app.getLocalization();

    setFloatable(false);

    addButtons();
  }
 /**
  * @param app app
  * @param sb sb
  * @return .ggb file encoded as base64 string
  */
 public static boolean appendBase64(AppD app, StringBuilder sb) {
   ByteArrayOutputStream baos = new ByteArrayOutputStream();
   try {
     app.getXMLio().writeGeoGebraFile(baos, false);
     sb.append(org.geogebra.common.util.Base64.encode(baos.toByteArray(), 0));
   } catch (IOException e) {
     e.printStackTrace();
     return false;
   }
   return true;
 }
Example #22
0
  /**
   * @param source event source
   * @param targetGeos cells that need updating
   */
  protected void processSource(Object source, ArrayList<GeoElement> targetGeos) {

    if (source == btnTextColor) {
      if (btnTextColor.getSelectedIndex() >= 0) {
        applyTextColor(targetGeos);
        // btnTextColor.setFgColor((Color)btnTextColor.getSelectedValue());
        // btnItalic.setForeground((Color)btnTextColor.getSelectedValue());
        // btnBold.setForeground((Color)btnTextColor.getSelectedValue());
      }
    } else if (source == btnBold) {
      applyFontStyle(targetGeos);
    } else if (source == btnItalic) {
      applyFontStyle(targetGeos);
    } else if (source == btnTextSize) {
      applyTextSize(targetGeos);
    } else if (source == btnUseAsText) {
      int i = casView.getConsoleTable().getEditingRow();
      int pos =
          ((CASTableCellEditorD)
                  casView.getConsoleTable().getCellEditor(i, CASTableD.COL_CAS_CELLS))
              .getCaretPosition();
      applyUseAsText(targetGeos);
      casView.getConsoleTable().startEditingRow(i);
      ((CASTableCellEditorD) casView.getConsoleTable().getCellEditor(i, CASTableD.COL_CAS_CELLS))
          .setCaretPosition(pos);
    } else if (source == btnShowKeyboard) {
      if (((GuiManagerInterfaceD) app.getGuiManager()) != null) {
        if (AppD.isVirtualKeyboardActive()
            && !((GuiManagerD) app.getGuiManager()).showVirtualKeyboard()) {

          // if keyboard is active but hidden, just show it
          ((GuiManagerD) app.getGuiManager()).toggleKeyboard(true);
          ((GuiManagerD) app.getGuiManager()).getVirtualKeyboard().toggleNumeric(true);

        } else {

          AppD.setVirtualKeyboardActive(!AppD.isVirtualKeyboardActive());
          ((GuiManagerD) app.getGuiManager()).toggleKeyboard(AppD.isVirtualKeyboardActive());
          ((GuiManagerD) app.getGuiManager())
              .getVirtualKeyboard()
              .toggleNumeric(AppD.isVirtualKeyboardActive());
        }
      }
    }
    updateStyleBar();
  }
Example #23
0
  /**
   * Mark this panel as focused. When gaining focus the panel will automatically request focus for
   * its parent frame.
   *
   * @remark The focus system implemented here has nothing to do with swings focus system, therefore
   *     Swings focus methods won't work.
   * @param hasFocus has the focus
   */
  protected void setFocus(boolean hasFocus) {

    // don't change anything if it's not necessary
    if (this.hasFocus == hasFocus) return;

    this.hasFocus = hasFocus;

    if (hasFocus) {
      // request focus and change toolbar if necessary
      if (openInFrame) {
        frame.requestFocus();
      } else {
        if (!app.isApplet()) {
          JFrame frame = app.getFrame();

          if (frame != null) {
            frame.toFront();
          }
        }

        setActiveToolBar();
      }
    } else {

    }

    // call callback methods for focus changes
    if (hasFocus) {
      focusGained();
    } else {
      focusLost();
    }

    /*
     * Mark the focused view in bold if the focus system is available. If
     * this isn't the case we always stick with the normal font as it would
     * confuse the users that the focus "indicator" just changes if we
     * switch between EVs.
     */
    setTitleLabelFocus();
  }
Example #24
0
  /**
   * @param view CAS view
   * @param app application
   */
  public CASStyleBar(CASViewD view, AppD app) {

    this.app = app;
    this.loc = app.getLocalization();
    this.casView = view;

    selectedRows = new ArrayList<GeoElement>();

    setFloatable(false);

    initGUI();
  }
Example #25
0
  private void createButtons() {
    int iconSize = 16; // app.getScaledIconSize();

    int toggleSize = (int) Math.round(app.getScaledIconSize() * 0.75);
    // button to show/hide styling bar and the title panel buttons
    toggleStyleBarButton = new JButton();
    toggleStyleBarButton.addActionListener(this);
    toggleStyleBarButton.setFocusPainted(false);
    toggleStyleBarButton.setBorderPainted(false);
    toggleStyleBarButton.setContentAreaFilled(false);
    toggleStyleBarButton.setPreferredSize(new Dimension(toggleSize, toggleSize));
    toggleStyleBarButton.setRolloverEnabled(true);

    // button to show/hide styling bar if the title panel is invisible
    toggleStyleBarButton2 = new JButton();
    toggleStyleBarButton2.setFocusPainted(false);
    toggleStyleBarButton2.setBorderPainted(false);
    toggleStyleBarButton2.setContentAreaFilled(false);
    toggleStyleBarButton2.setPreferredSize(new Dimension(toggleSize, toggleSize));
    toggleStyleBarButton2.addActionListener(this);
    toggleStyleBarButton2.setRolloverEnabled(true);

    updateToggleStyleBarButtons();

    // button to insert the view in the main window
    unwindowButton = new JButton(app.getScaledIcon("view-unwindow.png"));
    unwindowButton.addActionListener(this);
    unwindowButton.setFocusPainted(false);
    unwindowButton.setContentAreaFilled(false);
    unwindowButton.setBorderPainted(false);
    unwindowButton.setPreferredSize(new Dimension(iconSize, iconSize));

    // button to insert the view in the main window
    unwindowButton2 = new JButton(app.getScaledIcon("view-unwindow.png"));
    unwindowButton2.addActionListener(this);
    unwindowButton2.setFocusPainted(false);
    unwindowButton2.setContentAreaFilled(false);
    unwindowButton2.setBorderPainted(false);
    unwindowButton2.setPreferredSize(new Dimension(iconSize, iconSize));

    // button to display the view in a separate window
    windowButton = new JButton(app.getScaledIcon("view-window.png"));
    windowButton.addActionListener(this);
    windowButton.setFocusPainted(false);
    windowButton.setContentAreaFilled(false);
    windowButton.setBorderPainted(false);
    windowButton.setPreferredSize(new Dimension(iconSize, iconSize));

    // button to close the view
    closeButton = new JButton(app.getScaledIcon("view-close.png"));
    closeButton.addActionListener(this);
    closeButton.setFocusPainted(false);
    closeButton.setPreferredSize(new Dimension(iconSize, iconSize));

    // button to toggle maximize/normal state
    maximizeButton = new JButton(app.getScaledIcon("view-maximize.png"));
    maximizeButton.addActionListener(this);
    maximizeButton.setFocusPainted(false);
    maximizeButton.setPreferredSize(new Dimension(iconSize, iconSize));
  }
Example #26
0
  /**
   * Construct a regression panel
   *
   * @param app application
   * @param statDialog invoking instance of DataAnalysisView
   */
  public RegressionPanel(AppD app, DataAnalysisViewD statDialog) {

    this.app = app;
    this.loc = app.getLocalization();
    this.statDialog = statDialog;
    this.daModel = statDialog.getModel();
    this.setLayout(new BorderLayout());
    this.add(createRegressionPanel(), BorderLayout.CENTER);
    setLabels();
    updateRegressionPanel();
    updateGUI();
    isIniting = false;
  }
Example #27
0
  /**
   * create the focus panel (composed of titleLabel, and, for EuclidianDockPanels, focus icon)
   *
   * @return the focus panel
   */
  protected JComponent createFocusPanel() {
    titleLabel = new JLabel(loc.getPlain(title));
    titleLabel.setFont(app.getPlainFont());
    titleLabel.setForeground(Color.darkGray);

    JPanel p = new JPanel(new FlowLayout(app.flowLeft(), 2, 1));

    if (app.getLocalization().isRightToLeftReadingOrder()) {
      p.add(titleLabel);
      p.add(Box.createHorizontalStrut(2));
      if (this.hasStyleBar) {
        p.add(this.toggleStyleBarButton);
      }
    } else {
      if (this.hasStyleBar) {
        p.add(this.toggleStyleBarButton);
      }
      p.add(Box.createHorizontalStrut(2));
      p.add(titleLabel);
    }
    return p;
  }
Example #28
0
  /** Sets the labels according to current locale */
  public void setLabels() {
    regressionLabels = new String[Regression.values().length];
    setRegressionLabels();

    // we need to remove old labels from combobox and we don't want the
    // listener to
    // be operational since it will call unnecessary Construction updates
    int j = cbRegression.getSelectedIndex();
    ActionListener al = cbRegression.getActionListeners()[0];
    cbRegression.removeActionListener(al);
    cbRegression.removeAllItems();

    for (int i = 0; i < regressionLabels.length; i++) {
      cbRegression.addItem(regressionLabels[i]);
    }

    cbRegression.setSelectedIndex(j);
    cbRegression.addActionListener(al);
    ((TitledBorder) regressionPanel.getBorder()).setTitle(app.getMenu("RegressionModel"));
    lblEqn.setText(app.getMenu("Equation") + ":");

    lblEvaluate.setText(app.getMenu("Evaluate") + ": ");
  }
  public void updateGUI() {

    updateCheckBox(cbShowFormulaBar, settings().showFormulaBar());
    updateCheckBox(cbShowGrid, settings().showGrid());
    updateCheckBox(cbShowRowHeader, settings().showRowHeader());
    updateCheckBox(cbShowColumnHeader, settings().showColumnHeader());
    updateCheckBox(cbShowHScrollbar, settings().showHScrollBar());
    updateCheckBox(cbShowVScrollbar, settings().showVScrollBar());
    updateCheckBox(cbAllowSpecialEditor, settings().allowSpecialEditor());
    updateCheckBox(cbAllowToolTips, settings().allowToolTips());
    updateCheckBox(cbPrependCommands, settings().equalsRequired());
    updateCheckBox(cbEnableAutoComplete, settings().isEnableAutoComplete());
    updateCheckBox(cbShowNavigation, app.showConsProtNavigation(App.VIEW_SPREADSHEET));
  }
Example #30
0
  public void actionPerformed(ActionEvent e) {
    Object source = e.getSource();

    needUndo = false;

    processSource(source, selectedRows);

    if (needUndo) {
      app.storeUndoInfo();
      needUndo = false;
    }

    // updateGUI();
  }