
// AllOptsPlot.java
// Yuriy Guskov
// Modified by Andrew Davison, ad@coe.psu.ac.th, March 2023

/* A graph showing all the options for:
     * the plot (PlotOptions)
     * the data (DataSeriesOptions)
     * the axes (AxisOptions)

   Usage:
     > compile AllOptsPlot.java
     > run AllOptsPlot
*/


import java.awt.*;

import com.github.plot.Plot;
import com.github.plot.Plot.*;


public class AllOptsPlot
{

  public static void main(String[] args)
  {
    // configure options

    PlotOptions pOpts = Plot.plotOpts().
         title("All Options Plot").
         titleFont(new Font("Arial", Font.ITALIC, 20)).
                // the default is bold, 16pt
         width(800).height(450).
         bgColor(Color.LIGHT_GRAY).
         fgColor(Color.BLUE).
         padding(50).     // padding for the whole image
         plotPadding(30). // padding between plot
                          // border and the plot
         labelPadding(20). // padding between label and
                           // other elements
         labelFont(new Font("Arial", Font.BOLD, 14)).
         grids(5, 5).
         gridColor(Color.WHITE).  // usually gray
         gridStroke(new BasicStroke(1)).  // usually dashed
         tickSize(10).  // usually 5
         legend(Plot.LegendFormat.RIGHT);


    DataSeriesOptions dsOpts = Plot.seriesOpts().
          color(Color.BLACK).  // default is blue
          line(Plot.Line.SOLID).
          lineWidth(8).  // default is 2
          marker(Plot.Marker.DIAMOND).  // default is NONE
          markerColor(Color.GREEN).     // WHITE
          markerSize(12).               // 10
          xAxis("x").yAxis("y");
             // not useful here as only one x- and y-axis;
             // see LinePlots.java for their use


    AxisOptions axOpts = Plot.axisOpts().
          format(Plot.AxisFormat.NUMBER_INT). 
          range(0, 5);


    // supply data
    Data plotData = Plot.data().xy(1, 2).xy(3, 4);

    // build the plot
    Plot plot = Plot.plot(pOpts);
    plot.xAxis("x", axOpts);
    plot.yAxis("y", Plot.axisOpts().range(0, 5));
       // y-axis has same range as x-axis but with 2dp
    plot.series("Data", plotData, dsOpts);

    Utils.viewPlot("All Options Plot", plot);
  } /* main */

} // end of AllOptsPlot class
