/**
   * A demonstration application showing some bugs with tick labels in version 0.9.13
   *
   * @param title the frame title.
   */
  public XYTickLabelDemo(final String title) {

    super(title);
    this.chart = createChart();
    final ChartPanel chartPanel = new ChartPanel(this.chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(600, 270));

    final JPanel mainPanel = new JPanel(new BorderLayout());
    setContentPane(mainPanel);
    mainPanel.add(chartPanel);

    final JPanel optionsPanel = new JPanel();
    mainPanel.add(optionsPanel, BorderLayout.SOUTH);

    this.symbolicAxesCheckBox = new JCheckBox("Symbolic axes");
    this.symbolicAxesCheckBox.addActionListener(this);
    optionsPanel.add(this.symbolicAxesCheckBox);

    this.verticalTickLabelsCheckBox = new JCheckBox("Tick labels vertical");
    this.verticalTickLabelsCheckBox.addActionListener(this);
    optionsPanel.add(this.verticalTickLabelsCheckBox);

    this.fontSizeTextField = new JTextField(3);
    this.fontSizeTextField.addActionListener(this);
    optionsPanel.add(new JLabel("Font size:"));
    optionsPanel.add(this.fontSizeTextField);
    final ValueAxis axis = this.chart.getXYPlot().getDomainAxis();
    this.fontSizeTextField.setText(DEFAULT_FONT_SIZE + "");

    final XYPlot plot = this.chart.getXYPlot();
    Font ft = axis.getTickLabelFont();
    ft = ft.deriveFont((float) DEFAULT_FONT_SIZE);
    plot.getDomainAxis().setTickLabelFont(ft);
    plot.getRangeAxis().setTickLabelFont(ft);
    plot.getDomainAxis(1).setTickLabelFont(ft);
    plot.getRangeAxis(1).setTickLabelFont(ft);

    this.horizontalPlotCheckBox = new JCheckBox("Plot horizontal");
    this.horizontalPlotCheckBox.addActionListener(this);
    optionsPanel.add(this.horizontalPlotCheckBox);
  }
  /**
   * When a checkbox is changed ...
   *
   * @param event the event.
   */
  public void actionPerformed(final ActionEvent event) {
    final ValueAxis[] axes = new ValueAxis[4];
    final XYPlot plot = this.chart.getXYPlot();
    axes[0] = plot.getDomainAxis();
    axes[1] = plot.getRangeAxis();
    axes[2] = plot.getDomainAxis(1);
    axes[3] = plot.getRangeAxis(1);

    final Object source = event.getSource();

    if (source == this.symbolicAxesCheckBox) {

      final boolean val = this.symbolicAxesCheckBox.isSelected();

      for (int i = 0; i < axes.length; i++) {
        ValueAxis axis = axes[i];
        final String label = axis.getLabel();
        final int maxTick = (int) axis.getUpperBound();
        final String[] tickLabels = new String[maxTick];
        final Font ft = axis.getTickLabelFont();
        for (int itk = 0; itk < maxTick; itk++) {
          tickLabels[itk] = "Label " + itk;
        }
        axis = val ? new SymbolicAxis(label, tickLabels) : new NumberAxis(label);
        axis.setTickLabelFont(ft);
        axes[i] = axis;
      }
      plot.setDomainAxis(axes[0]);
      plot.setRangeAxis(axes[1]);
      plot.setDomainAxis(1, axes[2]);
      plot.setRangeAxis(1, axes[3]);
    }

    if (source == this.symbolicAxesCheckBox || source == this.verticalTickLabelsCheckBox) {
      final boolean val = this.verticalTickLabelsCheckBox.isSelected();

      for (int i = 0; i < axes.length; i++) {
        axes[i].setVerticalTickLabels(val);
      }

    } else if (source == this.symbolicAxesCheckBox || source == this.horizontalPlotCheckBox) {

      final PlotOrientation val =
          this.horizontalPlotCheckBox.isSelected()
              ? PlotOrientation.HORIZONTAL
              : PlotOrientation.VERTICAL;
      this.chart.getXYPlot().setOrientation(val);

    } else if (source == this.symbolicAxesCheckBox || source == this.fontSizeTextField) {
      final String s = this.fontSizeTextField.getText();
      if (s.length() > 0) {
        final float sz = Float.parseFloat(s);
        for (int i = 0; i < axes.length; i++) {
          final ValueAxis axis = axes[i];
          Font ft = axis.getTickLabelFont();
          ft = ft.deriveFont(sz);
          axis.setTickLabelFont(ft);
        }
      }
    }
  }