mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-10 22:17:13 -06:00
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;
|
||||
@@ -980,8 +981,16 @@ public class FlatSVGIcon
|
||||
|
||||
@Override
|
||||
public void setPaint( Paint paint ) {
|
||||
if( paint instanceof Color )
|
||||
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,13 @@ public class FlatSVGIcon
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
private Color[] filterColors( Color[] colors ) {
|
||||
Color[] newColor = new Color[colors.length];
|
||||
for( int i = 0; i < colors.length; i++ ) {
|
||||
newColor[i] = filterColor( colors[i] );
|
||||
}
|
||||
return newColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user