Example #1
0
 /** Set the text font. */
 protected void setTextFont(Font font) {
   if (font != null) {
     xTextField.setTextFont(font);
     yTextField.setTextFont(font);
     astAxisLabels.setFont(font);
   }
 }
Example #2
0
 /** Set the text colour. */
 protected void setTextColour(Color colour) {
   if (colour != null) {
     xTextField.setTextColour(colour);
     yTextField.setTextColour(colour);
     colourIcon.setMainColour(colour);
     colourButton.repaint();
     astAxisLabels.setColour(colour);
   }
 }
Example #3
0
  /** Update interface to reflect values of the current AstAxisLabel. */
  protected void updateFromAstAxisLabels() {
    //  Nothing in this method should change astAxisLabels, but
    //  we'll switch off the ChangeListener anyway.
    astAxisLabels.removeChangeListener(this);

    xShowLabel.setSelected(astAxisLabels.getXShown());
    if (!inhibitXDocumentListener) {
      xTextField.setText(astAxisLabels.getXLabel());
    }

    yShowLabel.setSelected(astAxisLabels.getYShown());
    if (!inhibitYDocumentListener) {
      yTextField.setText(astAxisLabels.getYLabel());
    }

    xTextField.setTextFont(astAxisLabels.getFont());
    yTextField.setTextFont(astAxisLabels.getFont());
    fontControls.setFont(astAxisLabels.getFont());
    xTextField.setTextColour(astAxisLabels.getColour());
    yTextField.setTextColour(astAxisLabels.getColour());
    colourIcon.setMainColour(astAxisLabels.getColour());
    colourButton.repaint();

    xSpinnerModel.setValue(new Double(astAxisLabels.getXGap()));
    ySpinnerModel.setValue(new Double(astAxisLabels.getYGap()));

    if (astAxisLabels.getXEdge() == AstAxisLabels.BOTTOM) {
      xEdge.setSelectedItem("BOTTOM");
    } else {
      xEdge.setSelectedItem("TOP");
    }
    if (astAxisLabels.getYEdge() == AstAxisLabels.LEFT) {
      yEdge.setSelectedItem("LEFT");
    } else {
      yEdge.setSelectedItem("RIGHT");
    }

    xUnits.setSelected(astAxisLabels.getShowXUnits());
    yUnits.setSelected(astAxisLabels.getShowYUnits());

    astAxisLabels.setXState(true);
    astAxisLabels.setYState(true);

    astAxisLabels.addChangeListener(this);
  }
Example #4
0
 /** Match the Y AstAxisLabels text to that displayed. */
 protected void matchYText() {
   inhibitYDocumentListener = true;
   astAxisLabels.setYLabel(yTextField.getText());
   inhibitYDocumentListener = false;
 }
Example #5
0
 /** Match the X AstAxisLabels text to that displayed. */
 protected void matchXText() {
   inhibitXDocumentListener = true;
   astAxisLabels.setXLabel(xTextField.getText());
   inhibitXDocumentListener = false;
 }
Example #6
0
 /** Set the Y label. */
 public void setYText(String text) {
   yTextField.setText(text);
 }
Example #7
0
 /** Set the X label. */
 public void setXText(String text) {
   xTextField.setText(text);
 }
Example #8
0
  /** Create and initialise the user interface. */
  protected void initUI() {
    //  Choices for label positioning.
    xEdge.addItem("BOTTOM");
    xEdge.addItem("TOP");
    yEdge.addItem("LEFT");
    yEdge.addItem("RIGHT");

    //  Act on request to display/remove a label.
    xShowLabel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            matchXShown();
          }
        });
    yShowLabel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            matchYShown();
          }
        });

    //  Set ColourIcon of colour button.
    colourButton.setIcon(colourIcon);
    colourButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            chooseColour();
          }
        });

    //  New labels are copied to AstAxisLabel.... Need to intercept
    //  keystrokes.
    Document doc = xTextField.getDocument();
    doc.addDocumentListener(
        new DocumentListener() {
          public void changedUpdate(DocumentEvent e) {
            matchXText();
          }

          public void insertUpdate(DocumentEvent e) {
            matchXText();
          }

          public void removeUpdate(DocumentEvent e) {
            matchXText();
          }
        });
    doc = yTextField.getDocument();
    doc.addDocumentListener(
        new DocumentListener() {
          public void changedUpdate(DocumentEvent e) {
            matchYText();
          }

          public void insertUpdate(DocumentEvent e) {
            matchYText();
          }

          public void removeUpdate(DocumentEvent e) {
            matchYText();
          }
        });

    //  New gaps.
    xGapSpinner = new ScientificSpinner(xSpinnerModel);
    xGapSpinner.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            matchXGap();
          }
        });

    yGapSpinner = new ScientificSpinner(ySpinnerModel);
    yGapSpinner.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            matchYGap();
          }
        });

    //  Edge selection.
    xEdge.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            matchXEdge();
          }
        });
    yEdge.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            matchYEdge();
          }
        });

    //  Units display.
    xUnits.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            matchXUnits();
          }
        });
    yUnits.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            matchYUnits();
          }
        });

    //  Add components.
    GridBagLayouter layouter = Utilities.getGridBagLayouter(this);

    layouter.add("Show X:", false);
    layouter.add(xShowLabel, true);

    layouter.add("X label:", false);
    layouter.add(xTextField, true);

    layouter.add("Show Y:", false);
    layouter.add(yShowLabel, true);

    layouter.add("Y label:", false);
    layouter.add(yTextField, true);

    addFontControls(layouter);

    layouter.add("Colour:", false);
    layouter.add(colourButton, false);
    layouter.eatLine();

    layouter.add("X gap:", false);
    layouter.add(xGapSpinner, false);
    layouter.eatLine();

    layouter.add("Y gap:", false);
    layouter.add(yGapSpinner, false);
    layouter.eatLine();

    layouter.add("X edge:", false);
    layouter.add(xEdge, false);
    layouter.eatLine();

    layouter.add("Y edge:", false);
    layouter.add(yEdge, false);
    layouter.eatLine();

    layouter.add("X units:", false);
    layouter.add(xUnits, true);

    layouter.add("Y units:", false);
    layouter.add(yUnits, true);

    layouter.eatSpare();

    //  Set tooltips.
    colourButton.setToolTipText("Select a colour");
    xTextField.setToolTipText("Type in the X axis label");
    yTextField.setToolTipText("Type in the Y axis label");
    xGapSpinner.setToolTipText("Set the gap between label and axis");
    yGapSpinner.setToolTipText("Set the gap between label and axis");
    xEdge.setToolTipText("Set edge for displaying label");
    yEdge.setToolTipText("Set edge for displaying label");
    xUnits.setToolTipText("Append any X axis units to label");
    xUnits.setToolTipText("Append any Y axis units to label");
  }