tags:

views:

68

answers:

2

We have an old (more than 10yrs old) Java Swing applicatin which draws lots of circles and connections (lines) between those circles on a JCanvas (a subclass of JComponent) based on lab data.

Because the data becames bigger and bigger, we cannot display the entire drawing now. We have put the JCavans into a JScrollPane but it is not convenience to scroll the drawing.

Can we add zoom in zoom out for it? if yes, how? I know we can zoom image but the drawing on Canvas is an image?

thanks,

EDIT:

we draw those circles and line with Graphics within paintComponent(Graphics g) method.

A: 

Without knowing anything about your application it's hard to provide useful advice (adding a code snippet or better yet a cutdown example app would be helpful to show how things are being drawn), but I'll give it a shot:

Why don't you multiply the x,y and width,height values by a scaling factor before you draw each circle/line? I assume that somewhere your canvas is using a Graphics object to draw each shape?

Ash
we draw those circles and line with Graphics within `paintComponent(Graphics g)` method.
5YrsLaterDBA
Try what @Waldheinz suggests. You might only need to change 1 line of code then.
Ash
A: 

You could apply a scaling Transform to the Graphics2D object passed to the paintComponent method. You can learn how to use it in the Java 2D programming trail.

Waldheinz