Changing the min and max value of JSlider depanding on condition
Asked Answered
I

2

4

I'm creating a Swing GUI in Netbeans. The purpose of this GUI is to open an (buffered)image (in a JLabel as icon) and apply Affine transforms on it. Now there are 4 transforms that I'm doing as follows.

enter image description here

Now, each transform requires two sliders to change the X and Y value, except that of rotate, which will require only one. I did it this way since its much better than having to do four tabs for all 4 types of transforms. Also I want it to be such that , for example, if an image is rotated, the same rotated image can be sheared by selecting shear from the Drop down list.

The problem is (are): How do i repaint the label icon and apply different transform on the same repainted image? Also, how do i change the minimum and maximum value of JSlider depanding on the effect selected?

Invitatory answered 9/10, 2012 at 19:34 Comment(0)
G
7

You should store originally loaded BufferedImage, and create its copy - that way you won't "destroy" it.

As for the changing value there are methods setMaximum and setMinimum - add listener to list, as stated in Oracle tutorial and modify the values.

Granvillegranvillebarker answered 9/10, 2012 at 19:38 Comment(3)
Yes, as you're supposed to store it somewhere ;)Granvillegranvillebarker
You could define a model that has the original buffer and a list of effects which can be used to produce to then return the "resulting" image. This would allow the ability to change the order of the effects and allow the views to decide how to react it...IMHOPot
See also the examples here and here.Improvised
I
4

As a concrete example of @Daniel's answer, the article Image processing with Java 2D describes the program ImageDicer. It constructs a TreeMap<String, BufferedImageOp> each of which may be selected from a JComboBox and applied to a BufferedImage.

See also related examples here and here.

Improvised answered 9/10, 2012 at 20:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.