piccolo2d / piccolo2d.java

Structured 2D Graphics Framework
http://piccolo2d.org
Other
51 stars 14 forks source link

SWTGraphics2D.fill wrong color used #245

Closed mro closed 9 years ago

mro commented 9 years ago

Originally reported on Google Code with ID 245

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.

Reported by ablock84 on 2012-11-23 12:47:10

mro 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.

Reported by heuermh on 2012-11-23 18:50:47

mro 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?

Reported by ablock84 on 2012-11-23 21:18:48

mro 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. 

Reported by heuermh on 2012-11-23 21:39:56

mro commented 9 years ago

Reported by heuermh on 2013-01-09 17:00:17