Home
Analytics
dynamic resolution of a chart
jsOpa
Hi,
again I need your help.
My problem is that the charts I created in the past have a fixed resolution.
I set it with the following script:
function beforeGeneration( chart, icsc )
{
chart.getBlock().getBounds().setHeight(450);
chart.getBlock().getBounds().setWidth(800);
}
But this size sometimes is too big, sometimes too small for the users of the charts because they are using 15" monitors or 19" monitors.
in another forum i found a script to find out the actual resolution of a monitor:
var mheight=0;
var mwidth=0;
var jkit = java.awt.Toolkit.getDefaultToolkit();
var scrsize = jkit.getScreenSize();
mwidth = scrsize.width;
mheight = scrsize.height;
I entered it into the beforeGeneration( chart, icsc ) function:
function beforeGeneration( chart, icsc )
{
var mheight=0;
var mwidth=0;
var jkit = java.awt.Toolkit.getDefaultToolkit();
var scrsize = jkit.getScreenSize();
mwidth = scrsize.width;
mheight = scrsize.height;
chart.getBlock().getBounds().setHeight(mheight/3);
chart.getBlock().getBounds().setWidth(mwidth/3);
}
And it works with the BIRT Report Viewer.
So I was happy and entered these reports into our online webinterface which you can use with a normal web browser.
But there I get the following error message when I try to run these reports:
"+ Wrapped java.awt.HeadlessException at line 61 of chart script:''"
What is my mistake? What can I do to solve this problem?
Thanks for your help,
jsOpa
Find more posts tagged with
Comments
mwilliams
Hi jsOpa,
Can you expand the error and post the entire thing in here? Do you know what is in line 61 of your script?
jsOpa
Hi Michael,<br />
<br />
thanks for your answer. The expanded error message is:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
The following items have errors:
Chart 09:
- Wrapped java.awt.HeadlessException at line 61 of chart script:''
exception.javascript.error ( 1 time(s) )
detail : org.eclipse.birt.report.engine.api.EngineException: Wrapped java.awt.HeadlessException at line 61 of chart script:''
at org.eclipse.birt.report.engine.executor.ExecutionContext.addException(ExecutionContext.java:1166)
at org.eclipse.birt.report.engine.presentation.LocalizedContentVisitor.processExtendedContent(LocalizedContentVisitor.java:990)
at org.eclipse.birt.report.engine.presentation.LocalizedContentVisitor.visitForeign(LocalizedContentVisitor.java:556)
at org.eclipse.birt.report.engine.content.impl.ForeignContent.accept(ForeignContent.java:71)
at org.eclipse.birt.report.engine.presentation.LocalizedContentVisitor.localize(LocalizedContentVisitor.java:154)
at org.eclipse.birt.report.engine.internal.executor.l18n.LocalizedReportItemExecutor.execute(LocalizedReportItemExecutor.java:37)
at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:64)
at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPageLM.java:90)
at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:99)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:167)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:75)
at org.eclipse.birt.report.service.ReportEngineService.runAndRenderReport(ReportEngineService.java:882)
at org.eclipse.birt.report.service.BirtViewerReportService.runAndRenderReport(BirtViewerReportService.java:973)
at org.eclipse.birt.report.service.actionhandler.BirtRunAndRenderActionHandler.__execute(BirtRunAndRenderActionHandler.java:76)
at org.eclipse.birt.report.service.actionhandler.AbstractBaseActionHandler.execute(AbstractBaseActionHandler.java:90)
at org.eclipse.birt.report.presentation.aggregation.layout.EngineFragment.doService(EngineFragment.java:318)
at org.eclipse.birt.report.presentation.aggregation.AbstractBaseFragment.service(AbstractBaseFragment.java:76)
at org.eclipse.birt.report.servlet.BirtEngineServlet.__doGet(BirtEngineServlet.java:120)
at org.eclipse.birt.report.servlet.BaseReportEngineServlet.doGet(BaseReportEngineServlet.java:185)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.eclipse.birt.report.servlet.BaseReportEngineServlet.service(BaseReportEngineServlet.java:116)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.eclipse.birt.report.filter.ViewerFilter.doFilter(ViewerFilter.java:68)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.ave.er.filters.SessionExpiredFilter.doFilter(SessionExpiredFilter.java:56)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.eclipse.birt.chart.exception.ChartException: Wrapped java.awt.HeadlessException at line 61 of chart script:''
at org.eclipse.birt.chart.script.ScriptHandler.convertException(ScriptHandler.java:1146)
at org.eclipse.birt.chart.script.ScriptHandler.callJavaScriptFunction(ScriptHandler.java:615)
at org.eclipse.birt.chart.script.ScriptHandler.callFunction(ScriptHandler.java:924)
at org.eclipse.birt.chart.factory.Generator.build(Generator.java:965)
at org.eclipse.birt.chart.reportitem.ChartReportItemPresentationBase.buildChart (ChartReportItemPresentationBase.java:887)
at org.eclipse.birt.chart.reportitem.ChartReportItemPresentationBase.onRowSets(ChartReportItemPresentationBase.java:758)
at org.eclipse.birt.chart.reportitem.ChartReportItemPresentationProxy.onRowSets(ChartReportItemPresentationProxy.java:116)
at org.eclipse.birt.report.engine.presentation.LocalizedContentVisitor.processExtendedContent(LocalizedContentVisitor.java:966)
... 39 more
Caused by: org.mozilla.javascript.WrappedException: Wrapped java.awt.HeadlessException (/report/body/extended-item[
@id="
;26"]/method[
@name="
;onRender"]#61)
at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1654)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:175)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:243)
at org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:119)
at org.mozilla.javascript.gen.c99._c2(/report/body/extended-item[
@id="
;26"]/method[
@name="
;onRender"]:61)
at org.mozilla.javascript.gen.c99.call(/report/body/extended-item[
@id="
;26"]/method[
@name="
;onRender"])
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:401)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3003)
at org.mozilla.javascript.gen.c99.call(/report/body/extended-item[
@id="
;26"]/method[
@name="
;onRender"])
at org.eclipse.birt.chart.script.ScriptHandler.callJavaScriptFunction(ScriptHandler.java:611)
... 45 more
Caused by: java.awt.HeadlessException
at sun.awt.HeadlessToolkit.getScreenSize(HeadlessToolkit.java:261)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:160)
... 53 more
</pre>
<br />
In the line #56-#66 of the script there is the following script, it is the complete function beforeGeneration():<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>function beforeGeneration( chart, icsc )
{
var mheight=0;
var mwidth=0;
var jkit = java.awt.Toolkit.getDefaultToolkit();
var scrsize = jkit.getScreenSize();
mwidth = scrsize.width;
mheight = scrsize.height;
chart.getBlock().getBounds().setHeight(mheight/3);
chart.getBlock().getBounds().setWidth(mwidth/3);
}
</pre>
<br />
Thanks for your help,<br />
<br />
regards, jsOpa