Jump to content
We've recently updated our Privacy Statement, available here ×

simon dark

Members
  • Posts

    8
  • Joined

  • Last visited

simon dark's Achievements

Apprentice

Apprentice (3/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Conversation Starter Rare

Recent Badges

0

Reputation

  1. Hallo Jasper developers, I have an issue concerning the generation of page numbers in a table of content. Following the example provided within the /samples/tablesofcontents I am able to create a table of contents and everything is fine except for the page numbering. I have a simple master report and a subreport that in fact displays the actual content of the report - a collection of charts with a title and a description. Here is a relevant code snippet of the subreport section: <band height="350" isSplitAllowed="false"> <break type="Page"> <reportElement x="0" y="0" width="0" height="0"/> </break> <line> <reportElement x="0" y="0" width="0" height="0"> <printWhenExpression> ((net.sim.jaspchart.ReportScriptlet)$P{REPORT_SCRIPTLET}).addEntry($F{title}) </printWhenExpression </reportElement> </line> ... two text fields (title + description) <image scaleImage="RetainShape" hAlign="Center" vAlign="Middle"> <reportElement x="0" y="90" width="515" height="260" positionType="Float"/> <imageExpression class="net.sf.jasperreports.engine.JRRenderable">$F{chart}</imageExpression> </image> </band> Note that each image (and the associated text fields) MUST be placed in an individual page and for this purpose I used the break element which functions properly - all elements are placed in a single page. Within the line element a scriptlet's method is called (addEntry($F{title})) which constructs a single table of contents' entry and adds it to a collection. Here is the scriptlet's method implementation; public Boolean addEntry(String title) throws JRScriptletException { Collection<TOCEntry> entries = (Collection<TOCEntry>)this.getParameterValue("tocEntries"); Integer pageNumber = (Integer)this.getVariableValue("PAGE_NUMBER"); TOCEntry tocEntry = new TOCEntry(title, pageNumber, title); return Boolean.valueOf( entries.add( tocEntry) ); } Note that each table of content entry has the format (title, page number, reference) The table of contents is constructed properly except for the page numbering which is as follows: In case of 2 elements Chart1 ........1 Chart2 ........1 In case we have 3 elements Chart1 ........1 Chart2 ........1 Chart3 ........2 In case we have 4 elements (charts) Chart1 ........1 Chart2 ........1 Chart3 ........2 Chart4 ........3 etc. I have no clue why Jasper starts to increment the page number after the second and not after the first TOCEntry object was created. This certainly has something to do with the way PAGE_NUMBER is used within a subreport. Any help is deeply appreciated.
  2. Hallo everyone, I am experiencing problems embedding a SVG-File into my Jasper report. After the graphic was generated and saved on the file system I create an instance of BatikRenderer with the SVG-File location and pass it to my report as parameter. This is done as follows: String svgFileLocation = "/a/path/to/my/svg/file"; JRRenderable imageRenderer = null; try { imageRenderer = BatikRenderer.getInstance(new File(svgFileLocation)); //imageRenderer = BatikRenderer.getInstance(new URL("file://" + svgFileLocation)); // doesn't work either } catch (JRException e){ e.printStackTrace(); } //catch (MalformedURLException me) { // me.printStackTrace(); //} ... ... ... // Pass the renderer to the report as a parameter m_parameters.put("graphImage", imageRenderer); <!--Access the renderer within the report --> <image scaleImage="RetainShape" onErrorType="Icon" isUsingCache="true"> <reportElement x="0" y="0" width="782" height="500"/> <imageExpression class="net.sf.jasperreports.engine.JRRenderable"><![CDATA[$P{graphImage}]]></imageExpression> <anchorNameExpression>"Image"</anchorNameExpression> </image> The only thing I become after this all is not even an error (onErrorType="Icon") but a blank screen which make the whole situation pretty frustrating for me. Does anybody have any Idea what the problem could be or has made similar experience with batik. I am using jasper 3.1.2. Greetings
  3. Hallo again, I have made a minor progress in specifying the problem concerning the incorrect painting of images in an pdf document. Consider the following XML code: <detail> <band height="15"> <frame> <reportElement x="0" y="0" width="782" height="15" positionType="Float"/> <textField isStretchWithOverflow="true" evaluationTime="Now"> <reportElement x="5" y="0" width="335" height="15" stretchType="RelativeToTallestObject"/> <textElement verticalAlignment="Middle" textAlignment="Justified"/> <textFieldExpression>$F{nr} + " " + $F{keyword}</textFieldExpression> </textField> <image scaleImage="Clip" onErrorType="Blank" hAlign="Center" vAlign="Middle"> <reportElement x="340" y="0" width="50" height="15" stretchType="RelativeToTallestObject" mode="Opaque"/> <imageExpression class="java.awt.Image">$F{color}</imageExpression> </image> <textField isStretchWithOverflow="true" evaluationTime="Now"> <reportElement x="340" y="0" width="50" height="15" stretchType="RelativeToTallestObject"/> <textElement verticalAlignment="Middle" textAlignment="Center"/> <textFieldExpression>String.valueOf($F{r}.intValue() * $F{p}.intValue() )</textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement x="390" y="0" width="387" height="15" style="FaktorGruppe"/> <textElement verticalAlignment="Middle" textAlignment="Justified"/> <textFieldExpression>$F{pm}</textFieldExpression> </textField> </frame> </band> </detail> The code above functions fine and the images are rendered correctly in the result PDF report but this is only the case if the scaleImage attribute of element image is set to Clip. Setting this attribute to (FillFrame or RetainShape) leads to erroneous painting of the images - issue that was already introduced my previous post. I want to use the opportunity to invite everyone again to share his thoughts and expirience about possible reasons for this behaviour. It would be a pitty to leave this issue unresolved because AFAIK there is really no other way to set colors in Jasper from the application. This example shows how to do it but it is not very useful if you are not able to print what you was able to display in the viewer.
  4. Hallo everybody, after some happy days working with Jasper I came to the point where I had to generate a PDF file and .... was suprised (actually stunned) to find out that the color images that I successfully was able to embed in my report were repainted with black color in the generated PDF. At first sight it seems that they were simply not exported but after getting the image big enough I noticed that black color was painted over the image (you have to zoom in heavily in order to notice that). I attached two screenshots from the report that is displayed in the viewer and in PDF respectively. Has anybody any idea what might have gone wrong during the export?
  5. Hallo Jasper developers, after reading of some other posts regarding the proper setting of a text field's "stretchType" attribute, I am still stuck with the following problem: First have a look at the relevant snippet of my xml template: <detail> <band height="15"> <frame> <reportElement x="0" y="0" width="782" height="15" positionType="Float"/> <textField isStretchWithOverflow="true" evaluationTime="Now"> <reportElement x="5" y="0" width="335" height="15" style="FactorGroup" stretchType="RelativeToTallestObject"/> <textElement verticalAlignment="Middle" textAlignment="Justified"/> <textFieldExpression>$F{nrPath} + " " + $F{keyword}</textFieldExpression> </textField> <!-- The text field is wrapped by a frame in order to allow image embedding --> <frame> <reportElement x="340" y="0" width="50" height="15" stretchType="RelativeToTallestObject" /> <image scaleImage="FillFrame" onErrorType="Blank"> <reportElement x="0" y="0" width="50" height="15" stretchType="RelativeToTallestObject"/> <imageExpression class="java.awt.Image">$F{color}</imageExpression> </image> <textField isStretchWithOverflow="true" evaluationTime="Now"> <reportElement x="0" y="0" width="50" height="15" stretchType="RelativeToTallestObject"/> <textElement verticalAlignment="Middle" textAlignment="Center"/> <textFieldExpression>String.valueOf($F{risk}.intValue() * $F{probability}.intValue() )</textFieldExpression> </textField> </frame> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement x="390" y="0" width="387" height="15" style="FactorGroup"/> <textElement verticalAlignment="Middle" textAlignment="Justified"/> <textFieldExpression>$F{pm}</textFieldExpression> </textField> </frame> </band> </detail> As you can see here, there are three text fields in my "detail band" that are placed within a frame and not directly under the band itself. The reasons for that are explained below for those who are interested. These text elements contain strings with different lengths. The third one for example contains text that usually will go beyound several lines causing the field to stretch. Setting the "stretchType" property of the other two text fields to "RelativeToTallestObject" should take care that their height is adjusted automatically to the height of the tallest object. Strangely, the first one (directly below the band) behaves as expected but not the second one (within the frame). I suppose that it has something to do with the frame but am not able to figure out what exactly. I also set columnCount="1" and printOrder="Vertical" because "detail bands in horizontal reports do not stretch by design". Does anyone has a clue what might have gone wrong ? Any help will be appreciated. P.S Q: Why did you place a text field inside a frame and not directly in the detail band? A: Certain text fields should be filled with a color set by the Java application and the only way to do this (to my best knowledge) is to embed the color as an image. In my case the expression : <imageExpression class="java.awt.Image">$F{color}</imageExpression> accesses a JavaBean property that points to an instance of class java.awt.Image. Since text fields are there to display text the developer needs another element that is able to contain images and <frame> perfectly does the job.
  6. Check this out: http://jasperforge.org/plugins/espforum/view.php?group_id=102&forumid=103&topicid=35202
  7. Hallo everyone, I would like to introduce an interesting case hoping to receive some direction and/or a piece of advice since I am really at my wits' end. I have two data structures called FactorGroup and Factor. FactorGroup has the following properties - a description - a collection of factor objects - a collection of factorGroup objects Factor has a simple description property. FactorGroup is implemented by a JavaBean that has a description and two collection properties respectively. Factor is implemented by a JavaBean that has a description property. My task is to represent this recursive data structure in JasperReports. What I "accomplished" until now was to create two report templates called Factor and FactorGroup that declare report fields that map the properties of the JavaBean classes and experiment a little bit. Here is a relevant snippet of my FactorGroup template: <parameter name="FactorGroup" class="net.sf.jasperreports.engine.JasperReport"/> <parameter name="Factor" class="net.sf.jasperreports.engine.JasperReport"/> <field name="description" class="java.lang.String"/> <field name="factors" class="java.util.Collection"/> <field name="factorGroups" class="java.util.Collection"/> <group name="factorGroups"> <groupExpression><![CDATA[$F{description}]]></groupExpression> <groupHeader> <band height="40"> <textField isStretchWithOverflow="true"> <reportElement x="0" y="0" width="200" height="10"/> <textFieldExpression><![CDATA[$F{description}]]></textFieldExpression> </textField> <subreport> <reportElement x="0" y="25" width="842" height="10"/> <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{factorGroups})]]></dataSourceExpression> <subreportExpression class="net.sf.jasperreports.engine.JasperReport"><![CDATA[$P{FactorGroup}]]></subreportExpression> </subreport> </band> </groupHeader> </group> .... .... .... At this stage the collection of factors is not referenced in the template - At very first I wanted to represent groups and subgroups at any level and then add on functionality. The whole thing is started by invoking JasperFillManager.fillReport(factorGroupReportObject,parameters, new JRBeanCollectionDataSource(m_rca.getFactorGroups()) ); where factorGroupReportObject is the compiled report template (FactorGroup) and the expression m_rca.getFactorGroups() returns a collection of (root) factorGroup objects - those that do not have any factorGroup parents. Using this template I manged to hierarchically represent all factorGroups at level 1 and their children. The output is like this: Group 1 Group 1.1 Group 1.2 Group 1.3 Group 2 Group 2.1 Group 2.2 Group 3 My goal is to achieve something like that: Group 1 Faktor 1.a Faktor 1.b Group 1.1 Faktor 1.1.a Faktor 1.1.b Faktor 1.1.c Group 1.2 Group 1.3 Group 2 Group 2.1 Group 2.2 Faktor 2.2.a Faktor 2.2.b Group 3 I am very curious to read your proposals or even solutions !
  8. Hallo, I have an issue concerning a crosstab displaying data from a JRBeanCollectionDataSource. In my particular case the JavaBean collection contains at least two JavaBean instances that have equal properties. As stated in the documentation, Bean properties are mapped to template report fields so that latter can be used in report expressions. I have created a class that adheres to the JavaBeans specification containting the three properties: person, time, action. I also created the corresponding template properties with the same name. Property "person" is evaluated to produce a value for the crosstab's row header Property "time" is evaluated to produce a value for the crosstab's column header Property "action" is evaluated to produce a value for the crosstab's cells In a case that the same person is carrying out two different actions at the same time - (speaking on the phone, and taking notes for example) I have created two JavaBean instances that have different values only for the "action" property. Unfortunately only one crosstable entry is being displayed (the one that was created at last). I would expect that the crosstab would display two entries with a different value for the action property (speaking on the phone and taking notes). Is this possible and if yes how ? Any help is appreciated !
×
×
  • Create New...