Package ofc

Source Code of ofc.OFC

package ofc;

import java.util.Date;

import jofc2.model.Chart;
import jofc2.model.elements.FilledBarChart;

import org.zkoss.zul.ChartModel;

public class OFC extends ZKOFC {

  /**
   *
   */
  private static final long serialVersionUID = 1L;

  /**
   * Whether a 3d chart.
   */
  private boolean threeD;

  /**
   * Chart model associated with this chart.
   */
  private ChartModel model;

  /**
   * Chart's type
   */
  private String type;

  /**
   * Chart's title
   */
  private String title;

  /**
   * Chart orientation
   */
  private String orient;

  /**
   * Color pallete for use in the series
   */
  private String[] pallete;

  /**
   * Generates the Java Open Flash Chart using the assigned model
   */
  private Chart renderChart() {
    OFCChartCreator creator = null;
    String type = getType();
    if (type == null) {
      type = org.zkoss.zul.Chart.PIE;
    }
    if (type.equals(org.zkoss.zul.Chart.PIE)) {
      creator = new OFCPieChartFactory(this);
    } else if (type.equals(org.zkoss.zul.Chart.BAR)) {
      creator = new OFCBarChartFactory(this);
    } else if (type.equals(org.zkoss.zul.Chart.LINE)) {
      creator = new OFCLineChartFactory(this);
    }
    return creator.createChart();
  }

  /**
   * Set true to show three dimensional graph (If a type of chart got no 3d
   * peer, this is ignored).
   *
   * @param threeD
   */
  public void setThreeD(boolean b) {
    this.threeD = b;
  }

  /**
   * Whether a 3d chart.
   */
  public boolean isThreeD() {
    return threeD;
  }

  /**
   * Returns the chart model associated with this chart, or null if this chart
   * is not associated with any chart data model.
   */
  public ChartModel getModel() {
    return model;
  }

  /**
   * Sets the chart model associated with this chart. If a non-null model is
   * assigned, no matter whether it is the same as the previous, it will
   * always cause re-render.
   */
  public void setModel(ChartModel model) {
    this.model = model;
    Chart chart = renderChart();
    //    String json = "{ \"elements\": [ { \"type\": \"bar_filled\",\"alpha\":\"0.8\", \"colour\": \"#3399ff\", \"outline-colour\": \"#0066CC\", \"values\": [ 9, 8, 7, 6, 5, 4, 3, 2, 1 ] } ], \"title\": { \"text\": \"Wed May 20 2009\" }, \"bg_colour\": \"#ffffff\" }";
    String json = chart.toString();
    setChart(json);
    System.out.println(chart.toDebugString());
  }

  /**
   * Get the chart's type.
   *
   */
  public String getType() {
    return type;
  }

  /**
   * Set the chart's type (Chart.PIE, Chart.BAR, Chart.LINE, etc.).
   *
   * Default: Chart.PIE.
   */
  public void setType(String type) {
    this.type = type;
  }

  /**
   * Get the chart's title.
   */
  public String getTitle() {
    return title;
  }

  /**
   * Set the chart's title.
   */
  public void setTitle(String title) {
    this.title = title;
  }

  /**
   * Get the chart orientation (vertical or horizontal)
   */
  public String getOrient() {
    return orient;
  }

  /**
   * Set the chart orientation
   */
  public void setOrient(String orient) {
    this.orient = orient;
  }

  /**
   * @return the pallete
   */
  public String[] getPallete() {
    return pallete;
  }

  /**
   * @param pallete
   *            the pallete to set
   */
  public void setPallete(String[] pallete) {
    this.pallete = pallete;
  }

}
TOP

Related Classes of ofc.OFC

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.