| Summary: | Figures with transparency draw improperly in EditPartViewer | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Tools] GEF | Reporter: | Mark Siegel <mark.siegel> | ||||
| Component: | GEF-Legacy GEF (MVC) | Assignee: | gef-inbox <gef-inbox> | ||||
| Status: | RESOLVED WORKSFORME | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | nyssen | ||||
| Version: | 3.2 | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Linux-GTK | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Created attachment 45866 [details]
Some pictures of the problem
Attaching some images of the problem:
shapes1.png - the rectangle part in the editor, displaying normally
shapes2.png - as I drag the part around, over itself, it renders black
shapes3.png - this is what it looks like when i scroll to the image if it began offscreen.
Can you reproduce this problem on windows? No, I can't seem to reproduce the problem on windows. This is probably an SWT bug. It would be helpful if you could remove the Shapes example from the equation, and just create a Shell, with a Canvas using DOUBLE_BUFFER style, and paint directly on the canvas. It is usually pretty tricky trying to reproduce exactly which SWT calls draw2d is making, but it's possible. I cannot reproduce this one under MacOS X Snow Leopard - Cocoa either. As this has been reported quite some while ago, could you confirm if it is still an issue? Resolving as WORKSFORME due to my last comment. Please re-open in case this can still be reproduced somewhere. |
It seems that when an EditPart is rendered using a figure that has transparency, strange drawing artifacts sometimes appear on the rendered figure. This usually happens when either: a) Another EditPart is being dragged over top of the figure with transparency b) The EditPart with transparency is off screen and the editor is scrolled to bring it on screen. To reproduce, I've altered the Sample GEF Shapes Editor example (see code snippet below). Insert a rectangle part and place it mostly off the screen to the top. Scroll up to bring it completely into view. Notice the strange drawing artifacts on the image. My system configuration is RHEL AS4 (Update 1). Replacing ShapeEditPart.createFigureForModel() private IFigure createFigureForModel() { if (getModel() instanceof EllipticalShape) { return new Ellipse(); } else if (getModel() instanceof RectangularShape) { return new Figure() { public void paintFigure (Graphics graphics) { Image image = ImageCreator.createImage (100,100); try { graphics.setInterpolation (SWT.LOW); graphics.drawImage (image, new Rectangle (image.getBounds ()), getBounds ().getCopy ()); } catch (SWTException e) { } } }; } else { // if Shapes gets extended the conditions above must be updated throw new IllegalArgumentException(); } } static class ImageCreator { private static final int BLACK = 0x000000; private static final int TRANSPARENT_COLOR = 0xFFFFFE; private static final PaletteData PALETTE_DATA = new PaletteData (0xFF0000, 0xFF00, 0xFF); public static Image createImage (int width, int height) { ImageData swtImageData = new ImageData (height, width, 24, PALETTE_DATA); swtImageData.transparentPixel = TRANSPARENT_COLOR; byte[] data = swtImageData.data; for (int i = 0; i < width; i++) { int idx = i * swtImageData.bytesPerLine; for (int j = 0; j < height; j++) { // draw a grid int rgb = i % 8 == 7 || j % 8 == 7 ? BLACK : TRANSPARENT_COLOR; for (int k = swtImageData.depth - 8; k >= 0; k -= 8) { data[idx++] = (byte) ((rgb >> k) & 0xFF); } } } return new Image (Display.getDefault (), swtImageData); } }