Package ofc

Source Code of ofc.OFCChartFactory

package ofc;

import java.util.List;

import jofc2.model.Chart;
import jofc2.model.Text;
import jofc2.model.elements.Element;

import org.zkoss.zul.CategoryModel;

public abstract class OFCChartFactory implements OFCChartCreator {
  protected OFC ofc;

  protected CategoryModel model;

  protected Chart chart;

  protected double minValue;

  protected double maxValue;

  public OFCChartFactory(OFC ofc) {
    this.ofc = ofc;
    this.model = (CategoryModel) ofc.getModel();
    this.chart = new Chart();
    this.minValue = Double.POSITIVE_INFINITY;
    this.maxValue = Double.NEGATIVE_INFINITY;
  }

  public Chart createChart() {
    String title = ofc.getTitle();
    if (title == null || title.trim().equals("")) {
      title = " ";
    }
    Text text = new Text(title);
    chart.setTitle(text);
    chart.addElements(createElements(ofc, model));
    chart.setBackgroundColour(ofc.getBgcolor());
    return chart;
  }

  protected abstract List<Element> createElements(OFC ofc, CategoryModel model);

  /**
   * Returns de minimun value of the y axis
   *
   * @return
   */
  protected Double getYMinValue() {
    return minValue;
  }

  /**
   * Returns de maximun value of the y axis
   *
   * @return
   */
  protected Double getYMaxValue() {
    return maxValue;
  }


  /**
   * @return the chart
   */
  public Chart getChart() {
    return chart;
  }

  /**
   * @param chart
   *            the chart to set
   */
  public void setChart(Chart chart) {
    this.chart = chart;
  }

}
TOP

Related Classes of ofc.OFCChartFactory

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.