mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-27 03:46:17 -06:00
added Error Prone (https://errorprone.info/) and fixed reported errors and warnings
- CI runs Error Prone with Java 11 - use Gradle task `errorprone` to run it on development machine - fixes are mostly cosmetic except: - use Locale.ENGLISH for String.toLowerCase() - use explicit character encoding when reading/writing files - TabbedPane: wrong logic in mouse-wheel scrolling - SplitPane: simplified property change listener (fixes hiding field `propertyChangeListener` of superclass)
This commit is contained in:
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@@ -43,6 +43,10 @@ jobs:
|
||||
distribution: adopt # Java 8 and 11 are pre-installed on ubuntu-latest
|
||||
cache: gradle
|
||||
|
||||
- name: Check with Error Prone
|
||||
if: matrix.java == '11'
|
||||
run: ./gradlew errorprone clean -Dtoolchain=${{ matrix.toolchain }}
|
||||
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build -Dtoolchain=${{ matrix.toolchain }}
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import net.ltgt.gradle.errorprone.errorprone
|
||||
|
||||
val releaseVersion = "3.1.1"
|
||||
val developmentVersion = "3.2-SNAPSHOT"
|
||||
|
||||
@@ -43,6 +45,10 @@ if( !toolchainJavaVersion.isNullOrEmpty() )
|
||||
println()
|
||||
|
||||
|
||||
plugins {
|
||||
alias( libs.plugins.errorprone ) apply false
|
||||
}
|
||||
|
||||
allprojects {
|
||||
tasks {
|
||||
withType<JavaCompile>().configureEach {
|
||||
@@ -81,4 +87,55 @@ allprojects {
|
||||
isFailOnError = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//---- Error Prone ----
|
||||
|
||||
tasks.register( "errorprone" ) {
|
||||
group = "verification"
|
||||
tasks.withType<JavaCompile>().forEach {
|
||||
dependsOn( it )
|
||||
}
|
||||
}
|
||||
|
||||
val useErrorProne = gradle.startParameter.taskNames.contains( "errorprone" )
|
||||
if( useErrorProne ) {
|
||||
plugins.withType<JavaPlugin> {
|
||||
apply( plugin = libs.plugins.errorprone.get().pluginId )
|
||||
|
||||
dependencies {
|
||||
"errorprone"( libs.errorprone )
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
options.compilerArgs.add( "-Werror" )
|
||||
options.errorprone {
|
||||
disable(
|
||||
"ReferenceEquality", // reports usage of '==' for objects
|
||||
"StringSplitter", // reports String.split()
|
||||
"JavaTimeDefaultTimeZone", // reports Year.now()
|
||||
"MissingSummary", // reports `/** @since 2 */`
|
||||
"InvalidBlockTag", // reports @uiDefault in javadoc
|
||||
"AlreadyChecked", // reports false positives
|
||||
"InlineMeSuggester", // suggests using Error Prone annotations for deprecated methods
|
||||
"TypeParameterUnusedInFormals",
|
||||
"UnsynchronizedOverridesSynchronized",
|
||||
)
|
||||
when( project.name ) {
|
||||
"flatlaf-intellij-themes" -> disable(
|
||||
"MutablePublicArray", // reports FlatAllIJThemes.INFOS
|
||||
)
|
||||
"flatlaf-theme-editor" -> disable(
|
||||
"CatchAndPrintStackTrace",
|
||||
)
|
||||
"flatlaf-testing" -> disable(
|
||||
"CatchAndPrintStackTrace",
|
||||
"JdkObsolete", // reports Hashtable used for JSlider.setLabelTable()
|
||||
"JavaUtilDate", // reports usage of class Date
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,7 +391,7 @@ public abstract class FlatLaf
|
||||
Method m = UIManager.class.getMethod( "createLookAndFeel", String.class );
|
||||
aquaLaf = (BasicLookAndFeel) m.invoke( null, "Mac OS X" );
|
||||
} else
|
||||
aquaLaf = (BasicLookAndFeel) Class.forName( aquaLafClassName ).getDeclaredConstructor().newInstance();
|
||||
aquaLaf = Class.forName( aquaLafClassName ).asSubclass( BasicLookAndFeel.class ).getDeclaredConstructor().newInstance();
|
||||
} catch( Exception ex ) {
|
||||
LoggingFacade.INSTANCE.logSevere( "FlatLaf: Failed to initialize Aqua look and feel '" + aquaLafClassName + "'.", ex );
|
||||
throw new IllegalStateException();
|
||||
@@ -581,10 +581,13 @@ public abstract class FlatLaf
|
||||
Object activeFont = new ActiveFont( null, null, -1, 0, 0, 0, 0 );
|
||||
|
||||
// override fonts
|
||||
List<String> fontKeys = new ArrayList<>( 50 );
|
||||
for( Object key : defaults.keySet() ) {
|
||||
if( key instanceof String && (((String)key).endsWith( ".font" ) || ((String)key).endsWith( "Font" )) )
|
||||
defaults.put( key, activeFont );
|
||||
fontKeys.add( (String) key );
|
||||
}
|
||||
for( String key : fontKeys )
|
||||
defaults.put( key, activeFont );
|
||||
|
||||
// add fonts that are not set in BasicLookAndFeel
|
||||
defaults.put( "RootPane.font", activeFont );
|
||||
@@ -1541,7 +1544,7 @@ public abstract class FlatLaf
|
||||
int newStyle = (style != -1)
|
||||
? style
|
||||
: (styleChange != 0)
|
||||
? baseStyle & ~((styleChange >> 16) & 0xffff) | (styleChange & 0xffff)
|
||||
? (baseStyle & ~((styleChange >> 16) & 0xffff)) | (styleChange & 0xffff)
|
||||
: baseStyle;
|
||||
|
||||
// new size
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
@@ -96,7 +97,7 @@ public class FlatPropertiesLaf
|
||||
protected ArrayList<Class<?>> getLafClassesForDefaultsLoading() {
|
||||
ArrayList<Class<?>> lafClasses = new ArrayList<>();
|
||||
lafClasses.add( FlatLaf.class );
|
||||
switch( baseTheme.toLowerCase() ) {
|
||||
switch( baseTheme.toLowerCase( Locale.ENGLISH ) ) {
|
||||
default:
|
||||
case "light":
|
||||
lafClasses.add( FlatLightLaf.class );
|
||||
|
||||
@@ -23,11 +23,14 @@ import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Toolkit;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.StringTokenizer;
|
||||
import javax.swing.text.StyleContext;
|
||||
import com.formdev.flatlaf.util.LoggingFacade;
|
||||
@@ -68,7 +71,7 @@ class LinuxFontPolicy
|
||||
if( word.endsWith( "," ) )
|
||||
word = word.substring( 0, word.length() - 1 ).trim();
|
||||
|
||||
String lword = word.toLowerCase();
|
||||
String lword = word.toLowerCase( Locale.ENGLISH );
|
||||
if( lword.equals( "italic" ) || lword.equals( "oblique" ) )
|
||||
style |= Font.ITALIC;
|
||||
else if( lword.equals( "bold" ) )
|
||||
@@ -104,7 +107,7 @@ class LinuxFontPolicy
|
||||
size = 1;
|
||||
|
||||
// handle logical font names
|
||||
String logicalFamily = mapFcName( family.toLowerCase() );
|
||||
String logicalFamily = mapFcName( family.toLowerCase( Locale.ENGLISH ) );
|
||||
if( logicalFamily != null )
|
||||
family = logicalFamily;
|
||||
|
||||
@@ -143,7 +146,7 @@ class LinuxFontPolicy
|
||||
return createFont( Font.DIALOG, style, size, dsize );
|
||||
|
||||
// check whether last work contains some font weight (e.g. Ultra-Bold or Heavy)
|
||||
String lastWord = family.substring( index + 1 ).toLowerCase();
|
||||
String lastWord = family.substring( index + 1 ).toLowerCase( Locale.ENGLISH );
|
||||
if( lastWord.contains( "bold" ) || lastWord.contains( "heavy" ) || lastWord.contains( "black" ) )
|
||||
style |= Font.BOLD;
|
||||
|
||||
@@ -257,6 +260,7 @@ class LinuxFontPolicy
|
||||
return createFont( family, style, size, dsize );
|
||||
}
|
||||
|
||||
@SuppressWarnings( "MixedMutabilityReturnType" ) // Error Prone
|
||||
private static List<String> readConfig( String filename ) {
|
||||
File userHome = new File( System.getProperty( "user.home" ) );
|
||||
|
||||
@@ -277,7 +281,9 @@ class LinuxFontPolicy
|
||||
|
||||
// read config file
|
||||
ArrayList<String> lines = new ArrayList<>( 200 );
|
||||
try( BufferedReader reader = new BufferedReader( new FileReader( file ) ) ) {
|
||||
try( BufferedReader reader = new BufferedReader( new InputStreamReader(
|
||||
new FileInputStream( file ), StandardCharsets.US_ASCII ) ) )
|
||||
{
|
||||
String line;
|
||||
while( (line = reader.readLine()) != null )
|
||||
lines.add( line );
|
||||
|
||||
@@ -348,8 +348,11 @@ class UIDefaultsLoader
|
||||
// convert binary color to string
|
||||
if( newValue instanceof Color ) {
|
||||
Color color = (Color) newValue;
|
||||
int rgb = color.getRGB() & 0xffffff;
|
||||
int alpha = color.getAlpha();
|
||||
return String.format( (alpha != 255) ? "#%06x%02x" : "#%06x", color.getRGB() & 0xffffff, alpha );
|
||||
return (alpha != 255)
|
||||
? String.format( "#%06x%02x", rgb, alpha )
|
||||
: String.format( "#%06x", rgb );
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException( "property value type '" + newValue.getClass().getName() + "' not supported in references" );
|
||||
@@ -702,8 +705,6 @@ class UIDefaultsLoader
|
||||
/**
|
||||
* Parses a hex color in {@code #RGB}, {@code #RGBA}, {@code #RRGGBB} or {@code #RRGGBBAA}
|
||||
* format and returns it as color object.
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
static ColorUIResource parseColor( String value ) {
|
||||
int rgba = parseColorRGBA( value );
|
||||
@@ -716,8 +717,6 @@ class UIDefaultsLoader
|
||||
* Parses a hex color in {@code #RGB}, {@code #RGBA}, {@code #RRGGBB} or {@code #RRGGBBAA}
|
||||
* format and returns it as {@code rgba} integer suitable for {@link java.awt.Color},
|
||||
* which includes alpha component in bits 24-31.
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
static int parseColorRGBA( String value ) {
|
||||
int len = value.length();
|
||||
|
||||
@@ -53,8 +53,8 @@ public class FlatInternalFrameCloseIcon
|
||||
|
||||
g.setColor( FlatButtonUI.buttonStateColor( c, c.getForeground(), null, null, hoverForeground, pressedForeground ) );
|
||||
|
||||
float mx = width / 2;
|
||||
float my = height / 2;
|
||||
float mx = width / 2f;
|
||||
float my = height / 2f;
|
||||
float r = 3.25f;
|
||||
|
||||
Path2D path = new Path2D.Float( Path2D.WIND_EVEN_ODD, 4 );
|
||||
|
||||
@@ -94,8 +94,8 @@ public class FlatTabbedPaneCloseIcon
|
||||
Color fg = FlatButtonUI.buttonStateColor( c, closeForeground, null, null, closeHoverForeground, closePressedForeground );
|
||||
g.setColor( FlatUIUtils.deriveColor( fg, c.getForeground() ) );
|
||||
|
||||
float mx = width / 2;
|
||||
float my = height / 2;
|
||||
float mx = width / 2f;
|
||||
float my = height / 2f;
|
||||
float r = ((bg != null) ? closeCrossFilledSize : closeCrossPlainSize) / 2;
|
||||
|
||||
// paint cross
|
||||
|
||||
@@ -502,9 +502,9 @@ class JsonParser {
|
||||
}
|
||||
|
||||
private boolean isHexDigit() {
|
||||
return current >= '0' && current <= '9'
|
||||
|| current >= 'a' && current <= 'f'
|
||||
|| current >= 'A' && current <= 'F';
|
||||
return (current >= '0' && current <= '9')
|
||||
|| (current >= 'a' && current <= 'f')
|
||||
|| (current >= 'A' && current <= 'F');
|
||||
}
|
||||
|
||||
private boolean isEndOfText() {
|
||||
|
||||
@@ -69,7 +69,7 @@ public class Location {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
if (!(obj instanceof Location)) {
|
||||
return false;
|
||||
}
|
||||
Location other = (Location)obj;
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.awt.Rectangle;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import javax.swing.Icon;
|
||||
@@ -179,7 +180,7 @@ public class FlatLabelUI
|
||||
// BASE_SIZE rule is parsed in javax.swing.text.html.StyleSheet.addRule()
|
||||
String style = "<style>BASE_SIZE " + c.getFont().getSize() + "</style>";
|
||||
|
||||
String lowerText = text.toLowerCase();
|
||||
String lowerText = text.toLowerCase( Locale.ENGLISH );
|
||||
int headIndex;
|
||||
int styleIndex;
|
||||
|
||||
@@ -228,7 +229,7 @@ public class FlatLabelUI
|
||||
int tagBegin = i + 1;
|
||||
for( i += 2; i < textLength; i++ ) {
|
||||
if( !Character.isLetterOrDigit( text.charAt( i ) ) ) {
|
||||
String tag = text.substring( tagBegin, i ).toLowerCase();
|
||||
String tag = text.substring( tagBegin, i ).toLowerCase( Locale.ENGLISH );
|
||||
if( tagsUseFontSizeSet.contains( tag ) )
|
||||
return true;
|
||||
|
||||
|
||||
@@ -391,7 +391,7 @@ public class FlatPopupFactory
|
||||
|
||||
//---- class NonFlashingPopup ---------------------------------------------
|
||||
|
||||
private class NonFlashingPopup
|
||||
private static class NonFlashingPopup
|
||||
extends Popup
|
||||
{
|
||||
private Popup delegate;
|
||||
|
||||
@@ -360,8 +360,8 @@ public class FlatScrollPaneUI
|
||||
protected void updateViewport( PropertyChangeEvent e ) {
|
||||
super.updateViewport( e );
|
||||
|
||||
JViewport oldViewport = (JViewport) (e.getOldValue());
|
||||
JViewport newViewport = (JViewport) (e.getNewValue());
|
||||
JViewport oldViewport = (JViewport) e.getOldValue();
|
||||
JViewport newViewport = (JViewport) e.getNewValue();
|
||||
|
||||
removeViewportListeners( oldViewport );
|
||||
addViewportListeners( newViewport );
|
||||
|
||||
@@ -87,7 +87,6 @@ public class FlatSplitPaneUI
|
||||
@Styleable protected Color oneTouchHoverArrowColor;
|
||||
@Styleable protected Color oneTouchPressedArrowColor;
|
||||
|
||||
private PropertyChangeListener propertyChangeListener;
|
||||
private Map<String, Object> oldStyleValues;
|
||||
|
||||
public static ComponentUI createUI( JComponent c ) {
|
||||
@@ -126,19 +125,9 @@ public class FlatSplitPaneUI
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void installListeners() {
|
||||
super.installListeners();
|
||||
|
||||
propertyChangeListener = FlatStylingSupport.createPropertyChangeListener( splitPane, this::installStyle, null );
|
||||
splitPane.addPropertyChangeListener( propertyChangeListener );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void uninstallListeners() {
|
||||
super.uninstallListeners();
|
||||
|
||||
splitPane.removePropertyChangeListener( propertyChangeListener );
|
||||
propertyChangeListener = null;
|
||||
protected PropertyChangeListener createPropertyChangeListener() {
|
||||
return FlatStylingSupport.createPropertyChangeListener( splitPane, this::installStyle,
|
||||
super.createPropertyChangeListener() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -278,6 +278,7 @@ public class FlatStylingSupport
|
||||
* @throws IllegalArgumentException on syntax errors
|
||||
* @throws ClassCastException if value type does not fit to expected type
|
||||
*/
|
||||
@SuppressWarnings( "ReturnValueIgnored" ) // Error Prone
|
||||
public static Map<String, Object> parseAndApply( Map<String, Object> oldStyleValues,
|
||||
Object style, BiFunction<String, Object, Object> applyProperty )
|
||||
throws UnknownStyleException, IllegalArgumentException
|
||||
|
||||
@@ -1967,7 +1967,7 @@ public class FlatTabbedPaneUI
|
||||
|
||||
//---- class TabCloseButton -----------------------------------------------
|
||||
|
||||
private class TabCloseButton
|
||||
private static class TabCloseButton
|
||||
extends JButton
|
||||
implements UIResource
|
||||
{
|
||||
@@ -1977,7 +1977,7 @@ public class FlatTabbedPaneUI
|
||||
|
||||
//---- class ContainerUIResource ------------------------------------------
|
||||
|
||||
private class ContainerUIResource
|
||||
private static class ContainerUIResource
|
||||
extends JPanel
|
||||
implements UIResource
|
||||
{
|
||||
@@ -2382,7 +2382,7 @@ public class FlatTabbedPaneUI
|
||||
if( isPreciseWheel &&
|
||||
getScrollButtonsPlacement() == BOTH &&
|
||||
getScrollButtonsPolicy() == AS_NEEDED_SINGLE &&
|
||||
(isLeftToRight() || !horizontal) || // scroll buttons are hidden in right-to-left
|
||||
(isLeftToRight() || !horizontal) && // scroll buttons are hidden in right-to-left
|
||||
scrollBackwardButtonPrefSize != null )
|
||||
{
|
||||
// special cases for scrolling with touchpad or high-resolution wheel:
|
||||
@@ -3051,7 +3051,7 @@ public class FlatTabbedPaneUI
|
||||
break;
|
||||
|
||||
case CENTER:
|
||||
shiftTabs( 0, (diff) / 2 );
|
||||
shiftTabs( 0, diff / 2 );
|
||||
topHeight += diff / 2;
|
||||
bottomHeight += diff - (diff / 2);
|
||||
break;
|
||||
|
||||
@@ -682,7 +682,7 @@ public class FlatTitlePane
|
||||
// Seems to be a bug in sun.awt.X11.XNETProtocol.requestState(),
|
||||
// which does some strange state XOR-ing...
|
||||
if( (oldState & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_VERT )
|
||||
newState = oldState & ~Frame.MAXIMIZED_BOTH | Frame.MAXIMIZED_HORIZ;
|
||||
newState = (oldState & ~Frame.MAXIMIZED_BOTH) | Frame.MAXIMIZED_HORIZ;
|
||||
}
|
||||
|
||||
frame.setExtendedState( newState );
|
||||
|
||||
@@ -575,7 +575,7 @@ public class FlatTreeUI
|
||||
if( isSelected && isWideSelection() ) {
|
||||
Color oldColor = g.getColor();
|
||||
g.setColor( selectionInactiveBackground );
|
||||
paintWideSelection( g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf );
|
||||
paintWideSelection( g, bounds, row );
|
||||
g.setColor( oldColor );
|
||||
}
|
||||
return;
|
||||
@@ -633,7 +633,7 @@ public class FlatTreeUI
|
||||
|
||||
if( isWideSelection() ) {
|
||||
// wide selection
|
||||
paintWideSelection( g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf );
|
||||
paintWideSelection( g, bounds, row );
|
||||
} else {
|
||||
// non-wide selection
|
||||
paintCellBackground( g, rendererComponent, bounds, row, true );
|
||||
@@ -702,9 +702,7 @@ public class FlatTreeUI
|
||||
return oldColor;
|
||||
}
|
||||
|
||||
private void paintWideSelection( Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds,
|
||||
TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf )
|
||||
{
|
||||
private void paintWideSelection( Graphics g, Rectangle bounds, int row ) {
|
||||
float arcTop, arcBottom;
|
||||
arcTop = arcBottom = UIScale.scale( selectionArc / 2f );
|
||||
|
||||
|
||||
@@ -725,7 +725,7 @@ public class FlatUIUtils
|
||||
{
|
||||
dotSize = UIScale.scale( dotSize );
|
||||
gap = UIScale.scale( gap );
|
||||
int gripSize = (dotSize * dotCount) + ((gap * (dotCount - 1)));
|
||||
int gripSize = (dotSize * dotCount) + (gap * (dotCount - 1));
|
||||
|
||||
// calculate grip position
|
||||
float gx;
|
||||
|
||||
@@ -28,7 +28,6 @@ import java.awt.Paint;
|
||||
import java.awt.Polygon;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.RenderingHints.Key;
|
||||
import java.awt.Shape;
|
||||
import java.awt.Stroke;
|
||||
import java.awt.font.FontRenderContext;
|
||||
@@ -368,12 +367,12 @@ public class Graphics2DProxy
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRenderingHint( Key hintKey, Object hintValue ) {
|
||||
public void setRenderingHint( RenderingHints.Key hintKey, Object hintValue ) {
|
||||
delegate.setRenderingHint( hintKey, hintValue );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getRenderingHint( Key hintKey ) {
|
||||
public Object getRenderingHint( RenderingHints.Key hintKey ) {
|
||||
return delegate.getRenderingHint( hintKey );
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
module com.formdev.flatlaf {
|
||||
|
||||
@@ -1214,6 +1214,7 @@ public class TestFlatStyleableValue
|
||||
|
||||
//---- class TestIcon -----------------------------------------------------
|
||||
|
||||
@SuppressWarnings( "EqualsHashCode" ) // Error Prone
|
||||
public static class TestIcon
|
||||
implements Icon
|
||||
{
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.formdev.flatlaf.FlatSystemProperties;
|
||||
*/
|
||||
public class TestUtils
|
||||
{
|
||||
@SuppressWarnings( "MutablePublicArray" ) // Error Prone
|
||||
public static final float[] FACTORS = { 1f, 1.25f, 1.5f, 1.75f, 2f, 2.25f, 2.5f, 2.75f, 3f, 3.25f, 3.5f, 3.75f, 4f, 5f, 6f };
|
||||
|
||||
public static void setup( boolean withFocus ) {
|
||||
|
||||
@@ -440,9 +440,9 @@ class DemoFrame
|
||||
|
||||
Class<? extends LookAndFeel> lafClass = UIManager.getLookAndFeel().getClass();
|
||||
try {
|
||||
FlatLaf.setup( lafClass.newInstance() );
|
||||
FlatLaf.setup( lafClass.getDeclaredConstructor().newInstance() );
|
||||
FlatLaf.updateUI();
|
||||
} catch( InstantiationException | IllegalAccessException ex ) {
|
||||
} catch( Exception ex ) {
|
||||
LoggingFacade.INSTANCE.logSevere( null, ex );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ public class FlatSVGIcon
|
||||
|
||||
private static synchronized URI loadFromStream( InputStream in ) throws IOException {
|
||||
try( InputStream in2 = in ) {
|
||||
return svgUniverse.loadSVG( in2, "/flatlaf-stream-" + (streamNumber++) );
|
||||
return svgUniverse.loadSVG( in2, "/flatlaf-stream-" + streamNumber++ );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -474,7 +474,7 @@ public class FlatSVGIcon
|
||||
URI uri = this.uri;
|
||||
if( uri == null ) {
|
||||
URL url = getIconURL( name, dark );
|
||||
if( url == null & dark )
|
||||
if( url == null && dark )
|
||||
url = getIconURL( name, false );
|
||||
|
||||
if( url == null ) {
|
||||
|
||||
@@ -770,6 +770,7 @@ public class FlatUIDefaultsInspector
|
||||
return String.valueOf( value );
|
||||
}
|
||||
|
||||
@SuppressWarnings( "FormatString" ) // Error Prone
|
||||
private static String color2hex( Color color ) {
|
||||
int rgb = color.getRGB();
|
||||
boolean hasAlpha = color.getAlpha() != 255;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
module com.formdev.flatlaf.extras {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
module com.formdev.flatlaf.fonts.inter {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
module com.formdev.flatlaf.fonts.jetbrains_mono {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
module com.formdev.flatlaf.fonts.roboto_mono {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
module com.formdev.flatlaf.fonts.roboto {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
module com.formdev.flatlaf.intellijthemes {
|
||||
|
||||
@@ -869,7 +869,6 @@ public class FlatWindowsNativeWindowBorder
|
||||
int GetSystemMetricsForDpi( int nIndex, int dpi );
|
||||
|
||||
boolean IsZoomed( HWND hWnd );
|
||||
HANDLE GetProp( HWND hWnd, String lpString );
|
||||
|
||||
HMENU GetSystemMenu( HWND hWnd, boolean bRevert );
|
||||
boolean SetMenuItemInfo( HMENU hmenu, int item, boolean fByPositon, MENUITEMINFO lpmii );
|
||||
|
||||
@@ -229,7 +229,7 @@ public class FlatTaskPaneUI
|
||||
|
||||
// compute chevron position
|
||||
int cx = (int) (x + width / 2 - cw / 2);
|
||||
int cy = (int) (y + (height / 2 - ch));
|
||||
int cy = (int) (y + height / 2 - ch);
|
||||
float offset = ch + UIScale.scale( 1f );
|
||||
|
||||
// set stroke with scaled width
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
module com.formdev.flatlaf.swingx {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
module com.formdev.flatlaf.testing.modular.app {
|
||||
|
||||
@@ -1456,7 +1456,7 @@ public class FlatComponents2Test
|
||||
|
||||
//---- TestTableRowHeaderModel --------------------------------------------
|
||||
|
||||
private class TestTableRowHeaderModel
|
||||
private static class TestTableRowHeaderModel
|
||||
extends AbstractTableModel
|
||||
implements TableModelListener
|
||||
{
|
||||
|
||||
@@ -932,7 +932,7 @@ public class FlatDisabledIconsTest
|
||||
@Override
|
||||
public int filterRGB(int x, int y, int rgb) {
|
||||
// Reduce the color bandwidth in quarter (>> 2) and Shift 0x88.
|
||||
return (rgb & 0xff000000) + 0x888888 + ((((rgb >> 16) & 0xff) >> 2) << 16) + ((((rgb >> 8) & 0xff) >> 2) << 8) + (((rgb) & 0xff) >> 2);
|
||||
return (rgb & 0xff000000) + 0x888888 + ((((rgb >> 16) & 0xff) >> 2) << 16) + ((((rgb >> 8) & 0xff) >> 2) << 8) + ((rgb & 0xff) >> 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -937,7 +937,7 @@ public class FlatMenusTest
|
||||
|
||||
//---- class PopupMenu ----------------------------------------------------
|
||||
|
||||
private class PopupMenu extends JPopupMenu {
|
||||
private static class PopupMenu extends JPopupMenu {
|
||||
private PopupMenu() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@@ -398,7 +398,7 @@ public class FlatSubMenusTest
|
||||
|
||||
//---- class PopupMenu ----------------------------------------------------
|
||||
|
||||
private class PopupMenu extends JPopupMenu {
|
||||
private static class PopupMenu extends JPopupMenu {
|
||||
private PopupMenu() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@@ -22,16 +22,20 @@ import java.awt.Font;
|
||||
import java.awt.Insets;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -229,7 +233,8 @@ public class UIDefaultsDump
|
||||
}
|
||||
if( origFile != null ) {
|
||||
try {
|
||||
Map<String, String> defaults1 = parse( new FileReader( origFile ) );
|
||||
Map<String, String> defaults1 = parse( new InputStreamReader(
|
||||
new FileInputStream( origFile ), StandardCharsets.UTF_8 ) );
|
||||
Map<String, String> defaults2 = parse( new StringReader( stringWriter.toString() ) );
|
||||
|
||||
content = diff( defaults1, defaults2 );
|
||||
@@ -242,7 +247,9 @@ public class UIDefaultsDump
|
||||
|
||||
// write to file
|
||||
file.getParentFile().mkdirs();
|
||||
try( FileWriter fileWriter = new FileWriter( file ) ) {
|
||||
try( Writer fileWriter = new OutputStreamWriter(
|
||||
new FileOutputStream( file ), StandardCharsets.UTF_8 ) )
|
||||
{
|
||||
fileWriter.write( content );
|
||||
} catch( IOException ex ) {
|
||||
ex.printStackTrace();
|
||||
@@ -419,7 +426,7 @@ public class UIDefaultsDump
|
||||
} else if( value instanceof Character ) {
|
||||
char ch = ((Character)value).charValue();
|
||||
if( ch >= ' ' && ch <= '~' )
|
||||
out.printf( "'%c'", value );
|
||||
out.printf( "'%c'", ch );
|
||||
else
|
||||
out.printf( "'\\u%h'", (int) ch );
|
||||
} else if( value.getClass().isArray() )
|
||||
|
||||
@@ -19,10 +19,13 @@ package com.formdev.flatlaf.testing.uidefaults;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
@@ -47,7 +50,9 @@ public class UIDefaultsKeysDump
|
||||
|
||||
// load existing keys file
|
||||
HashSet<String> keys = new HashSet<>();
|
||||
try( BufferedReader reader = new BufferedReader( new FileReader( keysFile ) ) ) {
|
||||
try( BufferedReader reader = new BufferedReader( new InputStreamReader(
|
||||
new FileInputStream( keysFile ), StandardCharsets.UTF_8 ) ) )
|
||||
{
|
||||
String key;
|
||||
while( (key = reader.readLine()) != null ) {
|
||||
keys.add( key );
|
||||
@@ -64,7 +69,9 @@ public class UIDefaultsKeysDump
|
||||
collectKeys( FlatTestLaf.class.getName(), keys );
|
||||
|
||||
// write key file
|
||||
try( Writer fileWriter = new BufferedWriter( new FileWriter( keysFile ) ) ) {
|
||||
try( Writer fileWriter = new BufferedWriter( new OutputStreamWriter(
|
||||
new FileOutputStream( keysFile ), StandardCharsets.UTF_8 ) ) )
|
||||
{
|
||||
String[] sortedKeys = keys.toArray( new String[keys.size()] );
|
||||
Arrays.sort( sortedKeys );
|
||||
for( String key : sortedKeys ) {
|
||||
|
||||
@@ -46,6 +46,6 @@ public class FlatLafThemeEditor
|
||||
System.setProperty( "apple.awt.application.appearance", "system" );
|
||||
}
|
||||
|
||||
FlatThemeFileEditor.main( args );
|
||||
FlatThemeFileEditor.launch( args );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ class FlatThemeEditorOverlay
|
||||
private Font font;
|
||||
private Font baseFont;
|
||||
|
||||
@SuppressWarnings( "FormatString" ) // Error Prone
|
||||
@Override
|
||||
public void paint( Graphics g, JComponent c ) {
|
||||
// paint the syntax text area
|
||||
|
||||
@@ -102,7 +102,7 @@ class FlatThemeFileEditor
|
||||
private final FlatThemePropertiesBaseManager propertiesBaseManager = new FlatThemePropertiesBaseManager();
|
||||
private final JButton newButton;
|
||||
|
||||
static void main( String[] args ) {
|
||||
static void launch( String[] args ) {
|
||||
File dir = (args.length > 0)
|
||||
? new File( args[0] )
|
||||
: null;
|
||||
@@ -1306,7 +1306,7 @@ class FlatThemeFileEditor
|
||||
super.addElement( obj );
|
||||
} else {
|
||||
int index = binarySearch( this, obj, comparator );
|
||||
insertElementAt( obj, (index < 0) ? ((-index)-1) : index );
|
||||
insertElementAt( obj, (index < 0) ? (-index - 1) : index );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,12 @@ junit-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "jun
|
||||
junit-params = { module = "org.junit.jupiter:junit-jupiter-params", version.ref = "junit" }
|
||||
junit-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit" }
|
||||
|
||||
# errorprone
|
||||
errorprone = "com.google.errorprone:error_prone_core:2.19.1"
|
||||
|
||||
|
||||
[bundles]
|
||||
junit = [ "junit-api", "junit-params" ]
|
||||
|
||||
[plugins]
|
||||
errorprone = { id = "net.ltgt.errorprone", version = "3.1.0" }
|
||||
|
||||
Reference in New Issue
Block a user