Graphics setAlpha() and connectors [message #235670] |
Thu, 14 June 2007 09:01  |
Eclipse User |
|
|
|
Originally posted by: johan.piculell.ericsson.com
Hi. I have figures in my graphical editor that inherits from Label,
contains an icon and a text. In order to get different background colors
with transparency I have overridden paintFigure() and uses setAlpha() on
the Graphics object. I have however two issues with this:
1. If I do this in my subclassed Label class:
...
setAlpha(100);
graphics.fillRectangle(getBounds());
setAlpha(255);
do rest of the drawing just as in Label.paintFigure()
...
Then the icon does not appear at all, instead I did a pushState before
setAlpha(100) and poped the state before drawing the rest and this works
fine. But I'm curious why and if this really is correct behavior. Seems to
me like icon drawing gets messed up if you touched the alpha stuff on the
graphics object.
2. For some reason all connectors also gets affected by the setAlpha()
call. This is a complete mystery for me, cannot see the relation here at
all, especially not since connectors are in a separate layer even.
Could this be a bug?
regards
/Johan
|
|
|
Re: Graphics setAlpha() and connectors [message #235711 is a reply to message #235670] |
Thu, 14 June 2007 18:31   |
Eclipse User |
|
|
|
Originally posted by: mlevison.gmail.com
Johan Piculell wrote:
> Hi. I have figures in my graphical editor that inherits from Label,
> contains an icon and a text. In order to get different background colors
> with transparency I have overridden paintFigure() and uses setAlpha() on
> the Graphics object. I have however two issues with this:
>
> 1. If I do this in my subclassed Label class:
> ..
> setAlpha(100);
> graphics.fillRectangle(getBounds());
> setAlpha(255);
> do rest of the drawing just as in Label.paintFigure()
> ..
>
> Then the icon does not appear at all, instead I did a pushState before
> setAlpha(100) and poped the state before drawing the rest and this works
> fine. But I'm curious why and if this really is correct behavior. Seems
> to me like icon drawing gets messed up if you touched the alpha stuff on
> the graphics object.
I'm going from memory here but doesn't setting the alpha push you into
advanced graphics mode?
|
|
|
Re: Graphics setAlpha() and connectors [message #235718 is a reply to message #235711] |
Thu, 14 June 2007 19:15   |
Eclipse User |
|
|
|
Originally posted by: piculell.telia.com
Mark Levison wrote:
> Johan Piculell wrote:
>> Hi. I have figures in my graphical editor that inherits from Label,
>> contains an icon and a text. In order to get different background
>> colors with transparency I have overridden paintFigure() and uses
>> setAlpha() on the Graphics object. I have however two issues with this:
>>
>> 1. If I do this in my subclassed Label class:
>> ..
>> setAlpha(100);
>> graphics.fillRectangle(getBounds());
>> setAlpha(255);
>> do rest of the drawing just as in Label.paintFigure()
>> ..
>>
>> Then the icon does not appear at all, instead I did a pushState before
>> setAlpha(100) and poped the state before drawing the rest and this
>> works fine. But I'm curious why and if this really is correct
>> behavior. Seems to me like icon drawing gets messed up if you touched
>> the alpha stuff on the graphics object.
>
> I'm going from memory here but doesn't setting the alpha push you into
> advanced graphics mode?
>
Not quite sure if I follow, you mean this is the reason for the first
issue?
|
|
|
Re: Graphics setAlpha() and connectors [message #235725 is a reply to message #235718] |
Thu, 14 June 2007 20:24   |
Eclipse User |
|
|
|
Originally posted by: mlevison.gmail.com
Johan Piculell wrote:
> Mark Levison wrote:
>> Johan Piculell wrote:
>>> Hi. I have figures in my graphical editor that inherits from Label,
>>> contains an icon and a text. In order to get different background
>>> colors with transparency I have overridden paintFigure() and uses
>>> setAlpha() on the Graphics object. I have however two issues with this:
>>>
>>> 1. If I do this in my subclassed Label class:
>>> ..
>>> setAlpha(100);
>>> graphics.fillRectangle(getBounds());
>>> setAlpha(255);
>>> do rest of the drawing just as in Label.paintFigure()
>>> ..
>>>
>>> Then the icon does not appear at all, instead I did a pushState
>>> before setAlpha(100) and poped the state before drawing the rest and
>>> this works fine. But I'm curious why and if this really is correct
>>> behavior. Seems to me like icon drawing gets messed up if you touched
>>> the alpha stuff on the graphics object.
>>
>> I'm going from memory here but doesn't setting the alpha push you into
>> advanced graphics mode?
>>
> Not quite sure if I follow, you mean this is the reason for the first
> issue?
Sorry I've not had enough sleep this week. I'm saying that setting your
Alpha may have an unintended side effect. In particular I think that the
alpha is part of the GDI+ and probably causes the advanced graphics mode
to be set (think SetGraphics(hdc, GM_ADVANCED)
http://msdn2.microsoft.com/en-us/library/ms532671.aspx). I suspect the
only way to clear it is by poping the state (not that I've checked).
Now the real question is - why does advanced graphics mode screw up the
drawing of your labels?
Distant memory says that text rendering in Advanced Graphics Mode can
have some funky issues.
I suspect that's part of why Sun implemented Java2D on top of DirectX
(don't quote me on any of this - I've just spent the past few years
doing WinForms development work).
Hope this provides some hints.
Cheers
Mark Levison
------------------------------------------------------------ ----------
Blog: http://www.notesfromatooluser.com/
Most Popular posts:
Aperture vs. Lightroom - best comparisons
http://www.notesfromatooluser.com/2007/02/aperture_vs_lig.ht ml
Scrum in a Nutshell Presentation
http://www.notesfromatooluser.com/2007/05/scrum_in_a_nuts.ht ml
Getting Things Done!!! Can't Keep Track of all the tasks you have to do?
Need a better Tool to Implement GTD?
http://www.notesfromatooluser.com/2006/12/getting_things_.ht ml
|
|
|
Re: Graphics setAlpha() and connectors [message #235731 is a reply to message #235725] |
Thu, 14 June 2007 20:37   |
Eclipse User |
|
|
|
Originally posted by: piculell.telia.com
Mark Levison wrote:
> Johan Piculell wrote:
>> Mark Levison wrote:
>>> Johan Piculell wrote:
>>>> Hi. I have figures in my graphical editor that inherits from Label,
>>>> contains an icon and a text. In order to get different background
>>>> colors with transparency I have overridden paintFigure() and uses
>>>> setAlpha() on the Graphics object. I have however two issues with this:
>>>>
>>>> 1. If I do this in my subclassed Label class:
>>>> ..
>>>> setAlpha(100);
>>>> graphics.fillRectangle(getBounds());
>>>> setAlpha(255);
>>>> do rest of the drawing just as in Label.paintFigure()
>>>> ..
>>>>
>>>> Then the icon does not appear at all, instead I did a pushState
>>>> before setAlpha(100) and poped the state before drawing the rest and
>>>> this works fine. But I'm curious why and if this really is correct
>>>> behavior. Seems to me like icon drawing gets messed up if you
>>>> touched the alpha stuff on the graphics object.
>>>
>>> I'm going from memory here but doesn't setting the alpha push you
>>> into advanced graphics mode?
>>>
>> Not quite sure if I follow, you mean this is the reason for the first
>> issue?
> Sorry I've not had enough sleep this week. I'm saying that setting your
> Alpha may have an unintended side effect. In particular I think that the
> alpha is part of the GDI+ and probably causes the advanced graphics mode
> to be set (think SetGraphics(hdc, GM_ADVANCED)
> http://msdn2.microsoft.com/en-us/library/ms532671.aspx). I suspect the
> only way to clear it is by poping the state (not that I've checked).
>
> Now the real question is - why does advanced graphics mode screw up the
> drawing of your labels?
>
> Distant memory says that text rendering in Advanced Graphics Mode can
> have some funky issues.
>
> I suspect that's part of why Sun implemented Java2D on top of DirectX
> (don't quote me on any of this - I've just spent the past few years
> doing WinForms development work).
>
> Hope this provides some hints.
>
> Cheers
> Mark Levison
> ------------------------------------------------------------ ----------
> Blog: http://www.notesfromatooluser.com/
> Most Popular posts:
> Aperture vs. Lightroom - best comparisons
> http://www.notesfromatooluser.com/2007/02/aperture_vs_lig.ht ml
> Scrum in a Nutshell Presentation
> http://www.notesfromatooluser.com/2007/05/scrum_in_a_nuts.ht ml
> Getting Things Done!!! Can't Keep Track of all the tasks you have to do?
> Need a better Tool to Implement GTD?
> http://www.notesfromatooluser.com/2006/12/getting_things_.ht ml
Thanks Mark. Forgot to mention that this is on Linux... but now you gave
me the idea of testing on Win as well to see what happens. Will do that
as soon as I find some time, might give me some leads.
Time for me to get some sleep now as well ;)
/Johan
|
|
|
Re: Graphics setAlpha() and connectors [message #235751 is a reply to message #235731] |
Fri, 15 June 2007 08:50   |
Eclipse User |
|
|
|
Originally posted by: johan.piculell.ericsson.com
Johan Piculell wrote:
> Mark Levison wrote:
>> Johan Piculell wrote:
>>> Mark Levison wrote:
>>>> Johan Piculell wrote:
>>>>> Hi. I have figures in my graphical editor that inherits from Label,
>>>>> contains an icon and a text. In order to get different background
>>>>> colors with transparency I have overridden paintFigure() and uses
>>>>> setAlpha() on the Graphics object. I have however two issues with this:
>>>>>
>>>>> 1. If I do this in my subclassed Label class:
>>>>> ..
>>>>> setAlpha(100);
>>>>> graphics.fillRectangle(getBounds());
>>>>> setAlpha(255);
>>>>> do rest of the drawing just as in Label.paintFigure()
>>>>> ..
>>>>>
>>>>> Then the icon does not appear at all, instead I did a pushState
>>>>> before setAlpha(100) and poped the state before drawing the rest and
>>>>> this works fine. But I'm curious why and if this really is correct
>>>>> behavior. Seems to me like icon drawing gets messed up if you
>>>>> touched the alpha stuff on the graphics object.
>>>>
>>>> I'm going from memory here but doesn't setting the alpha push you
>>>> into advanced graphics mode?
>>>>
>>> Not quite sure if I follow, you mean this is the reason for the first
>>> issue?
>> Sorry I've not had enough sleep this week. I'm saying that setting your
>> Alpha may have an unintended side effect. In particular I think that the
>> alpha is part of the GDI+ and probably causes the advanced graphics mode
>> to be set (think SetGraphics(hdc, GM_ADVANCED)
>> http://msdn2.microsoft.com/en-us/library/ms532671.aspx). I suspect the
>> only way to clear it is by poping the state (not that I've checked).
>>
>> Now the real question is - why does advanced graphics mode screw up the
>> drawing of your labels?
>>
>> Distant memory says that text rendering in Advanced Graphics Mode can
>> have some funky issues.
>>
>> I suspect that's part of why Sun implemented Java2D on top of DirectX
>> (don't quote me on any of this - I've just spent the past few years
>> doing WinForms development work).
>>
>> Hope this provides some hints.
>>
>> Cheers
>> Mark Levison
>> ------------------------------------------------------------ ----------
>> Blog: http://www.notesfromatooluser.com/
>> Most Popular posts:
>> Aperture vs. Lightroom - best comparisons
>> http://www.notesfromatooluser.com/2007/02/aperture_vs_lig.ht ml
>> Scrum in a Nutshell Presentation
>> http://www.notesfromatooluser.com/2007/05/scrum_in_a_nuts.ht ml
>> Getting Things Done!!! Can't Keep Track of all the tasks you have to do?
>> Need a better Tool to Implement GTD?
>> http://www.notesfromatooluser.com/2006/12/getting_things_.ht ml
> Thanks Mark. Forgot to mention that this is on Linux... but now you gave
> me the idea of testing on Win as well to see what happens. Will do that
> as soon as I find some time, might give me some leads.
> Time for me to get some sleep now as well ;)
> /Johan
Have now conducted some tests on windows:
- On windows I don't have to push and pop the state, setting alpha back to
255 works excellent there.
- The connectors does not get affected at all no matter how I draw my
figures, good!
- It is also possible to make icons transparent on windows, did not work
on Linux (but this does not matter much to me)
As I see it this connector issue is an annoying bug on Linux, the rest I
can live with. File a bugzilla? Is this SWT related or GEF?
regards
/Johan
|
|
|
Re: Graphics setAlpha() and connectors [message #235758 is a reply to message #235751] |
Fri, 15 June 2007 13:59   |
Eclipse User |
|
|
|
Originally posted by: mlevison.gmail.com
>
> Have now conducted some tests on windows:
> - On windows I don't have to push and pop the state, setting alpha back
> to 255 works excellent there.
>
> - The connectors does not get affected at all no matter how I draw my
> figures, good!
>
> - It is also possible to make icons transparent on windows, did not work
> on Linux (but this does not matter much to me)
>
> As I see it this connector issue is an annoying bug on Linux, the rest I
> can live with. File a bugzilla? Is this SWT related or GEF?
>
> regards
> /Johan
Interesting I never thought about Linux. Although the official company
line is that we support all three platforms. The Product Owner has made
it clear that expects 0 customers to ever run this on their desktops
(our end user is a business analyst and not a technologist). So will the
application must run on Linux/Mac - but we only care about who looks on
Windows. Sad perhaps - but its the reality of where our users are.
Cheers
Mark Levison
|
|
|
Re: Graphics setAlpha() and connectors [message #235772 is a reply to message #235758] |
Fri, 15 June 2007 16:13   |
Eclipse User |
|
|
|
Originally posted by: piculell.telia.com
Mark Levison wrote:
>
>>
>> Have now conducted some tests on windows:
>> - On windows I don't have to push and pop the state, setting alpha
>> back to 255 works excellent there.
>>
>> - The connectors does not get affected at all no matter how I draw my
>> figures, good!
>>
>> - It is also possible to make icons transparent on windows, did not
>> work on Linux (but this does not matter much to me)
>>
>> As I see it this connector issue is an annoying bug on Linux, the rest
>> I can live with. File a bugzilla? Is this SWT related or GEF?
>>
>> regards
>> /Johan
>
> Interesting I never thought about Linux. Although the official company
> line is that we support all three platforms. The Product Owner has made
> it clear that expects 0 customers to ever run this on their desktops
> (our end user is a business analyst and not a technologist). So will the
> application must run on Linux/Mac - but we only care about who looks on
> Windows. Sad perhaps - but its the reality of where our users are.
>
> Cheers
> Mark Levison
Ok, thats sad. So no use for me to file a bugreport then?
regards
/Johan
|
|
|
Re: Graphics setAlpha() and connectors [message #235779 is a reply to message #235772] |
Fri, 15 June 2007 17:23   |
Eclipse User |
|
|
|
Originally posted by: mlevison.gmail.com
Johan Piculell wrote:
> Mark Levison wrote:
>>
>>>
>>> Have now conducted some tests on windows:
>>> - On windows I don't have to push and pop the state, setting alpha
>>> back to 255 works excellent there.
>>>
>>> - The connectors does not get affected at all no matter how I draw my
>>> figures, good!
>>>
>>> - It is also possible to make icons transparent on windows, did not
>>> work on Linux (but this does not matter much to me)
>>>
>>> As I see it this connector issue is an annoying bug on Linux, the
>>> rest I can live with. File a bugzilla? Is this SWT related or GEF?
>>>
>>> regards
>>> /Johan
>>
>> Interesting I never thought about Linux. Although the official company
>> line is that we support all three platforms. The Product Owner has
>> made it clear that expects 0 customers to ever run this on their
>> desktops (our end user is a business analyst and not a technologist).
>> So will the application must run on Linux/Mac - but we only care about
>> who looks on Windows. Sad perhaps - but its the reality of where our
>> users are.
>>
>> Cheers
>> Mark Levison
> Ok, thats sad. So no use for me to file a bugreport then?
>
> regards
> /Johan
Sorry - Johan I was clear - I don't work on GEF/Eclipse or anything
else. I work for a large software company that is starting to build
Eclipse RCP applications. I'm sure your bug report will get the
attention it deserves. My comments about Linux/Mac are wrt my own project.
Sorry I'm not in a position to name my company. Hope that clarifies things.
Mark
|
|
|
|
Re: Graphics setAlpha() and connectors [message #235829 is a reply to message #235793] |
Mon, 18 June 2007 07:11   |
Eclipse User |
|
|
|
Originally posted by: johan.piculell.ericsson.com
Bug 193067 has been filed. Found a workaround however, if setAlpha(255) is
called before popping the graphic state things work fine.
/Johan
Anthony Hunter wrote:
> Hi Johan,
> Yes file a Bugzilla, if you have a snippet that exhibits the problem please
> include.
> Cheers...
> Anthony
|
|
|
Re: Graphics setAlpha() and connectors [message #239700 is a reply to message #235670] |
Fri, 09 November 2007 13:39  |
Eclipse User |
|
|
|
Originally posted by: simon.worknotes.org
I was going nuts. Tried my code on Mac and Windows - OK. I had just
reached the same conclusion when I came across your thread.
Sincerely, Thanks.
Johan Piculell wrote:
> Hi. I have figures in my graphical editor that inherits from Label,
> contains an icon and a text. In order to get different background colors
> with transparency I have overridden paintFigure() and uses setAlpha() on
> the Graphics object. I have however two issues with this:
>
> 1. If I do this in my subclassed Label class:
> ..
> setAlpha(100);
> graphics.fillRectangle(getBounds());
> setAlpha(255);
> do rest of the drawing just as in Label.paintFigure()
> ..
>
> Then the icon does not appear at all, instead I did a pushState before
> setAlpha(100) and poped the state before drawing the rest and this works
> fine. But I'm curious why and if this really is correct behavior. Seems
> to me like icon drawing gets messed up if you touched the alpha stuff on
> the graphics object.
>
> 2. For some reason all connectors also gets affected by the setAlpha()
> call. This is a complete mystery for me, cannot see the relation here at
> all, especially not since connectors are in a separate layer even.
> Could this be a bug?
>
> regards
> /Johan
>
|
|
|
Powered by
FUDForum. Page generated in 0.02442 seconds