mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 14:00:55 +03:00
Merge PR #817: Add LinearGradient paint in svg color filter
This commit is contained in:
@@ -25,6 +25,7 @@ import java.awt.Image;
|
||||
import java.awt.Paint;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.LinearGradientPaint;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.RGBImageFilter;
|
||||
import java.io.File;
|
||||
@@ -982,6 +983,14 @@ public class FlatSVGIcon
|
||||
public void setPaint( Paint paint ) {
|
||||
if( paint instanceof Color )
|
||||
paint = filterColor( (Color) paint );
|
||||
else if( paint instanceof LinearGradientPaint ) {
|
||||
LinearGradientPaint oldPaint = (LinearGradientPaint) paint;
|
||||
paint = new LinearGradientPaint( oldPaint.getStartPoint(),
|
||||
oldPaint.getEndPoint(),
|
||||
oldPaint.getFractions(),
|
||||
filterColors( oldPaint.getColors() ),
|
||||
oldPaint.getCycleMethod() );
|
||||
}
|
||||
super.setPaint( paint );
|
||||
}
|
||||
|
||||
@@ -1001,5 +1010,12 @@ public class FlatSVGIcon
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
private Color[] filterColors( Color[] colors ) {
|
||||
Color[] newColors = new Color[colors.length];
|
||||
for( int i = 0; i < colors.length; i++ )
|
||||
newColors[i] = filterColor( colors[i] );
|
||||
return newColors;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user