All Downloads are FREE. Search and download functionalities are using the official Maven repository.

br.com.digilabs.jqplot.ChartConfiguration Maven / Gradle / Ivy

/*
 *  Copyright 2011 Inaiat H. Moraes.
 * 
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 * 
 *       http://www.apache.org/licenses/LICENSE-2.0
 * 
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */
package br.com.digilabs.jqplot;

import br.com.digilabs.jqplot.axis.Axis;
import br.com.digilabs.jqplot.axis.XAxis;
import br.com.digilabs.jqplot.axis.YAxis;
import br.com.digilabs.jqplot.elements.Axes;
import br.com.digilabs.jqplot.elements.CanvasOverlay;
import br.com.digilabs.jqplot.elements.Cursor;
import br.com.digilabs.jqplot.elements.Grid;
import br.com.digilabs.jqplot.elements.GridPadding;
import br.com.digilabs.jqplot.elements.Highlighter;
import br.com.digilabs.jqplot.elements.Legend;
import br.com.digilabs.jqplot.elements.Serie;
import br.com.digilabs.jqplot.elements.SeriesDefaults;
import br.com.digilabs.jqplot.elements.Title;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;

/**
 * 
 * Base configuration of JqPlot Chart. See jqplot documention
 * http://www.jqplot.com/docs/files/usage-txt.html
 * 
 * @param 
 *            Type of {@link Axis}
 * 
 * @author inaiat
 */
public class ChartConfiguration implements Serializable {

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = 7082325039222592701L;

	/** The series. */
	protected Collection series;

	/** The axes. */
	protected Axes axes;

	/** The title. */
	protected Title title;

	/** The axes defaults. */
	protected Axis axesDefaults;

	/** The series defaults. */
	private SeriesDefaults seriesDefaults;

	/** The stack series. */
	private Boolean stackSeries;

	/** The show marker. */
	private Boolean showMarker;

	/** The legend. */
	private Legend legend;

	/** The capture right click. */
	private Boolean captureRightClick = null;

	/** The series colors. */
	private Collection seriesColors;

	/** The animate. */
	private Boolean animate;

	/** The highlighter. */
	private Highlighter highlighter;

	/** The grid. */
	private Grid grid;

	/** The cursor. */
	private Cursor cursor;

	/** The gridPadding attribute */
	private GridPadding gridPadding;

	/** The canvas overlay. */
	private CanvasOverlay canvasOverlay;

	/**
	 * Checks if is capture right click.
	 * 
	 * @return the boolean
	 */
	public Boolean isCaptureRightClick() {
		return captureRightClick;
	}

	/**
	 * Sets the capture right click.
	 * 
	 * @param captureRightClick
	 *            the new capture right click
	 * @return ChartConfiguration
	 */
	public ChartConfiguration setCaptureRightClick(Boolean captureRightClick) {
		this.captureRightClick = captureRightClick;
		return this;
	}

	/**
	 * Gets the legend.
	 * 
	 * @return the legend
	 */
	public Legend getLegend() {
		return legend;
	}

	/**
	 * Sets the legend.
	 * 
	 * @param legend
	 *            the new legend
	 * @return ChartConfiguration
	 */
	public ChartConfiguration setLegend(Legend legend) {
		this.legend = legend;
		return this;
	}

	/**
	 * Sets the simple title.
	 * 
	 * @param title
	 *            the new simple title
	 * @return ChartConfiguration
	 */
	public ChartConfiguration setSimpleTitle(String title) {
		if (title == null) {
			this.title = new Title(title);
		} else {
			this.title.setText(title);
		}
		return this;
	}

	/**
	 * Instantiates the cursor.
	 * 
	 * @return the cursor
	 */
	public Cursor cursorInstance() {
		if (cursor == null) {
			cursor = new Cursor();
		}
		return cursor;
	}

	/**
	 * Instantiates the grid.
	 * 
	 * @return the grid
	 */
	public Grid gridInstance() {
		if (grid == null) {
			grid = new Grid();
		}
		return grid;
	}

	/**
	 * Instantiates the axes.
	 * 
	 * @return the axes
	 */
	public Axes axesInstance() {
		if (axes == null) {
			this.axes = new Axes();
		}
		return this.axes;
	}

	/**
	 * Instantiates the axes defaults.
	 * 
	 * @return the axis
	 */
	public Axis axesDefaultsInstance() {
		if (axesDefaults == null) {
			axesDefaults = new Axis();
		}
		return axesDefaults;
	}

	public XAxis xAxisInstance() {
		return axesInstance().xAxisInstance();
	}

	public YAxis yAxisInstance() {
		return axesInstance().yAxisInstance();
	}

	public Collection seriesInstance() {
		if (series == null) {
			series = new ArrayList();
		}
		return series;
	}

	public SeriesDefaults seriesDefaultsInstance() {
		if (seriesDefaults == null) {
			seriesDefaults = new SeriesDefaults();
		}
		return seriesDefaults;
	}

	public Collection seriesColorsInstance() {
		if (this.seriesColors == null) {
			this.seriesColors = new ArrayList();
		}
		return seriesColors;
	}

	public Highlighter highlighterInstance() {
		if (highlighter == null) {
			highlighter = new Highlighter();
		}
		return highlighter;
	}

	/**
	 * Creates the cursor.
	 * 
	 * @return the cursor
	 * 
	 * @deprecated use withCursor()
	 */
	@Deprecated
	public Cursor createCursor() {
		return cursorInstance();
	}

	/**
	 * Creates the grid.
	 * 
	 * @return the grid
	 * @deprecated use withGrid
	 */
	@Deprecated
	public Grid createGrid() {
		return gridInstance();
	}

	/**
	 * Creates the axes.
	 * 
	 * @return the axes
	 * 
	 * @deprecated use withAxes()
	 */
	@Deprecated
	public Axes createAxes() {
		return axesInstance();
	}

	/**
	 * Creates the x axis.
	 * 
	 * @return the x axis
	 */
	@Deprecated
	public XAxis createXAxis() {
		return xAxisInstance();
	}

	/**
	 * Creates the y axis.
	 * 
	 * @return the y axis
	 */
	@Deprecated
	public YAxis createYAxis() {
		return yAxisInstance();
	}

	/**
	 * Creates the axes defaults.
	 * 
	 * @return the axis
	 */
	@Deprecated
	public Axis createAxesDefaults() {
		return axesDefaultsInstance();
	}

	/**
	 * Sets the label x.
	 * 
	 * @param label
	 *            the new label x
	 * @return ChartConfiguration
	 */
	public ChartConfiguration setLabelX(String label) {
		if (label != null) {
			axesInstance().xAxisInstance().setLabel(label);
		}
		return this;
	}

	/**
	 * Sets the label y.
	 * 
	 * @param label
	 *            the new label y
	 * @return ChartConfiguration
	 */
	public ChartConfiguration setLabelY(String label) {
		if (label != null) {
			axesInstance().yAxisInstance().setLabel(label);
		}
		return this;
	}

	/**
	 * Creates the series.
	 * 
	 * @return the collection
	 */
	@Deprecated
	public Collection createSeries() {
		return seriesInstance();
	}

	/**
	 * Gets the series.
	 * 
	 * @return the series
	 */
	public Collection getSeries() {
		return series;
	}

	/**
	 * Sets the series.
	 * 
	 * @param series
	 *            the series to set
	 * @return ChartConfiguration
	 */
	public ChartConfiguration setSeries(Collection series) {
		this.series = series;
		return this;
	}

	/**
	 * Adds the series.
	 * 
	 * @param serie
	 *            the serie
	 * @return ChartConfiguration
	 */
	public ChartConfiguration addSeries(Serie serie) {
		this.seriesInstance().add(serie);
		return this;
	}

	/**
	 * Gets the title.
	 * 
	 * @return the title
	 */
	public Title getTitle() {
		return title;
	}

	/**
	 * Sets the title.
	 * 
	 * @param title
	 *            the title to set
	 * @return ChartConfiguration
	 */
	public ChartConfiguration setTitle(Title title) {
		this.title = title;
		return this;
	}

	/**
	 * Gets the axes defaults.
	 * 
	 * @return the axesDefaults
	 */
	public Axis getAxesDefaults() {
		return axesDefaults;
	}

	/**
	 * Sets the axes defaults.
	 * 
	 * @param axesDefaults
	 *            the axesDefaults to set
	 * @return ChartConfiguration
	 */
	public ChartConfiguration setAxesDefaults(Axis axesDefaults) {
		this.axesDefaults = axesDefaults;
		return this;
	}

	/**
	 * Gets the axes.
	 * 
	 * @return the axes
	 */
	public Axes getAxes() {
		return axes;
	}

	/**
	 * Sets the axes.
	 * 
	 * @param axes
	 *            the axes to set
	 * @return ChartConfiguration
	 */
	public ChartConfiguration setAxes(Axes axes) {
		this.axes = axes;
		return this;
	}

	/**
	 * Creates the series defaults.
	 * 
	 * @return the series defaults
	 */
	@Deprecated
	public SeriesDefaults createSeriesDefaults() {
		return seriesDefaultsInstance();
	}

	/**
	 * Gets the series defaults.
	 * 
	 * @return the seriesDefaults
	 */
	public SeriesDefaults getSeriesDefaults() {
		return seriesDefaults;
	}

	/**
	 * Sets the series defaults.
	 * 
	 * @param seriesDefaults
	 *            the seriesDefaults to set
	 * @return ChartConfiguration
	 */
	public ChartConfiguration setSeriesDefaults(SeriesDefaults seriesDefaults) {
		this.seriesDefaults = seriesDefaults;
		return this;
	}

	/**
	 * Gets the stack series.
	 * 
	 * @return the stackSeries
	 */
	public Boolean getStackSeries() {
		return stackSeries;
	}

	/**
	 * Sets the stack series.
	 * 
	 * @param stackSeries
	 *            the stackSeries to set
	 * @return ChartConfiguration
	 */
	public ChartConfiguration setStackSeries(Boolean stackSeries) {
		this.stackSeries = stackSeries;
		return this;
	}

	/**
	 * Gets the show marker.
	 * 
	 * @return the showMarker
	 */
	public Boolean getShowMarker() {
		return showMarker;
	}

	/**
	 * Sets the show marker.
	 * 
	 * @param showMarker
	 *            the showMarker to set
	 * @return ChartConfiguration
	 */
	public ChartConfiguration setShowMarker(Boolean showMarker) {
		this.showMarker = showMarker;
		return this;
	}

	/**
	 * Creates the series colors.
	 * 
	 * @return the collection
	 */
	@Deprecated
	public Collection createSeriesColors() {
		return seriesColorsInstance();
	}

	/**
	 * Gets the series colors.
	 * 
	 * @return the series colors
	 */
	public Collection getSeriesColors() {
		return seriesColors;
	}

	/**
	 * Sets the series colors.
	 * 
	 * @param seriesColor
	 *            the new series colors
	 * @return ChartConfiguration
	 */
	public ChartConfiguration setSeriesColors(Collection seriesColor) {
		this.seriesColors = seriesColor;
		return this;
	}

	/**
	 * Gets the animate.
	 * 
	 * @return animate property
	 */
	public Boolean getAnimate() {
		return animate;
	}

	/**
	 * Turns on animation for all series in this plot.
	 * 
	 * @param animate
	 *            true, false
	 * @return ChartConfiguration
	 */
	public ChartConfiguration setAnimate(Boolean animate) {
		this.animate = animate;
		return this;
	}

	/**
	 * Creates the highlighter.
	 * 
	 * @return the highlighter
	 */
	@Deprecated
	public Highlighter createHighlighter() {
		return highlighterInstance();
	}

	/**
	 * Gets the highlighter.
	 * 
	 * @return hightLighter
	 */
	public Highlighter getHighlighter() {
		return highlighter;
	}

	/**
	 * set the highlighter.
	 * 
	 * @param highlighter
	 *            property
	 * @return ChartConfiguration
	 */
	public ChartConfiguration setHighlighter(Highlighter highlighter) {
		this.highlighter = highlighter;
		return this;
	}

	/**
	 * Gets the grid.
	 * 
	 * @return the grid
	 */
	public Grid getGrid() {
		return grid;
	}

	/**
	 * Sets the grid.
	 * 
	 * @param grid
	 *            the new grid
	 * @return ChartConfiguration
	 */
	public ChartConfiguration setGrid(Grid grid) {
		this.grid = grid;
		return this;
	}

	/**
	 * Gets the cursor.
	 * 
	 * @return the cursor
	 */
	public Cursor getCursor() {
		return cursor;
	}

	/**
	 * Sets the cursor.
	 * 
	 * @param cursor
	 *            the new cursor
	 * @return ChartConfiguration
	 */
	public ChartConfiguration setCursor(Cursor cursor) {
		this.cursor = cursor;
		return this;
	}

	/**
	 * Gets gridPadding
	 * 
	 * @return GridPadding
	 */
	public GridPadding getGridPadding() {
		return gridPadding;
	}

	/**
	 * Sets the gridPadding
	 * 
	 * @param gridPadding
	 *            the new gridPadding
	 * @return ChartConfiguration
	 */
	public ChartConfiguration setGridPadding(GridPadding gridPadding) {
		this.gridPadding = gridPadding;
		return this;
	}

	/**
	 * Get instance of GridPadding
	 * @return GridPadding
	 */
	public GridPadding gridPaddingInstance() {
		if (gridPadding == null) {
			gridPadding = new GridPadding();
		}
		return gridPadding;
	}

	/**
	 * Instantiates the canvas overlay.
	 * 
	 * @return the canvas overlay
	 */
	public CanvasOverlay canvasOverlayInstance() {
		if (canvasOverlay == null) {
			this.canvasOverlay = new CanvasOverlay();
		}
		return this.canvasOverlay;
	}

	/**
	 * Gets the canvas overlay.
	 * 
	 * @return the canvas overlay
	 */
	public CanvasOverlay getCanvasOverlay() {
		return canvasOverlay;
	}

	/**
	 * Sets the canvas overlay.
	 * 
	 * @param canvasOverlay
	 *            the canvasOverlay to set
	 * @return ChartConfiguration
	 */
	public ChartConfiguration setCanvasOverlay(CanvasOverlay canvasOverlay) {
		this.canvasOverlay = canvasOverlay;
		return this;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy