Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Using Browser Widget as report viewer, is it good approach ?
Using Browser Widget as report viewer, is it good approach ? [message #452407] Sun, 20 March 2005 10:43 Go to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Hi all,

I need to display report in my application, so far I plan to use
JasperReports engine to populate the report on server with data from
database then send the report to client to be previewed by Browser Widget
available in SWT, is this possible and a good solution (from performance
point of view, scalability etc) ? Has anybody ever used this approach ?

Any suggestions are welcomed and appreciated.

Thank you in advanced.


Setya
Re: Using Browser Widget as report viewer, is it good approach ? [message #452413 is a reply to message #452407] Sun, 20 March 2005 14:05 Go to previous messageGo to next message
ted stockwell is currently offline ted stockwellFriend
Messages: 123
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------030208090007050000020602
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Setya wrote:
> Hi all,
>
> I need to display report in my application, so far I plan to use
> JasperReports engine to populate the report on server with data from
> database then send the report to client to be previewed by Browser
> Widget available in SWT, is this possible and a good solution (from
> performance point of view, scalability etc) ? Has anybody ever used this
> approach ?
>
> Any suggestions are welcomed and appreciated.
>
> Thank you in advanced.
>
>
> Setya
>

Yes and no.


My company uses the SWT browser widget in our product to display JasperReports and that solution is working pretty well for us.
We currently have several hundred Windows users viewing reports this way with no problem.
We display reports in both our desktop RCP-based application and our web-based reports portal.
One cool thing is that we can display drill-down reports in the desktop that can open up editors.
So for instance, from the aged receivables report you can open up the associated customer editor or order editor by clicking on
links on the report (this is done by employing the Tomcat web server embedded in the desktop to open up the editors).

---------------------------------

HOWEVER, the HTML renderer that comes out of the box with JasperReports is quite lame and in my opinion is not suitable for use
in a production application. The problem with the renderer (and frankly, with JasperReports itself) is that the report design
is pixel based and the HTML render attempts to format the HTML to the exact pixel size specified in the report design.
What often ends up happening is that reports looks small when displayed in the browser.

I tweaked the JasperReport HTML render so that it does not include pixel units or font sizes specified in the report design in
the generated HTML. I find this renderer to be satisfactory. My requirement for diplaying reports in the browser is not that
the reports are formatted EXACTLY like they would look in PDF or RTF but that they look OK, easy to view.
I have attached a copy of this renderer.
By default the renderer will work exactly like the default JasperReports renderer. Set the IS_USING_REPORT_SIZES to false to
produce HTML that is not pixel-based.

---------------------------------

If you have not yet implemented anything then I strongly suggest that you first create a protoptype report with BIRT,
http://www.eclipse.org/birt.

One thing I like about BIRT is that the report design model is superior to JasperReports in that reports are not pixel-based
(but can support pixel-based elements). This will enabled me to use BIRT to produce forms that I cannot currently produce in
JasperReports (we currently use Apache FOP for forms that require more sophisticated formatting than JasperReports can provide).

One thing I don't like about BIRT is that the report design is more complicated/sophisticated compared to JasperReports. Using
the JasperAssistant report writer, http://www.jasperassistant.com/, I can whip out JasperReports at lightning speed. I found
JasperReports and JasperAssistant VERY easy to use out of the box. OTOH, I found the BIRT report design rather mysterious. It
took quite a lot of effort to create my first BIRT report.

---------------------------------

I would be interested in hearing other folks experience using BIRT in the SWT browser or in the RCP.


ted stockwell
technical director
RPC Software
rpcsoftware.com


--------------030208090007050000020602
Content-Type: text/plain;
name="JRHtmlExporter.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="JRHtmlExporter.java"

/*
* ============================================================ ================
* The JasperReports License, Version 1.0
* ============================================================ ================
*
* Copyright (C) 2001-2004 Teodor Danciu (teodord@users.sourceforge.net). All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment: "This product includes software
* developed by Teodor Danciu (http://jasperreports.sourceforge.net)."
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The name "JasperReports" must not be used to endorse or promote products
* derived from this software without prior written permission. For written
* permission, please contact teodord@users.sourceforge.net.
*
* 5. Products derived from this software may not be called "JasperReports", nor
* may "JasperReports" appear in their name, without prior written permission
* of Teodor Danciu.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
* DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/*
* ============================================================ ================
* GNU Lesser General Public License
* ============================================================ ================
*
* JasperReports - Free Java report-generating library.
* Copyright (C) 2001-2004 Teodor Danciu teodord@users.sourceforge.net
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* Teodor Danciu
* 173, Calea Calarasilor, Bl. 42, Sc. 1, Ap. 18
* Postal code 030615, Sector 3
* Bucharest, ROMANIA
* Email: teodord@users.sourceforge.net
*/

/*
* Contributors:
* Alex Parfenov - aparfeno@users.sourceforge.net
* Adrian Jackson - iapetus@users.sourceforge.net
* David Taylor - exodussystems@users.sourceforge.net
* Lars Kristensen - llk@users.sourceforge.net
*/
package net.sf.jasperreports.engine.export;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.font.TextAttribute;
import java.awt.geom.Dimension2D;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.text.AttributedCharacterIterator;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

import net.sf.jasperreports.engine.JRAbstractExporter;
import net.sf.jasperreports.engine.JRAlignment;
import net.sf.jasperreports.engine.JRElement;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExporterParameter;
import net.sf.jasperreports.engine.JRFont;
import net.sf.jasperreports.engine.JRGraphicElement;
import net.sf.jasperreports.engine.JRHyperlink;
import net.sf.jasperreports.engine.JRImage;
import net.sf.jasperreports.engine.JRImageRenderer;
import net.sf.jasperreports.engine.JRPrintElement;
import net.sf.jasperreports.engine.JRPrintEllipse;
import net.sf.jasperreports.engine.JRPrintImage;
import net.sf.jasperreports.engine.JRPrintLine;
import net.sf.jasperreports.engine.JRPrintPage;
import net.sf.jasperreports.engine.JRPrintRectangle;
import net.sf.jasperreports.engine.JRPrintText;
import net.sf.jasperreports.engine.JRRenderable;
import net.sf.jasperreports.engine.JRTextElement;
import net.sf.jasperreports.engine.JRWrappingSvgRenderer;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.base.JRBaseFont;
import net.sf.jasperreports.engine.util.JRImageLoader;
import net.sf.jasperreports.engine.util.JRStringUtil;
import net.sf.jasperreports.engine.util.JRStyledText;
import net.sf.jasperreports.engine.util.JRStyledTextParser;

import org.xml.sax.SAXException;


/**
* @author Teodor Danciu (teodord@users.sourceforge.net)
* @version $Id: JRHtmlExporter.java,v 1.1 2005/02/17 22:43:20 tstock Exp $
*/
public class JRHtmlExporter extends JRAbstractExporter
{


/**
*
*/
protected static final String JR_PAGE_ANCHOR_PREFIX = "JR_PAGE_ANCHOR_";

/**
*
*/
protected static final String CSS_TEXT_ALIGN_LEFT = "left";
protected static final String CSS_TEXT_ALIGN_RIGHT = "right";
protected static final String CSS_TEXT_ALIGN_CENTER = "center";
protected static final String CSS_TEXT_ALIGN_JUSTIFY = "justify";

/**
*
*/
protected static final String HTML_VERTICAL_ALIGN_TOP = "top";
protected static final String HTML_VERTICAL_ALIGN_MIDDLE = "middle";
protected static final String HTML_VERTICAL_ALIGN_BOTTOM = "bottom";

/**
*
*/
protected Writer writer = null;
protected JRExportProgressMonitor progressMonitor = null;
protected Map rendererToImageNameMap = null;
protected Map imageNameToImageDataMap = null;

protected int reportIndex = 0;

/**
*
*/
protected JRFont defaultFont = null;

/**
*
*/
protected JRStyledTextParser styledTextParser = new JRStyledTextParser();

/**
*
*/
protected File imagesDir = null;
protected String imagesURI = null;
protected boolean isOutputImagesToDir = false;
protected boolean isRemoveEmptySpace = false;
protected boolean isWhitePageBackground = true;
protected String encoding = null;
protected boolean isUsingReportSizes = true;


/**
*
*/
protected String htmlHeader = null;
protected String betweenPagesHtml = null;
protected String htmlFooter = null;

protected StringProvider emptyCellStringProvider = null;

/**
*
*/
protected static final int colorMask = Integer.parseInt("FFFFFF", 16);

/**
*
*/
protected JRExporterGridCell grid[][] = null;
protected boolean isRowNotEmpty[] = null;
protected List xCuts = null;
protected List yCuts = null;


/**
*
*/
protected JRFont getDefaultFont()
{
if (defaultFont == null)
{
defaultFont = jasperPrint.getDefaultFont();
if (defaultFont == null)
{
defaultFont = new JRBaseFont();
}
}

return defaultFont;
}


/**
*
*/
public void exportReport() throws JRException
{
progressMonitor = (JRExportProgressMonitor)parameters.get(JRExporterParameter. PROGRESS_MONITOR);

/* */
setOffset();

/* */
setInput();

/* */
if (!isModeBatch)
{
setPageRange();
}

htmlHeader = (String)parameters.get(JRHtmlExporterParameter.HTML_HEADER);
betweenPagesHtml = (String)parameters.get(JRHtmlExporterParameter.BETWEEN_PAGES _HTML);
htmlFooter = (String)parameters.get(JRHtmlExporterParameter.HTML_FOOTER);

imagesDir = (File)parameters.get(JRHtmlExporterParameter.IMAGES_DIR);
if (imagesDir == null)
{
String dir = (String)parameters.get(JRHtmlExporterParameter.IMAGES_DIR_NA ME);
if (dir != null)
{
imagesDir = new File(dir);
}
}

Boolean isRemoveEmptySpaceParameter = (Boolean)parameters.get(JRHtmlExporterParameter.IS_REMOVE_EM PTY_SPACE_BETWEEN_ROWS);
if (isRemoveEmptySpaceParameter != null)
{
isRemoveEmptySpace = isRemoveEmptySpaceParameter.booleanValue();
}

Boolean isWhitePageBackgroundParameter = (Boolean)parameters.get(JRHtmlExporterParameter.IS_WHITE_PAG E_BACKGROUND);
if (isWhitePageBackgroundParameter != null)
{
isWhitePageBackground = isWhitePageBackgroundParameter.booleanValue();
}

Boolean isOutputImagesToDirParameter = (Boolean)parameters.get(JRHtmlExporterParameter.IS_OUTPUT_IM AGES_TO_DIR);
if (isOutputImagesToDirParameter != null)
{
isOutputImagesToDir = isOutputImagesToDirParameter.booleanValue();
}

Boolean isUsingReportSizesParameter = (Boolean)parameters.get(JRHtmlExporterParameter.IS_USING_REP ORT_SIZES);
if (isUsingReportSizesParameter != null)
{
isUsingReportSizes = isUsingReportSizesParameter.booleanValue();
}

String uri = (String)parameters.get(JRHtmlExporterParameter.IMAGES_URI);
if (uri != null)
{
imagesURI = uri;
}

encoding = (String)parameters.get(JRExporterParameter.CHARACTER_ENCODIN G);
if (encoding == null)
{
encoding = "UTF-8";
}

rendererToImageNameMap = new HashMap();

imageNameToImageDataMap = (Map)parameters.get(JRHtmlExporterParameter.IMAGES_MAP);
if (imageNameToImageDataMap == null)
{
imageNameToImageDataMap = new HashMap();
}

Boolean isUsingImagesToAlignParameter = (Boolean)parameters.get(JRHtmlExporterParameter.IS_USING_IMA GES_TO_ALIGN);
if (isUsingImagesToAlignParameter == null)
{
isUsingImagesToAlignParameter = Boolean.TRUE;
}

if (isUsingImagesToAlignParameter.booleanValue())
{
emptyCellStringProvider =
new StringProvider()
{
public String getStringForCollapsedTD(Object value)
{
return "><img src=\"" + value + "px\"";
}
public String getStringForEmptyTD(Object value)
{
return "<img src=\"" + value + "px\" border=0>";
}
};

loadPxImage();
}
else
{
emptyCellStringProvider =
new StringProvider()
{
public String getStringForCollapsedTD(Object value)
{
return "";
}
public String getStringForEmptyTD(Object value)
{
return "";
}
};
}


StringBuffer sb = (StringBuffer)parameters.get(JRXmlExporterParameter.OUTPUT_S TRING_BUFFER);
if (sb != null)
{
try
{
writer = new StringWriter();
exportReportToWriter();
sb.append(writer.toString());
}
catch (IOException e)
{
throw new JRException("Error writing to StringBuffer writer : " + jasperPrint.getName(), e);
}
finally
{
if (writer != null)
{
try
{
writer.close();
}
catch(IOException e)
{
}
}
}
}
else
{
writer = (Writer)parameters.get(JRExporterParameter.OUTPUT_WRITER);
if (writer != null)
{
try
{
exportReportToWriter();
}
catch (IOException e)
{
throw new JRException("Error writing to writer : " + jasperPrint.getName(), e);
}
}
else
{
OutputStream os = (OutputStream)parameters.get(JRExporterParameter.OUTPUT_STRE AM);
if (os != null)
{
try
{
writer = new OutputStreamWriter(os, encoding);
exportReportToWriter();
}
catch (IOException e)
{
throw new JRException("Error writing to OutputStream writer : " + jasperPrint.getName(), e);
}
}
else
{
File destFile = (File)parameters.get(JRExporterParameter.OUTPUT_FILE);
if (destFile == null)
{
String fileName = (String)parameters.get(JRExporterParameter.OUTPUT_FILE_NAME) ;
if (fileName != null)
{
destFile = new File(fileName);
}
else
{
throw new JRException("No output specified for the exporter.");
}
}

try
{
os = new FileOutputStream(destFile);
writer = new OutputStreamWriter(os, encoding);
}
catch (IOException e)
{
throw new JRException("Error creating to file writer : " + jasperPrint.getName(), e);
}

if (imagesDir == null)
{
imagesDir = new File(destFile.getParent(), destFile.getName() + "_files");
}

if (isOutputImagesToDirParameter == null)
{
isOutputImagesToDir = true;
}

if (imagesURI == null)
{
imagesURI = imagesDir.getName() + "/";
}

try
{
exportReportToWriter();
}
catch (IOException e)
{
throw new JRException("Error writing to file writer : " + jasperPrint.getName(), e);
}
finally
{
if (writer != null)
{
try
{
writer.close();
}
catch(IOException e)
{
}
}
}
}
}
}

if (isOutputImagesToDir)
{
if (imagesDir == null)
{
throw new JRException("The images directory was not specified for the exporter.");
}

Collection imageNames = imageNameToImageDataMap.keySet();
if (imageNames != null && imageNames.size() > 0)
{
if (!imagesDir.exists())
{
imagesDir.mkdir();
}

for(Iterator it = imageNames.iterator(); it.hasNext();)
{
String imageName = (String)it.next();
byte[] imageData = (byte[])imageNameToImageDataMap.get(imageName);

File imageFile = new File(imagesDir, imageName);
FileOutputStream fos = null;

try
{
fos = new FileOutputStream(imageFile);
fos.write(imageData, 0, imageData.length);
}
catch (Exception e)
{
throw new JRException("Error writing to image file : " + imageFile, e);
}
finally
{
if (fos != null)
{
try
{
fos.close();
}
catch(IOException e)
{
}
}
}
}
}
}
}


/**
*
*/
protected void exportReportToWriter() throws JRException, IOException
{
if (htmlHeader == null)
{
writer.write("<html>\n");
writer.write("<head>\n");
writer.write(" <meta http-equiv=\"Content-Type\" content=\"text/html; charset=" + encoding + "\">\n");
writer.write(" <style type=\"text/css\">\n");
writer.write(" a {text-decoration: none}\n");
writer.write(" </style>\n");
writer.write("</head>\n");
writer.write("<body text=\"#000000\" link=\"#000000\" alink=\"#000000\" vlink=\"#000000\">\n");
writer.write("<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n");
writer.write("<tr><td width=\"50%\">&nbsp;</td><td align=\"center\">\n");
writer.write("\n");
}
else
{
writer.write(htmlHeader);
}

for(reportIndex = 0; reportIndex < jasperPrintList.size(); reportIndex++)
{
jasperPrint = (JasperPrint)jasperPrintList.get(reportIndex);
defaultFont = null;

List pages = jasperPrint.getPages();
if (pages != null && pages.size() > 0)
{
if (isModeBatch)
{
startPageIndex = 0;
endPageIndex = pages.size() - 1;
}

JRPrintPage page = null;
for(int pageIndex = startPageIndex; pageIndex <= endPageIndex; pageIndex++)
{
if (Thread.currentThread().isInterrupted())
{
throw new JRException("Current thread interrupted.");
}

page = (JRPrintPage)pages.get(pageIndex);

writer.write("<a name=\"" + JR_PAGE_ANCHOR_PREFIX + reportIndex + "_" + (pageIndex + 1) + "\"/>\n");

/* */
exportPage(page);

if (betweenPagesHtml == null)
{
writer.write("<br>\n<br>\n");
}
else
{
writer.write(betweenPagesHtml);
}

writer.write("\n");
}
}
}

if (htmlFooter == null)
{
writer.write("</td><td width=\"50%\">&nbsp;</td></tr>\n");
writer.write("</table>\n");
writer.write("</body>\n");
writer.write("</html>\n");
}
else
{
writer.write(htmlFooter);
}

writer.flush();
}


/**
*
*/
protected void exportPage(JRPrintPage page) throws JRException, IOException
{
if (isUsingReportSizes)
{
writer.write("<table width=" + jasperPrint.getPageWidth() + " cellpadding=0 cellspacing=0 border=0\n");
}
else
writer.write("<table width='100%' cellspacing=0 border=0\n");


if (isWhitePageBackground)
{
writer.write(" bgcolor=white");
}
writer.write(">\n");

layoutGrid(page);

if (isUsingReportSizes) {
writer.write("<tr>\n");
}
else
writer.write("<tr width='100%'>\n");

int width = 0;
for(int i = 1; i < xCuts.size(); i++)
{
width = ((Integer)xCuts.get(i)).intValue() - ((Integer)xCuts.get(i - 1)).intValue();
if (isUsingReportSizes) {
writer.write(" <td" + emptyCellStringProvider.getStringForCollapsedTD(imagesURI) + " width=" + width + " height=1></td>\n");
}
else
writer.write(" <td" + emptyCellStringProvider.getStringForCollapsedTD(imagesURI) + " height=1></td>\n");
}
writer.write("</tr>\n");

JRPrintElement element = null;
for(int y = 0; y < grid.length; y++)
{
if (isRowNotEmpty[y] || !isRemoveEmptySpace)
{
if (isUsingReportSizes)
{
writer.write("<tr valign=top>\n");
}
else
writer.write("<tr width='100%' valign=top>\n");

int emptyCellColSpan = 0;
int emptyCellWidth = 0;
int lastRowHeight = grid[y][0].height;

for(int x = 0; x < grid[y].length; x++)
{
if(grid[y][x].element != null)
{
if (emptyCellColSpan > 0)
{
writer.write(" <td");
if (emptyCellColSpan > 1)
{
writer.write(" colspan=" + emptyCellColSpan);
}
if (isUsingReportSizes) {
writer.write(emptyCellStringProvider.getStringForCollapsedTD (imagesURI) + " width=" + emptyCellWidth + " height=" + lastRowHeight + "></td>\n");
}
else {
writer.write(emptyCellStringProvider.getStringForCollapsedTD (imagesURI) + " ></td>\n");
}
emptyCellColSpan = 0;
emptyCellWidth = 0;
}

element = grid[y][x].element;

if (element instanceof JRPrintLine)
{
exportLine((JRPrintLine)element, grid[y][x]);
}
else if (element instanceof JRPrintRectangle)
{
exportRectangle(element, grid[y][x]);
}
else if (element instanceof JRPrintEllipse)
{
exportRectangle(element, grid[y][x]);
}
else if (element instanceof JRPrintImage)
{
exportImage((JRPrintImage)element, grid[y][x]);
}
else if (element instanceof JRPrintText)
{
exportText((JRPrintText)element, grid[y][x]);
}

x += grid[y][x].colSpan - 1;
}
else
{
emptyCellColSpan++;
emptyCellWidth += grid[y][x].width;
}
}

if (emptyCellColSpan > 0)
{
writer.write(" <td");
if (emptyCellColSpan > 1)
{
writer.write(" colspan=" + emptyCellColSpan);
}
if (isUsingReportSizes) {
writer.write(emptyCellStringProvider.getStringForCollapsedTD (imagesURI) + " width=" + emptyCellWidth + " height=" + lastRowHeight + "></td>\n");
}
else
{
writer.write(emptyCellStringProvider.getStringForCollapsedTD (imagesURI) + "></td>\n");
}
}

writer.write("</tr>\n");
}
}

writer.write("</table>\n");

if (progressMonitor != null)
{
progressMonitor.afterPageExport();
}
}


/**
*
*/
protected void exportLine(JRPrintLine line, JRExporterGridCell gridCell) throws IOException
{
writer.write(" <td");

if (isUsingReportSizes == false)
{
writer.write(" width='100%' ");
}

if (gridCell.colSpan > 1)
{
writer.write(" colspan=" + gridCell.colSpan);
}
if (gridCell.rowSpan > 1)
{
writer.write(" rowspan=" + gridCell.rowSpan);
}

if (
line.getForecolor().getRGB() != Color.white.getRGB()
)
{
writer.write(" bgcolor=#");
String hexa = Integer.toHexString(line.getForecolor().getRGB() & colorMask).toUpperCase();
hexa = ("000000" + hexa).substring(hexa.length());
writer.write(hexa);
}

writer.write(">");

writer.write(emptyCellStringProvider.getStringForEmptyTD(ima gesURI));

writer.write("</td>\n");
}


/**
*
*/
protected void exportRectangle(JRPrintElement element, JRExporterGridCell gridCell) throws IOException
{
writer.write(" <td");
if (gridCell.colSpan > 1)
{
writer.write(" colspan=" + gridCell.colSpan);
}
if (gridCell.rowSpan > 1)
{
writer.write(" rowspan=" + gridCell.rowSpan);
}

if (
element.getBackcolor().getRGB() != Color.white.getRGB()
&& element.getMode() == JRElement.MODE_OPAQUE
)
{
writer.write(" bgcolor=#");
String hexa = Integer.toHexString(element.getBackcolor().getRGB() & colorMask).toUpperCase();
hexa = ("000000" + hexa).substring(hexa.length());
writer.write(hexa);
}

writer.write(">");

writer.write(emptyCellStringProvider.getStringForEmptyTD(ima gesURI));

writer.write("</td>\n");
}


/**
*
*/
protected JRStyledText getStyledText(JRPrintText textElement)
{
JRStyledText styledText = null;

String text = textElement.getText();
if (text != null)
{
JRFont font = textElement.getFont();
if (font == null)
{
font = getDefaultFont();
}

Map attributes = new HashMap();
attributes.putAll(font.getAttributes());
attributes.put(TextAttribute.FOREGROUND, textElement.getForecolor());
if (textElement.getMode() == JRElement.MODE_OPAQUE)
{
attributes.put(TextAttribute.BACKGROUND, textElement.getBackcolor());
}

if (textElement.isStyledText())
{
try
{
styledText = styledTextParser.parse(attributes, text);
}
catch (SAXException e)
{
//ignore if invalid styled text and treat like normal text
}
}

if (styledText == null)
{
styledText = new JRStyledText();
styledText.append(text);
styledText.addRun(new JRStyledText.Run(attributes, 0, text.length()));
}
}

return styledText;
}


/**
*
*/
protected void exportStyledText(JRStyledText styledText) throws IOException
{
String text = styledText.getText();

int runLimit = 0;

AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator();

while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length())
{
exportStyledTextRun(iterator.getAttributes(), text.substring(iterator.getIndex(), runLimit));

iterator.setIndex(runLimit);
}
}


/**
*
*/
protected void exportStyledTextRun(Map attributes, String text) throws IOException
{
writer.write("<span style=\"font-family: ");
writer.write((String)attributes.get(TextAttribute.FAMILY));
writer.write("; ");

Color forecolor = (Color)attributes.get(TextAttribute.FOREGROUND);
if (!Color.black.equals(forecolor))
{
writer.write("color: #");
String hexa = Integer.toHexString(forecolor.getRGB() & colorMask).toUpperCase();
hexa = ("000000" + hexa).substring(hexa.length());
writer.write(hexa);
writer.write("; ");
}

Color backcolor = (Color)attributes.get(TextAttribute.BACKGROUND);
if (backcolor != null)
{
writer.write("background-color: #");
String hexa = Integer.toHexString(backcolor.getRGB() & colorMask).toUpperCase();
hexa = ("000000" + hexa).substring(hexa.length());
writer.write(hexa);
writer.write("; ");
}

if (isUsingReportSizes)
{
writer.write("font-size: ");
writer.write(String.valueOf(attributes.get(TextAttribute.SIZ E)));
writer.write("px;");
}

/*
if (!horizontalAlignment.equals(CSS_TEXT_ALIGN_LEFT))
{
writer.write(" text-align: ");
writer.write(horizontalAlignment);
writer.write(";");
}
*/

if (TextAttribute.WEIGHT_BOLD.equals(attributes.get(TextAttribu te.WEIGHT)))
{
writer.write(" font-weight: bold;");
}
if (TextAttribute.POSTURE_OBLIQUE.equals(attributes.get(TextAtt ribute.POSTURE)))
{
writer.write(" font-style: italic;");
}
if (TextAttribute.UNDERLINE_ON.equals(attributes.get(TextAttrib ute.UNDERLINE)))
{
writer.write(" text-decoration: underline;");
}
if (TextAttribute.STRIKETHROUGH_ON.equals(attributes.get(TextAt tribute.STRIKETHROUGH)))
{
writer.write(" text-decoration: line-through;");
}

writer.write("\">");

writer.write(
replaceNewLineWithBR(
JRStringUtil.xmlEncode(text)
)
);

writer.write("</span>");
}


/**
*
*/
protected void exportText(JRPrintText text, JRExporterGridCell gridCell) throws IOException
{
JRStyledText styledText = getStyledText(text);

int textLength = 0;

if (styledText != null)
{
textLength = styledText.length();
}

writer.write(" <td ");

if (isUsingReportSizes == false)
{
writer.write(" width='100%' ");
}

if (gridCell.colSpan > 1)
{
writer.write(" colspan=" + gridCell.colSpan);
}
if (gridCell.rowSpan > 1)
{
writer.write(" rowspan=" + gridCell.rowSpan);
}

String verticalAlignment = HTML_VERTICAL_ALIGN_TOP;

switch (text.getVerticalAlignment())
{
case JRAlignment.VERTICAL_ALIGN_BOTTOM :
{
verticalAlignment = HTML_VERTICAL_ALIGN_BOTTOM;
break;
}
case JRAlignment.VERTICAL_ALIGN_MIDDLE :
{
verticalAlignment = HTML_VERTICAL_ALIGN_MIDDLE;
break;
}
case JRAlignment.VERTICAL_ALIGN_TOP :
default :
{
verticalAlignment = HTML_VERTICAL_ALIGN_TOP;
}
}

if (!verticalAlignment.equals(HTML_VERTICAL_ALIGN_TOP))
{
writer.write(" valign=\"");
writer.write(verticalAlignment);
writer.write("\"");
}

if (text.getRunDirection() == JRPrintText.RUN_DIRECTION_RTL)
{
writer.write(" dir=\"rtl\"");
}

StringBuffer styleBuffer = new StringBuffer();

if (text.getBackcolor().getRGB() != Color.white.getRGB() && text.getMode() == JRElement.MODE_OPAQUE)
{
styleBuffer.append("background-color: #");
String hexa = Integer.toHexString(text.getBackcolor().getRGB() & colorMask).toUpperCase();
hexa = ("000000" + hexa).substring(hexa.length());
styleBuffer.append(hexa);
styleBuffer.append("; ");
}

if (text.getBox() != null)
{
appendBorder(
styleBuffer,
text.getBox().getTopBorder(),
text.getBox().getTopBorderColor() == null ? text.getForecolor() : text.getBox().getTopBorderColor(),
text.getBox().getTopPadding(),
"top"
);
appendBorder(
styleBuffer,
text.getBox().getLeftBorder(),
text.getBox().getLeftBorderColor() == null ? text.getForecolor() : text.getBox().getLeftBorderColor(),
text.getBox().getLeftPadding(),
"left"
);
appendBorder(
styleBuffer,
text.getBox().getBottomBorder(),
text.getBox().getBottomBorderColor() == null ? text.getForecolor() : text.getBox().getBottomBorderColor(),
text.getBox().getBottomPadding(),
"bottom"
);
appendBorder(
styleBuffer,
text.getBox().getRightBorder(),
text.getBox().getRightBorderColor() == null ? text.getForecolor() : text.getBox().getRightBorderColor(),
text.getBox().getRightPadding(),
"right"
);
}

String horizontalAlignment = CSS_TEXT_ALIGN_LEFT;

if (textLength > 0)
{
switch (text.getTextAlignment())
{
case JRAlignment.HORIZONTAL_ALIGN_RIGHT :
{
horizontalAlignment = CSS_TEXT_ALIGN_RIGHT;
break;
}
case JRAlignment.HORIZONTAL_ALIGN_CENTER :
{
horizontalAlignment = CSS_TEXT_ALIGN_CENTER;
break;
}
case JRAlignment.HORIZONTAL_ALIGN_JUSTIFIED :
{
horizontalAlignment = CSS_TEXT_ALIGN_JUSTIFY;
break;
}
case JRAlignment.HORIZONTAL_ALIGN_LEFT :
default :
{
horizontalAlignment = CSS_TEXT_ALIGN_LEFT;
}
}

if (!horizontalAlignment.equals(CSS_TEXT_ALIGN_LEFT))
{
styleBuffer.append("text-align: ");
styleBuffer.append(horizontalAlignment);
styleBuffer.append(";");
}
}

if (isUsingReportSizes == false)
{
styleBuffer.append("padding-left:4; padding-right:4;");
}

if (styleBuffer.length() > 0)
{
writer.write(" style=\"");
writer.write(styleBuffer.toString());
writer.write("\"");
}

writer.write(">");

if (text.getAnchorName() != null)
{
writer.write("<a name=\"");
writer.write(text.getAnchorName());
writer.write("\"/>");
}

String href = null;
switch(text.getHyperlinkType())
{
case JRHyperlink.HYPERLINK_TYPE_REFERENCE :
{
if (text.getHyperlinkReference() != null)
{
href = text.getHyperlinkReference();
}
break;
}
case JRHyperlink.HYPERLINK_TYPE_LOCAL_ANCHOR :
{
if (text.getHyperlinkAnchor() != null)
{
href = "#" + text.getHyperlinkAnchor();
}
break;
}
case JRHyperlink.HYPERLINK_TYPE_LOCAL_PAGE :
{
if (text.getHyperlinkPage() != null)
{
href = "#" + JR_PAGE_ANCHOR_PREFIX + reportIndex + "_" + text.getHyperlinkPage().toString();
}
break;
}
case JRHyperlink.HYPERLINK_TYPE_REMOTE_ANCHOR :
{
if (
text.getHyperlinkReference() != null &&
text.getHyperlinkAnchor() != null
)
{
href = text.getHyperlinkReference() + "#" + text.getHyperlinkAnchor();
}
break;
}
case JRHyperlink.HYPERLINK_TYPE_REMOTE_PAGE :
{
if (
text.getHyperlinkReference() != null &&
text.getHyperlinkPage() != null
)
{
href = text.getHyperlinkReference() + "#" + JR_PAGE_ANCHOR_PREFIX + "0_" + text.getHyperlinkPage().toString();
}
break;
}
case JRHyperlink.HYPERLINK_TYPE_NONE :
default :
{
break;
}
}

String target = null;
switch(text.getHyperlinkTarget())
{
case JRHyperlink.HYPERLINK_TARGET_BLANK :
{
target = "_blank";
break;
}
case JRHyperlink.HYPERLINK_TARGET_SELF :
default :
{
break;
}
}

if (href != null)
{
writer.write("<a href=\"");
writer.write(href);
writer.write("\"");
if (target != null)
{
writer.write(" target=\"");
writer.write(target);
writer.write("\"");
}
writer.write(">");
}

if (textLength > 0)
{
exportStyledText(styledText);
}
else
{
writer.write(emptyCellStringProvider.getStringForEmptyTD(ima gesURI));
}

if (href != null)
{
writer.write("</a>");
}

writer.write("</td>\n");
}


/**
*
*/
protected void exportImage(JRPrintImage image, JRExporterGridCell gridCell) throws JRException, IOException
{
writer.write(" <td");
if (gridCell.colSpan > 1)
{
writer.write(" colspan=" + gridCell.colSpan);
}
if (gridCell.rowSpan > 1)
{
writer.write(" rowspan=" + gridCell.rowSpan);
}
// if (image.getBackcolor().getRGB() != Color.white.getRGB() && image.getMode() == JRElement.MODE_OPAQUE)
// {
// writer.write(" bgcolor=#");
// String hexa = Integer.toHexString(image.getBackcolor().getRGB() & colorMask).toUpperCase();
// hexa = ("000000" + hexa).substring(hexa.length());
// writer.write(hexa);
// }

String horizontalAlignment = CSS_TEXT_ALIGN_LEFT;

switch (image.getHorizontalAlignment())
{
case JRAlignment.HORIZONTAL_ALIGN_RIGHT :
{
horizontalAlignment = CSS_TEXT_ALIGN_RIGHT;
break;
}
case JRAlignment.HORIZONTAL_ALIGN_CENTER :
{
horizontalAlignment = CSS_TEXT_ALIGN_CENTER;
break;
}
case JRAlignment.HORIZONTAL_ALIGN_LEFT :
default :
{
horizontalAlignment = CSS_TEXT_ALIGN_LEFT;
}
}

if (!horizontalAlignment.equals(CSS_TEXT_ALIGN_LEFT))
{
writer.write(" align=\"");
writer.write(horizontalAlignment);
writer.write("\"");
}

String verticalAlignment = HTML_VERTICAL_ALIGN_TOP;

switch (image.getVerticalAlignment())
{
case JRTextElement.VERTICAL_ALIGN_BOTTOM :
{
verticalAlignment = HTML_VERTICAL_ALIGN_BOTTOM;
break;
}
case JRTextElement.VERTICAL_ALIGN_MIDDLE :
{
verticalAlignment = HTML_VERTICAL_ALIGN_MIDDLE;
break;
}
case JRTextElement.VERTICAL_ALIGN_TOP :
default :
{
verticalAlignment = HTML_VERTICAL_ALIGN_TOP;
}
}

if (!verticalAlignment.equals(HTML_VERTICAL_ALIGN_TOP))
{
writer.write(" valign=\"");
writer.write(verticalAlignment);
writer.write("\"");
}

StringBuffer styleBuffer = new StringBuffer();

if (image.getBackcolor().getRGB() != Color.white.getRGB() && image.getMode() == JRElement.MODE_OPAQUE)
{
styleBuffer.append("background-color: #");
String hexa = Integer.toHexString(image.getBackcolor().getRGB() & colorMask).toUpperCase();
hexa = ("000000" + hexa).substring(hexa.length());
styleBuffer.append(hexa);
styleBuffer.append("; ");
}

if (image.getBox() != null)
{
appendBorder(
styleBuffer,
image.getBox().getTopBorder(),
image.getBox().getTopBorderColor() == null ? image.getForecolor() : image.getBox().getTopBorderColor(),
image.getBox().getTopPadding(),
"top"
);
appendBorder(
styleBuffer,
image.getBox().getLeftBorder(),
image.getBox().getLeftBorderColor() == null ? image.getForecolor() : image.getBox().getLeftBorderColor(),
image.getBox().getLeftPadding(),
"left"
);
appendBorder(
styleBuffer,
image.getBox().getBottomBorder(),
image.getBox().getBottomBorderColor() == null ? image.getForecolor() : image.getBox().getBottomBorderColor(),
image.getBox().getBottomPadding(),
"bottom"
);
appendBorder(
styleBuffer,
image.getBox().getRightBorder(),
image.getBox().getRightBorderColor() == null ? image.getForecolor() : image.getBox().getRightBorderColor(),
image.getBox().getRightPadding(),
"right"
);
}

if (styleBuffer.length() > 0)
{
writer.write(" style=\"");
writer.write(styleBuffer.toString());
writer.write("\"");
}

writer.write(">");

if (image.getAnchorName() != null)
{
writer.write("<a name=\"");
writer.write(image.getAnchorName());
writer.write("\"/>");
}

String href = null;
switch(image.getHyperlinkType())
{
case JRHyperlink.HYPERLINK_TYPE_REFERENCE :
{
if (image.getHyperlinkReference() != null)
{
href = image.getHyperlinkReference();
}
break;
}
case JRHyperlink.HYPERLINK_TYPE_LOCAL_ANCHOR :
{
if (image.getHyperlinkAnchor() != null)
{
href = "#" + image.getHyperlinkAnchor();
}
break;
}
case JRHyperlink.HYPERLINK_TYPE_LOCAL_PAGE :
{
if (image.getHyperlinkPage() != null)
{
href = "#" + JR_PAGE_ANCHOR_PREFIX + reportIndex + "_" + image.getHyperlinkPage().toString();
}
break;
}
case JRHyperlink.HYPERLINK_TYPE_REMOTE_ANCHOR :
{
if (
image.getHyperlinkReference() != null &&
image.getHyperlinkAnchor() != null
)
{
href = image.getHyperlinkReference() + "#" + image.getHyperlinkAnchor();
}
break;
}
case JRHyperlink.HYPERLINK_TYPE_REMOTE_PAGE :
{
if (
image.getHyperlinkReference() != null &&
image.getHyperlinkPage() != null
)
{
href = image.getHyperlinkReference() + "#" + JR_PAGE_ANCHOR_PREFIX + "0_" + image.getHyperlinkPage().toString();
}
break;
}
case JRHyperlink.HYPERLINK_TYPE_NONE :
default :
{
break;
}
}

String target = null;
switch(image.getHyperlinkTarget())
{
case JRHyperlink.HYPERLINK_TARGET_BLANK :
{
target = "_blank";
break;
}
case JRHyperlink.HYPERLINK_TARGET_SELF :
default :
{
break;
}
}

if (href != null)
{
writer.write("<a href=\"");
writer.write(href);
writer.write("\"");
if (target != null)
{
writer.write(" target=\"");
writer.write(target);
writer.write("\"");
}
writer.write(">");
}

writer.write("<img");

String imagePath = "";

byte scaleImage = image.getScaleImage();
JRRenderable renderer = image.getRenderer();
if (renderer != null)
{
if (renderer.getType() == JRRenderable.TYPE_IMAGE && rendererToImageNameMap.containsKey(renderer))
{
//imagePath = imagesDir.getName() + "/" + (String)rendererToImageNameMap(imageData);
imagePath = imagesURI + (String)rendererToImageNameMap.get(renderer);
}
else
{
if (renderer.getType() == JRRenderable.TYPE_SVG)
{
renderer =
new JRWrappingSvgRenderer(
renderer,
new Dimension(image.getWidth(), image.getHeight()),
image.getBackcolor()
);
}

String imageName = "img_" + String.valueOf(rendererToImageNameMap.size());
rendererToImageNameMap.put(renderer, imageName);
imageNameToImageDataMap.put(imageName, renderer.getImageData());

//imageSource = imagesDir.getName() + "/" + imageSource;
imagePath = imagesURI + imageName;
}
}
else
{
loadPxImage();
imagePath = imagesURI + "px";
scaleImage = JRImage.SCALE_IMAGE_FILL_FRAME;
}

writer.write(" src=\"");
writer.write(imagePath);
writer.write("\"");

int borderWidth = 0;
switch (image.getPen())
{
case JRGraphicElement.PEN_DOTTED :
{
borderWidth = 1;
break;
}
case JRGraphicElement.PEN_4_POINT :
{
borderWidth = 4;
break;
}
case JRGraphicElement.PEN_2_POINT :
{
borderWidth = 2;
break;
}
case JRGraphicElement.PEN_NONE :
{
borderWidth = 0;
break;
}
case JRGraphicElement.PEN_THIN :
{
borderWidth = 1;
break;
}
case JRGraphicElement.PEN_1_POINT :
default :
{
borderWidth = 1;
break;
}
}

writer.write(" border=");
writer.write(String.valueOf(borderWidth));

switch (scaleImage)
{
case JRImage.SCALE_IMAGE_FILL_FRAME :
{
writer.write(" width=");
writer.write(String.valueOf(image.getWidth()));

writer.write(" height=");
writer.write(String.valueOf(image.getHeight()));

break;
}
case JRImage.SCALE_IMAGE_CLIP :
case JRImage.SCALE_IMAGE_RETAIN_SHAPE :
default :
{
double normalWidth = image.getWidth();
double normalHeight = image.getHeight();

Dimension2D dimension = renderer.getDimension();
if (dimension != null)
{
normalWidth = dimension.getWidth();
normalHeight = dimension.getHeight();
}

if (image.getHeight() > 0)
{
double ratio = (double)normalWidth / (double)normalHeight;

if( ratio > (double)image.getWidth() / (double)image.getHeight() )
{
writer.write(" width=");
writer.write(String.valueOf(image.getWidth()));
}
else
{
writer.write(" height=");
writer.write(String.valueOf(image.getHeight()));
}
}
}
}

writer.write(">");

if (href != null)
{
writer.write("</a>");
}

writer.write("</td>\n");
}


/**
*
*/
protected void layoutGrid(JRPrintPage page)
{
xCuts = new ArrayList();
yCuts = new ArrayList();

xCuts.add(new Integer(0));
xCuts.add(new Integer(jasperPrint.getPageWidth()));
yCuts.add(new Integer(0));
yCuts.add(new Integer(jasperPrint.getPageHeight()));

Integer x = null;
Integer y = null;

JRPrintElement element = null;

List elems = page.getElements();
for(Iterator it = elems.iterator(); it.hasNext();)
{
element = ((JRPrintElement)it.next());

/*
if (element instanceof JRPrintLine)
{
//
}
else if (element instanceof JRPrintEllipse)
{
//
}
else if (
(element instanceof JRPrintRectangle) ||
(element instanceof JRPrintImage) ||
(element instanceof JRPrintText)
)
*/
{
x = new Integer(element.getX() + globalOffsetX);
if (!xCuts.contains(x))
{
xCuts.add(x);
}
x = new Integer(element.getX() + globalOffsetX + element.getWidth());
if (!xCuts.contains(x))
{
xCuts.add(x);
}
y = new Integer(element.getY() + globalOffsetY);
if (!yCuts.contains(y))
{
yCuts.add(y);
}
y = new Integer(element.getY() + globalOffsetY + element.getHeight());
if (!yCuts.contains(y))
{
yCuts.add(y);
}
}
}

Collections.sort(xCuts);
Collections.sort(yCuts);

int xCellCount = xCuts.size() - 1;
int yCellCount = yCuts.size() - 1;

grid = new JRExporterGridCell[yCellCount][xCellCount];
isRowNotEmpty = new boolean[yCellCount];

for(int j = 0; j < yCellCount; j++)
{
for(int i = 0; i < xCellCount; i++)
{
grid[j][i] =
new JRExporterGridCell(
null,
((Integer)xCuts.get(i + 1)).intValue() - ((Integer)xCuts.get(i)).intValue(),
((Integer)yCuts.get(j + 1)).intValue() - ((Integer)yCuts.get(j)).intValue(),
1,
1
);
}
}

int x1 = 0;
int y1 = 0;
int x2 = 0;
int y2 = 0;
int xi = 0;
int yi = 0;
boolean isOverlap = false;

for(int i = elems.size() - 1; i >= 0; i--)
{
element = ((JRPrintElement)elems.get(i));

/*
if (element instanceof JRPrintLine)
{
//
}
else if (element instanceof JRPrintEllipse)
{
//
}
else if (
(element instanceof JRPrintRectangle) ||
(element instanceof JRPrintImage) ||
(element instanceof JRPrintText)
)
*/
{
x1 = xCuts.indexOf(new Integer(element.getX() + globalOffsetX));
y1 = yCuts.indexOf(new Integer(element.getY() + globalOffsetY));
x2 = xCuts.indexOf(new Integer(element.getX() + globalOffsetX + element.getWidth()));
y2 = yCuts.indexOf(new Integer(element.getY() + globalOffsetY + element.getHeight()));

isOverlap = false;
yi = y1;
while(yi < y2 && !isOverlap)
{
xi = x1;
while(xi < x2 && !isOverlap)
{
if(grid[yi][xi].element != null)
{
isOverlap = true;
}
xi++;
}
yi++;
}

if (!isOverlap)
{
yi = y1;
while(yi < y2)
{
xi = x1;
while(xi < x2)
{
grid[yi][xi] = JRExporterGridCell.OCCUPIED_CELL;
xi++;
}
isRowNotEmpty[yi] = true;
yi++;
}

if (x2 - x1 != 0 && y2 - y1 != 0)
{
grid[y1][x1] =
new JRExporterGridCell(
element,
element.getWidth(),
element.getHeight(),
x2 - x1,
y2 - y1
);
}
}
}
}
}


/**
*
*/
protected static String replaceNewLineWithBR(String source)
{
String str = null;

if (source != null)
{
StringBuffer sbuffer = new StringBuffer();
StringTokenizer tkzer = new StringTokenizer(source, "\n", true);
String token = null;
while(tkzer.hasMoreTokens())
{
token = tkzer.nextToken();
if ("\n".equals(token))
{
sbuffer.append("<br>");
}
else
{
sbuffer.append(token);
}
}

str = sbuffer.toString();
}

return str;
}


/**
*
*/
protected void loadPxImage() throws JRException
{
if (!imageNameToImageDataMap.containsKey("px"))
{
JRRenderable pxRenderer =
JRImageRenderer.getInstance(
JRImageLoader.loadImageDataFromLocation("net/sf/jasperreports/engine/images/pixel.GIF ")
);
rendererToImageNameMap.put(pxRenderer, "px");
imageNameToImageDataMap.put("px", pxRenderer.getImageData());
}
}


/**
*
*/
protected static interface StringProvider
{

/**
*
*/
public String getStringForCollapsedTD(Object value);

/**
*
*/
public String getStringForEmptyTD(Object value);

}


/**
*
*/
private static void appendBorder(StringBuffer sb, byte pen, Color borderColor, int padding, String side)
{
String borderStyle = null;
String borderWidth = null;

switch (pen)
{
case JRGraphicElement.PEN_DOTTED :
{
borderStyle = "dashed";
borderWidth = "1px";
break;
}
case JRGraphicElement.PEN_4_POINT :
{
borderStyle = "solid";
borderWidth = "4px";
break;
}
case JRGraphicE
Re: Using Browser Widget as report viewer, is it good approach ? [message #452416 is a reply to message #452413] Mon, 21 March 2005 03:20 Go to previous messageGo to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
ted stockwell wrote:

> Setya wrote:
>> Hi all,
>>
>> I need to display report in my application, so far I plan to use
>> JasperReports engine to populate the report on server with data from
>> database then send the report to client to be previewed by Browser
>> Widget available in SWT, is this possible and a good solution (from
>> performance point of view, scalability etc) ? Has anybody ever used this
>> approach ?
>>
>> Any suggestions are welcomed and appreciated.
>>
>> Thank you in advanced.
>>
>>
>> Setya
>>

> Yes and no.


> My company uses the SWT browser widget in our product to display
JasperReports and that solution is working pretty well for us.
> We currently have several hundred Windows users viewing reports this way
with no problem.
> We display reports in both our desktop RCP-based application and our
web-based reports portal.
> One cool thing is that we can display drill-down reports in the desktop that
can open up editors.
> So for instance, from the aged receivables report you can open up the
associated customer editor or order editor by clicking on
> links on the report (this is done by employing the Tomcat web server
embedded in the desktop to open up the editors).

> ---------------------------------

> HOWEVER, the HTML renderer that comes out of the box with JasperReports is
quite lame and in my opinion is not suitable for use
> in a production application. The problem with the renderer (and frankly,
with JasperReports itself) is that the report design
> is pixel based and the HTML render attempts to format the HTML to the exact
pixel size specified in the report design.
> What often ends up happening is that reports looks small when displayed in
the browser.

> I tweaked the JasperReport HTML render so that it does not include pixel
units or font sizes specified in the report design in
> the generated HTML. I find this renderer to be satisfactory. My
requirement for diplaying reports in the browser is not that
> the reports are formatted EXACTLY like they would look in PDF or RTF but
that they look OK, easy to view.
> I have attached a copy of this renderer.
> By default the renderer will work exactly like the default JasperReports
renderer. Set the IS_USING_REPORT_SIZES to false to
> produce HTML that is not pixel-based.

> ---------------------------------

> If you have not yet implemented anything then I strongly suggest that you
first create a protoptype report with BIRT,
> http://www.eclipse.org/birt.

> One thing I like about BIRT is that the report design model is superior to
JasperReports in that reports are not pixel-based
> (but can support pixel-based elements). This will enabled me to use BIRT to
produce forms that I cannot currently produce in
> JasperReports (we currently use Apache FOP for forms that require more
sophisticated formatting than JasperReports can provide).

> One thing I don't like about BIRT is that the report design is more
complicated/sophisticated compared to JasperReports. Using
> the JasperAssistant report writer, http://www.jasperassistant.com/, I can
whip out JasperReports at lightning speed. I found
> JasperReports and JasperAssistant VERY easy to use out of the box. OTOH, I
found the BIRT report design rather mysterious. It
> took quite a lot of effort to create my first BIRT report.

> ---------------------------------

> I would be interested in hearing other folks experience using BIRT in the
SWT browser or in the RCP.


> ted stockwell
> technical director
> RPC Software
> rpcsoftware.com

Thank you so much for your explanations and attachments,

Actually I also consider BIRT but I feel that it still not production
ready and far from mature so I decide to at least wait and consider other
alternatives (JasperReports). What about instead of using Browser Widget
we use the SWTJasperViewer ? Have you tried it ?

Also the ability to link from the reports seems to be very interesting
feature , but having to embed Tomcat web server is rather daunting to me.
Does it burden your deployment efforts ?

Thanks


Setya
Re: Using Browser Widget as report viewer, is it good approach ? [message #452478 is a reply to message #452407] Mon, 21 March 2005 18:24 Go to previous messageGo to next message
Stavros Kounis is currently offline Stavros KounisFriend
Messages: 51
Registered: July 2009
Member
Setya wrote:

> Hi all,
>
> I neeembeddeddsplay report in my application, so far I plan to use
> JasperReports engine to populate the report on server with data from
> database then send the report to client to be previewed by Browser Widget
> available in SWT, is this possible and a good solution (from performance
> point of view, scalability etc) ? Has anybody ever used this approach ?
>
> Any suggestions are welcomed and appreciated.
>
> Thank you in advanced.
>
>
> Setya

hi setya

i use browser widget to display reports produced in several ways
1. Eclipse
- custom xml/xsl transformations
- BIRT
2. DotNet
- i use similar technics in my DotNet projects (using web browser control)

there are some problems after Windows SP2 similar in both platforms (eclipse
RCP, DotNet)

- if you want to render/load a file from the file systen (not from a server)
web control does not allow you to execute javascript (if try this with
internet explore a yellow bar on the top is asking you to allow or not
script's execution). WebControl or browser widget does not have/display
this yellow bar and just ignore javascript

- an other one issue is that webcontrol or browser widget some times prompt
you to download the file you want to load (if this file come from file
system) or open it in new window

all the above does not happend if you get your file from a web server using
(apache, tomcat, eclipse's internal tomcat etc)

- the only issue i have found and has to do with BIRT reports (served from
tomcat or eclipse's tomcat) is that browser widget does not dipslay
embedded images. you have to right click on the image and ask from widget
to display image

i think that somehow you can configure your system for all those security re
related issues, but until know i don't find anything

regard

Stavros
Re: Using Browser Widget as report viewer, is it good approach ? [message #452479 is a reply to message #452478] Mon, 21 March 2005 10:33 Go to previous messageGo to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Stavros Kounis wrote:

> Setya wrote:

>> Hi all,
>>
>> I neeembeddeddsplay report in my application, so far I plan to use
>> JasperReports engine to populate the report on server with data from
>> database then send the report to client to be previewed by Browser Widget
>> available in SWT, is this possible and a good solution (from performance
>> point of view, scalability etc) ? Has anybody ever used this approach ?
>>
>> Any suggestions are welcomed and appreciated.
>>
>> Thank you in advanced.
>>
>>
>> Setya

> hi setya

> i use browser widget to display reports produced in several ways
> 1. Eclipse
> - custom xml/xsl transformations
> - BIRT
> 2. DotNet
> - i use similar technics in my DotNet projects (using web browser control)

> there are some problems after Windows SP2 similar in both platforms (eclipse
> RCP, DotNet)

> - if you want to render/load a file from the file systen (not from a server)
> web control does not allow you to execute javascript (if try this with
> internet explore a yellow bar on the top is asking you to allow or not
> script's execution). WebControl or browser widget does not have/display
> this yellow bar and just ignore javascript

> - an other one issue is that webcontrol or browser widget some times prompt
> you to download the file you want to load (if this file come from file
> system) or open it in new window

> all the above does not happend if you get your file from a web server using
> (apache, tomcat, eclipse's internal tomcat etc)

> - the only issue i have found and has to do with BIRT reports (served from
> tomcat or eclipse's tomcat) is that browser widget does not dipslay
> embedded images. you have to right click on the image and ask from widget
> to display image

> i think that somehow you can configure your system for all those security re
> related issues, but until know i don't find anything

> regard

> Stavros

Stavros,

Thanks a lot for your information. BTW, you mention eclipse's internal
Tomcat. Where can I find it ?

Regards,


Setya
Re: Using Browser Widget as report viewer, is it good approach ? [message #452480 is a reply to message #452479] Mon, 21 March 2005 19:22 Go to previous messageGo to next message
Stavros Kounis is currently offline Stavros KounisFriend
Messages: 51
Registered: July 2009
Member
Setya wrote:

> Stavros Kounis wrote:
>
>> Setya wrote:
>
>>> Hi all,
>>>
>>> I neeembeddeddsplay report in my application, so far I plan to use
>>> JasperReports engine to populate the report on server with data from
>>> database then send the report to client to be previewed by Browser
>>> Widget available in SWT, is this possible and a good solution (from
>>> performance point of view, scalability etc) ? Has anybody ever used this
>>> approach ?
>>>
>>> Any suggestions are welcomed and appreciated.
>>>
>>> Thank you in advanced.
>>>
>>>
>>> Setya
>
>> hi setya
>
>> i use browser widget to display reports produced in several ways
>> 1. Eclipse
>> - custom xml/xsl transformations
>> - BIRT
>> 2. DotNet
>> - i use similar technics in my DotNet projects (using web browser
>> control)
>
>> there are some problems after Windows SP2 similar in both platforms
>> (eclipse RCP, DotNet)
>
>> - if you want to render/load a file from the file systen (not from a
>> server)
>> web control does not allow you to execute javascript (if try this with
>> internet explore a yellow bar on the top is asking you to allow or not
>> script's execution). WebControl or browser widget does not have/display
>> this yellow bar and just ignore javascript
>
>> - an other one issue is that webcontrol or browser widget some times
>> prompt
>> you to download the file you want to load (if this file come from file
>> system) or open it in new window
>
>> all the above does not happend if you get your file from a web server
>> using (apache, tomcat, eclipse's internal tomcat etc)
>
>> - the only issue i have found and has to do with BIRT reports (served
>> from
>> tomcat or eclipse's tomcat) is that browser widget does not dipslay
>> embedded images. you have to right click on the image and ask from
>> widget to display image
>
>> i think that somehow you can configure your system for all those security
>> re related issues, but until know i don't find anything
>
>> regard
>
>> Stavros
>
> Stavros,
>
> Thanks a lot for your information. BTW, you mention eclipse's internal
> Tomcat. Where can I find it ?
>
> Regards,
>
>
> Setya

org.eclipse.birt.report.viewer_0.0.1 plug-in is just a webapp
if you put it in a webapp container (tomcat) you can use it to get any
report you have create with report designer

i just have call/load the plugin that is used from eclipse to provide help
(is just a light tomcat instance i think) ask from it to load
org.eclipse.birt.report.viewer_0.0.1 as webapp

give me some time to provide you some code snipps too

you can find an interesting artice here
http://www.eclipse.org/birt/deploy/
Re: Using Browser Widget as report viewer, is it good approach ? [message #452485 is a reply to message #452480] Mon, 21 March 2005 13:37 Go to previous messageGo to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Stavros Kounis wrote:

> Setya wrote:

>> Stavros Kounis wrote:
>>
>>> Setya wrote:
>>
>>>> Hi all,
>>>>
>>>> I neeembeddeddsplay report in my application, so far I plan to use
>>>> JasperReports engine to populate the report on server with data from
>>>> database then send the report to client to be previewed by Browser
>>>> Widget available in SWT, is this possible and a good solution (from
>>>> performance point of view, scalability etc) ? Has anybody ever used this
>>>> approach ?
>>>>
>>>> Any suggestions are welcomed and appreciated.
>>>>
>>>> Thank you in advanced.
>>>>
>>>>
>>>> Setya
>>
>>> hi setya
>>
>>> i use browser widget to display reports produced in several ways
>>> 1. Eclipse
>>> - custom xml/xsl transformations
>>> - BIRT
>>> 2. DotNet
>>> - i use similar technics in my DotNet projects (using web browser
>>> control)
>>
>>> there are some problems after Windows SP2 similar in both platforms
>>> (eclipse RCP, DotNet)
>>
>>> - if you want to render/load a file from the file systen (not from a
>>> server)
>>> web control does not allow you to execute javascript (if try this with
>>> internet explore a yellow bar on the top is asking you to allow or not
>>> script's execution). WebControl or browser widget does not have/display
>>> this yellow bar and just ignore javascript
>>
>>> - an other one issue is that webcontrol or browser widget some times
>>> prompt
>>> you to download the file you want to load (if this file come from file
>>> system) or open it in new window
>>
>>> all the above does not happend if you get your file from a web server
>>> using (apache, tomcat, eclipse's internal tomcat etc)
>>
>>> - the only issue i have found and has to do with BIRT reports (served
>>> from
>>> tomcat or eclipse's tomcat) is that browser widget does not dipslay
>>> embedded images. you have to right click on the image and ask from
>>> widget to display image
>>
>>> i think that somehow you can configure your system for all those security
>>> re related issues, but until know i don't find anything
>>
>>> regard
>>
>>> Stavros
>>
>> Stavros,
>>
>> Thanks a lot for your information. BTW, you mention eclipse's internal
>> Tomcat. Where can I find it ?
>>
>> Regards,
>>
>>
>> Setya

> org.eclipse.birt.report.viewer_0.0.1 plug-in is just a webapp
> if you put it in a webapp container (tomcat) you can use it to get any
> report you have create with report designer

> i just have call/load the plugin that is used from eclipse to provide help
> (is just a light tomcat instance i think) ask from it to load
> org.eclipse.birt.report.viewer_0.0.1 as webapp

> give me some time to provide you some code snipps too

> you can find an interesting artice here
> http://www.eclipse.org/birt/deploy/

You're right, interesting article. Thank you again.

Setya
Re: Using Browser Widget as report viewer, is it good approach ? [message #452882 is a reply to message #452407] Sat, 26 March 2005 10:19 Go to previous messageGo to next message
Stavros Kounis is currently offline Stavros KounisFriend
Messages: 51
Registered: July 2009
Member
Setya wrote:

> Hi all,
>
> I need to display report in my application, so far I plan to use
> JasperReports engine to populate the report on server with data from
> database then send the report to client to be previewed by Browser Widget
> available in SWT, is this possible and a good solution (from performance
> point of view, scalability etc) ? Has anybody ever used this approach ?
>
> Any suggestions are welcomed and appreciated.
>
> Thank you in advanced.
>
>
> Setya

hi Setya

i have publish an eclipse plug-in that add a Report View perspective in
eclipse (and in any RCP application)

in this perspective you can start BIRTS Viewer webapp using eclipse's
internal appserver and the view any .rptdesign using it

you can find my article and source code here

http://tools.osmosis.gr/blog/

hope that this post can help

stavros
Re: Using Browser Widget as report viewer, is it good approach ? [message #452910 is a reply to message #452882] Mon, 28 March 2005 08:39 Go to previous message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Stavros Kounis wrote:

> Setya wrote:

>> Hi all,
>>
>> I need to display report in my application, so far I plan to use
>> JasperReports engine to populate the report on server with data from
>> database then send the report to client to be previewed by Browser Widget
>> available in SWT, is this possible and a good solution (from performance
>> point of view, scalability etc) ? Has anybody ever used this approach ?
>>
>> Any suggestions are welcomed and appreciated.
>>
>> Thank you in advanced.
>>
>>
>> Setya

> hi Setya

> i have publish an eclipse plug-in that add a Report View perspective in
> eclipse (and in any RCP application)

> in this perspective you can start BIRTS Viewer webapp using eclipse's
> internal appserver and the view any .rptdesign using it

> you can find my article and source code here

> http://tools.osmosis.gr/blog/

> hope that this post can help

> stavros

Hi Stavros,

Thank you very much for your plug-in and article, they're very helpful for
me to get started with BIRT.


Best Regards,


Setya
Previous Topic:Abount Scaling of Swt Images
Next Topic:Hook combo box dropdown event
Goto Forum:
  


Current Time: Tue Oct 22 09:54:15 GMT 2019

Powered by FUDForum. Page generated in 0.03019 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top