Dan Falcone

Greenhorn
+ Follow
since Feb 03, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Dan Falcone

Campbell - I got a chance to try it and it worked perfectly. Thanks! Should have known that one... still learning.
14 years ago
Campbell, thanks very much for the response. That's what I'll do then.

Much obliged...

- Dan
14 years ago
In a paintComponent method I'm calling g.drawImage several times, rotating some images with AffineTransform but not others, something like this, with object MyImage containing fields

boolean rotate; // true if image is to be rotated
x, y; // upper left position to place image
width, height; // of image
BufferedImage bi; // image itself
I understand that successive assignments of these transforms are cumulative, but (I'm new to this obviously) I don't want it to be here. What is the accepted method of "resetting" after each one? I see the createInverse method which I'm guessing is for other uses, not this. Is it necessary to use an AffineTransform instance static method? I've tried but with no success. Is it better to use a new graphics object?

Thanks for any input.
14 years ago
Never mind - figured it out. I subclassed JPanel to a class called Tile and added a boolean field called "rotated". Then I set rotated from the layout manager and referenced it in the container's paintComponent.

Tried to delete this post once I'd figured it out but couldn't. Sorry for the clutter.
14 years ago
I have a layout manager where I position each new component (JPanels containing images) in the "best fit" position. Sometimes the best fit position is rotated 90 degrees.

There's no problem setting the component's bounds to a rotated position, but how can I communicate back to the calling routine that the image must be rotated within those bounds? Is that possible?

(I'm not clear on all the advantages of LayoutManager2 over LayoutManager but as far as I can tell they don't help here.)

Thanks...

- Dan
14 years ago
Thanks very much Jesper - My thinking was that compiling the layout manager placed the class at
~ / JavaStuff / LAYOUT_MANAGERS / bin / com / danf / testLayout / Test01LayoutManager.class

Then when compiling the test source with classpath
~ / JavaStuff / LAYOUT_MANAGERS / bin

the remaining part (com / danf / testLayout / Test01LayoutManager.class) would be resolved by the import statement
import com.danf.testLayout.Test01LayoutManager;

Your comment about the package and import statements being in accordance must be key though - I was assuming that as long as combining the classpath with the import statement gave the same path as the location of the class, that was enough.

Off now to read the Sun Java Tutorial (which I have in the past but obviously need a refresher).

Thanks again...

- Dan

14 years ago
Thanks Narendira, but when I do that and recompile it the resulting layout manager class ends up farther down in ~ / JavaStuff / LAYOUT_MANAGERS / bin / com / danf / com / danf / testLayout / Test01LayoutManager.class.
14 years ago
Hello - I have a real mental block about classpaths and packages. Can someone please set me straight?

I have a layout manager at
~ / JavaStuff / LAYOUT_MANAGERS / Test01LayoutManager.java
which looks like
I compile it successfully from ~ / JavaStuff / LAYOUT_MANAGERS with
javac -d bin/com/danf ./Test01LayoutManager.java
so that the layout manager class file ends up as
~ / JavaStuff / LAYOUT_MANAGERS / bin / com / danf / testLayout / Test01LayoutManager.class
Good so far.
--------------------------------------------------------------------------------
I also have a source file that calls this layout manager at
~ / JavaStuff / TEST / Test01Harness.java
which looks likeI compile it with
javac -d bin -classpath "~/JavaStuff/LAYOUT_MANAGERS/bin" ./Test01Harness.java
and it produces this error:
Test01Harness.java:8: cannot access com.danf.testLayout.Test01LayoutManager
bad class file: ~/JavaStuff/LAYOUT_MANAGERS/bin/com/danf/testLayout/Test01LayoutManager.class
class file contains wrong class: testLayout.Test01LayoutManager
Please remove or make sure it appears in the correct subdirectory of the classpath.

where line 8 isI apologize ahead of time if this is embarrassingly obvious. I didn't want to clutter the post with the entire programs since I thought this was enough to go on. I guess what I really need (beyond the scope of this post) is a simple primer about classpaths, packages, and import statements.

Thanks very much for any attention you can give this.

- Dan
14 years ago