Skip to main content

[JAVA2D] zooming & double buffering

10 replies [Last post]
Anonymous

hi guys,
i have a big problem:
my application shows lot of rectangles which can be dragged on the
screen. the application also supports zooming, i implement this with
transform scale. is it possible to use double buffering to draw the
rectangles(they contains lot of text). when i use the standart
bufferedImage, the text looks not very good. for example i add two
screenshoots. one in 100% and one in 400%!!!
thanks

--
Mit freundlichen Gruessen
Michael Seele(Michael.Seele@guh-software.de)

G & H Softwareentwicklung GmbH Tel.: {+49|0} 7451 - 53 706 0
Robert-Bosch-Str. 23 Fax: {+49|0} 7451 - 53 706 90
D-72160 Horb a.N. http://www.guh-software.de

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
[100.jpg]
[400.jpg]

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Jens Calisti

hoi michael,

give JGraph a try : http://www.jgraph.com/

Features
a.. 100% pure Java, fully standards-compliant developer API
b.. Automatic edge routing and handling of self-references
c.. Command history for infinite undo/redo across multiple views
d.. Each view can have its own set of visible cells and separate
attributes
e.. Multiple connection points per vertex can float along the vertex
boundaries
f.. Layers, Grouping and stepping-into groups for managing large diagrams
g.. Built-in marquee selection, zoom, grid, anti-aliasing, and in-place
editing
h.. Copy and paste or drag and drop to and from Java and native
applications
i.. Very small footprint (150 K) for embedded use

Cheers,

Jens

----- Original Message -----
From: "Michael Seele"
To:
Sent: Wednesday, February 11, 2004 3:12 PM
Subject: [JAVA2D] zooming & double buffering

> hi guys,
> i have a big problem:
> my application shows lot of rectangles which can be dragged on the
> screen. the application also supports zooming, i implement this with
> transform scale. is it possible to use double buffering to draw the
> rectangles(they contains lot of text). when i use the standart
> bufferedImage, the text looks not very good. for example i add two
> screenshoots. one in 100% and one in 400%!!!
> thanks
>
> --
> Mit freundlichen Gruessen
> Michael Seele(Michael.Seele@guh-software.de)
>
> G & H Softwareentwicklung GmbH Tel.: {+49|0} 7451 - 53 706 0
> Robert-Bosch-Str. 23 Fax: {+49|0} 7451 - 53 706 90
> D-72160 Horb a.N. http://www.guh-software.de
>
>
>
===========================================================================
> To unsubscribe, send email to listserv@java.sun.com and include in the
body
> of the message "signoff JAVA2D-INTEREST". For general help, send email to
> listserv@java.sun.com and include in the body of the message "help".
>

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

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

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Michael Seele

do you know if jgraph uses double buffering? how manage jgraph zooming?

Jens Calisti schrieb am 11.02.2004 17:01:

>hoi michael,
>
>give JGraph a try : http://www.jgraph.com/
>
>Features
> a.. 100% pure Java, fully standards-compliant developer API
> b.. Automatic edge routing and handling of self-references
> c.. Command history for infinite undo/redo across multiple views
> d.. Each view can have its own set of visible cells and separate
>attributes
> e.. Multiple connection points per vertex can float along the vertex
>boundaries
> f.. Layers, Grouping and stepping-into groups for managing large diagrams
> g.. Built-in marquee selection, zoom, grid, anti-aliasing, and in-place
>editing
> h.. Copy and paste or drag and drop to and from Java and native
>applications
> i.. Very small footprint (150 K) for embedded use
>
>
>Cheers,
>
>Jens
>
>
>
>----- Original Message -----
>From: "Michael Seele"
>To:
>Sent: Wednesday, February 11, 2004 3:12 PM
>Subject: [JAVA2D] zooming & double buffering
>
>
>
>
>>hi guys,
>>i have a big problem:
>>my application shows lot of rectangles which can be dragged on the
>>screen. the application also supports zooming, i implement this with
>>transform scale. is it possible to use double buffering to draw the
>>rectangles(they contains lot of text). when i use the standart
>>bufferedImage, the text looks not very good. for example i add two
>>screenshoots. one in 100% and one in 400%!!!
>>thanks
>>
>>--
>>Mit freundlichen Gruessen
>>Michael Seele(Michael.Seele@guh-software.de)
>>
>>G & H Softwareentwicklung GmbH Tel.: {+49|0} 7451 - 53 706 0
>>Robert-Bosch-Str. 23 Fax: {+49|0} 7451 - 53 706 90
>>D-72160 Horb a.N. http://www.guh-software.de
>>
>>
>>
>>
>>
>===========================================================================
>
>
>>To unsubscribe, send email to listserv@java.sun.com and include in the
>>
>>
>body
>
>
>>of the message "signoff JAVA2D-INTEREST". For general help, send email to
>>listserv@java.sun.com and include in the body of the message "help".
>>
>>
>>
>
>
>----------------------------------------------------------------------------
>----
>
>
>
>
>
>
>----------------------------------------------------------------------------
>----
>
>===========================================================================
>To unsubscribe, send email to listserv@java.sun.com and include in the body
>of the message "signoff JAVA2D-INTEREST". For general help, send email to
>listserv@java.sun.com and include in the body of the message "help".
>
>
>

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Phil Race

Michael Seele wrote:
> hi guys,
> i have a big problem:
> my application shows lot of rectangles which can be dragged on the
> screen. the application also supports zooming, i implement this with
> transform scale. is it possible to use double buffering to draw the
> rectangles(they contains lot of text). when i use the standart
> bufferedImage, the text looks not very good. for example i add two
> screenshoots. one in 100% and one in 400%!!!
> thanks

its not just fonts, its everything. look at the tick marks too.
You will need to change your approach.
In your case when you scale there's no text drawing happening.
Its just image scaling on image pixels.
ie you are pre-rendering an image at one resolution and then
scaling the image pixels to other resolutions.
That is not how to do resolution independent graphics.

You will need to re-render eveything at the requested resolution
each time.

-phil.

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Michael Seele

thats right. but theres no change when i re-render my image on every
zoom change. please look at my example!

Phil Race schrieb am 11.02.2004 16:29:

> Michael Seele wrote:
>
>> hi guys,
>> i have a big problem:
>> my application shows lot of rectangles which can be dragged on the
>> screen. the application also supports zooming, i implement this with
>> transform scale. is it possible to use double buffering to draw the
>> rectangles(they contains lot of text). when i use the standart
>> bufferedImage, the text looks not very good. for example i add two
>> screenshoots. one in 100% and one in 400%!!!
>> thanks
>
>
> its not just fonts, its everything. look at the tick marks too.
> You will need to change your approach.
> In your case when you scale there's no text drawing happening.
> Its just image scaling on image pixels.
> ie you are pre-rendering an image at one resolution and then
> scaling the image pixels to other resolutions.
> That is not how to do resolution independent graphics.
>
> You will need to re-render eveything at the requested resolution
> each time.
>
> -phil.
>
> ===========================================================================
>
> To unsubscribe, send email to listserv@java.sun.com and include in the
> body
> of the message "signoff JAVA2D-INTEREST". For general help, send
> email to
> listserv@java.sun.com and include in the body of the message "help".
>

--
Mit freundlichen Gruessen
Michael Seele(Michael.Seele@guh-software.de)

G & H Softwareentwicklung GmbH Tel.: {+49|0} 7451 - 53 706 0
Robert-Bosch-Str. 23 Fax: {+49|0} 7451 - 53 706 90
D-72160 Horb a.N. http://www.guh-software.de

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
[src.zip]

Emmanuel Pietriga

I think there is a misunderstanding here. You have to apply the scaling
affine transform *before* calling drawing primitives such as drawText.
If you call it *after* the rendering has been done, i.e. on the rendered
buffered image, you're doing image scaling on image pixels as Phil Race
said, and there is no way you can get good font rendering with this
method (unless, maybe, if you do some antialiasing, but it would not be
that good, and would fail with large zooming factors).

Emmanuel

Michael Seele wrote:
> thats right. but theres no change when i re-render my image on every
> zoom change. please look at my example!
>
> Phil Race schrieb am 11.02.2004 16:29:
>
>> Michael Seele wrote:
>>
>>> hi guys,
>>> i have a big problem:
>>> my application shows lot of rectangles which can be dragged on the
>>> screen. the application also supports zooming, i implement this with
>>> transform scale. is it possible to use double buffering to draw the
>>> rectangles(they contains lot of text). when i use the standart
>>> bufferedImage, the text looks not very good. for example i add two
>>> screenshoots. one in 100% and one in 400%!!!
>>> thanks
>>
>>
>>
>> its not just fonts, its everything. look at the tick marks too.
>> You will need to change your approach.
>> In your case when you scale there's no text drawing happening.
>> Its just image scaling on image pixels.
>> ie you are pre-rendering an image at one resolution and then
>> scaling the image pixels to other resolutions.
>> That is not how to do resolution independent graphics.
>>
>> You will need to re-render eveything at the requested resolution
>> each time.
>>
>> -phil.
>>
>> ===========================================================================
>>
>>
>> To unsubscribe, send email to listserv@java.sun.com and include in the
>> body
>> of the message "signoff JAVA2D-INTEREST". For general help, send
>> email to
>> listserv@java.sun.com and include in the body of the message "help".
>>
>
> --
> Mit freundlichen Gruessen
> Michael Seele(Michael.Seele@guh-software.de)
>
> G & H Softwareentwicklung GmbH Tel.: {+49|0} 7451 - 53 706 0
> Robert-Bosch-Str. 23 Fax: {+49|0} 7451 - 53 706 90
> D-72160 Horb a.N. http://www.guh-software.de
>
>
> ===========================================================================
> To unsubscribe, send email to listserv@java.sun.com and include in the body
> of the message "signoff JAVA2D-INTEREST". For general help, send email to
> listserv@java.sun.com and include in the body of the message "help".

--
Emmanuel Pietriga (epietriga@nuxeo.com)
tel (mobile): +33 6 88 51 94 98
http://claribole.net

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Emmanuel Pietriga

Hello,

I'm using scaling affine transformations extensively in the context of
my Java2D-based ZUI toolkit [1], and I do not have this text rendering
problem, no matter which font I use.

[1] http://zvtm.sourceforge.net

It looks like you are applying the scaling affine transform for zooming
purposes on the final buffered image. Is that what you actually do?

If so, I think this explains why the font rendering does not look good
(it is applied on something equivalent to a bitmap). Instead, you should
apply it earlier in your rendering process, i.e. before calling the
drawText method: IIRC, the Java2D engine uses information about the
scale factor to choose the appropriate font size (and then renders it
correctly). If you apply the affine transform *after* the text has been
rendered, it is too late.

Emmanuel

--
Emmanuel Pietriga (epietriga@nuxeo.com)
tel (mobile): +33 6 88 51 94 98
http://claribole.net

Michael Seele wrote:

> hi guys,
> i have a big problem:
> my application shows lot of rectangles which can be dragged on the
> screen. the application also supports zooming, i implement this with
> transform scale. is it possible to use double buffering to draw the
> rectangles(they contains lot of text). when i use the standart
> bufferedImage, the text looks not very good. for example i add two
> screenshoots. one in 100% and one in 400%!!!
> thanks
>
> --
> Mit freundlichen Gruessen
> Michael Seele(Michael.Seele@guh-software.de)
>
> G & H Softwareentwicklung GmbH Tel.: {+49|0} 7451 - 53 706 0
> Robert-Bosch-Str. 23 Fax: {+49|0} 7451 - 53 706 90
> D-72160 Horb a.N. http://www.guh-software.de
>
>
> ===========================================================================
> To unsubscribe, send email to listserv@java.sun.com and include in the body
> of the message "signoff JAVA2D-INTEREST". For general help, send email to
> listserv@java.sun.com and include in the body of the message "help".
>
> ------------------------------------------------------------------------
>
>
> ------------------------------------------------------------------------
>

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Michael Seele

sorry i'm not a great specialist in Java2D. here is an example
application. the zoomFramework should not changed because it is
responsible for managing the events right.

Emmanuel Pietriga schrieb am 11.02.2004 15:41:

> Hello,
>
> I'm using scaling affine transformations extensively in the context of
> my Java2D-based ZUI toolkit [1], and I do not have this text rendering
> problem, no matter which font I use.
>
> [1] http://zvtm.sourceforge.net
>
> It looks like you are applying the scaling affine transform for zooming
> purposes on the final buffered image. Is that what you actually do?
>
> If so, I think this explains why the font rendering does not look good
> (it is applied on something equivalent to a bitmap). Instead, you should
> apply it earlier in your rendering process, i.e. before calling the
> drawText method: IIRC, the Java2D engine uses information about the
> scale factor to choose the appropriate font size (and then renders it
> correctly). If you apply the affine transform *after* the text has been
> rendered, it is too late.
>
> Emmanuel
>
> --
> Emmanuel Pietriga (epietriga@nuxeo.com)
> tel (mobile): +33 6 88 51 94 98
> http://claribole.net
>
> Michael Seele wrote:
>
>> hi guys,
>> i have a big problem:
>> my application shows lot of rectangles which can be dragged on the
>> screen. the application also supports zooming, i implement this with
>> transform scale. is it possible to use double buffering to draw the
>> rectangles(they contains lot of text). when i use the standart
>> bufferedImage, the text looks not very good. for example i add two
>> screenshoots. one in 100% and one in 400%!!!
>> thanks
>>
>> --
>> Mit freundlichen Gruessen
>> Michael Seele(Michael.Seele@guh-software.de)
>>
>> G & H Softwareentwicklung GmbH Tel.: {+49|0} 7451 - 53 706 0
>> Robert-Bosch-Str. 23 Fax: {+49|0} 7451 - 53 706 90
>> D-72160 Horb a.N. http://www.guh-software.de
>>
>>
>> ===========================================================================
>>
>> To unsubscribe, send email to listserv@java.sun.com and include in
>> the body
>> of the message "signoff JAVA2D-INTEREST". For general help, send
>> email to
>> listserv@java.sun.com and include in the body of the message "help".
>>
>> ------------------------------------------------------------------------
>>
>>
>> ------------------------------------------------------------------------
>>
>
> ===========================================================================
>
> To unsubscribe, send email to listserv@java.sun.com and include in the
> body
> of the message "signoff JAVA2D-INTEREST". For general help, send
> email to
> listserv@java.sun.com and include in the body of the message "help".
>

--
Mit freundlichen Gruessen
Michael Seele(Michael.Seele@guh-software.de)

G & H Softwareentwicklung GmbH Tel.: {+49|0} 7451 - 53 706 0
Robert-Bosch-Str. 23 Fax: {+49|0} 7451 - 53 706 90
D-72160 Horb a.N. http://www.guh-software.de

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
[example.zip]

Dave Kavanagh

When I've rendered text at different resolutions, I've just set the transform
on the Graphics2D before rendering. Unless its an outline font, it might not
scale well.
I've also used the TextLayout class, which knows about the transform via the
FontRenderContext you pass in (and got from the graphics).

David

Quoting Michael Seele :

> hi guys,
> i have a big problem:
> my application shows lot of rectangles which can be dragged on the
> screen. the application also supports zooming, i implement this with
> transform scale. is it possible to use double buffering to draw the
> rectangles(they contains lot of text). when i use the standart
> bufferedImage, the text looks not very good. for example i add two
> screenshoots. one in 100% and one in 400%!!!
> thanks
>
> --
> Mit freundlichen Gruessen
> Michael Seele(Michael.Seele@guh-software.de)
>
> G & H Softwareentwicklung GmbH Tel.: {+49|0} 7451 - 53 706 0
> Robert-Bosch-Str. 23 Fax: {+49|0} 7451 - 53 706 90
> D-72160 Horb a.N. http://www.guh-software.de
>
>
> ===========================================================================
> To unsubscribe, send email to listserv@java.sun.com and include in the body
> of the message "signoff JAVA2D-INTEREST". For general help, send email to
> listserv@java.sun.com and include in the body of the message "help".
>

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Rob Ross

> When I've rendered text at different resolutions, I've just set
> the transform
> on the Graphics2D before rendering. Unless its an outline font,
> it might not
> scale well.
> I've also used the TextLayout class, which knows about the
> transform via the
> FontRenderContext you pass in (and got from the graphics).
>
> David

Michael mentioned he was using BufferedImage. I wonder if he's pre-rendering
his rectangles as BufferedImages and then zooming those when he draws them
to the Graphics? If so then he's getting the behavior one would expect.
Instead of using BufferedImages, if he can just re-render his paintings with
the new scale size, shouldn't the Fonts "do the right thing" and draw
themselves bigger and smoother?

Also, one suggestion I have is you could query the zoom factor in your paint
method, and actually set the graphics to use a larger-scaled font, and use a
multiplier to draw your other objects, i.e., handle the zooming yourself
without using a transform. It's more work but you'd have more control of the
Font printing.

Rob

> Quoting Michael Seele :
>
> > hi guys,
> > i have a big problem:
> > my application shows lot of rectangles which can be dragged on the
> > screen. the application also supports zooming, i implement this with
> > transform scale. is it possible to use double buffering to draw the
> > rectangles(they contains lot of text). when i use the standart
> > bufferedImage, the text looks not very good. for example i add two
> > screenshoots. one in 100% and one in 400%!!!
> > thanks
> >
> > --
> > Mit freundlichen Gruessen
> > Michael Seele(Michael.Seele@guh-software.de)

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Michael Seele

i have testet selfhandling zoom, but i get to much rounding errors
because the fonts!

Rob Ross schrieb am 11.02.2004 15:53:

>>When I've rendered text at different resolutions, I've just set
>>the transform
>>on the Graphics2D before rendering. Unless its an outline font,
>>it might not
>>scale well.
>>I've also used the TextLayout class, which knows about the
>>transform via the
>>FontRenderContext you pass in (and got from the graphics).
>>
>>David
>>
>>
>
>Michael mentioned he was using BufferedImage. I wonder if he's pre-rendering
>his rectangles as BufferedImages and then zooming those when he draws them
>to the Graphics? If so then he's getting the behavior one would expect.
>Instead of using BufferedImages, if he can just re-render his paintings with
>the new scale size, shouldn't the Fonts "do the right thing" and draw
>themselves bigger and smoother?
>
>Also, one suggestion I have is you could query the zoom factor in your paint
>method, and actually set the graphics to use a larger-scaled font, and use a
>multiplier to draw your other objects, i.e., handle the zooming yourself
>without using a transform. It's more work but you'd have more control of the
>Font printing.
>
>Rob
>
>
>
>>Quoting Michael Seele :
>>
>>
>>
>>>hi guys,
>>>i have a big problem:
>>>my application shows lot of rectangles which can be dragged on the
>>>screen. the application also supports zooming, i implement this with
>>>transform scale. is it possible to use double buffering to draw the
>>>rectangles(they contains lot of text). when i use the standart
>>>bufferedImage, the text looks not very good. for example i add two
>>>screenshoots. one in 100% and one in 400%!!!
>>>thanks
>>>
>>>--
>>>Mit freundlichen Gruessen
>>>Michael Seele(Michael.Seele@guh-software.de)
>>>
>>>
>
>===========================================================================
>To unsubscribe, send email to listserv@java.sun.com and include in the body
>of the message "signoff JAVA2D-INTEREST". For general help, send email to
>listserv@java.sun.com and include in the body of the message "help".
>
>
>

--
Mit freundlichen Gruessen
Michael Seele(Michael.Seele@guh-software.de)

G & H Softwareentwicklung GmbH Tel.: {+49|0} 7451 - 53 706 0
Robert-Bosch-Str. 23 Fax: {+49|0} 7451 - 53 706 90
D-72160 Horb a.N. http://www.guh-software.de

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".