The Source for Java Technology Collaboration

Home » java.net Forums » Java Desktop Technologies » Swing & AWT

Thread: Is There A BalloonTip Component In Java?

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 80 - Last Post: Oct 30, 2006 11:57 PM by: Anthony Petrov
mijzcx

Posts: 22
Is There A BalloonTip Component In Java?
Posted: Sep 29, 2006 9:58 AM
  Click to reply to this thread Reply

Is there a BalloonTip component in java? Swing in particular or maybe in any other libraries?

Thank You.

jvaudry

Posts: 64
Re: Is There A BalloonTip Component In Java?
Posted: Sep 30, 2006 10:11 AM   in response to: mijzcx
  Click to reply to this thread Reply

Hi, I do not know of a ready-made balloon tip component. I've tried a couple approaches to create a balloon tip.

My first try was to develop a custom JPopupMenu. Using a lightweight popup you can walk up its component hierarchy and set everything to be non-opaque. That way you can show a rounded balloon shape (instead of seeing the usual rectangular window). I found that approach sometimes left a gray rectangle behind when it the popup was hidden. I couldn't figure out how to get rid of the grey rectangle so I used a second approach.

The second approach was to create a pojo object that knows how to draw the balloon (using g.drawString() to paint the text, and using constructive geometry to create the balloon (E.g., http://java.sun.com/docs/books/tutorial/2d/display/complexshapes.html)). Then I painted the balloon object on the glasspane of the main window (as opposed to painting it in a JPopupMenu). That approach worked much better.

Joshua Marinacci
Re: Is There A BalloonTip Component In Java?
Posted: Sep 30, 2006 10:16 AM   in response to: jvaudry
  Click to reply to this thread Reply

There is an example of this in the Swing Hacks book. However, it only
works for lightweight popups, of course.

- Josh

On Sep 30, 2006, at 10:11 AM, swing@javadesktop.org wrote:

> Hi, I do not know of a ready-made baloon tip component. I've tried
> a couple approaches to create a baloon tip.
>
> My first try was to develop a custom JPopupMenu. Using a
> lightweight popup you can walk up it's component hierarchy and set
> everything to be non-opaque. That way you can show a rounded baloon
> shape (instead of seeing the usual rectangular window). I found
> that approach sometimes left a gray rectangle behind when it the
> popup was hidden. I couldn't figure out how to get rid of the grey
> rectangle so I used a second approach.
>
> The second approach was to create a pojo object that knows how to
> draw the baloon (using g.drawString() to paint the text). Then I
> painted the baloon object on the glasspane of the main window (as
> opposed to painting it in a JPopupMenu). That approach worked much
> better.
> [Message sent by forum member 'jvaudry' (jvaudry)]
>
> http://forums.java.net/jive/thread.jspa?messageID=158479

- Blasting forth in three part harmony!


[att1.html]


jvaudry

Posts: 64
Re: Is There A BalloonTip Component In Java?
Posted: Sep 30, 2006 10:20 AM   in response to: Joshua Marinacci
  Click to reply to this thread Reply

hi, I have the book. Good read, btw :)

leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Sep 30, 2006 10:31 AM   in response to: mijzcx
  Click to reply to this thread Reply

Id guess that the non-rectangular windows feature would enable this kind of thing. I saw a picture of a X window with a nice circle cut out of the center of it. Don't know if that functionality will be part of the feature but it would be nice.

leouser

Joshua Marinacci
Re: Is There A BalloonTip Component In Java?
Posted: Sep 30, 2006 10:38 AM   in response to: leouser
  Click to reply to this thread Reply

We are pushing for this in Java 7, but I don't know if it will make
it in. Code contributions are always welcome, of course. :)

- J

On Sep 30, 2006, at 10:31 AM, swing@javadesktop.org wrote:

> Id guess that the non-rectangular windows feature would enable this
> kind of thing. I saw a picture of a X window with a nice circle
> cut out of the center of it. Don't know if that functionality will
> be part of the feature but it would be nice.
>
> leouser
> [Message sent by forum member 'leouser' (leouser)]
>
> http://forums.java.net/jive/thread.jspa?messageID=158490

- Blasting forth in three part harmony!


[att1.html]


leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Sep 30, 2006 11:46 AM   in response to: Joshua Marinacci
  Click to reply to this thread Reply

Hmm, maybe Ill play around with it this week on the X side. I see Ive got the shape.h file in the system, so hopefully I won't have to do any more system configuration. I am curious if the darn thing will just work if I make the backing XWindow a circle, will the AWT side of things be able to deal with it. I guess it would depend upon how X sends events to oddly shaped windows.

BH

Joshua Marinacci
Re: Is There A BalloonTip Component In Java?
Posted: Sep 30, 2006 7:48 PM   in response to: leouser
  Click to reply to this thread Reply

If you get something working could you start a new subproject under
the JDIC project for it? That's the best place to put such things.

- J

On Sep 30, 2006, at 11:46 AM, swing@javadesktop.org wrote:

> Hmm, maybe Ill play around with it this week on the X side. I see
> Ive got the shape.h file in the system, so hopefully I won't have
> to do any more system configuration. I am curious if the darn
> thing will just work if I make the backing XWindow a circle, will
> the AWT side of things be able to deal with it. I guess it would
> depend upon how X sends events to oddly shaped windows.
>
> BH
> [Message sent by forum member 'leouser' (leouser)]
>
> http://forums.java.net/jive/thread.jspa?messageID=158495

- Blasting forth in three part harmony!


[att1.html]


leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 1, 2006 7:51 AM   in response to: Joshua Marinacci
  Click to reply to this thread Reply

Ill see what happens, I guess the dividing line will be if it is going to require modifications to something coreish or if it can stand by itself. If its coreish, Im not sure if we are at the point in liscensing yet where I can do a public fork of the JDK.

BH

leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 2, 2006 12:28 PM   in response to: leouser
  Click to reply to this thread Reply

cool, Ive made enough progress where I am able to make a Window or JFrame where it is transparent visually and in behavior. By behavior I mean if I have a JFrame, the portion that is transparent will act as if its not there. A Window below it will be brought to the fore. While the non-transparent part acts like it always has. In the example its a big JButton, so it clicks.

I wish these forums had an attachment so I could show you a simple picture. Maybe Ill post one in the collab forum.

Anyway, Ive been able to do most of this without altering the JDK src. The only thing Ive altered so far was adding a public modifier to a static method so I could grab the Display. So its fairly conceivable, given what Ive seen, that a simple API could be developed so that a user could make things non-rectangular. Even with the API I think there is going to be a need to check if the extension is supported, given that it appears optional. Though from the article Im reading it sounds as though its a very popular extension.

BH

Joshua Marinacci
Re: Is There A BalloonTip Component In Java?
Posted: Oct 2, 2006 12:35 PM   in response to: leouser
  Click to reply to this thread Reply

This sounds great. Yes, definitely post a screenshot.

How are you doing this? Using JNI to call the native method and JAWT
to get a handle to the toplevel window/container handle? It would
definitely need an isTranslucencySupported() method of some kind. I
don't know if we should distinguish transparency and translucency at
the API level. I suppose it depends on what the native platform
supports. OSX and Vista should be no problem. I don't know about XP
or earlier. And it seems that X is a crapshoot, depending on what the
user has configured.

Is your code for Windows or X, btw?

- J


On Oct 2, 2006, at 12:28 PM, swing@javadesktop.org wrote:

> cool, Ive made enough progress where I am able to make a Window or
> JFrame where it is transparent visually and in behavior. By
> behavior I mean if I have a JFrame, the portion that is transparent
> will act as if its not there. A Window below it will be brought to
> the fore. While the non-transparent part acts like it always has.
> In the example its a big JButton, so it clicks.
>
> I wish these forums had an attachment so I could show you a
> simple picture. Maybe Ill post one in the collab forum.
>
> Anyway, Ive been able to do most of this without altering the JDK
> src. The only thing Ive altered so far was adding a public
> modifier to a static method so I could grab the Display. So its
> fairly conceivable, given what Ive seen, that a simple API could be
> developed so that a user could make things non-rectangular. Even
> with the API I think there is going to be a need to check if the
> extension is supported, given that it appears optional. Though
> from the article Im reading it sounds as though its a very popular
> extension.
>
> BH
> [Message sent by forum member 'leouser' (leouser)]
>
> http://forums.java.net/jive/thread.jspa?messageID=158918

- Blasting forth in three part harmony!


- Blasting forth in three part harmony!


[att1.html]


leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 2, 2006 12:49 PM   in response to: Joshua Marinacci
  Click to reply to this thread Reply

Its X at this juncture, Im crippled when it comes to Windows... no good C++ compiler to build things with.

Ive got a early picture posted here:
https://www.dev.java.net/files/forums/2899/1463/1432/NonRectWindow.png

Its not too exciting but it shows what you can do with Rectangles. The JButton should fill the entire frame.

Im going to be looking at how the Pixmap function looks next. This should make a cooler example. :)

BH

oleg_sukhodolsky

Posts: 87
Re: Is There A BalloonTip Component In Java?
Posted: Oct 3, 2006 12:16 AM   in response to: leouser
  Click to reply to this thread Reply

Hi Brian,

just to let you (and others) know. Transparent and shaped toplevels are in AWT wish-list for jdk 7 and, I hope, we will implement them. Also please note that we will implement shaped windows as part of another project thus I'd suggest you to postpone such project unless you want to have these cool features before 7.0, because any changes in this area may not be applicable for AWT :( And so we will not accept such submission.

Thanks, Oleg.

Joshua Marinacci
Re: Is There A BalloonTip Component In Java?
Posted: Oct 3, 2006 10:59 AM   in response to: oleg_sukhodolsky
  Click to reply to this thread Reply

Brian, please do continue your work and make it available for earlier
versions of Java. The JDIC project would be the likely place for
this. We understand that things will change when moved or re-
implemented in core, but transparent windows is very useful right
now. I know of a Mac developer who may be interested in helping on
that side. It would be good to come up with a common API for this.

- Josh


On Oct 3, 2006, at 12:16 AM, swing@javadesktop.org wrote:

> Hi Brian,
>
> just to let you (and others) know. Transparent and shaped
> toplevels are in AWT wish-list for jdk 7 and, I hope, we will
> implement them. Also please note that we will implement shaped
> windows as part of another project thus I'd suggest you to postpone
> such project unless you want to have these cool features before
> 7.0, because any changes in this area may not be applicable for
> AWT :( And so we will not accept such submission.
>
> Thanks, Oleg.
> [Message sent by forum member 'oleg_sukhodolsky' (oleg_sukhodolsky)]
>
> http://forums.java.net/jive/thread.jspa?messageID=159070

- Blasting forth in three part harmony!


[att1.html]


leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 3, 2006 6:44 PM   in response to: Joshua Marinacci
  Click to reply to this thread Reply

Hmm, Ill focus on making it a JDIC(if I make it further) project and skip it as collab submission. If I get far enough Ill ping you Josh about collaborating with this Mac dude(ss). This is pretty interesting stuff, so its worth investigating just for its own sake. Im not sure how far back it can be taken, maybe Java 5 is as deep as it could go on the X side. The reason I say this is that I believe the X classes Im currently working with sprung into existence in Java 5, maybe Im misguided about this. I have no idea what the API was before that.

I hope XP has simple support for this. I took Windows Media Player today and made it assume this very odd shape. That is a positive sign.

Im uncertain as to the best API for this. Maybe a static method that would take a Window and a GeneralPath:
public static void shapeWindow(Window w, GeneralPath shape);

probably would want to do an image based shape to if that was supported on all platforms:
public static void shapeWindow(Window w, Image image);

Im going to need to get a firm grasp on the Pixmap based shaping in X. I was doing some experimentation yesterday with it and the results were not quite what I was shooting for. Instead of a snowman shape I had 4-6 unconnected sharp triangles for a shape. If you clicked on one of the triangles it made the button click, if you clicked on the spaces between the triangles it did nothing but go to the entity behind it. That was semi-exciting stuff, but not what I was shooting for.

I almost think you need to keep transparency and translucency in separate categories. The transparency Im experimenting with appears to be an all or nothing game. The window either exists in a place or it doesn't. Contrast this with the "Allow JComponents to be translucent" patch I did a little while back. You could make the component transparent but it did not stop it from eating MouseEvents and such. It was there regardless of the fact if you were aware of it or not.

BH

Vyacheslav Bara...
Re: Is There A BalloonTip Component In Java?
Posted: Oct 4, 2006 5:00 AM   in response to: leouser
  Click to reply to this thread Reply

Hi Brian,

Windows support all the stuff you need, so feel free to move on.
I think it would be rather painful to build JDK with Cygwin g++,
but you can easily use it to build your own native libraries.

I think, we can participate in this project, at least with some
advice and code review.

Thanks,
Slava

PS I think it's better to use Shape as an argument instead of
GeneralPath.

PPS I would suggest thinking of setting shapes to Components
instead of Windows. It would not add work for heavyweight
components, and can be easily implemented for lightweights
by clipping Graphics2D while painting.

swing@javadesktop.org wrote:
> Hmm, Ill focus on making it a JDIC(if I make it further) project and skip it as collab submission. If I get far enough Ill ping you Josh about collaborating with this Mac dude(ss). This is pretty interesting stuff, so its worth investigating just for its own sake. Im not sure how far back it can be taken, maybe Java 5 is as deep as it could go on the X side. The reason I say this is that I believe the X classes Im currently working with sprung into existence in Java 5, maybe Im misguided about this. I have no idea what the API was before that.
>
> I hope XP has simple support for this. I took Windows Media Player today and made it assume this very odd shape. That is a positive sign.
>
> Im uncertain as to the best API for this. Maybe a static method that would take a Window and a GeneralPath:
> public static void shapeWindow(Window w, GeneralPath shape);
>
> probably would want to do an image based shape to if that was supported on all platforms:
> public static void shapeWindow(Window w, Image image);
>
> Im going to need to get a firm grasp on the Pixmap based shaping in X. I was doing some experimentation yesterday with it and the results were not quite what I was shooting for. Instead of a snowman shape I had 4-6 unconnected sharp triangles for a shape. If you clicked on one of the triangles it made the button click, if you clicked on the spaces between the triangles it did nothing but go to the entity behind it. That was semi-exciting stuff, but not what I was shooting for.
>
> I almost think you need to keep transparency and translucency in separate categories. The transparency Im experimenting with appears to be an all or nothing game. The window either exists in a place or it doesn't. Contrast this with the "Allow JComponents to be translucent" patch I did a little while back. You could make the component transparent but it did not stop it from eating MouseEvents and such. It was there regardless of the fact if you were aware of it or not.
>
> BH
> [Message sent by forum member 'leouser' (leouser)]
>
> http://forums.java.net/jive/thread.jspa?messageID=159527
>


leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 4, 2006 12:14 PM   in response to: Vyacheslav Bara...
  Click to reply to this thread Reply

yes, Shape sounds like a better idea. That would include the GeneralPath variants but many other things.

Doing at the Component level appears doable. If Im thinking right every component on X is an XWindow and the shape library works with XWindows, not just toplevels.

Yes, the idea of building Java with Cygwin and g++ scares me. :D

BH

Joshua Marinacci
Re: Is There A BalloonTip Component In Java?
Posted: Oct 4, 2006 1:11 PM   in response to: leouser
  Click to reply to this thread Reply

I discussed this with Chris Campbell at lunch today. We decided that
in the end you need both shape and image based apis, because some
platforms will support one and not the other. Plus some might be
faster than the other. You might also want to just set an alpha
value on the window as a whole. Thus you would need three set methods
plus three isSupported methods. It's not perfect but it's the only
way to cover everything and it gives the developer the power to do
what they want.

On transparency vs translucency. One thing to try is if the alpha = 0
then the window really shouldn't be in that spot and it should allow
the mouse events to go thorough. If it's anything but 0, even just 1
out of 255, then it should capture mouse events. As an interesting
side effect, since an alpha of 1 will visually look the same as an
alpha of 0, you could use to create a screen wide glasspane to do
cool things like a magnifying glass, drawing on the whole screen,
color selection on single click, etc.

- Josh

On Oct 3, 2006, at 6:44 PM, swing@javadesktop.org wrote:

> Hmm, Ill focus on making it a JDIC(if I make it further) project
> and skip it as collab submission. If I get far enough Ill ping you
> Josh about collaborating with this Mac dude(ss). This is pretty
> interesting stuff, so its worth investigating just for its own
> sake. Im not sure how far back it can be taken, maybe Java 5 is as
> deep as it could go on the X side. The reason I say this is that I
> believe the X classes Im currently working with sprung into
> existence in Java 5, maybe Im misguided about this. I have no idea
> what the API was before that.
>
> I hope XP has simple support for this. I took Windows Media Player
> today and made it assume this very odd shape. That is a positive
> sign.
>
> Im uncertain as to the best API for this. Maybe a static method
> that would take a Window and a GeneralPath:
> public static void shapeWindow(Window w, GeneralPath shape);
>
> probably would want to do an image based shape to if that was
> supported on all platforms:
> public static void shapeWindow(Window w, Image image);
>
> Im going to need to get a firm grasp on the Pixmap based shaping in
> X. I was doing some experimentation yesterday with it and the
> results were not quite what I was shooting for. Instead of a
> snowman shape I had 4-6 unconnected sharp triangles for a shape.
> If you clicked on one of the triangles it made the button click, if
> you clicked on the spaces between the triangles it did nothing but
> go to the entity behind it. That was semi-exciting stuff, but not
> what I was shooting for.
>
> I almost think you need to keep transparency and translucency in
> separate categories. The transparency Im experimenting with
> appears to be an all or nothing game. The window either exists in
> a place or it doesn't. Contrast this with the "Allow JComponents
> to be translucent" patch I did a little while back. You could make
> the component transparent but it did not stop it from eating
> MouseEvents and such. It was there regardless of the fact if you
> were aware of it or not.
>
> BH
> [Message sent by forum member 'leouser' (leouser)]
>
> http://forums.java.net/jive/thread.jspa?messageID=159527

- Blasting forth in three part harmony!


[att1.html]


Anthony Petrov
Re: Is There A BalloonTip Component In Java?
Posted: Oct 5, 2006 12:22 AM   in response to: Joshua Marinacci
  Click to reply to this thread Reply

Hi folks,

Sounds great, excellent, cool... apart from one tiny thing: neither
Windows nor X support translucency for child windows. These systems
support this stuff for top-levels only (I'm not sure about MacOSX though).
Now imagine one valuable point in JDK development - the support of
mixing of HW and LW components (the feature is planned and will probably
be available in JDK 7). LW components will paint themselves as expected
- with fancy translucent effects and all that cool stuff. And what about
HW components? What are your thoughts on supporting mixing for LW
components with translucency enabled?

On 10/05/2006 12:11 AM Joshua Marinacci wrote:
> I discussed this with Chris Campbell at lunch today. We decided that in
> the end you need both shape and image based apis, because some platforms
> will support one and not the other. Plus some might be faster than the
> other. You might also want to just set an alpha value on the window as
> a whole. Thus you would need three set methods plus three isSupported
> methods. It's not perfect but it's the only way to cover everything and
> it gives the developer the power to do what they want.
>
> On transparency vs translucency. One thing to try is if the alpha = 0
> then the window really shouldn't be in that spot and it should allow the
> mouse events to go thorough. If it's anything but 0, even just 1 out of
> 255, then it should capture mouse events. As an interesting side effect,
> since an alpha of 1 will visually look the same as an alpha of 0, you
> could use to create a screen wide glasspane to do cool things like a
> magnifying glass, drawing on the whole screen, color selection on single
> click, etc.
>
> - Josh
>
> On Oct 3, 2006, at 6:44 PM, swing@javadesktop.org
> <mailto:swing@javadesktop.org> wrote:
>
>> Hmm, Ill focus on making it a JDIC(if I make it further) project and
>> skip it as collab submission. If I get far enough Ill ping you Josh
>> about collaborating with this Mac dude(ss). This is pretty
>> interesting stuff, so its worth investigating just for its own sake.
>> Im not sure how far back it can be taken, maybe Java 5 is as deep as
>> it could go on the X side. The reason I say this is that I believe
>> the X classes Im currently working with sprung into existence in Java
>> 5, maybe Im misguided about this. I have no idea what the API was
>> before that.
>>
>> I hope XP has simple support for this. I took Windows Media Player
>> today and made it assume this very odd shape. That is a positive sign.
>>
>> Im uncertain as to the best API for this. Maybe a static method that
>> would take a Window and a GeneralPath:
>> public static void shapeWindow(Window w, GeneralPath shape);
>>
>> probably would want to do an image based shape to if that was
>> supported on all platforms:
>> public static void shapeWindow(Window w, Image image);
>>
>> Im going to need to get a firm grasp on the Pixmap based shaping in
>> X. I was doing some experimentation yesterday with it and the results
>> were not quite what I was shooting for. Instead of a snowman shape I
>> had 4-6 unconnected sharp triangles for a shape. If you clicked on
>> one of the triangles it made the button click, if you clicked on the
>> spaces between the triangles it did nothing but go to the entity
>> behind it. That was semi-exciting stuff, but not what I was shooting for.
>>
>> I almost think you need to keep transparency and translucency in
>> separate categories. The transparency Im experimenting with appears
>> to be an all or nothing game. The window either exists in a place or
>> it doesn't. Contrast this with the "Allow JComponents to be
>> translucent" patch I did a little while back. You could make the
>> component transparent but it did not stop it from eating MouseEvents
>> and such. It was there regardless of the fact if you were aware of it
>> or not.
>>
>> BH
>> [Message sent by forum member 'leouser' (leouser)]
>>
>> http://forums.java.net/jive/thread.jspa?messageID=159527
>
> - Blasting forth in three part harmony!
>
>

--
best regards,
Anthony


leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 5, 2006 7:27 AM   in response to: Anthony Petrov
  Click to reply to this thread Reply

When the Composite extension becomes a reality, this may no longer be true for X:
http://webcvs.freedesktop.org/xlibs/CompositeExt/protocol?view=markup

But again, this is probably going to be an option only for really new X implementations.

BH

Joshua Marinacci
Re: Is There A BalloonTip Component In Java?
Posted: Oct 5, 2006 9:39 AM   in response to: leouser
  Click to reply to this thread Reply

True. That's why I'm thinking the api needs to have levels that the
developer can query at runtime.

if (TFrame.isAlphaChannelSupported()) {
TFrame.setAlphaChannel(bufferedImage);
} else if (TFrame.isShapeSupported()) {
TFrame.setShape(shape);
} else if (TFrame.isTransparencySupported()) {
TFrame.setTransparency(0.5f);
} else {
System.out.println("sorry dude!");
}

:)
- J

On Oct 5, 2006, at 7:27 AM, swing@javadesktop.org wrote:

> When the Composite extension becomes a reality, this may no longer
> be true for X:
> http://webcvs.freedesktop.org/xlibs/CompositeExt/protocol?view=markup
>
> But again, this is probably going to be an option only for really
> new X implementations.
>
> BH
> [Message sent by forum member 'leouser' (leouser)]
>
> http://forums.java.net/jive/thread.jspa?messageID=160213

- Blasting forth in three part harmony!


[att1.html]


Joshua Marinacci
Re: Is There A BalloonTip Component In Java?
Posted: Oct 5, 2006 9:42 AM   in response to: Anthony Petrov
  Click to reply to this thread Reply

It's true that you need a full compositing window manager for
translucency of child windows (as OS X) but it's coming for Vista and
new versions of X. However, I don't this that transparent child
windows is the problem we are trying to solve here. Swing apps can
already make translucent and shaped internal frames and buttons/
labels/etc. The beauty of lightweight components is that we can
already do whatever we want with Java2D. It's the shaped frames, not
heavyweight internal components, that are the real concern right now
for most app developers. I'd rather build something that works but
doesn't cover every use case than wait for the perfect solution.

- J


On Oct 5, 2006, at 12:22 AM, Anthony Petrov wrote:

> Hi folks,
>
> Sounds great, excellent, cool... apart from one tiny thing: neither
> Windows nor X support translucency for child windows. These systems
> support this stuff for top-levels only (I'm not sure about MacOSX
> though).
> Now imagine one valuable point in JDK development - the support of
> mixing of HW and LW components (the feature is planned and will
> probably be available in JDK 7). LW components will paint
> themselves as expected - with fancy translucent effects and all
> that cool stuff. And what about HW components? What are your
> thoughts on supporting mixing for LW components with translucency
> enabled?
>
> On 10/05/2006 12:11 AM Joshua Marinacci wrote:
>> I discussed this with Chris Campbell at lunch today. We decided
>> that in the end you need both shape and image based apis, because
>> some platforms will support one and not the other. Plus some might
>> be faster than the other. You might also want to just set an
>> alpha value on the window as a whole. Thus you would need three
>> set methods plus three isSupported methods. It's not perfect but
>> it's the only way to cover everything and it gives the developer
>> the power to do what they want.
>> On transparency vs translucency. One thing to try is if the alpha
>> = 0 then the window really shouldn't be in that spot and it should
>> allow the mouse events to go thorough. If it's anything but 0,
>> even just 1 out of 255, then it should capture mouse events. As an
>> interesting side effect, since an alpha of 1 will visually look
>> the same as an alpha of 0, you could use to create a screen wide
>> glasspane to do cool things like a magnifying glass, drawing on
>> the whole screen, color selection on single click, etc.
>> - Josh
>> On Oct 3, 2006, at 6:44 PM, swing@javadesktop.org
>> <mailto:swing@javadesktop.org> wrote:
>>> Hmm, Ill focus on making it a JDIC(if I make it further) project
>>> and skip it as collab submission. If I get far enough Ill ping
>>> you Josh about collaborating with this Mac dude(ss). This is
>>> pretty interesting stuff, so its worth investigating just for its
>>> own sake. Im not sure how far back it can be taken, maybe Java 5
>>> is as deep as it could go on the X side. The reason I say this
>>> is that I believe the X classes Im currently working with sprung
>>> into existence in Java 5, maybe Im misguided about this. I have
>>> no idea what the API was before that.
>>>
>>> I hope XP has simple support for this. I took Windows Media
>>> Player today and made it assume this very odd shape. That is a
>>> positive sign.
>>>
>>> Im uncertain as to the best API for this. Maybe a static method
>>> that would take a Window and a GeneralPath:
>>> public static void shapeWindow(Window w, GeneralPath shape);
>>>
>>> probably would want to do an image based shape to if that was
>>> supported on all platforms:
>>> public static void shapeWindow(Window w, Image image);
>>>
>>> Im going to need to get a firm grasp on the Pixmap based shaping
>>> in X. I was doing some experimentation yesterday with it and the
>>> results were not quite what I was shooting for. Instead of a
>>> snowman shape I had 4-6 unconnected sharp triangles for a shape.
>>> If you clicked on one of the triangles it made the button click,
>>> if you clicked on the spaces between the triangles it did nothing
>>> but go to the entity behind it. That was semi-exciting stuff,
>>> but not what I was shooting for.
>>>
>>> I almost think you need to keep transparency and translucency in
>>> separate categories. The transparency Im experimenting with
>>> appears to be an all or nothing game. The window either exists
>>> in a place or it doesn't. Contrast this with the "Allow
>>> JComponents to be translucent" patch I did a little while back.
>>> You could make the component transparent but it did not stop it
>>> from eating MouseEvents and such. It was there regardless of the
>>> fact if you were aware of it or not.
>>>
>>> BH
>>> [Message sent by forum member 'leouser' (leouser)]
>>>
>>> http://forums.java.net/jive/thread.jspa?messageID=159527
>> - Blasting forth in three part harmony!
>
> --
> best regards,
> Anthony

- Blasting forth in three part harmony!


[att1.html]


Joshua Marinacci
Re: Is There A BalloonTip Component In Java?
Posted: Oct 5, 2006 9:43 AM   in response to: Anthony Petrov
  Click to reply to this thread Reply

It's true that you need a full compositing window manager for
translucency of child windows (as OS X) but it's coming for Vista and
new versions of X. However, I don't this that transparent child
windows is the problem we are trying to solve here. Swing apps can
already make translucent and shaped internal frames and buttons/
labels/etc. The beauty of lightweight components is that we can
already do whatever we want with Java2D. It's the shaped frames, not
heavyweight internal components, that are the real concern right now
for most app developers. I'd rather build something that works but
doesn't cover every use case than wait for the perfect solution.

- J


On Oct 5, 2006, at 12:22 AM, Anthony Petrov wrote:

> Hi folks,
>
> Sounds great, excellent, cool... apart from one tiny thing: neither
> Windows nor X support translucency for child windows. These systems
> support this stuff for top-levels only (I'm not sure about MacOSX
> though).
> Now imagine one valuable point in JDK development - the support of
> mixing of HW and LW components (the feature is planned and will
> probably be available in JDK 7). LW components will paint
> themselves as expected - with fancy translucent effects and all
> that cool stuff. And what about HW components? What are your
> thoughts on supporting mixing for LW components with translucency
> enabled?
>
> On 10/05/2006 12:11 AM Joshua Marinacci wrote:
>> I discussed this with Chris Campbell at lunch today. We decided
>> that in the end you need both shape and image based apis, because
>> some platforms will support one and not the other. Plus some might
>> be faster than the other. You might also want to just set an
>> alpha value on the window as a whole. Thus you would need three
>> set methods plus three isSupported methods. It's not perfect but
>> it's the only way to cover everything and it gives the developer
>> the power to do what they want.
>> On transparency vs translucency. One thing to try is if the alpha
>> = 0 then the window really shouldn't be in that spot and it should
>> allow the mouse events to go thorough. If it's anything but 0,
>> even just 1 out of 255, then it should capture mouse events. As an
>> interesting side effect, since an alpha of 1 will visually look
>> the same as an alpha of 0, you could use to create a screen wide
>> glasspane to do cool things like a magnifying glass, drawing on
>> the whole screen, color selection on single click, etc.
>> - Josh
>> On Oct 3, 2006, at 6:44 PM, swing@javadesktop.org
>> <mailto:swing@javadesktop.org> wrote:
>>> Hmm, Ill focus on making it a JDIC(if I make it further) project
>>> and skip it as collab submission. If I get far enough Ill ping
>>> you Josh about collaborating with this Mac dude(ss). This is
>>> pretty interesting stuff, so its worth investigating just for its
>>> own sake. Im not sure how far back it can be taken, maybe Java 5
>>> is as deep as it could go on the X side. The reason I say this
>>> is that I believe the X classes Im currently working with sprung
>>> into existence in Java 5, maybe Im misguided about this. I have
>>> no idea what the API was before that.
>>>
>>> I hope XP has simple support for this. I took Windows Media
>>> Player today and made it assume this very odd shape. That is a
>>> positive sign.
>>>
>>> Im uncertain as to the best API for this. Maybe a static method
>>> that would take a Window and a GeneralPath:
>>> public static void shapeWindow(Window w, GeneralPath shape);
>>>
>>> probably would want to do an image based shape to if that was
>>> supported on all platforms:
>>> public static void shapeWindow(Window w, Image image);
>>>
>>> Im going to need to get a firm grasp on the Pixmap based shaping
>>> in X. I was doing some experimentation yesterday with it and the
>>> results were not quite what I was shooting for. Instead of a
>>> snowman shape I had 4-6 unconnected sharp triangles for a shape.
>>> If you clicked on one of the triangles it made the button click,
>>> if you clicked on the spaces between the triangles it did nothing
>>> but go to the entity behind it. That was semi-exciting stuff,
>>> but not what I was shooting for.
>>>
>>> I almost think you need to keep transparency and translucency in
>>> separate categories. The transparency Im experimenting with
>>> appears to be an all or nothing game. The window either exists
>>> in a place or it doesn't. Contrast this with the "Allow
>>> JComponents to be translucent" patch I did a little while back.
>>> You could make the component transparent but it did not stop it
>>> from eating MouseEvents and such. It was there regardless of the
>>> fact if you were aware of it or not.
>>>
>>> BH
>>> [Message sent by forum member 'leouser' (leouser)]
>>>
>>> http://forums.java.net/jive/thread.jspa?messageID=159527
>> - Blasting forth in three part harmony!
>
> --
> best regards,
> Anthony

- Blasting forth in three part harmony!


[att1.html]


oleg_sukhodolsky

Posts: 87
Re: Is There A BalloonTip Component In Java?
Posted: Oct 5, 2006 10:06 AM   in response to: Joshua Marinacci
  Click to reply to this thread Reply

But you will never be able to integrate native components (such as AxtiveX) into such Swing application :(just to remind you that everything has its own price ;)

Joshua Marinacci
Re: Is There A BalloonTip Component In Java?
Posted: Oct 5, 2006 10:16 AM   in response to: oleg_sukhodolsky
  Click to reply to this thread Reply

Quite true, but I can't do that now either (at least not without a
commercial 3rd party library). I think it's a fair tradeoff for now.
Most apps which would like to use shaped windows don't need
heavyweight components. For the version that goes in Java 7 we would
need solve the problem completely, but this would let a lot of people
build cool looking apps right now. In fact, I suspect we will learn a
lot from this effort that can be applied to Java 7.

- Josh


On Oct 5, 2006, at 10:06 AM, swing@javadesktop.org wrote:

> But you will never be able to integrate native components (such as
> AxtiveX) into such Swing application :(just to remind you that
> everything has its own price ;)
> [Message sent by forum member 'oleg_sukhodolsky' (oleg_sukhodolsky)]
>
> http://forums.java.net/jive/thread.jspa?messageID=160326

- Blasting forth in three part harmony!


[att1.html]


rbair

Posts: 1,830
Re: Is There A BalloonTip Component In Java?
Posted: Oct 5, 2006 10:27 AM   in response to: Joshua Marinacci
  Click to reply to this thread Reply

I'm sorry, I missed it. Why can't you integrate ActiveX (or any other heavyweight components)? It seems like you can, with certain restrictions:
* Obviously, don't overlap a lightweight component on a heavyweight component
* Don't expect the heavyweight to be translucent
* Don't let the heavyweight extend beyond the visual bounds of the lightweight parent

There may be one or two more that I'm missing, but it seems like even with a half-way solution you could support shaped windows with embedded heavyweight components which don't extend beyond the bounds of the painted region.

I could be wrong, I only got 4 hours sleep last night :-)

Richard


> Quite true, but I can't do that now either (at least
> not without a
> commercial 3rd party library). I think it's a fair
> tradeoff for now.
> Most apps which would like to use shaped windows
> don't need
> heavyweight components. For the version that goes in
> Java 7 we would
> need solve the problem completely, but this would let
> a lot of people
> build cool looking apps right now. In fact, I suspect
> we will learn a
> lot from this effort that can be applied to Java 7.
>
> - Josh
>
>
> On Oct 5, 2006, at 10:06 AM, swing@javadesktop.org
> wrote:
>
> > But you will never be able to integrate native
> components (such as
> > AxtiveX) into such Swing application :(just to
> remind you that
> > everything has its own price ;)
> > [Message sent by forum member 'oleg_sukhodolsky'
> (oleg_sukhodolsky)]
> >
> >
> http://forums.java.net/jive/thread.jspa?messageID=1603
> 26
>
> - Blasting forth in three part harmony!
>
>
> [att1.html]

Joshua Marinacci
Re: Is There A BalloonTip Component In Java?
Posted: Oct 5, 2006 11:38 AM   in response to: rbair
  Click to reply to this thread Reply

We certainly could, it just won't be foolproof. I don't think concerns
about heavyweight components should hold back this implementation,
however. That's all I'm saying. We should press ahead with shaped
windows even if it won't work in all cases. (provided we document those
cases very well! :)

- J


swing@javadesktop.org wrote:
> I'm sorry, I missed it. Why can't you integrate ActiveX (or any other heavyweight components)? It seems like you can, with certain restrictions:
> * Obviously, don't overlap a lightweight component on a heavyweight component
> * Don't expect the heavyweight to be translucent
> * Don't let the heavyweight extend beyond the visual bounds of the lightweight parent
>
> There may be one or two more that I'm missing, but it seems like even with a half-way solution you could support shaped windows with embedded heavyweight components which don't extend beyond the bounds of the painted region.
>
> I could be wrong, I only got 4 hours sleep last night :-)
>
> Richard
>
>
>
>>Quite true, but I can't do that now either (at least
>>not without a
>>commercial 3rd party library). I think it's a fair
>>tradeoff for now.
>>Most apps which would like to use shaped windows
>>don't need
>>heavyweight components. For the version that goes in
>>Java 7 we would
>>need solve the problem completely, but this would let
>>a lot of people
>>build cool looking apps right now. In fact, I suspect
>>we will learn a
>>lot from this effort that can be applied to Java 7.
>>
>>- Josh
>>
>>
>>On Oct 5, 2006, at 10:06 AM, swing@javadesktop.org
>>wrote:
>>
>>
>>>But you will never be able to integrate native
>>
>>components (such as
>>
>>>AxtiveX) into such Swing application :(just to
>>
>>remind you that
>>
>>>everything has its own price ;)
>>>[Message sent by forum member 'oleg_sukhodolsky'
>>
>>(oleg_sukhodolsky)]
>>
>>>
>>http://forums.java.net/jive/thread.jspa?messageID=1603
>>26
>>
>>- Blasting forth in three part harmony!
>>
>>
>>[att1.html]
>
> [Message sent by forum member 'rbair' (rbair)]
>
> http://forums.java.net/jive/thread.jspa?messageID=160345


oleg_sukhodolsky

Posts: 87
Re: Is There A BalloonTip Component In Java?
Posted: Oct 5, 2006 12:15 PM   in response to: rbair
  Click to reply to this thread Reply

> * Obviously, don't overlap a lightweight component on a heavyweight component

It would be nice if it would be acceptable :( This means no menus, not internal frames, no glasspanes.

As for my previous post I meant that it would be very hard
(most likely impossible) to implement real mixing in case of
translucent lightweigh (if you allow them to overlap heavyweights)

Joshua Marinacci
Re: Is There A BalloonTip Component In Java?
Posted: Oct 5, 2006 12:52 PM   in response to: oleg_sukhodolsky
  Click to reply to this thread Reply



swing@javadesktop.org wrote:
>>* Obviously, don't overlap a lightweight component on a heavyweight component
>
>
> It would be nice if it would be acceptable :( This means no menus, not internal frames, no glasspanes.

Why would it mean no menus, internal frames, or glasspanes? Aren't
glasspanes and internal frames lightweight components. The menus will
probably be heavyweight which means they will be in their own top level
windows and thus be outside the shaped window, which seems like the
right behavior.

- Josh

>
> As for my previous post I meant that it would be very hard
> (most likely impossible) to implement real mixing in case of
> translucent lightweigh (if you allow them to overlap heavyweights)
> [Message sent by forum member 'oleg_sukhodolsky' (oleg_sukhodolsky)]
>
> http://forums.java.net/jive/thread.jspa?messageID=160405


oleg_sukhodolsky

Posts: 87
Re: Is There A BalloonTip Component In Java?
Posted: Oct 6, 2006 1:21 AM   in response to: Joshua Marinacci
  Click to reply to this thread Reply

Hi Josh,

I meant that we will have problems with mixing heavyweights and translucent lightweight components.

Thanks, Oleg.

leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 5, 2006 4:37 PM   in response to: oleg_sukhodolsky
  Click to reply to this thread Reply

Ive made some progress beyond the triangle madness problem and have successfully created a JWindow/JButton that looks like a snowman.

https://www.dev.java.net/files/forums/2899/1463/1439/jbuttonSnowman.png

maybe Ill do a cat tomorrow. :)
BH

Anthony Petrov
Re: Is There A BalloonTip Component In Java?
Posted: Oct 6, 2006 1:43 AM   in response to: Joshua Marinacci
  Click to reply to this thread Reply


On 10/05/2006 09:16 PM Joshua Marinacci wrote:
> Quite true, but I can't do that now either (at least not without a
> commercial 3rd party library). I think it's a fair tradeoff for now.
> Most apps which would like to use shaped windows don't need heavyweight
> components.
I'm not sure you are quite correct here. The "most apps which would like
to use shaped windows" are media players, aren't they? I could think of
a shaped Java media player using an Active X control embedded, and this
ActiveX control would actually show a movie or play some music, etc. :)

Anyway, shaped *toplevels* do NOT actually bring any problems with
neither translucency nor mixing. So I don't catch your point here.


--
best regards,
Anthony


leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 6, 2006 7:09 AM   in response to: Anthony Petrov
  Click to reply to this thread Reply

don't forget exciting applications like xeyes and xclock. With shaped windows we will be able to do these highly useful applications in Java.

BH

leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 6, 2006 7:11 AM   in response to: leouser
  Click to reply to this thread Reply

It appears that the Shape based shaping of Windows is now working:
https://www.dev.java.net/files/forums/2899/1463/1442/shapeGPWindow.png

This one was produced by using a Path2D.Float instance.

BH

swpalmer

Posts: 244
Re: Is There A BalloonTip Component In Java?
Posted: Oct 6, 2006 7:28 AM   in response to: leouser
  Click to reply to this thread Reply

I got to this thread through a link on the java.net home page. Great to see stuff happening in this area.

But, how do I see those linked images without getting:

"Your account does not have the "Project Forum - View" permission needed for you to access the page you requested in the jdk-collaboration project (view your permissions). Either ask the project administrator for more permission, or log in using a different account."

I don't even know what "project" it's talking about :)

leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 6, 2006 7:34 AM   in response to: swpalmer
  Click to reply to this thread Reply

I tossed the images up over in the collaboration forum since I don't have a good way of just posting these images here. If someone has a better place for me to toss these things, Im all ears. :)

BH

leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 6, 2006 9:24 AM   in response to: leouser
  Click to reply to this thread Reply

Component shaping appears to be working as well:
https://www.dev.java.net/files/forums/2899/1463/1443/shapedAWTComponent.png

This is a Window with a Button in it. The Button has been shaped by the same Path2D.Float instance that I used to shape the last screen shot of the Window.

I believe Ive successfully removed any dependencies on non-public methods in the X11 classes. In cases where the functionality could not be called without using reflection to break the access controls Ive replicated the functionality that does the work. Usually it isn't too horrible since some of the methods are just wrappers around one line statements to an X call. The largest copy so far has been this handy piece of code that transforms a BufferedImage into a byte array that is in XBM format. I had to do some research into what the XBM format is to understand what was happening but it looks and behaves fine.

It will be interesting to see if the other platforms support some form of image based shaping. I think its very plausable that if the platform supports image shaping than it should be able to easily support Shape shaping. X only supports rectangles but the code paints the shape in a BuffereImage and then transforms it into XBM.

BH

leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 6, 2006 9:55 AM   in response to: leouser
  Click to reply to this thread Reply

Im going to guess that doing Shaped lightweights isn't just going to entail dealing with the drawing of the widgets. Its also going to have to deal with how MouseEvents are dispatched. Which means, I think, that the LightweightDispatcher will have to be enhanced to do deal with irregular shapes. Another question would be if utility methods like getDeepestComponentAt should be modified to take into account the non-rectangular?

BH

Richard Bair
Re: Is There A BalloonTip Component In Java?
Posted: Oct 6, 2006 8:38 AM   in response to: leouser
  Click to reply to this thread Reply

Cool!

What was the decision about doing this in JDIC or something like that
--- is it possible? Or does it require changes in core?

Richard

On Oct 6, 2006, at 7:11 AM, swing@javadesktop.org wrote:

> It appears that the Shape based shaping of Windows is now working:
> https://www.dev.java.net/files/forums/2899/1463/1442/shapeGPWindow.png
>
> This one was produced by using a Path2D.Float instance.
>
> BH
> [Message sent by forum member 'leouser' (leouser)]
>
> http://forums.java.net/jive/thread.jspa?messageID=160627


leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 6, 2006 10:01 AM   in response to: Richard Bair
  Click to reply to this thread Reply

'Cool!

What was the decision about doing this in JDIC or something like that
--- is it possible? Or does it require changes in core?

Richard

On Oct 6, 2006, at 7:11 AM, swing@javadesktop.org wrote:

> It appears that the Shape based shaping of Windows is now working:
> https://www.dev.java.net/files/forums/2899/1463/1442/shapeGPWindow.png
>
> This one was produced by using a Path2D.Float instance.
>
> BH
> [Message sent by forum member 'leouser' (leouser)]
>
> http://forums.java.net/jive/thread.jspa?messageID=160627'

I must have missed this post! Yes, we are at a stage where I believe on the X side we can dispense with having to meddle with what already exists. I can't vouch for Windows or Mac or whatever but it appears that the machinery just works on X. :)

for the Shape API, the method looks something like this:
public static void shapeComponent(Component c, Shape s, int x, int y);

where c, is the Component
s is the Shape
x and y are the coordinates within the Bounds of the Component where it should be placed. Just imagine a BufferedImage with the same dimensions as the Component and a graphics call fill(s), where the origin has been translated to x and y. The resulting fill gives you the shape.

BH

leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 6, 2006 10:41 AM   in response to: leouser
  Click to reply to this thread Reply

For Windows, I think the method to call would be
SetWindowRegion which requires a pointer to the Window in question. This may be a long in WObjectPeer which has the descriptive comment of:
// The Windows handle for the native widget.

thankfully there looks like there is a public method to get this information.

BH

Richard Bair
Re: Is There A BalloonTip Component In Java?
Posted: Oct 6, 2006 11:46 AM   in response to: leouser
  Click to reply to this thread Reply

Coool. Next question: when can I run this code on my desktop :-)
(without going through the jdk project process).

Richard


On Oct 6, 2006, at 10:41 AM, swing@javadesktop.org wrote:

> For Windows, I think the method to call would be
> SetWindowRegion which requires a pointer to the Window in
> question. This may be a long in WObjectPeer which has the
> descriptive comment of:
> // The Windows handle for the native widget.
>
> thankfully there looks like there is a public method to get this
> information.
>
> BH
> [Message sent by forum member 'leouser' (leouser)]
>
> http://forums.java.net/jive/thread.jspa?messageID=160765


leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 6, 2006 12:04 PM   in response to: Richard Bair
  Click to reply to this thread Reply

Well, I can toss it up on the same collab forum thread that Im using for screenshots. How does that sound? You do have access to a *Nix don't you? It actually isn't that much code so far.

Im going to see how far I get with the Windows side of things next. Im getting Cygwin set up and it sounds like you can make JNI stuff and run it without having to refer to Cygwin.

BH

leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 6, 2006 1:07 PM   in response to: leouser
  Click to reply to this thread Reply

Ive tossed the src up here:
https://jdk-collaboration.dev.java.net/servlets/ProjectForumMessageView?messageID=15912&forumID=1463

Ive been using C++ but it should be simple to just use C for this. Also, Ive been using a function I believe is internal to the JVM and not part of the jni interface: jlong_to_ptr.

BH

leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 7, 2006 3:25 PM   in response to: leouser
  Click to reply to this thread Reply

'For Windows, I think the method to call would be
SetWindowRegion which requires a pointer to the Window in question. This may be a long in WObjectPeer which has the descriptive comment of:
// The Windows handle for the native widget.

thankfully there looks like there is a public method to get this information.

BH '

Almost but not quite, WWindowPeer holds a pointer, WObjectPeer we can't reference because it is package private. SetWindowRgn appears to be the method. After trying to mess around with MFC stuff(and realising that this stuff doesn't come with the Express version of C++) I focused on using GDI instead. At this point Im able to create a elliptical window or JFrame on Windows. There is definately a difference between how Frames are handled on X as opposed to Windows. On X, I think the frame decorations surround the shaped window. So you have a toolbar. On Windows it appears that the decorations are shaped as well, meaning that the top bar is visible but missing pieces of itself.

Im not sure if the Windows api supports shaping via images at this level, Ill have to do some research into it. If not, we will have to see if we can extract geometry from images.

BH

leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 9, 2006 11:09 AM   in response to: leouser
  Click to reply to this thread Reply

Things are going Ok on the Windows side. The code almost seems there... it should be able to support images and shapes. The big problem now seems to be that the shapes are inverted. This is ok for circles and rectangles but not good with Path2D instances.

It also looks like holes in the shape will be accepted. I just did a test where I had an image of the outline of a rectangle used as the shaping data and it gave me the outline of a rectangle as the window.

BH

leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 9, 2006 11:15 AM   in response to: leouser
  Click to reply to this thread Reply

allright, I guess I fixed the problem 2 seconds after I wrote the last post. :) My Path2D test appears to be working fine now. I guess the next step will be to create an API that is the same as the X side of things. After that, the focus should be on:
1. Having one API, the implementation will be hidden behind the scenes.

It will be interesting to see how well things are supported on X. I believe the Shape API has been in existence since 1988, so it has been a long time for X implementations to implement it.

BH

Joshua Marinacci
Re: Is There A BalloonTip Component In Java?
Posted: Oct 9, 2006 11:33 AM   in response to: leouser
  Click to reply to this thread Reply

That sounds great. I've been thinking that the API should support
two fallbacks as well.

On the Mac we can get a shaped window by setting the bg color of the
frame to 0,0,0,0. Then you can draw whatever you want. It doesn't
work perfectly all the time and sometimes has issues with shadows,
but it's a good fallback until we get the JNI version on Mac working.

We could also have a general fallback for cases where the other
versions fail, say because you are using the wrong version of java or
the libs can't be found or the platform isn't supported. In this case
we could do the screenshot hack to fake a shaped window.

This would let developers ship on all platforms with a reasonable
default when things go wrong.

This is shaping up to be a great project. I can't wait to try it out.
Thanks,
Josh

On Oct 9, 2006, at 11:15 AM, swing@javadesktop.org wrote:

> allright, I guess I fixed the problem 2 seconds after I wrote the
> last post. :) My Path2D test appears to be working fine now. I
> guess the next step will be to create an API that is the same as
> the X side of things. After that, the focus should be on:
> 1. Having one API, the implementation will be hidden behind the
> scenes.
>
> It will be interesting to see how well things are supported on X.
> I believe the Shape API has been in existence since 1988, so it has
> been a long time for X implementations to implement it.
>
> BH
> [Message sent by forum member 'leouser' (leouser)]
>
> http://forums.java.net/jive/thread.jspa?messageID=161255

- Blasting forth in three part harmony!


[att1.html]


leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 9, 2006 11:42 AM   in response to: Joshua Marinacci
  Click to reply to this thread Reply

Do you know if Mac ships with the source of its Peer implementations? Im trying to guess how hard it will be for someone to develop this on the Mac side.

BH

leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 9, 2006 1:13 PM   in response to: leouser
  Click to reply to this thread Reply

Ive put up the Windows src here:
https://jdk-collaboration.dev.java.net/servlets/ProjectForumMessageView?messageID=16005&forumID=1463

Its essentially the same API as the X API, they just don't have a common interface between them.

Further testing has shown that the Windows shaping api supports shaping Buttons and such as well. So we appear to be able to do the same things on X as on Windows, which is good. :)

BH

Joshua Marinacci
Re: Is There A BalloonTip Component In Java?
Posted: Oct 9, 2006 1:21 PM   in response to: leouser
  Click to reply to this thread Reply

I don't know but I'll find out.
- Josh

On Oct 9, 2006, at 11:42 AM, swing@javadesktop.org wrote:

> Do you know if Mac ships with the source of its Peer
> implementations? Im trying to guess how hard it will be for
> someone to develop this on the Mac side.
>
> BH
> [Message sent by forum member 'leouser' (leouser)]
>
> http://forums.java.net/jive/thread.jspa?messageID=161271

- Blasting forth in three part harmony!


[att1.html]


leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 10, 2006 11:08 AM   in response to: Joshua Marinacci
  Click to reply to this thread Reply

aha, it appears Ive ran into a monkey wrench. The X implementation uses the sun.misc.Unsafe class, but if we try to load it without the Shaping class on the bootclasspath, we get a SecurityException. I may have to replicate the functionality or find an instance of Unsafe in the X classes and use that.

Loading of the class may work this way:
1. User calls a static factory method to acquire the "ComponentShaper" instance.
2. The factory returns the Singleton instance or it loads it and then returns it.
3. Loading happens by loading the library identified by the environment variable COMPONENT_SHAPER, maybe it should be SHAPER_PATH. Then the factory method queries a static native method that is also implemented by the library. This returns the java class name that is associated with the libarary. This in turn results in the implementation being created.

BH

leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 10, 2006 11:52 AM   in response to: leouser
  Click to reply to this thread Reply

allright, it appears we don't have to rely upon the Unsafe class after all. I switched the byte sticking code over to a direct ByteBuffer and everything appears ok again. :)
Thankfully JNI has some functions to deal with direct ByteBuffers.

BH

leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 10, 2006 1:06 PM   in response to: leouser
  Click to reply to this thread Reply

Ive got the initial unification of the various implementations posted here:
https://jdk-collaboration.dev.java.net/servlets/ProjectForumMessageView?messageID=16034&forumID=1463

The X implementation no longer needs jlong.h, so the user should be able to compile without digging around in the Java source looking for the various headers.

The class is called ComponentShaper for now and until a better name becomes apparent. The package is org.component.shaper until there is some decision if it should be a JDIC project or something else entirely.

BH

leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 11, 2006 9:18 AM   in response to: leouser
  Click to reply to this thread Reply

cool, at least on the X side, and I suspect on the Windows side as well, you can change the shape over time. So if you had an application that wanted to do animations with the toplevel's shape it should be possible. I don't know what application that would be, I think Ive seen media players that allow the user to morph the shape of application but that isn't what Id call animation. Maybe this would help people develop toy programs like a dancing mouse moving around the users screen?

BH

Joshua Marinacci
Re: Is There A BalloonTip Component In Java?
Posted: Oct 11, 2006 9:35 AM   in response to: leouser
  Click to reply to this thread Reply

I'm sure we can think of some cool things to do with morphing windows.

What about a rotating cube window. Or a OSX Dashboard like overlay
window that zooms in. Or windows that have a StarTrek The Next
Generation stretch into warp drive effect when they are closed?
Trust me, we'll find something to do with it. :)

- J

On Oct 11, 2006, at 9:18 AM, swing@javadesktop.org wrote:

> cool, at least on the X side, and I suspect on the Windows side as
> well, you can change the shape over time. So if you had an
> application that wanted to do animations with the toplevel's shape
> it should be possible. I don't know what application that would
> be, I think Ive seen media players that allow the user to morph the
> shape of application but that isn't what Id call animation. Maybe
> this would help people develop toy programs like a dancing mouse
> moving around the users screen?
>
> BH
> [Message sent by forum member 'leouser' (leouser)]
>
> http://forums.java.net/jive/thread.jspa?messageID=162019

- Blasting forth in three part harmony!


[att1.html]


Joshua Marinacci
Re: Is There A BalloonTip Component In Java?
Posted: Oct 11, 2006 11:17 AM   in response to: Joshua Marinacci
  Click to reply to this thread Reply

I just got a message back from Scott at Apple on the OSX stuff:

On Oct 9, 2006, at 4:25 PM, Joshua Marinacci wrote:
Hi Scott. A developer working on the open JDK (leouser, the guy who
fixed all the bugs and came on stage at last May's JavaOne) has
started working on shaped / translucent windows for Frame. He has a
version working for Windows and X using JNI hooks. He would like to
know if the source to Apple's AWT peers is available anywhere so he
could do the same thing on Mac.

Check out this example code:

http://developer.apple.com/samplecode/RoundTransparentWindow/index.html

I believe what you're basically doing is creating a clear window that
has a view in the shape you want.

Scott


On Oct 11, 2006, at 9:35 AM, Joshua Marinacci wrote:

> I'm sure we can think of some cool things to do with morphing windows.
>
> What about a rotating cube window. Or a OSX Dashboard like overlay
> window that zooms in. Or windows that have a StarTrek The Next
> Generation stretch into warp drive effect when they are closed?
> Trust me, we'll find something to do with it. :)
>
> - J
>
> On Oct 11, 2006, at 9:18 AM, swing@javadesktop.org wrote:
>
>> cool, at least on the X side, and I suspect on the Windows side as
>> well, you can change the shape over time. So if you had an
>> application that wanted to do animations with the toplevel's shape
>> it should be possible. I don't know what application that would
>> be, I think Ive seen media players that allow the user to morph
>> the shape of application but that isn't what Id call animation.
>> Maybe this would help people develop toy programs like a dancing
>> mouse moving around the users screen?
>>
>> BH
>> [Message sent by forum member 'leouser' (leouser)]
>>
>> http://forums.java.net/jive/thread.jspa?messageID=162019
>
> - Blasting forth in three part harmony!
>
>

- Blasting forth in three part harmony!


[att1.html]


[Edited by: invalidname]

leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 11, 2006 1:21 PM   in response to: Joshua Marinacci
  Click to reply to this thread Reply

Ive got a couple of new API methods in place:
1. clearComponentsShaping that allows you to turn off shaping of a Component.

2. isShaped, which returns true if the Component is shaped. Im not sure if it should just do this or return an enum:
None
Shape
Image

Im also thinking of adding a method that returns the current Object that shaped the Component. Maybe:
Object getShaper(Component c);

I guess this one hinges on how useful it would be to the developer to be able to query for the shape. It gets rid of the need to track what was the shaper on the devlopers side and it probably won't be that hard to put together.

BH

leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 12, 2006 12:14 PM   in response to: leouser
  Click to reply to this thread Reply

Well, it looks like we can use this in Java 5 but it requires some modifications. The problem appears to be that the SunToolkit does not have a public awtLock/awtUnlock set of methods, they appear to be private in some way. Without these methods things do not work. We can overcome this with reflection but that in turn will make the code a little harder to use. The user may have put a SecurityManager in place that will guard against the access violations that reflection is doing. Im going to see if I can get this to run against the Motif peers next. If that's successful we may be able to go back to Java 4, but that would be a very lucky circumstance.

BH

leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 12, 2006 5:34 PM   in response to: leouser
  Click to reply to this thread Reply

I believe we have the Motif toolkit peers working now. So the user will be able to shape their windows regardless of whether or not X or Motif is used. Im able to take this back to Java 5. Ive tried working with this on a Java 4 but their is some problem loading the native code, don't know what.

BH

leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 13, 2006 8:06 AM   in response to: leouser
  Click to reply to this thread Reply

Hmm, I guess we may not have to resort to reflection after all. It appears that in JNI you can access private or package private methods. Not sure if its a good thing that you can do this but you can.

BH

leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 13, 2006 11:04 AM   in response to: leouser
  Click to reply to this thread Reply

applying this original question to the ComponentShaper, Ive been able to create a primitive Balloon with a JToolTip. I just watched in the JToolTip for the addNotify to be invoked and I shaped the toplevel. With my feeble balloon image I drew it gave an Ok(well...) balloon shape for the tip.

BH

joshy

Posts: 90
Re: Is There A BalloonTip Component In Java?
Posted: Oct 13, 2006 10:46 PM   in response to: leouser
  Click to reply to this thread Reply

I wouldn't worry about going back to Java 1.4. Java 5 has become our baseline for all new applications. Navigating the differences between 5 and 6 is doable, but Java 1.4 is just missing so much.

leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 19, 2006 6:37 PM   in response to: joshy
  Click to reply to this thread Reply

hmmm, it looks like we may be able to do translucent windows on Windows. Ive been reading about some styles you can set on a particular window to make it see through and also click through. Id like to just make it see through, though maybe someone would want click through as well. From what I gather this capability is from Windows 2000 onward. Ill have to try it out tomorrow. :)

Maybe if Im successful the name can be changed to ComponentTransmorgifier. That doesn't sound very good does it?

BH

Anthony Petrov
Re: Is There A BalloonTip Component In Java?
Posted: Oct 19, 2006 11:43 PM   in response to: leouser
  Click to reply to this thread Reply

Hi,

That's right. Windows (as well as X) allows you to make translucent
windows... but toplevels only :( You're not able to make a child window
a translucent one. This, IMO, is a terrible limitation in Windows/X API.

Look at SetLayeredWindowAttributes/UpdateLayeredWindow Win API functions
for more information.

--
best regards,
Anthony


leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 20, 2006 6:51 AM   in response to: Anthony Petrov
  Click to reply to this thread Reply

yes,

that sounds right. Im going to look at the Windows calls next. X it appears supports "pseudo transparency", which apparently means that when you make a new X Window you can set its background image to be what is rendered on the root X Window. That's ok but Id rather have a layered effect. I believe to get the layered effect the Composite extension must be used. Im going to have to get my X installation updated to include this and try to build transparency with that. It isn't just the Composite that needs to be there but also the Damage and the Render extensions, I believe. From what I gather you can do this in an isolated program or as part of a bunch of programs that are working with a composite manager.

BH

Anthony Petrov
Re: Is There A BalloonTip Component In Java?
Posted: Oct 20, 2006 7:28 AM   in response to: leouser
  Click to reply to this thread Reply

That's right,

you may take a look at xcompmgr source to get an idea on setting
transparency level for the whole window. After that, take a look at this
thread: http://people.freedesktop.org/~pasc/xorg/msg04644.html
It seems very interesting, though I wasn't able to get it work... Will you?

--
best regards,
Anthony


leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 20, 2006 8:28 AM   in response to: Anthony Petrov
  Click to reply to this thread Reply

Hmm, Ive kind of got this working on Windows. Though the monkey wrench so far appears that it does not play nicely with Swing so far. I keep on getting these images painted permanently to my screen, which is not what we want at all. It does seem to work okay-dokey with the natives though.

BH

oleg_sukhodolsky

Posts: 87
Re: Is There A BalloonTip Component In Java?
Posted: Oct 20, 2006 8:38 AM   in response to: leouser
  Click to reply to this thread Reply

I think you need to disable direct draw to have better results.

leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 20, 2006 9:04 AM   in response to: oleg_sukhodolsky
  Click to reply to this thread Reply

yes, that appears to change things quite dramatically. It even appears to work with shaping in play.

I haven't tried the UpdateLayeredWindow function yet, so Im not sure how that would alter things. It would be nice to be able to do this without having to turn things off.

BH

leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 20, 2006 11:04 AM   in response to: leouser
  Click to reply to this thread Reply

using the opengl pipeline with SetLayeredWindowAttributes does not work very well at all. Its not as bad as having direct draw enabled which leaves artifacts all over the screen. But it is bad enough that you get a nice black rectangle where the swing widget is supposed to be.

From looking at UpdateLayeredWindow it appears as though its supposed to be the function by which things are drawn. Im not sure how to stick this into the Java process. I guess it'd need to repaint itself when a WM_PAINT event occurs and also when Swing repaints itself. Another factor is how could we get the painting to be directed to the image that functions as the window? Maybe Im misunderstanding the function...

BH

joshy

Posts: 90
Re: Is There A BalloonTip Component In Java?
Posted: Oct 20, 2006 11:16 AM   in response to: leouser
  Click to reply to this thread Reply

Every time I've talked to the Java2D and AWT guys about shaped Windows they said it would probably hinder graphics acceleration. I suspect that if you want to run with shaped windows on an OS that doesn't have a full compositing window manager (ie: OSX, Vista, or X + extensions), then you'll have to drop accelleration.

leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 20, 2006 11:35 AM   in response to: joshy
  Click to reply to this thread Reply

shaping appears to work ok with the opengl pipeline, as far as I can tell.

I was thinking that translucency could be supplied on Windows if this simple forumla was met:
1. no direct draw on
2. no opengl pipeline on
3. If the windows API supports the layered windows api

#3 we can detect by doing some DLL loading. Im not sure about #1 or #2. We can pass #1 if the noddraw flag is set. #2 we could just check to see if the opengl flag is set to true. Im not certain but wasn't the opengl pipeline supposed to be turned on by default for Java 6?

Im not sure how to strategise this on X. First there needs to be proof the AWT is going to work with the Composite extension. If so we can just check to see if the Composite extension and its various other extensions are supported. If not, then what? Do we just veto it or do we try to fall back on "pseudo transparency" with the background being set to the root window? Would anyone even want that?

It sounds like the Mac peers have a method called setAlpha which turns on the transparency. So with fingures crossed, there may be no need to do any native diddling.

BH

leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 20, 2006 11:52 AM   in response to: leouser
  Click to reply to this thread Reply

I think just looking for opengl being turned on will do, from Chris Campbell's blog:
'Everytime I write about the OGL pipeline, the first question that is asked (without fail) is "Will the OGL pipeline be enabled by default?"... Well, the answer is still "no". It will never be enabled by default on the Windows platform (the DirectX-based pipelines are a better bet on Windows). However, I certainly hope that someday (Mustang? Dolphin?) the OGL pipeline will be enabled by default on Solaris and Linux, but only if we detect a "compatible" system, meaning hardware accelerated drivers are installed, bug-free, and performant.'

I don't think we need to worry about windows API calls being made on *Nixes.

BH

leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 20, 2006 12:36 PM   in response to: leouser
  Click to reply to this thread Reply

heh, apparently another factor against UpdateLayeredWindow is that you can't have child controls. They aren't painted and it looks like they don't respond to the mouse. That doesn't sound good.

BH

Anthony Petrov
Re: Is There A BalloonTip Component In Java?
Posted: Oct 22, 2006 11:30 PM   in response to: leouser
  Click to reply to this thread Reply

Actually you can :) Look at the WM_PRINT Windows message or something
similar. You may order your window to draw itself (including all its
children) into specified DC. The DC may be a bitmap DC that you'd use
with UpdateLayeredWindow. :)
The main problem with this function is that you have to decide when to
update your window... Do you have an answer? :)


--
best regards,
Anthony


joshy

Posts: 90
Re: Is There A BalloonTip Component In Java?
Posted: Oct 22, 2006 11:42 PM   in response to: Anthony Petrov
  Click to reply to this thread Reply

I think it could be done by hooking in a custom RepaintManager. That would let you know when the app window wants to be redrawn. It shouldn't be too hard to plug in a custom one which just makes a note of the request and delgates to the previous one.

Anthony Petrov
Re: Is There A BalloonTip Component In Java?
Posted: Oct 22, 2006 11:51 PM   in response to: joshy
  Click to reply to this thread Reply

Well joshy,

The main question is the performance though. We certainly can invoke the
UpdateLayeredWindow for each changed pixel but is it worth doing so?
Remember, the function updates the WHOLE window, not just some specified
area. :(

--
best regards,
Anthony


leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 23, 2006 6:50 AM   in response to: Anthony Petrov
  Click to reply to this thread Reply

That sounds like a de-optimisation, yikes. Though on the other hand, wouldn't regular Windows apps suffer from this same performance drop?

Interesting, so you can get your children painted with the "update" method. I ran into more than one person complaining about their buttons and such not showing up and the answer was: "doesn't work".

BH

leouser

Posts: 1,160
Re: Is There A BalloonTip Component In Java?
Posted: Oct 30, 2006 8:04 AM   in response to: leouser
  Click to reply to this thread Reply

yikes, I can see why people say "Translucency support not quite there on Solaris/Linux". Ive finally got a Xcomposite lib built and was testing out redirecting a Java window and it crashed the XServer. :( Not sure why yet, but it does.

BH

Anthony Petrov
Re: Is There A BalloonTip Component In Java?
Posted: Oct 30, 2006 11:57 PM   in response to: leouser
  Click to reply to this thread Reply

Hi Brian,

It's not the only reason. If/when you get it work, you'd see a numerous
artifacts all over your screen. So, it's just not usable yet...
unfortunately.


--
best regards,
Anthony





 XML java.net RSS