Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 491913

Summary: Improve export quality of gradient style for all format
Product: [Modeling] Sirius Reporter: Laurent Redor <laurent.redor>
Component: DiagramAssignee: Laurent Redor <laurent.redor>
Status: CLOSED FIXED QA Contact: Julien Dupont <julien.dupont>
Severity: normal    
Priority: P3 CC: julien.dupont, maxime.porhel, pierre-charles.david
Version: 3.0.0Keywords: triaged
Target Milestone: 4.1.0   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/70950
https://git.eclipse.org/r/68358
https://git.eclipse.org/r/70951
https://git.eclipse.org/r/68357
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=ad8c2a23533e04f6744495453307f36028b8470d
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=fc272903173652c4eba722c26aaecbe25198a610
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=1aa0866554e951523c77e681c5cd18177bc668a6
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=225f5107a327a9817035ba761203fdb5f93bedd2
https://git.eclipse.org/r/70982
https://git.eclipse.org/r/76417
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=ebc68755874dabd8873a839806689b5021cdd59b
https://git.eclipse.org/r/78290
https://bugs.eclipse.org/bugs/show_bug.cgi?id=498914
https://git.eclipse.org/r/78375
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=c82df54339b20693bfc37094442576d3c1605c74
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=1efb4840ea606e775faea4dfb1360c5ea2ea6cca
https://git.eclipse.org/r/78390
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=6cf0af74062f03be118eeadebe47308acea8eab6
Whiteboard:
Bug Depends on:    
Bug Blocks: 499106    
Attachments:
Description Flags
Sample of export results for a container with a gradient color as background
none
Sample Project
none
Capella reproduction case
none
PNG export of a Capella diagram - with color issues
none
Jpg export - no issues
none
PNG showing the second pattern issue - function at the bottom of the diagram
none
GradientSampleWithPngPb.zip
none
GradientSampleWithAllKind.zip none

Description Laurent Redor CLA 2016-04-18 09:49:38 EDT
Created attachment 261039 [details]
Sample of export results for a container with a gradient color as background

The quality of gradient color (used for background of some nodes) is not correct for all proposed export format.

It is OK for JPG but KO for PNG, SVG, BMP and GIF.
Comment 1 Laurent Redor CLA 2016-04-18 09:57:22 EDT
Created attachment 261040 [details]
Sample Project

Steps to reproduce:
* Import the project from GradientSample.zip
* Open the diagram "new Diag"
* Export the diagram as image (with the five proposed formats)
Comment 2 Laurent Redor CLA 2016-04-19 08:35:21 EDT
For BMP, the problem is only due to an explicit limitation in code. It seems there is no reason for this limitation.

For GIF, there is the same limitation as BMP. But for GIF, there is a real reason due to characteristics of this format. The color palette must be a 8 bits palette. So no improvement will be done for this format.

For PNG and SVG, GMF uses "awt" classes to the rendering. These classes do not handle gradient. But with these classes, it is possible to use GradientPaint to obtain a gradient rendering. For this issue, some GMF classes will be duplicated in Sirius code to allow compatibility with old GMF version. But the real solution will be to handle GradientPaint directly in GMF code.

No change will be done for JPG format that already handles gradient (by the org.eclipse.draw2d.SWTGraphics with an org.eclipse.swt.graphics.Pattern).
Comment 3 Eclipse Genie CLA 2016-04-19 08:37:42 EDT
New Gerrit change created: https://git.eclipse.org/r/70950
Comment 4 Eclipse Genie CLA 2016-04-19 08:37:44 EDT
New Gerrit change created: https://git.eclipse.org/r/70951
Comment 5 Laurent Redor CLA 2016-04-19 12:21:08 EDT
To backport the above fix directly in a GMF bugzilla, I analysed a pure GMF example (GeoShape). But I noted with astonishment, that the export is correctly managed in this example for all format (except for BMP and GIF for known reasons).
The retained solution is perhaps not the best. Another solution will be to change our GradientRoundedRectangle by really using the gradient aspect of the figure. For example, with the current figure, the outline view does not show the gradient.
I made quickly a POC for this solution but the impacts are more important with this solution that with only impacting classes concerning "export as image".

Remaining problems with this POC:
* Oblique gradient not handled
* Management of border for container and compartment
* Other kind of figure (OperandFigure, RegionRoundedGradientRectangle, ...)
* Style without rounded corner
* ...
Comment 6 Laurent Redor CLA 2016-04-19 12:24:44 EDT
The gerrit corresponding to the POC of comment 5 is https://git.eclipse.org/r/70982
Comment 11 Maxime Porhel CLA 2016-05-24 11:54:52 EDT
Created attachment 261982 [details]
Capella reproduction case

See Capella reproduction use case. 

I reproduced the issue with Capella nightly (Sirius 4.0.0.201605040857 - 4.0.0 M7)
It seems there is two issues around the gradient pattern creation for the PNG export (the other format will have to be checked)

The attached use case already contain a SFBD diagram to play with the export. 

The full provided scenarios by the Capella team: 
 
Constraints have the color of the item previously created when they should be systematically yellow and not gradient (see attached screenshots).
Steps to reproduce:
   1. create a Capella project
   2. create a [SDFB] diagram
   3. create a Constraint
   4. create a System Function
   5. create a Constraint
   6. create an Actor Function
   7. create a Constraint


Depending on where is the top element on the diagram, the gradient is not the same. All elements are darker if any items are placed higher in the diagram and all the elements become white if they are all in bottom of the diagram (see attached gradient.zip, black marker represents the upper left corner of the diagram at its initialization).
Steps to reproduce:
   1. create a project Capella
   2. create a [SDFB] diagram
   3. create a System Function
   4. move it up or down
   5. do an image export with PNG format
Comment 12 Maxime Porhel CLA 2016-05-24 11:57:16 EDT
Created attachment 261983 [details]
PNG export of a Capella diagram - with color issues
Comment 13 Maxime Porhel CLA 2016-05-24 11:59:01 EDT
Created attachment 261984 [details]
Jpg export - no issues
Comment 14 Maxime Porhel CLA 2016-05-24 11:59:38 EDT
Created attachment 261985 [details]
PNG showing the second pattern issue - function at the bottom of the diagram
Comment 15 Laurent Redor CLA 2016-07-01 05:18:43 EDT
Created attachment 262846 [details]
GradientSampleWithPngPb.zip

The pb described in the above comment can be reproduced with project contained in GradientSampleWithPngPb.zip.

This project contains 4 diagrams:
* diagStandard: the element is at location 45x35 and png export is OK (horizontal gradient from blue to red).
* diagWithElementAt1500x1500: the element is at location 1500x1500 and png export is KO (all the element is blue).
* diagWithElementAt-300x-300:  the element is at location -300x-300 and png export is KO (all the element is red).
* diagWithElementAt-20x-20: the element is at location -20x-20 and png export is OK (horizontal gradient from blue to red). But the gradient is not the same as for 45x35.

With these 4 diagrams we see that the location of the node has an incidence of the gradient computation at png export.
Comment 16 Eclipse Genie CLA 2016-07-01 07:25:01 EDT
New Gerrit change created: https://git.eclipse.org/r/76417
Comment 17 Laurent Redor CLA 2016-07-01 07:33:45 EDT
The above gerrit fix the problem of png export.
Comment 18 Maxime Porhel CLA 2016-07-07 04:35:57 EDT
With the proposed gerrit, the gradient is the same on the exported png image for all locations/diagrams.
Comment 20 Laurent Redor CLA 2016-08-02 03:22:58 EDT
There is a regression since the last commit. Some impacts, of the clarification of x, y, width and height, have been forgotten.
Comment 21 Eclipse Genie CLA 2016-08-02 04:09:22 EDT
New Gerrit change created: https://git.eclipse.org/r/78290
Comment 22 Laurent Redor CLA 2016-08-02 04:35:21 EDT
Created attachment 263414 [details]
GradientSampleWithAllKind.zip

New project with all kind of gradient to check the last regression. Use the same scenario as comment 15 (but on all kind of gradient) to validate it.
Comment 23 Eclipse Genie CLA 2016-08-03 03:54:48 EDT
New Gerrit change created: https://git.eclipse.org/r/78375
Comment 25 Laurent Redor CLA 2016-08-03 09:49:34 EDT
The last commit fixes the problem of comment 20.
Comment 27 Eclipse Genie CLA 2016-08-03 10:20:23 EDT
New Gerrit change created: https://git.eclipse.org/r/78390
Comment 29 Pierre-Charles David CLA 2016-10-18 11:06:52 EDT
Available in Sirius 4.1.0, see https://wiki.eclipse.org/Sirius/4.1.0 for details.