0

I have a window which contains upper JPanel where figures are painted and the lower JPanel where figures are listed in the JList the list looks like:

[minature][figure.toString()]

The minature is JPanel of a size 10x10. I would like it to contain minature of drawn figure in the upper Panel. By it I mean.

class minaturePanel{
Figure f;....
public void paint(Graphics g){
  g.drawFullSizeFigure(f);
  g.rescaleWholeInsidesOfThePanel();

}
}
user2344333
  • 147
  • 1
  • 1
  • 9

3 Answers3

3

This example paints into a BufferedImage and uses AffineTransformOp to do the scaling.

image

You may also want to look at JScrollNavigator, examined here. It lets you navigate on a thumbnail image of your entire component, seen at full size in an adjacent scroll pane.

image

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
1

It seems you want to draw your full figure to an image, return the image, and then rescale the image then draw the image on the panel which will be the right size as the panel now. Actually you can rescale the image while drawing it.

LanternMike
  • 664
  • 1
  • 5
  • 16
1

If the Figure has no capacity to scale it self. You can use a AffineTransformation to scale the Graphics context your self. Just don't forget to restore the previous transformation...

Check out Transforming Shapes, Text, and Images for more details.

MadProgrammer
  • 343,457
  • 22
  • 230
  • 366