@@ -784,9 +784,13 @@ public boolean hitClip(int x, int y, int width, int height) {
784784 return clipRect .intersects (x , y , width , height );
785785 }
786786
787+ private int alpha ;
787788 private void setGraphicsColor (Color c ) {
788789 if (c == null )
789790 return ; // this was the case with a JRootPanel graphic call
791+ int a = c .getAlpha ();
792+ if (a != alpha )
793+ ctx .globalAlpha = (alpha = a ) / 256F ;
790794 ctx .fillStyle = ctx .strokeStyle = JSToolkit .getCSSColor (c );
791795 }
792796
@@ -1004,13 +1008,8 @@ public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y) {
10041008 }
10051009
10061010 public void setAlpha (float f ) {
1007- /**
1008- * @j2sNative
1009- *
1010- * this.ctx.globalAlpha = f;
1011- */
1012- {
1013- }
1011+ ctx .globalAlpha = f ;
1012+ alpha = (int ) Math .floor (f * 256 + 0.0039 );
10141013 }
10151014
10161015 public HTML5Canvas getCanvas () {
@@ -1050,17 +1049,7 @@ public int mark() {
10501049 // note: This method is referred to in JComponent.java j2snative block as mark$
10511050 ctx .save ();
10521051 Object [] map = new Object [SAVE_MAX ];
1053-
1054- float alpha = 0 ;
1055- /**
1056- * @j2sNative
1057- *
1058- * alpha = this.ctx.globalAlpha;
1059- *
1060- */
1061- {
1062- }
1063- map [SAVE_ALPHA ] = Float .valueOf (alpha );
1052+ map [SAVE_ALPHA ] = Float .valueOf (ctx .globalAlpha );
10641053 map [SAVE_COMPOSITE ] = alphaComposite ;
10651054 map [SAVE_STROKE ] = currentStroke ;
10661055 map [SAVE_TRANSFORM ] = transform ;
@@ -1083,8 +1072,9 @@ public void reset(int n0) {
10831072 Object [] map = HTML5CanvasContext2D .pop (ctx );
10841073 setComposite ((Composite ) map [SAVE_COMPOSITE ]);
10851074 Float alpha = (Float ) map [SAVE_ALPHA ];
1086- if (alpha != null )
1075+ if (alpha != null ) {
10871076 setAlpha (alpha .floatValue ());
1077+ }
10881078 setStroke ((Stroke ) map [SAVE_STROKE ]);
10891079 setTransform ((AffineTransform ) map [SAVE_TRANSFORM ]);
10901080 setFont ((Font ) map [SAVE_FONT ]);
0 commit comments