@@ -70,10 +70,10 @@ public static void main(String[] args) {
7070
7171 // define PixelTransformers
7272 GTKDisablingTransformer gtkTransformer = new GTKDisablingTransformer ();
73- ThresholdBasedDisablingTransformer win32MacTransformer = new ThresholdBasedDisablingTransformer (GRAY_LOW , GRAY_HIGH , GRAY_HIGH , WIN32_COCOA_THRESHOLD , WIN32_COCOA_THRESHOLD );
73+ ThresholdBasedDisablingTransformer win32MacTransformer = new ThresholdBasedDisablingTransformer (GRAY_LOW , GRAY_HIGH , GRAY_HIGH , WIN32_COCOA_THRESHOLD , WIN32_COCOA_THRESHOLD , 1.f );
7474 EclipseRenderMojoDisablingTransformer eclipseMojoTransformer = new EclipseRenderMojoDisablingTransformer (ECLIPSE_RENDER_MOJOE_BRIGHTNESS_DEFAULT / 100f , ECLIPSE_RENDER_MOJO_ALPHA_DEFAULT / 100.f );
7575 HSBConversionDisablingTransformer hsbTransformer = new HSBConversionDisablingTransformer (HSB_DISABLING_BRIGHTNESS_DEFAULT / 100.f , HSB_DISABLING_ALPHA_DEFAULT / 100.f , HSB_DISABLING_SATURATION_DEFAULT / 100.f );
76- ThresholdBasedDisablingTransformer adjThreshAdditGray = new ThresholdBasedDisablingTransformer (GRAY_LOW , ADDITIONAL_GRAY_MID_DEFAULT , GRAY_HIGH , ADJUSTABLE_THRESHOLD_LOW_DEFAULT , ADJUSTABLE_THRESHOLD_HIGH_DEFAULT );
76+ ThresholdBasedDisablingTransformer adjThreshAdditGray = new ThresholdBasedDisablingTransformer (GRAY_LOW , ADDITIONAL_GRAY_MID_DEFAULT , GRAY_HIGH , ADJUSTABLE_THRESHOLD_LOW_DEFAULT , ADJUSTABLE_THRESHOLD_HIGH_DEFAULT , 1.f );
7777
7878 // create transformed icon rows
7979 Composite imagesComposite = new Composite (shell , SWT .NONE );
@@ -101,11 +101,12 @@ public static void main(String[] args) {
101101 Scale eclipsePreDisablingAlpha = addScale (eclipseMojoSliderComposite , "Eclipse Mojo Alpha %:" , 0 , 100 , ECLIPSE_RENDER_MOJO_ALPHA_DEFAULT );
102102
103103 Composite adjThreshAddGraySliderComposite = new Composite (shell , SWT .NONE );
104- adjThreshAddGraySliderComposite .setLayout (new GridLayout (9 , false ));
104+ adjThreshAddGraySliderComposite .setLayout (new GridLayout (12 , false ));
105105 adjThreshAddGraySliderComposite .setBackgroundMode (SWT .INHERIT_DEFAULT );
106106 Scale lowScale = addScale (adjThreshAddGraySliderComposite , "Low Threshold:" , 0 , MAX_BRIGHTNESS , WIN32_COCOA_THRESHOLD );
107107 Scale highScale = addScale (adjThreshAddGraySliderComposite , "High Threshold:" , 0 , MAX_BRIGHTNESS , ADJUSTABLE_THRESHOLD_HIGH_DEFAULT );
108108 Scale thirdGray = addScale (adjThreshAddGraySliderComposite , "3rd Gray:" , GRAY_LOW .red , GRAY_HIGH .red , ADDITIONAL_GRAY_MID_DEFAULT .red );
109+ Scale adjThreshAlphaChange = addScale (adjThreshAddGraySliderComposite , "Alpha %:" , 0 , 100 , 100 );
109110
110111 // update images on slider change
111112 addImageUpdateScaleListener (hsbDisablingBrightness , hsbTransformer , value -> hsbTransformer .setBrightnessChange (value / 100.f ), imageRowStorage , originalImages );
@@ -118,6 +119,7 @@ public static void main(String[] args) {
118119 addImageUpdateScaleListener (lowScale , adjThreshAdditGray , adjThreshAdditGray ::setThresholdLow , imageRowStorage , originalImages );
119120 addImageUpdateScaleListener (highScale , adjThreshAdditGray , adjThreshAdditGray ::setThresholdHigh , imageRowStorage , originalImages );
120121 addImageUpdateScaleListener (thirdGray , adjThreshAdditGray , value -> adjThreshAdditGray .setGrayMid (new RGB (value , value , value )), imageRowStorage , originalImages );
122+ addImageUpdateScaleListener (adjThreshAlphaChange , adjThreshAdditGray , value -> adjThreshAdditGray .setAlphaChange (value / 100.f ), imageRowStorage , originalImages );
121123
122124 // combo box for theme selection
123125 Combo themeCombo = new Combo (shell , SWT .DROP_DOWN | SWT .READ_ONLY );
@@ -248,14 +250,16 @@ public static class ThresholdBasedDisablingTransformer implements PixelTransform
248250 private RGB grayHigh ;
249251 private int thresholdLow ;
250252 private int thresholdHigh ;
253+ private float alphaChange ;
251254
252255 public ThresholdBasedDisablingTransformer (RGB grayLow , RGB grayMid , RGB grayHigh , int thresholdLow ,
253- int thresholdHigh ) {
256+ int thresholdHigh , float alphaChange ) {
254257 this .grayLow = grayLow ;
255258 this .grayMid = grayMid ;
256259 this .grayHigh = grayHigh ;
257260 this .thresholdLow = thresholdLow ;
258261 this .thresholdHigh = thresholdHigh ;
262+ this .alphaChange = alphaChange ;
259263 }
260264
261265 public void setThresholdLow (int thresholdLow ) {
@@ -270,6 +274,10 @@ public void setGrayMid(RGB grayMid) {
270274 this .grayMid = grayMid ;
271275 }
272276
277+ public void setAlphaChange (float alphaChange ) {
278+ this .alphaChange = alphaChange ;
279+ }
280+
273281 @ Override
274282 public RGBA transform (RGBA originalRgba ) {
275283 int red = originalRgba .rgb .red ;
@@ -280,11 +288,11 @@ public RGBA transform(RGBA originalRgba) {
280288 RGBA disabled ;
281289 int squareDist = red * red + green * green + blue * blue ;
282290 if (squareDist < thresholdLow ) {
283- disabled = new RGBA (grayLow .red , grayLow .green , grayLow .blue , alpha );
291+ disabled = new RGBA (grayLow .red , grayLow .green , grayLow .blue , ( int ) ( alphaChange * alpha ) );
284292 } else if (squareDist < thresholdHigh ) {
285- disabled = new RGBA (grayMid .red , grayMid .green , grayMid .blue , alpha );
293+ disabled = new RGBA (grayMid .red , grayMid .green , grayMid .blue , ( int ) ( alphaChange * alpha ) );
286294 } else {
287- disabled = new RGBA (grayHigh .red , grayHigh .green , grayHigh .blue , alpha );
295+ disabled = new RGBA (grayHigh .red , grayHigh .green , grayHigh .blue , ( int ) ( alphaChange * alpha ) );
288296 }
289297 return disabled ;
290298 }
0 commit comments