PDA

View Full Version : Bug in report/page header



Anonymous
05-16-2002, 09:18 AM
I've downloaded 0.7.2 & I think there's a bug if you attempt to print the page & report headers on the first page. The page header always comes out on the page before the report header - I think this may also affect subsequent pages. This problem appears in the demo for the first table.

Also since the large constructors have been removed it now seems harder to add elements dynamically i.e. I'm having to do the following in my program to add a line with some variable report title:

labelElement = new LabelElement();
labelElement.setLabel(repTitle);
labelElement.setName(repTitle);
labelElement.setAlignment(ElementConstants.CENTER);
labelElement.setBounds(new Rectangle2D.Double(0,0,200,10));

Am I missing the point here. Also I can't get it to align centrally.

Regards Shakes

Anonymous
05-16-2002, 12:05 PM
Shakes wrote:
> I've downloaded 0.7.2 & I think there's a bug if you attempt
> to print the page & report headers on the first page. The
> page header always comes out on the page before the report
> header - I think this may also affect subsequent pages. This
> problem appears in the demo for the first table.

It was coded that way on purpose, so that the page header is ALWAYS at the top of the page. I guess you could argue it either way, depending on what you are displaying in the respective headers. What do other report
generators do?

I always suppress the page header on page 1 anyway.

> Also since the large constructors have been removed it now
> seems harder to add elements dynamically i.e. I'm having to
> do the following in my program to add a line with some
> variable report title:
>
> labelElement = new LabelElement();
> labelElement.setLabel(repTitle);
> labelElement.setName(repTitle);
> labelElement.setAlignment(ElementConstants.CENTER);
> labelElement.setBounds(new Rectangle2D.Double(0,0,200,10));
>
> Am I missing the point here.

Here is the right place to be heard. I've delegated decisions about this type of thing to Thomas who is the new Project Leader. The change doesn't affect me personally, since I don't create report items dynamically...but I'm sure Thomas will consider your position. And if other people don't like this change, speak up now.

> Also I can't get it to align centrally.

I'll take a look at that...you might want to raise a bug on SourceForge also, in case I get distracted and then forget about it.

Regards,

DG.

Anonymous
05-16-2002, 02:57 PM
Hi,

I removed these headers, as they tend to require changes whenever the structure of an element changes. When properties get added to the element, we would either need to change the constructor or leave the new property to be set with get/set methods.

In the version I'm currently working on, the most of the elements get removed (especially all followups to textelement), and will be replaced by a Filter interface (a smallscale variant of a function used to convert one value to another). A label will then be created by an text element, stacked together with a StaticSource object containing the text.

But this seemed not supported by the way you create the report definition. :(
If you wouldn't mind to wait a day or two, then I pack the functionality of the changed XML-Parser, which maps the old element types to the new ones, into some factories, so that you get a one-line way of creating the elements.

Do you depend on the elements after you created the report definition? I'm asking this, because if you just create and forget the elements I don't see many advantages in extending the old elements in any way to add new functionality. I indended to set them deprecated and map them into the new element format (and removing them in a far future).


The pageheader thing is no bug. Every other program prints pageheaders on the top of the page and not in the middle. If you don't like the pageheader on your fist page, remove them using the "onfirstpage" property.

To your alignment bug, I have to say, all text elements get aligned, as you can see in the demo reports headers.

Have more fun,
said Thomas

Anonymous
05-16-2002, 05:49 PM
In the cvs there exists now a new class called ItemFactory. Using this factory
will protect you from any further changes of element's code. The interface of this factory will remain stable, except that functions get added and the internal processes to create elements will change.

Anonymous
05-21-2002, 08:25 AM
What I meant regarding the header information is that I couldn't see the point in having a report header & then having onfirstpage = true for the page header because the page header will always come out before the report header which (as the demo shows) doesn't look right.

Another thing I noticed is that when outputting to pdf format the report items don't get printed if you added them dynamically (as opposed to detailing each line in the xml).
Maybe if I explain why I'm creating things dynamically then it may help:
I have a main application with several tables each on a different tab - I want to use the same xml file for each table so that I have a generic format for report headers/page footers/fonts etc but the column headings & the items differ depending what table is being reported.

In the main I have it pretty much working so thanks for that - The pdf thing I'll let you know about unless you've noticed this as well.

Cheers Shakes

Anonymous
05-22-2002, 03:25 AM
The onfirstpage propery is "true" by default, to remove the header set it to "false". That the page header is printed before the report header, may not look right, but I think it is more logical. Every text processing engine prints the pageheader on the top of the page, regardless of the content contained in the page. An as in a text processor you have the opportinity to turn the header of for the first page.

The report items should be printed. Do they get printed on the graphics2d output (preview and printer)? if yes, then I'm completely clueless what happens. In that case, can you send me a short sample to reproduce this behaviour?

have more fun,
said Thomas

Anonymous
05-22-2002, 07:43 AM
OK - Try the following:

Edit the preview2 method in JReportFreeDemo & enter the following code before the line report2.setData (data2);

LabelElement field = new LabelElement();
field.setLabel("xxxxxx");
field.setName("xxxxxx");
field.setBounds(new Rectangle2D.Double(60,0,76,8));
report2.getItemBand().addElement(field);


report2.setData (data2);
frame2 = new PreviewFrame (report2);

Do the print preview for table2 & you'll see the xxxxx's printed - Then save as PDF & you'll see that things added "dynamically" to the itemband aren't shown (hopefully).

Also in the PrintPreview if you switch to landscape the lines don't stretch to the right hand side - I've experimented here but can't yet get it work.

Cheers Simon

Anonymous
05-22-2002, 05:21 PM
Argggh!

This was an evil thing. The reason why the text is printed in Graphics2D and not in the PDFTarget is simple and silly. The label you create has no textalignment set (here comes the bug: this should be done in the TextElement constructor - is fixed now in cvs). If no alignment is set, graphics2d doe not care, it prints leftaligned.

But the PDF target relies on the alignment (because iText does), and so it does no printing. All element generated by the parser get the default alignment set during the parsing, but the manual element got hit by the missing initialisation.

The line bug is known and fixed in the cvs version.

Btw. in the cvs is the ItemLibrary, which will give you back a way to create
elements in a single call. It will also protect you from changes to the internal structure as done in the upcoming version.
The textelement-inheritants still exist, but they are all deprecated now. The functionality done in all those classes is now done by a small set of filters, removing most of the duplicate code in JFreeReports base classes.

Have more fun,
said Thomas

Anonymous
05-24-2002, 08:41 AM
Thanks for that - Any idea when the changes will be encorporated into a new jar ?

Cheers Shakes

Anonymous
05-24-2002, 04:01 PM
Not yet, I've a small list of things to include (which should be done next week) and then there is the bigger task of documenting the code, what has changed, and write down some hints about the concepts, so that it is easier
to get into the code.

And when the this documentation is done, the release gets out.

So all say for now, that I will not actively implement new features after next week.

To all: But feel free to send requests, patches, whishes and ideas, they get into one of the next releases.
If you want to bring them in by yourself, just drop a note and tell me your Sourceforge name so you can get write access to the cvs.

Have more fun,
said Thomas

Anonymous
07-06-2002, 12:33 PM
Hi - Just upgraded to the latest version 0.7.4. When I tried running my existing code using this version I get:

com.jrefinery.report.function.FunctionInitializeException: No Such Property : reportProperty

I've changed the program to use the ItemFactory rather then new LabelElement(...) etc. Other than that things are the same as previously - Any ideas ?

Thanks Shakes

Anonymous
07-07-2002, 08:53 AM
OK - Sorted now - I see that you now must use <function name="report_date" - I previously had it as printdate which worked OK in the last version.

Cheers Simon