@@ -503,19 +503,17 @@ protected boolean shouldCalculateIntersection() {
503
503
}
504
504
505
505
@ Override
506
- public void fillRect (final float x , final float y , final float w , final float h , final Integer rgba ) {
506
+ public void fillRect (final float x , final float y , final float w , final float h , final Color color ) {
507
507
if (log .isLoggable (Level .FINE )) {
508
- String format = (rgba != null )
509
- ? "fillRect(%f, %f, %f, %f, 0x%x)"
510
- : "fillRect(%f, %f, %f, %f, null)" ;
511
- log .fine (String .format (format , x , y , w , h , rgba ));
508
+ String format = "fillRect(%f, %f, %f, %f, %s)" ;
509
+ log .fine (String .format (format , x , y , w , h , color ));
512
510
}
513
511
if (!shouldRenderRect (x , y , w , h , state .getShadowNoClone (), null )) {
514
512
return ;
515
513
}
516
514
new Composite () {
517
515
@ Override void doPaint (Graphics g ) {
518
- Paint paint = (rgba != null ) ? createColor ( rgba ) : state .getPaintNoClone ();
516
+ Paint paint = (color != null ) ? color : state .getPaintNoClone ();
519
517
DropShadow shadow = state .getShadowNoClone ();
520
518
// TextureMapperJava::drawSolidColor calls fillRect with perspective
521
519
// projection.
@@ -535,13 +533,13 @@ public void fillRect(final float x, final float y, final float w, final float h,
535
533
public void fillRoundedRect (final float x , final float y , final float w , final float h ,
536
534
final float topLeftW , final float topLeftH , final float topRightW , final float topRightH ,
537
535
final float bottomLeftW , final float bottomLeftH , final float bottomRightW , final float bottomRightH ,
538
- final int rgba )
536
+ final Color color )
539
537
{
540
538
if (log .isLoggable (Level .FINE )) {
541
539
log .fine (String .format ("fillRoundedRect(%f, %f, %f, %f, "
542
- + "%f, %f, %f, %f, %f, %f, %f, %f, 0x%x )" ,
540
+ + "%f, %f, %f, %f, %f, %f, %f, %f, %s )" ,
543
541
x , y , w , h , topLeftW , topLeftH , topRightW , topRightH ,
544
- bottomLeftW , bottomLeftH , bottomRightW , bottomRightH , rgba ));
542
+ bottomLeftW , bottomLeftH , bottomRightW , bottomRightH , color ));
545
543
}
546
544
if (!shouldRenderRect (x , y , w , h , state .getShadowNoClone (), null )) {
547
545
return ;
@@ -554,14 +552,13 @@ public void fillRoundedRect(final float x, final float y, final float w, final f
554
552
float arcW = (topLeftW + topRightW + bottomLeftW + bottomRightW ) / 2 ;
555
553
float arcH = (topLeftH + topRightH + bottomLeftH + bottomRightH ) / 2 ;
556
554
557
- Paint paint = createColor (rgba );
558
555
DropShadow shadow = state .getShadowNoClone ();
559
556
if (shadow != null ) {
560
557
final NGRectangle node = new NGRectangle ();
561
558
node .updateRectangle (x , y , w , h , arcW , arcH );
562
- render (g , shadow , paint , null , node );
559
+ render (g , shadow , color , null , node );
563
560
} else {
564
- g .setPaint (paint );
561
+ g .setPaint (color );
565
562
g .fillRoundRect (x , y , w , h , arcW , arcH );
566
563
}
567
564
}
@@ -585,11 +582,11 @@ public void clearRect(final float x, final float y, final float w, final float h
585
582
}
586
583
587
584
@ Override
588
- public void setFillColor (int rgba ) {
585
+ public void setFillColor (Color color ) {
589
586
if (log .isLoggable (Level .FINE )) {
590
- log .fine (String .format ("setFillColor(0x%x )" , rgba ));
587
+ log .fine (String .format ("setFillColor(%s )" , color ));
591
588
}
592
- state .setPaint (createColor ( rgba ) );
589
+ state .setPaint (color );
593
590
}
594
591
595
592
@ Override
@@ -627,11 +624,11 @@ public void setStrokeStyle(int style) {
627
624
}
628
625
629
626
@ Override
630
- public void setStrokeColor (int rgba ) {
627
+ public void setStrokeColor (Color color ) {
631
628
if (log .isLoggable (Level .FINE )) {
632
- log .fine (String .format ("setStrokeColor(0x%x )" , rgba ));
629
+ log .fine (String .format ("setStrokeColor(%s )" , color ));
633
630
}
634
- state .getStrokeNoClone ().setPaint (createColor ( rgba ) );
631
+ state .getStrokeNoClone ().setPaint (color );
635
632
}
636
633
637
634
@ Override
@@ -701,12 +698,12 @@ public void setMiterLimit(float miterLimit) {
701
698
}
702
699
703
700
@ Override
704
- public void setShadow (float dx , float dy , float blur , int rgba ) {
701
+ public void setShadow (float dx , float dy , float blur , Color color ) {
705
702
if (log .isLoggable (Level .FINE )) {
706
- String format = "setShadow(%f, %f, %f, 0x%x )" ;
707
- log .fine (String .format (format , dx , dy , blur , rgba ));
703
+ String format = "setShadow(%f, %f, %f, %s )" ;
704
+ log .fine (String .format (format , dx , dy , blur , color ));
708
705
}
709
- state .setShadow (createShadow (dx , dy , blur , rgba ));
706
+ state .setShadow (createShadow (dx , dy , blur , color ));
710
707
}
711
708
712
709
@ Override
@@ -1018,16 +1015,16 @@ public void drawEllipse(final int x, final int y, final int w, final int h) {
1018
1015
new float [] {1.0f }, 0.0f );
1019
1016
1020
1017
@ Override
1021
- public void drawFocusRing (final int x , final int y , final int w , final int h , final int rgba ) {
1018
+ public void drawFocusRing (final int x , final int y , final int w , final int h , final Color color ) {
1022
1019
if (log .isLoggable (Level .FINE )) {
1023
- log .fine (String .format ("drawFocusRing: %d, %d, %d, %d, 0x%x " , x , y , w , h , rgba ));
1020
+ log .fine (String .format ("drawFocusRing: %d, %d, %d, %d, %s " , x , y , w , h , color ));
1024
1021
}
1025
1022
if (!shouldRenderRect (x , y , w , h , null , focusRingStroke )) {
1026
1023
return ;
1027
1024
}
1028
1025
new Composite () {
1029
1026
@ Override void doPaint (Graphics g ) {
1030
- g .setPaint (createColor ( rgba ) );
1027
+ g .setPaint (color );
1031
1028
BasicStroke stroke = g .getStroke ();
1032
1029
g .setStroke (focusRingStroke );
1033
1030
g .drawRoundRect (x , y , w , h , 4 , 4 );
@@ -1115,31 +1112,22 @@ private static Rectangle intersect(Rectangle what, Rectangle with) {
1115
1112
return what ;
1116
1113
}
1117
1114
1118
- static Color createColor (int rgba ) {
1119
- float a = (0xFF & (rgba >> 24 )) / 255.0f ;
1120
- float r = (0xFF & (rgba >> 16 )) / 255.0f ;
1121
- float g = (0xFF & (rgba >> 8 )) / 255.0f ;
1122
- float b = (0xFF & (rgba )) / 255.0f ;
1123
- return new Color (r , g , b , a );
1124
- }
1125
-
1126
- private static Color4f createColor4f (int rgba ) {
1127
- float a = (0xFF & (rgba >> 24 )) / 255.0f ;
1128
- float r = (0xFF & (rgba >> 16 )) / 255.0f ;
1129
- float g = (0xFF & (rgba >> 8 )) / 255.0f ;
1130
- float b = (0xFF & (rgba )) / 255.0f ;
1131
- return new Color4f (r , g , b , a );
1115
+ private static Color4f createColor4f (Color color ) {
1116
+ return new Color4f (color .getRed (),
1117
+ color .getGreen (),
1118
+ color .getBlue (),
1119
+ color .getAlpha ());
1132
1120
}
1133
1121
1134
- private DropShadow createShadow (float dx , float dy , float blur , int rgba ) {
1122
+ private DropShadow createShadow (float dx , float dy , float blur , Color color ) {
1135
1123
if (dx == 0f && dy == 0f && blur == 0f ) {
1136
1124
return null ;
1137
1125
}
1138
1126
DropShadow shadow = new DropShadow ();
1139
1127
shadow .setOffsetX ((int ) dx );
1140
1128
shadow .setOffsetY ((int ) dy );
1141
1129
shadow .setRadius ((blur < 0f ) ? 0f : (blur > 127f ) ? 127f : blur );
1142
- shadow .setColor (createColor4f (rgba ));
1130
+ shadow .setColor (createColor4f (color ));
1143
1131
return shadow ;
1144
1132
}
1145
1133
0 commit comments