jadex.webservice.examples.rs.chart.ChartUserAgent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-applications-webservice Show documentation
Show all versions of jadex-applications-webservice Show documentation
The Jadex web service applications package contains several example applications, benchmarks and testcases using web service integration.
package jadex.webservice.examples.rs.chart;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import jadex.bridge.service.annotation.OnEnd;
import jadex.bridge.service.annotation.OnInit;
import jadex.commons.future.Future;
import jadex.commons.future.IFuture;
import jadex.extension.rs.invoke.RestServiceAgent;
import jadex.micro.annotation.Agent;
import jadex.micro.annotation.RequiredService;
import jadex.micro.annotation.RequiredServices;
/**
* Agent that searches and uses the chart service
* of another Jadex agent.
*/
@Agent
@RequiredServices(@RequiredService(name="chartservice", type=IChartService.class))
public class ChartUserAgent extends RestServiceAgent
{
//-------- attributes --------
protected JFrame f;
//-------- emthods --------
/**
* The agent init.
*/
//@AgentCreated
@OnInit
public IFuture init()
{
final Future ret = new Future();
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
f = ChartPanel.createChartFrame(agent.getExternalAccess());
f.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
agent.killComponent();
}
});
ret.setResult(null);
}
});
return ret;
}
/**
* Called when the agent is killed.
*/
//@AgentKilled
@OnEnd
public IFuture cleanup()
{
final Future ret = new Future();
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
f.dispose();
ret.setResult(null);
}
});
return ret;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy