Jump to content

Alignment of line and rectangle with 0.5 pix width


crominium

Recommended Posts

 Hello !

http://www.shrani.si/f/3B/YV/j8mEd3b/lineproblem.jpg

 

We have a problem with the lines in the jasperreport when they are smaller than 1 pix (0.5 as on the picture). You can see the alignment of the static text with the 0.5 border and the rectangle with the 0.5 thickness are the same, the line holding together with the rectangle is positioned on the same pixel as the both (rectangle,static text) but the line is aligned right in that exact pixel, the box and its border is alligned left in the also same pixel. Either iReport nor jasperReports is not giving an option for the line alignment (left, center, right) or something similar. What do you suggest?

 

We currently are using an old version of jasperReports 0.6.1. to be exact - if i draw a line in the old designer the code looks like this :

 

                <line direction="TopDown">

                                               <reportElement

                                                               mode="Opaque"

                                                               x="436"

                                                               y="1"

                                                               width="346"

                                                               height="0"

                                                               forecolor="#000000"

                                                               backcolor="#FFFFFF"

                                                               positionType="FixRelativeToTop"

                                                               isPrintRepeatedValues="true"

                                                               isRemoveLineWhenBlank="false"

                                                               isPrintInFirstWholeBand="false"

                                                               isPrintWhenDetailOverflows="false"/>

                                                <graphicElement stretchType="RelativeToBandHeight" pen="Thin" fill="Solid" />

                </line>

 

 

In the 3.7.0. the pen type Thin dissapears and you offer 0.25,0.5,1…pixel width of the line.

 

                <line>

                                                <reportElement stretchType="RelativeToBandHeight" mode="Opaque" x="0" y="1" width="1" height="11" forecolor="#000000" backcolor="#FFFFFF"/>

                                                <graphicElement fill="Solid">

                                               <pen lineWidth="0.5" lineStyle="Solid"/>

                                               </graphicElement>

                </line>

 

If i open an old report made with the 0.6.1. version the lines are not anymore aligned or in other words, the Thin is converted in the 3.7.0 version to 0.5 pix, which is right, just the alignment of the lines isn't anymore. I assume in the old version you had a centered alignment for the lines and in the 3.7.0 version you allign the rectangles and graphical elements left in the pixel, the lines are alligned right?This happens only if the line width is not a whole number, thin lines are very useful and 1 pix line width is very strong.

 

What is the solution for our problem?

Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

I'd completely switch to the 3.7.0 version, then:

1. Remove the rectangle that is off.

2. Create it anew.

3. Align it using the "Align to Left Margin" button in the alignment window.

I have run into similar problems when mixing 0.5 pixel widths with 1 pixel widths. I usually make everything 0.5 pixels and then alignment problems vanish.

Good luck!

Link to comment
Share on other sites

http://www.shrani.si/f/S/Dg/4nWb2Jit/lineproblem2.jpg

Description of the picture :

Visible are 4 pixels (I drawn this so I can explain exact), line width 0.5 pix, lines start on the same pixel. 

Obviously the line alignment is right and bottom and jasperreports does not support any influence on that alignment. So at line width 0.5 pix we have this problem. Is this a bug or a feature you decide ;) 

Try to draw two lines as I did and you'll see what happens. 

Still there is no solution for this problem.

 

Link to comment
Share on other sites

  • 2 weeks later...

This issue also affects some reports of mine, going from JasperReports 1.3.1 to 3.7.0

I am using a few different conditional lines along with other text elements that must line up (and used to prior to upgrading).

 

I cannot align rectangle borders and line elements (lines using width of 1, weight of 1) to each other.

See below, All line weights are = 1 and the colored parts are line elements, aligned left at x=210

Frame X=210, width = 40

Right line is at X=250, width = 1.

 

/uploads/projects/jasperreports/image/jr3_7_frame_line_width1.jpg

 

Changing the right line width = 3 for the right hand line:

/uploads/projects/jasperreports/image/jr3_7_frame_line_width3.jpg

It's aligned to the same coordinates as the bottom right point of the frame, however, it's not straight..

Can you just draw the lines from that same location straight down?

It seems as though the drawing coordinates are off for lines versus frames (+ rectangles)...

Can this be fixed, so that it's pixel perfect? :)

 

 

Link to comment
Share on other sites

Hi,

 

In JR 2.0.3, we have changed the way borders are drawn, when we introduced new types of borders and when we allowed borders to have any width.

If you have reports older than 2.0.3 and you want them to work like they did, then you need to turn this config property to true:

http://jasperreports.sourceforge.net/config.reference.html#net.sf.jasperreports.export.legacy.border.offset

 

Note that this property can be set globally (for all reports) in the jasperreports.properties file, or can be set to individual reports as a custom report property. I suggest you set it at report level for all your old reports, and for new reports, you just use the new types of borders.

Setting this property for all your old reports in an automatic way can be achieved with an Ant update task that was introduced in JR 3.7.1 (earlier this week).

If you get JR 3.7.1, check the /demo/samples/antupdate sample provided.

http://jasperreports.sourceforge.net/sample.reference/antupdate/index.html#antupdate

 

In the build.xml file of this sample, notice the commented line which specifies the legacy border setting updater. Uncomment that line if you want your JRXMLs to have the property added automatically when updated to the new JRXML syntax.

 

I hope this helps.
Teodor

 

Link to comment
Share on other sites

Great, that worked!

I just added the following underneath the "ireport.encoding" property to re-enable the previous look in the .jrxml report:

<property name="net.sf.jasperreports.export.legacy.border.offset" value="true"/>

 

(I had already re-saved the report in iReport 3.7.0)

Cheers!

Jamie

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...