Tomcat shutdowns abruptly when applet is closed.

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Jyothy
Posts: 17
Joined: Fri Mar 24, 2006 6:46 am

Tomcat shutdowns abruptly when applet is closed.

Post by Jyothy » Fri Mar 24, 2006 7:02 am

I am using applet(ChartPanel) to capture mouse events on the times series graph. On chartMouseMoved event i am displaying the x,y coordinate values in a tooltip.
The tooptip values are being displayed in an applet correctly, but the tomcat is being shutdown when applet is closed.

I am using Cewolf to display my graph in a jsp.

//This is the code to capture mouse events.

public void chartMouseClicked(ChartMouseEvent event) {
try {
int mouseX = event.getTrigger().getX();
int mouseY = event.getTrigger().getY();
//System.out.println("x = " + mouseX + ", y = " + mouseY);
Point2D p = chartPanel.translateScreenToJava2D(
new Point(mouseX, mouseY));
//System.out.println("----------chart"+ this.chart.getPlot().getClass().getName());
XYPlot plot = (XYPlot) this.chart.getPlot();
Rectangle2D plotArea = chartPanel.getScreenDataArea();
ValueAxis domainAxis = plot.getDomainAxis();
DateAxis xAxis = (DateAxis)plot.getDomainAxis();
RectangleEdge domainAxisEdge = plot.getDomainAxisEdge();
ValueAxis rangeAxis = plot.getRangeAxis();
RectangleEdge rangeAxisEdge = plot.getRangeAxisEdge();
double chartX = xAxis.java2DToValue(p.getX(), plotArea,
domainAxisEdge);
double chartY = rangeAxis.java2DToValue(p.getY(), plotArea,
rangeAxisEdge);
//System.out.println("Chart: x = " + chartX + ", y = " + chartY);
StandardXYToolTipGenerator toolTipGen = (StandardXYToolTipGenerator) StandardXYToolTipGenerator.getTimeSeriesInstance();
StandardXYItemRenderer renderer =
new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES,(org.jfree.chart.labels.StandardXYToolTipGenerator) toolTipGen);
renderer.setShapesFilled(true);
renderer.setSeriesToolTipGenerator(0,(org.jfree.chart.labels.StandardXYToolTipGenerator) toolTipGen);
//renderer.setDrawSeriesLineAsPath(true);
plot.setRenderer(renderer);
}catch(Exception ex){
ex.printStackTrace();
}
}


//This is the code to display panel

public void processChart(Object chart, Map params)
{
try {
chart1 = (JFreeChart)chart;
XYPlot plot = (XYPlot) chart1.getPlot();
DateAxis haxis = (DateAxis)plot.getDomainAxis();
haxis.setVerticalTickLabels(true);
haxis.setDateFormatOverride(new SimpleDateFormat("dd hh:mm"));

//wrapper class which extends ApplicationFrame and //implements ChartMouseListener
ChartMouseEvents event = new ChartMouseEvents(chart1);
RefineryUtilities.centerFrameOnScreen(event);
event.setVisible(true);

}catch(Exception ex){
ex.printStackTrace();
}

}


//jsp code

<jsp:useBean id="format" scope="session" class="com.netenrich.web.monitor.MonitorChartPostProcessor"/>
<cewolf:chart id="timeseries" title="" type="timeseries" xaxislabel="Time[DD hh:mm]" yaxislabel="Values">
<cewolf:data>
<cewolf:producer id="graph"/>
</cewolf:data>
<cewolf:chartpostprocessor id="format">
<cewolf:param name="interval" value="${requestScope.interval}"/>
</cewolf:chartpostprocessor>
<cewolf:colorpaint color="#EEEEEF"/>
</cewolf:chart>
<p><cewolf:img chartid="timeseries"
renderer="/cewolf" width="500" height="250">

</cewolf:img>


please let me why tomcat is being shut down. i am using tomcat 5.5 and java 1.5. OS windows professional

Thanks
Jyothy Anjuri

Taqua
JFreeReport Project Leader
Posts: 698
Joined: Fri Mar 14, 2003 3:34 pm
Contact:

Post by Taqua » Fri Mar 24, 2006 11:28 am

Hi,

you can't (or at least should not) create Frames or Dialogs inside a Servlet-Container. Usually, the servlet container is executed on a physically different location, so your user would never be able to "click" anything on the frame that pops up.

An applet is executed by the browser, your JSP code should generate an "<applet ..>" tag or the corresponding "<object ..>" tags to display them. Right now you are generating an image (using the "cewolf:img" JSP-tag), which is something funtamental different than an applet.

Maybe you should reconsider your application design ...

Regards,
Thomas

Jyothy
Posts: 17
Joined: Fri Mar 24, 2006 6:46 am

Post by Jyothy » Mon Mar 27, 2006 7:57 am

Thanks for your response.


Can you please tell me how can i show tooltip on each of xy coordinate of my graph with out using panel concept then?

May its possible using ChartPostProcessor . but how can i get the mouseMove event then??

i have used the following code but could not generate any tooptips

XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
renderer.setBaseShapesVisible(true);
renderer.setBaseShapesFilled(true);
StandardXYToolTipGenerator toolTipGen = (StandardXYToolTipGenerator) StandardXYToolTipGenerator.getTimeSeriesInstance();
renderer.setToolTipGenerator(toolTipGen);
renderer.setSeriesToolTipGenerator(0,(org.jfree.chart.labels.StandardXYToolTipGenerator) toolTipGen);

Please help me to resolve my problem

Thanks in advance
Jyothy Anjuri

Locked