tmpkus / piccolo2d

Automatically exported from code.google.com/p/piccolo2d
0 stars 0 forks source link

SWTGraphics2D.fill wrong color used #245

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Add a rectangle shape with no stroke but valid paint color.

What is the expected output? What do you see instead?
A simple filled rectangle with the paint color should be shown. However, 
nothing is shown.

What version of the product are you using? On what operating system?
Piccolo version: Current subversion trunk
SWT version: 3.1
OS: Debian testing

Please provide any additional information below.
PPath.paint calls setPaint on the Graphics2D object (which is actually 
SWTGraphics2D). This call sets the foreground color of the SWT GC object. For 
filling however, it is required to set the background color of the GC.

I have the feeling that the color/background -> foreground/background mapping 
in SWTGraphics2D is generally wrong. The colors have different meanings in AWT 
and SWT. In AWT the background color has only a meaning for clearRect which in 
SWT it is meant for filling operations.

Original issue reported on code.google.com by abloc...@gmail.com on 23 Nov 2012 at 12:47

GoogleCodeExporter commented 9 years ago
Thank you for reporting this issue.

I don't know SWT very well, but this code from 
org.piccolo2d.extras.swt.examples.FillShapeExample, line 107

PSWTPath rectNullStrokePaint = PSWTPath.createRectangle(325.0f, 400.0f, 50.0f, 
100.0f);
rectNullStrokePaint.setPaint(Color.YELLOW);
rectNullStrokePaint.setStrokeColor(null);

seems to do what I would expect, displays a yellow rectangle with no stroke.

Original comment by heue...@gmail.com on 23 Nov 2012 at 6:50

GoogleCodeExporter commented 9 years ago
Thanks for the answer. The problem seems to not occur when PSWTPath instead of 
PPath is used. Just tested it in my application. The difference seems to be 
that PSWTPath calls setBackground instead of setColor.

I will use PSWTPath now instead of PPath. Should the bug with PPath still be 
fixed?

I'm currently only evaluating Piccolo for my project. If I decide to use it, I 
will probably create some patches regarding SWT. I see some more problems, for 
example the SHAPE_CACHE in SWTGraphics2D. It gets filled up and only gets 
cleared when the last SWTGraphics2D object is disposed. This will get 
problematic when changing PPath/PSWTPath object are used because after every 
change to the path object, it gets reinserted without removing the old one. Or 
probably I've overseen something?

Original comment by abloc...@gmail.com on 23 Nov 2012 at 9:18

GoogleCodeExporter commented 9 years ago
org.piccolo2d.extras.swt is more of a parallel implementation of the Piccolo2D 
core APIs rather than an integration or extension of them.  Thus with 
PSWTCanvas you need to use all of the PSWT-prefixed subclasses of PNode.

Perhaps this issue might be resolved by adding some documentation in the right 
place?

With regards to other issues/patches with SWT support, yes, please submit them 
ideally with unit tests or an example that demonstrates the problem. 

Original comment by heue...@gmail.com on 23 Nov 2012 at 9:39

GoogleCodeExporter commented 9 years ago

Original comment by heue...@gmail.com on 9 Jan 2013 at 5:00