Jump to content
Software FX Community

Newbie Question To Using Templates in 6.5


jkirby

Recommended Posts

OK ..

I have built a horizontal gauge with designer (Community Edition) and call it via JSP:

<%
com.softwarefx.chartfx.gauge.HorizontalGauge.initWeb(pageContext,request,response);
com.softwarefx.chartfx.gauge.HorizontalGauge gauge = new com.softwarefx.chartfx.gauge.HorizontalGauge();
gauge.importGauge(com.softwarefx.chartfx.gauge.FileFormat.XML, application.getRealPath("smallChart.hgfx"));
gauge.renderToStream();

%>

smallChart.hgfx is located in my context root. 

First I get this error message in my Glassfish server log: 

StandardWrapperValve[jsp]: PWC1406: Servlet.service() for servlet jsp threw exception
java.lang.IllegalStateException: PWC3991: getOutputStream() has already been called for this response
  at org.apache.coyote.tomcat5.CoyoteResponse.getWriter(CoyoteResponse.java:700)
  at org.apache.coyote.tomcat5.CoyoteResponseFacade.getWriter(CoyoteResponseFacade.java:210)
  at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:135)

 Here is my template:

<?xml version="1.0" encoding="UTF-8"?>
<HorizontalGauge>
  <WIDTH>300</WIDTH>
  <HEIGHT>113</HEIGHT>
  <BORDER>
    <VISIBLE>true</VISIBLE>
    <COLOR>#ff003333</COLOR>
    <GLARE>false</GLARE>
    <STYLE>LinearBorder03</STYLE>
  </BORDER>
  <INNERGAUGES>
    <ITEM type="ChartFX.WebForms.Gauge.InnerDigitalPanel">
      <LAYOUT>
        <ALIGNMENT>BottomCenter</ALIGNMENT>
        <ANCHORPOINT>
          <X>0.75</X>
          <Y>1.1</Y>
        </ANCHORPOINT>
        <TARGET>AnchorPoint</TARGET>
      </LAYOUT>
      <INNERGAUGE>
        <BORDER>
          <VISIBLE>false</VISIBLE>
        </BORDER>
        <APPEARANCE>
          <COLOR>#ffff0000</COLOR>
          <LAYOUT>
            <ALIGNMENT>BottomCenter</ALIGNMENT>
            <ANCHORPOINT>
              <Y>0.37</Y>
            </ANCHORPOINT>
            <TARGET>AnchorPoint</TARGET>
          </LAYOUT>
          <SIZE>0.25</SIZE>
          <STYLE>FourteenSegments01</STYLE>
        </APPEARANCE>
        <VALUE>50.0</VALUE>
      </INNERGAUGE>
      <LINKTOMAINVALUE>true</LINKTOMAINVALUE>
      <SIZE>
        <WIDTH>0.5</WIDTH>
        <HEIGHT>0.5</HEIGHT>
      </SIZE>
    </ITEM>
  </INNERGAUGES>
  <TITLES>
    <ITEM>
      <LAYOUT>
        <ALIGNMENT>TopCenter</ALIGNMENT>
        <ANCHORPOINT>
          <X>0.5</X>
          <Y>0.03</Y>
        </ANCHORPOINT>
        <TARGET>AnchorPoint</TARGET>
      </LAYOUT>
      <VERTICALPOSITION>AboveIndicators</VERTICALPOSITION>
      <FONT type="ChartFX.WebForms.Gauge.GaugeFont">
        <FAMILYNAME>SansSerif</FAMILYNAME>
        <FONTSTYLE>Bold</FONTSTYLE>
      </FONT>
      <TEXT>CPU</TEXT>
    </ITEM>
  </TITLES>
  <SCALES>
    <ITEM>
      <INDEX>0</INDEX>
      <INDICATORS>
        <ITEM type="ChartFX.WebForms.Gauge.Filler">
          <COLOR>#ff006600</COLOR>
          <INDEX>0</INDEX>
          <FORMAT>
            <FORMATTYPE>Percentage</FORMATTYPE>
          </FORMAT>
          <STYLE>Repeater01</STYLE>
        </ITEM>
      </INDICATORS>
    </ITEM>
  </SCALES>
</HorizontalGauge>
 

How can I get this to go away? I also get this error running the example Combination.jsp but that gauge does appear.

So my main question is can I define the complete L&F/behavior in the template then just render it to a stream?

A good code example would be useful :-)
 

regards,
 

.j 

Link to comment
Share on other sites

The exception is not related to the template.  Some server are really picky about the handling of the output stream, and I guess GlassFish is one of them.

When you call renderToStream, Chart FX gets the output stream to push the image, but If you have blank line at the end JSP file for example, the compiled JSP will try to output that blank line to the output stream as well, and since ChartFX took it, you get the exception. Some serves will just throw a warning, but you'll get the image.

There are 2 things to try:

1) remove all extra lines and characters, ie:

<%com.softwarefx.chartfx.gauge.HorizontalGauge.initWeb(pageContext,request,response);

com.softwarefx.chartfx.gauge.HorizontalGauge gauge = new com.softwarefx.chartfx.gauge.HorizontalGauge();

gauge.importGauge(com.softwarefx.chartfx.gauge.FileFormat.XML, application.getRealPath("smallChart.hgfx"));

gauge.renderToStream();%>

Be sure the file ends at %>, or

2) Call gauge.renderToControl(), which will create a image in the temp folder and will return the image tag to the browser.

I'll take a look to the samples on Glasfish, and I'll adjust them accordingly 

 

Link to comment
Share on other sites

Thanks ... The space trick worked on the template but still throws outstream() exception.  My other question is on the demos (and my code)  the ticker labels (e.g number > two digits) get  "super-imposed" on each other.  The same affect happens with title text.  How does one get the labels to display properly?

Link to comment
Share on other sites

Hi, we were able to identify the issue.  It is a specific issue in the Mac JDK with fractional size fonts (Radar #4402021) which was fixed in the lastest update, but still seems to be present when the font size in less than 1.  Chart FX Gauges for Java internally uses size from 0 to 1 for font scalling, and this causing the failure.

The developer team is looking for a work around, hopefully they will have something for the end of this week or next week.  I'll will keep you informed.

Link to comment
Share on other sites

  • 2 months later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...