Browse Source

Theme: Fix errorprone warnings

pull/270/head
weisj 3 years ago
parent
commit
db26ca6bfa
No known key found for this signature in database
GPG Key ID: 31124CB75461DA2A
  1. 1
      theme/build.gradle.kts
  2. 6
      theme/src/main/java/com/github/weisj/darklaf/theme/DarculaTheme.java
  3. 6
      theme/src/main/java/com/github/weisj/darklaf/theme/IntelliJTheme.java
  4. 18
      theme/src/main/java/com/github/weisj/darklaf/theme/Theme.java
  5. 1
      theme/src/main/java/com/github/weisj/darklaf/theme/event/ThemeChangeListener.java
  6. 1
      theme/src/main/java/com/github/weisj/darklaf/theme/event/ThemePreferenceListener.java
  7. 2
      theme/src/main/java/com/github/weisj/darklaf/theme/info/AccentColorRule.java
  8. 4
      theme/src/main/java/com/github/weisj/darklaf/theme/info/FontSizeRule.java
  9. 2
      theme/src/main/java/com/github/weisj/darklaf/theme/info/PreferredThemeStyle.java
  10. 4
      theme/src/main/java/com/github/weisj/darklaf/theme/laf/SynthesisedThemedLaf.java

1
theme/build.gradle.kts

@ -8,6 +8,7 @@ dependencies {
implementation(projects.darklafUtils) implementation(projects.darklafUtils)
compileOnly(projects.darklafAnnotations) compileOnly(projects.darklafAnnotations)
compileOnly(libs.tools.errorprone.annotations)
annotationProcessor(projects.darklafAnnotationsProcessor) annotationProcessor(projects.darklafAnnotationsProcessor)
compileOnly(libs.autoservice.annotations) compileOnly(libs.autoservice.annotations)

6
theme/src/main/java/com/github/weisj/darklaf/theme/DarculaTheme.java

@ -31,7 +31,11 @@ import com.github.weisj.darklaf.theme.info.ColorToneRule;
import com.github.weisj.darklaf.theme.info.PresetIconRule; import com.github.weisj.darklaf.theme.info.PresetIconRule;
import com.google.auto.service.AutoService; import com.google.auto.service.AutoService;
/** @author Jannis Weis */ /**
* A theme following the color scheme from the IntelliJ Darcula theme.
*
* @author Jannis Weis
*/
@AutoService(Theme.class) @AutoService(Theme.class)
@SynthesiseLaf @SynthesiseLaf
public class DarculaTheme extends Theme { public class DarculaTheme extends Theme {

6
theme/src/main/java/com/github/weisj/darklaf/theme/IntelliJTheme.java

@ -31,7 +31,11 @@ import com.github.weisj.darklaf.theme.info.ColorToneRule;
import com.github.weisj.darklaf.theme.info.PresetIconRule; import com.github.weisj.darklaf.theme.info.PresetIconRule;
import com.google.auto.service.AutoService; import com.google.auto.service.AutoService;
/** @author Jannis Weis */ /**
* A theme following the default IntelliJ color scheme.
*
* @author Jannis Weis
*/
@AutoService(Theme.class) @AutoService(Theme.class)
@SynthesiseLaf @SynthesiseLaf
public class IntelliJTheme extends Theme { public class IntelliJTheme extends Theme {

18
theme/src/main/java/com/github/weisj/darklaf/theme/Theme.java

@ -23,7 +23,6 @@ package com.github.weisj.darklaf.theme;
import java.io.InputStream; import java.io.InputStream;
import java.io.Serializable; import java.io.Serializable;
import java.util.Comparator;
import java.util.Objects; import java.util.Objects;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
@ -38,8 +37,13 @@ import com.github.weisj.darklaf.theme.info.*;
import com.github.weisj.darklaf.theme.laf.RenamedTheme; import com.github.weisj.darklaf.theme.laf.RenamedTheme;
import com.github.weisj.darklaf.util.LogUtil; import com.github.weisj.darklaf.util.LogUtil;
/** @author Jannis Weis */ /**
public abstract class Theme implements Comparable<Theme>, Comparator<Theme>, Serializable { * A {@link Theme} is responsible for providing colors and customizing properties used by the
* darklaf look and feel.
*
* @author Jannis Weis
*/
public abstract class Theme implements Comparable<Theme>, Serializable {
private static final Logger LOGGER = LogUtil.getLogger(Theme.class); private static final Logger LOGGER = LogUtil.getLogger(Theme.class);
private final FontSizeRule fontSizeRule; private final FontSizeRule fontSizeRule;
@ -451,12 +455,6 @@ public abstract class Theme implements Comparable<Theme>, Comparator<Theme>, Ser
return stringComp; return stringComp;
} }
@Override
public int compare(final Theme o1, final Theme o2) {
if (o1 == null) return -1;
return o1.compareTo(o2);
}
public Class<? extends Theme> getThemeClass() { public Class<? extends Theme> getThemeClass() {
return getClass(); return getClass();
} }
@ -471,7 +469,7 @@ public abstract class Theme implements Comparable<Theme>, Comparator<Theme>, Ser
public int hashCode() { public int hashCode() {
int result = fontSizeRule != null ? fontSizeRule.hashCode() : 0; int result = fontSizeRule != null ? fontSizeRule.hashCode() : 0;
result = 31 * result + (accentColorRule != null ? accentColorRule.hashCode() : 0); result = 31 * result + (accentColorRule != null ? accentColorRule.hashCode() : 0);
result = 31 * result + (getThemeClass().hashCode()); result = 31 * result + getThemeClass().hashCode();
return result; return result;
} }

1
theme/src/main/java/com/github/weisj/darklaf/theme/event/ThemeChangeListener.java

@ -23,6 +23,7 @@ package com.github.weisj.darklaf.theme.event;
public interface ThemeChangeListener extends ThemeEventListener<ThemeChangeEvent> { public interface ThemeChangeListener extends ThemeEventListener<ThemeChangeEvent> {
@Override
default void onEvent(final ThemeChangeEvent event) { default void onEvent(final ThemeChangeEvent event) {
themeChanged(event); themeChanged(event);
} }

1
theme/src/main/java/com/github/weisj/darklaf/theme/event/ThemePreferenceListener.java

@ -23,6 +23,7 @@ package com.github.weisj.darklaf.theme.event;
public interface ThemePreferenceListener extends ThemeEventListener<ThemePreferenceChangeEvent> { public interface ThemePreferenceListener extends ThemeEventListener<ThemePreferenceChangeEvent> {
@Override
default void onEvent(final ThemePreferenceChangeEvent event) { default void onEvent(final ThemePreferenceChangeEvent event) {
themePreferenceChanged(event); themePreferenceChanged(event);
} }

2
theme/src/main/java/com/github/weisj/darklaf/theme/info/AccentColorRule.java

@ -63,7 +63,7 @@ public class AccentColorRule implements Serializable {
@Override @Override
public boolean equals(final Object o) { public boolean equals(final Object o) {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (!(o instanceof AccentColorRule)) return false;
AccentColorRule that = (AccentColorRule) o; AccentColorRule that = (AccentColorRule) o;
if (!Objects.equals(accentColor, that.accentColor)) return false; if (!Objects.equals(accentColor, that.accentColor)) return false;
return Objects.equals(selectionColor, that.selectionColor); return Objects.equals(selectionColor, that.selectionColor);

4
theme/src/main/java/com/github/weisj/darklaf/theme/info/FontSizeRule.java

@ -104,9 +104,9 @@ public class FontSizeRule implements Serializable {
@Override @Override
public boolean equals(final Object o) { public boolean equals(final Object o) {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (!(o instanceof FontSizeRule)) return false;
FontSizeRule that = (FontSizeRule) o; FontSizeRule that = (FontSizeRule) o;
return Float.compare(that.getPercentage(), getPercentage()) == 0; return that.getPercentage() == getPercentage();
} }
@Override @Override

2
theme/src/main/java/com/github/weisj/darklaf/theme/info/PreferredThemeStyle.java

@ -102,7 +102,7 @@ public class PreferredThemeStyle {
@Override @Override
public boolean equals(final Object o) { public boolean equals(final Object o) {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (!(o instanceof PreferredThemeStyle)) return false;
PreferredThemeStyle that = (PreferredThemeStyle) o; PreferredThemeStyle that = (PreferredThemeStyle) o;
return contrastRule == that.contrastRule && colorToneRule == that.colorToneRule return contrastRule == that.contrastRule && colorToneRule == that.colorToneRule
&& Objects.equals(fontSizeRule, that.fontSizeRule) && Objects.equals(fontSizeRule, that.fontSizeRule)

4
theme/src/main/java/com/github/weisj/darklaf/theme/laf/SynthesisedThemedLaf.java

@ -23,9 +23,8 @@ package com.github.weisj.darklaf.theme.laf;
import java.util.ServiceLoader; import java.util.ServiceLoader;
import javax.swing.*;
import com.github.weisj.darklaf.theme.Theme; import com.github.weisj.darklaf.theme.Theme;
import com.google.errorprone.annotations.Immutable;
public class SynthesisedThemedLaf extends DelegatingThemedLaf { public class SynthesisedThemedLaf extends DelegatingThemedLaf {
@ -33,6 +32,7 @@ public class SynthesisedThemedLaf extends DelegatingThemedLaf {
super(theme, BaseLafProvider.INSTANCE.createBaseLaf()); super(theme, BaseLafProvider.INSTANCE.createBaseLaf());
} }
@Immutable
public interface ThemedLafProvider { public interface ThemedLafProvider {
ThemedLookAndFeel create(); ThemedLookAndFeel create();
} }

Loading…
Cancel
Save