1818import org .eclipse .jface .resource .ImageDescriptor ;
1919import org .eclipse .swt .SWT ;
2020import org .eclipse .swt .widgets .Composite ;
21+ import org .eclipse .swt .widgets .Display ;
2122import org .eclipse .swt .widgets .Label ;
23+ import org .eclipse .swt .widgets .Shell ;
2224import org .junit .Test ;
2325import org .junit .experimental .categories .Category ;
2426
@@ -28,28 +30,43 @@ public class Issue_2228 {
2830 public void recreate () {
2931 // testCoat probably takes a title and a lambda that receives the parent Composite
3032 InteractiveTest .testCoat (
31- "Show the difference between `.svg` and `@x2.png` rendering" ,
32- (Composite parent ) -> {
33- // two-column grid
34- Layouts .setGrid (parent ).numColumns (2 );
35-
36- // “.svg” label + image
37- Label svgLabel = new Label (parent , SWT .NONE );
38- svgLabel .setText (".svg" );
39-
40- Label svgImage = new Label (parent , SWT .NONE );
41- ImageDescriptor svgDesc = ImageDescriptor .createFromFile (
42- Issue_2228 .class , "/issue_2228/strikethrough.svg" );
43- svgImage .setImage (svgDesc .createImage ());
44-
45- // “.png” label + image
46- Label pngLabel = new Label (parent , SWT .NONE );
47- pngLabel .setText (".png" );
48-
49- Label pngImage = new Label (parent , SWT .NONE );
50- ImageDescriptor pngDesc = ImageDescriptor .createFromFile (
51- Issue_2228 .class , "/issue_2228/strikethrough.png" );
52- pngImage .setImage (pngDesc .createImage ());
53- });
33+ "Show the difference between `.svg` and `@x2.png` rendering" , Issue_2228 ::svg_and_png );
34+ }
35+
36+ private static void svg_and_png (Composite parent ) {
37+ // two-column grid
38+ Layouts .setGrid (parent ).numColumns (2 );
39+
40+ // “.svg” label + image
41+ Label svgLabel = new Label (parent , SWT .NONE );
42+ svgLabel .setText (".svg" );
43+
44+ Label svgImage = new Label (parent , SWT .NONE );
45+ ImageDescriptor svgDesc = ImageDescriptor .createFromFile (
46+ Issue_2228 .class , "/issue_2228/strikethrough.svg" );
47+ svgImage .setImage (svgDesc .createImage ());
48+
49+ // “.png” label + image
50+ Label pngLabel = new Label (parent , SWT .NONE );
51+ pngLabel .setText (".png" );
52+
53+ Label pngImage = new Label (parent , SWT .NONE );
54+ ImageDescriptor pngDesc = ImageDescriptor .createFromFile (
55+ Issue_2228 .class , "/issue_2228/strikethrough.png" );
56+ pngImage .setImage (pngDesc .createImage ());
57+
58+ }
59+
60+ public static void main (String [] args ) {
61+ Display display = Display .getDefault ();
62+ Shell shell = new Shell (display , SWT .SHELL_TRIM );
63+ svg_and_png (shell );
64+ shell .open ();
65+ while (!shell .isDisposed ()) {
66+ if (!display .readAndDispatch ()) {
67+ display .sleep ();
68+ }
69+ }
70+ display .dispose ();
5471 }
5572}
0 commit comments