Example usage for org.jfree.chart.axis NumberAxis getLowerBound

List of usage examples for org.jfree.chart.axis NumberAxis getLowerBound

Introduction

In this page you can find the example usage for org.jfree.chart.axis NumberAxis getLowerBound.

Prototype

public double getLowerBound() 

Source Link

Document

Returns the lower bound of the axis range.

Usage

From source file:Applet.EmbeddedChart.java

public synchronized void updateInfo(String[] legends, List<double[][]> yVals, boolean gofr) {
    removeAll();/*w w w.j  a  va  2  s  .  c  om*/
    GridBagLayout gbl = new GridBagLayout();
    gbl.columnWidths = new int[] { 10, 0, 0 };
    gbl.rowHeights = new int[] { 0, 0, 0 };
    gbl.columnWeights = new double[] { 0.0, 1.0, 1.0 };
    gbl.rowWeights = new double[] { 1.0, 1.0, 0.0 };
    setLayout(gbl);

    this.legends = legends;
    this.yvals = yVals;
    this.gofr = gofr;

    XYDataset dataset = createDataset(gofr, legends, yVals);
    JFreeChart chart = createChart(dataset, title, gofr);
    chartPanel = new ChartPanel(chart);
    chartPanel.setMinimumDrawWidth(0);
    chartPanel.setMinimumDrawHeight(0);
    chartPanel.setMaximumDrawWidth(2000);
    chartPanel.setMaximumDrawHeight(2000);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    chartPanel.getChart().setBackgroundPaint(null);
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.gridwidth = 2;
    gbc.gridheight = 2;
    gbc.fill = GridBagConstraints.BOTH;
    add(chartPanel, gbc);

    GridBagConstraints gbcX1 = new GridBagConstraints();
    GridBagConstraints gbcX2 = new GridBagConstraints();
    GridBagConstraints gbcY1 = new GridBagConstraints();
    GridBagConstraints gbcY2 = new GridBagConstraints();
    GridBagConstraints gbcButton = new GridBagConstraints();
    final NumberAxis domain = (NumberAxis) ((XYPlot) chartPanel.getChart().getPlot()).getDomainAxis();
    final NumberAxis range = (NumberAxis) ((XYPlot) chartPanel.getChart().getPlot()).getRangeAxis();

    if (gofr) {
        domain.setLowerBound(over.gr_xMin);
        domain.setUpperBound(over.gr_xMax);
        range.setLowerBound(over.gr_yMin);
        range.setUpperBound(over.gr_yMax);
    } else {
        domain.setLowerBound(over.pot_xMin);
        domain.setUpperBound(over.pot_xMax);
        range.setLowerBound(over.pot_yMin);
        range.setUpperBound(over.pot_yMax);
    }

    gbcX2.gridx = 2;
    gbcX2.gridy = 2;
    gbcX2.anchor = GridBagConstraints.EAST;
    gbcX2.insets = new Insets(0, 0, 0, 12);
    final JTextField xMax = new JTextField(5);
    xMax.setMinimumSize(new Dimension(50, 20));
    xMax.setText("" + domain.getUpperBound());
    // gbcX2.fill = GridBagConstraints.VERTICAL;
    add(xMax, gbcX2);
    final boolean gr = gofr;
    xMax.addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent e) {
            if (gr) {
                over.gr_xMax = Double.parseDouble(xMax.getText());
                domain.setRange(over.gr_xMin, over.gr_xMax);
            } else {
                over.pot_xMax = Double.parseDouble(xMax.getText());
                domain.setRange(over.pot_xMin, over.pot_xMax);
            }
        }

        @Override
        public void focusGained(FocusEvent e) {
        }
    });

    gbcX1.gridx = 1;
    gbcX1.gridy = 2;
    gbcX1.anchor = GridBagConstraints.WEST;
    gbcX1.insets = new Insets(0, 70, 0, 0);
    final JTextField xMin = new JTextField(5);
    xMin.setMinimumSize(new Dimension(50, 20));
    xMin.setText("" + domain.getLowerBound());
    // gbcX1.fill = GridBagConstraints.VERTICAL;
    add(xMin, gbcX1);
    xMin.addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent e) {
            x1 = Double.parseDouble(xMin.getText());
            domain.setRange(x1, x2);
            if (gr) {
                over.gr_xMin = Double.parseDouble(xMin.getText());
                domain.setRange(over.gr_xMin, over.gr_xMax);
            } else {
                over.pot_xMin = Double.parseDouble(xMin.getText());
                domain.setRange(over.pot_xMin, over.pot_xMax);
            }
        }

        @Override
        public void focusGained(FocusEvent e) {
        }
    });

    gbcY1.gridx = 0;
    gbcY1.gridy = 1;
    gbcY1.anchor = GridBagConstraints.SOUTH;
    gbcY1.insets = new Insets(0, 0, 45, 0);
    final JTextField yMin = new JTextField(5);
    yMin.setMinimumSize(new Dimension(50, 20));
    yMin.setText("" + range.getLowerBound());
    // gbcY1.fill = GridBagConstraints.BOTH;
    add(yMin, gbcY1);
    yMin.addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent e) {
            if (gr) {
                over.gr_yMin = Double.parseDouble(yMin.getText());
                range.setRange(over.gr_yMin, over.gr_yMax);
            } else {
                over.pot_yMin = Double.parseDouble(yMin.getText());
                range.setRange(over.pot_yMin, over.pot_yMax);
            }

        }

        @Override
        public void focusGained(FocusEvent e) {
        }
    });

    gbcY2.gridx = 0;
    gbcY2.gridy = 0;
    gbcY2.anchor = GridBagConstraints.NORTH;
    gbcY2.insets = new Insets(10, 0, 0, 0);
    final JTextField yMax = new JTextField(5);
    yMax.setMinimumSize(new Dimension(50, 20));
    yMax.setText("" + range.getUpperBound());
    // gbcY2.fill = GridBagConstraints.BOTH;
    add(yMax, gbcY2);
    yMax.addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent e) {
            if (gr) {
                over.gr_yMax = Double.parseDouble(yMax.getText());
                range.setRange(over.gr_yMin, over.gr_yMax);
            } else {
                over.pot_yMax = Double.parseDouble(yMax.getText());
                range.setRange(over.pot_yMin, over.pot_yMax);
            }
        }

        @Override
        public void focusGained(FocusEvent e) {
        }
    });

}