/*
* File name: HistPlug.java (package eas.users.lukas.demos.stupidModel)
* Author(s): aifb
* Java version: 6.0
* Generation date: 14.09.2011 (17:03:02)
*
* (c) This file and the EAS (Easy Agent Simulation) framework containing it
* is protected by Creative Commons by-nc-sa license. Any altered or
* further developed versions of this file have to meet the agreements
* stated by the license conditions.
*
* In a nutshell
* -------------
* You are free:
* - to Share -- to copy, distribute and transmit the work
* - to Remix -- to adapt the work
*
* Under the following conditions:
* - Attribution -- You must attribute the work in the manner specified by the
* author or licensor (but not in any way that suggests that they endorse
* you or your use of the work).
* - Noncommercial -- You may not use this work for commercial purposes.
* - Share Alike -- If you alter, transform, or build upon this work, you may
* distribute the resulting work only under the same or a similar license to
* this one.
*
* + Detailed license conditions (Germany):
* http://creativecommons.org/licenses/by-nc-sa/3.0/de/
* + Detailed license conditions (unported):
* http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en
*
* This header must be placed in the beginning of any version of this file.
*/
package eas.users.demos.stupidModel;
import java.util.LinkedList;
import java.util.List;
import org.jfree.data.statistics.HistogramDataset;
import org.jfree.data.statistics.HistogramType;
import eas.plugins.AbstractDefaultPlugin;
import eas.plugins.PluginProperties;
import eas.simulation.Wink;
import eas.simulation.event.EASEvent;
import eas.startSetup.ParCollection;
import eas.startSetup.SingleParameter;
/**
* @author aifb
*
*/
@PluginProperties (pluginIsHidden = true)
public class StupidHistogramPlugin extends AbstractDefaultPlugin<StupidEnvironment> {
/**
*
*/
private static final long serialVersionUID = 5443688791601066979L;
// private JFreeChart chart;
private HistogramDataset dataset;
// private StaticWindow show;
@Override
public List<String> getRequiredPlugins() {
return null;
}
@Override
public List<SingleParameter> getParameters() {
return new LinkedList<SingleParameter>();
}
@Override
public String id() {
return "Stupid-histogram";
}
@Override
public void runBeforeSimulation(StupidEnvironment env, ParCollection params) {
dataset = new HistogramDataset();
dataset.setType(HistogramType.RELATIVE_FREQUENCY);
// chart = ChartFactory.createHistogram(
// "Test",
// "LabelX",
// "LabelY",
// dataset,
// PlotOrientation.VERTICAL,
// false,
// false,
// false);
//
// show = StaticMethods.showImage(chart.createBufferedImage(500, 500), "Histogramm");
}
@Override
public void runAfterSimulation(StupidEnvironment env, ParCollection params) {
}
@Override
public void runDuringSimulation(StupidEnvironment env, Wink currentSimTime,
ParCollection params) {
if (currentSimTime.getLastTick() % 1 != 0) {
return;
}
List<StupidBug> list = env.getAgents();
double[] values = new double[list.size()];
int i = 0;
int max = 1;
for (StupidBug b : list) {
values[i] = b.getMyScale();
if (b.getMyScale() > max) {
max = b.getMyScale();
}
i++;
}
dataset = new HistogramDataset();
dataset.setType(HistogramType.RELATIVE_FREQUENCY);
dataset.addSeries("Test", values, max);
// chart = ChartFactory.createHistogram(
// "Test",
// "LabelX",
// "LabelY",
// dataset,
// PlotOrientation.VERTICAL,
// false,
// false,
// false);
//
// show.getPanel().setImg(chart.createBufferedImage(500, 500));
// show.getPanel().repaint();
}
@Override
public void handleEvent(EASEvent e, StupidEnvironment env,
Wink lastSimTime, ParCollection params) {
}
/* (non-Javadoc)
* @see eas.plugins.Plugin#getSupportedPlugins()
*/
@Override
public List<String> getSupportedPlugins() {
// TODO Auto-generated method stub
return null;
}
@Override
public void onSimulationResumed(StupidEnvironment env, Wink resumeTime,
ParCollection params) {
}
}