Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Alpha Blending with Viewport
Alpha Blending with Viewport [message #187628] Thu, 14 July 2005 01:49 Go to next message
Eclipse UserFriend
Originally posted by: jjefferies.acm.org

I have been working with the Logic Example for awhile, and have developed
a similar project. I am curious as to how to alpha blend on a Viewport
figure.

Basically, I have evolved the Logic example, such that the Ruler's will
alpha blend depending on a certain zoom factor
(for example: zoom = 1 -> alpha = 255
zoom = 2 -> alpha = 128
...
) ...this works no problem.

However, when I attempt the same alpha blending technique to my Viewport
figures (Rectangles with text), I do not get the same effect.

I have followed a similar structure to that of the example for my Viewport
figures. Basically, each editpart has:

protected void createFigure(){
return new blahBlahViewport();
}
...
public class blahBlahViewport extends Viewport{

public blahBlahViewport(){
super(true);
}

// a bunch of methods for setting attributes

public void paintFigure(Graphics graphics){
graphics.setAlpha( transparencyRatio );
}
...
}

I have tested the alpha blending for these Viewport figures by setting the
initial alpha value to 50, for instance, and the figure is mostly
transparent. However, when I zoom in, the transparency no longer exists,
and the original color of the Viewport figure is shown. Now, when I zoom
out, back to the original zoom factor, the alpha value of 50 returns, and
the transparency works.

I have a class that extends RulerFigure, and I have re-written the
paintFigure method to fit my own purpose, and it is here that I set the
alpha value to a ratio depending on the zoom factor. When I run the Debug
feature, I notice that the setAlpha method in SWTGraphics/GC gets called,
and my transparency works. However, duplicating the paintFigure method
from RulerFigure into my Viewport figures, and running the Debug feature,
I do not go into the same setAlpha method.

I think I am missing a minor (hopefully) detail, and would appreciate any
advice that anyone can offer.

Thanks in advance,
Jim
Re: Alpha Blending with Viewport [message #187646 is a reply to message #187628] Thu, 14 July 2005 14:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Are you using the final 3.1 release of draw2d?
Re: Alpha Blending with Viewport [message #187660 is a reply to message #187646] Thu, 14 July 2005 15:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jjefferies.acm.org

yes i am...

Draw2D 3.1.0
Graphical Editing Framework 3.1.0
Eclipse Platform 3.1.0

I have borrowed the zoomlistener and handleZoomChanged functionality from
RulerFigure for all my Viewport figures...and I do know that I am firing a
Zoom Change event, as it should.

If i cannot get the alpha blending to work through the use of:
graphics.setAlpha(myValue);
is there a way to implement transparency on my own? i.e. how would i go
about setting the RGB values of a certain color, such that transparency
will work for me?

Basically, I have 15 zoom levels from which I determine a ratio for alpha
blending on particular Viewports. Initially, I have an Editpart with,
say, 2 children...The children are scaled such that they are scaled to fit
within the contents of the parent editpart's Viewport figure. The
children should be completely transparent when I am at min zoom. As I zoom
in, the parent Viewport should become more transparent, and the children
should become less transparent, until max zoom. At max zoom, I wish to
have the children at full color, while the parent should be almost
completely transparent (only the outline of the parent is shown)

Your help in this matter is greatly appreciated.
Thanks again,
Jim
Re: Alpha Blending with Viewport [message #187692 is a reply to message #187660] Thu, 14 July 2005 17:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

I had thought that perhaps a pre-release version of ScaledGraphics did not
forward setAlpha() to SWTGraphics. But I guess you've eliminates that
option.

Try creating the minimum draw2d snippet which shows the problem and open a
bugzilla.

"Jim Jefferies" <jjefferies@acm.org> wrote in message
news:4758a598b783055b998e7d7c2bd093cb$1@www.eclipse.org...
> yes i am...
>
> Draw2D 3.1.0
> Graphical Editing Framework 3.1.0
> Eclipse Platform 3.1.0
>
> I have borrowed the zoomlistener and handleZoomChanged functionality from
> RulerFigure for all my Viewport figures...and I do know that I am firing a
> Zoom Change event, as it should.
>
> If i cannot get the alpha blending to work through the use of:
> graphics.setAlpha(myValue);
> is there a way to implement transparency on my own? i.e. how would i go
> about setting the RGB values of a certain color, such that transparency
> will work for me?
>
> Basically, I have 15 zoom levels from which I determine a ratio for alpha
> blending on particular Viewports. Initially, I have an Editpart with,
> say, 2 children...The children are scaled such that they are scaled to fit
> within the contents of the parent editpart's Viewport figure. The
> children should be completely transparent when I am at min zoom. As I zoom
> in, the parent Viewport should become more transparent, and the children
> should become less transparent, until max zoom. At max zoom, I wish to
> have the children at full color, while the parent should be almost
> completely transparent (only the outline of the parent is shown)
>
> Your help in this matter is greatly appreciated.
> Thanks again,
> Jim
>
Re: Alpha Blending with Viewport [message #187839 is a reply to message #187692] Fri, 15 July 2005 17:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jjefferies.acm.org

I have another question relating to this topic.

I am currently refactoring my project, since my Viewport figures reference
their editparts. I know this is bad, and hence, why the refactor.

Currently, before the refactor, I can set the initial alpha value to 50,
and the figure is mostly transparent. When I zoom in, (still using the 50
as an alpha value) the figure's transparency does not stay at 50, and
becomes full color. But, when I zoom back to the initial zoom factor, the
figures transparency goes back to 50.

So, my question is this:

When I read the GEF article on how to "Create an Eclipse-based application
using the Graphical Editing Framework", I noticed that editparts get
garbage collected and recreated over time. Since this is the case, do you
think that because my Viewport figures are referencing an editpart, then
when I zoom in, the editpart is garbage collected and a new editpart is
created with the given background color and alpha value?

I have a suspicion that this is the case, and with my refactoring, I may
be able to solve the problem.

Your response is greatly appreciated,
Jim
Re: Alpha Blending with Viewport [message #187861 is a reply to message #187839] Fri, 15 July 2005 18:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

The zoom problem sounds related to the use of ScaledGraphics. If zoom is
100%, SWTGraphics is used by itself. Anything else, and a new wrapper is
inserted which performs the zoom and also override setAlpha. Editparts are
not recreated during zooming, only when the model is structurally modified.

"Jim Jefferies" <jjefferies@acm.org> wrote in message
news:b6b2729b20e325a5b6be5d339be5c5c8$1@www.eclipse.org...
>I have another question relating to this topic.
>
> I am currently refactoring my project, since my Viewport figures reference
> their editparts. I know this is bad, and hence, why the refactor.
>
> Currently, before the refactor, I can set the initial alpha value to 50,
> and the figure is mostly transparent. When I zoom in, (still using the 50
> as an alpha value) the figure's transparency does not stay at 50, and
> becomes full color. But, when I zoom back to the initial zoom factor, the
> figures transparency goes back to 50.
>
> So, my question is this:
>
> When I read the GEF article on how to "Create an Eclipse-based application
> using the Graphical Editing Framework", I noticed that editparts get
> garbage collected and recreated over time. Since this is the case, do you
> think that because my Viewport figures are referencing an editpart, then
> when I zoom in, the editpart is garbage collected and a new editpart is
> created with the given background color and alpha value?
>
> I have a suspicion that this is the case, and with my refactoring, I may
> be able to solve the problem.
>
> Your response is greatly appreciated,
> Jim
>
>
Re: Alpha Blending with Viewport [message #188819 is a reply to message #187861] Fri, 22 July 2005 18:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jjefferies.acm.org

I have downloaded the newest Eclipse SDK 4.1 from the main downloads page,
and the newest Eclipse GEF 3.1, and dynamic alpha blending works!

Must have been a problem with the previous version of the SDK.

Jim
Re: Alpha Blending with Viewport [message #188933 is a reply to message #188819] Sat, 23 July 2005 14:57 Go to previous messageGo to next message
Konstantin Scheglov is currently offline Konstantin ScheglovFriend
Messages: 555
Registered: July 2009
Senior Member
Jim Jefferies:

> I have downloaded the newest Eclipse SDK 4.1 from the main downloads
> page, and the newest Eclipse GEF 3.1, and dynamic alpha blending works!

Just interesting - what means alpha blending?
Can anyone describe this shortly or give me screenshot?

Something like old graphics.setXORMode(true)?


Konstantin Scheglov,
Google, Inc.
Re: Alpha Blending with Viewport [message #189089 is a reply to message #188933] Mon, 25 July 2005 17:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jjefferies.acm.org

Alpha Blending can be understood as:

If your model contains a heirarchy (i.e. consider city maps that show you
the roads, the green areas, schools, etc...), you can view the topmost
layer without seeing additional layers beneath it. You can now "alpha
blend" into the topmost layer, by bringing to the front some of the layers
beneath it using transparency.

This is analogous to zooming into the model to extract more detailed
information.

As you look through the topmost layer (zoom into it), it will eventually
become transparent, and at the same time, the layer directly beneath it
will begin blending into the foreground (i.e. from transparent to full
color.)

Jim
Re: Alpha Blending with Viewport [message #189203 is a reply to message #189089] Tue, 26 July 2005 15:43 Go to previous messageGo to next message
Konstantin Scheglov is currently offline Konstantin ScheglovFriend
Messages: 555
Registered: July 2009
Senior Member
Jim Jefferies:

Thank you for detailed description.

> Alpha Blending can be understood as:
>
> If your model contains a heirarchy (i.e. consider city maps that show
> you the roads, the green areas, schools, etc...), you can view the
> topmost layer without seeing additional layers beneath it. You can now
> "alpha blend" into the topmost layer, by bringing to the front some of
> the layers beneath it using transparency.
>
> This is analogous to zooming into the model to extract more detailed
> information.
>
> As you look through the topmost layer (zoom into it), it will eventually
> become transparent, and at the same time, the layer directly beneath it
> will begin blending into the foreground (i.e. from transparent to full
> color.)
> Jim
>


Konstantin Scheglov,
Google, Inc.
Re: Alpha Blending with Viewport [message #189399 is a reply to message #189089] Wed, 27 July 2005 02:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: zhlmmc.hotmail.com

Hi,
Does this feature only supported in 3.1 ?
I can't find the Graphics.setAlpha() method in 3.0.1.
Re: Alpha Blending with Viewport [message #189451 is a reply to message #189399] Wed, 27 July 2005 14:55 Go to previous message
Eclipse UserFriend
Originally posted by: jjefferies.acm.org

I believe it is only supported from 3.1 and on.
Previous Topic:RCP/GEF developer Wanted
Next Topic:Palette Tools Malfunction While Zooming
Goto Forum:
  


Current Time: Fri Dec 13 03:54:43 GMT 2024

Powered by FUDForum. Page generated in 1.03801 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top