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

jadex.extension.envsupport.evaluation.AbstractChartDataConsumer Maven / Gradle / Ivy

Go to download

The Jadex kernel extension envsupport allows for using 2D spaces in concert with components.

There is a newer version: 3.0.117
Show newest version
package jadex.extension.envsupport.evaluation;

import java.io.IOException;
import java.util.List;

import javax.swing.JPanel;
import javax.swing.SwingUtilities;

import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;

import jadex.commons.ResourceInfo;
import jadex.commons.SUtil;
import jadex.commons.SimplePropertyObject;
import jadex.extension.envsupport.environment.AbstractEnvironmentSpace;
import jadex.javaparser.IParsedExpression;
import jadex.javaparser.SimpleValueFetcher;

/**
 *  Abstract base class for chart consumers.
 */
public abstract class AbstractChartDataConsumer extends SimplePropertyObject implements ITableDataConsumer
{
	//-------- attributes --------
	
	/** The chart. */
	protected JFreeChart chart;
	
	//-------- constructors --------

	/**
	 *  Create a new chart consumer.
	 */
	public AbstractChartDataConsumer()
	{
	}
		
	//-------- methods --------
	
	/**
	 *  Consume data from the provider.
	 */
	public void consumeData(final long currenttime, final double tick)
	{
		ITableDataProvider provider = getTableDataProvider();
		final DataTable data = provider.getTableData(currenttime, tick);
		
		SwingUtilities.invokeLater(new Runnable()
		{
			public void run()
			{
				List rows = data.getRows();
				
				if(rows!=null && rows.size()>0)
				{
					SimpleValueFetcher fetcher = new SimpleValueFetcher();
					fetcher.setValue("$object", data);

					for(int s=0; ;s++)
					{
						String serid;
						if(s==0 && getPropertyNames().contains("seriesid"))
							serid = (String)getProperty("seriesid");
						else
							serid = (String)getProperty("seriesid_"+s);
						
						if(serid!=null)
						{
							// For a multi-series each row has to be processed.

							for(int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy