/** Update localization */
  public void setLabels() {
    initGUI();

    btnUseAsText.setToolTipText(loc.getPlainTooltip("stylebar.UseAsText"));
    btnTextColor.setToolTipText(loc.getPlainTooltip("stylebar.TextColor"));
    btnTextSize.setToolTipText(loc.getPlainTooltip("stylebar.TextSize"));
    btnBold.setToolTipText(loc.getPlainTooltip("stylebar.Bold"));
    btnItalic.setToolTipText(loc.getPlainTooltip("stylebar.Italic"));
  }
  private JPanel createRegressionPanel() {

    // components
    String[] orders = {"2", "3", "4", "5", "6", "7", "8", "9"};
    cbPolyOrder = new JComboBox(orders);
    cbPolyOrder.setSelectedIndex(0);
    cbPolyOrder.addActionListener(this);
    cbPolyOrder.setFocusable(false);

    regressionLabels = new String[Regression.values().length];
    setRegressionLabels();
    cbRegression = new JComboBox(regressionLabels);
    cbRegression.addActionListener(this);
    cbRegression.setFocusable(false);

    lblRegEquation = new JLabel();
    lblEqn = new JLabel();

    // regression combo panel
    JPanel cbPanel = new JPanel();
    cbPanel.setLayout(new BoxLayout(cbPanel, BoxLayout.Y_AXIS));
    cbPanel.add(LayoutUtil.flowPanel(cbRegression));
    cbPanel.add(LayoutUtil.flowPanel(cbPolyOrder));

    // regression label panel
    JPanel eqnPanel = new JPanel(new BorderLayout());
    eqnPanel.add(lblRegEquation, BorderLayout.CENTER);
    JScrollPane scroller = new JScrollPane(eqnPanel);
    scroller.setBorder(BorderFactory.createEmptyBorder());

    // prediction panel
    createPredictionPanel();

    // model panel: equation + prediction
    JPanel modelPanel = new JPanel();
    modelPanel.setLayout(new BoxLayout(modelPanel, BoxLayout.Y_AXIS));
    modelPanel.add(scroller);
    modelPanel.add(predictionPanel);

    // put it all together
    regressionPanel = new JPanel(new BorderLayout(30, 0));
    regressionPanel.add(modelPanel, BorderLayout.CENTER);
    regressionPanel.add(cbPanel, loc.borderWest());
    regressionPanel.setBorder(BorderFactory.createTitledBorder(loc.getMenu("RegressionModel")));

    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(regressionPanel, BorderLayout.CENTER);

    return mainPanel;
  }
  /** Draws the regression equation into the regression equation JLabel icon */
  public void setRegressionEquationLabel() {

    // get the LaTeX string for the regression equation

    String eqn;
    // GeoElement geoRegression = statDialog.getRegressionModel();

    try {
      // prepare number format
      StringTemplate highPrecision;
      if (daModel.getPrintDecimals() >= 0)
        highPrecision =
            StringTemplate.printDecimals(StringType.LATEX, daModel.getPrintDecimals(), false);
      else
        highPrecision =
            StringTemplate.printFigures(StringType.LATEX, daModel.getPrintFigures(), false);

      // no regression
      if (daModel.getRegressionMode().equals(Regression.NONE)
          || statDialog.getRegressionModel() == null) {
        eqn = "";
      }

      // nonlinear
      else {
        eqn = "y = " + statDialog.getRegressionModel().getFormulaString(highPrecision, true);
      }

    } catch (Exception e) {
      e.printStackTrace();
      eqn = "\\text{" + loc.getPlain("NotAvailable") + "}";
    }

    // create an icon with the LaTeX string
    ImageIcon icon =
        GeoGebraIconD.createLatexIcon(app, eqn, this.getFont(), false, Color.RED, null);

    // set the label icon with our equation string
    lblRegEquation.setIcon(icon);
    lblRegEquation.revalidate();

    updateGUI();
  }
  /**
   * Update all labels of this DockPanel. Called while initializing and if the language was changed.
   */
  public void updateLabels() {
    closeButton.setToolTipText(loc.getMenuTooltip("Close"));
    windowButton.setToolTipText(loc.getPlainTooltip("ViewOpenExtraWindow"));
    unwindowButton.setToolTipText(loc.getPlainTooltip("ViewCloseExtraWindow"));
    unwindowButton2.setToolTipText(loc.getPlainTooltip("ViewCloseExtraWindow"));
    toggleStyleBarButton.setToolTipText(loc.getPlainTooltip("ToggleStyleBar"));
    toggleStyleBarButton2.setToolTipText(loc.getPlainTooltip("ToggleStyleBar"));

    if (frame == null) {
      titleLabel.setText(getPlainTitle());
    } else {
      updateTitle();
    }
  }
  /** Creates a panel to evaluate the regression model for a given x value */
  private void createPredictionPanel() {

    JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT));
    lblEvaluate = new JLabel();
    fldInputX = new MyTextFieldD(app);
    fldInputX.addActionListener(this);

    fldInputX.setColumns(6);
    lblOutputY = new JLabel();
    fldOutputY = new JLabel();

    p.add(lblEvaluate);
    p.add(new JLabel("x = "));
    p.add(fldInputX);
    p.add(new JLabel("y = "));
    p.add(lblOutputY);
    p.add(fldOutputY);

    predictionPanel = new JPanel(new BorderLayout());
    predictionPanel.add(p, loc.borderWest());
  }
  /**
   * 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;
  }
 /** @return title in plain style */
 protected String getPlainTitle() {
   return loc.getPlain(title);
 }
  /**
   * Bind this view to a dock manager. Also initializes the whole GUI as just at this point the
   * application is available.
   *
   * @param dockManager1 dock manager
   */
  public void register(DockManagerD dockManager1) {
    this.dockManager = dockManager1;
    setApp(dockManager1.getLayout().getApplication());
    // create buttons for the panels
    createButtons();

    // create button panel
    buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout(app.flowRight(), 0, 1));
    if (app.getLocalization().isRightToLeftReadingOrder()) {
      buttonPanel.add(closeButton);
      buttonPanel.add(Box.createHorizontalStrut(4));
      buttonPanel.add(windowButton);
      buttonPanel.add(unwindowButton);
      buttonPanel.add(Box.createHorizontalStrut(4));
      buttonPanel.add(maximizeButton);
    } else {
      buttonPanel.add(maximizeButton);
      buttonPanel.add(Box.createHorizontalStrut(4));
      buttonPanel.add(unwindowButton);
      buttonPanel.add(windowButton);
      buttonPanel.add(Box.createHorizontalStrut(4));
      buttonPanel.add(closeButton);
    }

    // Custom border for the major panels (title, stylebar and toolbar)
    Border panelBorder =
        BorderFactory.createCompoundBorder(
            BorderFactory.createMatteBorder(0, 0, 1, 0, SystemColor.controlShadow),
            BorderFactory.createEmptyBorder(0, 2, 0, 2));

    // create style bar panel
    styleBarPanel = new JPanel(new BorderLayout(1, 2));
    styleBarPanel.setBorder(panelBorder);
    styleBarPanel.addMouseListener(this);

    styleBarButtonPanel = new JPanel(new BorderLayout());
    JPanel p = new JPanel(new FlowLayout(0, 0, app.flowLeft()));
    if (this.hasStyleBar) {
      p.add(toggleStyleBarButton2);
    }
    p.add(Box.createHorizontalStrut(4));

    styleBarButtonPanel.add(p, BorderLayout.NORTH);
    styleBarPanel.add(styleBarButtonPanel, loc.borderWest());
    styleBarPanel.add(LayoutUtil.flowPanelRight(0, 0, 4, unwindowButton2), loc.borderEast());

    // construct the title panel and add all elements
    titlePanel = new JPanel();
    titlePanel.setBorder(panelBorder);
    titlePanel.setLayout(new BorderLayout());

    titlePanel.add(createFocusPanel(), loc.borderWest());
    titlePanel.add(buttonPanel, loc.borderEast());
    titlePanel.addMouseListener(this); // dragging to reconfigure
    titlePanel.addMouseListener(new MyButtonHider());

    // create toolbar panel
    if (hasToolbar()) {
      toolbarPanel = new JPanel(new BorderLayout());
      toolbarPanel.setBorder(panelBorder);
    }

    // construct a meta panel to hold the title, tool bar and style bar
    // panels

    JPanel titleBar = new JPanel(new BorderLayout());
    titleBar.add(styleBarPanel, BorderLayout.SOUTH);
    titleBar.add(titlePanel, BorderLayout.NORTH);

    JPanel metaPanel = new JPanel(new BorderLayout());
    metaPanel.add(titleBar, BorderLayout.SOUTH);
    if (hasToolbar()) metaPanel.add(toolbarPanel, BorderLayout.CENTER);

    // make titlebar visible if necessary
    updatePanel();

    add(metaPanel, BorderLayout.NORTH);
  }
Exemple #9
0
  public void setLabels() {

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

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

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

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

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

    // bar chart
    lblBarWidth.setText(loc.getMenu("Width"));
    ckAutoBarWidth.setText(loc.getMenu("AutoDimension"));

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

    lblXInterval.setText(loc.getMenu("xstep") + ":");
    lblYInterval.setText(loc.getMenu("ystep") + ":");

    rbStandToStand.setText(loc.getMenu("Standard To Standard"));
    rbLogToStand.setText(loc.getMenu("Logarithmic To Standard"));
    rbStandToLog.setText(loc.getMenu("Standard To Logarithmic"));
    rbLogToLog.setText(loc.getMenu("Logarithmic To Logarithmic"));

    // scatterplot options
    ckShowLines.setText(loc.getMenu("LineGraph"));

    // boxplot options
    ckShowOutliers.setText(loc.getMenu("ShowOutliers"));

    repaint();
  }
Exemple #10
0
  public void setPanel(PlotType plotType) {

    tabbedPane.removeAll();
    this.setVisible(true);

    // add plot-specific tab
    String tabTitle = plotType.getTranslatedKey(loc);
    tabbedPane.insertTab(tabTitle, null, new JScrollPane(mainPanel), null, 0);
    classesPanel.setVisible(false);
    histogramPanel.setVisible(false);
    scatterplotPanel.setVisible(false);
    barChartPanel.setVisible(false);
    boxPlotPanel.setVisible(false);

    rbNormalized.setVisible(false);
    ckOverlayNormal.setVisible(false);
    ckShowHistogram.setVisible(false);
    ckCumulative.setVisible(false);
    ckOverlayPolygon.setVisible(false);

    // add graph tab
    tabbedPane.addTab(loc.getMenu("Graph"), new JScrollPane(graphPanel));
    graphPanel.setVisible(true);
    showYAxisSettings = true;

    // set visibility for plot-specific panels
    switch (plotType) {
      case HISTOGRAM:
        classesPanel.setVisible(true);
        histogramPanel.setVisible(true);
        rbNormalized.setVisible(true);
        ckOverlayNormal.setVisible(true);
        ckShowHistogram.setVisible(true);
        ckCumulative.setVisible(true);
        ckOverlayPolygon.setVisible(true);

        layoutHistogramPanel();

        break;

      case BOXPLOT:
      case MULTIBOXPLOT:
        boxPlotPanel.setVisible(true);
        break;

      case BARCHART:
        barChartPanel.setVisible(true);
        layoutBarChartPanel();
        break;

      case SCATTERPLOT:
        scatterplotPanel.setVisible(true);
        break;

        // graph tab only
      case DOTPLOT:
      case NORMALQUANTILE:
      case RESIDUAL:
        tabbedPane.removeTabAt(0);
        break;

      case STEMPLOT:
        this.setVisible(false);
        break;
    }

    setLabels();
    updateGUI();
  }