diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index b4b04697..e195327d 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -1,3 +1,27 @@ +# +# MIT License +# +# Copyright (c) 2020 Jannis Weis +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# name: Documentation on: push: diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml index 405a2b30..206abee4 100644 --- a/.github/workflows/gradle-wrapper-validation.yml +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -1,3 +1,27 @@ +# +# MIT License +# +# Copyright (c) 2020 Jannis Weis +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# name: "Validate Gradle Wrapper" on: [push, pull_request] diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 6e33f17d..3b73fc1b 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -1,3 +1,27 @@ +# +# MIT License +# +# Copyright (c) 2020 Jannis Weis +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# name: CI on: @@ -12,29 +36,29 @@ jobs: name: Windows (Java 11) runs-on: windows-latest steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 10 - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: 11 - - name: Build - run: ./gradlew build + - uses: actions/checkout@v2 + with: + fetch-depth: 10 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Build + run: ./gradlew build linux: name: Linux (Java 8) runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 10 - - name: Set up JDK 8 - uses: actions/setup-java@v1 - with: - java-version: 8 - - name: Build - run: ./gradlew build + - uses: actions/checkout@v2 + with: + fetch-depth: 10 + - name: Set up JDK 8 + uses: actions/setup-java@v1 + with: + java-version: 8 + - name: Build + run: ./gradlew build macos: name: macOS (Java 11) diff --git a/.github/workflows/libs.yml b/.github/workflows/libs.yml index 132c3cdc..caead39f 100644 --- a/.github/workflows/libs.yml +++ b/.github/workflows/libs.yml @@ -1,17 +1,41 @@ +# +# MIT License +# +# Copyright (c) 2020 Jannis Weis +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# name: Build Native Libraries on: push: paths: - - '**.cpp' - - '**.mm' + - '**.cpp' + - '**.mm' pull_request: paths: - - '**.cpp' - - '**.mm' + - '**.cpp' + - '**.mm' release: types: - - published + - published schedule: - cron: '0 0 1 * *' jobs: @@ -19,41 +43,41 @@ jobs: name: Windows (Java 11) runs-on: windows-latest steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 10 - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: 11 - - name: Build - run: ./gradlew :darklaf-windows:build - - name: Upload x86 artifact - uses: actions/upload-artifact@v1 - with: - name: darklaf-windows_x86.dll - path: windows/build/lib/main/release/x86/darklaf-windows.dll - - name: Upload x86-64 artifact - uses: actions/upload-artifact@v1 - with: - name: darklaf-windows_x86-64.dll - path: windows/build/lib/main/release/x86-64/darklaf-windows.dll - + - uses: actions/checkout@v2 + with: + fetch-depth: 10 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Build + run: ./gradlew :darklaf-windows:build + - name: Upload x86 artifact + uses: actions/upload-artifact@v1 + with: + name: darklaf-windows_x86.dll + path: windows/build/lib/main/release/x86/darklaf-windows.dll + - name: Upload x86-64 artifact + uses: actions/upload-artifact@v1 + with: + name: darklaf-windows_x86-64.dll + path: windows/build/lib/main/release/x86-64/darklaf-windows.dll + macOS: name: macOS (Java 11) runs-on: macos-latest steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 10 - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: 11 - - name: Build - run: ./gradlew :darklaf-macos:build - - name: Upload artifact - uses: actions/upload-artifact@v1 - with: - name: libdarklaf-macos.dylib - path: macos/build/lib/main/release/stripped/libdarklaf-macos.dylib + - uses: actions/checkout@v2 + with: + fetch-depth: 10 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Build + run: ./gradlew :darklaf-macos:build + - name: Upload artifact + uses: actions/upload-artifact@v1 + with: + name: libdarklaf-macos.dylib + path: macos/build/lib/main/release/stripped/libdarklaf-macos.dylib diff --git a/README.md b/README.md index 30b67f38..440d63b5 100644 --- a/README.md +++ b/README.md @@ -123,4 +123,3 @@ Here is a list of things that currently are not finished or need refinement. Thi # License This project is licensed under the [MIT license](https://github.com/weisJ/darklaf/blob/master/LICENSE). - diff --git a/build.gradle.kts b/build.gradle.kts index 5a390187..2fcc4b9d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,3 +1,5 @@ +import com.github.autostyle.generic.DefaultCopyrightStyle +import com.github.autostyle.gradle.BaseFormatExtension import com.github.vlsi.gradle.crlf.CrLfSpec import com.github.vlsi.gradle.crlf.LineEndings import com.github.vlsi.gradle.properties.dsl.props @@ -5,6 +7,7 @@ import com.github.vlsi.gradle.publishing.dsl.simplifyXml import com.github.vlsi.gradle.publishing.dsl.versionFromResolution plugins { + id("com.github.autostyle") id("com.github.vlsi.crlf") id("com.github.vlsi.gradle-extensions") id("com.github.vlsi.stage-vote-release") @@ -13,6 +16,7 @@ plugins { val skipJavadoc by props() val enableMavenLocal by props() val enableGradleMetadata by props() +val skipAutostyle by props() val String.v: String get() = rootProject.extra["$this.version"] as String @@ -40,6 +44,18 @@ releaseParams { } } +fun BaseFormatExtension.license() { + licenseHeader(File("${project.rootDir}/LICENSE").readText()) { + filter { + exclude("**/org/pbjar/jxlayer/*") + } + copyrightStyle("bat", DefaultCopyrightStyle.REM) + copyrightStyle("cmd", DefaultCopyrightStyle.REM) + } + trimTrailingWhitespace() + endWithNewline() +} + allprojects { group = "com.github.weisj" version = buildVersion @@ -51,6 +67,34 @@ allprojects { mavenCentral() } + if (!skipAutostyle) { + apply(plugin = "com.github.autostyle") + autostyle { + kotlinGradle { + ktlint() + } + format("configs") { + filter { + include("**/*.sh", "**/*.bsh", "**/*.cmd", "**/*.bat") + include("**/*.properties", "**/*.yml") + include("**/*.xsd", "**/*.xsl", "**/*.xml") + // Autostyle does not support gitignore yet https://github.com/autostyle/autostyle/issues/13 + exclude("out/**") + if (project == rootProject) { + exclude("gradlew*") + } else { + exclude("bin/**") + } + } + license() + } + format("markdown") { + filter.include("**/*.md") + endWithNewline() + } + } + } + tasks.withType().configureEach { // Ensure builds are reproducible isPreserveFileTimestamps = false @@ -107,6 +151,19 @@ allprojects { } } + if (!skipAutostyle) { + autostyle { + java { + importOrder("java", "javax", "org", "com") + removeUnusedImports() + license() + eclipse { + configFile("${project.rootDir}/darklaf_java.eclipseformat.xml") + } + } + } + } + apply(plugin = "maven-publish") val generatePomFile by props() @@ -173,7 +230,7 @@ allprojects { configure { if (project.path.startsWith(":darklaf-dependencies-bom") || - project.path == ":") { + project.path == ":") { // We don't it to Central for now return@configure } diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 32319e6a..41f27e30 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -1,6 +1,3 @@ -import com.github.vlsi.gradle.crlf.CrLfSpec -import com.github.vlsi.gradle.crlf.LineEndings - plugins { `java-library` id("com.github.johnrengelman.shadow") @@ -23,18 +20,6 @@ dependencies { testImplementation("org.swinglabs:swingx") } -tasks.jar { - CrLfSpec(LineEndings.LF).run { - into("META-INF") { - filteringCharset = "UTF-8" - textFrom("licenses/NOTICE.txt") - textFrom("licenses/DARCULA_LICENSE.txt") - textFrom("licenses/PBJAR_LICENSE.txt") - textFrom("licenses/INTELLIJ_LICENSE.txt") - } - } -} - val makeDocumentation by tasks.registering(JavaExec::class) { group = "Development" description = "Builds the documentation" @@ -66,10 +51,13 @@ tasks.shadowJar { abstract class DemoTask : JavaExec() { init { - setMain("UIDemo") + main = "UIDemo" } - @Option(option = "class", description = "Specifies the main class to run (e.g. UIDemo, ui.table.TableDemo, ui.button.ButtonDemo, ...)") + @Option( + option = "class", + description = "Specifies the main class to run (e.g. UIDemo, ui.table.TableDemo, ui.button.ButtonDemo, ...)" + ) override fun setMain(mainClassName: String?) = super.setMain(mainClassName) } @@ -86,6 +74,7 @@ val runDemo by tasks.registering(DemoTask::class) { val value = System.getProperty(name) ?: default value?.let { systemProperty(name, it) } } + val props = System.getProperties() @Suppress("UNCHECKED_CAST") for (e in props.propertyNames() as `java.util`.Enumeration) { diff --git a/core/gradle.properties b/core/gradle.properties index a2556c5a..8074f847 100644 --- a/core/gradle.properties +++ b/core/gradle.properties @@ -1 +1,25 @@ -generatePomFile = true +# +# MIT License +# +# Copyright (c) 2020 Jannis Weis +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# +generatePomFile = true diff --git a/core/pom.xml b/core/pom.xml index 8ac2bd53..3a061e5a 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -1,81 +1,106 @@ - - 4.0.0 - com.github.weisj - darklaf-core - 1.4.3.1 - Darklaf core - A themeable Look and Feel for java swing - https://github.com/weisJ/darklaf - - com.github.weisj - https://github.com/weisj - - - - MIT - https://github.com/weisJ/darklaf/blob/master/LICENSE - repo - - - - - Jannis Weis - - - - scm:git:git://github.com/weisJ/darklaf.git - scm:git:ssh://git@github.com:weisj/darklaf.git + + + 4.0.0 + com.github.weisj + darklaf-core + 1.4.3.1 + Darklaf core + A themeable Look and Feel for java swing https://github.com/weisJ/darklaf - - - GitHub - https://github.com/weisJ/darklaf/issues - - - - - com.github.weisj - darklaf-native-utils - 1.4.3.1 - runtime - - - com.github.weisj - darklaf-utils - 1.4.3.1 - runtime - - - com.github.weisj - darklaf-decorations-base - 1.4.3.1 - runtime - - - com.github.weisj - darklaf-windows - 1.4.3.1 - runtime - - - com.github.weisj - darklaf-macos - 1.4.3.1 - runtime - - - com.github.weisj - darklaf-property-loader - 1.4.3.1 - runtime - - - org.swinglabs - jxlayer - 3.0.4 - runtime - - + + com.github.weisj + https://github.com/weisj + + + + MIT + https://github.com/weisJ/darklaf/blob/master/LICENSE + repo + + + + + Jannis Weis + + + + scm:git:git://github.com/weisJ/darklaf.git + scm:git:ssh://git@github.com:weisj/darklaf.git + https://github.com/weisJ/darklaf + + + GitHub + https://github.com/weisJ/darklaf/issues + + + + + com.github.weisj + darklaf-native-utils + 1.4.3.1 + runtime + + + com.github.weisj + darklaf-utils + 1.4.3.1 + runtime + + + com.github.weisj + darklaf-decorations-base + 1.4.3.1 + runtime + + + com.github.weisj + darklaf-windows + 1.4.3.1 + runtime + + + com.github.weisj + darklaf-macos + 1.4.3.1 + runtime + + + com.github.weisj + darklaf-property-loader + 1.4.3.1 + runtime + + + org.swinglabs + jxlayer + 3.0.4 + runtime + + diff --git a/core/src/main/java/com/github/weisj/darklaf/DarkLaf.java b/core/src/main/java/com/github/weisj/darklaf/DarkLaf.java index c5900ddb..ff4e062d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/DarkLaf.java +++ b/core/src/main/java/com/github/weisj/darklaf/DarkLaf.java @@ -20,9 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.swing.*; +import javax.swing.plaf.basic.BasicLookAndFeel; +import javax.swing.plaf.metal.MetalLookAndFeel; + import com.github.weisj.darklaf.platform.DecorationsHandler; import com.github.weisj.darklaf.task.*; import com.github.weisj.darklaf.theme.Theme; @@ -30,12 +38,6 @@ import com.github.weisj.darklaf.ui.DarkPopupFactory; import com.github.weisj.darklaf.ui.popupmenu.DarkPopupMenuUI; import com.github.weisj.darklaf.util.SystemInfo; -import javax.swing.*; -import javax.swing.plaf.basic.BasicLookAndFeel; -import javax.swing.plaf.metal.MetalLookAndFeel; -import java.util.logging.Level; -import java.util.logging.Logger; - /** * @author Jannis Weis */ @@ -48,13 +50,13 @@ public class DarkLaf extends BasicLookAndFeel { * All tasks for initializing the ui defaults in order of execution. */ private static final DefaultsInitTask[] INIT_TASKS = new DefaultsInitTask[]{ - new ThemeDefaultsInitTask(), - new InputDefaultsInitTask(), - new IdeaDefaultsInitTask(), - new FontDefaultsInitTask(), - new UtilityDefaultsInitTask(), - new SystemDefaultsInitTask(), - new PlatformDefaultsInitTask() + new ThemeDefaultsInitTask(), + new InputDefaultsInitTask(), + new IdeaDefaultsInitTask(), + new FontDefaultsInitTask(), + new UtilityDefaultsInitTask(), + new SystemDefaultsInitTask(), + new PlatformDefaultsInitTask() }; /* * The base look and feel. This may vary to handle different platform support. @@ -143,13 +145,11 @@ public class DarkLaf extends BasicLookAndFeel { return "Darklaf"; } - @Override public String getID() { return getName(); } - @Override public String getDescription() { return "Dark Look and feel based on Darcula-LAF"; diff --git a/core/src/main/java/com/github/weisj/darklaf/DarkLafInfo.java b/core/src/main/java/com/github/weisj/darklaf/DarkLafInfo.java index 0cf79e91..f9e57818 100644 --- a/core/src/main/java/com/github/weisj/darklaf/DarkLafInfo.java +++ b/core/src/main/java/com/github/weisj/darklaf/DarkLafInfo.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf; diff --git a/core/src/main/java/com/github/weisj/darklaf/LafManager.java b/core/src/main/java/com/github/weisj/darklaf/LafManager.java index 616320d6..42201dbd 100644 --- a/core/src/main/java/com/github/weisj/darklaf/LafManager.java +++ b/core/src/main/java/com/github/weisj/darklaf/LafManager.java @@ -20,9 +20,21 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf; +import java.awt.*; +import java.io.IOException; +import java.io.InputStream; +import java.util.*; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.LogManager; +import java.util.logging.Logger; + +import javax.swing.*; + import com.github.weisj.darklaf.platform.DecorationsHandler; import com.github.weisj.darklaf.platform.ThemePreferencesHandler; import com.github.weisj.darklaf.task.DefaultsAdjustmentTask; @@ -33,16 +45,6 @@ import com.github.weisj.darklaf.theme.info.DefaultThemeProvider; import com.github.weisj.darklaf.theme.info.PreferredThemeStyle; import com.github.weisj.darklaf.theme.info.ThemeProvider; -import javax.swing.*; -import java.awt.*; -import java.io.IOException; -import java.io.InputStream; -import java.util.List; -import java.util.*; -import java.util.logging.Level; -import java.util.logging.LogManager; -import java.util.logging.Logger; - /** * Manager for the Look and Feel. * @@ -78,8 +80,7 @@ public final class LafManager { LogManager.getLogManager().reset(); } else { try (InputStream inputStream = DarkLaf.class.getClassLoader() - .getResourceAsStream( - "com/github/weisj/darklaf/log/logging.properties")) { + .getResourceAsStream("com/github/weisj/darklaf/log/logging.properties")) { if (inputStream != null) { Logger.getGlobal().fine("Loading logging configuration."); LogManager.getLogManager().readConfiguration(inputStream); @@ -143,9 +144,9 @@ public final class LafManager { * if preferences have changed. * * @param listener the listener to add. - * @see ThemePreferenceListener - * @see #enabledPreferenceChangeReporting(boolean) - * @see #isPreferenceChangeReportingEnabled() + * @see ThemePreferenceListener + * @see #enabledPreferenceChangeReporting(boolean) + * @see #isPreferenceChangeReportingEnabled() */ public static void addThemePreferenceChangeListener(final ThemePreferenceListener listener) { ThemePreferencesHandler.getSharedInstance().addThemePreferenceChangeListener(listener); @@ -155,9 +156,9 @@ public final class LafManager { * Removes a {@link ThemePreferenceListener}. * * @param listener the listener to add. - * @see ThemePreferenceListener - * @see #enabledPreferenceChangeReporting(boolean) - * @see #isPreferenceChangeReportingEnabled() + * @see ThemePreferenceListener + * @see #enabledPreferenceChangeReporting(boolean) + * @see #isPreferenceChangeReportingEnabled() */ public static void removeThemePreferenceChangeListener(final ThemePreferenceListener listener) { ThemePreferencesHandler.getSharedInstance().removeThemePreferenceChangeListener(listener); @@ -168,8 +169,8 @@ public final class LafManager { * to determine these values. * * @return the preferred theme style. - * @see #isPreferenceChangeReportingEnabled() - * @see #enabledPreferenceChangeReporting(boolean) + * @see #isPreferenceChangeReportingEnabled() + * @see #enabledPreferenceChangeReporting(boolean) */ public static PreferredThemeStyle getPreferredThemeStyle() { return ThemePreferencesHandler.getSharedInstance().getPreferredThemeStyle(); @@ -180,7 +181,7 @@ public final class LafManager { * preferred theme style. * * @return the theme provider. - * @see PreferredThemeStyle + * @see PreferredThemeStyle */ public static ThemeProvider getThemeProvider() { if (themeProvider == null) themeProvider = createDefaultThemeProvider(); @@ -192,7 +193,7 @@ public final class LafManager { * preferred theme style. * * @param themeProvider the theme provider. - * @see PreferredThemeStyle + * @see PreferredThemeStyle */ public static void setThemeProvider(final ThemeProvider themeProvider) { LafManager.themeProvider = themeProvider; @@ -208,8 +209,8 @@ public final class LafManager { /** * Get the associated theme for the given preferred style. * - * @param style the preferred theme style. - * @return the associated Theme or best match if there is none associated. + * @param style the preferred theme style. + * @return the associated Theme or best match if there is none associated. */ public static Theme themeForPreferredStyle(final PreferredThemeStyle style) { return getThemeProvider().getTheme(style); @@ -310,7 +311,6 @@ public final class LafManager { setTheme(themeForPreferredStyle(preferredThemeStyle)); } - /** * Sets the current theme and installs the LaF. If the LaF is already installed the theme is switched. This behaves * exactly like {@link #setTheme(Theme)} followed by {@link #install()} @@ -334,7 +334,7 @@ public final class LafManager { * Overload for {@link #installTheme(Theme)}. * * @param theme the theme to install. - * @see #installTheme(Theme) installTheme(). + * @see #installTheme(Theme) installTheme(). */ public static void install(final Theme theme) { installTheme(theme); @@ -350,9 +350,9 @@ public final class LafManager { UIManager.setLookAndFeel(DarkLaf.class.getCanonicalName()); updateLaf(); } catch (final ClassNotFoundException - | InstantiationException - | IllegalAccessException - | UnsupportedLookAndFeelException e) { + | InstantiationException + | IllegalAccessException + | UnsupportedLookAndFeelException e) { e.printStackTrace(); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/color/DarkColorModel.java b/core/src/main/java/com/github/weisj/darklaf/color/DarkColorModel.java index 9e211193..06a33b2f 100644 --- a/core/src/main/java/com/github/weisj/darklaf/color/DarkColorModel.java +++ b/core/src/main/java/com/github/weisj/darklaf/color/DarkColorModel.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.color; -import javax.swing.*; import java.awt.*; +import javax.swing.*; + /** * @author Jannis Weis */ @@ -34,7 +36,6 @@ public abstract class DarkColorModel { private final String prefix; private final String[] labels; - public DarkColorModel(final String name, final String... labels) { this.prefix = "ColorChooser." + name; this.labels = labels; diff --git a/core/src/main/java/com/github/weisj/darklaf/color/DarkColorModelCMYK.java b/core/src/main/java/com/github/weisj/darklaf/color/DarkColorModelCMYK.java index 7b1bdc53..ac02f47b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/color/DarkColorModelCMYK.java +++ b/core/src/main/java/com/github/weisj/darklaf/color/DarkColorModelCMYK.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.color; @@ -74,7 +75,6 @@ public class DarkColorModelCMYK extends DarkColorModel { return RGBtoCMYK(color.getRed(), color.getGreen(), color.getBlue()); } - private static int[] RGBtoCMYK(final int r, final int g, final int b) { double max = DarkColorModelHSL.max(r / 255.0, g / 255.0, b / 255.0); if (max > 0.0f) { @@ -96,12 +96,10 @@ public class DarkColorModelCMYK extends DarkColorModel { return new Color(rgb[0], rgb[1], rgb[2]); } - private static int[] CMYKtoRGB(final double c, final double m, final double y, final double k) { rgb[0] = (int) Math.round(255 * (1 - c) * (1 - k)); rgb[1] = (int) Math.round(255 * (1 - m) * (1 - k)); rgb[2] = (int) Math.round(255 * (1 - y) * (1 - k)); return rgb; } - } diff --git a/core/src/main/java/com/github/weisj/darklaf/color/DarkColorModelHSB.java b/core/src/main/java/com/github/weisj/darklaf/color/DarkColorModelHSB.java index 1a8085b8..fe57fed7 100644 --- a/core/src/main/java/com/github/weisj/darklaf/color/DarkColorModelHSB.java +++ b/core/src/main/java/com/github/weisj/darklaf/color/DarkColorModelHSB.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.color; diff --git a/core/src/main/java/com/github/weisj/darklaf/color/DarkColorModelHSL.java b/core/src/main/java/com/github/weisj/darklaf/color/DarkColorModelHSL.java index d4400bdf..c291d892 100644 --- a/core/src/main/java/com/github/weisj/darklaf/color/DarkColorModelHSL.java +++ b/core/src/main/java/com/github/weisj/darklaf/color/DarkColorModelHSL.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.color; @@ -87,13 +88,13 @@ public class DarkColorModelHSL extends DarkColorModel { double saturation = (max - min); if (saturation > 0.0f) { saturation /= (summa > 1.0f) - ? 2.0f - summa - : summa; + ? 2.0f - summa + : summa; } return new double[]{ - getHue(r / 255.0, g / 255.0, b / 255.0, max, min), - saturation, - summa / 2.0 + getHue(r / 255.0, g / 255.0, b / 255.0, max, min), + saturation, + summa / 2.0 }; } @@ -115,7 +116,6 @@ public class DarkColorModelHSL extends DarkColorModel { return Math.min(min, blue); } - private static double getHue(final double red, final double green, final double blue, final double max, final double min) { double hue = max - min; @@ -127,7 +127,7 @@ public class DarkColorModelHSL extends DarkColorModel { } } else if (max == green) { hue = 2.0f + (blue - red) / hue; - } else /*max == blue*/ { + } else /* max == blue */ { hue = 4.0f + (red - green) / hue; } hue /= 6.0f; @@ -143,7 +143,8 @@ public class DarkColorModelHSL extends DarkColorModel { private static int[] HSLtoRGB(final double h, final double saturation, final double lightness) { double hue = h; - while (hue < 0) hue += 1; + while (hue < 0) + hue += 1; hue = hue - Math.floor(hue); if (saturation > 0.0f) { hue = (hue < 1.0f) ? hue * 6.0f : 0.0f; diff --git a/core/src/main/java/com/github/weisj/darklaf/color/DarkColorModelRGB.java b/core/src/main/java/com/github/weisj/darklaf/color/DarkColorModelRGB.java index 1adff6e2..970303c8 100644 --- a/core/src/main/java/com/github/weisj/darklaf/color/DarkColorModelRGB.java +++ b/core/src/main/java/com/github/weisj/darklaf/color/DarkColorModelRGB.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.color; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/ArrowButton.java b/core/src/main/java/com/github/weisj/darklaf/components/ArrowButton.java index 43f158eb..d8e74dc7 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/ArrowButton.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/ArrowButton.java @@ -20,26 +20,25 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components; -import com.github.weisj.darklaf.icons.UIAwareIcon; -import com.github.weisj.darklaf.ui.button.DarkButtonUI; +import java.awt.*; import javax.swing.*; import javax.swing.plaf.DimensionUIResource; import javax.swing.plaf.basic.BasicArrowButton; -import java.awt.*; + +import com.github.weisj.darklaf.icons.UIAwareIcon; +import com.github.weisj.darklaf.ui.button.DarkButtonUI; /** * @author Jannis Weis */ public final class ArrowButton implements SwingConstants { - - private ArrowButton() { - } - + private ArrowButton() {} public static JButton createUpDownArrow(final JComponent parent, final int orientation, final boolean center) { @@ -47,25 +46,23 @@ public final class ArrowButton implements SwingConstants { new Insets(0, 0, 0, 0)); } - public static JButton createUpDownArrow(final JComponent parent, final int orientation, final boolean center, final boolean applyInsetsOnSize, final Insets insets) { UIAwareIcon icon; switch (orientation) { - case NORTH: + case NORTH : icon = (UIAwareIcon) UIManager.getIcon("ArrowButton.up.icon"); break; - case SOUTH: + case SOUTH : icon = (UIAwareIcon) UIManager.getIcon("ArrowButton.down.icon"); break; - default: + default : throw new IllegalStateException("Invalid button orientation: " + orientation); } return createUpDownArrow(parent, icon, icon.getDual(), orientation, center, applyInsetsOnSize, insets); } - public static JButton createUpDownArrow(final JComponent parent, final Icon activeIcon, final Icon inactiveIcon, final int orientation, final boolean center, @@ -105,13 +102,11 @@ public final class ArrowButton implements SwingConstants { getIcon().paintIcon(this, g, x, y); } - @Override public Insets getInsets() { return getInsets(new Insets(0, 0, 0, 0)); } - @Override public Insets getInsets(final Insets i) { i.left = insets.left; @@ -121,7 +116,6 @@ public final class ArrowButton implements SwingConstants { return i; } - @Override public boolean isOpaque() { return false; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/ClosableTabComponent.java b/core/src/main/java/com/github/weisj/darklaf/components/ClosableTabComponent.java index 69ce28c7..943cc55e 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/ClosableTabComponent.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/ClosableTabComponent.java @@ -20,16 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components; -import com.github.weisj.darklaf.ui.button.DarkButtonUI; -import com.github.weisj.darklaf.ui.tabbedpane.DarkTabbedPaneUI; +import java.awt.*; +import java.awt.event.*; import javax.swing.*; import javax.swing.plaf.ComponentUI; -import java.awt.*; -import java.awt.event.*; + +import com.github.weisj.darklaf.ui.button.DarkButtonUI; +import com.github.weisj.darklaf.ui.tabbedpane.DarkTabbedPaneUI; /** * @author Jannis Weis diff --git a/core/src/main/java/com/github/weisj/darklaf/components/ClosableTabbedPane.java b/core/src/main/java/com/github/weisj/darklaf/components/ClosableTabbedPane.java index 948f6f4f..df01674d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/ClosableTabbedPane.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/ClosableTabbedPane.java @@ -20,14 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components; -import javax.swing.*; import java.awt.*; import java.beans.PropertyVetoException; import java.beans.VetoableChangeListener; +import javax.swing.*; + /** * @author Jannis Weis */ @@ -86,12 +88,12 @@ public class ClosableTabbedPane extends JTabbedPane { private void notifyTabListeners(final TabEvent event) { TabListener[] listeners = listenerList.getListeners(TabListener.class); switch (event.getID()) { - case TabEvent.TAB_CLOSED: + case TabEvent.TAB_CLOSED : for (TabListener l : listeners) { l.tabClosed(event); } break; - case TabEvent.TAB_OPENED: + case TabEvent.TAB_OPENED : for (TabListener l : listeners) { l.tabOpened(event); } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/ColorPipetteBase.java b/core/src/main/java/com/github/weisj/darklaf/components/ColorPipetteBase.java index a7dab824..0eea15db 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/ColorPipetteBase.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/ColorPipetteBase.java @@ -20,23 +20,23 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ - package com.github.weisj.darklaf.components; +import java.awt.*; +import java.awt.event.AWTEventListener; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; + +import javax.swing.*; +import javax.swing.plaf.basic.BasicRootPaneUI; import com.github.weisj.darklaf.ui.colorchooser.ColorListener; import com.github.weisj.darklaf.ui.colorchooser.ColorPipette; import com.github.weisj.darklaf.ui.rootpane.DarkRootPaneUI; import com.github.weisj.darklaf.util.DarkUIUtil; -import javax.swing.*; -import javax.swing.plaf.basic.BasicRootPaneUI; -import java.awt.*; -import java.awt.event.AWTEventListener; -import java.awt.event.KeyEvent; -import java.awt.event.MouseEvent; - public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener { protected final JComponent parent; protected final Robot robot; @@ -55,7 +55,6 @@ public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener robot = createRobot(); } - private static Robot createRobot() { try { return new Robot(); @@ -80,7 +79,6 @@ public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener return robot.getPixelColor(location.x, location.y); } - protected Color getInitialColor() { return initialColor; } @@ -91,7 +89,6 @@ public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener setColor(initialColor); } - @Override public Color getColor() { return currentColor; @@ -106,8 +103,8 @@ public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener Window picker = getOrCreatePickerWindow(); Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_MOTION_EVENT_MASK - | AWTEvent.MOUSE_EVENT_MASK - | AWTEvent.KEY_EVENT_MASK); + | AWTEvent.MOUSE_EVENT_MASK + | AWTEvent.KEY_EVENT_MASK); updateLocation(); picker.setVisible(true); return picker; @@ -138,7 +135,6 @@ public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener Toolkit.getDefaultToolkit().removeAWTEventListener(this); } - protected Window getOrCreatePickerWindow() { if (pickerWindow == null) { Window owner = SwingUtilities.getWindowAncestor(parent); @@ -152,7 +148,6 @@ public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener return pickerWindow; } - protected Point updateLocation() { PointerInfo pointerInfo = MouseInfo.getPointerInfo(); if (pointerInfo == null) return null; @@ -169,7 +164,6 @@ public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener return new PickerWindow(); } - protected Window getPickerWindow() { return pickerWindow; } @@ -183,23 +177,23 @@ public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener public void eventDispatched(final AWTEvent event) { if (pickerWindow == null || !pickerWindow.isVisible()) return; switch (event.getID()) { - case MouseEvent.MOUSE_PRESSED: + case MouseEvent.MOUSE_PRESSED : ((MouseEvent) event).consume(); pickAndClose(); break; - case MouseEvent.MOUSE_CLICKED: + case MouseEvent.MOUSE_CLICKED : ((MouseEvent) event).consume(); break; - case KeyEvent.KEY_PRESSED: + case KeyEvent.KEY_PRESSED : downKeyCode = ((KeyEvent) event).getKeyCode(); switch (downKeyCode) { - case KeyEvent.VK_ESCAPE: + case KeyEvent.VK_ESCAPE : cancelPipette(); break; - case KeyEvent.VK_ENTER: + case KeyEvent.VK_ENTER : pickAndClose(); break; - default: + default : break; } if (!keyDown) { @@ -207,14 +201,14 @@ public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener updatePipette(true); } break; - case KeyEvent.KEY_RELEASED: + case KeyEvent.KEY_RELEASED : keyDown = false; Window picker = getPickerWindow(); if (picker != null) { picker.repaint(); } break; - default: + default : break; } } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/ColoredRadioButton.java b/core/src/main/java/com/github/weisj/darklaf/components/ColoredRadioButton.java index a6b8e402..3218cd71 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/ColoredRadioButton.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/ColoredRadioButton.java @@ -20,9 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components; +import java.awt.*; +import java.util.Properties; + +import javax.swing.*; +import javax.swing.plaf.ButtonUI; + import com.github.weisj.darklaf.DarkLaf; import com.github.weisj.darklaf.LafManager; import com.github.weisj.darklaf.PropertyLoader; @@ -32,11 +39,6 @@ import com.github.weisj.darklaf.task.AccentColorAdjustmentTask; import com.github.weisj.darklaf.theme.Theme; import com.github.weisj.darklaf.ui.togglebutton.radiobutton.DarkRadioButtonUI; -import javax.swing.*; -import javax.swing.plaf.ButtonUI; -import java.awt.*; -import java.util.Properties; - public class ColoredRadioButton extends JRadioButton { public static final Color DEFAULT_FILLED = new Color(0); @@ -73,35 +75,35 @@ public class ColoredRadioButton extends JRadioButton { protected static class ColoredRadioButtonUI extends DarkRadioButtonUI { private static final String[] PROPERTIES = { - "Icons.RadioButton.activeFillColor", - "Icons.RadioButton.activeBorderColor", - "Icons.RadioButtonDisabled.inactiveFillColor", - "Icons.RadioButtonDisabled.inactiveBorderColor", - "Icons.RadioButtonFocused.activeFillColor", - "Icons.RadioButtonFocused.focusBorderColor", - "Icons.RadioButtonFocused.glowFocus", - "Icons.RadioButtonFocused.glowOpacity", - "Icons.RadioButtonSelected.selectedFillColor", - "Icons.RadioButtonSelected.selectedBorderColor", - "Icons.RadioButtonSelected.selectionSelectedColor", - "Icons.RadioButtonSelectedDisabled.inactiveFillColor", - "Icons.RadioButtonSelectedDisabled.inactiveBorderColor", - "Icons.RadioButtonSelectedDisabled.selectionDisabledColor", - "Icons.RadioButtonSelectedFocused.selectedFillColor", - "Icons.RadioButtonSelectedFocused.focusSelectedBorderColor", - "Icons.RadioButtonSelectedFocused.selectionFocusSelectedColor", - "Icons.RadioButtonSelectedFocused.glowFocus", - "Icons.RadioButtonSelectedFocused.glowOpacity" + "Icons.RadioButton.activeFillColor", + "Icons.RadioButton.activeBorderColor", + "Icons.RadioButtonDisabled.inactiveFillColor", + "Icons.RadioButtonDisabled.inactiveBorderColor", + "Icons.RadioButtonFocused.activeFillColor", + "Icons.RadioButtonFocused.focusBorderColor", + "Icons.RadioButtonFocused.glowFocus", + "Icons.RadioButtonFocused.glowOpacity", + "Icons.RadioButtonSelected.selectedFillColor", + "Icons.RadioButtonSelected.selectedBorderColor", + "Icons.RadioButtonSelected.selectionSelectedColor", + "Icons.RadioButtonSelectedDisabled.inactiveFillColor", + "Icons.RadioButtonSelectedDisabled.inactiveBorderColor", + "Icons.RadioButtonSelectedDisabled.selectionDisabledColor", + "Icons.RadioButtonSelectedFocused.selectedFillColor", + "Icons.RadioButtonSelectedFocused.focusSelectedBorderColor", + "Icons.RadioButtonSelectedFocused.selectionFocusSelectedColor", + "Icons.RadioButtonSelectedFocused.glowFocus", + "Icons.RadioButtonSelectedFocused.glowOpacity" }; private static final String[] COLOR_PROPERTIES = { - "Icons.RadioButton.activeFillColor", - "Icons.RadioButton.activeBorderColor", - "Icons.RadioButtonFocused.activeFillColor", - "Icons.RadioButtonFocused.focusBorderColor", - "Icons.RadioButtonSelected.selectedFillColor", - "Icons.RadioButtonSelected.selectedBorderColor", - "Icons.RadioButtonSelectedFocused.selectedFillColor", - "Icons.RadioButtonSelectedFocused.focusSelectedBorderColor" + "Icons.RadioButton.activeFillColor", + "Icons.RadioButton.activeBorderColor", + "Icons.RadioButtonFocused.activeFillColor", + "Icons.RadioButtonFocused.focusBorderColor", + "Icons.RadioButtonSelected.selectedFillColor", + "Icons.RadioButtonSelected.selectedBorderColor", + "Icons.RadioButtonSelectedFocused.selectedFillColor", + "Icons.RadioButtonSelectedFocused.focusSelectedBorderColor" }; private Properties propertyMap; @@ -129,12 +131,11 @@ public class ColoredRadioButton extends JRadioButton { theme.loadDefaults(props, defaults); Color c = color == DEFAULT_FILLED ? (Color) props.get("widgetFillDefault") : color; adjustment.applyColors(LafManager.getTheme(), props, c, null); - PropertyLoader.putProperties( - PropertyLoader.loadProperties(DarkLaf.class, "radioButton", "properties/ui/"), - props, defaults); - PropertyLoader.putProperties( - PropertyLoader.loadProperties(DarkLaf.class, "radioButton", "properties/icons/"), - props, defaults); + PropertyLoader.putProperties(PropertyLoader.loadProperties(DarkLaf.class, "radioButton", "properties/ui/"), + props, defaults); + PropertyLoader.putProperties(PropertyLoader.loadProperties(DarkLaf.class, "radioButton", + "properties/icons/"), + props, defaults); propertyMap = new Properties(); for (String prop : PROPERTIES) { propertyMap.put(prop, props.get(prop)); @@ -144,12 +145,12 @@ public class ColoredRadioButton extends JRadioButton { } stateIcon = new StateIcon(new Icon[]{ - load(loader, "control/radio.svg"), - load(loader, "control/radioDisabled.svg"), - load(loader, "control/radioFocused.svg"), - load(loader, "control/radioSelected.svg"), - load(loader, "control/radioSelectedDisabled.svg"), - load(loader, "control/radioSelectedFocused.svg") + load(loader, "control/radio.svg"), + load(loader, "control/radioDisabled.svg"), + load(loader, "control/radioFocused.svg"), + load(loader, "control/radioSelected.svg"), + load(loader, "control/radioSelectedDisabled.svg"), + load(loader, "control/radioSelectedFocused.svg") }); } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/DefaultButton.java b/core/src/main/java/com/github/weisj/darklaf/components/DefaultButton.java index f07195b7..c62d00e0 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/DefaultButton.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/DefaultButton.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/DefaultColorPipette.java b/core/src/main/java/com/github/weisj/darklaf/components/DefaultColorPipette.java index 52ff66c9..213bdd99 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/DefaultColorPipette.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/DefaultColorPipette.java @@ -20,20 +20,22 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components; -import com.github.weisj.darklaf.ui.colorchooser.ColorListener; -import com.github.weisj.darklaf.util.GraphicsContext; -import com.github.weisj.darklaf.util.GraphicsUtil; -import com.github.weisj.darklaf.util.TimerUtil; - -import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.awt.geom.Ellipse2D; import java.awt.image.BufferedImage; +import javax.swing.*; + +import com.github.weisj.darklaf.ui.colorchooser.ColorListener; +import com.github.weisj.darklaf.util.GraphicsContext; +import com.github.weisj.darklaf.util.GraphicsUtil; +import com.github.weisj.darklaf.util.TimerUtil; + public class DefaultColorPipette extends ColorPipetteBase { private static final int SIZE = 36; private static final int DIALOG_SIZE = 50; @@ -196,7 +198,7 @@ public class DefaultColorPipette extends ColorPipetteBase { GraphicsUtil.setupStrokePainting(g2); Graphics2D g = (Graphics2D) g2; - //Draw region to be recognised as inside the window. + // Draw region to be recognised as inside the window. g.setColor(Color.WHITE); GraphicsContext config = GraphicsUtil.paintWithAlpha(g, 0.005f); Point p = MouseInfo.getPointerInfo().getLocation(); diff --git a/core/src/main/java/com/github/weisj/darklaf/components/Disposable.java b/core/src/main/java/com/github/weisj/darklaf/components/Disposable.java index 9ebdb1f4..52586152 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/Disposable.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/Disposable.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/JXPopupMenu.java b/core/src/main/java/com/github/weisj/darklaf/components/JXPopupMenu.java index cf0c1692..88d8598c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/JXPopupMenu.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/JXPopupMenu.java @@ -20,16 +20,19 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components; -import com.github.weisj.darklaf.util.DarkUIUtil; +import java.awt.*; +import java.awt.geom.AffineTransform; + +import javax.swing.*; + import org.jdesktop.jxlayer.JXLayer; import org.pbjar.jxlayer.plaf.ext.TransformUI; -import javax.swing.*; -import java.awt.*; -import java.awt.geom.AffineTransform; +import com.github.weisj.darklaf.util.DarkUIUtil; /** * Popup menu that is aware of {@link org.pbjar.jxlayer.plaf.ext.TransformUI}. diff --git a/core/src/main/java/com/github/weisj/darklaf/components/OverlayScrollPane.java b/core/src/main/java/com/github/weisj/darklaf/components/OverlayScrollPane.java index 1ecbf14a..d02efb7b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/OverlayScrollPane.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/OverlayScrollPane.java @@ -20,14 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components; -import com.github.weisj.darklaf.ui.scrollpane.ScrollLayoutManagerDelegate; +import java.awt.*; import javax.swing.*; import javax.swing.plaf.ScrollPaneUI; -import java.awt.*; + +import com.github.weisj.darklaf.ui.scrollpane.ScrollLayoutManagerDelegate; /** * Scroll pane that displays its content beneath the scrollbar. @@ -54,7 +56,7 @@ public class OverlayScrollPane extends JLayeredPane { * scrolling in underway or the mouse is over the scrollbar position. * * @param view the component to display in the scrollable viewport - * @see JScrollPane#setViewportView + * @see JScrollPane#setViewportView */ public OverlayScrollPane(final JComponent view) { this(view, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); @@ -64,7 +66,8 @@ public class OverlayScrollPane extends JLayeredPane { * Creates a JScrollIndicator that displays the view component in a viewport whose view position can be controlled * with a pair of scrollbars. The scrollbar policies specify when the scrollbars are displayed, For example, if * vsbPolicy is JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED then the vertical scrollbar only appears if the view - * doesn't fit vertically. The available policy settings are listed at {@link JScrollPane#setVerticalScrollBarPolicy(int)} + * doesn't fit vertically. The available policy settings are listed at + * {@link JScrollPane#setVerticalScrollBarPolicy(int)} * and {@link JScrollPane#setHorizontalScrollBarPolicy}. * * @param view the view of the component. @@ -89,7 +92,6 @@ public class OverlayScrollPane extends JLayeredPane { * * @return the scrollPane */ - public JScrollPane getScrollPane() { return scrollPane; } @@ -111,7 +113,6 @@ public class OverlayScrollPane extends JLayeredPane { controlPanel.showHorizontalScrollBar(policy != JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); } - public JScrollBar getVerticalScrollBar() { return scrollPane.verticalScrollBar; } @@ -121,7 +122,6 @@ public class OverlayScrollPane extends JLayeredPane { return scrollPane.getPreferredSize(); } - public JScrollBar getHorizontalScrollBar() { return scrollPane.horizontalScrollBar; } @@ -148,7 +148,6 @@ public class OverlayScrollPane extends JLayeredPane { private JScrollBar verticalScrollBar; private JScrollBar horizontalScrollBar; - protected OScrollPane(final JComponent view, final int vsbPolicy, final int hsbPolicy) { super(view, vsbPolicy, hsbPolicy); } @@ -294,12 +293,9 @@ public class OverlayScrollPane extends JLayeredPane { && scrollPane.verticalScrollBar.getBounds().contains(x, y); } - @Override public boolean isOpaque() { return false; } } - - } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/ScrollPopupMenu.java b/core/src/main/java/com/github/weisj/darklaf/components/ScrollPopupMenu.java index 12a1cb17..2e1f3910 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/ScrollPopupMenu.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/ScrollPopupMenu.java @@ -20,14 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components; -import com.github.weisj.darklaf.ui.popupmenu.PopupMenuContainer; -import com.github.weisj.darklaf.util.PropertyKey; +import java.awt.*; import javax.swing.*; -import java.awt.*; + +import com.github.weisj.darklaf.ui.popupmenu.PopupMenuContainer; +import com.github.weisj.darklaf.util.PropertyKey; /** * @author Jannis Weis @@ -84,7 +86,6 @@ public class ScrollPopupMenu extends JPopupMenu { posY = y; } - @Override public void setVisible(final boolean b) { if (b == isVisible()) { @@ -126,8 +127,7 @@ public class ScrollPopupMenu extends JPopupMenu { } @Override - public void pack() { - } + public void pack() {} private boolean isPopupMenu() { Component invoker = getInvoker(); diff --git a/core/src/main/java/com/github/weisj/darklaf/components/SelectableTreeNode.java b/core/src/main/java/com/github/weisj/darklaf/components/SelectableTreeNode.java index 3d17e27b..c17bdc1b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/SelectableTreeNode.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/SelectableTreeNode.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/TabEvent.java b/core/src/main/java/com/github/weisj/darklaf/components/TabEvent.java index 79c98b7d..9a4d0960 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/TabEvent.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/TabEvent.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/TabListener.java b/core/src/main/java/com/github/weisj/darklaf/components/TabListener.java index 86ee479e..6a77c62a 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/TabListener.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/TabListener.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/TabPropertyChangeEvent.java b/core/src/main/java/com/github/weisj/darklaf/components/TabPropertyChangeEvent.java index e388e925..7acfba38 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/TabPropertyChangeEvent.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/TabPropertyChangeEvent.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/VolumeSlider.java b/core/src/main/java/com/github/weisj/darklaf/components/VolumeSlider.java index 18d30332..48814aac 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/VolumeSlider.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/VolumeSlider.java @@ -20,13 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components; -import com.github.weisj.darklaf.ui.slider.DarkSliderUI; - import javax.swing.*; +import com.github.weisj.darklaf.ui.slider.DarkSliderUI; + public class VolumeSlider extends JSlider { private boolean showVolumeIcon; @@ -38,79 +39,75 @@ public class VolumeSlider extends JSlider { this(HORIZONTAL, 0, 100, 50); } - /** * Creates a slider using the specified orientation with the range {@code 0} to {@code 100} and an initial value of * {@code 50}. The orientation can be either SwingConstants.VERTICAL or * SwingConstants.HORIZONTAL. * - * @param orientation the orientation of the slider + * @param orientation the orientation of the slider * @throws IllegalArgumentException if orientation is not one of {@code VERTICAL}, {@code HORIZONTAL} - * @see #setOrientation + * @see #setOrientation */ public VolumeSlider(final int orientation) { this(orientation, 0, 100, 50); } - /** * Creates a horizontal slider using the specified min and max with an initial value equal to the average of the min * plus max. *

* The BoundedRangeModel that holds the slider's data handles any issues that may arise from improperly - * setting the minimum and maximum values on the slider. See the {@code BoundedRangeModel} documentation for + * setting the minimum and maximum values on the slider. See the {@code BoundedRangeModel} documentation for * details. * * @param min the minimum value of the slider * @param max the maximum value of the slider - * @see BoundedRangeModel - * @see #setMinimum - * @see #setMaximum + * @see BoundedRangeModel + * @see #setMinimum + * @see #setMaximum */ public VolumeSlider(final int min, final int max) { this(HORIZONTAL, min, max, (min + max) / 2); } - /** * Creates a horizontal slider using the specified min, max and value. *

* The BoundedRangeModel that holds the slider's data handles any issues that may arise from improperly - * setting the minimum, initial, and maximum values on the slider. See the {@code BoundedRangeModel} documentation + * setting the minimum, initial, and maximum values on the slider. See the {@code BoundedRangeModel} documentation * for details. * * @param min the minimum value of the slider * @param max the maximum value of the slider * @param value the initial value of the slider - * @see BoundedRangeModel - * @see #setMinimum - * @see #setMaximum - * @see #setValue + * @see BoundedRangeModel + * @see #setMinimum + * @see #setMaximum + * @see #setValue */ public VolumeSlider(final int min, final int max, final int value) { this(HORIZONTAL, min, max, value); } - /** * Creates a slider with the specified orientation and the specified minimum, maximum, and initial values. The * orientation can be either SwingConstants.VERTICAL or * SwingConstants.HORIZONTAL. *

* The BoundedRangeModel that holds the slider's data handles any issues that may arise from improperly - * setting the minimum, initial, and maximum values on the slider. See the {@code BoundedRangeModel} documentation + * setting the minimum, initial, and maximum values on the slider. See the {@code BoundedRangeModel} documentation * for details. * - * @param orientation the orientation of the slider - * @param min the minimum value of the slider - * @param max the maximum value of the slider - * @param value the initial value of the slider + * @param orientation the orientation of the slider + * @param min the minimum value of the slider + * @param max the maximum value of the slider + * @param value the initial value of the slider * @throws IllegalArgumentException if orientation is not one of {@code VERTICAL}, {@code HORIZONTAL} - * @see BoundedRangeModel - * @see #setOrientation - * @see #setMinimum - * @see #setMaximum - * @see #setValue + * @see BoundedRangeModel + * @see #setOrientation + * @see #setMinimum + * @see #setMaximum + * @see #setValue */ public VolumeSlider(final int orientation, final int min, final int max, final int value) { super(orientation, min, max, value); diff --git a/core/src/main/java/com/github/weisj/darklaf/components/alignment/AlignmentStrategy.java b/core/src/main/java/com/github/weisj/darklaf/components/alignment/AlignmentStrategy.java index f2d145f5..9504ce0f 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/alignment/AlignmentStrategy.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/alignment/AlignmentStrategy.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.alignment; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/border/BubbleBorder.java b/core/src/main/java/com/github/weisj/darklaf/components/border/BubbleBorder.java index dd8d37db..a45d6f3e 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/border/BubbleBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/border/BubbleBorder.java @@ -20,20 +20,22 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.border; -import com.github.weisj.darklaf.util.Alignment; -import com.github.weisj.darklaf.util.GraphicsContext; -import com.github.weisj.darklaf.util.GraphicsUtil; - -import javax.swing.border.AbstractBorder; -import javax.swing.plaf.InsetsUIResource; import java.awt.*; import java.awt.geom.Area; import java.awt.geom.Path2D; import java.awt.geom.RoundRectangle2D; +import javax.swing.border.AbstractBorder; +import javax.swing.plaf.InsetsUIResource; + +import com.github.weisj.darklaf.util.Alignment; +import com.github.weisj.darklaf.util.GraphicsContext; +import com.github.weisj.darklaf.util.GraphicsUtil; + /** * @author Jannis Weis */ @@ -89,10 +91,9 @@ public class BubbleBorder extends AbstractBorder { /** * Set the border colour. * - * @param color border colour - * @return this + * @param color border colour + * @return this */ - public BubbleBorder setColor(final Color color) { this.color = color; return this; @@ -110,15 +111,14 @@ public class BubbleBorder extends AbstractBorder { /** * Set the with of the pointer base. * - * @param pointerWidth the width of the pointer base. - * @return this + * @param pointerWidth the width of the pointer base. + * @return this */ public BubbleBorder setPointerWidth(final int pointerWidth) { this.pointerWidth = pointerWidth; return this; } - /** * Get the border thickness. * @@ -131,10 +131,9 @@ public class BubbleBorder extends AbstractBorder { /** * Set the border thickness. * - * @param n new thickness - * @return this + * @param n new thickness + * @return this */ - public BubbleBorder setThickness(final int n) { thickness = Math.max(n, 0); return setPointerSize(pointerSize); @@ -152,10 +151,9 @@ public class BubbleBorder extends AbstractBorder { /** * Set the pointer size Clips at 0. * - * @param size size of pointer. - * @return this + * @param size size of pointer. + * @return this */ - public BubbleBorder setPointerSize(final int size) { pointerSize = Math.max(size, 0); float left = thickness; @@ -164,23 +162,23 @@ public class BubbleBorder extends AbstractBorder { float top = thickness; switch (pointerSide) { - case NORTH: - case NORTH_WEST: - case NORTH_EAST: + case NORTH : + case NORTH_WEST : + case NORTH_EAST : top += pointerSize; break; - case SOUTH: - case SOUTH_WEST: - case SOUTH_EAST: + case SOUTH : + case SOUTH_WEST : + case SOUTH_EAST : bottom += pointerSize; break; - case WEST: + case WEST : left += pointerSize; break; - case EAST: + case EAST : right += pointerSize; break; - default: + default : break; } insets.set((int) top, (int) left, (int) bottom, (int) right); @@ -199,10 +197,9 @@ public class BubbleBorder extends AbstractBorder { /** * Set the corner radius. * - * @param radius radius of corner. - * @return this + * @param radius radius of corner. + * @return this */ - public BubbleBorder setRadius(final int radius) { this.radius = radius; return setPointerSize(pointerSize); @@ -222,10 +219,9 @@ public class BubbleBorder extends AbstractBorder { * Alignment#NORTH_EAST} and {@link Alignment#NORTH_WEST} as well as {@link Alignment#SOUTH}, {@link * Alignment#SOUTH_EAST} and {@link Alignment#SOUTH_WEST} {@link Alignment#CENTER} results in no pointer. * - * @param side direction in which the pointer should point. - * @return this. + * @param side direction in which the pointer should point. + * @return this. */ - public BubbleBorder setPointerSide(final Alignment side) { this.pointerSide = side; setPointerSize(pointerSize); @@ -236,27 +232,26 @@ public class BubbleBorder extends AbstractBorder { return (float) calculatePointerPad(w, h, Alignment.NORTH_WEST); } - private double calculatePointerPad(final float width, final float height, final Alignment side) { double pointerPad; switch (side) { - case WEST: - case EAST: + case WEST : + case EAST : pointerPad = radius + (height - insets.top - insets.bottom - 2 * radius) / 2.0; break; - case NORTH_WEST: - case SOUTH_WEST: + case NORTH_WEST : + case SOUTH_WEST : pointerPad = radius + insets.left + pointerWidth; break; - case NORTH_EAST: - case SOUTH_EAST: + case NORTH_EAST : + case SOUTH_EAST : pointerPad = width - radius - insets.right - pointerWidth; break; - case SOUTH: - case NORTH: + case SOUTH : + case NORTH : pointerPad = radius + (0.5 * (width - insets.left - insets.right - 2 * radius)); break; - default: + default : pointerPad = 0; break; } @@ -270,13 +265,11 @@ public class BubbleBorder extends AbstractBorder { paintBorder(g, area); } - @Override public Insets getBorderInsets(final Component c) { return new InsetsUIResource(insets.top, insets.left, insets.bottom, insets.right); } - @Override public Insets getBorderInsets(final Component c, final Insets insets) { return getBorderInsets(c); @@ -294,15 +287,15 @@ public class BubbleBorder extends AbstractBorder { if (pointerSide != Alignment.CENTER) { double pointerPad = calculatePointerPad(w, h, pointerSide); switch (pointerSide) { - case SOUTH_EAST: - case NORTH_EAST: + case SOUTH_EAST : + case NORTH_EAST : if (inner) pointerPad += adj; break; - case NORTH_WEST: - case SOUTH_WEST: + case NORTH_WEST : + case SOUTH_WEST : if (inner) pointerPad -= adj; break; - default: + default : break; } Path2D pointer = creatPointerShape(pointerPad, pSize, pWidth, bubble); @@ -326,14 +319,12 @@ public class BubbleBorder extends AbstractBorder { config.restore(); } - public RoundRectangle2D.Float calculateBubbleRect(final float x, final float y, final float width, final float height) { return new RoundRectangle2D.Float(x + insets.left, y + insets.top, width - insets.left - insets.right, height - insets.top - insets.bottom, radius, radius); } - private Path2D creatPointerShape(final double pointerPad, final double pSize, final double pWidth, final RoundRectangle2D.Float bubble) { final double w = pWidth / 2.0; @@ -341,31 +332,31 @@ public class BubbleBorder extends AbstractBorder { double x = bubble.x; double y = bubble.y; switch (pointerSide) { - case WEST: - pointer.moveTo(x, y + pointerPad - w); //Top + case WEST : + pointer.moveTo(x, y + pointerPad - w); // Top pointer.lineTo(x - pSize, y + pointerPad); pointer.lineTo(x, y + pointerPad + w);// bottom break; - case EAST: + case EAST : pointer.moveTo(x + bubble.width, y + pointerPad - w);// top pointer.lineTo(x + bubble.width + pSize, y + pointerPad); pointer.lineTo(x + bubble.width, y + pointerPad + w);// bottom break; - case NORTH: - case NORTH_WEST: - case NORTH_EAST: + case NORTH : + case NORTH_WEST : + case NORTH_EAST : pointer.moveTo(x + pointerPad - w, y);// left pointer.lineTo(x + pointerPad, y - pSize); pointer.lineTo(x + pointerPad + w, y);// right break; - case SOUTH: - case SOUTH_WEST: - case SOUTH_EAST: + case SOUTH : + case SOUTH_WEST : + case SOUTH_EAST : pointer.moveTo(x + pointerPad - w, y + bubble.height);// left pointer.lineTo(x + pointerPad, y + bubble.height + pSize); pointer.lineTo(x + pointerPad + w, y + bubble.height);// right break; - default: + default : break; } pointer.closePath(); diff --git a/core/src/main/java/com/github/weisj/darklaf/components/border/DarkBorders.java b/core/src/main/java/com/github/weisj/darklaf/components/border/DarkBorders.java index fdd01a88..9005fa49 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/border/DarkBorders.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/border/DarkBorders.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.border; -import javax.swing.border.Border; import java.awt.*; +import javax.swing.border.Border; + public final class DarkBorders { private static DarkLineBorder sharedBorderEmpty; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/border/DarkLineBorder.java b/core/src/main/java/com/github/weisj/darklaf/components/border/DarkLineBorder.java index 681c9d29..851bae0d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/border/DarkLineBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/border/DarkLineBorder.java @@ -20,17 +20,19 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.border; +import java.awt.*; +import java.util.function.Function; + +import javax.swing.*; + import com.github.weisj.darklaf.DarkLaf; import com.github.weisj.darklaf.LafManager; import com.github.weisj.darklaf.theme.Theme; -import javax.swing.*; -import java.awt.*; -import java.util.function.Function; - public class DarkLineBorder extends MutableLineBorder { private final String key; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/border/DropShadowBorder.java b/core/src/main/java/com/github/weisj/darklaf/components/border/DropShadowBorder.java index 2c06f1de..442dd3f5 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/border/DropShadowBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/border/DropShadowBorder.java @@ -20,13 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.border; - -import com.github.weisj.darklaf.util.ImageUtil; - -import javax.swing.border.Border; import java.awt.*; import java.awt.geom.RoundRectangle2D; import java.awt.image.BufferedImage; @@ -37,17 +34,24 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Map; +import javax.swing.border.Border; + +import com.github.weisj.darklaf.util.ImageUtil; + /** * Implements a DropShadow for components. In general, the DropShadowBorder will work with any rectangular components * that do not have a default border installed as part of the look and feel, or otherwise. For example, DropShadowBorder * works wonderfully with JPanel, but horribly with JComboBox. *

* Note: {@code DropShadowBorder} should usually be added to non-opaque components, otherwise the background is likely - * to bleed through.

- *

Note: Since generating drop shadows is relatively expensive operation, + * to bleed through. + *

+ *

+ * Note: Since generating drop shadows is relatively expensive operation, * {@code DropShadowBorder} keeps internal static cache that allows sharing same border for multiple re-rendering and * between different instances of the class. Since this cache is shared at class level and never reset, it might bleed - * your app memory in case you tend to create many different borders rapidly.

+ * your app memory in case you tend to create many different borders rapidly. + *

* * @author rbair Adaptions made by * @author Jannis Weis @@ -63,18 +67,15 @@ public class DropShadowBorder implements Border, Serializable { private boolean showBottomShadow; private boolean showRightShadow; - public DropShadowBorder() { this(Color.BLACK, 5); } - public DropShadowBorder(final Color shadowColor, final int shadowSize) { this(shadowColor, shadowSize, .5f, 12, false, true, true, true); } - public DropShadowBorder(final Color shadowColor, final int shadowSize, final float shadowOpacity, final int cornerSize, final boolean showTopShadow, final boolean showLeftShadow, final boolean showBottomShadow, @@ -89,7 +90,6 @@ public class DropShadowBorder implements Border, Serializable { setShowRightShadow(showRightShadow); } - @Override public void paintBorder(final Component c, final Graphics graphics, final int x, final int y, final int width, final int height) { @@ -102,14 +102,14 @@ public class DropShadowBorder implements Border, Serializable { Graphics2D g2 = (Graphics2D) graphics.create(); try { - //The location and size of the shadows depends on which shadows are being - //drawn. For instance, if the left & bottom shadows are being drawn, then - //the left shadow extends all the way down to the corner, a corner is drawn, - //and then the bottom shadow begins at the corner. If, however, only the - //bottom shadow is drawn, then the bottom-left corner is drawn to the - //right of the corner, and the bottom shadow is somewhat shorter than before. + // The location and size of the shadows depends on which shadows are being + // drawn. For instance, if the left & bottom shadows are being drawn, then + // the left shadow extends all the way down to the corner, a corner is drawn, + // and then the bottom shadow begins at the corner. If, however, only the + // bottom shadow is drawn, then the bottom-left corner is drawn to the + // right of the corner, and the bottom shadow is somewhat shorter than before. - int shadowOffset = 2; //the distance between the shadow and the edge + int shadowOffset = 2; // the distance between the shadow and the edge Point topLeftShadowPoint = null; if (showLeftShadow || showTopShadow) { @@ -166,9 +166,8 @@ public class DropShadowBorder implements Border, Serializable { if (showLeftShadow) { assert topLeftShadowPoint != null && bottomLeftShadowPoint != null; - Rectangle leftShadowRect = - new Rectangle(x, topLeftShadowPoint.y + shadowSize, shadowSize, - bottomLeftShadowPoint.y - topLeftShadowPoint.y - shadowSize); + Rectangle leftShadowRect = new Rectangle(x, topLeftShadowPoint.y + shadowSize, shadowSize, + bottomLeftShadowPoint.y - topLeftShadowPoint.y - shadowSize); g2.drawImage(images[Position.LEFT.ordinal()], leftShadowRect.x, leftShadowRect.y, leftShadowRect.width, leftShadowRect.height, null); @@ -176,10 +175,11 @@ public class DropShadowBorder implements Border, Serializable { if (showBottomShadow) { assert bottomLeftShadowPoint != null && bottomRightShadowPoint != null; - Rectangle bottomShadowRect = - new Rectangle(bottomLeftShadowPoint.x + shadowSize, y + height - shadowSize, - bottomRightShadowPoint.x - bottomLeftShadowPoint.x - shadowSize, - shadowSize); + Rectangle bottomShadowRect = new Rectangle(bottomLeftShadowPoint.x + shadowSize, + y + height - shadowSize, + bottomRightShadowPoint.x - bottomLeftShadowPoint.x + - shadowSize, + shadowSize); g2.drawImage(images[Position.BOTTOM.ordinal()], bottomShadowRect.x, bottomShadowRect.y, bottomShadowRect.width, bottomShadowRect.height, null); @@ -187,9 +187,10 @@ public class DropShadowBorder implements Border, Serializable { if (showRightShadow) { assert topRightShadowPoint != null && bottomRightShadowPoint != null; - Rectangle rightShadowRect = - new Rectangle(x + width - shadowSize, topRightShadowPoint.y + shadowSize, shadowSize, - bottomRightShadowPoint.y - topRightShadowPoint.y - shadowSize); + Rectangle rightShadowRect = new Rectangle(x + width - shadowSize, topRightShadowPoint.y + shadowSize, + shadowSize, + bottomRightShadowPoint.y - topRightShadowPoint.y + - shadowSize); g2.drawImage(images[Position.RIGHT.ordinal()], rightShadowRect.x, rightShadowRect.y, rightShadowRect.width, rightShadowRect.height, null); @@ -197,9 +198,9 @@ public class DropShadowBorder implements Border, Serializable { if (showTopShadow) { assert topLeftShadowPoint != null && topRightShadowPoint != null; - Rectangle topShadowRect = - new Rectangle(topLeftShadowPoint.x + shadowSize, y, - topRightShadowPoint.x - topLeftShadowPoint.x - shadowSize, shadowSize); + Rectangle topShadowRect = new Rectangle(topLeftShadowPoint.x + shadowSize, y, + topRightShadowPoint.x - topLeftShadowPoint.x - shadowSize, + shadowSize); g2.drawImage(images[Position.TOP.ordinal()], topShadowRect.x, topShadowRect.y, topShadowRect.width, topShadowRect.height, null); @@ -231,25 +232,25 @@ public class DropShadowBorder implements Border, Serializable { @SuppressWarnings("SuspiciousNameCombination") private BufferedImage[] getImages(final Graphics2D g2) { - //first, check to see if an image for this size has already been rendered - //if so, use the cache. Else, draw and save + // first, check to see if an image for this size has already been rendered + // if so, use the cache. Else, draw and save BufferedImage[] images = CACHE.get(getBorderHash(shadowSize, shadowOpacity, shadowColor)); if (images == null) { images = new BufferedImage[Position.count()]; /* * To draw a drop shadow, I have to: - * 1) Create a rounded rectangle - * 2) Create a BufferedImage to draw the rounded rect in - * 3) Translate the graphics for the image, so that the rectangle - * is centered in the drawn space. The border around the rectangle - * needs to be shadowWidth wide, so that there is space for the - * shadow to be drawn. - * 4) Draw the rounded rect as shadowColor, with an opacity of shadowOpacity - * 5) Create the BLUR_KERNEL - * 6) Blur the image - * 7) copy off the corners, sides, etc into images to be used for - * drawing the Border + * 1) Create a rounded rectangle + * 2) Create a BufferedImage to draw the rounded rect in + * 3) Translate the graphics for the image, so that the rectangle + * is centered in the drawn space. The border around the rectangle + * needs to be shadowWidth wide, so that there is space for the + * shadow to be drawn. + * 4) Draw the rounded rect as shadowColor, with an opacity of shadowOpacity + * 5) Create the BLUR_KERNEL + * 6) Blur the image + * 7) copy off the corners, sides, etc into images to be used for + * drawing the Border */ int rectWidth = cornerSize + 1; RoundRectangle2D rect = new RoundRectangle2D.Double(0, 0, rectWidth, rectWidth, cornerSize, cornerSize); @@ -328,10 +329,9 @@ public class DropShadowBorder implements Border, Serializable { } /** - * Returns a new BufferedImage that represents a subregion of the given BufferedImage. (Note that this method does + * Returns a new BufferedImage that represents a subregion of the given BufferedImage. (Note that this method does * not use BufferedImage.getSubimage(), which will defeat image acceleration strategies on later JDKs.) */ - private BufferedImage getSubImage(final BufferedImage img, final int x, final int y, final int w, final int h) { BufferedImage ret = ImageUtil.createCompatibleTranslucentImage(w, h); Graphics2D g2 = ret.createGraphics(); @@ -437,12 +437,17 @@ public class DropShadowBorder implements Border, Serializable { } private enum Position { - TOP, TOP_LEFT, LEFT, BOTTOM_LEFT, - BOTTOM, BOTTOM_RIGHT, RIGHT, TOP_RIGHT; + TOP, + TOP_LEFT, + LEFT, + BOTTOM_LEFT, + BOTTOM, + BOTTOM_RIGHT, + RIGHT, + TOP_RIGHT; static int count() { return 8; } } - } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/border/MutableLineBorder.java b/core/src/main/java/com/github/weisj/darklaf/components/border/MutableLineBorder.java index 774fd463..325f0a93 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/border/MutableLineBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/border/MutableLineBorder.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.border; -import javax.swing.border.AbstractBorder; import java.awt.*; +import javax.swing.border.AbstractBorder; + /** * @author Jannis Weis */ @@ -41,8 +43,7 @@ public class MutableLineBorder extends AbstractBorder { this(insets.top, insets.left, insets.bottom, insets.right, color); } - public MutableLineBorder( - final int top, final int left, final int bottom, final int right, final Color color) { + public MutableLineBorder(final int top, final int left, final int bottom, final int right, final Color color) { this.top = top; this.left = left; this.bottom = bottom; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/color/PopupColorChooser.java b/core/src/main/java/com/github/weisj/darklaf/components/color/PopupColorChooser.java index fc0ecb14..9e365f91 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/color/PopupColorChooser.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/color/PopupColorChooser.java @@ -20,9 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.color; +import java.awt.*; +import java.awt.event.*; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Consumer; + +import javax.swing.*; + import com.github.weisj.darklaf.components.tooltip.ToolTipContext; import com.github.weisj.darklaf.ui.DarkPopupFactory; import com.github.weisj.darklaf.ui.tooltip.DarkTooltipBorder; @@ -30,12 +38,6 @@ import com.github.weisj.darklaf.ui.tooltip.DarkTooltipUI; import com.github.weisj.darklaf.util.Alignment; import com.github.weisj.darklaf.util.DarkUIUtil; -import javax.swing.*; -import java.awt.*; -import java.awt.event.*; -import java.util.concurrent.atomic.AtomicReference; -import java.util.function.Consumer; - public class PopupColorChooser extends JToolTip { protected DarkTooltipBorder border; @@ -128,17 +130,17 @@ public class PopupColorChooser extends JToolTip { protected ToolTipContext createToolTipContext() { return new ToolTipContext() - .setAlignment(Alignment.CENTER) - .setCenterAlignment(Alignment.SOUTH) - .setUseBestFit(true) - .setToolTipInsets(new Insets(2, 2, 2, 2)) - .setFallBackPositionProvider(c -> { - Window window = DarkUIUtil.getWindow(c.getTarget()); - Dimension size = c.getToolTip().getPreferredSize(); - Rectangle bounds = window.getBounds(); - return new Point(bounds.x + (bounds.width - size.width) / 2, - bounds.y + (bounds.height - size.height) / 2); - }); + .setAlignment(Alignment.CENTER) + .setCenterAlignment(Alignment.SOUTH) + .setUseBestFit(true) + .setToolTipInsets(new Insets(2, 2, 2, 2)) + .setFallBackPositionProvider(c -> { + Window window = DarkUIUtil.getWindow(c.getTarget()); + Dimension size = c.getToolTip().getPreferredSize(); + Rectangle bounds = window.getBounds(); + return new Point(bounds.x + (bounds.width - size.width) / 2, + bounds.y + (bounds.height - size.height) / 2); + }); } @Override diff --git a/core/src/main/java/com/github/weisj/darklaf/components/color/QuickColorChooser.java b/core/src/main/java/com/github/weisj/darklaf/components/color/QuickColorChooser.java index 99053ad6..10140e22 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/color/QuickColorChooser.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/color/QuickColorChooser.java @@ -20,20 +20,22 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.color; -import com.github.weisj.darklaf.decorators.MouseClickListener; -import com.github.weisj.darklaf.icons.EmptyIcon; -import com.github.weisj.darklaf.icons.SolidColorIcon; - -import javax.swing.*; import java.awt.*; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.function.Supplier; +import javax.swing.*; + +import com.github.weisj.darklaf.decorators.MouseClickListener; +import com.github.weisj.darklaf.icons.EmptyIcon; +import com.github.weisj.darklaf.icons.SolidColorIcon; + public class QuickColorChooser extends JPanel { private final SolidColorIcon icon; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/color/SmallColorChooser.java b/core/src/main/java/com/github/weisj/darklaf/components/color/SmallColorChooser.java index 2a91652f..33356109 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/color/SmallColorChooser.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/color/SmallColorChooser.java @@ -20,9 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.color; +import java.awt.*; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Consumer; + +import javax.swing.*; + import com.github.weisj.darklaf.color.DarkColorModel; import com.github.weisj.darklaf.color.DarkColorModelHSB; import com.github.weisj.darklaf.color.DarkColorModelHSL; @@ -40,12 +48,6 @@ import com.github.weisj.darklaf.ui.text.DarkTextUI; import com.github.weisj.darklaf.util.ColorUtil; import com.github.weisj.darklaf.util.DarkUIUtil; -import javax.swing.*; -import java.awt.*; -import java.util.HashMap; -import java.util.Map; -import java.util.function.Consumer; - public class SmallColorChooser extends JPanel { private static final DarkColorModel[] COLOR_MODELS = new DarkColorModel[]{DarkColorModelRGB.getInstance(), @@ -106,13 +108,13 @@ public class SmallColorChooser extends JPanel { hexField.getDocument().addDocumentListener((UpdateDocumentListener) () -> { try { String hexStr = String.format("%1$-" + 8 + "s", - hexField.getText()).replaceAll(" ", "F"); + hexField.getText()) + .replaceAll(" ", "F"); int[] rgb = new int[]{Integer.valueOf(hexStr.substring(0, 2), 16), Integer.valueOf(hexStr.substring(2, 4), 16), Integer.valueOf(hexStr.substring(4, 6), 16)}; setColor(hexField, DarkColorModelRGB.getInstance(), rgb); - } catch (NumberFormatException | IndexOutOfBoundsException ignore) { - } + } catch (NumberFormatException | IndexOutOfBoundsException ignore) {} }); } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/JTabFrame.java b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/JTabFrame.java index 596c779a..7a581dac 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/JTabFrame.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/JTabFrame.java @@ -20,20 +20,22 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.tabframe; -import com.github.weisj.darklaf.ui.tabframe.TabFrameTransferHandler; -import com.github.weisj.darklaf.util.Alignment; - -import javax.swing.*; -import javax.swing.plaf.ComponentUI; import java.awt.*; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Objects; +import javax.swing.*; +import javax.swing.plaf.ComponentUI; + +import com.github.weisj.darklaf.ui.tabframe.TabFrameTransferHandler; +import com.github.weisj.darklaf.util.Alignment; + /** * Frame that supports popup components. * @@ -71,9 +73,9 @@ public class JTabFrame extends JComponent { add(content.getComponent()); int count = Alignment.values().length; - //noinspection unchecked + // noinspection unchecked tabLists = (ArrayList[]) new ArrayList[count]; - //noinspection unchecked + // noinspection unchecked popupLists = (ArrayList[]) new ArrayList[count]; for (int i = 0; i < count; i++) { tabLists[i] = new ArrayList<>(); @@ -175,8 +177,8 @@ public class JTabFrame extends JComponent { /** * Get the number of tabs at the given alignment position. * - * @param a the alignment position. - * @return number of tabs. + * @param a the alignment position. + * @return number of tabs. */ public int getTabCountAt(final Alignment a) { return tabsForAlignment(a).size(); @@ -328,7 +330,7 @@ public class JTabFrame extends JComponent { tabComp.setOrientation(a); getTabContainer(a).add(tabComp.getComponent()); List tabs = tabsForAlignment(a); - //Adjust indices for tabs. + // Adjust indices for tabs. Iterator iterator = tabs.listIterator(index); while (iterator.hasNext()) { TabFrameTab tab = iterator.next(); @@ -346,8 +348,8 @@ public class JTabFrame extends JComponent { /** * Get a list of components at the given alignment position. * - * @param a the alignment position. - * @return list of components at position. + * @param a the alignment position. + * @return list of components at position. */ public List compsForAlignment(final Alignment a) { return popupLists[a.ordinal()]; @@ -356,27 +358,26 @@ public class JTabFrame extends JComponent { /** * Get the tab container for the given alignment position. * - * @param a the alignment position.{@link TabFramePosition#getAlignment()} - * @return the tab container. + * @param a the alignment position.{@link TabFramePosition#getAlignment()} + * @return the tab container. */ - public JComponent getTabContainer(final Alignment a) { switch (a) { - case NORTH: - case NORTH_EAST: + case NORTH : + case NORTH_EAST : return getTopTabContainer(); - case SOUTH: - case SOUTH_WEST: + case SOUTH : + case SOUTH_WEST : return getBottomTabContainer(); - case EAST: - case SOUTH_EAST: + case EAST : + case SOUTH_EAST : return getRightTabContainer(); - case WEST: - case NORTH_WEST: + case WEST : + case NORTH_WEST : return getLeftTabContainer(); - case CENTER: + case CENTER : throw new IllegalArgumentException("invalid alignment: " + a); - default: + default : throw new IllegalArgumentException(); } } @@ -384,8 +385,8 @@ public class JTabFrame extends JComponent { /** * Get a list of tab components at the given alignment position. * - * @param a the alignment position. - * @return list of tab components at position. + * @param a the alignment position. + * @return list of tab components at position. */ public List tabsForAlignment(final Alignment a) { return tabLists[a.ordinal()]; @@ -462,9 +463,9 @@ public class JTabFrame extends JComponent { /** * Get the tab component at the given position. * - * @param a the alignment position.{@link TabFramePosition#getAlignment()} - * @param index the index.{@link TabFramePosition#getIndex()} - * @return the tab component. + * @param a the alignment position.{@link TabFramePosition#getAlignment()} + * @param index the index.{@link TabFramePosition#getIndex()} + * @return the tab component. * @throws IndexOutOfBoundsException if the alignment or index is out of bounds, or the tab doesn't exist. */ public TabFrameTab getTabComponentAt(final Alignment a, final int index) { @@ -486,9 +487,9 @@ public class JTabFrame extends JComponent { /** * Get the component at the given position. * - * @param a the alignment position.{@link TabFramePosition#getAlignment()} - * @param index the index. {@link TabFramePosition#getIndex()} ()} - * @return the popup component specified by {@link TabFramePopup#getContentPane()}. + * @param a the alignment position.{@link TabFramePosition#getAlignment()} + * @param index the index. {@link TabFramePosition#getIndex()} ()} + * @return the popup component specified by {@link TabFramePopup#getContentPane()}. * @throws IndexOutOfBoundsException if the alignment or index is out of bounds, or the tab doesn't exist. */ public Component getComponentAt(final Alignment a, final int index) { @@ -511,8 +512,8 @@ public class JTabFrame extends JComponent { /** * Gets the position of the given component or null if it isn't currently added. * - * @param c the component to find. - * @return the position in the tabFrame.{@link TabFramePosition} + * @param c the component to find. + * @return the position in the tabFrame.{@link TabFramePosition} */ public TabFramePosition findComponent(final Component c) { for (Alignment a : Alignment.values()) { @@ -529,8 +530,8 @@ public class JTabFrame extends JComponent { /** * Close a popup. * - * @param a the alignment position of the popup.{@link TabFramePosition#getAlignment()} - * @param index the index of the tab.{@link TabFramePosition#getIndex()} + * @param a the alignment position of the popup.{@link TabFramePosition#getAlignment()} + * @param index the index of the tab.{@link TabFramePosition#getIndex()} * @throws IndexOutOfBoundsException if the alignment or index is out of bounds, or the tab doesn't exist. */ public void closeTab(final Alignment a, final int index) { @@ -540,9 +541,9 @@ public class JTabFrame extends JComponent { /** * Toggles the visibility of a tab. * - * @param a the alignment position.{@link TabFramePosition#getAlignment()} - * @param index the index.{@link TabFramePosition#getIndex()} - * @param enabled true if visible. + * @param a the alignment position.{@link TabFramePosition#getAlignment()} + * @param index the index.{@link TabFramePosition#getIndex()} + * @param enabled true if visible. * @throws IndexOutOfBoundsException if the alignment or index is out of bounds, or the tab doesn't exist. */ public void toggleTab(final Alignment a, final int index, final boolean enabled) { @@ -565,9 +566,9 @@ public class JTabFrame extends JComponent { * Enable or disable a tab. A disabled tab cannot be opened. Enabling a tab does not open it. Disabling a tab closes * it. After the tab has been disabled enabling it won't restore the open state, * - * @param a the alignment position.{@link TabFramePosition#getAlignment()} - * @param index the index.{@link TabFramePosition#getIndex()} - * @param enabled true if enabled. + * @param a the alignment position.{@link TabFramePosition#getAlignment()} + * @param index the index.{@link TabFramePosition#getIndex()} + * @param enabled true if enabled. * @throws IndexOutOfBoundsException if the alignment or index is out of bounds, or the tab doesn't exist. */ public void setTabEnabled(final Alignment a, final int index, final boolean enabled) { @@ -610,8 +611,8 @@ public class JTabFrame extends JComponent { /** * Get the popup component at the given position that is currently active. * - * @param a the alignment position. {@link TabFramePosition#getAlignment()} - * @return the popup component specified by {@link TabFramePopup#getComponent()}. + * @param a the alignment position. {@link TabFramePosition#getAlignment()} + * @return the popup component specified by {@link TabFramePopup#getComponent()}. */ public Component getPopupComponentAt(final Alignment a) { List tabs = compsForAlignment(a); @@ -756,7 +757,7 @@ public class JTabFrame extends JComponent { */ private void removeTabComp(final Alignment a, final int index) { List tabs = tabsForAlignment(a); - //Adjust indices for tabs. + // Adjust indices for tabs. Iterator iterator = tabs.listIterator(index); while (iterator.hasNext()) { TabFrameTab tab = iterator.next(); @@ -769,9 +770,9 @@ public class JTabFrame extends JComponent { /** * Get the popup component at the given position. * - * @param a the alignment position.{@link TabFramePosition#getAlignment()} - * @param index the index.{@link TabFramePosition#getIndex()} - * @return the popup component specified by {@link TabFramePopup#getComponent()}. + * @param a the alignment position.{@link TabFramePosition#getAlignment()} + * @param index the index.{@link TabFramePosition#getIndex()} + * @return the popup component specified by {@link TabFramePopup#getComponent()}. */ public Component getPopupComponentAt(final Alignment a, final int index) { List tabs = compsForAlignment(a); @@ -781,8 +782,8 @@ public class JTabFrame extends JComponent { /** * Get the component at the given position. * - * @param a the alignment position. {@link TabFramePosition#getAlignment()} - * @return the component specified by {@link TabFramePopup#getContentPane()}. + * @param a the alignment position. {@link TabFramePosition#getAlignment()} + * @return the component specified by {@link TabFramePopup#getContentPane()}. */ public Component getComponentAt(final Alignment a) { List tabs = compsForAlignment(a); @@ -792,9 +793,9 @@ public class JTabFrame extends JComponent { /** * Get the custom tab component at the given position. * - * @param a the alignment position.{@link TabFramePosition#getAlignment()} - * @param index the index.{@link TabFramePosition#getIndex()} - * @return the user tab component or null if none is installed. + * @param a the alignment position.{@link TabFramePosition#getAlignment()} + * @param index the index.{@link TabFramePosition#getIndex()} + * @return the user tab component or null if none is installed. */ public Component getUserTabComponentAt(final Alignment a, final int index) { TabFrameTab tab = getTabComponentAt(a, index); @@ -844,28 +845,31 @@ public class JTabFrame extends JComponent { * Get the position of the alignment peer. That being the other position that occupies the same tab container given * by {@link #getTabContainer(Alignment)}. *

- * NORTH = NORTH_EAST - *

- * EAST = SOUTH_EAST - *

- * SOUTH = SOUTH_WEST - *

- * WEST = NORTH_WEST + * NORTH = NORTH_EAST + *

+ *

+ * EAST = SOUTH_EAST + *

+ *

+ * SOUTH = SOUTH_WEST + *

+ *

+ * WEST = NORTH_WEST * - * @param a the alignment position.{@link TabFramePosition#getAlignment()} - * @return the peer position.{@link TabFramePosition#getAlignment()} + * @param a the alignment position.{@link TabFramePosition#getAlignment()} + * @return the peer position.{@link TabFramePosition#getAlignment()} */ public Alignment getPeer(final Alignment a) { switch (a) { - case NORTH: - case SOUTH: - case WEST: - case EAST: + case NORTH : + case SOUTH : + case WEST : + case EAST : return a.clockwise(); - case NORTH_EAST: - case NORTH_WEST: - case SOUTH_EAST: - case SOUTH_WEST: + case NORTH_EAST : + case NORTH_WEST : + case SOUTH_EAST : + case SOUTH_WEST : return a.anticlockwise(); } return a; @@ -906,9 +910,9 @@ public class JTabFrame extends JComponent { /** * Returns whether the given tab is selected. * - * @param a the alignment position.{@link TabFramePosition#getAlignment()} - * @param index the index.{@link TabFramePosition#getIndex()} - * @return true if selected. + * @param a the alignment position.{@link TabFramePosition#getAlignment()} + * @param index the index.{@link TabFramePosition#getIndex()} + * @return true if selected. */ public boolean isSelected(final Alignment a, final int index) { if (a == null) return false; @@ -918,8 +922,8 @@ public class JTabFrame extends JComponent { /** * Get the index that is currently selected at the given location or -1 if none is selected. * - * @param a the alignment position.{@link TabFramePosition#getAlignment()} - * @return the current selected index at the alignment position. + * @param a the alignment position.{@link TabFramePosition#getAlignment()} + * @return the current selected index at the alignment position. */ public int getSelectedIndex(final Alignment a) { return selectedIndices[a.ordinal()]; @@ -986,7 +990,6 @@ public class JTabFrame extends JComponent { private Alignment a; private int index; - public TabFramePosition(final Alignment a, final int index) { this.a = a; this.index = index; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/PanelPopup.java b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/PanelPopup.java index d2b37fa2..a54f1e1d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/PanelPopup.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/PanelPopup.java @@ -20,20 +20,22 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.tabframe; -import com.github.weisj.darklaf.util.Alignment; +import java.awt.*; import javax.swing.*; import javax.swing.plaf.PanelUI; -import java.awt.*; + +import com.github.weisj.darklaf.util.Alignment; /** * Popup Component for {@link JTabFrame}. * * @author Jannis Weis - * @since 2019 + * @since 2019 */ public class PanelPopup extends JPanel implements TabFramePopup { private Component content; @@ -150,7 +152,6 @@ public class PanelPopup extends JPanel implements TabFramePopup { } } - private boolean isOpen() { return open; } @@ -176,7 +177,8 @@ public class PanelPopup extends JPanel implements TabFramePopup { public void setAlignment(final Alignment alignment) { if (alignment == null || this.alignment == Alignment.CENTER) { throw new IllegalArgumentException("Illegal alignment: " + (alignment != null - ? alignment.toString() : "null")); + ? alignment.toString() + : "null")); } Alignment old = this.alignment; this.alignment = alignment; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/PopupContainer.java b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/PopupContainer.java index b882ce34..b806f3e0 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/PopupContainer.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/PopupContainer.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.tabframe; +import java.awt.*; + import javax.swing.*; import javax.swing.border.Border; -import java.awt.*; /** * Holder component. @@ -59,7 +61,6 @@ public class PopupContainer extends JPanel { super.setBorder(null); } - @Override public Border getBorder() { return null; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabArea.java b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabArea.java index c5cb1ba4..56331747 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabArea.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabArea.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.tabframe; -import javax.swing.*; import java.awt.*; +import javax.swing.*; + public final class TabArea extends JPanel { public TabArea() { diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameContent.java b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameContent.java index c4aa1239..253314c3 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameContent.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameContent.java @@ -20,13 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.tabframe; -import com.github.weisj.darklaf.util.Alignment; - import java.awt.*; +import com.github.weisj.darklaf.util.Alignment; + public interface TabFrameContent { /** @@ -54,8 +55,8 @@ public interface TabFrameContent { /** * Returns whether the given popup is enabled. * - * @param a the alignment of the popup. - * @return true if enabled. + * @param a the alignment of the popup. + * @return true if enabled. */ boolean isEnabled(Alignment a); @@ -84,8 +85,8 @@ public interface TabFrameContent { /** * Get the popup container at the given location. * - * @param alignment the alignment position. - * @return the popup container. + * @param alignment the alignment position. + * @return the popup container. */ PopupContainer getContainer(Alignment alignment); } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameContentPane.java b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameContentPane.java index bef7b62c..63c07f17 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameContentPane.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameContentPane.java @@ -20,16 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.tabframe; -import com.github.weisj.darklaf.decorators.AncestorAdapter; -import com.github.weisj.darklaf.util.Alignment; +import java.awt.*; +import java.util.function.BiConsumer; import javax.swing.*; import javax.swing.event.AncestorEvent; -import java.awt.*; -import java.util.function.BiConsumer; + +import com.github.weisj.darklaf.decorators.AncestorAdapter; +import com.github.weisj.darklaf.util.Alignment; /** * Content pane for {@link JTabFrame}. @@ -88,7 +90,6 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent { bottomSplitter.setLeftComponent(bottomLeftPanel); bottomSplitter.setRightComponent(bottomRightPanel); - topSplit = createSplitPane("topSplit"); bottomSplit = createSplitPane("bottomSplit"); topSplit.setOrientation(JSplitPane.VERTICAL_SPLIT); @@ -187,63 +188,55 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent { public void setEnabled(final Alignment a, final boolean enabled, final boolean force) { if (enabled == isEnabled(a) && !force) return; switch (a) { - case NORTH: - changeStatus( - enabled, Alignment.NORTH_EAST, - topSplit, topSplitter, - new LayoutProportions(VERTICAL_PROP_TOP, 1.0, 0.0, 0.0), - new LayoutWeights(0.0, 0.0, 0.0, 1.0)); + case NORTH : + changeStatus(enabled, Alignment.NORTH_EAST, + topSplit, topSplitter, + new LayoutProportions(VERTICAL_PROP_TOP, 1.0, 0.0, 0.0), + new LayoutWeights(0.0, 0.0, 0.0, 1.0)); break; - case NORTH_EAST: - changeStatus( - enabled, Alignment.NORTH, - topSplit, topSplitter, - new LayoutProportions(VERTICAL_PROP_TOP, 0.0, 0.0, 1.0), - new LayoutWeights(0.0, 0.0, 1.0, 0.0)); + case NORTH_EAST : + changeStatus(enabled, Alignment.NORTH, + topSplit, topSplitter, + new LayoutProportions(VERTICAL_PROP_TOP, 0.0, 0.0, 1.0), + new LayoutWeights(0.0, 0.0, 1.0, 0.0)); break; - case EAST: - changeStatus( - enabled, Alignment.SOUTH_EAST, - rightSplit, rightSplitter, - new LayoutProportions(HORIZONTAL_PROP_RIGHT, 1.0, 1.0, 0.0), - new LayoutWeights(1.0, 1.0, 0.0, 1.0)); + case EAST : + changeStatus(enabled, Alignment.SOUTH_EAST, + rightSplit, rightSplitter, + new LayoutProportions(HORIZONTAL_PROP_RIGHT, 1.0, 1.0, 0.0), + new LayoutWeights(1.0, 1.0, 0.0, 1.0)); break; - case SOUTH_EAST: - changeStatus( - enabled, Alignment.EAST, - rightSplit, rightSplitter, - new LayoutProportions(HORIZONTAL_PROP_RIGHT, 0.0, 1.0, 1.0), - new LayoutWeights(1.0, 1.0, 1.0, 0.0)); + case SOUTH_EAST : + changeStatus(enabled, Alignment.EAST, + rightSplit, rightSplitter, + new LayoutProportions(HORIZONTAL_PROP_RIGHT, 0.0, 1.0, 1.0), + new LayoutWeights(1.0, 1.0, 1.0, 0.0)); break; - case NORTH_WEST: - changeStatus( - enabled, Alignment.WEST, - leftSplit, leftSplitter, - new LayoutProportions(VERTICAL_PROP_TOP, 1.0, 0.0, 0.0), - new LayoutWeights(0.0, 0.0, 0.0, 1.0)); + case NORTH_WEST : + changeStatus(enabled, Alignment.WEST, + leftSplit, leftSplitter, + new LayoutProportions(VERTICAL_PROP_TOP, 1.0, 0.0, 0.0), + new LayoutWeights(0.0, 0.0, 0.0, 1.0)); break; - case WEST: - changeStatus( - enabled, Alignment.NORTH_WEST, - leftSplit, leftSplitter, - new LayoutProportions(VERTICAL_PROP_TOP, 0.0, 0.0, 1.0), - new LayoutWeights(0.0, 0.0, 1.0, 0.0)); + case WEST : + changeStatus(enabled, Alignment.NORTH_WEST, + leftSplit, leftSplitter, + new LayoutProportions(VERTICAL_PROP_TOP, 0.0, 0.0, 1.0), + new LayoutWeights(0.0, 0.0, 1.0, 0.0)); break; - case SOUTH_WEST: - changeStatus( - enabled, Alignment.SOUTH, - bottomSplit, bottomSplitter, - new LayoutProportions(VERTICAL_PROP_BOTTOM, 1.0, 1.0, 0.0), - new LayoutWeights(1.0, 1.0, 0.0, 1.0)); + case SOUTH_WEST : + changeStatus(enabled, Alignment.SOUTH, + bottomSplit, bottomSplitter, + new LayoutProportions(VERTICAL_PROP_BOTTOM, 1.0, 1.0, 0.0), + new LayoutWeights(1.0, 1.0, 0.0, 1.0)); break; - case SOUTH: - changeStatus( - enabled, Alignment.SOUTH_WEST, - bottomSplit, bottomSplitter, - new LayoutProportions(VERTICAL_PROP_BOTTOM, 0.0, 1.0, 1.0), - new LayoutWeights(1.0, 1.0, 1.0, 0.0)); + case SOUTH : + changeStatus(enabled, Alignment.SOUTH_WEST, + bottomSplit, bottomSplitter, + new LayoutProportions(VERTICAL_PROP_BOTTOM, 0.0, 1.0, 1.0), + new LayoutWeights(1.0, 1.0, 1.0, 0.0)); break; - case CENTER: + case CENTER : break; } setEnabledFlag(a, enabled); @@ -320,8 +313,8 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent { /** * Returns whether the corresponding panel is currently enabled/visible. * - * @param a the position of the panel. - * @return true if enabled. + * @param a the position of the panel. + * @return true if enabled. */ public boolean isEnabled(final Alignment a) { if (a == Alignment.CENTER) { @@ -333,31 +326,31 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent { public void setComponentAt(final Alignment a, final Component c) { switch (a) { - case NORTH: + case NORTH : ((PopupContainer) topSplitter.getLeftComponent()).setPopup(c); break; - case NORTH_EAST: + case NORTH_EAST : ((PopupContainer) topSplitter.getRightComponent()).setPopup(c); break; - case EAST: + case EAST : ((PopupContainer) rightSplitter.getTopComponent()).setPopup(c); break; - case SOUTH_EAST: + case SOUTH_EAST : ((PopupContainer) rightSplitter.getBottomComponent()).setPopup(c); break; - case SOUTH: + case SOUTH : ((PopupContainer) bottomSplitter.getRightComponent()).setPopup(c); break; - case SOUTH_WEST: + case SOUTH_WEST : ((PopupContainer) bottomSplitter.getLeftComponent()).setPopup(c); break; - case WEST: + case WEST : ((PopupContainer) leftSplitter.getBottomComponent()).setPopup(c); break; - case NORTH_WEST: + case NORTH_WEST : ((PopupContainer) leftSplitter.getTopComponent()).setPopup(c); break; - case CENTER: + case CENTER : break; } } @@ -381,31 +374,31 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent { public PopupContainer getContainer(final Alignment alignment) { PopupContainer popupComponent; switch (alignment) { - case NORTH: + case NORTH : popupComponent = ((PopupContainer) topSplitter.getLeftComponent()); break; - case NORTH_EAST: + case NORTH_EAST : popupComponent = ((PopupContainer) topSplitter.getRightComponent()); break; - case EAST: + case EAST : popupComponent = ((PopupContainer) rightSplitter.getTopComponent()); break; - case SOUTH_EAST: + case SOUTH_EAST : popupComponent = ((PopupContainer) rightSplitter.getBottomComponent()); break; - case SOUTH: + case SOUTH : popupComponent = ((PopupContainer) bottomSplitter.getRightComponent()); break; - case SOUTH_WEST: + case SOUTH_WEST : popupComponent = ((PopupContainer) bottomSplitter.getLeftComponent()); break; - case WEST: + case WEST : popupComponent = ((PopupContainer) leftSplitter.getBottomComponent()); break; - case NORTH_WEST: + case NORTH_WEST : popupComponent = ((PopupContainer) leftSplitter.getTopComponent()); break; - default: + default : throw new IllegalArgumentException("CENTER is not supported"); } return popupComponent; @@ -414,8 +407,8 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent { /** * Get the popup component at the position. * - * @param a the position. - * @return the popup component at position. + * @param a the position. + * @return the popup component at position. */ public Component getPopupComponent(final Alignment a) { return getContainer(a).getPopup(); @@ -427,7 +420,6 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent { protected final double splitDisable; protected final double splitterDisable; - public LayoutProportions(final double splitRestore, final double splitterPeerDisable, final double splitDisable, final double splitterDisable) { this.splitRestore = splitRestore; @@ -443,7 +435,6 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent { protected final double splitDisable; protected final double splitterPeerDisable; - public LayoutWeights(final double splitEnable, final double splitterDisable, final double splitDisable, final double splitterPeerDisable) { this.splitEnable = splitEnable; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFramePopup.java b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFramePopup.java index 255f8258..f0fe5d9f 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFramePopup.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFramePopup.java @@ -20,13 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.tabframe; -import com.github.weisj.darklaf.util.Alignment; +import java.awt.*; import javax.swing.*; -import java.awt.*; + +import com.github.weisj.darklaf.util.Alignment; public interface TabFramePopup { String KEY_VISIBLE_TAB = "visibleTab"; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFramePopupUI.java b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFramePopupUI.java index 6fdb73c6..5a963544 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFramePopupUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFramePopupUI.java @@ -20,8 +20,8 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.tabframe; -public interface TabFramePopupUI { -} +public interface TabFramePopupUI {} diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTab.java b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTab.java index 01be5780..7b8ccef4 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTab.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTab.java @@ -20,13 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.tabframe; -import com.github.weisj.darklaf.util.Alignment; - import java.awt.*; +import com.github.weisj.darklaf.util.Alignment; + public interface TabFrameTab { String KEY_SELECTED = "selected"; String KEY_CONTENT = "content"; @@ -125,5 +126,4 @@ public interface TabFrameTab { * @param tabFrame the TabFrame. */ void setTabFrame(JTabFrame tabFrame); - } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabContainer.java b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabContainer.java index ab56d269..5b296dda 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabContainer.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabContainer.java @@ -20,13 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.tabframe; -import com.github.weisj.darklaf.util.Alignment; +import java.awt.*; import javax.swing.*; -import java.awt.*; + +import com.github.weisj.darklaf.util.Alignment; public class TabFrameTabContainer extends JPanel implements TabFrameTab { diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabLabel.java b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabLabel.java index 6fecf225..af29bdf5 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabLabel.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabLabel.java @@ -20,17 +20,19 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.tabframe; +import java.awt.*; +import java.util.Objects; + +import javax.swing.*; + import com.github.weisj.darklaf.icons.EmptyIcon; import com.github.weisj.darklaf.ui.tabframe.DarkTabFrameTabLabelUI; import com.github.weisj.darklaf.util.Alignment; -import javax.swing.*; -import java.awt.*; -import java.util.Objects; - /** * Tab Component for {@link JTabFrame}. * diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabbedPopupUI.java b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabbedPopupUI.java index 0956560d..9ae4c86e 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabbedPopupUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabbedPopupUI.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.tabframe; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameUI.java b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameUI.java index be1b828b..02ff6a5a 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameUI.java @@ -20,13 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.tabframe; -import com.github.weisj.darklaf.util.Alignment; +import java.awt.*; import javax.swing.plaf.ComponentUI; -import java.awt.*; + +import com.github.weisj.darklaf.util.Alignment; public abstract class TabFrameUI extends ComponentUI { diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabbedPopup.java b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabbedPopup.java index 2966cb84..31bad4df 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabbedPopup.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabbedPopup.java @@ -20,16 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.tabframe; -import javax.swing.*; -import javax.swing.plaf.PanelUI; import java.awt.*; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import javax.swing.*; +import javax.swing.plaf.PanelUI; + /** * Tabbed Popup Component for {@link JTabFrame}. * @@ -125,7 +127,7 @@ public class TabbedPopup extends PanelPopup { * Gets the currently selected component from the TabbedPane. * * @return the selected component. - * @see #getTabbedPane() + * @see #getTabbedPane() */ public Component getContentPane() { return tabbedPane.getSelectedComponent(); @@ -150,7 +152,7 @@ public class TabbedPopup extends PanelPopup { * TabbedPane. * * @return a collection of components. - * @see #getTabbedPane() + * @see #getTabbedPane() */ public Collection getContentPanes() { int size = getTabbedPane().getTabCount(); diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/ToggleSplitPane.java b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/ToggleSplitPane.java index 90ef7cee..062411c4 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/ToggleSplitPane.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/ToggleSplitPane.java @@ -20,15 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.tabframe; -import com.github.weisj.darklaf.ui.splitpane.DarkSplitPaneUI; +import java.awt.*; import javax.swing.*; import javax.swing.plaf.basic.BasicSplitPaneDivider; import javax.swing.plaf.basic.BasicSplitPaneUI; -import java.awt.*; + +import com.github.weisj.darklaf.ui.splitpane.DarkSplitPaneUI; public class ToggleSplitPane extends JSplitPane { @@ -49,7 +51,6 @@ public class ToggleSplitPane extends JSplitPane { putClientProperty(DarkSplitPaneUI.KEY_STYLE, DarkSplitPaneUI.STYLE_INVISIBLE); } - public boolean isResizable() { return resizable; } @@ -148,7 +149,6 @@ public class ToggleSplitPane extends JSplitPane { } } - @Override public void setDividerLocation(final int location) { if (isInLayout) return; @@ -165,7 +165,6 @@ public class ToggleSplitPane extends JSplitPane { isInLayout = false; } - @Override public int getMaximumDividerLocation() { int max = getOrientation() == HORIZONTAL_SPLIT ? getWidth() : getHeight(); @@ -176,8 +175,7 @@ public class ToggleSplitPane extends JSplitPane { public int getMinimumDividerLocation() { Component comp = getRightComponent(); return comp == null ? 0 : getOrientation() == HORIZONTAL_SPLIT - ? comp.getMinimumSize().width - : comp.getMinimumSize().height; + ? comp.getMinimumSize().width + : comp.getMinimumSize().height; } - } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/text/IconListener.java b/core/src/main/java/com/github/weisj/darklaf/components/text/IconListener.java index 3859ee07..d7e8ea70 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/text/IconListener.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/text/IconListener.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.text; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/text/IndexListener.java b/core/src/main/java/com/github/weisj/darklaf/components/text/IndexListener.java index 633628df..85680def 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/text/IndexListener.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/text/IndexListener.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.text; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/text/LineHighlighter.java b/core/src/main/java/com/github/weisj/darklaf/components/text/LineHighlighter.java index 1307cc46..0902d99b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/text/LineHighlighter.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/text/LineHighlighter.java @@ -20,16 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.text; +import java.awt.*; + import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.text.BadLocationException; import javax.swing.text.Highlighter; import javax.swing.text.JTextComponent; -import java.awt.*; public class LineHighlighter implements Highlighter.HighlightPainter, ChangeListener { private JTextComponent component; @@ -49,9 +51,9 @@ public class LineHighlighter implements Highlighter.HighlightPainter, ChangeList } /* - * You can reset the line color at any time + * You can reset the line color at any time * - * @param color the color of the background line + * @param color the color of the background line */ public void setColor(final Color color) { this.color = color; @@ -82,11 +84,11 @@ public class LineHighlighter implements Highlighter.HighlightPainter, ChangeList } /* - * Caret position has changed, remove the highlight + * Caret position has changed, remove the highlight */ private void resetHighlight() { - // Use invokeLater to make sure updates to the Document are completed, - // otherwise Undo processing causes the modelToView method to loop. + // Use invokeLater to make sure updates to the Document are completed, + // otherwise Undo processing causes the modelToView method to loop. if (component == null) return; SwingUtilities.invokeLater(() -> { try { @@ -96,7 +98,7 @@ public class LineHighlighter implements Highlighter.HighlightPainter, ChangeList if (view == null) return; Rectangle currentView = view.getBounds(); - // Remove the highlighting from the previously highlighted line + // Remove the highlighting from the previously highlighted line if (lastView != null && lastView.y != currentView.y) { if (lastView.isEmpty()) { component.repaint(); @@ -105,8 +107,7 @@ public class LineHighlighter implements Highlighter.HighlightPainter, ChangeList } lastView = currentView; } - } catch (BadLocationException ignored) { - } + } catch (BadLocationException ignored) {} }); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/text/NonWrappingEditorPane.java b/core/src/main/java/com/github/weisj/darklaf/components/text/NonWrappingEditorPane.java index 585e7df5..aba791f2 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/text/NonWrappingEditorPane.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/text/NonWrappingEditorPane.java @@ -20,18 +20,20 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.text; +import java.awt.*; + import javax.swing.*; import javax.swing.plaf.ComponentUI; -import java.awt.*; /** * JTextPane that keeps the original width of text. * * @author Jannis Weis - * @since 2018 + * @since 2018 */ public class NonWrappingEditorPane extends JEditorPane { diff --git a/core/src/main/java/com/github/weisj/darklaf/components/text/NonWrappingTextArea.java b/core/src/main/java/com/github/weisj/darklaf/components/text/NonWrappingTextArea.java index 7b58cce8..8ba92177 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/text/NonWrappingTextArea.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/text/NonWrappingTextArea.java @@ -20,18 +20,20 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.text; +import java.awt.*; + import javax.swing.*; import javax.swing.plaf.ComponentUI; -import java.awt.*; /** * JTextPane that keeps the original width of text. * * @author Jannis Weis - * @since 2018 + * @since 2018 */ public class NonWrappingTextArea extends JTextArea { diff --git a/core/src/main/java/com/github/weisj/darklaf/components/text/NonWrappingTextPane.java b/core/src/main/java/com/github/weisj/darklaf/components/text/NonWrappingTextPane.java index da3fb1d0..d8785e11 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/text/NonWrappingTextPane.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/text/NonWrappingTextPane.java @@ -20,18 +20,20 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.text; +import java.awt.*; + import javax.swing.*; import javax.swing.plaf.ComponentUI; -import java.awt.*; /** * JTextPane that keeps the original width of text. * * @author Jannis Weis - * @since 2018 + * @since 2018 */ public class NonWrappingTextPane extends JTextPane { diff --git a/core/src/main/java/com/github/weisj/darklaf/components/text/NumberedTextComponent.java b/core/src/main/java/com/github/weisj/darklaf/components/text/NumberedTextComponent.java index 3ae7cc3a..89350a32 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/text/NumberedTextComponent.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/text/NumberedTextComponent.java @@ -20,14 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.text; -import com.github.weisj.darklaf.components.OverlayScrollPane; +import java.awt.*; import javax.swing.*; import javax.swing.text.JTextComponent; -import java.awt.*; + +import com.github.weisj.darklaf.components.OverlayScrollPane; public class NumberedTextComponent extends JPanel { diff --git a/core/src/main/java/com/github/weisj/darklaf/components/text/NumberingPane.java b/core/src/main/java/com/github/weisj/darklaf/components/text/NumberingPane.java index 5c73ee81..a531d2cd 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/text/NumberingPane.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/text/NumberingPane.java @@ -20,15 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.text; -import com.github.weisj.darklaf.util.StringUtil; +import java.util.*; +import java.util.stream.Collectors; import javax.swing.*; import javax.swing.text.*; -import java.util.*; -import java.util.stream.Collectors; + +import com.github.weisj.darklaf.util.StringUtil; public class NumberingPane extends JComponent { @@ -88,7 +90,7 @@ public class NumberingPane extends JComponent { } public Position addIconAtLine(final int lineIndex, final Icon icon, final boolean atTextStart) - throws BadLocationException { + throws BadLocationException { int offset = textComponent.getDocument().getDefaultRootElement().getElement(lineIndex).getStartOffset(); if (atTextStart) { Document doc = textComponent.getDocument(); diff --git a/core/src/main/java/com/github/weisj/darklaf/components/text/SearchEvent.java b/core/src/main/java/com/github/weisj/darklaf/components/text/SearchEvent.java index 1e5c56fe..e341a5e7 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/text/SearchEvent.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/text/SearchEvent.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.text; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/text/SearchListener.java b/core/src/main/java/com/github/weisj/darklaf/components/text/SearchListener.java index 1165ec33..fc40e7a3 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/text/SearchListener.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/text/SearchListener.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.text; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/text/SearchTextField.java b/core/src/main/java/com/github/weisj/darklaf/components/text/SearchTextField.java index b3149acc..f113a047 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/text/SearchTextField.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/text/SearchTextField.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.text; @@ -31,7 +32,7 @@ public class SearchTextField extends JTextField { public static final int SEARCH = 0; /** - * Constructs a new TextField. A default model is created, the initial string is null, + * Constructs a new TextField. A default model is created, the initial string is null, * and the number of columns is set to 0. */ public SearchTextField() { @@ -43,12 +44,15 @@ public class SearchTextField extends JTextField { * This is the constructor through which the other constructors feed. If the document is null, a * default model is created. * - * @param doc the text storage to use; if this is null, a default will be provided by calling the - * createDefaultModel method - * @param text the initial string to display, or null - * @param columns the number of columns to use to calculate the preferred width >= 0; if columns is - * set to zero, the preferred width will be whatever naturally results from the component - * implementation + * @param doc the text storage to use; if this is null, a default will be + * provided by calling the + * createDefaultModel method + * @param text the initial string to display, or null + * @param columns the number of columns to use to calculate the preferred width >= 0; if + * columns is + * set to zero, the preferred width will be whatever naturally results from the + * component + * implementation * @throws IllegalArgumentException if columns < 0 */ public SearchTextField(final Document doc, final String text, final int columns) { @@ -88,7 +92,7 @@ public class SearchTextField extends JTextField { } /** - * Constructs a new TextField initialized with the specified text and columns. A default model is + * Constructs a new TextField initialized with the specified text and columns. A default model is * created. * * @param text the text to be displayed, or null diff --git a/core/src/main/java/com/github/weisj/darklaf/components/text/SearchTextFieldWithHistory.java b/core/src/main/java/com/github/weisj/darklaf/components/text/SearchTextFieldWithHistory.java index b5a3b70e..8430c589 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/text/SearchTextFieldWithHistory.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/text/SearchTextFieldWithHistory.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.text; -import javax.swing.text.Document; import java.util.List; +import javax.swing.text.Document; + /** * {@link SearchTextField} that has a popup that displays the search history. A search entry is added * @@ -36,7 +38,7 @@ public class SearchTextFieldWithHistory extends SearchTextField { protected final TextFieldHistoryPopup history; /** - * Constructs a new TextField. A default model is created, the initial string is null, + * Constructs a new TextField. A default model is created, the initial string is null, * and the number of columns is set to 0. */ public SearchTextFieldWithHistory() { @@ -48,12 +50,15 @@ public class SearchTextFieldWithHistory extends SearchTextField { * This is the constructor through which the other constructors feed. If the document is null, a * default model is created. * - * @param doc the text storage to use; if this is null, a default will be provided by calling the - * createDefaultModel method - * @param text the initial string to display, or null - * @param columns the number of columns to use to calculate the preferred width >= 0; if columns is - * set to zero, the preferred width will be whatever naturally results from the component - * implementation + * @param doc the text storage to use; if this is null, a default will be + * provided by calling the + * createDefaultModel method + * @param text the initial string to display, or null + * @param columns the number of columns to use to calculate the preferred width >= 0; if + * columns is + * set to zero, the preferred width will be whatever naturally results from the + * component + * implementation * @throws IllegalArgumentException if columns < 0 */ public SearchTextFieldWithHistory(final Document doc, final String text, final int columns) { @@ -85,7 +90,7 @@ public class SearchTextFieldWithHistory extends SearchTextField { } /** - * Constructs a new TextField initialized with the specified text and columns. A default model is + * Constructs a new TextField initialized with the specified text and columns. A default model is * created. * * @param text the text to be displayed, or null @@ -99,8 +104,8 @@ public class SearchTextFieldWithHistory extends SearchTextField { /** * Set the maximum height of the popup. If the size is larger than the specified maximum height the content will be * wrapped inside a scroll pane. - * - *

Note: A value of less than or equal to 0 indicates that the height should not be limited. + *

+ * Note: A value of less than or equal to 0 indicates that the height should not be limited. * * @param maximumHeight the max height to use. */ @@ -128,9 +133,9 @@ public class SearchTextFieldWithHistory extends SearchTextField { * Add entry to the history. If the size is greater than the capacity the oldest entry will be deleted. * * @param entry the entry to add. - * @see #getLength() getLength - * @see #setCapacity(int) setCapacity - * @see #getCapacity() getCapacity + * @see #getLength() getLength + * @see #setCapacity(int) setCapacity + * @see #getCapacity() getCapacity */ public void addEntry(final String entry) { history.addEntry(entry); @@ -140,7 +145,7 @@ public class SearchTextFieldWithHistory extends SearchTextField { * Get the capacity of the history. * * @return the capacity. - * @see #setCapacity(int) setCapacity() + * @see #setCapacity(int) setCapacity() */ public int getCapacity() { return history.getCapacity(); @@ -149,7 +154,7 @@ public class SearchTextFieldWithHistory extends SearchTextField { /** * Set the capacity of the history. If the size grows larger than the capacity the oldest entry will be deleted. * - * @param capacity the capacity. + * @param capacity the capacity. * @throws IllegalArgumentException if capacity is negative */ public void setCapacity(final int capacity) throws IllegalArgumentException { diff --git a/core/src/main/java/com/github/weisj/darklaf/components/text/TextFieldHistoryPopup.java b/core/src/main/java/com/github/weisj/darklaf/components/text/TextFieldHistoryPopup.java index 9d4258ce..b3bb13d6 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/text/TextFieldHistoryPopup.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/text/TextFieldHistoryPopup.java @@ -20,18 +20,20 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.text; +import java.awt.*; +import java.util.*; +import java.util.List; + +import javax.swing.*; + import com.github.weisj.darklaf.components.ScrollPopupMenu; import com.github.weisj.darklaf.decorators.PlainAction; import com.github.weisj.darklaf.util.StringUtil; -import javax.swing.*; -import java.awt.*; -import java.util.List; -import java.util.*; - /** * @author Jannis Weis */ @@ -73,7 +75,7 @@ public class TextFieldHistoryPopup extends ScrollPopupMenu implements SearchList * Get the capacity of the history. * * @return the capacity. - * @see #setCapacity(int) setCapacity() + * @see #setCapacity(int) setCapacity() */ public int getCapacity() { return capacity; @@ -82,7 +84,7 @@ public class TextFieldHistoryPopup extends ScrollPopupMenu implements SearchList /** * Set the capacity of the history. If the size grows larger than the capacity the oldest entry will be deleted. * - * @param capacity the capacity. + * @param capacity the capacity. * @throws IllegalArgumentException if capacity is negative */ public void setCapacity(final int capacity) throws IllegalArgumentException { @@ -111,9 +113,9 @@ public class TextFieldHistoryPopup extends ScrollPopupMenu implements SearchList * Add entry to the history. If the size is greater than the capacity the oldest entry will be deleted. * * @param entry the entry to add. - * @see #getLength() getLength - * @see #setCapacity(int) setCapacity - * @see #getCapacity() getCapacity + * @see #getLength() getLength + * @see #setCapacity(int) setCapacity + * @see #getCapacity() getCapacity */ public void addEntry(final String entry) { history.remove(entry); diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipAware.java b/core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipAware.java index d4da93d6..73efb206 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipAware.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipAware.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.tooltip; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipContext.java b/core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipContext.java index 348b2ecf..ae2989ef 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipContext.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipContext.java @@ -20,17 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.tooltip; -import com.github.weisj.darklaf.components.alignment.AlignmentStrategy; -import com.github.weisj.darklaf.ui.tooltip.DarkTooltipBorder; -import com.github.weisj.darklaf.ui.tooltip.DarkTooltipUI; -import com.github.weisj.darklaf.util.Alignment; -import com.github.weisj.darklaf.util.DarkUIUtil; - -import javax.swing.*; -import javax.swing.border.Border; import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -38,6 +31,15 @@ import java.awt.event.MouseListener; import java.awt.geom.Area; import java.util.function.Function; +import javax.swing.*; +import javax.swing.border.Border; + +import com.github.weisj.darklaf.components.alignment.AlignmentStrategy; +import com.github.weisj.darklaf.ui.tooltip.DarkTooltipBorder; +import com.github.weisj.darklaf.ui.tooltip.DarkTooltipUI; +import com.github.weisj.darklaf.util.Alignment; +import com.github.weisj.darklaf.util.DarkUIUtil; + public class ToolTipContext { private static ToolTipContext defaultContext; @@ -108,7 +110,6 @@ public class ToolTipContext { this(null, null, null, null, true, null); } - /** * Create a new tooltip context to ease the creation of custom tooltips. * @@ -146,9 +147,9 @@ public class ToolTipContext { /** * Set the style of the tooltip. * - * @param style the tooltip style. - * @return this - * @see ToolTipStyle ToolTipStyle + * @param style the tooltip style. + * @return this + * @see ToolTipStyle ToolTipStyle */ public ToolTipContext setToolTipStyle(final ToolTipStyle style) { this.style = style; @@ -164,8 +165,8 @@ public class ToolTipContext { *

* Default is false. * - * @param updatePosition true if it should be recalculated. - * @return this + * @param updatePosition true if it should be recalculated. + * @return this */ public ToolTipContext setUpdatePosition(final boolean updatePosition) { return this; @@ -177,7 +178,6 @@ public class ToolTipContext { * @param target the component which the tooltip belongs to. * @param alignment {@link #setAlignment(Alignment)} */ - public ToolTipContext(final JComponent target, final Alignment alignment) { this(target, alignment, null, null, true, null); } @@ -187,10 +187,10 @@ public class ToolTipContext { * not {@link Alignment#CENTER}. Default is true *

* - * @param alignInside true if the tooltip should be aligned inside. - * @return this. - * @see #setAlignment(Alignment) - * @see #setToolTipRectSupplier(Function) + * @param alignInside true if the tooltip should be aligned inside. + * @return this. + * @see #setAlignment(Alignment) + * @see #setToolTipRectSupplier(Function) */ public ToolTipContext setAlignInside(final boolean alignInside) { this.alignInside = alignInside; @@ -210,9 +210,9 @@ public class ToolTipContext { * additionally supply an alignment using {@link #setCenterAlignment(Alignment)}. The tooltip will either be aligned * outside of the rectangle or inside depending on {@link #setAlignInside(boolean)}. * - * @param alignment the alignment. - * @return this. - * @see #setToolTipRectSupplier(Function) + * @param alignment the alignment. + * @return this. + * @see #setToolTipRectSupplier(Function) */ public ToolTipContext setAlignment(final Alignment alignment) { this.alignment = alignment; @@ -228,8 +228,8 @@ public class ToolTipContext { *

* Default is {@link Alignment#NORTH}. * - * @param centerAlignment the center alignment. - * @return this + * @param centerAlignment the center alignment. + * @return this */ public ToolTipContext setCenterAlignment(final Alignment centerAlignment) { this.centerAlignment = centerAlignment; @@ -242,12 +242,12 @@ public class ToolTipContext { /** * Set the alignment strategy which determines how the current mouse position is considered when calculating the * tooltip location. + *

+ * Default will be {@link AlignmentStrategy#COMPONENT_BOTH}. * - *

Default will be {@link AlignmentStrategy#COMPONENT_BOTH}. - * - * @param alignmentStrategy the alignment strategy. - * @return this - * @see AlignmentStrategy + * @param alignmentStrategy the alignment strategy. + * @return this + * @see AlignmentStrategy */ public ToolTipContext setAlignmentStrategy(final AlignmentStrategy alignmentStrategy) { this.alignmentStrategy = alignmentStrategy; @@ -264,7 +264,6 @@ public class ToolTipContext { * @param alignment {@link #setAlignment(Alignment)} * @param centerAlignment {@link #setCenterAlignment(Alignment)} */ - public ToolTipContext(final JComponent target, final Alignment alignment, final Alignment centerAlignment) { this(target, alignment, centerAlignment, null, true, null); } @@ -276,7 +275,6 @@ public class ToolTipContext { * @param alignment {@link #setAlignment(Alignment)} * @param alignInside {@link #setAlignInside(boolean)} */ - public ToolTipContext(final JComponent target, final Alignment alignment, final boolean alignInside) { this(target, alignment, null, null, alignInside, null); } @@ -289,7 +287,6 @@ public class ToolTipContext { * @param centerAlignment {@link #setCenterAlignment(Alignment)} * @param alignInside {@link #setAlignInside(boolean)} */ - public ToolTipContext(final JComponent target, final Alignment alignment, final Alignment centerAlignment, final boolean alignInside) { this(target, alignment, centerAlignment, null, alignInside, null); @@ -302,7 +299,6 @@ public class ToolTipContext { * @param alignment {@link #setAlignment(Alignment)} * @param alignmentStrategy {@link #setAlignmentStrategy(AlignmentStrategy)} */ - public ToolTipContext(final JComponent target, final Alignment alignment, final AlignmentStrategy alignmentStrategy) { this(target, alignment, null, alignmentStrategy, true, null); @@ -316,7 +312,6 @@ public class ToolTipContext { * @param centerAlignment {@link #setCenterAlignment(Alignment)} * @param alignmentStrategy {@link #setAlignmentStrategy(AlignmentStrategy)} */ - public ToolTipContext(final JComponent target, final Alignment alignment, final Alignment centerAlignment, final AlignmentStrategy alignmentStrategy) { this(target, alignment, centerAlignment, alignmentStrategy, true, null); @@ -330,7 +325,6 @@ public class ToolTipContext { * @param alignmentStrategy {@link #setAlignmentStrategy(AlignmentStrategy)} * @param alignInside {@link #setAlignInside(boolean)} */ - public ToolTipContext(final JComponent target, final Alignment alignment, final AlignmentStrategy alignmentStrategy, final boolean alignInside) { this(target, alignment, null, alignmentStrategy, alignInside, null); @@ -341,8 +335,8 @@ public class ToolTipContext { *

* Default is false. * - * @param hideOnExit true if tooltip should hide. - * @return this. + * @param hideOnExit true if tooltip should hide. + * @return this. */ public ToolTipContext setHideOnExit(final boolean hideOnExit) { this.hideOnExit = hideOnExit; @@ -362,8 +356,8 @@ public class ToolTipContext { *

* Default will be the component bounding rectangle. * - * @param toolTipRectSupplier rectangle supplier method. - * @return this + * @param toolTipRectSupplier rectangle supplier method. + * @return this */ public ToolTipContext setToolTipRectSupplier(final Function toolTipRectSupplier) { this.toolTipRectSupplier = toolTipRectSupplier; @@ -377,8 +371,8 @@ public class ToolTipContext { if (toolTip != null) { toolTip.putClientProperty(DarkTooltipUI.KEY_POINTER_LOCATION, alignment == Alignment.CENTER - ? centerAlignment.opposite() - : alignInside ? alignment : alignment.opposite()); + ? centerAlignment.opposite() + : alignInside ? alignment : alignment.opposite()); toolTip.putClientProperty(DarkTooltipUI.KEY_INSETS, insets); toolTip.putClientProperty(DarkTooltipUI.KEY_STYLE, style); toolTip.doLayout(); @@ -391,8 +385,8 @@ public class ToolTipContext { *

* Defaults to * - * @param insideRect the area to check. - * @return this. + * @param insideRect the area to check. + * @return this. */ public ToolTipContext setInsideArea(final Area insideRect) { this.hotSpotArea = insideRect; @@ -405,8 +399,8 @@ public class ToolTipContext { *

* Default is false. * - * @param applyInsetsToRect true if they should be applied. - * @return this. + * @param applyInsetsToRect true if they should be applied. + * @return this. */ public ToolTipContext setApplyComponentInsetsToRect(final boolean applyInsetsToRect) { this.applyInsetsToRect = applyInsetsToRect; @@ -414,9 +408,9 @@ public class ToolTipContext { } /** - * @param insideRect the rectangle to check. - * @return this - * @see #setInsideArea(Area) + * @param insideRect the rectangle to check. + * @return this + * @see #setInsideArea(Area) */ public ToolTipContext setInsideArea(final Rectangle insideRect) { this.hotSpotArea = new Area(insideRect); @@ -426,8 +420,8 @@ public class ToolTipContext { /** * Sets insets for the tooltip. * - * @param insets the insets to set. - * @return this. + * @param insets the insets to set. + * @return this. */ public ToolTipContext setToolTipInsets(final Insets insets) { this.insets = insets; @@ -443,8 +437,8 @@ public class ToolTipContext { * Sets whether the border should be ignored when aligning outside. If true the tooltip is aligned w.r.t. to the * content rect and not the component bounds. * - * @param ignoreBorder true if border insets should be ignored. - * @return this. + * @param ignoreBorder true if border insets should be ignored. + * @return this. */ public ToolTipContext setIgnoreBorder(final boolean ignoreBorder) { this.ignoreBorder = ignoreBorder; @@ -454,8 +448,8 @@ public class ToolTipContext { /** * Sets whether the tooltip should try its best to fit inside the window/screen. * - * @param bestFit true if best fit adjustments should be made. - * @return this. + * @param bestFit true if best fit adjustments should be made. + * @return this. */ public ToolTipContext setUseBestFit(final boolean bestFit) { this.bestFit = bestFit; @@ -465,10 +459,10 @@ public class ToolTipContext { /** * Calculates the tooltip location. * - * @param mp the mouse position in the target component coordinate space. - * @param mouseEvent the mouse event. - * @return the tooltip location. - * @see JComponent#getToolTipLocation(MouseEvent) + * @param mp the mouse position in the target component coordinate space. + * @param mouseEvent the mouse event. + * @return the tooltip location. + * @see JComponent#getToolTipLocation(MouseEvent) */ public Point getToolTipLocation(final Point mp, final MouseEvent mouseEvent) { if (target == null) return null; @@ -529,7 +523,7 @@ public class ToolTipContext { * Get the tooltip. * * @return the tooltip. - * @see JComponent#createToolTip() + * @see JComponent#createToolTip() */ public JToolTip getToolTip() { if (toolTip == null) { @@ -551,7 +545,6 @@ public class ToolTipContext { return dim; } - private Point alignCenter(final Dimension dim, final Rectangle rect) { rect.x += rect.width / 2; rect.y += rect.height / 2; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipStyle.java b/core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipStyle.java index 1228c509..4f6c53c7 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipStyle.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipStyle.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.tooltip; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tooltip/TooltipAwareButton.java b/core/src/main/java/com/github/weisj/darklaf/components/tooltip/TooltipAwareButton.java index 87fd021d..e9d287a1 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tooltip/TooltipAwareButton.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/tooltip/TooltipAwareButton.java @@ -20,14 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.tooltip; +import javax.swing.*; + import com.github.weisj.darklaf.ui.tooltip.DarkTooltipUI; import com.github.weisj.darklaf.util.Alignment; -import javax.swing.*; - public class TooltipAwareButton extends JButton implements ToolTipAware { private ToolTipContext context; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tooltip/TooltipAwareToggleButton.java b/core/src/main/java/com/github/weisj/darklaf/components/tooltip/TooltipAwareToggleButton.java index f81c7909..21b9b9b5 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tooltip/TooltipAwareToggleButton.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/tooltip/TooltipAwareToggleButton.java @@ -20,14 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.tooltip; +import javax.swing.*; + import com.github.weisj.darklaf.ui.tooltip.DarkTooltipUI; import com.github.weisj.darklaf.util.Alignment; -import javax.swing.*; - public class TooltipAwareToggleButton extends JToggleButton implements ToolTipAware { private ToolTipContext context; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateButtonModel.java b/core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateButtonModel.java index d84a2a12..05610dc2 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateButtonModel.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateButtonModel.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.tristate; -import javax.swing.*; import java.awt.event.ItemEvent; +import javax.swing.*; + public class TristateButtonModel extends JToggleButton.ToggleButtonModel { private TristateState state = TristateState.DESELECTED; @@ -80,7 +82,7 @@ public class TristateButtonModel extends JToggleButton.ToggleButtonModel { displayState(); fireStateChanged(); int indeterminate = 3; - //noinspection MagicConstant + // noinspection MagicConstant fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED, this, indeterminate)); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateCheckBox.java b/core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateCheckBox.java index bd873093..b234590c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateCheckBox.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateCheckBox.java @@ -20,19 +20,21 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.tristate; -import com.github.weisj.darklaf.DarkLaf; - -import javax.swing.*; -import javax.swing.event.ChangeListener; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.InputEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import javax.swing.*; +import javax.swing.event.ChangeListener; + +import com.github.weisj.darklaf.DarkLaf; + public class TristateCheckBox extends JCheckBox { private final ChangeListener enableListener = e -> TristateCheckBox.this.setFocusable(getModel().isEnabled()); @@ -74,7 +76,6 @@ public class TristateCheckBox extends JCheckBox { return (TristateButtonModel) super.getModel(); } - public String getUIClassID() { if (UIManager.getLookAndFeel() instanceof DarkLaf) { return "TristateCheckBoxUI"; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateCheckBoxMenuItem.java b/core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateCheckBoxMenuItem.java index 99d50237..f94ba1ae 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateCheckBoxMenuItem.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateCheckBoxMenuItem.java @@ -20,18 +20,20 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.tristate; -import com.github.weisj.darklaf.DarkLaf; - -import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.InputEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import javax.swing.*; + +import com.github.weisj.darklaf.DarkLaf; + public class TristateCheckBoxMenuItem extends JCheckBoxMenuItem { /** @@ -63,7 +65,7 @@ public class TristateCheckBoxMenuItem extends JCheckBoxMenuItem { * Creates a menu item whose properties are taken from the Action supplied. * * @param a the action of the {@code JCheckBoxMenuItem} - * @since 1.3 + * @since 1.3 */ public TristateCheckBoxMenuItem(final Action a) { this(); diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateState.java b/core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateState.java index c763e396..5c60e39e 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateState.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateState.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.tristate; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/uiresource/Insets2D.java b/core/src/main/java/com/github/weisj/darklaf/components/uiresource/Insets2D.java index d8a5bba6..36ff85ee 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/uiresource/Insets2D.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/uiresource/Insets2D.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.uiresource; @@ -38,7 +39,6 @@ public final class Insets2D implements Cloneable { * @param bottom the inset from the bottom. * @param right the inset from the right. */ - public Insets2D(final double top, final double left, final double bottom, final double right) { this.top = top; this.left = left; @@ -53,7 +53,7 @@ public final class Insets2D implements Cloneable { * @param left the inset from the left. * @param bottom the inset from the bottom. * @param right the inset from the right. - * @since 1.5 + * @since 1.5 */ public void set(final double top, final double left, final double bottom, final double right) { this.top = top; @@ -62,7 +62,6 @@ public final class Insets2D implements Cloneable { this.right = right; } - @Override public int hashCode() { double sum1 = left + bottom; @@ -73,7 +72,6 @@ public final class Insets2D implements Cloneable { return (int) (sum3 * (sum3 + 1) / 2 + val2); } - @Override public boolean equals(final Object obj) { if (obj instanceof Insets2D) { @@ -84,16 +82,12 @@ public final class Insets2D implements Cloneable { return false; } - @Override public Insets2D clone() { return new Insets2D(top, left, bottom, right); } - public String toString() { return getClass().getName() + "[top=" + top + ",left=" + left + ",bottom=" + bottom + ",right=" + right + "]"; } - - } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/uiresource/JButtonUIResource.java b/core/src/main/java/com/github/weisj/darklaf/components/uiresource/JButtonUIResource.java index 0a579538..7471eec2 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/uiresource/JButtonUIResource.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/uiresource/JButtonUIResource.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.uiresource; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/uiresource/JLabelUIResource.java b/core/src/main/java/com/github/weisj/darklaf/components/uiresource/JLabelUIResource.java index 81573007..8930884b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/uiresource/JLabelUIResource.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/uiresource/JLabelUIResource.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.uiresource; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/uiresource/JPanelUIResource.java b/core/src/main/java/com/github/weisj/darklaf/components/uiresource/JPanelUIResource.java index e9999cac..c1984e32 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/uiresource/JPanelUIResource.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/uiresource/JPanelUIResource.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.uiresource; +import java.awt.*; + import javax.swing.*; import javax.swing.plaf.UIResource; -import java.awt.*; public class JPanelUIResource extends JPanel implements UIResource { diff --git a/core/src/main/java/com/github/weisj/darklaf/components/uiresource/UIResourceWrapper.java b/core/src/main/java/com/github/weisj/darklaf/components/uiresource/UIResourceWrapper.java index f7ee7fdc..497ef555 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/uiresource/UIResourceWrapper.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/uiresource/UIResourceWrapper.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.components.uiresource; -import javax.swing.border.Border; import java.awt.*; +import javax.swing.border.Border; + public class UIResourceWrapper extends JPanelUIResource { public UIResourceWrapper(final Component component) { @@ -41,8 +43,7 @@ public class UIResourceWrapper extends JPanelUIResource { } @Override - public void setOpaque(final boolean isOpaque) { - } + public void setOpaque(final boolean isOpaque) {} @Override public boolean isOpaque() { diff --git a/core/src/main/java/com/github/weisj/darklaf/decorators/AncestorAdapter.java b/core/src/main/java/com/github/weisj/darklaf/decorators/AncestorAdapter.java index 2b04c6c9..5eb514c1 100644 --- a/core/src/main/java/com/github/weisj/darklaf/decorators/AncestorAdapter.java +++ b/core/src/main/java/com/github/weisj/darklaf/decorators/AncestorAdapter.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.decorators; @@ -28,14 +29,11 @@ import javax.swing.event.AncestorListener; public class AncestorAdapter implements AncestorListener { @Override - public void ancestorAdded(final AncestorEvent event) { - } + public void ancestorAdded(final AncestorEvent event) {} @Override - public void ancestorRemoved(final AncestorEvent event) { - } + public void ancestorRemoved(final AncestorEvent event) {} @Override - public void ancestorMoved(final AncestorEvent event) { - } + public void ancestorMoved(final AncestorEvent event) {} } diff --git a/core/src/main/java/com/github/weisj/darklaf/decorators/CellRenderer.java b/core/src/main/java/com/github/weisj/darklaf/decorators/CellRenderer.java index 65004567..c713de80 100644 --- a/core/src/main/java/com/github/weisj/darklaf/decorators/CellRenderer.java +++ b/core/src/main/java/com/github/weisj/darklaf/decorators/CellRenderer.java @@ -20,8 +20,8 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.decorators; -public interface CellRenderer { -} +public interface CellRenderer {} diff --git a/core/src/main/java/com/github/weisj/darklaf/decorators/ComponentResizeListener.java b/core/src/main/java/com/github/weisj/darklaf/decorators/ComponentResizeListener.java index 7b2e32d8..e43cf183 100644 --- a/core/src/main/java/com/github/weisj/darklaf/decorators/ComponentResizeListener.java +++ b/core/src/main/java/com/github/weisj/darklaf/decorators/ComponentResizeListener.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.decorators; @@ -30,21 +31,18 @@ import java.awt.event.ComponentListener; * Wrapper interface for resize listener. * * @author Jannis Weis - * @since 2019 + * @since 2019 */ public interface ComponentResizeListener extends ComponentListener { @Override void componentResized(ComponentEvent e); @Override - default void componentMoved(final ComponentEvent e) { - } + default void componentMoved(final ComponentEvent e) {} @Override - default void componentShown(final ComponentEvent e) { - } + default void componentShown(final ComponentEvent e) {} @Override - default void componentHidden(final ComponentEvent e) { - } + default void componentHidden(final ComponentEvent e) {} } diff --git a/core/src/main/java/com/github/weisj/darklaf/decorators/HoverListener.java b/core/src/main/java/com/github/weisj/darklaf/decorators/HoverListener.java index 5fc076ef..1294ffcb 100644 --- a/core/src/main/java/com/github/weisj/darklaf/decorators/HoverListener.java +++ b/core/src/main/java/com/github/weisj/darklaf/decorators/HoverListener.java @@ -20,13 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.decorators; -import javax.swing.*; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; +import javax.swing.*; + /** * @author Jannis Weis */ @@ -36,7 +38,6 @@ public class HoverListener implements MouseListener { private boolean hover = false; private boolean scheduled = false; - public HoverListener(final JComponent component) { this.component = component; } diff --git a/core/src/main/java/com/github/weisj/darklaf/decorators/LayoutManagerDelegate.java b/core/src/main/java/com/github/weisj/darklaf/decorators/LayoutManagerDelegate.java index 5f41b6b3..343f0b85 100644 --- a/core/src/main/java/com/github/weisj/darklaf/decorators/LayoutManagerDelegate.java +++ b/core/src/main/java/com/github/weisj/darklaf/decorators/LayoutManagerDelegate.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.decorators; @@ -28,7 +29,6 @@ import java.awt.*; public class LayoutManagerDelegate implements LayoutManager { private final LayoutManager delegate; - public LayoutManagerDelegate(final LayoutManager delegate) { if (delegate == null) { throw new IllegalArgumentException("Delegate is null"); diff --git a/core/src/main/java/com/github/weisj/darklaf/decorators/MouseClickListener.java b/core/src/main/java/com/github/weisj/darklaf/decorators/MouseClickListener.java index 676f062f..553323b7 100644 --- a/core/src/main/java/com/github/weisj/darklaf/decorators/MouseClickListener.java +++ b/core/src/main/java/com/github/weisj/darklaf/decorators/MouseClickListener.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.decorators; @@ -33,18 +34,14 @@ public interface MouseClickListener extends MouseListener { void mouseClicked(MouseEvent e); @Override - default void mousePressed(final MouseEvent e) { - } + default void mousePressed(final MouseEvent e) {} @Override - default void mouseReleased(final MouseEvent e) { - } + default void mouseReleased(final MouseEvent e) {} @Override - default void mouseEntered(final MouseEvent e) { - } + default void mouseEntered(final MouseEvent e) {} @Override - default void mouseExited(final MouseEvent e) { - } + default void mouseExited(final MouseEvent e) {} } diff --git a/core/src/main/java/com/github/weisj/darklaf/decorators/MouseInputDelegate.java b/core/src/main/java/com/github/weisj/darklaf/decorators/MouseInputDelegate.java index 5acc7d93..0aaaac87 100644 --- a/core/src/main/java/com/github/weisj/darklaf/decorators/MouseInputDelegate.java +++ b/core/src/main/java/com/github/weisj/darklaf/decorators/MouseInputDelegate.java @@ -20,15 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.decorators; -import javax.swing.event.MouseInputListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; +import javax.swing.event.MouseInputListener; + public class MouseInputDelegate implements MouseInputListener { protected MouseListener mouseDelegate; @@ -62,16 +64,14 @@ public class MouseInputDelegate implements MouseInputListener { public void setMotionDelegate(final MouseMotionListener motionDelegate) { this.motionDelegate = motionDelegate; if (motionDelegate == null) { - this.motionDelegate = new MouseAdapter() { - }; + this.motionDelegate = new MouseAdapter() {}; } } public void setMouseDelegate(final MouseListener delegate) { this.mouseDelegate = delegate; if (delegate == null) { - this.mouseDelegate = new MouseAdapter() { - }; + this.mouseDelegate = new MouseAdapter() {}; } } diff --git a/core/src/main/java/com/github/weisj/darklaf/decorators/MouseMovementListener.java b/core/src/main/java/com/github/weisj/darklaf/decorators/MouseMovementListener.java index 8c185806..c52658a3 100644 --- a/core/src/main/java/com/github/weisj/darklaf/decorators/MouseMovementListener.java +++ b/core/src/main/java/com/github/weisj/darklaf/decorators/MouseMovementListener.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.decorators; @@ -29,8 +30,7 @@ import java.awt.event.MouseMotionListener; public interface MouseMovementListener extends MouseMotionListener { @Override - default void mouseDragged(final MouseEvent e) { - } + default void mouseDragged(final MouseEvent e) {} @Override void mouseMoved(MouseEvent e); diff --git a/core/src/main/java/com/github/weisj/darklaf/decorators/MouseResponder.java b/core/src/main/java/com/github/weisj/darklaf/decorators/MouseResponder.java index bec06845..c7f28992 100644 --- a/core/src/main/java/com/github/weisj/darklaf/decorators/MouseResponder.java +++ b/core/src/main/java/com/github/weisj/darklaf/decorators/MouseResponder.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.decorators; @@ -31,7 +32,6 @@ public class MouseResponder implements MouseListener { private final Consumer consumer; - public MouseResponder(final Consumer consumer) { this.consumer = consumer; } diff --git a/core/src/main/java/com/github/weisj/darklaf/decorators/PlainAction.java b/core/src/main/java/com/github/weisj/darklaf/decorators/PlainAction.java index 77d0cdb7..1d96cbf8 100644 --- a/core/src/main/java/com/github/weisj/darklaf/decorators/PlainAction.java +++ b/core/src/main/java/com/github/weisj/darklaf/decorators/PlainAction.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.decorators; -import javax.swing.*; import java.awt.event.ActionEvent; +import javax.swing.*; + /** * @author Jannis Weis */ diff --git a/core/src/main/java/com/github/weisj/darklaf/decorators/PopupMenuAdapter.java b/core/src/main/java/com/github/weisj/darklaf/decorators/PopupMenuAdapter.java index e9cba58b..a613f45e 100644 --- a/core/src/main/java/com/github/weisj/darklaf/decorators/PopupMenuAdapter.java +++ b/core/src/main/java/com/github/weisj/darklaf/decorators/PopupMenuAdapter.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.decorators; diff --git a/core/src/main/java/com/github/weisj/darklaf/decorators/UpdateDocumentListener.java b/core/src/main/java/com/github/weisj/darklaf/decorators/UpdateDocumentListener.java index a7179a66..5cf12aea 100644 --- a/core/src/main/java/com/github/weisj/darklaf/decorators/UpdateDocumentListener.java +++ b/core/src/main/java/com/github/weisj/darklaf/decorators/UpdateDocumentListener.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.decorators; diff --git a/core/src/main/java/com/github/weisj/darklaf/log/LogFormatter.java b/core/src/main/java/com/github/weisj/darklaf/log/LogFormatter.java index 4694e9a3..b25ff535 100644 --- a/core/src/main/java/com/github/weisj/darklaf/log/LogFormatter.java +++ b/core/src/main/java/com/github/weisj/darklaf/log/LogFormatter.java @@ -20,17 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.log; -import com.github.weisj.darklaf.util.StringUtil; - import java.text.SimpleDateFormat; import java.util.Date; import java.util.logging.Formatter; import java.util.logging.Level; import java.util.logging.LogRecord; +import com.github.weisj.darklaf.util.StringUtil; + /** * @author Jannis Weis */ @@ -98,7 +99,6 @@ public class LogFormatter extends Formatter { return builder.toString(); } - private String calculateDateString(final long milliseconds) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = new Date(milliseconds); diff --git a/core/src/main/java/com/github/weisj/darklaf/platform/DecorationsHandler.java b/core/src/main/java/com/github/weisj/darklaf/platform/DecorationsHandler.java index 1f17bf0c..1929d8d8 100644 --- a/core/src/main/java/com/github/weisj/darklaf/platform/DecorationsHandler.java +++ b/core/src/main/java/com/github/weisj/darklaf/platform/DecorationsHandler.java @@ -20,9 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.platform; +import java.awt.*; +import java.util.Properties; + +import javax.swing.*; + import com.github.weisj.darklaf.DarkLaf; import com.github.weisj.darklaf.LafManager; import com.github.weisj.darklaf.platform.decorations.CustomTitlePane; @@ -32,10 +38,6 @@ import com.github.weisj.darklaf.platform.windows.WindowsDecorationsProvider; import com.github.weisj.darklaf.util.PropertyValue; import com.github.weisj.darklaf.util.SystemInfo; -import javax.swing.*; -import java.awt.*; -import java.util.Properties; - public class DecorationsHandler { public static final String DECORATIONS_FLAG = DarkLaf.SYSTEM_PROPERTY_PREFIX + "decorations"; @@ -54,19 +56,19 @@ public class DecorationsHandler { protected DecorationsHandler() { try { - //Extend for different platforms. + // Extend for different platforms. boolean enableDecorations = isNativeDecorationsEnabled(); if (SystemInfo.isWindows10 && enableDecorations) { - //Decorations are in the Windows10 visuals. Disable for older version. + // Decorations are in the Windows10 visuals. Disable for older version. decorationsProvider = new WindowsDecorationsProvider(); } else if (SystemInfo.isMacOSYosemite && enableDecorations) { - //Compiled binary needs at least macOS 10.10 (Yosemite). + // Compiled binary needs at least macOS 10.10 (Yosemite). decorationsProvider = new MacOSDecorationsProvider(); } else { decorationsProvider = new DefaultDecorationsProvider(); } } catch (Throwable e) { - //If decorations modules are not available disable them. + // If decorations modules are not available disable them. decorationsProvider = new DefaultDecorationsProvider(); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/platform/DefaultDecorationsProvider.java b/core/src/main/java/com/github/weisj/darklaf/platform/DefaultDecorationsProvider.java index f9dc4297..3b7f74b9 100644 --- a/core/src/main/java/com/github/weisj/darklaf/platform/DefaultDecorationsProvider.java +++ b/core/src/main/java/com/github/weisj/darklaf/platform/DefaultDecorationsProvider.java @@ -20,27 +20,27 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.platform; -import com.github.weisj.darklaf.platform.decorations.CustomTitlePane; -import com.github.weisj.darklaf.platform.decorations.DecorationsProvider; - -import javax.swing.*; import java.awt.*; import java.util.Properties; +import javax.swing.*; + +import com.github.weisj.darklaf.platform.decorations.CustomTitlePane; +import com.github.weisj.darklaf.platform.decorations.DecorationsProvider; + public class DefaultDecorationsProvider implements DecorationsProvider { @Override public CustomTitlePane createTitlePane(final JRootPane rootPane, final int decorationStyle, final Window window) { return new CustomTitlePane() { @Override - public void install() { - } + public void install() {} @Override - public void uninstall() { - } + public void uninstall() {} @Override public Insets getWindowSizeAdjustment() { @@ -55,10 +55,8 @@ public class DefaultDecorationsProvider implements DecorationsProvider { } @Override - public void initialize() { - } + public void initialize() {} @Override - public void loadDecorationProperties(final Properties properties, final UIDefaults currentDefaults) { - } + public void loadDecorationProperties(final Properties properties, final UIDefaults currentDefaults) {} } diff --git a/core/src/main/java/com/github/weisj/darklaf/platform/DefaultThemePreferenceProvider.java b/core/src/main/java/com/github/weisj/darklaf/platform/DefaultThemePreferenceProvider.java index ea8c9c2e..27d669c5 100644 --- a/core/src/main/java/com/github/weisj/darklaf/platform/DefaultThemePreferenceProvider.java +++ b/core/src/main/java/com/github/weisj/darklaf/platform/DefaultThemePreferenceProvider.java @@ -20,16 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.platform; +import java.util.function.Consumer; + import com.github.weisj.darklaf.theme.info.ColorToneRule; import com.github.weisj.darklaf.theme.info.ContrastRule; import com.github.weisj.darklaf.theme.info.PreferredThemeStyle; import com.github.weisj.darklaf.theme.info.ThemePreferenceProvider; -import java.util.function.Consumer; - public class DefaultThemePreferenceProvider implements ThemePreferenceProvider { @Override public PreferredThemeStyle getPreference() { @@ -37,16 +38,13 @@ public class DefaultThemePreferenceProvider implements ThemePreferenceProvider { } @Override - public void initialize() { - } + public void initialize() {} @Override - public void setCallback(final Consumer callback) { - } + public void setCallback(final Consumer callback) {} @Override - public void setReporting(final boolean reporting) { - } + public void setReporting(final boolean reporting) {} @Override public boolean isReporting() { diff --git a/core/src/main/java/com/github/weisj/darklaf/platform/ThemePreferencesHandler.java b/core/src/main/java/com/github/weisj/darklaf/platform/ThemePreferencesHandler.java index 3f1b85b6..5d2258f6 100644 --- a/core/src/main/java/com/github/weisj/darklaf/platform/ThemePreferencesHandler.java +++ b/core/src/main/java/com/github/weisj/darklaf/platform/ThemePreferencesHandler.java @@ -20,9 +20,12 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.platform; +import javax.swing.*; + import com.github.weisj.darklaf.DarkLaf; import com.github.weisj.darklaf.platform.macos.MacOSThemePreferenceProvider; import com.github.weisj.darklaf.platform.windows.WindowsThemePreferenceProvider; @@ -34,8 +37,6 @@ import com.github.weisj.darklaf.theme.info.ThemePreferenceProvider; import com.github.weisj.darklaf.util.PropertyValue; import com.github.weisj.darklaf.util.SystemInfo; -import javax.swing.*; - public class ThemePreferencesHandler { public static final String PREFERENCE_REPORTING_FLAG = DarkLaf.SYSTEM_PROPERTY_PREFIX + "enableNativePreferences"; @@ -44,7 +45,6 @@ public class ThemePreferencesHandler { private final ThemePreferenceChangeSupport changeSupport = new ThemePreferenceChangeSupport(); private ThemePreferenceProvider preferenceProvider; - public static ThemePreferencesHandler getSharedInstance() { if (sharedInstance == null) setSharedInstance(new ThemePreferencesHandler()); return sharedInstance; @@ -118,7 +118,6 @@ public class ThemePreferencesHandler { return preferenceProvider.supportsNativeTheme(); } - public PreferredThemeStyle getPreferredThemeStyle() { return preferenceProvider.getPreference(); } diff --git a/core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettings.java b/core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettings.java index 6e795cac..6a639b76 100644 --- a/core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettings.java +++ b/core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettings.java @@ -20,9 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.settings; +import java.awt.*; +import java.awt.event.WindowEvent; +import java.util.ResourceBundle; + +import javax.swing.*; + import com.github.weisj.darklaf.LafManager; import com.github.weisj.darklaf.components.DefaultButton; import com.github.weisj.darklaf.theme.Theme; @@ -33,11 +40,6 @@ import com.github.weisj.darklaf.theme.info.FontSizeRule; import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.ImageUtil; -import javax.swing.*; -import java.awt.*; -import java.awt.event.WindowEvent; -import java.util.ResourceBundle; - public class ThemeSettings implements ThemePreferenceListener { private static ThemeSettings instance; @@ -54,7 +56,7 @@ public class ThemeSettings implements ThemePreferenceListener { /** * Show the settings as a dialog. * - * @param parent the parent component. + * @param parent the parent component. * @throws IllegalStateException If {@link #getSettingsPanel()} is already in use. */ public static void showSettingsDialog(final Component parent) { @@ -64,8 +66,8 @@ public class ThemeSettings implements ThemePreferenceListener { /** * Show the settings as a dialog. * - * @param parent the parent component. - * @param modalityType the modality type. + * @param parent the parent component. + * @param modalityType the modality type. * @throws IllegalStateException If {@link #getSettingsPanel()} is already in use. */ public static void showSettingsDialog(final Component parent, final Dialog.ModalityType modalityType) { @@ -96,8 +98,8 @@ public class ThemeSettings implements ThemePreferenceListener { /** * Show the settings as a dialog. * - * @param parent the parent component. - * @param modal the modality type. + * @param parent the parent component. + * @param modal the modality type. * @throws IllegalStateException If {@link #getSettingsPanel()} is already in use. */ public void showDialog(final Component parent, final Dialog.ModalityType modal) { @@ -128,11 +130,11 @@ public class ThemeSettings implements ThemePreferenceListener { * Returns whether the option to follow the system settings is enabled. * * @return true if enabled. - * @see #isSystemPreferencesEnabled() (boolean) - * @see #isThemeFollowsSystem() - * @see #isAccentColorFollowsSystem() - * @see #isSelectionColorFollowsSystem() - * @see #isFontSizeFollowsSystem() + * @see #isSystemPreferencesEnabled() (boolean) + * @see #isThemeFollowsSystem() + * @see #isAccentColorFollowsSystem() + * @see #isSelectionColorFollowsSystem() + * @see #isFontSizeFollowsSystem() */ public boolean isSystemPreferencesEnabled() { return settingsPanel.isSystemPreferencesEnabled(); @@ -142,7 +144,7 @@ public class ThemeSettings implements ThemePreferenceListener { * Returns whether the accent color follows the system settings. * * @return true if accent color follows system settings. - * @see #setAccentColorFollowsSystem(boolean) + * @see #setAccentColorFollowsSystem(boolean) */ public boolean isAccentColorFollowsSystem() { return settingsPanel.isAccentColorFollowsSystem(); @@ -152,7 +154,7 @@ public class ThemeSettings implements ThemePreferenceListener { * Returns whether the font size follows the system settings. * * @return true if font size follows system settings. - * @see #setFontSizeFollowsSystem(boolean) + * @see #setFontSizeFollowsSystem(boolean) */ public boolean isFontSizeFollowsSystem() { return settingsPanel.isFontSizeFollowsSystem(); @@ -162,7 +164,7 @@ public class ThemeSettings implements ThemePreferenceListener { * Returns whether the selection color follows the system settings. * * @return true if selection color follows system settings. - * @see #setSelectionColorFollowsSystem(boolean) + * @see #setSelectionColorFollowsSystem(boolean) */ public boolean isSelectionColorFollowsSystem() { return settingsPanel.isSelectionColorFollowsSystem(); @@ -172,19 +174,18 @@ public class ThemeSettings implements ThemePreferenceListener { * Returns whether the theme follows the system settings. * * @return true if theme follows system settings. - * @see #setThemeFollowsSystem(boolean) + * @see #setThemeFollowsSystem(boolean) */ public boolean isThemeFollowsSystem() { return settingsPanel.isThemeFollowsSystem(); } - /** * Get the currently selected accent color rule. This is not the same as the rule of {@link LafManager#getTheme()} * as the current settings might not have been applied. * * @return the current selected accent color rule. - * @see #setAccentColorRule(AccentColorRule) + * @see #setAccentColorRule(AccentColorRule) */ public AccentColorRule getAccentColorRule() { return settingsPanel.getAccentColorRule(); @@ -195,7 +196,7 @@ public class ThemeSettings implements ThemePreferenceListener { * the current settings might not have been applied. * * @return the current selected font size rule. - * @see #setFontSizeRule(FontSizeRule) + * @see #setFontSizeRule(FontSizeRule) */ public FontSizeRule getFontSizeRule() { return settingsPanel.getFontSizeRule(); @@ -206,7 +207,7 @@ public class ThemeSettings implements ThemePreferenceListener { * might not have been applied. * * @return the current selected theme. - * @see #setTheme(Theme) + * @see #setTheme(Theme) */ public Theme getTheme() { return settingsPanel.getTheme(); @@ -216,10 +217,10 @@ public class ThemeSettings implements ThemePreferenceListener { * Enables the option to follow system preferences. * * @param enabled true if enabled. - * @see #setAccentColorFollowsSystem(boolean) - * @see #setSelectionColorFollowsSystem(boolean) - * @see #setFontSizeFollowsSystem(boolean) - * @see #setThemeFollowsSystem(boolean) + * @see #setAccentColorFollowsSystem(boolean) + * @see #setSelectionColorFollowsSystem(boolean) + * @see #setFontSizeFollowsSystem(boolean) + * @see #setThemeFollowsSystem(boolean) */ public void setEnabledSystemPreferences(final boolean enabled) { settingsPanel.setEnabledSystemPreferences(enabled); @@ -230,7 +231,7 @@ public class ThemeSettings implements ThemePreferenceListener { * #isSelectionColorFollowsSystem()} is true. * * @param accentColorFollowsSystem true if accent color should follow system. - * @see #isAccentColorFollowsSystem() + * @see #isAccentColorFollowsSystem() */ public void setAccentColorFollowsSystem(final boolean accentColorFollowsSystem) { settingsPanel.setAccentColorFollowsSystem(accentColorFollowsSystem); @@ -241,7 +242,7 @@ public class ThemeSettings implements ThemePreferenceListener { * #isSelectionColorFollowsSystem()} is true. * * @param fontSizeFollowsSystem true if font size should follow system. - * @see #isFontSizeFollowsSystem() + * @see #isFontSizeFollowsSystem() */ public void setFontSizeFollowsSystem(final boolean fontSizeFollowsSystem) { settingsPanel.setFontSizeFollowsSystem(fontSizeFollowsSystem); @@ -252,7 +253,7 @@ public class ThemeSettings implements ThemePreferenceListener { * #isSelectionColorFollowsSystem()} is true. * * @param selectionColorFollowsSystem true if selection color should follow system. - * @see #isSelectionColorFollowsSystem() + * @see #isSelectionColorFollowsSystem() */ public void setSelectionColorFollowsSystem(final boolean selectionColorFollowsSystem) { settingsPanel.setSelectionColorFollowsSystem(selectionColorFollowsSystem); @@ -263,7 +264,7 @@ public class ThemeSettings implements ThemePreferenceListener { * #isSelectionColorFollowsSystem()} is true. * * @param themeFollowsSystem true if theme should follow system. - * @see #isThemeFollowsSystem() + * @see #isThemeFollowsSystem() */ public void setThemeFollowsSystem(final boolean themeFollowsSystem) { settingsPanel.setThemeFollowsSystem(themeFollowsSystem); @@ -273,7 +274,7 @@ public class ThemeSettings implements ThemePreferenceListener { * Sets the font accent color rule. The theme is not updated until {@link #apply()} is called. * * @param accentColorRule the accent color rule - * @see #getAccentColorRule() + * @see #getAccentColorRule() */ public void setAccentColorRule(final AccentColorRule accentColorRule) { settingsPanel.setAccentColorRule(accentColorRule); @@ -283,7 +284,7 @@ public class ThemeSettings implements ThemePreferenceListener { * Sets the font size rule. The theme is not updated until {@link #apply()} is called. * * @param fontSizeRule the font size rule. - * @see #getFontSizeRule() + * @see #getFontSizeRule() */ public void setFontSizeRule(final FontSizeRule fontSizeRule) { settingsPanel.setFontSizeRule(fontSizeRule); @@ -293,7 +294,7 @@ public class ThemeSettings implements ThemePreferenceListener { * Sets the theme. The theme is not updated until {@link #apply()} is called. * * @param theme the theme. - * @see #getTheme() + * @see #getTheme() */ public void setTheme(final Theme theme) { settingsPanel.setTheme(theme); diff --git a/core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettingsPanel.java b/core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettingsPanel.java index f8819ad9..8f86cac3 100644 --- a/core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettingsPanel.java +++ b/core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettingsPanel.java @@ -20,9 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.settings; +import java.awt.*; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.util.*; + +import javax.swing.*; +import javax.swing.plaf.SliderUI; + import com.github.weisj.darklaf.LafManager; import com.github.weisj.darklaf.components.ColoredRadioButton; import com.github.weisj.darklaf.components.color.QuickColorChooser; @@ -41,13 +50,6 @@ import com.github.weisj.darklaf.ui.slider.DarkSliderUI; import com.github.weisj.darklaf.ui.tooltip.ToolTipConstants; import com.github.weisj.darklaf.util.Alignment; -import javax.swing.*; -import javax.swing.plaf.SliderUI; -import java.awt.*; -import java.awt.event.ActionListener; -import java.awt.event.MouseEvent; -import java.util.*; - public class ThemeSettingsPanel extends JPanel { private final ResourceBundle resourceBundle; @@ -115,10 +117,10 @@ public class ThemeSettingsPanel extends JPanel { fontSizeFollowsSystem.setEnabled(enabled); if (enabledSystemPreferences.isSelected()) { themeFollowsSystem.setSelected(themeFollowsSystem.isSelected() && themeFollowsSystem.isEnabled()); - accentColorFollowsSystem.setSelected( - accentColorFollowsSystem.isSelected() && accentColorFollowsSystem.isEnabled()); - selectionColorFollowsSystem.setSelected( - selectionColorFollowsSystem.isSelected() && selectionColorFollowsSystem.isEnabled()); + accentColorFollowsSystem.setSelected(accentColorFollowsSystem.isSelected() + && accentColorFollowsSystem.isEnabled()); + selectionColorFollowsSystem.setSelected(selectionColorFollowsSystem.isSelected() + && selectionColorFollowsSystem.isEnabled()); fontSizeFollowsSystem.setSelected(fontSizeFollowsSystem.isSelected() && fontSizeFollowsSystem.isEnabled()); } if (!skipPreferences) { @@ -216,9 +218,9 @@ public class ThemeSettingsPanel extends JPanel { private Component createGeneralSettings() { JLabel themeLabel = new JLabel(resourceBundle.getString("label_theme")); - themeComboBox = new JComboBox(LafManager.getThemeComboBoxModel()) {{ - setSelectedItem(LafManager.getTheme()); - }}; + themeComboBox = new JComboBox(LafManager.getThemeComboBoxModel()); + themeComboBox.setSelectedItem(LafManager.getTheme()); + themeComboBox.putClientProperty(ComboBoxConstants.KEY_DO_NOT_UPDATE_WHEN_SCROLLED, true); themeComboBox.addItemListener(e -> update(false)); themeLabel.setLabelFor(themeComboBox); @@ -335,8 +337,8 @@ public class ThemeSettingsPanel extends JPanel { protected Theme getTheme(final PreferredThemeStyle preferredThemeStyle) { return isThemeFollowsSystem() - ? LafManager.themeForPreferredStyle(preferredThemeStyle) - : (Theme) themeComboBox.getSelectedItem(); + ? LafManager.themeForPreferredStyle(preferredThemeStyle) + : (Theme) themeComboBox.getSelectedItem(); } public FontSizeRule getFontSizeRule() { @@ -347,8 +349,8 @@ public class ThemeSettingsPanel extends JPanel { protected FontSizeRule getFontSizeRule(final Theme theme, final PreferredThemeStyle preferredThemeStyle) { if (theme == null) return FontSizeRule.getDefault(); return isFontSizeFollowsSystem() - ? preferredThemeStyle.getFontSizeRule() - : FontSizeRule.relativeAdjustment(fontSlider.getValue()); + ? preferredThemeStyle.getFontSizeRule() + : FontSizeRule.relativeAdjustment(fontSlider.getValue()); } public AccentColorRule getAccentColorRule() { @@ -365,16 +367,16 @@ public class ThemeSettingsPanel extends JPanel { protected Color getAccentColor(final Theme theme, final boolean useThemeColor) { return theme.supportsCustomAccentColor() - ? useThemeColor ? theme.getAccentColorRule().getAccentColor() - : getSelectedColor(bgAccent) - : null; + ? useThemeColor ? theme.getAccentColorRule().getAccentColor() + : getSelectedColor(bgAccent) + : null; } protected Color getSelectionColor(final Theme theme, final boolean useThemeColor) { return theme.supportsCustomSelectionColor() - ? useThemeColor ? theme.getAccentColorRule().getSelectionColor() - : getSelectedColor(bgSelection) - : null; + ? useThemeColor ? theme.getAccentColorRule().getSelectionColor() + : getSelectedColor(bgSelection) + : null; } public void setEnabledSystemPreferences(final boolean enabled) { @@ -458,19 +460,19 @@ public class ThemeSettingsPanel extends JPanel { } }; ToolTipContext context = new ToolTipContext() - .setAlignment(Alignment.CENTER) - .setCenterAlignment(Alignment.NORTH) - .setUseBestFit(true) - .setToolTipRectSupplier(e -> { - SliderUI ui = fontSlider.getUI(); - if (ui instanceof DarkSliderUI) { - Rectangle r = ((DarkSliderUI) ui).getThumbRect(); - r.x -= 1; - return r; - } - return new Rectangle(0, 0, fontSlider.getWidth(), - fontSlider.getHeight()); - }); + .setAlignment(Alignment.CENTER) + .setCenterAlignment(Alignment.NORTH) + .setUseBestFit(true) + .setToolTipRectSupplier(e -> { + SliderUI ui = fontSlider.getUI(); + if (ui instanceof DarkSliderUI) { + Rectangle r = ((DarkSliderUI) ui).getThumbRect(); + r.x -= 1; + return r; + } + return new Rectangle(0, 0, fontSlider.getWidth(), + fontSlider.getHeight()); + }); fontSlider.putClientProperty(DarkSliderUI.KEY_INSTANT_SCROLL, true); fontSlider.putClientProperty(ToolTipConstants.KEY_CONTEXT, context); fontSlider.putClientProperty(ToolTipConstants.KEY_STYLE, ToolTipConstants.VARIANT_BALLOON); @@ -627,8 +629,8 @@ public class ThemeSettingsPanel extends JPanel { verticalComponentGroup.addComponent(field, p, p, p); } for (int i = 0; i < left.length; i++) { - verticalGroup.addGroup(layout.createParallelGroup( - GroupLayout.Alignment.CENTER).addComponent(left[i]).addComponent(right[i], p, p, p)); + verticalGroup.addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER) + .addComponent(left[i]).addComponent(right[i], p, p, p)); } return panel; } diff --git a/core/src/main/java/com/github/weisj/darklaf/settings/ThemedColor.java b/core/src/main/java/com/github/weisj/darklaf/settings/ThemedColor.java index 5224805c..be25b3e4 100644 --- a/core/src/main/java/com/github/weisj/darklaf/settings/ThemedColor.java +++ b/core/src/main/java/com/github/weisj/darklaf/settings/ThemedColor.java @@ -20,16 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.settings; +import java.awt.*; + +import javax.swing.*; + import com.github.weisj.darklaf.LafManager; import com.github.weisj.darklaf.theme.Theme; import com.github.weisj.darklaf.util.ColorWrapper; -import javax.swing.*; -import java.awt.*; - public class ThemedColor extends ColorWrapper { protected Theme currentTheme; diff --git a/core/src/main/java/com/github/weisj/darklaf/task/AccentColorAdjustmentTask.java b/core/src/main/java/com/github/weisj/darklaf/task/AccentColorAdjustmentTask.java index 5bee8dd1..9178137d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/task/AccentColorAdjustmentTask.java +++ b/core/src/main/java/com/github/weisj/darklaf/task/AccentColorAdjustmentTask.java @@ -20,22 +20,24 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.task; +import java.awt.*; +import java.util.List; +import java.util.Properties; +import java.util.logging.Logger; + +import javax.swing.*; +import javax.swing.plaf.ColorUIResource; + import com.github.weisj.darklaf.PropertyLoader; import com.github.weisj.darklaf.color.DarkColorModelHSB; import com.github.weisj.darklaf.icons.IconLoader; import com.github.weisj.darklaf.theme.Theme; import com.github.weisj.darklaf.util.Pair; -import javax.swing.*; -import javax.swing.plaf.ColorUIResource; -import java.awt.*; -import java.util.List; -import java.util.Properties; -import java.util.logging.Logger; - public class AccentColorAdjustmentTask implements DefaultsAdjustmentTask { private static final Logger LOGGER = Logger.getLogger(AccentColorAdjustmentTask.class.getName()); diff --git a/core/src/main/java/com/github/weisj/darklaf/task/DefaultsAdjustmentTask.java b/core/src/main/java/com/github/weisj/darklaf/task/DefaultsAdjustmentTask.java index e19e42db..bbb406c7 100644 --- a/core/src/main/java/com/github/weisj/darklaf/task/DefaultsAdjustmentTask.java +++ b/core/src/main/java/com/github/weisj/darklaf/task/DefaultsAdjustmentTask.java @@ -20,13 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.task; -import com.github.weisj.darklaf.theme.Theme; - import java.util.Properties; +import com.github.weisj.darklaf.theme.Theme; + public interface DefaultsAdjustmentTask { /** diff --git a/core/src/main/java/com/github/weisj/darklaf/task/DefaultsInitTask.java b/core/src/main/java/com/github/weisj/darklaf/task/DefaultsInitTask.java index 8887a840..ecbf9360 100644 --- a/core/src/main/java/com/github/weisj/darklaf/task/DefaultsInitTask.java +++ b/core/src/main/java/com/github/weisj/darklaf/task/DefaultsInitTask.java @@ -20,13 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.task; -import com.github.weisj.darklaf.theme.Theme; - import javax.swing.*; +import com.github.weisj.darklaf.theme.Theme; + public interface DefaultsInitTask { /** diff --git a/core/src/main/java/com/github/weisj/darklaf/task/FontDefaultsInitTask.java b/core/src/main/java/com/github/weisj/darklaf/task/FontDefaultsInitTask.java index 53704e77..2490d40b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/task/FontDefaultsInitTask.java +++ b/core/src/main/java/com/github/weisj/darklaf/task/FontDefaultsInitTask.java @@ -20,18 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.task; -import com.github.weisj.darklaf.DarkLaf; -import com.github.weisj.darklaf.PropertyLoader; -import com.github.weisj.darklaf.theme.Theme; -import com.github.weisj.darklaf.theme.info.FontSizeRule; -import com.github.weisj.darklaf.util.SystemInfo; - -import javax.swing.*; -import javax.swing.plaf.FontUIResource; -import javax.swing.plaf.UIResource; import java.awt.*; import java.awt.font.TextAttribute; import java.text.AttributedCharacterIterator; @@ -40,6 +32,16 @@ import java.util.Map; import java.util.Properties; import java.util.logging.Logger; +import javax.swing.*; +import javax.swing.plaf.FontUIResource; +import javax.swing.plaf.UIResource; + +import com.github.weisj.darklaf.DarkLaf; +import com.github.weisj.darklaf.PropertyLoader; +import com.github.weisj.darklaf.theme.Theme; +import com.github.weisj.darklaf.theme.info.FontSizeRule; +import com.github.weisj.darklaf.util.SystemInfo; + public class FontDefaultsInitTask implements DefaultsInitTask { private static final Logger LOGGER = Logger.getLogger(FontDefaultsInitTask.class.getName()); @@ -47,10 +49,10 @@ public class FontDefaultsInitTask implements DefaultsInitTask { private static final String FONT_SIZE_DEFAULTS_NAME = "font_sizes"; private static final String FONT_DEFAULTS_NAME = "font"; - private static final Map ENABLE_KERNING - = Collections.singletonMap(TextAttribute.KERNING, TextAttribute.KERNING_ON); - private static final Map DISABLE_KERNING - = Collections.singletonMap(TextAttribute.KERNING, null); + private static final Map ENABLE_KERNING = Collections.singletonMap(TextAttribute.KERNING, + TextAttribute.KERNING_ON); + private static final Map DISABLE_KERNING = Collections.singletonMap(TextAttribute.KERNING, + null); private static final String MAC_OS_CATALINA_FONT_NAME = ".AppleSystemUIFont"; private static final String MAC_OS_FONT_NAME = ".SF NS Text"; diff --git a/core/src/main/java/com/github/weisj/darklaf/task/FontMapper.java b/core/src/main/java/com/github/weisj/darklaf/task/FontMapper.java index 9d8fab0e..84289831 100644 --- a/core/src/main/java/com/github/weisj/darklaf/task/FontMapper.java +++ b/core/src/main/java/com/github/weisj/darklaf/task/FontMapper.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.task; -import javax.swing.*; import java.awt.*; +import javax.swing.*; + public interface FontMapper { Font map(final Font font, final UIDefaults defaults); diff --git a/core/src/main/java/com/github/weisj/darklaf/task/IdeaDefaultsInitTask.java b/core/src/main/java/com/github/weisj/darklaf/task/IdeaDefaultsInitTask.java index f040d945..64d9bd0b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/task/IdeaDefaultsInitTask.java +++ b/core/src/main/java/com/github/weisj/darklaf/task/IdeaDefaultsInitTask.java @@ -20,13 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.task; -import com.github.weisj.darklaf.theme.Theme; - import javax.swing.*; +import com.github.weisj.darklaf.theme.Theme; + public class IdeaDefaultsInitTask implements DefaultsInitTask { @Override public void run(final Theme currentTheme, final UIDefaults defaults) { @@ -35,60 +36,82 @@ public class IdeaDefaultsInitTask implements DefaultsInitTask { @SuppressWarnings({"HardCodedStringLiteral"}) private void initIdeaDefaults(final UIDefaults defaults) { - defaults.put("Table.ancestorInputMap", new UIDefaults.LazyInputMap( - new Object[]{ - "ctrl C", "copy", - "meta C", "copy", - "ctrl V", "paste", - "meta V", "paste", - "ctrl X", "cut", - "meta X", "cut", - "COPY", "copy", - "PASTE", "paste", - "CUT", "cut", - "control INSERT", "copy", - "shift INSERT", "paste", - "shift DELETE", "cut", - "RIGHT", "selectNextColumn", - "KP_RIGHT", "selectNextColumn", - "LEFT", "selectPreviousColumn", - "KP_LEFT", "selectPreviousColumn", - "DOWN", "selectNextRow", - "KP_DOWN", "selectNextRow", - "UP", "selectPreviousRow", - "KP_UP", "selectPreviousRow", - "shift RIGHT", "selectNextColumnExtendSelection", - "shift KP_RIGHT", "selectNextColumnExtendSelection", - "shift LEFT", "selectPreviousColumnExtendSelection", - "shift KP_LEFT", "selectPreviousColumnExtendSelection", - "shift DOWN", "selectNextRowExtendSelection", - "shift KP_DOWN", "selectNextRowExtendSelection", - "shift UP", "selectPreviousRowExtendSelection", - "shift KP_UP", "selectPreviousRowExtendSelection", - "PAGE_UP", "scrollUpChangeSelection", - "PAGE_DOWN", "scrollDownChangeSelection", - "HOME", "selectFirstColumn", - "END", "selectLastColumn", - "shift PAGE_UP", "scrollUpExtendSelection", - "shift PAGE_DOWN", "scrollDownExtendSelection", - "shift HOME", "selectFirstColumnExtendSelection", - "shift END", "selectLastColumnExtendSelection", - "ctrl PAGE_UP", "scrollLeftChangeSelection", - "ctrl PAGE_DOWN", "scrollRightChangeSelection", - "ctrl HOME", "selectFirstRow", - "ctrl END", "selectLastRow", - "ctrl shift PAGE_UP", "scrollRightExtendSelection", - "ctrl shift PAGE_DOWN", "scrollLeftExtendSelection", - "ctrl shift HOME", "selectFirstRowExtendSelection", - "ctrl shift END", "selectLastRowExtendSelection", - "TAB", "selectNextColumnCell", - "shift TAB", "selectPreviousColumnCell", - "ENTER", "selectNextRowCell", - "shift ENTER", "selectPreviousRowCell", - "ctrl A", "selectAll", - "meta A", "selectAll", - "ESCAPE", "cancel", - "F2", "startEditing" - })); + defaults.put("Table.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[]{ + "ctrl C", "copy", + "meta C", "copy", + "ctrl V", "paste", + "meta V", "paste", + "ctrl X", "cut", + "meta X", "cut", + "COPY", "copy", + "PASTE", "paste", + "CUT", "cut", + "control INSERT", "copy", + "shift INSERT", "paste", + "shift DELETE", "cut", + "RIGHT", "selectNextColumn", + "KP_RIGHT", "selectNextColumn", + "LEFT", "selectPreviousColumn", + "KP_LEFT", + "selectPreviousColumn", + "DOWN", "selectNextRow", + "KP_DOWN", "selectNextRow", + "UP", "selectPreviousRow", + "KP_UP", "selectPreviousRow", + "shift RIGHT", + "selectNextColumnExtendSelection", + "shift KP_RIGHT", + "selectNextColumnExtendSelection", + "shift LEFT", + "selectPreviousColumnExtendSelection", + "shift KP_LEFT", + "selectPreviousColumnExtendSelection", + "shift DOWN", + "selectNextRowExtendSelection", + "shift KP_DOWN", + "selectNextRowExtendSelection", + "shift UP", + "selectPreviousRowExtendSelection", + "shift KP_UP", + "selectPreviousRowExtendSelection", + "PAGE_UP", + "scrollUpChangeSelection", + "PAGE_DOWN", + "scrollDownChangeSelection", + "HOME", "selectFirstColumn", + "END", "selectLastColumn", + "shift PAGE_UP", + "scrollUpExtendSelection", + "shift PAGE_DOWN", + "scrollDownExtendSelection", + "shift HOME", + "selectFirstColumnExtendSelection", + "shift END", + "selectLastColumnExtendSelection", + "ctrl PAGE_UP", + "scrollLeftChangeSelection", + "ctrl PAGE_DOWN", + "scrollRightChangeSelection", + "ctrl HOME", "selectFirstRow", + "ctrl END", "selectLastRow", + "ctrl shift PAGE_UP", + "scrollRightExtendSelection", + "ctrl shift PAGE_DOWN", + "scrollLeftExtendSelection", + "ctrl shift HOME", + "selectFirstRowExtendSelection", + "ctrl shift END", + "selectLastRowExtendSelection", + "TAB", "selectNextColumnCell", + "shift TAB", + "selectPreviousColumnCell", + "ENTER", "selectNextRowCell", + "shift ENTER", + "selectPreviousRowCell", + "ctrl A", "selectAll", + "meta A", "selectAll", + "ESCAPE", "cancel", + "F2", "startEditing" + })); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/task/InputDefaultsInitTask.java b/core/src/main/java/com/github/weisj/darklaf/task/InputDefaultsInitTask.java index d11fed04..6fa69a62 100644 --- a/core/src/main/java/com/github/weisj/darklaf/task/InputDefaultsInitTask.java +++ b/core/src/main/java/com/github/weisj/darklaf/task/InputDefaultsInitTask.java @@ -20,17 +20,19 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.task; -import com.github.weisj.darklaf.theme.Theme; -import com.github.weisj.darklaf.util.SystemInfo; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; import javax.swing.*; import javax.swing.plaf.metal.MetalLookAndFeel; import javax.swing.text.DefaultEditorKit; -import java.awt.event.InputEvent; -import java.awt.event.KeyEvent; + +import com.github.weisj.darklaf.theme.Theme; +import com.github.weisj.darklaf.util.SystemInfo; public class InputDefaultsInitTask implements DefaultsInitTask { @@ -44,7 +46,7 @@ public class InputDefaultsInitTask implements DefaultsInitTask { // Make ENTER work in JTrees final InputMap treeInputMap = (InputMap) defaults.get("Tree.focusInputMap"); if (treeInputMap != null) { - // it's really possible. For example, GTK+ doesn't have such a map. + // it's really possible. For example, GTK+ doesn't have such a map. treeInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "toggle"); } // Cut/Copy/Paste in JTextAreas diff --git a/core/src/main/java/com/github/weisj/darklaf/task/PlatformDefaultsInitTask.java b/core/src/main/java/com/github/weisj/darklaf/task/PlatformDefaultsInitTask.java index 8d29498b..f9ec81ee 100644 --- a/core/src/main/java/com/github/weisj/darklaf/task/PlatformDefaultsInitTask.java +++ b/core/src/main/java/com/github/weisj/darklaf/task/PlatformDefaultsInitTask.java @@ -20,16 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.task; +import javax.swing.*; + import com.github.weisj.darklaf.platform.DecorationsHandler; import com.github.weisj.darklaf.theme.Theme; import com.github.weisj.darklaf.ui.popupmenu.DarkPopupMenuUI; import com.github.weisj.darklaf.util.SystemInfo; -import javax.swing.*; - public class PlatformDefaultsInitTask implements DefaultsInitTask { @Override public void run(final Theme currentTheme, final UIDefaults defaults) { diff --git a/core/src/main/java/com/github/weisj/darklaf/task/PropertyFontMapper.java b/core/src/main/java/com/github/weisj/darklaf/task/PropertyFontMapper.java index 15ffd8bd..e5d99005 100644 --- a/core/src/main/java/com/github/weisj/darklaf/task/PropertyFontMapper.java +++ b/core/src/main/java/com/github/weisj/darklaf/task/PropertyFontMapper.java @@ -20,16 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.task; -import com.github.weisj.darklaf.LafManager; -import com.github.weisj.darklaf.theme.Theme; - -import javax.swing.*; import java.awt.*; import java.util.logging.Logger; +import javax.swing.*; + +import com.github.weisj.darklaf.LafManager; +import com.github.weisj.darklaf.theme.Theme; + public class PropertyFontMapper implements FontMapper { private static final Logger LOGGER = Logger.getLogger(PropertyFontMapper.class.getName()); diff --git a/core/src/main/java/com/github/weisj/darklaf/task/SystemDefaultsInitTask.java b/core/src/main/java/com/github/weisj/darklaf/task/SystemDefaultsInitTask.java index e798fd55..39626364 100644 --- a/core/src/main/java/com/github/weisj/darklaf/task/SystemDefaultsInitTask.java +++ b/core/src/main/java/com/github/weisj/darklaf/task/SystemDefaultsInitTask.java @@ -20,16 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.task; +import java.util.Properties; + +import javax.swing.*; + import com.github.weisj.darklaf.DarkLaf; import com.github.weisj.darklaf.PropertyLoader; import com.github.weisj.darklaf.theme.Theme; -import javax.swing.*; -import java.util.Properties; - public class SystemDefaultsInitTask implements DefaultsInitTask { private static final String OVERWRITES_PATH = "properties/"; @@ -43,8 +45,8 @@ public class SystemDefaultsInitTask implements DefaultsInitTask { private void loadSystemOverwrites(final UIDefaults defaults) { Properties overwrites = PropertyLoader.loadProperties(DarkLaf.class, OVERWRITES_NAME, OVERWRITES_PATH); overwrites.values().removeIf(v -> System.getProperty(DarkLaf.SYSTEM_PROPERTY_PREFIX + v.toString()) == null); - overwrites.entrySet().forEach( - e -> e.setValue(System.getProperty(DarkLaf.SYSTEM_PROPERTY_PREFIX + e.getValue().toString()))); + overwrites.entrySet().forEach(e -> e.setValue(System.getProperty(DarkLaf.SYSTEM_PROPERTY_PREFIX + + e.getValue().toString()))); PropertyLoader.putProperties(overwrites, defaults); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/task/ThemeDefaultsInitTask.java b/core/src/main/java/com/github/weisj/darklaf/task/ThemeDefaultsInitTask.java index e3ce840b..43fb60a6 100644 --- a/core/src/main/java/com/github/weisj/darklaf/task/ThemeDefaultsInitTask.java +++ b/core/src/main/java/com/github/weisj/darklaf/task/ThemeDefaultsInitTask.java @@ -20,33 +20,40 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.task; +import java.util.HashMap; +import java.util.Properties; + +import javax.swing.*; +import javax.swing.text.html.HTMLEditorKit; + import com.github.weisj.darklaf.DarkLaf; import com.github.weisj.darklaf.PropertyLoader; import com.github.weisj.darklaf.platform.DecorationsHandler; import com.github.weisj.darklaf.theme.Theme; import com.github.weisj.darklaf.util.SystemInfo; -import javax.swing.*; -import javax.swing.text.html.HTMLEditorKit; -import java.util.HashMap; -import java.util.Properties; - public class ThemeDefaultsInitTask implements DefaultsInitTask { private static final String GLOBAL_PREFIX = "global."; private static final String MAC_OS_MENU_BAR_KEY = "apple.laf.useScreenMenuBar"; private static final String[] UI_PROPERTIES = new String[]{ - "borders", "button", "checkBox", "colorChooser", "comboBox", "fileChooser", "tristate", - "internalFrame", "label", "list", "menu", "menuBar", "menuItem", "numberingPane", "optionPane", "panel", - "popupMenu", "progressBar", "radioButton", "rootPane", "scrollBar", "scrollPane", "separator", - "slider", "spinner", "splitPane", "statusBar", "tabbedPane", "tabFrame", "table", "taskPane", "text", - "toggleButton", "toolBar", "toolTip", "tree", "misc" + "borders", "button", "checkBox", "colorChooser", + "comboBox", "fileChooser", "tristate", + "internalFrame", "label", "list", "menu", "menuBar", + "menuItem", "numberingPane", "optionPane", "panel", + "popupMenu", "progressBar", "radioButton", "rootPane", + "scrollBar", "scrollPane", "separator", + "slider", "spinner", "splitPane", "statusBar", + "tabbedPane", "tabFrame", "table", "taskPane", "text", + "toggleButton", "toolBar", "toolTip", "tree", "misc" }; private static final String[] ICON_PROPERTIES = new String[]{ - "checkBox", "radioButton", "dialog", "files", "frame", "indicator", "menu", "misc", "navigation" + "checkBox", "radioButton", "dialog", "files", "frame", + "indicator", "menu", "misc", "navigation" }; private final DefaultsAdjustmentTask userPreferenceAdjustment = new UserPreferenceAdjustmentTask(); private final DefaultsAdjustmentTask accentColorAdjustment = new AccentColorAdjustmentTask(); @@ -84,8 +91,8 @@ public class ThemeDefaultsInitTask implements DefaultsInitTask { } private void initGlobals(final Theme currentTheme, final UIDefaults defaults, final Properties uiProps) { - PropertyLoader.putProperties( - PropertyLoader.loadProperties(DarkLaf.class, "globals", "properties/"), uiProps, defaults); + PropertyLoader.putProperties(PropertyLoader.loadProperties(DarkLaf.class, "globals", "properties/"), uiProps, + defaults); currentTheme.customizeGlobals(uiProps, defaults); installGlobals(uiProps, defaults); @@ -98,20 +105,19 @@ public class ThemeDefaultsInitTask implements DefaultsInitTask { globalSettings.put(((String) key).substring(GLOBAL_PREFIX.length()), uiProps.get(key)); } } - PropertyLoader.replaceProperties( - defaults, - e -> e.getKey() instanceof String && ((String) e.getKey()).contains("."), - e -> { - final String s = (String) e.getKey(); - final String globalKey = s.substring(s.lastIndexOf('.') + 1); - return globalSettings.get(globalKey); - }); + PropertyLoader.replaceProperties(defaults, + e -> e.getKey() instanceof String && ((String) e.getKey()).contains("."), + e -> { + final String s = (String) e.getKey(); + final String globalKey = s.substring(s.lastIndexOf('.') + 1); + return globalSettings.get(globalKey); + }); } private void initUIProperties(final Theme currentTheme, final UIDefaults defaults, final Properties uiProps) { for (String property : UI_PROPERTIES) { - PropertyLoader.putProperties( - PropertyLoader.loadProperties(DarkLaf.class, property, "properties/ui/"), uiProps, defaults); + PropertyLoader.putProperties(PropertyLoader.loadProperties(DarkLaf.class, property, "properties/ui/"), + uiProps, defaults); } currentTheme.customizeUIProperties(uiProps, defaults); } @@ -119,15 +125,15 @@ public class ThemeDefaultsInitTask implements DefaultsInitTask { private void initIconTheme(final Theme currentTheme, final UIDefaults defaults, final Properties uiProps) { currentTheme.loadIconTheme(uiProps, defaults); for (String property : ICON_PROPERTIES) { - PropertyLoader.putProperties( - PropertyLoader.loadProperties(DarkLaf.class, property, "properties/icons/"), uiProps, defaults); + PropertyLoader.putProperties(PropertyLoader.loadProperties(DarkLaf.class, property, "properties/icons/"), + uiProps, defaults); } currentTheme.customizeIconTheme(uiProps, defaults); } private void initPlatformProperties(final Theme currentTheme, final UIDefaults defaults, final Properties uiProps) { - PropertyLoader.putProperties( - PropertyLoader.loadProperties(DarkLaf.class, getOsName(), "properties/platform/"), uiProps, defaults); + PropertyLoader.putProperties(PropertyLoader.loadProperties(DarkLaf.class, getOsName(), "properties/platform/"), + uiProps, defaults); currentTheme.customizePlatformProperties(uiProps, defaults); } diff --git a/core/src/main/java/com/github/weisj/darklaf/task/UserPreferenceAdjustmentTask.java b/core/src/main/java/com/github/weisj/darklaf/task/UserPreferenceAdjustmentTask.java index fff394bf..c9bfe825 100644 --- a/core/src/main/java/com/github/weisj/darklaf/task/UserPreferenceAdjustmentTask.java +++ b/core/src/main/java/com/github/weisj/darklaf/task/UserPreferenceAdjustmentTask.java @@ -20,14 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.task; +import java.util.Properties; + import com.github.weisj.darklaf.LafManager; import com.github.weisj.darklaf.theme.Theme; -import java.util.Properties; - public class UserPreferenceAdjustmentTask implements DefaultsAdjustmentTask { @Override diff --git a/core/src/main/java/com/github/weisj/darklaf/task/UtilityDefaultsInitTask.java b/core/src/main/java/com/github/weisj/darklaf/task/UtilityDefaultsInitTask.java index c6686e9f..3ab40c9d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/task/UtilityDefaultsInitTask.java +++ b/core/src/main/java/com/github/weisj/darklaf/task/UtilityDefaultsInitTask.java @@ -20,16 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.task; +import javax.swing.*; + import com.github.weisj.darklaf.icons.AwareIconStyle; import com.github.weisj.darklaf.icons.IconLoader; import com.github.weisj.darklaf.theme.Theme; import com.github.weisj.darklaf.util.DarkUIUtil; -import javax.swing.*; - public class UtilityDefaultsInitTask implements DefaultsInitTask { @Override public void run(final Theme currentTheme, final UIDefaults defaults) { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/BasicTransferable.java b/core/src/main/java/com/github/weisj/darklaf/ui/BasicTransferable.java index 8155b088..0b4e604c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/BasicTransferable.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/BasicTransferable.java @@ -20,11 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui; - -import javax.swing.plaf.UIResource; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; import java.awt.datatransfer.UnsupportedFlavorException; @@ -34,10 +33,12 @@ import java.io.StringBufferInputStream; import java.io.StringReader; import java.util.logging.Logger; +import javax.swing.plaf.UIResource; + /** * A transferable implementation for the default data transfer of some Swing components. * - * @author Timothy Prinzing + * @author Timothy Prinzing * @version 1.10 11/17/05 */ public class BasicTransferable implements Transferable, UIResource { @@ -75,9 +76,8 @@ public class BasicTransferable implements Transferable, UIResource { this.htmlData = htmlData; } - /** - * Returns an array of DataFlavor objects indicating the flavors the data can be provided in. The array should be + * Returns an array of DataFlavor objects indicating the flavors the data can be provided in. The array should be * ordered according to preference for providing the data (from most richly descriptive to least descriptive). * * @return an array of data flavors in which this data can be transferred. @@ -115,8 +115,8 @@ public class BasicTransferable implements Transferable, UIResource { /** * Returns whether the specified data flavor is supported for this object. * - * @param flavor the requested flavor for the data - * @return boolean indicating whether the data flavor is supported. + * @param flavor the requested flavor for the data + * @return boolean indicating whether the data flavor is supported. */ public boolean isDataFlavorSupported(final DataFlavor flavor) { DataFlavor[] flavors = getTransferDataFlavors(); @@ -129,12 +129,12 @@ public class BasicTransferable implements Transferable, UIResource { } /** - * Returns an object which represents the data to be transferred. The class of the object returned is defined by + * Returns an object which represents the data to be transferred. The class of the object returned is defined by * the representation class of the flavor. * - * @param flavor the requested flavor for the data + * @param flavor the requested flavor for the data * @throws UnsupportedFlavorException if the requested data flavor is not supported. - * @see DataFlavor#getRepresentationClass + * @see DataFlavor#getRepresentationClass */ public Object getTransferData(final DataFlavor flavor) throws UnsupportedFlavorException { if (isRicherFlavor(flavor)) { @@ -184,7 +184,7 @@ public class BasicTransferable implements Transferable, UIResource { } /** - * Some subclasses will have flavors that are more descriptive than HTML or plain text. If this method returns a + * Some subclasses will have flavors that are more descriptive than HTML or plain text. If this method returns a * non-null value, it will be placed at the start of the array of supported flavors. * * @return the supported data flavours as array. @@ -202,8 +202,8 @@ public class BasicTransferable implements Transferable, UIResource { /** * Returns whether or not the specified data flavor is an HTML flavor that is supported. * - * @param flavor the requested flavor for the data - * @return boolean indicating whether or not the data flavor is supported + * @param flavor the requested flavor for the data + * @return boolean indicating whether or not the data flavor is supported */ protected boolean isHTMLFlavor(final DataFlavor flavor) { DataFlavor[] flavors = htmlFlavors; @@ -216,7 +216,7 @@ public class BasicTransferable implements Transferable, UIResource { } /** - * Should the HTML flavors be offered? If so, the method getHTMLData should be implemented to provide something + * Should the HTML flavors be offered? If so, the method getHTMLData should be implemented to provide something * reasonable. * * @return true if html is supported. @@ -239,8 +239,8 @@ public class BasicTransferable implements Transferable, UIResource { /** * Returns whether or not the specified data flavor is an plain flavor that is supported. * - * @param flavor the requested flavor for the data - * @return boolean indicating whether or not the data flavor is supported + * @param flavor the requested flavor for the data + * @return boolean indicating whether or not the data flavor is supported */ protected boolean isPlainFlavor(final DataFlavor flavor) { DataFlavor[] flavors = plainFlavors; @@ -253,7 +253,7 @@ public class BasicTransferable implements Transferable, UIResource { } /** - * Should the plain text flavors be offered? If so, the method getPlainData should be implemented to provide + * Should the plain text flavors be offered? If so, the method getPlainData should be implemented to provide * something reasonable. * * @return true if plain text is supported. @@ -276,8 +276,8 @@ public class BasicTransferable implements Transferable, UIResource { /** * Returns whether or not the specified data flavor is a String flavor that is supported. * - * @param flavor the requested flavor for the data - * @return boolean indicating whether or not the data flavor is supported + * @param flavor the requested flavor for the data + * @return boolean indicating whether or not the data flavor is supported */ protected boolean isStringFlavor(final DataFlavor flavor) { DataFlavor[] flavors = stringFlavors; @@ -288,6 +288,4 @@ public class BasicTransferable implements Transferable, UIResource { } return false; } - - } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/DarkPopupFactory.java b/core/src/main/java/com/github/weisj/darklaf/ui/DarkPopupFactory.java index ad46e233..ec641665 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/DarkPopupFactory.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/DarkPopupFactory.java @@ -20,17 +20,19 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui; +import java.awt.*; + +import javax.swing.*; + import com.github.weisj.darklaf.platform.DecorationsHandler; import com.github.weisj.darklaf.ui.popupmenu.DarkPopupMenuUI; import com.github.weisj.darklaf.ui.rootpane.DarkRootPaneUI; import com.github.weisj.darklaf.util.DarkUIUtil; -import javax.swing.*; -import java.awt.*; - public class DarkPopupFactory extends PopupFactory { public static final String KEY_NO_DECORATION = "JPopupFactory.noDecorations"; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/DragRecognitionSupport.java b/core/src/main/java/com/github/weisj/darklaf/ui/DragRecognitionSupport.java index 80e2a7c9..77eca12a 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/DragRecognitionSupport.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/DragRecognitionSupport.java @@ -20,34 +20,36 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui; -import org.jdesktop.swingx.SwingXUtilities; - -import javax.swing.*; import java.awt.dnd.DragSource; import java.awt.event.MouseEvent; -//import sun.awt.dnd.SunDragSourceContextPeer; -//import sun.awt.AppContext; + +import javax.swing.*; + +import org.jdesktop.swingx.SwingXUtilities; +// import sun.awt.dnd.SunDragSourceContextPeer; +// import sun.awt.AppContext; /** * Drag gesture recognition support for classes that have a * TransferHandler. The gesture for a drag in this class is a mouse * press followed by movement by DragSource.getDragThreshold() pixels. An instance of this class is * maintained per AppContext, and the public static methods call into the appropriate instance. - * - *

This is a c and p of core (package private) needed for BasicXListUI. It differs from core in that references to + *

+ * This is a c and p of core (package private) needed for BasicXListUI. It differs from core in that references to * sun * packages have been replaced. *

    - *
  • a static method of SunDragSourceContextPeer has been copied into SwingXUtilities - * and is used here - *
  • the shared instance of this class is maintained in the UIManager instead of - * per appContext. + *
  • a static method of SunDragSourceContextPeer has been copied into SwingXUtilities + * and is used here + *
  • the shared instance of this class is maintained in the UIManager instead of + * per appContext. *
* - * @author Shannon Hickey + * @author Shannon Hickey * @version 1.2 11/17/05 */ public class DragRecognitionSupport { @@ -58,8 +60,8 @@ public class DragRecognitionSupport { /** * Returns whether or not the event is potentially part of a drag sequence. * - * @param me the MouseEvent. - * @return true if mouse is pressed. + * @param me the MouseEvent. + * @return true if mouse is pressed. */ public static boolean mousePressed(final MouseEvent me) { return getDragRecognitionSupport().mousePressedImpl(me); @@ -71,8 +73,7 @@ public class DragRecognitionSupport { private boolean mousePressedImpl(final MouseEvent me) { component = (JComponent) me.getSource(); - if (mapDragOperationFromModifiers(me, component.getTransferHandler()) - != TransferHandler.NONE) { + if (mapDragOperationFromModifiers(me, component.getTransferHandler()) != TransferHandler.NONE) { motionThreshold = DragSource.getDragThreshold(); dndArmedEvent = me; @@ -87,17 +88,16 @@ public class DragRecognitionSupport { * Returns the DragRecognitionSupport for the caller's AppContext. */ private static DragRecognitionSupport getDragRecognitionSupport() { -// DragRecognitionSupport support = -// (DragRecognitionSupport)AppContext.getAppContext(). -// get(DragRecognitionSupport.class); -// -// if (support == null) { -// support = new DragRecognitionSupport(); -// AppContext.getAppContext().put(DragRecognitionSupport.class, support); -// } - - DragRecognitionSupport support = (DragRecognitionSupport) - UIManager.get("sharedInstance.dragRecognitionSupport"); + // DragRecognitionSupport support = + // (DragRecognitionSupport)AppContext.getAppContext(). + // get(DragRecognitionSupport.class); + // + // if (support == null) { + // support = new DragRecognitionSupport(); + // AppContext.getAppContext().put(DragRecognitionSupport.class, support); + // } + + DragRecognitionSupport support = (DragRecognitionSupport) UIManager.get("sharedInstance.dragRecognitionSupport"); if (support == null) { support = new DragRecognitionSupport(); UIManager.put("sharedInstance.dragRecognitionSupport", support); @@ -112,9 +112,8 @@ public class DragRecognitionSupport { return TransferHandler.NONE; } // PENDING JW: c'p from SunDragSourceContextPeer - return SwingXUtilities. - convertModifiersToDropAction(me.getModifiersEx(), - th.getSourceActions(component)); + return SwingXUtilities.convertModifiersToDropAction(me.getModifiersEx(), + th.getSourceActions(component)); } private void clearState() { @@ -126,12 +125,11 @@ public class DragRecognitionSupport { * If a dnd recognition has been going on, return the MouseEvent that started the recognition. Otherwise, return * null. * - * @param me the MouseEvent. - * @return true if mouse has been released. + * @param me the MouseEvent. + * @return true if mouse has been released. */ public static MouseEvent mouseReleased(final MouseEvent me) { - return getDragRecognitionSupport(). - mouseReleasedImpl(me); + return getDragRecognitionSupport().mouseReleasedImpl(me); } /** @@ -157,9 +155,9 @@ public class DragRecognitionSupport { /** * Returns whether or not a drag gesture recognition is ongoing. * - * @param me the me - * @param bd the bd - * @return the boolean + * @param me the me + * @param bd the bd + * @return the boolean */ public static boolean mouseDragged(final MouseEvent me, final BeforeDrag bd) { return getDragRecognitionSupport().mouseDraggedImpl(me, bd); @@ -202,7 +200,5 @@ public class DragRecognitionSupport { * This interface allows us to pass in a handler to mouseDragged, so that we can be notified immediately before a * drag begins. */ - public interface BeforeDrag { - void dragStarting(MouseEvent me); - } + public interface BeforeDrag { void dragStarting(MouseEvent me); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/button/AbstractButtonLayoutDelegate.java b/core/src/main/java/com/github/weisj/darklaf/ui/button/AbstractButtonLayoutDelegate.java index 52a85059..52e5ef0c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/button/AbstractButtonLayoutDelegate.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/button/AbstractButtonLayoutDelegate.java @@ -20,13 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.button; -import com.github.weisj.darklaf.util.PropertyKey; +import java.awt.*; import javax.swing.*; -import java.awt.*; + +import com.github.weisj.darklaf.util.PropertyKey; public class AbstractButtonLayoutDelegate extends AbstractButton { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/button/ButtonConstants.java b/core/src/main/java/com/github/weisj/darklaf/ui/button/ButtonConstants.java index 83c1200a..5c7b64df 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/button/ButtonConstants.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/button/ButtonConstants.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.button; +import java.awt.*; + import javax.swing.*; import javax.swing.plaf.UIResource; -import java.awt.*; public interface ButtonConstants { String KEY_VARIANT = "JButton.variant"; @@ -77,8 +79,8 @@ public interface ButtonConstants { if (isBorderlessRectangular(c)) return true; if (c instanceof JButton) { JButton b = (JButton) c; - return doConvertToBorderless((AbstractButton) c) || VARIANT_BORDERLESS.equals( - b.getClientProperty(KEY_VARIANT)); + return doConvertToBorderless((AbstractButton) c) + || VARIANT_BORDERLESS.equals(b.getClientProperty(KEY_VARIANT)); } return false; } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonBorder.java index bd0d59d6..2a3d6fe1 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonBorder.java @@ -20,20 +20,22 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.button; -import com.github.weisj.darklaf.util.AlignmentExt; -import com.github.weisj.darklaf.util.DarkUIUtil; -import com.github.weisj.darklaf.util.GraphicsContext; +import java.awt.*; +import java.awt.geom.Area; +import java.awt.geom.RoundRectangle2D; import javax.swing.*; import javax.swing.border.Border; import javax.swing.plaf.InsetsUIResource; import javax.swing.plaf.UIResource; -import java.awt.*; -import java.awt.geom.Area; -import java.awt.geom.RoundRectangle2D; + +import com.github.weisj.darklaf.util.AlignmentExt; +import com.github.weisj.darklaf.util.DarkUIUtil; +import com.github.weisj.darklaf.util.GraphicsContext; /** * @author Konstantin Bulenkov @@ -278,8 +280,8 @@ public class DarkButtonBorder implements Border, UIResource { boolean square = ButtonConstants.isSquare(c); Insets pad = ButtonConstants.isThin(c) ? square ? squareThinInsets : thinInsets - : square ? squareInsets - : insets; + : square ? squareInsets + : insets; return maskInsets(new InsetsUIResource(pad.top, pad.left, pad.bottom, pad.right), c, shadow); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonListener.java b/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonListener.java index 84bfd65f..fe5529f1 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonListener.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonListener.java @@ -20,17 +20,19 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.button; -import com.github.weisj.darklaf.util.PropertyKey; - -import javax.swing.*; -import javax.swing.plaf.basic.BasicButtonListener; import java.awt.event.FocusEvent; import java.awt.event.MouseEvent; import java.beans.PropertyChangeEvent; +import javax.swing.*; +import javax.swing.plaf.basic.BasicButtonListener; + +import com.github.weisj.darklaf.util.PropertyKey; + public class DarkButtonListener extends BasicButtonListener { private final DarkButtonUI ui; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java index 0d800c03..c9981011 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.button; @@ -406,8 +407,8 @@ public class DarkButtonUI extends BasicButtonUI implements ButtonConstants { b.getVerticalTextPosition(), b.getHorizontalTextPosition(), viewRect, iconRect, textRect, b.getText() == null || ButtonConstants.isIconOnly(b) - ? 0 - : b.getIconTextGap()); + ? 0 + : b.getIconTextGap()); } @Override diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/cell/CellEditorToggleButton.java b/core/src/main/java/com/github/weisj/darklaf/ui/cell/CellEditorToggleButton.java index 02a91bcc..d4cacc56 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/cell/CellEditorToggleButton.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/cell/CellEditorToggleButton.java @@ -20,12 +20,11 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.cell; /** * @author Jannis Weis */ -public interface CellEditorToggleButton { - void setHasFocus(final boolean hasFocus); -} +public interface CellEditorToggleButton { void setHasFocus(final boolean hasFocus); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/cell/CellUtil.java b/core/src/main/java/com/github/weisj/darklaf/ui/cell/CellUtil.java index 6bbeb5ef..c930327b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/cell/CellUtil.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/cell/CellUtil.java @@ -20,16 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.cell; -import com.github.weisj.darklaf.ui.list.DarkListUI; -import com.github.weisj.darklaf.ui.table.DarkTableCellEditor; -import com.github.weisj.darklaf.util.DarkUIUtil; +import java.awt.*; import javax.swing.*; import javax.swing.plaf.ListUI; -import java.awt.*; + +import com.github.weisj.darklaf.ui.list.DarkListUI; +import com.github.weisj.darklaf.ui.table.DarkTableCellEditor; +import com.github.weisj.darklaf.util.DarkUIUtil; public class CellUtil { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellBorder.java index 40a01b78..b2fbf890 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellBorder.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.cell; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellRendererToggleButton.java b/core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellRendererToggleButton.java index 71133548..e2436c9d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellRendererToggleButton.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellRendererToggleButton.java @@ -20,9 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.cell; +import java.awt.*; + +import javax.swing.*; +import javax.swing.table.TableCellRenderer; +import javax.swing.tree.TreeCellRenderer; + import com.github.weisj.darklaf.components.SelectableTreeNode; import com.github.weisj.darklaf.decorators.CellRenderer; import com.github.weisj.darklaf.ui.table.DarkTableCellFocusBorder; @@ -31,22 +38,16 @@ import com.github.weisj.darklaf.ui.togglebutton.ToggleButtonConstants; import com.github.weisj.darklaf.ui.tree.DarkTreeCellRenderer; import com.github.weisj.darklaf.util.DarkUIUtil; -import javax.swing.*; -import javax.swing.table.TableCellRenderer; -import javax.swing.tree.TreeCellRenderer; -import java.awt.*; - /** * @author vincencopalazzo * @author atarw * @author Jannis Weis */ public class DarkCellRendererToggleButton - implements TableCellRenderer, TreeCellRenderer, SwingConstants { + implements TableCellRenderer, TreeCellRenderer, SwingConstants { private final T toggleButton; - public DarkCellRendererToggleButton(final T toggleButton) { this.toggleButton = toggleButton; } @@ -148,5 +149,4 @@ public class DarkCellRendererToggleButton text.select(0, 0)); } - private boolean isValid(final int length) { return (0 <= length) && (length <= getLength()); } @@ -179,7 +179,6 @@ public final class ColorValueFormatter extends JFormattedTextField.AbstractForma return hex ? getHexLength() : String.valueOf(model.getMaximum(fieldIndex)).length(); } - private int getHexLength() { return transparencyEnabled ? 8 : 6; } @@ -219,8 +218,8 @@ public final class ColorValueFormatter extends JFormattedTextField.AbstractForma int b = Integer.valueOf(hexStr.substring(4, 6), 16); checkRange(b, 0, 255); int alpha = hexStr.length() >= 8 - ? Integer.valueOf(hexStr.substring(6, 8), 16) - : 255; + ? Integer.valueOf(hexStr.substring(6, 8), 16) + : 255; checkRange(alpha, 0, 255); return new Color(r, g, b, alpha); } else { @@ -243,7 +242,6 @@ public final class ColorValueFormatter extends JFormattedTextField.AbstractForma } } - @Override public String valueToString(final Object object) throws ParseException { if (object instanceof Integer && !hex) { @@ -263,7 +261,6 @@ public final class ColorValueFormatter extends JFormattedTextField.AbstractForma throw new ParseException("illegal object", 0); } - @Override protected DocumentFilter getDocumentFilter() { return this.filter; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorWheelPanel.java b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorWheelPanel.java index 54e08eb9..047af5ef 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorWheelPanel.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorWheelPanel.java @@ -20,14 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ - package com.github.weisj.darklaf.ui.colorchooser; -import com.github.weisj.darklaf.color.DarkColorModel; +import java.awt.*; import javax.swing.*; -import java.awt.*; + +import com.github.weisj.darklaf.color.DarkColorModel; /** * @author pegov diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserPanel.java b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserPanel.java index 535cc889..80fa054b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserPanel.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserPanel.java @@ -20,10 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ - package com.github.weisj.darklaf.ui.colorchooser; +import java.awt.*; +import java.awt.event.KeyEvent; + +import javax.swing.*; +import javax.swing.colorchooser.AbstractColorChooserPanel; +import javax.swing.colorchooser.ColorSelectionModel; +import javax.swing.event.AncestorEvent; + import com.github.weisj.darklaf.color.DarkColorModel; import com.github.weisj.darklaf.components.DefaultColorPipette; import com.github.weisj.darklaf.decorators.AncestorAdapter; @@ -31,13 +39,6 @@ import com.github.weisj.darklaf.decorators.UpdateDocumentListener; import com.github.weisj.darklaf.ui.button.DarkButtonUI; import com.github.weisj.darklaf.util.ColorUtil; -import javax.swing.*; -import javax.swing.colorchooser.AbstractColorChooserPanel; -import javax.swing.colorchooser.ColorSelectionModel; -import javax.swing.event.AncestorEvent; -import java.awt.*; -import java.awt.event.KeyEvent; - /** * @author pegov * @author Konstantin Bulenkov @@ -126,14 +127,12 @@ public class DarkColorChooserPanel extends AbstractColorChooserPanel implements try { String hexStr = String.format("%1$-" + 8 + "s", textHex.getText()).replaceAll(" ", "F"); int alpha = isColorTransparencySelectionEnabled() - ? Integer.valueOf(hexStr.substring(6, 8), 16) : 255; - return new Color( - Integer.valueOf(hexStr.substring(0, 2), 16), - Integer.valueOf(hexStr.substring(2, 4), 16), - Integer.valueOf(hexStr.substring(4, 6), 16), - alpha); - } catch (NumberFormatException | IndexOutOfBoundsException ignore) { - } + ? Integer.valueOf(hexStr.substring(6, 8), 16) : 255; + return new Color(Integer.valueOf(hexStr.substring(0, 2), 16), + Integer.valueOf(hexStr.substring(2, 4), 16), + Integer.valueOf(hexStr.substring(4, 6), 16), + alpha); + } catch (NumberFormatException | IndexOutOfBoundsException ignore) {} return null; } @@ -275,7 +274,6 @@ public class DarkColorChooserPanel extends AbstractColorChooserPanel implements return (DarkColorModel) formatBox.getSelectedItem(); } - private JComponent buildTopPanel(final boolean enablePipette) { final JPanel result = new JPanel(new BorderLayout()); @@ -289,7 +287,6 @@ public class DarkColorChooserPanel extends AbstractColorChooserPanel implements previewPanel.add(previewComponent, BorderLayout.CENTER); result.add(previewPanel, BorderLayout.NORTH); - final JPanel valuePanel = new JPanel(); valuePanel.setLayout(new BoxLayout(valuePanel, BoxLayout.X_AXIS)); valuePanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); @@ -370,8 +367,7 @@ public class DarkColorChooserPanel extends AbstractColorChooserPanel implements } @Override - public void updateChooser() { - } + public void updateChooser() {} @Override public String getDisplayName() { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserUI.java index da432301..297326a4 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserUI.java @@ -20,15 +20,12 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.colorchooser; -import com.github.weisj.darklaf.color.DarkColorModelCMYK; -import com.github.weisj.darklaf.color.DarkColorModelHSB; -import com.github.weisj.darklaf.color.DarkColorModelHSL; -import com.github.weisj.darklaf.color.DarkColorModelRGB; -import com.github.weisj.darklaf.decorators.AncestorAdapter; -import com.github.weisj.darklaf.util.PropertyKey; +import java.awt.*; +import java.beans.PropertyChangeListener; import javax.swing.*; import javax.swing.colorchooser.AbstractColorChooserPanel; @@ -36,8 +33,13 @@ import javax.swing.event.AncestorEvent; import javax.swing.event.AncestorListener; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicColorChooserUI; -import java.awt.*; -import java.beans.PropertyChangeListener; + +import com.github.weisj.darklaf.color.DarkColorModelCMYK; +import com.github.weisj.darklaf.color.DarkColorModelHSB; +import com.github.weisj.darklaf.color.DarkColorModelHSL; +import com.github.weisj.darklaf.color.DarkColorModelRGB; +import com.github.weisj.darklaf.decorators.AncestorAdapter; +import com.github.weisj.darklaf.util.PropertyKey; /** * @author Jannis Weis @@ -73,7 +75,6 @@ public class DarkColorChooserUI extends BasicColorChooserUI { } }; - public static ComponentUI createUI(final JComponent c) { return new DarkColorChooserUI(); } @@ -81,12 +82,12 @@ public class DarkColorChooserUI extends BasicColorChooserUI { @Override protected AbstractColorChooserPanel[] createDefaultChoosers() { return new AbstractColorChooserPanel[]{ - new DarkColorChooserPanel(DarkColorModelRGB.getInstance(), - DarkColorModelHSB.getInstance(), - DarkColorModelHSL.getInstance(), - DarkColorModelCMYK.getInstance()), - new DarkSwatchesChooserPanel(), - }; + new DarkColorChooserPanel(DarkColorModelRGB.getInstance(), + DarkColorModelHSB.getInstance(), + DarkColorModelHSL.getInstance(), + DarkColorModelCMYK.getInstance()), + new DarkSwatchesChooserPanel(), + }; } @Override diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkPreviewPanel.java b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkPreviewPanel.java index c133543f..1cb36f1c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkPreviewPanel.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkPreviewPanel.java @@ -20,15 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.colorchooser; -import com.github.weisj.darklaf.util.GraphicsContext; -import com.github.weisj.darklaf.util.GraphicsUtil; -import sun.swing.SwingUtilities2; +import java.awt.*; import javax.swing.*; -import java.awt.*; + +import sun.swing.SwingUtilities2; + +import com.github.weisj.darklaf.util.GraphicsContext; +import com.github.weisj.darklaf.util.GraphicsUtil; /** * @author Jannis Weis @@ -40,7 +43,6 @@ public class DarkPreviewPanel extends JPanel { private static final int INNER_GAP = 4; private static final int SWATCH_WIDTH = 75; - private static final int TEXT_GAP = 5; private String sampleText; @@ -118,7 +120,6 @@ public class DarkPreviewPanel extends JPanel { SQUARE_SIZE - (INNER_GAP * 2)); g.translate(-(SQUARE_SIZE + SQUARE_GAP), -(SQUARE_SIZE + SQUARE_GAP)); - g.translate((SQUARE_SIZE + SQUARE_GAP) * 2, 0); g.setColor(Color.white); g.fillRect(offsetX, 0, SQUARE_SIZE, SQUARE_SIZE); @@ -169,7 +170,6 @@ public class DarkPreviewPanel extends JPanel { SwingUtilities2.drawString(host, g, getSampleText(), textXOffset + (TEXT_GAP / 2), height + ascent + TEXT_GAP + 2); - g.setColor(Color.white); g.fillRect(textXOffset, (height + TEXT_GAP) * 2, width + (TEXT_GAP), height + 2); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkSwatchesChooserPanel.java b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkSwatchesChooserPanel.java index fc30bf2d..7a38ba54 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkSwatchesChooserPanel.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkSwatchesChooserPanel.java @@ -20,25 +20,26 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.colorchooser; +import java.awt.*; +import java.awt.event.*; +import java.io.Serializable; + import javax.accessibility.AccessibleContext; import javax.swing.*; import javax.swing.border.Border; import javax.swing.border.LineBorder; import javax.swing.colorchooser.AbstractColorChooserPanel; import javax.swing.colorchooser.ColorSelectionModel; -import java.awt.*; -import java.awt.event.*; -import java.io.Serializable; /** * @author Jannis Weis */ public class DarkSwatchesChooserPanel extends AbstractColorChooserPanel { - private SwatchPanel swatchPanel; private RecentSwatchPanel recentSwatchPanel; private ColorPreviewComponent previewPanel; @@ -144,7 +145,7 @@ public class DarkSwatchesChooserPanel extends AbstractColorChooserPanel { recentSwatchListener = null; recentSwatchKeyListener = null; - removeAll(); // strip out all the sub-components + removeAll(); // strip out all the sub-components } protected void setSelectedColor(final Color color) { @@ -196,5 +197,4 @@ public class DarkSwatchesChooserPanel extends AbstractColorChooserPanel { } } } - } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/MainSwatchPanel.java b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/MainSwatchPanel.java index 72fcf53a..6832a4fd 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/MainSwatchPanel.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/MainSwatchPanel.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.colorchooser; -import javax.swing.*; import java.awt.*; +import javax.swing.*; + /** * @author Jannis Weis */ @@ -47,459 +49,458 @@ class MainSwatchPanel extends SwatchPanel { } } - private int[] initRawValues() { return new int[]{ - 0, 0, 0, - 31, 0, 0, - 31, 6, 0, - 31, 12, 0, - 31, 18, 0, - 31, 24, 0, - 31, 31, 0, - 24, 31, 0, - 18, 31, 0, - 12, 31, 0, - 6, 31, 0, - 0, 31, 0, - 0, 31, 6, - 0, 31, 12, - 0, 31, 18, - 0, 31, 24, - 0, 31, 31, - 0, 24, 31, - 0, 18, 31, - 0, 12, 31, - 0, 6, 31, - 0, 0, 31, - 6, 0, 31, - 12, 0, 31, - 18, 0, 31, - 24, 0, 31, - 31, 0, 31, - 31, 0, 24, - 31, 0, 18, - 31, 0, 12, - 18, 18, 18, - 61, 0, 0, - 61, 12, 0, - 61, 24, 0, - 61, 37, 0, - 61, 49, 0, - 61, 61, 0, - 49, 61, 0, - 37, 61, 0, - 24, 61, 0, - 12, 61, 0, - 0, 61, 0, - 0, 61, 12, - 0, 61, 24, - 0, 61, 37, - 0, 61, 49, - 0, 61, 61, - 0, 49, 61, - 0, 37, 61, - 0, 24, 61, - 0, 12, 61, - 0, 0, 61, - 11, 0, 61, - 24, 0, 61, - 37, 0, 61, - 49, 0, 61, - 61, 0, 61, - 61, 0, 49, - 61, 0, 37, - 61, 0, 24, - 36, 36, 36, - 92, 0, 0, - 92, 18, 0, - 92, 37, 0, - 92, 55, 0, - 92, 73, 0, - 92, 92, 0, - 73, 92, 0, - 55, 92, 0, - 37, 92, 0, - 18, 92, 0, - 0, 92, 0, - 0, 92, 18, - 0, 92, 37, - 0, 92, 55, - 0, 92, 73, - 0, 92, 92, - 0, 73, 92, - 0, 55, 92, - 0, 37, 92, - 0, 18, 92, - 0, 0, 92, - 17, 0, 92, - 37, 0, 92, - 55, 0, 92, - 73, 0, 92, - 92, 0, 92, - 92, 0, 73, - 92, 0, 55, - 92, 0, 37, - 54, 54, 54, - 128, 0, 0, - 128, 26, 0, - 128, 51, 0, - 128, 77, 0, - 128, 102, 0, - 128, 128, 0, - 102, 128, 0, - 77, 128, 0, - 51, 128, 0, - 26, 128, 0, - 0, 128, 0, - 0, 128, 25, - 0, 128, 51, - 0, 128, 77, - 0, 128, 102, - 0, 128, 128, - 0, 102, 128, - 0, 77, 128, - 0, 51, 128, - 0, 26, 128, - 0, 0, 128, - 23, 0, 128, - 51, 0, 128, - 77, 0, 128, - 102, 0, 128, - 128, 0, 128, - 128, 0, 102, - 128, 0, 76, - 128, 0, 51, - 72, 72, 72, - 158, 0, 0, - 158, 32, 0, - 158, 63, 0, - 158, 95, 0, - 158, 126, 0, - 158, 158, 0, - 126, 158, 0, - 95, 158, 0, - 63, 158, 0, - 32, 158, 0, - 0, 158, 0, - 0, 158, 32, - 0, 158, 63, - 0, 158, 95, - 0, 158, 126, - 0, 158, 158, - 0, 126, 158, - 0, 95, 158, - 0, 63, 158, - 0, 32, 158, - 0, 0, 158, - 29, 0, 158, - 63, 0, 158, - 95, 0, 158, - 126, 0, 158, - 158, 0, 158, - 158, 0, 126, - 158, 0, 95, - 158, 0, 63, - 91, 91, 91, - 189, 0, 0, - 189, 38, 0, - 189, 75, 0, - 189, 113, 0, - 189, 151, 0, - 189, 189, 0, - 151, 189, 0, - 113, 189, 0, - 75, 189, 0, - 38, 189, 0, - 0, 189, 0, - 0, 189, 38, - 0, 189, 75, - 0, 189, 113, - 0, 189, 151, - 0, 189, 189, - 0, 151, 189, - 0, 113, 189, - 0, 75, 189, - 0, 38, 189, - 0, 0, 189, - 35, 0, 189, - 75, 0, 189, - 113, 0, 189, - 151, 0, 189, - 189, 0, 189, - 189, 0, 151, - 189, 0, 113, - 189, 0, 75, - 109, 109, 109, - 219, 0, 0, - 219, 44, 0, - 219, 88, 0, - 219, 132, 0, - 219, 175, 0, - 219, 219, 0, - 175, 219, 0, - 132, 219, 0, - 88, 219, 0, - 44, 219, 0, - 0, 219, 0, - 0, 219, 44, - 0, 219, 88, - 0, 219, 132, - 0, 219, 175, - 0, 219, 219, - 0, 175, 219, - 0, 132, 219, - 0, 88, 219, - 0, 44, 219, - 0, 0, 219, - 40, 0, 219, - 88, 0, 219, - 132, 0, 219, - 175, 0, 219, - 219, 0, 219, - 219, 0, 175, - 219, 0, 132, - 219, 0, 88, - 127, 127, 127, - 255, 0, 0, - 255, 51, 0, - 255, 102, 0, - 255, 153, 0, - 255, 204, 0, - 255, 255, 0, - 204, 255, 0, - 153, 255, 0, - 102, 255, 0, - 51, 255, 0, - 0, 255, 0, - 0, 255, 51, - 0, 255, 102, - 0, 255, 153, - 0, 255, 204, - 0, 255, 255, - 0, 204, 255, - 0, 153, 255, - 0, 102, 255, - 0, 51, 255, - 0, 0, 255, - 47, 0, 255, - 102, 0, 255, - 153, 0, 255, - 204, 0, 255, - 255, 0, 255, - 255, 0, 204, - 255, 0, 153, - 255, 0, 102, - 145, 145, 145, - 255, 31, 31, - 255, 75, 31, - 255, 120, 31, - 255, 165, 31, - 255, 210, 31, - 255, 255, 31, - 210, 255, 31, - 165, 255, 31, - 120, 255, 31, - 75, 255, 31, - 31, 255, 31, - 31, 255, 75, - 31, 255, 120, - 31, 255, 165, - 31, 255, 210, - 31, 255, 255, - 31, 210, 255, - 31, 165, 255, - 31, 120, 255, - 31, 75, 255, - 31, 31, 255, - 72, 31, 255, - 120, 31, 255, - 165, 31, 255, - 210, 31, 255, - 255, 31, 255, - 255, 31, 210, - 255, 31, 165, - 255, 31, 120, - 163, 163, 163, - 255, 61, 61, - 255, 100, 61, - 255, 139, 61, - 255, 177, 61, - 255, 216, 61, - 255, 255, 61, - 216, 255, 61, - 177, 255, 61, - 139, 255, 61, - 100, 255, 61, - 61, 255, 61, - 61, 255, 100, - 61, 255, 139, - 61, 255, 177, - 61, 255, 216, - 61, 255, 255, - 61, 216, 255, - 61, 177, 255, - 61, 139, 255, - 61, 100, 255, - 61, 61, 255, - 97, 61, 255, - 139, 61, 255, - 177, 61, 255, - 216, 61, 255, - 255, 61, 255, - 255, 61, 216, - 255, 61, 177, - 255, 61, 139, - 182, 182, 182, - 255, 92, 92, - 255, 124, 92, - 255, 157, 92, - 255, 190, 92, - 255, 222, 92, - 255, 255, 92, - 222, 255, 92, - 190, 255, 92, - 157, 255, 92, - 124, 255, 92, - 92, 255, 92, - 92, 255, 124, - 92, 255, 157, - 92, 255, 190, - 92, 255, 222, - 92, 255, 255, - 92, 222, 255, - 92, 190, 255, - 92, 157, 255, - 92, 124, 255, - 92, 92, 255, - 122, 92, 255, - 157, 92, 255, - 190, 92, 255, - 222, 92, 255, - 255, 92, 255, - 255, 92, 222, - 255, 92, 190, - 255, 92, 157, - 200, 200, 200, - 255, 128, 128, - 255, 153, 128, - 255, 179, 128, - 255, 204, 128, - 255, 230, 128, - 255, 255, 128, - 229, 255, 128, - 204, 255, 128, - 179, 255, 128, - 153, 255, 128, - 128, 255, 128, - 128, 255, 153, - 128, 255, 179, - 128, 255, 204, - 128, 255, 229, - 128, 255, 255, - 128, 229, 255, - 128, 204, 255, - 128, 179, 255, - 128, 153, 255, - 128, 128, 255, - 151, 128, 255, - 178, 128, 255, - 204, 128, 255, - 230, 128, 255, - 255, 128, 255, - 255, 128, 229, - 255, 128, 204, - 255, 128, 179, - 218, 218, 218, - 255, 158, 158, - 255, 177, 158, - 255, 197, 158, - 255, 216, 158, - 255, 236, 158, - 255, 255, 158, - 236, 255, 158, - 216, 255, 158, - 197, 255, 158, - 177, 255, 158, - 158, 255, 158, - 158, 255, 177, - 158, 255, 197, - 158, 255, 216, - 158, 255, 236, - 158, 255, 255, - 158, 236, 255, - 158, 216, 255, - 158, 197, 255, - 158, 177, 255, - 158, 158, 255, - 176, 158, 255, - 197, 158, 255, - 216, 158, 255, - 236, 158, 255, - 255, 158, 255, - 255, 158, 236, - 255, 158, 216, - 255, 158, 197, - 236, 236, 236, - 255, 189, 189, - 255, 202, 189, - 255, 215, 189, - 255, 228, 189, - 255, 242, 189, - 255, 255, 189, - 242, 255, 189, - 228, 255, 189, - 215, 255, 189, - 202, 255, 189, - 189, 255, 189, - 189, 255, 202, - 189, 255, 215, - 189, 255, 228, - 189, 255, 242, - 189, 255, 255, - 189, 242, 255, - 189, 228, 255, - 189, 215, 255, - 189, 202, 255, - 189, 189, 255, - 201, 189, 255, - 215, 189, 255, - 228, 189, 255, - 242, 189, 255, - 255, 189, 255, - 255, 189, 242, - 255, 189, 228, - 255, 189, 215, - 255, 255, 255, - 255, 219, 219, - 255, 226, 219, - 255, 234, 219, - 255, 241, 219, - 255, 248, 219, - 255, 255, 219, - 248, 255, 219, - 241, 255, 219, - 234, 255, 219, - 226, 255, 219, - 219, 255, 219, - 219, 255, 226, - 219, 255, 234, - 219, 255, 241, - 219, 255, 248, - 219, 255, 255, - 219, 248, 255, - 219, 241, 255, - 219, 234, 255, - 219, 226, 255, - 219, 219, 255, - 226, 219, 255, - 234, 219, 255, - 241, 219, 255, - 248, 219, 255, - 255, 219, 255, - 255, 219, 248, - 255, 219, 241, - 255, 219, 234, - }; + 0, 0, 0, + 31, 0, 0, + 31, 6, 0, + 31, 12, 0, + 31, 18, 0, + 31, 24, 0, + 31, 31, 0, + 24, 31, 0, + 18, 31, 0, + 12, 31, 0, + 6, 31, 0, + 0, 31, 0, + 0, 31, 6, + 0, 31, 12, + 0, 31, 18, + 0, 31, 24, + 0, 31, 31, + 0, 24, 31, + 0, 18, 31, + 0, 12, 31, + 0, 6, 31, + 0, 0, 31, + 6, 0, 31, + 12, 0, 31, + 18, 0, 31, + 24, 0, 31, + 31, 0, 31, + 31, 0, 24, + 31, 0, 18, + 31, 0, 12, + 18, 18, 18, + 61, 0, 0, + 61, 12, 0, + 61, 24, 0, + 61, 37, 0, + 61, 49, 0, + 61, 61, 0, + 49, 61, 0, + 37, 61, 0, + 24, 61, 0, + 12, 61, 0, + 0, 61, 0, + 0, 61, 12, + 0, 61, 24, + 0, 61, 37, + 0, 61, 49, + 0, 61, 61, + 0, 49, 61, + 0, 37, 61, + 0, 24, 61, + 0, 12, 61, + 0, 0, 61, + 11, 0, 61, + 24, 0, 61, + 37, 0, 61, + 49, 0, 61, + 61, 0, 61, + 61, 0, 49, + 61, 0, 37, + 61, 0, 24, + 36, 36, 36, + 92, 0, 0, + 92, 18, 0, + 92, 37, 0, + 92, 55, 0, + 92, 73, 0, + 92, 92, 0, + 73, 92, 0, + 55, 92, 0, + 37, 92, 0, + 18, 92, 0, + 0, 92, 0, + 0, 92, 18, + 0, 92, 37, + 0, 92, 55, + 0, 92, 73, + 0, 92, 92, + 0, 73, 92, + 0, 55, 92, + 0, 37, 92, + 0, 18, 92, + 0, 0, 92, + 17, 0, 92, + 37, 0, 92, + 55, 0, 92, + 73, 0, 92, + 92, 0, 92, + 92, 0, 73, + 92, 0, 55, + 92, 0, 37, + 54, 54, 54, + 128, 0, 0, + 128, 26, 0, + 128, 51, 0, + 128, 77, 0, + 128, 102, 0, + 128, 128, 0, + 102, 128, 0, + 77, 128, 0, + 51, 128, 0, + 26, 128, 0, + 0, 128, 0, + 0, 128, 25, + 0, 128, 51, + 0, 128, 77, + 0, 128, 102, + 0, 128, 128, + 0, 102, 128, + 0, 77, 128, + 0, 51, 128, + 0, 26, 128, + 0, 0, 128, + 23, 0, 128, + 51, 0, 128, + 77, 0, 128, + 102, 0, 128, + 128, 0, 128, + 128, 0, 102, + 128, 0, 76, + 128, 0, 51, + 72, 72, 72, + 158, 0, 0, + 158, 32, 0, + 158, 63, 0, + 158, 95, 0, + 158, 126, 0, + 158, 158, 0, + 126, 158, 0, + 95, 158, 0, + 63, 158, 0, + 32, 158, 0, + 0, 158, 0, + 0, 158, 32, + 0, 158, 63, + 0, 158, 95, + 0, 158, 126, + 0, 158, 158, + 0, 126, 158, + 0, 95, 158, + 0, 63, 158, + 0, 32, 158, + 0, 0, 158, + 29, 0, 158, + 63, 0, 158, + 95, 0, 158, + 126, 0, 158, + 158, 0, 158, + 158, 0, 126, + 158, 0, 95, + 158, 0, 63, + 91, 91, 91, + 189, 0, 0, + 189, 38, 0, + 189, 75, 0, + 189, 113, 0, + 189, 151, 0, + 189, 189, 0, + 151, 189, 0, + 113, 189, 0, + 75, 189, 0, + 38, 189, 0, + 0, 189, 0, + 0, 189, 38, + 0, 189, 75, + 0, 189, 113, + 0, 189, 151, + 0, 189, 189, + 0, 151, 189, + 0, 113, 189, + 0, 75, 189, + 0, 38, 189, + 0, 0, 189, + 35, 0, 189, + 75, 0, 189, + 113, 0, 189, + 151, 0, 189, + 189, 0, 189, + 189, 0, 151, + 189, 0, 113, + 189, 0, 75, + 109, 109, 109, + 219, 0, 0, + 219, 44, 0, + 219, 88, 0, + 219, 132, 0, + 219, 175, 0, + 219, 219, 0, + 175, 219, 0, + 132, 219, 0, + 88, 219, 0, + 44, 219, 0, + 0, 219, 0, + 0, 219, 44, + 0, 219, 88, + 0, 219, 132, + 0, 219, 175, + 0, 219, 219, + 0, 175, 219, + 0, 132, 219, + 0, 88, 219, + 0, 44, 219, + 0, 0, 219, + 40, 0, 219, + 88, 0, 219, + 132, 0, 219, + 175, 0, 219, + 219, 0, 219, + 219, 0, 175, + 219, 0, 132, + 219, 0, 88, + 127, 127, 127, + 255, 0, 0, + 255, 51, 0, + 255, 102, 0, + 255, 153, 0, + 255, 204, 0, + 255, 255, 0, + 204, 255, 0, + 153, 255, 0, + 102, 255, 0, + 51, 255, 0, + 0, 255, 0, + 0, 255, 51, + 0, 255, 102, + 0, 255, 153, + 0, 255, 204, + 0, 255, 255, + 0, 204, 255, + 0, 153, 255, + 0, 102, 255, + 0, 51, 255, + 0, 0, 255, + 47, 0, 255, + 102, 0, 255, + 153, 0, 255, + 204, 0, 255, + 255, 0, 255, + 255, 0, 204, + 255, 0, 153, + 255, 0, 102, + 145, 145, 145, + 255, 31, 31, + 255, 75, 31, + 255, 120, 31, + 255, 165, 31, + 255, 210, 31, + 255, 255, 31, + 210, 255, 31, + 165, 255, 31, + 120, 255, 31, + 75, 255, 31, + 31, 255, 31, + 31, 255, 75, + 31, 255, 120, + 31, 255, 165, + 31, 255, 210, + 31, 255, 255, + 31, 210, 255, + 31, 165, 255, + 31, 120, 255, + 31, 75, 255, + 31, 31, 255, + 72, 31, 255, + 120, 31, 255, + 165, 31, 255, + 210, 31, 255, + 255, 31, 255, + 255, 31, 210, + 255, 31, 165, + 255, 31, 120, + 163, 163, 163, + 255, 61, 61, + 255, 100, 61, + 255, 139, 61, + 255, 177, 61, + 255, 216, 61, + 255, 255, 61, + 216, 255, 61, + 177, 255, 61, + 139, 255, 61, + 100, 255, 61, + 61, 255, 61, + 61, 255, 100, + 61, 255, 139, + 61, 255, 177, + 61, 255, 216, + 61, 255, 255, + 61, 216, 255, + 61, 177, 255, + 61, 139, 255, + 61, 100, 255, + 61, 61, 255, + 97, 61, 255, + 139, 61, 255, + 177, 61, 255, + 216, 61, 255, + 255, 61, 255, + 255, 61, 216, + 255, 61, 177, + 255, 61, 139, + 182, 182, 182, + 255, 92, 92, + 255, 124, 92, + 255, 157, 92, + 255, 190, 92, + 255, 222, 92, + 255, 255, 92, + 222, 255, 92, + 190, 255, 92, + 157, 255, 92, + 124, 255, 92, + 92, 255, 92, + 92, 255, 124, + 92, 255, 157, + 92, 255, 190, + 92, 255, 222, + 92, 255, 255, + 92, 222, 255, + 92, 190, 255, + 92, 157, 255, + 92, 124, 255, + 92, 92, 255, + 122, 92, 255, + 157, 92, 255, + 190, 92, 255, + 222, 92, 255, + 255, 92, 255, + 255, 92, 222, + 255, 92, 190, + 255, 92, 157, + 200, 200, 200, + 255, 128, 128, + 255, 153, 128, + 255, 179, 128, + 255, 204, 128, + 255, 230, 128, + 255, 255, 128, + 229, 255, 128, + 204, 255, 128, + 179, 255, 128, + 153, 255, 128, + 128, 255, 128, + 128, 255, 153, + 128, 255, 179, + 128, 255, 204, + 128, 255, 229, + 128, 255, 255, + 128, 229, 255, + 128, 204, 255, + 128, 179, 255, + 128, 153, 255, + 128, 128, 255, + 151, 128, 255, + 178, 128, 255, + 204, 128, 255, + 230, 128, 255, + 255, 128, 255, + 255, 128, 229, + 255, 128, 204, + 255, 128, 179, + 218, 218, 218, + 255, 158, 158, + 255, 177, 158, + 255, 197, 158, + 255, 216, 158, + 255, 236, 158, + 255, 255, 158, + 236, 255, 158, + 216, 255, 158, + 197, 255, 158, + 177, 255, 158, + 158, 255, 158, + 158, 255, 177, + 158, 255, 197, + 158, 255, 216, + 158, 255, 236, + 158, 255, 255, + 158, 236, 255, + 158, 216, 255, + 158, 197, 255, + 158, 177, 255, + 158, 158, 255, + 176, 158, 255, + 197, 158, 255, + 216, 158, 255, + 236, 158, 255, + 255, 158, 255, + 255, 158, 236, + 255, 158, 216, + 255, 158, 197, + 236, 236, 236, + 255, 189, 189, + 255, 202, 189, + 255, 215, 189, + 255, 228, 189, + 255, 242, 189, + 255, 255, 189, + 242, 255, 189, + 228, 255, 189, + 215, 255, 189, + 202, 255, 189, + 189, 255, 189, + 189, 255, 202, + 189, 255, 215, + 189, 255, 228, + 189, 255, 242, + 189, 255, 255, + 189, 242, 255, + 189, 228, 255, + 189, 215, 255, + 189, 202, 255, + 189, 189, 255, + 201, 189, 255, + 215, 189, 255, + 228, 189, 255, + 242, 189, 255, + 255, 189, 255, + 255, 189, 242, + 255, 189, 228, + 255, 189, 215, + 255, 255, 255, + 255, 219, 219, + 255, 226, 219, + 255, 234, 219, + 255, 241, 219, + 255, 248, 219, + 255, 255, 219, + 248, 255, 219, + 241, 255, 219, + 234, 255, 219, + 226, 255, 219, + 219, 255, 219, + 219, 255, 226, + 219, 255, 234, + 219, 255, 241, + 219, 255, 248, + 219, 255, 255, + 219, 248, 255, + 219, 241, 255, + 219, 234, 255, + 219, 226, 255, + 219, 219, 255, + 226, 219, 255, + 234, 219, 255, + 241, 219, 255, + 248, 219, 255, + 255, 219, 255, + 255, 219, 248, + 255, 219, 241, + 255, 219, 234, + }; } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/RecentSwatchPanel.java b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/RecentSwatchPanel.java index eb8d4fb2..2253af8e 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/RecentSwatchPanel.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/RecentSwatchPanel.java @@ -20,14 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.colorchooser; -import javax.swing.*; import java.awt.*; import java.awt.event.MouseEvent; import java.util.Objects; +import javax.swing.*; + /** * @author Jannis Weis */ @@ -40,7 +42,6 @@ class RecentSwatchPanel extends SwatchPanel { gap = new Dimension(1, 1); } - protected void initColors() { defaultRecentColor = UIManager.getColor("ColorChooser.swatchesDefaultRecentColor"); int numColors = numSwatches.width * numSwatches.height; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/SlideComponent.java b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/SlideComponent.java index 9379c051..478fb72a 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/SlideComponent.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/SlideComponent.java @@ -20,16 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ - package com.github.weisj.darklaf.ui.colorchooser; -import com.github.weisj.darklaf.components.tooltip.ToolTipContext; -import com.github.weisj.darklaf.util.Alignment; -import com.github.weisj.darklaf.util.ColorUtil; -import com.github.weisj.darklaf.util.DarkUIUtil; - -import javax.swing.*; import java.awt.*; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; @@ -39,6 +33,13 @@ import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; +import javax.swing.*; + +import com.github.weisj.darklaf.components.tooltip.ToolTipContext; +import com.github.weisj.darklaf.util.Alignment; +import com.github.weisj.darklaf.util.ColorUtil; +import com.github.weisj.darklaf.util.DarkUIUtil; + /** * @author Alexey Pegov * @author Konstantin Bulenkov @@ -88,7 +89,6 @@ class SlideComponent extends JComponent implements ColorListener { } }); - addMouseWheelListener(event -> { int units = event.getUnitsToScroll(); if (units == 0) return; @@ -160,8 +160,8 @@ class SlideComponent extends JComponent implements ColorListener { public void setValue(final int value) { if (value < Unit.LEVEL.getMin() || value > Unit.LEVEL.getMax()) { - throw new IllegalArgumentException( - "Value " + value + " not in range [" + Unit.LEVEL.getMin() + "," + Unit.LEVEL.getMax() + "]"); + throw new IllegalArgumentException("Value " + value + " not in range [" + Unit.LEVEL.getMin() + "," + + Unit.LEVEL.getMax() + "]"); } pointerValue = valueToPointerValue(value); this.value = value; @@ -306,7 +306,6 @@ class SlideComponent extends JComponent implements ColorListener { } }; - protected final float max; protected final float min; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/SwatchPanel.java b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/SwatchPanel.java index 256a2563..3539ef5d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/SwatchPanel.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/SwatchPanel.java @@ -20,18 +20,20 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.colorchooser; +import java.awt.*; +import java.awt.event.*; + +import javax.swing.*; + import com.github.weisj.darklaf.components.tooltip.ToolTipContext; import com.github.weisj.darklaf.util.Alignment; import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.GraphicsUtil; -import javax.swing.*; -import java.awt.*; -import java.awt.event.*; - /** * @author Jannis Weis */ @@ -42,9 +44,9 @@ abstract class SwatchPanel extends JPanel { protected Dimension numSwatches; protected Dimension gap; private final ToolTipContext toolTipContext = new ToolTipContext(this) - .setAlignment(Alignment.CENTER) - .setToolTipRectSupplier(this::getSwatchBounds) - .setHideOnExit(true); + .setAlignment(Alignment.CENTER) + .setToolTipRectSupplier(this::getSwatchBounds) + .setHideOnExit(true); private int selRow; private int selCol; @@ -69,19 +71,19 @@ abstract class SwatchPanel extends JPanel { public void keyPressed(final KeyEvent e) { int typed = e.getKeyCode(); switch (typed) { - case KeyEvent.VK_UP: + case KeyEvent.VK_UP : if (selRow > 0) { selRow--; repaint(); } break; - case KeyEvent.VK_DOWN: + case KeyEvent.VK_DOWN : if (selRow < numSwatches.height - 1) { selRow++; repaint(); } break; - case KeyEvent.VK_LEFT: + case KeyEvent.VK_LEFT : if (selCol > 0 && SwatchPanel.this.getComponentOrientation().isLeftToRight()) { selCol--; repaint(); @@ -91,7 +93,7 @@ abstract class SwatchPanel extends JPanel { repaint(); } break; - case KeyEvent.VK_RIGHT: + case KeyEvent.VK_RIGHT : if (selCol < numSwatches.width - 1 && SwatchPanel.this.getComponentOrientation().isLeftToRight()) { selCol++; @@ -101,12 +103,12 @@ abstract class SwatchPanel extends JPanel { repaint(); } break; - case KeyEvent.VK_HOME: + case KeyEvent.VK_HOME : selCol = 0; selRow = 0; repaint(); break; - case KeyEvent.VK_END: + case KeyEvent.VK_END : selCol = numSwatches.width - 1; selRow = numSwatches.height - 1; repaint(); @@ -126,14 +128,12 @@ abstract class SwatchPanel extends JPanel { } - protected void initColors() { - } + protected void initColors() {} public Color getSelectedColor() { return getColorForCell(selCol, selRow); } - private Color getColorForCell(final int column, final int row) { int index = (row * numSwatches.width) + column; if (index >= colors.length) return null; @@ -165,7 +165,6 @@ abstract class SwatchPanel extends JPanel { } } - private int getYForRow(final int row) { return row * (swatchSize.height + gap.height); } @@ -216,7 +215,6 @@ abstract class SwatchPanel extends JPanel { return new Point(column, row); } - protected Rectangle getSwatchBounds(final MouseEvent e) { Point p = getCoordinatesForLocation(e.getX(), e.getY()); int x = getXForColumn(p.x); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/combobox/ComboBoxConstants.java b/core/src/main/java/com/github/weisj/darklaf/ui/combobox/ComboBoxConstants.java index 967d55cb..7650de97 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/combobox/ComboBoxConstants.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/combobox/ComboBoxConstants.java @@ -20,14 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.combobox; -import com.github.weisj.darklaf.ui.table.DarkTableUI; -import com.github.weisj.darklaf.ui.tree.DarkTreeUI; +import java.awt.*; import javax.swing.*; -import java.awt.*; + +import com.github.weisj.darklaf.ui.table.DarkTableUI; +import com.github.weisj.darklaf.ui.tree.DarkTreeUI; public interface ComboBoxConstants { String KEY_IS_TREE_EDITOR = DarkTreeUI.KEY_IS_TREE_EDITOR; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/combobox/ComboIcon.java b/core/src/main/java/com/github/weisj/darklaf/ui/combobox/ComboIcon.java index e98ba9f8..1828ba03 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/combobox/ComboIcon.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/combobox/ComboIcon.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.combobox; -import javax.swing.*; import java.awt.*; +import javax.swing.*; + public class ComboIcon implements Icon { private final JComboBox box; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxBorder.java index f3c6dae8..161d838e 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxBorder.java @@ -20,18 +20,20 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.combobox; -import com.github.weisj.darklaf.ui.cell.CellUtil; -import com.github.weisj.darklaf.util.DarkUIUtil; -import com.github.weisj.darklaf.util.GraphicsContext; +import java.awt.*; import javax.swing.*; import javax.swing.border.Border; import javax.swing.plaf.InsetsUIResource; import javax.swing.plaf.UIResource; -import java.awt.*; + +import com.github.weisj.darklaf.ui.cell.CellUtil; +import com.github.weisj.darklaf.util.DarkUIUtil; +import com.github.weisj.darklaf.util.GraphicsContext; public class DarkComboBoxBorder implements Border, UIResource { @@ -123,7 +125,8 @@ public class DarkComboBoxBorder implements Border, UIResource { public Insets getBorderInsets(final Component c) { if (ComboBoxConstants.isTreeOrTableCellEditor(c)) { return CellUtil.adjustEditorInsets(new InsetsUIResource(cellPadding.top, cellPadding.left, - cellPadding.bottom, cellPadding.right), c); + cellPadding.bottom, cellPadding.right), + c); } if (c.getComponentOrientation().isLeftToRight()) { return new InsetsUIResource(boxPadding.top, boxPadding.left, boxPadding.bottom, borderSize); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxListener.java b/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxListener.java index 7bf83744..a676eccd 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxListener.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxListener.java @@ -20,17 +20,19 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.combobox; -import com.github.weisj.darklaf.util.PropertyKey; - -import javax.swing.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import javax.swing.*; + +import com.github.weisj.darklaf.util.PropertyKey; + public class DarkComboBoxListener extends MouseAdapter implements PropertyChangeListener, ComboBoxConstants { protected final JComboBox comboBox; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxUI.java index 14d91568..4e1bb3f9 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxUI.java @@ -20,21 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.combobox; -import com.github.weisj.darklaf.components.ArrowButton; -import com.github.weisj.darklaf.decorators.LayoutManagerDelegate; -import com.github.weisj.darklaf.ui.list.DarkListCellRenderer; -import com.github.weisj.darklaf.util.DarkUIUtil; -import com.github.weisj.darklaf.util.PropertyKey; - -import javax.swing.*; -import javax.swing.border.Border; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.UIResource; -import javax.swing.plaf.basic.BasicComboBoxUI; -import javax.swing.plaf.basic.ComboPopup; import java.awt.*; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; @@ -43,6 +32,19 @@ import java.awt.event.KeyEvent; import java.awt.geom.Area; import java.awt.geom.RoundRectangle2D; +import javax.swing.*; +import javax.swing.border.Border; +import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.UIResource; +import javax.swing.plaf.basic.BasicComboBoxUI; +import javax.swing.plaf.basic.ComboPopup; + +import com.github.weisj.darklaf.components.ArrowButton; +import com.github.weisj.darklaf.decorators.LayoutManagerDelegate; +import com.github.weisj.darklaf.ui.list.DarkListCellRenderer; +import com.github.weisj.darklaf.util.DarkUIUtil; +import com.github.weisj.darklaf.util.PropertyKey; + /** * @author Konstantin Bulenkov * @author Jannis Weis @@ -303,9 +305,9 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements ComboBoxConstants // calculate the width and height of the button int buttonHeight = size.height; int buttonWidth = squareButton - ? buttonHeight - : arrowButton.getPreferredSize().width - + arrowButton.getInsets().left + arrowButton.getInsets().right; + ? buttonHeight + : arrowButton.getPreferredSize().width + + arrowButton.getInsets().left + arrowButton.getInsets().right; // adjust the size based on the button width size.height += insets.top + insets.bottom; size.width += insets.left + insets.right + buttonWidth; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboPopup.java b/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboPopup.java index e08da47b..6f3f1dd9 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboPopup.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboPopup.java @@ -20,20 +20,22 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.combobox; -import com.github.weisj.darklaf.components.OverlayScrollPane; -import com.github.weisj.darklaf.ui.scrollpane.DarkScrollBarUI; - -import javax.swing.*; -import javax.swing.border.Border; -import javax.swing.plaf.basic.BasicComboPopup; import java.awt.*; import java.awt.event.AdjustmentListener; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionListener; +import javax.swing.*; +import javax.swing.border.Border; +import javax.swing.plaf.basic.BasicComboPopup; + +import com.github.weisj.darklaf.components.OverlayScrollPane; +import com.github.weisj.darklaf.ui.scrollpane.DarkScrollBarUI; + /** * @author Jannis Weis */ @@ -67,7 +69,6 @@ public class DarkComboPopup extends BasicComboPopup { this.borderSize = borderSize; } - @Override protected void firePopupMenuWillBecomeVisible() { if (list.getModel().getSize() != 0) { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFileChooserListViewBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFileChooserListViewBorder.java index cc0625f7..716d5e1b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFileChooserListViewBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFileChooserListViewBorder.java @@ -20,13 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.filechooser; -import com.github.weisj.darklaf.components.border.MutableLineBorder; - import javax.swing.*; +import com.github.weisj.darklaf.components.border.MutableLineBorder; + public class DarkFileChooserListViewBorder extends MutableLineBorder.UIResource { public DarkFileChooserListViewBorder() { super(1, 1, 1, 1, null); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFileChooserUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFileChooserUI.java index 383e0d0e..e2cc506c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFileChooserUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFileChooserUI.java @@ -20,15 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.filechooser; -import com.github.weisj.darklaf.components.tooltip.TooltipAwareButton; -import com.github.weisj.darklaf.components.tooltip.TooltipAwareToggleButton; -import com.github.weisj.darklaf.ui.button.DarkButtonUI; -import com.github.weisj.darklaf.ui.combobox.ComboBoxConstants; -import com.github.weisj.darklaf.util.AlignmentExt; -import sun.swing.FilePane; +import java.awt.*; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; import javax.accessibility.AccessibleContext; import javax.swing.*; @@ -38,12 +39,14 @@ import javax.swing.event.ListDataListener; import javax.swing.filechooser.FileSystemView; import javax.swing.filechooser.FileView; import javax.swing.plaf.ComponentUI; -import java.awt.*; -import java.awt.event.FocusAdapter; -import java.awt.event.FocusEvent; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; + +import sun.swing.FilePane; + +import com.github.weisj.darklaf.components.tooltip.TooltipAwareButton; +import com.github.weisj.darklaf.components.tooltip.TooltipAwareToggleButton; +import com.github.weisj.darklaf.ui.button.DarkButtonUI; +import com.github.weisj.darklaf.ui.combobox.ComboBoxConstants; +import com.github.weisj.darklaf.util.AlignmentExt; public class DarkFileChooserUI extends DarkFileChooserUIBridge { @@ -130,11 +133,11 @@ public class DarkFileChooserUI extends DarkFileChooserUIBridge { if (KEY_VIEW_TYPE.equals(e.getPropertyName())) { int viewType = filePane.getViewType(); switch (viewType) { - case FilePane.VIEWTYPE_LIST: + case FilePane.VIEWTYPE_LIST : listViewButton.setSelected(true); break; - case FilePane.VIEWTYPE_DETAILS: + case FilePane.VIEWTYPE_DETAILS : detailsViewButton.setSelected(true); break; } @@ -162,15 +165,13 @@ public class DarkFileChooserUI extends DarkFileChooserUIBridge { fileNameTextField = new FileTextField(); fileNamePanel.add(fileNameTextField); fileNameLabel.setLabelFor(fileNameTextField); - fileNameTextField.addFocusListener( - new FocusAdapter() { - public void focusGained(final FocusEvent e) { - if (!getFileChooser().isMultiSelectionEnabled()) { - filePane.clearSelection(); - } + fileNameTextField.addFocusListener(new FocusAdapter() { + public void focusGained(final FocusEvent e) { + if (!getFileChooser().isMultiSelectionEnabled()) { + filePane.clearSelection(); } } - ); + }); if (fileChooser.isMultiSelectionEnabled()) { setFileName(fileNameString(fileChooser.getSelectedFiles())); } else { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFileChooserUIBridge.java b/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFileChooserUIBridge.java index 764fa23e..30849f46 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFileChooserUIBridge.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFileChooserUIBridge.java @@ -20,23 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.filechooser; -import com.github.weisj.darklaf.util.PropertyKey; -import sun.awt.shell.ShellFolder; -import sun.swing.FilePane; - -import javax.swing.*; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import javax.swing.filechooser.FileFilter; -import javax.swing.filechooser.FileSystemView; -import javax.swing.plaf.ActionMapUIResource; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.basic.BasicDirectoryModel; -import javax.swing.plaf.basic.BasicFileChooserUI; -import javax.swing.plaf.metal.MetalFileChooserUI; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.MouseAdapter; @@ -51,6 +38,21 @@ import java.util.Locale; import java.util.Objects; import java.util.Vector; +import javax.swing.*; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.filechooser.FileFilter; +import javax.swing.filechooser.FileSystemView; +import javax.swing.plaf.ActionMapUIResource; +import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.basic.BasicDirectoryModel; +import javax.swing.plaf.basic.BasicFileChooserUI; +import javax.swing.plaf.metal.MetalFileChooserUI; + +import sun.awt.shell.ShellFolder; +import sun.swing.FilePane; + +import com.github.weisj.darklaf.util.PropertyKey; /** * Metal L&F implementation of a FileChooser. @@ -124,8 +126,8 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI { /** * Constructs a new instance of {@code MetalFileChooserUI}. * - * @param c a component - * @return a new instance of {@code MetalFileChooserUI} + * @param c a component + * @return a new instance of {@code MetalFileChooserUI} */ public static ComponentUI createUI(final JComponent c) { return new MetalFileChooserUI((JFileChooser) c); @@ -219,46 +221,46 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI { return e -> { String s = e.getPropertyName(); switch (s) { - case JFileChooser.SELECTED_FILE_CHANGED_PROPERTY: + case JFileChooser.SELECTED_FILE_CHANGED_PROPERTY : doSelectedFileChanged(e); break; - case JFileChooser.SELECTED_FILES_CHANGED_PROPERTY: + case JFileChooser.SELECTED_FILES_CHANGED_PROPERTY : doSelectedFilesChanged(e); break; - case JFileChooser.DIRECTORY_CHANGED_PROPERTY: - case "FileChooser.useShellFolder": + case JFileChooser.DIRECTORY_CHANGED_PROPERTY : + case "FileChooser.useShellFolder" : doDirectoryChanged(e); break; - case JFileChooser.FILE_FILTER_CHANGED_PROPERTY: + case JFileChooser.FILE_FILTER_CHANGED_PROPERTY : doFilterChanged(e); break; - case JFileChooser.FILE_SELECTION_MODE_CHANGED_PROPERTY: + case JFileChooser.FILE_SELECTION_MODE_CHANGED_PROPERTY : doFileSelectionModeChanged(e); break; - case JFileChooser.ACCESSORY_CHANGED_PROPERTY: + case JFileChooser.ACCESSORY_CHANGED_PROPERTY : doAccessoryChanged(e); break; - case JFileChooser.APPROVE_BUTTON_TEXT_CHANGED_PROPERTY: - case JFileChooser.APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY: + case JFileChooser.APPROVE_BUTTON_TEXT_CHANGED_PROPERTY : + case JFileChooser.APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY : doApproveButtonTextChanged(e); break; - case JFileChooser.DIALOG_TYPE_CHANGED_PROPERTY: + case JFileChooser.DIALOG_TYPE_CHANGED_PROPERTY : doDialogTypeChanged(e); break; - case JFileChooser.APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY: + case JFileChooser.APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY : doApproveButtonMnemonicChanged(e); break; - case JFileChooser.CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY: + case JFileChooser.CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY : doControlButtonsChanged(e); break; - case PropertyKey.COMPONENT_ORIENTATION: + case PropertyKey.COMPONENT_ORIENTATION : ComponentOrientation o = (ComponentOrientation) e.getNewValue(); JFileChooser cc = (JFileChooser) e.getSource(); if (o != e.getOldValue()) { cc.applyComponentOrientation(o); } break; - case PropertyKey.ANCESTOR: + case PropertyKey.ANCESTOR : if (e.getOldValue() == null && e.getNewValue() != null) { // Ancestor was added, set initial focus fileNameTextField.selectAll(); @@ -405,7 +407,6 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI { } /* The following methods are used by the PropertyChange Listener */ - /** * Sets the directory name. * @@ -430,8 +431,8 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI { /** * Creates a selection listener for the list of files and directories. * - * @param fc a JFileChooser - * @return a ListSelectionListener + * @param fc a JFileChooser + * @return a ListSelectionListener */ public ListSelectionListener createListSelectionListener(final JFileChooser fc) { return super.createListSelectionListener(fc); @@ -442,7 +443,7 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI { * selection event. * * @param directorySelected if a directory is currently selected. - * @since 1.4 + * @since 1.4 */ protected void setDirectorySelected(final boolean directorySelected) { super.setDirectorySelected(directorySelected); @@ -483,8 +484,8 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI { /** * Constructs a new instance of {@code DataModel} for {@code DirectoryComboBox}. * - * @param fc a {@code JFileChooser} - * @return a new instance of {@code DataModel} for {@code DirectoryComboBox} + * @param fc a {@code JFileChooser} + * @return a new instance of {@code DataModel} for {@code DirectoryComboBox} */ protected DirectoryComboBoxModel createDirectoryComboBoxModel(final JFileChooser fc) { return new DirectoryComboBoxModel(); @@ -493,8 +494,8 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI { /** * Constructs a new instance of {@code DirectoryComboBoxRenderer}. * - * @param fc a {@code JFileChooser} - * @return a new instance of {@code DirectoryComboBoxRenderer} + * @param fc a {@code JFileChooser} + * @return a new instance of {@code DirectoryComboBoxRenderer} */ protected DefaultListCellRenderer createDirectoryComboBoxRenderer(final JFileChooser fc) { return new DirectoryComboBoxRenderer(); @@ -600,8 +601,8 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI { /** * Constructs a details view. * - * @param fc a {@code JFileChooser} - * @return the list + * @param fc a {@code JFileChooser} + * @return the list */ protected JPanel createList(final JFileChooser fc) { return filePane.createList(); @@ -610,8 +611,8 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI { /** * Constructs a details view. * - * @param fc a {@code JFileChooser} - * @return the details view + * @param fc a {@code JFileChooser} + * @return the details view */ protected JPanel createDetailsView(final JFileChooser fc) { return filePane.createDetailsView(); @@ -623,8 +624,8 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI { * The preferred size is at least as large, in both height and width, as the preferred size recommended by the file * chooser's layout manager. * - * @param c a JFileChooser - * @return a Dimension specifying the preferred width and height of the file chooser + * @param c a JFileChooser + * @return a Dimension specifying the preferred width and height of the file chooser */ @Override public Dimension getPreferredSize(final JComponent c) { @@ -641,8 +642,8 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI { /** * Returns the minimum size of the JFileChooser. * - * @param c a JFileChooser - * @return a Dimension specifying the minimum width and height of the file chooser + * @param c a JFileChooser + * @return a Dimension specifying the minimum width and height of the file chooser */ @Override public Dimension getMinimumSize(final JComponent c) { @@ -652,8 +653,8 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI { /** * Returns the maximum size of the JFileChooser. * - * @param c a JFileChooser - * @return a Dimension specifying the maximum width and height of the file chooser + * @param c a JFileChooser + * @return a Dimension specifying the maximum width and height of the file chooser */ @Override public Dimension getMaximumSize(final JComponent c) { @@ -702,11 +703,9 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI { protected final int hGap = 5; protected int topMargin = 17; - public void addLayoutComponent(final String string, final Component comp) { - } + public void addLayoutComponent(final String string, final Component comp) {} - public void removeLayoutComponent(final Component c) { - } + public void removeLayoutComponent(final Component c) {} public Dimension preferredLayoutSize(final Container c) { return minimumLayoutSize(c); @@ -826,8 +825,7 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI { * * @param list an instance of {@code JList} */ - public SingleClickListener(final JList list) { - } + public SingleClickListener(final JList list) {} } /** @@ -836,14 +834,13 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI { * @deprecated As of JDK version 9. Obsolete class. */ @SuppressWarnings("serial") // Superclass is not serializable across versions - protected static class FileRenderer extends DefaultListCellRenderer { - } + protected static class FileRenderer extends DefaultListCellRenderer {} // // Renderer for DirectoryComboBox // @SuppressWarnings("serial") - // Superclass is not serializable across versions + // Superclass is not serializable across versions class DirectoryComboBoxRenderer extends DefaultListCellRenderer { final IndentIcon ii = new IndentIcon(); @@ -887,7 +884,6 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI { public int getIconHeight() { return icon.getIconHeight(); } - } /** @@ -930,8 +926,8 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI { directories.clear(); File[] baseFolders = (useShellFolder) - ? (File[]) ShellFolder.get("fileChooserComboBoxFolders") - : fsv.getRoots(); + ? (File[]) ShellFolder.get("fileChooserComboBoxFolders") + : fsv.getRoots(); directories.addAll(Arrays.asList(baseFolders)); // Get the canonical (full) path. This has the side @@ -994,8 +990,8 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI { /** * Returns the depth of {@code i}-th file. * - * @param i an index - * @return the depth of {@code i}-th file + * @param i an index + * @return the depth of {@code i}-th file */ public int getDepth(final int i) { return (depths != null && i >= 0 && i < depths.length) ? depths[i] : 0; @@ -1014,12 +1010,9 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI { fireContentsChanged(this, -1, -1); } - public Object getSelectedItem() { return selectedDirectory; } - - } /** @@ -1027,7 +1020,7 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI { */ @SuppressWarnings("serial") // Same-version serialization only protected class FilterComboBoxModel extends AbstractListModel - implements ComboBoxModel, PropertyChangeListener { + implements ComboBoxModel, PropertyChangeListener { /** * An array of file filters. @@ -1134,7 +1127,6 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI { setAlignmentX(JComponent.LEFT_ALIGNMENT); } - AlignedLabel(final String text) { super(text); setAlignmentX(JComponent.LEFT_ALIGNMENT); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFilePane.java b/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFilePane.java index e5df48c4..a4dbc7ca 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFilePane.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFilePane.java @@ -20,15 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.filechooser; -import com.github.weisj.darklaf.components.OverlayScrollPane; -import com.github.weisj.darklaf.ui.list.DarkListCellRenderer; -import com.github.weisj.darklaf.ui.table.DarkTableUI; -import com.github.weisj.darklaf.ui.table.TextTableCellEditorBorder; -import com.github.weisj.darklaf.util.DarkUIUtil; -import sun.swing.SwingUtilities2; +import java.awt.*; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; +import java.io.File; +import java.util.function.Supplier; import javax.accessibility.AccessibleContext; import javax.swing.*; @@ -37,13 +39,14 @@ import javax.swing.event.ListDataListener; import javax.swing.event.TableModelEvent; import javax.swing.table.TableCellRenderer; import javax.swing.text.Position; -import java.awt.*; -import java.awt.event.ComponentAdapter; -import java.awt.event.ComponentEvent; -import java.awt.event.KeyEvent; -import java.awt.event.MouseEvent; -import java.io.File; -import java.util.function.Supplier; + +import sun.swing.SwingUtilities2; + +import com.github.weisj.darklaf.components.OverlayScrollPane; +import com.github.weisj.darklaf.ui.list.DarkListCellRenderer; +import com.github.weisj.darklaf.ui.table.DarkTableUI; +import com.github.weisj.darklaf.ui.table.TextTableCellEditorBorder; +import com.github.weisj.darklaf.util.DarkUIUtil; public class DarkFilePane extends DarkFilePaneUIBridge { @@ -187,12 +190,11 @@ public class DarkFilePane extends DarkFilePaneUIBridge { detailsTable.putClientProperty("JTable.fileChooserParent", (Supplier) this::getFileChooser); detailsTable.putClientProperty("JTable.fileNameColumnIndex", COLUMN_FILENAME); - Font font = list.getFont(); detailsTable.setFont(font); - TableCellRenderer headerRenderer = - new AlignableTableHeaderRenderer(detailsTable.getTableHeader().getDefaultRenderer()); + TableCellRenderer headerRenderer = new AlignableTableHeaderRenderer(detailsTable.getTableHeader() + .getDefaultRenderer()); detailsTable.getTableHeader().setDefaultRenderer(headerRenderer); TableCellRenderer cellRenderer = new DetailsTableCellRenderer(chooser); detailsTable.setDefaultRenderer(Object.class, cellRenderer); @@ -278,7 +280,7 @@ public class DarkFilePane extends DarkFilePaneUIBridge { ensureIndexIsVisible(index); switch (viewType) { - case VIEWTYPE_LIST: + case VIEWTYPE_LIST : editFile = (File) getModel().getElementAt(getRowSorter().convertRowIndexToModel(index)); Rectangle r = list.getCellBounds(index, index); if (editCell == null) { @@ -313,7 +315,7 @@ public class DarkFilePane extends DarkFilePaneUIBridge { editCell.selectAll(); break; - case VIEWTYPE_DETAILS: + case VIEWTYPE_DETAILS : detailsTable.editCellAt(index, COLUMN_FILENAME); break; } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFilePaneUIBridge.java b/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFilePaneUIBridge.java index 773227d2..14afa353 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFilePaneUIBridge.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFilePaneUIBridge.java @@ -20,24 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.filechooser; -import com.github.weisj.darklaf.ui.list.DarkListCellRenderer; -import com.github.weisj.darklaf.ui.table.DarkTableCellEditor; -import com.github.weisj.darklaf.ui.table.DarkTableCellRenderer; -import com.github.weisj.darklaf.ui.table.TextTableCellEditorBorder; -import com.github.weisj.darklaf.util.PropertyKey; -import sun.awt.shell.ShellFolder; -import sun.awt.shell.ShellFolderColumnInfo; -import sun.swing.FilePane; - -import javax.swing.*; -import javax.swing.border.Border; -import javax.swing.event.*; -import javax.swing.filechooser.FileSystemView; -import javax.swing.plaf.basic.BasicDirectoryModel; -import javax.swing.table.*; import java.awt.*; import java.awt.event.*; import java.beans.PropertyChangeEvent; @@ -46,10 +32,27 @@ import java.io.File; import java.io.FileNotFoundException; import java.text.DateFormat; import java.text.MessageFormat; -import java.util.List; import java.util.*; +import java.util.List; import java.util.concurrent.Callable; +import javax.swing.*; +import javax.swing.border.Border; +import javax.swing.event.*; +import javax.swing.filechooser.FileSystemView; +import javax.swing.plaf.basic.BasicDirectoryModel; +import javax.swing.table.*; + +import sun.awt.shell.ShellFolder; +import sun.awt.shell.ShellFolderColumnInfo; +import sun.swing.FilePane; + +import com.github.weisj.darklaf.ui.list.DarkListCellRenderer; +import com.github.weisj.darklaf.ui.table.DarkTableCellEditor; +import com.github.weisj.darklaf.ui.table.DarkTableCellRenderer; +import com.github.weisj.darklaf.ui.table.TextTableCellEditorBorder; +import com.github.weisj.darklaf.util.PropertyKey; + /** * WARNING: This class is an implementation detail and is only * public so that it can be used by two packages. You should NOT consider this public API. @@ -77,8 +80,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha public static final int VIEWTYPE_LIST = 0; public static final int VIEWTYPE_DETAILS = 1; protected static final int VIEWTYPE_COUNT = 2; - protected static final Cursor waitCursor = - Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR); + protected static final Cursor waitCursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR); protected static final int COLUMN_FILENAME = 0; protected static final int COLUMN_SIZE = 1; protected static final FocusListener repaintListener = new FocusListener() { @@ -341,8 +343,8 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha /** * Returns true if specified FileChooser should use ShellFolder * - * @param chooser the chooser - * @return the boolean + * @param chooser the chooser + * @return the boolean */ public static boolean usesShellFolder(final JFileChooser chooser) { Boolean prop = (Boolean) chooser.getClientProperty("FileChooser.useShellFolder"); @@ -377,7 +379,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha Component newFocusOwner = null; switch (viewType) { - case VIEWTYPE_LIST: + case VIEWTYPE_LIST : if (viewPanels[viewType] == null) { createdViewPanel = fileChooserUIAccessor.createList(); if (createdViewPanel == null) { @@ -398,7 +400,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha newFocusOwner = list; break; - case VIEWTYPE_DETAILS: + case VIEWTYPE_DETAILS : if (viewPanels[viewType] == null) { createdViewPanel = fileChooserUIAccessor.createDetailsView(); if (createdViewPanel == null) { @@ -457,18 +459,13 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha // TUDU: On windows, get the following localized strings from the OS UIDefaults metal = MetalUIDefaults.DEFAULTS; - viewMenuLabelText = - metal.getString("FileChooser.viewMenuLabelText", l); - refreshActionLabelText = - metal.getString("FileChooser.refreshActionLabelText", l); - newFolderActionLabelText = - metal.getString("FileChooser.newFolderActionLabelText", l); + viewMenuLabelText = metal.getString("FileChooser.viewMenuLabelText", l); + refreshActionLabelText = metal.getString("FileChooser.refreshActionLabelText", l); + newFolderActionLabelText = metal.getString("FileChooser.newFolderActionLabelText", l); viewTypeActionNames = new String[VIEWTYPE_COUNT]; - viewTypeActionNames[VIEWTYPE_LIST] = - metal.getString("FileChooser.listViewActionLabelText", l); - viewTypeActionNames[VIEWTYPE_DETAILS] = - metal.getString("FileChooser.detailsViewActionLabelText", l); + viewTypeActionNames[VIEWTYPE_LIST] = metal.getString("FileChooser.listViewActionLabelText", l); + viewTypeActionNames[VIEWTYPE_DETAILS] = metal.getString("FileChooser.detailsViewActionLabelText", l); kiloByteString = UIManager.getString("FileChooser.fileSizeKiloBytes", l); megaByteString = UIManager.getString("FileChooser.fileSizeMegaBytes", l); @@ -491,7 +488,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha public Action[] getActions() { if (actions == null) { @SuppressWarnings("serial") - // JDK-implementation class + // JDK-implementation class class FilePaneAction extends AbstractAction { FilePaneAction(final String name) { this(name, name); @@ -621,8 +618,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha // Install cell editor for editing file name if (!readOnly && columnModel.getColumnCount() > COLUMN_FILENAME) { - columnModel.getColumn(COLUMN_FILENAME). - setCellEditor(getDetailsTableCellEditor()); + columnModel.getColumn(COLUMN_FILENAME).setCellEditor(getDetailsTableCellEditor()); } table.setColumnModel(columnModel); @@ -638,8 +634,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha } @Override - public void setBorder(final Border border) { - } + public void setBorder(final Border border) {} }); } return tableCellEditor; @@ -694,7 +689,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha if (!newDisplayName.equals(oldDisplayName)) { newFileName = newDisplayName; - //Check if extension is hidden from user + // Check if extension is hidden from user int i1 = oldFileName.length(); int i2 = oldDisplayName.length(); if (i1 > i2 && oldFileName.charAt(i2) == '.') { @@ -716,8 +711,8 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha chooser.setSelectedFile(f2); } } else { - //Could be because of delay in updating Desktop folder - //chooser.setSelectedFile(null); + // Could be because of delay in updating Desktop folder + // chooser.setSelectedFile(null); } } else { JOptionPane.showMessageDialog(chooser, MessageFormat.format(renameErrorText, oldFileName), @@ -809,8 +804,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha // restore the anchor and lead if (listSelectionModel instanceof DefaultListSelectionModel) { - ((DefaultListSelectionModel) listSelectionModel). - moveLeadSelectionIndex(lead); + ((DefaultListSelectionModel) listSelectionModel).moveLeadSelectionIndex(lead); listSelectionModel.setAnchorSelectionIndex(anchor); } } finally { @@ -845,8 +839,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha } protected void doDeselectFile(final Object fileToDeselect) { - int index = getRowSorter().convertRowIndexToView( - getModel().indexOf(fileToDeselect)); + int index = getRowSorter().convertRowIndexToView(getModel().indexOf(fileToDeselect)); listSelectionModel.removeSelectionInterval(index, index); } @@ -927,31 +920,31 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha String s = e.getPropertyName(); switch (s) { - case JFileChooser.SELECTED_FILE_CHANGED_PROPERTY: + case JFileChooser.SELECTED_FILE_CHANGED_PROPERTY : doSelectedFileChanged(e); break; - case JFileChooser.SELECTED_FILES_CHANGED_PROPERTY: + case JFileChooser.SELECTED_FILES_CHANGED_PROPERTY : doSelectedFilesChanged(e); break; - case JFileChooser.DIRECTORY_CHANGED_PROPERTY: + case JFileChooser.DIRECTORY_CHANGED_PROPERTY : doDirectoryChanged(e); break; - case JFileChooser.FILE_FILTER_CHANGED_PROPERTY: + case JFileChooser.FILE_FILTER_CHANGED_PROPERTY : doFilterChanged(e); break; - case JFileChooser.FILE_SELECTION_MODE_CHANGED_PROPERTY: + case JFileChooser.FILE_SELECTION_MODE_CHANGED_PROPERTY : doFileSelectionModeChanged(e); break; - case JFileChooser.MULTI_SELECTION_ENABLED_CHANGED_PROPERTY: + case JFileChooser.MULTI_SELECTION_ENABLED_CHANGED_PROPERTY : doMultiSelectionChanged(e); break; - case JFileChooser.CANCEL_SELECTION: + case JFileChooser.CANCEL_SELECTION : applyEdit(); break; - case "busy": + case "busy" : setCursor((Boolean) e.getNewValue() ? waitCursor : null); break; - case PropertyKey.COMPONENT_ORIENTATION: + case PropertyKey.COMPONENT_ORIENTATION : ComponentOrientation o = (ComponentOrientation) e.getNewValue(); JFileChooser cc = (JFileChooser) e.getSource(); if (o != e.getOldValue()) { @@ -991,7 +984,6 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha } /* The following methods are used by the PropertyChange Listener */ - public void rescanCurrentDirectory() { getModel().validateFileCache(); } @@ -1089,13 +1081,13 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha String cmd; switch (viewType) { - case VIEWTYPE_LIST: + case VIEWTYPE_LIST : cmd = ACTION_VIEW_LIST; break; - case VIEWTYPE_DETAILS: + case VIEWTYPE_DETAILS : cmd = ACTION_VIEW_DETAILS; break; - default: + default : cmd = (String) getValue(Action.NAME); } putValue(Action.ACTION_COMMAND_KEY, cmd); @@ -1111,7 +1103,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha */ @SuppressWarnings("serial") // JDK-implementation class protected class SortableListModel extends AbstractListModel - implements TableModelListener, RowSorterListener { + implements TableModelListener, RowSorterListener { public SortableListModel() { getDetailsTableModel().addTableModelListener(this); @@ -1137,7 +1129,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha } @SuppressWarnings("serial") - // JDK-implementation class + // JDK-implementation class class DetailsTableModel extends AbstractTableModel implements ListDataListener { final JFileChooser chooser; final BasicDirectoryModel directoryModel; @@ -1235,7 +1227,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha if (!newDisplayName.equals(oldDisplayName)) { newFileName = newDisplayName; - //Check if extension is hidden from user + // Check if extension is hidden from user int i1 = oldFileName.length(); int i2 = oldDisplayName.length(); if (i1 > i2 && oldFileName.charAt(i2) == '.') { @@ -1283,8 +1275,8 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha return f.isDirectory() ? null : f.length(); } return (col == COLUMN_FILENAME) - ? f // always return the file itself for the 1st column - : ShellFolder.getFolderColumnValue(f, columnMap[col]); + ? f // always return the file itself for the 1st column + : ShellFolder.getFolderColumnValue(f, columnMap[col]); } public void intervalAdded(final ListDataEvent e) { @@ -1396,10 +1388,8 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha } } if (detailsTableModel.getColumns()[column].isCompareByColumn()) { - return comparator.compare( - getDetailsTableModel().getFileColumnValue(f1, column), - getDetailsTableModel().getFileColumnValue(f2, column) - ); + return comparator.compare(getDetailsTableModel().getFileColumnValue(f1, column), + getDetailsTableModel().getFileColumnValue(f2, column)); } // For this column we need to pass the file itself (not a // column value) to the comparator @@ -1448,7 +1438,8 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha final int row, final int column) { if ((table.convertColumnIndexToModel(column) != COLUMN_FILENAME || - (listViewWindowsStyle && !table.isFocusOwner())) && !fullRowSelection) { + (listViewWindowsStyle && !table.isFocusOwner())) + && !fullRowSelection) { isSelected = false; } @@ -1462,8 +1453,8 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha Integer alignment = columnInfo.getAlignment(); if (alignment == null) { alignment = (value instanceof Number) - ? SwingConstants.RIGHT - : SwingConstants.LEADING; + ? SwingConstants.RIGHT + : SwingConstants.LEADING; } setHorizontalAlignment(alignment); @@ -1515,12 +1506,11 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha this.wrappedRenderer = wrappedRenderer; } - public Component getTableCellRendererComponent( - final JTable table, final Object value, final boolean isSelected, - final boolean hasFocus, final int row, final int column) { + public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, + final boolean hasFocus, final int row, final int column) { - Component c = wrappedRenderer.getTableCellRendererComponent( - table, value, isSelected, hasFocus, row, column); + Component c = wrappedRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, + column); int modelColumn = table.convertColumnIndexToModel(column); ShellFolderColumnInfo columnInfo = detailsTableModel.getColumns()[modelColumn]; @@ -1554,8 +1544,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha public void run() { setFileSelected(); if (editFile != null) { - editFileName(getRowSorter().convertRowIndexToView( - getModel().indexOf(editFile))); + editFileName(getRowSorter().convertRowIndexToView(getModel().indexOf(editFile))); editFile = null; } } @@ -1654,8 +1643,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha // Lazy creation of Basic's listener if (doubleClickListener == null && list != null) { - doubleClickListener = - fileChooserUIAccessor.createDoubleClickListener(list); + doubleClickListener = fileChooserUIAccessor.createDoubleClickListener(list); } return doubleClickListener; } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFilterComboBoxRenderer.java b/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFilterComboBoxRenderer.java index a194a5b4..a1d66997 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFilterComboBoxRenderer.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFilterComboBoxRenderer.java @@ -20,14 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.filechooser; -import com.github.weisj.darklaf.ui.list.DarkListCellRenderer; +import java.awt.*; import javax.swing.*; import javax.swing.filechooser.FileFilter; -import java.awt.*; + +import com.github.weisj.darklaf.ui.list.DarkListCellRenderer; public class DarkFilterComboBoxRenderer extends DarkListCellRenderer { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/FileTextField.java b/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/FileTextField.java index f30d3843..1267312c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/FileTextField.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/FileTextField.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.filechooser; -import javax.swing.*; import java.awt.*; +import javax.swing.*; + public class FileTextField extends JTextField { public FileTextField() { @@ -35,5 +37,4 @@ public class FileTextField extends JTextField { public Dimension getMaximumSize() { return new Dimension(Short.MAX_VALUE, super.getPreferredSize().height); } - } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/MetalUIDefaults.java b/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/MetalUIDefaults.java index d15a03aa..33900cc4 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/MetalUIDefaults.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/MetalUIDefaults.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.filechooser; @@ -27,6 +28,4 @@ import javax.swing.*; import javax.swing.plaf.metal.MetalLookAndFeel; // Extra class is for lazy initialization -class MetalUIDefaults { - static final UIDefaults DEFAULTS = new MetalLookAndFeel().getDefaults(); -} +class MetalUIDefaults { static final UIDefaults DEFAULTS = new MetalLookAndFeel().getDefaults(); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/html/DarkHTML.java b/core/src/main/java/com/github/weisj/darklaf/ui/html/DarkHTML.java index 8cc57899..e81b92de 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/html/DarkHTML.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/html/DarkHTML.java @@ -20,15 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.html; +import java.awt.*; + import javax.swing.plaf.basic.BasicHTML; import javax.swing.text.AttributeSet; import javax.swing.text.StyleConstants; import javax.swing.text.View; import javax.swing.text.html.HTML; -import java.awt.*; public class DarkHTML extends BasicHTML { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkDesktopIconBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkDesktopIconBorder.java index f129a60c..9cc59726 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkDesktopIconBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkDesktopIconBorder.java @@ -20,14 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.internalframe; -import com.github.weisj.darklaf.components.border.MutableLineBorder; - import javax.swing.*; import javax.swing.plaf.UIResource; +import com.github.weisj.darklaf.components.border.MutableLineBorder; + /** * @author Jannis Weis */ diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkDesktopIconUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkDesktopIconUI.java index 5aa421dc..df0ff244 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkDesktopIconUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkDesktopIconUI.java @@ -20,19 +20,21 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.internalframe; -import com.github.weisj.darklaf.components.uiresource.JButtonUIResource; -import com.github.weisj.darklaf.ui.button.DarkButtonUI; +import java.awt.*; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; import javax.swing.*; import javax.swing.border.MatteBorder; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicDesktopIconUI; -import java.awt.*; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; + +import com.github.weisj.darklaf.components.uiresource.JButtonUIResource; +import com.github.weisj.darklaf.ui.button.DarkButtonUI; /** * @author Jannis Weis diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameBorder.java index e41a200c..5f988b53 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameBorder.java @@ -20,15 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.internalframe; -import com.github.weisj.darklaf.components.border.DropShadowBorder; +import java.awt.*; import javax.swing.*; import javax.swing.plaf.InsetsUIResource; import javax.swing.plaf.UIResource; -import java.awt.*; + +import com.github.weisj.darklaf.components.border.DropShadowBorder; /** * @author Jannis Weis diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameTitlePane.java b/core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameTitlePane.java index ba5ce202..9b48a15a 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameTitlePane.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameTitlePane.java @@ -20,20 +20,23 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.internalframe; -import com.github.weisj.darklaf.components.uiresource.JButtonUIResource; -import com.github.weisj.darklaf.icons.EmptyIcon; -import com.github.weisj.darklaf.icons.ToggleIcon; -import com.github.weisj.darklaf.ui.button.DarkButtonUI; -import sun.swing.SwingUtilities2; +import java.awt.*; +import java.beans.PropertyChangeListener; import javax.accessibility.AccessibleContext; import javax.swing.*; import javax.swing.plaf.basic.BasicInternalFrameTitlePane; -import java.awt.*; -import java.beans.PropertyChangeListener; + +import sun.swing.SwingUtilities2; + +import com.github.weisj.darklaf.components.uiresource.JButtonUIResource; +import com.github.weisj.darklaf.icons.EmptyIcon; +import com.github.weisj.darklaf.icons.ToggleIcon; +import com.github.weisj.darklaf.ui.button.DarkButtonUI; /** * @author Jannis Weis @@ -61,7 +64,6 @@ public class DarkInternalFrameTitlePane extends BasicInternalFrameTitlePane { private PropertyChangeListener propertyChangeListener2; - public DarkInternalFrameTitlePane(final JInternalFrame f) { super(f); } @@ -204,7 +206,6 @@ public class DarkInternalFrameTitlePane extends BasicInternalFrameTitlePane { return frame.isSelected() ? selectedTitleColor : notSelectedTitleColor; } - private static JButton createButton(final String accessibleName) { JButton button = new JButtonUIResource() { @Override @@ -244,15 +245,12 @@ public class DarkInternalFrameTitlePane extends BasicInternalFrameTitlePane { } @Override - protected void paintBorder(final Graphics g) { - } + protected void paintBorder(final Graphics g) {} protected class DarkTitlePaneLayout implements LayoutManager { - public void addLayoutComponent(final String name, final Component c) { - } + public void addLayoutComponent(final String name, final Component c) {} - public void removeLayoutComponent(final Component c) { - } + public void removeLayoutComponent(final Component c) {} public Dimension preferredLayoutSize(final Container c) { return minimumLayoutSize(c); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameUI.java index eacf6cfe..90343794 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameUI.java @@ -20,15 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.internalframe; -import com.github.weisj.darklaf.util.PropertyKey; +import java.awt.*; import javax.swing.*; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicInternalFrameUI; -import java.awt.*; + +import com.github.weisj.darklaf.util.PropertyKey; /** * @author Jannis Weis @@ -39,7 +41,6 @@ public class DarkInternalFrameUI extends BasicInternalFrameUI { super(b); } - public static ComponentUI createUI(final JComponent b) { return new DarkInternalFrameUI((JInternalFrame) b); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/label/DarkLabelUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/label/DarkLabelUI.java index d1062751..ae2d0509 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/label/DarkLabelUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/label/DarkLabelUI.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.label; @@ -33,14 +34,14 @@ import javax.swing.plaf.basic.BasicHTML; import javax.swing.plaf.basic.BasicLabelUI; import javax.swing.text.View; +import sun.swing.SwingUtilities2; + import com.github.weisj.darklaf.ui.cell.CellUtil; import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.GraphicsContext; import com.github.weisj.darklaf.util.GraphicsUtil; import com.github.weisj.darklaf.util.PropertyKey; -import sun.swing.SwingUtilities2; - /** * @author Jannis Weis */ diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListCellBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListCellBorder.java index e8b9fbf0..71565fa7 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListCellBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListCellBorder.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.list; @@ -28,5 +29,4 @@ import com.github.weisj.darklaf.ui.cell.DarkCellBorder; /** * @author Jannis Weis */ -public class DarkListCellBorder extends DarkCellBorder { -} +public class DarkListCellBorder extends DarkCellBorder {} diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListCellFocusBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListCellFocusBorder.java index 9d546451..9f3d2dcb 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListCellFocusBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListCellFocusBorder.java @@ -20,14 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.list; -import com.github.weisj.darklaf.ui.cell.DarkCellBorder; -import com.github.weisj.darklaf.util.DarkUIUtil; +import java.awt.*; import javax.swing.*; -import java.awt.*; + +import com.github.weisj.darklaf.ui.cell.DarkCellBorder; +import com.github.weisj.darklaf.util.DarkUIUtil; public class DarkListCellFocusBorder extends DarkCellBorder { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListCellRenderer.java b/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListCellRenderer.java index c4856cae..4a77704c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListCellRenderer.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListCellRenderer.java @@ -20,14 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.list; -import com.github.weisj.darklaf.ui.cell.CellUtil; -import com.github.weisj.darklaf.util.DarkUIUtil; +import java.awt.*; import javax.swing.*; -import java.awt.*; + +import com.github.weisj.darklaf.ui.cell.CellUtil; +import com.github.weisj.darklaf.util.DarkUIUtil; public class DarkListCellRenderer extends DefaultListCellRenderer { @@ -67,7 +69,7 @@ public class DarkListCellRenderer extends DefaultListCellRenderer { } } if (getText().isEmpty()) { - //Fix cell height for empty string. + // Fix cell height for empty string. setText(" "); } return comp; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUI.java index 7ebefcce..87e09180 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUI.java @@ -20,17 +20,19 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.list; -import com.github.weisj.darklaf.util.DarkUIUtil; - -import javax.swing.*; -import javax.swing.plaf.ComponentUI; import java.awt.*; import java.awt.event.MouseEvent; import java.beans.PropertyChangeEvent; +import javax.swing.*; +import javax.swing.plaf.ComponentUI; + +import com.github.weisj.darklaf.util.DarkUIUtil; + /** * @author Jannis Weis */ @@ -51,7 +53,6 @@ public class DarkListUI extends DarkListUIBridge { UIManager.put("List.cellRenderer", new DarkListCellRenderer()); } - public static ComponentUI createUI(final JComponent list) { return new DarkListUI(); } @@ -72,19 +73,19 @@ public class DarkListUI extends DarkListUIBridge { protected void paintImpl(final Graphics g, final JComponent c) { switch (layoutOrientation) { - case JList.VERTICAL_WRAP: + case JList.VERTICAL_WRAP : if (list.getHeight() != listHeight) { updateLayoutStateNeeded |= heightChanged; redrawList(); } break; - case JList.HORIZONTAL_WRAP: + case JList.HORIZONTAL_WRAP : if (list.getWidth() != listWidth) { updateLayoutStateNeeded |= widthChanged; redrawList(); } break; - default: + default : break; } maybeUpdateLayoutState(); @@ -113,7 +114,6 @@ public class DarkListUI extends DarkListUIBridge { int leadIndex = adjustIndex(list.getLeadSelectionIndex(), list); int rowIncrement = (layoutOrientation == JList.HORIZONTAL_WRAP) ? columnCount : 1; - Rectangle rowBounds; for (int colCounter = startColumn; colCounter <= endColumn; colCounter++) { int row = convertLocationToRowInColumn(paintBounds.y, colCounter); @@ -166,8 +166,8 @@ public class DarkListUI extends DarkListUIBridge { g.setColor(c); } if (!empty) { - Component rendererComponent = - cellRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + Component rendererComponent = cellRenderer.getListCellRendererComponent(list, value, index, isSelected, + cellHasFocus); if (Boolean.TRUE.equals(list.getClientProperty(KEY_SHRINK_WRAP))) { // Shrink renderer to preferred size. This is mostly used on Windows // where selection is only shown around the file name, instead of diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUIBridge.java b/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUIBridge.java index bfa6a9aa..88447ef1 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUIBridge.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUIBridge.java @@ -20,25 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.list; -import com.github.weisj.darklaf.ui.BasicTransferable; -import com.github.weisj.darklaf.ui.DragRecognitionSupport; -import com.github.weisj.darklaf.util.DarkSwingUtil; -import com.github.weisj.darklaf.util.DarkUIUtil; -import com.github.weisj.darklaf.util.LazyActionMap; -import com.github.weisj.darklaf.util.PropertyKey; -import sun.swing.DefaultLookup; -import sun.swing.SwingUtilities2; -import sun.swing.UIAction; - -import javax.swing.*; -import javax.swing.event.*; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.UIResource; -import javax.swing.plaf.basic.BasicListUI; -import javax.swing.text.Position; import java.awt.*; import java.awt.datatransfer.Transferable; import java.awt.event.*; @@ -47,6 +32,24 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Objects; +import javax.swing.*; +import javax.swing.event.*; +import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.UIResource; +import javax.swing.plaf.basic.BasicListUI; +import javax.swing.text.Position; + +import sun.swing.DefaultLookup; +import sun.swing.SwingUtilities2; +import sun.swing.UIAction; + +import com.github.weisj.darklaf.ui.BasicTransferable; +import com.github.weisj.darklaf.ui.DragRecognitionSupport; +import com.github.weisj.darklaf.util.DarkSwingUtil; +import com.github.weisj.darklaf.util.DarkUIUtil; +import com.github.weisj.darklaf.util.LazyActionMap; +import com.github.weisj.darklaf.util.PropertyKey; + /** * An extensible implementation of {@code ListUI}. *

@@ -61,8 +64,7 @@ public class DarkListUIBridge extends BasicListUI { /** * The constant BASELINE_COMPONENT_KEY. */ - protected static final StringBuilder BASELINE_COMPONENT_KEY = - new StringBuilder("List.baselineComponent"); + protected static final StringBuilder BASELINE_COMPONENT_KEY = new StringBuilder("List.baselineComponent"); /** * The bit relates to model changed property. */ @@ -130,7 +132,7 @@ public class DarkListUIBridge extends BasicListUI { /** * The constant defaultTransferHandler. */ -// Following ivars are used if the list is laying out horizontally + // Following ivars are used if the list is laying out horizontally protected static final TransferHandler defaultTransferHandler = new ListTransferHandler(); /** * The instance of {@code JList}. @@ -153,10 +155,11 @@ public class DarkListUIBridge extends BasicListUI { */ protected ListSelectionListener listSelectionListener; - /* The bits below define JList property changes that affect layout. + /* + * The bits below define JList property changes that affect layout. * When one of these properties changes we set a bit in - * updateLayoutStateNeeded. The change is dealt with lazily, see - * maybeUpdateLayoutState. Changes to the JLists model, e.g. the + * updateLayoutStateNeeded. The change is dealt with lazily, see + * maybeUpdateLayoutState. Changes to the JLists model, e.g. the * models length changed, are handled similarly, see DataListener. */ /** @@ -230,8 +233,8 @@ public class DarkListUIBridge extends BasicListUI { * Returns a new instance of {@code BasicListUI}. {@code BasicListUI} delegates are allocated one per {@code * JList}*. * - * @param list a component - * @return a new {@code ListUI} implementation for the Windows look and feel. + * @param list a component + * @return a new {@code ListUI} implementation for the Windows look and feel. */ public static ComponentUI createUI(final JComponent list) { return new BasicListUI(); @@ -293,7 +296,7 @@ public class DarkListUIBridge extends BasicListUI { * @param dataModel a list model * @param selModel a selection model * @param leadIndex a lead index - * @see #paint + * @see #paint */ protected void paintCell(final Graphics g, final int row, @@ -306,8 +309,8 @@ public class DarkListUIBridge extends BasicListUI { boolean cellHasFocus = list.hasFocus() && (row == leadIndex); boolean isSelected = selModel.isSelectedIndex(row); - Component rendererComponent = - cellRenderer.getListCellRendererComponent(list, value, row, isSelected, cellHasFocus); + Component rendererComponent = cellRenderer.getListCellRendererComponent(list, value, row, isSelected, + cellHasFocus); int cx = rowBounds.x; int cy = rowBounds.y; @@ -329,7 +332,7 @@ public class DarkListUIBridge extends BasicListUI { } /** - * Paint the rows that intersect the Graphics objects clipRect. This method calls paintCell as necessary. + * Paint the rows that intersect the Graphics objects clipRect. This method calls paintCell as necessary. * Subclasses may want to override these methods. * * @see #paintCell @@ -347,15 +350,14 @@ public class DarkListUIBridge extends BasicListUI { * * @throws NullPointerException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} - * @see javax.swing.JComponent#getBaseline(int, int) - * @since 1.6 + * @see javax.swing.JComponent#getBaseline(int, int) + * @since 1.6 */ public int getBaseline(final JComponent c, final int width, final int height) { super.getBaseline(c, width, height); int rowHeight = list.getFixedCellHeight(); UIDefaults lafDefaults = UIManager.getLookAndFeelDefaults(); - Component renderer = (Component) lafDefaults.get( - BASELINE_COMPONENT_KEY); + Component renderer = (Component) lafDefaults.get(BASELINE_COMPONENT_KEY); if (renderer == null) { @SuppressWarnings("unchecked") ListCellRenderer lcr = (ListCellRenderer) UIManager.get("List.cellRenderer"); @@ -365,15 +367,14 @@ public class DarkListUIBridge extends BasicListUI { if (lcr == null) { lcr = new DefaultListCellRenderer(); } - renderer = lcr.getListCellRendererComponent( - list, "a", -1, false, false); + renderer = lcr.getListCellRendererComponent(list, "a", -1, false, false); lafDefaults.put(BASELINE_COMPONENT_KEY, renderer); } renderer.setFont(list.getFont()); // JList actually has much more complex behavior here. // If rowHeight != -1 the rowHeight is either the max of all cell // heights (layout orientation != VERTICAL), or is variable depending - // upon the cell. We assume a default size. + // upon the cell. We assume a default size. // We could theoretically query the real renderer, but that would // not work for an empty model and the results may vary with // the content. @@ -388,66 +389,64 @@ public class DarkListUIBridge extends BasicListUI { * Returns an enum indicating how the baseline of the component changes as the size changes. * * @throws NullPointerException {@inheritDoc} - * @see javax.swing.JComponent#getBaseline(int, int) - * @since 1.6 + * @see javax.swing.JComponent#getBaseline(int, int) + * @since 1.6 */ - public Component.BaselineResizeBehavior getBaselineResizeBehavior( - final JComponent c) { + public Component.BaselineResizeBehavior getBaselineResizeBehavior(final JComponent c) { super.getBaselineResizeBehavior(c); return Component.BaselineResizeBehavior.CONSTANT_ASCENT; } /** * The preferredSize of the list depends upon the layout orientation. - * * * * - * - * + * * - * - * - * - * + * + * + * *
Describes the preferred size for each layout orientation *
Layout Orientation - * Preferred Size + *
Layout Orientation + * Preferred Size *
JList.VERTICAL - * The preferredSize of the list is total height of the rows - * and the maximum width of the cells. If JList.fixedCellHeight - * is specified then the total height of the rows is just - * (cellVerticalMargins + fixedCellHeight) * model.getSize() where - * rowVerticalMargins is the space we allocate for drawing - * the yellow focus outline. Similarly if fixedCellWidth is - * specified then we just use that. - *
JList.VERTICAL_WRAP - * If the visible row count is greater than zero, the preferredHeight - * is the maximum cell height * visibleRowCount. If the visible row - * count is <= 0, the preferred height is either the current height - * of the list, or the maximum cell height, whichever is - * bigger. The preferred width is than the maximum cell width * - * number of columns needed. Where the number of columns needs is - * list.height / max cell height. Max cell height is either the fixed - * cell height, or is determined by iterating through all the cells - * to find the maximum height from the ListCellRenderer. - *
JList.HORIZONTAL_WRAP - * If the visible row count is greater than zero, the preferredHeight - * is the maximum cell height * adjustedRowCount. Where - * visibleRowCount is used to determine the number of columns. - * Because this lays out horizontally the number of rows is - * then determined from the column count. For example, lets say - * you have a model with 10 items and the visible row count is 8. - * The number of columns needed to display this is 2, but you no - * longer need 8 rows to display this, you only need 5, thus - * the adjustedRowCount is 5. + *
JList.VERTICAL + * The preferredSize of the list is total height of the rows + * and the maximum width of the cells. If JList.fixedCellHeight + * is specified then the total height of the rows is just + * (cellVerticalMargins + fixedCellHeight) * model.getSize() where + * rowVerticalMargins is the space we allocate for drawing + * the yellow focus outline. Similarly if fixedCellWidth is + * specified then we just use that. + *
JList.VERTICAL_WRAP + * If the visible row count is greater than zero, the preferredHeight + * is the maximum cell height * visibleRowCount. If the visible row + * count is <= 0, the preferred height is either the current height + * of the list, or the maximum cell height, whichever is + * bigger. The preferred width is than the maximum cell width * + * number of columns needed. Where the number of columns needs is + * list.height / max cell height. Max cell height is either the fixed + * cell height, or is determined by iterating through all the cells + * to find the maximum height from the ListCellRenderer. + *
JList.HORIZONTAL_WRAP + * If the visible row count is greater than zero, the preferredHeight + * is the maximum cell height * adjustedRowCount. Where + * visibleRowCount is used to determine the number of columns. + * Because this lays out horizontally the number of rows is + * then determined from the column count. For example, lets say + * you have a model with 10 items and the visible row count is 8. + * The number of columns needed to display this is 2, but you no + * longer need 8 rows to display this, you only need 5, thus + * the adjustedRowCount is 5. *

- * If the visible row count is <= 0, the preferred height is dictated - * by the number of columns, which will be as many as can fit in the - * width of the {@code JList} (width / max cell width), with at least - * one column. The preferred height then becomes the model size / number - * of columns * maximum cell height. Max cell height is either the fixed - * cell height, or is determined by iterating through all the cells to - * find the maximum height from the ListCellRenderer. + * If the visible row count is <= 0, the preferred height is dictated + * by the number of columns, which will be as many as can fit in the + * width of the {@code JList} (width / max cell width), with at least + * one column. The preferred height then becomes the model size / number + * of columns * maximum cell height. Max cell height is either the fixed + * cell height, or is determined by iterating through all the cells to + * find the maximum height from the ListCellRenderer. *

*

@@ -457,8 +456,8 @@ public class DarkListUIBridge extends BasicListUI { * insets.bottom. Where the Insets are determined from * list.getInsets(). * - * @param c The JList component. - * @return The total size of the list. + * @param c The JList component. + * @return The total size of the list. */ public Dimension getPreferredSize(final JComponent c) { maybeUpdateLayoutState(); @@ -558,7 +557,7 @@ public class DarkListUIBridge extends BasicListUI { } /** - * Creates and installs the listeners for the JList, its model, and its selectionModel. This method is called at + * Creates and installs the listeners for the JList, its model, and its selectionModel. This method is called at * installUI() time. * * @see #installUI @@ -599,8 +598,8 @@ public class DarkListUIBridge extends BasicListUI { } /** - * Removes the listeners from the JList, its model, and its selectionModel. All of the listener fields, are reset - * to null here. This method is called at uninstallUI() time, it should be kept in sync with installListeners. + * Removes the listeners from the JList, its model, and its selectionModel. All of the listener fields, are reset + * to null here. This method is called at uninstallUI() time, it should be kept in sync with installListeners. * * @see #uninstallUI * @see #installListeners @@ -747,13 +746,12 @@ public class DarkListUIBridge extends BasicListUI { /** * Gets input map. * - * @param condition the condition - * @return the input map + * @param condition the condition + * @return the input map */ InputMap getInputMap(final int condition) { if (condition == JComponent.WHEN_FOCUSED) { - InputMap keyMap = (InputMap) DefaultLookup.get( - list, this, "List.focusInputMap"); + InputMap keyMap = (InputMap) DefaultLookup.get(list, this, "List.focusInputMap"); InputMap rtlKeyMap; if (isLeftToRight || @@ -771,9 +769,9 @@ public class DarkListUIBridge extends BasicListUI { /** * Returns the closest location to the model index of the passed in location. * - * @param x the x - * @param y the y - * @return the int + * @param x the x + * @param y the y + * @return the int */ protected int convertLocationToModel(final int x, final int y) { int row = convertLocationToRow(x, y, true); @@ -788,7 +786,7 @@ public class DarkListUIBridge extends BasicListUI { /** * Uninitializes this.list by calling uninstallListeners(), * uninstallKeyboardActions(), and uninstallDefaults() - * in order. Sets this.list to null. + * in order. Sets this.list to null. * * @see #uninstallListeners * @see #uninstallKeyboardActions @@ -877,11 +875,11 @@ public class DarkListUIBridge extends BasicListUI { /** * Returns the height of the specified row based on the current layout. * - * @param row a row - * @return the specified row height or -1 if row isn't valid - * @see #convertYToRow - * @see #convertRowToY - * @see #updateLayoutState + * @param row a row + * @return the specified row height or -1 if row isn't valid + * @see #convertYToRow + * @see #convertRowToY + * @see #updateLayoutState */ protected int getRowHeight(final int row) { return getHeight(0, row); @@ -891,10 +889,10 @@ public class DarkListUIBridge extends BasicListUI { * Convert the {@code JList} relative coordinate to the row that contains it, based on the current layout. If {@code * y0} doesn't fall within any row, return -1. * - * @param y0 a relative Y coordinate - * @return the row that contains y0, or -1 - * @see #getRowHeight - * @see #updateLayoutState + * @param y0 a relative Y coordinate + * @return the row that contains y0, or -1 + * @see #getRowHeight + * @see #updateLayoutState */ protected int convertYToRow(final int y0) { return convertLocationToRow(0, y0, false); @@ -903,10 +901,10 @@ public class DarkListUIBridge extends BasicListUI { /** * Return the {@code JList} relative Y coordinate of the origin of the specified row or -1 if row isn't valid. * - * @param row a row - * @return the Y coordinate of the origin of row, or -1 - * @see #getRowHeight - * @see #updateLayoutState + * @param row a row + * @return the Y coordinate of the origin of row, or -1 + * @see #getRowHeight + * @see #updateLayoutState */ protected int convertRowToY(final int row) { if (row >= getRowCount(0) || row < 0) { @@ -917,7 +915,7 @@ public class DarkListUIBridge extends BasicListUI { } /** - * If updateLayoutStateNeeded is non zero, call updateLayoutState() and reset updateLayoutStateNeeded. This method + * If updateLayoutStateNeeded is non zero, call updateLayoutState() and reset updateLayoutStateNeeded. This method * should be called by methods before doing any computation based on the geometry of the list. For example it's the * first call in paint() and getPreferredSize(). * @@ -937,11 +935,11 @@ public class DarkListUIBridge extends BasicListUI { * @see #maybeUpdateLayoutState */ protected void updateLayoutState() { - /* If both JList fixedCellWidth and fixedCellHeight have been + /* + * If both JList fixedCellWidth and fixedCellHeight have been * set, then initialize cellWidth and cellHeight, and set * cellHeights to null. */ - int fixedCellHeight = list.getFixedCellHeight(); int fixedCellWidth = list.getFixedCellWidth(); @@ -955,13 +953,13 @@ public class DarkListUIBridge extends BasicListUI { cellHeights = new int[list.getModel().getSize()]; } - /* If either of JList fixedCellWidth and fixedCellHeight haven't + /* + * If either of JList fixedCellWidth and fixedCellHeight haven't * been set, then initialize cellWidth and cellHeights by - * scanning through the entire model. Note: if the renderer is + * scanning through the entire model. Note: if the renderer is * null, we just set cellWidth and cellHeights[*] to zero, * if they're not set already. */ - if ((fixedCellWidth == -1) || (fixedCellHeight == -1)) { ListModel dataModel = list.getModel(); @@ -1004,6 +1002,7 @@ public class DarkListUIBridge extends BasicListUI { * Creates a delegate that implements {@code MouseInputListener}. The delegate is added to the corresponding {@code * java.awt.Component} listener lists at {@code installUI()} time. Subclasses can override this method to return a * custom {@code MouseInputListener}, e.g. + * *
      * class MyListUI extends BasicListUI {
      *    protected MouseInputListener createMouseInputListener() {
@@ -1019,8 +1018,8 @@ public class DarkListUIBridge extends BasicListUI {
      * 
* * @return an instance of {@code MouseInputListener} - * @see MouseInputHandler - * @see #installUI + * @see MouseInputHandler + * @see #installUI */ protected MouseInputListener createMouseInputListener() { return getHandler(); @@ -1037,7 +1036,8 @@ public class DarkListUIBridge extends BasicListUI { /** * Creates an instance of {@code ListSelectionHandler} that's added to the {@code JLists} by selectionModel as - * needed. Subclasses can override this method to return a custom {@code ListSelectionListener}, e.g. + * needed. Subclasses can override this method to return a custom {@code ListSelectionListener}, e.g. + * *
      * class MyListUI extends BasicListUI {
      *    protected ListSelectionListener createListSelectionListener() {
@@ -1053,8 +1053,8 @@ public class DarkListUIBridge extends BasicListUI {
      * 
* * @return an instance of {@code ListSelectionHandler} - * @see ListSelectionHandler - * @see #installUI + * @see ListSelectionHandler + * @see #installUI */ protected ListSelectionListener createListSelectionListener() { return getHandler(); @@ -1063,6 +1063,7 @@ public class DarkListUIBridge extends BasicListUI { /** * Creates an instance of {@code ListDataListener} that's added to the {@code JLists} by model as needed. Subclasses * can override this method to return a custom {@code ListDataListener}, e.g. + * *
      * class MyListUI extends BasicListUI {
      *    protected ListDataListener createListDataListener() {
@@ -1078,9 +1079,9 @@ public class DarkListUIBridge extends BasicListUI {
      * 
* * @return an instance of {@code ListDataListener} - * @see ListDataListener - * @see JList#getModel - * @see #installUI + * @see ListDataListener + * @see JList#getModel + * @see #installUI */ protected ListDataListener createListDataListener() { return getHandler(); @@ -1089,6 +1090,7 @@ public class DarkListUIBridge extends BasicListUI { /** * Creates an instance of {@code PropertyChangeHandler} that's added to the {@code JList} by {@code installUI()}. * Subclasses can override this method to return a custom {@code PropertyChangeListener}, e.g. + * *
      * class MyListUI extends BasicListUI {
      *    protected PropertyChangeListener createPropertyChangeListener() {
@@ -1106,8 +1108,8 @@ public class DarkListUIBridge extends BasicListUI {
      * 
* * @return an instance of {@code PropertyChangeHandler} - * @see PropertyChangeListener - * @see #installUI + * @see PropertyChangeListener + * @see #installUI */ protected PropertyChangeListener createPropertyChangeListener() { return getHandler(); @@ -1116,11 +1118,12 @@ public class DarkListUIBridge extends BasicListUI { /** * Returns the row at location x/y. * - * @param x the x - * @param y0 the y 0 - * @param closest If true and the location doesn't exactly match a particular location, this will return the closest - * row. - * @return the int + * @param x the x + * @param y0 the y 0 + * @param closest If true and the location doesn't exactly match a particular location, this will return the + * closest + * row. + * @return the int */ public int convertLocationToRow(final int x, final int y0, final boolean closest) { int size = list.getModel().getSize(); @@ -1130,8 +1133,7 @@ public class DarkListUIBridge extends BasicListUI { } Insets insets = list.getInsets(); if (cellHeights == null) { - int row = (cellHeight == 0) ? 0 : - ((y0 - insets.top) / cellHeight); + int row = (cellHeight == 0) ? 0 : ((y0 - insets.top) / cellHeight); if (closest) { if (row < 0) { row = 0; @@ -1164,9 +1166,9 @@ public class DarkListUIBridge extends BasicListUI { /** * Returns the closest column to the passed in location. * - * @param x the x - * @param y the y - * @return the int + * @param x the x + * @param y the y + * @return the int */ protected int convertLocationToColumn(final int x, final int y) { if (cellWidth > 0) { @@ -1194,19 +1196,19 @@ public class DarkListUIBridge extends BasicListUI { * Returns the model index for the specified display location. If columnxrow is beyond the * length of the model, this will return the model size - 1. * - * @param column the column - * @param row the row - * @return the model index + * @param column the column + * @param row the row + * @return the model index */ protected int getModelIndex(final int column, final int row) { switch (layoutOrientation) { - case JList.VERTICAL_WRAP: + case JList.VERTICAL_WRAP : return Math.min(list.getModel().getSize() - 1, rowsPerColumn * column + Math.min(row, rowsPerColumn - 1)); - case JList.HORIZONTAL_WRAP: + case JList.HORIZONTAL_WRAP : return Math.min(list.getModel().getSize() - 1, row * columnCount + column); - default: + default : return row; } } @@ -1273,7 +1275,8 @@ public class DarkListUIBridge extends BasicListUI { } } else if (layoutOrientation == JList.VERTICAL_WRAP && height != 0) { rowsPerColumn = Math.max(1, (listHeight - insets.top - - insets.bottom) / height); + insets.bottom) + / height); columnCount = Math.max(1, dataModelSize / rowsPerColumn); if (dataModelSize > 0 && dataModelSize > rowsPerColumn && dataModelSize % rowsPerColumn != 0) { @@ -1282,7 +1285,8 @@ public class DarkListUIBridge extends BasicListUI { } else if (layoutOrientation == JList.HORIZONTAL_WRAP && cellWidth > 0 && listWidth > 0) { columnCount = Math.max(1, (listWidth - insets.left - - insets.right) / cellWidth); + insets.right) + / cellWidth); rowsPerColumn = dataModelSize / columnCount; if (dataModelSize % columnCount > 0) { rowsPerColumn++; @@ -1300,19 +1304,19 @@ public class DarkListUIBridge extends BasicListUI { */ protected void paintImpl(final Graphics g, final JComponent c) { switch (layoutOrientation) { - case JList.VERTICAL_WRAP: + case JList.VERTICAL_WRAP : if (list.getHeight() != listHeight) { updateLayoutStateNeeded |= heightChanged; redrawList(); } break; - case JList.HORIZONTAL_WRAP: + case JList.HORIZONTAL_WRAP : if (list.getWidth() != listWidth) { updateLayoutStateNeeded |= widthChanged; redrawList(); } break; - default: + default : break; } maybeUpdateLayoutState(); @@ -1345,9 +1349,7 @@ public class DarkListUIBridge extends BasicListUI { } int maxY = paintBounds.y + paintBounds.height; int leadIndex = adjustIndex(list.getLeadSelectionIndex(), list); - int rowIncrement = (layoutOrientation == JList.HORIZONTAL_WRAP) ? - columnCount : 1; - + int rowIncrement = (layoutOrientation == JList.HORIZONTAL_WRAP) ? columnCount : 1; for (int colCounter = startColumn; colCounter <= endColumn; colCounter++) { @@ -1390,9 +1392,9 @@ public class DarkListUIBridge extends BasicListUI { /** * Adjust index int. * - * @param index the index - * @param list the list - * @return the int + * @param index the index + * @param list the list + * @return the int */ protected static int adjustIndex(final int index, final JList list) { return index < list.getModel().getSize() ? index : -1; @@ -1401,9 +1403,9 @@ public class DarkListUIBridge extends BasicListUI { /** * Returns the closest row that starts at the specified y-location in the passed in column. * - * @param y the y - * @param column the column - * @return the int + * @param y the y + * @param column the column + * @return the int */ protected int convertLocationToRowInColumn(final int y, final int column) { int x = 0; @@ -1421,8 +1423,8 @@ public class DarkListUIBridge extends BasicListUI { /** * Returns the number of rows in the given column. * - * @param column the column - * @return the row count + * @param column the column + * @return the row count */ protected int getRowCount(final int column) { if (column < 0 || column >= columnCount) { @@ -1452,9 +1454,9 @@ public class DarkListUIBridge extends BasicListUI { /** * Returns the height of the cell at the passed in location. * - * @param column the column - * @param row the row - * @return the height + * @param column the column + * @param row the row + * @return the height */ protected int getHeight(final int column, final int row) { if (column < 0 || column > columnCount || row < 0) { @@ -1466,8 +1468,7 @@ public class DarkListUIBridge extends BasicListUI { if (row >= list.getModel().getSize()) { return -1; } - return (cellHeights == null) ? cellHeight : - ((row < cellHeights.length) ? cellHeights[row] : -1); + return (cellHeights == null) ? cellHeight : ((row < cellHeights.length) ? cellHeights[row] : -1); } /** @@ -1492,8 +1493,8 @@ public class DarkListUIBridge extends BasicListUI { /** * Gets drop line rect. * - * @param loc the loc - * @return the drop line rect + * @param loc the loc + * @return the drop line rect */ protected Rectangle getDropLineRect(final JList.DropLocation loc) { int size = list.getModel().getSize(); @@ -1521,8 +1522,7 @@ public class DarkListUIBridge extends BasicListUI { if (layoutOrientation == JList.HORIZONTAL_WRAP) { if (index == size) { decr = true; - } else if (index != 0 && convertModelToRow(index) - != convertModelToRow(index - 1)) { + } else if (index != 0 && convertModelToRow(index) != convertModelToRow(index - 1)) { Rectangle prev = getCellBounds(list, index - 1); Rectangle me = getCellBounds(list, index); @@ -1531,17 +1531,15 @@ public class DarkListUIBridge extends BasicListUI { if (isLeftToRight) { decr = Point2D.distance(prev.x + prev.width, prev.y + (int) (prev.height / 2.0), - p.x, p.y) - < Point2D.distance(me.x, - me.y + (int) (me.height / 2.0), - p.x, p.y); + p.x, p.y) < Point2D.distance(me.x, + me.y + (int) (me.height / 2.0), + p.x, p.y); } else { decr = Point2D.distance(prev.x, prev.y + (int) (prev.height / 2.0), - p.x, p.y) - < Point2D.distance(me.x + me.width, - me.y + (int) (prev.height / 2.0), - p.x, p.y); + p.x, p.y) < Point2D.distance(me.x + me.width, + me.y + (int) (prev.height / 2.0), + p.x, p.y); } } @@ -1572,18 +1570,16 @@ public class DarkListUIBridge extends BasicListUI { index--; rect = getCellBounds(list, index); rect.y += rect.height; - } else if (index != 0 && convertModelToColumn(index) - != convertModelToColumn(index - 1)) { + } else if (index != 0 && convertModelToColumn(index) != convertModelToColumn(index - 1)) { Rectangle prev = getCellBounds(list, index - 1); Rectangle me = getCellBounds(list, index); Point p = loc.getDropPoint(); if (Point2D.distance(prev.x + (int) (prev.width / 2.0), prev.y + prev.height, - p.x, p.y) - < Point2D.distance(me.x + (int) (me.width / 2.0), - me.y, - p.x, p.y)) { + p.x, p.y) < Point2D.distance(me.x + (int) (me.width / 2.0), + me.y, + p.x, p.y)) { index--; rect = getCellBounds(list, index); @@ -1622,8 +1618,8 @@ public class DarkListUIBridge extends BasicListUI { /** * Returns the row that the model index index will be displayed in.. * - * @param index the index - * @return the int + * @param index the index + * @return the int */ public int convertModelToRow(final int index) { int size = list.getModel().getSize(); @@ -1646,9 +1642,9 @@ public class DarkListUIBridge extends BasicListUI { * Gets the bounds of the specified model index, returning the resulting bounds, or null if index is * not valid. * - * @param list the list - * @param index the index - * @return the cell bounds + * @param list the list + * @param index the index + * @return the cell bounds */ protected Rectangle getCellBounds(final JList list, final int index) { maybeUpdateLayoutState(); @@ -1666,8 +1662,8 @@ public class DarkListUIBridge extends BasicListUI { int y = insets.top; int h; switch (layoutOrientation) { - case JList.VERTICAL_WRAP: - case JList.HORIZONTAL_WRAP: + case JList.VERTICAL_WRAP : + case JList.HORIZONTAL_WRAP : if (isLeftToRight) { x = insets.left + column * cellWidth; } else { @@ -1676,7 +1672,7 @@ public class DarkListUIBridge extends BasicListUI { y += cellHeight * row; h = cellHeight; break; - default: + default : x = insets.left; if (cellHeights == null) { y += (cellHeight * row); @@ -1697,8 +1693,8 @@ public class DarkListUIBridge extends BasicListUI { /** * Returns the column that the model index index will be displayed in. * - * @param index the index - * @return the int + * @param index the index + * @return the int */ protected int convertModelToColumn(final int index) { int size = list.getModel().getSize(); @@ -1730,9 +1726,9 @@ public class DarkListUIBridge extends BasicListUI { /** * Create a Transferable to use as the source for a data transfer. * - * @param c The component holding the data to be transfered. This argument is provided to enable sharing of - * TransferHandlers by multiple components. - * @return The representation of the data to be transfered. + * @param c The component holding the data to be transfered. This argument is provided to enable sharing of + * TransferHandlers by multiple components. + * @return The representation of the data to be transfered. */ @SuppressWarnings("deprecation") protected Transferable createTransferable(final JComponent c) { @@ -1764,51 +1760,33 @@ public class DarkListUIBridge extends BasicListUI { return null; } - } private static class Actions extends UIAction { - private static final String SELECT_PREVIOUS_COLUMN = - "selectPreviousColumn"; - private static final String SELECT_PREVIOUS_COLUMN_EXTEND = - "selectPreviousColumnExtendSelection"; - private static final String SELECT_PREVIOUS_COLUMN_CHANGE_LEAD = - "selectPreviousColumnChangeLead"; + private static final String SELECT_PREVIOUS_COLUMN = "selectPreviousColumn"; + private static final String SELECT_PREVIOUS_COLUMN_EXTEND = "selectPreviousColumnExtendSelection"; + private static final String SELECT_PREVIOUS_COLUMN_CHANGE_LEAD = "selectPreviousColumnChangeLead"; private static final String SELECT_NEXT_COLUMN = "selectNextColumn"; - private static final String SELECT_NEXT_COLUMN_EXTEND = - "selectNextColumnExtendSelection"; - private static final String SELECT_NEXT_COLUMN_CHANGE_LEAD = - "selectNextColumnChangeLead"; + private static final String SELECT_NEXT_COLUMN_EXTEND = "selectNextColumnExtendSelection"; + private static final String SELECT_NEXT_COLUMN_CHANGE_LEAD = "selectNextColumnChangeLead"; private static final String SELECT_PREVIOUS_ROW = "selectPreviousRow"; - private static final String SELECT_PREVIOUS_ROW_EXTEND = - "selectPreviousRowExtendSelection"; - private static final String SELECT_PREVIOUS_ROW_CHANGE_LEAD = - "selectPreviousRowChangeLead"; + private static final String SELECT_PREVIOUS_ROW_EXTEND = "selectPreviousRowExtendSelection"; + private static final String SELECT_PREVIOUS_ROW_CHANGE_LEAD = "selectPreviousRowChangeLead"; private static final String SELECT_NEXT_ROW = "selectNextRow"; - private static final String SELECT_NEXT_ROW_EXTEND = - "selectNextRowExtendSelection"; - private static final String SELECT_NEXT_ROW_CHANGE_LEAD = - "selectNextRowChangeLead"; + private static final String SELECT_NEXT_ROW_EXTEND = "selectNextRowExtendSelection"; + private static final String SELECT_NEXT_ROW_CHANGE_LEAD = "selectNextRowChangeLead"; private static final String SELECT_FIRST_ROW = "selectFirstRow"; - private static final String SELECT_FIRST_ROW_EXTEND = - "selectFirstRowExtendSelection"; - private static final String SELECT_FIRST_ROW_CHANGE_LEAD = - "selectFirstRowChangeLead"; + private static final String SELECT_FIRST_ROW_EXTEND = "selectFirstRowExtendSelection"; + private static final String SELECT_FIRST_ROW_CHANGE_LEAD = "selectFirstRowChangeLead"; private static final String SELECT_LAST_ROW = "selectLastRow"; - private static final String SELECT_LAST_ROW_EXTEND = - "selectLastRowExtendSelection"; - private static final String SELECT_LAST_ROW_CHANGE_LEAD = - "selectLastRowChangeLead"; + private static final String SELECT_LAST_ROW_EXTEND = "selectLastRowExtendSelection"; + private static final String SELECT_LAST_ROW_CHANGE_LEAD = "selectLastRowChangeLead"; private static final String SCROLL_UP = "scrollUp"; - private static final String SCROLL_UP_EXTEND = - "scrollUpExtendSelection"; - private static final String SCROLL_UP_CHANGE_LEAD = - "scrollUpChangeLead"; + private static final String SCROLL_UP_EXTEND = "scrollUpExtendSelection"; + private static final String SCROLL_UP_CHANGE_LEAD = "scrollUpChangeLead"; private static final String SCROLL_DOWN = "scrollDown"; - private static final String SCROLL_DOWN_EXTEND = - "scrollDownExtendSelection"; - private static final String SCROLL_DOWN_CHANGE_LEAD = - "scrollDownChangeLead"; + private static final String SCROLL_DOWN_EXTEND = "scrollDownExtendSelection"; + private static final String SCROLL_DOWN_CHANGE_LEAD = "scrollDownChangeLead"; private static final String SELECT_ALL = "selectAll"; private static final String CLEAR_SELECTION = "clearSelection"; @@ -1913,8 +1891,7 @@ public class DarkListUIBridge extends BasicListUI { } else if (Objects.equals(name, CLEAR_SELECTION)) { clearSelection(list); } else if (Objects.equals(name, ADD_TO_SELECTION)) { - int index = adjustIndex( - list.getSelectionModel().getLeadSelectionIndex(), list); + int index = adjustIndex(list.getSelectionModel().getLeadSelectionIndex(), list); if (!list.isSelectedIndex(index)) { int oldAnchor = list.getSelectionModel().getAnchorSelectionIndex(); @@ -1924,8 +1901,7 @@ public class DarkListUIBridge extends BasicListUI { list.setValueIsAdjusting(false); } } else if (Objects.equals(name, TOGGLE_AND_ANCHOR)) { - int index = adjustIndex( - list.getSelectionModel().getLeadSelectionIndex(), list); + int index = adjustIndex(list.getSelectionModel().getLeadSelectionIndex(), list); if (list.isSelectedIndex(index)) { list.removeSelectionInterval(index, index); @@ -1933,15 +1909,13 @@ public class DarkListUIBridge extends BasicListUI { list.addSelectionInterval(index, index); } } else if (Objects.equals(name, EXTEND_TO)) { - changeSelection( - list, EXTEND_SELECTION, - adjustIndex(list.getSelectionModel().getLeadSelectionIndex(), list), - 0); + changeSelection(list, EXTEND_SELECTION, + adjustIndex(list.getSelectionModel().getLeadSelectionIndex(), list), + 0); } else if (Objects.equals(name, MOVE_SELECTION_TO)) { - changeSelection( - list, CHANGE_SELECTION, - adjustIndex(list.getSelectionModel().getLeadSelectionIndex(), list), - 0); + changeSelection(list, CHANGE_SELECTION, + adjustIndex(list.getSelectionModel().getLeadSelectionIndex(), list), + 0); } } @@ -1952,8 +1926,7 @@ public class DarkListUIBridge extends BasicListUI { // CHANGE_LEAD is only valid with multiple interval selection if (type == CHANGE_LEAD && - list.getSelectionMode() - != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { + list.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { type = CHANGE_SELECTION; } @@ -2049,8 +2022,7 @@ public class DarkListUIBridge extends BasicListUI { Rectangle visRect = list.getVisibleRect(); ListSelectionModel lsm = list.getSelectionModel(); int lead = adjustIndex(lsm.getLeadSelectionIndex(), list); - Rectangle leadRect = - (lead == -1) ? new Rectangle() : list.getCellBounds(lead, lead); + Rectangle leadRect = (lead == -1) ? new Rectangle() : list.getCellBounds(lead, lead); if (leadRect == null) { return index; @@ -2152,8 +2124,7 @@ public class DarkListUIBridge extends BasicListUI { // go up one cell if last visible cell doesn't fit // into visible rectangle if (cellBounds != null && - cellBounds.y + cellBounds.height > - visRect.y + visRect.height) { + cellBounds.y + cellBounds.height > visRect.y + visRect.height) { p.y = cellBounds.y - 1; index = list.locationToIndex(p); if (index == -1) { @@ -2176,8 +2147,7 @@ public class DarkListUIBridge extends BasicListUI { // go one cell up if last visible cell doesn't fit // into adjasted visible rectangle if (cellBounds != null && - cellBounds.y + cellBounds.height > - visRect.y + visRect.height) { + cellBounds.y + cellBounds.height > visRect.y + visRect.height) { p.y = cellBounds.y - 1; index = list.locationToIndex(p); if (index == -1) { @@ -2251,8 +2221,7 @@ public class DarkListUIBridge extends BasicListUI { // right for left-to-right int x = Math.max(0, cellBounds.x + cellBounds.width - visRect.width); - int startIndex = - list.locationToIndex(new Point(x, cellBounds.y)); + int startIndex = list.locationToIndex(new Point(x, cellBounds.y)); if (startIndex == -1) { return; } @@ -2261,8 +2230,7 @@ public class DarkListUIBridge extends BasicListUI { if (startRect != null && startRect.x < x && startRect.x < cellBounds.x) { startRect.x += startRect.width; - startIndex = - list.locationToIndex(startRect.getLocation()); + startIndex = list.locationToIndex(startRect.getLocation()); if (startIndex == -1) { return; } @@ -2278,8 +2246,7 @@ public class DarkListUIBridge extends BasicListUI { if (direction > 0) { // left for right-to-left int x = cellBounds.x + visRect.width; - int rightIndex = - list.locationToIndex(new Point(x, cellBounds.y)); + int rightIndex = list.locationToIndex(new Point(x, cellBounds.y)); if (rightIndex == -1) { return; } @@ -2306,13 +2273,11 @@ public class DarkListUIBridge extends BasicListUI { // vertical if (direction > 0 && (cellBounds.y < visRect.y || - cellBounds.y + cellBounds.height - > visRect.y + visRect.height)) { - //down + cellBounds.y + cellBounds.height > visRect.y + visRect.height)) { + // down int y = Math.max(0, cellBounds.y + cellBounds.height - visRect.height); - int startIndex = - list.locationToIndex(new Point(cellBounds.x, y)); + int startIndex = list.locationToIndex(new Point(cellBounds.x, y)); if (startIndex == -1) { return; } @@ -2321,13 +2286,11 @@ public class DarkListUIBridge extends BasicListUI { if (startRect != null && startRect.y < y && startRect.y < cellBounds.y) { startRect.y += startRect.height; - startIndex = - list.locationToIndex(startRect.getLocation()); + startIndex = list.locationToIndex(startRect.getLocation()); if (startIndex == -1) { return; } - startRect = - list.getCellBounds(startIndex, startIndex); + startRect = list.getCellBounds(startIndex, startIndex); } cellBounds = startRect; if (cellBounds != null) { @@ -2347,8 +2310,8 @@ public class DarkListUIBridge extends BasicListUI { /** * Accept boolean. * - * @param c the c - * @return the boolean + * @param c the c + * @return the boolean */ public boolean accept(final Object c) { Object name = getName(); @@ -2363,8 +2326,7 @@ public class DarkListUIBridge extends BasicListUI { // discontinuous selection actions are only enabled for // DefaultListSelectionModel - return c != null && ((JList) c).getSelectionModel() - instanceof DefaultListSelectionModel; + return c != null && ((JList) c).getSelectionModel() instanceof DefaultListSelectionModel; } return true; @@ -2383,10 +2345,10 @@ public class DarkListUIBridge extends BasicListUI { getHandler().repaintCellFocus(); } - /* The focusGained() focusLost() methods run when the JList + /* + * The focusGained() focusLost() methods run when the JList * focus changes. */ - public void focusGained(final FocusEvent e) { getHandler().focusGained(e); } @@ -2397,13 +2359,13 @@ public class DarkListUIBridge extends BasicListUI { } /** - * Mouse input, and focus handling for JList. An instance of this class is added to the appropriate - * java.awt.Component lists at installUI() time. Note keyboard input is handled with JComponent KeyboardActions, + * Mouse input, and focus handling for JList. An instance of this class is added to the appropriate + * java.awt.Component lists at installUI() time. Note keyboard input is handled with JComponent KeyboardActions, * see installKeyboardActions(). *

* Warning: * Serialized objects of this class will not be compatible with future Swing releases. The current serialization - * support is appropriate for short term storage or RMI between applications running the same version of Swing. As + * support is appropriate for short term storage or RMI between applications running the same version of Swing. As * of 1.4, support for long term storage of all JavaBeans™ has been added to the java.beans * package. Please see {@link java.beans.XMLEncoder}. * @@ -2444,11 +2406,11 @@ public class DarkListUIBridge extends BasicListUI { /** * The ListSelectionListener that's added to the JLists selection model at installUI time, and whenever the - * JList.selectionModel property changes. When the selection changes we repaint the affected rows. + * JList.selectionModel property changes. When the selection changes we repaint the affected rows. *

* Warning: * Serialized objects of this class will not be compatible with future Swing releases. The current serialization - * support is appropriate for short term storage or RMI between applications running the same version of Swing. As + * support is appropriate for short term storage or RMI between applications running the same version of Swing. As * of 1.4, support for long term storage of all JavaBeans™ has been added to the java.beans * package. Please see {@link java.beans.XMLEncoder}. * @@ -2468,7 +2430,7 @@ public class DarkListUIBridge extends BasicListUI { *

* Warning: * Serialized objects of this class will not be compatible with future Swing releases. The current serialization - * support is appropriate for short term storage or RMI between applications running the same version of Swing. As + * support is appropriate for short term storage or RMI between applications running the same version of Swing. As * of 1.4, support for long term storage of all JavaBeans™ has been added to the java.beans * package. Please see {@link java.beans.XMLEncoder}. * @@ -2483,25 +2445,23 @@ public class DarkListUIBridge extends BasicListUI { getHandler().intervalAdded(e); } - public void intervalRemoved(final ListDataEvent e) { getHandler().intervalRemoved(e); } - public void contentsChanged(final ListDataEvent e) { getHandler().contentsChanged(e); } } /** - * The PropertyChangeListener that's added to the JList at installUI time. When the value of a JList property that + * The PropertyChangeListener that's added to the JList at installUI time. When the value of a JList property that * affects layout changes, we set a bit in updateLayoutStateNeeded. If the JLists model changes we additionally - * remove our listeners from the old model. Likewise for the JList selectionModel. + * remove our listeners from the old model. Likewise for the JList selectionModel. *

* Warning: * Serialized objects of this class will not be compatible with future Swing releases. The current serialization - * support is appropriate for short term storage or RMI between applications running the same version of Swing. As + * support is appropriate for short term storage or RMI between applications running the same version of Swing. As * of 1.4, support for long term storage of all JavaBeans™ has been added to the java.beans * package. Please see {@link java.beans.XMLEncoder}. * @@ -2520,13 +2480,13 @@ public class DarkListUIBridge extends BasicListUI { * The type Handler. */ protected class Handler implements FocusListener, KeyListener, - ListDataListener, ListSelectionListener, - MouseInputListener, PropertyChangeListener, - DragRecognitionSupport.BeforeDrag { + ListDataListener, ListSelectionListener, + MouseInputListener, PropertyChangeListener, + DragRecognitionSupport.BeforeDrag { /** * The Prefix. */ -// + // // KeyListener // protected String prefix = ""; @@ -2541,7 +2501,7 @@ public class DarkListUIBridge extends BasicListUI { /** * The Drag press did selection. */ -// Whether or not the mouse press (which is being considered as part + // Whether or not the mouse press (which is being considered as part // of a drag sequence) also caused the selection change to be fully // processed. protected boolean dragPressDidSelection; @@ -2624,15 +2584,14 @@ public class DarkListUIBridge extends BasicListUI { * Invoked when a key has been released. See the class description for {@link KeyEvent} for a definition of a * key released event. */ - public void keyReleased(final KeyEvent e) { - } + public void keyReleased(final KeyEvent e) {} /** - * Returns whether or not the supplied key event maps to a key that is used for navigation. This is used for + * Returns whether or not the supplied key event maps to a key that is used for navigation. This is used for * optimizing key input by only passing non- navigation keys to the first letter navigation mechanism. * - * @param event the event - * @return the boolean + * @param event the event + * @return the boolean */ protected boolean isNavigationKey(final KeyEvent event) { InputMap inputMap = list.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); @@ -2647,7 +2606,8 @@ public class DarkListUIBridge extends BasicListUI { public void propertyChange(final PropertyChangeEvent e) { String propertyName = e.getPropertyName(); - /* If the JList.model property changes, remove our listener, + /* + * If the JList.model property changes, remove our listener, * listDataListener from the old model and add it to the new one. */ if (Objects.equals(propertyName, "model")) { @@ -2663,7 +2623,8 @@ public class DarkListUIBridge extends BasicListUI { redrawList(); } - /* If the JList.selectionModel property changes, remove our listener, + /* + * If the JList.selectionModel property changes, remove our listener, * listSelectionListener from the old selectionModel and add it to the new one. */ else if (Objects.equals(propertyName, "selectionModel")) { @@ -2756,15 +2717,16 @@ public class DarkListUIBridge extends BasicListUI { int minIndex = Math.min(e.getIndex0(), e.getIndex1()); int maxIndex = Math.max(e.getIndex0(), e.getIndex1()); - /* Sync the SelectionModel with the DataModel. + /* + * Sync the SelectionModel with the DataModel. */ - ListSelectionModel sm = list.getSelectionModel(); if (sm != null) { sm.insertIndexInterval(minIndex, maxIndex - minIndex + 1, true); } - /* Repaint the entire list, from the origin of + /* + * Repaint the entire list, from the origin of * the first added cell, to the bottom of the * component. */ @@ -2774,19 +2736,19 @@ public class DarkListUIBridge extends BasicListUI { public void intervalRemoved(final ListDataEvent e) { updateLayoutStateNeeded = modelChanged; - /* Sync the SelectionModel with the DataModel. + /* + * Sync the SelectionModel with the DataModel. */ - ListSelectionModel sm = list.getSelectionModel(); if (sm != null) { sm.removeIndexInterval(e.getIndex0(), e.getIndex1()); } - /* Repaint the entire list, from the origin of + /* + * Repaint the entire list, from the origin of * the first removed cell, to the bottom of the * component. */ - redrawList(); } @@ -2815,8 +2777,7 @@ public class DarkListUIBridge extends BasicListUI { // // MouseListener // - public void mouseClicked(final MouseEvent e) { - } + public void mouseClicked(final MouseEvent e) {} public void mousePressed(final MouseEvent e) { if (SwingUtilities2.shouldIgnore(e, list)) { @@ -2930,11 +2891,9 @@ public class DarkListUIBridge extends BasicListUI { } } - public void mouseEntered(final MouseEvent e) { - } + public void mouseEntered(final MouseEvent e) {} - public void mouseExited(final MouseEvent e) { - } + public void mouseExited(final MouseEvent e) {} public void dragStarting(final MouseEvent me) { if (DarkUIUtil.isMenuShortcutKeyDown(me)) { @@ -2959,7 +2918,7 @@ public class DarkListUIBridge extends BasicListUI { int row = locationToIndex(list, e.getPoint()); if (row != -1) { - // 4835633. Dragging onto a File should not select it. + // 4835633. Dragging onto a File should not select it. if (isFileList) { return; } @@ -2971,21 +2930,20 @@ public class DarkListUIBridge extends BasicListUI { } } - public void mouseMoved(final MouseEvent e) { - } + public void mouseMoved(final MouseEvent e) {} public void focusGained(final FocusEvent e) { repaintCellFocus(); } - /* The focusGained() focusLost() methods run when the JList + /* + * The focusGained() focusLost() methods run when the JList * focus changes. */ - /** * Repaint cell focus. */ -// + // // FocusListener // protected void repaintCellFocus() { @@ -3002,5 +2960,4 @@ public class DarkListUIBridge extends BasicListUI { repaintCellFocus(); } } - } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuBarBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuBarBorder.java index 646d4a38..236f746b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuBarBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuBarBorder.java @@ -20,14 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.menu; +import java.awt.*; + import javax.swing.*; import javax.swing.border.Border; import javax.swing.plaf.InsetsUIResource; import javax.swing.plaf.UIResource; -import java.awt.*; /** * @author Jannis Weis diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuBarUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuBarUI.java index ee356a14..73100e9d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuBarUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuBarUI.java @@ -20,14 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.menu; +import java.awt.*; + import javax.swing.*; import javax.swing.event.ChangeListener; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.metal.MetalMenuBarUI; -import java.awt.*; /** * @author Jannis Weis diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuItemBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuItemBorder.java index 2aa407b3..8ae34651 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuItemBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuItemBorder.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.menu; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuItemUIBase.java b/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuItemUIBase.java index 3c27adbc..73a5b020 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuItemUIBase.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuItemUIBase.java @@ -20,19 +20,22 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.menu; -import com.github.weisj.darklaf.util.*; -import sun.swing.MenuItemLayoutHelper; -import sun.swing.SwingUtilities2; -import sun.swing.UIAction; +import java.awt.*; +import java.awt.event.ActionEvent; import javax.swing.*; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicMenuItemUI; -import java.awt.*; -import java.awt.event.ActionEvent; + +import sun.swing.MenuItemLayoutHelper; +import sun.swing.SwingUtilities2; +import sun.swing.UIAction; + +import com.github.weisj.darklaf.util.*; /** * @author Konstantin Bulenkov @@ -40,7 +43,6 @@ import java.awt.event.ActionEvent; */ public class DarkMenuItemUIBase extends BasicMenuItemUI { - protected int acceleratorTextOffset; protected boolean useEvenHeight; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuUI.java index 10187d2f..ce1f0cb3 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuUI.java @@ -20,20 +20,22 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.menu; -import com.github.weisj.darklaf.decorators.MouseInputDelegate; -import com.github.weisj.darklaf.util.GraphicsContext; -import com.github.weisj.darklaf.util.GraphicsUtil; +import java.awt.*; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; import javax.swing.*; import javax.swing.event.MouseInputListener; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicMenuUI; -import java.awt.*; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; + +import com.github.weisj.darklaf.decorators.MouseInputDelegate; +import com.github.weisj.darklaf.util.GraphicsContext; +import com.github.weisj.darklaf.util.GraphicsUtil; public class DarkMenuUI extends BasicMenuUI { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/menu/MenuItemLayoutDelegate.java b/core/src/main/java/com/github/weisj/darklaf/ui/menu/MenuItemLayoutDelegate.java index 5e5e3c19..51eb9612 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/menu/MenuItemLayoutDelegate.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/menu/MenuItemLayoutDelegate.java @@ -20,15 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.menu; -import com.github.weisj.darklaf.ui.html.DarkHTML; - -import javax.swing.*; import java.awt.*; import java.awt.font.TextAttribute; +import javax.swing.*; + +import com.github.weisj.darklaf.ui.html.DarkHTML; + public class MenuItemLayoutDelegate extends JMenuItem { private JMenuItem delegate; @@ -122,6 +124,4 @@ public class MenuItemLayoutDelegate extends JMenuItem { if (delegate != null) return delegate.getText(); return super.getText(); } - } - diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/numberingpane/DarkNumberingPaneBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/numberingpane/DarkNumberingPaneBorder.java index 7459cfcc..ab684066 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/numberingpane/DarkNumberingPaneBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/numberingpane/DarkNumberingPaneBorder.java @@ -20,14 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.numberingpane; -import com.github.weisj.darklaf.components.border.MutableLineBorder; - import javax.swing.*; import javax.swing.plaf.UIResource; +import com.github.weisj.darklaf.components.border.MutableLineBorder; + public class DarkNumberingPaneBorder extends MutableLineBorder implements UIResource { public DarkNumberingPaneBorder() { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/numberingpane/DarkNumberingPaneUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/numberingpane/DarkNumberingPaneUI.java index d8da9818..7ac100af 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/numberingpane/DarkNumberingPaneUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/numberingpane/DarkNumberingPaneUI.java @@ -20,23 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.numberingpane; -import com.github.weisj.darklaf.components.text.IconListener; -import com.github.weisj.darklaf.components.text.IndexListener; -import com.github.weisj.darklaf.components.text.LineHighlighter; -import com.github.weisj.darklaf.components.text.NumberingPane; -import com.github.weisj.darklaf.util.DarkUIUtil; -import com.github.weisj.darklaf.util.GraphicsContext; -import com.github.weisj.darklaf.util.GraphicsUtil; -import com.github.weisj.darklaf.util.PropertyKey; - -import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import javax.swing.plaf.ComponentUI; -import javax.swing.text.*; import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -48,6 +35,21 @@ import java.util.Collection; import java.util.List; import java.util.Map; +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.plaf.ComponentUI; +import javax.swing.text.*; + +import com.github.weisj.darklaf.components.text.IconListener; +import com.github.weisj.darklaf.components.text.IndexListener; +import com.github.weisj.darklaf.components.text.LineHighlighter; +import com.github.weisj.darklaf.components.text.NumberingPane; +import com.github.weisj.darklaf.util.DarkUIUtil; +import com.github.weisj.darklaf.util.GraphicsContext; +import com.github.weisj.darklaf.util.GraphicsUtil; +import com.github.weisj.darklaf.util.PropertyKey; + public class DarkNumberingPaneUI extends ComponentUI { protected static final int OUTER_PAD = 7; @@ -63,7 +65,6 @@ public class DarkNumberingPaneUI extends ComponentUI { protected int maxIconWidth = 0; protected Color oldBackground; - public static ComponentUI createUI(final JComponent c) { return new DarkNumberingPaneUI(); } @@ -199,16 +200,15 @@ public class DarkNumberingPaneUI extends ComponentUI { g.setColor(lineRect.y == yCur ? foregroundHighlight : numberingPane.getForeground()); g.drawString(String.format("%1$" + digits + "d", i), OUTER_PAD, lineRect.y + lineRect.height - descent); - } catch (BadLocationException ignored) { - } + } catch (BadLocationException ignored) {} } config.restore(); } protected void paintIcons(final Graphics g, final int startLine, final int endLine, final Element root) { - List> icons = numberingPane.getIconsInRange( - root.getElement(startLine).getStartOffset(), - root.getElement(endLine).getEndOffset()); + List> icons = numberingPane.getIconsInRange(root.getElement(startLine) + .getStartOffset(), + root.getElement(endLine).getEndOffset()); for (Map.Entry icon : icons) { Rectangle lineRect; try { @@ -217,8 +217,7 @@ public class DarkNumberingPaneUI extends ComponentUI { int x = OUTER_PAD + PAD + textWidth; int y = lineRect.y + lineRect.height / 2 - h / 2; icon.getValue().paintIcon(numberingPane, g, x, y); - } catch (BadLocationException ignored) { - } + } catch (BadLocationException ignored) {} } } @@ -272,8 +271,7 @@ public class DarkNumberingPaneUI extends ComponentUI { listener.iconClicked(e); } } - } catch (BadLocationException ignored) { - } + } catch (BadLocationException ignored) {} } IndexListener[] list = numberingPane.getIndexListeners(); for (IndexListener listener : list) { @@ -359,8 +357,7 @@ public class DarkNumberingPaneUI extends ComponentUI { currentHighlight = textComponent.getHighlighter().addHighlight(0, 0, currentLinePainter); textComponent.getCaret().addChangeListener(currentLinePainter); currentLinePainter.setComponent(textComponent); - } catch (BadLocationException ignored) { - } + } catch (BadLocationException ignored) {} textComponent.addPropertyChangeListener(getPropertyChangeListener()); textComponent.getCaret().addChangeListener(getChangeListener()); Font font = textComponent.getFont(); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/optionpane/DarkOptionPaneBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/optionpane/DarkOptionPaneBorder.java index e56e483c..bbfba18d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/optionpane/DarkOptionPaneBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/optionpane/DarkOptionPaneBorder.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.optionpane; +import java.awt.*; + import javax.swing.*; import javax.swing.border.EmptyBorder; -import java.awt.*; public class DarkOptionPaneBorder extends EmptyBorder { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/optionpane/DarkOptionPaneUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/optionpane/DarkOptionPaneUI.java index 0036210a..667011b4 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/optionpane/DarkOptionPaneUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/optionpane/DarkOptionPaneUI.java @@ -20,19 +20,20 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.optionpane; -import sun.swing.DefaultLookup; +import java.awt.*; import javax.swing.*; import javax.swing.border.Border; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicOptionPaneUI; -import java.awt.*; -public class DarkOptionPaneUI extends BasicOptionPaneUI { +import sun.swing.DefaultLookup; +public class DarkOptionPaneUI extends BasicOptionPaneUI { public static ComponentUI createUI(final JComponent x) { return new DarkOptionPaneUI(); @@ -46,11 +47,13 @@ public class DarkOptionPaneUI extends BasicOptionPaneUI { if (border != null) { bottom.setBorder(border); } - bottom.setLayout(new DarkButtonAreaLayout( - DefaultLookup.getBoolean(optionPane, this, "OptionPane.sameSizeButtons", false), - DefaultLookup.getInt(optionPane, this, "OptionPane.buttonPadding", 6), - DefaultLookup.getInt(optionPane, this, "OptionPane.buttonOrientation", SwingConstants.CENTER), - DefaultLookup.getBoolean(optionPane, this, "OptionPane.isYesLast", false))); + bottom.setLayout(new DarkButtonAreaLayout(DefaultLookup.getBoolean(optionPane, this, + "OptionPane.sameSizeButtons", false), + DefaultLookup.getInt(optionPane, this, "OptionPane.buttonPadding", 6), + DefaultLookup.getInt(optionPane, this, "OptionPane.buttonOrientation", + SwingConstants.CENTER), + DefaultLookup.getBoolean(optionPane, this, "OptionPane.isYesLast", + false))); addButtonComponents(bottom, getButtons(), getInitialValueIndex()); return bottom; } @@ -163,18 +166,17 @@ public class DarkOptionPaneUI extends BasicOptionPaneUI { return orientation; } switch (orientation) { - case SwingConstants.LEFT: + case SwingConstants.LEFT : return SwingConstants.RIGHT; - case SwingConstants.RIGHT: + case SwingConstants.RIGHT : return SwingConstants.LEFT; - case SwingConstants.CENTER: + case SwingConstants.CENTER : return SwingConstants.CENTER; } return SwingConstants.LEFT; } - public void addLayoutComponent(final String string, final Component comp) { - } + public void addLayoutComponent(final String string, final Component comp) {} public void layoutContainer(final Container container) { Component[] children = container.getComponents(); @@ -208,26 +210,27 @@ public class DarkOptionPaneUI extends BasicOptionPaneUI { totalButtonWidth += (numChildren - 1) * padding; } - switch (getOrientation(container)) { - case SwingConstants.LEFT: + case SwingConstants.LEFT : x = insets.left; break; - case SwingConstants.RIGHT: + case SwingConstants.RIGHT : x = container.getWidth() - insets.right - totalButtonWidth; break; - case SwingConstants.CENTER: + case SwingConstants.CENTER : if (getCentersChildren() || numChildren < 2) { x = (container.getWidth() - totalButtonWidth) / 2; } else { x = insets.left; if (getSyncAllWidths()) { xOffset = (container.getWidth() - insets.left - - insets.right - totalButtonWidth) / + insets.right - totalButtonWidth) + / (numChildren - 1) + maxWidth; } else { xOffset = (container.getWidth() - insets.left - - insets.right - totalButtonWidth) / + insets.right - totalButtonWidth) + / (numChildren - 1); } } @@ -235,8 +238,7 @@ public class DarkOptionPaneUI extends BasicOptionPaneUI { } for (int counter = 0; counter < numChildren; counter++) { - int index = (reverse) ? numChildren - counter - 1 : - counter; + int index = (reverse) ? numChildren - counter - 1 : counter; Dimension pref = children[index].getPreferredSize(); if (getSyncAllWidths()) { @@ -297,7 +299,6 @@ public class DarkOptionPaneUI extends BasicOptionPaneUI { return minimumLayoutSize(c); } - public void removeLayoutComponent(final Component c) { - } + public void removeLayoutComponent(final Component c) {} } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/panel/DarkPanelUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/panel/DarkPanelUI.java index c9e2cf9e..794f97f9 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/panel/DarkPanelUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/panel/DarkPanelUI.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.panel; @@ -32,7 +33,6 @@ import javax.swing.plaf.basic.BasicPanelUI; */ public class DarkPanelUI extends BasicPanelUI { - public static ComponentUI createUI(final JComponent c) { return new DarkPanelUI(); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuBorder.java index 904967fe..560d2645 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuBorder.java @@ -20,15 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.popupmenu; -import com.github.weisj.darklaf.components.border.MutableLineBorder; +import java.awt.*; import javax.swing.*; import javax.swing.plaf.InsetsUIResource; import javax.swing.plaf.UIResource; -import java.awt.*; + +import com.github.weisj.darklaf.components.border.MutableLineBorder; /** * @author Jannis Weis @@ -45,7 +47,6 @@ public class DarkPopupMenuBorder extends MutableLineBorder implements UIResource super.paintBorder(c, g, x, y, width, height); } - @Override public Insets getBorderInsets(final Component c) { return new InsetsUIResource(1, 1, 1, 1); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuSeparatorUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuSeparatorUI.java index ff176466..13ee879c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuSeparatorUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuSeparatorUI.java @@ -20,26 +20,26 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.popupmenu; -import com.github.weisj.darklaf.ui.separator.DarkSeparatorUI; +import java.awt.*; import javax.swing.*; import javax.swing.plaf.ComponentUI; -import java.awt.*; + +import com.github.weisj.darklaf.ui.separator.DarkSeparatorUI; /** * @author Jannis Weis */ public class DarkPopupMenuSeparatorUI extends DarkSeparatorUI { - public static ComponentUI createUI(final JComponent c) { return new DarkPopupMenuSeparatorUI(); } - @Override public void paint(final Graphics g, final JComponent c) { Dimension s = c.getSize(); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuUI.java index e08fe6ff..a68af30d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuUI.java @@ -20,20 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.popupmenu; -import com.github.weisj.darklaf.components.OverlayScrollPane; -import com.github.weisj.darklaf.components.ScrollPopupMenu; -import com.github.weisj.darklaf.ui.DarkPopupFactory; -import com.github.weisj.darklaf.util.DarkUIUtil; -import sun.awt.SunToolkit; - -import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.basic.BasicPopupMenuUI; import java.applet.Applet; import java.awt.*; import java.awt.event.*; @@ -41,6 +31,19 @@ import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.List; +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.basic.BasicPopupMenuUI; + +import sun.awt.SunToolkit; + +import com.github.weisj.darklaf.components.OverlayScrollPane; +import com.github.weisj.darklaf.components.ScrollPopupMenu; +import com.github.weisj.darklaf.ui.DarkPopupFactory; +import com.github.weisj.darklaf.util.DarkUIUtil; + /** * This implementation for PopupMenuUI is almost identical to the one of BasicPopupMenuUI. The key difference is that it * allows components to specify HIDE_POPUP_KEY and set a property to prevent scroll events from closing a popup. This @@ -53,8 +56,7 @@ public class DarkPopupMenuUI extends BasicPopupMenuUI { public static final String KEY_DO_NOT_CANCEL_POPUP = "doNotCancelPopup"; public static final String KEY_DO_NOT_CANCEL_ON_SCROLL = "doNotCancelOnScroll"; public static final String KEY_MAKE_VISIBLE = "PopupFactory.makeVisible"; - public static final StringBufferWrapper HIDE_POPUP_VALUE = new StringBufferWrapper(new StringBuffer( - "doNotCancelPopup")); + public static final StringBufferWrapper HIDE_POPUP_VALUE = new StringBufferWrapper(new StringBuffer("doNotCancelPopup")); public static final String KEY_DEFAULT_LIGHTWEIGHT_POPUPS = "PopupMenu.defaultLightWeightPopups"; protected static MouseGrabber mouseGrabber; private PopupMenuContainer popupMenuContainer; @@ -136,7 +138,7 @@ public class DarkPopupMenuUI extends BasicPopupMenuUI { } public static class MouseGrabber implements ChangeListener, - AWTEventListener, ComponentListener, WindowListener { + AWTEventListener, ComponentListener, WindowListener { Window grabbedWindow; MenuElement[] lastPathSelected; @@ -153,27 +155,25 @@ public class DarkPopupMenuUI extends BasicPopupMenuUI { protected void grabWindow(final MenuElement[] newPath) { // A grab needs to be added final Toolkit tk = Toolkit.getDefaultToolkit(); - java.security.AccessController.doPrivileged( - (PrivilegedAction) () -> { - tk.addAWTEventListener(MouseGrabber.this, - AWTEvent.MOUSE_EVENT_MASK - | AWTEvent.MOUSE_MOTION_EVENT_MASK - | AWTEvent.MOUSE_WHEEL_EVENT_MASK - | AWTEvent.WINDOW_EVENT_MASK - | SunToolkit.GRAB_EVENT_MASK); - return null; - } - ); + java.security.AccessController.doPrivileged((PrivilegedAction) () -> { + tk.addAWTEventListener(MouseGrabber.this, + AWTEvent.MOUSE_EVENT_MASK + | AWTEvent.MOUSE_MOTION_EVENT_MASK + | AWTEvent.MOUSE_WHEEL_EVENT_MASK + | AWTEvent.WINDOW_EVENT_MASK + | SunToolkit.GRAB_EVENT_MASK); + return null; + }); Component invoker = newPath[0].getComponent(); if (invoker instanceof JPopupMenu) { invoker = ((JPopupMenu) invoker).getInvoker(); } grabbedWindow = (invoker == null) - ? null - : ((invoker instanceof Window) - ? (Window) invoker - : SwingUtilities.getWindowAncestor(invoker)); + ? null + : ((invoker instanceof Window) + ? (Window) invoker + : SwingUtilities.getWindowAncestor(invoker)); if (grabbedWindow != null) { if (tk instanceof sun.awt.SunToolkit) { ((sun.awt.SunToolkit) tk).grab(grabbedWindow); @@ -193,12 +193,10 @@ public class DarkPopupMenuUI extends BasicPopupMenuUI { protected void ungrabWindow() { final Toolkit tk = Toolkit.getDefaultToolkit(); // The grab should be removed - java.security.AccessController.doPrivileged( - (PrivilegedAction) () -> { - tk.removeAWTEventListener(MouseGrabber.this); - return null; - } - ); + java.security.AccessController.doPrivileged((PrivilegedAction) () -> { + tk.removeAWTEventListener(MouseGrabber.this); + return null; + }); realUngrabWindow(); } @@ -262,10 +260,10 @@ public class DarkPopupMenuUI extends BasicPopupMenuUI { // or inside a Popup#HeavyWeightWindow or inside a frame // popup should not close which is the standard behaviour switch (me.getID()) {/* - * Changed here: Make doNotCancelPopup accessible to all component. - * Allows for more versatile PopupMenus. - */ - case MouseEvent.MOUSE_PRESSED: + * Changed here: Make doNotCancelPopup accessible to all component. + * Allows for more versatile PopupMenus. + */ + case MouseEvent.MOUSE_PRESSED : if (isInPopup(src) || (src instanceof JMenu && ((JMenu) src).isSelected())) { return; @@ -285,7 +283,7 @@ public class DarkPopupMenuUI extends BasicPopupMenuUI { } } break; - case MouseEvent.MOUSE_RELEASED: + case MouseEvent.MOUSE_RELEASED : if (!(src instanceof MenuElement)) { // Do not forward event to MSM, let component handle it if (isInPopup(src)) { @@ -296,7 +294,7 @@ public class DarkPopupMenuUI extends BasicPopupMenuUI { MenuSelectionManager.defaultManager().processMouseEvent(me); } break; - case MouseEvent.MOUSE_DRAGGED: + case MouseEvent.MOUSE_DRAGGED : if (!(src instanceof MenuElement)) { // For the MOUSE_DRAGGED event the src is // the Component in which mouse button was pressed. @@ -308,7 +306,7 @@ public class DarkPopupMenuUI extends BasicPopupMenuUI { } MenuSelectionManager.defaultManager().processMouseEvent(me); break; - case MouseEvent.MOUSE_WHEEL: + case MouseEvent.MOUSE_WHEEL : if (isInPopup(src) || ((src instanceof JComboBox) && ((JComboBox) src).isPopupVisible()) || ((src instanceof JWindow) && src.isVisible()) @@ -374,8 +372,7 @@ public class DarkPopupMenuUI extends BasicPopupMenuUI { cancelPopupMenu(); } - public void windowOpened(final WindowEvent e) { - } + public void windowOpened(final WindowEvent e) {} public void windowClosing(final WindowEvent e) { cancelPopupMenu(); @@ -389,11 +386,9 @@ public class DarkPopupMenuUI extends BasicPopupMenuUI { cancelPopupMenu(); } - public void windowDeiconified(final WindowEvent e) { - } + public void windowDeiconified(final WindowEvent e) {} - public void windowActivated(final WindowEvent e) { - } + public void windowActivated(final WindowEvent e) {} public void windowDeactivated(final WindowEvent e) { cancelPopupMenu(); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/PopupMenuContainer.java b/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/PopupMenuContainer.java index 8ec74c72..eb1d2d03 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/PopupMenuContainer.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/PopupMenuContainer.java @@ -20,27 +20,29 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.popupmenu; -import com.github.weisj.darklaf.components.OverlayScrollPane; -import com.github.weisj.darklaf.decorators.PopupMenuAdapter; -import com.github.weisj.darklaf.ui.scrollpane.DarkScrollBarUI; -import com.github.weisj.darklaf.util.DarkUIUtil; +import java.awt.*; import javax.swing.*; import javax.swing.event.MenuKeyEvent; import javax.swing.event.MenuKeyListener; import javax.swing.event.PopupMenuEvent; import javax.swing.event.PopupMenuListener; -import java.awt.*; + +import com.github.weisj.darklaf.components.OverlayScrollPane; +import com.github.weisj.darklaf.decorators.PopupMenuAdapter; +import com.github.weisj.darklaf.ui.scrollpane.DarkScrollBarUI; +import com.github.weisj.darklaf.util.DarkUIUtil; public class PopupMenuContainer extends JPanel { private final JScrollPane scrollPane; private final MenuKeyListener menuKeyListener; private final PopupMenuListener menuListener; - private JPanel view; + private final JPanel view; private JPopupMenu popupMenu; public PopupMenuContainer() { @@ -51,8 +53,7 @@ public class PopupMenuContainer extends JPanel { add(overlayScrollPane, BorderLayout.CENTER); menuKeyListener = new MenuKeyListener() { @Override - public void menuKeyTyped(final MenuKeyEvent e) { - } + public void menuKeyTyped(final MenuKeyEvent e) {} @Override public void menuKeyPressed(final MenuKeyEvent e) { @@ -69,8 +70,7 @@ public class PopupMenuContainer extends JPanel { } @Override - public void menuKeyReleased(final MenuKeyEvent e) { - } + public void menuKeyReleased(final MenuKeyEvent e) {} }; menuListener = new PopupMenuAdapter() { @Override @@ -108,8 +108,11 @@ public class PopupMenuContainer extends JPanel { return PopupFactory.getSharedInstance().getPopup(popupMenu.getInvoker(), popupMenu, posX, posY); } else { int increment = popupMenu.getComponentCount() > 0 - ? Math.max(1, popupMenu.getComponent(0).getPreferredSize().height / 2) - : 1; + ? Math.max(1, + popupMenu.getComponent(0) + .getPreferredSize().height + / 2) + : 1; JScrollBar bar = scrollPane.getVerticalScrollBar(); bar.setValue(bar.getMinimum()); bar.setUnitIncrement(increment); @@ -123,9 +126,8 @@ public class PopupMenuContainer extends JPanel { } private OverlayScrollPane createScrollPane(final JComponent content) { - OverlayScrollPane overlayScrollPane = - new OverlayScrollPane(content, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, - JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + OverlayScrollPane overlayScrollPane = new OverlayScrollPane(content, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); JScrollBar bar = overlayScrollPane.getVerticalScrollBar(); bar.putClientProperty(DarkScrollBarUI.KEY_SMALL, Boolean.TRUE); DarkUIUtil.doNotCancelPopupSetup(bar); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/progressbar/DarkProgressBarBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/progressbar/DarkProgressBarBorder.java index 0872d067..3d2863c3 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/progressbar/DarkProgressBarBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/progressbar/DarkProgressBarBorder.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.progressbar; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/progressbar/DarkProgressBarUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/progressbar/DarkProgressBarUI.java index b495ec9b..f89c3581 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/progressbar/DarkProgressBarUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/progressbar/DarkProgressBarUI.java @@ -20,17 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.progressbar; -import com.github.weisj.darklaf.util.DarkUIUtil; -import com.github.weisj.darklaf.util.GraphicsContext; -import com.github.weisj.darklaf.util.GraphicsUtil; -import com.github.weisj.darklaf.util.PropertyKey; - -import javax.swing.*; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.basic.BasicProgressBarUI; import java.awt.*; import java.awt.geom.AffineTransform; import java.awt.geom.Rectangle2D; @@ -38,6 +31,15 @@ import java.awt.geom.RoundRectangle2D; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import javax.swing.*; +import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.basic.BasicProgressBarUI; + +import com.github.weisj.darklaf.util.DarkUIUtil; +import com.github.weisj.darklaf.util.GraphicsContext; +import com.github.weisj.darklaf.util.GraphicsUtil; +import com.github.weisj.darklaf.util.PropertyKey; + /** * @author Konstantin Bulenkov * @author Jannis Weis @@ -62,7 +64,6 @@ public class DarkProgressBarUI extends BasicProgressBarUI implements PropertyCha private Color passedEndColor; private int stripeWidth; - public static ComponentUI createUI(final JComponent c) { return new DarkProgressBarUI(); } @@ -204,7 +205,6 @@ public class DarkProgressBarUI extends BasicProgressBarUI implements PropertyCha return indeterminateEndColor; } - private Shape getShapedRect(final float x, final float y, final float w, final float h, final float ar) { return new RoundRectangle2D.Float(x, y, w, h, ar, ar); } @@ -332,7 +332,6 @@ public class DarkProgressBarUI extends BasicProgressBarUI implements PropertyCha return stripeWidth; } - private static boolean isSimplified() { return UIManager.getBoolean("ProgressBar.isSimplified"); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkRootPaneBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkRootPaneBorder.java index 8fcdbd14..600ace01 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkRootPaneBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkRootPaneBorder.java @@ -20,15 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.rootpane; -import com.github.weisj.darklaf.components.border.MutableLineBorder; -import com.github.weisj.darklaf.platform.DecorationsHandler; - import javax.swing.*; import javax.swing.plaf.UIResource; +import com.github.weisj.darklaf.components.border.MutableLineBorder; +import com.github.weisj.darklaf.platform.DecorationsHandler; + public class DarkRootPaneBorder extends MutableLineBorder implements UIResource { public DarkRootPaneBorder() { @@ -38,6 +39,6 @@ public class DarkRootPaneBorder extends MutableLineBorder implements UIResource @Override public int getTop() { return DecorationsHandler.getSharedInstance().isCustomDecorationSupported() - ? super.getTop() : 0; + ? super.getTop() : 0; } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkRootPaneUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkRootPaneUI.java index 105430d5..03a8ce91 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkRootPaneUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkRootPaneUI.java @@ -20,18 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ - package com.github.weisj.darklaf.ui.rootpane; -import com.github.weisj.darklaf.platform.DecorationsHandler; -import com.github.weisj.darklaf.platform.decorations.CustomTitlePane; -import com.github.weisj.darklaf.util.DarkUIUtil; -import com.github.weisj.darklaf.util.PropertyKey; - -import javax.swing.*; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.basic.BasicRootPaneUI; import java.awt.*; import java.awt.event.HierarchyEvent; import java.awt.event.HierarchyListener; @@ -39,6 +31,14 @@ import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.beans.PropertyChangeEvent; +import javax.swing.*; +import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.basic.BasicRootPaneUI; + +import com.github.weisj.darklaf.platform.DecorationsHandler; +import com.github.weisj.darklaf.platform.decorations.CustomTitlePane; +import com.github.weisj.darklaf.util.DarkUIUtil; +import com.github.weisj.darklaf.util.PropertyKey; /** * @author Konstantin Bulenkov @@ -50,11 +50,14 @@ public class DarkRootPaneUI extends BasicRootPaneUI implements HierarchyListener public static final String KEY_NO_DECORATIONS_UPDATE = KEY_PREFIX + "noDecorationsUpdate"; public static final String KEY_NO_DECORATIONS = KEY_PREFIX + "noDecorations"; protected static final String[] borderKeys = new String[]{ - "RootPane.border", "RootPane.frameBorder", "RootPane.plainDialogBorder", - "RootPane.informationDialogBorder", - "RootPane.errorDialogBorder", "RootPane.colorChooserDialogBorder", - "RootPane.fileChooserDialogBorder", "RootPane.questionDialogBorder", - "RootPane.warningDialogBorder" + "RootPane.border", "RootPane.frameBorder", + "RootPane.plainDialogBorder", + "RootPane.informationDialogBorder", + "RootPane.errorDialogBorder", + "RootPane.colorChooserDialogBorder", + "RootPane.fileChooserDialogBorder", + "RootPane.questionDialogBorder", + "RootPane.warningDialogBorder" }; private Window window; @@ -67,7 +70,6 @@ public class DarkRootPaneUI extends BasicRootPaneUI implements HierarchyListener private boolean decorationStyleLock = false; private int windowDecorationsStyle = -1; - public static ComponentUI createUI(final JComponent comp) { return new DarkRootPaneUI(); } @@ -178,7 +180,6 @@ public class DarkRootPaneUI extends BasicRootPaneUI implements HierarchyListener } } - private void setTitlePane(final JRootPane root, final CustomTitlePane titlePane) { JLayeredPane layeredPane = root.getLayeredPane(); JComponent oldTitlePane = getTitlePane(); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkSubstanceRootLayout.java b/core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkSubstanceRootLayout.java index dc80f425..d3461df6 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkSubstanceRootLayout.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkSubstanceRootLayout.java @@ -20,14 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.rootpane; -import com.github.weisj.darklaf.platform.decorations.CustomTitlePane; +import java.awt.*; import javax.swing.*; -import java.awt.*; +import com.github.weisj.darklaf.platform.decorations.CustomTitlePane; /** * @author Konstantin Bulenkov @@ -36,15 +37,12 @@ import java.awt.*; class DarkSubstanceRootLayout implements LayoutManager2 { @Override - public void addLayoutComponent(final String name, final Component comp) { - } + public void addLayoutComponent(final String name, final Component comp) {} @Override - public void removeLayoutComponent(final Component comp) { - } + public void removeLayoutComponent(final Component comp) {} - public void addLayoutComponent(final Component comp, final Object constraints) { - } + public void addLayoutComponent(final Component comp, final Object constraints) {} public Dimension preferredLayoutSize(final Container parent) { Dimension cpd, mbd, tpd; @@ -128,7 +126,7 @@ class DarkSubstanceRootLayout implements LayoutManager2 { if ((root.getWindowDecorationStyle() != JRootPane.NONE) && (root.getUI() instanceof DarkRootPaneUI)) { JComponent titlePane = ((DarkRootPaneUI) root.getUI()) - .getTitlePane(); + .getTitlePane(); if (titlePane != null) { tpd = titlePane.getMinimumSize(); if (tpd != null) { @@ -139,7 +137,8 @@ class DarkSubstanceRootLayout implements LayoutManager2 { } return new Dimension(Math.max(Math.max(cpWidth, mbWidth), tpWidth) - + i.left + i.right, cpHeight + mbHeight + tpHeight + i.top + + i.left + i.right, + cpHeight + mbHeight + tpHeight + i.top + i.bottom); } @@ -214,7 +213,7 @@ class DarkSubstanceRootLayout implements LayoutManager2 { if ((root.getWindowDecorationStyle() != JRootPane.NONE) && (root.getUI() instanceof DarkRootPaneUI)) { JComponent titlePane = ((DarkRootPaneUI) root.getUI()) - .getTitlePane(); + .getTitlePane(); if (titlePane != null) { tpd = titlePane.getMaximumSize(); if (tpd != null) { @@ -246,6 +245,5 @@ class DarkSubstanceRootLayout implements LayoutManager2 { return 0.0f; } - public void invalidateLayout(final Container target) { - } + public void invalidateLayout(final Container target) {} } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarListener.java b/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarListener.java index 81bbac1a..0e4f3616 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarListener.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarListener.java @@ -20,15 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.scrollpane; -import com.github.weisj.darklaf.util.Animator; - -import javax.swing.*; import java.awt.*; import java.awt.event.*; +import javax.swing.*; + +import com.github.weisj.darklaf.util.Animator; + public class DarkScrollBarListener extends MouseAdapter implements AdjustmentListener, ScrollBarConstants { private static final float THUMB_ALPHA = 0.6f; @@ -204,17 +206,14 @@ public class DarkScrollBarListener extends MouseAdapter implements AdjustmentLis return new TrackFadeOutAnimator(); } - protected Animator createThumbFadeoutAnimator() { return new ThumbFadeOutAnimator(); } - protected Animator createTrackFadeinAnimator() { return new TrackFadeInAnimator(); } - protected Animator createThumbFadeinAnimator() { return new ThumbFadeInAnimator(); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarUI.java index f7e76c1c..ff73cbd8 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarUI.java @@ -20,16 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.scrollpane; -import com.github.weisj.darklaf.util.DarkUIUtil; +import java.awt.*; import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicScrollBarUI; -import java.awt.*; + +import com.github.weisj.darklaf.util.DarkUIUtil; /** * @author Konstantin Bulenkov @@ -169,7 +171,6 @@ public class DarkScrollBarUI extends BasicScrollBarUI implements ScrollBarConsta return true; } - protected Color getTrackColor() { return trackBackground; } @@ -214,7 +215,7 @@ public class DarkScrollBarUI extends BasicScrollBarUI implements ScrollBarConsta try { super.layoutContainer(scrollbarContainer); } catch (NullPointerException ignore) { - //installUI is not performed yet or uninstallUI has set almost every field to null. + // installUI is not performed yet or uninstallUI has set almost every field to null. } } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollPaneUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollPaneUI.java index 1d31ca03..4df9ecf2 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollPaneUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollPaneUI.java @@ -20,16 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.scrollpane; -import javax.swing.*; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.basic.BasicScrollPaneUI; import java.awt.*; import java.awt.event.MouseWheelListener; import java.beans.PropertyChangeListener; +import javax.swing.*; +import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.basic.BasicScrollPaneUI; + /** * @author Jannis Weis */ @@ -95,7 +97,6 @@ public class DarkScrollPaneUI extends BasicScrollPaneUI { }; private ScrollPaneLayout oldLayout; - public static ComponentUI createUI(final JComponent c) { return new DarkScrollPaneUI(); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/EmptyButton.java b/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/EmptyButton.java index 05327935..e130c9c0 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/EmptyButton.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/EmptyButton.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.scrollpane; +import java.awt.*; + import javax.swing.*; import javax.swing.plaf.UIResource; -import java.awt.*; public class EmptyButton extends JButton implements UIResource { public EmptyButton() { @@ -38,13 +40,11 @@ public class EmptyButton extends JButton implements UIResource { return getMaximumSize(); } - @Override public Dimension getMaximumSize() { return new Dimension(0, 0); } - @Override public Dimension getMinimumSize() { return getMaximumSize(); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/ScrollBarConstants.java b/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/ScrollBarConstants.java index 56d2bdf1..9295a393 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/ScrollBarConstants.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/ScrollBarConstants.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.scrollpane; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/ScrollBarUtil.java b/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/ScrollBarUtil.java index 8726c3db..9bb3d00c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/ScrollBarUtil.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/ScrollBarUtil.java @@ -20,13 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.scrollpane; -import javax.swing.*; import java.awt.*; import java.awt.event.MouseWheelEvent; +import javax.swing.*; + public class ScrollBarUtil implements ScrollBarConstants { @SuppressWarnings("MagicConstant") diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/ScrollLayoutManagerDelegate.java b/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/ScrollLayoutManagerDelegate.java index 755632d4..d03fee29 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/ScrollLayoutManagerDelegate.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/ScrollLayoutManagerDelegate.java @@ -20,19 +20,20 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.scrollpane; -import javax.swing.*; import java.awt.*; +import javax.swing.*; + /** * @author Jannis Weis */ public class ScrollLayoutManagerDelegate extends ScrollPaneLayout { private final ScrollPaneLayout delegate; - public ScrollLayoutManagerDelegate(final ScrollPaneLayout delegate) { if (delegate == null) { throw new IllegalArgumentException("Delegate is null"); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/separator/DarkSeparatorUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/separator/DarkSeparatorUI.java index c3efb409..451eeddd 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/separator/DarkSeparatorUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/separator/DarkSeparatorUI.java @@ -20,13 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.separator; +import java.awt.*; + import javax.swing.*; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicSeparatorUI; -import java.awt.*; /** * @author Jannis Weis diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/slider/DarkSliderUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/slider/DarkSliderUI.java index 343cd5f2..765a2cd4 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/slider/DarkSliderUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/slider/DarkSliderUI.java @@ -20,18 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.slider; -import com.github.weisj.darklaf.decorators.MouseClickListener; -import com.github.weisj.darklaf.util.DarkUIUtil; -import com.github.weisj.darklaf.util.GraphicsContext; -import com.github.weisj.darklaf.util.GraphicsUtil; -import com.github.weisj.darklaf.util.PropertyKey; - -import javax.swing.*; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.basic.BasicSliderUI; import java.awt.*; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; @@ -40,6 +32,16 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Dictionary; +import javax.swing.*; +import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.basic.BasicSliderUI; + +import com.github.weisj.darklaf.decorators.MouseClickListener; +import com.github.weisj.darklaf.util.DarkUIUtil; +import com.github.weisj.darklaf.util.GraphicsContext; +import com.github.weisj.darklaf.util.GraphicsUtil; +import com.github.weisj.darklaf.util.PropertyKey; + /** * @author Jannis Weis */ @@ -107,7 +109,6 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene super(b); } - public static ComponentUI createUI(final JComponent c) { return new DarkSliderUI((JSlider) c); } @@ -218,8 +219,7 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene */ public void scrollByBlock(final int direction) { synchronized (slider) { - int blockIncrement = - (slider.getMaximum() - slider.getMinimum()) / 10; + int blockIncrement = (slider.getMaximum() - slider.getMinimum()) / 10; if (blockIncrement == 0) { blockIncrement = 1; } @@ -340,8 +340,8 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene return new Dimension(plainThumbRadius + 6, plainThumbRadius + 6); } return isHorizontal() - ? new Dimension(thumbSize.width, thumbSize.height) - : new Dimension(thumbSize.height, thumbSize.width); + ? new Dimension(thumbSize.width, thumbSize.height) + : new Dimension(thumbSize.height, thumbSize.width); } @Override @@ -354,7 +354,7 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene @Override public void paintFocus(final Graphics g2) { - //Do nothing + // Do nothing } @Override @@ -436,7 +436,6 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene super.paintVerticalLabel(g, value, label); } - @Override public void paintThumb(final Graphics g2) { Graphics2D g = (Graphics2D) g2; @@ -475,7 +474,6 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene } } - protected Color getDisabledTickColor() { return inactiveTickForeground; } @@ -583,17 +581,15 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene return slider.getOrientation() == JSlider.HORIZONTAL; } - private Area getHorizontalTrackShape() { int arc = arcSize; int yOff = (trackRect.height / 2) - trackSize / 2; int w = showVolumeIcon(slider) ? trackRect.width + getIconBarExt() : trackRect.width; if (slider.getComponentOrientation().isLeftToRight()) { - return new Area(new RoundRectangle2D.Double( - trackRect.x, trackRect.y + yOff, w, trackSize, arc, arc)); + return new Area(new RoundRectangle2D.Double(trackRect.x, trackRect.y + yOff, w, trackSize, arc, arc)); } else { - return new Area(new RoundRectangle2D.Double( - trackRect.x - getIconBarExt(), trackRect.y + yOff, w, trackSize, arc, arc)); + return new Area(new RoundRectangle2D.Double(trackRect.x - getIconBarExt(), trackRect.y + yOff, w, trackSize, + arc, arc)); } } @@ -607,17 +603,15 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene return track; } - private Area getVerticalTrackShape() { int arc = arcSize; int xOff = (trackRect.width / 2) - trackSize / 2; int h = showVolumeIcon(slider) ? trackRect.height + getIconBarExt() : trackRect.height; if (slider.getComponentOrientation().isLeftToRight()) { - return new Area(new RoundRectangle2D.Double( - trackRect.x + xOff, trackRect.y, trackSize, h, arc, arc)); + return new Area(new RoundRectangle2D.Double(trackRect.x + xOff, trackRect.y, trackSize, h, arc, arc)); } else { - return new Area(new RoundRectangle2D.Double( - trackRect.x + xOff, trackRect.y - getIconBarExt(), trackSize, h, arc, arc)); + return new Area(new RoundRectangle2D.Double(trackRect.x + xOff, trackRect.y - getIconBarExt(), trackSize, h, + arc, arc)); } } @@ -692,7 +686,6 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene } } - private Path2D getHorizontalThumbShape() { int w = thumbRect.width; int h = thumbRect.height; @@ -707,7 +700,6 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene return shape; } - private Path2D getVerticalThumbShapeLR() { int w = thumbRect.width; int h = thumbRect.height; @@ -722,7 +714,6 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene return shape; } - private Path2D getVerticalThumbShapeRL() { int w = thumbRect.width; int h = thumbRect.height; @@ -737,7 +728,6 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene return shape; } - protected Color getThumbColor() { if (isVolumeSlider(slider)) { return slider.isEnabled() ? volumeThumbBackground : volumeThumbInactiveBackground; @@ -746,17 +736,14 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene } } - protected Color getThumbBorderColor() { return slider.isEnabled() ? thumbBorderColor : thumbInactiveBorderColor; } - protected Color getTrackBackground() { return trackBackground; } - protected Color getSelectedTrackColor() { if (isVolumeSlider(slider)) { return slider.isEnabled() ? selectedVolumeTrackBackground : selectedVolumeTrackInactiveBackground; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerBorder.java index 5f49d1f0..898cc621 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerBorder.java @@ -20,18 +20,20 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.spinner; -import com.github.weisj.darklaf.ui.cell.CellUtil; -import com.github.weisj.darklaf.util.DarkUIUtil; -import com.github.weisj.darklaf.util.GraphicsContext; +import java.awt.*; import javax.swing.*; import javax.swing.border.Border; import javax.swing.plaf.InsetsUIResource; import javax.swing.plaf.UIResource; -import java.awt.*; + +import com.github.weisj.darklaf.ui.cell.CellUtil; +import com.github.weisj.darklaf.util.DarkUIUtil; +import com.github.weisj.darklaf.util.GraphicsContext; /** * @author Konstantin Bulenkov @@ -76,8 +78,8 @@ public class DarkSpinnerBorder implements Border, UIResource { JComponent editor = spinner.getEditor(); if (editor != null) { int off = spinner.getComponentOrientation().isLeftToRight() - ? editor.getBounds().x + editor.getWidth() - : editor.getBounds().x - 1 - borderSize; + ? editor.getBounds().x + editor.getWidth() + : editor.getBounds().x - 1 - borderSize; g.setColor(getBorderColor(spinner)); if (!treeCellEditor) { g.fillRect(off, size, 1, height - 2 * size); @@ -116,7 +118,8 @@ public class DarkSpinnerBorder implements Border, UIResource { public Insets getBorderInsets(final Component c) { if (SpinnerConstants.isTreeOrTableCellEditor(c)) { return CellUtil.adjustEditorInsets(new InsetsUIResource(cellInsets.top, cellInsets.left, - cellInsets.bottom, cellInsets.right), c); + cellInsets.bottom, cellInsets.right), + c); } return new InsetsUIResource(insets.top, insets.left, insets.bottom, insets.right); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerListener.java b/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerListener.java index 75d153e8..fd621c8b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerListener.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerListener.java @@ -20,12 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.spinner; -import com.github.weisj.darklaf.util.PropertyKey; - -import javax.swing.*; import java.awt.*; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; @@ -34,8 +32,12 @@ import java.awt.event.MouseEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import javax.swing.*; + +import com.github.weisj.darklaf.util.PropertyKey; + public class DarkSpinnerListener extends MouseAdapter implements PropertyChangeListener, FocusListener, - SpinnerConstants { + SpinnerConstants { protected final JSpinner spinner; protected final DarkSpinnerUI ui; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerUI.java index 3011ad44..902a7db0 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerUI.java @@ -20,13 +20,13 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.spinner; -import com.github.weisj.darklaf.components.ArrowButton; -import com.github.weisj.darklaf.decorators.LayoutManagerDelegate; -import com.github.weisj.darklaf.util.DarkUIUtil; -import com.github.weisj.darklaf.util.PropertyKey; +import java.awt.*; +import java.awt.geom.Area; +import java.awt.geom.RoundRectangle2D; import javax.swing.*; import javax.swing.border.Border; @@ -35,9 +35,11 @@ import javax.swing.border.EmptyBorder; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.UIResource; import javax.swing.plaf.basic.BasicSpinnerUI; -import java.awt.*; -import java.awt.geom.Area; -import java.awt.geom.RoundRectangle2D; + +import com.github.weisj.darklaf.components.ArrowButton; +import com.github.weisj.darklaf.decorators.LayoutManagerDelegate; +import com.github.weisj.darklaf.util.DarkUIUtil; +import com.github.weisj.darklaf.util.PropertyKey; /** * @author Konstantin Bulenkov @@ -65,7 +67,6 @@ public class DarkSpinnerUI extends BasicSpinnerUI implements SpinnerConstants { private Component editorComponent; private JButton nextButton; - public static ComponentUI createUI(final JComponent c) { return new DarkSpinnerUI(); } @@ -197,7 +198,6 @@ public class DarkSpinnerUI extends BasicSpinnerUI implements SpinnerConstants { } } - private JButton createArrow(final int direction) { int buttonPad = UIManager.getInt("Spinner.buttonPad"); Insets insets = new Insets(0, buttonPad, 0, buttonPad); @@ -270,7 +270,6 @@ public class DarkSpinnerUI extends BasicSpinnerUI implements SpinnerConstants { } } - protected void paintSpinBackground(final Graphics2D g, final int width, final int height, final int bSize, final int arc) { Rectangle bounds = prevButton.getBounds(); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/spinner/SpinnerConstants.java b/core/src/main/java/com/github/weisj/darklaf/ui/spinner/SpinnerConstants.java index 827b9897..9ff1f740 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/spinner/SpinnerConstants.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/spinner/SpinnerConstants.java @@ -20,14 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.spinner; -import com.github.weisj.darklaf.ui.table.DarkTableUI; -import com.github.weisj.darklaf.ui.tree.DarkTreeUI; +import java.awt.*; import javax.swing.*; -import java.awt.*; + +import com.github.weisj.darklaf.ui.table.DarkTableUI; +import com.github.weisj.darklaf.ui.tree.DarkTreeUI; public interface SpinnerConstants { String KEY_VARIANT = "JSpinner.variant"; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/spinner/SpinnerIcon.java b/core/src/main/java/com/github/weisj/darklaf/ui/spinner/SpinnerIcon.java index cb631ad0..a7cad4c7 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/spinner/SpinnerIcon.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/spinner/SpinnerIcon.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.spinner; -import javax.swing.*; import java.awt.*; +import javax.swing.*; + public class SpinnerIcon implements Icon { private final JSpinner spinner; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DarkSplitPaneBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DarkSplitPaneBorder.java index 1b279327..3ea4bf3c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DarkSplitPaneBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DarkSplitPaneBorder.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.splitpane; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DarkSplitPaneDivider.java b/core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DarkSplitPaneDivider.java index 75e1c273..4da5bdd5 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DarkSplitPaneDivider.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DarkSplitPaneDivider.java @@ -20,17 +20,19 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.splitpane; -import com.github.weisj.darklaf.icons.EmptyIcon; -import com.github.weisj.darklaf.ui.button.DarkButtonUI; +import java.awt.*; import javax.swing.*; import javax.swing.plaf.UIResource; import javax.swing.plaf.basic.BasicSplitPaneDivider; import javax.swing.plaf.basic.BasicSplitPaneUI; -import java.awt.*; + +import com.github.weisj.darklaf.icons.EmptyIcon; +import com.github.weisj.darklaf.ui.button.DarkButtonUI; /** * @author Jannis Weis @@ -56,7 +58,6 @@ public class DarkSplitPaneDivider extends BasicSplitPaneDivider { borderColor = UIManager.getColor("SplitPane.dividerLineColor"); } - @Override public void paint(final Graphics g) { super.paint(g); @@ -121,7 +122,6 @@ public class DarkSplitPaneDivider extends BasicSplitPaneDivider { setFocusPainted(false); } - @SuppressWarnings("deprecation") public boolean isFocusTraversable() { return false; @@ -143,7 +143,8 @@ public class DarkSplitPaneDivider extends BasicSplitPaneDivider { public Icon getIcon() { if (splitPane != null) { return splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT - ? getRightOneTouchIcon() : getBottomOneTouchIcon(); + ? getRightOneTouchIcon() + : getBottomOneTouchIcon(); } return EmptyIcon.create(0); } @@ -154,7 +155,8 @@ public class DarkSplitPaneDivider extends BasicSplitPaneDivider { public Icon getIcon() { if (splitPane != null) { return splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT - ? getLeftOneTouchIcon() : getTopOneTouchIcon(); + ? getLeftOneTouchIcon() + : getTopOneTouchIcon(); } return EmptyIcon.create(0); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DarkSplitPaneDividerBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DarkSplitPaneDividerBorder.java index bfa5e148..de6111ad 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DarkSplitPaneDividerBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DarkSplitPaneDividerBorder.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.splitpane; +import java.awt.*; + import javax.swing.border.Border; import javax.swing.plaf.UIResource; -import java.awt.*; /** * @author Jannis Weis @@ -34,8 +36,7 @@ public class DarkSplitPaneDividerBorder implements Border, UIResource { @Override public void paintBorder(final Component c, final Graphics g, final int x, final int y, - final int width, final int height) { - } + final int width, final int height) {} @Override public Insets getBorderInsets(final Component c) { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DarkSplitPaneUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DarkSplitPaneUI.java index 63510a62..eff1c892 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DarkSplitPaneUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DarkSplitPaneUI.java @@ -20,19 +20,21 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.splitpane; -import com.github.weisj.darklaf.decorators.LayoutManagerDelegate; -import com.github.weisj.darklaf.util.PropertyKey; +import java.awt.*; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; import javax.swing.*; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicSplitPaneDivider; import javax.swing.plaf.basic.BasicSplitPaneUI; -import java.awt.*; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; + +import com.github.weisj.darklaf.decorators.LayoutManagerDelegate; +import com.github.weisj.darklaf.util.PropertyKey; /** * @author Jannis Weis @@ -54,7 +56,6 @@ public class DarkSplitPaneUI extends BasicSplitPaneUI implements PropertyChangeL this.style = style; } - public static ComponentUI createUI(final JComponent c) { return new DarkSplitPaneUI(Style.get(UIManager.getString("SplitPane.defaultDividerStyle"))); } @@ -164,7 +165,6 @@ public class DarkSplitPaneUI extends BasicSplitPaneUI implements PropertyChangeL final private String name; - Style(final String name) { this.name = name; } @@ -180,8 +180,7 @@ public class DarkSplitPaneUI extends BasicSplitPaneUI implements PropertyChangeL if (obj instanceof Style) return (Style) obj; try { return valueOf(obj.toString()); - } catch (IllegalArgumentException ignored) { - } + } catch (IllegalArgumentException ignored) {} for (Style s : values()) { if (s.name.equalsIgnoreCase(obj.toString())) return s; } @@ -195,7 +194,6 @@ public class DarkSplitPaneUI extends BasicSplitPaneUI implements PropertyChangeL super(ui); } - @Override public int getDividerSize() { return style == Style.LINE ? 1 : 0; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/statusbar/DarkStatusBarUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/statusbar/DarkStatusBarUI.java index c8312e2f..e52cdd4c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/statusbar/DarkStatusBarUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/statusbar/DarkStatusBarUI.java @@ -20,26 +20,26 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.statusbar; -import org.jdesktop.swingx.JXStatusBar; -import org.jdesktop.swingx.plaf.basic.BasicStatusBarUI; +import java.awt.*; import javax.swing.*; import javax.swing.plaf.ComponentUI; -import java.awt.*; + +import org.jdesktop.swingx.JXStatusBar; +import org.jdesktop.swingx.plaf.basic.BasicStatusBarUI; /** * @author Jannis Weis */ public class DarkStatusBarUI extends BasicStatusBarUI { - protected Color background; protected Color borderColor; - public static ComponentUI createUI(final JComponent c) { return new DarkStatusBarUI(); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkHandler.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkHandler.java index 819bd3a9..b3fcf040 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkHandler.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkHandler.java @@ -20,18 +20,20 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabbedpane; -import com.github.weisj.darklaf.util.PropertyKey; - -import javax.swing.*; -import javax.swing.event.ChangeEvent; import java.awt.*; import java.awt.dnd.DropTarget; import java.awt.event.MouseEvent; import java.beans.PropertyChangeEvent; +import javax.swing.*; +import javax.swing.event.ChangeEvent; + +import com.github.weisj.darklaf.util.PropertyKey; + public class DarkHandler extends TabbedPaneHandler { protected final DarkTabbedPaneUI ui; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkScrollHandler.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkScrollHandler.java index fbdab7e7..f6efa8eb 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkScrollHandler.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkScrollHandler.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabbedpane; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkScrollableTabPanel.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkScrollableTabPanel.java index 818a1cfc..51f65fcf 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkScrollableTabPanel.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkScrollableTabPanel.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabbedpane; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkScrollableTabSupport.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkScrollableTabSupport.java index 7e310634..bc3316d5 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkScrollableTabSupport.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkScrollableTabSupport.java @@ -20,21 +20,23 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabbedpane; -import com.github.weisj.darklaf.components.ScrollPopupMenu; -import com.github.weisj.darklaf.decorators.PopupMenuAdapter; - -import javax.swing.*; -import javax.swing.event.PopupMenuEvent; -import javax.swing.event.PopupMenuListener; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseWheelEvent; import java.awt.event.MouseWheelListener; +import javax.swing.*; +import javax.swing.event.PopupMenuEvent; +import javax.swing.event.PopupMenuListener; + +import com.github.weisj.darklaf.components.ScrollPopupMenu; +import com.github.weisj.darklaf.decorators.PopupMenuAdapter; + public class DarkScrollableTabSupport extends ScrollableTabSupport implements MouseWheelListener, ActionListener { protected static final int SCROLL_REWIND_DELAY = 1200; @@ -59,8 +61,7 @@ public class DarkScrollableTabSupport extends ScrollableTabSupport implements Mo moreTabsButton.addActionListener(this); newTabButton = ui.createNewTabButton(); - newTabButton.setVisible( - Boolean.TRUE.equals(ui.tabPane.getClientProperty(DarkTabbedPaneUI.KEY_SHOW_NEW_TAB_BUTTON))); + newTabButton.setVisible(Boolean.TRUE.equals(ui.tabPane.getClientProperty(DarkTabbedPaneUI.KEY_SHOW_NEW_TAB_BUTTON))); scrollPopupMenu = new ScrollPopupMenu(UIManager.getInt(DarkTabbedPaneUI.KEY_MAX_POPUP_HEIGHT)); PopupMenuListener popupMenuListener = new PopupMenuAdapter() { @@ -102,15 +103,15 @@ public class DarkScrollableTabSupport extends ScrollableTabSupport implements Mo Dimension pref = scrollPopupMenu.getPreferredSize(); boolean leftToRight = ui.tabPane.getComponentOrientation().isLeftToRight(); switch (ui.tabPane.getTabPlacement()) { - case SwingConstants.LEFT: + case SwingConstants.LEFT : scrollPopupMenu.show(moreTabsButton, moreTabsButton.getWidth(), moreTabsButton.getHeight() - pref.height); break; - case SwingConstants.RIGHT: + case SwingConstants.RIGHT : scrollPopupMenu.show(moreTabsButton, -pref.width, moreTabsButton.getHeight() - pref.height); break; - case SwingConstants.TOP: + case SwingConstants.TOP : if (leftToRight) { scrollPopupMenu.show(moreTabsButton, moreTabsButton.getWidth() - pref.width, moreTabsButton.getHeight()); @@ -118,7 +119,7 @@ public class DarkScrollableTabSupport extends ScrollableTabSupport implements Mo scrollPopupMenu.show(moreTabsButton, 0, moreTabsButton.getHeight()); } break; - case SwingConstants.BOTTOM: + case SwingConstants.BOTTOM : if (leftToRight) { scrollPopupMenu.show(moreTabsButton, moreTabsButton.getWidth() - pref.width, -pref.height); @@ -219,7 +220,6 @@ public class DarkScrollableTabSupport extends ScrollableTabSupport implements Mo moreTabsButton.repaint(); } - protected JMenuItem createMenuItem(final int i) { Icon icon = ui.tabPane.getIconAt(i); if (icon != null && !ui.tabPane.getComponentAt(i).isEnabled()) { @@ -230,8 +230,8 @@ public class DarkScrollableTabSupport extends ScrollableTabSupport implements Mo @Override public void actionPerformed(final ActionEvent e) { if (i >= 0 && i <= ui.tabPane.getTabCount()) { - //Use component instead of index as index may have changed in between creation - //and invocation of action. + // Use component instead of index as index may have changed in between creation + // and invocation of action. ui.tabPane.setSelectedComponent(comp); ui.tabPane.doLayout(); comp.requestFocus(); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkScrollableTabViewport.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkScrollableTabViewport.java index eedc22ae..cdb2797b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkScrollableTabViewport.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkScrollableTabViewport.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabbedpane; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabAreaButton.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabAreaButton.java index 2b16a6ee..02c6a4ed 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabAreaButton.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabAreaButton.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabbedpane; +import java.awt.*; + import javax.swing.*; import javax.swing.plaf.UIResource; -import java.awt.*; public class DarkTabAreaButton extends JButton implements UIResource { @@ -42,6 +44,5 @@ public class DarkTabAreaButton extends JButton implements UIResource { ui.paintTabAreaBorder(g, ui.tabPane.getTabPlacement(), 0, 0, getWidth(), getHeight()); } - protected void paintButton(final Graphics g) { - } + protected void paintButton(final Graphics g) {} } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneBorder.java index 5fc73c3c..285633bb 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneBorder.java @@ -20,14 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabbedpane; -import com.github.weisj.darklaf.components.border.MutableLineBorder; - import javax.swing.*; import javax.swing.plaf.UIResource; +import com.github.weisj.darklaf.components.border.MutableLineBorder; + public class DarkTabbedPaneBorder extends MutableLineBorder implements UIResource { public DarkTabbedPaneBorder() { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneLayout.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneLayout.java index fd4afd6c..cd585ec2 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneLayout.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneLayout.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabbedpane; -import javax.swing.*; import java.awt.*; +import javax.swing.*; + public class DarkTabbedPaneLayout extends TabbedPaneLayout { private final DarkTabbedPaneUI ui; @@ -35,7 +37,6 @@ public class DarkTabbedPaneLayout extends TabbedPaneLayout { this.ui = ui; } - @Override protected void centerTabs(final int tabPlacement, final int tabCount, final int returnAt) { if (ui.runCount == 1 && Boolean.TRUE.equals(ui.tabPane.getClientProperty(DarkTabbedPaneUI.KEY_CENTER_TABS))) { @@ -84,7 +85,7 @@ public class DarkTabbedPaneLayout extends TabbedPaneLayout { // In order to allow programs to use a single component // as the display for multiple tabs, we will not change // the visible component if the currently selected tab - // has a null component. This is a bit dicey, as we don't + // has a null component. This is a bit dicey, as we don't // explicitly state we support this in the spec, but since // programs are now depending on this, we're making it work. // @@ -104,7 +105,7 @@ public class DarkTabbedPaneLayout extends TabbedPaneLayout { if (numChildren > 0) { switch (tabPlacement) { - case SwingConstants.LEFT: + case SwingConstants.LEFT : tw = ui.calculateTabAreaWidth(tabPlacement, ui.runCount, ui.maxTabWidth); tx = insets.left + tabAreaInsets.left; ty = insets.top + tabAreaInsets.top; @@ -115,7 +116,7 @@ public class DarkTabbedPaneLayout extends TabbedPaneLayout { - tabAreaInsets.left - tabAreaInsets.right; ch = bounds.height - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom; break; - case SwingConstants.RIGHT: + case SwingConstants.RIGHT : tw = ui.calculateTabAreaWidth(tabPlacement, ui.runCount, ui.maxTabWidth); tx = bounds.width - insets.left - tw - tabAreaInsets.right - tabAreaInsets.left; ty = insets.top + tabAreaInsets.top; @@ -126,7 +127,7 @@ public class DarkTabbedPaneLayout extends TabbedPaneLayout { - tabAreaInsets.left - tabAreaInsets.right; ch = bounds.height - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom; break; - case SwingConstants.BOTTOM: + case SwingConstants.BOTTOM : th = ui.calculateTabAreaHeight(tabPlacement, ui.runCount, ui.maxTabHeight); ty = bounds.height - insets.bottom - th; tx = insets.left + tabAreaInsets.left; @@ -136,7 +137,7 @@ public class DarkTabbedPaneLayout extends TabbedPaneLayout { cw = bounds.width - insets.left - insets.right - contentInsets.left - contentInsets.right; ch = bounds.height - th - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom; break; - default: + default : ty = insets.top + tabAreaInsets.top; tx = insets.left + tabAreaInsets.left; tw = bounds.width - insets.left - insets.right - tabAreaInsets.left - tabAreaInsets.right; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneScrollLayout.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneScrollLayout.java index 86eaff92..9b3b3665 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneScrollLayout.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneScrollLayout.java @@ -20,13 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabbedpane; -import javax.swing.*; import java.awt.*; import java.util.function.Function; +import javax.swing.*; + public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout { private final DarkTabbedPaneUI ui; @@ -65,7 +67,7 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout { // In order to allow programs to use a single component // as the display for multiple tabs, we will not change // the visible component if the currently selected tab - // has a null component. This is a bit dicey, as we don't + // has a null component. This is a bit dicey, as we don't // explicitly state we support this in the spec, but since // programs are now depending on this, we're making it work. // @@ -88,7 +90,7 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout { if (numChildren > 0) { switch (tabPlacement) { - case SwingConstants.LEFT: + case SwingConstants.LEFT : tw = ui.calculateTabAreaWidth(tabPlacement, ui.runCount, ui.maxTabWidth); th = bounds.height - insets.top - insets.bottom - tabAreaInsets.top - tabAreaInsets.bottom; tx = insets.left + tabAreaInsets.left; @@ -100,7 +102,7 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout { ch = bounds.height - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom; tw -= tabAreaInsets.left + tabAreaInsets.right; break; - case SwingConstants.RIGHT: + case SwingConstants.RIGHT : tw = ui.calculateTabAreaWidth(tabPlacement, ui.runCount, ui.maxTabWidth); th = bounds.height - insets.top - insets.bottom - tabAreaInsets.top - tabAreaInsets.bottom; tx = bounds.width - insets.right - tw + tabAreaInsets.left; @@ -111,7 +113,7 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout { ch = bounds.height - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom; tw -= tabAreaInsets.left + tabAreaInsets.right; break; - case SwingConstants.BOTTOM: + case SwingConstants.BOTTOM : tw = bounds.width - insets.left - insets.right - tabAreaInsets.left - tabAreaInsets.right; th = ui.calculateTabAreaHeight(tabPlacement, ui.runCount, ui.maxTabHeight); tx = insets.left + tabAreaInsets.left; @@ -122,7 +124,7 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout { ch = bounds.height - insets.top - insets.bottom - th - contentInsets.top - contentInsets.bottom; th -= tabAreaInsets.top + tabAreaInsets.bottom; break; - default: + default : tw = bounds.width - insets.left - insets.right - tabAreaInsets.left - tabAreaInsets.right; th = ui.calculateTabAreaHeight(tabPlacement, ui.runCount, ui.maxTabHeight); tx = insets.left + tabAreaInsets.left; @@ -144,12 +146,12 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout { int vw = tw; int vh = th; Dimension butSize = moreTabs.isVisible() - ? moreTabs.getPreferredSize() - : new Dimension(0, 0); + ? moreTabs.getPreferredSize() + : new Dimension(0, 0); boolean showNewTabButton = newTab.isVisible() && newTab.getParent() == ui.tabPane; Dimension butSize2 = showNewTabButton - ? newTab.getPreferredSize() - : new Dimension(0, 0); + ? newTab.getPreferredSize() + : new Dimension(0, 0); boolean leftToRight = ui.tabPane.getComponentOrientation().isLeftToRight(); if (tabPlacement == SwingConstants.LEFT || tabPlacement == SwingConstants.RIGHT) { vh = th - butSize.height - butSize2.height; @@ -309,8 +311,8 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout { JButton tabsButton = ui.scrollableTabSupport.moreTabsButton; Rectangle selectedBounds = ui.tabPane.getSelectedIndex() > 0 - ? new Rectangle(ui.rects[ui.tabPane.getSelectedIndex()]) - : new Rectangle(0, 0, 0, 0); + ? new Rectangle(ui.rects[ui.tabPane.getSelectedIndex()]) + : new Rectangle(0, 0, 0, 0); if (!verticalTabRuns) { int rightMargin = size.width - (insets.right + tabAreaInsets.right + insets.left + tabAreaInsets.left); @@ -332,13 +334,13 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout { } if (tabsButton.isVisible() && ui.tabPane.getSelectedIndex() < ui.maxVisible) { - //Shift again. Hiding the the tab button might reveal the last tab. - //Only do this if the last visible tab is not currently selected. - //Otherwise the selected tab forces the whole tab area the jump by the width of the tab button. + // Shift again. Hiding the the tab button might reveal the last tab. + // Only do this if the last visible tab is not currently selected. + // Otherwise the selected tab forces the whole tab area the jump by the width of the tab button. int margin = returnAt + tabsButton.getPreferredSize().width; shiftTabsX(0, leftMargin, margin, tabCount, false); if (ui.minVisible > 0 || ui.maxVisible < tabCount - 1) { - //Tab button is still visible but may hide a further tab. restore visible bounds. + // Tab button is still visible but may hide a further tab. restore visible bounds. shiftTabsX(0, leftMargin, returnAt, tabCount, false); } } @@ -430,7 +432,6 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout { @SuppressWarnings("SuspiciousNameCombination") - protected Point getMargins(final int tabPlacement) { Dimension size = ui.tabPane.getSize(); Insets insets = ui.tabPane.getInsets(); @@ -464,7 +465,7 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout { protected void adjustForDropX(final int minX, final int maxX, final int tabCount) { if (ui.dropSourceIndex >= 0 && ui.dropSourceIndex < ui.tabPane.getTabCount()) { - //Hide the source tab. + // Hide the source tab. int shift = ui.rects[ui.dropSourceIndex].width; ui.rects[ui.dropSourceIndex].setSize(0, 0); commitShiftX(ui.dropSourceIndex + 1, tabCount - 1, -1 * shift, tabCount); @@ -532,11 +533,11 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout { protected void shiftBoundsToVisibleX(final Rectangle selectedBounds, final int leftMargin, final int rightMargin, final int tabCount) { if (selectedBounds.x + selectedBounds.width > rightMargin) { - //SelectedTab is not fully visible. Covered on right side. + // SelectedTab is not fully visible. Covered on right side. shiftTabsX(rightMargin - selectedBounds.x - selectedBounds.width, leftMargin, rightMargin, tabCount, true); } else if (selectedBounds.x < leftMargin) { - //SelectedTab is not fully visible. Covered on left side. + // SelectedTab is not fully visible. Covered on left side. shiftTabsX(-selectedBounds.x + leftMargin, leftMargin, rightMargin, tabCount, true); } } @@ -544,11 +545,11 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout { protected void shiftBoundsToVisibleY(final Rectangle selectedBounds, final int topMargin, final int bottomMargin, final int tabCount) { if (selectedBounds.y + selectedBounds.height > bottomMargin) { - //SelectedTab is not fully visible. Covered on right side. + // SelectedTab is not fully visible. Covered on right side. shiftTabsY(bottomMargin - selectedBounds.y - selectedBounds.height, topMargin, bottomMargin, tabCount, true); } else if (selectedBounds.y < topMargin) { - //SelectedTab is not fully visible. Covered on left side. + // SelectedTab is not fully visible. Covered on left side. shiftTabsY(-selectedBounds.y + topMargin, topMargin, bottomMargin, tabCount, true); } @@ -605,7 +606,7 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout { protected void adjustForDropY(final int minY, final int maxY, final int tabCount) { if (ui.dropSourceIndex >= 0 && ui.dropSourceIndex < ui.tabPane.getTabCount()) { - //Hide the source tab. + // Hide the source tab. int shift = ui.rects[ui.dropSourceIndex].height; ui.rects[ui.dropSourceIndex].setSize(0, 0); commitShiftY(ui.dropSourceIndex + 1, tabCount - 1, -1 * shift, tabCount); @@ -664,7 +665,7 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout { Function isVisible = isX ? (i -> isVisibleX(i, currShift, minVal, returnAt)) : (i -> isVisibleY(i, currShift, minVal, returnAt)); if (isVisible.apply(minStart)) { - //Descent to find minimum. + // Descent to find minimum. min = minStart; for (int i = minStart - 1; i >= 0; i--) { if (isVisible.apply(i)) { @@ -674,7 +675,7 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout { } } } else { - //Ascent to find minimum. + // Ascent to find minimum. for (int i = minStart + 1; i < tabCount; i++) { if (isVisible.apply(i)) { min = i; @@ -686,7 +687,7 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout { min = tabCount; } if (isVisible.apply(maxStart)) { - //Ascent to find maximum. + // Ascent to find maximum. max = maxStart; for (int i = maxStart + 1; i < tabCount; i++) { if (isVisible.apply(i)) { @@ -696,7 +697,7 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout { } } } else { - //Descent to find maximum. + // Descent to find maximum. for (int i = maxStart - 1; i >= 0; i--) { if (isVisible.apply(i)) { max = i; @@ -716,14 +717,12 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout { } } - protected boolean isVisibleX(final int i, final int shift, final int minX, final int maxX) { int begin = ui.rects[i].x + shift; int end = begin + ui.rects[i].width; return !(begin >= maxX || end < minX); } - protected boolean isVisibleY(final int i, final int shift, final int minX, final int maxX) { int begin = ui.rects[i].y + shift; int end = begin + ui.rects[i].height; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUI.java index fcb182b1..54c46615 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUI.java @@ -20,17 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabbedpane; -import com.github.weisj.darklaf.components.uiresource.UIResourceWrapper; -import com.github.weisj.darklaf.util.DarkUIUtil; -import com.github.weisj.darklaf.util.GraphicsContext; -import com.github.weisj.darklaf.util.GraphicsUtil; - -import javax.swing.*; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.UIResource; import java.awt.*; import java.awt.dnd.DropTarget; import java.awt.event.AWTEventListener; @@ -39,6 +32,15 @@ import java.awt.event.MouseEvent; import java.util.TooManyListenersException; import java.util.function.Consumer; +import javax.swing.*; +import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.UIResource; + +import com.github.weisj.darklaf.components.uiresource.UIResourceWrapper; +import com.github.weisj.darklaf.util.DarkUIUtil; +import com.github.weisj.darklaf.util.GraphicsContext; +import com.github.weisj.darklaf.util.GraphicsUtil; + /** * @author Jannis Weis */ @@ -47,8 +49,8 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { protected static final String KEY_PREFIX = "JTabbedPane."; /* * Centering tabs only applies if in - * - WRAP_TAB_LAYOUT there is only one tab run. - * - SCROLL_TAB_LAYOUT the viewport doesn't need to be scrolled. + * - WRAP_TAB_LAYOUT there is only one tab run. + * - SCROLL_TAB_LAYOUT the viewport doesn't need to be scrolled. */ public static final String KEY_CENTER_TABS = KEY_PREFIX + "centerTabs"; public static final String KEY_DND = KEY_PREFIX + "dndEnabled"; @@ -110,7 +112,6 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { protected Icon moreTabsIcon; protected Icon newTabIcon; - protected DarkScrollHandler scrollHandler; protected Component leadingComp; protected Component trailingComp; @@ -119,7 +120,6 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { protected Component southComp; protected Component westComp; - public static ComponentUI createUI(final JComponent c) { return new DarkTabbedPaneUI(); } @@ -180,7 +180,6 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { paintContentBorder(g, tabPlacement, selectedIndex); } - // If scrollable tabs are enabled, the tab area will be // painted by the scrollable tab panel instead. if (!scrollableTabLayoutEnabled()) { // WRAP_TAB_LAYOUT @@ -231,16 +230,16 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { final boolean isSelected) { g.setColor(getTabBorderColor()); switch (tabPlacement) { - case TOP: + case TOP : g.fillRect(x, y + h - 1, w, 1); break; - case BOTTOM: + case BOTTOM : g.fillRect(x, y, w, 1); break; - case LEFT: + case LEFT : g.fillRect(x + w - 1, y, 1, h); break; - case RIGHT: + case RIGHT : g.fillRect(x, y, 1, h); break; } @@ -254,16 +253,16 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { if (!drawFocusBar()) return; g.setColor(getAccentColor()); switch (tabPlacement) { - case LEFT: + case LEFT : g.fillRect(r.x + r.width - focusSize, r.y, focusSize, r.height); break; - case RIGHT: + case RIGHT : g.fillRect(r.x, r.y, focusSize, r.height); break; - case BOTTOM: + case BOTTOM : g.fillRect(r.x, r.y + 1, r.width, focusSize); break; - default: + default : g.fillRect(r.x, r.y + r.height - focusSize, r.width, focusSize); break; } @@ -299,14 +298,14 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { b.setLocation(0, 0); } switch (tabPlacement) { - case BOTTOM: + case BOTTOM : b.y++; - case TOP: + case TOP : b.height--; break; - case RIGHT: + case RIGHT : b.x++; - case LEFT: + case LEFT : b.width--; break; } @@ -375,8 +374,7 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { protected void paintFocusIndicator(final Graphics g, final int tabPlacement, final Rectangle[] rects, final int tabIndex, final Rectangle iconRect, final Rectangle textRect, - final boolean isSelected) { - } + final boolean isSelected) {} private void paintTabAreaBorder(final Graphics g, final int tabPlacement) { int width = tabPane.getWidth(); @@ -385,17 +383,17 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { int h = calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight); int w = calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth); switch (tabPlacement) { - case TOP: + case TOP : paintTabAreaBorder(g, tabPlacement, ins.left, 0, width - ins.left - ins.right, h + ins.top); break; - case BOTTOM: + case BOTTOM : paintTabAreaBorder(g, tabPlacement, ins.left, height - h - ins.top, width - ins.left - ins.right, h + ins.top + 1); break; - case LEFT: + case LEFT : paintTabAreaBorder(g, tabPlacement, 0, ins.top, w + ins.left, height - ins.top - ins.bottom); break; - case RIGHT: + case RIGHT : paintTabAreaBorder(g, tabPlacement, width - w - ins.right, ins.top, w + ins.right, height - ins.top - ins.bottom); break; @@ -507,16 +505,16 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { final int x, final int y, final int w, final int h) { g.setColor(getTabBorderColor()); switch (tabPlacement) { - case TOP: + case TOP : g.fillRect(x, y + h - 1, w, 1); break; - case BOTTOM: + case BOTTOM : g.fillRect(x, y, w, 1); break; - case LEFT: + case LEFT : g.fillRect(w - 1, y, 1, h); break; - case RIGHT: + case RIGHT : g.fillRect(x, y, 1, h); break; } @@ -533,16 +531,16 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { ((Graphics2D) g).setComposite(DarkUIUtil.getDropComposite()); } switch (tabPane.getTabPlacement()) { - case TOP: + case TOP : g.fillRect(dropRect.x, dropRect.y, dropRect.width, dropRect.height - 1); break; - case BOTTOM: + case BOTTOM : g.fillRect(dropRect.x, dropRect.y + 1, dropRect.width, dropRect.height - 1); break; - case LEFT: + case LEFT : g.fillRect(dropRect.x, dropRect.y, dropRect.width - 1, dropRect.height); break; - case RIGHT: + case RIGHT : g.fillRect(dropRect.x + 1, dropRect.y, dropRect.width - 1, dropRect.height); break; } @@ -557,17 +555,17 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { int centerY = (tabHeight - h) / 2; int centerX = (tabWidth - w) / 2; switch (tabPlacement) { - case LEFT: + case LEFT : comp.setBounds(insets.left + centerX, insets.top, w, b.height); break; - case RIGHT: + case RIGHT : comp.setBounds(tx - tabAreaInsets.left + centerX, insets.top, w, b.height); break; - case TOP: + case TOP : comp.setBounds(insets.left, insets.top + centerY, b.width, h); break; - case BOTTOM: + case BOTTOM : comp.setBounds(insets.left, ty - tabAreaInsets.bottom + centerY, b.width, h); break; @@ -584,18 +582,18 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { int centerY = (tabHeight - h) / 2; int centerX = (tabWidth - w) / 2; switch (tabPlacement) { - case LEFT: + case LEFT : comp.setBounds(insets.left + centerX, size.height - b.height - insets.bottom, w, b.height); break; - case RIGHT: + case RIGHT : comp.setBounds(tx - tabAreaInsets.left + centerX, size.height - b.height - insets.bottom, w, b.height); break; - case TOP: + case TOP : comp.setBounds(size.width - b.width - insets.right, insets.top + centerY, b.width, h); break; - case BOTTOM: + case BOTTOM : comp.setBounds(size.width - b.width - insets.right, ty - tabAreaInsets.bottom + centerY, b.width, h); break; @@ -667,7 +665,7 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { } getTabBounds(i, rect); - //Adjust dragged component position. + // Adjust dragged component position. if (i == dropSourceIndex) { if (dragging) { rect.setBounds(dragRect); @@ -687,7 +685,7 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge { int outerY = rect.y + insets.top + delta.y; int outerWidth = rect.width - insets.left - insets.right; int outerHeight = rect.height - insets.top - insets.bottom; - //centralize component + // centralize component int x = outerX + (outerWidth - preferredSize.width) / 2; int y = outerY + (outerHeight - preferredSize.height) / 2; int tabPlacement = tabPane.getTabPlacement(); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUIBridge.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUIBridge.java index 182485bf..dd374cc1 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUIBridge.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUIBridge.java @@ -20,23 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabbedpane; -import com.github.weisj.darklaf.util.DarkUIUtil; -import com.github.weisj.darklaf.util.LazyActionMap; -import com.github.weisj.darklaf.util.PropertyKey; -import sun.swing.DefaultLookup; -import sun.swing.SwingUtilities2; -import sun.swing.UIAction; - -import javax.swing.*; -import javax.swing.event.ChangeListener; -import javax.swing.plaf.ComponentInputMapUIResource; -import javax.swing.plaf.TabbedPaneUI; -import javax.swing.plaf.UIResource; -import javax.swing.plaf.basic.BasicHTML; -import javax.swing.text.View; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.FocusListener; @@ -47,6 +34,22 @@ import java.util.Hashtable; import java.util.Objects; import java.util.Vector; +import javax.swing.*; +import javax.swing.event.ChangeListener; +import javax.swing.plaf.ComponentInputMapUIResource; +import javax.swing.plaf.TabbedPaneUI; +import javax.swing.plaf.UIResource; +import javax.swing.plaf.basic.BasicHTML; +import javax.swing.text.View; + +import sun.swing.DefaultLookup; +import sun.swing.SwingUtilities2; +import sun.swing.UIAction; + +import com.github.weisj.darklaf.util.DarkUIUtil; +import com.github.weisj.darklaf.util.LazyActionMap; +import com.github.weisj.darklaf.util.PropertyKey; + /** * A Basic L&F implementation of TabbedPaneUI. * @@ -54,14 +57,17 @@ import java.util.Vector; * @author Philip Milne * @author Steve Wilson * @author Tom Santos - * @author Dave Moore

This class stands in to allow to access the hell of ui code produced in {@link - * javax.swing.plaf.basic.BasicTabbedPaneUI}. This code is almost identical to the original implementation besides the - * fact that all fields and methods are now protected instead of private. + * @author Dave Moore + *

+ * This class stands in to allow to access the hell of ui code produced in {@link + * javax.swing.plaf.basic.BasicTabbedPaneUI}. This code is almost identical to the original implementation + * besides the + * fact that all fields and methods are now protected instead of private. * @author Jannis Weis */ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements SwingConstants { -// Instance variables initialized at installation + // Instance variables initialized at installation /** * The Current pad insets. @@ -104,11 +110,10 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi */ protected boolean tabsOverlapBorder; - /** * The Tabs opaque. */ -// Transient variables (recalculated each time TabbedPane is layed out) + // Transient variables (recalculated each time TabbedPane is layed out) protected boolean tabsOpaque = true; /** * The Content opaque. @@ -147,7 +152,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi @Deprecated protected KeyStroke rightKey; -// Listeners + // Listeners /** * Tab runs */ @@ -165,7 +170,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi */ protected Rectangle[] rects = new Rectangle[0]; -// Private instance data + // Private instance data /** * Maximum tab height */ @@ -197,7 +202,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * The Html views. */ -// PENDING(api): See comment for ContainerHandler + // PENDING(api): See comment for ContainerHandler protected Vector htmlViews; /** * The Mnemonic to index map. @@ -211,7 +216,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * The Tab scroller. */ -// For use when tabLayoutPolicy = SCROLL_TAB_LAYOUT + // For use when tabLayoutPolicy = SCROLL_TAB_LAYOUT protected ScrollableTabSupport tabScroller; /** * The Tab container. @@ -230,9 +235,9 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi */ protected int rolloverTabIndex; -// UI creation + // UI creation /** - * This is set to true when a component is added/removed from the tab pane and set to false when layout happens. If + * This is set to true when a component is added/removed from the tab pane and set to false when layout happens. If * true it indicates that tabRuns is not valid and shouldn't be used. */ protected boolean isRunsDirty; @@ -249,7 +254,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * The Baseline. */ -// UI Installation/De-installation + // UI Installation/De-installation protected int baseline; /** @@ -302,8 +307,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi */ protected void uninstallKeyboardActions() { SwingUtilities.replaceUIActionMap(tabPane, null); - SwingUtilities.replaceUIInputMap(tabPane, JComponent. - WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, + SwingUtilities.replaceUIInputMap(tabPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null); SwingUtilities.replaceUIInputMap(tabPane, JComponent.WHEN_FOCUSED, null); @@ -422,8 +426,8 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi * * @throws NullPointerException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} - * @see javax.swing.JComponent#getBaseline(int, int) - * @since 1.6 + * @see javax.swing.JComponent#getBaseline(int, int) + * @since 1.6 */ public int getBaseline(final JComponent c, final int width, final int height) { super.getBaseline(c, width, height); @@ -433,12 +437,12 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi Insets insets = tabPane.getInsets(); Insets tabAreaInsets = getTabAreaInsets(placement); switch (placement) { - case JTabbedPane.TOP: - case JTabbedPane.LEFT: - case JTabbedPane.RIGHT: + case JTabbedPane.TOP : + case JTabbedPane.LEFT : + case JTabbedPane.RIGHT : baseline += insets.top + tabAreaInsets.top; return baseline; - case JTabbedPane.BOTTOM: + case JTabbedPane.BOTTOM : baseline = height - insets.bottom - tabAreaInsets.bottom - maxTabHeight + baseline; return baseline; @@ -451,18 +455,17 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi * Returns an enum indicating how the baseline of the component changes as the size changes. * * @throws NullPointerException {@inheritDoc} - * @see javax.swing.JComponent#getBaseline(int, int) - * @since 1.6 + * @see javax.swing.JComponent#getBaseline(int, int) + * @since 1.6 */ - public Component.BaselineResizeBehavior getBaselineResizeBehavior( - final JComponent c) { + public Component.BaselineResizeBehavior getBaselineResizeBehavior(final JComponent c) { super.getBaselineResizeBehavior(c); switch (tabPane.getTabPlacement()) { - case JTabbedPane.LEFT: - case JTabbedPane.RIGHT: - case JTabbedPane.TOP: + case JTabbedPane.LEFT : + case JTabbedPane.RIGHT : + case JTabbedPane.TOP : return Component.BaselineResizeBehavior.CONSTANT_ASCENT; - case JTabbedPane.BOTTOM: + case JTabbedPane.BOTTOM : return Component.BaselineResizeBehavior.CONSTANT_DESCENT; } return Component.BaselineResizeBehavior.OTHER; @@ -473,7 +476,8 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi * * @return the boolean */ - /* In an attempt to preserve backward compatibility for programs + /* + * In an attempt to preserve backward compatibility for programs * which have extended BasicTabbedPaneUI to do their own layout, the * UI uses the installed layoutManager (and not tabLayoutPolicy) to * determine if scrollTabLayout is enabled. @@ -493,7 +497,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * Paints the tabs in the tab area. Invoked by paint(). The graphics parameter must be a valid Graphics - * object. Tab placement may be either: + * object. Tab placement may be either: * JTabbedPane.TOP, JTabbedPane.BOTTOM, * JTabbedPane.LEFT, or JTabbedPane.RIGHT. * The selected index must be a valid tabbed pane tab index (0 to tab count - 1, inclusive) or -1 if no tab is @@ -502,13 +506,13 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi * @param g the graphics object to use for rendering * @param tabPlacement the placement for the tabs within the JTabbedPane * @param selectedIndex the tab index of the selected component - * @since 1.4 + * @since 1.4 */ protected void paintTabArea(final Graphics g, final int tabPlacement, final int selectedIndex) { int tabCount = tabPane.getTabCount(); Rectangle iconRect = new Rectangle(), - textRect = new Rectangle(); + textRect = new Rectangle(); Rectangle clipRect = g.getClipBounds(); // Paint tabRuns of tabs from back to front @@ -630,12 +634,12 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * Returns the icon for a tab. * - * @param tabIndex the index of the tab - * @return the icon for a tab + * @param tabIndex the index of the tab + * @return the icon for a tab */ protected Icon getIconForTab(final int tabIndex) { - return (!tabPane.isEnabled() || !tabPane.isEnabledAt(tabIndex)) ? - tabPane.getDisabledIconAt(tabIndex) : tabPane.getIconAt(tabIndex); + return (!tabPane.isEnabled() || !tabPane.isEnabledAt(tabIndex)) ? tabPane.getDisabledIconAt(tabIndex) + : tabPane.getIconAt(tabIndex); } /** @@ -688,8 +692,8 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi * Invoked by installUI to create a layout manager object to manage the JTabbedPane. * * @return a layout manager object - * @see TabbedPaneLayout - * @see javax.swing.JTabbedPane#getTabLayoutPolicy javax.swing.JTabbedPane#getTabLayoutPolicy + * @see TabbedPaneLayout + * @see javax.swing.JTabbedPane#getTabLayoutPolicy javax.swing.JTabbedPane#getTabLayoutPolicy */ protected abstract LayoutManager createLayoutManager(); @@ -789,9 +793,9 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi * Returns the text View object required to render stylized text (HTML) for the specified tab or null if no * specialized text rendering is needed for this tab. This is provided to support html rendering inside tabs. * - * @param tabIndex the index of the tab - * @return the text view to render the tab's text or null if no specialized rendering is required - * @since 1.4 + * @param tabIndex the index of the tab + * @return the text view to render the tab's text or null if no specialized rendering is required + * @since 1.4 */ protected View getTextViewForTab(final int tabIndex) { if (htmlViews != null) { @@ -803,25 +807,24 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * Returns the tab label.properties shift x. * - * @param tabPlacement the tab placement - * @param tabIndex the tab index - * @param isSelected selection status - * @return the tab label.properties shift x + * @param tabPlacement the tab placement + * @param tabIndex the tab index + * @param isSelected selection status + * @return the tab label.properties shift x */ protected int getTabLabelShiftX(final int tabPlacement, final int tabIndex, final boolean isSelected) { Rectangle tabRect = rects[tabIndex]; String propKey = (isSelected ? "selectedLabelShift" : "labelShift"); - int nudge = DefaultLookup.getInt( - tabPane, this, "TabbedPane." + propKey, 1); + int nudge = DefaultLookup.getInt(tabPane, this, "TabbedPane." + propKey, 1); switch (tabPlacement) { - case LEFT: + case LEFT : return nudge; - case RIGHT: + case RIGHT : return -nudge; - case BOTTOM: - case TOP: - default: + case BOTTOM : + case TOP : + default : return tabRect.width % 2; } } @@ -829,24 +832,24 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * Returns the tab label.properties shift y. * - * @param tabPlacement the tab placement - * @param tabIndex the tab index - * @param isSelected selection status - * @return the tab label.properties shift y + * @param tabPlacement the tab placement + * @param tabIndex the tab index + * @param isSelected selection status + * @return the tab label.properties shift y */ protected int getTabLabelShiftY(final int tabPlacement, final int tabIndex, final boolean isSelected) { Rectangle tabRect = rects[tabIndex]; - int nudge = (isSelected ? DefaultLookup.getInt(tabPane, this, "TabbedPane.selectedLabelShift", -1) : - DefaultLookup.getInt(tabPane, this, "TabbedPane.labelShift", 1)); + int nudge = (isSelected ? DefaultLookup.getInt(tabPane, this, "TabbedPane.selectedLabelShift", -1) + : DefaultLookup.getInt(tabPane, this, "TabbedPane.labelShift", 1)); switch (tabPlacement) { - case BOTTOM: + case BOTTOM : return -nudge; - case LEFT: - case RIGHT: + case LEFT : + case RIGHT : return tabRect.height % 2; - case TOP: - default: + case TOP : + default : return nudge; } } @@ -920,7 +923,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi if (contentBorderInsets == null) contentBorderInsets = new Insets(2, 2, 3, 3); } -// UI Rendering + // UI Rendering /** * Install the listeners. @@ -949,11 +952,9 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi * Installs the keyboard actions. */ protected void installKeyboardActions() { - InputMap km = getInputMap(JComponent. - WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + InputMap km = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); - SwingUtilities.replaceUIInputMap(tabPane, JComponent. - WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, + SwingUtilities.replaceUIInputMap(tabPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, km); km = getInputMap(JComponent.WHEN_FOCUSED); SwingUtilities.replaceUIInputMap(tabPane, JComponent.WHEN_FOCUSED, km); @@ -1026,8 +1027,8 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * Gets input map. * - * @param condition the condition - * @return the input map + * @param condition the condition + * @return the input map */ InputMap getInputMap(final int condition) { if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) { @@ -1112,11 +1113,11 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * Tab for coordinate int. * - * @param pane the pane - * @param x the x - * @param y the y - * @param validateIfNecessary the validate if necessary - * @return the int + * @param pane the pane + * @param x the x + * @param y the y + * @param validateIfNecessary the validate if necessary + * @return the int */ protected int tabForCoordinate(final JTabbedPane pane, final int x, final int y, final boolean validateIfNecessary) { @@ -1166,9 +1167,10 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi if (!tabPane.isValid()) { tabPane.validate(); } - /* If tabPane doesn't have a peer yet, the validate() call will - * silently fail. We handle that by forcing a layout if tabPane - * is still invalid. See bug 4237677. + /* + * If tabPane doesn't have a peer yet, the validate() call will + * silently fail. We handle that by forcing a layout if tabPane + * is still invalid. See bug 4237677. */ if (!tabPane.isValid()) { TabbedPaneLayout layout = (TabbedPaneLayout) tabPane.getLayout(); @@ -1178,12 +1180,12 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * Returns a point which is translated from the specified point in the JTabbedPane's coordinate space to the - * coordinate space of the ScrollableTabPanel. This is used for SCROLL_TAB_LAYOUT ONLY. + * coordinate space of the ScrollableTabPanel. This is used for SCROLL_TAB_LAYOUT ONLY. * - * @param srcx the srcx - * @param srcy the srcy - * @param dest the dest - * @return the point + * @param srcx the srcx + * @param srcy the srcy + * @param dest the dest + * @return the point */ protected Point translatePointToTabPanel(final int srcx, final int srcy, final Point dest) { Point vpp = tabScroller.viewport.getLocation(); @@ -1213,7 +1215,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi * Returns the tab the mouse is currently over, or {@code -1} if the mouse is no longer over any tab. * * @return the tab the mouse is currently over, or {@code -1} if the mouse is no longer over any tab - * @since 1.5 + * @since 1.5 */ protected int getRolloverTab() { return rolloverTabIndex; @@ -1225,7 +1227,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi * tab. No checking is done to ensure the passed in index identifies a valid tab. * * @param index Index of the tab the mouse is over. - * @since 1.5 + * @since 1.5 */ protected void setRolloverTab(final int index) { rolloverTabIndex = index; @@ -1234,10 +1236,10 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * Returns the baseline for the specified tab. * - * @param tab index of tab to get baseline for - * @return baseline or a value < 0 indicating there is no reasonable baseline + * @param tab index of tab to get baseline for + * @return baseline or a value < 0 indicating there is no reasonable baseline * @throws IndexOutOfBoundsException if index is out of range (index < 0 || index >= tab count) - * @since 1.6 + * @since 1.6 */ protected int getBaseline(final int tab) { if (tabPane.getTabComponentAt(tab) != null) { @@ -1258,8 +1260,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi View view = getTextViewForTab(tab); if (view != null) { int viewHeight = (int) view.getPreferredSpan(View.Y_AXIS); - int baseline = BasicHTML.getHTMLBaseline( - view, (int) view.getPreferredSpan(View.X_AXIS), viewHeight); + int baseline = BasicHTML.getHTMLBaseline(view, (int) view.getPreferredSpan(View.X_AXIS), viewHeight); if (baseline >= 0) { return maxTabHeight / 2 - viewHeight / 2 + baseline + getBaselineOffset(); @@ -1275,26 +1276,26 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi } /** - * Returns the amount the baseline is offset by. This is typically the same as getTabLabelShiftY. + * Returns the amount the baseline is offset by. This is typically the same as getTabLabelShiftY. * * @return amount to offset the baseline by - * @since 1.6 + * @since 1.6 */ protected int getBaselineOffset() { switch (tabPane.getTabPlacement()) { - case JTabbedPane.TOP: + case JTabbedPane.TOP : if (tabPane.getTabCount() > 1) { return 1; } else { return -1; } - case JTabbedPane.BOTTOM: + case JTabbedPane.BOTTOM : if (tabPane.getTabCount() > 1) { return -1; } else { return 1; } - default: // RIGHT|LEFT + default : // RIGHT|LEFT return (maxTabHeight % 2); } } @@ -1306,11 +1307,10 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi return tabForCoordinate(pane, x, y, true); } - -// TabbedPaneUI methods + // TabbedPaneUI methods /** - * Returns the bounds of the specified tab index. The bounds are with respect to the JTabbedPane's coordinate + * Returns the bounds of the specified tab index. The bounds are with respect to the JTabbedPane's coordinate * space. */ public Rectangle getTabBounds(final JTabbedPane pane, final int i) { @@ -1364,7 +1364,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi return tabPane.getTabPlacement() == TOP || tabPane.getTabPlacement() == BOTTOM; } -// BasicTabbedPaneUI methods + // BasicTabbedPaneUI methods /** * Paint focus indicator. @@ -1414,9 +1414,9 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * Returns the run for a tab. * - * @param tabCount the tab count - * @param tabIndex the tab index. - * @return the run for a tab + * @param tabCount the tab count + * @param tabIndex the tab index. + * @return the run for a tab */ protected int getRunForTab(final int tabCount, final int tabIndex) { for (int i = 0; i < runCount; i++) { @@ -1432,9 +1432,9 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * Returns the last tab in a run. * - * @param tabCount the tab count - * @param run the run - * @return the last tab in a run + * @param tabCount the tab count + * @param run the run + * @return the last tab in a run */ protected int lastTabInRun(final int tabCount, final int run) { if (runCount == 1) { @@ -1450,8 +1450,8 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * Returns the tab run overlay. * - * @param tabPlacement the placement (left, right, bottom, top) of the tab - * @return the tab run overlay + * @param tabPlacement the placement (left, right, bottom, top) of the tab + * @return the tab run overlay */ protected int getTabRunOverlay(final int tabPlacement) { return tabRunOverlay; @@ -1460,9 +1460,9 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * Returns the tab run indent. * - * @param tabPlacement the placement (left, right, bottom, top) of the tab - * @param run the tab run - * @return the tab run indent + * @param tabPlacement the placement (left, right, bottom, top) of the tab + * @param run the tab run + * @return the tab run indent */ protected int getTabRunIndent(final int tabPlacement, final int run) { return 0; @@ -1471,9 +1471,9 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * Returns whether or not the tab run should be padded. * - * @param tabPlacement the placement (left, right, bottom, top) of the tab - * @param run the tab run - * @return whether or not the tab run should be padded + * @param tabPlacement the placement (left, right, bottom, top) of the tab + * @param run the tab run + * @return whether or not the tab run should be padded */ protected boolean shouldPadTabRun(final int tabPlacement, final int run) { return runCount > 1; @@ -1482,8 +1482,8 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * Returns whether or not the tab run should be rotated. * - * @param tabPlacement the placement (left, right, bottom, top) of the tab - * @return whether or not the tab run should be rotated + * @param tabPlacement the placement (left, right, bottom, top) of the tab + * @return whether or not the tab run should be rotated */ protected boolean shouldRotateTabRuns(final int tabPlacement) { return true; @@ -1492,10 +1492,10 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * Calculates the tab height. * - * @param tabPlacement the placement (left, right, bottom, top) of the tab - * @param tabIndex the index of the tab with respect to other tabs - * @param fontHeight the font height - * @return the tab height + * @param tabPlacement the placement (left, right, bottom, top) of the tab + * @param tabIndex the index of the tab with respect to other tabs + * @param fontHeight the font height + * @return the tab height */ protected int calculateTabHeight(final int tabPlacement, final int tabIndex, final int fontHeight) { int height = 0; @@ -1525,8 +1525,8 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * Calculates the maximum tab height. * - * @param tabPlacement the placement (left, right, bottom, top) of the tab - * @return the maximum tab height + * @param tabPlacement the placement (left, right, bottom, top) of the tab + * @return the maximum tab height */ protected int calculateMaxTabHeight(final int tabPlacement) { FontMetrics metrics = getFontMetrics(); @@ -1542,8 +1542,8 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * Calculates the maximum tab width. * - * @param tabPlacement the placement (left, right, bottom, top) of the tab - * @return the maximum tab width + * @param tabPlacement the placement (left, right, bottom, top) of the tab + * @return the maximum tab width */ protected int calculateMaxTabWidth(final int tabPlacement) { FontMetrics metrics = getFontMetrics(); @@ -1568,10 +1568,10 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * Calculates the tab width. * - * @param tabPlacement the placement (left, right, bottom, top) of the tab - * @param tabIndex the index of the tab with respect to other tabs - * @param metrics the font metrics - * @return the tab width + * @param tabPlacement the placement (left, right, bottom, top) of the tab + * @param tabIndex the index of the tab with respect to other tabs + * @param metrics the font metrics + * @return the tab width */ protected int calculateTabWidth(final int tabPlacement, final int tabIndex, final FontMetrics metrics) { Insets tabInsets = getTabInsets(tabPlacement, tabIndex); @@ -1600,9 +1600,9 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * Returns the tab insets. * - * @param tabPlacement the placement (left, right, bottom, top) of the tab - * @param tabIndex the tab index - * @return the tab insets + * @param tabPlacement the placement (left, right, bottom, top) of the tab + * @param tabIndex the tab index + * @return the tab insets */ protected Insets getTabInsets(final int tabPlacement, final int tabIndex) { return tabInsets; @@ -1611,42 +1611,40 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * Calculates the tab area height. * - * @param tabPlacement the placement (left, right, bottom, top) of the tab - * @param horizRunCount horizontal run count - * @param maxTabHeight maximum tab height - * @return the tab area height + * @param tabPlacement the placement (left, right, bottom, top) of the tab + * @param horizRunCount horizontal run count + * @param maxTabHeight maximum tab height + * @return the tab area height */ protected int calculateTabAreaHeight(final int tabPlacement, final int horizRunCount, final int maxTabHeight) { Insets tabAreaInsets = getTabAreaInsets(tabPlacement); int tabRunOverlay = getTabRunOverlay(tabPlacement); - return (horizRunCount > 0 ? - horizRunCount * (maxTabHeight - tabRunOverlay) + tabRunOverlay + - tabAreaInsets.top + tabAreaInsets.bottom : - 0); + return (horizRunCount > 0 ? horizRunCount * (maxTabHeight - tabRunOverlay) + tabRunOverlay + + tabAreaInsets.top + tabAreaInsets.bottom + : 0); } /** * Calculates the tab area width. * - * @param tabPlacement the placement (left, right, bottom, top) of the tab - * @param vertRunCount vertical run count - * @param maxTabWidth maximum tab width - * @return the tab area width + * @param tabPlacement the placement (left, right, bottom, top) of the tab + * @param vertRunCount vertical run count + * @param maxTabWidth maximum tab width + * @return the tab area width */ protected int calculateTabAreaWidth(final int tabPlacement, final int vertRunCount, final int maxTabWidth) { Insets tabAreaInsets = getTabAreaInsets(tabPlacement); int tabRunOverlay = getTabRunOverlay(tabPlacement); - return (vertRunCount > 0 ? - vertRunCount * (maxTabWidth - tabRunOverlay) + tabRunOverlay + - tabAreaInsets.left + tabAreaInsets.right : - 0); + return (vertRunCount > 0 ? vertRunCount * (maxTabWidth - tabRunOverlay) + tabRunOverlay + + tabAreaInsets.left + tabAreaInsets.right + : 0); } /** * Returns the selected tab pad insets. * - * @param tabPlacement the placement (left, right, bottom, top) of the tab - * @return the selected tab pad insets + * @param tabPlacement the placement (left, right, bottom, top) of the tab + * @return the selected tab pad insets */ protected Insets getSelectedTabPadInsets(final int tabPlacement) { rotateInsets(selectedTabPadInsets, currentPadInsets, tabPlacement); @@ -1664,26 +1662,26 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi protected static void rotateInsets(final Insets topInsets, final Insets targetInsets, final int targetPlacement) { switch (targetPlacement) { - case LEFT: + case LEFT : targetInsets.top = topInsets.left; targetInsets.left = topInsets.top; targetInsets.bottom = topInsets.right; targetInsets.right = topInsets.bottom; break; - case BOTTOM: + case BOTTOM : targetInsets.top = topInsets.bottom; targetInsets.left = topInsets.left; targetInsets.bottom = topInsets.top; targetInsets.right = topInsets.right; break; - case RIGHT: + case RIGHT : targetInsets.top = topInsets.left; targetInsets.left = topInsets.bottom; targetInsets.bottom = topInsets.right; targetInsets.right = topInsets.top; break; - case TOP: - default: + case TOP : + default : targetInsets.top = topInsets.top; targetInsets.left = topInsets.left; targetInsets.bottom = topInsets.bottom; @@ -1694,8 +1692,8 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * Returns the tab area insets. * - * @param tabPlacement the placement (left, right, bottom, top) of the tab - * @return the pad area insets + * @param tabPlacement the placement (left, right, bottom, top) of the tab + * @return the pad area insets */ protected Insets getTabAreaInsets(final int tabPlacement) { rotateInsets(tabAreaInsets, currentTabAreaInsets, tabPlacement); @@ -1705,8 +1703,8 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * Returns the content border insets. * - * @param tabPlacement the placement (left, right, bottom, top) of the tab - * @return the content border insets + * @param tabPlacement the placement (left, right, bottom, top) of the tab + * @return the content border insets */ protected Insets getContentBorderInsets(final int tabPlacement) { return contentBorderInsets; @@ -1720,8 +1718,8 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi protected void navigateSelectedTab(final int direction) { int tabPlacement = tabPane.getTabPlacement(); int current = DefaultLookup.getBoolean(tabPane, this, - "TabbedPane.selectionFollowsFocus", true) ? - tabPane.getSelectedIndex() : getFocusIndex(); + "TabbedPane.selectionFollowsFocus", true) ? tabPane.getSelectedIndex() + : getFocusIndex(); int tabCount = tabPane.getTabCount(); boolean leftToRight = tabPane.getComponentOrientation().isLeftToRight(); @@ -1732,65 +1730,65 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi int offset; switch (tabPlacement) { - case LEFT: - case RIGHT: + case LEFT : + case RIGHT : switch (direction) { - case NEXT: + case NEXT : selectNextTab(current); break; - case PREVIOUS: + case PREVIOUS : selectPreviousTab(current); break; - case NORTH: + case NORTH : selectPreviousTabInRun(current); break; - case SOUTH: + case SOUTH : selectNextTabInRun(current); break; - case WEST: + case WEST : offset = getTabRunOffset(tabPlacement, tabCount, current, false); selectAdjacentRunTab(tabPlacement, current, offset); break; - case EAST: + case EAST : offset = getTabRunOffset(tabPlacement, tabCount, current, true); selectAdjacentRunTab(tabPlacement, current, offset); break; - default: + default : } break; - case BOTTOM: - case TOP: - default: + case BOTTOM : + case TOP : + default : switch (direction) { - case NEXT: + case NEXT : selectNextTab(current); break; - case PREVIOUS: + case PREVIOUS : selectPreviousTab(current); break; - case NORTH: + case NORTH : offset = getTabRunOffset(tabPlacement, tabCount, current, false); selectAdjacentRunTab(tabPlacement, current, offset); break; - case SOUTH: + case SOUTH : offset = getTabRunOffset(tabPlacement, tabCount, current, true); selectAdjacentRunTab(tabPlacement, current, offset); break; - case EAST: + case EAST : if (leftToRight) { selectNextTabInRun(current); } else { selectPreviousTabInRun(current); } break; - case WEST: + case WEST : if (leftToRight) { selectPreviousTabInRun(current); } else { selectNextTabInRun(current); } break; - default: + default : } } } @@ -1810,8 +1808,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi navigateTo(tabIndex); } - -// Tab Navigation methods + // Tab Navigation methods /** * Select the previous tab in the run. @@ -1871,14 +1868,14 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi int newIndex; Rectangle r = rects[tabIndex]; switch (tabPlacement) { - case LEFT: - case RIGHT: + case LEFT : + case RIGHT : newIndex = tabForCoordinate(tabPane, r.x + r.width / 2 + offset, r.y + r.height / 2); break; - case BOTTOM: - case TOP: - default: + case BOTTOM : + case TOP : + default : newIndex = tabForCoordinate(tabPane, r.x + r.width / 2, r.y + r.height / 2 + offset); } @@ -1944,19 +1941,19 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi } /** - * Returns the bounds of the specified tab in the coordinate space of the JTabbedPane component. This is required + * Returns the bounds of the specified tab in the coordinate space of the JTabbedPane component. This is required * because the tab rects are by default defined in the coordinate space of the component where they are rendered, * which could be the JTabbedPane (for WRAP_TAB_LAYOUT) or a ScrollableTabPanel (SCROLL_TAB_LAYOUT). This method * should be used whenever the tab rectangle must be relative to the JTabbedPane itself and the result should be * placed in a designated Rectangle object (rather than instantiating and returning a new Rectangle each time). The - * tab index parameter must be a valid tabbed pane tab index (0 to tab count - 1, inclusive). The destination + * tab index parameter must be a valid tabbed pane tab index (0 to tab count - 1, inclusive). The destination * rectangle parameter must be a valid Rectangle instance. The handling of invalid parameters is * unspecified. * - * @param tabIndex the index of the tab - * @param dest the rectangle where the result should be placed - * @return the resulting rectangle - * @since 1.4 + * @param tabIndex the index of the tab + * @param dest the rectangle where the result should be placed + * @return the resulting rectangle + * @since 1.4 */ protected Rectangle getTabBounds(final int tabIndex, final Rectangle dest) { dest.width = rects[tabIndex].width; @@ -1981,9 +1978,9 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi * Returns the index of the tab closest to the passed in location, note that the returned tab may not contain the * location x,y. * - * @param x the x - * @param y the y - * @return the closest tab + * @param x the x + * @param y the y + * @return the closest tab */ protected int getClosestTab(final int x, final int y) { int min = 0; @@ -2026,7 +2023,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi * Returns the index of the tab that has focus. * * @return index of tab that has focus - * @since 1.5 + * @since 1.5 */ protected int getFocusIndex() { return focusIndex; @@ -2035,70 +2032,62 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * Returns the tab run offset. * - * @param tabPlacement the placement (left, right, bottom, top) of the tab - * @param tabCount the tab count - * @param tabIndex the index of the tab with respect to other tabs - * @param forward forward or not - * @return the tab run offset + * @param tabPlacement the placement (left, right, bottom, top) of the tab + * @param tabCount the tab count + * @param tabIndex the index of the tab with respect to other tabs + * @param forward forward or not + * @return the tab run offset */ protected int getTabRunOffset(final int tabPlacement, final int tabCount, final int tabIndex, final boolean forward) { int run = getRunForTab(tabCount, tabIndex); int offset; switch (tabPlacement) { - case LEFT: { + case LEFT : { if (run == 0) { - offset = (forward ? - -(calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth) - maxTabWidth) : - -maxTabWidth); + offset = (forward ? -(calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth) - maxTabWidth) + : -maxTabWidth); } else if (run == runCount - 1) { - offset = (forward ? - maxTabWidth : - calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth) - maxTabWidth); + offset = (forward ? maxTabWidth + : calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth) - maxTabWidth); } else { offset = (forward ? maxTabWidth : -maxTabWidth); } break; } - case RIGHT: { + case RIGHT : { if (run == 0) { - offset = (forward ? - maxTabWidth : - calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth) - maxTabWidth); + offset = (forward ? maxTabWidth + : calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth) - maxTabWidth); } else if (run == runCount - 1) { - offset = (forward ? - -(calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth) - maxTabWidth) : - -maxTabWidth); + offset = (forward ? -(calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth) - maxTabWidth) + : -maxTabWidth); } else { offset = (forward ? maxTabWidth : -maxTabWidth); } break; } - case BOTTOM: { + case BOTTOM : { if (run == 0) { - offset = (forward ? - maxTabHeight : - calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight) - maxTabHeight); + offset = (forward ? maxTabHeight + : calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight) - maxTabHeight); } else if (run == runCount - 1) { - offset = (forward ? - -(calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight) - maxTabHeight) : - -maxTabHeight); + offset = (forward ? -(calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight) - maxTabHeight) + : -maxTabHeight); } else { offset = (forward ? maxTabHeight : -maxTabHeight); } break; } - case TOP: - default: { + case TOP : + default : { if (run == 0) { - offset = (forward ? - -(calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight) - maxTabHeight) : - -maxTabHeight); + offset = (forward ? -(calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight) - maxTabHeight) + : -maxTabHeight); } else if (run == runCount - 1) { - offset = (forward ? - maxTabHeight : - calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight) - maxTabHeight); + offset = (forward ? maxTabHeight + : calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight) - maxTabHeight); } else { offset = (forward ? maxTabHeight : -maxTabHeight); } @@ -2110,8 +2099,8 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * Returns the previous tab index. * - * @param base the base - * @return the previous tab index + * @param base the base + * @return the previous tab index */ protected int getPreviousTabIndex(final int base) { int tabIndex = (base - 1 >= 0 ? base - 1 : tabPane.getTabCount() - 1); @@ -2121,8 +2110,8 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * Returns the next tab index. * - * @param base the base - * @return the next tab index + * @param base the base + * @return the next tab index */ protected int getNextTabIndex(final int base) { return (base + 1) % tabPane.getTabCount(); @@ -2131,9 +2120,9 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * Returns the next tab index in the run. * - * @param tabCount the tab count - * @param base the base - * @return the next tab index in the run + * @param tabCount the tab count + * @param base the base + * @return the next tab index in the run */ protected int getNextTabIndexInRun(final int tabCount, final int base) { if (runCount < 2) { @@ -2150,9 +2139,9 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * Returns the previous tab index in the run. * - * @param tabCount the tab count - * @param base the base - * @return the previous tab index in the run + * @param tabCount the tab count + * @param base the base + * @return the previous tab index in the run */ protected int getPreviousTabIndexInRun(final int tabCount, final int base) { if (runCount < 2) { @@ -2169,8 +2158,8 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * Returns the previous tab run. * - * @param baseRun the base run - * @return the previous tab run + * @param baseRun the base run + * @return the previous tab run */ protected int getPreviousTabRun(final int baseRun) { int runIndex = (baseRun - 1 >= 0 ? baseRun - 1 : runCount - 1); @@ -2180,8 +2169,8 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * Returns the next tab run. * - * @param baseRun the base run - * @return the next tab run + * @param baseRun the base run + * @return the next tab run */ protected int getNextTabRun(final int baseRun) { return (baseRun + 1) % runCount; @@ -2192,7 +2181,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi * * @return the boolean */ -// REMIND(aim,7/29/98): This method should be made + // REMIND(aim,7/29/98): This method should be made // protected in the next release where // API changes are allowed boolean requestFocusForVisibleComponent() { @@ -2270,8 +2259,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi /** * The Request focus for visible. */ - static final String REQUEST_FOCUS_FOR_VISIBLE = - "requestFocusForVisibleComponent"; + static final String REQUEST_FOCUS_FOR_VISIBLE = "requestFocusForVisibleComponent"; /** * The Set selected. */ @@ -2302,8 +2290,8 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi String key = getName(); JTabbedPane pane = (JTabbedPane) e.getSource(); DarkTabbedPaneUIBridge ui = (DarkTabbedPaneUIBridge) DarkUIUtil - .getUIOfType(pane.getUI(), - DarkTabbedPaneUIBridge.class); + .getUIOfType(pane.getUI(), + DarkTabbedPaneUIBridge.class); if (ui == null) { return; @@ -2360,8 +2348,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi } } - -// Controller: event listeners + // Controller: event listeners /** * The type Tab container. @@ -2418,5 +2405,4 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi return true; } } - } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/MoreTabsButton.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/MoreTabsButton.java index a46b0ccf..041146cf 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/MoreTabsButton.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/MoreTabsButton.java @@ -20,17 +20,19 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabbedpane; +import java.awt.*; + +import javax.swing.*; + import com.github.weisj.darklaf.icons.EmptyIcon; import com.github.weisj.darklaf.ui.button.DarkButtonUI; import com.github.weisj.darklaf.util.GraphicsContext; import com.github.weisj.darklaf.util.GraphicsUtil; -import javax.swing.*; -import java.awt.*; - public class MoreTabsButton extends DarkTabAreaButton { protected final static String INFINITY = "\u221e"; @@ -63,7 +65,6 @@ public class MoreTabsButton extends DarkTabAreaButton { int x = (getWidth() - (icon.getIconWidth() + labelWidth + pad)) / 2; int y = (getHeight() - icon.getIconHeight()) / 2; - GraphicsContext config = GraphicsUtil.setupAntialiasing(g); /* * These offsets are due to the nature of the used icon. They are applied to match the baseline of @@ -85,7 +86,6 @@ public class MoreTabsButton extends DarkTabAreaButton { config.restore(); } - protected String getLabelString() { int invisible = Math.min(ui.minVisible - 1 + ui.tabPane.getTabCount() - ui.maxVisible, ui.tabPane.getTabCount()); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/NewTabButton.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/NewTabButton.java index a4aaf579..17a87fb8 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/NewTabButton.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/NewTabButton.java @@ -20,15 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabbedpane; -import com.github.weisj.darklaf.components.uiresource.JButtonUIResource; -import com.github.weisj.darklaf.ui.button.DarkButtonUI; +import java.awt.*; import javax.swing.*; import javax.swing.plaf.UIResource; -import java.awt.*; + +import com.github.weisj.darklaf.components.uiresource.JButtonUIResource; +import com.github.weisj.darklaf.ui.button.DarkButtonUI; public class NewTabButton extends JPanel implements UIResource { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/ScrollableTabPanel.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/ScrollableTabPanel.java index 21d4d45b..8505b45d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/ScrollableTabPanel.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/ScrollableTabPanel.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabbedpane; +import java.awt.*; + import javax.swing.*; import javax.swing.plaf.UIResource; -import java.awt.*; public class ScrollableTabPanel extends JPanel implements UIResource { private final DarkTabbedPaneUIBridge ui; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/ScrollableTabSupport.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/ScrollableTabSupport.java index 7d7fda0f..06ae9f3b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/ScrollableTabSupport.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/ScrollableTabSupport.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabbedpane; @@ -41,8 +42,7 @@ class ScrollableTabSupport { /** * Recreates the scroll buttons and adds them to the TabbedPane. */ - void createButtons(final DarkTabbedPaneUIBridge ui) { - } + void createButtons(final DarkTabbedPaneUIBridge ui) {} public String toString() { return "viewport.viewSize=" + viewport.getViewSize() + "\n" + @@ -50,5 +50,4 @@ class ScrollableTabSupport { "leadingTabIndex=" + leadingTabIndex + "\n" + "tabViewPosition=" + tabViewPosition; } - } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/ScrollableTabViewport.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/ScrollableTabViewport.java index 63559bc4..231bd533 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/ScrollableTabViewport.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/ScrollableTabViewport.java @@ -20,15 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabbedpane; +import java.awt.*; + import javax.swing.*; import javax.swing.plaf.UIResource; -import java.awt.*; @SuppressWarnings("serial") - // Superclass is not serializable across versions +// Superclass is not serializable across versions class ScrollableTabViewport extends JViewport implements UIResource { public ScrollableTabViewport(final DarkTabbedPaneUIBridge ui) { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneHandler.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneHandler.java index ca2d3b27..57696d94 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneHandler.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneHandler.java @@ -20,11 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabbedpane; -import com.github.weisj.darklaf.util.DarkSwingUtil; -import com.github.weisj.darklaf.util.PropertyKey; +import java.awt.*; +import java.awt.event.*; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.Objects; import javax.swing.*; import javax.swing.event.ChangeEvent; @@ -32,14 +36,12 @@ import javax.swing.event.ChangeListener; import javax.swing.plaf.UIResource; import javax.swing.plaf.basic.BasicHTML; import javax.swing.text.View; -import java.awt.*; -import java.awt.event.*; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.Objects; + +import com.github.weisj.darklaf.util.DarkSwingUtil; +import com.github.weisj.darklaf.util.PropertyKey; public class TabbedPaneHandler implements ChangeListener, ContainerListener, FocusListener, - MouseListener, MouseMotionListener, PropertyChangeListener { + MouseListener, MouseMotionListener, PropertyChangeListener { private final DarkTabbedPaneUIBridge ui; // @@ -50,7 +52,6 @@ public class TabbedPaneHandler implements ChangeListener, ContainerListener, Foc this.ui = ui; } - public void propertyChange(final PropertyChangeEvent e) { JTabbedPane pane = (JTabbedPane) e.getSource(); String name = e.getPropertyName(); @@ -85,8 +86,7 @@ public class TabbedPaneHandler implements ChangeListener, ContainerListener, Foc if (ui.tabContainer != null) { ui.tabContainer.removeUnusedTabComponents(); } - Component c = ui.tabPane.getTabComponentAt( - (Integer) e.getNewValue()); + Component c = ui.tabPane.getTabComponentAt((Integer) e.getNewValue()); if (c != null) { if (ui.tabContainer == null) { ui.installTabContainer(); @@ -109,16 +109,16 @@ public class TabbedPaneHandler implements ChangeListener, ContainerListener, Foc String title = ui.tabPane.getTitleAt(index); boolean isHTML = BasicHTML.isHTMLString(title); if (isHTML) { - if (ui.htmlViews == null) { // Initialize vector + if (ui.htmlViews == null) { // Initialize vector ui.htmlViews = ui.createHTMLVector(); - } else { // Vector already exists + } else { // Vector already exists View v = BasicHTML.createHTMLView(ui.tabPane, title); setHtmlView(v, inserted, index); } - } else { // Not HTML - if (ui.htmlViews != null) { // Add placeholder + } else { // Not HTML + if (ui.htmlViews != null) { // Add placeholder setHtmlView(null, inserted, index); - } // else nada! + } // else nada! } ui.updateMnemonics(); } @@ -145,8 +145,7 @@ public class TabbedPaneHandler implements ChangeListener, ContainerListener, Foc ui.ensureCurrentLayout(); int index = tabPane.getSelectedIndex(); if (index < ui.rects.length && index != -1) { - ui.tabScroller.tabPanel.scrollRectToVisible( - (Rectangle) ui.rects[index].clone()); + ui.tabScroller.tabPanel.scrollRectToVisible((Rectangle) ui.rects[index].clone()); } } } @@ -154,8 +153,7 @@ public class TabbedPaneHandler implements ChangeListener, ContainerListener, Foc // // MouseListener // - public void mouseClicked(final MouseEvent e) { - } + public void mouseClicked(final MouseEvent e) {} public void mousePressed(final MouseEvent e) { if (!ui.tabPane.isEnabled()) { @@ -171,14 +169,13 @@ public class TabbedPaneHandler implements ChangeListener, ContainerListener, Foc ui.tabPane.setSelectedIndex(tabIndex); } else if (ui.tabPane.isRequestFocusEnabled()) { // Clicking on selected tab, try and give the tabbedpane - // focus. Repaint will occur in focusGained. + // focus. Repaint will occur in focusGained. ui.tabPane.requestFocus(); } } } - public void mouseReleased(final MouseEvent e) { - } + public void mouseReleased(final MouseEvent e) {} public void mouseEntered(final MouseEvent e) { ui.setRolloverTab(e.getX(), e.getY()); @@ -191,8 +188,7 @@ public class TabbedPaneHandler implements ChangeListener, ContainerListener, Foc // // MouseMotionListener // - public void mouseDragged(final MouseEvent e) { - } + public void mouseDragged(final MouseEvent e) {} public void mouseMoved(final MouseEvent e) { ui.setRolloverTab(e.getX(), e.getY()); @@ -209,40 +205,40 @@ public class TabbedPaneHandler implements ChangeListener, ContainerListener, Foc ui.repaintTab(ui.focusIndex); } - // // ContainerListener // -/* GES 2/3/99: - The container listener code was added to support HTML - rendering of tab titles. - - Ideally, we would be able to listen for property changes - when a tab is added or its text modified. At the moment - there are no such events because the Beans spec doesn't - allow 'indexed' property changes (i.e. tab 2's text changed - from A to B). - - In order to get around this, we listen for tabs to be added - or removed by listening for the container events. we then - queue up a runnable (so the component has a chance to complete - the add) which checks the tab title of the new component to see - if it requires HTML rendering. - - The Views (one per tab title requiring HTML rendering) are - stored in the htmlViews Vector, which is only allocated after - the first time we run into an HTML tab. Note that this vector - is kept in step with the number of pages, and nulls are added - for those pages whose tab title do not require HTML rendering. - - This makes it easy for the paint and layout code to tell - whether to invoke the HTML engine without having to check - the string during time-sensitive operations. - - When we have added a way to listen for tab additions and - changes to tab text, this code should be removed and - replaced by something which uses that. */ - + /* + * GES 2/3/99: + * The container listener code was added to support HTML + * rendering of tab titles. + * + * Ideally, we would be able to listen for property changes + * when a tab is added or its text modified. At the moment + * there are no such events because the Beans spec doesn't + * allow 'indexed' property changes (i.e. tab 2's text changed + * from A to B). + * + * In order to get around this, we listen for tabs to be added + * or removed by listening for the container events. we then + * queue up a runnable (so the component has a chance to complete + * the add) which checks the tab title of the new component to see + * if it requires HTML rendering. + * + * The Views (one per tab title requiring HTML rendering) are + * stored in the htmlViews Vector, which is only allocated after + * the first time we run into an HTML tab. Note that this vector + * is kept in step with the number of pages, and nulls are added + * for those pages whose tab title do not require HTML rendering. + * + * This makes it easy for the paint and layout code to tell + * whether to invoke the HTML engine without having to check + * the string during time-sensitive operations. + * + * When we have added a way to listen for tab additions and + * changes to tab text, this code should be removed and + * replaced by something which uses that. + */ public void componentAdded(final ContainerEvent e) { JTabbedPane tp = (JTabbedPane) e.getContainer(); Component child = e.getChild(); @@ -262,7 +258,7 @@ public class TabbedPaneHandler implements ChangeListener, ContainerListener, Foc // NOTE 4/15/2002 (joutwate): // This fix is implemented using client properties since there is - // currently no IndexPropertyChangeEvent. Once + // currently no IndexPropertyChangeEvent. Once // IndexPropertyChangeEvents have been added this code should be // modified to use it. Integer indexObj = (Integer) tp.getClientProperty("__index_to_remove__"); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneLayout.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneLayout.java index c697974d..f5bafc22 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneLayout.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneLayout.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabbedpane; -import javax.swing.*; import java.awt.*; +import javax.swing.*; + /** * This class should be treated as a "protected" inner class. Instantiate it only within subclasses of * BasicTabbedPaneUI. @@ -38,11 +40,9 @@ public abstract class TabbedPaneLayout implements LayoutManager { this.ui = ui; } - public void addLayoutComponent(final String name, final Component comp) { - } + public void addLayoutComponent(final String name, final Component comp) {} - public void removeLayoutComponent(final Component comp) { - } + public void removeLayoutComponent(final Component comp) {} public Dimension preferredLayoutSize(final Container parent) { return calculateSize(false); @@ -57,7 +57,8 @@ public abstract class TabbedPaneLayout implements LayoutManager { */ @SuppressWarnings("deprecation") public void layoutContainer(final Container parent) { - /* Some of the code in this method deals with changing the + /* + * Some of the code in this method deals with changing the * visibility of components to hide and show the contents for the * selected tab. This is older code that has since been duplicated * in JTabbedPane.fireStateChanged(), so as to allow visibility @@ -67,7 +68,6 @@ public abstract class TabbedPaneLayout implements LayoutManager { * Any changes here need to be kept in synch with * JTabbedPane.fireStateChanged(). */ - ui.setRolloverTab(-1); int tabPlacement = ui.tabPane.getTabPlacement(); @@ -96,7 +96,7 @@ public abstract class TabbedPaneLayout implements LayoutManager { // In order to allow programs to use a single component // as the display for multiple tabs, we will not change // the visible compnent if the currently selected tab - // has a null component. This is a bit dicey, as we don't + // has a null component. This is a bit dicey, as we don't // explicitly state we support this in the spec, but since // programs are now depending on this, we're making it work. // @@ -116,23 +116,23 @@ public abstract class TabbedPaneLayout implements LayoutManager { if (numChildren > 0) { switch (tabPlacement) { - case SwingConstants.LEFT: + case SwingConstants.LEFT : totalTabWidth = ui.calculateTabAreaWidth(tabPlacement, ui.runCount, ui.maxTabWidth); cx = insets.left + totalTabWidth + contentInsets.left; cy = insets.top + contentInsets.top; break; - case SwingConstants.RIGHT: + case SwingConstants.RIGHT : totalTabWidth = ui.calculateTabAreaWidth(tabPlacement, ui.runCount, ui.maxTabWidth); cx = insets.left + contentInsets.left; cy = insets.top + contentInsets.top; break; - case SwingConstants.BOTTOM: + case SwingConstants.BOTTOM : totalTabHeight = ui.calculateTabAreaHeight(tabPlacement, ui.runCount, ui.maxTabHeight); cx = insets.left + contentInsets.left; cy = insets.top + contentInsets.top; break; - case SwingConstants.TOP: - default: + case SwingConstants.TOP : + default : totalTabHeight = ui.calculateTabAreaHeight(tabPlacement, ui.runCount, ui.maxTabHeight); cx = insets.left + contentInsets.left; cy = insets.top + totalTabHeight + contentInsets.top; @@ -149,12 +149,12 @@ public abstract class TabbedPaneLayout implements LayoutManager { Component child = ui.tabPane.getComponent(i); if (child == ui.tabContainer) { - int tabContainerWidth = totalTabWidth == 0 ? bounds.width : - totalTabWidth + insets.left + insets.right + - contentInsets.left + contentInsets.right; - int tabContainerHeight = totalTabHeight == 0 ? bounds.height : - totalTabHeight + insets.top + insets.bottom + - contentInsets.top + contentInsets.bottom; + int tabContainerWidth = totalTabWidth == 0 ? bounds.width + : totalTabWidth + insets.left + insets.right + + contentInsets.left + contentInsets.right; + int tabContainerHeight = totalTabHeight == 0 ? bounds.height + : totalTabHeight + insets.top + insets.bottom + + contentInsets.top + contentInsets.bottom; int tabContainerX = 0; int tabContainerY = 0; @@ -208,7 +208,7 @@ public abstract class TabbedPaneLayout implements LayoutManager { int outerY = rect.y + insets.top + delta.y; int outerWidth = rect.width - insets.left - insets.right; int outerHeight = rect.height - insets.top - insets.bottom; - //centralize component + // centralize component int x = outerX + (outerWidth - preferredSize.width) / 2; int y = outerY + (outerHeight - preferredSize.height) / 2; int tabPlacement = ui.tabPane.getTabPlacement(); @@ -243,26 +243,26 @@ public abstract class TabbedPaneLayout implements LayoutManager { // Calculate bounds within which a tab run must fit // switch (tabPlacement) { - case SwingConstants.LEFT: + case SwingConstants.LEFT : ui.maxTabWidth = ui.calculateMaxTabWidth(tabPlacement); x = insets.left + tabAreaInsets.left; y = insets.top + tabAreaInsets.top; returnAt = size.height - (insets.bottom + tabAreaInsets.bottom); break; - case SwingConstants.RIGHT: + case SwingConstants.RIGHT : ui.maxTabWidth = ui.calculateMaxTabWidth(tabPlacement); x = size.width - insets.right - tabAreaInsets.right - ui.maxTabWidth; y = insets.top + tabAreaInsets.top; returnAt = size.height - (insets.bottom + tabAreaInsets.bottom); break; - case SwingConstants.BOTTOM: + case SwingConstants.BOTTOM : ui.maxTabHeight = ui.calculateMaxTabHeight(tabPlacement); x = insets.left + tabAreaInsets.left; y = size.height - insets.bottom - tabAreaInsets.bottom - ui.maxTabHeight; returnAt = size.width - (insets.right + tabAreaInsets.right); break; - case SwingConstants.TOP: - default: + case SwingConstants.TOP : + default : ui.maxTabHeight = ui.calculateMaxTabHeight(tabPlacement); x = insets.left + tabAreaInsets.left; y = insets.top + tabAreaInsets.top; @@ -310,7 +310,7 @@ public abstract class TabbedPaneLayout implements LayoutManager { } // Initialize y position in case there's just one run rect.y = y; - rect.height = ui.maxTabHeight/* - 2*/; + rect.height = ui.maxTabHeight/* - 2 */; } else { // Tabs on LEFT or RIGHT... @@ -338,7 +338,7 @@ public abstract class TabbedPaneLayout implements LayoutManager { } // Initialize x position in case there's just one column rect.x = x; - rect.width = ui.maxTabWidth/* - 2*/; + rect.width = ui.maxTabWidth/* - 2 */; } if (i == selectedIndex) { @@ -435,7 +435,7 @@ public abstract class TabbedPaneLayout implements LayoutManager { // // Starting with the last run, determine whether the last tab in // the previous run would fit (generously) in this run; if so, - // move tab to current run and shift tabs accordingly. Cycle + // move tab to current run and shift tabs accordingly. Cycle // through remaining runs using the same algorithm. // while (keepAdjusting) { @@ -590,8 +590,8 @@ public abstract class TabbedPaneLayout implements LayoutManager { /** * Returns the calculated size. * - * @param minimum use the minimum size or preferred size - * @return the calculated size + * @param minimum use the minimum size or preferred size + * @return the calculated size */ protected Dimension calculateSize(final boolean minimum) { int tabPlacement = ui.tabPane.getTabPlacement(); @@ -611,8 +611,7 @@ public abstract class TabbedPaneLayout implements LayoutManager { for (int i = 0; i < ui.tabPane.getTabCount(); i++) { Component component = ui.tabPane.getComponentAt(i); if (component != null) { - Dimension size = minimum ? component.getMinimumSize() : - component.getPreferredSize(); + Dimension size = minimum ? component.getMinimumSize() : component.getPreferredSize(); if (size != null) { cHeight = Math.max(size.height, cHeight); @@ -629,15 +628,15 @@ public abstract class TabbedPaneLayout implements LayoutManager { // minimum size required to display largest child + content border // switch (tabPlacement) { - case SwingConstants.LEFT: - case SwingConstants.RIGHT: + case SwingConstants.LEFT : + case SwingConstants.RIGHT : height = Math.max(height, ui.calculateMaxTabHeight(tabPlacement)); tabExtent = preferredTabAreaWidth(tabPlacement, height - tabAreaInsets.top - tabAreaInsets.bottom); width += tabExtent; break; - case SwingConstants.TOP: - case SwingConstants.BOTTOM: - default: + case SwingConstants.TOP : + case SwingConstants.BOTTOM : + default : width = Math.max(width, ui.calculateMaxTabWidth(tabPlacement)); tabExtent = preferredTabAreaHeight(tabPlacement, width - tabAreaInsets.left - tabAreaInsets.right); height += tabExtent; @@ -650,9 +649,9 @@ public abstract class TabbedPaneLayout implements LayoutManager { /** * Returns the preferred tab area width. * - * @param tabPlacement the tab placement - * @param height the height - * @return the preferred tab area widty + * @param tabPlacement the tab placement + * @param height the height + * @return the preferred tab area widty */ protected int preferredTabAreaWidth(final int tabPlacement, final int height) { FontMetrics metrics = ui.getFontMetrics(); @@ -682,9 +681,9 @@ public abstract class TabbedPaneLayout implements LayoutManager { /** * Returns the preferred tab area height. * - * @param tabPlacement the tab placement - * @param width the width - * @return the preferred tab area height + * @param tabPlacement the tab placement + * @param width the width + * @return the preferred tab area height */ protected int preferredTabAreaHeight(final int tabPlacement, final int width) { FontMetrics metrics = ui.getFontMetrics(); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneScrollLayout.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneScrollLayout.java index 769dd938..c098d7b6 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneScrollLayout.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneScrollLayout.java @@ -20,12 +20,12 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabbedpane; abstract class TabbedPaneScrollLayout extends TabbedPaneLayout { - public TabbedPaneScrollLayout(final DarkTabbedPaneUIBridge ui) { super(ui); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneTransferHandler.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneTransferHandler.java index 1b42e72d..9e5a27fb 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneTransferHandler.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneTransferHandler.java @@ -20,13 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabbedpane; -import com.github.weisj.darklaf.util.ImageUtil; - -import javax.swing.*; -import javax.swing.plaf.TabbedPaneUI; import java.awt.*; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; @@ -35,6 +32,10 @@ import java.awt.dnd.*; import java.awt.event.InputEvent; import java.awt.event.MouseEvent; +import javax.swing.*; +import javax.swing.plaf.TabbedPaneUI; + +import com.github.weisj.darklaf.util.ImageUtil; /** * @author Robert Futrell @@ -54,12 +55,10 @@ public class TabbedPaneTransferHandler extends TransferHandler implements DropTa private DataFlavor tabFlavor; private TabTransferable currentTransferable; - public TabbedPaneTransferHandler() { try { tabFlavor = new DataFlavor(MIME_TYPE); - } catch (ClassNotFoundException ignored) { - } + } catch (ClassNotFoundException ignored) {} } public void exportAsDrag(final JComponent comp, final InputEvent e, final int a) { @@ -87,13 +86,13 @@ public class TabbedPaneTransferHandler extends TransferHandler implements DropTa } /** - * Called when the drag-and-drop operation has just completed. This creates a new tab identical to the one + * Called when the drag-and-drop operation has just completed. This creates a new tab identical to the one * "dragged" and places it in the destination JTabbedPane. * - * @param c The component receiving the "drop" (the instance of - * JTabbedPane). - * @param t The data being transfered (information about the tab and the component contained by the tab). - * @return Whether or not the import was successful. + * @param c The component receiving the "drop" (the instance of + * JTabbedPane). + * @param t The data being transfered (information about the tab and the component contained by the tab). + * @return Whether or not the import was successful. */ @Override public boolean importData(final JComponent c, final Transferable t) { @@ -132,8 +131,8 @@ public class TabbedPaneTransferHandler extends TransferHandler implements DropTa /** * We can only move tabs, we cannot copy them. * - * @param c This parameter is ignored. - * @return TransferHandler.MOVE, as we can only move tabs. + * @param c This parameter is ignored. + * @return TransferHandler.MOVE, as we can only move tabs. */ @Override public int getSourceActions(final JComponent c) { @@ -190,7 +189,6 @@ public class TabbedPaneTransferHandler extends TransferHandler implements DropTa return false; } - private DarkTabbedPaneUI supportsIndicator(final Component c) { if (c instanceof JTabbedPane) { TabbedPaneUI ui = ((JTabbedPane) c).getUI(); @@ -202,8 +200,7 @@ public class TabbedPaneTransferHandler extends TransferHandler implements DropTa } @Override - public void dragEnter(final DropTargetDragEvent e) { - } + public void dragEnter(final DropTargetDragEvent e) {} @Override public void dragOver(final DropTargetDragEvent e) { @@ -236,8 +233,7 @@ public class TabbedPaneTransferHandler extends TransferHandler implements DropTa } @Override - public void dropActionChanged(final DropTargetDragEvent e) { - } + public void dropActionChanged(final DropTargetDragEvent e) {} @Override public void dragExit(final DropTargetEvent e) { @@ -258,7 +254,6 @@ public class TabbedPaneTransferHandler extends TransferHandler implements DropTa } } - protected static class TabbedPaneDragGestureRecognizer extends DragGestureRecognizer { protected TabbedPaneDragGestureRecognizer(final DragGestureListener dgl) { @@ -275,16 +270,14 @@ public class TabbedPaneTransferHandler extends TransferHandler implements DropTa /** * register this DragGestureRecognizer's Listeners with the Component */ - protected void registerListeners() { - } + protected void registerListeners() {} /** * unregister this DragGestureRecognizer's Listeners with the Component *

* subclasses must override this method */ - protected void unregisterListeners() { - } + protected void unregisterListeners() {} } public static class UIResource extends TabbedPaneTransferHandler { @@ -318,7 +311,6 @@ public class TabbedPaneTransferHandler extends TransferHandler implements DropTa return tabFlavor.equals(flavor); } - @Override public Object getTransferData(final DataFlavor flavor) throws UnsupportedFlavorException { if (!isDataFlavorSupported(flavor)) { @@ -336,15 +328,12 @@ public class TabbedPaneTransferHandler extends TransferHandler implements DropTa private final int tabIndex; private final Rectangle tabBounds; - public TabTransferData(final JTabbedPane tabbedPane, final int tabIndex) { this.sourceTabbedPane = tabbedPane; this.tabIndex = tabIndex; this.tabBounds = tabbedPane.getBoundsAt(tabIndex); } - } - } protected class TabbedPaneDragHandler implements DragGestureListener, DragSourceListener { @@ -384,23 +373,19 @@ public class TabbedPaneTransferHandler extends TransferHandler implements DropTa /** * as the hotspot enters a platform dependent drop site */ - public void dragEnter(final DragSourceDragEvent dsde) { - } + public void dragEnter(final DragSourceDragEvent dsde) {} /** * as the hotspot moves over a platform dependent drop site */ - public void dragOver(final DragSourceDragEvent dsde) { - } + public void dragOver(final DragSourceDragEvent dsde) {} - public void dropActionChanged(final DragSourceDragEvent dsde) { - } + public void dropActionChanged(final DragSourceDragEvent dsde) {} /** * as the hotspot exits a platform dependent drop site */ - public void dragExit(final DragSourceEvent dsde) { - } + public void dragExit(final DragSourceEvent dsde) {} /** * as the operation completes diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneUtil.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneUtil.java index bc5d6da7..4cc06ec6 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneUtil.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneUtil.java @@ -20,13 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabbedpane; -import com.github.weisj.darklaf.util.DarkUIUtil; +import java.awt.*; import javax.swing.*; -import java.awt.*; + +import com.github.weisj.darklaf.util.DarkUIUtil; /** * @author Jannis Weis @@ -84,8 +86,8 @@ public class TabbedPaneUtil implements SwingConstants { Rectangle sb = (ui.scrollableTabLayoutEnabled()) ? tabBounds : EMPTY_RECT; switch (tabbedPane.getTabPlacement()) { - case TOP: - case BOTTOM: + case TOP : + case BOTTOM : if (tabbedPane.getComponentOrientation().isLeftToRight()) { if (p.x >= b.x + sb.width + (b.width - sb.width) / 2) { tab += 1; @@ -96,8 +98,8 @@ public class TabbedPaneUtil implements SwingConstants { } } break; - case LEFT: - case RIGHT: + case LEFT : + case RIGHT : if (p.y >= b.y + sb.height + (b.height - sb.height) / 2) { tab += 1; } @@ -111,7 +113,6 @@ public class TabbedPaneUtil implements SwingConstants { return tab; } - public static Rectangle getDropRect(final DarkTabbedPaneUI ui, final JTabbedPane destTabbedPane, final JTabbedPane source, final Point mouseLocation, final Rectangle tabBounds, @@ -143,8 +144,8 @@ public class TabbedPaneUtil implements SwingConstants { } switch (tabPlacement) { - case TOP: - case BOTTOM: + case TOP : + case BOTTOM : if (destTabbedPane.getComponentOrientation().isLeftToRight()) { if (tab >= destTabbedPane.getTabCount() && !lastInSource) { destRect.x += destRect.width; @@ -167,8 +168,8 @@ public class TabbedPaneUtil implements SwingConstants { } tabBounds.y = destRect.y + destRect.height - tabBounds.height; break; - case LEFT: - case RIGHT: + case LEFT : + case RIGHT : if (tab >= destTabbedPane.getTabCount()) { destRect.y += destRect.height; } @@ -240,7 +241,7 @@ public class TabbedPaneUtil implements SwingConstants { final int sourceIndex, final int tab) { if (tabbedPane == sourcePane && sourceIndex == tab) { - //Nothing to do. Just select the tab to be sure. + // Nothing to do. Just select the tab to be sure. Component comp = sourcePane.getTabComponentAt(tab); if (comp != null) comp.setVisible(true); selectTab(sourcePane, sourceIndex); @@ -280,7 +281,7 @@ public class TabbedPaneUtil implements SwingConstants { } /** - * Selects the specified tab in the specified tabbed pane. This method can be overridden by subclasses to do more + * Selects the specified tab in the specified tabbed pane. This method can be overridden by subclasses to do more * stuff than simply select the tab. * * @param tabbedPane The tabbed pane. diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkPanelPopupUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkPanelPopupUI.java index f22f7c2b..b498f8ee 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkPanelPopupUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkPanelPopupUI.java @@ -20,9 +20,23 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabframe; +import java.awt.*; +import java.awt.event.AWTEventListener; +import java.awt.event.ActionEvent; +import java.awt.event.FocusEvent; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +import javax.swing.*; +import javax.swing.FocusManager; +import javax.swing.border.EmptyBorder; +import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.UIResource; + import com.github.weisj.darklaf.components.border.MutableLineBorder; import com.github.weisj.darklaf.components.tabframe.JTabFrame; import com.github.weisj.darklaf.components.tabframe.PanelPopup; @@ -35,20 +49,8 @@ import com.github.weisj.darklaf.ui.tooltip.ToolTipConstants; import com.github.weisj.darklaf.util.Alignment; import com.github.weisj.darklaf.util.DarkUIUtil; -import javax.swing.FocusManager; -import javax.swing.*; -import javax.swing.border.EmptyBorder; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.UIResource; -import java.awt.*; -import java.awt.event.AWTEventListener; -import java.awt.event.ActionEvent; -import java.awt.event.FocusEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - public class DarkPanelPopupUI extends DarkPanelUI implements PropertyChangeListener, AWTEventListener, - TabFramePopupUI { + TabFramePopupUI { protected HeaderButton closeButton; private final Action closeAction = new AbstractAction() { @@ -72,7 +74,6 @@ public class DarkPanelPopupUI extends DarkPanelUI implements PropertyChangeListe private MutableLineBorder contentBorder; private boolean oldFocus; - public static ComponentUI createUI(final JComponent c) { return new DarkPanelPopupUI(); } @@ -282,7 +283,7 @@ public class DarkPanelPopupUI extends DarkPanelUI implements PropertyChangeListe try { Component peer = tabFrame.getPopupComponentAt(tabFrame.getPeer(popupComponent.getAlignment())); peer.firePropertyChange(TabFramePopup.KEY_PEER_INSETS, 0, 1); - } catch (IndexOutOfBoundsException ignored) {/*may happen during transfer*/} + } catch (IndexOutOfBoundsException ignored) {/* may happen during transfer */} } } } @@ -290,8 +291,8 @@ public class DarkPanelPopupUI extends DarkPanelUI implements PropertyChangeListe protected Insets getBorderSize(final Alignment a, final boolean[] info) { Insets insets = new Insets(0, 0, 0, 0); switch (a) { - case NORTH: - case NORTH_EAST: + case NORTH : + case NORTH_EAST : if (info[Alignment.NORTH.getIndex()] || info[Alignment.NORTH_EAST.getIndex()]) { insets.bottom = 1; } @@ -299,8 +300,8 @@ public class DarkPanelPopupUI extends DarkPanelUI implements PropertyChangeListe insets.left = 1; } return insets; - case SOUTH: - case SOUTH_WEST: + case SOUTH : + case SOUTH_WEST : if (info[Alignment.SOUTH_WEST.getIndex()] || info[Alignment.SOUTH.getIndex()]) { insets.top = 1; } @@ -308,8 +309,8 @@ public class DarkPanelPopupUI extends DarkPanelUI implements PropertyChangeListe insets.left = 1; } return insets; - case EAST: - case SOUTH_EAST: + case EAST : + case SOUTH_EAST : if (info[Alignment.EAST.getIndex()] || info[Alignment.SOUTH_EAST.getIndex()]) { insets.left = 1; } @@ -317,8 +318,8 @@ public class DarkPanelPopupUI extends DarkPanelUI implements PropertyChangeListe insets.top = 1; } return insets; - case WEST: - case NORTH_WEST: + case WEST : + case NORTH_WEST : if (info[Alignment.NORTH_WEST.getIndex()] || info[Alignment.WEST.getIndex()]) { insets.right = 1; } @@ -326,7 +327,7 @@ public class DarkPanelPopupUI extends DarkPanelUI implements PropertyChangeListe insets.top = 1; } return insets; - default: + default : return insets; } } @@ -348,8 +349,8 @@ public class DarkPanelPopupUI extends DarkPanelUI implements PropertyChangeListe if (focusOwner instanceof JRootPane) return; boolean focus = DarkUIUtil.hasFocus(popupComponent); if (popupComponent.getTabFrame() != null) { - Container container = popupComponent.getTabFrame().getContentPane().getContainer( - popupComponent.getAlignment()); + Container container = popupComponent.getTabFrame().getContentPane() + .getContainer(popupComponent.getAlignment()); focus = focus || DarkUIUtil.hasFocus(container); } setHeaderBackground(focus); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameComponentPopupMenu.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameComponentPopupMenu.java index 3470303c..09201d65 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameComponentPopupMenu.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameComponentPopupMenu.java @@ -20,20 +20,22 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabframe; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +import javax.swing.*; +import javax.swing.plaf.UIResource; + import com.github.weisj.darklaf.components.JXPopupMenu; import com.github.weisj.darklaf.components.tabframe.TabFrameTab; import com.github.weisj.darklaf.icons.EmptyIcon; import com.github.weisj.darklaf.util.Alignment; import com.github.weisj.darklaf.util.PropertyKey; -import javax.swing.*; -import javax.swing.plaf.UIResource; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - public class DarkTabFrameComponentPopupMenu extends JXPopupMenu implements PropertyChangeListener, UIResource { private final TabFrameTab tab; @@ -87,24 +89,24 @@ public class DarkTabFrameComponentPopupMenu extends JXPopupMenu implements Prope protected String getDescription(final Alignment a) { switch (a) { - case NORTH: + case NORTH : return "Top Left"; - case SOUTH: + case SOUTH : return "Bottom Right"; - case EAST: + case EAST : return "Right Top"; - case WEST: + case WEST : return "Left Bottom"; - case NORTH_EAST: + case NORTH_EAST : return "Top Right"; - case NORTH_WEST: + case NORTH_WEST : return "Left Top"; - case SOUTH_EAST: + case SOUTH_EAST : return "Right Bottom"; - case SOUTH_WEST: + case SOUTH_WEST : return "Bottom Left"; - case CENTER: - default: + case CENTER : + default : return ""; } } @@ -112,24 +114,24 @@ public class DarkTabFrameComponentPopupMenu extends JXPopupMenu implements Prope protected Icon createIcon(final Alignment a, final boolean enabled) { String suffix = enabled ? "" : "Disabled"; switch (a) { - case NORTH: + case NORTH : return UIManager.getIcon("TabFrame.moveToTopLeft" + suffix + ".icon"); - case SOUTH: + case SOUTH : return UIManager.getIcon("TabFrame.moveToBottomRight" + suffix + ".icon"); - case EAST: + case EAST : return UIManager.getIcon("TabFrame.moveToRightTop" + suffix + ".icon"); - case WEST: + case WEST : return UIManager.getIcon("TabFrame.moveToLeftBottom" + suffix + ".icon"); - case NORTH_EAST: + case NORTH_EAST : return UIManager.getIcon("TabFrame.moveToTopRight" + suffix + ".icon"); - case NORTH_WEST: + case NORTH_WEST : return UIManager.getIcon("TabFrame.moveToLeftTop" + suffix + ".icon"); - case SOUTH_EAST: + case SOUTH_EAST : return UIManager.getIcon("TabFrame.moveToRightBottom" + suffix + ".icon"); - case SOUTH_WEST: + case SOUTH_WEST : return UIManager.getIcon("TabFrame.moveToBottomLeft" + suffix + ".icon"); - case CENTER: - default: + case CENTER : + default : return EmptyIcon.create(0); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFramePopupHeaderBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFramePopupHeaderBorder.java index eda3de62..d380b945 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFramePopupHeaderBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFramePopupHeaderBorder.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabframe; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabBorder.java index a8e6e517..6a1e55da 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabBorder.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabframe; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabContainerUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabContainerUI.java index 09d38081..a13ca0ea 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabContainerUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabContainerUI.java @@ -20,9 +20,21 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabframe; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +import javax.swing.*; +import javax.swing.plaf.ComponentUI; + import com.github.weisj.darklaf.components.tabframe.JTabFrame; import com.github.weisj.darklaf.components.tabframe.TabFrameTab; import com.github.weisj.darklaf.components.tabframe.TabFrameTabContainer; @@ -32,16 +44,6 @@ import com.github.weisj.darklaf.util.Alignment; import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.PropertyKey; -import javax.swing.*; -import javax.swing.plaf.ComponentUI; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - public class DarkTabFrameTabContainerUI extends DarkPanelUI implements PropertyChangeListener { private static final String ACCELERATOR_PREFIX = "accelerator_"; @@ -61,7 +63,6 @@ public class DarkTabFrameTabContainerUI extends DarkPanelUI implements PropertyC private Color hoverColor; private boolean printing; - public static ComponentUI createUI(final JComponent c) { return new DarkTabFrameTabContainerUI(); } @@ -208,7 +209,9 @@ public class DarkTabFrameTabContainerUI extends DarkPanelUI implements PropertyC public Color getBackground(final TabFrameTabContainer tab) { if (printing) return tab.getBackground(); return tab.isSelected() - ? selectedColor : hoverListener.isHover() && !tab.getTabFrame().isInTransfer() - ? hoverColor : tab.getBackground(); + ? selectedColor + : hoverListener.isHover() && !tab.getTabFrame().isInTransfer() + ? hoverColor + : tab.getBackground(); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabLabelUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabLabelUI.java index 8c744bd3..9a113dbf 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabLabelUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabLabelUI.java @@ -20,9 +20,26 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabframe; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +import javax.swing.*; +import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.UIResource; +import javax.swing.plaf.basic.BasicHTML; +import javax.swing.text.View; + +import sun.swing.SwingUtilities2; + import com.github.weisj.darklaf.components.tabframe.JTabFrame; import com.github.weisj.darklaf.components.tabframe.TabFrameTab; import com.github.weisj.darklaf.components.tabframe.TabFrameTabLabel; @@ -32,20 +49,6 @@ import com.github.weisj.darklaf.ui.label.DarkLabelUI; import com.github.weisj.darklaf.util.Alignment; import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.PropertyKey; -import sun.swing.SwingUtilities2; - -import javax.swing.*; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.UIResource; -import javax.swing.plaf.basic.BasicHTML; -import javax.swing.text.View; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; public class DarkTabFrameTabLabelUI extends DarkLabelUI implements PropertyChangeListener { @@ -71,7 +74,6 @@ public class DarkTabFrameTabLabelUI extends DarkLabelUI implements PropertyChang private final RotatableIcon rotatableIcon = new RotatableIcon(); private boolean printing; - public static ComponentUI createUI(final JComponent c) { return new DarkTabFrameTabLabelUI(); } @@ -181,7 +183,7 @@ public class DarkTabFrameTabLabelUI extends DarkLabelUI implements PropertyChang String key = e.getPropertyName(); if (TabFrameTab.KEY_SELECTED.equals(key)) { tabComponent.setForeground(Boolean.TRUE.equals(e.getNewValue()) - ? selectedFontColor : defaultFontColor); + ? selectedFontColor : defaultFontColor); tabComponent.repaint(); } else if (TabFrameTab.KEY_TITLE.equals(key)) { updateText(); @@ -257,15 +259,19 @@ public class DarkTabFrameTabLabelUI extends DarkLabelUI implements PropertyChang public Color getBackground(final TabFrameTabLabel tab) { if (printing || !tab.isEnabled()) return tab.getBackground(); return tab.isSelected() - ? selectedColor : hoverListener.isHover() && !tab.getTabFrame().isInTransfer() - ? hoverColor : tab.getBackground(); + ? selectedColor + : hoverListener.isHover() && !tab.getTabFrame().isInTransfer() + ? hoverColor + : tab.getBackground(); } public Color getForeground(final TabFrameTabLabel tab) { if (printing) return tab.getForeground(); return tab.isSelected() - ? selectedFontColor : hoverListener.isHover() && !tab.getTabFrame().isInTransfer() - ? fontHoverColor : tab.getForeground(); + ? selectedFontColor + : hoverListener.isHover() && !tab.getTabFrame().isInTransfer() + ? fontHoverColor + : tab.getForeground(); } protected Icon getIcon() { @@ -279,17 +285,17 @@ public class DarkTabFrameTabLabelUI extends DarkLabelUI implements PropertyChang protected Alignment mapOrientation(final Alignment newValue) { switch (newValue) { - case CENTER: - case NORTH: - case NORTH_EAST: - case SOUTH: - case SOUTH_WEST: + case CENTER : + case NORTH : + case NORTH_EAST : + case SOUTH : + case SOUTH_WEST : return Alignment.NORTH; - case EAST: - case SOUTH_EAST: + case EAST : + case SOUTH_EAST : return Alignment.WEST; - case WEST: - case NORTH_WEST: + case WEST : + case NORTH_WEST : return Alignment.EAST; } return Alignment.NORTH; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameUI.java index 7f0958c2..9f8e6e43 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameUI.java @@ -20,20 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabframe; -import com.github.weisj.darklaf.components.border.MutableLineBorder; -import com.github.weisj.darklaf.components.tabframe.*; -import com.github.weisj.darklaf.components.uiresource.JPanelUIResource; -import com.github.weisj.darklaf.util.Alignment; -import com.github.weisj.darklaf.util.Pair; -import org.jdesktop.jxlayer.JXLayer; -import org.pbjar.jxlayer.plaf.ext.transform.DefaultTransformModel; -import org.pbjar.jxlayer.plaf.ext.transform.TransformUtils; - -import javax.swing.*; -import javax.swing.plaf.ComponentUI; import java.awt.*; import java.awt.dnd.DropTarget; import java.awt.event.AWTEventListener; @@ -41,11 +31,24 @@ import java.awt.event.MouseEvent; import java.util.List; import java.util.TooManyListenersException; +import javax.swing.*; +import javax.swing.plaf.ComponentUI; + +import org.jdesktop.jxlayer.JXLayer; +import org.pbjar.jxlayer.plaf.ext.transform.DefaultTransformModel; +import org.pbjar.jxlayer.plaf.ext.transform.TransformUtils; + +import com.github.weisj.darklaf.components.border.MutableLineBorder; +import com.github.weisj.darklaf.components.tabframe.*; +import com.github.weisj.darklaf.components.uiresource.JPanelUIResource; +import com.github.weisj.darklaf.util.Alignment; +import com.github.weisj.darklaf.util.Pair; + /** * UI class for {@link JTabFrame}. * * @author Jannis Weis - * @since 2018 + * @since 2018 */ public class DarkTabFrameUI extends TabFrameUI implements AWTEventListener { @@ -73,7 +76,6 @@ public class DarkTabFrameUI extends TabFrameUI implements AWTEventListener { private Alignment destAlign; private int destIndex; - public static ComponentUI createUI(final JComponent c) { return new DarkTabFrameUI(); } @@ -191,7 +193,6 @@ public class DarkTabFrameUI extends TabFrameUI implements AWTEventListener { return tabHeight; } - @Override public void clearTargetIndicator() { destIndex = -10; @@ -261,26 +262,26 @@ public class DarkTabFrameUI extends TabFrameUI implements AWTEventListener { public Rectangle getTabContainerBounds(final JTabFrame tabFrame, final Alignment a) { switch (a) { - case NORTH: - case NORTH_EAST: + case NORTH : + case NORTH_EAST : Rectangle rect = getTopContainer().getBounds(); rect.x = 0; rect.width = tabFrame.getWidth(); return rect; - case EAST: - case SOUTH_EAST: + case EAST : + case SOUTH_EAST : return getRightContainer().getBounds(); - case SOUTH: - case SOUTH_WEST: + case SOUTH : + case SOUTH_WEST : Rectangle rect2 = getTopContainer().getBounds(); rect2.x = 0; rect2.width = tabFrame.getWidth(); return rect2; - case WEST: - case NORTH_WEST: + case WEST : + case NORTH_WEST : return getLeftContainer().getBounds(); - default: - case CENTER: + default : + case CENTER : return tabFrame.getContentPane().getComponent().getBounds(); } } @@ -336,7 +337,7 @@ public class DarkTabFrameUI extends TabFrameUI implements AWTEventListener { a = Alignment.SOUTH_EAST; } int tmp = pos.x; - //noinspection SuspiciousNameCombination + // noinspection SuspiciousNameCombination pos.x = pos.y; pos.y = tmp; } @@ -454,16 +455,16 @@ public class DarkTabFrameUI extends TabFrameUI implements AWTEventListener { protected boolean isForward(final Alignment a) { switch (a) { - case NORTH: - case EAST: - case WEST: - case SOUTH_WEST: + case NORTH : + case EAST : + case WEST : + case SOUTH_WEST : return true; - case NORTH_WEST: - case SOUTH: - case NORTH_EAST: - case SOUTH_EAST: - default: + case NORTH_WEST : + case SOUTH : + case NORTH_EAST : + case SOUTH_EAST : + default : return false; } } @@ -482,26 +483,26 @@ public class DarkTabFrameUI extends TabFrameUI implements AWTEventListener { int w = a == destAlign && destIndex == -1 ? dropSize.width : 0; Component comp = getTabContainer(a); switch (a) { - case NORTH: - case SOUTH_WEST: + case NORTH : + case SOUTH_WEST : if (p.x > getLeftContainer().getWidth() + w) { tab.setIndex(tabFrame.getTabCountAt(a) - 1); } break; - case NORTH_EAST: - case SOUTH: + case NORTH_EAST : + case SOUTH : if (p.x < comp.getWidth() - getRightContainer().getWidth() - w) { tab.setIndex(tabFrame.getTabCountAt(a) - 1); } break; - case EAST: - case WEST: + case EAST : + case WEST : if (p.x > w) { tab.setIndex(tabFrame.getTabCountAt(a) - 1); } break; - case SOUTH_EAST: - case NORTH_WEST: + case SOUTH_EAST : + case NORTH_WEST : if (p.x < comp.getHeight() - w) { tab.setIndex(tabFrame.getTabCountAt(a) - 1); } @@ -513,17 +514,17 @@ public class DarkTabFrameUI extends TabFrameUI implements AWTEventListener { protected Component getTabContainer(final Alignment a) { switch (a) { - case NORTH: - case NORTH_EAST: + case NORTH : + case NORTH_EAST : return getTopContainer(); - case EAST: - case SOUTH_EAST: + case EAST : + case SOUTH_EAST : return getRightContainer(); - case SOUTH: - case SOUTH_WEST: + case SOUTH : + case SOUTH_WEST : return getBottomContainer(); - case WEST: - case NORTH_WEST: + case WEST : + case NORTH_WEST : return getLeftContainer(); } return null; @@ -562,19 +563,19 @@ public class DarkTabFrameUI extends TabFrameUI implements AWTEventListener { public JComponent getDropComponent(final Alignment a) { switch (a) { - default: - case CENTER: - case NORTH: - case NORTH_EAST: + default : + case CENTER : + case NORTH : + case NORTH_EAST : return getDropComponentTop(); - case EAST: - case SOUTH_EAST: + case EAST : + case SOUTH_EAST : return getDropComponentRight(); - case SOUTH: - case SOUTH_WEST: + case SOUTH : + case SOUTH_WEST : return getDropComponentBottom(); - case WEST: - case NORTH_WEST: + case WEST : + case NORTH_WEST : return getDropComponentLeft(); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabbedPopupUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabbedPopupUI.java index 72e05bef..bfe6aa7a 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabbedPopupUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabbedPopupUI.java @@ -20,9 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabframe; +import java.awt.*; +import java.util.function.Supplier; + +import javax.swing.*; +import javax.swing.border.EmptyBorder; +import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.TabbedPaneUI; + import com.github.weisj.darklaf.components.border.MutableLineBorder; import com.github.weisj.darklaf.components.tabframe.TabFrameTabbedPopupUI; import com.github.weisj.darklaf.components.tabframe.TabbedPopup; @@ -32,13 +41,6 @@ import com.github.weisj.darklaf.ui.tabbedpane.DarkTabbedPaneUI; import com.github.weisj.darklaf.ui.tabbedpane.MoreTabsButton; import com.github.weisj.darklaf.ui.tabbedpane.NewTabButton; -import javax.swing.*; -import javax.swing.border.EmptyBorder; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.TabbedPaneUI; -import java.awt.*; -import java.util.function.Supplier; - public class DarkTabbedPopupUI extends DarkPanelPopupUI implements TabFrameTabbedPopupUI { protected Color headerHoverBackground; @@ -54,7 +56,6 @@ public class DarkTabbedPopupUI extends DarkPanelPopupUI implements TabFrameTabbe private JPanel holder; private JButton newTabButton; - public static ComponentUI createUI(final JComponent c) { return new DarkTabbedPopupUI(); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabDragListener.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabDragListener.java index ddb899d7..827db605 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabDragListener.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabDragListener.java @@ -20,19 +20,22 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabframe; -import com.github.weisj.darklaf.components.tabframe.TabFrameTab; -import com.github.weisj.darklaf.util.DarkUIUtil; -import com.github.weisj.darklaf.util.SwingXUtilities; -import org.jdesktop.jxlayer.JXLayer; - -import javax.swing.*; import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import javax.swing.*; + +import org.jdesktop.jxlayer.JXLayer; + +import com.github.weisj.darklaf.components.tabframe.TabFrameTab; +import com.github.weisj.darklaf.util.DarkUIUtil; +import com.github.weisj.darklaf.util.SwingXUtilities; + public class TabDragListener extends MouseAdapter { private final TabFrameTab tabComponent; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabFrameLayout.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabFrameLayout.java index 10f1cc62..f4fa1dd9 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabFrameLayout.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabFrameLayout.java @@ -20,19 +20,20 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabframe; +import java.awt.*; +import java.util.Arrays; + import com.github.weisj.darklaf.components.tabframe.JTabFrame; import com.github.weisj.darklaf.components.tabframe.TabFrameTab; import com.github.weisj.darklaf.util.Alignment; -import java.awt.*; -import java.util.Arrays; - /** * @author Jannis Weis - * @since 2019 + * @since 2019 */ public class TabFrameLayout implements LayoutManager { @@ -45,7 +46,6 @@ public class TabFrameLayout implements LayoutManager { private int rightHeight; private int bottomHeight; - public TabFrameLayout(final JTabFrame tabFrame, final DarkTabFrameUI ui) { this.tabFrame = tabFrame; this.ui = ui; @@ -54,13 +54,10 @@ public class TabFrameLayout implements LayoutManager { } @Override - public void addLayoutComponent(final String name, final Component comp) { - } + public void addLayoutComponent(final String name, final Component comp) {} @Override - public void removeLayoutComponent(final Component comp) { - } - + public void removeLayoutComponent(final Component comp) {} @Override public Dimension preferredLayoutSize(final Container parent) { @@ -68,17 +65,20 @@ public class TabFrameLayout implements LayoutManager { return new Dimension(tabFrame.getLeftTabContainer().getWidth() + tabFrame.getRightTabContainer().getWidth() + b.width, tabFrame.getTopTabContainer().getHeight() - + tabFrame.getBottomTabContainer().getHeight() + b.height); + + tabFrame.getBottomTabContainer() + .getHeight() + + b.height); } - @Override public Dimension minimumLayoutSize(final Container parent) { Dimension b = tabFrame.getContentPane().getComponent().getMinimumSize(); return new Dimension(tabFrame.getLeftTabContainer().getWidth() + tabFrame.getRightTabContainer().getWidth() + b.width, tabFrame.getTopTabContainer().getHeight() - + tabFrame.getBottomTabContainer().getHeight() + b.height); + + tabFrame.getBottomTabContainer() + .getHeight() + + b.height); } @Override @@ -229,8 +229,8 @@ public class TabFrameLayout implements LayoutManager { int size = rightCount > 0 ? rightHeight : tabFrame.getTabSize(); int height = dim.height - topPane.getHeight() - bottomPane.getHeight(); rightPane.setBounds(dim.width - rightHeight, topPane.getHeight(), size, height + (height % 2)); - tabFrame.getRightTabContainer().setPreferredSize( - new Dimension(rightPane.getHeight(), rightPane.getWidth())); + tabFrame.getRightTabContainer().setPreferredSize(new Dimension(rightPane.getHeight(), + rightPane.getWidth())); tabFrame.getRightTabContainer().setSize(tabFrame.getRightTabContainer().getPreferredSize()); if (rightCount > 0) { Point start = new Point(0, 0); @@ -268,17 +268,17 @@ public class TabFrameLayout implements LayoutManager { protected int getIndex(final Alignment a) { switch (a) { - case NORTH: - case NORTH_EAST: + case NORTH : + case NORTH_EAST : return 0; - case EAST: - case SOUTH_EAST: + case EAST : + case SOUTH_EAST : return 1; - case SOUTH: - case SOUTH_WEST: + case SOUTH : + case SOUTH_WEST : return 2; - case WEST: - case NORTH_WEST: + case WEST : + case NORTH_WEST : return 3; } return 0; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabFrameTransferHandler.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabFrameTransferHandler.java index 33b015d9..bbf24a56 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabFrameTransferHandler.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabFrameTransferHandler.java @@ -20,17 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tabframe; -import com.github.weisj.darklaf.components.tabframe.JTabFrame; -import com.github.weisj.darklaf.components.tabframe.TabFramePopup; -import com.github.weisj.darklaf.components.tabframe.TabFrameTab; -import com.github.weisj.darklaf.components.tabframe.TabFrameUI; -import com.github.weisj.darklaf.util.Alignment; -import com.github.weisj.darklaf.util.ImageUtil; - -import javax.swing.*; import java.awt.*; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; @@ -39,6 +32,14 @@ import java.awt.dnd.*; import java.awt.event.InputEvent; import java.awt.event.MouseEvent; +import javax.swing.*; + +import com.github.weisj.darklaf.components.tabframe.JTabFrame; +import com.github.weisj.darklaf.components.tabframe.TabFramePopup; +import com.github.weisj.darklaf.components.tabframe.TabFrameTab; +import com.github.weisj.darklaf.components.tabframe.TabFrameUI; +import com.github.weisj.darklaf.util.Alignment; +import com.github.weisj.darklaf.util.ImageUtil; /** * @author Jannis Weis @@ -60,12 +61,10 @@ public class TabFrameTransferHandler extends TransferHandler implements DropTarg private TabTransferable currentTransferable; private JTabFrame lastTabFrame; - public TabFrameTransferHandler() { try { tabFlavor = new DataFlavor(MIME_TYPE); - } catch (ClassNotFoundException ignored) { - } + } catch (ClassNotFoundException ignored) {} timer = new Timer(100, e -> { if (lastTabFrame != null) { Point p = MouseInfo.getPointerInfo().getLocation(); @@ -87,7 +86,6 @@ public class TabFrameTransferHandler extends TransferHandler implements DropTarg startTimer.setRepeats(false); } - private TabFrameUI getUI(final Component c) { if (c instanceof JTabFrame) return ((JTabFrame) c).getUI(); return null; @@ -166,8 +164,8 @@ public class TabFrameTransferHandler extends TransferHandler implements DropTarg /** * We can only move tabs, we cannot copy them. * - * @param c This parameter is ignored. - * @return TransferHandler.MOVE, as we can only move tabs. + * @param c This parameter is ignored. + * @return TransferHandler.MOVE, as we can only move tabs. */ @Override public int getSourceActions(final JComponent c) { @@ -219,13 +217,13 @@ public class TabFrameTransferHandler extends TransferHandler implements DropTarg } /** - * Called when the drag-and-drop operation has just completed. This creates a new tab identical to the one + * Called when the drag-and-drop operation has just completed. This creates a new tab identical to the one * "dragged" and places it in the destination JTabbedPane. * - * @param c The component receiving the "drop" (the instance of - * JTabbedPane). - * @param t The data being transfered (information about the tab and the component contained by the tab). - * @return Whether or not the import was successful. + * @param c The component receiving the "drop" (the instance of + * JTabbedPane). + * @param t The data being transfered (information about the tab and the component contained by the tab). + * @return Whether or not the import was successful. */ @Override public boolean importData(final JComponent c, final Transferable t) { @@ -246,7 +244,7 @@ public class TabFrameTransferHandler extends TransferHandler implements DropTarg index++; if (tabFrame == td.sourceTabFrame && a == td.tabAlignment && index == td.tabIndex) { - //Nothing to do. Just select the tab to be sure. + // Nothing to do. Just select the tab to be sure. if (td.wasSelected) { selectTab(td.sourceTabFrame, a, index); } @@ -277,8 +275,7 @@ public class TabFrameTransferHandler extends TransferHandler implements DropTarg } @Override - public void dropActionChanged(final DropTargetDragEvent e) { - } + public void dropActionChanged(final DropTargetDragEvent e) {} protected Transferable createTransferable(final JComponent c, final DragGestureEvent dge) { JTabFrame tabFrame = (JTabFrame) c; @@ -324,16 +321,14 @@ public class TabFrameTransferHandler extends TransferHandler implements DropTarg /** * register this DragGestureRecognizer's Listeners with the Component */ - protected void registerListeners() { - } + protected void registerListeners() {} /** * unregister this DragGestureRecognizer's Listeners with the Component *

* subclasses must override this method */ - protected void unregisterListeners() { - } + protected void unregisterListeners() {} } public static class UIResource extends TabFrameTransferHandler { @@ -366,7 +361,6 @@ public class TabFrameTransferHandler extends TransferHandler implements DropTarg return tabFlavor.equals(flavor); } - @Override public Object getTransferData(final DataFlavor flavor) throws UnsupportedFlavorException { if (!isDataFlavorSupported(flavor)) { @@ -386,7 +380,6 @@ public class TabFrameTransferHandler extends TransferHandler implements DropTarg private final TabFrameTab tab; private final boolean wasSelected; - public TabTransferData(final JTabFrame tabbedPane, final Alignment tabAlignment, final int tabIndex) { this.sourceTabFrame = tabbedPane; @@ -395,9 +388,7 @@ public class TabFrameTransferHandler extends TransferHandler implements DropTarg this.tab = tabbedPane.getTabComponentAt(tabAlignment, tabIndex); this.wasSelected = tab.isSelected(); } - } - } protected class TabbedPaneDragHandler implements DragGestureListener, DragSourceListener { @@ -437,23 +428,19 @@ public class TabFrameTransferHandler extends TransferHandler implements DropTarg /** * as the hotspot enters a platform dependent drop site */ - public void dragEnter(final DragSourceDragEvent dsde) { - } + public void dragEnter(final DragSourceDragEvent dsde) {} /** * as the hotspot moves over a platform dependent drop site */ - public void dragOver(final DragSourceDragEvent dsde) { - } + public void dragOver(final DragSourceDragEvent dsde) {} - public void dropActionChanged(final DragSourceDragEvent dsde) { - } + public void dropActionChanged(final DragSourceDragEvent dsde) {} /** * as the hotspot exits a platform dependent drop site */ - public void dragExit(final DragSourceEvent dsde) { - } + public void dragExit(final DragSourceEvent dsde) {} /** * as the operation completes diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkColorTableCellRendererEditor.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkColorTableCellRendererEditor.java index d7e94f56..6be22f00 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkColorTableCellRendererEditor.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkColorTableCellRendererEditor.java @@ -20,16 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.table; -import javax.swing.*; -import javax.swing.table.TableCellEditor; -import javax.swing.table.TableCellRenderer; import java.awt.*; import java.awt.event.MouseEvent; import java.util.EventObject; +import javax.swing.*; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; + /** * @author Jannis Weis */ diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellBorder.java index 601f0c63..83625064 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellBorder.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.table; @@ -28,5 +29,4 @@ import com.github.weisj.darklaf.ui.cell.DarkCellBorder; /** * @author Jannis Weis */ -public class DarkTableCellBorder extends DarkCellBorder { -} +public class DarkTableCellBorder extends DarkCellBorder {} diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellEditor.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellEditor.java index 14cc4ee9..e062aa36 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellEditor.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellEditor.java @@ -20,9 +20,24 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.table; +import java.awt.*; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; +import java.text.DateFormat; +import java.text.NumberFormat; +import java.text.ParseException; +import java.util.EventObject; + +import javax.swing.*; +import javax.swing.border.Border; +import javax.swing.event.PopupMenuEvent; +import javax.swing.event.PopupMenuListener; +import javax.swing.table.TableCellEditor; + import com.github.weisj.darklaf.ui.cell.CellUtil; import com.github.weisj.darklaf.ui.combobox.ComboBoxConstants; import com.github.weisj.darklaf.ui.combobox.DarkComboBoxUI; @@ -32,19 +47,6 @@ import com.github.weisj.darklaf.ui.text.DarkTextUI; import com.github.weisj.darklaf.ui.togglebutton.ToggleButtonConstants; import com.github.weisj.darklaf.util.PropertyValue; -import javax.swing.*; -import javax.swing.border.Border; -import javax.swing.event.PopupMenuEvent; -import javax.swing.event.PopupMenuListener; -import javax.swing.table.TableCellEditor; -import java.awt.*; -import java.awt.event.KeyEvent; -import java.awt.event.MouseEvent; -import java.text.DateFormat; -import java.text.NumberFormat; -import java.text.ParseException; -import java.util.EventObject; - /** * @author vincencopalazzo * @author atarw @@ -55,10 +57,10 @@ public class DarkTableCellEditor extends DefaultCellEditor { private static final JCheckBox dummyCheckBox = new JCheckBox(); private static final IconWrapper iconWrapper = new IconWrapper(); - private final DarkTableCellEditorToggleButton checkBoxEditor = - new DarkTableCellEditorToggleButton(this, new DarkTableCellEditorToggleButton.CellCheckBox()); - private final DarkTableCellEditorToggleButton radioButtonEditor = - new DarkTableCellEditorToggleButton(this, new DarkTableCellEditorToggleButton.CellRadioButton()); + private final DarkTableCellEditorToggleButton checkBoxEditor = new DarkTableCellEditorToggleButton(this, + new DarkTableCellEditorToggleButton.CellCheckBox()); + private final DarkTableCellEditorToggleButton radioButtonEditor = new DarkTableCellEditorToggleButton(this, + new DarkTableCellEditorToggleButton.CellRadioButton()); private boolean value; private boolean isBooleanEditor; private JTable table; @@ -276,7 +278,6 @@ public class DarkTableCellEditor extends DefaultCellEditor { } } - private boolean useBooleanEditor(final Object value, final JTable table) { return value instanceof Boolean && DarkTableCellRenderer.isBooleanRenderingEnabled(table) && !(editorComponent instanceof JCheckBox || editorComponent instanceof JRadioButton); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellEditorToggleButton.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellEditorToggleButton.java index 9df1adf6..a4400e90 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellEditorToggleButton.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellEditorToggleButton.java @@ -20,17 +20,19 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.table; -import com.github.weisj.darklaf.decorators.CellRenderer; -import com.github.weisj.darklaf.ui.cell.CellUtil; -import com.github.weisj.darklaf.util.DarkUIUtil; +import java.awt.*; +import java.util.EventObject; import javax.swing.*; import javax.swing.table.TableCellEditor; -import java.awt.*; -import java.util.EventObject; + +import com.github.weisj.darklaf.decorators.CellRenderer; +import com.github.weisj.darklaf.ui.cell.CellUtil; +import com.github.weisj.darklaf.util.DarkUIUtil; /** * @author vincencopalazzo diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellFocusBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellFocusBorder.java index 88e7a629..d44c6e77 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellFocusBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellFocusBorder.java @@ -20,14 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.table; -import com.github.weisj.darklaf.ui.cell.DarkCellBorder; -import com.github.weisj.darklaf.util.DarkUIUtil; +import java.awt.*; import javax.swing.*; -import java.awt.*; + +import com.github.weisj.darklaf.ui.cell.DarkCellBorder; +import com.github.weisj.darklaf.util.DarkUIUtil; /** * @author Jannis Weis diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellRenderer.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellRenderer.java index 5a970331..6e894631 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellRenderer.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellRenderer.java @@ -20,19 +20,21 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.table; -import com.github.weisj.darklaf.ui.cell.CellUtil; -import com.github.weisj.darklaf.ui.cell.DarkCellRendererToggleButton; -import com.github.weisj.darklaf.util.DarkUIUtil; +import java.awt.*; import javax.swing.*; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.JTableHeader; import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumn; -import java.awt.*; + +import com.github.weisj.darklaf.ui.cell.CellUtil; +import com.github.weisj.darklaf.ui.cell.DarkCellRendererToggleButton; +import com.github.weisj.darklaf.util.DarkUIUtil; /** * @author vincencopalazzo @@ -41,10 +43,8 @@ import java.awt.*; */ public class DarkTableCellRenderer extends DefaultTableCellRenderer { - private final DarkCellRendererToggleButton checkBoxRenderer = - new DarkCellRendererToggleButton<>(new DarkCellRendererToggleButton.CellEditorCheckBox(true)); - private final DarkCellRendererToggleButton radioRenderer = - new DarkCellRendererToggleButton<>(new DarkCellRendererToggleButton.CellEditorRadioButton(true)); + private final DarkCellRendererToggleButton checkBoxRenderer = new DarkCellRendererToggleButton<>(new DarkCellRendererToggleButton.CellEditorCheckBox(true)); + private final DarkCellRendererToggleButton radioRenderer = new DarkCellRendererToggleButton<>(new DarkCellRendererToggleButton.CellEditorRadioButton(true)); protected static boolean isBooleanRenderingEnabled(final JTable table) { return Boolean.TRUE.equals(table.getClientProperty(DarkTableUI.KEY_RENDER_BOOLEAN_AS_CHECKBOX)); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableHeaderBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableHeaderBorder.java index 80a8225a..4966d602 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableHeaderBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableHeaderBorder.java @@ -20,14 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.table; -import com.github.weisj.darklaf.components.border.MutableLineBorder; +import java.awt.*; import javax.swing.*; import javax.swing.plaf.UIResource; -import java.awt.*; + +import com.github.weisj.darklaf.components.border.MutableLineBorder; /** * @author Jannis Weis diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableHeaderCorner.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableHeaderCorner.java index aedf1d27..7208182b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableHeaderCorner.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableHeaderCorner.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.table; +import java.awt.*; + import javax.swing.*; import javax.swing.plaf.UIResource; -import java.awt.*; /** * @author Jannis Weis diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableHeaderUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableHeaderUI.java index b0328d61..c4fd8bad 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableHeaderUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableHeaderUI.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.table; @@ -116,7 +117,7 @@ public class DarkTableHeaderUI extends DarkTableHeaderUIBridge { Color borderColor = c.getBorder() instanceof DarkTableScrollPaneBorder ? ((DarkTableScrollPaneBorder) c.getBorder()).getBorderColor() - : getBorderColor(); + : getBorderColor(); g.setColor(borderColor); TableColumn draggedColumn = header.getDraggedColumn(); @@ -224,11 +225,11 @@ public class DarkTableHeaderUI extends DarkTableHeaderUIBridge { boolean onLeftEdge = ltr ? draggedColumnIndex == cMin : draggedColumnIndex == cMax; boolean onRightEdge = ltr ? draggedColumnIndex == cMax : draggedColumnIndex == cMin; - //left + // left if (dist != 0 || !onLeftEdge) { g.fillRect(draggedCellRect.x - 1, draggedCellRect.y, 1, draggedCellRect.height); } - //right + // right if (dist != 0 || !onRightEdge) { g.fillRect(draggedCellRect.x + draggedCellRect.width - 1, draggedCellRect.y, 1, draggedCellRect.height); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableHeaderUIBridge.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableHeaderUIBridge.java index 23bc23f3..d6c0a6ed 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableHeaderUIBridge.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableHeaderUIBridge.java @@ -20,13 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.table; -import com.github.weisj.darklaf.util.DarkUIUtil; -import com.github.weisj.darklaf.util.PropertyKey; -import sun.swing.SwingUtilities2; -import sun.swing.UIAction; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.MouseEvent; +import java.util.Enumeration; +import java.util.Objects; import javax.swing.*; import javax.swing.event.MouseInputListener; @@ -36,13 +40,12 @@ import javax.swing.table.JTableHeader; import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.MouseEvent; -import java.util.Enumeration; -import java.util.Objects; + +import sun.swing.SwingUtilities2; +import sun.swing.UIAction; + +import com.github.weisj.darklaf.util.DarkUIUtil; +import com.github.weisj.darklaf.util.PropertyKey; /** * The type Dark table header ui bridge. @@ -59,9 +62,9 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { /** * The constant focusListener. */ -// -// Instance Variables -// + // + // Instance Variables + // protected static final FocusListener focusListener = new FocusListener() { public void focusGained(final FocusEvent e) { repaintHeader(e.getSource()); @@ -74,8 +77,8 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { protected void repaintHeader(final Object source) { if (source instanceof JTableHeader) { JTableHeader th = (JTableHeader) source; - DarkTableHeaderUIBridge ui = - (DarkTableHeaderUIBridge) DarkUIUtil.getUIOfType(th.getUI(), DarkTableHeaderUIBridge.class); + DarkTableHeaderUIBridge ui = (DarkTableHeaderUIBridge) DarkUIUtil.getUIOfType(th.getUI(), + DarkTableHeaderUIBridge.class); if (ui == null) { return; } @@ -86,34 +89,34 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { /** * The Rollover column. */ -// The column header over which the mouse currently is. + // The column header over which the mouse currently is. protected int rolloverColumn = -1; /** * The Selected column index. */ -// The column that should be highlighted when the table header has the focus. + // The column that should be highlighted when the table header has the focus. protected int selectedColumnIndex = 0; // Read ONLY via getSelectedColumnIndex! /** * Returns a new instance of {@code DarkTableHeaderUIBridge}. * - * @param h a component. - * @return a new instance of {@code DarkTableHeaderUIBridge} + * @param h a component. + * @return a new instance of {@code DarkTableHeaderUIBridge} */ public static ComponentUI createUI(final JComponent h) { return new DarkTableHeaderUIBridge(); } -// -// Factory methods for the Listeners -// + // + // Factory methods for the Listeners + // /** * Can resize boolean. * - * @param column the column - * @param header the header - * @return the boolean + * @param column the column + * @param header the header + * @return the boolean */ protected static boolean canResize(final TableColumn column, final JTableHeader header) { @@ -121,9 +124,9 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { && column.getResizable(); } -// -// The installation/uninstall procedures and support -// + // + // The installation/uninstall procedures and support + // /** * Update rollover column. @@ -146,12 +149,12 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { /** * Select next column int. * - * @param doIt the do it - * @return the int + * @param doIt the do it + * @return the int */ -// -// Support for keyboard and mouse access -// + // + // Support for keyboard and mouse access + // protected int selectNextColumn(final boolean doIt) { int newIndex = getSelectedColumnIndex(); if (newIndex < header.getColumnModel().getColumnCount() - 1) { @@ -212,7 +215,7 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { return new DarkTableHeaderUIBridge.MouseInputHandler(); } -// Installation + // Installation /** * Used by selectColumn to scroll horizontally, if necessary, to ensure that the newly selected column is visible. @@ -223,7 +226,7 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { Container container; JTable table; - //Test whether the header is in a scroll pane and has a table. + // Test whether the header is in a scroll pane and has a table. if ((header.getParent() == null) || ((container = header.getParent().getParent()) == null) || !(container instanceof JScrollPane) || @@ -231,7 +234,7 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { return; } - //Now scroll, if necessary. + // Now scroll, if necessary. Rectangle vis = table.getVisibleRect(); Rectangle cellBounds = table.getCellRect(0, col, true); vis.x = cellBounds.x; @@ -242,8 +245,8 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { /** * Select previous column int. * - * @param doIt the do it - * @return the int + * @param doIt the do it + * @return the int */ protected int selectPreviousColumn(final boolean doIt) { int newIndex = getSelectedColumnIndex(); @@ -259,11 +262,11 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { /** * Change column width int. * - * @param resizingColumn the resizing column - * @param th the th - * @param oldWidth the old width - * @param newWidth the new width - * @return the int + * @param resizingColumn the resizing column + * @param th the th + * @param oldWidth the old width + * @param newWidth the new width + * @return the int */ protected int changeColumnWidth(final TableColumn resizingColumn, final JTableHeader th, @@ -292,7 +295,8 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { tableSize.width += diff; table.setSize(tableSize); - /* If this table is in AUTO_RESIZE_OFF mode and + /* + * If this table is in AUTO_RESIZE_OFF mode and * has a horizontal scrollbar, we need to update * a view's position. */ @@ -324,8 +328,8 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { /** * Gets header renderer. * - * @param columnIndex the column index - * @return the header renderer + * @param columnIndex the column index + * @return the header renderer */ protected Component getHeaderRenderer(final int columnIndex) { TableColumn aColumn = header.getColumnModel().getColumn(columnIndex); @@ -347,7 +351,6 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { super.installUI(c); } - /** * Initializes JTableHeader properties such as font, foreground, and background. The font, foreground, and * background properties are only set if their current value is either null or a UIResource, other properties are @@ -361,7 +364,6 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { LookAndFeel.installProperty(header, PropertyKey.OPAQUE, Boolean.TRUE); } - /** * Attaches listeners to the JTableHeader. */ @@ -373,8 +375,7 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { header.addFocusListener(focusListener); } -// Uninstall methods - + // Uninstall methods public void uninstallUI(final JComponent c) { uninstallDefaults(); @@ -386,13 +387,10 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { header = null; } - /** * Uninstalls default properties */ - protected void uninstallDefaults() { - } - + protected void uninstallDefaults() {} /** * Unregisters listeners. @@ -405,7 +403,6 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { mouseInputListener = null; } - /** * Unregisters default key actions. */ @@ -414,45 +411,41 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { SwingUtilities.replaceUIActionMap(header, null); } -// -// Support for mouse rollover -// - + // + // Support for mouse rollover + // /** * Returns the index of the column header over which the mouse currently is. When the mouse is not over the table * header, -1 is returned. * * @return the index of the current rollover column - * @see #rolloverColumnUpdated(int, int) - * @since 1.6 + * @see #rolloverColumnUpdated(int, int) + * @since 1.6 */ protected int getRolloverColumn() { return rolloverColumn; } - /** * This method gets called every time when a rollover column in the table header is updated. Every look and feel * that supports a rollover effect in a table header should override this method and repaint the header. * * @param oldColumn the index of the previous rollover column or -1 if the mouse was not over a column * @param newColumn the index of the new rollover column or -1 if the mouse is not over a column - * @see #getRolloverColumn() - * @see JTableHeader#getHeaderRect(int) - * @since 1.6 + * @see #getRolloverColumn() + * @see JTableHeader#getHeaderRect(int) + * @since 1.6 */ - protected void rolloverColumnUpdated(final int oldColumn, final int newColumn) { - } - + protected void rolloverColumnUpdated(final int oldColumn, final int newColumn) {} /** * Returns the baseline. * * @throws NullPointerException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} - * @see javax.swing.JComponent#getBaseline(int, int) - * @since 1.6 + * @see javax.swing.JComponent#getBaseline(int, int) + * @since 1.6 */ public int getBaseline(final JComponent c, final int width, final int height) { super.getBaseline(c, width, height); @@ -476,9 +469,9 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { return baseline; } -// -// Baseline -// + // + // Baseline + // public void paint(final Graphics g, final JComponent c) { if (header.getColumnModel().getColumnCount() <= 0) { @@ -552,15 +545,15 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { rendererPane.removeAll(); } -// -// Paint Methods and support -// + // + // Paint Methods and support + // /** * View index for column int. * - * @param aColumn the a column - * @return the int + * @param aColumn the a column + * @return the int */ protected int viewIndexForColumn(final TableColumn aColumn) { TableColumnModel cm = header.getColumnModel(); @@ -575,8 +568,8 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { /** * Create header size dimension. * - * @param width the width - * @return the dimension + * @param width the width + * @return the dimension */ protected Dimension createHeaderSize(long width) { // None of the callers include the intercell spacing, do it here. @@ -630,43 +623,35 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { /** * The constant TOGGLE_SORT_ORDER. */ - public static final String TOGGLE_SORT_ORDER = - "toggleSortOrder"; + public static final String TOGGLE_SORT_ORDER = "toggleSortOrder"; /** * The constant SELECT_COLUMN_TO_LEFT. */ - public static final String SELECT_COLUMN_TO_LEFT = - "selectColumnToLeft"; + public static final String SELECT_COLUMN_TO_LEFT = "selectColumnToLeft"; /** * The constant SELECT_COLUMN_TO_RIGHT. */ - public static final String SELECT_COLUMN_TO_RIGHT = - "selectColumnToRight"; + public static final String SELECT_COLUMN_TO_RIGHT = "selectColumnToRight"; /** * The constant MOVE_COLUMN_LEFT. */ - public static final String MOVE_COLUMN_LEFT = - "moveColumnLeft"; + public static final String MOVE_COLUMN_LEFT = "moveColumnLeft"; /** * The constant MOVE_COLUMN_RIGHT. */ - public static final String MOVE_COLUMN_RIGHT = - "moveColumnRight"; + public static final String MOVE_COLUMN_RIGHT = "moveColumnRight"; /** * The constant RESIZE_LEFT. */ - public static final String RESIZE_LEFT = - "resizeLeft"; + public static final String RESIZE_LEFT = "resizeLeft"; /** * The constant RESIZE_RIGHT. */ - public static final String RESIZE_RIGHT = - "resizeRight"; + public static final String RESIZE_RIGHT = "resizeRight"; /** * The constant FOCUS_TABLE. */ - public static final String FOCUS_TABLE = - "focusTable"; + public static final String FOCUS_TABLE = "focusTable"; /** * Instantiates a new Actions. @@ -680,8 +665,8 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { /** * Accept boolean. * - * @param sender the sender - * @return the boolean + * @param sender the sender + * @return the boolean */ public boolean accept(final Object sender) { if (sender instanceof JTableHeader) { @@ -692,8 +677,8 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { } String key = getName(); - DarkTableHeaderUIBridge ui = - (DarkTableHeaderUIBridge) DarkUIUtil.getUIOfType(th.getUI(), DarkTableHeaderUIBridge.class); + DarkTableHeaderUIBridge ui = (DarkTableHeaderUIBridge) DarkUIUtil.getUIOfType(th.getUI(), + DarkTableHeaderUIBridge.class); if (ui != null) { if (Objects.equals(key, MOVE_COLUMN_LEFT)) { return th.getReorderingAllowed() @@ -715,11 +700,11 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { /** * Maybe move column boolean. * - * @param leftArrow the left arrow - * @param th the th - * @param ui the ui - * @param doIt the do it - * @return the boolean + * @param leftArrow the left arrow + * @param th the th + * @param ui the ui + * @param doIt the do it + * @return the boolean */ protected boolean maybeMoveColumn(final boolean leftArrow, final JTableHeader th, final DarkTableHeaderUIBridge ui, final boolean doIt) { @@ -747,8 +732,8 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { public void actionPerformed(final ActionEvent e) { JTableHeader th = (JTableHeader) e.getSource(); - DarkTableHeaderUIBridge ui = - (DarkTableHeaderUIBridge) DarkUIUtil.getUIOfType(th.getUI(), DarkTableHeaderUIBridge.class); + DarkTableHeaderUIBridge ui = (DarkTableHeaderUIBridge) DarkUIUtil.getUIOfType(th.getUI(), + DarkTableHeaderUIBridge.class); if (ui == null) { return; } @@ -759,8 +744,7 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { RowSorter sorter = table == null ? null : table.getRowSorter(); if (sorter != null) { int columnIndex = ui.getSelectedColumnIndex(); - columnIndex = table.convertColumnIndexToModel( - columnIndex); + columnIndex = table.convertColumnIndexToModel(columnIndex); sorter.toggleSortOrder(columnIndex); } } else if (Objects.equals(SELECT_COLUMN_TO_LEFT, name)) { @@ -813,8 +797,7 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { protected void resize(final boolean leftArrow, final JTableHeader th, final DarkTableHeaderUIBridge ui) { int columnIndex = ui.getSelectedColumnIndex(); - TableColumn resizingColumn = - th.getColumnModel().getColumn(columnIndex); + TableColumn resizingColumn = th.getColumnModel().getColumn(columnIndex); th.setResizingColumn(resizingColumn); int oldWidth = resizingColumn.getWidth(); @@ -830,9 +813,9 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { } } -// -// Size Methods -// + // + // Size Methods + // /** * This class should be treated as a "protected" inner class. Instantiate it only within subclasses of @@ -860,8 +843,7 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { if (table != null && (sorter = table.getRowSorter()) != null) { int columnIndex = header.columnAtPoint(e.getPoint()); if (columnIndex != -1) { - columnIndex = table.convertColumnIndexToModel( - columnIndex); + columnIndex = table.convertColumnIndexToModel(columnIndex); sorter.toggleSortOrder(columnIndex); } } @@ -950,8 +932,8 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { /** * Gets resizing column. * - * @param p the p - * @return the resizing column + * @param p the p + * @return the resizing column */ protected TableColumn getResizingColumn(final Point p) { return getResizingColumn(p, header.columnAtPoint(p)); @@ -991,14 +973,14 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { mouseXOffset = mouseXOffset + direction * width; header.setDraggedDistance(draggedDistance - direction * width); - //Cache the selected column. + // Cache the selected column. int selectedIndex = SwingUtilities2.convertColumnIndexToModel(header.getColumnModel(), getSelectedColumnIndex()); - //Now do the move. + // Now do the move. cm.moveColumn(columnIndex, newColumnIndex); - //Update the selected index. + // Update the selected index. selectColumn(SwingUtilities2.convertColumnIndexToView(header.getColumnModel(), selectedIndex), false); @@ -1015,8 +997,7 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { if (!header.isEnabled()) { return; } - if (canResize(getResizingColumn(e.getPoint()), header) != - (header.getCursor() == resizeCursor)) { + if (canResize(getResizingColumn(e.getPoint()), header) != (header.getCursor() == resizeCursor)) { swapCursor(); } updateRolloverColumn(e); @@ -1025,9 +1006,9 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { /** * Gets resizing column. * - * @param p the p - * @param column the column - * @return the resizing column + * @param p the p + * @param column the column + * @return the resizing column */ protected TableColumn getResizingColumn(final Point p, final int column) { if (column == -1) { @@ -1050,9 +1031,9 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { } return header.getColumnModel().getColumn(columnIndex); } -// -// Protected & protected Methods -// + // + // Protected & protected Methods + // /** * Swap cursor. @@ -1106,6 +1087,4 @@ public class DarkTableHeaderUIBridge extends BasicTableHeaderUI { } return createHeaderSize(width); } - - } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableScrollPaneBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableScrollPaneBorder.java index 88f867ed..9c0c0a87 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableScrollPaneBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableScrollPaneBorder.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.table; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java index e760b7ef..5306bc33 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java @@ -20,14 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.table; -import com.github.weisj.darklaf.components.OverlayScrollPane; -import com.github.weisj.darklaf.ui.cell.CellUtil; -import com.github.weisj.darklaf.util.DarkUIUtil; -import com.github.weisj.darklaf.util.PropertyKey; -import sun.swing.SwingUtilities2; +import java.awt.*; +import java.awt.event.*; +import java.beans.PropertyChangeListener; +import java.util.Objects; +import java.util.function.Supplier; import javax.swing.*; import javax.swing.plaf.ComponentUI; @@ -36,11 +37,13 @@ import javax.swing.table.JTableHeader; import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; -import java.awt.*; -import java.awt.event.*; -import java.beans.PropertyChangeListener; -import java.util.Objects; -import java.util.function.Supplier; + +import sun.swing.SwingUtilities2; + +import com.github.weisj.darklaf.components.OverlayScrollPane; +import com.github.weisj.darklaf.ui.cell.CellUtil; +import com.github.weisj.darklaf.util.DarkUIUtil; +import com.github.weisj.darklaf.util.PropertyKey; /** * @author Jannis Weis @@ -300,7 +303,8 @@ public class DarkTableUI extends DarkTableUIBridge implements FocusListener { JTableHeader header = table.getTableHeader(); int dist = header != null ? adjustDistance(header.getDraggedDistance(), table.getCellRect(0, draggedIndex, true), - table) : 0; + table) + : 0; boolean isDragged = column == draggedIndex && dist != 0; if (!scrollVisible) { if (ltr) { @@ -358,7 +362,6 @@ public class DarkTableUI extends DarkTableUIBridge implements FocusListener { g.setColor(parent.getBackground()); g.fillRect(vacatedColumnRect.x, 0, vacatedColumnRect.width - 1, tableHeight); - // Move to the where the cell has been dragged. vacatedColumnRect.x += dist; @@ -368,7 +371,6 @@ public class DarkTableUI extends DarkTableUIBridge implements FocusListener { g.setColor(table.getBackground()); g.fillRect(vacatedColumnRect.x, 0, vacatedColumnRect.width, tableHeight); - // Paint the vertical grid lines if necessary. if (table.getShowVerticalLines()) { g.setColor(table.getGridColor()); @@ -421,27 +423,27 @@ public class DarkTableUI extends DarkTableUIBridge implements FocusListener { if (event != null) { int keyCode = event.getKeyCode(); switch (keyCode) { - case KeyEvent.VK_ALT_GRAPH: - case KeyEvent.VK_META: - case KeyEvent.VK_CAPS_LOCK: - case KeyEvent.VK_HOME: - case KeyEvent.VK_WINDOWS: - case KeyEvent.VK_CONTEXT_MENU: - case KeyEvent.VK_PRINTSCREEN: - case KeyEvent.VK_NUM_LOCK: - case KeyEvent.VK_SCROLL_LOCK: - case KeyEvent.VK_CLEAR: - case KeyEvent.VK_HELP: - case KeyEvent.VK_INSERT: - case KeyEvent.VK_ESCAPE: + case KeyEvent.VK_ALT_GRAPH : + case KeyEvent.VK_META : + case KeyEvent.VK_CAPS_LOCK : + case KeyEvent.VK_HOME : + case KeyEvent.VK_WINDOWS : + case KeyEvent.VK_CONTEXT_MENU : + case KeyEvent.VK_PRINTSCREEN : + case KeyEvent.VK_NUM_LOCK : + case KeyEvent.VK_SCROLL_LOCK : + case KeyEvent.VK_CLEAR : + case KeyEvent.VK_HELP : + case KeyEvent.VK_INSERT : + case KeyEvent.VK_ESCAPE : return true; - default: + default : break; } if (table == null) return false; KeyStroke stroke = KeyStroke.getKeyStroke(event.getExtendedKeyCode(), event.getModifiersEx()); - String actionName = String.valueOf( - table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).get(stroke)); + String actionName = String.valueOf(table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) + .get(stroke)); if ("null".equals(actionName)) actionName = null; String cutActionName = String.valueOf(TransferHandler.getCutAction().getValue(Action.NAME)); String copyActionName = String.valueOf(TransferHandler.getCopyAction().getValue(Action.NAME)); @@ -505,12 +507,10 @@ public class DarkTableUI extends DarkTableUIBridge implements FocusListener { } @Override - protected void maybeStartTimer() { - } + protected void maybeStartTimer() {} @Override - public void actionPerformed(final ActionEvent ae) { - } + public void actionPerformed(final ActionEvent ae) {} @Override public void keyTyped(final KeyEvent e) { @@ -542,7 +542,8 @@ public class DarkTableUI extends DarkTableUIBridge implements FocusListener { : -1; int dist = header != null ? adjustDistance(header.getDraggedDistance(), table.getCellRect(row, draggedIndex, true), - table) : 0; + table) + : 0; boolean isDragged = column == draggedIndex && dist != 0; Rectangle rectWithSpacing = table.getCellRect(row, cMin, true); Rectangle r = new Rectangle(cellRect); @@ -603,6 +604,4 @@ public class DarkTableUI extends DarkTableUIBridge implements FocusListener { } return dist; } - - } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUIBridge.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUIBridge.java index fe3a2be0..cabafccb 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUIBridge.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUIBridge.java @@ -20,18 +20,21 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.table; -import com.github.weisj.darklaf.util.DarkUIUtil; -import sun.swing.SwingUtilities2; +import java.awt.*; import javax.swing.*; import javax.swing.table.JTableHeader; import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; -import java.awt.*; + +import sun.swing.SwingUtilities2; + +import com.github.weisj.darklaf.util.DarkUIUtil; /** * @author Jannis Weis @@ -60,8 +63,8 @@ public class DarkTableUIBridge extends TableUIBridge { bounds.x = bounds.y = 0; if (table.getRowCount() <= 0 || table.getColumnCount() <= 0 || - // this check prevents us from painting the entire table - // when the clip doesn't intersect our bounds at all + // this check prevents us from painting the entire table + // when the clip doesn't intersect our bounds at all !bounds.intersects(clip)) { paintDropLines(g); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/TableUIBridge.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/TableUIBridge.java index 4e39ce41..327589a0 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/TableUIBridge.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/TableUIBridge.java @@ -20,17 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.table; -import com.github.weisj.darklaf.ui.BasicTransferable; -import com.github.weisj.darklaf.ui.DragRecognitionSupport; -import com.github.weisj.darklaf.util.DarkUIUtil; -import com.github.weisj.darklaf.util.LazyActionMap; -import com.github.weisj.darklaf.util.PropertyKey; -import sun.swing.DefaultLookup; -import sun.swing.SwingUtilities2; -import sun.swing.UIAction; +import java.awt.*; +import java.awt.datatransfer.Transferable; +import java.awt.event.*; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.Enumeration; +import java.util.Objects; import javax.swing.*; import javax.swing.event.ListSelectionEvent; @@ -42,13 +42,16 @@ import javax.swing.plaf.TableUI; import javax.swing.plaf.UIResource; import javax.swing.plaf.basic.BasicTableUI; import javax.swing.table.*; -import java.awt.*; -import java.awt.datatransfer.Transferable; -import java.awt.event.*; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.Enumeration; -import java.util.Objects; + +import sun.swing.DefaultLookup; +import sun.swing.SwingUtilities2; +import sun.swing.UIAction; + +import com.github.weisj.darklaf.ui.BasicTransferable; +import com.github.weisj.darklaf.ui.DragRecognitionSupport; +import com.github.weisj.darklaf.util.DarkUIUtil; +import com.github.weisj.darklaf.util.LazyActionMap; +import com.github.weisj.darklaf.util.PropertyKey; /** * The type Table ui bridge. @@ -58,17 +61,16 @@ public abstract class TableUIBridge extends TableUI { /** * The constant BASELINE_COMPONENT_KEY. */ - protected static final StringBuilder BASELINE_COMPONENT_KEY = - new StringBuilder("Table.baselineComponent"); + protected static final StringBuilder BASELINE_COMPONENT_KEY = new StringBuilder("Table.baselineComponent"); -// -// Instance Variables -// + // + // Instance Variables + // /** * The constant defaultTransferHandler. */ -// The JTable that is delegating the painting to this UI. + // The JTable that is delegating the painting to this UI. protected static final TransferHandler defaultTransferHandler = new TableTransferHandler(); /** * The instance of {@code JTable}. @@ -95,32 +97,31 @@ public abstract class TableUIBridge extends TableUI { */ protected Handler handler; -// -// Helper class for keyboard actions -// + // + // Helper class for keyboard actions + // /** * Local cache of Table's client property DarkTableUI.KEY_IS_FILE_LIST */ protected boolean isFileList = false; - -// -// The Table's Key listener -// + // + // The Table's Key listener + // /** * Returns a new instance of {@code BasicTableUI}. * - * @param c a component - * @return a new instance of {@code BasicTableUI} + * @param c a component + * @return a new instance of {@code BasicTableUI} */ public static ComponentUI createUI(final JComponent c) { return new BasicTableUI(); } -// -// The Table's focus listener -// + // + // The Table's focus listener + // /** * Load action map. @@ -132,7 +133,7 @@ public abstract class TableUIBridge extends TableUI { // passed to the Actions constructor. Only certain parameter // combinations are supported. For example, the following Action would // not work as expected: - // new Actions(Actions.NEXT_ROW_CELL, 1, 4, false, true) + // new Actions(Actions.NEXT_ROW_CELL, 1, 4, false, true) // Actions which move within the selection only (having a true // inSelection parameter) require that one of dx or dy be // zero and the other be -1 or 1. The point of this warning is @@ -226,16 +227,16 @@ public abstract class TableUIBridge extends TableUI { map.put(new Actions(Actions.FOCUS_HEADER)); } -// -// The Table's mouse and mouse motion listeners -// + // + // The Table's mouse and mouse motion listeners + // /** * Gets adjusted lead. * - * @param table the table - * @param row the row - * @return the adjusted lead + * @param table the table + * @param row the row + * @return the adjusted lead */ protected static int getAdjustedLead(final JTable table, final boolean row) { return row ? getAdjustedLead(table, row, table.getSelectionModel()) @@ -245,10 +246,10 @@ public abstract class TableUIBridge extends TableUI { /** * Gets adjusted lead. * - * @param table the table - * @param row the row - * @param model the model - * @return the adjusted lead + * @param table the table + * @param row the row + * @param model the model + * @return the adjusted lead */ protected static int getAdjustedLead(final JTable table, final boolean row, @@ -262,14 +263,14 @@ public abstract class TableUIBridge extends TableUI { /** * Point outside pref size boolean. * - * @param row the row - * @param column the column - * @param p the p - * @return the boolean + * @param row the row + * @param column the column + * @param p the p + * @return the boolean */ /* * Returns true if the given point is outside the preferredSize of the - * item at the given row of the table. (Column must be 0). + * item at the given row of the table. (Column must be 0). * Returns false if the DarkTableUI.KEY_IS_FILE_LIST client property is not set. */ protected boolean pointOutsidePrefSize(final int row, final int column, final Point p) { @@ -280,9 +281,9 @@ public abstract class TableUIBridge extends TableUI { return SwingUtilities2.pointOutsidePrefSize(table, row, column, p); } -// -// Factory methods for the Listeners -// + // + // Factory methods for the Listeners + // public void installUI(final JComponent c) { table = (JTable) c; @@ -305,11 +306,11 @@ public abstract class TableUIBridge extends TableUI { protected void installDefaults() { LookAndFeel.installColorsAndFont(table, "Table.background", "Table.foreground", "Table.font"); - // JTable's original row height is 16. To correctly display the + // JTable's original row height is 16. To correctly display the // contents on Linux we should have set it to 18, Windows 19 and - // Solaris 20. As these values vary so much it's too hard to + // Solaris 20. As these values vary so much it's too hard to // be backward compatable and try to update the row height, we're - // therefor NOT going to adjust the row height based on font. If the + // therefor NOT going to adjust the row height based on font. If the // developer changes the font, it's there responsability to update // the row height. @@ -334,9 +335,9 @@ public abstract class TableUIBridge extends TableUI { } // install the scrollpane border - Container parent = DarkUIUtil.getUnwrappedParent(table); // should be viewport + Container parent = DarkUIUtil.getUnwrappedParent(table); // should be viewport if (parent != null) { - parent = parent.getParent(); // should be the scrollpane + parent = parent.getParent(); // should be the scrollpane if (parent != null && parent instanceof JScrollPane) { LookAndFeel.installBorder((JScrollPane) parent, "Table.scrollPaneBorder"); } @@ -378,23 +379,23 @@ public abstract class TableUIBridge extends TableUI { } } -// -// The installation/uninstall procedures and support -// + // + // The installation/uninstall procedures and support + // /** * Register all keyboard actions on the JTable. */ protected void installKeyboardActions() { LazyActionMap.installLazyActionMap(table, TableUIBridge.class, "Table.actionMap"); -// var map = new LazyActionMap(null); -// loadActionMap(map); -// SwingUtilities.replaceUIActionMap(table, map); + // var map = new LazyActionMap(null); + // loadActionMap(map); + // SwingUtilities.replaceUIActionMap(table, map); InputMap inputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); SwingUtilities.replaceUIInputMap(table, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, inputMap); } -// Installation + // Installation /** * Creates the focus listener for handling keyboard navigation in the {@code JTable}. @@ -438,14 +439,13 @@ public abstract class TableUIBridge extends TableUI { /** * Gets input map. * - * @param condition the condition - * @return the input map + * @param condition the condition + * @return the input map */ InputMap getInputMap(final int condition) { if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) { - InputMap keyMap = - (InputMap) DefaultLookup.get(table, this, - "Table.ancestorInputMap"); + InputMap keyMap = (InputMap) DefaultLookup.get(table, this, + "Table.ancestorInputMap"); InputMap rtlKeyMap; if (table.getComponentOrientation().isLeftToRight() || @@ -479,7 +479,7 @@ public abstract class TableUIBridge extends TableUI { } } -// Uninstallation + // Uninstallation /** * Unregisters listeners. @@ -504,8 +504,7 @@ public abstract class TableUIBridge extends TableUI { * Unregisters keyboard actions. */ protected void uninstallKeyboardActions() { - SwingUtilities.replaceUIInputMap(table, JComponent. - WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null); + SwingUtilities.replaceUIInputMap(table, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null); SwingUtilities.replaceUIActionMap(table, null); } @@ -521,8 +520,8 @@ public abstract class TableUIBridge extends TableUI { bounds.x = bounds.y = 0; if (table.getRowCount() <= 0 || table.getColumnCount() <= 0 || - // this check prevents us from painting the entire table - // when the clip doesn't intersect our bounds at all + // this check prevents us from painting the entire table + // when the clip doesn't intersect our bounds at all !bounds.intersects(clip)) { paintDropLines(g); @@ -649,44 +648,42 @@ public abstract class TableUIBridge extends TableUI { return createTableSize(width); } -// -// Size Methods -// + // + // Size Methods + // /** * Returns the baseline. * * @throws NullPointerException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} - * @see javax.swing.JComponent#getBaseline(int, int) - * @since 1.6 + * @see javax.swing.JComponent#getBaseline(int, int) + * @since 1.6 */ public int getBaseline(final JComponent c, final int width, final int height) { super.getBaseline(c, width, height); UIDefaults lafDefaults = UIManager.getLookAndFeelDefaults(); - Component renderer = (Component) lafDefaults.get( - BASELINE_COMPONENT_KEY); + Component renderer = (Component) lafDefaults.get(BASELINE_COMPONENT_KEY); if (renderer == null) { DefaultTableCellRenderer tcr = new DefaultTableCellRenderer(); - renderer = tcr.getTableCellRendererComponent( - table, "a", false, false, -1, -1); + renderer = tcr.getTableCellRendererComponent(table, "a", false, false, -1, -1); lafDefaults.put(BASELINE_COMPONENT_KEY, renderer); } renderer.setFont(table.getFont()); int rowMargin = table.getRowMargin(); return renderer.getBaseline(Integer.MAX_VALUE, table.getRowHeight() - - rowMargin) + rowMargin / 2; + rowMargin) + + rowMargin / 2; } /** * Returns an enum indicating how the baseline of the component changes as the size changes. * * @throws NullPointerException {@inheritDoc} - * @see javax.swing.JComponent#getBaseline(int, int) - * @since 1.6 + * @see javax.swing.JComponent#getBaseline(int, int) + * @since 1.6 */ - public Component.BaselineResizeBehavior getBaselineResizeBehavior( - final JComponent c) { + public Component.BaselineResizeBehavior getBaselineResizeBehavior(final JComponent c) { super.getBaselineResizeBehavior(c); return Component.BaselineResizeBehavior.CONSTANT_ASCENT; } @@ -694,8 +691,8 @@ public abstract class TableUIBridge extends TableUI { /** * Create table size dimension. * - * @param width the width - * @return the dimension + * @param width the width + * @return the dimension */ protected Dimension createTableSize(final long width) { int height = 0; @@ -763,15 +760,15 @@ public abstract class TableUIBridge extends TableUI { } } -// -// Paint methods and support -// + // + // Paint methods and support + // /** * Gets h drop line rect. * - * @param loc the loc - * @return the h drop line rect + * @param loc the loc + * @return the h drop line rect */ protected Rectangle getHDropLineRect(final JTable.DropLocation loc) { if (!loc.isInsertRow()) { @@ -806,9 +803,9 @@ public abstract class TableUIBridge extends TableUI { /** * Extend rect rectangle. * - * @param rect the rect - * @param horizontal the horizontal - * @return the rectangle + * @param rect the rect + * @param horizontal the horizontal + * @return the rectangle */ protected Rectangle extendRect(final Rectangle rect, final boolean horizontal) { if (rect == null) { @@ -835,8 +832,8 @@ public abstract class TableUIBridge extends TableUI { /** * Gets v drop line rect. * - * @param loc the loc - * @return the v drop line rect + * @param loc the loc + * @return the v drop line rect */ protected Rectangle getVDropLineRect(final JTable.DropLocation loc) { if (!loc.isInsertColumn()) { @@ -1072,8 +1069,8 @@ public abstract class TableUIBridge extends TableUI { /** * View index for column int. * - * @param aColumn the a column - * @return the int + * @param aColumn the a column + * @return the int */ protected int viewIndexForColumn(final TableColumn aColumn) { TableColumnModel cm = table.getColumnModel(); @@ -1117,13 +1114,11 @@ public abstract class TableUIBridge extends TableUI { /** * The constant NEXT_ROW_EXTEND_SELECTION. */ - protected static final String NEXT_ROW_EXTEND_SELECTION = - "selectNextRowExtendSelection"; + protected static final String NEXT_ROW_EXTEND_SELECTION = "selectNextRowExtendSelection"; /** * The constant NEXT_ROW_CHANGE_LEAD. */ - protected static final String NEXT_ROW_CHANGE_LEAD = - "selectNextRowChangeLead"; + protected static final String NEXT_ROW_CHANGE_LEAD = "selectNextRowChangeLead"; /** * The constant PREVIOUS_ROW. */ @@ -1135,13 +1130,11 @@ public abstract class TableUIBridge extends TableUI { /** * The constant PREVIOUS_ROW_EXTEND_SELECTION. */ - protected static final String PREVIOUS_ROW_EXTEND_SELECTION = - "selectPreviousRowExtendSelection"; + protected static final String PREVIOUS_ROW_EXTEND_SELECTION = "selectPreviousRowExtendSelection"; /** * The constant PREVIOUS_ROW_CHANGE_LEAD. */ - protected static final String PREVIOUS_ROW_CHANGE_LEAD = - "selectPreviousRowChangeLead"; + protected static final String PREVIOUS_ROW_CHANGE_LEAD = "selectPreviousRowChangeLead"; /** * The constant NEXT_COLUMN. @@ -1154,13 +1147,11 @@ public abstract class TableUIBridge extends TableUI { /** * The constant NEXT_COLUMN_EXTEND_SELECTION. */ - protected static final String NEXT_COLUMN_EXTEND_SELECTION = - "selectNextColumnExtendSelection"; + protected static final String NEXT_COLUMN_EXTEND_SELECTION = "selectNextColumnExtendSelection"; /** * The constant NEXT_COLUMN_CHANGE_LEAD. */ - protected static final String NEXT_COLUMN_CHANGE_LEAD = - "selectNextColumnChangeLead"; + protected static final String NEXT_COLUMN_CHANGE_LEAD = "selectNextColumnChangeLead"; /** * The constant PREVIOUS_COLUMN. */ @@ -1168,131 +1159,112 @@ public abstract class TableUIBridge extends TableUI { /** * The constant PREVIOUS_COLUMN_CELL. */ - protected static final String PREVIOUS_COLUMN_CELL = - "selectPreviousColumnCell"; + protected static final String PREVIOUS_COLUMN_CELL = "selectPreviousColumnCell"; /** * The constant PREVIOUS_COLUMN_EXTEND_SELECTION. */ - protected static final String PREVIOUS_COLUMN_EXTEND_SELECTION = - "selectPreviousColumnExtendSelection"; + protected static final String PREVIOUS_COLUMN_EXTEND_SELECTION = "selectPreviousColumnExtendSelection"; /** * The constant PREVIOUS_COLUMN_CHANGE_LEAD. */ - protected static final String PREVIOUS_COLUMN_CHANGE_LEAD = - "selectPreviousColumnChangeLead"; + protected static final String PREVIOUS_COLUMN_CHANGE_LEAD = "selectPreviousColumnChangeLead"; /** * The constant SCROLL_LEFT_CHANGE_SELECTION. */ - protected static final String SCROLL_LEFT_CHANGE_SELECTION = - "scrollLeftChangeSelection"; + protected static final String SCROLL_LEFT_CHANGE_SELECTION = "scrollLeftChangeSelection"; /** * The constant SCROLL_LEFT_EXTEND_SELECTION. */ - protected static final String SCROLL_LEFT_EXTEND_SELECTION = - "scrollLeftExtendSelection"; + protected static final String SCROLL_LEFT_EXTEND_SELECTION = "scrollLeftExtendSelection"; /** * The constant SCROLL_RIGHT_CHANGE_SELECTION. */ - protected static final String SCROLL_RIGHT_CHANGE_SELECTION = - "scrollRightChangeSelection"; + protected static final String SCROLL_RIGHT_CHANGE_SELECTION = "scrollRightChangeSelection"; /** * The constant SCROLL_RIGHT_EXTEND_SELECTION. */ - protected static final String SCROLL_RIGHT_EXTEND_SELECTION = - "scrollRightExtendSelection"; + protected static final String SCROLL_RIGHT_EXTEND_SELECTION = "scrollRightExtendSelection"; /** * The constant SCROLL_UP_CHANGE_SELECTION. */ - protected static final String SCROLL_UP_CHANGE_SELECTION = - "scrollUpChangeSelection"; + protected static final String SCROLL_UP_CHANGE_SELECTION = "scrollUpChangeSelection"; /** * The constant SCROLL_UP_EXTEND_SELECTION. */ - protected static final String SCROLL_UP_EXTEND_SELECTION = - "scrollUpExtendSelection"; + protected static final String SCROLL_UP_EXTEND_SELECTION = "scrollUpExtendSelection"; /** * The constant SCROLL_DOWN_CHANGE_SELECTION. */ - protected static final String SCROLL_DOWN_CHANGE_SELECTION = - "scrollDownChangeSelection"; + protected static final String SCROLL_DOWN_CHANGE_SELECTION = "scrollDownChangeSelection"; /** * The constant SCROLL_DOWN_EXTEND_SELECTION. */ - protected static final String SCROLL_DOWN_EXTEND_SELECTION = - "scrollDownExtendSelection"; + protected static final String SCROLL_DOWN_EXTEND_SELECTION = "scrollDownExtendSelection"; /** * The constant FIRST_COLUMN. */ - protected static final String FIRST_COLUMN = - "selectFirstColumn"; + protected static final String FIRST_COLUMN = "selectFirstColumn"; /** * The constant FIRST_COLUMN_EXTEND_SELECTION. */ - protected static final String FIRST_COLUMN_EXTEND_SELECTION = - "selectFirstColumnExtendSelection"; + protected static final String FIRST_COLUMN_EXTEND_SELECTION = "selectFirstColumnExtendSelection"; /** * The constant LAST_COLUMN. */ - protected static final String LAST_COLUMN = - "selectLastColumn"; + protected static final String LAST_COLUMN = "selectLastColumn"; /** * The constant LAST_COLUMN_EXTEND_SELECTION. */ - protected static final String LAST_COLUMN_EXTEND_SELECTION = - "selectLastColumnExtendSelection"; + protected static final String LAST_COLUMN_EXTEND_SELECTION = "selectLastColumnExtendSelection"; /** * The constant FIRST_ROW. */ - protected static final String FIRST_ROW = - "selectFirstRow"; + protected static final String FIRST_ROW = "selectFirstRow"; /** * The constant FIRST_ROW_EXTEND_SELECTION. */ - protected static final String FIRST_ROW_EXTEND_SELECTION = - "selectFirstRowExtendSelection"; + protected static final String FIRST_ROW_EXTEND_SELECTION = "selectFirstRowExtendSelection"; /** * The constant LAST_ROW. */ - protected static final String LAST_ROW = - "selectLastRow"; + protected static final String LAST_ROW = "selectLastRow"; /** * The constant LAST_ROW_EXTEND_SELECTION. */ - protected static final String LAST_ROW_EXTEND_SELECTION = - "selectLastRowExtendSelection"; + protected static final String LAST_ROW_EXTEND_SELECTION = "selectLastRowExtendSelection"; /** * The constant ADD_TO_SELECTION. */ -// add the lead item to the selection without changing lead or anchor + // add the lead item to the selection without changing lead or anchor protected static final String ADD_TO_SELECTION = "addToSelection"; /** * The constant TOGGLE_AND_ANCHOR. */ -// toggle the selected state of the lead item and move the anchor to it + // toggle the selected state of the lead item and move the anchor to it protected static final String TOGGLE_AND_ANCHOR = "toggleAndAnchor"; /** * The constant EXTEND_TO. */ -// extend the selection to the lead item + // extend the selection to the lead item protected static final String EXTEND_TO = "extendTo"; /** * The constant MOVE_SELECTION_TO. */ -// move the anchor to the lead and ensure only that item is selected + // move the anchor to the lead and ensure only that item is selected protected static final String MOVE_SELECTION_TO = "moveSelectionTo"; /** * The constant FOCUS_HEADER. */ -// give focus to the JTableHeader, if one exists + // give focus to the JTableHeader, if one exists protected static final String FOCUS_HEADER = "focusHeader"; /** @@ -1315,7 +1287,7 @@ public abstract class TableUIBridge extends TableUI { /** * The Forwards. */ -// horizontally, forwards always means right, + // horizontally, forwards always means right, // regardless of component orientation protected boolean forwards; /** @@ -1400,8 +1372,8 @@ public abstract class TableUIBridge extends TableUI { /** * Sign int. * - * @param num the num - * @return the int + * @param num the num + * @return the int */ protected static int sign(final int num) { return Integer.compare(num, 0); @@ -1417,7 +1389,7 @@ public abstract class TableUIBridge extends TableUI { ListSelectionModel csm = table.getColumnModel().getSelectionModel(); leadColumn = getAdjustedLead(table, false, csm); - if (Objects.equals(key, SCROLL_LEFT_CHANGE_SELECTION) || // Paging Actions + if (Objects.equals(key, SCROLL_LEFT_CHANGE_SELECTION) || // Paging Actions Objects.equals(key, SCROLL_LEFT_EXTEND_SELECTION) || Objects.equals(key, SCROLL_RIGHT_CHANGE_SELECTION) || Objects.equals(key, SCROLL_RIGHT_EXTEND_SELECTION) || @@ -1444,8 +1416,7 @@ public abstract class TableUIBridge extends TableUI { this.dy = 0; } } else { - if (!(DarkUIUtil.getUnwrappedParent(table).getParent() instanceof - JScrollPane)) { + if (!(DarkUIUtil.getUnwrappedParent(table).getParent() instanceof JScrollPane)) { return; } @@ -1489,7 +1460,7 @@ public abstract class TableUIBridge extends TableUI { } } } - if (Objects.equals(key, NEXT_ROW) || // Navigate Actions + if (Objects.equals(key, NEXT_ROW) || // Navigate Actions Objects.equals(key, NEXT_ROW_CELL) || Objects.equals(key, NEXT_ROW_EXTEND_SELECTION) || Objects.equals(key, NEXT_ROW_CHANGE_LEAD) || @@ -1545,12 +1516,10 @@ public abstract class TableUIBridge extends TableUI { boolean changeLead = false; if (Objects.equals(key, NEXT_ROW_CHANGE_LEAD) || Objects.equals(key, PREVIOUS_ROW_CHANGE_LEAD)) { - changeLead = (rsm.getSelectionMode() - == ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + changeLead = (rsm.getSelectionMode() == ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } else if (Objects.equals(key, NEXT_COLUMN_CHANGE_LEAD) || Objects.equals(key, PREVIOUS_COLUMN_CHANGE_LEAD)) { - changeLead = (csm.getSelectionMode() - == ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + changeLead = (csm.getSelectionMode() == ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } if (changeLead) { @@ -1614,18 +1583,18 @@ public abstract class TableUIBridge extends TableUI { } /* - if (wasEditingWithFocus) { - table.editCellAt(leadRow, leadColumn); - final Component editorComp = table.getEditorComponent(); - if (editorComp != null) { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - editorComp.requestFocus(); - } - }); - } - } - */ + * if (wasEditingWithFocus) { + * table.editCellAt(leadRow, leadColumn); + * final Component editorComp = table.getEditorComponent(); + * if (editorComp != null) { + * SwingUtilities.invokeLater(new Runnable() { + * public void run() { + * editorComp.requestFocus(); + * } + * }); + * } + * } + */ } else if (Objects.equals(key, CANCEL_EDITING)) { table.removeEditor(); } else if (Objects.equals(key, SELECT_ALL)) { @@ -1667,7 +1636,7 @@ public abstract class TableUIBridge extends TableUI { } else if (Objects.equals(key, FOCUS_HEADER)) { JTableHeader th = table.getTableHeader(); if (th != null) { - //Set the header's selected column to match the table. + // Set the header's selected column to match the table. int col = table.getSelectedColumn(); if (col >= 0) { TableHeaderUI thUI = th.getUI(); @@ -1676,7 +1645,7 @@ public abstract class TableUIBridge extends TableUI { } } - //Then give the header the focus. + // Then give the header the focus. th.requestFocusInWindow(); } } @@ -1697,10 +1666,10 @@ public abstract class TableUIBridge extends TableUI { /** * Clip to range int. * - * @param i the - * @param a the a - * @param b the b - * @return the int + * @param i the + * @param a the a + * @param b the b + * @return the int */ protected static int clipToRange(final int i, final int a, final int b) { return Math.min(Math.max(i, a), b - 1); @@ -1714,12 +1683,12 @@ public abstract class TableUIBridge extends TableUI { * performing modifications, it is recommended that caution be taken in order to preserve the intent of this * method, especially when deciding whether to query the selection models or interact with JTable directly. * - * @param table the table - * @param dx the dx - * @param dy the dy - * @param rsm the rsm - * @param csm the csm - * @return the boolean + * @param table the table + * @param dx the dx + * @param dy the dy + * @param rsm the rsm + * @param csm the csm + * @return the boolean */ protected boolean moveWithinSelectedRange(final JTable table, final int dx, final int dy, final ListSelectionModel rsm, final ListSelectionModel csm) { @@ -1772,7 +1741,7 @@ public abstract class TableUIBridge extends TableUI { // - nothing selected if (totalCount == 0 || - // - one item selected, and the lead is already selected + // - one item selected, and the lead is already selected (totalCount == 1 && table.isCellSelected(leadRow, leadColumn))) { stayInSelection = false; @@ -1866,8 +1835,8 @@ public abstract class TableUIBridge extends TableUI { /** * Accept boolean. * - * @param sender the sender - * @return the boolean + * @param sender the sender + * @return the boolean */ public boolean accept(final Object sender) { String key = getName(); @@ -1904,15 +1873,13 @@ public abstract class TableUIBridge extends TableUI { // discontinuous selection actions are only enabled for // DefaultListSelectionModel return sender != null && - ((JTable) sender).getSelectionModel() - instanceof DefaultListSelectionModel; + ((JTable) sender).getSelectionModel() instanceof DefaultListSelectionModel; } else if (Objects.equals(key, NEXT_COLUMN_CHANGE_LEAD) || Objects.equals(key, PREVIOUS_COLUMN_CHANGE_LEAD)) { // discontinuous selection actions are only enabled for // DefaultListSelectionModel return sender != null && - ((JTable) sender).getColumnModel().getSelectionModel() - instanceof DefaultListSelectionModel; + ((JTable) sender).getColumnModel().getSelectionModel() instanceof DefaultListSelectionModel; } else if (Objects.equals(key, ADD_TO_SELECTION) && sender instanceof JTable) { // This action is typically bound to SPACE. // If the table is already in an editing mode, SPACE should @@ -1947,9 +1914,9 @@ public abstract class TableUIBridge extends TableUI { /** * Create a Transferable to use as the source for a data transfer. * - * @param c The component holding the data to be transfered. This argument is provided to enable sharing of - * TransferHandlers by multiple components. - * @return The representation of the data to be transfered. + * @param c The component holding the data to be transfered. This argument is provided to enable sharing of + * TransferHandlers by multiple components. + * @return The representation of the data to be transfered. */ protected Transferable createTransferable(final JComponent c) { if (c instanceof JTable) { @@ -2014,13 +1981,13 @@ public abstract class TableUIBridge extends TableUI { return null; } - } /** * This class should be treated as a "protected" inner class. Instantiate it only within subclasses of * {@code BasicTableUI}. - *

As of Java 2 platform v1.3 this class is no longer used. + *

+ * As of Java 2 platform v1.3 this class is no longer used. * Instead JTable overrides processKeyBinding to dispatch the event to the current * TableCellEditor. */ @@ -2102,19 +2069,19 @@ public abstract class TableUIBridge extends TableUI { * The type Handler. */ protected class Handler implements FocusListener, MouseInputListener, - PropertyChangeListener, ListSelectionListener, ActionListener, - DragRecognitionSupport.BeforeDrag { + PropertyChangeListener, ListSelectionListener, ActionListener, + DragRecognitionSupport.BeforeDrag { /** * The Dispatch component. */ -// Component receiving mouse events during editing. + // Component receiving mouse events during editing. // May not be editorComponent. protected Component dispatchComponent; /** * The Pressed row. */ -// The row and column where the press occurred and the + // The row and column where the press occurred and the // press event itself protected int pressedRow; /** @@ -2128,35 +2095,34 @@ public abstract class TableUIBridge extends TableUI { /** * The Drag press did selection. */ -// Whether or not the mouse press (which is being considered as part + // Whether or not the mouse press (which is being considered as part // of a drag sequence) also caused the selection change to be fully // processed. protected boolean dragPressDidSelection; /** * The Drag started. */ -// Set to true when a drag gesture has been fully recognized and DnD + // Set to true when a drag gesture has been fully recognized and DnD // begins. Use this to ignore further mouse events which could be // delivered if DnD is cancelled (via ESCAPE for example) protected boolean dragStarted; - /** * The Should start timer. */ -// MouseInputListener + // MouseInputListener // Whether or not we should start the editing timer on release protected boolean shouldStartTimer; /** * The Outside pref size. */ -// To cache the return value of pointOutsidePrefSize since we use + // To cache the return value of pointOutsidePrefSize since we use // it multiple times. protected boolean outsidePrefSize; /** * The Timer. */ -// Used to delay the start of editing. + // Used to delay the start of editing. protected Timer timer = null; public void focusGained(final FocusEvent e) { @@ -2166,7 +2132,7 @@ public abstract class TableUIBridge extends TableUI { /** * Repaint lead cell. */ -// FocusListener + // FocusListener protected void repaintLeadCell() { int lr = getAdjustedLead(table, true); int lc = getAdjustedLead(table, false); @@ -2188,17 +2154,15 @@ public abstract class TableUIBridge extends TableUI { * * @param e the e */ -// KeyListener - public void keyPressed(final KeyEvent e) { - } + // KeyListener + public void keyPressed(final KeyEvent e) {} /** * Key released. * * @param e the e */ - public void keyReleased(final KeyEvent e) { - } + public void keyReleased(final KeyEvent e) {} /** * Key typed. @@ -2255,8 +2219,7 @@ public abstract class TableUIBridge extends TableUI { map = component.getInputMap(JComponent.WHEN_FOCUSED); Object binding = (map != null) ? map.get(keyStroke) : null; if (binding == null) { - map = component.getInputMap(JComponent. - WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + map = component.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); binding = (map != null) ? map.get(keyStroke) : null; } if (binding != null) { @@ -2271,8 +2234,7 @@ public abstract class TableUIBridge extends TableUI { } } - public void mouseClicked(final MouseEvent e) { - } + public void mouseClicked(final MouseEvent e) {} public void mousePressed(final MouseEvent e) { if (SwingUtilities2.shouldIgnore(e, table)) { @@ -2293,11 +2255,10 @@ public abstract class TableUIBridge extends TableUI { outsidePrefSize = pointOutsidePrefSize(pressedRow, pressedCol, p); if (isFileList) { - shouldStartTimer = - table.isCellSelected(pressedRow, pressedCol) && - !e.isShiftDown() && - !DarkUIUtil.isMenuShortcutKeyDown(e) && - !outsidePrefSize; + shouldStartTimer = table.isCellSelected(pressedRow, pressedCol) && + !e.isShiftDown() && + !DarkUIUtil.isMenuShortcutKeyDown(e) && + !outsidePrefSize; } if (table.getDragEnabled()) { @@ -2383,8 +2344,7 @@ public abstract class TableUIBridge extends TableUI { // For single select or non-shift-click, clear the selection if (e.getID() == MouseEvent.MOUSE_PRESSED && (!e.isShiftDown() || - table.getSelectionModel().getSelectionMode() == - ListSelectionModel.SINGLE_SELECTION)) { + table.getSelectionModel().getSelectionMode() == ListSelectionModel.SINGLE_SELECTION)) { table.clearSelection(); TableCellEditor tce = table.getCellEditor(); if (tce != null) { @@ -2446,8 +2406,8 @@ public abstract class TableUIBridge extends TableUI { /** * Repost event boolean. * - * @param e the e - * @return the boolean + * @param e the e + * @return the boolean */ protected boolean repostEvent(final MouseEvent e) { // Check for isEditing() in case another event has @@ -2504,11 +2464,9 @@ public abstract class TableUIBridge extends TableUI { adjustSelection(e); } - public void mouseEntered(final MouseEvent e) { - } + public void mouseEntered(final MouseEvent e) {} - public void mouseExited(final MouseEvent e) { - } + public void mouseExited(final MouseEvent e) {} /** * Can start drag boolean. @@ -2525,10 +2483,9 @@ public abstract class TableUIBridge extends TableUI { } // if this is a single selection table - if ((table.getSelectionModel().getSelectionMode() == - ListSelectionModel.SINGLE_SELECTION) && - (table.getColumnModel().getSelectionModel().getSelectionMode() == - ListSelectionModel.SINGLE_SELECTION)) { + if ((table.getSelectionModel().getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) && + (table.getColumnModel().getSelectionModel() + .getSelectionMode() == ListSelectionModel.SINGLE_SELECTION)) { return true; } @@ -2543,8 +2500,7 @@ public abstract class TableUIBridge extends TableUI { */ protected void setValueIsAdjusting(final boolean flag) { table.getSelectionModel().setValueIsAdjusting(flag); - table.getColumnModel().getSelectionModel(). - setValueIsAdjusting(flag); + table.getColumnModel().getSelectionModel().setValueIsAdjusting(flag); } public void valueChanged(final ListSelectionEvent e) { @@ -2568,8 +2524,7 @@ public abstract class TableUIBridge extends TableUI { if (DarkUIUtil.isMenuShortcutKeyDown(me) && isFileList) { table.getSelectionModel().addSelectionInterval(pressedRow, pressedRow); - table.getColumnModel().getSelectionModel(). - addSelectionInterval(pressedCol, pressedCol); + table.getColumnModel().getSelectionModel().addSelectionInterval(pressedCol, pressedCol); } pressedEvent = null; @@ -2605,16 +2560,14 @@ public abstract class TableUIBridge extends TableUI { table.changeSelection(row, column, DarkUIUtil.isMenuShortcutKeyDown(e), true); } - public void mouseMoved(final MouseEvent e) { - } + public void mouseMoved(final MouseEvent e) {} // PropertyChangeListener public void propertyChange(final PropertyChangeEvent event) { String changeName = event.getPropertyName(); if (PropertyKey.COMPONENT_ORIENTATION.equals(changeName)) { - InputMap inputMap = getInputMap( - JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + InputMap inputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); SwingUtilities.replaceUIInputMap(table, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, @@ -2622,8 +2575,7 @@ public abstract class TableUIBridge extends TableUI { JTableHeader header = table.getTableHeader(); if (header != null) { - header.setComponentOrientation( - (ComponentOrientation) event.getNewValue()); + header.setComponentOrientation((ComponentOrientation) event.getNewValue()); } } else if ("dropLocation".equals(changeName)) { JTable.DropLocation oldValue = (JTable.DropLocation) event.getOldValue(); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/TextTableCellEditorBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/TextTableCellEditorBorder.java index 5b649fab..330d6c26 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/TextTableCellEditorBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/TextTableCellEditorBorder.java @@ -20,14 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.table; -import com.github.weisj.darklaf.ui.cell.CellUtil; -import com.github.weisj.darklaf.util.DarkUIUtil; +import java.awt.*; import javax.swing.*; -import java.awt.*; + +import com.github.weisj.darklaf.ui.cell.CellUtil; +import com.github.weisj.darklaf.util.DarkUIUtil; /** * @author Jannis Weis @@ -56,5 +58,4 @@ public class TextTableCellEditorBorder extends DarkTableCellBorder { public Insets getBorderInsets(final Component c) { return CellUtil.adjustEditorInsets(super.getBorderInsets(), c); } - } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/taskpane/DarkTaskPaneContainerUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/taskpane/DarkTaskPaneContainerUI.java index 68c0bc06..64b84735 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/taskpane/DarkTaskPaneContainerUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/taskpane/DarkTaskPaneContainerUI.java @@ -20,16 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.taskpane; -import org.jdesktop.swingx.plaf.basic.BasicTaskPaneContainerUI; - import javax.swing.*; import javax.swing.plaf.ComponentUI; -public class DarkTaskPaneContainerUI extends BasicTaskPaneContainerUI { +import org.jdesktop.swingx.plaf.basic.BasicTaskPaneContainerUI; +public class DarkTaskPaneContainerUI extends BasicTaskPaneContainerUI { public static ComponentUI createUI(final JComponent c) { return new DarkTaskPaneContainerUI(); @@ -41,5 +41,4 @@ public class DarkTaskPaneContainerUI extends BasicTaskPaneContainerUI { taskPane.setOpaque(false); taskPane.setBackgroundPainter(null); } - } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/taskpane/DarkTaskPaneUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/taskpane/DarkTaskPaneUI.java index ed573a7d..a761b85e 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/taskpane/DarkTaskPaneUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/taskpane/DarkTaskPaneUI.java @@ -20,21 +20,24 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.taskpane; -import com.github.weisj.darklaf.util.DarkUIUtil; -import org.jdesktop.swingx.JXCollapsiblePane; -import org.jdesktop.swingx.JXHyperlink; -import org.jdesktop.swingx.JXTaskPane; -import org.jdesktop.swingx.plaf.metal.MetalTaskPaneUI; +import java.awt.*; import javax.swing.*; import javax.swing.border.Border; import javax.swing.border.CompoundBorder; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.UIResource; -import java.awt.*; + +import org.jdesktop.swingx.JXCollapsiblePane; +import org.jdesktop.swingx.JXHyperlink; +import org.jdesktop.swingx.JXTaskPane; +import org.jdesktop.swingx.plaf.metal.MetalTaskPaneUI; + +import com.github.weisj.darklaf.util.DarkUIUtil; public class DarkTaskPaneUI extends MetalTaskPaneUI { @@ -46,7 +49,6 @@ public class DarkTaskPaneUI extends MetalTaskPaneUI { protected Icon openIcon; protected int arc; - public static ComponentUI createUI(final JComponent c) { return new DarkTaskPaneUI(); } @@ -98,7 +100,6 @@ public class DarkTaskPaneUI extends MetalTaskPaneUI { protected final Color color; protected final int arc; - public DarkContentPaneBorder(final Color color, final int arc) { this.arc = arc; this.color = color; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkCaret.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkCaret.java index 2a6111de..2f513b0e 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkCaret.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkCaret.java @@ -20,21 +20,23 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.text; -import com.github.weisj.darklaf.util.DarkUIUtil; +import java.awt.*; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.Transferable; +import java.awt.event.ActionEvent; +import java.awt.event.MouseEvent; import javax.swing.*; import javax.swing.plaf.TextUI; import javax.swing.plaf.UIResource; import javax.swing.text.*; import javax.swing.text.DefaultHighlighterDark.DarkHighlightPainter; -import java.awt.*; -import java.awt.datatransfer.Clipboard; -import java.awt.datatransfer.Transferable; -import java.awt.event.ActionEvent; -import java.awt.event.MouseEvent; + +import com.github.weisj.darklaf.util.DarkUIUtil; /** * @author Jannis Weis @@ -101,7 +103,7 @@ public class DarkCaret extends DefaultCaret implements UIResource { * contextual purposes while they are displayed. * * @param alwaysVisible Whether this caret should always be visible. - * @see #isAlwaysVisible() + * @see #isAlwaysVisible() */ public void setAlwaysVisible(final boolean alwaysVisible) { if (alwaysVisible != this.alwaysVisible) { @@ -123,7 +125,7 @@ public class DarkCaret extends DefaultCaret implements UIResource { } /** - * Called when the mouse is clicked. If the click was generated from button1, a double click selects a word, and a + * Called when the mouse is clicked. If the click was generated from button1, a double click selects a word, and a * triple click the current line. * * @param e the mouse event @@ -138,11 +140,11 @@ public class DarkCaret extends DefaultCaret implements UIResource { if (clickCount > 2) { clickCount %= 2; // Alternate selecting word/line. switch (clickCount) { - case 0: + case 0 : selectWord(e); selectedWordEvent = null; break; - case 1: + case 1 : selectLine.actionPerformed(new ActionEvent(textArea, ActionEvent.ACTION_PERFORMED, null, e.getWhen(), e.getModifiersEx())); @@ -154,7 +156,7 @@ public class DarkCaret extends DefaultCaret implements UIResource { if (clickCount == 1 && textArea.isEditable() && textArea.isEnabled()) { // Paste the system selection, if it exists (e.g., on UNIX // platforms, the user can select text, the middle-mouse click - // to paste it; this doesn't work on Windows). If the system + // to paste it; this doesn't work on Windows). If the system // doesn't support system selection, just do a normal paste. JTextComponent c = (JTextComponent) e.getSource(); if (c != null) { @@ -179,8 +181,7 @@ public class DarkCaret extends DefaultCaret implements UIResource { else { textArea.paste(); } - } catch (HeadlessException ignored) { - } + } catch (HeadlessException ignored) {} } } } @@ -195,7 +196,6 @@ public class DarkCaret extends DefaultCaret implements UIResource { } } - private void adjustFocus(final boolean inWindow) { JTextComponent textArea = getComponent(); if ((textArea != null) && textArea.isEnabled() && @@ -238,7 +238,6 @@ public class DarkCaret extends DefaultCaret implements UIResource { return pasteOnMiddleMouseClick; } - @Override public void mousePressed(final MouseEvent e) { super.mousePressed(e); @@ -281,17 +280,17 @@ public class DarkCaret extends DefaultCaret implements UIResource { Color textAreaBg = textArea.getBackground(); switch (style) { - case BLOCK_STYLE: + case BLOCK_STYLE : if (textAreaBg == null) { textAreaBg = Color.white; } g.setXORMode(textAreaBg); g.fillRect(r.x, r.y, r.width, r.height); break; - case BLOCK_BORDER_STYLE: + case BLOCK_BORDER_STYLE : DarkUIUtil.drawRect(g, r.x, r.y, r.width - 1, r.height, 1); break; - case UNDERLINE_STYLE: + case UNDERLINE_STYLE : if (textAreaBg == null) { textAreaBg = Color.white; } @@ -299,17 +298,16 @@ public class DarkCaret extends DefaultCaret implements UIResource { int y = r.y + r.height; g.fillRect(r.x, y - 1, r.width, 1); break; - case THICK_VERTICAL_LINE_STYLE: + case THICK_VERTICAL_LINE_STYLE : g.fillRect(r.x, r.y, 2, r.height); break; - case VERTICAL_LINE_STYLE: + case VERTICAL_LINE_STYLE : g.fillRect(r.x, r.y, 1, r.height); break; } } } - /** * Selects word based on a mouse event. */ @@ -326,18 +324,15 @@ public class DarkCaret extends DefaultCaret implements UIResource { selectedWordEvent = e; } - public void setPasteOnMiddleMouseClick(final boolean paste) { pasteOnMiddleMouseClick = paste; } - @Override public void setSelectionVisible(final boolean visible) { super.setSelectionVisible(true); } - private void validateWidth(final Rectangle rect) { if (rect != null && rect.width <= 1) { JTextComponent textArea = getComponent(); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkEditorPaneUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkEditorPaneUI.java index 02885884..5084d426 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkEditorPaneUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkEditorPaneUI.java @@ -20,10 +20,12 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.text; -import com.github.weisj.darklaf.util.PropertyKey; +import java.awt.*; +import java.beans.PropertyChangeEvent; import javax.swing.*; import javax.swing.plaf.ActionMapUIResource; @@ -32,8 +34,8 @@ import javax.swing.plaf.UIResource; import javax.swing.text.*; import javax.swing.text.html.HTMLDocument; import javax.swing.text.html.StyleSheet; -import java.awt.*; -import java.beans.PropertyChangeEvent; + +import com.github.weisj.darklaf.util.PropertyKey; /** * @author Jannis Weis @@ -46,7 +48,6 @@ public class DarkEditorPaneUI extends DarkTextUI { */ private static final String FONT_ATTRIBUTE_KEY = "FONT_ATTRIBUTE_KEY"; - /** * Creates a new BasicEditorPaneUI. */ @@ -57,8 +58,6 @@ public class DarkEditorPaneUI extends DarkTextUI { /* * Implementation of DarkEditorPaneUI */ - - public static ComponentUI createUI(final JComponent c) { return new DarkEditorPaneUI(); } @@ -82,8 +81,7 @@ public class DarkEditorPaneUI extends DarkTextUI { JComponent c = getComponent(); Object honorDisplayPropertiesObject = c.getClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES); boolean honorDisplayProperties = false; - Object w3cLengthUnitsObject = c.getClientProperty(JEditorPane. - W3C_LENGTH_UNITS); + Object w3cLengthUnitsObject = c.getClientProperty(JEditorPane.W3C_LENGTH_UNITS); boolean w3cLengthUnits = false; if (honorDisplayPropertiesObject instanceof Boolean) { honorDisplayProperties = (Boolean) honorDisplayPropertiesObject; @@ -92,7 +90,7 @@ public class DarkEditorPaneUI extends DarkTextUI { w3cLengthUnits = (Boolean) w3cLengthUnitsObject; } if (this instanceof DarkTextPaneUI || honorDisplayProperties) { - //using equals because can not use UIResource for Boolean + // using equals because can not use UIResource for Boolean Document doc = getComponent().getDocument(); if (doc instanceof StyledDocument) { if (doc instanceof HTMLDocument && honorDisplayProperties) { @@ -125,8 +123,7 @@ public class DarkEditorPaneUI extends DarkTextUI { Document document = component.getDocument(); if (document instanceof HTMLDocument) { StyleSheet styleSheet = new StyleSheetUIResource(); - StyleSheet documentStyleSheet = - ((HTMLDocument) document).getStyleSheet(); + StyleSheet documentStyleSheet = ((HTMLDocument) document).getStyleSheet(); StyleSheet[] styleSheets = documentStyleSheet.getStyleSheets(); if (styleSheets != null) { for (StyleSheet s : styleSheets) { @@ -250,9 +247,8 @@ public class DarkEditorPaneUI extends DarkTextUI { } /** - * Fetch an action map to use. The map for a JEditorPane is not shared because it changes with the EditorKit. + * Fetch an action map to use. The map for a JEditorPane is not shared because it changes with the EditorKit. */ - public ActionMap getActionMap() { ActionMap am = new ActionMapUIResource(); am.put("requestFocus", new FocusAction()); @@ -280,7 +276,7 @@ public class DarkEditorPaneUI extends DarkTextUI { } /** - * This method gets called when a bound property is changed on the associated JTextComponent. This is a hook which + * This method gets called when a bound property is changed on the associated JTextComponent. This is a hook which * UI implementations may change to reflect how the UI displays bound properties of JTextComponent subclasses. This * is implemented to rebuild the ActionMap based upon an EditorKit change. * @@ -314,8 +310,7 @@ public class DarkEditorPaneUI extends DarkTextUI { || PropertyKey.FONT.equals(name) || PropertyKey.DOCUMENT.equals(name) || JEditorPane.W3C_LENGTH_UNITS.equals(name) - || JEditorPane.HONOR_DISPLAY_PROPERTIES.equals(name) - ) { + || JEditorPane.HONOR_DISPLAY_PROPERTIES.equals(name)) { JComponent c = getComponent(); updateDisplayProperties(c.getFont(), c.getForeground()); if (JEditorPane.W3C_LENGTH_UNITS.equals(name) @@ -333,12 +328,11 @@ public class DarkEditorPaneUI extends DarkTextUI { } } - } } /** - * Fetches the name used as a key to lookup properties through the UIManager. This is used as a prefix to all the + * Fetches the name used as a key to lookup properties through the UIManager. This is used as a prefix to all the * standard text properties. * * @return the name ("EditorPane") @@ -358,7 +352,7 @@ public class DarkEditorPaneUI extends DarkTextUI { } /** - * Fetches the EditorKit for the UI. This is whatever is currently set in the associated JEditorPane. + * Fetches the EditorKit for the UI. This is whatever is currently set in the associated JEditorPane. * * @return the editor capabilities */ @@ -373,6 +367,5 @@ public class DarkEditorPaneUI extends DarkTextUI { } } - protected static class StyleSheetUIResource extends StyleSheet implements UIResource { - } + protected static class StyleSheetUIResource extends StyleSheet implements UIResource {} } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkFormattedTextFieldUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkFormattedTextFieldUI.java index 878ee93b..c218412c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkFormattedTextFieldUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkFormattedTextFieldUI.java @@ -20,19 +20,21 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.text; -import com.github.weisj.darklaf.util.PropertyKey; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.text.ParseException; import javax.swing.*; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.plaf.ComponentUI; import javax.swing.text.Document; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.text.ParseException; + +import com.github.weisj.darklaf.util.PropertyKey; /** * @author Jannis Weis @@ -41,7 +43,6 @@ public class DarkFormattedTextFieldUI extends DarkTextFieldUI implements Propert private JFormattedTextField textField; - public static ComponentUI createUI(final JComponent c) { return new DarkFormattedTextFieldUI(); } @@ -94,8 +95,7 @@ public class DarkFormattedTextFieldUI extends DarkTextFieldUI implements Propert } @Override - public void changedUpdate(final DocumentEvent e) { - } + public void changedUpdate(final DocumentEvent e) {} protected void update() { if (textField == null) return; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkHighlighter.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkHighlighter.java index b9c5e2f2..b820e6c7 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkHighlighter.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkHighlighter.java @@ -20,10 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.text; import javax.swing.plaf.basic.BasicTextUI; -public class DarkHighlighter extends BasicTextUI.BasicHighlighter { -} +public class DarkHighlighter extends BasicTextUI.BasicHighlighter {} diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkPasswordFieldUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkPasswordFieldUI.java index 48c19cb1..36175941 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkPasswordFieldUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkPasswordFieldUI.java @@ -20,21 +20,23 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.text; -import com.github.weisj.darklaf.decorators.MouseMovementListener; -import com.github.weisj.darklaf.util.DarkUIUtil; -import com.github.weisj.darklaf.util.GraphicsContext; +import java.awt.*; +import java.awt.event.*; +import java.beans.PropertyChangeEvent; +import java.util.Arrays; import javax.swing.*; import javax.swing.border.Border; import javax.swing.plaf.ComponentUI; import javax.swing.text.JTextComponent; -import java.awt.*; -import java.awt.event.*; -import java.beans.PropertyChangeEvent; -import java.util.Arrays; + +import com.github.weisj.darklaf.decorators.MouseMovementListener; +import com.github.weisj.darklaf.util.DarkUIUtil; +import com.github.weisj.darklaf.util.GraphicsContext; /** * @author Konstantin Bulenkov @@ -90,7 +92,6 @@ public class DarkPasswordFieldUI extends DarkPasswordFieldUIBridge { } }; - public static ComponentUI createUI(final JComponent c) { return new DarkPasswordFieldUI(); } @@ -184,7 +185,6 @@ public class DarkPasswordFieldUI extends DarkPasswordFieldUIBridge { && Boolean.TRUE.equals(((JComponent) c).getClientProperty(KEY_SHOW_VIEW_BUTTON)); } - private Point getShowIconCoord() { Rectangle r = getDrawingRect(getComponent()); int w = getShowIcon().getIconWidth(); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkPasswordFieldUIBridge.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkPasswordFieldUIBridge.java index a6d44076..ae883fb9 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkPasswordFieldUIBridge.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkPasswordFieldUIBridge.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.text; @@ -54,7 +55,7 @@ public abstract class DarkPasswordFieldUIBridge extends DarkTextFieldUI { } /** - * Fetches the name used as a key to look up properties through the UIManager. This is used as a prefix to all the + * Fetches the name used as a key to look up properties through the UIManager. This is used as a prefix to all the * standard text properties. * * @return the name ("PasswordField") @@ -66,18 +67,17 @@ public abstract class DarkPasswordFieldUIBridge extends DarkTextFieldUI { /** * Creates a view (PasswordView) for an element. * - * @param elem the element - * @return the view + * @param elem the element + * @return the view */ public View create(final Element elem) { return new PasswordView(elem); } /** - * Create the action map for Password Field. This map provides same actions for double mouse click and and for + * Create the action map for Password Field. This map provides same actions for double mouse click and and for * triple mouse click (see bug 4231444). */ - public ActionMap createActionMap() { ActionMap map = super.createActionMap(); if (map.get(DefaultEditorKit.selectWordAction) != null) { @@ -89,5 +89,4 @@ public abstract class DarkPasswordFieldUIBridge extends DarkTextFieldUI { } return map; } - } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextAreaUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextAreaUI.java index b2280ba3..f42327b4 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextAreaUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextAreaUI.java @@ -20,18 +20,20 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.text; -import com.github.weisj.darklaf.ui.html.DarkHTML; -import com.github.weisj.darklaf.util.PropertyKey; +import java.awt.*; +import java.beans.PropertyChangeEvent; import javax.swing.*; import javax.swing.event.DocumentEvent; import javax.swing.plaf.ComponentUI; import javax.swing.text.*; -import java.awt.*; -import java.beans.PropertyChangeEvent; + +import com.github.weisj.darklaf.ui.html.DarkHTML; +import com.github.weisj.darklaf.util.PropertyKey; /** * @author Jannis Weis @@ -45,9 +47,8 @@ public class DarkTextAreaUI extends DarkTextUI { /* * Implementation of BasicTextAreaUI */ - /** - * This method gets called when a bound property is changed on the associated JTextComponent. This is a hook which + * This method gets called when a bound property is changed on the associated JTextComponent. This is a hook which * UI implementations may change to reflect how the UI displays bound properties of JTextComponent subclasses. This * is implemented to rebuild the View when the * WrapLine or the WrapStyleWord property changes. @@ -67,7 +68,7 @@ public class DarkTextAreaUI extends DarkTextUI { } /** - * Fetches the name used as a key to look up properties through the UIManager. This is used as a prefix to all the + * Fetches the name used as a key to look up properties through the UIManager. This is used as a prefix to all the * standard text properties. * * @return the name ("TextArea") @@ -79,38 +80,38 @@ public class DarkTextAreaUI extends DarkTextUI { /** * The method is overridden to take into account caret width. * - * @param c the editor component - * @return the preferred size + * @param c the editor component + * @return the preferred size * @throws IllegalArgumentException if invalid value is passed - * @since 1.5 + * @since 1.5 */ public Dimension getPreferredSize(final JComponent c) { return super.getPreferredSize(c); - //the fix for 4785160 is undone + // the fix for 4785160 is undone } /** * The method is overridden to take into account caret width. * - * @param c the editor component - * @return the minimum size + * @param c the editor component + * @return the minimum size * @throws IllegalArgumentException if invalid value is passed - * @since 1.5 + * @since 1.5 */ public Dimension getMinimumSize(final JComponent c) { return super.getMinimumSize(c); - //the fix for 4785160 is undone + // the fix for 4785160 is undone } /** - * Creates the view for an element. Returns a WrappedPlainView or PlainView. + * Creates the view for an element. Returns a WrappedPlainView or PlainView. * - * @param elem the element - * @return the view + * @param elem the element + * @return the view */ public View create(final Element elem) { Document doc = elem.getDocument(); - Object i18nFlag = doc.getProperty("i18n"/*AbstractDocument.I18NProperty*/); + Object i18nFlag = doc.getProperty("i18n"/* AbstractDocument.I18NProperty */); if ((i18nFlag != null) && i18nFlag.equals(Boolean.TRUE)) { // build a view that support bidi return createI18N(elem); @@ -147,8 +148,8 @@ public class DarkTextAreaUI extends DarkTextUI { * * @throws NullPointerException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} - * @see javax.swing.JComponent#getBaseline(int, int) - * @since 1.6 + * @see javax.swing.JComponent#getBaseline(int, int) + * @since 1.6 */ public int getBaseline(final JComponent c, final int width, int height) { super.getBaseline(c, width, height); @@ -176,11 +177,10 @@ public class DarkTextAreaUI extends DarkTextUI { * Returns an enum indicating how the baseline of the component changes as the size changes. * * @throws NullPointerException {@inheritDoc} - * @see javax.swing.JComponent#getBaseline(int, int) - * @since 1.6 + * @see javax.swing.JComponent#getBaseline(int, int) + * @since 1.6 */ - public Component.BaselineResizeBehavior getBaselineResizeBehavior( - final JComponent c) { + public Component.BaselineResizeBehavior getBaselineResizeBehavior(final JComponent c) { super.getBaselineResizeBehavior(c); return Component.BaselineResizeBehavior.CONSTANT_ASCENT; } @@ -190,7 +190,6 @@ public class DarkTextAreaUI extends DarkTextUI { return DarkCaret.CaretStyle.VERTICAL_LINE_STYLE; } - /** * Paragraph for representing plain-text lines that support bidirectional text. */ @@ -256,7 +255,7 @@ public class DarkTextAreaUI extends DarkTextUI { } /** - * Sets the size of the view. If the size has changed, layout is redone. The size is the full size of the view + * Sets the size of the view. If the size has changed, layout is redone. The size is the full size of the view * including the inset areas. * * @param width the width (non negative) @@ -270,9 +269,9 @@ public class DarkTextAreaUI extends DarkTextUI { } /** - * This class can be used to represent a logical view for a flow. It keeps the children updated to reflect the + * This class can be used to represent a logical view for a flow. It keeps the children updated to reflect the * state of the model, gives the logical child views access to the view hierarchy, and calculates a preferred - * span. It doesn't do any rendering, layout, or model/view translation. + * span. It doesn't do any rendering, layout, or model/view translation. */ protected static class LogicalView extends CompositeView { @@ -302,8 +301,7 @@ public class DarkTextAreaUI extends DarkTextUI { return null; } - protected void childAllocation(final int index, final Rectangle a) { - } + protected void childAllocation(final int index, final Rectangle a) {} // The following methods don't do anything useful, they // simply keep the class from being abstract. @@ -325,8 +323,7 @@ public class DarkTextAreaUI extends DarkTextUI { return v.getPreferredSpan(axis); } - public void paint(final Graphics g, final Shape allocation) { - } + public void paint(final Graphics g, final Shape allocation) {} protected boolean updateChildren(final DocumentEvent.ElementChange ec, final DocumentEvent e, final ViewFactory f) { @@ -334,7 +331,7 @@ public class DarkTextAreaUI extends DarkTextUI { } /** - * Forward the DocumentEvent to the given child view. This is implemented to reparent the child to the + * Forward the DocumentEvent to the given child view. This is implemented to reparent the child to the * logical view (the children may have been parented by a row in the flow if they fit without breaking) and * then execute the superclass behavior. * @@ -342,8 +339,8 @@ public class DarkTextAreaUI extends DarkTextUI { * @param e the change information from the associated document * @param a the current allocation of the view * @param f the factory to use to rebuild if the view has children - * @see #forwardUpdate - * @since 1.3 + * @see #forwardUpdate + * @since 1.3 */ protected void forwardUpdateToView(final View v, final DocumentEvent e, final Shape a, final ViewFactory f) { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextBorder.java index 640f0cf1..3c05863e 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextBorder.java @@ -20,18 +20,20 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.text; -import com.github.weisj.darklaf.util.DarkUIUtil; -import com.github.weisj.darklaf.util.GraphicsContext; -import com.github.weisj.darklaf.util.GraphicsUtil; +import java.awt.*; import javax.swing.*; import javax.swing.border.Border; import javax.swing.plaf.UIResource; import javax.swing.text.JTextComponent; -import java.awt.*; + +import com.github.weisj.darklaf.util.DarkUIUtil; +import com.github.weisj.darklaf.util.GraphicsContext; +import com.github.weisj.darklaf.util.GraphicsUtil; /** * @author Jannis Weis diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUI.java index d75a8cc5..66982f85 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUI.java @@ -20,24 +20,26 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.text; -import com.github.weisj.darklaf.decorators.MouseClickListener; -import com.github.weisj.darklaf.decorators.MouseMovementListener; -import com.github.weisj.darklaf.decorators.PopupMenuAdapter; -import com.github.weisj.darklaf.util.DarkUIUtil; -import com.github.weisj.darklaf.util.GraphicsContext; +import java.awt.*; +import java.awt.event.*; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; import javax.swing.*; import javax.swing.event.PopupMenuEvent; import javax.swing.event.PopupMenuListener; import javax.swing.plaf.ComponentUI; import javax.swing.text.JTextComponent; -import java.awt.*; -import java.awt.event.*; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; + +import com.github.weisj.darklaf.decorators.MouseClickListener; +import com.github.weisj.darklaf.decorators.MouseMovementListener; +import com.github.weisj.darklaf.decorators.PopupMenuAdapter; +import com.github.weisj.darklaf.util.DarkUIUtil; +import com.github.weisj.darklaf.util.GraphicsContext; /** * @author Konstantin Bulenkov @@ -87,17 +89,14 @@ public class DarkTextFieldUI extends DarkTextFieldUIBridge implements PropertyCh } }; - public static ComponentUI createUI(final JComponent c) { return new DarkTextFieldUI(); } - protected static Icon getClearIcon(final boolean clearHovered) { return clearHovered ? clearHover : clear; } - public static Rectangle getTextRect(final JComponent c) { Insets i = c.getInsets(); Dimension dim = c.getSize(); @@ -119,15 +118,15 @@ public class DarkTextFieldUI extends DarkTextFieldUIBridge implements PropertyCh Rectangle drawRect = getDrawingRect(getComponent()); Rectangle textRect = getTextRect(getComponent()); int rightBoundary = getComponent().getText().isEmpty() - ? drawRect.x + drawRect.width - : getClearIconCoord().x; + ? drawRect.x + drawRect.width + : getClearIconCoord().x; boolean insideTextArea = drawRect.contains(p) && p.x >= textRect.x && p.x < rightBoundary; if (insideTextArea) { getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); } else { Cursor cursor = action == ClickAction.NONE - ? Cursor.getDefaultCursor() - : Cursor.getPredefinedCursor(Cursor.HAND_CURSOR); + ? Cursor.getDefaultCursor() + : Cursor.getPredefinedCursor(Cursor.HAND_CURSOR); getComponent().setCursor(cursor); } } @@ -145,7 +144,6 @@ public class DarkTextFieldUI extends DarkTextFieldUIBridge implements PropertyCh return ClickAction.NONE; } - private static JPopupMenu getSearchPopup(final JComponent c) { Object value = c.getClientProperty(KEY_FIND_POPUP); return value instanceof JPopupMenu ? (JPopupMenu) value : null; @@ -166,7 +164,6 @@ public class DarkTextFieldUI extends DarkTextFieldUIBridge implements PropertyCh return isSearchField(c) && getSearchPopup((JComponent) c) != null; } - public static boolean isSearchField(final Component c) { return c instanceof JTextField && VARIANT_SEARCH.equals(((JTextField) c).getClientProperty(KEY_VARIANT)); } @@ -217,7 +214,6 @@ public class DarkTextFieldUI extends DarkTextFieldUIBridge implements PropertyCh w, editor); } - protected void showSearchPopup() { if (lastSearchEvent == 0 || (System.currentTimeMillis() - lastSearchEvent) > 250) { JPopupMenu menu = getSearchPopup(getComponent()); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUIBridge.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUIBridge.java index 81195e13..472e415c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUIBridge.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUIBridge.java @@ -20,16 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.text; -import com.github.weisj.darklaf.ui.html.DarkHTML; +import java.awt.*; import javax.swing.*; import javax.swing.event.DocumentEvent; import javax.swing.plaf.basic.BasicTextFieldUI; import javax.swing.text.*; -import java.awt.*; + +import com.github.weisj.darklaf.ui.html.DarkHTML; /** * This class is an exact copy of the implementation of {@link BasicTextFieldUI}. In this way it is possible to contain @@ -41,7 +43,7 @@ import java.awt.*; public abstract class DarkTextFieldUIBridge extends DarkTextUI { /** - * Fetches the name used as a key to lookup properties through the UIManager. This is used as a prefix to all the + * Fetches the name used as a key to lookup properties through the UIManager. This is used as a prefix to all the * standard text properties. * * @return the name ("TextField") @@ -53,12 +55,12 @@ public abstract class DarkTextFieldUIBridge extends DarkTextUI { /** * Creates a view (FieldView) based on an element. * - * @param elem the element - * @return the view + * @param elem the element + * @return the view */ public View create(final Element elem) { Document doc = elem.getDocument(); - Object i18nFlag = doc.getProperty("i18n"/*AbstractDocument.I18NProperty*/); + Object i18nFlag = doc.getProperty("i18n"/* AbstractDocument.I18NProperty */); if (Boolean.TRUE.equals(i18nFlag)) { // To support bidirectional text, we build a more heavyweight // representation of the field. @@ -86,8 +88,8 @@ public abstract class DarkTextFieldUIBridge extends DarkTextUI { * * @throws NullPointerException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} - * @see javax.swing.JComponent#getBaseline(int, int) - * @since 1.6 + * @see javax.swing.JComponent#getBaseline(int, int) + * @since 1.6 */ public int getBaseline(final JComponent c, final int width, int height) { super.getBaseline(c, width, height); @@ -104,9 +106,8 @@ public abstract class DarkTextFieldUIBridge extends DarkTextUI { baseline += slop / 2; } if (fieldView instanceof I18nFieldView) { - int fieldBaseline = DarkHTML.getBaseline( - fieldView, width - insets.left - insets.right, - height); + int fieldBaseline = DarkHTML.getBaseline(fieldView, width - insets.left - insets.right, + height); if (fieldBaseline < 0) { return -1; } @@ -125,16 +126,14 @@ public abstract class DarkTextFieldUIBridge extends DarkTextUI { * Returns an enum indicating how the baseline of the component changes as the size changes. * * @throws NullPointerException {@inheritDoc} - * @see javax.swing.JComponent#getBaseline(int, int) - * @since 1.6 + * @see javax.swing.JComponent#getBaseline(int, int) + * @since 1.6 */ - public Component.BaselineResizeBehavior getBaselineResizeBehavior( - final JComponent c) { + public Component.BaselineResizeBehavior getBaselineResizeBehavior(final JComponent c) { super.getBaselineResizeBehavior(c); return Component.BaselineResizeBehavior.CENTER_OFFSET; } - /** * A field view that support bidirectional text via the support provided by ParagraphView. */ @@ -150,7 +149,7 @@ public abstract class DarkTextFieldUIBridge extends DarkTextUI { } /** - * Fetch the constraining span to flow against for the given child index. There is no limit for a field since + * Fetch the constraining span to flow against for the given child index. There is no limit for a field since * it scrolls, so this is implemented to return Integer.MAX_VALUE. */ public int getFlowSpan(final int index) { @@ -163,7 +162,7 @@ public abstract class DarkTextFieldUIBridge extends DarkTextUI { * * @param g the rendering surface to use * @param a the allocated region to render into - * @see View#paint + * @see View#paint */ public void paint(final Graphics g, final Shape a) { Rectangle r = (Rectangle) a; @@ -177,8 +176,8 @@ public abstract class DarkTextFieldUIBridge extends DarkTextUI { * Horizontally the view is adjusted according to the horizontal alignment property set on the associated * JTextField (if that is the type of the hosting component). * - * @param a the allocation given to the view, which may need to be adjusted. - * @return the allocation that the superclass should use. + * @param a the allocation given to the view, which may need to be adjusted. + * @return the allocation that the superclass should use. */ Shape adjustAllocation(final Shape a) { if (a != null) { @@ -224,11 +223,11 @@ public abstract class DarkTextFieldUIBridge extends DarkTextUI { } switch (align) { - case SwingConstants.CENTER: + case SwingConstants.CENTER : bounds.x += slop / 2; bounds.width -= slop; break; - case SwingConstants.RIGHT: + case SwingConstants.RIGHT : bounds.x += slop; bounds.width -= slop; break; @@ -251,10 +250,10 @@ public abstract class DarkTextFieldUIBridge extends DarkTextUI { // --- View methods ------------------------------------------- /** - * Determines the resizability of the view along the given axis. A value of 0 or less is not resizable. + * Determines the resizability of the view along the given axis. A value of 0 or less is not resizable. * - * @param axis View.X_AXIS or View.Y_AXIS - * @return the weight -> 1 for View.X_AXIS, else 0 + * @param axis View.X_AXIS or View.Y_AXIS + * @return the weight -> 1 for View.X_AXIS, else 0 */ public int getResizeWeight(final int axis) { if (axis == View.X_AXIS) { @@ -267,12 +266,12 @@ public abstract class DarkTextFieldUIBridge extends DarkTextUI { * Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to * it. * - * @param pos the position to convert >= 0 - * @param a the allocated region to render into - * @return the bounding box of the given position + * @param pos the position to convert >= 0 + * @param a the allocated region to render into + * @return the bounding box of the given position * @throws BadLocationException if the given position does not represent a valid location in the associated * document - * @see View#modelToView + * @see View#modelToView */ public Shape modelToView(final int pos, final Shape a, final Position.Bias b) throws BadLocationException { return super.modelToView(pos, adjustAllocation(a), b); @@ -281,11 +280,11 @@ public abstract class DarkTextFieldUIBridge extends DarkTextUI { /** * Provides a mapping from the view coordinate space to the logical coordinate space of the model. * - * @param fx the X coordinate >= 0.0f - * @param fy the Y coordinate >= 0.0f - * @param a the allocated region to render into - * @return the location within the model that best represents the given point in the view - * @see View#viewToModel + * @param fx the X coordinate >= 0.0f + * @param fy the Y coordinate >= 0.0f + * @param a the allocated region to render into + * @return the location within the model that best represents the given point in the view + * @see View#viewToModel */ public int viewToModel(final float fx, final float fy, final Shape a, final Position.Bias[] bias) { return super.viewToModel(fx, fy, adjustAllocation(a), bias); @@ -295,22 +294,24 @@ public abstract class DarkTextFieldUIBridge extends DarkTextUI { * Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to * it. * - * @param p0 the position to convert >= 0 - * @param b0 the bias toward the previous character or the next character represented by p0, in case the - * position is a boundary of two views. - * @param p1 the position to convert >= 0 - * @param b1 the bias toward the previous character or the next character represented by p1, in case the - * position is a boundary of two views. - * @param a the allocated region to render into - * @return the bounding box of the given position is returned + * @param p0 the position to convert >= 0 + * @param b0 the bias toward the previous character or the next character represented by + * p0, in case the + * position is a boundary of two views. + * @param p1 the position to convert >= 0 + * @param b1 the bias toward the previous character or the next character represented by + * p1, in case the + * position is a boundary of two views. + * @param a the allocated region to render into + * @return the bounding box of the given position is returned * @throws BadLocationException if the given position does not represent a valid location in the associated * document * @throws IllegalArgumentException for an invalid bias argument - * @see View#viewToModel + * @see View#viewToModel */ public Shape modelToView(final int p0, final Position.Bias b0, final int p1, final Position.Bias b1, final Shape a) - throws BadLocationException { + throws BadLocationException { return super.modelToView(p0, b0, p1, b1, adjustAllocation(a)); } @@ -321,7 +322,7 @@ public abstract class DarkTextFieldUIBridge extends DarkTextUI { * @param changes the change information from the associated document * @param a the current allocation of the view * @param f the factory to use to rebuild if the view has children - * @see View#insertUpdate + * @see View#insertUpdate */ public void insertUpdate(final DocumentEvent changes, final Shape a, final ViewFactory f) { super.insertUpdate(changes, adjustAllocation(a), f); @@ -330,7 +331,7 @@ public abstract class DarkTextFieldUIBridge extends DarkTextUI { /** * Update the visibility model with the associated JTextField (if there is one) to reflect the current - * visibility as a result of changes to the document model. The bounded range properties are updated. If the + * visibility as a result of changes to the document model. The bounded range properties are updated. If the * view hasn't yet been shown the extent will be zero and we just set it to be full until determined otherwise. */ void updateVisibilityModel() { @@ -359,12 +360,11 @@ public abstract class DarkTextFieldUIBridge extends DarkTextUI { * @param changes the change information from the associated document * @param a the current allocation of the view * @param f the factory to use to rebuild if the view has children - * @see View#removeUpdate + * @see View#removeUpdate */ public void removeUpdate(final DocumentEvent changes, final Shape a, final ViewFactory f) { super.removeUpdate(changes, adjustAllocation(a), f); updateVisibilityModel(); } - } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextPaneUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextPaneUI.java index df34034c..89cbdf84 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextPaneUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextPaneUI.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.text; @@ -33,7 +34,6 @@ import javax.swing.text.View; */ public class DarkTextPaneUI extends DarkEditorPaneUI { - public static ComponentUI createUI(final JComponent c) { return new DarkTextPaneUI(); } @@ -41,7 +41,6 @@ public class DarkTextPaneUI extends DarkEditorPaneUI { /* * Implementation of BasicEditorPaneUI */ - @Override public void installUI(final JComponent c) { super.installUI(c); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java index e4adbf03..abc43e08 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.text; @@ -38,6 +39,9 @@ import javax.swing.plaf.InputMapUIResource; import javax.swing.plaf.basic.BasicTextUI; import javax.swing.text.*; +import sun.awt.SunToolkit; +import sun.swing.DefaultLookup; + import com.github.weisj.darklaf.ui.list.DarkListUI; import com.github.weisj.darklaf.ui.table.DarkTableCellBorder; import com.github.weisj.darklaf.ui.table.DarkTableUI; @@ -47,9 +51,6 @@ import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.GraphicsContext; import com.github.weisj.darklaf.util.GraphicsUtil; -import sun.awt.SunToolkit; -import sun.swing.DefaultLookup; - /** * @author Jannis Weis */ @@ -99,8 +100,8 @@ public abstract class DarkTextUI extends BasicTextUI implements PropertyChangeLi // OpenJDK BorderlessTextField has a bug with its setBorder implementation // so we reset the border // See https://mail.openjdk.java.net/pipermail/swing-dev/2020-March/010226.html - if (editor != null && "javax.swing.plaf.basic.BasicComboBoxEditor$BorderlessTextField".equals( - editor.getClass().getName())) { + if (editor != null && "javax.swing.plaf.basic.BasicComboBoxEditor$BorderlessTextField".equals(editor.getClass() + .getName())) { editor.setBorder(null); } if (editor != null) { @@ -272,7 +273,6 @@ public abstract class DarkTextUI extends BasicTextUI implements PropertyChangeLi /* * Implementation of BasicTextUI. */ - /** * Get the InputMap to use for the UI. * @@ -334,13 +334,11 @@ public abstract class DarkTextUI extends BasicTextUI implements PropertyChangeLi char accelerator = editor.getFocusAccelerator(); if (changed || accelerator != '\0') { - InputMap km = SwingUtilities.getUIInputMap - (editor, JComponent.WHEN_IN_FOCUSED_WINDOW); + InputMap km = SwingUtilities.getUIInputMap(editor, JComponent.WHEN_IN_FOCUSED_WINDOW); if (km == null && accelerator != '\0') { km = new ComponentInputMapUIResource(editor); - SwingUtilities.replaceUIInputMap(editor, JComponent. - WHEN_IN_FOCUSED_WINDOW, km); + SwingUtilities.replaceUIInputMap(editor, JComponent.WHEN_IN_FOCUSED_WINDOW, km); ActionMap am = getActionMap(); SwingUtilities.replaceUIActionMap(editor, am); } @@ -349,7 +347,8 @@ public abstract class DarkTextUI extends BasicTextUI implements PropertyChangeLi if (accelerator != '\0') { km.put(KeyStroke.getKeyStroke(accelerator, getFocusAcceleratorKeyMask()), "requestFocus"); km.put(KeyStroke - .getKeyStroke(accelerator, DarkSwingUtil.setAltGraphMask(getFocusAcceleratorKeyMask())), + .getKeyStroke(accelerator, + DarkSwingUtil.setAltGraphMask(getFocusAcceleratorKeyMask())), "requestFocus"); } } @@ -357,7 +356,7 @@ public abstract class DarkTextUI extends BasicTextUI implements PropertyChangeLi } /** - * Create a default action map. This is basically the set of actions found exported by the component. + * Create a default action map. This is basically the set of actions found exported by the component. * * @return the action map */ @@ -395,10 +394,8 @@ public abstract class DarkTextUI extends BasicTextUI implements PropertyChangeLi */ EditorKit editorKit = getEditorKit(editor); if (editorKit instanceof DefaultEditorKit) { - Set storedForwardTraversalKeys = editor.getFocusTraversalKeys( - KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS); - Set storedBackwardTraversalKeys = editor.getFocusTraversalKeys( - KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS); + Set storedForwardTraversalKeys = editor.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS); + Set storedBackwardTraversalKeys = editor.getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS); Set forwardTraversalKeys = new HashSet<>(storedForwardTraversalKeys); Set backwardTraversalKeys = new HashSet<>(storedBackwardTraversalKeys); if (editor.isEditable()) { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/SelectLineAction.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/SelectLineAction.java index 4fe8620c..51435299 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/SelectLineAction.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/SelectLineAction.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.text; +import java.awt.event.ActionEvent; + import javax.swing.*; import javax.swing.text.*; -import java.awt.event.ActionEvent; /** * @author Jannis Weis @@ -96,7 +98,6 @@ public class SelectLineAction extends TextAction { } - private int getFirstNonWhitespacePos() { int offset = currentLine.offset; int end = offset + currentLine.count - 1; @@ -137,5 +138,4 @@ public class SelectLineAction extends TextAction { } } } - } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/SelectWordAction.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/SelectWordAction.java index 2365eb05..30f1c59c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/SelectWordAction.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/SelectWordAction.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.text; +import java.awt.event.ActionEvent; + import javax.swing.*; import javax.swing.text.*; -import java.awt.event.ActionEvent; /** * @author Jannis Weis @@ -72,7 +74,7 @@ public class SelectWordAction extends TextAction { } public int getWordStart(final JTextComponent textArea, final int offs) - throws BadLocationException { + throws BadLocationException { return Utilities.getWordStart(textArea, offs); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/StyleConstantsEx.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/StyleConstantsEx.java index a87ac5c1..07b28415 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/StyleConstantsEx.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/StyleConstantsEx.java @@ -20,9 +20,8 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.text; -public class StyleConstantsEx { - public static final Object SelectedForeground = "selectedForeground"; -} +public class StyleConstantsEx { public static final Object SelectedForeground = "selectedForeground"; } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/titledborder/DarkTitledBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/titledborder/DarkTitledBorder.java index a5c064dc..273d1108 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/titledborder/DarkTitledBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/titledborder/DarkTitledBorder.java @@ -20,16 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.titledborder; -import com.github.weisj.darklaf.components.border.MutableLineBorder; +import java.awt.*; import javax.swing.*; import javax.swing.border.Border; import javax.swing.border.TitledBorder; import javax.swing.plaf.UIResource; -import java.awt.*; + +import com.github.weisj.darklaf.components.border.MutableLineBorder; public class DarkTitledBorder extends MutableLineBorder implements UIResource { @@ -69,5 +71,4 @@ public class DarkTitledBorder extends MutableLineBorder implements UIResource { } } } - } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/ButtonGroupInfo.java b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/ButtonGroupInfo.java index 768beb8f..192c9c3f 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/ButtonGroupInfo.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/ButtonGroupInfo.java @@ -20,14 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.togglebutton; -import javax.swing.*; import java.awt.*; import java.util.Enumeration; import java.util.HashSet; +import javax.swing.*; + public class ButtonGroupInfo { protected final AbstractButton activeButton; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/DarkToggleButtonKeyHandler.java b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/DarkToggleButtonKeyHandler.java index 6a3a731e..5f22247e 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/DarkToggleButtonKeyHandler.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/DarkToggleButtonKeyHandler.java @@ -20,15 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.togglebutton; -import javax.swing.*; import java.awt.*; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.util.Set; +import javax.swing.*; + public class DarkToggleButtonKeyHandler implements KeyListener { // This listener checks if the key event is a focus traversal key event @@ -56,9 +58,7 @@ public class DarkToggleButtonKeyHandler implements KeyListener { return keys != null && keys.contains(stroke); } - public void keyReleased(final KeyEvent e) { - } + public void keyReleased(final KeyEvent e) {} - public void keyTyped(final KeyEvent e) { - } + public void keyTyped(final KeyEvent e) {} } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/DarkToggleButtonListener.java b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/DarkToggleButtonListener.java index 259283d3..03d4818b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/DarkToggleButtonListener.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/DarkToggleButtonListener.java @@ -20,19 +20,20 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.togglebutton; +import java.beans.PropertyChangeEvent; + +import javax.swing.*; + import com.github.weisj.darklaf.ui.button.DarkButtonListener; import com.github.weisj.darklaf.ui.button.DarkButtonUI; import com.github.weisj.darklaf.util.PropertyKey; -import javax.swing.*; -import java.beans.PropertyChangeEvent; - public class DarkToggleButtonListener extends DarkButtonListener implements ToggleButtonConstants { - public DarkToggleButtonListener(final AbstractButton b, final DarkButtonUI ui) { super(b, ui); } @@ -48,11 +49,7 @@ public class DarkToggleButtonListener extends DarkButtonListener implements Togg if (oldVal != null && oldVal.equals(newVal)) { return; } - if (VARIANT_SLIDER.equals(newVal)) { - b.setBorderPainted(false); - } else { - b.setBorderPainted(true); - } + b.setBorderPainted(!VARIANT_SLIDER.equals(newVal)); } else if (PropertyKey.COMPONENT_ORIENTATION.equals(key)) { b.doLayout(); b.repaint(); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/DarkToggleButtonUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/DarkToggleButtonUI.java index badade3d..9cfd8987 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/DarkToggleButtonUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/DarkToggleButtonUI.java @@ -20,21 +20,24 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.togglebutton; -import com.github.weisj.darklaf.ui.button.DarkButtonUI; -import com.github.weisj.darklaf.util.DarkUIUtil; -import com.github.weisj.darklaf.util.GraphicsContext; -import com.github.weisj.darklaf.util.GraphicsUtil; -import sun.swing.SwingUtilities2; +import java.awt.*; +import java.awt.geom.RoundRectangle2D; import javax.swing.*; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.UIResource; import javax.swing.plaf.basic.BasicButtonListener; -import java.awt.*; -import java.awt.geom.RoundRectangle2D; + +import sun.swing.SwingUtilities2; + +import com.github.weisj.darklaf.ui.button.DarkButtonUI; +import com.github.weisj.darklaf.util.DarkUIUtil; +import com.github.weisj.darklaf.util.GraphicsContext; +import com.github.weisj.darklaf.util.GraphicsUtil; /** * @author Jannis Weis @@ -175,7 +178,6 @@ public class DarkToggleButtonUI extends DarkButtonUI implements ToggleButtonCons return b.isEnabled() ? sliderBorderColor : inactiveSliderBorderColor; } - protected Rectangle getSliderBounds(final JComponent c) { int x = borderSize; int y = (c.getHeight() - sliderSize.height) / 2; @@ -216,12 +218,11 @@ public class DarkToggleButtonUI extends DarkButtonUI implements ToggleButtonCons iconRect.x = iconRect.y = iconRect.width = iconRect.height = 0; // layout the text and icon - return SwingUtilities.layoutCompoundLabel( - b, fm, b.getText(), b.getIcon(), - b.getVerticalAlignment(), b.getHorizontalAlignment(), - b.getVerticalTextPosition(), b.getHorizontalTextPosition(), - viewRect, iconRect, textRect, - b.getText() == null ? 0 : b.getIconTextGap()); + return SwingUtilities.layoutCompoundLabel(b, fm, b.getText(), b.getIcon(), + b.getVerticalAlignment(), b.getHorizontalAlignment(), + b.getVerticalTextPosition(), b.getHorizontalTextPosition(), + viewRect, iconRect, textRect, + b.getText() == null ? 0 : b.getIconTextGap()); } public Dimension getPreferredSize(final JComponent c) { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/StateIconUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/StateIconUI.java index 493a0639..4139b0b5 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/StateIconUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/StateIconUI.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.togglebutton; @@ -45,6 +46,6 @@ public interface StateIconUI { return selected ? enabled ? hasFocus ? ui.getSelectedFocusedIcon() : ui.getSelectedIcon() : ui.getSelectedDisabledIcon() : enabled ? hasFocus ? ui.getFocusedIcon() : ui.getIcon() - : ui.getDisabledIcon(); + : ui.getDisabledIcon(); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/ToggleButtonConstants.java b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/ToggleButtonConstants.java index e7598e44..e578581f 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/ToggleButtonConstants.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/ToggleButtonConstants.java @@ -20,16 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.togglebutton; +import java.awt.*; + +import javax.swing.*; + import com.github.weisj.darklaf.ui.table.DarkTableUI; import com.github.weisj.darklaf.ui.tree.DarkTreeUI; import com.github.weisj.darklaf.util.DarkUIUtil; -import javax.swing.*; -import java.awt.*; - public interface ToggleButtonConstants { String KEY_VARIANT = "JToggleButton.variant"; String KEY_IS_TREE_EDITOR = DarkTreeUI.KEY_IS_TREE_EDITOR; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/ToggleButtonFocusNavigationActions.java b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/ToggleButtonFocusNavigationActions.java index b03d3726..677be4ed 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/ToggleButtonFocusNavigationActions.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/ToggleButtonFocusNavigationActions.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.togglebutton; -import javax.swing.*; import java.awt.event.ActionEvent; +import javax.swing.*; + public class ToggleButtonFocusNavigationActions { public static void installActions(final AbstractButton button) { @@ -33,14 +35,11 @@ public class ToggleButtonFocusNavigationActions { button.getActionMap().put("Previous", new SelectPreviousBtn()); button.getActionMap().put("Next", new SelectNextBtn()); - button.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT). - put(KeyStroke.getKeyStroke("UP"), "Previous"); - button.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT). - put(KeyStroke.getKeyStroke("DOWN"), "Next"); - button.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT). - put(KeyStroke.getKeyStroke("LEFT"), "Previous"); - button.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT). - put(KeyStroke.getKeyStroke("RIGHT"), "Next"); + button.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("UP"), "Previous"); + button.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("DOWN"), "Next"); + button.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("LEFT"), + "Previous"); + button.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("RIGHT"), "Next"); } public static void uninstallActions(final AbstractButton button) { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/ToggleButtonMenuItemConstants.java b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/ToggleButtonMenuItemConstants.java index 53052a1a..3c7c5e51 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/ToggleButtonMenuItemConstants.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/ToggleButtonMenuItemConstants.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.togglebutton; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/checkbox/DarkCheckBoxBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/checkbox/DarkCheckBoxBorder.java index 19ad6cef..de197b0c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/checkbox/DarkCheckBoxBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/checkbox/DarkCheckBoxBorder.java @@ -20,16 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.togglebutton.checkbox; - -import com.github.weisj.darklaf.ui.togglebutton.ToggleButtonConstants; +import java.awt.*; import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.plaf.UIResource; -import java.awt.*; + +import com.github.weisj.darklaf.ui.togglebutton.ToggleButtonConstants; /** * @author Jannis Weis diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/checkbox/DarkCheckBoxMenuItemUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/checkbox/DarkCheckBoxMenuItemUI.java index d73d6b35..4c89aafd 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/checkbox/DarkCheckBoxMenuItemUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/checkbox/DarkCheckBoxMenuItemUI.java @@ -20,14 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.togglebutton.checkbox; -import com.github.weisj.darklaf.ui.togglebutton.radiobutton.DarkRadioButtonMenuItemUI; - import javax.swing.*; import javax.swing.plaf.ComponentUI; +import com.github.weisj.darklaf.ui.togglebutton.radiobutton.DarkRadioButtonMenuItemUI; + /** * @author Jannis Weis */ diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/checkbox/DarkCheckBoxUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/checkbox/DarkCheckBoxUI.java index 88aa15e5..0ce98a0e 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/checkbox/DarkCheckBoxUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/checkbox/DarkCheckBoxUI.java @@ -20,15 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.togglebutton.checkbox; -import com.github.weisj.darklaf.ui.togglebutton.radiobutton.DarkRadioButtonUI; +import java.awt.geom.RectangularShape; +import java.awt.geom.RoundRectangle2D; import javax.swing.*; import javax.swing.plaf.ComponentUI; -import java.awt.geom.RectangularShape; -import java.awt.geom.RoundRectangle2D; + +import com.github.weisj.darklaf.ui.togglebutton.radiobutton.DarkRadioButtonUI; /** * @author Konstantin Bulenkov @@ -70,5 +72,4 @@ public class DarkCheckBoxUI extends DarkRadioButtonUI { return new RoundRectangle2D.Float(Math.max(iconRect.x, 0), Math.max(iconRect.y, 0), iconRect.width, iconRect.height, arcSize, arcSize); } - } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonBorder.java index 6b7d8b6c..a343cab8 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonBorder.java @@ -20,16 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.togglebutton.radiobutton; - -import com.github.weisj.darklaf.ui.togglebutton.ToggleButtonConstants; +import java.awt.*; import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.plaf.UIResource; -import java.awt.*; + +import com.github.weisj.darklaf.ui.togglebutton.ToggleButtonConstants; /** * @author Jannis Weis diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonMenuItemUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonMenuItemUI.java index a43417aa..5846b477 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonMenuItemUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonMenuItemUI.java @@ -20,18 +20,21 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.togglebutton.radiobutton; +import java.awt.*; + +import javax.swing.*; +import javax.swing.plaf.ComponentUI; + +import sun.swing.MenuItemLayoutHelper; + import com.github.weisj.darklaf.decorators.MouseClickListener; import com.github.weisj.darklaf.ui.menu.DarkMenuItemUIBase; import com.github.weisj.darklaf.ui.menu.MenuItemLayoutDelegate; import com.github.weisj.darklaf.ui.togglebutton.ToggleButtonMenuItemConstants; -import sun.swing.MenuItemLayoutHelper; - -import javax.swing.*; -import javax.swing.plaf.ComponentUI; -import java.awt.*; /** * @author Jannis Weis diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonUI.java index 63afdf15..73c8335b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonUI.java @@ -20,17 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.togglebutton.radiobutton; -import com.github.weisj.darklaf.ui.togglebutton.DarkToggleButtonKeyHandler; -import com.github.weisj.darklaf.ui.togglebutton.DarkToggleButtonUI; -import com.github.weisj.darklaf.ui.togglebutton.ToggleButtonConstants; -import com.github.weisj.darklaf.ui.togglebutton.ToggleButtonFocusNavigationActions; -import com.github.weisj.darklaf.util.GraphicsContext; -import com.github.weisj.darklaf.util.GraphicsUtil; -import com.github.weisj.darklaf.util.PropertyKey; -import sun.swing.SwingUtilities2; +import java.awt.*; +import java.awt.event.KeyListener; +import java.awt.geom.Ellipse2D; +import java.awt.geom.RectangularShape; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; import javax.swing.*; import javax.swing.plaf.ComponentUI; @@ -38,12 +37,16 @@ import javax.swing.plaf.basic.BasicButtonListener; import javax.swing.plaf.basic.BasicHTML; import javax.swing.plaf.metal.MetalRadioButtonUI; import javax.swing.text.View; -import java.awt.*; -import java.awt.event.KeyListener; -import java.awt.geom.Ellipse2D; -import java.awt.geom.RectangularShape; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; + +import sun.swing.SwingUtilities2; + +import com.github.weisj.darklaf.ui.togglebutton.DarkToggleButtonKeyHandler; +import com.github.weisj.darklaf.ui.togglebutton.DarkToggleButtonUI; +import com.github.weisj.darklaf.ui.togglebutton.ToggleButtonConstants; +import com.github.weisj.darklaf.ui.togglebutton.ToggleButtonFocusNavigationActions; +import com.github.weisj.darklaf.util.GraphicsContext; +import com.github.weisj.darklaf.util.GraphicsUtil; +import com.github.weisj.darklaf.util.PropertyKey; /** * @author Konstantin Bulenkov @@ -63,7 +66,6 @@ public class DarkRadioButtonUI extends MetalRadioButtonUI implements PropertyCha protected BasicButtonListener buttonListener; protected KeyListener keyListener; - public static ComponentUI createUI(final JComponent c) { return new DarkRadioButtonUI(); } @@ -83,7 +85,6 @@ public class DarkRadioButtonUI extends MetalRadioButtonUI implements PropertyCha installIcons(); } - protected void installIcons() { stateIcon = UIManager.getIcon("RadioButton.icon"); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/tristate/DarkTristateCheckBoxMenuItemUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/tristate/DarkTristateCheckBoxMenuItemUI.java index d3afd6fe..4b2ba38d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/tristate/DarkTristateCheckBoxMenuItemUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/tristate/DarkTristateCheckBoxMenuItemUI.java @@ -20,16 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.togglebutton.tristate; +import javax.swing.*; +import javax.swing.plaf.ComponentUI; + import com.github.weisj.darklaf.components.tristate.TristateButtonModel; import com.github.weisj.darklaf.components.tristate.TristateCheckBoxMenuItem; import com.github.weisj.darklaf.ui.togglebutton.checkbox.DarkCheckBoxMenuItemUI; -import javax.swing.*; -import javax.swing.plaf.ComponentUI; - /** * @author Jannis Weis */ diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/tristate/DarkTristateCheckBoxUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/tristate/DarkTristateCheckBoxUI.java index 77336928..20d746cb 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/tristate/DarkTristateCheckBoxUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/tristate/DarkTristateCheckBoxUI.java @@ -20,15 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.togglebutton.tristate; -import com.github.weisj.darklaf.components.tristate.TristateCheckBox; -import com.github.weisj.darklaf.ui.togglebutton.checkbox.DarkCheckBoxUI; - import javax.swing.*; import javax.swing.plaf.ComponentUI; +import com.github.weisj.darklaf.components.tristate.TristateCheckBox; +import com.github.weisj.darklaf.ui.togglebutton.checkbox.DarkCheckBoxUI; + /** * @author Jannis Weis */ diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DarkToolBarBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DarkToolBarBorder.java index b6253f59..e797cb78 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DarkToolBarBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DarkToolBarBorder.java @@ -20,13 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.toolbar; +import java.awt.*; + import javax.swing.*; import javax.swing.border.AbstractBorder; import javax.swing.plaf.UIResource; -import java.awt.*; /** * @author Konstantin Bulenkov @@ -44,7 +46,6 @@ public class DarkToolBarBorder extends AbstractBorder implements UIResource, Swi borderColor = UIManager.getColor("ToolBar.borderColor"); } - public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int w, final int h) { g.translate(x, y); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DarkToolBarLayout.java b/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DarkToolBarLayout.java index c9cad0eb..8298a700 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DarkToolBarLayout.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DarkToolBarLayout.java @@ -20,18 +20,20 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.toolbar; -import com.github.weisj.darklaf.util.PropertyKey; - -import javax.swing.*; -import javax.swing.plaf.UIResource; import java.awt.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.Serializable; +import javax.swing.*; +import javax.swing.plaf.UIResource; + +import com.github.weisj.darklaf.util.PropertyKey; + public class DarkToolBarLayout implements LayoutManager2, Serializable, PropertyChangeListener, UIResource { protected final JToolBar toolBar; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DarkToolBarSeparatorUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DarkToolBarSeparatorUI.java index 06c5f73e..fa2c0537 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DarkToolBarSeparatorUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DarkToolBarSeparatorUI.java @@ -20,14 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.toolbar; -import com.github.weisj.darklaf.ui.separator.DarkSeparatorUI; +import java.awt.*; import javax.swing.*; import javax.swing.plaf.ComponentUI; -import java.awt.*; + +import com.github.weisj.darklaf.ui.separator.DarkSeparatorUI; public class DarkToolBarSeparatorUI extends DarkSeparatorUI { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DarkToolBarUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DarkToolBarUI.java index 5acd0223..4fb82b30 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DarkToolBarUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DarkToolBarUI.java @@ -20,19 +20,21 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.toolbar; -import com.github.weisj.darklaf.decorators.MouseResponder; -import com.github.weisj.darklaf.util.DarkUIUtil; - -import javax.swing.*; -import javax.swing.plaf.ComponentUI; import java.awt.*; import java.awt.event.MouseEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import javax.swing.*; +import javax.swing.plaf.ComponentUI; + +import com.github.weisj.darklaf.decorators.MouseResponder; +import com.github.weisj.darklaf.util.DarkUIUtil; + /** * @author Jannis Weis */ @@ -48,7 +50,6 @@ public class DarkToolBarUI extends DarkToolBarUIBridge { private Dimension horizontalDim = new Dimension(0, 0); private final Timer timer = new Timer(5, e -> dragTo()); - public static ComponentUI createUI(final JComponent c) { return new DarkToolBarUI(); } @@ -75,12 +76,10 @@ public class DarkToolBarUI extends DarkToolBarUIBridge { } @Override - protected void setBorderToRollover(final Component c) { - } + protected void setBorderToRollover(final Component c) {} @Override - protected void setBorderToNormal(final Component c) { - } + protected void setBorderToNormal(final Component c) {} @Override public void setFloating(final boolean b, final Point p) { @@ -144,8 +143,7 @@ public class DarkToolBarUI extends DarkToolBarUIBridge { background = UIManager.getColor("ToolBar.background"); } - protected void setBorderToNonRollover(final Component c) { - } + protected void setBorderToNonRollover(final Component c) {} @Override protected DragWindow createDragWindow(final JToolBar toolbar) { @@ -182,11 +180,11 @@ public class DarkToolBarUI extends DarkToolBarUIBridge { protected String getDockingConstraint(final Component c, final Point p) { if (p == null) return constraintBeforeFloating; if (c.contains(p)) { - //North + // North if (p.y < horizontalDim.height && !isBlocked(c, BorderLayout.NORTH)) { return BorderLayout.NORTH; } - //South + // South if (p.y >= c.getHeight() - horizontalDim.height && !isBlocked(c, BorderLayout.SOUTH)) { return BorderLayout.SOUTH; } @@ -251,7 +249,7 @@ public class DarkToolBarUI extends DarkToolBarUIBridge { dragWindow.getContentPane().add(toolBar); updateDockingSource(); dragWindow.setVisible(true); - //Is needed to intercept ongoing drag. + // Is needed to intercept ongoing drag. SwingUtilities.invokeLater(() -> robot.mouseRelease(MouseEvent.BUTTON1_DOWN_MASK)); int oldOrientation = toolBar.getOrientation(); @@ -285,8 +283,7 @@ public class DarkToolBarUI extends DarkToolBarUIBridge { setFloating(true, null); } dockingSource.remove(previewPanel); - } catch (IllegalComponentStateException ignored) { - } + } catch (IllegalComponentStateException ignored) {} } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DarkToolBarUIBridge.java b/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DarkToolBarUIBridge.java index 49adff4f..ea9f73cf 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DarkToolBarUIBridge.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DarkToolBarUIBridge.java @@ -20,14 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.toolbar; -import com.github.weisj.darklaf.util.DarkUIUtil; -import com.github.weisj.darklaf.util.LazyActionMap; -import com.github.weisj.darklaf.util.PropertyKey; -import sun.swing.DefaultLookup; -import sun.swing.UIAction; +import java.awt.*; +import java.awt.event.*; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Objects; import javax.swing.*; import javax.swing.border.Border; @@ -37,16 +40,16 @@ import javax.swing.event.MouseInputListener; import javax.swing.plaf.ToolBarUI; import javax.swing.plaf.UIResource; import javax.swing.plaf.basic.BasicBorders; -import java.awt.*; -import java.awt.event.*; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Objects; + +import sun.swing.DefaultLookup; +import sun.swing.UIAction; + +import com.github.weisj.darklaf.util.DarkUIUtil; +import com.github.weisj.darklaf.util.LazyActionMap; +import com.github.weisj.darklaf.util.PropertyKey; /** - * A Basic L&F implementation of ToolBarUI. This implementation is a "combined" view/controller. + * A Basic L&F implementation of ToolBarUI. This implementation is a "combined" view/controller. * * @author Georges Saab * @author Jeff Shapiro @@ -219,8 +222,7 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons /** * Unregisters components. */ - protected void uninstallComponents() { - } + protected void uninstallComponents() {} /** * Unregisters listeners. @@ -235,7 +237,7 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons if (propertyListener != null) { toolBar.removePropertyChangeListener(propertyListener); - propertyListener = null; // removed in setFloating + propertyListener = null; // removed in setFloating } if (toolBarContListener != null) { @@ -282,8 +284,8 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons * This is a convenience method to call setBorderNormal for each child component. * * @param c container which holds the child components (usually a JToolBar) - * @see #setBorderToNonRollover - * @since 1.4 + * @see #setBorderToNonRollover + * @since 1.4 */ protected void installNormalBorders(final JComponent c) { // Put back the normal borders on buttons @@ -299,8 +301,8 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons * installed on the child component before it was added to the toolbar. * * @param c component which will have a normal border re-installed - * @see #createNonRolloverBorder - * @since 1.4 + * @see #createNonRolloverBorder + * @since 1.4 */ protected void setBorderToNormal(final Component c) { if (c instanceof AbstractButton) { @@ -360,15 +362,13 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons nonRolloverToggleBorder = createNonRolloverToggleBorder(); } - setRolloverBorders(isRolloverBorders()); } /** * Registers components. */ - protected void installComponents() { - } + protected void installComponents() {} /** * Registers listeners. @@ -381,7 +381,7 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons toolBar.addMouseListener(dockingListener); } - propertyListener = createPropertyListener(); // added in setFloating + propertyListener = createPropertyListener(); // added in setFloating if (propertyListener != null) { toolBar.addPropertyChangeListener(propertyListener); } @@ -432,7 +432,7 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons * Override this method to provide an alternate rollover border. * * @return a rollover border for toolbar components - * @since 1.4 + * @since 1.4 */ protected Border createRolloverBorder() { Object border = UIManager.get("ToolBar.rolloverBorder"); @@ -440,11 +440,10 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons return (Border) border; } UIDefaults table = UIManager.getLookAndFeelDefaults(); - return new CompoundBorder(new BasicBorders.RolloverButtonBorder( - table.getColor("controlShadow"), - table.getColor("controlDkShadow"), - table.getColor("controlHighlight"), - table.getColor("controlLtHighlight")), + return new CompoundBorder(new BasicBorders.RolloverButtonBorder(table.getColor("controlShadow"), + table.getColor("controlDkShadow"), + table.getColor("controlHighlight"), + table.getColor("controlLtHighlight")), new EmptyBorder(0, 0, 0, 0)); } @@ -455,7 +454,7 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons * Override this method to provide an alternate rollover border. * * @return the non rollover border for toolbar components - * @since 1.4 + * @since 1.4 */ protected Border createNonRolloverBorder() { Object border = UIManager.get("ToolBar.nonrolloverBorder"); @@ -463,11 +462,10 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons return (Border) border; } UIDefaults table = UIManager.getLookAndFeelDefaults(); - return new CompoundBorder(new BasicBorders.ButtonBorder( - table.getColor("Button.shadow"), - table.getColor("Button.darkShadow"), - table.getColor("Button.light"), - table.getColor("Button.highlight")), + return new CompoundBorder(new BasicBorders.ButtonBorder(table.getColor("Button.shadow"), + table.getColor("Button.darkShadow"), + table.getColor("Button.light"), + table.getColor("Button.highlight")), new EmptyBorder(0, 0, 0, 0)); } @@ -478,11 +476,10 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons */ protected Border createNonRolloverToggleBorder() { UIDefaults table = UIManager.getLookAndFeelDefaults(); - return new CompoundBorder(new BasicBorders.RadioButtonBorder( - table.getColor("ToggleButton.shadow"), - table.getColor("ToggleButton.darkShadow"), - table.getColor("ToggleButton.light"), - table.getColor("ToggleButton.highlight")), + return new CompoundBorder(new BasicBorders.RadioButtonBorder(table.getColor("ToggleButton.shadow"), + table.getColor("ToggleButton.darkShadow"), + table.getColor("ToggleButton.light"), + table.getColor("ToggleButton.highlight")), new EmptyBorder(0, 0, 0, 0)); } @@ -490,8 +487,8 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons * Returns a flag to determine whether rollover button borders are enabled. * * @return true if rollover borders are enabled; false otherwise - * @see #setRolloverBorders - * @since 1.4 + * @see #setRolloverBorders + * @since 1.4 */ public boolean isRolloverBorders() { return rolloverBorders; @@ -502,8 +499,8 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons * depending on the state of the flag. * * @param rollover if true, rollover borders are installed. Otherwise non-rollover borders are installed - * @see #isRolloverBorders - * @since 1.4 + * @see #isRolloverBorders + * @since 1.4 */ public void setRolloverBorders(final boolean rollover) { rolloverBorders = rollover; @@ -565,8 +562,8 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons * This is a convenience method to call setBorderToRollover for each child component. * * @param c container which holds the child components (usually a JToolBar) - * @see #setBorderToRollover - * @since 1.4 + * @see #setBorderToRollover + * @since 1.4 */ protected void installRolloverBorders(final JComponent c) { // Put rollover borders on buttons @@ -587,8 +584,8 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons * This is a convenience method to call setBorderToNonRollover for each child component. * * @param c container which holds the child components (usually a JToolBar) - * @see #setBorderToNonRollover - * @since 1.4 + * @see #setBorderToNonRollover + * @since 1.4 */ protected void installNonRolloverBorders(final JComponent c) { // Put non-rollover borders on buttons. These borders reduce the margin. @@ -614,8 +611,8 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons * method. * * @param c component which will have a rollover border installed - * @see #createRolloverBorder - * @since 1.4 + * @see #createRolloverBorder + * @since 1.4 */ protected void setBorderToRollover(final Component c) { if (c instanceof AbstractButton) { @@ -631,8 +628,7 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons b.setBorder(getRolloverBorder(b)); } - rolloverTable.put(b, b.isRolloverEnabled() ? - Boolean.TRUE : Boolean.FALSE); + rolloverTable.put(b, b.isRolloverEnabled() ? Boolean.TRUE : Boolean.FALSE); b.setRolloverEnabled(true); } } @@ -642,8 +638,8 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons * #createNonRolloverBorder} method. * * @param c component which will have a non-rollover border installed - * @see #createNonRolloverBorder - * @since 1.4 + * @see #createNonRolloverBorder + * @since 1.4 */ protected void setBorderToNonRollover(final Component c) { if (c instanceof AbstractButton) { @@ -658,8 +654,7 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons if (b.getBorder() instanceof UIResource) { b.setBorder(getNonRolloverBorder(b)); } - rolloverTable.put(b, b.isRolloverEnabled() ? - Boolean.TRUE : Boolean.FALSE); + rolloverTable.put(b, b.isRolloverEnabled() ? Boolean.TRUE : Boolean.FALSE); b.setRolloverEnabled(false); } } @@ -667,10 +662,10 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons /** * Returns a rollover border for the button. * - * @param b the button to calculate the rollover border for - * @return the rollover border - * @see #setBorderToRollover - * @since 1.6 + * @param b the button to calculate the rollover border for + * @return the rollover border + * @see #setBorderToRollover + * @since 1.6 */ protected Border getRolloverBorder(final AbstractButton b) { return rolloverBorder; @@ -679,10 +674,10 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons /** * Returns a non-rollover border for the button. * - * @param b the button to calculate the non-rollover border for - * @return the non-rollover border - * @see #setBorderToNonRollover - * @since 1.6 + * @param b the button to calculate the non-rollover border for + * @return the non-rollover border + * @see #setBorderToNonRollover + * @since 1.6 */ protected Border getNonRolloverBorder(final AbstractButton b) { if (b instanceof JToggleButton) { @@ -702,8 +697,8 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons int nComp = toolBar.getComponentCount(); int j; switch (direction) { - case EAST: - case SOUTH: + case EAST : + case SOUTH : if (focusedCompIndex < 0 || focusedCompIndex >= nComp) { break; } @@ -719,8 +714,8 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons } } break; - case WEST: - case NORTH: + case WEST : + case NORTH : if (focusedCompIndex < 0 || focusedCompIndex >= nComp) { break; } @@ -737,7 +732,7 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons } } break; - default: + default : break; } } @@ -745,13 +740,13 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons /** * Creates a window which contains the toolbar after it has been dragged out from its container * - * @param toolbar an instance of {@code JToolBar} - * @return a {@code RootPaneContainer} object, containing the toolbar - * @since 1.4 + * @param toolbar an instance of {@code JToolBar} + * @return a {@code RootPaneContainer} object, containing the toolbar + * @since 1.4 */ protected RootPaneContainer createFloatingWindow(final JToolBar toolbar) { @SuppressWarnings("serial") - // Superclass is not serializable across versions + // Superclass is not serializable across versions class ToolBarDialog extends JDialog { public ToolBarDialog(final Frame owner, final String title, final boolean modal) { super(owner, title, modal); @@ -765,7 +760,7 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons // the frame when contents change protected JRootPane createRootPane() { @SuppressWarnings("serial") // anonymous class - JRootPane rootPane = new JRootPane() { + JRootPane rootPane = new JRootPane() { protected boolean packing = false; public void validate() { @@ -881,9 +876,9 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons /** * Returns {@code true} if the {@code JToolBar} can dock at the given position. * - * @param c a component - * @param p a position - * @return {@code true} if the {@code JToolBar} can dock at the given position + * @param c a component + * @param p a position + * @return {@code true} if the {@code JToolBar} can dock at the given position */ public boolean canDock(final Component c, final Point p) { return (p != null && getDockingConstraint(c, p) != null); @@ -914,9 +909,9 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons /** * Paints the contents of the window used for dragging. * - * @param g Graphics to paint to. + * @param g Graphics to paint to. * @throws NullPointerException is g is null - * @since 1.5 + * @since 1.5 */ protected void paintDragWindow(final Graphics g) { g.setColor(dragWindow.getBackground()); @@ -927,7 +922,6 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons g.drawRect(0, 0, w - 1, h - 1); } - protected static class Actions extends UIAction { protected static final String NAVIGATE_RIGHT = "navigateRight"; protected static final String NAVIGATE_LEFT = "navigateLeft"; @@ -957,9 +951,8 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons } } - protected class Handler implements ContainerListener, - FocusListener, MouseInputListener, PropertyChangeListener { + FocusListener, MouseInputListener, PropertyChangeListener { // // MouseInputListener (DockingListener) @@ -1003,8 +996,7 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons focusedCompIndex = toolBar.getComponentIndex(c); } - public void focusLost(final FocusEvent evt) { - } + public void focusLost(final FocusEvent evt) {} public void mouseDragged(final MouseEvent evt) { if (!tb.isEnabled()) { @@ -1014,11 +1006,9 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons dragTo(); } - public void mouseMoved(final MouseEvent evt) { - } + public void mouseMoved(final MouseEvent evt) {} - public void mouseClicked(final MouseEvent evt) { - } + public void mouseClicked(final MouseEvent evt) {} public void mousePressed(final MouseEvent evt) { if (!tb.isEnabled()) { @@ -1037,11 +1027,9 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons isDragging = false; } - public void mouseEntered(final MouseEvent evt) { - } + public void mouseEntered(final MouseEvent evt) {} - public void mouseExited(final MouseEvent evt) { - } + public void mouseExited(final MouseEvent evt) {} // // PropertyChangeListener @@ -1122,7 +1110,6 @@ public abstract class DarkToolBarUIBridge extends ToolBarUI implements SwingCons dockingSource.repaint(); } } - } /** diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DropPreviewPanel.java b/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DropPreviewPanel.java index 788e4c8c..79a34a2d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DropPreviewPanel.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DropPreviewPanel.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.toolbar; -import javax.swing.*; import java.awt.*; +import javax.swing.*; + /** * @author Jannis Weis */ diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkDefaultToolTipBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkDefaultToolTipBorder.java index e79a2aec..766c6532 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkDefaultToolTipBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkDefaultToolTipBorder.java @@ -20,14 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tooltip; -import com.github.weisj.darklaf.components.border.MutableLineBorder; - import javax.swing.*; import javax.swing.plaf.UIResource; +import com.github.weisj.darklaf.components.border.MutableLineBorder; + public class DarkDefaultToolTipBorder extends MutableLineBorder implements UIResource { public DarkDefaultToolTipBorder() { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipBorder.java index b4ab92a7..541d8f3c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipBorder.java @@ -20,9 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tooltip; +import java.awt.*; +import java.awt.geom.Area; +import java.awt.geom.Rectangle2D; + +import javax.swing.*; +import javax.swing.border.Border; + import com.github.weisj.darklaf.components.border.BubbleBorder; import com.github.weisj.darklaf.components.border.DropShadowBorder; import com.github.weisj.darklaf.components.tooltip.ToolTipStyle; @@ -30,12 +38,6 @@ import com.github.weisj.darklaf.util.Alignment; import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.GraphicsContext; -import javax.swing.*; -import javax.swing.border.Border; -import java.awt.*; -import java.awt.geom.Area; -import java.awt.geom.Rectangle2D; - /** * @author Jannis Weis */ @@ -63,7 +65,6 @@ public class DarkTooltipBorder implements Border { false, true, true, true); } - public Area getBackgroundArea(final Component c, final int width, final int height, final boolean forPaint) { if (isPlain(c)) { return new Area(new Rectangle(0, 0, width, height)); @@ -201,18 +202,18 @@ public class DarkTooltipBorder implements Border { public int getDistanceToPointer() { switch (bubbleBorder.getPointerSide()) { - case WEST: - case SOUTH: - case SOUTH_EAST: - case SOUTH_WEST: - case EAST: + case WEST : + case SOUTH : + case SOUTH_EAST : + case SOUTH_WEST : + case EAST : return Math.max(0, shadowBorder.getShadowSize() - bubbleBorder.getPointerSize()) + bubbleBorder.getThickness(); - case NORTH: - case NORTH_EAST: - case NORTH_WEST: - case CENTER: - default: + case NORTH : + case NORTH_EAST : + case NORTH_WEST : + case CENTER : + default : return bubbleBorder.getThickness(); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipUI.java index 8a2b436d..d5382257 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipUI.java @@ -20,29 +20,31 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tooltip; -import com.github.weisj.darklaf.components.tooltip.ToolTipStyle; -import com.github.weisj.darklaf.ui.DarkPopupFactory; -import com.github.weisj.darklaf.util.*; +import java.awt.*; +import java.awt.event.*; +import java.awt.geom.Area; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; import javax.swing.*; import javax.swing.border.Border; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicToolTipUI; import javax.swing.text.View; -import java.awt.*; -import java.awt.event.*; -import java.awt.geom.Area; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; + +import com.github.weisj.darklaf.components.tooltip.ToolTipStyle; +import com.github.weisj.darklaf.ui.DarkPopupFactory; +import com.github.weisj.darklaf.util.*; /** * @author Jannis Weis */ public class DarkTooltipUI extends BasicToolTipUI implements PropertyChangeListener, HierarchyListener, - ToolTipConstants { + ToolTipConstants { protected static final float MAX_ALPHA = 1.0f; protected Animator fadeAnimator; @@ -57,10 +59,11 @@ public class DarkTooltipUI extends BasicToolTipUI implements PropertyChangeListe public void mouseExited(final MouseEvent e) { boolean inside = isInside(e); if (!inside) { - ToolTipManager.sharedInstance().mouseExited( - new MouseEvent(toolTip.getComponent(), e.getID(), e.getWhen(), e.getModifiersEx(), - Integer.MIN_VALUE, Integer.MIN_VALUE, e.getClickCount(), e.isPopupTrigger(), - e.getButton())); + ToolTipManager.sharedInstance().mouseExited(new MouseEvent(toolTip.getComponent(), e.getID(), + e.getWhen(), e.getModifiersEx(), + Integer.MIN_VALUE, Integer.MIN_VALUE, + e.getClickCount(), e.isPopupTrigger(), + e.getButton())); } } }; @@ -71,7 +74,8 @@ public class DarkTooltipUI extends BasicToolTipUI implements PropertyChangeListe /* * We redispatch the event to the ToolTipManager with a corrected location. * Because the ToolTipManager check for outside using >= width/height instead of > width/height and due to - * the nature of mouseEntered events most of the times having width/height as their coordinated ToolTips would + * the nature of mouseEntered events most of the times having width/height as their coordinated ToolTips + * would * not show up when the component is entered through the bottom/right side of the component. */ Point p = e.getPoint(); @@ -97,7 +101,6 @@ public class DarkTooltipUI extends BasicToolTipUI implements PropertyChangeListe }; private boolean added; - public static ComponentUI createUI(final JComponent c) { if (Boolean.TRUE.equals(c.getClientProperty(KEY_PLAIN_TOOLTIP))) { return BasicToolTipUI.createUI(c); @@ -157,7 +160,6 @@ public class DarkTooltipUI extends BasicToolTipUI implements PropertyChangeListe } } - @Override public void paint(final Graphics g, final JComponent c) { if (((JToolTip) c).getTipText() == null) return; @@ -171,7 +173,7 @@ public class DarkTooltipUI extends BasicToolTipUI implements PropertyChangeListe g.setColor(c.getBackground()); if (c.getBorder() instanceof DarkTooltipBorder) { Area area = ((DarkTooltipBorder) c.getBorder()) - .getBackgroundArea(c, c.getWidth(), c.getHeight(), true); + .getBackgroundArea(c, c.getWidth(), c.getHeight(), true); ((Graphics2D) g).fill(area); } super.paint(g, c); @@ -202,7 +204,7 @@ public class DarkTooltipUI extends BasicToolTipUI implements PropertyChangeListe public void hierarchyChanged(final HierarchyEvent e) { Window w = SwingUtilities.getWindowAncestor(toolTip); if (toolTip.getParent() instanceof JComponent) { - //For MediumWeightPopup still need to make parent non opaque. + // For MediumWeightPopup still need to make parent non opaque. ((JComponent) toolTip.getParent()).setOpaque(false); } if (lastRootPane != null) { @@ -245,7 +247,8 @@ public class DarkTooltipUI extends BasicToolTipUI implements PropertyChangeListe Border b = c.getBorder(); if (b instanceof DarkTooltipBorder) { Area insideArea = ((DarkTooltipBorder) b) - .getBackgroundArea(toolTip, toolTip.getWidth(), toolTip.getHeight(), false); + .getBackgroundArea(toolTip, toolTip.getWidth(), + toolTip.getHeight(), false); return insideArea.contains(x, y); } else { return super.contains(c, x, y); @@ -309,7 +312,7 @@ public class DarkTooltipUI extends BasicToolTipUI implements PropertyChangeListe } } else if (PropertyKey.ANCESTOR.equals(key)) { if (evt.getOldValue() == null) { - //Added to hierarchy. Schedule animation start. + // Added to hierarchy. Schedule animation start. added = true; ToolTipUtil.applyContext(toolTip); } @@ -329,9 +332,8 @@ public class DarkTooltipUI extends BasicToolTipUI implements PropertyChangeListe if (comp != null) { ToolTipStyle style = getStyle(comp.getClientProperty(KEY_STYLE)); ToolTipStyle tooltipStyle = getStyle(toolTip.getClientProperty(KEY_STYLE)); - toolTip.putClientProperty(KEY_STYLE, style != null ? style : - tooltipStyle != null ? tooltipStyle - : ToolTipStyle.PLAIN_BALLOON); + toolTip.putClientProperty(KEY_STYLE, style != null ? style : tooltipStyle != null ? tooltipStyle + : ToolTipStyle.PLAIN_BALLOON); } } @@ -353,7 +355,6 @@ public class DarkTooltipUI extends BasicToolTipUI implements PropertyChangeListe private static final int DELAY_FRAMES = 6; private static final int FADEIN_FRAMES_COUNT = DELAY_FRAMES + 10; - public FadeInAnimator() { super("Tooltip fadein", FADEIN_FRAMES_COUNT, FADEIN_FRAMES_COUNT * 15, false); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/ToolTipConstants.java b/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/ToolTipConstants.java index 5547f003..85f7bde4 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/ToolTipConstants.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/ToolTipConstants.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tooltip; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/ToolTipUtil.java b/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/ToolTipUtil.java index 7154043f..2d1cecf9 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/ToolTipUtil.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/ToolTipUtil.java @@ -20,18 +20,20 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tooltip; +import java.awt.*; +import java.util.function.BiConsumer; + +import javax.swing.*; + import com.github.weisj.darklaf.components.tooltip.ToolTipContext; import com.github.weisj.darklaf.components.tooltip.ToolTipStyle; import com.github.weisj.darklaf.util.Alignment; import com.github.weisj.darklaf.util.DarkUIUtil; -import javax.swing.*; -import java.awt.*; -import java.util.function.BiConsumer; - public class ToolTipUtil { public static void applyContext(final JToolTip toolTip) { @@ -74,7 +76,7 @@ public class ToolTipUtil { if (pos != null) break; } if (pos == null) { - //Try again with screen bounds instead. + // Try again with screen bounds instead. for (Alignment a : alignments) { pos = tryPosition(a, context, p, tooltipBounds, screenBounds, screenBounds, setter); if (pos != null) break; @@ -96,16 +98,16 @@ public class ToolTipUtil { } protected static Alignment[] getAlignments(final Alignment start) { - //Example with NORTH: + // Example with NORTH: return new Alignment[]{ - start, //NORTH - start.opposite(), //SOUTH - start.clockwise().clockwise(),//EAST - start.anticlockwise().anticlockwise(), //WEST - start.clockwise(), //NORTH_EAST - start.clockwise().opposite(), //SOUTH_WEST - start.anticlockwise(), //NORTH_WEST - start.anticlockwise().opposite() //SOUTH_EAST + start, // NORTH + start.opposite(), // SOUTH + start.clockwise().clockwise(), // EAST + start.anticlockwise().anticlockwise(), // WEST + start.clockwise(), // NORTH_EAST + start.clockwise().opposite(), // SOUTH_WEST + start.anticlockwise(), // NORTH_WEST + start.anticlockwise().opposite() // SOUTH_EAST }; } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkDefaultTreeEditor.java b/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkDefaultTreeEditor.java index a82572ca..f92b6231 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkDefaultTreeEditor.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkDefaultTreeEditor.java @@ -20,11 +20,13 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tree; -import com.github.weisj.darklaf.ui.cell.DarkCellRendererToggleButton; -import com.github.weisj.darklaf.ui.text.DarkTextUI; +import java.awt.*; +import java.awt.event.MouseEvent; +import java.util.EventObject; import javax.swing.*; import javax.swing.border.Border; @@ -32,9 +34,9 @@ import javax.swing.tree.DefaultTreeCellEditor; import javax.swing.tree.TreeCellEditor; import javax.swing.tree.TreeCellRenderer; import javax.swing.tree.TreePath; -import java.awt.*; -import java.awt.event.MouseEvent; -import java.util.EventObject; + +import com.github.weisj.darklaf.ui.cell.DarkCellRendererToggleButton; +import com.github.weisj.darklaf.ui.text.DarkTextUI; /** * @author Jannis Weis diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeCellBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeCellBorder.java index 52b4fc9e..25dd8752 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeCellBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeCellBorder.java @@ -20,16 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tree; -import com.github.weisj.darklaf.util.DarkUIUtil; +import java.awt.*; import javax.swing.*; import javax.swing.border.Border; import javax.swing.plaf.InsetsUIResource; import javax.swing.plaf.UIResource; -import java.awt.*; + +import com.github.weisj.darklaf.util.DarkUIUtil; /** * @author Jannis Weis @@ -61,5 +63,4 @@ public class DarkTreeCellBorder implements Border, UIResource { public boolean isBorderOpaque() { return true; } - } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeCellEditor.java b/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeCellEditor.java index e3f314e5..90c25cc4 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeCellEditor.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeCellEditor.java @@ -20,20 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tree; -import com.github.weisj.darklaf.components.SelectableTreeNode; -import com.github.weisj.darklaf.ui.combobox.ComboBoxConstants; -import com.github.weisj.darklaf.ui.spinner.SpinnerConstants; -import com.github.weisj.darklaf.ui.text.DarkTextUI; -import com.github.weisj.darklaf.ui.togglebutton.ToggleButtonConstants; -import com.github.weisj.darklaf.util.DarkUIUtil; - -import javax.swing.*; -import javax.swing.event.PopupMenuEvent; -import javax.swing.event.PopupMenuListener; -import javax.swing.tree.TreeCellEditor; import java.awt.*; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; @@ -43,6 +33,18 @@ import java.text.NumberFormat; import java.text.ParseException; import java.util.EventObject; +import javax.swing.*; +import javax.swing.event.PopupMenuEvent; +import javax.swing.event.PopupMenuListener; +import javax.swing.tree.TreeCellEditor; + +import com.github.weisj.darklaf.components.SelectableTreeNode; +import com.github.weisj.darklaf.ui.combobox.ComboBoxConstants; +import com.github.weisj.darklaf.ui.spinner.SpinnerConstants; +import com.github.weisj.darklaf.ui.text.DarkTextUI; +import com.github.weisj.darklaf.ui.togglebutton.ToggleButtonConstants; +import com.github.weisj.darklaf.util.DarkUIUtil; + /** * @author Jannis Weis */ @@ -174,7 +176,6 @@ public class DarkTreeCellEditor extends DefaultCellEditor implements TreeCellEdi return editorComponent; } - protected void updateFocus(final FocusEvent e) { if (DarkUIUtil.hasFocus(editorComponent, e)) { editorComponent.setForeground(UIManager.getColor("Tree.selectionForeground")); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeCellRenderer.java b/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeCellRenderer.java index d15daa38..b1a3e3d6 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeCellRenderer.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeCellRenderer.java @@ -20,28 +20,28 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tree; -import com.github.weisj.darklaf.ui.cell.CellUtil; -import com.github.weisj.darklaf.ui.cell.DarkCellRendererToggleButton; -import com.github.weisj.darklaf.util.PropertyValue; +import java.awt.*; import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.TreeCellRenderer; -import java.awt.*; + +import com.github.weisj.darklaf.ui.cell.CellUtil; +import com.github.weisj.darklaf.ui.cell.DarkCellRendererToggleButton; +import com.github.weisj.darklaf.util.PropertyValue; /** * @author Jannis Weis */ public class DarkTreeCellRenderer extends DefaultTreeCellRenderer implements TreeRendererSupport { - private final DarkCellRendererToggleButton checkBoxRenderer = - new DarkCellRendererToggleButton<>(new DarkCellRendererToggleButton.CellEditorCheckBox(false)); - private final DarkCellRendererToggleButton radioRenderer = - new DarkCellRendererToggleButton<>(new DarkCellRendererToggleButton.CellEditorRadioButton(false)); + private final DarkCellRendererToggleButton checkBoxRenderer = new DarkCellRendererToggleButton<>(new DarkCellRendererToggleButton.CellEditorCheckBox(false)); + private final DarkCellRendererToggleButton radioRenderer = new DarkCellRendererToggleButton<>(new DarkCellRendererToggleButton.CellEditorRadioButton(false)); private final TreeRendererComponent rendererComponent = new TreeRendererComponent(); private final TreeCellRenderer parent; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java index fff5e82e..19a530ac 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java @@ -20,11 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tree; -import com.github.weisj.darklaf.util.DarkUIUtil; -import com.github.weisj.darklaf.util.SystemInfo; +import java.awt.*; +import java.awt.event.*; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.Enumeration; import javax.swing.*; import javax.swing.plaf.ComponentUI; @@ -34,11 +38,9 @@ import javax.swing.tree.TreeCellEditor; import javax.swing.tree.TreeCellRenderer; import javax.swing.tree.TreeModel; import javax.swing.tree.TreePath; -import java.awt.*; -import java.awt.event.*; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.Enumeration; + +import com.github.weisj.darklaf.util.DarkUIUtil; +import com.github.weisj.darklaf.util.SystemInfo; /** * @author Konstantin Bulenkov @@ -120,7 +122,6 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener { protected Icon collapsed; private boolean myOldRepaintAllRowValue; - public static ComponentUI createUI(final JComponent c) { return new DarkTreeUI(); } @@ -237,8 +238,8 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener { TreePath selectionPath = tree.getPathForRow(selectionRow); if (selectionPath == null) return; - if (tree.getModel().isLeaf(selectionPath.getLastPathComponent()) || tree.isCollapsed( - selectionRow)) { + if (tree.getModel().isLeaf(selectionPath.getLastPathComponent()) + || tree.isCollapsed(selectionRow)) { final TreePath parentPath = tree.getPathForRow(selectionRow).getParentPath(); if (parentPath != null) { if (parentPath.getParentPath() != null || tree.isRootVisible()) { @@ -336,11 +337,9 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener { owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); } boolean treeEditor = owner instanceof JComponent - && Boolean.TRUE.equals( - ((JComponent) owner).getClientProperty(DarkTreeUI.KEY_IS_TREE_EDITOR)); + && Boolean.TRUE.equals(((JComponent) owner).getClientProperty(DarkTreeUI.KEY_IS_TREE_EDITOR)); boolean treeRenderer = !treeEditor && owner instanceof JComponent - && Boolean.TRUE.equals( - ((JComponent) owner).getClientProperty(DarkTreeUI.KEY_IS_TREE_RENDERER)); + && Boolean.TRUE.equals(((JComponent) owner).getClientProperty(DarkTreeUI.KEY_IS_TREE_RENDERER)); return treeEditor || treeRenderer; } return true; @@ -413,7 +412,7 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener { TreePath path; boolean rootVisible = isRootVisible(); - //Paint row backgrounds + // Paint row backgrounds Enumeration backgroundEnumerator = treeState.getVisiblePathsFrom(initialPath); while (backgroundEnumerator != null && backgroundEnumerator.hasMoreElements()) { path = (TreePath) backgroundEnumerator.nextElement(); @@ -511,9 +510,11 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener { final int row, final boolean isExpanded, final boolean hasBeenExpanded, final boolean isLeaf) { final int containerWidth = tree.getParent() instanceof JViewport - ? tree.getParent().getWidth() : tree.getWidth(); + ? tree.getParent().getWidth() + : tree.getWidth(); final int xOffset = tree.getParent() instanceof JViewport - ? ((JViewport) tree.getParent()).getViewPosition().x : 0; + ? ((JViewport) tree.getParent()).getViewPosition().x + : 0; if (path != null) { boolean selected = tree.isPathSelected(path); @@ -685,9 +686,9 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener { } } - //Descend to deepest last child. - TreePath lastChildPath = path.pathByAddingChild( - treeModel.getChild(path.getLastPathComponent(), childCount - 1)); + // Descend to deepest last child. + TreePath lastChildPath = path.pathByAddingChild(treeModel.getChild(path.getLastPathComponent(), + childCount - 1)); while (tree.isExpanded(lastChildPath)) { int count = treeModel.getChildCount(lastChildPath.getLastPathComponent()); if (count == 0) break; @@ -730,8 +731,10 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener { stopEditingInCompleteEditing && editingComponent != null) { cellEditor.stopCellEditing(); } - /* Invoke cancelCellEditing, this will do nothing if stopCellEditing - was successful. */ + /* + * Invoke cancelCellEditing, this will do nothing if stopCellEditing + * was successful. + */ completeEditing(false, true, true); } @@ -755,6 +758,5 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener { } } - private abstract static class TreeUIAction extends AbstractAction implements UIResource { - } + private abstract static class TreeUIAction extends AbstractAction implements UIResource {} } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tree/TreeCellEditorDelegate.java b/core/src/main/java/com/github/weisj/darklaf/ui/tree/TreeCellEditorDelegate.java index 96405305..41b3848b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tree/TreeCellEditorDelegate.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tree/TreeCellEditorDelegate.java @@ -20,14 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tree; +import java.awt.*; +import java.util.EventObject; + import javax.swing.*; import javax.swing.event.CellEditorListener; import javax.swing.tree.TreeCellEditor; -import java.awt.*; -import java.util.EventObject; /** * @author Jannis Weis @@ -36,7 +38,6 @@ public class TreeCellEditorDelegate implements TreeCellEditor { private final TreeCellEditor editor; - public TreeCellEditorDelegate(final TreeCellEditor editor) { this.editor = editor; } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tree/TreeRendererComponent.java b/core/src/main/java/com/github/weisj/darklaf/ui/tree/TreeRendererComponent.java index b7984c56..6d1b9d68 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tree/TreeRendererComponent.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tree/TreeRendererComponent.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tree; -import javax.swing.*; import java.awt.*; +import javax.swing.*; + /** * @author Jannis Weis */ diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tree/TreeRendererSupport.java b/core/src/main/java/com/github/weisj/darklaf/ui/tree/TreeRendererSupport.java index e0ddf5c5..10abf50d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tree/TreeRendererSupport.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tree/TreeRendererSupport.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.ui.tree; -import javax.swing.*; import java.awt.*; +import javax.swing.*; + /** * @author Jannis Weis */ diff --git a/core/src/main/java/com/github/weisj/darklaf/util/Animator.java b/core/src/main/java/com/github/weisj/darklaf/util/Animator.java index f72a6c73..c6cb42d9 100644 --- a/core/src/main/java/com/github/weisj/darklaf/util/Animator.java +++ b/core/src/main/java/com/github/weisj/darklaf/util/Animator.java @@ -20,16 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.util; -import javax.swing.*; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; +import javax.swing.*; /** * @author Konstantin Bulenkov @@ -74,7 +75,6 @@ public abstract class Animator { startTime = -1; } - private static ScheduledExecutorService createScheduler() { ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1, r -> { final Thread thread = new Thread(r, "Darcula Animations"); @@ -186,7 +186,6 @@ public abstract class Animator { return ticker != null; } - public final boolean isForward() { return forward; } diff --git a/core/src/main/java/com/github/weisj/darklaf/util/ColorWrapper.java b/core/src/main/java/com/github/weisj/darklaf/util/ColorWrapper.java index 5e1d318f..356da6fc 100644 --- a/core/src/main/java/com/github/weisj/darklaf/util/ColorWrapper.java +++ b/core/src/main/java/com/github/weisj/darklaf/util/ColorWrapper.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.util; @@ -131,6 +132,4 @@ public class ColorWrapper extends Color { public int getTransparency() { return getColor().getTransparency(); } - - } diff --git a/core/src/main/java/com/github/weisj/darklaf/util/DarkSwingUtil.java b/core/src/main/java/com/github/weisj/darklaf/util/DarkSwingUtil.java index 8aee947a..0527c874 100644 --- a/core/src/main/java/com/github/weisj/darklaf/util/DarkSwingUtil.java +++ b/core/src/main/java/com/github/weisj/darklaf/util/DarkSwingUtil.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.util; diff --git a/core/src/main/java/com/github/weisj/darklaf/util/DarkUIUtil.java b/core/src/main/java/com/github/weisj/darklaf/util/DarkUIUtil.java index 36ec30d2..02897c35 100644 --- a/core/src/main/java/com/github/weisj/darklaf/util/DarkUIUtil.java +++ b/core/src/main/java/com/github/weisj/darklaf/util/DarkUIUtil.java @@ -20,20 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.util; -import com.github.weisj.darklaf.decorators.CellRenderer; -import com.github.weisj.darklaf.ui.popupmenu.DarkPopupMenuUI; -import com.github.weisj.darklaf.ui.table.DarkTableHeaderUI; -import sun.awt.SunToolkit; - -import javax.swing.*; -import javax.swing.border.Border; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.InsetsUIResource; -import javax.swing.table.TableCellRenderer; -import javax.swing.tree.TreeCellRenderer; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.FocusEvent; @@ -43,6 +33,19 @@ import java.awt.geom.Ellipse2D; import java.awt.geom.Path2D; import java.awt.geom.RoundRectangle2D; +import javax.swing.*; +import javax.swing.border.Border; +import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.InsetsUIResource; +import javax.swing.table.TableCellRenderer; +import javax.swing.tree.TreeCellRenderer; + +import sun.awt.SunToolkit; + +import com.github.weisj.darklaf.decorators.CellRenderer; +import com.github.weisj.darklaf.ui.popupmenu.DarkPopupMenuUI; +import com.github.weisj.darklaf.ui.table.DarkTableHeaderUI; + /** * @author Konstantin Bulenkov * @author Jannis Weis @@ -228,7 +231,6 @@ public final class DarkUIUtil { g.fill(new RoundRectangle2D.Float(x + lw, y + lw, width - 2 * lw, height - 2 * lw, arcSze, arcSze)); } - public static Color blendColors(final Color color1, final Color color2, final double percent) { if (percent == 1) return color1; if (percent == 0) return color2; @@ -268,9 +270,9 @@ public final class DarkUIUtil { /** * Returns whether the component has the focus, or one of the subcomponents has it. * - * @param c the component. - * @param e an event associated with focusLost. optional (i.e. can be null). - * @return true if the component or one of its subcomponents has the focus. + * @param c the component. + * @param e an event associated with focusLost. optional (i.e. can be null). + * @return true if the component or one of its subcomponents has the focus. */ public static boolean hasFocus(final Component c, final FocusEvent e) { if (c == null) return false; @@ -312,7 +314,6 @@ public final class DarkUIUtil { return ActionEvent.ALT_MASK; } - public static Object getUIOfType(final ComponentUI ui, final Class klass) { if (klass.isInstance(ui)) { return ui; @@ -326,8 +327,8 @@ public final class DarkUIUtil { } public static boolean isInCell(final Component c) { - boolean tableHeaderCell = c instanceof JComponent && Boolean.TRUE.equals( - ((JComponent) c).getClientProperty(DarkTableHeaderUI.KEY_IS_HEADER_RENDERER)); + boolean tableHeaderCell = c instanceof JComponent + && Boolean.TRUE.equals(((JComponent) c).getClientProperty(DarkTableHeaderUI.KEY_IS_HEADER_RENDERER)); boolean inCellRenderer = !tableHeaderCell && (getParentOfType(CellRendererPane.class, c) != null || getParentOfType(TableCellRenderer.class, c) != null @@ -348,7 +349,6 @@ public final class DarkUIUtil { return null; } - public static Window getWindow(final Component component) { if (component == null) { return null; @@ -361,7 +361,6 @@ public final class DarkUIUtil { return hideTipAction.isEnabled(); } - public static MenuElement findEnabledChild(final MenuElement[] e, final MenuElement elem, final boolean forward) { for (int i = 0; i < e.length; i++) { if (e[i] == elem) { @@ -383,7 +382,6 @@ public final class DarkUIUtil { return result; } - private static MenuElement nextEnabledChild(final MenuElement[] e, final int fromIndex, final int toIndex) { for (int i = fromIndex; i <= toIndex; i++) { if (e[i] != null) { @@ -398,7 +396,6 @@ public final class DarkUIUtil { return null; } - private static MenuElement previousEnabledChild(final MenuElement[] e, final int fromIndex, final int toIndex) { for (int i = fromIndex; i >= toIndex; i--) { if (e[i] != null) { @@ -428,10 +425,14 @@ public final class DarkUIUtil { public static boolean isOverText(final MouseEvent e, final int index, final JList list) { Rectangle bounds = list.getCellBounds(index, index); if (!bounds.contains(e.getPoint())) return false; - //noinspection unchecked + // noinspection unchecked Component cellRenderer = ((ListCellRenderer) list.getCellRenderer()) - .getListCellRendererComponent(list, list.getModel().getElementAt(index), - index, false, false); + .getListCellRendererComponent(list, + list.getModel() + .getElementAt(index), + index, + false, + false); if (cellRenderer instanceof JLabel) { return isOverText((JLabel) cellRenderer, bounds, e.getPoint()); } else { @@ -454,8 +455,11 @@ public final class DarkUIUtil { final JTable table) { Rectangle bounds = table.getCellRect(row, column, false); if (!bounds.contains(e.getPoint())) return false; - Component cellRenderer = table.getCellRenderer(row, column).getTableCellRendererComponent( - table, table.getValueAt(row, column), false, false, row, column); + Component cellRenderer = table.getCellRenderer(row, column).getTableCellRendererComponent(table, + table.getValueAt(row, + column), + false, false, row, + column); if (cellRenderer instanceof JLabel) { return isOverText((JLabel) cellRenderer, bounds, e.getPoint()); } else { diff --git a/core/src/main/java/com/github/weisj/darklaf/util/GraphicsContext.java b/core/src/main/java/com/github/weisj/darklaf/util/GraphicsContext.java index fa099a01..8059c036 100644 --- a/core/src/main/java/com/github/weisj/darklaf/util/GraphicsContext.java +++ b/core/src/main/java/com/github/weisj/darklaf/util/GraphicsContext.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.util; diff --git a/core/src/main/java/com/github/weisj/darklaf/util/GraphicsUtil.java b/core/src/main/java/com/github/weisj/darklaf/util/GraphicsUtil.java index a146b6af..1f3bd2e0 100644 --- a/core/src/main/java/com/github/weisj/darklaf/util/GraphicsUtil.java +++ b/core/src/main/java/com/github/weisj/darklaf/util/GraphicsUtil.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.util; @@ -32,14 +33,12 @@ import java.util.Map; */ public final class GraphicsUtil { - private GraphicsUtil() { - } + private GraphicsUtil() {} public static GraphicsContext setupAntialiasing(final Graphics g2) { return setupAntialiasing(g2, true, false); } - public static GraphicsContext setupAntialiasing(final Graphics g2, final boolean enableAA, final boolean ignoreSystemSettings) { GraphicsContext config = new GraphicsContext(g2); @@ -52,14 +51,13 @@ public final class GraphicsUtil { } else { g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, enableAA - ? RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HBGR - : RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); + ? RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HBGR + : RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); } } return config; } - public static GraphicsContext setupAAPainting(final Graphics g) { GraphicsContext config = new GraphicsContext(g); Graphics2D g2 = (Graphics2D) g; @@ -68,7 +66,6 @@ public final class GraphicsUtil { return config; } - public static GraphicsContext paintWithAlpha(final Graphics g, final float alpha) { assert 0.0F <= alpha && alpha <= 1.0F : "alpha should be in range 0.0f .. 1.0f"; @@ -78,7 +75,6 @@ public final class GraphicsUtil { return config; } - public static GraphicsContext setupStrokePainting(final Graphics g) { Graphics2D g2 = (Graphics2D) g; GraphicsContext context = new GraphicsContext(g2); diff --git a/core/src/main/java/com/github/weisj/darklaf/util/ImageUtil.java b/core/src/main/java/com/github/weisj/darklaf/util/ImageUtil.java index e096f47f..a2e65976 100644 --- a/core/src/main/java/com/github/weisj/darklaf/util/ImageUtil.java +++ b/core/src/main/java/com/github/weisj/darklaf/util/ImageUtil.java @@ -20,20 +20,21 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.util; -import javax.swing.*; import java.awt.*; import java.awt.image.BufferedImage; +import javax.swing.*; + /** * @author Jannis Weis */ public final class ImageUtil { - private ImageUtil() { - } + private ImageUtil() {} private static final int FRAME_ICON_SIZE = 32; @@ -76,9 +77,9 @@ public final class ImageUtil { /** * Create image from component. * - * @param c the component. - * @param bounds the bounds inside the component to capture. - * @return image containing the captured area. + * @param c the component. + * @param bounds the bounds inside the component to capture. + * @return image containing the captured area. */ public static BufferedImage imageFromComponent(final Component c, final Rectangle bounds) { return scaledImageFromComponent(c, bounds, 1.0, 1.0, true); @@ -87,9 +88,9 @@ public final class ImageUtil { /** * Create image from component. * - * @param c the component. - * @param bounds the bounds inside the component to capture. - * @return image containing the captured area. + * @param c the component. + * @param bounds the bounds inside the component to capture. + * @return image containing the captured area. */ public static BufferedImage imageFromComponent(final Component c, final Rectangle bounds, final boolean print) { return scaledImageFromComponent(c, bounds, 1.0, 1.0, print); @@ -98,23 +99,22 @@ public final class ImageUtil { /** * Create image from component. * - * @param c the component. - * @param bounds the bounds inside the component to capture. - * @return image containing the captured area. + * @param c the component. + * @param bounds the bounds inside the component to capture. + * @return image containing the captured area. */ public static BufferedImage scaledImageFromComponent(final Component c, final Rectangle bounds) { return scaledImageFromComponent(c, bounds, Scale.SCALE_X, Scale.SCALE_Y, true); } - /** * Create image from component. * - * @param c the component. - * @param bounds the bounds inside the component to capture. - * @param scalex the x scale - * @param scaley the y scale - * @return image containing the captured area. + * @param c the component. + * @param bounds the bounds inside the component to capture. + * @param scalex the x scale + * @param scaley the y scale + * @return image containing the captured area. */ public static BufferedImage scaledImageFromComponent(final Component c, final Rectangle bounds, final double scalex, final double scaley, @@ -144,10 +144,9 @@ public final class ImageUtil { public static BufferedImage createCompatibleTranslucentImage(final int width, final int height) { - return isHeadless() ? - new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB) : - getGraphicsConfiguration().createCompatibleImage(width, height, - Transparency.TRANSLUCENT); + return isHeadless() ? new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB) + : getGraphicsConfiguration().createCompatibleImage(width, height, + Transparency.TRANSLUCENT); } private static boolean isHeadless() { @@ -155,7 +154,6 @@ public final class ImageUtil { } private static GraphicsConfiguration getGraphicsConfiguration() { - return GraphicsEnvironment.getLocalGraphicsEnvironment(). - getDefaultScreenDevice().getDefaultConfiguration(); + return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration(); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/util/LazyActionMap.java b/core/src/main/java/com/github/weisj/darklaf/util/LazyActionMap.java index fc39d7db..03673610 100644 --- a/core/src/main/java/com/github/weisj/darklaf/util/LazyActionMap.java +++ b/core/src/main/java/com/github/weisj/darklaf/util/LazyActionMap.java @@ -20,14 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.util; -import javax.swing.*; -import javax.swing.plaf.ActionMapUIResource; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import javax.swing.*; +import javax.swing.plaf.ActionMapUIResource; + /** * An ActionMap that populates its contents as necessary. The contents are populated by invoking the * loadActionMap method on the passed in Object. @@ -73,12 +75,11 @@ public class LazyActionMap extends ActionMapUIResource { *

* This should be used if the ActionMap can be shared. * - * @param loaderClass Class object that gets loadActionMap invoked on. - * @param defaultsKey Key to use to defaults table to check for existing map and what resulting Map will be - * registered on. - * @return the action map + * @param loaderClass Class object that gets loadActionMap invoked on. + * @param defaultsKey Key to use to defaults table to check for existing map and what resulting Map will be + * registered on. + * @return the action map */ - public static ActionMap getActionMap(final Class loaderClass, final String defaultsKey) { ActionMap map = (ActionMap) UIManager.get(defaultsKey); @@ -106,8 +107,8 @@ public class LazyActionMap extends ActionMapUIResource { assert false : "LazyActionMap unable to load actions " + klass; } catch (IllegalAccessException - | InvocationTargetException - | IllegalArgumentException iae) { + | InvocationTargetException + | IllegalArgumentException iae) { assert false : "LazyActionMap unable to load actions " + iae; } diff --git a/core/src/main/java/com/github/weisj/darklaf/util/SwingXUtilities.java b/core/src/main/java/com/github/weisj/darklaf/util/SwingXUtilities.java index dfc7a83f..e5e7acd4 100644 --- a/core/src/main/java/com/github/weisj/darklaf/util/SwingXUtilities.java +++ b/core/src/main/java/com/github/weisj/darklaf/util/SwingXUtilities.java @@ -20,18 +20,19 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.util; -import org.jdesktop.jxlayer.JXLayer; -import org.pbjar.jxlayer.plaf.ext.TransformUI; - -import javax.swing.*; import java.awt.*; import java.awt.geom.AffineTransform; -public class SwingXUtilities { +import javax.swing.*; +import org.jdesktop.jxlayer.JXLayer; +import org.pbjar.jxlayer.plaf.ext.TransformUI; + +public class SwingXUtilities { @SuppressWarnings("unchecked") public static Point convertPointToParent(final Component source, final Point p) { diff --git a/core/src/main/java/com/github/weisj/darklaf/util/TimerUtil.java b/core/src/main/java/com/github/weisj/darklaf/util/TimerUtil.java index 76c3ccf9..b82a181c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/util/TimerUtil.java +++ b/core/src/main/java/com/github/weisj/darklaf/util/TimerUtil.java @@ -20,18 +20,19 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.util; -import javax.swing.*; import java.awt.event.ActionListener; +import javax.swing.*; + /** * @author Jannis Weis */ public final class TimerUtil { - public static Timer createNamedTimer(final String name, final int delay, final ActionListener listener) { return new Timer(delay, listener) { @@ -42,7 +43,6 @@ public final class TimerUtil { }; } - public static Timer createNamedTimer(final String name, final int delay) { return new Timer(delay, null) { @Override diff --git a/core/src/main/java/javax/swing/text/DefaultHighlighterDark/DarkHighlightPainter.java b/core/src/main/java/javax/swing/text/DefaultHighlighterDark/DarkHighlightPainter.java index 9d0e8214..efdc30fa 100644 --- a/core/src/main/java/javax/swing/text/DefaultHighlighterDark/DarkHighlightPainter.java +++ b/core/src/main/java/javax/swing/text/DefaultHighlighterDark/DarkHighlightPainter.java @@ -20,23 +20,26 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package javax.swing.text.DefaultHighlighterDark; +import java.awt.*; +import java.awt.geom.Arc2D; +import java.awt.geom.Area; +import java.awt.geom.Rectangle2D; + +import javax.swing.*; +import javax.swing.plaf.TextUI; +import javax.swing.text.*; + +import sun.swing.SwingUtilities2; + import com.github.weisj.darklaf.ui.text.DarkTextUI; import com.github.weisj.darklaf.ui.text.StyleConstantsEx; import com.github.weisj.darklaf.util.ColorWrapper; import com.github.weisj.darklaf.util.GraphicsContext; import com.github.weisj.darklaf.util.GraphicsUtil; -import sun.swing.SwingUtilities2; - -import javax.swing.*; -import javax.swing.plaf.TextUI; -import javax.swing.text.*; -import java.awt.*; -import java.awt.geom.Arc2D; -import java.awt.geom.Area; -import java.awt.geom.Rectangle2D; /** * Note this class only sits inside this weird package because of a hack used in {@link @@ -61,22 +64,18 @@ public class DarkHighlightPainter extends DefaultHighlighter.DefaultHighlightPai private boolean suppressRounded = false; private boolean enabled; - public DarkHighlightPainter() { this(null); } - public DarkHighlightPainter(final Paint paint) { this(paint, false); } - public DarkHighlightPainter(final Paint paint, final boolean rounded) { this(paint, rounded, 1.0f); } - public DarkHighlightPainter(final Paint paint, final boolean rounded, final float alpha) { super(null); setPaint(paint); @@ -100,7 +99,6 @@ public class DarkHighlightPainter extends DefaultHighlighter.DefaultHighlightPai roundedEdges = rounded; } - @Override public Color getColor() { return wrapper; @@ -151,8 +149,7 @@ public class DarkHighlightPainter extends DefaultHighlighter.DefaultHighlightPai g2d.fillRect(alloc.x, p1.y, (p1.x - alloc.x), p1.height); } - } catch (BadLocationException ignored) { - } finally { + } catch (BadLocationException ignored) {} finally { context.restore(); } } @@ -201,8 +198,7 @@ public class DarkHighlightPainter extends DefaultHighlighter.DefaultHighlightPai } try { dirtyShape = paintLayerImpl(g2d, offs0, offs1, c); - } catch (BadLocationException ignored) { - } finally { + } catch (BadLocationException ignored) {} finally { context.restoreComposite(); } @@ -369,8 +365,6 @@ public class DarkHighlightPainter extends DefaultHighlighter.DefaultHighlightPai /* * Selection is contained to one line. */ - - private Shape paintSelection(final Graphics2D g2d, final JTextComponent c, final Rectangle r, final boolean selectionStart, final boolean selectionEnd) { if (DEBUG_COLOR) g2d.setColor(Color.BLUE); @@ -481,12 +475,11 @@ public class DarkHighlightPainter extends DefaultHighlighter.DefaultHighlightPai private void paintStartArc(final Graphics2D g2d, final Rectangle r) { if (DEBUG_COLOR) g2d.setColor(Color.PINK); - Area arc = new Area(new Rectangle2D.Double( - r.x - arcSize + 0.25, r.y + r.height - arcSize + 0.25, arcSize, arcSize)); - arc.subtract(new Area(new Arc2D.Double( - r.x - 2 * arcSize + 0.25, - r.y + r.height - 2 * arcSize + 0.25, 2 * arcSize, 2 * arcSize, - 0, -90, Arc2D.Double.PIE))); + Area arc = new Area(new Rectangle2D.Double(r.x - arcSize + 0.25, r.y + r.height - arcSize + 0.25, arcSize, + arcSize)); + arc.subtract(new Area(new Arc2D.Double(r.x - 2 * arcSize + 0.25, + r.y + r.height - 2 * arcSize + 0.25, 2 * arcSize, 2 * arcSize, + 0, -90, Arc2D.Double.PIE))); g2d.fill(arc); r.x -= arcSize; r.width += arcSize; @@ -509,11 +502,9 @@ public class DarkHighlightPainter extends DefaultHighlighter.DefaultHighlightPai private void paintEndArc(final Graphics2D g2d, final Rectangle r) { if (DEBUG_COLOR) g2d.setColor(Color.PINK); - Area arc = new Area(new Rectangle2D.Double( - r.x + r.width - 0.25, r.y - 0.25, arcSize, arcSize)); - arc.subtract(new Area(new Arc2D.Double( - r.x + r.width - 0.25, - r.y - 0.25, 2 * arcSize, 2 * arcSize, 90, 90, Arc2D.Double.PIE))); + Area arc = new Area(new Rectangle2D.Double(r.x + r.width - 0.25, r.y - 0.25, arcSize, arcSize)); + arc.subtract(new Area(new Arc2D.Double(r.x + r.width - 0.25, + r.y - 0.25, 2 * arcSize, 2 * arcSize, 90, 90, Arc2D.Double.PIE))); g2d.fill(arc); } diff --git a/core/src/main/java/org/pbjar/jxlayer/plaf/ext/MouseEventUI.java b/core/src/main/java/org/pbjar/jxlayer/plaf/ext/MouseEventUI.java index 2af26a37..23e26df6 100644 --- a/core/src/main/java/org/pbjar/jxlayer/plaf/ext/MouseEventUI.java +++ b/core/src/main/java/org/pbjar/jxlayer/plaf/ext/MouseEventUI.java @@ -1,41 +1,35 @@ /* - Copyright (c) 2009, Piet Blok - All rights reserved. -

- Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: -

- * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of the copyright holder nor the names of the - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. -

- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * Copyright (c) 2009, Piet Blok + * All rights reserved. + *

+ * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + *

+ * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * Neither the name of the copyright holder nor the names of the + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + *

+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.pbjar.jxlayer.plaf.ext; -import org.jdesktop.jxlayer.JXLayer; -import org.jdesktop.jxlayer.plaf.AbstractLayerUI; -import org.jdesktop.jxlayer.plaf.LayerUI; - -import javax.swing.*; -import javax.swing.plaf.ComponentUI; import java.awt.*; import java.awt.event.MouseEvent; import java.awt.event.MouseWheelEvent; @@ -43,6 +37,13 @@ import java.awt.event.MouseWheelListener; import java.awt.geom.AffineTransform; import java.awt.geom.NoninvertibleTransformException; +import javax.swing.*; +import javax.swing.plaf.ComponentUI; + +import org.jdesktop.jxlayer.JXLayer; +import org.jdesktop.jxlayer.plaf.AbstractLayerUI; +import org.jdesktop.jxlayer.plaf.LayerUI; + /** * This class provides for {@link MouseEvent} re-dispatching. It may be used to set a tool tip on {@link JXLayer}'s * glass pane and still have the child components receive {@link MouseEvent}s. @@ -66,7 +67,6 @@ public class MouseEventUI extends AbstractLayerUI { new JInternalFrame(); } - private Component lastEnteredTarget, lastPressedTarget; private boolean dispatchingMode = false; @@ -88,7 +88,7 @@ public class MouseEventUI extends AbstractLayerUI { * component} as the installed {@link JXLayer}. * * @throws IllegalStateException when this {@link LayerUI} has been installed already - * @see #getInstalledLayer() + * @see #getInstalledLayer() */ @SuppressWarnings("unchecked") @Override @@ -192,7 +192,6 @@ public class MouseEventUI extends AbstractLayerUI { } } - private Point calculateTargetPoint(final JXLayer layer, final MouseEvent mouseEvent) { Point point = mouseEvent.getPoint(); @@ -218,9 +217,8 @@ public class MouseEventUI extends AbstractLayerUI { // } } - - private MouseWheelEvent createMouseWheelEvent( - final MouseWheelEvent mouseWheelEvent, final Point point, final Component target) { + private MouseWheelEvent createMouseWheelEvent(final MouseWheelEvent mouseWheelEvent, final Point point, + final Component target) { return new MouseWheelEvent(target, // mouseWheelEvent.getID(), // mouseWheelEvent.getWhen(), // @@ -242,7 +240,6 @@ public class MouseEventUI extends AbstractLayerUI { } } - private Component findWheelListenerComponent(final Component target) { if (target == null) { return null; @@ -270,27 +267,26 @@ public class MouseEventUI extends AbstractLayerUI { private Component getListeningComponent(final MouseEvent event, final Component component) { Component comp; switch (event.getID()) { - case MouseEvent.MOUSE_CLICKED: - case MouseEvent.MOUSE_ENTERED: - case MouseEvent.MOUSE_EXITED: - case MouseEvent.MOUSE_PRESSED: - case MouseEvent.MOUSE_RELEASED: + case MouseEvent.MOUSE_CLICKED : + case MouseEvent.MOUSE_ENTERED : + case MouseEvent.MOUSE_EXITED : + case MouseEvent.MOUSE_PRESSED : + case MouseEvent.MOUSE_RELEASED : comp = getMouseListeningComponent(component); break; - case MouseEvent.MOUSE_DRAGGED: - case MouseEvent.MOUSE_MOVED: + case MouseEvent.MOUSE_DRAGGED : + case MouseEvent.MOUSE_MOVED : comp = getMouseMotionListeningComponent(component); break; - case MouseEvent.MOUSE_WHEEL: + case MouseEvent.MOUSE_WHEEL : comp = getMouseWheelListeningComponent(component); break; - default: + default : comp = null; } return comp; } - private Component getMouseListeningComponent(final Component component) { if (component.getMouseListeners().length > 0) { return component; @@ -326,7 +322,6 @@ public class MouseEventUI extends AbstractLayerUI { } } - private Component getMouseWheelListeningComponent(final Component component) { if (component.getMouseWheelListeners().length > 0) { return component; @@ -340,7 +335,6 @@ public class MouseEventUI extends AbstractLayerUI { } } - private Component getTarget(final JXLayer layer, final Point targetPoint) { Component view = layer.getView(); if (view == null) { @@ -369,34 +363,32 @@ public class MouseEventUI extends AbstractLayerUI { } switch (originalEvent.getID()) { - case MouseEvent.MOUSE_PRESSED: + case MouseEvent.MOUSE_PRESSED : newEvent = transformMouseEvent(layer, originalEvent, realTarget, realPoint); if (newEvent != null) { lastPressedTarget = newEvent.getComponent(); } break; - case MouseEvent.MOUSE_RELEASED: - newEvent = - transformMouseEvent(layer, originalEvent, lastPressedTarget, realPoint); + case MouseEvent.MOUSE_RELEASED : + newEvent = transformMouseEvent(layer, originalEvent, lastPressedTarget, realPoint); lastPressedTarget = null; break; - case MouseEvent.MOUSE_ENTERED: - case MouseEvent.MOUSE_EXITED: + case MouseEvent.MOUSE_ENTERED : + case MouseEvent.MOUSE_EXITED : generateEnterExitEvents(layer, originalEvent, realTarget, realPoint); break; - case MouseEvent.MOUSE_MOVED: + case MouseEvent.MOUSE_MOVED : newEvent = transformMouseEvent(layer, originalEvent, realTarget, realPoint); generateEnterExitEvents(layer, originalEvent, realTarget, realPoint); break; - case MouseEvent.MOUSE_DRAGGED: - newEvent = - transformMouseEvent(layer, originalEvent, lastPressedTarget, realPoint); + case MouseEvent.MOUSE_DRAGGED : + newEvent = transformMouseEvent(layer, originalEvent, lastPressedTarget, realPoint); generateEnterExitEvents(layer, originalEvent, realTarget, realPoint); break; - case MouseEvent.MOUSE_CLICKED: + case MouseEvent.MOUSE_CLICKED : newEvent = transformMouseEvent(layer, originalEvent, realTarget, realPoint); break; - case (MouseEvent.MOUSE_WHEEL): + case (MouseEvent.MOUSE_WHEEL) : redispatchMouseWheelEvent((MouseWheelEvent) originalEvent, realTarget, layer); break; } @@ -406,19 +398,16 @@ public class MouseEventUI extends AbstractLayerUI { private void redispatchMouseWheelEvent(final MouseWheelEvent mouseWheelEvent, final Component target, final JXLayer layer) { - MouseWheelEvent newEvent = this.transformMouseWheelEvent( - mouseWheelEvent, target, layer); + MouseWheelEvent newEvent = this.transformMouseWheelEvent(mouseWheelEvent, target, layer); processMouseWheelEvent(newEvent, layer); } - private MouseEvent transformMouseEvent(final JXLayer layer, final MouseEvent mouseEvent, final Component target, final Point realPoint) { return transformMouseEvent(layer, mouseEvent, target, realPoint, mouseEvent.getID()); } - private MouseEvent transformMouseEvent(final JXLayer layer, final MouseEvent mouseEvent, final Component target, final Point targetPoint, final int id) { @@ -440,10 +429,8 @@ public class MouseEventUI extends AbstractLayerUI { } } - - private MouseWheelEvent transformMouseWheelEvent( - final MouseWheelEvent mouseWheelEvent, final Component t, - final JXLayer layer) { + private MouseWheelEvent transformMouseWheelEvent(final MouseWheelEvent mouseWheelEvent, final Component t, + final JXLayer layer) { Component target = t; if (target == null) { target = layer; @@ -454,7 +441,6 @@ public class MouseEventUI extends AbstractLayerUI { point, target); } - private Point transformPoint(final JXLayer layer, final Point point) { AffineTransform transform = this.getTransform(layer); if (transform != null) { @@ -467,9 +453,7 @@ public class MouseEventUI extends AbstractLayerUI { return point; } - protected JXLayer getInstalledLayer() { return installedLayer; } - } diff --git a/core/src/main/java/org/pbjar/jxlayer/plaf/ext/TransformUI.java b/core/src/main/java/org/pbjar/jxlayer/plaf/ext/TransformUI.java index 610ad663..bda85880 100644 --- a/core/src/main/java/org/pbjar/jxlayer/plaf/ext/TransformUI.java +++ b/core/src/main/java/org/pbjar/jxlayer/plaf/ext/TransformUI.java @@ -1,4 +1,5 @@ package org.pbjar.jxlayer.plaf.ext; + /* * Copyright (c) 2009, Piet Blok * All rights reserved. @@ -30,8 +31,21 @@ package org.pbjar.jxlayer.plaf.ext; * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import com.github.weisj.darklaf.log.LogFormatter; -import com.sun.java.swing.SwingUtilities3; +import java.awt.*; +import java.awt.geom.AffineTransform; +import java.awt.geom.Area; +import java.awt.image.BufferedImage; +import java.beans.PropertyChangeListener; +import java.util.*; +import java.util.logging.ConsoleHandler; +import java.util.logging.Logger; + +import javax.swing.*; +import javax.swing.border.Border; +import javax.swing.event.ChangeListener; +import javax.swing.text.GlyphView.GlyphPainter; +import javax.swing.text.JTextComponent; + import org.jdesktop.jxlayer.JXLayer; import org.jdesktop.jxlayer.plaf.AbstractBufferedLayerUI; import org.jdesktop.jxlayer.plaf.LayerUI; @@ -41,25 +55,13 @@ import org.pbjar.jxlayer.repaint.RepaintManagerProvider; import org.pbjar.jxlayer.repaint.RepaintManagerUtils; import org.pbjar.jxlayer.repaint.WrappedRepaintManager; -import javax.swing.*; -import javax.swing.border.Border; -import javax.swing.event.ChangeListener; -import javax.swing.text.GlyphView.GlyphPainter; -import javax.swing.text.JTextComponent; -import java.awt.*; -import java.awt.geom.AffineTransform; -import java.awt.geom.Area; -import java.awt.image.BufferedImage; -import java.beans.PropertyChangeListener; -import java.util.*; -import java.util.logging.ConsoleHandler; -import java.util.logging.Logger; +import com.github.weisj.darklaf.log.LogFormatter; +import com.sun.java.swing.SwingUtilities3; /** * This class provides for all necessary functionality when using transformations in a {@link LayerUI}. - * - *

Some implementation details: - * + *

+ * Some implementation details: *

    *
  • It extends {@link MouseEventUI} because, when applying transformations, the whereabouts of * child components on screen (device space) do not necessarily match the location according @@ -88,16 +90,16 @@ import java.util.logging.Logger; *
  • Rendering hints may be set with {@link #setRenderingHints(Map)}, {@link * #addRenderingHint(RenderingHints.Key, Object)} and {@link #addRenderingHints(Map)}. *
- * - *

Known limitations: - * + *

+ * Known limitations: *

    *
  1. In Java versions before Java 6u10, this implementation employs a custom {@link * RepaintManager} in order to have descendant's repaint requests propagated up to the {@link * JXLayer} ancestor. This {@link RepaintManager} will work well with and without other {@link * RepaintManager} that are either subclasses of the {@link WrappedRepaintManager} or SwingX's * {@link ForwardingRepaintManager}. Other {@link RepaintManager}s may cause conflicts. - *

    In Java versions 6u10 or higher, an attempt will be made to use the new + *

    + * In Java versions 6u10 or higher, an attempt will be made to use the new * RepaintManager delegate facility that has been designed for JavaFX. *

  2. Transformations will be applied on the whole of the content of the {@link JXLayer}. The * result is that {@link Border}s and other content within {@link JXLayer}'s insets will @@ -106,7 +108,6 @@ import java.util.logging.Logger; * be set on the view instead. On the other hand, if you want the {@link Border} not to be * transformed, that border must be set on {@link JXLayer}'s parent. *
- * * Note: A {@link TransformUI} instance cannot be shared and can be set to a single {@link * JXLayer} instance only. * @@ -114,7 +115,6 @@ import java.util.logging.Logger; */ public class TransformUI extends MouseEventUI { - private static final LayoutManager transformLayout = new TransformLayout(); private static final String KEY_VIEW = "view"; private static final boolean delegatePossible; @@ -141,31 +141,27 @@ public class TransformUI extends MouseEventUI { } private final ChangeListener changeListener = e -> revalidateLayer(); - private final RepaintManagerProvider rpmProvider = - new RepaintManagerProvider() { - - - @Override - public Class getForwardingRepaintManagerClass() { - return TransformRPMSwingX.class; - } + private final RepaintManagerProvider rpmProvider = new RepaintManagerProvider() { + @Override + public Class getForwardingRepaintManagerClass() { + return TransformRPMSwingX.class; + } - @Override - public Class getWrappedRepaintManagerClass() { - return TransformRPMFallBack.class; - } + @Override + public Class getWrappedRepaintManagerClass() { + return TransformRPMFallBack.class; + } - @Override - public boolean isAdequate(final Class manager) { - return manager.isAnnotationPresent(TransformRPMAnnotation.class); - } - }; + @Override + public boolean isAdequate(final Class manager) { + return manager.isAnnotationPresent(TransformRPMAnnotation.class); + } + }; private final Map renderingHints = new HashMap<>(); private final Set originalDoubleBuffered = new HashSet<>(); private JComponent view; - private final PropertyChangeListener viewChangeListener = - evt -> setView((JComponent) evt.getNewValue()); + private final PropertyChangeListener viewChangeListener = evt -> setView((JComponent) evt.getNewValue()); private TransformModel transformModel; private LayoutManager originalLayout; @@ -199,14 +195,14 @@ public class TransformUI extends MouseEventUI { * {@link JTextComponent} and its descendants have some caret position problems when used inside a transformed * {@link JXLayer}. When you plan to use {@link JTextComponent}(s) inside the hierarchy of a transformed {@link * JXLayer}, call this method in an early stage, before instantiating any {@link JTextComponent}. - * - *

It executes the following method: + *

+ * It executes the following method: * *

      * System.setProperty("i18n", Boolean.TRUE.toString());
      * 
- * - *

As a result, a {@link GlyphPainter} will be selected that uses floating point instead of + *

+ * As a result, a {@link GlyphPainter} will be selected that uses floating point instead of * fixed point calculations. */ public static void prepareForJTextComponent() { @@ -236,10 +232,8 @@ public class TransformUI extends MouseEventUI { * Get the {@link TransformModel}. * * @return the {@link TransformModel} - * @see #setModel(TransformModel) + * @see #setModel(TransformModel) */ - - public final TransformModel getModel() { return transformModel; } @@ -247,11 +241,10 @@ public class TransformUI extends MouseEventUI { /** * Set a new {@link TransformModel}. The new model may not be {@code null}. * - * @param transformModel the new model + * @param transformModel the new model * @throws NullPointerException if transformModel is {@code null} - * @see #getModel() + * @see #getModel() */ - public final void setModel(final TransformModel transformModel) throws NullPointerException { if (transformModel == null) { throw new NullPointerException("The TransformModel may not be null"); @@ -267,71 +260,73 @@ public class TransformUI extends MouseEventUI { /** * Get a preferred {@link AffineTransform}. This method will typically be invoked by programs that calculate a * preferred size. - * - *

The {@code size} argument will be used to compute anchor values for some types of + *

+ * The {@code size} argument will be used to compute anchor values for some types of * transformations. If the {@code size} argument is {@code null} a value of (0,0) is used for the anchor. - * - *

In {@code enabled} state this method is delegated to the {@link TransformModel} that has + *

+ * In {@code enabled} state this method is delegated to the {@link TransformModel} that has * been set. Otherwise {@code null} will be returned. * - * @param size a {@link Dimension} instance to be used for an anchor or {@code null} - * @param layer the {@link JXLayer}. - * @return a {@link AffineTransform} instance or {@code null} + * @param size a {@link Dimension} instance to be used for an anchor or {@code null} + * @param layer the {@link JXLayer}. + * @return a {@link AffineTransform} instance or {@code null} */ - public AffineTransform getPreferredTransform(final Dimension size, final JXLayer layer) { return this.transformModel != null ? this.transformModel.getPreferredTransform(size, layer) : new AffineTransform(); } - /* - {@inheritDoc} -

- This implementation does the following: -

    -
  1. - A {@link BufferedImage} is created the size of the clip bounds of the - argument graphics object.
  2. -
  3. - A Graphics object is obtained from the image.
  4. -
  5. - The image is filled with a background color.
  6. -
  7. - The image graphics is translated according to x and y of the clip bounds. -
  8. -
  9. - The clip from the argument graphics object is set to the image graphics.
  10. -
  11. - {@link #configureGraphics(Graphics2D, JXLayer)} is invoked with the image - graphics as an argument.
  12. -
  13. - {@link #paintLayer(Graphics2D, JXLayer)} is invoked with the image - graphics as an argument.
  14. -
  15. - The image graphics is disposed.
  16. -
  17. - The image is drawn on the argument graphics object.
  18. -
- */ - /* @SuppressWarnings("unchecked") - @Override - public final void paint(Graphics g, JComponent component) { - Graphics2D g2 = (Graphics2D) g; - JXLayer layer = (JXLayer) component; - Shape clip = g2.getClip(); - Rectangle clipBounds = g2.getClipBounds(); - BufferedImage buffer = layer.getGraphicsConfiguration() - .createCompatibleImage(clipBounds.width, clipBounds.height, - Transparency.OPAQUE);// - Graphics2D g3 = buffer.createGraphics(); - try { - g3.setColor(this.getBackgroundColor(layer)); - g3.fillRect(0, 0, buffer.getWidth(), buffer.getHeight()); - g3.translate(-clipBounds.x, -clipBounds.y); - g3.setClip(clip); - configureGraphics(g3, layer); - paintLayer(g3, layer); - } catch (Throwable t) {*/ + /* + * {@inheritDoc} + *

+ * This implementation does the following: + *

    + *
  1. + * A {@link BufferedImage} is created the size of the clip bounds of the + * argument graphics object.
  2. + *
  3. + * A Graphics object is obtained from the image.
  4. + *
  5. + * The image is filled with a background color.
  6. + *
  7. + * The image graphics is translated according to x and y of the clip bounds. + *
  8. + *
  9. + * The clip from the argument graphics object is set to the image graphics.
  10. + *
  11. + * {@link #configureGraphics(Graphics2D, JXLayer)} is invoked with the image + * graphics as an argument.
  12. + *
  13. + * {@link #paintLayer(Graphics2D, JXLayer)} is invoked with the image + * graphics as an argument.
  14. + *
  15. + * The image graphics is disposed.
  16. + *
  17. + * The image is drawn on the argument graphics object.
  18. + *
+ */ + /* + * @SuppressWarnings("unchecked") + * + * @Override + * public final void paint(Graphics g, JComponent component) { + * Graphics2D g2 = (Graphics2D) g; + * JXLayer layer = (JXLayer) component; + * Shape clip = g2.getClip(); + * Rectangle clipBounds = g2.getClipBounds(); + * BufferedImage buffer = layer.getGraphicsConfiguration() + * .createCompatibleImage(clipBounds.width, clipBounds.height, + * Transparency.OPAQUE);// + * Graphics2D g3 = buffer.createGraphics(); + * try { + * g3.setColor(this.getBackgroundColor(layer)); + * g3.fillRect(0, 0, buffer.getWidth(), buffer.getHeight()); + * g3.translate(-clipBounds.x, -clipBounds.y); + * g3.setClip(clip); + * configureGraphics(g3, layer); + * paintLayer(g3, layer); + * } catch (Throwable t) { + */ /* * Under some rare circumstances, the graphics engine may throw a * transformation exception like this: @@ -364,13 +359,14 @@ public class TransformUI extends MouseEventUI { // System.err.println("scaleX = " + at.getScaleX() + " scaleY = " // + at.getScaleY() + " shearX = " + at.getShearX() // + " shearY = " + at.getShearY()); - /*} finally { - g3.dispose(); - } - g2.drawImage(buffer, clipBounds.x, clipBounds.y, null); - setDirty(false); - }*/ - + /* + * } finally { + * g3.dispose(); + * } + * g2.drawImage(buffer, clipBounds.x, clipBounds.y, null); + * setDirty(false); + * } + */ /** * Overridden to replace the {@link LayoutManager}, to add some listeners and to ensure that an appropriate {@link * RepaintManager} is installed. @@ -435,9 +431,9 @@ public class TransformUI extends MouseEventUI { /** * Primarily intended for use by {@link RepaintManager}. * - * @param rect a rectangle - * @param layer the layer - * @return the argument rectangle if no {@link AffineTransform} is available, else a new rectangle + * @param rect a rectangle + * @param layer the layer + * @return the argument rectangle if no {@link AffineTransform} is available, else a new rectangle */ public final Rectangle transform(final Rectangle rect, final JXLayer layer) { AffineTransform at = getTransform(layer); @@ -496,17 +492,16 @@ public class TransformUI extends MouseEventUI { * If the view of the {@link JXLayer} is (partly) obscured by its parent (this is the case when the size of the view * (in component space) is larger than the size of the {@link JXLayer}), the obscured parts will not be painted by * the super implementation. Therefore, only under this condition, a special painting technique is executed: - * *
    *
  1. All descendants of the {@link JXLayer} are temporarily set to non double buffered. *
  2. The graphics object is translated for the X and Y coordinates of the view. *
  3. The view is painted. *
  4. The original double buffered property is restored for all descendants. *
- * - *

In all other cases, the super method is invoked. - * - *

The {@code g2} argument is a graphics object obtained from a {@link BufferedImage}. + *

+ * In all other cases, the super method is invoked. + *

+ * The {@code g2} argument is a graphics object obtained from a {@link BufferedImage}. * * @see #paint(Graphics, JComponent) */ @@ -530,11 +525,10 @@ public class TransformUI extends MouseEventUI { /** * Get the {@link AffineTransform} customized for the {@code layer} argument. - * - *

In {@code enabled} state this method is delegated to the {@link TransformModel} that has + *

+ * In {@code enabled} state this method is delegated to the {@link TransformModel} that has * been set. Otherwise {@code null} will be returned. */ - @Override protected final AffineTransform getTransform(final JXLayer layer) { return transformModel != null ? transformModel.getTransform(layer) @@ -545,11 +539,10 @@ public class TransformUI extends MouseEventUI { * Get the rendering hints. * * @return the rendering hints - * @see #setRenderingHints(Map) - * @see #addRenderingHints(Map) - * @see #addRenderingHint(RenderingHints.Key, Object) + * @see #setRenderingHints(Map) + * @see #addRenderingHints(Map) + * @see #addRenderingHint(RenderingHints.Key, Object) */ - @Override protected Map getRenderingHints(final JXLayer layer) { return renderingHints; @@ -558,14 +551,13 @@ public class TransformUI extends MouseEventUI { /** * A delegate {@link RepaintManager} that can be set on the view of a {@link JXLayer} in Java versions starting with * Java 6u10. - * - *

For older Java versions, {@link RepaintManager#setCurrentManager(RepaintManager)} will be + *

+ * For older Java versions, {@link RepaintManager#setCurrentManager(RepaintManager)} will be * used with either {@link TransformRPMFallBack} or {@link TransformRPMSwingX}. */ protected static final class TransformRepaintManager extends RepaintManager { - private TransformRepaintManager() { - } + private TransformRepaintManager() {} /** * Finds the JXLayer ancestor and have ancestor marked invalid via the current {@link RepaintManager}. @@ -600,10 +592,9 @@ public class TransformUI extends MouseEventUI { /** * Find the ancestor {@link JXLayer} instance. * - * @param c a component - * @return the ancestor {@link JXLayer} instance + * @param c a component + * @return the ancestor {@link JXLayer} instance */ - @SuppressWarnings("unchecked") private JXLayer findJXLayer(final JComponent c) { JXLayer layer = (JXLayer) SwingUtilities.getAncestorOfClass(JXLayer.class, c); diff --git a/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/DefaultLayerLayout.java b/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/DefaultLayerLayout.java index 3baa35da..cd6a85fe 100644 --- a/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/DefaultLayerLayout.java +++ b/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/DefaultLayerLayout.java @@ -1,4 +1,5 @@ package org.pbjar.jxlayer.plaf.ext.transform; + /* * Copyright (c) 2009, Piet Blok * All rights reserved. @@ -30,11 +31,11 @@ package org.pbjar.jxlayer.plaf.ext.transform; * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import org.jdesktop.jxlayer.JXLayer; - import java.awt.*; import java.io.Serializable; +import org.jdesktop.jxlayer.JXLayer; + /** * A copy of the private static inner class in JXLayer. * @@ -44,19 +45,16 @@ public class DefaultLayerLayout implements LayoutManager, Serializable { /** * {@inheritDoc} */ - public void addLayoutComponent(final String name, final Component comp) { - } + public void addLayoutComponent(final String name, final Component comp) {} /** * {@inheritDoc} */ - public void removeLayoutComponent(final Component comp) { - } + public void removeLayoutComponent(final Component comp) {} /** * {@inheritDoc} */ - public Dimension preferredLayoutSize(final Container parent) { JXLayer layer = (JXLayer) parent; Insets insets = layer.getInsets(); @@ -75,7 +73,6 @@ public class DefaultLayerLayout implements LayoutManager, Serializable { /** * {@inheritDoc} */ - public Dimension minimumLayoutSize(final Container parent) { JXLayer layer = (JXLayer) parent; Insets insets = layer.getInsets(); @@ -103,9 +100,8 @@ public class DefaultLayerLayout implements LayoutManager, Serializable { if (view != null) { Insets insets = layer.getInsets(); view.setLocation(insets.left, insets.top); - view.setSize( - layer.getWidth() - insets.left - insets.right, - layer.getHeight() - insets.top - insets.bottom); + view.setSize(layer.getWidth() - insets.left - insets.right, + layer.getHeight() - insets.top - insets.bottom); } if (glassPane != null) { glassPane.setLocation(0, 0); diff --git a/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/DefaultTransformModel.java b/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/DefaultTransformModel.java index ed831240..9fdebdd6 100644 --- a/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/DefaultTransformModel.java +++ b/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/DefaultTransformModel.java @@ -1,4 +1,5 @@ package org.pbjar.jxlayer.plaf.ext.transform; + /* * Copyright (c) 2009, Piet Blok All rights reserved. *

@@ -27,11 +28,6 @@ package org.pbjar.jxlayer.plaf.ext.transform; * POSSIBILITY OF SUCH DAMAGE. */ -import org.jdesktop.jxlayer.JXLayer; - -import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; import java.awt.*; import java.awt.geom.AffineTransform; import java.awt.geom.Area; @@ -42,6 +38,12 @@ import java.util.Map; import java.util.WeakHashMap; import java.util.function.Function; +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; + +import org.jdesktop.jxlayer.JXLayer; + /** * This is an implementation of {@link TransformModel} with methods to explicitly set transformation values. * @@ -72,7 +74,6 @@ public class DefaultTransformModel implements TransformModel { listeners.put(listener, null); } - @Override public AffineTransform getPreferredTransform(final Dimension size, final JXLayer layer) { Point2D p = getRotationCenter(size); @@ -81,7 +82,7 @@ public class DefaultTransformModel implements TransformModel { AffineTransform transform = transformNoScale(centerX, centerY); double scaleX = getValue(Type.PreferredScale); transform.translate(centerX, centerY); - transform.scale((boolean) getValue(Type.Mirror) ? -scaleX : scaleX, scaleX); + transform.scale(getValue(Type.Mirror) ? -scaleX : scaleX, scaleX); transform.translate(-centerX, -centerY); return transform; } @@ -89,8 +90,8 @@ public class DefaultTransformModel implements TransformModel { /** * Get the rotation center corresponding to the size. * - * @param size the size. - * @return center of rotation. + * @param size the size. + * @return center of rotation. */ public Point2D getRotationCenter(final Dimension size) { if (supplier != null) { @@ -104,11 +105,10 @@ public class DefaultTransformModel implements TransformModel { /** * Apply the prescribed transformations, excluding the scale. * - * @param centerX a center X - * @param centerY a center Y - * @return a new {@link AffineTransform} + * @param centerX a center X + * @param centerY a center Y + * @return a new {@link AffineTransform} */ - protected AffineTransform transformNoScale(final double centerX, final double centerY) { AffineTransform at = new AffineTransform(); at.translate(centerX, centerY); @@ -123,13 +123,12 @@ public class DefaultTransformModel implements TransformModel { * Get the rotation value in radians as set by {@link #setRotation(double)}. The default value is {@code 0}. * * @return the rotation value. - * @see #setRotation(double) + * @see #setRotation(double) */ public double getRotation() { return (Double) getValue(Type.Rotation); } - @SuppressWarnings("unchecked") protected T getValue(final Type type) { return (T) values[type.ordinal()]; @@ -139,7 +138,7 @@ public class DefaultTransformModel implements TransformModel { * Get the quadrant rotation value. The default value is {@code 0}. * * @return the quadrant rotation value - * @see #setQuadrantRotation(int) + * @see #setQuadrantRotation(int) */ public int getQuadrantRotation() { return (Integer) getValue(Type.QuadrantRotation); @@ -149,7 +148,7 @@ public class DefaultTransformModel implements TransformModel { * Set the rotation in quadrants. The default value is {@code 0}. * * @param newValue the number of quadrants - * @see #getQuadrantRotation() + * @see #getQuadrantRotation() */ public void setQuadrantRotation(final int newValue) { setValue(Type.QuadrantRotation, newValue); @@ -157,17 +156,17 @@ public class DefaultTransformModel implements TransformModel { /** * Set a scale. - * - *

The scale is primarily used to calculate a preferred size. Unless {@code + *

+ * The scale is primarily used to calculate a preferred size. Unless {@code * ScaleToPreferredSize} is set to {@code true} (see {@link #setScaleToPreferredSize(boolean)} and {@link * #isScaleToPreferredSize()}), actual scaling itself is calculated such that the view occupies as much space as * possible on the {@link JXLayer}. + *

+ * The default value is 1. * - *

The default value is 1. - * - * @param newValue the preferred scale + * @param newValue the preferred scale * @throws IllegalArgumentException when the argument value is 0 - * @see #getScale() + * @see #getScale() */ public void setScale(final double newValue) throws IllegalArgumentException { if (newValue == 0.0) { @@ -181,7 +180,6 @@ public class DefaultTransformModel implements TransformModel { * * @return the currently active {@link AffineTransform} */ - @Override public AffineTransform getTransform(final JXLayer layer) { JComponent view = layer == null ? null : layer.getView(); @@ -207,7 +205,7 @@ public class DefaultTransformModel implements TransformModel { double scaleX; double scaleY; - if ((boolean) getValue(Type.ScaleToPreferredSize)) { + if (getValue(Type.ScaleToPreferredSize)) { scaleX = getValue(Type.PreferredScale); scaleY = scaleX; } else { @@ -217,14 +215,14 @@ public class DefaultTransformModel implements TransformModel { scaleX = layer == null ? 0 : layer.getWidth() / bounds.getWidth(); scaleY = layer == null ? 0 : layer.getHeight() / bounds.getHeight(); - if ((boolean) getValue(Type.PreserveAspectRatio)) { + if (getValue(Type.PreserveAspectRatio)) { scaleX = Math.min(scaleX, scaleY); scaleY = scaleX; } } transform.translate(centerX, centerY); - transform.scale((boolean) getValue(Type.Mirror) ? -scaleX : scaleX, scaleY); + transform.scale(getValue(Type.Mirror) ? -scaleX : scaleX, scaleY); transform.translate(-centerX, -centerY); transform.concatenate(nonScaledTransform); } @@ -237,7 +235,7 @@ public class DefaultTransformModel implements TransformModel { * Get the shearX value as set by {@link #setShearX(double)}; The default value is {@code 0}. * * @return the shear x value - * @see #setShearX(double) + * @see #setShearX(double) */ public double getShearX() { return (Double) getValue(Type.ShearX); @@ -247,7 +245,7 @@ public class DefaultTransformModel implements TransformModel { * Set the shearX value. The default value is {@code 0}. * * @param newValue the shear x - * @see #getShearX() + * @see #getShearX() */ public void setShearX(final double newValue) { setValue(Type.ShearX, newValue); @@ -257,7 +255,7 @@ public class DefaultTransformModel implements TransformModel { * Get the shearY value as set by {@link #setShearY(double)}; The default value is {@code 0}. * * @return the shear y value - * @see #setShearY(double) + * @see #setShearY(double) */ public double getShearY() { return (Double) getValue(Type.ShearY); @@ -267,7 +265,7 @@ public class DefaultTransformModel implements TransformModel { * Set the shearY value. The default value is {@code 0}. * * @param newValue the shear y - * @see #getShearY() + * @see #getShearY() */ public void setShearY(final double newValue) { setValue(Type.ShearY, newValue); @@ -277,7 +275,7 @@ public class DefaultTransformModel implements TransformModel { * Set the rotation in radians. The default value is {@code 0}. * * @param newValue the rotation in radians - * @see #getRotation() + * @see #getRotation() */ public void setRotation(final double newValue) { setValue(Type.Rotation, newValue); @@ -304,7 +302,7 @@ public class DefaultTransformModel implements TransformModel { * Get the scale. * * @return the scale - * @see #setScale(double) + * @see #setScale(double) */ public double getScale() { return (Double) getValue(Type.PreferredScale); @@ -331,11 +329,11 @@ public class DefaultTransformModel implements TransformModel { /** * Get the mirror property. - * - *

The default value is {@code false}. + *

+ * The default value is {@code false}. * * @return {@code true} if the transformation will mirror the view. - * @see #setMirror(boolean) + * @see #setMirror(boolean) */ public boolean isMirror() { return (Boolean) getValue(Type.Mirror); @@ -343,11 +341,11 @@ public class DefaultTransformModel implements TransformModel { /** * Set the mirror property. - * - *

The default value is {@code false} + *

+ * The default value is {@code false} * * @param newValue the new value - * @see #isMirror() + * @see #isMirror() */ public void setMirror(final boolean newValue) { setValue(Type.Mirror, newValue); @@ -355,11 +353,11 @@ public class DefaultTransformModel implements TransformModel { /** * Get the preserve aspect ratio value. - * - *

The default value is {@code true}. + *

+ * The default value is {@code true}. * * @return {@code true} if preserving aspect ratio, {@code false} otherwise - * @see #setPreserveAspectRatio(boolean) + * @see #setPreserveAspectRatio(boolean) */ public boolean isPreserveAspectRatio() { return (Boolean) getValue(Type.PreserveAspectRatio); @@ -367,11 +365,11 @@ public class DefaultTransformModel implements TransformModel { /** * Set preserve aspect ratio. - * - *

The default value is {@code true}. + *

+ * The default value is {@code true}. * * @param newValue the new value - * @see #isPreserveAspectRatio() + * @see #isPreserveAspectRatio() */ public void setPreserveAspectRatio(final boolean newValue) { setValue(Type.PreserveAspectRatio, newValue); @@ -379,17 +377,17 @@ public class DefaultTransformModel implements TransformModel { /** * Get the scale to preferred size value. - * - *

The default value is {@code false}. - * - *

When {@code true}, the view is scaled according to the preferred scale, regardless of the + *

+ * The default value is {@code false}. + *

+ * When {@code true}, the view is scaled according to the preferred scale, regardless of the * size of the {@link JXLayer}. - * - *

When {@code false}, the view is scaled to occupy as much as possible of the size of the + *

+ * When {@code false}, the view is scaled to occupy as much as possible of the size of the * {@link JXLayer}. * * @return {@code true} if scale to preferred size, {@code false} otherwise - * @see #setScaleToPreferredSize(boolean) + * @see #setScaleToPreferredSize(boolean) */ public boolean isScaleToPreferredSize() { return (Boolean) getValue(Type.ScaleToPreferredSize); @@ -397,17 +395,17 @@ public class DefaultTransformModel implements TransformModel { /** * Set scaleToPreferredSize. - * - *

The default value is {@code false}. - * - *

When {@code true}, the view is scaled according to the preferred scale, regardless of the + *

+ * The default value is {@code false}. + *

+ * When {@code true}, the view is scaled according to the preferred scale, regardless of the * size of the {@link JXLayer}. - * - *

When {@code false}, the view is scaled to occupy as much as possible of the size of the + *

+ * When {@code false}, the view is scaled to occupy as much as possible of the size of the * {@link JXLayer}. * * @param newValue the new value - * @see #isScaleToPreferredSize() + * @see #isScaleToPreferredSize() */ public void setScaleToPreferredSize(final boolean newValue) { setValue(Type.ScaleToPreferredSize, newValue); @@ -433,23 +431,23 @@ public class DefaultTransformModel implements TransformModel { /** * Enum for internal convenience. - * - *

Describes the values that on change trigger recalculation of the transform. All have a + *

+ * Describes the values that on change trigger recalculation of the transform. All have a * default value, used for initializing arrays. - * - *

These enums are used for two purposes: - * - *

1: To easily detect a change that requires renewed calculation of the transform(both program + *

+ * These enums are used for two purposes: + *

+ * 1: To easily detect a change that requires renewed calculation of the transform(both program * values and user options). - * - *

2: To generalize setters (both program values and user options) and getters (only + *

+ * 2: To generalize setters (both program values and user options) and getters (only * userOptions) for the various values. - * - *

There are two groups: - * - *

1: Program values that reflect the current size etc. of affected components - * - *

2: User options + *

+ * There are two groups: + *

+ * 1: Program values that reflect the current size etc. of affected components + *

+ * 2: User options */ protected enum Type { /* @@ -473,12 +471,10 @@ public class DefaultTransformModel implements TransformModel { private final Object defaultValue; - Type(final Object defaultValue) { this.defaultValue = defaultValue; } - public static Object[] createArray() { Object[] array = new Object[values().length]; for (Type type : values()) { diff --git a/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/TransformLayout.java b/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/TransformLayout.java index 763d2548..671d38b8 100644 --- a/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/TransformLayout.java +++ b/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/TransformLayout.java @@ -1,54 +1,53 @@ /* - Copyright (c) 2009, Piet Blok - All rights reserved. -

- Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: -

+ * Copyright (c) 2009, Piet Blok + * All rights reserved. + *

+ * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + *

* Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. * Neither the name of the copyright holder nor the names of the - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. -

- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + *

+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package org.pbjar.jxlayer.plaf.ext.transform; -import org.jdesktop.jxlayer.JXLayer; -import org.jdesktop.jxlayer.plaf.LayerUI; -import org.pbjar.jxlayer.plaf.ext.TransformUI; - -import javax.swing.*; import java.awt.*; import java.awt.geom.AffineTransform; import java.awt.geom.Area; import java.awt.geom.Rectangle2D; +import javax.swing.*; + +import org.jdesktop.jxlayer.JXLayer; +import org.jdesktop.jxlayer.plaf.LayerUI; +import org.pbjar.jxlayer.plaf.ext.TransformUI; + /** * A specialized layout manager for {@link JXLayer} in combination with the {@link TransformUI}. - * - *

It extends {@link DefaultLayerLayout} and, as long as no enabled {@link TransformUI} is set to + *

+ * It extends {@link DefaultLayerLayout} and, as long as no enabled {@link TransformUI} is set to * {@link JXLayer}, will act exactly the same as its super class. - * - *

However, when the above conditions are all true, its behavior becomes different: - * + *

+ * However, when the above conditions are all true, its behavior becomes different: *

    *
  1. Instead of setting the view's size to the layer's calculated inner area, it will set the * view's size to its preferred size. @@ -73,7 +72,6 @@ public class TransformLayout extends DefaultLayerLayout { * Overridden to apply a preferred transform on the {@link Dimension} object returned from the super * implementation. */ - @Override public Dimension preferredLayoutSize(final Container parent) { return transform(parent, super.preferredLayoutSize(parent)); @@ -83,7 +81,6 @@ public class TransformLayout extends DefaultLayerLayout { * Overridden to apply a preferred transform on the {@link Dimension} object returned from the super * implementation. */ - @Override public Dimension minimumLayoutSize(final Container parent) { return transform(parent, super.minimumLayoutSize(parent)); @@ -119,7 +116,6 @@ public class TransformLayout extends DefaultLayerLayout { super.layoutContainer(parent); } - @SuppressWarnings("unchecked") private Dimension transform(final Container parent, final Dimension size) { JXLayer layer = (JXLayer) parent; diff --git a/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/TransformModel.java b/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/TransformModel.java index f5dc2cf1..0068c353 100644 --- a/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/TransformModel.java +++ b/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/TransformModel.java @@ -1,43 +1,43 @@ /* - Copyright (c) 2009, Piet Blok - All rights reserved. -

    - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: -

    + * Copyright (c) 2009, Piet Blok + * All rights reserved. + *

    + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + *

    * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. * Neither the name of the copyright holder nor the names of the - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. -

    - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + *

    + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package org.pbjar.jxlayer.plaf.ext.transform; -import org.jdesktop.jxlayer.JXLayer; -import org.pbjar.jxlayer.plaf.ext.TransformUI; +import java.awt.*; +import java.awt.geom.AffineTransform; import javax.swing.*; import javax.swing.event.ChangeListener; -import java.awt.*; -import java.awt.geom.AffineTransform; + +import org.jdesktop.jxlayer.JXLayer; +import org.pbjar.jxlayer.plaf.ext.TransformUI; /** * The {@link TransformModel} interface specifies the methods the {@link TransformUI} will use to interrogate a @@ -51,39 +51,37 @@ public interface TransformModel { * Add a {@link ChangeListener} that will be notified when the internal state of this model changes. * * @param listener a {@link ChangeListener} - * @see #removeChangeListener(ChangeListener) + * @see #removeChangeListener(ChangeListener) */ void addChangeListener(ChangeListener listener); /** * Get a preferred {@link AffineTransform}. This method will typically be invoked by programs that calculate a * preferred size. - * - *

    The {@code size} argument will be used to compute anchor values for some types of + *

    + * The {@code size} argument will be used to compute anchor values for some types of * transformations. If the {@code size} argument is {@code null} a value of (0,0) is used for the anchor. * - * @param size a {@link Dimension} instance to be used for an anchor or {@code null} - * @param layer the {@link JXLayer}. - * @return a {@link AffineTransform} instance or {@code null} + * @param size a {@link Dimension} instance to be used for an anchor or {@code null} + * @param layer the {@link JXLayer}. + * @return a {@link AffineTransform} instance or {@code null} */ - AffineTransform getPreferredTransform(Dimension size, JXLayer layer); /** * Get a {@link AffineTransform}. This method will typically be invoked by programs that are about to prepare a * {@link Graphics} object. * - * @param layer the {@link JXLayer} - * @return a {@link AffineTransform} or {@code null} + * @param layer the {@link JXLayer} + * @return a {@link AffineTransform} or {@code null} */ - AffineTransform getTransform(JXLayer layer); /** * Remove a {@link ChangeListener}. * * @param listener a {@link ChangeListener} - * @see #addChangeListener(ChangeListener) + * @see #addChangeListener(ChangeListener) */ void removeChangeListener(ChangeListener listener); } diff --git a/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/TransformRPMAnnotation.java b/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/TransformRPMAnnotation.java index c06b35b1..45fd5a01 100644 --- a/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/TransformRPMAnnotation.java +++ b/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/TransformRPMAnnotation.java @@ -1,44 +1,44 @@ /* - Copyright (c) 2009, Piet Blok - All rights reserved. -

    - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: -

    + * Copyright (c) 2009, Piet Blok + * All rights reserved. + *

    + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + *

    * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. * Neither the name of the copyright holder nor the names of the - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. -

    - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + *

    + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package org.pbjar.jxlayer.plaf.ext.transform; -import org.pbjar.jxlayer.plaf.ext.TransformUI; - -import javax.swing.*; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import javax.swing.*; + +import org.pbjar.jxlayer.plaf.ext.TransformUI; + /** * A marker for an adequate {@link RepaintManager} for the {@link TransformUI}. * @@ -46,5 +46,4 @@ import java.lang.annotation.Target; */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) -public @interface TransformRPMAnnotation { -} +public @interface TransformRPMAnnotation {} diff --git a/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/TransformRPMFallBack.java b/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/TransformRPMFallBack.java index c6f39873..1f7a72b4 100644 --- a/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/TransformRPMFallBack.java +++ b/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/TransformRPMFallBack.java @@ -1,48 +1,47 @@ /* - Copyright (c) 2008-2009, Piet Blok - All rights reserved. -

    - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: -

    + * Copyright (c) 2008-2009, Piet Blok + * All rights reserved. + *

    + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + *

    * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. * Neither the name of the copyright holder nor the names of the - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. -

    - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + *

    + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package org.pbjar.jxlayer.plaf.ext.transform; +import javax.swing.*; + import org.jdesktop.swingx.ForwardingRepaintManager; import org.pbjar.jxlayer.repaint.RepaintManagerProvider; import org.pbjar.jxlayer.repaint.RepaintManagerUtils; import org.pbjar.jxlayer.repaint.WrappedRepaintManager; -import javax.swing.*; - /** * A specialized {@link RepaintManager} that checks for every JComponent that is being set dirty, if it has a JXLayer * ancestor, equipped with a TransformUI. In that case, the transformed region on the JXLayer is also marked dirty. - * - *

    A fall back class if the {@link ForwardingRepaintManager} cannot be instantiated because the + *

    + * A fall back class if the {@link ForwardingRepaintManager} cannot be instantiated because the * SwingX packages are not on the class path. * * @see RepaintManagerProvider diff --git a/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/TransformRPMImpl.java b/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/TransformRPMImpl.java index 1f62811f..86943c7c 100644 --- a/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/TransformRPMImpl.java +++ b/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/TransformRPMImpl.java @@ -1,42 +1,35 @@ /* - Copyright (c) 2009, Piet Blok - All rights reserved. -

    - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: -

    - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of the copyright holder nor the names of the - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. -

    - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * Copyright (c) 2009, Piet Blok + * All rights reserved. + *

    + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + *

    + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * Neither the name of the copyright holder nor the names of the + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + *

    + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - package org.pbjar.jxlayer.plaf.ext.transform; -import com.github.weisj.darklaf.log.LogFormatter; -import org.jdesktop.jxlayer.JXLayer; -import org.jdesktop.jxlayer.plaf.LayerUI; -import org.pbjar.jxlayer.plaf.ext.TransformUI; - -import javax.swing.*; import java.awt.*; import java.lang.reflect.Field; import java.lang.reflect.Method; @@ -44,6 +37,14 @@ import java.util.logging.ConsoleHandler; import java.util.logging.Level; import java.util.logging.Logger; +import javax.swing.*; + +import org.jdesktop.jxlayer.JXLayer; +import org.jdesktop.jxlayer.plaf.LayerUI; +import org.pbjar.jxlayer.plaf.ext.TransformUI; + +import com.github.weisj.darklaf.log.LogFormatter; + /** * To avoid duplicate code, this class implements the actual logic for {@link TransformRPMSwingX} and {@link * TransformRPMFallBack}. @@ -68,8 +69,7 @@ public final class TransformRPMImpl { LOGGER.addHandler(handler); } - private TransformRPMImpl() { - } + private TransformRPMImpl() {} /** * Searches upwards in the component hierarchy for a {@link JXLayer} ancestor with an enabled {@link TransformUI}. @@ -82,14 +82,15 @@ public final class TransformRPMImpl { * Else, (@code false} is returned. *

    * - * @param aComponent a component - * @param x the X of the dirty region - * @param y the Y of the dirty region - * @param w the width of the dirty region - * @param h the height of the dirty region - * @param manager the current {@link RepaintManager} - * @return {@code true} if the call is delegated to the manager with a transformed rectangle, {@code false} - * otherwise + * @param aComponent a component + * @param x the X of the dirty region + * @param y the Y of the dirty region + * @param w the width of the dirty region + * @param h the height of the dirty region + * @param manager the current {@link RepaintManager} + * @return {@code true} if the call is delegated to the manager with a transformed rectangle, + * {@code false} + * otherwise */ @SuppressWarnings("unchecked") public static boolean addDirtyRegion(final JComponent aComponent, final int x, final int y, @@ -145,22 +146,22 @@ public final class TransformRPMImpl { LOGGER.warning("Copied paintManager of type: " + paintManager.getClass().getName()); switch (bufferStrategyType) { - case (0): + case (0) : LOGGER.warning("Copied bufferStrategyType " + bufferStrategyType + ": BUFFER_STRATEGY_NOT_SPECIFIED"); break; - case (1): + case (1) : LOGGER.warning("Copied bufferStrategyType " + bufferStrategyType + ": BUFFER_STRATEGY_SPECIFIED_ON"); break; - case (2): + case (2) : LOGGER.warning("Copied bufferStrategyType " + bufferStrategyType + ": BUFFER_STRATEGY_SPECIFIED_OFF"); break; - default: + default : LOGGER.warning("Copied bufferStrategyType " + bufferStrategyType + ": ???"); break; @@ -174,14 +175,12 @@ public final class TransformRPMImpl { /** * Find the first ancestor {@link JXLayer} with an enabled {@link TransformUI}. * - * @param aComponent some component - * @return a {@link JXLayer} instance or {@code null} + * @param aComponent some component + * @return a {@link JXLayer} instance or {@code null} */ - private static JXLayer findJXLayer(final JComponent aComponent) { - JXLayer layer = (JXLayer) SwingUtilities.getAncestorOfClass( - JXLayer.class, aComponent); + JXLayer layer = (JXLayer) SwingUtilities.getAncestorOfClass(JXLayer.class, aComponent); if (layer != null) { LayerUI ui = ((JXLayer) layer).getUI(); if (ui instanceof TransformUI) { diff --git a/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/TransformRPMSwingX.java b/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/TransformRPMSwingX.java index 8bbb4865..5804a2a2 100644 --- a/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/TransformRPMSwingX.java +++ b/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/TransformRPMSwingX.java @@ -1,53 +1,52 @@ /* - Copyright (c) 2009, Piet Blok - All rights reserved. -

    - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: -

    + * Copyright (c) 2009, Piet Blok + * All rights reserved. + *

    + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + *

    * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. * Neither the name of the copyright holder nor the names of the - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. -

    - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + *

    + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package org.pbjar.jxlayer.plaf.ext.transform; +import javax.swing.*; + import org.jdesktop.swingx.ForwardingRepaintManager; import org.pbjar.jxlayer.repaint.RepaintManagerProvider; import org.pbjar.jxlayer.repaint.RepaintManagerUtils; -import javax.swing.*; - /** * A specialized {@link RepaintManager} that checks for every JComponent that is being set dirty, if it has a JXLayer * ancestor, equipped with a TransformUI. In that case, the transformed region on the JXLayer is also marked dirty. - * - *

    If this class cannot be instantiated because the SwingX packages are not on the class path, + *

    + * If this class cannot be instantiated because the SwingX packages are not on the class path, * use {@link TransformRPMFallBack} * * @author Piet Blok - * @see TransformRPMFallBack - * @see RepaintManagerProvider - * @see RepaintManagerUtils + * @see TransformRPMFallBack + * @see RepaintManagerProvider + * @see RepaintManagerUtils */ @TransformRPMAnnotation public class TransformRPMSwingX extends ForwardingRepaintManager { diff --git a/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/TransformUtils.java b/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/TransformUtils.java index 03e46ba0..3fbb9641 100644 --- a/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/TransformUtils.java +++ b/core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/TransformUtils.java @@ -1,34 +1,33 @@ /* - Copyright (c) 2009, Piet Blok - All rights reserved. -

    - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: -

    + * Copyright (c) 2009, Piet Blok + * All rights reserved. + *

    + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + *

    * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. * Neither the name of the copyright holder nor the names of the - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. -

    - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + *

    + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package org.pbjar.jxlayer.plaf.ext.transform; import org.jdesktop.jxlayer.JXLayer; @@ -45,17 +44,14 @@ import java.util.Map; */ public final class TransformUtils { - - private TransformUtils() { - } + private TransformUtils() {} /** * Create a Transform JXLayer. * - * @param component the component. - * @return the JXLayer. + * @param component the component. + * @return the JXLayer. */ - public static JXLayer createTransformJXLayer(final JComponent component) { return createTransformJXLayer(component, 1.0, null); } @@ -63,14 +59,13 @@ public final class TransformUtils { /** * Create a Transform JXLayer. * - * @param component the component. - * @param scale the scaling - * @param hints the rendering hints. - * @return the JXLayer. + * @param component the component. + * @param scale the scaling + * @param hints the rendering hints. + * @return the JXLayer. */ - - public static JXLayer createTransformJXLayer( - final JComponent component, final double scale, final Map hints) { + public static JXLayer createTransformJXLayer(final JComponent component, final double scale, + final Map hints) { DefaultTransformModel model = new DefaultTransformModel(); model.setScale(scale); return createTransformJXLayer(component, model, hints); @@ -79,15 +74,13 @@ public final class TransformUtils { /** * Create a Transform JXLayer. * - * @param component the component. - * @param model the transform model. - * @param hints the rendering hints. - * @return the JXLayer. + * @param component the component. + * @param model the transform model. + * @param hints the rendering hints. + * @return the JXLayer. */ - - - public static JXLayer createTransformJXLayer( - final JComponent component, final TransformModel model, final Map hints) { + public static JXLayer createTransformJXLayer(final JComponent component, final TransformModel model, + final Map hints) { TransformUI ui = new TransformUI(model); ui.setRenderingHints(hints); return new JXLayer<>(component, ui); @@ -96,11 +89,10 @@ public final class TransformUtils { /** * Create a Transform JXLayer. * - * @param component the component. - * @param scale the scaling - * @return the JXLayer. + * @param component the component. + * @param scale the scaling + * @return the JXLayer. */ - public static JXLayer createTransformJXLayer(final JComponent component, final double scale) { return createTransformJXLayer(component, scale, null); } @@ -108,13 +100,11 @@ public final class TransformUtils { /** * Create a Transform JXLayer. * - * @param component the component. - * @param model the transform model. - * @return the JXLayer. + * @param component the component. + * @param model the transform model. + * @return the JXLayer. */ - - public static JXLayer createTransformJXLayer( - final JComponent component, final TransformModel model) { + public static JXLayer createTransformJXLayer(final JComponent component, final TransformModel model) { return createTransformJXLayer(component, model, null); } } diff --git a/core/src/main/java/org/pbjar/jxlayer/repaint/RepaintManagerProvider.java b/core/src/main/java/org/pbjar/jxlayer/repaint/RepaintManagerProvider.java index bf44c99c..34feb752 100644 --- a/core/src/main/java/org/pbjar/jxlayer/repaint/RepaintManagerProvider.java +++ b/core/src/main/java/org/pbjar/jxlayer/repaint/RepaintManagerProvider.java @@ -1,74 +1,71 @@ /* - Copyright (c) 2009, Piet Blok - All rights reserved. -

    - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: -

    + * Copyright (c) 2009, Piet Blok + * All rights reserved. + *

    + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + *

    * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. * Neither the name of the copyright holder nor the names of the - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. -

    - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + *

    + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package org.pbjar.jxlayer.repaint; -import org.jdesktop.swingx.ForwardingRepaintManager; - import javax.swing.*; +import org.jdesktop.swingx.ForwardingRepaintManager; + /** * To be implemented by classes that provide for a custom RepaintManager. * * @author Piet Blok - * @see RepaintManagerUtils + * @see RepaintManagerUtils */ public interface RepaintManagerProvider { /** * Get the class of a {@link RepaintManager} that extends {@link ForwardingRepaintManager}. - * - *

    Note: the class must provide for a public constructor that takes a delegate {@link + *

    + * Note: the class must provide for a public constructor that takes a delegate {@link * RepaintManager} as its only argument. * * @return a class object */ - Class getForwardingRepaintManagerClass(); /** * Get the class of a {@link RepaintManager} that extends {@link WrappedRepaintManager}. - * - *

    Note: the class must provide for a public constructor that takes a delegate {@link + *

    + * Note: the class must provide for a public constructor that takes a delegate {@link * RepaintManager} as its only argument. * * @return a class object */ - Class getWrappedRepaintManagerClass(); /** * Checks whether or not the argument class is a {@link RepaintManager} class that will do the required job. * - * @param rpm a {@link RepaintManager} class - * @return {@code true} if the argument class will do the required job, {@code false} otherwise + * @param rpm a {@link RepaintManager} class + * @return {@code true} if the argument class will do the required job, {@code false} otherwise */ boolean isAdequate(Class rpm); } diff --git a/core/src/main/java/org/pbjar/jxlayer/repaint/RepaintManagerUtils.java b/core/src/main/java/org/pbjar/jxlayer/repaint/RepaintManagerUtils.java index 0c45ecb4..4acaf498 100644 --- a/core/src/main/java/org/pbjar/jxlayer/repaint/RepaintManagerUtils.java +++ b/core/src/main/java/org/pbjar/jxlayer/repaint/RepaintManagerUtils.java @@ -1,40 +1,35 @@ /* - Copyright (c) 2009, Piet Blok - All rights reserved. -

    - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: -

    + * Copyright (c) 2009, Piet Blok + * All rights reserved. + *

    + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + *

    * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. * Neither the name of the copyright holder nor the names of the - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. -

    - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + *

    + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package org.pbjar.jxlayer.repaint; -import com.github.weisj.darklaf.log.LogFormatter; -import org.jdesktop.swingx.ForwardingRepaintManager; - -import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.io.PrintWriter; @@ -42,6 +37,12 @@ import java.io.StringWriter; import java.util.logging.ConsoleHandler; import java.util.logging.Logger; +import javax.swing.*; + +import org.jdesktop.swingx.ForwardingRepaintManager; + +import com.github.weisj.darklaf.log.LogFormatter; + /** * Utility class that ensures that a correct {@link RepaintManager} is set. * @@ -62,9 +63,7 @@ public final class RepaintManagerUtils { LOGGER.addHandler(handler); } - - private RepaintManagerUtils() { - } + private RepaintManagerUtils() {} /** * Create and return an {@link Action} that will display the delegate structure of the current {@link @@ -72,8 +71,6 @@ public final class RepaintManagerUtils { * * @return an {@link Action} object */ - - public static Action createRPDisplayAction() { return new DisplayAction(); } @@ -85,8 +82,7 @@ public final class RepaintManagerUtils { * @param c a component from which the current repaint manager can be obtained. * @param provider the provider */ - public static void ensureRepaintManagerSet( - final Component c, final RepaintManagerProvider provider) { + public static void ensureRepaintManagerSet(final Component c, final RepaintManagerProvider provider) { ensureImpl(RepaintManager.currentManager(c), provider); } @@ -96,8 +92,7 @@ public final class RepaintManagerUtils { * @param delegate a delegate RepaintManager * @param provider the provider that provides for the type and implementation of a delegated RepaintManager */ - private static void ensureImpl( - final RepaintManager delegate, final RepaintManagerProvider provider) { + private static void ensureImpl(final RepaintManager delegate, final RepaintManagerProvider provider) { /* * Setup a traversal variable. */ @@ -108,25 +103,23 @@ public final class RepaintManagerUtils { if (manager instanceof ForwardingRepaintManager) { manager = ((ForwardingRepaintManager) manager).getDelegateManager(); } else { - RepaintManager.setCurrentManager( - createManager(provider.getForwardingRepaintManagerClass(), delegate)); + RepaintManager.setCurrentManager(createManager(provider.getForwardingRepaintManagerClass(), + delegate)); break; } } else { if (manager instanceof WrappedRepaintManager) { manager = ((WrappedRepaintManager) manager).getDelegateManager(); } else { - RepaintManager.setCurrentManager( - createManager(provider.getWrappedRepaintManagerClass(), delegate)); + RepaintManager.setCurrentManager(createManager(provider.getWrappedRepaintManagerClass(), delegate)); break; } } } } - - private static RepaintManager createManager( - final Class clazz, final RepaintManager delegate) { + private static RepaintManager createManager(final Class clazz, + final RepaintManager delegate) { try { return clazz.getConstructor(RepaintManager.class).newInstance(delegate); } catch (Throwable t) { @@ -141,8 +134,7 @@ public final class RepaintManagerUtils { * @param c a component from which the current repaint manager can be obtained. * @param provider the provider */ - public static void ensureRepaintManagerSet( - final JComponent c, final RepaintManagerProvider provider) { + public static void ensureRepaintManagerSet(final JComponent c, final RepaintManagerProvider provider) { ensureImpl(RepaintManager.currentManager(c), provider); } @@ -186,8 +178,7 @@ public final class RepaintManagerUtils { message.setContentType("text/plain"); message.setText(text); message.setEditable(false); - JOptionPane.showMessageDialog( - c, message, "The RepaintManager tree", JOptionPane.INFORMATION_MESSAGE); + JOptionPane.showMessageDialog(c, message, "The RepaintManager tree", JOptionPane.INFORMATION_MESSAGE); } private void appendClass(final PrintWriter writer, final Object obj) { diff --git a/core/src/main/java/org/pbjar/jxlayer/repaint/WrappedRepaintManager.java b/core/src/main/java/org/pbjar/jxlayer/repaint/WrappedRepaintManager.java index 0befb691..ad18df9e 100644 --- a/core/src/main/java/org/pbjar/jxlayer/repaint/WrappedRepaintManager.java +++ b/core/src/main/java/org/pbjar/jxlayer/repaint/WrappedRepaintManager.java @@ -1,62 +1,61 @@ /* - Copyright (c) 2009, Piet Blok - All rights reserved. -

    - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: -

    + * Copyright (c) 2009, Piet Blok + * All rights reserved. + *

    + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + *

    * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. * Neither the name of the copyright holder nor the names of the - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. -

    - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + *

    + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package org.pbjar.jxlayer.repaint; -import org.jdesktop.swingx.ForwardingRepaintManager; - -import javax.swing.*; import java.applet.Applet; import java.awt.*; +import javax.swing.*; + +import org.jdesktop.swingx.ForwardingRepaintManager; + /** * A fall back class for when the SwingX class {@link ForwardingRepaintManager} is not available on the class path. - * - *

    A {@link RepaintManager} that preserves functionality of a wrapped {@code RepaintManager}. All + *

    + * A {@link RepaintManager} that preserves functionality of a wrapped {@code RepaintManager}. All * methods will delegate to the wrapped {@code RepaintManager}. - * - *

    When sub classing this class, one must in all overridden methods call the {@code super} + *

    + * When sub classing this class, one must in all overridden methods call the {@code super} * method. * * @author Piet Blok - * @see RepaintManagerUtils - * @see RepaintManagerProvider - * @see ForwardingRepaintManager + * @see RepaintManagerUtils + * @see RepaintManagerProvider + * @see ForwardingRepaintManager */ public class WrappedRepaintManager extends RepaintManager { /** * The wrapped manager. */ - private final RepaintManager delegate; /** @@ -64,7 +63,6 @@ public class WrappedRepaintManager extends RepaintManager { * * @param delegate an existing RepaintManager */ - public WrappedRepaintManager(final RepaintManager delegate) { if (delegate == null) { throw new NullPointerException(); @@ -159,7 +157,6 @@ public class WrappedRepaintManager extends RepaintManager { * * @return the delegate */ - public RepaintManager getDelegateManager() { return delegate; } @@ -212,7 +209,6 @@ public class WrappedRepaintManager extends RepaintManager { return delegate.isDoubleBufferingEnabled(); } - /** * Just delegates. {@inheritDoc} */ @@ -220,6 +216,4 @@ public class WrappedRepaintManager extends RepaintManager { public void setDoubleBufferingEnabled(final boolean flag) { delegate.setDoubleBufferingEnabled(flag); } - - } diff --git a/core/src/main/resources/com/github/weisj/darklaf/icons/dark/info.md b/core/src/main/resources/com/github/weisj/darklaf/icons/dark/info.md index 9edacfed..aadc8916 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/icons/dark/info.md +++ b/core/src/main/resources/com/github/weisj/darklaf/icons/dark/info.md @@ -1 +1 @@ -Theme aware icons will looks from this sub directory for the dark version of the icon. \ No newline at end of file +Theme aware icons will looks from this sub directory for the dark version of the icon. diff --git a/core/src/main/resources/com/github/weisj/darklaf/icons/light/info.md b/core/src/main/resources/com/github/weisj/darklaf/icons/light/info.md index 5d7fd222..43ee49ed 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/icons/light/info.md +++ b/core/src/main/resources/com/github/weisj/darklaf/icons/light/info.md @@ -1 +1 @@ -Theme aware icons will looks from this sub directory for the light version of the icon. \ No newline at end of file +Theme aware icons will looks from this sub directory for the light version of the icon. diff --git a/core/src/main/resources/com/github/weisj/darklaf/log/logging.properties b/core/src/main/resources/com/github/weisj/darklaf/log/logging.properties index 6c65e6e5..5e9ca84e 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/log/logging.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/log/logging.properties @@ -21,10 +21,11 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# handlers = java.util.logging.ConsoleHandler .level = ALL java.util.logging.ConsoleHandler.level = INFO java.util.logging.ConsoleHandler.formatter = com.github.weisj.darklaf.log.LogFormatter -com.github.weisj.darklaf.level = INFO \ No newline at end of file +com.github.weisj.darklaf.level = INFO diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/font.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/font.properties index bf30ef9b..10561a48 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/font.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/font.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# Button.font = withSize(%fontSize.default)withStyle(0) CheckBox.font = withSize(%fontSize.default)withStyle(0) CheckBoxMenuItem.font = withSize(%fontSize.default)withStyle(0) diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/font_sizes.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/font_sizes.properties index a3cfbe23..65fac13a 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/font_sizes.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/font_sizes.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,5 +21,5 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # -# The default font size to use. (in points) +# fontSize.default = 12 diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/globals.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/globals.properties index a1fdef50..17dd81e9 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/globals.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/globals.properties @@ -1,27 +1,27 @@ -#MIT License # -#Copyright (c) 2020 Jannis Weis +# MIT License # -#Permission is hereby granted, free of charge, to any person obtaining a copy -#of this software and associated documentation files (the "Software"), to deal -#in the Software without restriction, including without limitation the rights -#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -#copies of the Software, and to permit persons to whom the Software is -#furnished to do so, subject to the following conditions: +# Copyright (c) 2020 Jannis Weis # -#The above copyright notice and this permission notice shall be included in all -#copies or substantial portions of the Software. +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. # -#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -#SOFTWARE. # -# suppress inspection "UnusedProperty" for whole file -###Global#### global.background = %background global.inactiveBackground = %background global.selectionInactiveBackground = %highlightFill diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/icons/checkBox.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/icons/checkBox.properties index f56ca0e8..e3cdf0ff 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/icons/checkBox.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/icons/checkBox.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# Icons.CheckBox.activeFillColor = %CheckBox.activeFillColor Icons.CheckBox.activeBorderColor = %CheckBox.activeBorderColor diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/icons/dialog.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/icons/dialog.properties index 6a261d59..2e481c41 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/icons/dialog.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/icons/dialog.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,7 +21,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# Icons.errorDialog.color = %errorIconColor Icons.informationDialog.color = %informationIconColor Icons.questionDialog.color = %questionIconColor -Icons.warningDialog.color = %warningIconColor \ No newline at end of file +Icons.warningDialog.color = %warningIconColor diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/icons/files.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/icons/files.properties index 7b3c1021..8176b7cc 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/icons/files.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/icons/files.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# Icons.desktop.color = %menuIconEnabled Icons.drive.color = %fileIconBackground diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/icons/frame.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/icons/frame.properties index 9ba567d2..f8f55f71 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/icons/frame.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/icons/frame.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# Icons.windowClose.color = %windowButton Icons.windowCloseHover.color = %windowCloseHovered Icons.windowCloseInactive.color = %windowButtonDisabled @@ -38,4 +38,4 @@ Icons.windowMinimizeInactive.color = %windowButtonDisabled Icons.windowRestore.color = %windowButton Icons.windowRestoreInactive.color = %windowButtonDisabled -Icons.frame.color = %menuIconEnabled \ No newline at end of file +Icons.frame.color = %menuIconEnabled diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/icons/indicator.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/icons/indicator.properties index 2319b814..dd90900f 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/icons/indicator.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/icons/indicator.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# Icons.speaker0.color = %menuIconEnabled Icons.speaker0.crossColor = %menuIconEnabled Icons.speaker0Disabled.color = %menuIconDisabled @@ -45,4 +45,4 @@ Icons.speaker3Disabled.volumeColor = %menuIconDisabled Icons.speaker4.color = %menuIconEnabled Icons.speaker4.volumeColor = %menuIconEnabled Icons.speaker4Disabled.color = %menuIconDisabled -Icons.speaker4Disabled.volumeColor = %menuIconDisabled \ No newline at end of file +Icons.speaker4Disabled.volumeColor = %menuIconDisabled diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/icons/menu.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/icons/menu.properties index 50ae418b..6600db92 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/icons/menu.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/icons/menu.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# Icons.copy.color = %menuIconEnabled Icons.cut.color = %menuIconEnabled Icons.delete.color = %menuIconEnabled diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/icons/misc.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/icons/misc.properties index 8d437628..07c53733 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/icons/misc.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/icons/misc.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# Icons.minus.color = %menuIconEnabled Icons.minusSelected.color = %menuIconSelected Icons.pipette.color = %menuIconEnabled @@ -29,4 +29,4 @@ Icons.pipetteRollover.color = %errorIconColor Icons.plus.color = %menuIconEnabled Icons.plusSelected.color = %menuIconSelected Icons.eye.color = %menuIconEnabled -Icons.eyeHovered.color = %menuIconDisabled \ No newline at end of file +Icons.eyeHovered.color = %menuIconDisabled diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/icons/navigation.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/icons/navigation.properties index a7f1215e..c90e5afa 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/icons/navigation.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/icons/navigation.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# Icons.add.color = %menuIconEnabled Icons.arrowDivider.color = %menuIconEnabled Icons.arrowDivider.opacity = %menuIconOpacity diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/icons/radioButton.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/icons/radioButton.properties index 4d06495a..53132c4a 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/icons/radioButton.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/icons/radioButton.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# Icons.RadioButton.activeFillColor = %RadioButton.activeFillColor Icons.RadioButton.activeBorderColor = %RadioButton.activeBorderColor diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/overwrites.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/overwrites.properties index c92e1a44..d16e69b4 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/overwrites.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/overwrites.properties @@ -21,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# SplitPane.defaultDividerStyle = spDividerStyle Table.renderBooleanAsCheckBox = tableBooleanRenderer Tree.renderBooleanAsCheckBox = treeBooleanRenderer diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/platform/linux.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/platform/linux.properties index 8902c201..f9d92a3b 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/platform/linux.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/platform/linux.properties @@ -1,20 +1,28 @@ # -# Copyright 2000-2014 JetBrains s.r.o. +# MIT License # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright (c) 2020 Jannis Weis # -# http://www.apache.org/licenses/LICENSE-2.0 +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. # -# suppress inspection "UnusedProperty" for whole file FileChooser.listViewWindowsStyle = false Table.alternateRowColor = false Tree.alternateRowColor = false -List.alternateRowColor = false \ No newline at end of file +List.alternateRowColor = false diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/platform/mac.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/platform/mac.properties index 60cc6f8a..73bb04c8 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/platform/mac.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/platform/mac.properties @@ -1,19 +1,27 @@ # -# Copyright 2000-2014 JetBrains s.r.o. +# MIT License # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright (c) 2020 Jannis Weis # -# http://www.apache.org/licenses/LICENSE-2.0 +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. # -# suppress inspection "UnusedProperty" for whole file Table.alternateRowColor = true Tree.alternateRowColor = true List.alternateRowColor = true diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/platform/windows.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/platform/windows.properties index 7e6c771f..4b495a19 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/platform/windows.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/platform/windows.properties @@ -1,26 +1,27 @@ -#MIT License # -#Copyright (c) 2020 Jannis Weis +# MIT License # -#Permission is hereby granted, free of charge, to any person obtaining a copy -#of this software and associated documentation files (the "Software"), to deal -#in the Software without restriction, including without limitation the rights -#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -#copies of the Software, and to permit persons to whom the Software is -#furnished to do so, subject to the following conditions: +# Copyright (c) 2020 Jannis Weis # -#The above copyright notice and this permission notice shall be included in all -#copies or substantial portions of the Software. +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. # -#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -#SOFTWARE. # -# suppress inspection "UnusedProperty" for whole file FileChooser.listViewWindowsStyle = true Table.alternateRowColor = false diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/borders.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/borders.properties index 02110f12..1a5af90c 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/borders.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/borders.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# TitledBorder.titleColor = %textForeground TitledBorder.border = com.github.weisj.darklaf.ui.titledborder.DarkTitledBorder TitledBorder.borderColor = %borderSecondary diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/button.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/button.properties index 452b1bc1..dfa73328 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/button.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/button.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# ButtonUI = com.github.weisj.darklaf.ui.button.DarkButtonUI Button.border = com.github.weisj.darklaf.ui.button.DarkButtonBorder Button.disabledText = %textForegroundInactive diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/checkBox.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/checkBox.properties index fbd263c3..350755fd 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/checkBox.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/checkBox.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# CheckBoxUI = com.github.weisj.darklaf.ui.togglebutton.checkbox.DarkCheckBoxUI CheckBox.border = com.github.weisj.darklaf.ui.togglebutton.checkbox.DarkCheckBoxBorder CheckBox.activeFillColor = %widgetFill diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/colorChooser.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/colorChooser.properties index 9a768b89..24fd6068 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/colorChooser.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/colorChooser.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# ColorChooserUI = com.github.weisj.darklaf.ui.colorchooser.DarkColorChooserUI ColorChooser.pipetteEnabled = true ColorChooser.previewBorderColor = %widgetBorder diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/comboBox.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/comboBox.properties index aa5af147..7ce8d12b 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/comboBox.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/comboBox.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# ComboBoxUI = com.github.weisj.darklaf.ui.combobox.DarkComboBoxUI ComboBox.squareButton = false ComboBox.background = %backgroundContainer diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/fileChooser.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/fileChooser.properties index c81e62e8..7348f773 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/fileChooser.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/fileChooser.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# FileChooserUI = com.github.weisj.darklaf.ui.filechooser.DarkFileChooserUI FileChooser.newFolderIcon = files/newFolder.svg[themed] FileChooser.upFolderIcon = files/upFolder.svg[themed] diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/internalFrame.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/internalFrame.properties index 69531ec6..3461bac6 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/internalFrame.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/internalFrame.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# InternalFrameUI = com.github.weisj.darklaf.ui.internalframe.DarkInternalFrameUI InternalFrame.border = com.github.weisj.darklaf.ui.internalframe.DarkInternalFrameBorder InternalFrame.optionDialogBorder = com.github.weisj.darklaf.ui.internalframe.DarkInternalFrameBorder diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/label.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/label.properties index 13a68234..c5b75736 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/label.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/label.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# LabelUI = com.github.weisj.darklaf.ui.label.DarkLabelUI Label.inactiveForeground = %textForegroundInactive Label.cellForegroundNoFocus = %textSelectionForegroundInactive diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/list.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/list.properties index d1f81ef1..77ee4877 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/list.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/list.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# ListUI = com.github.weisj.darklaf.ui.list.DarkListUI List.border = null List.background = %backgroundContainer diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/menu.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/menu.properties index 6191b740..96556c32 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/menu.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/menu.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# MenuUI = com.github.weisj.darklaf.ui.menu.DarkMenuUI Menu.maxGutterIconWidth = 18 Menu.border = com.github.weisj.darklaf.ui.menu.DarkMenuItemBorder diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/menuBar.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/menuBar.properties index 2a2ebfab..aa0a89b4 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/menuBar.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/menuBar.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,9 +21,10 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# MenuBarUI = com.github.weisj.darklaf.ui.menu.DarkMenuBarUI MenuBar.disabledBackground = %background MenuBar.border = com.github.weisj.darklaf.ui.menu.DarkMenuBarBorder MenuBar.borderColor = %borderSecondary MenuBar.highlight = %background -MenuBar.background = %background \ No newline at end of file +MenuBar.background = %background diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/menuItem.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/menuItem.properties index 9c04076e..2aa0c9bb 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/menuItem.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/menuItem.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# MenuItemUI = com.github.weisj.darklaf.ui.menu.DarkMenuItemUIBase MenuItem.border = com.github.weisj.darklaf.ui.menu.DarkMenuItemBorder diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/misc.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/misc.properties index b3ab8f3c..dc99c02f 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/misc.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/misc.properties @@ -21,4 +21,5 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# ThemeSettings.icon = menu/settings.svg[themed] diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/numberingPane.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/numberingPane.properties index 526d1d22..e629fa0b 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/numberingPane.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/numberingPane.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# NumberingPaneUI = com.github.weisj.darklaf.ui.numberingpane.DarkNumberingPaneUI NumberingPane.border = com.github.weisj.darklaf.ui.numberingpane.DarkNumberingPaneBorder NumberingPane.borderColor = %borderSecondary @@ -29,4 +29,4 @@ NumberingPane.foreground = %textForegroundSecondary NumberingPane.background = %textBackgroundSecondaryInactive NumberingPane.textBackground = %textBackgroundSecondary NumberingPane.currentLineForeground = %textForeground -NumberingPane.currentLineBackground = %textSelectionBackgroundSecondary \ No newline at end of file +NumberingPane.currentLineBackground = %textSelectionBackgroundSecondary diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/optionPane.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/optionPane.properties index 9ba90a7c..b34bc421 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/optionPane.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/optionPane.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# OptionPaneUI = com.github.weisj.darklaf.ui.optionpane.DarkOptionPaneUI OptionPane.border = com.github.weisj.darklaf.ui.optionpane.DarkOptionPaneBorder OptionPane.messageForeground = %textForeground diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/panel.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/panel.properties index 40f22a4e..5116eb2a 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/panel.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/panel.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# PanelUI = com.github.weisj.darklaf.ui.panel.DarkPanelUI Panel.foreground = %textForeground Panel.background = %background diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/popupMenu.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/popupMenu.properties index 4f65d431..94da548c 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/popupMenu.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/popupMenu.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# PopupMenuUI = com.github.weisj.darklaf.ui.popupmenu.DarkPopupMenuUI PopupMenu.border = com.github.weisj.darklaf.ui.popupmenu.DarkPopupMenuBorder PopupMenu.translucentBackground = %backgroundContainer diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/progressBar.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/progressBar.properties index 407b8909..b945e1ee 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/progressBar.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/progressBar.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# ProgressBarUI = com.github.weisj.darklaf.ui.progressbar.DarkProgressBarUI ProgressBar.border = com.github.weisj.darklaf.ui.progressbar.DarkProgressBarBorder ProgressBar.foreground = %textForeground diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/radioButton.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/radioButton.properties index 4458eac8..151e109d 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/radioButton.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/radioButton.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# RadioButtonUI = com.github.weisj.darklaf.ui.togglebutton.radiobutton.DarkRadioButtonUI RadioButton.border = com.github.weisj.darklaf.ui.togglebutton.radiobutton.DarkRadioButtonBorder RadioButton.selectionSelectedColor = %controlFill diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/rootPane.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/rootPane.properties index 8f3d28a4..599975c5 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/rootPane.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/rootPane.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# RootPaneUI = com.github.weisj.darklaf.ui.rootpane.DarkRootPaneUI RootPane.borderInsets = 0,0,0,0 @@ -35,4 +35,3 @@ RootPane.colorChooserDialogBorder = com.github.weisj.darklaf.ui.rootpane.DarkRoo RootPane.fileChooserDialogBorder = com.github.weisj.darklaf.ui.rootpane.DarkRootPaneBorder RootPane.questionDialogBorder = com.github.weisj.darklaf.ui.rootpane.DarkRootPaneBorder RootPane.errorDialogBorder = com.github.weisj.darklaf.ui.rootpane.DarkRootPaneBorder - diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/scrollBar.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/scrollBar.properties index 7ac49b02..166ab683 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/scrollBar.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/scrollBar.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# ScrollBarUI = com.github.weisj.darklaf.ui.scrollpane.DarkScrollBarUI ScrollBar.fadeStartColor = %controlFadeStart ScrollBar.fadeEndColor = %controlFadeEnd diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/scrollPane.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/scrollPane.properties index b8ec63bf..fc8340bd 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/scrollPane.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/scrollPane.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# ScrollPaneUI = com.github.weisj.darklaf.ui.scrollpane.DarkScrollPaneUI ScrollPane.barInsets = 0,0,0,0 ScrollPane.border = null diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/separator.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/separator.properties index 1f597381..d09fdf86 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/separator.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/separator.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# SeparatorUI = com.github.weisj.darklaf.ui.separator.DarkSeparatorUI PopupMenuSeparatorUI = com.github.weisj.darklaf.ui.popupmenu.DarkPopupMenuSeparatorUI Separator.foreground = %borderSecondary diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/slider.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/slider.properties index fa693b88..389cf1c7 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/slider.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/slider.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# SliderUI = com.github.weisj.darklaf.ui.slider.DarkSliderUI Slider.tickColor = %textForegroundSecondary Slider.disabledTickColor = %textForegroundInactive diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/spinner.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/spinner.properties index 58ac9b51..abefac43 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/spinner.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/spinner.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# SpinnerUI = com.github.weisj.darklaf.ui.spinner.DarkSpinnerUI Spinner.border = com.github.weisj.darklaf.ui.spinner.DarkSpinnerBorder Spinner.activeBorderColor = %widgetBorder diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/splitPane.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/splitPane.properties index 53520c53..6f8215b7 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/splitPane.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/splitPane.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# SplitPaneUI = com.github.weisj.darklaf.ui.splitpane.DarkSplitPaneUI SplitPane.border = com.github.weisj.darklaf.ui.splitpane.DarkSplitPaneBorder SplitPaneDivider.border = com.github.weisj.darklaf.ui.splitpane.DarkSplitPaneDividerBorder diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/statusBar.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/statusBar.properties index 9502e6d9..791fb90b 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/statusBar.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/statusBar.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# StatusBarUI = com.github.weisj.darklaf.ui.statusbar.DarkStatusBarUI StatusBar.topColor = %borderSecondary -StatusBar.background = %background \ No newline at end of file +StatusBar.background = %background diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/tabFrame.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/tabFrame.properties index 18d8f3ce..7c20d341 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/tabFrame.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/tabFrame.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# TabFramePanelPopupUI = com.github.weisj.darklaf.ui.tabframe.DarkPanelPopupUI TabFrameTabbedPopupUI = com.github.weisj.darklaf.ui.tabframe.DarkTabbedPopupUI TabFramePopup.headerBorder = com.github.weisj.darklaf.ui.tabframe.DarkTabFramePopupHeaderBorder diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/tabbedPane.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/tabbedPane.properties index 1194c3a3..48b24c7a 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/tabbedPane.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/tabbedPane.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# TabbedPaneUI = com.github.weisj.darklaf.ui.tabbedpane.DarkTabbedPaneUI TabbedPane.tabInsets = 5,7,5,7 TabbedPane.tabRunOverlay = 0 diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/table.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/table.properties index 6e18e999..5dc9b9b6 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/table.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/table.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# TableHeaderUI = com.github.weisj.darklaf.ui.table.DarkTableHeaderUI TableHeader.cellBorder = com.github.weisj.darklaf.ui.table.DarkTableCellBorder TableHeader.focusCellBorder = com.github.weisj.darklaf.ui.table.DarkTableCellBorder @@ -63,4 +63,3 @@ Table.rowHeight = 22 Table.ascendingSortIcon = menu/up.svg[themed](8,16) Table.descendingSortIcon = menu/down.svg[themed](8,16) Table.naturalSortIcon = empty(8,16) - diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/taskPane.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/taskPane.properties index 159c2dc6..fc445edf 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/taskPane.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/taskPane.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# swingx/TaskPaneUI = com.github.weisj.darklaf.ui.taskpane.DarkTaskPaneUI swingx/TaskPaneContainerUI = com.github.weisj.darklaf.ui.taskpane.DarkTaskPaneContainerUI TaskPane.background = %widgetFill diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/text.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/text.properties index d5c288c4..bc084e76 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/text.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/text.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# TextComponent.roundedSelection = true EditorPaneUI = com.github.weisj.darklaf.ui.text.DarkEditorPaneUI diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/toggleButton.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/toggleButton.properties index 7edda676..c1a1e777 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/toggleButton.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/toggleButton.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# ToggleButtonUI = com.github.weisj.darklaf.ui.togglebutton.DarkToggleButtonUI ToggleButton.border = com.github.weisj.darklaf.ui.button.DarkButtonBorder ToggleButton.sliderBorderColor = %widgetBorder diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/toolBar.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/toolBar.properties index 6a1fede4..1019aea7 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/toolBar.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/toolBar.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# ToolBarUI = com.github.weisj.darklaf.ui.toolbar.DarkToolBarUI ToolBar.border = com.github.weisj.darklaf.ui.toolbar.DarkToolBarBorder ToolBar.rolloverBorder = com.github.weisj.darklaf.ui.toolbar.DarkToolBarBorder diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/toolTip.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/toolTip.properties index 4d2498cc..5c058734 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/toolTip.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/toolTip.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# ToolTipUI = com.github.weisj.darklaf.ui.tooltip.DarkTooltipUI ToolTip.background = %backgroundToolTip ToolTip.backgroundInactive = %backgroundToolTipInactive diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/tree.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/tree.properties index 9827150e..a63d1d37 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/tree.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/tree.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# TreeUI = com.github.weisj.darklaf.ui.tree.DarkTreeUI Tree.editorBorder = com.github.weisj.darklaf.ui.tree.DarkTreeCellBorder Tree.editorBorderColor = %widgetBorder diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/tristate.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/tristate.properties index f8b92071..5441a4da 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/tristate.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/tristate.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,5 +21,6 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# TristateCheckBoxUI = com.github.weisj.darklaf.ui.togglebutton.tristate.DarkTristateCheckBoxUI TristateCheckBoxMenuItemUI = com.github.weisj.darklaf.ui.togglebutton.tristate.DarkTristateCheckBoxMenuItemUI diff --git a/core/src/main/resources/theme_settings.properties b/core/src/main/resources/theme_settings.properties index 93c80475..324752e5 100644 --- a/core/src/main/resources/theme_settings.properties +++ b/core/src/main/resources/theme_settings.properties @@ -21,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# title = Theme Settings color_default = Default color_Blue = Blue diff --git a/core/src/main/resources/theme_settings_de.properties b/core/src/main/resources/theme_settings_de.properties index 99ccb8f2..e1319a28 100644 --- a/core/src/main/resources/theme_settings_de.properties +++ b/core/src/main/resources/theme_settings_de.properties @@ -21,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# title = Thema Einstellungen color_default = Standard color_Blue = Blau diff --git a/core/src/main/resources/theme_settings_en_GB.properties b/core/src/main/resources/theme_settings_en_GB.properties index 5d049518..4a9701d7 100644 --- a/core/src/main/resources/theme_settings_en_GB.properties +++ b/core/src/main/resources/theme_settings_en_GB.properties @@ -21,7 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # -#Todo +# title = Theme Settings color_default = Default color_Blue = Blue diff --git a/core/src/main/resources/theme_settings_en_US.properties b/core/src/main/resources/theme_settings_en_US.properties index 93c80475..324752e5 100644 --- a/core/src/main/resources/theme_settings_en_US.properties +++ b/core/src/main/resources/theme_settings_en_US.properties @@ -21,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# title = Theme Settings color_default = Default color_Blue = Blue diff --git a/core/src/main/resources/theme_settings_es.properties b/core/src/main/resources/theme_settings_es.properties index 6b767d96..185def23 100644 --- a/core/src/main/resources/theme_settings_es.properties +++ b/core/src/main/resources/theme_settings_es.properties @@ -21,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# title = Configuración de Temas color_default = Defecto color_Blue = Azul diff --git a/core/src/main/resources/theme_settings_fr.properties b/core/src/main/resources/theme_settings_fr.properties index aa06a46b..5ec60224 100644 --- a/core/src/main/resources/theme_settings_fr.properties +++ b/core/src/main/resources/theme_settings_fr.properties @@ -21,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# title = Réglage des Thèmes color_default = Défaut color_Blue = Bleu diff --git a/core/src/main/resources/theme_settings_ru.properties b/core/src/main/resources/theme_settings_ru.properties index 871d84ca..1d045802 100644 --- a/core/src/main/resources/theme_settings_ru.properties +++ b/core/src/main/resources/theme_settings_ru.properties @@ -21,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# title = Настройки Темы color_default = По умолчанию color_Blue = Синий diff --git a/core/src/test/java/DarklafDemo.java b/core/src/test/java/DarklafDemo.java index e851571b..1cdd577b 100644 --- a/core/src/test/java/DarklafDemo.java +++ b/core/src/test/java/DarklafDemo.java @@ -1,7 +1,31 @@ -import com.github.weisj.darklaf.LafManager; - +/* + * MIT License + * + * Copyright (c) 2020 Jannis Weis + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ import javax.swing.*; +import com.github.weisj.darklaf.LafManager; + public class DarklafDemo { public static void main(final String[] args) { diff --git a/core/src/test/java/PreferenceChangeDemo.java b/core/src/test/java/PreferenceChangeDemo.java index ad9f83ac..0870592c 100644 --- a/core/src/test/java/PreferenceChangeDemo.java +++ b/core/src/test/java/PreferenceChangeDemo.java @@ -1,15 +1,41 @@ -import com.github.weisj.darklaf.LafManager; -import com.github.weisj.darklaf.icons.SolidColorIcon; -import com.github.weisj.darklaf.theme.Theme; -import ui.ComponentDemo; -import ui.DemoPanel; - -import javax.swing.*; +/* + * MIT License + * + * Copyright (c) 2020 Jannis Weis + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ import java.awt.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; +import javax.swing.*; + +import ui.ComponentDemo; +import ui.DemoPanel; + +import com.github.weisj.darklaf.LafManager; +import com.github.weisj.darklaf.icons.SolidColorIcon; +import com.github.weisj.darklaf.theme.Theme; + /* * MIT License * @@ -42,12 +68,14 @@ public class PreferenceChangeDemo implements ComponentDemo { @Override public JComponent createComponent() { LafManager.addThemePreferenceChangeListener(LafManager::installTheme); - DemoPanel panel = new DemoPanel(new JToggleButton("Start") {{ - addActionListener(e -> { - setText(isSelected() ? "Stop" : "Start"); - LafManager.enabledPreferenceChangeReporting(isSelected()); - }); - }}); + DemoPanel panel = new DemoPanel(new JToggleButton("Start") { + { + addActionListener(e -> { + setText(isSelected() ? "Stop" : "Start"); + LafManager.enabledPreferenceChangeReporting(isSelected()); + }); + } + }); Icon accentColorIcon = new SolidColorIcon() { @Override public Color getColor() { @@ -65,18 +93,20 @@ public class PreferenceChangeDemo implements ComponentDemo { controlPanel.add(new JLabel("Selection Color", selectionColorIcon, JLabel.LEFT)); controlPanel = panel.addControls(); - controlPanel.add(new JTextArea() {{ - setMargin(new Insets(5, 5, 5, 5)); - setEditable(false); - setText("Press start/stop to enable/disable preference monitoring.\n" - + "Then do one of the following\n" - + " - switch between dark/light theme (Windows/macOS)\n" - + " - toggle high contrast mode (Windows/macOS)\n" - + " - change accent color (Windows/macOS)\n" - + " - change selection color (macOS)\n" - + " - change font scaling (Windows)\n" - + "The theme should then adjust automatically (if monitoring is started).\n"); - }}); + controlPanel.add(new JTextArea() { + { + setMargin(new Insets(5, 5, 5, 5)); + setEditable(false); + setText("Press start/stop to enable/disable preference monitoring.\n" + + "Then do one of the following\n" + + " - switch between dark/light theme (Windows/macOS)\n" + + " - toggle high contrast mode (Windows/macOS)\n" + + " - change accent color (Windows/macOS)\n" + + " - change selection color (macOS)\n" + + " - change font scaling (Windows)\n" + + "The theme should then adjust automatically (if monitoring is started).\n"); + } + }); return panel; } diff --git a/core/src/test/java/SettingsDemo.java b/core/src/test/java/SettingsDemo.java index eb790811..0419815a 100644 --- a/core/src/test/java/SettingsDemo.java +++ b/core/src/test/java/SettingsDemo.java @@ -1,10 +1,36 @@ +/* + * MIT License + * + * Copyright (c) 2020 Jannis Weis + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ +import java.awt.*; + +import javax.swing.*; + +import ui.ComponentDemo; + import com.github.weisj.darklaf.components.DefaultButton; import com.github.weisj.darklaf.settings.ThemeSettings; import com.github.weisj.darklaf.util.ImageUtil; -import ui.ComponentDemo; - -import javax.swing.*; -import java.awt.*; /* * MIT License @@ -44,12 +70,16 @@ public class SettingsDemo implements ComponentDemo { Box box = Box.createHorizontalBox(); box.setBorder(settingsPanel.getBorder()); box.add(Box.createHorizontalGlue()); - box.add(new DefaultButton("Apply") {{ - addActionListener(e -> settings.apply()); - }}); - box.add(new JButton("Revert") {{ - addActionListener(e -> settings.revert()); - }}); + box.add(new DefaultButton("Apply") { + { + addActionListener(e -> settings.apply()); + } + }); + box.add(new JButton("Revert") { + { + addActionListener(e -> settings.revert()); + } + }); content.add(box, BorderLayout.SOUTH); return content; } diff --git a/core/src/test/java/UIDemo.java b/core/src/test/java/UIDemo.java index 3a8206f3..52e367cd 100644 --- a/core/src/test/java/UIDemo.java +++ b/core/src/test/java/UIDemo.java @@ -1,3 +1,39 @@ +/* + * MIT License + * + * Copyright (c) 2020 Jannis Weis + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ +import java.awt.*; +import java.awt.event.ActionEvent; +import java.util.logging.Logger; + +import javax.swing.*; + +import org.jdesktop.swingx.JXStatusBar; +import org.jdesktop.swingx.JXTaskPane; +import org.jdesktop.swingx.JXTaskPaneContainer; + +import ui.DemoResources; + import com.github.weisj.darklaf.LafManager; import com.github.weisj.darklaf.components.text.SearchTextField; import com.github.weisj.darklaf.components.text.SearchTextFieldWithHistory; @@ -5,421 +41,559 @@ import com.github.weisj.darklaf.components.tristate.TristateCheckBox; import com.github.weisj.darklaf.theme.HighContrastDarkTheme; import com.github.weisj.darklaf.ui.button.DarkButtonUI; import com.github.weisj.darklaf.ui.slider.DarkSliderUI; -import org.jdesktop.swingx.JXStatusBar; -import org.jdesktop.swingx.JXTaskPane; -import org.jdesktop.swingx.JXTaskPaneContainer; -import ui.DemoResources; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.util.logging.Logger; /** * @author Jannis Weis - * @since 2018 + * @since 2018 */ public final class UIDemo { public static void main(final String[] args) { - SwingUtilities.invokeLater( - () -> { - LafManager.install(new HighContrastDarkTheme()); - JFrame.setDefaultLookAndFeelDecorated(true); + SwingUtilities.invokeLater(() -> { + LafManager.install(new HighContrastDarkTheme()); + JFrame.setDefaultLookAndFeelDecorated(true); - JXTaskPaneContainer taskpanecontainer = new JXTaskPaneContainer(); - JXTaskPane taskpane = new JXTaskPane(); - for (int i = 0; i < 3; i++) { - taskpane.add(new AbstractAction("Test Task " + i) { - @Override - public void actionPerformed(final ActionEvent e) { - Logger.getGlobal().info("hello from test task"); - } - }); - } - taskpane.setTitle("My Tasks"); - taskpanecontainer.add(taskpane); + JXTaskPaneContainer taskpanecontainer = new JXTaskPaneContainer(); + JXTaskPane taskpane = new JXTaskPane(); + for (int i = 0; i < 3; i++) { + taskpane.add(new AbstractAction("Test Task " + i) { + @Override + public void actionPerformed(final ActionEvent e) { + Logger.getGlobal().info("hello from test task"); + } + }); + } + taskpane.setTitle("My Tasks"); + taskpanecontainer.add(taskpane); - JFrame frame = new JFrame("UIDemo"); - frame.setIconImage(Toolkit.getDefaultToolkit().createImage( - UIDemo.class.getClassLoader().getResource("mima.png") - )); + JFrame frame = new JFrame("UIDemo"); + frame.setIconImage(Toolkit.getDefaultToolkit().createImage(UIDemo.class.getClassLoader() + .getResource("mima.png"))); - Icon folderIcon = DemoResources.FOLDER_ICON; + Icon folderIcon = DemoResources.FOLDER_ICON; - JPanel panel = new JPanel(new GridLayout(3, 4)); - JPanel content = new JPanel(new BorderLayout()); - content.add(panel, BorderLayout.CENTER); - JXStatusBar statusBar = new JXStatusBar(); - statusBar.add(new JLabel("test1")); - statusBar.add(new JLabel("test2")); - statusBar.add(new JLabel("test3")); - content.add(statusBar, BorderLayout.SOUTH); + JPanel panel = new JPanel(new GridLayout(3, 4)); + JPanel content = new JPanel(new BorderLayout()); + content.add(panel, BorderLayout.CENTER); + JXStatusBar statusBar = new JXStatusBar(); + statusBar.add(new JLabel("test1")); + statusBar.add(new JLabel("test2")); + statusBar.add(new JLabel("test3")); + content.add(statusBar, BorderLayout.SOUTH); - JButton defaultButton = new JButton("default") {{ + JButton defaultButton = new JButton("default") { + { setDefaultCapable(true); - }}; + } + }; - panel.add(new JPanel() {{ + panel.add(new JPanel() { + { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); - add(new JPanel(new FlowLayout(FlowLayout.LEFT)) {{ - add(new JCheckBox("disabled selected") {{ - setSelected(true); + add(new JPanel(new FlowLayout(FlowLayout.LEFT)) { + { + add(new JCheckBox("disabled selected") { + { + setSelected(true); + setEnabled(false); + } + }); + add(new JCheckBox("enabled")); + } + }); + add(new JPanel(new FlowLayout(FlowLayout.LEFT)) { + { + add(new JRadioButton("disabled") { + { + setSelected(true); + setEnabled(false); + } + }); + add(new JRadioButton("enabled")); + } + }); + add(new JPanel(new FlowLayout(FlowLayout.LEFT)) { + { + add(new TristateCheckBox("disabled") { + { + setIndeterminate(); + setEnabled(false); + } + }); + add(new TristateCheckBox("enabled")); + } + }); + add(new JPanel(new FlowLayout(FlowLayout.LEFT)) { + { + add(new JButton("IconButton", folderIcon) { + { + setRolloverEnabled(true); + putClientProperty(DarkButtonUI.KEY_VARIANT, + DarkButtonUI.VARIANT_BORDERLESS); + } + }); + add(new JButton(folderIcon) { + { + setRolloverEnabled(true); + putClientProperty(DarkButtonUI.KEY_SQUARE, true); + putClientProperty(DarkButtonUI.KEY_VARIANT, + DarkButtonUI.VARIANT_BORDERLESS); + } + }); + add(new JButton(folderIcon) { + { + setRolloverEnabled(true); + putClientProperty(DarkButtonUI.KEY_SQUARE, true); + putClientProperty(DarkButtonUI.KEY_THIN, Boolean.TRUE); + putClientProperty(DarkButtonUI.KEY_ALT_ARC, + Boolean.TRUE); + putClientProperty(DarkButtonUI.KEY_VARIANT, + DarkButtonUI.VARIANT_BORDERLESS); + } + }); + add(new JButton(folderIcon) { + { + putClientProperty(DarkButtonUI.KEY_VARIANT, + DarkButtonUI.VARIANT_ONLY_LABEL); + } + }); + } + }); + add(new JToggleButton("toggle") { + { + putClientProperty("JToggleButton.variant", "slider"); setEnabled(false); - }}); - add(new JCheckBox("enabled")); - }}); - add(new JPanel(new FlowLayout(FlowLayout.LEFT)) {{ - add(new JRadioButton("disabled") {{ setSelected(true); + } + }); + } + }); + panel.add(new JPanel() { + { + setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + add(new JComboBox() { + { + addItem("Editable ComboBox"); + for (int i = 0; i < 20; i++) { + addItem("item " + i); + } + setEditable(true); + } + }); + add(new JComboBox() { + { + addItem("Uneditable ComboBox"); + for (int i = 0; i < 20; i++) { + addItem("item " + i); + } + setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + } + }); + add(new JComboBox() { + { + addItem("DisabledComboBox"); setEnabled(false); - }}); - add(new JRadioButton("enabled")); - }}); - add(new JPanel(new FlowLayout(FlowLayout.LEFT)) {{ - add(new TristateCheckBox("disabled") {{ - setIndeterminate(); + } + }); + add(new JSpinner() { + { + putClientProperty("JSpinner.variant", "plusMinus"); + } + }); + add(new JSpinner() { + { + setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + } + }); + add(new JSpinner() { + { setEnabled(false); - }}); - add(new TristateCheckBox("enabled")); - }}); - add(new JPanel(new FlowLayout(FlowLayout.LEFT)) {{ - add(new JButton("IconButton", folderIcon) {{ - setRolloverEnabled(true); - putClientProperty(DarkButtonUI.KEY_VARIANT, DarkButtonUI.VARIANT_BORDERLESS); - }}); - add(new JButton(folderIcon) {{ - setRolloverEnabled(true); - putClientProperty(DarkButtonUI.KEY_SQUARE, true); - putClientProperty(DarkButtonUI.KEY_VARIANT, DarkButtonUI.VARIANT_BORDERLESS); - }}); - add(new JButton(folderIcon) {{ - setRolloverEnabled(true); - putClientProperty(DarkButtonUI.KEY_SQUARE, true); - putClientProperty(DarkButtonUI.KEY_THIN, Boolean.TRUE); - putClientProperty(DarkButtonUI.KEY_ALT_ARC, Boolean.TRUE); - putClientProperty(DarkButtonUI.KEY_VARIANT, DarkButtonUI.VARIANT_BORDERLESS); - }}); - add(new JButton(folderIcon) {{ - putClientProperty(DarkButtonUI.KEY_VARIANT, DarkButtonUI.VARIANT_ONLY_LABEL); - }}); - }}); - add(new JToggleButton("toggle") {{ - putClientProperty("JToggleButton.variant", "slider"); - setEnabled(false); - setSelected(true); - }}); - }}); - panel.add(new JPanel() {{ - setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); - add(new JComboBox() {{ - addItem("Editable ComboBox"); - for (int i = 0; i < 20; i++) { - addItem("item " + i); - } - setEditable(true); - }}); - add(new JComboBox() {{ - addItem("Uneditable ComboBox"); - for (int i = 0; i < 20; i++) { - addItem("item " + i); - } - setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); - }}); - add(new JComboBox() {{ - addItem("DisabledComboBox"); - setEnabled(false); - }}); - add(new JSpinner() {{ - putClientProperty("JSpinner.variant", "plusMinus"); - }}); - add(new JSpinner() {{ - setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); - }}); - add(new JSpinner() {{ - setEnabled(false); - }}); - }}); - panel.add(new JPanel() {{ + } + }); + } + }); + panel.add(new JPanel() { + { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); add(new JTextField("TextField")); - add(new JTextField("TextField") {{ - setEnabled(false); - }}); - add(new JTextField("TextField") {{ - putClientProperty("JTextField.alternativeArc", Boolean.TRUE); - }}); + add(new JTextField("TextField") { + { + setEnabled(false); + } + }); + add(new JTextField("TextField") { + { + putClientProperty("JTextField.alternativeArc", Boolean.TRUE); + } + }); add(new SearchTextField("SearchField")); add(new SearchTextFieldWithHistory("SearchFieldWithHistory")); add(new JPasswordField("Password")); - add(new JPasswordField("VeryStrongPassword") {{ - putClientProperty("JTextField.alternativeArc", Boolean.TRUE); - putClientProperty("JPasswordField.showViewIcon", Boolean.TRUE); - }}); - }}); - panel.add(new JPanel() {{ + add(new JPasswordField("VeryStrongPassword") { + { + putClientProperty("JTextField.alternativeArc", Boolean.TRUE); + putClientProperty("JPasswordField.showViewIcon", Boolean.TRUE); + } + }); + } + }); + panel.add(new JPanel() { + { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); - add(new JButton("enabled") {{ - }}); - add(new JButton("disabled") {{ - setEnabled(false); - }}); + add(new JButton("enabled") { {} }); + add(new JButton("disabled") { + { + setEnabled(false); + } + }); add(defaultButton); - add(new JToggleButton("toggle") {{ - putClientProperty("JToggleButton.variant", "slider"); - }}); - add(new JButton("square") {{ - putClientProperty(DarkButtonUI.KEY_SQUARE, true); - }}); - }}); - panel.add(taskpanecontainer); - panel.add(new JPanel() {{ - add(new JProgressBar() {{ - setValue(50); - }}); - add(new JProgressBar() {{ - setValue(50); - putClientProperty("JProgressBar.failed", true); - }}); - add(new JProgressBar() {{ - setValue(50); - putClientProperty("JProgressBar.passed", true); - }}); - add(new JProgressBar() {{ - setIndeterminate(true); - }}); - add(new JProgressBar() {{ - setIndeterminate(true); - putClientProperty("JProgressBar.failed", true); - }}); - add(new JProgressBar() {{ - setIndeterminate(true); - putClientProperty("JProgressBar.passed", true); - }}); - }}); - panel.add(new JPanel() {{ + add(new JToggleButton("toggle") { + { + putClientProperty("JToggleButton.variant", "slider"); + } + }); + add(new JButton("square") { + { + putClientProperty(DarkButtonUI.KEY_SQUARE, true); + } + }); + } + }); + panel.add(taskpanecontainer); + panel.add(new JPanel() { + { + add(new JProgressBar() { + { + setValue(50); + } + }); + add(new JProgressBar() { + { + setValue(50); + putClientProperty("JProgressBar.failed", true); + } + }); + add(new JProgressBar() { + { + setValue(50); + putClientProperty("JProgressBar.passed", true); + } + }); + add(new JProgressBar() { + { + setIndeterminate(true); + } + }); + add(new JProgressBar() { + { + setIndeterminate(true); + putClientProperty("JProgressBar.failed", true); + } + }); + add(new JProgressBar() { + { + setIndeterminate(true); + putClientProperty("JProgressBar.passed", true); + } + }); + } + }); + panel.add(new JPanel() { + { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); add(new JSlider()); - add(new JSlider() {{ - setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); - }}); - add(new JSlider() {{ - setInverted(true); - }}); - add(new JSlider() {{ - setInverted(true); - setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); - }}); - add(new JSlider() {{ - putClientProperty(DarkSliderUI.KEY_VARIANT, DarkSliderUI.VARIANT_VOLUME); - putClientProperty(DarkSliderUI.KEY_INSTANT_SCROLL, Boolean.TRUE); - }}); - add(new JSlider() {{ - putClientProperty("Slider.variant", "volume"); - putClientProperty("Slider.instantScrollEnabled", Boolean.TRUE); - putClientProperty(DarkSliderUI.KEY_SHOW_VOLUME_ICON, Boolean.TRUE); - }}); - add(new JSlider() {{ - setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); - putClientProperty("Slider.variant", "volume"); - putClientProperty("Slider.instantScrollEnabled", Boolean.TRUE); - putClientProperty(DarkSliderUI.KEY_SHOW_VOLUME_ICON, Boolean.TRUE); - }}); - }}); - panel.add(new JPanel() {{ + add(new JSlider() { + { + setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + } + }); + add(new JSlider() { + { + setInverted(true); + } + }); + add(new JSlider() { + { + setInverted(true); + setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + } + }); + add(new JSlider() { + { + putClientProperty(DarkSliderUI.KEY_VARIANT, + DarkSliderUI.VARIANT_VOLUME); + putClientProperty(DarkSliderUI.KEY_INSTANT_SCROLL, Boolean.TRUE); + } + }); + add(new JSlider() { + { + putClientProperty("Slider.variant", "volume"); + putClientProperty("Slider.instantScrollEnabled", Boolean.TRUE); + putClientProperty(DarkSliderUI.KEY_SHOW_VOLUME_ICON, + Boolean.TRUE); + } + }); + add(new JSlider() { + { + setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + putClientProperty("Slider.variant", "volume"); + putClientProperty("Slider.instantScrollEnabled", Boolean.TRUE); + putClientProperty(DarkSliderUI.KEY_SHOW_VOLUME_ICON, + Boolean.TRUE); + } + }); + } + }); + panel.add(new JPanel() { + { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); - add(new JSlider() {{ - setSnapToTicks(true); - setPaintTicks(true); - setMajorTickSpacing(20); - setMinorTickSpacing(5); - setPaintLabels(true); - }}); - add(new JSlider() {{ - setSnapToTicks(true); - setPaintTicks(true); - setMajorTickSpacing(20); - setMinorTickSpacing(5); - setPaintLabels(true); - setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); - }}); - add(new JSlider() {{ - setSnapToTicks(true); - setPaintTicks(true); - setMajorTickSpacing(20); - setMinorTickSpacing(5); - setPaintLabels(true); - setInverted(true); - }}); - add(new JSlider() {{ - setSnapToTicks(true); - setPaintTicks(true); - setMajorTickSpacing(20); - setMinorTickSpacing(5); - setPaintLabels(true); - setInverted(true); - setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); - }}); - }}); - panel.add(new JPanel() {{ + add(new JSlider() { + { + setSnapToTicks(true); + setPaintTicks(true); + setMajorTickSpacing(20); + setMinorTickSpacing(5); + setPaintLabels(true); + } + }); + add(new JSlider() { + { + setSnapToTicks(true); + setPaintTicks(true); + setMajorTickSpacing(20); + setMinorTickSpacing(5); + setPaintLabels(true); + setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + } + }); + add(new JSlider() { + { + setSnapToTicks(true); + setPaintTicks(true); + setMajorTickSpacing(20); + setMinorTickSpacing(5); + setPaintLabels(true); + setInverted(true); + } + }); + add(new JSlider() { + { + setSnapToTicks(true); + setPaintTicks(true); + setMajorTickSpacing(20); + setMinorTickSpacing(5); + setPaintLabels(true); + setInverted(true); + setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + } + }); + } + }); + panel.add(new JPanel() { + { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); - add(new JSlider() {{ - setSnapToTicks(true); - setPaintTicks(true); - setMajorTickSpacing(20); - setMinorTickSpacing(5); - setPaintLabels(true); - putClientProperty("Slider.variant", "volume"); - putClientProperty("Slider.instantScrollEnabled", Boolean.TRUE); - }}); - add(new JSlider() {{ - setSnapToTicks(true); - setPaintTicks(true); - setMajorTickSpacing(20); - setMinorTickSpacing(5); - setPaintLabels(true); - putClientProperty("Slider.variant", "volume"); - putClientProperty("Slider.instantScrollEnabled", Boolean.TRUE); - putClientProperty(DarkSliderUI.KEY_SHOW_VOLUME_ICON, Boolean.TRUE); - }}); - add(new JSlider() {{ - setSnapToTicks(true); - setPaintTicks(true); - setMajorTickSpacing(20); - setMinorTickSpacing(5); - setPaintLabels(true); - setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); - putClientProperty("Slider.variant", "volume"); - putClientProperty("Slider.instantScrollEnabled", Boolean.TRUE); - putClientProperty(DarkSliderUI.KEY_SHOW_VOLUME_ICON, Boolean.TRUE); - }}); - }}); - panel.add(new JPanel() {{ + add(new JSlider() { + { + setSnapToTicks(true); + setPaintTicks(true); + setMajorTickSpacing(20); + setMinorTickSpacing(5); + setPaintLabels(true); + putClientProperty("Slider.variant", "volume"); + putClientProperty("Slider.instantScrollEnabled", Boolean.TRUE); + } + }); + add(new JSlider() { + { + setSnapToTicks(true); + setPaintTicks(true); + setMajorTickSpacing(20); + setMinorTickSpacing(5); + setPaintLabels(true); + putClientProperty("Slider.variant", "volume"); + putClientProperty("Slider.instantScrollEnabled", Boolean.TRUE); + putClientProperty(DarkSliderUI.KEY_SHOW_VOLUME_ICON, + Boolean.TRUE); + } + }); + add(new JSlider() { + { + setSnapToTicks(true); + setPaintTicks(true); + setMajorTickSpacing(20); + setMinorTickSpacing(5); + setPaintLabels(true); + setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + putClientProperty("Slider.variant", "volume"); + putClientProperty("Slider.instantScrollEnabled", Boolean.TRUE); + putClientProperty(DarkSliderUI.KEY_SHOW_VOLUME_ICON, + Boolean.TRUE); + } + }); + } + }); + panel.add(new JPanel() { + { setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); - add(new JSlider() {{ - setOrientation(VERTICAL); - }}); - add(new JSlider() {{ - setOrientation(VERTICAL); - setInverted(true); - }}); - add(new JSlider() {{ - setOrientation(VERTICAL); - putClientProperty("Slider.variant", "volume"); - putClientProperty("Slider.instantScrollEnabled", Boolean.TRUE); - }}); - add(new JSlider() {{ - setOrientation(VERTICAL); - putClientProperty("Slider.variant", "volume"); - putClientProperty("Slider.instantScrollEnabled", Boolean.TRUE); - putClientProperty(DarkSliderUI.KEY_SHOW_VOLUME_ICON, Boolean.TRUE); - }}); - add(new JSlider() {{ - setOrientation(VERTICAL); - setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); - putClientProperty("Slider.variant", "volume"); - putClientProperty("Slider.instantScrollEnabled", Boolean.TRUE); - putClientProperty(DarkSliderUI.KEY_SHOW_VOLUME_ICON, Boolean.TRUE); - }}); - }}); - panel.add(new JPanel() {{ + add(new JSlider() { + { + setOrientation(VERTICAL); + } + }); + add(new JSlider() { + { + setOrientation(VERTICAL); + setInverted(true); + } + }); + add(new JSlider() { + { + setOrientation(VERTICAL); + putClientProperty("Slider.variant", "volume"); + putClientProperty("Slider.instantScrollEnabled", Boolean.TRUE); + } + }); + add(new JSlider() { + { + setOrientation(VERTICAL); + putClientProperty("Slider.variant", "volume"); + putClientProperty("Slider.instantScrollEnabled", Boolean.TRUE); + putClientProperty(DarkSliderUI.KEY_SHOW_VOLUME_ICON, + Boolean.TRUE); + } + }); + add(new JSlider() { + { + setOrientation(VERTICAL); + setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + putClientProperty("Slider.variant", "volume"); + putClientProperty("Slider.instantScrollEnabled", Boolean.TRUE); + putClientProperty(DarkSliderUI.KEY_SHOW_VOLUME_ICON, + Boolean.TRUE); + } + }); + } + }); + panel.add(new JPanel() { + { setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); - add(new JSlider() {{ - setOrientation(VERTICAL); - setSnapToTicks(true); - setPaintTicks(true); - setMajorTickSpacing(20); - setMinorTickSpacing(5); - setPaintLabels(true); - }}); - add(new JSlider() {{ - setOrientation(VERTICAL); - setSnapToTicks(true); - setPaintTicks(true); - setMajorTickSpacing(20); - setMinorTickSpacing(5); - setPaintLabels(true); - setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); - }}); - add(new JSlider() {{ - setOrientation(VERTICAL); - setSnapToTicks(true); - setPaintTicks(true); - setMajorTickSpacing(20); - setMinorTickSpacing(5); - setPaintLabels(true); - setInverted(true); - }}); - add(new JSlider() {{ - setOrientation(VERTICAL); - setSnapToTicks(true); - setPaintTicks(true); - setMajorTickSpacing(20); - setMinorTickSpacing(5); - setPaintLabels(true); - setInverted(true); - setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); - }}); - }}); - panel.add(new JPanel() {{ + add(new JSlider() { + { + setOrientation(VERTICAL); + setSnapToTicks(true); + setPaintTicks(true); + setMajorTickSpacing(20); + setMinorTickSpacing(5); + setPaintLabels(true); + } + }); + add(new JSlider() { + { + setOrientation(VERTICAL); + setSnapToTicks(true); + setPaintTicks(true); + setMajorTickSpacing(20); + setMinorTickSpacing(5); + setPaintLabels(true); + setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + } + }); + add(new JSlider() { + { + setOrientation(VERTICAL); + setSnapToTicks(true); + setPaintTicks(true); + setMajorTickSpacing(20); + setMinorTickSpacing(5); + setPaintLabels(true); + setInverted(true); + } + }); + add(new JSlider() { + { + setOrientation(VERTICAL); + setSnapToTicks(true); + setPaintTicks(true); + setMajorTickSpacing(20); + setMinorTickSpacing(5); + setPaintLabels(true); + setInverted(true); + setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + } + }); + } + }); + panel.add(new JPanel() { + { setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); - add(new JSlider() {{ - setOrientation(VERTICAL); - setSnapToTicks(true); - setPaintTicks(true); - setMajorTickSpacing(20); - setMinorTickSpacing(5); - setPaintLabels(true); - putClientProperty("Slider.variant", "volume"); - putClientProperty("Slider.instantScrollEnabled", Boolean.TRUE); - }}); - add(new JSlider() {{ - setOrientation(VERTICAL); - setSnapToTicks(true); - setPaintTicks(true); - setMajorTickSpacing(20); - setMinorTickSpacing(5); - setPaintLabels(true); - putClientProperty("Slider.variant", "volume"); - putClientProperty("Slider.instantScrollEnabled", Boolean.TRUE); - putClientProperty(DarkSliderUI.KEY_SHOW_VOLUME_ICON, Boolean.TRUE); - }}); - add(new JSlider() {{ - setOrientation(VERTICAL); - setSnapToTicks(true); - setPaintTicks(true); - setMajorTickSpacing(20); - setMinorTickSpacing(5); - setPaintLabels(true); - setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); - putClientProperty("Slider.variant", "volume"); - putClientProperty("Slider.instantScrollEnabled", Boolean.TRUE); - putClientProperty(DarkSliderUI.KEY_SHOW_VOLUME_ICON, Boolean.TRUE); - }}); - }}); + add(new JSlider() { + { + setOrientation(VERTICAL); + setSnapToTicks(true); + setPaintTicks(true); + setMajorTickSpacing(20); + setMinorTickSpacing(5); + setPaintLabels(true); + putClientProperty("Slider.variant", "volume"); + putClientProperty("Slider.instantScrollEnabled", Boolean.TRUE); + } + }); + add(new JSlider() { + { + setOrientation(VERTICAL); + setSnapToTicks(true); + setPaintTicks(true); + setMajorTickSpacing(20); + setMinorTickSpacing(5); + setPaintLabels(true); + putClientProperty("Slider.variant", "volume"); + putClientProperty("Slider.instantScrollEnabled", Boolean.TRUE); + putClientProperty(DarkSliderUI.KEY_SHOW_VOLUME_ICON, + Boolean.TRUE); + } + }); + add(new JSlider() { + { + setOrientation(VERTICAL); + setSnapToTicks(true); + setPaintTicks(true); + setMajorTickSpacing(20); + setMinorTickSpacing(5); + setPaintLabels(true); + setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + putClientProperty("Slider.variant", "volume"); + putClientProperty("Slider.instantScrollEnabled", Boolean.TRUE); + putClientProperty(DarkSliderUI.KEY_SHOW_VOLUME_ICON, + Boolean.TRUE); + } + }); + } + }); - frame.setContentPane(content); + frame.setContentPane(content); - JMenuBar menuBar = new JMenuBar(); - JMenu menu = new JMenu("test"); - menu.add(new JMenu("submenu") {{ + JMenuBar menuBar = new JMenuBar(); + JMenu menu = new JMenu("test"); + menu.add(new JMenu("submenu") { + { add(new JMenuItem("item1")); add(new JMenuItem("item2")); add(new JMenuItem("item3")); add(new JMenuItem("item4")); add(new JMenuItem("item5")); - }}); - menu.addSeparator(); - menu.add(new JRadioButtonMenuItem("radioButton")); - menu.add(new JCheckBoxMenuItem("checkBox")); - menuBar.add(menu); - frame.setJMenuBar(menuBar); - - frame.getRootPane().setDefaultButton(defaultButton); - frame.setSize(1200, 800); - frame.setLocationRelativeTo(null); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - frame.setVisible(true); + } }); + menu.addSeparator(); + menu.add(new JRadioButtonMenuItem("radioButton")); + menu.add(new JCheckBoxMenuItem("checkBox")); + menuBar.add(menu); + frame.setJMenuBar(menuBar); + + frame.getRootPane().setDefaultButton(defaultButton); + frame.setSize(1200, 800); + frame.setLocationRelativeTo(null); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setVisible(true); + }); } } diff --git a/core/src/test/java/defaults/SafeIcon.java b/core/src/test/java/defaults/SafeIcon.java index 964a34c9..87c5574e 100644 --- a/core/src/test/java/defaults/SafeIcon.java +++ b/core/src/test/java/defaults/SafeIcon.java @@ -1,30 +1,54 @@ +/* + * MIT License + * + * Copyright (c) 2020 Jannis Weis + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ package defaults; -import javax.swing.*; import java.awt.*; import java.awt.image.BufferedImage; import java.lang.reflect.InvocationTargetException; +import javax.swing.*; + /** * Thanks to Jeanette for the use of this code found at: - * - *

    https://jdnc-incubator.dev.java.net/source/browse/jdnc-incubator/src/kleopatra/java/org + *

    + * https://jdnc-incubator.dev.java.net/source/browse/jdnc-incubator/src/kleopatra/java/org * /jdesktop/swingx/renderer/UIPropertiesViewer.java?rev=1.2&view=markup - * - *

    Some ui-icons misbehave in that they unconditionally class-cast to the component type they + *

    + * Some ui-icons misbehave in that they unconditionally class-cast to the component type they * are mostly painted on. Consequently they blow up if we are trying to paint them anywhere else (f.i. in a renderer). - * - *

    This Icon is an adaption of a cool trick by Darryl Burke found at + *

    + * This Icon is an adaption of a cool trick by Darryl Burke found at * http://tips4java.wordpress.com/2008/12/18/icon-table-cell-renderer - * - *

    The base idea is to instantiate a component of the type expected by the icon, let it paint + *

    + * The base idea is to instantiate a component of the type expected by the icon, let it paint * into the graphics of a bufferedImage and create an ImageIcon from it. In subsequent calls the ImageIcon is used. */ final class SafeIcon implements Icon { private final Icon wrappee; private Icon standIn; - SafeIcon(final Icon wrappee) { this.wrappee = wrappee; } @@ -55,8 +79,7 @@ final class SafeIcon implements Icon { return wrappee.getIconHeight(); } - private void paintFallback( - final Component c, final Graphics g, final int x, final int y) { + private void paintFallback(final Component c, final Graphics g, final int x, final int y) { g.drawRect(x, y, getIconWidth(), getIconHeight()); g.drawLine(x, y, x + getIconWidth(), y + getIconHeight()); g.drawLine(x + getIconWidth(), y, x, y + getIconHeight()); @@ -84,8 +107,7 @@ final class SafeIcon implements Icon { try { standInComponent = (JComponent) clazz.getDeclaredConstructor().newInstance(); } catch (final InstantiationException e) { - standInComponent = new AbstractButton() { - }; + standInComponent = new AbstractButton() {}; ((AbstractButton) standInComponent).setModel(new DefaultButtonModel()); } catch (NoSuchMethodException | InvocationTargetException e) { e.printStackTrace(); @@ -93,10 +115,8 @@ final class SafeIcon implements Icon { return standInComponent; } - private Icon createImageIcon(final JComponent standInComponent) { - final BufferedImage image = - new BufferedImage(getIconWidth(), getIconHeight(), BufferedImage.TYPE_INT_ARGB); + final BufferedImage image = new BufferedImage(getIconWidth(), getIconHeight(), BufferedImage.TYPE_INT_ARGB); final Graphics g = image.createGraphics(); try { wrappee.paintIcon(standInComponent, g, 0, 0); diff --git a/core/src/test/java/defaults/SampleRenderer.java b/core/src/test/java/defaults/SampleRenderer.java index 9a106442..6f7efdfb 100644 --- a/core/src/test/java/defaults/SampleRenderer.java +++ b/core/src/test/java/defaults/SampleRenderer.java @@ -1,19 +1,43 @@ +/* + * MIT License + * + * Copyright (c) 2020 Jannis Weis + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ package defaults; -import com.github.weisj.darklaf.ui.cell.DarkCellRendererToggleButton; +import java.awt.*; import javax.swing.*; import javax.swing.border.Border; import javax.swing.table.TableCellRenderer; -import java.awt.*; + +import com.github.weisj.darklaf.ui.cell.DarkCellRendererToggleButton; /* - * Render the value based on its class. + * Render the value based on its class. */ public class SampleRenderer extends JLabel implements TableCellRenderer { - private final DarkCellRendererToggleButton booleanRenderer = - new DarkCellRendererToggleButton<>(new DarkCellRendererToggleButton.CellEditorCheckBox(true)); + private final DarkCellRendererToggleButton booleanRenderer = new DarkCellRendererToggleButton<>(new DarkCellRendererToggleButton.CellEditorCheckBox(true)); public SampleRenderer() { super(); @@ -21,14 +45,12 @@ public class SampleRenderer extends JLabel implements TableCellRenderer { setOpaque(true); } - - public Component getTableCellRendererComponent( - final JTable table, - final Object sample, - final boolean isSelected, - final boolean hasFocus, - final int row, - final int column) { + public Component getTableCellRendererComponent(final JTable table, + final Object sample, + final boolean isSelected, + final boolean hasFocus, + final int row, + final int column) { setBackground(null); setBorder(null); setIcon(null); @@ -50,9 +72,9 @@ public class SampleRenderer extends JLabel implements TableCellRenderer { } /* - * Some icons are painted using inner classes and are not meant to be - * shared by other items. This code will catch the - * ClassCastException that is thrown. + * Some icons are painted using inner classes and are not meant to be + * shared by other items. This code will catch the + * ClassCastException that is thrown. */ public void paint(final Graphics g) { try { diff --git a/core/src/test/java/defaults/UIManagerDefaults.java b/core/src/test/java/defaults/UIManagerDefaults.java index e7b66029..fa60ed54 100644 --- a/core/src/test/java/defaults/UIManagerDefaults.java +++ b/core/src/test/java/defaults/UIManagerDefaults.java @@ -1,22 +1,49 @@ +/* + * MIT License + * + * Copyright (c) 2020 Jannis Weis + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ package defaults; + /* - * This programs uses the information found in the UIManager - * to create a table of key/value pairs for each Swing component. + * This programs uses the information found in the UIManager + * to create a table of key/value pairs for each Swing component. */ -import com.github.weisj.darklaf.components.OverlayScrollPane; -import com.github.weisj.darklaf.ui.table.DarkColorTableCellRendererEditor; -import ui.ComponentDemo; +import java.awt.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.*; import javax.swing.*; import javax.swing.border.Border; import javax.swing.border.EmptyBorder; import javax.swing.plaf.ColorUIResource; import javax.swing.table.DefaultTableModel; -import java.awt.*; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.util.*; + +import ui.ComponentDemo; + +import com.github.weisj.darklaf.components.OverlayScrollPane; +import com.github.weisj.darklaf.ui.table.DarkColorTableCellRendererEditor; public class UIManagerDefaults implements ItemListener, ComponentDemo { private static final String[] COLUMN_NAMES = {"Key", "Value", "Sample"}; @@ -27,7 +54,6 @@ public class UIManagerDefaults implements ItemListener, ComponentDemo { private JRadioButton byComponent; private JTable table; - public static void main(final String[] args) { ComponentDemo.showDemo(new UIManagerDefaults()); } @@ -48,7 +74,7 @@ public class UIManagerDefaults implements ItemListener, ComponentDemo { } /* - * This panel is added to the North of the content pane + * This panel is added to the North of the content pane */ private JComponent createSelectionPanel() { comboBox = new JComboBox<>(); @@ -107,7 +133,7 @@ public class UIManagerDefaults implements ItemListener, ComponentDemo { } /* - * When the LAF is changed we need to reset the content pane + * When the LAF is changed we need to reset the content pane */ public void resetComponents() { items.clear(); @@ -131,33 +157,31 @@ public class UIManagerDefaults implements ItemListener, ComponentDemo { } /* - * The item map will contain items for each component or - * items for each attribute type. + * The item map will contain items for each component or + * items for each attribute type. */ private void buildItemsMap() { final UIDefaults defaults = UIManager.getLookAndFeelDefaults(); - // Build of Map of items, and a Map of attributes for each item + // Build of Map of items, and a Map of attributes for each item for (final Object key : new HashSet<>(defaults.keySet())) { final Object value = defaults.get(key); final String itemName = getItemName(key.toString(), value); if (itemName == null) { continue; } - // Get the attribute map for this component, or - // create a map when one is not found - final TreeMap attributeMap = - items.computeIfAbsent(itemName, k -> new TreeMap<>()); - // Add the attribute to the map for this component + // Get the attribute map for this component, or + // create a map when one is not found + final TreeMap attributeMap = items.computeIfAbsent(itemName, k -> new TreeMap<>()); + // Add the attribute to the map for this component attributeMap.put(key.toString(), value); } } /* - * Parse the key to determine the item name to use + * Parse the key to determine the item name to use */ - private String getItemName(final String key, final Object value) { - // Seems like this is an old check required for JDK1.4.2 + // Seems like this is an old check required for JDK1.4.2 if (key.startsWith("class") || key.startsWith("javax")) { return null; } @@ -169,10 +193,10 @@ public class UIManagerDefaults implements ItemListener, ComponentDemo { } private String getComponentName(final String key, final Object value) { - // The key is of the form: - // "componentName.componentProperty", or - // "componentNameUI", or - // "someOtherString" + // The key is of the form: + // "componentName.componentProperty", or + // "componentNameUI", or + // "someOtherString" String componentName; final int pos = componentNameEndOffset(key); if (pos != -1) { @@ -184,7 +208,7 @@ public class UIManagerDefaults implements ItemListener, ComponentDemo { } else { componentName = "Miscellaneous"; } - // Fix inconsistency + // Fix inconsistency if (componentName.equals("Checkbox")) { componentName = "CheckBox"; } @@ -224,10 +248,10 @@ public class UIManagerDefaults implements ItemListener, ComponentDemo { } private int componentNameEndOffset(final String key) { - // Handle Nimbus properties first - // "ComboBox.scrollPane", "Table.editor" and "Tree.cellEditor" - // have different format even within the Nimbus properties. - // (the component name is specified in quotes) + // Handle Nimbus properties first + // "ComboBox.scrollPane", "Table.editor" and "Tree.cellEditor" + // have different format even within the Nimbus properties. + // (the component name is specified in quotes) if (key.startsWith("\"")) { return key.indexOf("\"", 1) + 1; } @@ -239,12 +263,12 @@ public class UIManagerDefaults implements ItemListener, ComponentDemo { if (pos != -1) { return pos; } - // Handle normal properties + // Handle normal properties return key.indexOf("."); } /* - * Implement the ItemListener interface + * Implement the ItemListener interface */ public void itemStateChanged(final ItemEvent e) { final String itemName = (String) e.getItem(); @@ -254,17 +278,17 @@ public class UIManagerDefaults implements ItemListener, ComponentDemo { } /* - * Change the TableModel in the table for the selected item + * Change the TableModel in the table for the selected item */ private void changeTableModel(final String itemName) { - // The model has been created previously so just use it + // The model has been created previously so just use it DefaultTableModel model = models.get(itemName); if (model != null) { table.setModel(model); return; } - // Create a new model for the requested item - // and addAtHead the attributes of the item to the model + // Create a new model for the requested item + // and addAtHead the attributes of the item to the model model = new DefaultTableModel(COLUMN_NAMES, 0); final Map attributes = items.get(itemName); for (final Object o : attributes.keySet()) { @@ -289,8 +313,8 @@ public class UIManagerDefaults implements ItemListener, ComponentDemo { } /* - * Some rows containing icons, may need to be sized taller to fully - * display the icon. + * Some rows containing icons, may need to be sized taller to fully + * display the icon. */ private void updateRowHeights() { try { @@ -298,13 +322,11 @@ public class UIManagerDefaults implements ItemListener, ComponentDemo { int rowHeight = table.getRowHeight(); for (int column = 0; column < table.getColumnCount(); column++) { - final Component comp = - table.prepareRenderer(table.getCellRenderer(row, column), row, column); + final Component comp = table.prepareRenderer(table.getCellRenderer(row, column), row, column); rowHeight = Math.max(rowHeight, comp.getPreferredSize().height); } table.setRowHeight(row, rowHeight); } - } catch (final ClassCastException ignored) { - } + } catch (final ClassCastException ignored) {} } } diff --git a/core/src/test/java/documentation/CreateUITable.java b/core/src/test/java/documentation/CreateUITable.java index 7b16225c..25f3913f 100644 --- a/core/src/test/java/documentation/CreateUITable.java +++ b/core/src/test/java/documentation/CreateUITable.java @@ -20,24 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package documentation; -import com.github.weisj.darklaf.DarkLaf; -import com.github.weisj.darklaf.LafManager; -import com.github.weisj.darklaf.PropertyLoader; -import com.github.weisj.darklaf.components.border.DropShadowBorder; -import com.github.weisj.darklaf.icons.DarkSVGIcon; -import com.github.weisj.darklaf.icons.EmptyIcon; -import com.github.weisj.darklaf.theme.Theme; -import com.github.weisj.darklaf.util.*; -import com.kitfox.svg.app.beans.SVGIcon; -import defaults.SampleRenderer; - -import javax.imageio.ImageIO; -import javax.swing.*; -import javax.swing.border.Border; -import javax.swing.border.EmptyBorder; import java.awt.*; import java.awt.image.BufferedImage; import java.io.*; @@ -49,6 +35,22 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; +import javax.imageio.ImageIO; +import javax.swing.*; +import javax.swing.border.Border; +import javax.swing.border.EmptyBorder; + +import com.github.weisj.darklaf.DarkLaf; +import com.github.weisj.darklaf.LafManager; +import com.github.weisj.darklaf.PropertyLoader; +import com.github.weisj.darklaf.components.border.DropShadowBorder; +import com.github.weisj.darklaf.icons.DarkSVGIcon; +import com.github.weisj.darklaf.icons.EmptyIcon; +import com.github.weisj.darklaf.theme.Theme; +import com.github.weisj.darklaf.util.*; +import com.kitfox.svg.app.beans.SVGIcon; +import defaults.SampleRenderer; + public class CreateUITable { private static final int SAMPLE_WIDTH = 150; @@ -73,8 +75,8 @@ public class CreateUITable { new File(workingFolder).mkdirs(); new File(htmlFile).createNewFile(); - try (OutputStreamWriter writer = - new OutputStreamWriter(new FileOutputStream(htmlFile), StandardCharsets.UTF_8)) { + try (OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(htmlFile), + StandardCharsets.UTF_8)) { CreateUITable tableCreator = new CreateUITable(); writer.append("\n"); writer.append("back\n"); @@ -109,7 +111,8 @@ public class CreateUITable { builder.append(StringUtil.repeat(IDENT, ident)).append("

    ").append("Miscellaneous").append("

    \n"); appendTable(builder, defaults.entrySet().stream() .filter(entry -> miscKeys.contains(entry.getKey().toString())) - .collect(Collectors.toSet()), ident); + .collect(Collectors.toSet()), + ident); return builder.toString(); } @@ -127,15 +130,17 @@ public class CreateUITable { final String group, final String heading) { builder.append(StringUtil.repeat(IDENT, ident)).append("

    ").append(heading).append("

    \n"); Set> values = defaults - .entrySet().stream() - .filter(entry -> { - String key = entry.getKey().toString(); - if (key.startsWith("%")) return true; - if (key.endsWith("UI")) return key.substring(0, key.length() - 2).equals(group); - if (key.contains(".")) return key.split("\\.")[0].equals(group); - return key.equals(group); - }) - .collect(Collectors.toSet()); + .entrySet().stream() + .filter(entry -> { + String key = entry.getKey().toString(); + if (key.startsWith("%")) return true; + if (key.endsWith("UI")) + return key.substring(0, key.length() - 2).equals(group); + if (key.contains(".")) + return key.split("\\.")[0].equals(group); + return key.equals(group); + }) + .collect(Collectors.toSet()); appendTable(builder, values, ident); values.forEach(entry -> defaults.remove(entry.getKey())); builder.append('\n'); @@ -193,12 +198,12 @@ public class CreateUITable { appendData(builder, key, ident + 1); Object value = entry.getValue(); if (value instanceof Pair) { - appendData(builder, parseValue(((Pair) value).getSecond()), ident + 1); //Value - appendData(builder, ((Pair) value).getFirst(), ident + 1); //Reference + appendData(builder, parseValue(((Pair) value).getSecond()), ident + 1); // Value + appendData(builder, ((Pair) value).getFirst(), ident + 1); // Reference builder.append(parsePreview(key, ((Pair) value).getSecond(), ident + 1)); } else { - appendData(builder, parseValue(value), ident + 1); //Value - appendData(builder, "", ident + 1); //Reference + appendData(builder, parseValue(value), ident + 1); // Value + appendData(builder, "", ident + 1); // Reference builder.append(parsePreview(key, value, ident + 1)); } builder.append(StringUtil.repeat(IDENT, ident)).append("\n"); @@ -310,7 +315,7 @@ public class CreateUITable { private void readFile(final URL url, final StringBuilder builder, final int ident) throws IOException { InputStream inputStream = url.openStream(); InputStreamReader isReader = new InputStreamReader(inputStream); - //Creating a BufferedReader object + // Creating a BufferedReader object BufferedReader reader = new BufferedReader(isReader); String str; while ((str = reader.readLine()) != null) { diff --git a/core/src/test/java/icon/AllIcons.java b/core/src/test/java/icon/AllIcons.java index 108cbb92..d8a8b06c 100644 --- a/core/src/test/java/icon/AllIcons.java +++ b/core/src/test/java/icon/AllIcons.java @@ -20,19 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package icon; -import com.github.weisj.darklaf.DarkLaf; -import com.github.weisj.darklaf.components.OverlayScrollPane; -import com.github.weisj.darklaf.icons.IconLoader; -import com.github.weisj.darklaf.icons.ThemedSVGIcon; -import com.github.weisj.darklaf.util.Pair; -import com.kitfox.svg.app.beans.SVGIcon; -import ui.ComponentDemo; - -import javax.swing.*; -import javax.swing.event.ListDataListener; import java.awt.*; import java.io.File; import java.io.IOException; @@ -42,15 +33,29 @@ import java.nio.file.FileSystem; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; -import java.util.List; import java.util.*; +import java.util.List; import java.util.stream.Stream; +import javax.swing.*; +import javax.swing.event.ListDataListener; + +import ui.ComponentDemo; + +import com.github.weisj.darklaf.DarkLaf; +import com.github.weisj.darklaf.components.OverlayScrollPane; +import com.github.weisj.darklaf.icons.IconLoader; +import com.github.weisj.darklaf.icons.ThemedSVGIcon; +import com.github.weisj.darklaf.util.Pair; +import com.kitfox.svg.app.beans.SVGIcon; + public class AllIcons implements ComponentDemo { private static final String[] FOLDERS = new String[]{ - "icons/control", "icons/dialog", "icons/files", "icons/indicator", "icons/menu", "icons/misc", - "icons/navigation", "platform/windows/icons/window", "platform/windows/icons" + "icons/control", "icons/dialog", "icons/files", + "icons/indicator", "icons/menu", "icons/misc", + "icons/navigation", "platform/windows/icons/window", + "platform/windows/icons" }; public static void main(final String[] args) { @@ -73,19 +78,16 @@ public class AllIcons implements ComponentDemo { } @Override - public void addListDataListener(final ListDataListener l) { - } + public void addListDataListener(final ListDataListener l) {} @Override - public void removeListDataListener(final ListDataListener l) { - } + public void removeListDataListener(final ListDataListener l) {} }); list.setLayoutOrientation(JList.VERTICAL); list.setCellRenderer(new IconListRenderer()); return new OverlayScrollPane(list); } - private List> loadIcons() { List> list = new ArrayList<>(); try { @@ -117,7 +119,8 @@ public class AllIcons implements ComponentDemo { } public Pair, Optional> walk(final String path, final Class clazz) - throws URISyntaxException, IOException { + throws URISyntaxException, + IOException { URI uri = clazz.getResource(path).toURI(); if ("jar".equals(uri.getScheme())) { FileSystem fileSystem = FileSystems.newFileSystem(uri, Collections.emptyMap()); @@ -126,7 +129,9 @@ public class AllIcons implements ComponentDemo { return new Pair<>(Files.walk(resourcePath, 1), Optional.of(fileSystem)); } else { return new Pair<>(Arrays.stream(Optional.ofNullable(new File(uri).listFiles()) - .orElse(new File[0])).map(File::toPath), Optional.empty()); + .orElse(new File[0])) + .map(File::toPath), + Optional.empty()); } } diff --git a/core/src/test/java/icon/IconDemo.java b/core/src/test/java/icon/IconDemo.java index d169c066..8988ea73 100644 --- a/core/src/test/java/icon/IconDemo.java +++ b/core/src/test/java/icon/IconDemo.java @@ -20,20 +20,23 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package icon; +import java.awt.*; + +import javax.swing.*; + +import ui.ComponentDemo; +import ui.DemoPanel; + import com.github.weisj.darklaf.LafManager; import com.github.weisj.darklaf.components.color.QuickColorChooser; import com.github.weisj.darklaf.icons.IconLoader; import com.github.weisj.darklaf.icons.UIAwareIcon; import com.github.weisj.darklaf.theme.DarculaTheme; import com.github.weisj.darklaf.theme.IntelliJTheme; -import ui.ComponentDemo; -import ui.DemoPanel; - -import javax.swing.*; -import java.awt.*; public class IconDemo implements ComponentDemo { @@ -67,11 +70,13 @@ public class IconDemo implements ComponentDemo { JPanel controlPanel = panel.addControls(); controlPanel.setLayout(new FlowLayout()); - controlPanel.add(new JToggleButton("Light/Dark") {{ - putClientProperty("JToggleButton.variant", "slider"); - addActionListener(e -> LafManager.installTheme(isSelected() ? new DarculaTheme() - : new IntelliJTheme())); - }}); + controlPanel.add(new JToggleButton("Light/Dark") { + { + putClientProperty("JToggleButton.variant", "slider"); + addActionListener(e -> LafManager.installTheme(isSelected() ? new DarculaTheme() + : new IntelliJTheme())); + } + }); controlPanel.add(new QuickColorChooser("Themed icon color", UIManager.getColor("TestIcon.color"), IconDemo::updateThemedIconColor)); diff --git a/core/src/test/java/icon/RotatableIconDemo.java b/core/src/test/java/icon/RotatableIconDemo.java index ebf89cd8..f7934b24 100644 --- a/core/src/test/java/icon/RotatableIconDemo.java +++ b/core/src/test/java/icon/RotatableIconDemo.java @@ -20,15 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package icon; -import com.github.weisj.darklaf.icons.RotatableIcon; +import javax.swing.*; + import ui.ComponentDemo; import ui.DemoPanel; import ui.DemoResources; -import javax.swing.*; +import com.github.weisj.darklaf.icons.RotatableIcon; public class RotatableIconDemo implements ComponentDemo { diff --git a/core/src/test/java/misc/GenerateColors.java b/core/src/test/java/misc/GenerateColors.java index 965d77df..70656b59 100644 --- a/core/src/test/java/misc/GenerateColors.java +++ b/core/src/test/java/misc/GenerateColors.java @@ -20,14 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package misc; -import com.github.weisj.darklaf.color.DarkColorModelHSL; - import java.awt.*; import java.util.logging.Logger; +import com.github.weisj.darklaf.color.DarkColorModelHSL; + /** * Used to generate the color swatches for ColorChooser. */ diff --git a/core/src/test/java/theme/MyCustomTheme.java b/core/src/test/java/theme/MyCustomTheme.java index c3d87cd7..dfa13398 100644 --- a/core/src/test/java/theme/MyCustomTheme.java +++ b/core/src/test/java/theme/MyCustomTheme.java @@ -20,17 +20,19 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package theme; +import java.util.Properties; + +import javax.swing.*; + import com.github.weisj.darklaf.theme.Theme; import com.github.weisj.darklaf.theme.info.ColorToneRule; import com.github.weisj.darklaf.theme.info.PresetIconRule; import com.github.weisj.darklaf.util.SystemInfo; -import javax.swing.*; -import java.util.Properties; - public class MyCustomTheme extends Theme { @Override @@ -89,5 +91,4 @@ public class MyCustomTheme extends Theme { public ColorToneRule getColorToneRule() { return ColorToneRule.LIGHT; } - } diff --git a/core/src/test/java/ui/ComponentDemo.java b/core/src/test/java/ui/ComponentDemo.java index 86c5390e..6111bebc 100644 --- a/core/src/test/java/ui/ComponentDemo.java +++ b/core/src/test/java/ui/ComponentDemo.java @@ -20,19 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui; -import com.github.weisj.darklaf.LafManager; -import com.github.weisj.darklaf.settings.ThemeSettings; -import com.github.weisj.darklaf.theme.Theme; -import com.github.weisj.darklaf.theme.info.ColorToneRule; -import com.github.weisj.darklaf.theme.info.ContrastRule; -import com.github.weisj.darklaf.theme.info.PreferredThemeStyle; - -import javax.swing.*; -import javax.swing.event.MenuEvent; -import javax.swing.event.MenuListener; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.WindowAdapter; @@ -41,6 +32,17 @@ import java.util.Enumeration; import java.util.Objects; import java.util.Optional; +import javax.swing.*; +import javax.swing.event.MenuEvent; +import javax.swing.event.MenuListener; + +import com.github.weisj.darklaf.LafManager; +import com.github.weisj.darklaf.settings.ThemeSettings; +import com.github.weisj.darklaf.theme.Theme; +import com.github.weisj.darklaf.theme.info.ColorToneRule; +import com.github.weisj.darklaf.theme.info.ContrastRule; +import com.github.weisj.darklaf.theme.info.PreferredThemeStyle; + public interface ComponentDemo { static Theme getTheme() { @@ -88,8 +90,7 @@ public interface ComponentDemo { } default WindowListener createWindowListener() { - return new WindowAdapter() { - }; + return new WindowAdapter() {}; } static JMenu createThemeMenu() { @@ -102,7 +103,8 @@ public interface ComponentDemo { @Override public void menuSelected(final MenuEvent e) { bg.setSelected(Optional.ofNullable(getSelectedThemeButton(bg)) - .map(AbstractButton::getModel).orElse(null), true); + .map(AbstractButton::getModel).orElse(null), + true); } @Override diff --git a/core/src/test/java/ui/DemoPanel.java b/core/src/test/java/ui/DemoPanel.java index 468af73b..81da6d6d 100644 --- a/core/src/test/java/ui/DemoPanel.java +++ b/core/src/test/java/ui/DemoPanel.java @@ -20,14 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui; -import com.github.weisj.darklaf.components.border.DarkBorders; -import net.miginfocom.swing.MigLayout; +import java.awt.*; import javax.swing.*; -import java.awt.*; + +import net.miginfocom.swing.MigLayout; + +import com.github.weisj.darklaf.components.border.DarkBorders; public class DemoPanel extends JPanel { diff --git a/core/src/test/java/ui/DemoResources.java b/core/src/test/java/ui/DemoResources.java index b8220da3..a702d2c3 100644 --- a/core/src/test/java/ui/DemoResources.java +++ b/core/src/test/java/ui/DemoResources.java @@ -20,37 +20,37 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui; -import com.github.weisj.darklaf.icons.IconLoader; - import javax.swing.*; +import com.github.weisj.darklaf.icons.IconLoader; + public class DemoResources { - public static final String LOREM_IPSUM = - "Lorem ipsum dolor sit amet, consectetur adipiscing elit. In tempor quis nibh a semper. Nullam\n" - + " auctor, erat non viverra commodo, libero orci aliquam quam, ac interdum nunc est sed\n " - + "ligula. Aliquam vel velit non dolor accumsan blandit id eu metus. Aenean iaculis urna in\n " - + "placerat aliquam. Aliquam dui quam, bibendum sed magna in, cursus ornare est. Quisque\n " - + "tempor nunc quis nunc tempor convallis. Vestibulum tristique luctus ante, ac hendrerit dui.\n\n" - + "Donec ut maximus augue. Nam eleifend maximus scelerisque. Duis varius accumsan est, non\n " - + "aliquam dolor. Aenean iaculis nibh in aliquam viverra. Sed laoreet, urna ut facilisis\n " - + "convallis, arcu turpis vestibulum augue, id convallis tellus metus nec orci. Lorem ipsum\n " - + "dolor sit amet, consectetur adipiscing elit. Donec hendrerit purus velit, at blandit elit\n " - + "luctus ut. Proin diam nisl, sodales vitae dignissim nec, eleifend eu libero. Maecenas odio\n" - + " ligula, fermentum eget nisl vel, cursus tristique est. In nec nibh nec dui tempor\n " - + "ullamcorper. Praesent tincidunt luctus sem, ut luctus dolor commodo non. Nulla consectetur\n" - + " facilisis dolor, in facilisis ligula fringilla et. Cras id placerat libero. Donec\n " - + "vehicula orci a quam rutrum, eu efficitur lorem iaculis. Aenean varius nisi in dictum\n " - + "accumsan.\n\n" - + "Nulla massa ipsum, consectetur non gravida ut, blandit quis velit. Ut pretium quam aliquam\n" - + " diam porttitor mattis. Nam ullamcorper, felis ut iaculis iaculis, nunc odio pulvinar \n" - + "enim, vitae iaculis turpis sapien iaculis metus. Donec rutrum varius augue in dictum. Cras\n" - + " vestibulum vitae mauris ut finibus. Ut dictum imperdiet lorem et imperdiet. Vivamus \n" - + "semper tempor dolor eu porta. Sed at vehicula nisl. Pellentesque ut lorem tincidunt, \n" - + "elementum ligula at, porta turpis. Praesent feugiat dolor diam, at facilisis metus gravida\n" - + " non. Aliquam quis pellentesque nibh. Sed vestibulum porttitor nisi. In vitae malesuada\n " - + "sapien."; + public static final String LOREM_IPSUM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. In tempor quis nibh a semper. Nullam\n" + + " auctor, erat non viverra commodo, libero orci aliquam quam, ac interdum nunc est sed\n " + + "ligula. Aliquam vel velit non dolor accumsan blandit id eu metus. Aenean iaculis urna in\n " + + "placerat aliquam. Aliquam dui quam, bibendum sed magna in, cursus ornare est. Quisque\n " + + "tempor nunc quis nunc tempor convallis. Vestibulum tristique luctus ante, ac hendrerit dui.\n\n" + + "Donec ut maximus augue. Nam eleifend maximus scelerisque. Duis varius accumsan est, non\n " + + "aliquam dolor. Aenean iaculis nibh in aliquam viverra. Sed laoreet, urna ut facilisis\n " + + "convallis, arcu turpis vestibulum augue, id convallis tellus metus nec orci. Lorem ipsum\n " + + "dolor sit amet, consectetur adipiscing elit. Donec hendrerit purus velit, at blandit elit\n " + + "luctus ut. Proin diam nisl, sodales vitae dignissim nec, eleifend eu libero. Maecenas odio\n" + + " ligula, fermentum eget nisl vel, cursus tristique est. In nec nibh nec dui tempor\n " + + "ullamcorper. Praesent tincidunt luctus sem, ut luctus dolor commodo non. Nulla consectetur\n" + + " facilisis dolor, in facilisis ligula fringilla et. Cras id placerat libero. Donec\n " + + "vehicula orci a quam rutrum, eu efficitur lorem iaculis. Aenean varius nisi in dictum\n " + + "accumsan.\n\n" + + "Nulla massa ipsum, consectetur non gravida ut, blandit quis velit. Ut pretium quam aliquam\n" + + " diam porttitor mattis. Nam ullamcorper, felis ut iaculis iaculis, nunc odio pulvinar \n" + + "enim, vitae iaculis turpis sapien iaculis metus. Donec rutrum varius augue in dictum. Cras\n" + + " vestibulum vitae mauris ut finibus. Ut dictum imperdiet lorem et imperdiet. Vivamus \n" + + "semper tempor dolor eu porta. Sed at vehicula nisl. Pellentesque ut lorem tincidunt, \n" + + "elementum ligula at, porta turpis. Praesent feugiat dolor diam, at facilisis metus gravida\n" + + " non. Aliquam quis pellentesque nibh. Sed vestibulum porttitor nisi. In vitae malesuada\n " + + "sapien."; public static Icon FOLDER_ICON = IconLoader.get().getIcon("files/folder.svg", 19, 19, true); } diff --git a/core/src/test/java/ui/SolidColorComponent.java b/core/src/test/java/ui/SolidColorComponent.java index f3899a4d..c77d54fc 100644 --- a/core/src/test/java/ui/SolidColorComponent.java +++ b/core/src/test/java/ui/SolidColorComponent.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui; -import javax.swing.*; import java.awt.*; +import javax.swing.*; + public class SolidColorComponent extends JPanel { public SolidColorComponent(final Color color, final int width, final int height) { diff --git a/core/src/test/java/ui/button/ButtonDemo.java b/core/src/test/java/ui/button/ButtonDemo.java index 2a1a79af..62fd4f18 100644 --- a/core/src/test/java/ui/button/ButtonDemo.java +++ b/core/src/test/java/ui/button/ButtonDemo.java @@ -20,18 +20,21 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.button; -import com.github.weisj.darklaf.components.color.QuickColorChooser; -import com.github.weisj.darklaf.ui.button.DarkButtonUI; -import com.github.weisj.darklaf.util.AlignmentExt; +import java.awt.*; + +import javax.swing.*; + import ui.ComponentDemo; import ui.DemoPanel; import ui.DemoResources; -import javax.swing.*; -import java.awt.*; +import com.github.weisj.darklaf.components.color.QuickColorChooser; +import com.github.weisj.darklaf.ui.button.DarkButtonUI; +import com.github.weisj.darklaf.util.AlignmentExt; public class ButtonDemo implements ComponentDemo { @@ -45,87 +48,116 @@ public class ButtonDemo implements ComponentDemo { JButton button = new JButton("Test Button", icon); DemoPanel panel = new DemoPanel(button); JPanel controlPanel = panel.addControls(); - controlPanel.add(new JCheckBox("enabled") {{ - setSelected(button.isEnabled()); - addActionListener(e -> button.setEnabled(isSelected())); - }}); - controlPanel.add(new JCheckBox("focusable") {{ - setSelected(button.isFocusable()); - addActionListener(e -> button.setFocusable(isSelected())); - }}); - controlPanel.add(new JCheckBox("default") {{ - setSelected(button.isDefaultButton()); - addActionListener(e -> SwingUtilities.getRootPane(button).setDefaultButton(isSelected() ? button : null)); - }}); - controlPanel.add(new JCheckBox("LeftToRight") {{ - setSelected(button.getComponentOrientation().isLeftToRight()); - addActionListener(e -> button.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT - : ComponentOrientation.RIGHT_TO_LEFT)); - }}); - controlPanel.add(new JCheckBox("Rollover") {{ - setSelected(button.isRolloverEnabled()); - addActionListener(e -> button.setRolloverEnabled(isSelected())); - }}); - controlPanel.add(new JCheckBox(DarkButtonUI.KEY_SQUARE) {{ - setSelected(false); - addActionListener(e -> button.putClientProperty(DarkButtonUI.KEY_SQUARE, isSelected())); - }}); - controlPanel.add(new JCheckBox(DarkButtonUI.KEY_THIN) {{ - setSelected(false); - addActionListener(e -> button.putClientProperty(DarkButtonUI.KEY_THIN, isSelected())); - }}); - controlPanel.add(new JCheckBox(DarkButtonUI.KEY_ALT_ARC) {{ - setSelected(false); - addActionListener(e -> button.putClientProperty(DarkButtonUI.KEY_ALT_ARC, isSelected())); - }}); - controlPanel.add(new JCheckBox("Button.defaultButtonFollowsFocus") {{ - setSelected(UIManager.getBoolean("Button.defaultButtonFollowsFocus")); - addActionListener(e -> UIManager.put("Button.defaultButtonFollowsFocus", isSelected())); - }}); + controlPanel.add(new JCheckBox("enabled") { + { + setSelected(button.isEnabled()); + addActionListener(e -> button.setEnabled(isSelected())); + } + }); + controlPanel.add(new JCheckBox("focusable") { + { + setSelected(button.isFocusable()); + addActionListener(e -> button.setFocusable(isSelected())); + } + }); + controlPanel.add(new JCheckBox("default") { + { + setSelected(button.isDefaultButton()); + addActionListener(e -> SwingUtilities.getRootPane(button) + .setDefaultButton(isSelected() ? button : null)); + } + }); + controlPanel.add(new JCheckBox("LeftToRight") { + { + setSelected(button.getComponentOrientation().isLeftToRight()); + addActionListener(e -> button.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT + : ComponentOrientation.RIGHT_TO_LEFT)); + } + }); + controlPanel.add(new JCheckBox("Rollover") { + { + setSelected(button.isRolloverEnabled()); + addActionListener(e -> button.setRolloverEnabled(isSelected())); + } + }); + controlPanel.add(new JCheckBox(DarkButtonUI.KEY_SQUARE) { + { + setSelected(false); + addActionListener(e -> button.putClientProperty(DarkButtonUI.KEY_SQUARE, isSelected())); + } + }); + controlPanel.add(new JCheckBox(DarkButtonUI.KEY_THIN) { + { + setSelected(false); + addActionListener(e -> button.putClientProperty(DarkButtonUI.KEY_THIN, isSelected())); + } + }); + controlPanel.add(new JCheckBox(DarkButtonUI.KEY_ALT_ARC) { + { + setSelected(false); + addActionListener(e -> button.putClientProperty(DarkButtonUI.KEY_ALT_ARC, isSelected())); + } + }); + controlPanel.add(new JCheckBox("Button.defaultButtonFollowsFocus") { + { + setSelected(UIManager.getBoolean("Button.defaultButtonFollowsFocus")); + addActionListener(e -> UIManager.put("Button.defaultButtonFollowsFocus", isSelected())); + } + }); controlPanel = panel.addControls(); - controlPanel.add(new JCheckBox("Text enabled") {{ - setSelected(true); - addActionListener(e -> button.setText(isSelected() ? "Test Button" : null)); - }}); - controlPanel.add(new JCheckBox("Icon enabled") {{ - setSelected(true); - addActionListener(e -> button.setIcon(isSelected() ? icon : null)); - }}); + controlPanel.add(new JCheckBox("Text enabled") { + { + setSelected(true); + addActionListener(e -> button.setText(isSelected() ? "Test Button" : null)); + } + }); + controlPanel.add(new JCheckBox("Icon enabled") { + { + setSelected(true); + addActionListener(e -> button.setIcon(isSelected() ? icon : null)); + } + }); controlPanel = panel.addControls(); controlPanel.add(new QuickColorChooser(DarkButtonUI.KEY_HOVER_COLOR, Color.BLACK, (b, c) -> button - .putClientProperty(DarkButtonUI.KEY_HOVER_COLOR, b ? c : null))); + .putClientProperty(DarkButtonUI.KEY_HOVER_COLOR, + b ? c : null))); controlPanel.add(new QuickColorChooser(DarkButtonUI.KEY_HOVER_COLOR, Color.BLACK, (b, c) -> button - .putClientProperty(DarkButtonUI.KEY_CLICK_COLOR, b ? c : null))); + .putClientProperty(DarkButtonUI.KEY_CLICK_COLOR, + b ? c : null))); controlPanel = panel.addControls(); controlPanel.add(new JLabel(DarkButtonUI.KEY_VARIANT + ":")); - controlPanel.add(new JComboBox() {{ - addItem(DarkButtonUI.VARIANT_NONE); - addItem(DarkButtonUI.VARIANT_BORDERLESS); - addItem(DarkButtonUI.VARIANT_BORDERLESS_RECTANGULAR); - addItem(DarkButtonUI.VARIANT_ONLY_LABEL); - setSelectedItem(DarkButtonUI.VARIANT_NONE); - addItemListener(e -> button.putClientProperty(DarkButtonUI.KEY_VARIANT, e.getItem())); - }}); - controlPanel.add(new JLabel(DarkButtonUI.KEY_CORNER + ":")); - controlPanel.add(new JComboBox() {{ - addItem("None"); - for (AlignmentExt a : AlignmentExt.values()) { - addItem(a.name()); + controlPanel.add(new JComboBox() { + { + addItem(DarkButtonUI.VARIANT_NONE); + addItem(DarkButtonUI.VARIANT_BORDERLESS); + addItem(DarkButtonUI.VARIANT_BORDERLESS_RECTANGULAR); + addItem(DarkButtonUI.VARIANT_ONLY_LABEL); + setSelectedItem(DarkButtonUI.VARIANT_NONE); + addItemListener(e -> button.putClientProperty(DarkButtonUI.KEY_VARIANT, e.getItem())); } - setSelectedItem("None"); - addItemListener(e -> { - if ("None".equals(e.getItem())) { - button.putClientProperty(DarkButtonUI.KEY_CORNER, null); - } else { - button.putClientProperty(DarkButtonUI.KEY_CORNER, AlignmentExt.valueOf(e.getItem().toString())); + }); + controlPanel.add(new JLabel(DarkButtonUI.KEY_CORNER + ":")); + controlPanel.add(new JComboBox() { + { + addItem("None"); + for (AlignmentExt a : AlignmentExt.values()) { + addItem(a.name()); } - }); - }}); + setSelectedItem("None"); + addItemListener(e -> { + if ("None".equals(e.getItem())) { + button.putClientProperty(DarkButtonUI.KEY_CORNER, null); + } else { + button.putClientProperty(DarkButtonUI.KEY_CORNER, AlignmentExt.valueOf(e.getItem().toString())); + } + }); + } + }); return panel; } @@ -133,5 +165,4 @@ public class ButtonDemo implements ComponentDemo { public String getTitle() { return "Button Demo"; } - } diff --git a/core/src/test/java/ui/button/GroupedButtonDemo.java b/core/src/test/java/ui/button/GroupedButtonDemo.java index 11117e64..034e2ef9 100644 --- a/core/src/test/java/ui/button/GroupedButtonDemo.java +++ b/core/src/test/java/ui/button/GroupedButtonDemo.java @@ -20,16 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.button; -import com.github.weisj.darklaf.icons.IconLoader; -import com.github.weisj.darklaf.ui.button.DarkButtonUI; -import com.github.weisj.darklaf.util.AlignmentExt; +import javax.swing.*; + import ui.ComponentDemo; import ui.DemoPanel; -import javax.swing.*; +import com.github.weisj.darklaf.icons.IconLoader; +import com.github.weisj.darklaf.ui.button.DarkButtonUI; +import com.github.weisj.darklaf.util.AlignmentExt; public class GroupedButtonDemo implements ComponentDemo { @@ -63,15 +65,17 @@ public class GroupedButtonDemo implements ComponentDemo { protected AbstractButton createButton(final Icon icon, final Icon selected, final ButtonGroup bg, final AlignmentExt a, final boolean isSelected, final AbstractButton prev) { - return new JToggleButton(icon) {{ - setSelectedIcon(selected); - putClientProperty(DarkButtonUI.KEY_THIN, true); - putClientProperty(DarkButtonUI.KEY_CORNER, a); - if (prev != null) prev.putClientProperty(DarkButtonUI.KEY_RIGHT_NEIGHBOUR, this); - putClientProperty(DarkButtonUI.KEY_LEFT_NEIGHBOUR, prev); - setSelected(isSelected); - bg.add(this); - }}; + return new JToggleButton(icon) { + { + setSelectedIcon(selected); + putClientProperty(DarkButtonUI.KEY_THIN, true); + putClientProperty(DarkButtonUI.KEY_CORNER, a); + if (prev != null) prev.putClientProperty(DarkButtonUI.KEY_RIGHT_NEIGHBOUR, this); + putClientProperty(DarkButtonUI.KEY_LEFT_NEIGHBOUR, prev); + setSelected(isSelected); + bg.add(this); + } + }; } @Override diff --git a/core/src/test/java/ui/button/ToggleButtonDemo.java b/core/src/test/java/ui/button/ToggleButtonDemo.java index 2d19b3de..ffb24f0a 100644 --- a/core/src/test/java/ui/button/ToggleButtonDemo.java +++ b/core/src/test/java/ui/button/ToggleButtonDemo.java @@ -20,17 +20,20 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.button; -import com.github.weisj.darklaf.ui.togglebutton.DarkToggleButtonUI; -import com.github.weisj.darklaf.ui.togglebutton.ToggleButtonConstants; +import java.awt.*; + +import javax.swing.*; + import ui.ComponentDemo; import ui.DemoPanel; import ui.DemoResources; -import javax.swing.*; -import java.awt.*; +import com.github.weisj.darklaf.ui.togglebutton.DarkToggleButtonUI; +import com.github.weisj.darklaf.ui.togglebutton.ToggleButtonConstants; public class ToggleButtonDemo implements ComponentDemo { @@ -45,36 +48,48 @@ public class ToggleButtonDemo implements ComponentDemo { DemoPanel panel = new DemoPanel(button); JPanel controlPanel = panel.addControls(); - controlPanel.add(new JCheckBox("enabled") {{ - setSelected(button.isEnabled()); - addActionListener(e -> button.setEnabled(isSelected())); - }}); - controlPanel.add(new JCheckBox("LeftToRight") {{ - setSelected(button.getComponentOrientation().isLeftToRight()); - addActionListener(e -> button.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT - : ComponentOrientation.RIGHT_TO_LEFT)); - }}); - controlPanel.add(new JCheckBox(DarkToggleButtonUI.KEY_IS_TREE_EDITOR) {{ - setSelected(false); - addActionListener(e -> button.putClientProperty(DarkToggleButtonUI.KEY_IS_TREE_EDITOR, isSelected())); - }}); - controlPanel.add(new JCheckBox(DarkToggleButtonUI.KEY_IS_TABLE_EDITOR) {{ - setSelected(false); - addActionListener(e -> button.putClientProperty(DarkToggleButtonUI.KEY_IS_TABLE_EDITOR, isSelected())); - }}); - controlPanel.add(new JCheckBox("Rollover") {{ - setSelected(button.isRolloverEnabled()); - addActionListener(e -> button.setRolloverEnabled(isSelected())); - }}, "span"); + controlPanel.add(new JCheckBox("enabled") { + { + setSelected(button.isEnabled()); + addActionListener(e -> button.setEnabled(isSelected())); + } + }); + controlPanel.add(new JCheckBox("LeftToRight") { + { + setSelected(button.getComponentOrientation().isLeftToRight()); + addActionListener(e -> button.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT + : ComponentOrientation.RIGHT_TO_LEFT)); + } + }); + controlPanel.add(new JCheckBox(DarkToggleButtonUI.KEY_IS_TREE_EDITOR) { + { + setSelected(false); + addActionListener(e -> button.putClientProperty(DarkToggleButtonUI.KEY_IS_TREE_EDITOR, isSelected())); + } + }); + controlPanel.add(new JCheckBox(DarkToggleButtonUI.KEY_IS_TABLE_EDITOR) { + { + setSelected(false); + addActionListener(e -> button.putClientProperty(DarkToggleButtonUI.KEY_IS_TABLE_EDITOR, isSelected())); + } + }); + controlPanel.add(new JCheckBox("Rollover") { + { + setSelected(button.isRolloverEnabled()); + addActionListener(e -> button.setRolloverEnabled(isSelected())); + } + }, "span"); controlPanel = panel.addControls(); controlPanel.add(new JLabel(ToggleButtonConstants.KEY_VARIANT + ":")); - controlPanel.add(new JComboBox() {{ - addItem(ToggleButtonConstants.VARIANT_SLIDER); - addItem("none"); - setSelectedItem("none"); - addItemListener(e -> button.putClientProperty("JToggleButton.variant", e.getItem())); - }}); + controlPanel.add(new JComboBox() { + { + addItem(ToggleButtonConstants.VARIANT_SLIDER); + addItem("none"); + setSelectedItem("none"); + addItemListener(e -> button.putClientProperty("JToggleButton.variant", e.getItem())); + } + }); return panel; } diff --git a/core/src/test/java/ui/checkBox/CheckBoxDemo.java b/core/src/test/java/ui/checkBox/CheckBoxDemo.java index 18994532..fa94f6f3 100644 --- a/core/src/test/java/ui/checkBox/CheckBoxDemo.java +++ b/core/src/test/java/ui/checkBox/CheckBoxDemo.java @@ -20,15 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.checkBox; -import com.github.weisj.darklaf.ui.togglebutton.DarkToggleButtonUI; +import java.awt.*; + +import javax.swing.*; + import ui.ComponentDemo; import ui.DemoPanel; -import javax.swing.*; -import java.awt.*; +import com.github.weisj.darklaf.ui.togglebutton.DarkToggleButtonUI; public class CheckBoxDemo implements ComponentDemo { @@ -42,27 +45,37 @@ public class CheckBoxDemo implements ComponentDemo { DemoPanel panel = new DemoPanel(button); JPanel controlPanel = panel.addControls(1); - controlPanel.add(new JCheckBox("enabled") {{ - setSelected(button.isEnabled()); - addActionListener(e -> button.setEnabled(isSelected())); - }}); - controlPanel.add(new JCheckBox("LeftToRight") {{ - setSelected(button.getComponentOrientation().isLeftToRight()); - addActionListener(e -> button.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT - : ComponentOrientation.RIGHT_TO_LEFT)); - }}); - controlPanel.add(new JCheckBox("Rollover") {{ - setSelected(button.isRolloverEnabled()); - addActionListener(e -> button.setRolloverEnabled(isSelected())); - }}); - controlPanel.add(new JCheckBox(DarkToggleButtonUI.KEY_IS_TREE_EDITOR) {{ - setSelected(false); - addActionListener(e -> button.putClientProperty(DarkToggleButtonUI.KEY_IS_TREE_EDITOR, isSelected())); - }}); - controlPanel.add(new JCheckBox(DarkToggleButtonUI.KEY_IS_TABLE_EDITOR) {{ - setSelected(false); - addActionListener(e -> button.putClientProperty(DarkToggleButtonUI.KEY_IS_TABLE_EDITOR, isSelected())); - }}); + controlPanel.add(new JCheckBox("enabled") { + { + setSelected(button.isEnabled()); + addActionListener(e -> button.setEnabled(isSelected())); + } + }); + controlPanel.add(new JCheckBox("LeftToRight") { + { + setSelected(button.getComponentOrientation().isLeftToRight()); + addActionListener(e -> button.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT + : ComponentOrientation.RIGHT_TO_LEFT)); + } + }); + controlPanel.add(new JCheckBox("Rollover") { + { + setSelected(button.isRolloverEnabled()); + addActionListener(e -> button.setRolloverEnabled(isSelected())); + } + }); + controlPanel.add(new JCheckBox(DarkToggleButtonUI.KEY_IS_TREE_EDITOR) { + { + setSelected(false); + addActionListener(e -> button.putClientProperty(DarkToggleButtonUI.KEY_IS_TREE_EDITOR, isSelected())); + } + }); + controlPanel.add(new JCheckBox(DarkToggleButtonUI.KEY_IS_TABLE_EDITOR) { + { + setSelected(false); + addActionListener(e -> button.putClientProperty(DarkToggleButtonUI.KEY_IS_TABLE_EDITOR, isSelected())); + } + }); return panel; } @@ -75,9 +88,11 @@ public class CheckBoxDemo implements ComponentDemo { public JMenuBar createMenuBar() { JMenuBar menuBar = new JMenuBar(); menuBar.add(ComponentDemo.createThemeMenu()); - menuBar.add(new JMenu("Demo") {{ - add(new JCheckBoxMenuItem("CheckBox menu item")); - }}); + menuBar.add(new JMenu("Demo") { + { + add(new JCheckBoxMenuItem("CheckBox menu item")); + } + }); return menuBar; } } diff --git a/core/src/test/java/ui/checkBox/TriCheckBoxDemo.java b/core/src/test/java/ui/checkBox/TriCheckBoxDemo.java index 02378d94..91f18f36 100644 --- a/core/src/test/java/ui/checkBox/TriCheckBoxDemo.java +++ b/core/src/test/java/ui/checkBox/TriCheckBoxDemo.java @@ -20,17 +20,20 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.checkBox; -import com.github.weisj.darklaf.components.tristate.TristateCheckBox; -import com.github.weisj.darklaf.components.tristate.TristateCheckBoxMenuItem; -import com.github.weisj.darklaf.ui.togglebutton.DarkToggleButtonUI; +import java.awt.*; + +import javax.swing.*; + import ui.ComponentDemo; import ui.DemoPanel; -import javax.swing.*; -import java.awt.*; +import com.github.weisj.darklaf.components.tristate.TristateCheckBox; +import com.github.weisj.darklaf.components.tristate.TristateCheckBoxMenuItem; +import com.github.weisj.darklaf.ui.togglebutton.DarkToggleButtonUI; public class TriCheckBoxDemo implements ComponentDemo { @@ -44,27 +47,37 @@ public class TriCheckBoxDemo implements ComponentDemo { DemoPanel panel = new DemoPanel(button); JPanel controlPanel = panel.addControls(1); - controlPanel.add(new JCheckBox("enabled") {{ - setSelected(button.isEnabled()); - addActionListener(e -> button.setEnabled(isSelected())); - }}); - controlPanel.add(new JCheckBox("LeftToRight") {{ - setSelected(button.getComponentOrientation().isLeftToRight()); - addActionListener(e -> button.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT - : ComponentOrientation.RIGHT_TO_LEFT)); - }}); - controlPanel.add(new JCheckBox("Rollover") {{ - setSelected(button.isRolloverEnabled()); - addActionListener(e -> button.setRolloverEnabled(isSelected())); - }}); - controlPanel.add(new JCheckBox(DarkToggleButtonUI.KEY_IS_TREE_EDITOR) {{ - setSelected(false); - addActionListener(e -> button.putClientProperty(DarkToggleButtonUI.KEY_IS_TREE_EDITOR, isSelected())); - }}); - controlPanel.add(new JCheckBox(DarkToggleButtonUI.KEY_IS_TABLE_EDITOR) {{ - setSelected(false); - addActionListener(e -> button.putClientProperty(DarkToggleButtonUI.KEY_IS_TABLE_EDITOR, isSelected())); - }}); + controlPanel.add(new JCheckBox("enabled") { + { + setSelected(button.isEnabled()); + addActionListener(e -> button.setEnabled(isSelected())); + } + }); + controlPanel.add(new JCheckBox("LeftToRight") { + { + setSelected(button.getComponentOrientation().isLeftToRight()); + addActionListener(e -> button.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT + : ComponentOrientation.RIGHT_TO_LEFT)); + } + }); + controlPanel.add(new JCheckBox("Rollover") { + { + setSelected(button.isRolloverEnabled()); + addActionListener(e -> button.setRolloverEnabled(isSelected())); + } + }); + controlPanel.add(new JCheckBox(DarkToggleButtonUI.KEY_IS_TREE_EDITOR) { + { + setSelected(false); + addActionListener(e -> button.putClientProperty(DarkToggleButtonUI.KEY_IS_TREE_EDITOR, isSelected())); + } + }); + controlPanel.add(new JCheckBox(DarkToggleButtonUI.KEY_IS_TABLE_EDITOR) { + { + setSelected(false); + addActionListener(e -> button.putClientProperty(DarkToggleButtonUI.KEY_IS_TABLE_EDITOR, isSelected())); + } + }); return panel; } @@ -77,9 +90,11 @@ public class TriCheckBoxDemo implements ComponentDemo { public JMenuBar createMenuBar() { JMenuBar menuBar = new JMenuBar(); menuBar.add(ComponentDemo.createThemeMenu()); - menuBar.add(new JMenu("Demo") {{ - add(new TristateCheckBoxMenuItem("TristateCheckBox menu item")); - }}); + menuBar.add(new JMenu("Demo") { + { + add(new TristateCheckBoxMenuItem("TristateCheckBox menu item")); + } + }); return menuBar; } } diff --git a/core/src/test/java/ui/colorChooser/ColorChooserDemo.java b/core/src/test/java/ui/colorChooser/ColorChooserDemo.java index 0af9a3df..2955aa96 100644 --- a/core/src/test/java/ui/colorChooser/ColorChooserDemo.java +++ b/core/src/test/java/ui/colorChooser/ColorChooserDemo.java @@ -20,14 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.colorChooser; -import com.github.weisj.darklaf.LafManager; -import ui.ComponentDemo; +import java.awt.*; import javax.swing.*; -import java.awt.*; + +import ui.ComponentDemo; + +import com.github.weisj.darklaf.LafManager; public final class ColorChooserDemo { diff --git a/core/src/test/java/ui/comboBox/ComboBoxDemo.java b/core/src/test/java/ui/comboBox/ComboBoxDemo.java index eb13dc63..3f504780 100644 --- a/core/src/test/java/ui/comboBox/ComboBoxDemo.java +++ b/core/src/test/java/ui/comboBox/ComboBoxDemo.java @@ -20,16 +20,19 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.comboBox; -import com.github.weisj.darklaf.ui.combobox.ComboBoxConstants; -import com.github.weisj.darklaf.util.PropertyKey; +import java.awt.*; + +import javax.swing.*; + import ui.ComponentDemo; import ui.DemoPanel; -import javax.swing.*; -import java.awt.*; +import com.github.weisj.darklaf.ui.combobox.ComboBoxConstants; +import com.github.weisj.darklaf.util.PropertyKey; public class ComboBoxDemo implements ComponentDemo { @@ -46,27 +49,37 @@ public class ComboBoxDemo implements ComponentDemo { DemoPanel panel = new DemoPanel(comboBox); JPanel controlPanel = panel.addControls(1); - controlPanel.add(new JCheckBox("enabled") {{ - setSelected(comboBox.isEnabled()); - addActionListener(e -> comboBox.setEnabled(isSelected())); - }}); - controlPanel.add(new JCheckBox(PropertyKey.EDITABLE) {{ - setSelected(comboBox.isEditable()); - addActionListener(e -> comboBox.setEditable(isSelected())); - }}); - controlPanel.add(new JCheckBox("LeftToRight") {{ - setSelected(comboBox.getComponentOrientation().isLeftToRight()); - addActionListener(e -> comboBox.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT - : ComponentOrientation.RIGHT_TO_LEFT)); - }}); - controlPanel.add(new JCheckBox(ComboBoxConstants.KEY_IS_TREE_EDITOR) {{ - setSelected(false); - addActionListener(e -> comboBox.putClientProperty(ComboBoxConstants.KEY_IS_TREE_EDITOR, isSelected())); - }}); - controlPanel.add(new JCheckBox(ComboBoxConstants.KEY_IS_TABLE_EDITOR) {{ - setSelected(false); - addActionListener(e -> comboBox.putClientProperty(ComboBoxConstants.KEY_IS_TABLE_EDITOR, isSelected())); - }}); + controlPanel.add(new JCheckBox("enabled") { + { + setSelected(comboBox.isEnabled()); + addActionListener(e -> comboBox.setEnabled(isSelected())); + } + }); + controlPanel.add(new JCheckBox(PropertyKey.EDITABLE) { + { + setSelected(comboBox.isEditable()); + addActionListener(e -> comboBox.setEditable(isSelected())); + } + }); + controlPanel.add(new JCheckBox("LeftToRight") { + { + setSelected(comboBox.getComponentOrientation().isLeftToRight()); + addActionListener(e -> comboBox.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT + : ComponentOrientation.RIGHT_TO_LEFT)); + } + }); + controlPanel.add(new JCheckBox(ComboBoxConstants.KEY_IS_TREE_EDITOR) { + { + setSelected(false); + addActionListener(e -> comboBox.putClientProperty(ComboBoxConstants.KEY_IS_TREE_EDITOR, isSelected())); + } + }); + controlPanel.add(new JCheckBox(ComboBoxConstants.KEY_IS_TABLE_EDITOR) { + { + setSelected(false); + addActionListener(e -> comboBox.putClientProperty(ComboBoxConstants.KEY_IS_TABLE_EDITOR, isSelected())); + } + }); return panel; } diff --git a/core/src/test/java/ui/dialog/CustomDialog.java b/core/src/test/java/ui/dialog/CustomDialog.java index 8d62c9ea..d021140d 100644 --- a/core/src/test/java/ui/dialog/CustomDialog.java +++ b/core/src/test/java/ui/dialog/CustomDialog.java @@ -20,18 +20,19 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ - package ui.dialog; -import javax.swing.*; -import javax.swing.text.DefaultFormatterFactory; import java.awt.*; import java.awt.event.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.text.ParseException; +import javax.swing.*; +import javax.swing.text.DefaultFormatterFactory; + /* 1.4 example used by DialogDemo.java. */ class CustomDialog extends JDialog implements ActionListener, PropertyChangeListener { private String typedText = null; @@ -72,23 +73,23 @@ class CustomDialog extends JDialog implements ActionListener, PropertyChangeList })); textField.setFocusLostBehavior(JFormattedTextField.COMMIT); - //Create an array of the text and components to be displayed. + // Create an array of the text and components to be displayed. String msgString1 = "What was Dr. SEUSS's real last name?"; String msgString2 = "(The answer is \"" + magicWord + "\".)"; Object[] array = {msgString1, msgString2, textField}; - //Create an array specifying the number of dialog buttons - //and their text. + // Create an array specifying the number of dialog buttons + // and their text. Object[] options = {btnString1, btnString2}; - //Create the JOptionPane. + // Create the JOptionPane. optionPane = new JOptionPane(array, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null, options, options[0]); - //Make this dialog display it. + // Make this dialog display it. setContentPane(optionPane); - //Handle window closing correctly. + // Handle window closing correctly. setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { public void windowClosing(final WindowEvent we) { @@ -101,17 +102,17 @@ class CustomDialog extends JDialog implements ActionListener, PropertyChangeList } }); - //Ensure the text field always gets the first focus. + // Ensure the text field always gets the first focus. addComponentListener(new ComponentAdapter() { public void componentShown(final ComponentEvent ce) { textField.requestFocusInWindow(); } }); - //Register an event handler that puts the text into the option pane. + // Register an event handler that puts the text into the option pane. textField.addActionListener(this); - //Register an event handler that reacts to option pane state changes. + // Register an event handler that reacts to option pane state changes. optionPane.addPropertyChangeListener(this); } @@ -142,33 +143,33 @@ class CustomDialog extends JDialog implements ActionListener, PropertyChangeList Object value = optionPane.getValue(); if (value == JOptionPane.UNINITIALIZED_VALUE) { - //ignore reset + // ignore reset return; } - //Reset the JOptionPane's value. - //If you don't do this, then if the user - //presses the same button next time, no - //property change event will be fired. + // Reset the JOptionPane's value. + // If you don't do this, then if the user + // presses the same button next time, no + // property change event will be fired. optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE); if (btnString1.equals(value)) { typedText = textField.getText(); String ucText = typedText.toUpperCase(); if (magicWord.equals(ucText)) { - //we're done; clear and dismiss the dialog + // we're done; clear and dismiss the dialog clearAndHide(); } else { - //text was invalid + // text was invalid textField.selectAll(); JOptionPane.showMessageDialog(CustomDialog.this, "Sorry, \"" + typedText + "\" " + "isn't a valid response.\n" - + "Please enter " + magicWord + ".", + + "Please enter " + magicWord + ".", "Try again", JOptionPane.ERROR_MESSAGE); typedText = null; textField.requestFocusInWindow(); } - } else { //user closed dialog or clicked cancel + } else { // user closed dialog or clicked cancel dd.setLabel("It's OK. We won't force you to type " + magicWord + "."); typedText = null; clearAndHide(); diff --git a/core/src/test/java/ui/dialog/DialogDemo.java b/core/src/test/java/ui/dialog/DialogDemo.java index e55a2fb9..78fb69f2 100644 --- a/core/src/test/java/ui/dialog/DialogDemo.java +++ b/core/src/test/java/ui/dialog/DialogDemo.java @@ -20,24 +20,26 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ - package ui.dialog; -import com.github.weisj.darklaf.LafManager; -import ui.ComponentDemo; - -import javax.swing.*; -import javax.swing.border.Border; import java.awt.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.util.Objects; +import javax.swing.*; +import javax.swing.border.Border; + +import ui.ComponentDemo; + +import com.github.weisj.darklaf.LafManager; + /* * DialogDemo.java requires these files: - * CustomDialog.java - * images/middle.gif + * CustomDialog.java + * images/middle.gif */ public class DialogDemo extends JPanel { private final JLabel label; @@ -57,7 +59,7 @@ public class DialogDemo extends JPanel { customDialog = new CustomDialog(frame, "geisel", this); customDialog.pack(); - //Create the components. + // Create the components. JPanel frequentPanel = createSimpleDialogBox(); JPanel featurePanel = createFeatureDialogBox(); JPanel iconPanel = createIconDialogBox(); @@ -65,7 +67,7 @@ public class DialogDemo extends JPanel { + " to bring up the selected dialog.", JLabel.CENTER); - //Lay them out. + // Lay them out. Border padding = BorderFactory.createEmptyBorder(20, 20, 5, 20); frequentPanel.setBorder(padding); featurePanel.setBorder(padding); @@ -74,13 +76,13 @@ public class DialogDemo extends JPanel { JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("Simple Modal Dialogs", null, frequentPanel, - simpleDialogDesc); //tooltip text + simpleDialogDesc); // tooltip text tabbedPane.addTab("More Dialogs", null, featurePanel, - moreDialogDesc); //tooltip text + moreDialogDesc); // tooltip text tabbedPane.addTab("Dialog Icons", null, iconPanel, - iconDesc); //tooltip text + iconDesc); // tooltip text add(tabbedPane, BorderLayout.CENTER); add(label, BorderLayout.PAGE_END); @@ -88,8 +90,8 @@ public class DialogDemo extends JPanel { } public static void main(final String[] args) { - //Schedule a job for the event-dispatching thread: - //creating and showing this application's GUI. + // Schedule a job for the event-dispatching thread: + // creating and showing this application's GUI. LafManager.install(ComponentDemo.getTheme()); javax.swing.SwingUtilities.invokeLater(DialogDemo::createAndShowGUI); } @@ -135,86 +137,81 @@ public class DialogDemo extends JPanel { showItButton.addActionListener(e -> { String command = group.getSelection().getActionCommand(); - //pick one of many + // pick one of many if (Objects.equals(command, pickOneCommand)) { Object[] possibilities = {"ham", "spam", "yam"}; - String s = (String) JOptionPane.showInputDialog( - frame, - "Complete the sentence:\n" - + "\"Green eggs and...\"", - "Customized Dialog", - JOptionPane.PLAIN_MESSAGE, - icon, - possibilities, - "ham"); - - //If a string was returned, say so. + String s = (String) JOptionPane.showInputDialog(frame, + "Complete the sentence:\n" + + "\"Green eggs and...\"", + "Customized Dialog", + JOptionPane.PLAIN_MESSAGE, + icon, + possibilities, + "ham"); + + // If a string was returned, say so. if ((s != null) && (s.length() > 0)) { setLabel("Green eggs and... " + s + "!"); return; } - //If you're here, the return value was null/empty. + // If you're here, the return value was null/empty. setLabel("Come on, finish the sentence!"); - //text input + // text input } else if (Objects.equals(command, textEnteredCommand)) { - String s = (String) JOptionPane.showInputDialog( - frame, - "Complete the sentence:\n" - + "\"Green eggs and...\"", - "Customized Dialog", - JOptionPane.PLAIN_MESSAGE, - icon, - null, - "ham"); - - //If a string was returned, say so. + String s = (String) JOptionPane.showInputDialog(frame, + "Complete the sentence:\n" + + "\"Green eggs and...\"", + "Customized Dialog", + JOptionPane.PLAIN_MESSAGE, + icon, + null, + "ham"); + + // If a string was returned, say so. if ((s != null) && (s.length() > 0)) { setLabel("Green eggs and... " + s + "!"); return; } - //If you're here, the return value was null/empty. + // If you're here, the return value was null/empty. setLabel("Come on, finish the sentence!"); - //non-auto-closing dialog + // non-auto-closing dialog } else if (Objects.equals(command, nonAutoCommand)) { - final JOptionPane optionPane = new JOptionPane( - "The only way to close this dialog is by\n" - + "pressing one of the following buttons.\n" - + "Do you understand?", - JOptionPane.QUESTION_MESSAGE, - JOptionPane.YES_NO_OPTION); - - //You can't use pane.createDialog() because that - //method sets up the JDialog with a property change - //listener that automatically closes the window - //when a button is clicked. + final JOptionPane optionPane = new JOptionPane("The only way to close this dialog is by\n" + + "pressing one of the following buttons.\n" + + "Do you understand?", + JOptionPane.QUESTION_MESSAGE, + JOptionPane.YES_NO_OPTION); + + // You can't use pane.createDialog() because that + // method sets up the JDialog with a property change + // listener that automatically closes the window + // when a button is clicked. final JDialog dialog = new JDialog(frame, "Click a button", true); dialog.setContentPane(optionPane); - dialog.setDefaultCloseOperation( - JDialog.DO_NOTHING_ON_CLOSE); + dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); dialog.addWindowListener(new WindowAdapter() { public void windowClosing(final WindowEvent we) { setLabel("Thwarted user attempt to close window."); } }); - optionPane.addPropertyChangeListener( - e12 -> { - String prop = e12.getPropertyName(); - - if (dialog.isVisible() - && (e12.getSource() == optionPane) - && (JOptionPane.VALUE_PROPERTY.equals(prop))) { - //If you were going to check something - //before closing the window, you'd do - //it here. - dialog.setVisible(false); - } - }); + optionPane.addPropertyChangeListener(e12 -> { + String prop = e12.getPropertyName(); + + if (dialog.isVisible() + && (e12.getSource() == optionPane) + && (JOptionPane.VALUE_PROPERTY.equals(prop))) { + // If you were going to check something + // before closing the window, you'd do + // it here. + dialog.setVisible(false); + } + }); dialog.pack(); dialog.setLocationRelativeTo(frame); dialog.setVisible(true); @@ -230,27 +227,27 @@ public class DialogDemo extends JPanel { setLabel("Window unavoidably closed (ESC?)."); } - //non-auto-closing dialog with custom message area - //NOTE: if you don't intend to check the input, - //then just use showInputDialog instead. + // non-auto-closing dialog with custom message area + // NOTE: if you don't intend to check the input, + // then just use showInputDialog instead. } else if (Objects.equals(command, customOptionCommand)) { customDialog.setLocationRelativeTo(frame); customDialog.setVisible(true); String s = customDialog.getValidatedText(); if (s != null) { - //The text is valid. + // The text is valid. setLabel("Congratulations! " + "You entered \"" + s + "\"."); } - //non-modal dialog + // non-modal dialog } else if (Objects.equals(command, nonModalCommand)) { - //Create the dialog. + // Create the dialog. final JDialog dialog = new JDialog(frame, "A Non-Modal Dialog"); - //Add contents to it. It must have a close button, - //since some L&Fs (notably Java/Metal) don't provide one - //in the window decorations for dialogs. + // Add contents to it. It must have a close button, + // since some L&Fs (notably Java/Metal) don't provide one + // in the window decorations for dialogs. JLabel label = new JLabel("

    " + "This is a non-modal dialog.
    " + "You can have one or more of these up
    " @@ -275,7 +272,7 @@ public class DialogDemo extends JPanel { contentPane.setOpaque(true); dialog.setContentPane(contentPane); - //Show it. + // Show it. dialog.setSize(new Dimension(300, 150)); dialog.setLocationRelativeTo(frame); dialog.setVisible(true); @@ -332,43 +329,43 @@ public class DialogDemo extends JPanel { showItButton.addActionListener(e -> { String command = group.getSelection().getActionCommand(); - //no icon + // no icon if (Objects.equals(command, plainCommand)) { JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "A plain message", JOptionPane.PLAIN_MESSAGE); - //information icon + // information icon } else if (Objects.equals(command, infoCommand)) { JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "Inane informational dialog", JOptionPane.INFORMATION_MESSAGE); - //XXX: It doesn't make sense to make a question with - //XXX: only one button. - //XXX: See "Yes/No (but not in those words)" for a better solution. - //question icon + // XXX: It doesn't make sense to make a question with + // XXX: only one button. + // XXX: See "Yes/No (but not in those words)" for a better solution. + // question icon } else if (Objects.equals(command, questionCommand)) { JOptionPane.showMessageDialog(frame, "You shouldn't use a message dialog " - + "(like this)\n" - + "for a question, OK?", + + "(like this)\n" + + "for a question, OK?", "Inane question", JOptionPane.QUESTION_MESSAGE); - //error icon + // error icon } else if (Objects.equals(command, errorCommand)) { JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "Inane error", JOptionPane.ERROR_MESSAGE); - //warning icon + // warning icon } else if (Objects.equals(command, warningCommand)) { JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "Inane warning", JOptionPane.WARNING_MESSAGE); - //custom icon + // custom icon } else if (Objects.equals(command, customCommand)) { JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", @@ -391,19 +388,19 @@ public class DialogDemo extends JPanel { } /** - * Create the GUI and show it. For thread safety, this method should be invoked from the event-dispatching thread. + * Create the GUI and show it. For thread safety, this method should be invoked from the event-dispatching thread. */ private static void createAndShowGUI() { - //Create and set up the window. + // Create and set up the window. JFrame frame = new JFrame("DialogDemo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - //Create and set up the content pane. + // Create and set up the content pane. DialogDemo newContentPane = new DialogDemo(frame); - newContentPane.setOpaque(true); //content panes must be opaque + newContentPane.setOpaque(true); // content panes must be opaque frame.setContentPane(newContentPane); - //Display the window. + // Display the window. frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); @@ -483,16 +480,15 @@ public class DialogDemo extends JPanel { showItButton.addActionListener(e -> { String command = group.getSelection().getActionCommand(); - //ok dialog + // ok dialog if (Objects.equals(command, defaultMessageCommand)) { JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green."); - //yes/no dialog + // yes/no dialog } else if (Objects.equals(command, yesNoCommand)) { - int n = JOptionPane.showConfirmDialog( - frame, "Would you like green eggs and ham?", - "An Inane Question", - JOptionPane.YES_NO_OPTION); + int n = JOptionPane.showConfirmDialog(frame, "Would you like green eggs and ham?", + "An Inane Question", + JOptionPane.YES_NO_OPTION); if (n == JOptionPane.YES_OPTION) { setLabel("Ewww!"); } else if (n == JOptionPane.NO_OPTION) { @@ -501,7 +497,7 @@ public class DialogDemo extends JPanel { setLabel("Come on -- tell me!"); } - //yes/no (not in those words) + // yes/no (not in those words) } else if (Objects.equals(command, yeahNahCommand)) { Object[] options = {"Yes, please", "No way!"}; int n = JOptionPane.showOptionDialog(frame, @@ -520,14 +516,14 @@ public class DialogDemo extends JPanel { setLabel("Come on -- 'fess up!"); } - //yes/no/cancel (not in those words) + // yes/no/cancel (not in those words) } else if (Objects.equals(command, yncCommand)) { Object[] options = {"Yes, please", "No, thanks", "No eggs, no ham!"}; int n = JOptionPane.showOptionDialog(frame, "Would you like some green eggs to go " - + "with that ham?", + + "with that ham?", "A Silly Question", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, @@ -552,7 +548,7 @@ public class DialogDemo extends JPanel { } /** - * Like createPane, but creates a pane with 2 columns of radio buttons. The number of buttons passed in *must* be + * Like createPane, but creates a pane with 2 columns of radio buttons. The number of buttons passed in *must* be * even. */ private JPanel create2ColPane(final String description, @@ -579,5 +575,4 @@ public class DialogDemo extends JPanel { return pane; } - } diff --git a/core/src/test/java/ui/fileChooser/FileChooserDemo.java b/core/src/test/java/ui/fileChooser/FileChooserDemo.java index dd620df4..5da9f6a3 100644 --- a/core/src/test/java/ui/fileChooser/FileChooserDemo.java +++ b/core/src/test/java/ui/fileChooser/FileChooserDemo.java @@ -20,15 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.fileChooser; -import com.github.weisj.darklaf.LafManager; -import ui.ComponentDemo; - import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; +import ui.ComponentDemo; + +import com.github.weisj.darklaf.LafManager; + public final class FileChooserDemo { public static void main(final String[] args) { diff --git a/core/src/test/java/ui/internalFrame/DemoInternalFrame.java b/core/src/test/java/ui/internalFrame/DemoInternalFrame.java index b8bb16ce..28957723 100644 --- a/core/src/test/java/ui/internalFrame/DemoInternalFrame.java +++ b/core/src/test/java/ui/internalFrame/DemoInternalFrame.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.internalFrame; @@ -33,10 +34,14 @@ public class DemoInternalFrame extends JInternalFrame { super("Document #" + (++openFrameCount), true, true, true, true); setSize(300, 300); setLocation(xOffset * openFrameCount, yOffset * openFrameCount); - setJMenuBar(new JMenuBar() {{ - add(new JMenu("Test") {{ - add(new JMenuItem("Test Item")); - }}); - }}); + setJMenuBar(new JMenuBar() { + { + add(new JMenu("Test") { + { + add(new JMenuItem("Test Item")); + } + }); + } + }); } } diff --git a/core/src/test/java/ui/internalFrame/InternalFrameDemo.java b/core/src/test/java/ui/internalFrame/InternalFrameDemo.java index 2783bbe4..1d906f71 100644 --- a/core/src/test/java/ui/internalFrame/InternalFrameDemo.java +++ b/core/src/test/java/ui/internalFrame/InternalFrameDemo.java @@ -20,13 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.internalFrame; -import com.github.weisj.darklaf.LafManager; -import ui.ComponentDemo; - -import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -34,9 +31,15 @@ import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import java.beans.PropertyVetoException; +import javax.swing.*; + +import ui.ComponentDemo; + +import com.github.weisj.darklaf.LafManager; + /* * internalFrame.InternalFrameDemo.java requires: - * internalFrame.MyInternalFrame.java + * internalFrame.MyInternalFrame.java */ public class InternalFrameDemo extends JFrame implements ActionListener { private final JDesktopPane desktop; @@ -44,8 +47,8 @@ public class InternalFrameDemo extends JFrame implements ActionListener { private InternalFrameDemo() { super("InternalFrameDemo"); - //Make the big window be indented 50 pixels from each edge - //of the screen. + // Make the big window be indented 50 pixels from each edge + // of the screen. int inset = 50; Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); setBounds(inset, inset, screenSize.width - inset * 2, screenSize.height - inset * 2); @@ -55,7 +58,7 @@ public class InternalFrameDemo extends JFrame implements ActionListener { setContentPane(desktop); setJMenuBar(createMenuBar()); - //Make dragging a little faster but perhaps uglier. + // Make dragging a little faster but perhaps uglier. desktop.setDragMode(JDesktopPane.LIVE_DRAG_MODE); } @@ -63,16 +66,15 @@ public class InternalFrameDemo extends JFrame implements ActionListener { SwingUtilities.invokeLater(InternalFrameDemo::createAndShowGUI); } - private JMenuBar createMenuBar() { JMenuBar menuBar = new JMenuBar(); - //Set up the lone menu. + // Set up the lone menu. JMenu menu = new JMenu("Document"); menu.setMnemonic(KeyEvent.VK_D); menuBar.add(menu); - //Set up the first menu item. + // Set up the first menu item. JMenuItem menuItem = new JMenuItem("New"); menuItem.setMnemonic(KeyEvent.VK_N); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.ALT_DOWN_MASK)); @@ -80,7 +82,7 @@ public class InternalFrameDemo extends JFrame implements ActionListener { menuItem.addActionListener(this); menu.add(menuItem); - //Set up the second menu item. + // Set up the second menu item. menuItem = new JMenuItem("Quit"); menuItem.setMnemonic(KeyEvent.VK_Q); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, InputEvent.ALT_DOWN_MASK)); @@ -92,31 +94,30 @@ public class InternalFrameDemo extends JFrame implements ActionListener { } /** - * Create the GUI and show it. For thread safety, this method should be invoked from the event-dispatching thread. + * Create the GUI and show it. For thread safety, this method should be invoked from the event-dispatching thread. */ private static void createAndShowGUI() { LafManager.install(ComponentDemo.getTheme()); - //Create and set up the window. + // Create and set up the window. InternalFrameDemo frame = new InternalFrameDemo(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - //Display the window. + // Display the window. frame.setVisible(true); } - //Create a new internal frame. + // Create a new internal frame. private void createFrame() { DemoInternalFrame frame = new DemoInternalFrame(); frame.setVisible(true); desktop.add(frame); try { frame.setSelected(true); - } catch (PropertyVetoException ignored) { - } + } catch (PropertyVetoException ignored) {} } - //React to menu selections. + // React to menu selections. public void actionPerformed(final ActionEvent e) { if ("new".equals(e.getActionCommand())) { createFrame(); @@ -125,7 +126,7 @@ public class InternalFrameDemo extends JFrame implements ActionListener { } } - //Quit the application. + // Quit the application. private void quit() { System.exit(0); diff --git a/core/src/test/java/ui/label/LabelDemo.java b/core/src/test/java/ui/label/LabelDemo.java index 5ee8c92c..64389b85 100644 --- a/core/src/test/java/ui/label/LabelDemo.java +++ b/core/src/test/java/ui/label/LabelDemo.java @@ -20,16 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.label; +import java.awt.*; + +import javax.swing.*; + import ui.ComponentDemo; import ui.DemoPanel; import ui.DemoResources; -import javax.swing.*; -import java.awt.*; - public class LabelDemo implements ComponentDemo { public static void main(final String[] args) { @@ -43,15 +45,19 @@ public class LabelDemo implements ComponentDemo { DemoPanel panel = new DemoPanel(label); JPanel controlPanel = panel.addControls(); - controlPanel.add(new JCheckBox("enabled") {{ - setSelected(label.isEnabled()); - addActionListener(e -> label.setEnabled(isSelected())); - }}); - controlPanel.add(new JCheckBox("LeftToRight") {{ - setSelected(label.getComponentOrientation().isLeftToRight()); - addActionListener(e -> label.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT - : ComponentOrientation.RIGHT_TO_LEFT)); - }}); + controlPanel.add(new JCheckBox("enabled") { + { + setSelected(label.isEnabled()); + addActionListener(e -> label.setEnabled(isSelected())); + } + }); + controlPanel.add(new JCheckBox("LeftToRight") { + { + setSelected(label.getComponentOrientation().isLeftToRight()); + addActionListener(e -> label.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT + : ComponentOrientation.RIGHT_TO_LEFT)); + } + }); return panel; } diff --git a/core/src/test/java/ui/list/ListDemo.java b/core/src/test/java/ui/list/ListDemo.java index b6fce939..224005cc 100644 --- a/core/src/test/java/ui/list/ListDemo.java +++ b/core/src/test/java/ui/list/ListDemo.java @@ -20,18 +20,21 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.list; -import com.github.weisj.darklaf.ui.list.DarkListUI; -import ui.ComponentDemo; -import ui.DemoPanel; - -import javax.swing.*; import java.awt.*; import java.util.HashMap; import java.util.Map; +import javax.swing.*; + +import ui.ComponentDemo; +import ui.DemoPanel; + +import com.github.weisj.darklaf.ui.list.DarkListUI; + public final class ListDemo implements ComponentDemo { public static void main(final String[] args) { @@ -47,41 +50,51 @@ public final class ListDemo implements ComponentDemo { DemoPanel panel = new DemoPanel(list, new BorderLayout(), 0); JPanel controlPanel = panel.addControls(); - controlPanel.add(new JCheckBox(DarkListUI.KEY_ALTERNATE_ROW_COLOR) {{ - setSelected(Boolean.TRUE.equals(list.getClientProperty(DarkListUI.KEY_ALTERNATE_ROW_COLOR))); - addActionListener(e -> list.putClientProperty(DarkListUI.KEY_ALTERNATE_ROW_COLOR, isSelected())); - }}, "span"); + controlPanel.add(new JCheckBox(DarkListUI.KEY_ALTERNATE_ROW_COLOR) { + { + setSelected(Boolean.TRUE.equals(list.getClientProperty(DarkListUI.KEY_ALTERNATE_ROW_COLOR))); + addActionListener(e -> list.putClientProperty(DarkListUI.KEY_ALTERNATE_ROW_COLOR, isSelected())); + } + }, "span"); controlPanel = panel.addControls(); controlPanel.add(new JLabel("Layout orientation:", JLabel.RIGHT)); - controlPanel.add(new JComboBox() {{ - Map mapping = new HashMap() {{ - put("VERTICAL", JList.VERTICAL); - put("VERTICAL_WRAP", JList.VERTICAL_WRAP); - put("HORIZONTAL_WRAP", JList.HORIZONTAL_WRAP); - }}; - addItem("VERTICAL"); - addItem("VERTICAL_WRAP"); - addItem("HORIZONTAL_WRAP"); - setSelectedItem("VERTICAL"); - //noinspection MagicConstant - addItemListener(e -> list.setLayoutOrientation(mapping.get(e.getItem().toString()))); - }}, "sgx"); + controlPanel.add(new JComboBox() { + { + Map mapping = new HashMap() { + { + put("VERTICAL", JList.VERTICAL); + put("VERTICAL_WRAP", JList.VERTICAL_WRAP); + put("HORIZONTAL_WRAP", JList.HORIZONTAL_WRAP); + } + }; + addItem("VERTICAL"); + addItem("VERTICAL_WRAP"); + addItem("HORIZONTAL_WRAP"); + setSelectedItem("VERTICAL"); + // noinspection MagicConstant + addItemListener(e -> list.setLayoutOrientation(mapping.get(e.getItem().toString()))); + } + }, "sgx"); controlPanel.add(new JLabel("Selection mode:", JLabel.RIGHT)); - controlPanel.add(new JComboBox() {{ - Map mapping = new HashMap() {{ - put("SINGLE_SELECTION", ListSelectionModel.SINGLE_SELECTION); - put("MULTIPLE_INTERVAL_SELECTION", ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - put("SINGLE_INTERVAL_SELECTION", ListSelectionModel.SINGLE_INTERVAL_SELECTION); - }}; - addItem("SINGLE_SELECTION"); - addItem("MULTIPLE_INTERVAL_SELECTION"); - addItem("SINGLE_INTERVAL_SELECTION"); - setSelectedItem("SINGLE_SELECTION"); - list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - //noinspection MagicConstant - addItemListener(e -> list.setSelectionMode(mapping.get(e.getItem().toString()))); - }}, "sgx"); + controlPanel.add(new JComboBox() { + { + Map mapping = new HashMap() { + { + put("SINGLE_SELECTION", ListSelectionModel.SINGLE_SELECTION); + put("MULTIPLE_INTERVAL_SELECTION", ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + put("SINGLE_INTERVAL_SELECTION", ListSelectionModel.SINGLE_INTERVAL_SELECTION); + } + }; + addItem("SINGLE_SELECTION"); + addItem("MULTIPLE_INTERVAL_SELECTION"); + addItem("SINGLE_INTERVAL_SELECTION"); + setSelectedItem("SINGLE_SELECTION"); + list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + // noinspection MagicConstant + addItemListener(e -> list.setSelectionMode(mapping.get(e.getItem().toString()))); + } + }, "sgx"); return panel; } diff --git a/core/src/test/java/ui/popupMenu/PopupMenuDemo.java b/core/src/test/java/ui/popupMenu/PopupMenuDemo.java index 85017358..a8d59298 100644 --- a/core/src/test/java/ui/popupMenu/PopupMenuDemo.java +++ b/core/src/test/java/ui/popupMenu/PopupMenuDemo.java @@ -20,14 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.popupMenu; -import ui.ComponentDemo; -import ui.DemoResources; +import java.awt.*; import javax.swing.*; -import java.awt.*; + +import ui.ComponentDemo; +import ui.DemoResources; public class PopupMenuDemo implements ComponentDemo { @@ -40,39 +42,53 @@ public class PopupMenuDemo implements ComponentDemo { JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); Icon icon = DemoResources.FOLDER_ICON; - panel.add(new JLabel("Right click anywhere to open menu.") {{ - setInheritsPopupMenu(true); - }}); + panel.add(new JLabel("Right click anywhere to open menu.") { + { + setInheritsPopupMenu(true); + } + }); panel.setPreferredSize(new Dimension(200, 200)); - panel.setComponentPopupMenu(new JPopupMenu() {{ - for (int i = 0; i < 3; i++) { - add(new JMenu("Menu " + i) {{ - setIcon(icon); - for (int j = 0; j < 2; j++) { - add(new JMenu("SubMenu " + j) {{ - add(new JMenuItem("Item", icon)); - }}); - add(new JMenuItem("Item 1")); - add(new JMenuItem("Item 2", icon)); - addSeparator(); - } - add(new JMenuItem("Item 1", icon)); - add(new JMenuItem("Item 2")); - addSeparator(); - }}); - add(new JMenuItem("Item 1", icon) {{ - setAccelerator(KeyStroke.getKeyStroke("alt A")); - }}); - add(new JCheckBoxMenuItem("CheckBox")); - add(new JMenuItem("Item 2") {{ - setAccelerator(KeyStroke.getKeyStroke("alt shift B")); - }}); - add(new JRadioButtonMenuItem("RadioButton")); - add(new JMenuItem("Item 3", icon) {{ - setAccelerator(KeyStroke.getKeyStroke("alt control shift C")); - }}); + panel.setComponentPopupMenu(new JPopupMenu() { + { + for (int i = 0; i < 3; i++) { + add(new JMenu("Menu " + i) { + { + setIcon(icon); + for (int j = 0; j < 2; j++) { + add(new JMenu("SubMenu " + j) { + { + add(new JMenuItem("Item", icon)); + } + }); + add(new JMenuItem("Item 1")); + add(new JMenuItem("Item 2", icon)); + addSeparator(); + } + add(new JMenuItem("Item 1", icon)); + add(new JMenuItem("Item 2")); + addSeparator(); + } + }); + add(new JMenuItem("Item 1", icon) { + { + setAccelerator(KeyStroke.getKeyStroke("alt A")); + } + }); + add(new JCheckBoxMenuItem("CheckBox")); + add(new JMenuItem("Item 2") { + { + setAccelerator(KeyStroke.getKeyStroke("alt shift B")); + } + }); + add(new JRadioButtonMenuItem("RadioButton")); + add(new JMenuItem("Item 3", icon) { + { + setAccelerator(KeyStroke.getKeyStroke("alt control shift C")); + } + }); + } } - }}); + }); return panel; } @@ -80,11 +96,13 @@ public class PopupMenuDemo implements ComponentDemo { public JMenuBar createMenuBar() { JMenuBar menuBar = new JMenuBar(); menuBar.add(ComponentDemo.createThemeMenu()); - menuBar.add(new JMenu("CheckBoxes") {{ - for (int i = 0; i < 10; i++) { - add(new JCheckBoxMenuItem("Item " + i)); + menuBar.add(new JMenu("CheckBoxes") { + { + for (int i = 0; i < 10; i++) { + add(new JCheckBoxMenuItem("Item " + i)); + } } - }}); + }); return menuBar; } diff --git a/core/src/test/java/ui/progressBar/ProgressBarDemo.java b/core/src/test/java/ui/progressBar/ProgressBarDemo.java index 81fa8f79..da65950c 100644 --- a/core/src/test/java/ui/progressBar/ProgressBarDemo.java +++ b/core/src/test/java/ui/progressBar/ProgressBarDemo.java @@ -20,17 +20,19 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.progressBar; -import ui.ComponentDemo; -import ui.DemoPanel; - -import javax.swing.*; import java.awt.*; import java.util.HashMap; import java.util.Map; +import javax.swing.*; + +import ui.ComponentDemo; +import ui.DemoPanel; + public class ProgressBarDemo implements ComponentDemo { public static void main(final String[] args) { @@ -47,52 +49,72 @@ public class ProgressBarDemo implements ComponentDemo { DemoPanel panel = new DemoPanel(progressBar); JPanel controlPanel = panel.addControls(); - controlPanel.add(new JCheckBox("enabled") {{ - setSelected(progressBar.isEnabled()); - addActionListener(e -> progressBar.setEnabled(isSelected())); - }}); - controlPanel.add(new JCheckBox("indeterminate") {{ - setSelected(progressBar.isIndeterminate()); - addActionListener(e -> progressBar.setIndeterminate(isSelected())); - }}); - controlPanel.add(new JCheckBox("LeftToRight") {{ - setSelected(progressBar.getComponentOrientation().isLeftToRight()); - addActionListener(e -> progressBar.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT - : ComponentOrientation.RIGHT_TO_LEFT)); - }}); - controlPanel.add(new JCheckBox("String painted") {{ - setSelected(progressBar.isStringPainted()); - addActionListener(e -> progressBar.setStringPainted(isSelected())); - }}); - controlPanel.add(new JCheckBox("JProgressBar.failed") {{ - addActionListener(e -> progressBar.putClientProperty("JProgressBar.failed", isSelected())); - }}); - controlPanel.add(new JCheckBox("JProgressBar.passed") {{ - addActionListener(e -> progressBar.putClientProperty("JProgressBar.passed", isSelected())); - }}); + controlPanel.add(new JCheckBox("enabled") { + { + setSelected(progressBar.isEnabled()); + addActionListener(e -> progressBar.setEnabled(isSelected())); + } + }); + controlPanel.add(new JCheckBox("indeterminate") { + { + setSelected(progressBar.isIndeterminate()); + addActionListener(e -> progressBar.setIndeterminate(isSelected())); + } + }); + controlPanel.add(new JCheckBox("LeftToRight") { + { + setSelected(progressBar.getComponentOrientation().isLeftToRight()); + addActionListener(e -> progressBar.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT + : ComponentOrientation.RIGHT_TO_LEFT)); + } + }); + controlPanel.add(new JCheckBox("String painted") { + { + setSelected(progressBar.isStringPainted()); + addActionListener(e -> progressBar.setStringPainted(isSelected())); + } + }); + controlPanel.add(new JCheckBox("JProgressBar.failed") { + { + addActionListener(e -> progressBar.putClientProperty("JProgressBar.failed", isSelected())); + } + }); + controlPanel.add(new JCheckBox("JProgressBar.passed") { + { + addActionListener(e -> progressBar.putClientProperty("JProgressBar.passed", isSelected())); + } + }); controlPanel = panel.addControls(); controlPanel.add(new JLabel("Orientation:", JLabel.RIGHT)); - controlPanel.add(new JComboBox() {{ - Map mapping = new HashMap() {{ - put("HORIZONTAL", JProgressBar.HORIZONTAL); - put("VERTICAL", JProgressBar.VERTICAL); - }}; - addItem("HORIZONTAL"); - addItem("VERTICAL"); - setSelectedItem("HORIZONTAL"); - addItemListener(e -> progressBar.setOrientation(mapping.get(e.getItem().toString()))); - }}, "sgx"); + controlPanel.add(new JComboBox() { + { + Map mapping = new HashMap() { + { + put("HORIZONTAL", JProgressBar.HORIZONTAL); + put("VERTICAL", JProgressBar.VERTICAL); + } + }; + addItem("HORIZONTAL"); + addItem("VERTICAL"); + setSelectedItem("HORIZONTAL"); + addItemListener(e -> progressBar.setOrientation(mapping.get(e.getItem().toString()))); + } + }, "sgx"); controlPanel.add(new JLabel("Value:", JLabel.RIGHT)); - controlPanel.add(new JPanel() {{ - //Wrap in JPanel. Otherwise, the slider appears too low. - add(new JSlider() {{ - setMinimum(progressBar.getMinimum()); - setMaximum(progressBar.getMaximum()); - setValue(progressBar.getValue()); - addChangeListener(e -> progressBar.setValue(getValue())); - }}); - }}, "sgx"); + controlPanel.add(new JPanel() { + { + // Wrap in JPanel. Otherwise, the slider appears too low. + add(new JSlider() { + { + setMinimum(progressBar.getMinimum()); + setMaximum(progressBar.getMaximum()); + setValue(progressBar.getValue()); + addChangeListener(e -> progressBar.setValue(getValue())); + } + }); + } + }, "sgx"); return panel; } diff --git a/core/src/test/java/ui/radioButton/RadioButtonDemo.java b/core/src/test/java/ui/radioButton/RadioButtonDemo.java index a4c78dd7..aa349c2b 100644 --- a/core/src/test/java/ui/radioButton/RadioButtonDemo.java +++ b/core/src/test/java/ui/radioButton/RadioButtonDemo.java @@ -20,15 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.radioButton; -import com.github.weisj.darklaf.ui.togglebutton.DarkToggleButtonUI; +import java.awt.*; + +import javax.swing.*; + import ui.ComponentDemo; import ui.DemoPanel; -import javax.swing.*; -import java.awt.*; +import com.github.weisj.darklaf.ui.togglebutton.DarkToggleButtonUI; public class RadioButtonDemo implements ComponentDemo { @@ -42,27 +45,37 @@ public class RadioButtonDemo implements ComponentDemo { DemoPanel panel = new DemoPanel(button); JPanel controlPanel = panel.addControls(1); - controlPanel.add(new JCheckBox("enabled") {{ - setSelected(button.isEnabled()); - addActionListener(e -> button.setEnabled(isSelected())); - }}); - controlPanel.add(new JCheckBox("LeftToRight") {{ - setSelected(button.getComponentOrientation().isLeftToRight()); - addActionListener(e -> button.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT - : ComponentOrientation.RIGHT_TO_LEFT)); - }}); - controlPanel.add(new JCheckBox("Rollover") {{ - setSelected(button.isRolloverEnabled()); - addActionListener(e -> button.setRolloverEnabled(isSelected())); - }}); - controlPanel.add(new JCheckBox(DarkToggleButtonUI.KEY_IS_TREE_EDITOR) {{ - setSelected(false); - addActionListener(e -> button.putClientProperty(DarkToggleButtonUI.KEY_IS_TREE_EDITOR, isSelected())); - }}); - controlPanel.add(new JCheckBox(DarkToggleButtonUI.KEY_IS_TABLE_EDITOR) {{ - setSelected(false); - addActionListener(e -> button.putClientProperty(DarkToggleButtonUI.KEY_IS_TABLE_EDITOR, isSelected())); - }}); + controlPanel.add(new JCheckBox("enabled") { + { + setSelected(button.isEnabled()); + addActionListener(e -> button.setEnabled(isSelected())); + } + }); + controlPanel.add(new JCheckBox("LeftToRight") { + { + setSelected(button.getComponentOrientation().isLeftToRight()); + addActionListener(e -> button.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT + : ComponentOrientation.RIGHT_TO_LEFT)); + } + }); + controlPanel.add(new JCheckBox("Rollover") { + { + setSelected(button.isRolloverEnabled()); + addActionListener(e -> button.setRolloverEnabled(isSelected())); + } + }); + controlPanel.add(new JCheckBox(DarkToggleButtonUI.KEY_IS_TREE_EDITOR) { + { + setSelected(false); + addActionListener(e -> button.putClientProperty(DarkToggleButtonUI.KEY_IS_TREE_EDITOR, isSelected())); + } + }); + controlPanel.add(new JCheckBox(DarkToggleButtonUI.KEY_IS_TABLE_EDITOR) { + { + setSelected(false); + addActionListener(e -> button.putClientProperty(DarkToggleButtonUI.KEY_IS_TABLE_EDITOR, isSelected())); + } + }); return panel; } @@ -75,9 +88,11 @@ public class RadioButtonDemo implements ComponentDemo { public JMenuBar createMenuBar() { JMenuBar menuBar = new JMenuBar(); menuBar.add(ComponentDemo.createThemeMenu()); - menuBar.add(new JMenu("Demo") {{ - add(new JRadioButtonMenuItem("RadioButton menu item")); - }}); + menuBar.add(new JMenu("Demo") { + { + add(new JRadioButtonMenuItem("RadioButton menu item")); + } + }); return menuBar; } } diff --git a/core/src/test/java/ui/scrollPane/OverlayScrollPaneDemo.java b/core/src/test/java/ui/scrollPane/OverlayScrollPaneDemo.java index 3be6d952..620ca8db 100644 --- a/core/src/test/java/ui/scrollPane/OverlayScrollPaneDemo.java +++ b/core/src/test/java/ui/scrollPane/OverlayScrollPaneDemo.java @@ -20,17 +20,20 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.scrollPane; -import com.github.weisj.darklaf.components.OverlayScrollPane; -import com.github.weisj.darklaf.util.StringUtil; +import java.awt.*; + +import javax.swing.*; + import ui.ComponentDemo; import ui.DemoPanel; import ui.DemoResources; -import javax.swing.*; -import java.awt.*; +import com.github.weisj.darklaf.components.OverlayScrollPane; +import com.github.weisj.darklaf.util.StringUtil; public class OverlayScrollPaneDemo implements ComponentDemo { @@ -40,8 +43,8 @@ public class OverlayScrollPaneDemo implements ComponentDemo { @Override public JComponent createComponent() { - OverlayScrollPane scrollPane = new OverlayScrollPane( - new JTextArea(StringUtil.repeat(DemoResources.LOREM_IPSUM, 5))); + OverlayScrollPane scrollPane = new OverlayScrollPane(new JTextArea(StringUtil.repeat(DemoResources.LOREM_IPSUM, + 5))); return new DemoPanel(scrollPane, new BorderLayout(), 0); } diff --git a/core/src/test/java/ui/scrollPane/ScrollPaneDemo.java b/core/src/test/java/ui/scrollPane/ScrollPaneDemo.java index fd701808..95162287 100644 --- a/core/src/test/java/ui/scrollPane/ScrollPaneDemo.java +++ b/core/src/test/java/ui/scrollPane/ScrollPaneDemo.java @@ -20,21 +20,24 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.scrollPane; -import com.github.weisj.darklaf.util.StringUtil; +import java.awt.*; + +import javax.swing.*; + import ui.ComponentDemo; import ui.DemoPanel; import ui.DemoResources; import ui.SolidColorComponent; -import javax.swing.*; -import java.awt.*; +import com.github.weisj.darklaf.util.StringUtil; /** * @author Jannis Weis - * @since 2019 + * @since 2019 */ public final class ScrollPaneDemo implements ComponentDemo { @@ -44,9 +47,11 @@ public final class ScrollPaneDemo implements ComponentDemo { @Override public JComponent createComponent() { - JScrollPane scrollPane = new JScrollPane(new JTextArea() {{ - setText(StringUtil.repeat(DemoResources.LOREM_IPSUM, 10)); - }}); + JScrollPane scrollPane = new JScrollPane(new JTextArea() { + { + setText(StringUtil.repeat(DemoResources.LOREM_IPSUM, 10)); + } + }); JPanel upperLeft = new SolidColorComponent(Color.RED, 20, 20); JPanel upperRight = new SolidColorComponent(Color.RED, 20, 20); JPanel lowerLeft = new SolidColorComponent(Color.RED, 20, 20); @@ -55,29 +60,39 @@ public final class ScrollPaneDemo implements ComponentDemo { DemoPanel panel = new DemoPanel(scrollPane, new BorderLayout(), 10); JPanel controlPanel = panel.addControls(); - controlPanel.add(new JCheckBox("LeftToRight") {{ - setSelected(scrollPane.getComponentOrientation().isLeftToRight()); - addActionListener(e -> scrollPane.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT - : ComponentOrientation.RIGHT_TO_LEFT)); - }}, "span"); + controlPanel.add(new JCheckBox("LeftToRight") { + { + setSelected(scrollPane.getComponentOrientation().isLeftToRight()); + addActionListener(e -> scrollPane.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT + : ComponentOrientation.RIGHT_TO_LEFT)); + } + }, "span"); controlPanel = panel.addControls(); - controlPanel.add(new JCheckBox("UpperLeft corner") {{ - addActionListener( - e -> scrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, isSelected() ? upperLeft : null)); - }}); - controlPanel.add(new JCheckBox("UpperRight corner") {{ - addActionListener( - e -> scrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, isSelected() ? upperRight : null)); - }}); - controlPanel.add(new JCheckBox("LowerLeft corner") {{ - addActionListener( - e -> scrollPane.setCorner(JScrollPane.LOWER_LEFT_CORNER, isSelected() ? lowerLeft : null)); - }}); - controlPanel.add(new JCheckBox("LowerRight corner") {{ - addActionListener( - e -> scrollPane.setCorner(JScrollPane.LOWER_RIGHT_CORNER, isSelected() ? lowerRight : null)); - }}); + controlPanel.add(new JCheckBox("UpperLeft corner") { + { + addActionListener(e -> scrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, + isSelected() ? upperLeft : null)); + } + }); + controlPanel.add(new JCheckBox("UpperRight corner") { + { + addActionListener(e -> scrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, + isSelected() ? upperRight : null)); + } + }); + controlPanel.add(new JCheckBox("LowerLeft corner") { + { + addActionListener(e -> scrollPane.setCorner(JScrollPane.LOWER_LEFT_CORNER, + isSelected() ? lowerLeft : null)); + } + }); + controlPanel.add(new JCheckBox("LowerRight corner") { + { + addActionListener(e -> scrollPane.setCorner(JScrollPane.LOWER_RIGHT_CORNER, + isSelected() ? lowerRight : null)); + } + }); return panel; } diff --git a/core/src/test/java/ui/slider/SliderDemo.java b/core/src/test/java/ui/slider/SliderDemo.java index 6c8c316e..4b3f2036 100644 --- a/core/src/test/java/ui/slider/SliderDemo.java +++ b/core/src/test/java/ui/slider/SliderDemo.java @@ -20,15 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.slider; -import com.github.weisj.darklaf.ui.slider.DarkSliderUI; +import java.awt.*; + +import javax.swing.*; + import ui.ComponentDemo; import ui.DemoPanel; -import javax.swing.*; -import java.awt.*; +import com.github.weisj.darklaf.ui.slider.DarkSliderUI; public class SliderDemo implements ComponentDemo { @@ -45,55 +48,77 @@ public class SliderDemo implements ComponentDemo { JPanel controlPanel = panel.addControls(); controlPanel.add(new JLabel("Orientation:")); - controlPanel.add(new JComboBox() {{ - setEditable(false); - addItem("Horizontal"); - addItem("Vertical"); - setSelectedItem("Horizontal"); - addItemListener( - e -> slider.setOrientation(e.getItem() == "Vertical" ? JSlider.VERTICAL : JSlider.HORIZONTAL)); - }}); + controlPanel.add(new JComboBox() { + { + setEditable(false); + addItem("Horizontal"); + addItem("Vertical"); + setSelectedItem("Horizontal"); + addItemListener(e -> slider.setOrientation(e.getItem() == "Vertical" ? JSlider.VERTICAL + : JSlider.HORIZONTAL)); + } + }); controlPanel = panel.addControls(); - controlPanel.add(new JCheckBox("enabled") {{ - setSelected(slider.isEnabled()); - addActionListener(e -> slider.setEnabled(isSelected())); - }}); - controlPanel.add(new JCheckBox("LeftToRight") {{ - setSelected(slider.getComponentOrientation().isLeftToRight()); - addActionListener(e -> slider.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT - : ComponentOrientation.RIGHT_TO_LEFT)); - }}); - controlPanel.add(new JCheckBox("inverted") {{ - setSelected(slider.getInverted()); - addActionListener(e -> slider.setInverted(isSelected())); - }}); - controlPanel.add(new JCheckBox("snap to ticks") {{ - setSelected(slider.getSnapToTicks()); - addActionListener(e -> slider.setSnapToTicks(isSelected())); - }}); - controlPanel.add(new JCheckBox("paint ticks") {{ - setSelected(slider.getPaintTicks()); - addActionListener(e -> slider.setPaintTicks(isSelected())); - }}); - controlPanel.add(new JCheckBox("paint labels") {{ - setSelected(slider.getPaintLabels()); - addActionListener(e -> slider.setPaintLabels(isSelected())); - }}); - controlPanel.add(new JCheckBox("paint track") {{ - setSelected(slider.getPaintTrack()); - addActionListener(e -> slider.setPaintTrack(isSelected())); - }}); - controlPanel.add(new JCheckBox(DarkSliderUI.KEY_VARIANT + " = " + DarkSliderUI.VARIANT_VOLUME) {{ - addActionListener(e -> slider.putClientProperty(DarkSliderUI.KEY_VARIANT, isSelected() - ? DarkSliderUI.VARIANT_VOLUME - : null)); - }}); - controlPanel.add(new JCheckBox(DarkSliderUI.KEY_INSTANT_SCROLL) {{ - addActionListener(e -> slider.putClientProperty(DarkSliderUI.KEY_INSTANT_SCROLL, isSelected())); - }}); - controlPanel.add(new JCheckBox(DarkSliderUI.KEY_SHOW_VOLUME_ICON) {{ - addActionListener(e -> slider.putClientProperty(DarkSliderUI.KEY_SHOW_VOLUME_ICON, isSelected())); - }}); + controlPanel.add(new JCheckBox("enabled") { + { + setSelected(slider.isEnabled()); + addActionListener(e -> slider.setEnabled(isSelected())); + } + }); + controlPanel.add(new JCheckBox("LeftToRight") { + { + setSelected(slider.getComponentOrientation().isLeftToRight()); + addActionListener(e -> slider.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT + : ComponentOrientation.RIGHT_TO_LEFT)); + } + }); + controlPanel.add(new JCheckBox("inverted") { + { + setSelected(slider.getInverted()); + addActionListener(e -> slider.setInverted(isSelected())); + } + }); + controlPanel.add(new JCheckBox("snap to ticks") { + { + setSelected(slider.getSnapToTicks()); + addActionListener(e -> slider.setSnapToTicks(isSelected())); + } + }); + controlPanel.add(new JCheckBox("paint ticks") { + { + setSelected(slider.getPaintTicks()); + addActionListener(e -> slider.setPaintTicks(isSelected())); + } + }); + controlPanel.add(new JCheckBox("paint labels") { + { + setSelected(slider.getPaintLabels()); + addActionListener(e -> slider.setPaintLabels(isSelected())); + } + }); + controlPanel.add(new JCheckBox("paint track") { + { + setSelected(slider.getPaintTrack()); + addActionListener(e -> slider.setPaintTrack(isSelected())); + } + }); + controlPanel.add(new JCheckBox(DarkSliderUI.KEY_VARIANT + " = " + DarkSliderUI.VARIANT_VOLUME) { + { + addActionListener(e -> slider.putClientProperty(DarkSliderUI.KEY_VARIANT, isSelected() + ? DarkSliderUI.VARIANT_VOLUME + : null)); + } + }); + controlPanel.add(new JCheckBox(DarkSliderUI.KEY_INSTANT_SCROLL) { + { + addActionListener(e -> slider.putClientProperty(DarkSliderUI.KEY_INSTANT_SCROLL, isSelected())); + } + }); + controlPanel.add(new JCheckBox(DarkSliderUI.KEY_SHOW_VOLUME_ICON) { + { + addActionListener(e -> slider.putClientProperty(DarkSliderUI.KEY_SHOW_VOLUME_ICON, isSelected())); + } + }); return panel; } diff --git a/core/src/test/java/ui/spinner/SpinnerDemo.java b/core/src/test/java/ui/spinner/SpinnerDemo.java index 88d4f547..b1c7256e 100644 --- a/core/src/test/java/ui/spinner/SpinnerDemo.java +++ b/core/src/test/java/ui/spinner/SpinnerDemo.java @@ -20,15 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.spinner; -import com.github.weisj.darklaf.ui.spinner.SpinnerConstants; +import java.awt.*; + +import javax.swing.*; + import ui.ComponentDemo; import ui.DemoPanel; -import javax.swing.*; -import java.awt.*; +import com.github.weisj.darklaf.ui.spinner.SpinnerConstants; public class SpinnerDemo implements ComponentDemo { @@ -42,28 +45,38 @@ public class SpinnerDemo implements ComponentDemo { DemoPanel panel = new DemoPanel(spinner); JPanel controlPanel = panel.addControls(1); - controlPanel.add(new JCheckBox("enabled") {{ - setSelected(spinner.isEnabled()); - addActionListener(e -> spinner.setEnabled(isSelected())); - }}); - controlPanel.add(new JCheckBox("LeftToRight") {{ - setSelected(spinner.getComponentOrientation().isLeftToRight()); - addActionListener(e -> spinner.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT - : ComponentOrientation.RIGHT_TO_LEFT)); - }}); - controlPanel.add(new JCheckBox(SpinnerConstants.KEY_VARIANT + " = " + SpinnerConstants.VARIANT_PLUS_MINUS) {{ - addActionListener(e -> spinner.putClientProperty(SpinnerConstants.KEY_VARIANT, - isSelected() ? SpinnerConstants.VARIANT_PLUS_MINUS - : null)); - }}); - controlPanel.add(new JCheckBox(SpinnerConstants.KEY_IS_TREE_EDITOR) {{ - setSelected(false); - addActionListener(e -> spinner.putClientProperty(SpinnerConstants.KEY_IS_TREE_EDITOR, isSelected())); - }}); - controlPanel.add(new JCheckBox(SpinnerConstants.KEY_IS_TABLE_EDITOR) {{ - setSelected(false); - addActionListener(e -> spinner.putClientProperty(SpinnerConstants.KEY_IS_TABLE_EDITOR, isSelected())); - }}); + controlPanel.add(new JCheckBox("enabled") { + { + setSelected(spinner.isEnabled()); + addActionListener(e -> spinner.setEnabled(isSelected())); + } + }); + controlPanel.add(new JCheckBox("LeftToRight") { + { + setSelected(spinner.getComponentOrientation().isLeftToRight()); + addActionListener(e -> spinner.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT + : ComponentOrientation.RIGHT_TO_LEFT)); + } + }); + controlPanel.add(new JCheckBox(SpinnerConstants.KEY_VARIANT + " = " + SpinnerConstants.VARIANT_PLUS_MINUS) { + { + addActionListener(e -> spinner.putClientProperty(SpinnerConstants.KEY_VARIANT, + isSelected() ? SpinnerConstants.VARIANT_PLUS_MINUS + : null)); + } + }); + controlPanel.add(new JCheckBox(SpinnerConstants.KEY_IS_TREE_EDITOR) { + { + setSelected(false); + addActionListener(e -> spinner.putClientProperty(SpinnerConstants.KEY_IS_TREE_EDITOR, isSelected())); + } + }); + controlPanel.add(new JCheckBox(SpinnerConstants.KEY_IS_TABLE_EDITOR) { + { + setSelected(false); + addActionListener(e -> spinner.putClientProperty(SpinnerConstants.KEY_IS_TABLE_EDITOR, isSelected())); + } + }); return panel; } diff --git a/core/src/test/java/ui/splitPane/SplitPaneDemo.java b/core/src/test/java/ui/splitPane/SplitPaneDemo.java index 65769077..2bc5dceb 100644 --- a/core/src/test/java/ui/splitPane/SplitPaneDemo.java +++ b/core/src/test/java/ui/splitPane/SplitPaneDemo.java @@ -20,17 +20,19 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.splitPane; -import ui.ComponentDemo; -import ui.DemoPanel; - -import javax.swing.*; import java.awt.*; import java.util.HashMap; import java.util.Map; +import javax.swing.*; + +import ui.ComponentDemo; +import ui.DemoPanel; + public final class SplitPaneDemo implements ComponentDemo { public static void main(final String[] args) { @@ -40,51 +42,67 @@ public final class SplitPaneDemo implements ComponentDemo { @Override public JComponent createComponent() { JSplitPane splitPane = new JSplitPane(); - JPanel leftPanel = new JPanel() {{ - setBackground(UIManager.getColor("glowError")); - }}; - JPanel rightPanel = new JPanel() {{ - setBackground(UIManager.getColor("glowFocus")); - }}; + JPanel leftPanel = new JPanel() { + { + setBackground(UIManager.getColor("glowError")); + } + }; + JPanel rightPanel = new JPanel() { + { + setBackground(UIManager.getColor("glowFocus")); + } + }; splitPane.setLeftComponent(leftPanel); splitPane.setRightComponent(rightPanel); DemoPanel panel = new DemoPanel(splitPane, new BorderLayout(), 0); JPanel controlPanel = panel.addControls(); - controlPanel.add(new JCheckBox("ContinuousLayout") {{ - setSelected(splitPane.isContinuousLayout()); - addActionListener(e -> splitPane.setContinuousLayout(isSelected())); - }}); - controlPanel.add(new JCheckBox("OneTouchExpandable") {{ - setSelected(splitPane.isOneTouchExpandable()); - addActionListener(e -> splitPane.setOneTouchExpandable(isSelected())); - }}); - controlPanel.add(new JCheckBox("enabled") {{ - setSelected(splitPane.isEnabled()); - addActionListener(e -> splitPane.setEnabled(isSelected())); - }}); + controlPanel.add(new JCheckBox("ContinuousLayout") { + { + setSelected(splitPane.isContinuousLayout()); + addActionListener(e -> splitPane.setContinuousLayout(isSelected())); + } + }); + controlPanel.add(new JCheckBox("OneTouchExpandable") { + { + setSelected(splitPane.isOneTouchExpandable()); + addActionListener(e -> splitPane.setOneTouchExpandable(isSelected())); + } + }); + controlPanel.add(new JCheckBox("enabled") { + { + setSelected(splitPane.isEnabled()); + addActionListener(e -> splitPane.setEnabled(isSelected())); + } + }); controlPanel = panel.addControls(); controlPanel.add(new JLabel("Orientation:", JLabel.RIGHT)); - controlPanel.add(new JComboBox() {{ - Map mapping = new HashMap() {{ - put("VERTICAL_SPLIT", JSplitPane.VERTICAL_SPLIT); - put("HORIZONTAL_SPLIT", JSplitPane.HORIZONTAL_SPLIT); - }}; - addItem("VERTICAL_SPLIT"); - addItem("HORIZONTAL_SPLIT"); - setSelectedItem("HORIZONTAL_SPLIT"); - addItemListener(e -> splitPane.setOrientation(mapping.get(e.getItem().toString()))); - }}, "sgx"); + controlPanel.add(new JComboBox() { + { + Map mapping = new HashMap() { + { + put("VERTICAL_SPLIT", JSplitPane.VERTICAL_SPLIT); + put("HORIZONTAL_SPLIT", JSplitPane.HORIZONTAL_SPLIT); + } + }; + addItem("VERTICAL_SPLIT"); + addItem("HORIZONTAL_SPLIT"); + setSelectedItem("HORIZONTAL_SPLIT"); + addItemListener(e -> splitPane.setOrientation(mapping.get(e.getItem().toString()))); + } + }, "sgx"); controlPanel.add(new JLabel("JSplitPane.style:", JLabel.RIGHT)); - controlPanel.add(new JComboBox() {{ - addItem("grip"); - addItem("line"); - addItem("invisible"); - setSelectedItem(UIManager.get("SplitPane.defaultDividerStyle")); - addItemListener(e -> splitPane.putClientProperty("JSplitPane.style", e.getItem())); - }}, "sgx"); + controlPanel.add(new JComboBox() { + { + addItem("grip"); + addItem("line"); + addItem("invisible"); + setSelectedItem(UIManager.get("SplitPane.defaultDividerStyle")); + addItemListener(e -> splitPane.putClientProperty("JSplitPane.style", e.getItem())); + } + }, "sgx"); return panel; } diff --git a/core/src/test/java/ui/tabFrame/TabFrameDemo.java b/core/src/test/java/ui/tabFrame/TabFrameDemo.java index f58f996c..65dec857 100644 --- a/core/src/test/java/ui/tabFrame/TabFrameDemo.java +++ b/core/src/test/java/ui/tabFrame/TabFrameDemo.java @@ -20,9 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.tabFrame; +import java.awt.*; + +import javax.swing.*; +import javax.swing.text.BadLocationException; + +import ui.ComponentDemo; +import ui.DemoResources; + import com.github.weisj.darklaf.components.tabframe.JTabFrame; import com.github.weisj.darklaf.components.tabframe.TabbedPopup; import com.github.weisj.darklaf.components.text.NonWrappingTextPane; @@ -31,12 +40,6 @@ import com.github.weisj.darklaf.components.text.NumberingPane; import com.github.weisj.darklaf.icons.IconLoader; import com.github.weisj.darklaf.util.Alignment; import com.github.weisj.darklaf.util.StringUtil; -import ui.ComponentDemo; -import ui.DemoResources; - -import javax.swing.*; -import javax.swing.text.BadLocationException; -import java.awt.*; public class TabFrameDemo implements ComponentDemo { @@ -44,12 +47,13 @@ public class TabFrameDemo implements ComponentDemo { ComponentDemo.showDemo(new TabFrameDemo(), new Dimension(1000, 500)); } - private static Component createTextArea() { - NumberedTextComponent numberPane = new NumberedTextComponent(new NonWrappingTextPane() {{ - setText(StringUtil.repeat(DemoResources.LOREM_IPSUM, 10)); - setFont(new Font(Font.MONOSPACED, Font.PLAIN, getFont().getSize())); - }}); + NumberedTextComponent numberPane = new NumberedTextComponent(new NonWrappingTextPane() { + { + setText(StringUtil.repeat(DemoResources.LOREM_IPSUM, 10)); + setFont(new Font(Font.MONOSPACED, Font.PLAIN, getFont().getSize())); + } + }); NumberingPane numbering = numberPane.getNumberingPane(); Icon icon = IconLoader.get().getIcon("navigation/arrowRight.svg"); try { @@ -84,14 +88,15 @@ public class TabFrameDemo implements ComponentDemo { panel.add(label); tabbedPopup.getTabbedPane().addTab("Tab " + i, panel); } - /* Activate for a custom tab. - tabFrame.setUserTabComponentAt(new JLabel("NORTH (custom tab)") {{ - setBorder(new EmptyBorder(0, 5, 0, 5)); - setOpaque(false); - setForeground(Color.RED); - setFont(new Font(Font.SERIF, Font.ITALIC, 12)); - }}, Alignment.NORTH, 1); - */ + /* + * Activate for a custom tab. + * tabFrame.setUserTabComponentAt(new JLabel("NORTH (custom tab)") {{ + * setBorder(new EmptyBorder(0, 5, 0, 5)); + * setOpaque(false); + * setForeground(Color.RED); + * setFont(new Font(Font.SERIF, Font.ITALIC, 12)); + * }}, Alignment.NORTH, 1); + */ tabFrame.setAcceleratorAt(1, Alignment.NORTH_WEST, 0); tabFrame.setTabEnabled(Alignment.NORTH_EAST, 0, false); diff --git a/core/src/test/java/ui/tabbedPane/ClosableTabbedPaneDemo.java b/core/src/test/java/ui/tabbedPane/ClosableTabbedPaneDemo.java index b4122351..1672c1fa 100644 --- a/core/src/test/java/ui/tabbedPane/ClosableTabbedPaneDemo.java +++ b/core/src/test/java/ui/tabbedPane/ClosableTabbedPaneDemo.java @@ -20,13 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.tabbedPane; -import com.github.weisj.darklaf.components.ClosableTabbedPane; +import javax.swing.*; + import ui.ComponentDemo; -import javax.swing.*; +import com.github.weisj.darklaf.components.ClosableTabbedPane; public class ClosableTabbedPaneDemo extends TabbedPaneDemo { @@ -43,4 +45,3 @@ public class ClosableTabbedPaneDemo extends TabbedPaneDemo { return "ClosableTabbPane Demo"; } } - diff --git a/core/src/test/java/ui/tabbedPane/TabbedPaneDemo.java b/core/src/test/java/ui/tabbedPane/TabbedPaneDemo.java index 57157112..7caf4e3a 100644 --- a/core/src/test/java/ui/tabbedPane/TabbedPaneDemo.java +++ b/core/src/test/java/ui/tabbedPane/TabbedPaneDemo.java @@ -20,22 +20,25 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.tabbedPane; -import com.github.weisj.darklaf.ui.tabbedpane.DarkTabbedPaneUI; -import com.github.weisj.darklaf.util.StringUtil; -import ui.ComponentDemo; -import ui.DemoPanel; +import java.awt.*; +import java.util.HashMap; +import java.util.Map; import javax.swing.*; import javax.swing.border.CompoundBorder; import javax.swing.border.EmptyBorder; import javax.swing.border.LineBorder; import javax.swing.plaf.UIResource; -import java.awt.*; -import java.util.HashMap; -import java.util.Map; + +import ui.ComponentDemo; +import ui.DemoPanel; + +import com.github.weisj.darklaf.ui.tabbedpane.DarkTabbedPaneUI; +import com.github.weisj.darklaf.util.StringUtil; public class TabbedPaneDemo implements ComponentDemo { @@ -58,86 +61,114 @@ public class TabbedPaneDemo implements ComponentDemo { JPanel controlPanel = panel.addControls(); controlPanel.add(new JLabel("TabLayoutPolicy:", JLabel.RIGHT)); - controlPanel.add(new JComboBox() {{ - Map mapping = new HashMap() {{ - put("SCROLL_TAB_LAYOUT", JTabbedPane.SCROLL_TAB_LAYOUT); - put("WRAP_TAB_LAYOUT", JTabbedPane.WRAP_TAB_LAYOUT); - }}; - addItem("SCROLL_TAB_LAYOUT"); - addItem("WRAP_TAB_LAYOUT"); - setSelectedItem("SCROLL_TAB_LAYOUT"); - addItemListener(e -> tabbedPane.setTabLayoutPolicy(mapping.get(e.getItem().toString()))); - }}, "sgx"); + controlPanel.add(new JComboBox() { + { + Map mapping = new HashMap() { + { + put("SCROLL_TAB_LAYOUT", JTabbedPane.SCROLL_TAB_LAYOUT); + put("WRAP_TAB_LAYOUT", JTabbedPane.WRAP_TAB_LAYOUT); + } + }; + addItem("SCROLL_TAB_LAYOUT"); + addItem("WRAP_TAB_LAYOUT"); + setSelectedItem("SCROLL_TAB_LAYOUT"); + addItemListener(e -> tabbedPane.setTabLayoutPolicy(mapping.get(e.getItem().toString()))); + } + }, "sgx"); controlPanel.add(new JLabel("TabPlacement:", JLabel.RIGHT)); - controlPanel.add(new JComboBox() {{ - Map mapping = new HashMap() {{ - put("TOP", JTabbedPane.TOP); - put("BOTTOM", JTabbedPane.BOTTOM); - put("LEFT", JTabbedPane.LEFT); - put("RIGHT", JTabbedPane.RIGHT); - }}; - addItem("TOP"); - addItem("BOTTOM"); - addItem("LEFT"); - addItem("RIGHT"); - setSelectedItem("TOP"); - addItemListener(e -> tabbedPane.setTabPlacement(mapping.get(e.getItem().toString()))); - }}, "sgx"); + controlPanel.add(new JComboBox() { + { + Map mapping = new HashMap() { + { + put("TOP", JTabbedPane.TOP); + put("BOTTOM", JTabbedPane.BOTTOM); + put("LEFT", JTabbedPane.LEFT); + put("RIGHT", JTabbedPane.RIGHT); + } + }; + addItem("TOP"); + addItem("BOTTOM"); + addItem("LEFT"); + addItem("RIGHT"); + setSelectedItem("TOP"); + addItemListener(e -> tabbedPane.setTabPlacement(mapping.get(e.getItem().toString()))); + } + }, "sgx"); controlPanel = panel.addControls(); - controlPanel.add(new JCheckBox("LeftToRight") {{ - setSelected(tabbedPane.getComponentOrientation().isLeftToRight()); - addActionListener(e -> tabbedPane.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT - : ComponentOrientation.RIGHT_TO_LEFT)); - }}); - controlPanel.add(new JCheckBox(DarkTabbedPaneUI.KEY_CENTER_TABS) {{ - setSelected(false); - addActionListener(e -> tabbedPane.putClientProperty(DarkTabbedPaneUI.KEY_CENTER_TABS, isSelected())); - }}); - controlPanel.add(new JCheckBox("JTabbedPane.dndEnabled") {{ - setSelected(false); - addActionListener(e -> tabbedPane.putClientProperty("JTabbedPane.dndEnabled", isSelected())); - }}); - controlPanel.add(new JCheckBox("JTabbedPane.showNewTabButton") {{ - setSelected(false); - addActionListener(e -> tabbedPane.putClientProperty("JTabbedPane.showNewTabButton", isSelected())); - }}); - controlPanel.add(new JCheckBox("JTabbedPane.leadingComponent") {{ - setSelected(false); - JLabel leading = new PlaceholderLabel("Leading"); - addActionListener(e -> tabbedPane.putClientProperty("JTabbedPane.leadingComponent", - isSelected() ? leading : null)); - }}); - controlPanel.add(new JCheckBox("JTabbedPane.trailingComponent") {{ - setSelected(false); - JLabel trailing = new PlaceholderLabel("Trailing"); - addActionListener(e -> tabbedPane.putClientProperty("JTabbedPane.trailingComponent", - isSelected() ? trailing : null)); - }}); - controlPanel.add(new JCheckBox("JTabbedPane.northComponent") {{ - setSelected(false); - JLabel north = new PlaceholderLabel("North"); - addActionListener(e -> tabbedPane.putClientProperty("JTabbedPane.northComponent", - isSelected() ? north : null)); - }}); - controlPanel.add(new JCheckBox("JTabbedPane.eastComponent") {{ - setSelected(false); - JLabel east = new PlaceholderLabel("East"); - addActionListener(e -> tabbedPane.putClientProperty("JTabbedPane.eastComponent", - isSelected() ? east : null)); - }}); - controlPanel.add(new JCheckBox("JTabbedPane.southComponent") {{ - setSelected(false); - JLabel south = new PlaceholderLabel("South"); - addActionListener(e -> tabbedPane.putClientProperty("JTabbedPane.southComponent", - isSelected() ? south : null)); - }}); - controlPanel.add(new JCheckBox("JTabbedPane.westComponent") {{ - setSelected(false); - JLabel west = new PlaceholderLabel("West"); - addActionListener(e -> tabbedPane.putClientProperty("JTabbedPane.westComponent", - isSelected() ? west : null)); - }}); + controlPanel.add(new JCheckBox("LeftToRight") { + { + setSelected(tabbedPane.getComponentOrientation().isLeftToRight()); + addActionListener(e -> tabbedPane.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT + : ComponentOrientation.RIGHT_TO_LEFT)); + } + }); + controlPanel.add(new JCheckBox(DarkTabbedPaneUI.KEY_CENTER_TABS) { + { + setSelected(false); + addActionListener(e -> tabbedPane.putClientProperty(DarkTabbedPaneUI.KEY_CENTER_TABS, isSelected())); + } + }); + controlPanel.add(new JCheckBox("JTabbedPane.dndEnabled") { + { + setSelected(false); + addActionListener(e -> tabbedPane.putClientProperty("JTabbedPane.dndEnabled", isSelected())); + } + }); + controlPanel.add(new JCheckBox("JTabbedPane.showNewTabButton") { + { + setSelected(false); + addActionListener(e -> tabbedPane.putClientProperty("JTabbedPane.showNewTabButton", isSelected())); + } + }); + controlPanel.add(new JCheckBox("JTabbedPane.leadingComponent") { + { + setSelected(false); + JLabel leading = new PlaceholderLabel("Leading"); + addActionListener(e -> tabbedPane.putClientProperty("JTabbedPane.leadingComponent", + isSelected() ? leading : null)); + } + }); + controlPanel.add(new JCheckBox("JTabbedPane.trailingComponent") { + { + setSelected(false); + JLabel trailing = new PlaceholderLabel("Trailing"); + addActionListener(e -> tabbedPane.putClientProperty("JTabbedPane.trailingComponent", + isSelected() ? trailing : null)); + } + }); + controlPanel.add(new JCheckBox("JTabbedPane.northComponent") { + { + setSelected(false); + JLabel north = new PlaceholderLabel("North"); + addActionListener(e -> tabbedPane.putClientProperty("JTabbedPane.northComponent", + isSelected() ? north : null)); + } + }); + controlPanel.add(new JCheckBox("JTabbedPane.eastComponent") { + { + setSelected(false); + JLabel east = new PlaceholderLabel("East"); + addActionListener(e -> tabbedPane.putClientProperty("JTabbedPane.eastComponent", + isSelected() ? east : null)); + } + }); + controlPanel.add(new JCheckBox("JTabbedPane.southComponent") { + { + setSelected(false); + JLabel south = new PlaceholderLabel("South"); + addActionListener(e -> tabbedPane.putClientProperty("JTabbedPane.southComponent", + isSelected() ? south : null)); + } + }); + controlPanel.add(new JCheckBox("JTabbedPane.westComponent") { + { + setSelected(false); + JLabel west = new PlaceholderLabel("West"); + addActionListener(e -> tabbedPane.putClientProperty("JTabbedPane.westComponent", + isSelected() ? west : null)); + } + }); return panel; } @@ -158,4 +189,3 @@ public class TabbedPaneDemo implements ComponentDemo { } } } - diff --git a/core/src/test/java/ui/tabbedPane/TabbedPaneKeyboardShortcut.java b/core/src/test/java/ui/tabbedPane/TabbedPaneKeyboardShortcut.java index 12feb815..a4e89fa4 100644 --- a/core/src/test/java/ui/tabbedPane/TabbedPaneKeyboardShortcut.java +++ b/core/src/test/java/ui/tabbedPane/TabbedPaneKeyboardShortcut.java @@ -20,15 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.tabbedPane; -import ui.ComponentDemo; - -import javax.swing.*; import java.awt.*; import java.awt.event.KeyEvent; +import javax.swing.*; + +import ui.ComponentDemo; + public class TabbedPaneKeyboardShortcut implements ComponentDemo { public static void main(final String[] args) { diff --git a/core/src/test/java/ui/table/TableDemo.java b/core/src/test/java/ui/table/TableDemo.java index 79a74ae4..a196a546 100644 --- a/core/src/test/java/ui/table/TableDemo.java +++ b/core/src/test/java/ui/table/TableDemo.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.table; @@ -30,13 +31,13 @@ import javax.swing.*; import javax.swing.table.JTableHeader; import javax.swing.table.TableCellEditor; +import ui.ComponentDemo; +import ui.DemoPanel; + import com.github.weisj.darklaf.ui.table.DarkTableCellEditor; import com.github.weisj.darklaf.ui.table.DarkTableUI; import com.github.weisj.darklaf.util.PropertyKey; -import ui.ComponentDemo; -import ui.DemoPanel; - public class TableDemo implements ComponentDemo { public static void main(final String[] args) { @@ -46,7 +47,7 @@ public class TableDemo implements ComponentDemo { @Override public JComponent createComponent() { String[] columns = new String[]{ - "Id", "Name", "Hourly Rate", "Part Time", "Components" + "Id", "Name", "Hourly Rate", "Part Time", "Components" }; Object[][] data = new Object[][]{{1, "John", 40.0, false, "Item"}, @@ -78,67 +79,94 @@ public class TableDemo implements ComponentDemo { DemoPanel panel = new DemoPanel(new JScrollPane(table), new BorderLayout(), 10); JPanel controlPanel = panel.addControls(3); - controlPanel.add(new JCheckBox("enabled") {{ - setSelected(table.isEnabled()); - addActionListener(e -> table.setEnabled(isSelected())); - }}); - controlPanel.add(new JCheckBox(PropertyKey.EDITABLE) {{ - setSelected(editable.get()); - addActionListener(e -> editable.set(isSelected())); - }}); - controlPanel.add(new JCheckBox("horizontal lines") {{ - setSelected(table.getShowHorizontalLines()); - addActionListener(e -> table.setShowHorizontalLines(isSelected())); - }}); - controlPanel.add(new JCheckBox("vertical lines") {{ - setSelected(table.getShowVerticalLines()); - addActionListener(e -> table.setShowVerticalLines(isSelected())); - }}); - controlPanel.add(new JCheckBox("LeftToRight") {{ - setSelected(table.getComponentOrientation().isLeftToRight()); - addActionListener(e -> table.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT - : ComponentOrientation.RIGHT_TO_LEFT)); - }}); - controlPanel.add(new JCheckBox(DarkTableUI.KEY_ALTERNATE_ROW_COLOR) {{ - setSelected(Boolean.TRUE.equals(table.getClientProperty(DarkTableUI.KEY_ALTERNATE_ROW_COLOR))); - addActionListener(e -> table.putClientProperty(DarkTableUI.KEY_ALTERNATE_ROW_COLOR, isSelected())); - }}); - controlPanel.add(new JCheckBox("reordering") {{ - setSelected(header.getReorderingAllowed()); - addActionListener(e -> header.setReorderingAllowed(isSelected())); - }}); - controlPanel.add(new JCheckBox("cell selection") {{ - setSelected(table.getCellSelectionEnabled()); - addActionListener(e -> table.setCellSelectionEnabled(isSelected())); - }}); - controlPanel.add(new JCheckBox("column selection") {{ - setSelected(table.getColumnSelectionAllowed()); - addActionListener(e -> table.setColumnSelectionAllowed(isSelected())); - table.addPropertyChangeListener(e -> setSelected(table.getColumnSelectionAllowed())); - }}); - controlPanel.add(new JCheckBox("row selection") {{ - setSelected(table.getRowSelectionAllowed()); - addActionListener(e -> table.setRowSelectionAllowed(isSelected())); - table.addPropertyChangeListener(e -> setSelected(table.getRowSelectionAllowed())); - }}); - controlPanel.add(new JCheckBox(DarkTableUI.KEY_RENDER_BOOLEAN_AS_CHECKBOX) {{ - setSelected(Boolean.TRUE.equals(table.getClientProperty(DarkTableUI.KEY_RENDER_BOOLEAN_AS_CHECKBOX))); - addActionListener(e -> table.putClientProperty(DarkTableUI.KEY_RENDER_BOOLEAN_AS_CHECKBOX, isSelected())); - }}, "span"); + controlPanel.add(new JCheckBox("enabled") { + { + setSelected(table.isEnabled()); + addActionListener(e -> table.setEnabled(isSelected())); + } + }); + controlPanel.add(new JCheckBox(PropertyKey.EDITABLE) { + { + setSelected(editable.get()); + addActionListener(e -> editable.set(isSelected())); + } + }); + controlPanel.add(new JCheckBox("horizontal lines") { + { + setSelected(table.getShowHorizontalLines()); + addActionListener(e -> table.setShowHorizontalLines(isSelected())); + } + }); + controlPanel.add(new JCheckBox("vertical lines") { + { + setSelected(table.getShowVerticalLines()); + addActionListener(e -> table.setShowVerticalLines(isSelected())); + } + }); + controlPanel.add(new JCheckBox("LeftToRight") { + { + setSelected(table.getComponentOrientation().isLeftToRight()); + addActionListener(e -> table.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT + : ComponentOrientation.RIGHT_TO_LEFT)); + } + }); + controlPanel.add(new JCheckBox(DarkTableUI.KEY_ALTERNATE_ROW_COLOR) { + { + setSelected(Boolean.TRUE.equals(table.getClientProperty(DarkTableUI.KEY_ALTERNATE_ROW_COLOR))); + addActionListener(e -> table.putClientProperty(DarkTableUI.KEY_ALTERNATE_ROW_COLOR, isSelected())); + } + }); + controlPanel.add(new JCheckBox("reordering") { + { + setSelected(header.getReorderingAllowed()); + addActionListener(e -> header.setReorderingAllowed(isSelected())); + } + }); + controlPanel.add(new JCheckBox("cell selection") { + { + setSelected(table.getCellSelectionEnabled()); + addActionListener(e -> table.setCellSelectionEnabled(isSelected())); + } + }); + controlPanel.add(new JCheckBox("column selection") { + { + setSelected(table.getColumnSelectionAllowed()); + addActionListener(e -> table.setColumnSelectionAllowed(isSelected())); + table.addPropertyChangeListener(e -> setSelected(table.getColumnSelectionAllowed())); + } + }); + controlPanel.add(new JCheckBox("row selection") { + { + setSelected(table.getRowSelectionAllowed()); + addActionListener(e -> table.setRowSelectionAllowed(isSelected())); + table.addPropertyChangeListener(e -> setSelected(table.getRowSelectionAllowed())); + } + }); + controlPanel.add(new JCheckBox(DarkTableUI.KEY_RENDER_BOOLEAN_AS_CHECKBOX) { + { + setSelected(Boolean.TRUE.equals(table.getClientProperty(DarkTableUI.KEY_RENDER_BOOLEAN_AS_CHECKBOX))); + addActionListener(e -> table.putClientProperty(DarkTableUI.KEY_RENDER_BOOLEAN_AS_CHECKBOX, + isSelected())); + } + }, "span"); controlPanel.add(new JLabel(DarkTableUI.KEY_BOOLEAN_RENDER_TYPE + ":", JLabel.RIGHT)); - controlPanel.add(new JComboBox() {{ - addItem(DarkTableUI.RENDER_TYPE_CHECKBOX); - addItem(DarkTableUI.RENDER_TYPE_RADIOBUTTON); - setSelectedItem(table.getClientProperty(DarkTableUI.KEY_BOOLEAN_RENDER_TYPE)); - addItemListener(e -> table.putClientProperty(DarkTableUI.KEY_BOOLEAN_RENDER_TYPE, e.getItem())); - }}); + controlPanel.add(new JComboBox() { + { + addItem(DarkTableUI.RENDER_TYPE_CHECKBOX); + addItem(DarkTableUI.RENDER_TYPE_RADIOBUTTON); + setSelectedItem(table.getClientProperty(DarkTableUI.KEY_BOOLEAN_RENDER_TYPE)); + addItemListener(e -> table.putClientProperty(DarkTableUI.KEY_BOOLEAN_RENDER_TYPE, e.getItem())); + } + }); controlPanel = panel.addControls(3); controlPanel.add(new JLabel("Row height:")); - controlPanel.add(new JSpinner() {{ - setValue(table.getRowHeight()); - addChangeListener(e -> table.setRowHeight(Integer.parseInt(getValue().toString()))); - }}); + controlPanel.add(new JSpinner() { + { + setValue(table.getRowHeight()); + addChangeListener(e -> table.setRowHeight(Integer.parseInt(getValue().toString()))); + } + }); return panel; } diff --git a/core/src/test/java/ui/text/EditorPaneDemo.java b/core/src/test/java/ui/text/EditorPaneDemo.java index 5c2b93e5..2fe5b828 100644 --- a/core/src/test/java/ui/text/EditorPaneDemo.java +++ b/core/src/test/java/ui/text/EditorPaneDemo.java @@ -20,13 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.text; -import ui.ComponentDemo; - import javax.swing.*; +import ui.ComponentDemo; + public class EditorPaneDemo extends TextComponentDemo { public static void main(final String[] args) { diff --git a/core/src/test/java/ui/text/FormattedTextFieldDemo.java b/core/src/test/java/ui/text/FormattedTextFieldDemo.java index 555a48c1..b3dfcd72 100644 --- a/core/src/test/java/ui/text/FormattedTextFieldDemo.java +++ b/core/src/test/java/ui/text/FormattedTextFieldDemo.java @@ -20,13 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.text; -import ui.ComponentDemo; - import javax.swing.*; +import ui.ComponentDemo; + public class FormattedTextFieldDemo extends TextFieldDemo { public static void main(final String[] args) { diff --git a/core/src/test/java/ui/text/PasswordFieldDemo.java b/core/src/test/java/ui/text/PasswordFieldDemo.java index 80280079..cadbc687 100644 --- a/core/src/test/java/ui/text/PasswordFieldDemo.java +++ b/core/src/test/java/ui/text/PasswordFieldDemo.java @@ -20,15 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.text; -import com.github.weisj.darklaf.util.PropertyKey; +import java.awt.*; + +import javax.swing.*; + import ui.ComponentDemo; import ui.DemoPanel; -import javax.swing.*; -import java.awt.*; +import com.github.weisj.darklaf.util.PropertyKey; public class PasswordFieldDemo implements ComponentDemo { @@ -42,29 +45,41 @@ public class PasswordFieldDemo implements ComponentDemo { DemoPanel panel = new DemoPanel(textField); JPanel controlPanel = panel.addControls(); - controlPanel.add(new JCheckBox("enabled") {{ - setSelected(textField.isEnabled()); - addActionListener(e -> textField.setEnabled(isSelected())); - }}); - controlPanel.add(new JCheckBox(PropertyKey.EDITABLE) {{ - setSelected(textField.isEditable()); - addActionListener(e -> textField.setEditable(isSelected())); - }}); - controlPanel.add(new JCheckBox("LeftToRight") {{ - setEnabled(true); - addActionListener(e -> textField.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT - : ComponentOrientation.RIGHT_TO_LEFT)); - }}); - controlPanel.add(new JCheckBox("JTextComponent.roundedSelection") {{ - setSelected(true); - addActionListener(e -> textField.putClientProperty("JTextComponent.roundedSelection", isSelected())); - }}); - controlPanel.add(new JCheckBox("JPasswordField.showViewIcon") {{ - addActionListener(e -> textField.putClientProperty("JPasswordField.showViewIcon", isSelected())); - }}); - controlPanel.add(new JCheckBox("JTextComponent.hasError") {{ - addActionListener(e -> textField.putClientProperty("JTextComponent.hasError", isSelected())); - }}); + controlPanel.add(new JCheckBox("enabled") { + { + setSelected(textField.isEnabled()); + addActionListener(e -> textField.setEnabled(isSelected())); + } + }); + controlPanel.add(new JCheckBox(PropertyKey.EDITABLE) { + { + setSelected(textField.isEditable()); + addActionListener(e -> textField.setEditable(isSelected())); + } + }); + controlPanel.add(new JCheckBox("LeftToRight") { + { + setEnabled(true); + addActionListener(e -> textField.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT + : ComponentOrientation.RIGHT_TO_LEFT)); + } + }); + controlPanel.add(new JCheckBox("JTextComponent.roundedSelection") { + { + setSelected(true); + addActionListener(e -> textField.putClientProperty("JTextComponent.roundedSelection", isSelected())); + } + }); + controlPanel.add(new JCheckBox("JPasswordField.showViewIcon") { + { + addActionListener(e -> textField.putClientProperty("JPasswordField.showViewIcon", isSelected())); + } + }); + controlPanel.add(new JCheckBox("JTextComponent.hasError") { + { + addActionListener(e -> textField.putClientProperty("JTextComponent.hasError", isSelected())); + } + }); return panel; } diff --git a/core/src/test/java/ui/text/TextAreaDemo.java b/core/src/test/java/ui/text/TextAreaDemo.java index a62dc1be..e78ec037 100644 --- a/core/src/test/java/ui/text/TextAreaDemo.java +++ b/core/src/test/java/ui/text/TextAreaDemo.java @@ -20,13 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.text; -import ui.ComponentDemo; - import javax.swing.*; +import ui.ComponentDemo; + public class TextAreaDemo extends TextComponentDemo { public static void main(final String[] args) { diff --git a/core/src/test/java/ui/text/TextComponentDemo.java b/core/src/test/java/ui/text/TextComponentDemo.java index 176ee900..cea48967 100644 --- a/core/src/test/java/ui/text/TextComponentDemo.java +++ b/core/src/test/java/ui/text/TextComponentDemo.java @@ -20,19 +20,21 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.text; -import com.github.weisj.darklaf.ui.text.DarkTextBorder; -import com.github.weisj.darklaf.util.PropertyKey; -import com.github.weisj.darklaf.util.StringUtil; -import ui.ComponentDemo; -import ui.DemoPanel; - import javax.swing.*; import javax.swing.border.Border; import javax.swing.text.JTextComponent; +import ui.ComponentDemo; +import ui.DemoPanel; + +import com.github.weisj.darklaf.ui.text.DarkTextBorder; +import com.github.weisj.darklaf.util.PropertyKey; +import com.github.weisj.darklaf.util.StringUtil; + public abstract class TextComponentDemo implements ComponentDemo { @Override @@ -44,25 +46,35 @@ public abstract class TextComponentDemo implements Com Border border = text.getBorder(); JPanel controlPanel = panel.addControls(); - controlPanel.add(new JCheckBox("enabled") {{ - setSelected(text.isEnabled()); - addActionListener(e -> text.setEnabled(isSelected())); - }}); - controlPanel.add(new JCheckBox(PropertyKey.EDITABLE) {{ - setSelected(text.isEditable()); - addActionListener(e -> text.setEditable(isSelected())); - }}); - controlPanel.add(new JCheckBox("text border") {{ - setSelected(false); - addActionListener(e -> text.setBorder(isSelected() ? textBorder : border)); - }}); - controlPanel.add(new JCheckBox("JTextComponent.roundedSelection") {{ - setSelected(true); - addActionListener(e -> text.putClientProperty("JTextComponent.roundedSelection", isSelected())); - }}); - controlPanel.add(new JCheckBox("JTextComponent.hasError") {{ - addActionListener(e -> text.putClientProperty("JTextComponent.hasError", isSelected())); - }}); + controlPanel.add(new JCheckBox("enabled") { + { + setSelected(text.isEnabled()); + addActionListener(e -> text.setEnabled(isSelected())); + } + }); + controlPanel.add(new JCheckBox(PropertyKey.EDITABLE) { + { + setSelected(text.isEditable()); + addActionListener(e -> text.setEditable(isSelected())); + } + }); + controlPanel.add(new JCheckBox("text border") { + { + setSelected(false); + addActionListener(e -> text.setBorder(isSelected() ? textBorder : border)); + } + }); + controlPanel.add(new JCheckBox("JTextComponent.roundedSelection") { + { + setSelected(true); + addActionListener(e -> text.putClientProperty("JTextComponent.roundedSelection", isSelected())); + } + }); + controlPanel.add(new JCheckBox("JTextComponent.hasError") { + { + addActionListener(e -> text.putClientProperty("JTextComponent.hasError", isSelected())); + } + }); return panel; } diff --git a/core/src/test/java/ui/text/TextFieldDemo.java b/core/src/test/java/ui/text/TextFieldDemo.java index 477197d8..aa6e6634 100644 --- a/core/src/test/java/ui/text/TextFieldDemo.java +++ b/core/src/test/java/ui/text/TextFieldDemo.java @@ -20,15 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.text; -import com.github.weisj.darklaf.util.PropertyKey; +import java.awt.*; + +import javax.swing.*; + import ui.ComponentDemo; import ui.DemoPanel; -import javax.swing.*; -import java.awt.*; +import com.github.weisj.darklaf.util.PropertyKey; public class TextFieldDemo implements ComponentDemo { @@ -42,29 +45,41 @@ public class TextFieldDemo implements ComponentDemo { DemoPanel panel = new DemoPanel(textField); JPanel controlPanel = panel.addControls(); - controlPanel.add(new JCheckBox("enabled") {{ - setSelected(textField.isEnabled()); - addActionListener(e -> textField.setEnabled(isSelected())); - }}); - controlPanel.add(new JCheckBox(PropertyKey.EDITABLE) {{ - setSelected(textField.isEditable()); - addActionListener(e -> textField.setEditable(isSelected())); - }}); - controlPanel.add(new JCheckBox("LeftToRight") {{ - setEnabled(true); - addActionListener(e -> textField.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT - : ComponentOrientation.RIGHT_TO_LEFT)); - }}); - controlPanel.add(new JCheckBox("JTextComponent.roundedSelection") {{ - setSelected(true); - addActionListener(e -> textField.putClientProperty("JTextComponent.roundedSelection", isSelected())); - }}); - controlPanel.add(new JCheckBox("JTextField.variant = search") {{ - addActionListener(e -> textField.putClientProperty("JTextField.variant", isSelected() ? "search" : "")); - }}); - controlPanel.add(new JCheckBox("JTextComponent.hasError") {{ - addActionListener(e -> textField.putClientProperty("JTextComponent.hasError", isSelected())); - }}); + controlPanel.add(new JCheckBox("enabled") { + { + setSelected(textField.isEnabled()); + addActionListener(e -> textField.setEnabled(isSelected())); + } + }); + controlPanel.add(new JCheckBox(PropertyKey.EDITABLE) { + { + setSelected(textField.isEditable()); + addActionListener(e -> textField.setEditable(isSelected())); + } + }); + controlPanel.add(new JCheckBox("LeftToRight") { + { + setEnabled(true); + addActionListener(e -> textField.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT + : ComponentOrientation.RIGHT_TO_LEFT)); + } + }); + controlPanel.add(new JCheckBox("JTextComponent.roundedSelection") { + { + setSelected(true); + addActionListener(e -> textField.putClientProperty("JTextComponent.roundedSelection", isSelected())); + } + }); + controlPanel.add(new JCheckBox("JTextField.variant = search") { + { + addActionListener(e -> textField.putClientProperty("JTextField.variant", isSelected() ? "search" : "")); + } + }); + controlPanel.add(new JCheckBox("JTextComponent.hasError") { + { + addActionListener(e -> textField.putClientProperty("JTextComponent.hasError", isSelected())); + } + }); return panel; } diff --git a/core/src/test/java/ui/text/TextPaneDemo.java b/core/src/test/java/ui/text/TextPaneDemo.java index 5f36f0bd..a2ce9a79 100644 --- a/core/src/test/java/ui/text/TextPaneDemo.java +++ b/core/src/test/java/ui/text/TextPaneDemo.java @@ -20,13 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.text; -import ui.ComponentDemo; - import javax.swing.*; +import ui.ComponentDemo; + public class TextPaneDemo extends TextComponentDemo { public static void main(final String[] args) { diff --git a/core/src/test/java/ui/toolBar/ToolBarDemo.java b/core/src/test/java/ui/toolBar/ToolBarDemo.java index 30d763d2..8ad4dacd 100644 --- a/core/src/test/java/ui/toolBar/ToolBarDemo.java +++ b/core/src/test/java/ui/toolBar/ToolBarDemo.java @@ -20,37 +20,38 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. - */ -package ui.toolBar;/* - * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of Oracle or the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +package ui.toolBar;/* + * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Oracle or the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ /* * toolBar.ToolBarDemo.java requires the following additional files: @@ -58,14 +59,14 @@ package ui.toolBar;/* * images/Forward24.gif * images/Up24.gif */ - -import ui.ComponentDemo; - -import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import javax.swing.*; + +import ui.ComponentDemo; + public class ToolBarDemo extends JPanel implements ActionListener, ComponentDemo { private static final String PREVIOUS = "previous"; private static final String UP = "up"; @@ -95,7 +96,7 @@ public class ToolBarDemo extends JPanel implements ActionListener, ComponentDemo private JButton makeNavigationButton(final String actionCommand, final String toolTipText, final String altText) { - //Create and initialize the button. + // Create and initialize the button. JButton button = new JButton(); button.setActionCommand(actionCommand); button.setToolTipText(toolTipText); @@ -110,7 +111,7 @@ public class ToolBarDemo extends JPanel implements ActionListener, ComponentDemo String description = null; // Handle each button. - if (PREVIOUS.equals(cmd)) { //first button clicked + if (PREVIOUS.equals(cmd)) { // first button clicked description = "taken you to the previous ."; } else if (UP.equals(cmd)) { // second button clicked description = "taken you up one level to ."; @@ -129,17 +130,17 @@ public class ToolBarDemo extends JPanel implements ActionListener, ComponentDemo @Override public JComponent createComponent() { - //Create the toolbar. + // Create the toolbar. JToolBar toolBar = new JToolBar("Demo ToolBar"); addButtons(toolBar); - //Create the text area used for output. Request - //enough space for 5 rows and 30 columns. + // Create the text area used for output. Request + // enough space for 5 rows and 30 columns. textArea = new JTextArea(5, 30); textArea.setEditable(false); JScrollPane scrollPane = new JScrollPane(textArea); - //Lay out the main panel. + // Lay out the main panel. setPreferredSize(new Dimension(450, 130)); add(toolBar, BorderLayout.PAGE_START); add(scrollPane, BorderLayout.CENTER); diff --git a/core/src/test/java/ui/toolTip/ToolTipDemo.java b/core/src/test/java/ui/toolTip/ToolTipDemo.java index b5ee5a61..d8395594 100644 --- a/core/src/test/java/ui/toolTip/ToolTipDemo.java +++ b/core/src/test/java/ui/toolTip/ToolTipDemo.java @@ -20,18 +20,20 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.toolTip; +import javax.swing.*; + +import ui.ComponentDemo; +import ui.DemoPanel; + import com.github.weisj.darklaf.components.alignment.AlignmentStrategy; import com.github.weisj.darklaf.components.tooltip.ToolTipContext; import com.github.weisj.darklaf.components.tooltip.ToolTipStyle; import com.github.weisj.darklaf.ui.tooltip.DarkTooltipUI; import com.github.weisj.darklaf.util.Alignment; -import ui.ComponentDemo; -import ui.DemoPanel; - -import javax.swing.*; public class ToolTipDemo implements ComponentDemo { @@ -51,40 +53,54 @@ public class ToolTipDemo implements ComponentDemo { JPanel controlPanel = panel.addControls(3); - controlPanel.add(new JCheckBox("Align inside") {{ - setSelected(context.isAlignInside()); - addActionListener(e -> context.setAlignInside(isSelected())); - }}); - controlPanel.add(new JCheckBox("Ignore Border") {{ - setSelected(context.isIgnoreBorder()); - addActionListener(e -> context.setIgnoreBorder(isSelected())); - }}); - controlPanel.add(new JCheckBox("Use best fit") {{ - setSelected(context.isBestFit()); - addActionListener(e -> context.setUseBestFit(isSelected())); - }}); + controlPanel.add(new JCheckBox("Align inside") { + { + setSelected(context.isAlignInside()); + addActionListener(e -> context.setAlignInside(isSelected())); + } + }); + controlPanel.add(new JCheckBox("Ignore Border") { + { + setSelected(context.isIgnoreBorder()); + addActionListener(e -> context.setIgnoreBorder(isSelected())); + } + }); + controlPanel.add(new JCheckBox("Use best fit") { + { + setSelected(context.isBestFit()); + addActionListener(e -> context.setUseBestFit(isSelected())); + } + }); controlPanel = panel.addControls(); controlPanel.add(new JLabel("Tooltip Style:", JLabel.RIGHT)); - controlPanel.add(new JComboBox(ToolTipStyle.values()) {{ - setSelectedItem(ToolTipStyle.BALLOON); - addItemListener(e -> context.setToolTipStyle((ToolTipStyle) e.getItem())); - }}, "sgx"); + controlPanel.add(new JComboBox(ToolTipStyle.values()) { + { + setSelectedItem(ToolTipStyle.BALLOON); + addItemListener(e -> context.setToolTipStyle((ToolTipStyle) e.getItem())); + } + }, "sgx"); controlPanel.add(new JLabel("Alignment:", JLabel.RIGHT)); - controlPanel.add(new JComboBox(Alignment.values()) {{ - setSelectedItem(context.getAlignment()); - addItemListener(e -> context.setAlignment((Alignment) e.getItem())); - }}, "sgx"); + controlPanel.add(new JComboBox(Alignment.values()) { + { + setSelectedItem(context.getAlignment()); + addItemListener(e -> context.setAlignment((Alignment) e.getItem())); + } + }, "sgx"); controlPanel.add(new JLabel("Center Alignment:", JLabel.RIGHT)); - controlPanel.add(new JComboBox(Alignment.values()) {{ - setSelectedItem(context.getCenterAlignment()); - addItemListener(e -> context.setCenterAlignment((Alignment) e.getItem())); - }}, "sgx"); + controlPanel.add(new JComboBox(Alignment.values()) { + { + setSelectedItem(context.getCenterAlignment()); + addItemListener(e -> context.setCenterAlignment((Alignment) e.getItem())); + } + }, "sgx"); controlPanel.add(new JLabel("Alignment Strategy:", JLabel.RIGHT)); - controlPanel.add(new JComboBox(AlignmentStrategy.values()) {{ - setSelectedItem(context.getAlignmentStrategy()); - addItemListener(e -> context.setAlignmentStrategy((AlignmentStrategy) e.getItem())); - }}, "sgx"); + controlPanel.add(new JComboBox(AlignmentStrategy.values()) { + { + setSelectedItem(context.getAlignmentStrategy()); + addItemListener(e -> context.setAlignmentStrategy((AlignmentStrategy) e.getItem())); + } + }, "sgx"); return panel; } diff --git a/core/src/test/java/ui/tree/TreeDemo.java b/core/src/test/java/ui/tree/TreeDemo.java index 68feda2f..5abd245b 100644 --- a/core/src/test/java/ui/tree/TreeDemo.java +++ b/core/src/test/java/ui/tree/TreeDemo.java @@ -20,21 +20,24 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package ui.tree; -import com.github.weisj.darklaf.components.OverlayScrollPane; -import com.github.weisj.darklaf.components.SelectableTreeNode; -import com.github.weisj.darklaf.ui.tree.DarkTreeUI; -import com.github.weisj.darklaf.util.PropertyKey; -import net.miginfocom.swing.MigLayout; -import ui.ComponentDemo; -import ui.DemoPanel; +import java.awt.*; import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeCellRenderer; -import java.awt.*; + +import net.miginfocom.swing.MigLayout; +import ui.ComponentDemo; +import ui.DemoPanel; + +import com.github.weisj.darklaf.components.OverlayScrollPane; +import com.github.weisj.darklaf.components.SelectableTreeNode; +import com.github.weisj.darklaf.ui.tree.DarkTreeUI; +import com.github.weisj.darklaf.util.PropertyKey; public class TreeDemo implements ComponentDemo { @@ -63,8 +66,8 @@ public class TreeDemo implements ComponentDemo { public Component getTreeCellRendererComponent(final JTree tree, final Object value, final boolean sel, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus) { - Component component = super.getTreeCellRendererComponent( - tree, value, sel, expanded, leaf, row, hasFocus); + Component component = super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, + hasFocus); component.setEnabled(value != parent1 && value != child); return component; } @@ -72,42 +75,56 @@ public class TreeDemo implements ComponentDemo { DemoPanel panel = new DemoPanel(new OverlayScrollPane(tree), new BorderLayout(), 0); JPanel controlPanel = panel.addControls(); controlPanel.setLayout(new MigLayout("fillx, wrap 2", "[][grow]")); - controlPanel.add(new JCheckBox(PropertyKey.EDITABLE) {{ - setSelected(tree.isEditable()); - addActionListener(e -> tree.setEditable(isSelected())); - }}); - controlPanel.add(new JCheckBox("LeftToRight") {{ - setSelected(tree.getComponentOrientation().isLeftToRight()); - addActionListener(e -> tree.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT - : ComponentOrientation.RIGHT_TO_LEFT)); - }}); - controlPanel.add(new JCheckBox("show root handles") {{ - setSelected(tree.getShowsRootHandles()); - addActionListener(e -> tree.setShowsRootHandles(isSelected())); - }}); - controlPanel.add(new JCheckBox(DarkTreeUI.KEY_ALTERNATE_ROW_COLOR) {{ - setSelected(Boolean.TRUE.equals(tree.getClientProperty(DarkTreeUI.KEY_ALTERNATE_ROW_COLOR))); - addActionListener(e -> tree.putClientProperty(DarkTreeUI.KEY_ALTERNATE_ROW_COLOR, isSelected())); - }}); - controlPanel.add(new JCheckBox(DarkTreeUI.KEY_RENDER_BOOLEAN_AS_CHECKBOX) {{ - setSelected(Boolean.TRUE.equals(tree.getClientProperty(DarkTreeUI.KEY_RENDER_BOOLEAN_AS_CHECKBOX))); - addActionListener(e -> tree.putClientProperty(DarkTreeUI.KEY_RENDER_BOOLEAN_AS_CHECKBOX, isSelected())); - }}, "span"); + controlPanel.add(new JCheckBox(PropertyKey.EDITABLE) { + { + setSelected(tree.isEditable()); + addActionListener(e -> tree.setEditable(isSelected())); + } + }); + controlPanel.add(new JCheckBox("LeftToRight") { + { + setSelected(tree.getComponentOrientation().isLeftToRight()); + addActionListener(e -> tree.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT + : ComponentOrientation.RIGHT_TO_LEFT)); + } + }); + controlPanel.add(new JCheckBox("show root handles") { + { + setSelected(tree.getShowsRootHandles()); + addActionListener(e -> tree.setShowsRootHandles(isSelected())); + } + }); + controlPanel.add(new JCheckBox(DarkTreeUI.KEY_ALTERNATE_ROW_COLOR) { + { + setSelected(Boolean.TRUE.equals(tree.getClientProperty(DarkTreeUI.KEY_ALTERNATE_ROW_COLOR))); + addActionListener(e -> tree.putClientProperty(DarkTreeUI.KEY_ALTERNATE_ROW_COLOR, isSelected())); + } + }); + controlPanel.add(new JCheckBox(DarkTreeUI.KEY_RENDER_BOOLEAN_AS_CHECKBOX) { + { + setSelected(Boolean.TRUE.equals(tree.getClientProperty(DarkTreeUI.KEY_RENDER_BOOLEAN_AS_CHECKBOX))); + addActionListener(e -> tree.putClientProperty(DarkTreeUI.KEY_RENDER_BOOLEAN_AS_CHECKBOX, isSelected())); + } + }, "span"); controlPanel.add(new JLabel(DarkTreeUI.KEY_BOOLEAN_RENDER_TYPE + ":", JLabel.RIGHT)); - controlPanel.add(new JComboBox() {{ - addItem(DarkTreeUI.RENDER_TYPE_CHECKBOX); - addItem(DarkTreeUI.RENDER_TYPE_RADIOBUTTON); - setSelectedItem(tree.getClientProperty(DarkTreeUI.KEY_BOOLEAN_RENDER_TYPE)); - addItemListener(e -> tree.putClientProperty(DarkTreeUI.KEY_BOOLEAN_RENDER_TYPE, e.getItem())); - }}); + controlPanel.add(new JComboBox() { + { + addItem(DarkTreeUI.RENDER_TYPE_CHECKBOX); + addItem(DarkTreeUI.RENDER_TYPE_RADIOBUTTON); + setSelectedItem(tree.getClientProperty(DarkTreeUI.KEY_BOOLEAN_RENDER_TYPE)); + addItemListener(e -> tree.putClientProperty(DarkTreeUI.KEY_BOOLEAN_RENDER_TYPE, e.getItem())); + } + }); controlPanel.add(new JLabel("JTree.lineStyle:", JLabel.RIGHT)); - controlPanel.add(new JComboBox() {{ - addItem("Dashed"); - addItem("None"); - addItem("Line"); - setSelectedItem("Line"); - addItemListener(e -> tree.putClientProperty("JTree.lineStyle", e.getItem())); - }}); + controlPanel.add(new JComboBox() { + { + addItem("Dashed"); + addItem("None"); + addItem("Line"); + setSelectedItem("Line"); + addItemListener(e -> tree.putClientProperty("JTree.lineStyle", e.getItem())); + } + }); tree.setLargeModel(true); return panel; } diff --git a/core/src/test/resources/theme/my_custom_theme_defaults.properties b/core/src/test/resources/theme/my_custom_theme_defaults.properties index fee4c9bd..c2ea6d61 100644 --- a/core/src/test/resources/theme/my_custom_theme_defaults.properties +++ b/core/src/test/resources/theme/my_custom_theme_defaults.properties @@ -1,9 +1,27 @@ -# suppress inspection "UnusedProperty" for whole file # -# Customization of general ui-element colors. -# (Example values taken from SolarizedLightTheme) +# MIT License +# +# Copyright (c) 2020 Jannis Weis +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# # -####Background#### %background = EEE8D5 %backgroundAlternative = F0EBDB %backgroundColorful = DEDDD1 diff --git a/core/src/test/resources/theme/my_custom_theme_icons.properties b/core/src/test/resources/theme/my_custom_theme_icons.properties index 206516af..625f670c 100644 --- a/core/src/test/resources/theme/my_custom_theme_icons.properties +++ b/core/src/test/resources/theme/my_custom_theme_icons.properties @@ -1,7 +1,26 @@ -# suppress inspection "UnusedProperty" for whole file # -# Customization of icon colors. -# (Example values taken from SolarizedLightTheme) +# MIT License +# +# Copyright (c) 2020 Jannis Weis +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# # %menuIconEnabled = 586E75 %menuIconHovered = BDECFB @@ -24,4 +43,4 @@ %errorIconColor = DC322F %informationIconColor = 268BD2 %warningIconColor = B58900 -%questionIconColor = 268BD2 \ No newline at end of file +%questionIconColor = 268BD2 diff --git a/core/src/test/resources/theme/my_custom_theme_linux.properties b/core/src/test/resources/theme/my_custom_theme_linux.properties index 18f46a57..153c3b6e 100644 --- a/core/src/test/resources/theme/my_custom_theme_linux.properties +++ b/core/src/test/resources/theme/my_custom_theme_linux.properties @@ -1 +1,24 @@ -# Properties that are specific to linux. \ No newline at end of file +# +# MIT License +# +# Copyright (c) 2020 Jannis Weis +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# diff --git a/core/src/test/resources/theme/my_custom_theme_mac.properties b/core/src/test/resources/theme/my_custom_theme_mac.properties index e26243d9..153c3b6e 100644 --- a/core/src/test/resources/theme/my_custom_theme_mac.properties +++ b/core/src/test/resources/theme/my_custom_theme_mac.properties @@ -1 +1,24 @@ -# Properties that are specific to macOS. \ No newline at end of file +# +# MIT License +# +# Copyright (c) 2020 Jannis Weis +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# diff --git a/core/src/test/resources/theme/my_custom_theme_ui.properties b/core/src/test/resources/theme/my_custom_theme_ui.properties index 5169cfe8..153c3b6e 100644 --- a/core/src/test/resources/theme/my_custom_theme_ui.properties +++ b/core/src/test/resources/theme/my_custom_theme_ui.properties @@ -1 +1,24 @@ -# Customization of properties found under com/github/weisj/darklaf/properties/ui \ No newline at end of file +# +# MIT License +# +# Copyright (c) 2020 Jannis Weis +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# diff --git a/core/src/test/resources/theme/my_custom_theme_windows.properties b/core/src/test/resources/theme/my_custom_theme_windows.properties index f6c66d4f..153c3b6e 100644 --- a/core/src/test/resources/theme/my_custom_theme_windows.properties +++ b/core/src/test/resources/theme/my_custom_theme_windows.properties @@ -1 +1,24 @@ -# Properties that are specific to windows. \ No newline at end of file +# +# MIT License +# +# Copyright (c) 2020 Jannis Weis +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# diff --git a/darklaf.importorder b/darklaf.importorder deleted file mode 100644 index b014a109..00000000 --- a/darklaf.importorder +++ /dev/null @@ -1,6 +0,0 @@ -#Organize Import Order -#Mon Apr 06 22:00:20 CEST 2020 -0=java -1=javax -2=org -3=com diff --git a/darklaf_java.eclipseformat.xml b/darklaf_java.eclipseformat.xml index 08e185de..bac5de80 100644 --- a/darklaf_java.eclipseformat.xml +++ b/darklaf_java.eclipseformat.xml @@ -1,4 +1,28 @@ + @@ -13,7 +37,7 @@ - + @@ -125,7 +149,7 @@ value="do not insert"/> - + @@ -143,7 +167,7 @@ + value="one_line_if_single_item"/> @@ -212,7 +236,7 @@ value="do not insert"/> - + @@ -257,7 +281,7 @@ - + - + diff --git a/darklaf_obj_c.eclipseformat.xml b/darklaf_obj_c.eclipseformat.xml deleted file mode 100644 index 1bde687a..00000000 --- a/darklaf_obj_c.eclipseformat.xml +++ /dev/null @@ -1,255 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gradle.properties b/gradle.properties index 71d2e428..0d6662f4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,27 @@ -# Gradle +# +# MIT License +# +# Copyright (c) 2020 Jannis Weis +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# org.gradle.parallel = true kotlin.code.style = official @@ -13,6 +36,7 @@ darklaf.version = 1.4.3.1 shadow.version = 5.1.0 com.github.vlsi.vlsi-release-plugins.version = 1.70 com.github.johnrengelman.shadow.version = 5.1.0 +com.github.autostyle.version = 3.1 # Dependencies jna.version = 5.5.0 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3d27ac58..216e62cd 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,29 @@ -distributionSha256Sum=0f316a67b971b7b571dac7215dcf2591a30994b3450e0629925ffcfe2c68cc5c -distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStorePath=wrapper/dists +# +# MIT License +# +# Copyright (c) 2020 Jannis Weis +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# +distributionSha256Sum = 0f316a67b971b7b571dac7215dcf2591a30994b3450e0629925ffcfe2c68cc5c +distributionUrl = https\://services.gradle.org/distributions/gradle-6.3-all.zip +distributionBase = GRADLE_USER_HOME +distributionPath = wrapper/dists +zipStorePath = wrapper/dists diff --git a/macos/gradle.properties b/macos/gradle.properties index 31539f5c..59760392 100644 --- a/macos/gradle.properties +++ b/macos/gradle.properties @@ -1 +1,25 @@ +# +# MIT License +# +# Copyright (c) 2020 Jannis Weis +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# defaultLibraryName = libdarklaf-macos.dylib diff --git a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/JNIDecorationsMacOS.java b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/JNIDecorationsMacOS.java index 0977dbdc..11d6dfd0 100644 --- a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/JNIDecorationsMacOS.java +++ b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/JNIDecorationsMacOS.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.platform.macos; diff --git a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/JNIThemeInfoMacOS.java b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/JNIThemeInfoMacOS.java index 4b175a3e..c54f16a9 100644 --- a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/JNIThemeInfoMacOS.java +++ b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/JNIThemeInfoMacOS.java @@ -20,13 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.platform.macos; -import com.github.weisj.darklaf.platform.macos.theme.MacOSColors; - import java.awt.*; +import com.github.weisj.darklaf.platform.macos.theme.MacOSColors; + public class JNIThemeInfoMacOS { /** @@ -48,7 +49,6 @@ public class JNIThemeInfoMacOS { */ private static native int nativeGetAccentColor(); - /** * Returns the current accent color. * @@ -57,23 +57,23 @@ public class JNIThemeInfoMacOS { public static Color getAccentColor() { int index = nativeGetAccentColor(); switch (index) { - case -2: + case -2 : return MacOSColors.BLUE; - case -1: + case -1 : return MacOSColors.GRAY; - case 0: + case 0 : return MacOSColors.RED; - case 1: + case 1 : return MacOSColors.ORANGE; - case 2: + case 2 : return MacOSColors.YELLOW; - case 3: + case 3 : return MacOSColors.GREEN; - case 5: + case 5 : return MacOSColors.LILAC; - case 6: + case 6 : return MacOSColors.ROSE; - default: + default : return null; } } @@ -83,7 +83,6 @@ public class JNIThemeInfoMacOS { */ private static native int nativeGetSelectionColor(); - /** * Returns the current selection color. * @@ -99,8 +98,8 @@ public class JNIThemeInfoMacOS { /** * Create an preference change listener. * - * @param callback the event callback. - * @return the pointer to the listener. + * @param callback the event callback. + * @return the pointer to the listener. */ public static native long createPreferenceChangeListener(final Runnable callback); diff --git a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSDecorationsProvider.java b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSDecorationsProvider.java index 9fb7958b..8a580513 100644 --- a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSDecorationsProvider.java +++ b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSDecorationsProvider.java @@ -20,19 +20,21 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.platform.macos; +import java.awt.*; +import java.util.Properties; + +import javax.swing.*; + import com.github.weisj.darklaf.PropertyLoader; import com.github.weisj.darklaf.icons.IconLoader; import com.github.weisj.darklaf.platform.decorations.CustomTitlePane; import com.github.weisj.darklaf.platform.decorations.DecorationsProvider; import com.github.weisj.darklaf.platform.macos.ui.MacOSTitlePane; -import javax.swing.*; -import java.awt.*; -import java.util.Properties; - public class MacOSDecorationsProvider implements DecorationsProvider { @Override diff --git a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSLibrary.java b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSLibrary.java index 281daa1d..15ebecb1 100644 --- a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSLibrary.java +++ b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSLibrary.java @@ -20,15 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.platform.macos; -import com.github.weisj.darklaf.platform.NativeUtil; -import com.github.weisj.darklaf.util.SystemInfo; - import java.util.logging.Level; import java.util.logging.Logger; +import com.github.weisj.darklaf.platform.NativeUtil; +import com.github.weisj.darklaf.util.SystemInfo; + public class MacOSLibrary { private static final Logger LOGGER = Logger.getLogger(MacOSLibrary.class.getName()); @@ -51,8 +52,7 @@ public class MacOSLibrary { } try { if (SystemInfo.isX64) { - NativeUtil.loadLibraryFromJar( - "/com/github/weisj/darklaf/platform/darklaf-macos/macos-x86-64/libdarklaf-macos.dylib"); + NativeUtil.loadLibraryFromJar("/com/github/weisj/darklaf/platform/darklaf-macos/macos-x86-64/libdarklaf-macos.dylib"); loaded = true; LOGGER.info("Loaded libdarklaf-macos.dylib. Native features are enabled."); } else { @@ -61,9 +61,10 @@ public class MacOSLibrary { + "' not supported. Native features will be disabled"); } } catch (Throwable e) { - //Library not found, SecurityManager prevents library loading etc. + // Library not found, SecurityManager prevents library loading etc. LOGGER.log(Level.SEVERE, "Could not load decorations library libdarklaf-macos.dylib." + - " Native features will be disabled", e); + " Native features will be disabled", + e); } } diff --git a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSPreferenceMonitor.java b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSPreferenceMonitor.java index 940e7818..4af8b31b 100644 --- a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSPreferenceMonitor.java +++ b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSPreferenceMonitor.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.platform.macos; diff --git a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSThemePreferenceProvider.java b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSThemePreferenceProvider.java index 9e426998..de651701 100644 --- a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSThemePreferenceProvider.java +++ b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSThemePreferenceProvider.java @@ -20,14 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.platform.macos; -import com.github.weisj.darklaf.theme.info.*; - import java.awt.*; import java.util.function.Consumer; +import com.github.weisj.darklaf.theme.info.*; + public class MacOSThemePreferenceProvider implements ThemePreferenceProvider { private final PreferredThemeStyle fallbackStyle = new PreferredThemeStyle(ContrastRule.STANDARD, diff --git a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/theme/MacOSColors.java b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/theme/MacOSColors.java index fa6005e2..c82bbcd6 100644 --- a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/theme/MacOSColors.java +++ b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/theme/MacOSColors.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.platform.macos.theme; diff --git a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/DecorationInformation.java b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/DecorationInformation.java index fe7fdd0f..b3e2573a 100644 --- a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/DecorationInformation.java +++ b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/DecorationInformation.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.platform.macos.ui; diff --git a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSDecorationsUtil.java b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSDecorationsUtil.java index c78806cd..81cb9ae4 100644 --- a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSDecorationsUtil.java +++ b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSDecorationsUtil.java @@ -20,14 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.platform.macos.ui; -import com.github.weisj.darklaf.platform.macos.JNIDecorationsMacOS; -import com.github.weisj.darklaf.util.SystemInfo; +import java.awt.*; import javax.swing.*; -import java.awt.*; + +import com.github.weisj.darklaf.platform.macos.JNIDecorationsMacOS; +import com.github.weisj.darklaf.util.SystemInfo; public class MacOSDecorationsUtil { diff --git a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSTitlePane.java b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSTitlePane.java index fd3b0521..b1b7ddea 100644 --- a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSTitlePane.java +++ b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSTitlePane.java @@ -20,14 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.platform.macos.ui; -import com.github.weisj.darklaf.platform.decorations.CustomTitlePane; -import com.github.weisj.darklaf.platform.macos.JNIDecorationsMacOS; -import com.github.weisj.darklaf.util.PropertyKey; - -import javax.swing.*; import java.awt.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; @@ -35,6 +31,12 @@ import java.awt.event.WindowListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import javax.swing.*; + +import com.github.weisj.darklaf.platform.decorations.CustomTitlePane; +import com.github.weisj.darklaf.platform.macos.JNIDecorationsMacOS; +import com.github.weisj.darklaf.util.PropertyKey; + public class MacOSTitlePane extends CustomTitlePane { private final JRootPane rootPane; @@ -58,21 +60,21 @@ public class MacOSTitlePane extends CustomTitlePane { protected void determineColors() { switch (getWindowDecorationStyle()) { - case JRootPane.ERROR_DIALOG: + case JRootPane.ERROR_DIALOG : activeBackground = UIManager.getColor("MacOS.OptionPane.errorDialog.titlePane.background"); activeForeground = UIManager.getColor("MacOS.OptionPane.errorDialog.titlePane.foreground"); break; - case JRootPane.QUESTION_DIALOG: - case JRootPane.COLOR_CHOOSER_DIALOG: - case JRootPane.FILE_CHOOSER_DIALOG: + case JRootPane.QUESTION_DIALOG : + case JRootPane.COLOR_CHOOSER_DIALOG : + case JRootPane.FILE_CHOOSER_DIALOG : activeBackground = UIManager.getColor("MacOS.OptionPane.questionDialog.titlePane.background"); activeForeground = UIManager.getColor("MacOS.OptionPane.questionDialog.titlePane.foreground"); break; - case JRootPane.WARNING_DIALOG: + case JRootPane.WARNING_DIALOG : activeBackground = UIManager.getColor("MacOS.OptionPane.warningDialog.titlePane.background"); activeForeground = UIManager.getColor("MacOS.OptionPane.warningDialog.titlePane.foreground"); break; - default: //JRootPane.Frame + default : // JRootPane.Frame activeBackground = UIManager.getColor("MacOS.TitlePane.background"); activeForeground = UIManager.getColor("MacOS.TitlePane.foreground"); break; @@ -135,7 +137,6 @@ public class MacOSTitlePane extends CustomTitlePane { return ""; } - @Override public void uninstall() { if (titleLabel != null) { diff --git a/macos/src/main/resources/com/github/weisj/darklaf/platform/macos/macos_decorations.properties b/macos/src/main/resources/com/github/weisj/darklaf/platform/macos/macos_decorations.properties index 8ee75040..0109e616 100644 --- a/macos/src/main/resources/com/github/weisj/darklaf/platform/macos/macos_decorations.properties +++ b/macos/src/main/resources/com/github/weisj/darklaf/platform/macos/macos_decorations.properties @@ -21,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# MacOS.TitlePane.borderColor = %borderSecondary MacOS.TitlePane.background = %background MacOS.TitlePane.foreground = %textForegroundSecondary diff --git a/native-utils/src/main/java/com/github/weisj/darklaf/platform/NativeUtil.java b/native-utils/src/main/java/com/github/weisj/darklaf/platform/NativeUtil.java index b8d41738..9d69bed4 100644 --- a/native-utils/src/main/java/com/github/weisj/darklaf/platform/NativeUtil.java +++ b/native-utils/src/main/java/com/github/weisj/darklaf/platform/NativeUtil.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2012 Adam Heinrich + * Copyright (c) 2020 Jannis Weis * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.platform; @@ -33,7 +34,8 @@ import java.nio.file.*; * A simple library class which helps with loading dynamic libraries stored in the JAR archive. These libraries usually * contain implementation of some methods in native code (using JNI - Java Native Interface). * - * @see http://adamheinrich.com/blog/2012/how-to-load-native-jni-library-from-jar + * @see http://adamheinrich.com/blog/2012/how-to-load-native-jni-library-from-jar * @see https://github.com/adamheinrich/native-utils */ public class NativeUtil { @@ -48,9 +50,7 @@ public class NativeUtil { */ private static File temporaryDir; - - private NativeUtil() { - } + private NativeUtil() {} /** * Loads library from current JAR archive @@ -58,7 +58,8 @@ public class NativeUtil { * The file from JAR is copied into system temporary directory and then loaded. The temporary file is deleted after * exiting. Method uses String as filename because the pathname is "abstract", not system-dependent. * - * @param path The path of file inside JAR as absolute path (beginning with '/'), e.g. /package/File.ext + * @param path The path of file inside JAR as absolute path (beginning with '/'), e.g. + * /package/File.ext * @throws IOException If temporary file creation or read/write operation fails * @throws IllegalArgumentException If source file (param path) does not exist * @throws IllegalArgumentException If the path is not absolute or if the filename is shorter than three characters @@ -66,7 +67,6 @@ public class NativeUtil { * java.lang.String)}). * @throws FileNotFoundException If the file could not be found inside the JAR. */ - public static void loadLibraryFromJar(final String path) throws IOException { if (null == path || !path.startsWith("/")) { @@ -113,7 +113,6 @@ public class NativeUtil { } } - private static File createTempDirectory(final String prefix) throws IOException { String tempDir = System.getProperty("java.io.tmpdir"); File generatedDir = new File(tempDir, prefix + System.nanoTime()); @@ -131,8 +130,8 @@ public class NativeUtil { .supportedFileAttributeViews() .contains("posix"); } catch (FileSystemNotFoundException - | ProviderNotFoundException - | SecurityException e) { + | ProviderNotFoundException + | SecurityException e) { return false; } } diff --git a/platform-base/src/main/java/com/github/weisj/darklaf/platform/decorations/CustomTitlePane.java b/platform-base/src/main/java/com/github/weisj/darklaf/platform/decorations/CustomTitlePane.java index 4d849584..3d786af6 100644 --- a/platform-base/src/main/java/com/github/weisj/darklaf/platform/decorations/CustomTitlePane.java +++ b/platform-base/src/main/java/com/github/weisj/darklaf/platform/decorations/CustomTitlePane.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.platform.decorations; -import javax.swing.*; import java.awt.*; +import javax.swing.*; + public abstract class CustomTitlePane extends JComponent { protected int decorationStyle; diff --git a/platform-base/src/main/java/com/github/weisj/darklaf/platform/decorations/DecorationsProvider.java b/platform-base/src/main/java/com/github/weisj/darklaf/platform/decorations/DecorationsProvider.java index 18f36957..82e4db91 100644 --- a/platform-base/src/main/java/com/github/weisj/darklaf/platform/decorations/DecorationsProvider.java +++ b/platform-base/src/main/java/com/github/weisj/darklaf/platform/decorations/DecorationsProvider.java @@ -20,23 +20,25 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.platform.decorations; -import javax.swing.*; import java.awt.*; import java.util.Properties; +import javax.swing.*; + public interface DecorationsProvider { /** * Create the custom title pane. * - * @param rootPane The root pane to create the title pane for. - * @param decorationStyle The style of the decorations. - * @param window The target window. - * @return the custom title pane. - * @see JRootPane#getWindowDecorationStyle() + * @param rootPane The root pane to create the title pane for. + * @param decorationStyle The style of the decorations. + * @param window The target window. + * @return the custom title pane. + * @see JRootPane#getWindowDecorationStyle() */ CustomTitlePane createTitlePane(final JRootPane rootPane, final int decorationStyle, final Window window); @@ -53,7 +55,7 @@ public interface DecorationsProvider { void initialize(); /** - * Load the necessary properties into the defaults. + * Load the necessary properties into the defaults. * * @param properties the properties to load the values into. * @param currentDefaults the current ui defaults. @@ -63,12 +65,10 @@ public interface DecorationsProvider { /** * Initialize the window of a popup menu. */ - default void installPopupMenu(final Window window) { - } + default void installPopupMenu(final Window window) {} /** * Uninstall the window of a popup menu. */ - default void uninstallPopupWindow(final Window window) { - } + default void uninstallPopupWindow(final Window window) {} } diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/PropertyLoader.java b/property-loader/src/main/java/com/github/weisj/darklaf/PropertyLoader.java index f0d8912f..90aae35e 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/PropertyLoader.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/PropertyLoader.java @@ -20,35 +20,37 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf; -import com.github.weisj.darklaf.icons.DarkUIAwareIcon; -import com.github.weisj.darklaf.icons.EmptyIcon; -import com.github.weisj.darklaf.icons.IconLoader; -import com.github.weisj.darklaf.icons.StateIcon; -import com.github.weisj.darklaf.util.ColorUtil; -import com.github.weisj.darklaf.util.Pair; -import com.github.weisj.darklaf.util.PropertyValue; - -import javax.swing.*; -import javax.swing.plaf.ColorUIResource; -import javax.swing.plaf.DimensionUIResource; -import javax.swing.plaf.FontUIResource; -import javax.swing.plaf.InsetsUIResource; import java.awt.*; import java.awt.font.TextAttribute; import java.io.IOException; import java.io.InputStream; import java.text.AttributedCharacterIterator; -import java.util.List; import java.util.*; +import java.util.List; import java.util.function.Function; import java.util.function.Predicate; import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collectors; +import javax.swing.*; +import javax.swing.plaf.ColorUIResource; +import javax.swing.plaf.DimensionUIResource; +import javax.swing.plaf.FontUIResource; +import javax.swing.plaf.InsetsUIResource; + +import com.github.weisj.darklaf.icons.DarkUIAwareIcon; +import com.github.weisj.darklaf.icons.EmptyIcon; +import com.github.weisj.darklaf.icons.IconLoader; +import com.github.weisj.darklaf.icons.StateIcon; +import com.github.weisj.darklaf.util.ColorUtil; +import com.github.weisj.darklaf.util.Pair; +import com.github.weisj.darklaf.util.PropertyValue; + /** * @author Konstantin Bulenkov * @author Jannis Weis @@ -80,15 +82,13 @@ public final class PropertyLoader { private static boolean addReferenceInfo; - private static final Map attributes = Collections.singletonMap( - TextAttribute.KERNING, - TextAttribute.KERNING_ON); + private static final Map attributes = Collections.singletonMap(TextAttribute.KERNING, + TextAttribute.KERNING_ON); public static void setAddReferenceInfo(final boolean addReferenceInfo) { PropertyLoader.addReferenceInfo = addReferenceInfo; } - public static Properties loadProperties(final Class clazz, final String name, final String path) { final Properties properties = new Properties(); String p = path + name + ".properties"; @@ -167,7 +167,6 @@ public final class PropertyLoader { return key.startsWith(String.valueOf(REFERENCE_PREFIX)) ? key.substring(1) : key; } - public static Object parseValue(final String propertyKey, final String value, final Map accumulator, final UIDefaults currentDefaults, final IconLoader iconLoader) { @@ -198,16 +197,14 @@ public final class PropertyLoader { } else if (key.endsWith("Size") || key.endsWith(".size")) { returnVal = parseSize(value); } else if (value.startsWith(String.valueOf(LIST_START))) { - returnVal = parseList( - (v, acc, defs, iconL) -> PropertyLoader.parseValue("", v, acc, defs, iconL), - value, accumulator, currentDefaults, iconLoader); + returnVal = parseList((v, acc, defs, iconL) -> PropertyLoader.parseValue("", v, acc, defs, iconL), + value, accumulator, currentDefaults, iconLoader); } else if (value.startsWith(String.valueOf(INT_LIST_START))) { returnVal = parseList((SimpleValueMapper) Integer::parseInt, value, accumulator, currentDefaults, iconLoader, INT_LIST_START, INT_LIST_END, SEPARATOR); } else if (value.contains(String.valueOf(PAIR_SEPARATOR))) { - returnVal = parsePair( - (v, acc, defs, iconL) -> PropertyLoader.parseValue("", v, acc, defs, iconL), - value, accumulator, currentDefaults, iconLoader); + returnVal = parsePair((v, acc, defs, iconL) -> PropertyLoader.parseValue("", v, acc, defs, iconL), + value, accumulator, currentDefaults, iconLoader); } else if (PropertyValue.NULL.equalsIgnoreCase(value)) { returnVal = null; } else if (value.startsWith(String.valueOf(REFERENCE_PREFIX))) { @@ -217,8 +214,8 @@ public final class PropertyLoader { final Color color = ColorUtil.fromHex(value, null); final Integer invVal = getInteger(value); final Boolean boolVal = PropertyValue.TRUE.equalsIgnoreCase(value) - ? Boolean.TRUE - : PropertyValue.FALSE.equalsIgnoreCase(value) ? Boolean.FALSE : null; + ? Boolean.TRUE + : PropertyValue.FALSE.equalsIgnoreCase(value) ? Boolean.FALSE : null; if (color != null && (value.length() == 6 || value.length() == 8)) { return new ColorUIResource(color); } else if (invVal != null) { @@ -264,7 +261,6 @@ public final class PropertyLoader { return returnVal; } - private static Object parseInsets(final String value, final Map accumulator, final UIDefaults currentDefaults, final IconLoader iconLoader) { @@ -446,7 +442,6 @@ public final class PropertyLoader { } } - private static Integer getInteger(final String value) { try { return Integer.parseInt(value); @@ -463,17 +458,14 @@ public final class PropertyLoader { } } - private static Object parseObject(final String value) { try { return Class.forName(value).getDeclaredConstructor().newInstance(); - } catch (final Exception ignored) { - } + } catch (final Exception ignored) {} return null; } - private static final class LoadError { - } + private static final class LoadError {} private interface ParseFunction { diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/icons/AwareIconStyle.java b/property-loader/src/main/java/com/github/weisj/darklaf/icons/AwareIconStyle.java index 60c83e54..453f83ed 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/icons/AwareIconStyle.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/icons/AwareIconStyle.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.icons; diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/icons/CustomThemedIcon.java b/property-loader/src/main/java/com/github/weisj/darklaf/icons/CustomThemedIcon.java index d96b8b44..c0c6b653 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/icons/CustomThemedIcon.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/icons/CustomThemedIcon.java @@ -20,16 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.icons; -import com.kitfox.svg.SVGUniverse; -import com.kitfox.svg.app.beans.SVGIcon; - -import javax.swing.*; import java.net.URI; import java.util.Map; +import javax.swing.*; + +import com.kitfox.svg.SVGUniverse; +import com.kitfox.svg.app.beans.SVGIcon; + public class CustomThemedIcon extends ThemedSVGIcon { private final UIDefaults defaults; diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/icons/DarkSVGIcon.java b/property-loader/src/main/java/com/github/weisj/darklaf/icons/DarkSVGIcon.java index 9ecc7113..3f291c51 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/icons/DarkSVGIcon.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/icons/DarkSVGIcon.java @@ -20,23 +20,25 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.icons; -import com.kitfox.svg.app.beans.SVGIcon; - -import javax.swing.*; import java.awt.*; import java.io.Serializable; import java.net.URI; import java.util.concurrent.atomic.AtomicBoolean; import java.util.logging.Logger; +import javax.swing.*; + +import com.kitfox.svg.app.beans.SVGIcon; + /** * Icon from SVG image. * * @author Jannis Weis - * @since 2019 + * @since 2019 */ public class DarkSVGIcon implements Icon, Serializable { @@ -62,7 +64,6 @@ public class DarkSVGIcon implements Icon, Serializable { loaded = new AtomicBoolean(false); } - private DarkSVGIcon(final int width, final int height, final DarkSVGIcon icon) { this.size = new Dimension(width, height); this.icon = icon.icon; diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/icons/DarkUIAwareIcon.java b/property-loader/src/main/java/com/github/weisj/darklaf/icons/DarkUIAwareIcon.java index ad6c2ea2..6972d423 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/icons/DarkUIAwareIcon.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/icons/DarkUIAwareIcon.java @@ -20,20 +20,22 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.icons; -import javax.swing.*; -import javax.swing.plaf.UIResource; import java.awt.*; import java.io.Serializable; +import javax.swing.*; +import javax.swing.plaf.UIResource; + /** * Icon that is aware of the current ui theme and adjusts the icon accordingly. Icons are loaded lazily at their point * of usage. * * @author Jannis Weis - * @since 2019 + * @since 2019 */ public class DarkUIAwareIcon implements UIAwareIcon, UIResource, Serializable { @@ -47,7 +49,6 @@ public class DarkUIAwareIcon implements UIAwareIcon, UIResource, Serializable { private transient Icon icon; private AwareIconStyle currentStyle; - /** * Create new ui aware icon. * @@ -57,7 +58,6 @@ public class DarkUIAwareIcon implements UIAwareIcon, UIResource, Serializable { * @param h height of icon. * @param parentClass the class to resolve the path while lazy loading. */ - public DarkUIAwareIcon(final String darkKey, final String lightKey, final int w, final int h, final Class parentClass) { this.darkKey = darkKey; @@ -68,7 +68,6 @@ public class DarkUIAwareIcon implements UIAwareIcon, UIResource, Serializable { this.dual = new DarkUIAwareIcon(this); } - private DarkUIAwareIcon(final DarkUIAwareIcon dual) { this.darkKey = dual.lightKey; this.lightKey = dual.darkKey; @@ -94,7 +93,6 @@ public class DarkUIAwareIcon implements UIAwareIcon, UIResource, Serializable { } } - private boolean isLoaded() { return loaded && (currentStyle == IconLoader.getAwareStyle()); } diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/icons/EmptyIcon.java b/property-loader/src/main/java/com/github/weisj/darklaf/icons/EmptyIcon.java index e02551a5..25e7babb 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/icons/EmptyIcon.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/icons/EmptyIcon.java @@ -20,15 +20,17 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.icons; -import javax.swing.*; -import javax.swing.plaf.UIResource; import java.awt.*; import java.util.HashMap; import java.util.Map; +import javax.swing.*; +import javax.swing.plaf.UIResource; + /** * @author Konstantin Bulenkov * @author Jannis Weis @@ -38,23 +40,19 @@ public final class EmptyIcon implements Icon, UIResource { private final int width; private final int height; - private EmptyIcon(final int width, final int height) { this.width = width; this.height = height; } - public static Icon create(final Icon base) { return create(base.getIconWidth(), base.getIconHeight()); } - public static Icon create(final int width, final int height) { return width == height ? create(width) : new EmptyIcon(width, height); } - public static Icon create(final int size) { Icon icon = cache.get(size); if (icon == null && size < 129) { @@ -63,26 +61,21 @@ public final class EmptyIcon implements Icon, UIResource { return icon == null ? new EmptyIcon(size, size) : icon; } - public void paintIcon(final Component component, final Graphics g, final int i, final int j) { - } - + public void paintIcon(final Component component, final Graphics g, final int i, final int j) {} public int getIconWidth() { return this.width; } - public int getIconHeight() { return this.height; } - public int hashCode() { int sum = this.width + this.height; return sum * (sum + 1) / 2 + this.width; } - public boolean equals(final Object o) { if (this == o) { return true; diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/icons/IconColorMapper.java b/property-loader/src/main/java/com/github/weisj/darklaf/icons/IconColorMapper.java index 1e23c60a..ff9f0184 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/icons/IconColorMapper.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/icons/IconColorMapper.java @@ -20,9 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.icons; +import java.awt.*; +import java.util.Arrays; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.swing.*; + import com.github.weisj.darklaf.util.ColorUtil; import com.github.weisj.darklaf.util.Pair; import com.kitfox.svg.*; @@ -30,13 +39,6 @@ import com.kitfox.svg.animation.AnimationElement; import com.kitfox.svg.app.beans.SVGIcon; import com.kitfox.svg.xml.StyleAttribute; -import javax.swing.*; -import java.awt.*; -import java.util.Arrays; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; - /** * @author Jannis Weis */ @@ -127,7 +129,7 @@ public final class IconColorMapper { } private static Pair createColor(final Color c, final String name, final float opacity) - throws SVGElementException { + throws SVGElementException { LinearGradient grad = new LinearGradient(); grad.addAttribute("id", AnimationElement.AT_XML, name); return new Pair<>(grad, () -> { diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/icons/IconLoader.java b/property-loader/src/main/java/com/github/weisj/darklaf/icons/IconLoader.java index 4e0b175a..471ee77a 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/icons/IconLoader.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/icons/IconLoader.java @@ -20,10 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.icons; -import javax.swing.*; import java.net.URI; import java.net.URISyntaxException; import java.util.HashMap; @@ -33,6 +33,8 @@ import java.util.WeakHashMap; import java.util.logging.Level; import java.util.logging.Logger; +import javax.swing.*; + /** * @author Jannis Weis */ @@ -57,7 +59,6 @@ public final class IconLoader { iconLoaderMap.put(parentClass, this); } - public static IconLoader get() { return instance; } @@ -106,8 +107,6 @@ public final class IconLoader { /* * Helper method to create the icons. */ - - public DarkUIAwareIcon create(final String name, final int w, final int h) { return new DarkUIAwareIcon("dark/" + name, "light/" + name, w, h, parentClass); } @@ -127,19 +126,19 @@ public final class IconLoader { } else if (awareIconMap.containsKey(key)) { return awareIconMap.get(key); } else { - key.w = -1; //Enable wild card search. Find any icon that matches path. + key.w = -1; // Enable wild card search. Find any icon that matches path. if (iconMap.containsKey(key)) { Icon icon = iconMap.get(key); if (icon instanceof DarkSVGIcon) { - //If the desired icon is an DarkSVGIcon we can create a view that shares the underlying svg with - //the existing icon. + // If the desired icon is an DarkSVGIcon we can create a view that shares the underlying svg with + // the existing icon. Icon derived = ((DarkSVGIcon) icon).derive(w, h); key.w = w; iconMap.put(key, derived); return derived; } } - key.w = w; //Restore key. + key.w = w; // Restore key. if (path.endsWith(".svg")) { Icon icon = loadSVGIcon(path, w, h, themed); iconMap.put(key, icon); @@ -196,7 +195,6 @@ public final class IconLoader { int w; int h; - private IconKey(final String path, final int w, final int h) { this.path = path; this.w = w; @@ -208,7 +206,6 @@ public final class IconLoader { return Objects.hash(path, w, h); } - @Override public boolean equals(final Object o) { if (this == o) return true; @@ -217,7 +214,7 @@ public final class IconLoader { IconKey iconKey = (IconKey) o; if (iconKey.w == -1 || iconKey.h == -1) { - //Math any size. + // Math any size. return Objects.equals(path, iconKey.path); } if (w != iconKey.w) return false; @@ -225,7 +222,6 @@ public final class IconLoader { return Objects.equals(path, iconKey.path); } - @Override public String toString() { return "[path=" + path + ", w=" + w + ", h=" + h + "]"; diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/icons/LazyIcon.java b/property-loader/src/main/java/com/github/weisj/darklaf/icons/LazyIcon.java index da983272..b027bd28 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/icons/LazyIcon.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/icons/LazyIcon.java @@ -20,14 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.icons; -import javax.swing.*; -import javax.swing.plaf.UIResource; import java.awt.*; import java.util.logging.Logger; +import javax.swing.*; +import javax.swing.plaf.UIResource; + /** * @author Jannis Weis */ @@ -40,7 +42,6 @@ public abstract class LazyIcon implements Icon, UIResource { private boolean loaded; private Icon icon; - public LazyIcon(final String path, final IconLoader.IconKey key, final Class parentClass) { this.path = path; this.key = key; diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/icons/LazyImageIcon.java b/property-loader/src/main/java/com/github/weisj/darklaf/icons/LazyImageIcon.java index 5ba4a82f..2e61a76e 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/icons/LazyImageIcon.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/icons/LazyImageIcon.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.icons; diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/icons/RotatableIcon.java b/property-loader/src/main/java/com/github/weisj/darklaf/icons/RotatableIcon.java index 0d5d6ed4..7d98907b 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/icons/RotatableIcon.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/icons/RotatableIcon.java @@ -20,21 +20,22 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.icons; -import com.github.weisj.darklaf.util.Alignment; - -import javax.swing.*; import java.awt.*; import java.awt.geom.AffineTransform; +import javax.swing.*; + +import com.github.weisj.darklaf.util.Alignment; + public class RotatableIcon implements Icon { private Icon icon; private Alignment alignment; - public RotatableIcon() { this(null); } @@ -61,33 +62,32 @@ public class RotatableIcon implements Icon { } } - private double getAngle() { double angle = 0.0; switch (alignment) { - case NORTH: - case CENTER: + case NORTH : + case CENTER : angle = 0.0; break; - case SOUTH: + case SOUTH : angle = 180.0; break; - case EAST: + case EAST : angle = 90.0; break; - case WEST: + case WEST : angle = 270.0; break; - case NORTH_EAST: + case NORTH_EAST : angle = 45.0; break; - case NORTH_WEST: + case NORTH_WEST : angle = 315.0; break; - case SOUTH_EAST: + case SOUTH_EAST : angle = 135.0; break; - case SOUTH_WEST: + case SOUTH_WEST : angle = 225.0; break; } diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/icons/ScaledIcon.java b/property-loader/src/main/java/com/github/weisj/darklaf/icons/ScaledIcon.java index 74069218..add7f58c 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/icons/ScaledIcon.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/icons/ScaledIcon.java @@ -20,13 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.icons; -import com.github.weisj.darklaf.util.Scale; +import java.awt.*; import javax.swing.*; -import java.awt.*; + +import com.github.weisj.darklaf.util.Scale; public class ScaledIcon implements Icon { diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/icons/SolidColorIcon.java b/property-loader/src/main/java/com/github/weisj/darklaf/icons/SolidColorIcon.java index e7c4215f..71a3eac6 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/icons/SolidColorIcon.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/icons/SolidColorIcon.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.icons; -import javax.swing.*; import java.awt.*; +import javax.swing.*; + public class SolidColorIcon implements Icon { private final int width; private final int height; diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/icons/StateIcon.java b/property-loader/src/main/java/com/github/weisj/darklaf/icons/StateIcon.java index f78bb4c4..0150805f 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/icons/StateIcon.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/icons/StateIcon.java @@ -20,13 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.icons; -import javax.swing.*; import java.awt.*; import java.util.List; +import javax.swing.*; + /** * Icon that should be used with JCheckBox or JRadioButton. All icons should have the same size. */ @@ -81,7 +83,7 @@ public class StateIcon implements Icon { Icon icn = selected ? enabled ? hasFocus ? selectedFocusedIcon : selectedIcon : selectedDisabledIcon : enabled ? hasFocus ? focusedIcon : icon - : disabledIcon; + : disabledIcon; return icn != null ? icn : EmptyIcon.create(0); } diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/icons/ThemedSVGIcon.java b/property-loader/src/main/java/com/github/weisj/darklaf/icons/ThemedSVGIcon.java index c4e340f7..9f0d536d 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/icons/ThemedSVGIcon.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/icons/ThemedSVGIcon.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.icons; diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/icons/ToggleIcon.java b/property-loader/src/main/java/com/github/weisj/darklaf/icons/ToggleIcon.java index 73221438..203a9459 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/icons/ToggleIcon.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/icons/ToggleIcon.java @@ -20,12 +20,14 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.icons; -import javax.swing.*; import java.awt.*; +import javax.swing.*; + /** * @author Jannis Weis */ @@ -35,7 +37,6 @@ public class ToggleIcon implements Icon { private final Icon inactiveIcon; private boolean active = true; - public ToggleIcon(final Icon active, final Icon inactive) { this.activeIcon = active; this.inactiveIcon = inactive; @@ -50,7 +51,6 @@ public class ToggleIcon implements Icon { currentIcon().paintIcon(c, g, x, y); } - private Icon currentIcon() { return active ? activeIcon : inactiveIcon; } diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/icons/UIAwareIcon.java b/property-loader/src/main/java/com/github/weisj/darklaf/icons/UIAwareIcon.java index 3878f484..a28df0db 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/icons/UIAwareIcon.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/icons/UIAwareIcon.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.icons; @@ -31,6 +32,4 @@ import javax.swing.*; public interface UIAwareIcon extends Icon { UIAwareIcon getDual(); - - } diff --git a/settings.gradle.kts b/settings.gradle.kts index 0f171330..62f8882a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -3,10 +3,10 @@ pluginManagement { fun String.v() = extra["$this.version"].toString() fun PluginDependenciesSpec.idv(id: String, key: String = id) = id(id) version key.v() + idv("com.github.autostyle") idv("com.github.johnrengelman.shadow") idv("com.github.vlsi.crlf", "com.github.vlsi.vlsi-release-plugins") idv("com.github.vlsi.gradle-extensions", "com.github.vlsi.vlsi-release-plugins") - idv("com.github.vlsi.ide", "com.github.vlsi.vlsi-release-plugins") idv("com.github.vlsi.license-gather", "com.github.vlsi.vlsi-release-plugins") idv("com.github.vlsi.stage-vote-release", "com.github.vlsi.vlsi-release-plugins") } diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/DarculaTheme.java b/theme/src/main/java/com/github/weisj/darklaf/theme/DarculaTheme.java index 4596b57b..3de161e9 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/DarculaTheme.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/DarculaTheme.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.theme; diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/HighContrastDarkTheme.java b/theme/src/main/java/com/github/weisj/darklaf/theme/HighContrastDarkTheme.java index 0075b826..cb3e0ea3 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/HighContrastDarkTheme.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/HighContrastDarkTheme.java @@ -20,16 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.theme; +import java.util.Properties; + +import javax.swing.*; + import com.github.weisj.darklaf.theme.info.ColorToneRule; import com.github.weisj.darklaf.theme.info.ContrastRule; import com.github.weisj.darklaf.theme.info.PresetIconRule; -import javax.swing.*; -import java.util.Properties; - public class HighContrastDarkTheme extends Theme { @Override diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/HighContrastLightTheme.java b/theme/src/main/java/com/github/weisj/darklaf/theme/HighContrastLightTheme.java index 0ea5836e..dc19b5e7 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/HighContrastLightTheme.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/HighContrastLightTheme.java @@ -20,16 +20,18 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.theme; +import java.util.Properties; + +import javax.swing.*; + import com.github.weisj.darklaf.theme.info.ColorToneRule; import com.github.weisj.darklaf.theme.info.ContrastRule; import com.github.weisj.darklaf.theme.info.PresetIconRule; -import javax.swing.*; -import java.util.Properties; - public class HighContrastLightTheme extends Theme { @Override diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/IntelliJTheme.java b/theme/src/main/java/com/github/weisj/darklaf/theme/IntelliJTheme.java index f8da1b93..81967627 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/IntelliJTheme.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/IntelliJTheme.java @@ -20,14 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.theme; -import com.github.weisj.darklaf.theme.info.ColorToneRule; -import com.github.weisj.darklaf.theme.info.PresetIconRule; +import java.util.Properties; import javax.swing.*; -import java.util.Properties; + +import com.github.weisj.darklaf.theme.info.ColorToneRule; +import com.github.weisj.darklaf.theme.info.PresetIconRule; /** * @author Jannis Weis diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/OneDarkTheme.java b/theme/src/main/java/com/github/weisj/darklaf/theme/OneDarkTheme.java index 39fb2796..68276605 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/OneDarkTheme.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/OneDarkTheme.java @@ -20,14 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.theme; -import com.github.weisj.darklaf.theme.info.ColorToneRule; -import com.github.weisj.darklaf.theme.info.PresetIconRule; +import java.util.Properties; import javax.swing.*; -import java.util.Properties; + +import com.github.weisj.darklaf.theme.info.ColorToneRule; +import com.github.weisj.darklaf.theme.info.PresetIconRule; public class OneDarkTheme extends Theme { @Override diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/SolarizedDarkTheme.java b/theme/src/main/java/com/github/weisj/darklaf/theme/SolarizedDarkTheme.java index 9b406d3a..8b0c4171 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/SolarizedDarkTheme.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/SolarizedDarkTheme.java @@ -20,14 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.theme; -import com.github.weisj.darklaf.theme.info.ColorToneRule; -import com.github.weisj.darklaf.theme.info.PresetIconRule; +import java.util.Properties; import javax.swing.*; -import java.util.Properties; + +import com.github.weisj.darklaf.theme.info.ColorToneRule; +import com.github.weisj.darklaf.theme.info.PresetIconRule; public class SolarizedDarkTheme extends Theme { diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/SolarizedLightTheme.java b/theme/src/main/java/com/github/weisj/darklaf/theme/SolarizedLightTheme.java index 36e27477..6ed71072 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/SolarizedLightTheme.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/SolarizedLightTheme.java @@ -20,14 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.theme; -import com.github.weisj.darklaf.theme.info.ColorToneRule; -import com.github.weisj.darklaf.theme.info.PresetIconRule; +import java.util.Properties; import javax.swing.*; -import java.util.Properties; + +import com.github.weisj.darklaf.theme.info.ColorToneRule; +import com.github.weisj.darklaf.theme.info.PresetIconRule; public class SolarizedLightTheme extends Theme { diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/Theme.java b/theme/src/main/java/com/github/weisj/darklaf/theme/Theme.java index 3ec4061b..d34134c1 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/Theme.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/Theme.java @@ -20,14 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.theme; -import com.github.weisj.darklaf.PropertyLoader; -import com.github.weisj.darklaf.theme.info.*; - -import javax.swing.*; -import javax.swing.text.html.StyleSheet; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; @@ -38,6 +34,12 @@ import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; +import javax.swing.*; +import javax.swing.text.html.StyleSheet; + +import com.github.weisj.darklaf.PropertyLoader; +import com.github.weisj.darklaf.theme.info.*; + /** * @author Jannis Weis */ @@ -59,9 +61,9 @@ public abstract class Theme implements Comparable, Comparator { /** * Create a derived theme with the given {@link FontSizeRule} and {@link AccentColorRule}. * - * @param fontSizeRule the font size rule. - * @param accentColorRule the accent color rule. - * @return the derived theme. + * @param fontSizeRule the font size rule. + * @param accentColorRule the accent color rule. + * @return the derived theme. */ public Theme derive(final FontSizeRule fontSizeRule, final AccentColorRule accentColorRule) { return new ThemeDelegate(this, fontSizeRule, accentColorRule); @@ -81,8 +83,8 @@ public abstract class Theme implements Comparable, Comparator { /** * Returns whether the theme is a dark theme. This is used to determine the default mode for [aware] icons. * - * @param theme the theme. - * @return true if dark. + * @param theme the theme. + * @return true if dark. */ public static boolean isDark(final Theme theme) { if (theme == null) return false; @@ -92,8 +94,8 @@ public abstract class Theme implements Comparable, Comparator { /** * Returns whether the theme is a high contrast theme. * - * @param theme the theme. - * @return true if the theme is a high contrast theme. + * @param theme the theme. + * @return true if the theme is a high contrast theme. */ public static boolean isHighContrast(final Theme theme) { if (theme == null) return false; @@ -124,8 +126,7 @@ public abstract class Theme implements Comparable, Comparator { * @param properties the properties to load the values into. * @param currentDefaults the current ui defaults. */ - public void customizeGlobals(final Properties properties, final UIDefaults currentDefaults) { - } + public void customizeGlobals(final Properties properties, final UIDefaults currentDefaults) {} /** * Customize the icon defaults. @@ -137,8 +138,7 @@ public abstract class Theme implements Comparable, Comparator { * @param properties the properties to load the value into. * @param currentDefaults the current ui defaults. */ - public void customizeIconTheme(final Properties properties, final UIDefaults currentDefaults) { - } + public void customizeIconTheme(final Properties properties, final UIDefaults currentDefaults) {} /** * Load the general properties file for the icon themes. @@ -154,14 +154,14 @@ public abstract class Theme implements Comparable, Comparator { PresetIconRule iconTheme = getPresetIconRule(); Properties props; switch (iconTheme) { - case DARK: + case DARK : props = PropertyLoader.loadProperties(Theme.class, "dark_icons", "icon_presets/"); break; - case LIGHT: + case LIGHT : props = PropertyLoader.loadProperties(Theme.class, "light_icons", "icon_presets/"); break; - case NONE: - default: + case NONE : + default : props = loadPropertyFile("icons"); } PropertyLoader.putProperties(props, properties, currentDefaults); @@ -176,8 +176,7 @@ public abstract class Theme implements Comparable, Comparator { * @param properties the properties to load the values into. * @param currentDefaults the current ui defaults. */ - public void customizePlatformProperties(final Properties properties, final UIDefaults currentDefaults) { - } + public void customizePlatformProperties(final Properties properties, final UIDefaults currentDefaults) {} /** * Customize the ui defaults. @@ -188,8 +187,7 @@ public abstract class Theme implements Comparable, Comparator { * @param properties the properties to load the values into. * @param currentDefaults the current ui defaults. */ - public void customizeUIProperties(final Properties properties, final UIDefaults currentDefaults) { - } + public void customizeUIProperties(final Properties properties, final UIDefaults currentDefaults) {} /** * The preset icon theme. @@ -219,8 +217,8 @@ public abstract class Theme implements Comparable, Comparator { *

    * Note: When overwriting a theme you should use {@link #loadWithClass(String, Class)} instead. * - * @param name the properties file to load. - * @return the properties. + * @param name the properties file to load. + * @return the properties. */ protected final Properties load(final String name) { return loadWithClass(name, getLoaderClass()); @@ -229,9 +227,9 @@ public abstract class Theme implements Comparable, Comparator { /** * Load a .properties file. * - * @param name the properties file to load. - * @param loaderClass the class to resolve the file location from. - * @return the properties. + * @param name the properties file to load. + * @param loaderClass the class to resolve the file location from. + * @return the properties. */ protected final Properties loadWithClass(final String name, final Class loaderClass) { final Properties properties = new Properties(); @@ -243,7 +241,6 @@ public abstract class Theme implements Comparable, Comparator { return properties; } - /** * Load the css style sheet used for html display in text components with a {@link * javax.swing.text.html.HTMLEditorKit}. @@ -258,8 +255,8 @@ public abstract class Theme implements Comparable, Comparator { * Load the css style sheet used for html display in text components with a {@link * javax.swing.text.html.HTMLEditorKit}. * - * @param loaderClass the class to resolve the location of the style sheet. - * @return the {@link StyleSheet}. + * @param loaderClass the class to resolve the location of the style sheet. + * @return the {@link StyleSheet}. */ public final StyleSheet loadStyleSheetWithClass(final Class loaderClass) { StyleSheet styleSheet = new StyleSheet(); @@ -301,7 +298,6 @@ public abstract class Theme implements Comparable, Comparator { */ public abstract String getName(); - /** * The class used to determine the runtime location of resources. It is advised to explicitly return the class * instead of using {@link #getClass()} to protect against extending the theme. @@ -313,8 +309,8 @@ public abstract class Theme implements Comparable, Comparator { /** * Get the path for the file [prefix]_[name].properties in the themes resource location. * - * @param name the of the file. - * @return the path relative to the location of {@link #getLoaderClass()}. + * @param name the of the file. + * @return the path relative to the location of {@link #getLoaderClass()}. */ protected String getPropertyFilePath(final String name) { return getResourcePath() + getPrefix() + "_" + name + ".properties"; @@ -325,8 +321,8 @@ public abstract class Theme implements Comparable, Comparator { * theme adds the theme property prefix and appends ".properties" e.g. "test" -> * [resource_location]/[prefix_of_theme]_test.properties. * - * @param name the properties name. - * @return the properties. + * @param name the properties name. + * @return the properties. */ public final Properties loadPropertyFile(final String name) { return loadPropertyFile(name, false); @@ -337,10 +333,10 @@ public abstract class Theme implements Comparable, Comparator { * theme adds the theme property prefix and appends ".properties" e.g. "test" -> * [resource_location]/[prefix_of_theme]_test.properties. * - * @param name the properties name. - * @param silent if true no warnings are issues if the file is not present. Instead, an empty property instance is - * returned. - * @return the properties. + * @param name the properties name. + * @param silent if true no warnings are issues if the file is not present. Instead, an empty property instance is + * returned. + * @return the properties. */ public final Properties loadPropertyFile(final String name, final boolean silent) { Level level = LOGGER.getLevel(); diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/ThemeDelegate.java b/theme/src/main/java/com/github/weisj/darklaf/theme/ThemeDelegate.java index 8d948254..098c63c7 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/ThemeDelegate.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/ThemeDelegate.java @@ -20,13 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.theme; -import com.github.weisj.darklaf.theme.info.*; +import java.util.Properties; import javax.swing.*; -import java.util.Properties; + +import com.github.weisj.darklaf.theme.info.*; public class ThemeDelegate extends Theme { diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/UnsupportedThemeException.java b/theme/src/main/java/com/github/weisj/darklaf/theme/UnsupportedThemeException.java index 4562def3..a8758a84 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/UnsupportedThemeException.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/UnsupportedThemeException.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.theme; diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/event/ThemePreferenceChangeEvent.java b/theme/src/main/java/com/github/weisj/darklaf/theme/event/ThemePreferenceChangeEvent.java index 5452b73d..68d06504 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/event/ThemePreferenceChangeEvent.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/event/ThemePreferenceChangeEvent.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.theme.event; diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/event/ThemePreferenceChangeSupport.java b/theme/src/main/java/com/github/weisj/darklaf/theme/event/ThemePreferenceChangeSupport.java index bc3e04a0..16529d61 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/event/ThemePreferenceChangeSupport.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/event/ThemePreferenceChangeSupport.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.theme.event; diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/event/ThemePreferenceListener.java b/theme/src/main/java/com/github/weisj/darklaf/theme/event/ThemePreferenceListener.java index a9cbf396..f7296227 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/event/ThemePreferenceListener.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/event/ThemePreferenceListener.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.theme.event; diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/info/AccentColorRule.java b/theme/src/main/java/com/github/weisj/darklaf/theme/info/AccentColorRule.java index fe26cf7c..ec1fa5d0 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/info/AccentColorRule.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/info/AccentColorRule.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.theme.info; diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/info/ColorToneRule.java b/theme/src/main/java/com/github/weisj/darklaf/theme/info/ColorToneRule.java index f90f38ee..67175089 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/info/ColorToneRule.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/info/ColorToneRule.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.theme.info; diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/info/ContrastRule.java b/theme/src/main/java/com/github/weisj/darklaf/theme/info/ContrastRule.java index 53dc2fd3..d5a107a7 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/info/ContrastRule.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/info/ContrastRule.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.theme.info; diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/info/DefaultThemeProvider.java b/theme/src/main/java/com/github/weisj/darklaf/theme/info/DefaultThemeProvider.java index 7bc8f3ca..29bf8dde 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/info/DefaultThemeProvider.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/info/DefaultThemeProvider.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.theme.info; @@ -78,7 +79,6 @@ public class DefaultThemeProvider implements ThemeProvider { this.darkHighContrastTheme = darkHighContrastTheme; } - @Override public Theme getTheme(final PreferredThemeStyle themeStyle) { if (themeStyle == null) return lightTheme; diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/info/FontSizePreset.java b/theme/src/main/java/com/github/weisj/darklaf/theme/info/FontSizePreset.java index d4dd06f6..36b7b51d 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/info/FontSizePreset.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/info/FontSizePreset.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.theme.info; diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/info/FontSizeRule.java b/theme/src/main/java/com/github/weisj/darklaf/theme/info/FontSizeRule.java index f641fe87..f456f98f 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/info/FontSizeRule.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/info/FontSizeRule.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.theme.info; @@ -84,11 +85,11 @@ public class FontSizeRule { builder.append(", preset=").append(preset); } else { switch (type) { - case RELATIVE_ADJUSTMENT: + case RELATIVE_ADJUSTMENT : builder.append(", relativeAdjustment=").append(relativeAdjustment); break; - case NO_ADJUSTMENT: - default: + case NO_ADJUSTMENT : + default : break; } } @@ -117,5 +118,4 @@ public class FontSizeRule { abstract public float adjustSize(final float size, final float relative); } - } diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/info/PreferredThemeStyle.java b/theme/src/main/java/com/github/weisj/darklaf/theme/info/PreferredThemeStyle.java index fd24c139..99a5ad00 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/info/PreferredThemeStyle.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/info/PreferredThemeStyle.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.theme.info; diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/info/PresetIconRule.java b/theme/src/main/java/com/github/weisj/darklaf/theme/info/PresetIconRule.java index 99ffcb8d..c601bbf2 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/info/PresetIconRule.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/info/PresetIconRule.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.theme.info; diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/info/ThemePreferenceProvider.java b/theme/src/main/java/com/github/weisj/darklaf/theme/info/ThemePreferenceProvider.java index 9bb0957b..feea7eaa 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/info/ThemePreferenceProvider.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/info/ThemePreferenceProvider.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.theme.info; @@ -57,7 +58,7 @@ public interface ThemePreferenceProvider { * Returns whether changes in theme preference are signaled to the callback. * * @return true if changes are reported. - * @see #setCallback(Consumer) + * @see #setCallback(Consumer) */ boolean isReporting(); diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/info/ThemeProvider.java b/theme/src/main/java/com/github/weisj/darklaf/theme/info/ThemeProvider.java index 5789b2a4..6d3805f1 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/info/ThemeProvider.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/info/ThemeProvider.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.theme.info; diff --git a/theme/src/main/resources/com/github/weisj/darklaf/theme/darcula/darcula_accents.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/darcula/darcula_accents.properties index 75cb994c..207c1da6 100644 --- a/theme/src/main/resources/com/github/weisj/darklaf/theme/darcula/darcula_accents.properties +++ b/theme/src/main/resources/com/github/weisj/darklaf/theme/darcula/darcula_accents.properties @@ -21,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# mainAccent.propertyList = {widgetFillDefault:[100,100,100];\ hoverHighlightDefault:[100,80,80];\ clickHighlightDefault:[100,90,85];\ @@ -38,4 +39,3 @@ mainAccent.propertyList = {widgetFillDefault:[100,100,100];\ controlFillHighlightDisabled:[100,77,50];\ hyperlink:[100,100,100]} selectionAccent.propertyList = {textSelectionBackground} - diff --git a/theme/src/main/resources/com/github/weisj/darklaf/theme/darcula/darcula_defaults.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/darcula/darcula_defaults.properties index f0c08bd8..2b9e9018 100644 --- a/theme/src/main/resources/com/github/weisj/darklaf/theme/darcula/darcula_defaults.properties +++ b/theme/src/main/resources/com/github/weisj/darklaf/theme/darcula/darcula_defaults.properties @@ -1,26 +1,27 @@ -#MIT License # -#Copyright (c) 2020 Jannis Weis +# MIT License # -#Permission is hereby granted, free of charge, to any person obtaining a copy -#of this software and associated documentation files (the "Software"), to deal -#in the Software without restriction, including without limitation the rights -#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -#copies of the Software, and to permit persons to whom the Software is -#furnished to do so, subject to the following conditions: +# Copyright (c) 2020 Jannis Weis # -#The above copyright notice and this permission notice shall be included in all -#copies or substantial portions of the Software. +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. # -#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -#SOFTWARE. # -# suppress inspection "UnusedProperty" for whole file Theme.dark = true Theme.highContrast = false diff --git a/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_defaults.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_defaults.properties index 7a6a5e9a..f1ce3603 100644 --- a/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_defaults.properties +++ b/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_defaults.properties @@ -1,26 +1,27 @@ -#MIT License # -#Copyright (c) 2020 Jannis Weis +# MIT License # -#Permission is hereby granted, free of charge, to any person obtaining a copy -#of this software and associated documentation files (the "Software"), to deal -#in the Software without restriction, including without limitation the rights -#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -#copies of the Software, and to permit persons to whom the Software is -#furnished to do so, subject to the following conditions: +# Copyright (c) 2020 Jannis Weis # -#The above copyright notice and this permission notice shall be included in all -#copies or substantial portions of the Software. +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. # -#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -#SOFTWARE. # -# suppress inspection "UnusedProperty" for whole file Theme.dark = true Theme.highContrast = true diff --git a/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_icons.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_icons.properties index e0fb5cbe..d7ddfe00 100644 --- a/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_icons.properties +++ b/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_icons.properties @@ -21,7 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # -# suppress inspection "UnusedProperty" for whole file +# %menuIconOpacity = 100 %fileIconOpacity = 100 diff --git a/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_platform.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_platform.properties index 2a200d7c..345330e7 100644 --- a/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_platform.properties +++ b/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_platform.properties @@ -21,7 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # -# suppress inspection "UnusedProperty" for whole file +# ###Windows### Windows.TitlePane.inactiveBackgroundHover = 473724 diff --git a/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_ui.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_ui.properties index 68a7fc02..c419af18 100644 --- a/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_ui.properties +++ b/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_ui.properties @@ -21,7 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # -# suppress inspection "UnusedProperty" for whole file +# ColorChooser.swatchesDefaultRecentColor = 000000 Button.borderless.drawOutline = true TabbedPane.selectedHoverBackground = %backgroundHover diff --git a/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_defaults.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_defaults.properties index b3e5c69e..1277831e 100644 --- a/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_defaults.properties +++ b/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_defaults.properties @@ -1,26 +1,27 @@ -#MIT License # -#Copyright (c) 2020 Jannis Weis +# MIT License # -#Permission is hereby granted, free of charge, to any person obtaining a copy -#of this software and associated documentation files (the "Software"), to deal -#in the Software without restriction, including without limitation the rights -#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -#copies of the Software, and to permit persons to whom the Software is -#furnished to do so, subject to the following conditions: +# Copyright (c) 2020 Jannis Weis # -#The above copyright notice and this permission notice shall be included in all -#copies or substantial portions of the Software. +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. # -#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -#SOFTWARE. # -# suppress inspection "UnusedProperty" for whole file Theme.dark = false Theme.highContrast = true diff --git a/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_icons.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_icons.properties index 233a6143..71189219 100644 --- a/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_icons.properties +++ b/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_icons.properties @@ -21,7 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # -# suppress inspection "UnusedProperty" for whole file +# %menuIconOpacity = 100 %fileIconOpacity = 100 diff --git a/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_platform.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_platform.properties index a5ff1de1..05f50b69 100644 --- a/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_platform.properties +++ b/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_platform.properties @@ -21,7 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # -# suppress inspection "UnusedProperty" for whole file +# ###Windows### Windows.TitlePane.inactiveBackgroundHover = dbcbb8 diff --git a/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_ui.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_ui.properties index fccded92..1d6ead2e 100644 --- a/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_ui.properties +++ b/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_ui.properties @@ -21,7 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # -# suppress inspection "UnusedProperty" for whole file +# ColorChooser.swatchesDefaultRecentColor = FFFFFF Button.borderless.drawOutline = true ToolTip.paintShadow = false diff --git a/theme/src/main/resources/com/github/weisj/darklaf/theme/icon_presets/dark_icons.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/icon_presets/dark_icons.properties index 74639224..0e5a030c 100644 --- a/theme/src/main/resources/com/github/weisj/darklaf/theme/icon_presets/dark_icons.properties +++ b/theme/src/main/resources/com/github/weisj/darklaf/theme/icon_presets/dark_icons.properties @@ -21,7 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # -# suppress inspection "UnusedProperty" for whole file +# %menuIconOpacity = 80 %fileIconOpacity = 80 diff --git a/theme/src/main/resources/com/github/weisj/darklaf/theme/icon_presets/light_icons.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/icon_presets/light_icons.properties index 69ab128d..2b8142c0 100644 --- a/theme/src/main/resources/com/github/weisj/darklaf/theme/icon_presets/light_icons.properties +++ b/theme/src/main/resources/com/github/weisj/darklaf/theme/icon_presets/light_icons.properties @@ -21,7 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # -# suppress inspection "UnusedProperty" for whole file +# %menuIconOpacity = 80 %fileIconOpacity = 80 diff --git a/theme/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_accents.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_accents.properties index 402d30d2..dfd68c1a 100644 --- a/theme/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_accents.properties +++ b/theme/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_accents.properties @@ -21,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# mainAccent.propertyList = {widgetFillDefault:[100,100,100];\ hoverHighlightDefault:[100,80,100];\ clickHighlightDefault:[100,90,100];\ @@ -38,4 +39,3 @@ mainAccent.propertyList = {widgetFillDefault:[100,100,100];\ controlFillHighlight:[100,100,100];\ hyperlink:[100,100,100]} selectionAccent.propertyList = {textSelectionBackground} - diff --git a/theme/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_defaults.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_defaults.properties index 212c628c..7f6fb4b9 100644 --- a/theme/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_defaults.properties +++ b/theme/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_defaults.properties @@ -4,6 +4,24 @@ # Copyright (c) 2020 Jannis Weis # # Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights diff --git a/theme/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_ui.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_ui.properties index fe55ce08..2817bff8 100644 --- a/theme/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_ui.properties +++ b/theme/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_ui.properties @@ -21,7 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # -# suppress inspection "UnusedProperty" for whole file +# Button.shadow = 808080 ProgressBar.selectionForeground = %textSelectionForeground ProgressBar.selectionBackground = %textForeground diff --git a/theme/src/main/resources/com/github/weisj/darklaf/theme/one_dark/one_dark_defaults.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/one_dark/one_dark_defaults.properties index 79905944..e2f572df 100644 --- a/theme/src/main/resources/com/github/weisj/darklaf/theme/one_dark/one_dark_defaults.properties +++ b/theme/src/main/resources/com/github/weisj/darklaf/theme/one_dark/one_dark_defaults.properties @@ -1,26 +1,27 @@ -#MIT License # -#Copyright (c) 2020 Jannis Weis +# MIT License # -#Permission is hereby granted, free of charge, to any person obtaining a copy -#of this software and associated documentation files (the "Software"), to deal -#in the Software without restriction, including without limitation the rights -#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -#copies of the Software, and to permit persons to whom the Software is -#furnished to do so, subject to the following conditions: +# Copyright (c) 2020 Jannis Weis # -#The above copyright notice and this permission notice shall be included in all -#copies or substantial portions of the Software. +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. # -#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -#SOFTWARE. # -# suppress inspection "UnusedProperty" for whole file Theme.dark = true Theme.highContrast = false diff --git a/theme/src/main/resources/com/github/weisj/darklaf/theme/one_dark/one_dark_icons.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/one_dark/one_dark_icons.properties index 2f63696c..0f5dbf0f 100644 --- a/theme/src/main/resources/com/github/weisj/darklaf/theme/one_dark/one_dark_icons.properties +++ b/theme/src/main/resources/com/github/weisj/darklaf/theme/one_dark/one_dark_icons.properties @@ -1,26 +1,27 @@ -#MIT License # -#Copyright (c) 2020 Jannis Weis +# MIT License # -#Permission is hereby granted, free of charge, to any person obtaining a copy -#of this software and associated documentation files (the "Software"), to deal -#in the Software without restriction, including without limitation the rights -#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -#copies of the Software, and to permit persons to whom the Software is -#furnished to do so, subject to the following conditions: +# Copyright (c) 2020 Jannis Weis # -#The above copyright notice and this permission notice shall be included in all -#copies or substantial portions of the Software. +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. # -#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -#SOFTWARE. # -# suppress inspection "UnusedProperty" for whole file %menuIconOpacity = 80 %fileIconOpacity = 80 diff --git a/theme/src/main/resources/com/github/weisj/darklaf/theme/one_dark/one_dark_icons_adjustments.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/one_dark/one_dark_icons_adjustments.properties index f68fbbca..d349cb72 100644 --- a/theme/src/main/resources/com/github/weisj/darklaf/theme/one_dark/one_dark_icons_adjustments.properties +++ b/theme/src/main/resources/com/github/weisj/darklaf/theme/one_dark/one_dark_icons_adjustments.properties @@ -1,26 +1,27 @@ -#MIT License # -#Copyright (c) 2020 Jannis Weis +# MIT License # -#Permission is hereby granted, free of charge, to any person obtaining a copy -#of this software and associated documentation files (the "Software"), to deal -#in the Software without restriction, including without limitation the rights -#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -#copies of the Software, and to permit persons to whom the Software is -#furnished to do so, subject to the following conditions: +# Copyright (c) 2020 Jannis Weis # -#The above copyright notice and this permission notice shall be included in all -#copies or substantial portions of the Software. +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. # -#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -#SOFTWARE. # -# suppress inspection "UnusedProperty" for whole file Icons.arrowUp.color = %textIconEnabled Icons.arrowDown.color = %textIconEnabled Icons.arrowLeft.color = %textIconEnabled diff --git a/theme/src/main/resources/com/github/weisj/darklaf/theme/one_dark/one_dark_ui.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/one_dark/one_dark_ui.properties index 9d6d51eb..fd97fdf2 100644 --- a/theme/src/main/resources/com/github/weisj/darklaf/theme/one_dark/one_dark_ui.properties +++ b/theme/src/main/resources/com/github/weisj/darklaf/theme/one_dark/one_dark_ui.properties @@ -21,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# CheckBox.activeFillColor = %textBackground CheckBox.selectedFillColor = %textBackground Slider.activeThumbFill = %textBackground diff --git a/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_defaults.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_defaults.properties index da1a4783..58b223d0 100644 --- a/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_defaults.properties +++ b/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_defaults.properties @@ -1,26 +1,27 @@ -#MIT License # -#Copyright (c) 2020 Jannis Weis +# MIT License # -#Permission is hereby granted, free of charge, to any person obtaining a copy -#of this software and associated documentation files (the "Software"), to deal -#in the Software without restriction, including without limitation the rights -#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -#copies of the Software, and to permit persons to whom the Software is -#furnished to do so, subject to the following conditions: +# Copyright (c) 2020 Jannis Weis # -#The above copyright notice and this permission notice shall be included in all -#copies or substantial portions of the Software. +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. # -#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -#SOFTWARE. # -# suppress inspection "UnusedProperty" for whole file Theme.dark = true Theme.highContrast = false diff --git a/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_icons.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_icons.properties index 32ce25aa..13cb6767 100644 --- a/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_icons.properties +++ b/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_icons.properties @@ -21,7 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # -# suppress inspection "UnusedProperty" for whole file +# %menuIconOpacity = 80 %fileIconOpacity = 80 diff --git a/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_ui.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_ui.properties index da8fb6c4..c883ad8e 100644 --- a/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_ui.properties +++ b/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_ui.properties @@ -21,5 +21,5 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # -# suppress inspection "UnusedProperty" for whole file +# ColorChooser.swatchesDefaultRecentColor = EAEEEF diff --git a/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_defaults.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_defaults.properties index bc63d7e3..c0da5ecc 100644 --- a/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_defaults.properties +++ b/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_defaults.properties @@ -21,7 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # -# suppress inspection "UnusedProperty" for whole file +# Theme.dark = false Theme.highContrast = false diff --git a/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_icons.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_icons.properties index 47abcf9c..db2d3cf3 100644 --- a/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_icons.properties +++ b/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_icons.properties @@ -21,7 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # -# suppress inspection "UnusedProperty" for whole file +# %menuIconOpacity = 80 %fileIconOpacity = 80 diff --git a/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_ui.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_ui.properties index 6b585915..095e2de8 100644 --- a/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_ui.properties +++ b/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_ui.properties @@ -21,5 +21,5 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # -# suppress inspection "UnusedProperty" for whole file +# ColorChooser.swatchesDefaultRecentColor = EAE4D1 diff --git a/utils/src/main/java/com/github/weisj/darklaf/util/Alignment.java b/utils/src/main/java/com/github/weisj/darklaf/util/Alignment.java index ef38d03e..88fd492e 100644 --- a/utils/src/main/java/com/github/weisj/darklaf/util/Alignment.java +++ b/utils/src/main/java/com/github/weisj/darklaf/util/Alignment.java @@ -20,51 +20,41 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.util; +import static com.github.weisj.darklaf.util.AlignmentHelper.*; + import java.awt.*; import java.util.function.BiFunction; -import static com.github.weisj.darklaf.util.AlignmentHelper.*; - /** * @author Jannis Weis */ public enum Alignment { NORTH(AlignmentHelper.align(HOR_CENTER_INSIDE, VERT_TOP_INSIDE), - AlignmentHelper.align(HOR_CENTER_OUTSIDE, VERT_TOP_OUTSIDE) - ), + AlignmentHelper.align(HOR_CENTER_OUTSIDE, VERT_TOP_OUTSIDE)), SOUTH(AlignmentHelper.align(HOR_CENTER_INSIDE, VERT_BOTTOM_INSIDE), - AlignmentHelper.align(HOR_CENTER_OUTSIDE, VERT_BOTTOM_OUTSIDE) - ), + AlignmentHelper.align(HOR_CENTER_OUTSIDE, VERT_BOTTOM_OUTSIDE)), EAST(AlignmentHelper.align(HOR_RIGHT_INSIDE, VERT_CENTER_INSIDE), - AlignmentHelper.align(HOR_RIGHT_OUTSIDE, VERT_CENTER_OUTSIDE) - ), + AlignmentHelper.align(HOR_RIGHT_OUTSIDE, VERT_CENTER_OUTSIDE)), WEST(AlignmentHelper.align(HOR_LEFT_INSIDE, VERT_CENTER_INSIDE), - AlignmentHelper.align(HOR_LEFT_OUTSIDE, VERT_CENTER_OUTSIDE) - ), + AlignmentHelper.align(HOR_LEFT_OUTSIDE, VERT_CENTER_OUTSIDE)), NORTH_EAST(AlignmentHelper.align(HOR_RIGHT_INSIDE, VERT_TOP_INSIDE), - AlignmentHelper.align(HOR_RIGHT_OUTSIDE, VERT_TOP_OUTSIDE) - ), + AlignmentHelper.align(HOR_RIGHT_OUTSIDE, VERT_TOP_OUTSIDE)), NORTH_WEST(AlignmentHelper.align(HOR_LEFT_INSIDE, VERT_TOP_INSIDE), - AlignmentHelper.align(HOR_LEFT_OUTSIDE, VERT_TOP_OUTSIDE) - ), + AlignmentHelper.align(HOR_LEFT_OUTSIDE, VERT_TOP_OUTSIDE)), SOUTH_EAST(AlignmentHelper.align(HOR_RIGHT_INSIDE, VERT_BOTTOM_INSIDE), - AlignmentHelper.align(HOR_RIGHT_OUTSIDE, VERT_BOTTOM_OUTSIDE) - ), + AlignmentHelper.align(HOR_RIGHT_OUTSIDE, VERT_BOTTOM_OUTSIDE)), SOUTH_WEST(AlignmentHelper.align(HOR_LEFT_INSIDE, VERT_BOTTOM_INSIDE), - AlignmentHelper.align(HOR_LEFT_OUTSIDE, VERT_BOTTOM_OUTSIDE) - ), + AlignmentHelper.align(HOR_LEFT_OUTSIDE, VERT_BOTTOM_OUTSIDE)), CENTER(AlignmentHelper.align(HOR_CENTER_INSIDE, VERT_CENTER_INSIDE), - AlignmentHelper.align(HOR_CENTER_OUTSIDE, VERT_CENTER_OUTSIDE) - ); - + AlignmentHelper.align(HOR_CENTER_OUTSIDE, VERT_CENTER_OUTSIDE)); private final BiFunction alignInside; private final BiFunction alignOutside; - Alignment(final BiFunction alignInside, final BiFunction alignOutside) { this.alignInside = alignInside; @@ -74,13 +64,12 @@ public enum Alignment { /** * Get fitting alignment. * - * @param point point to align at. - * @param size Size of rectangle to align. - * @param outerBounds outer boundaries to align in. - * @param hint preferred alignment. - * @return fitting alignment. If none is found the default is {@link Alignment#CENTER}. + * @param point point to align at. + * @param size Size of rectangle to align. + * @param outerBounds outer boundaries to align in. + * @param hint preferred alignment. + * @return fitting alignment. If none is found the default is {@link Alignment#CENTER}. */ - public static Alignment getAlignment(final Point point, final Dimension size, final Rectangle outerBounds, @@ -100,10 +89,10 @@ public enum Alignment { /** * Check whether the given Rectangle can be aligned at point inside boundaries. * - * @param point point to align at. - * @param size size of rectangle to align. - * @param outerBounds boundaries. - * @return true if can be aligned. + * @param point point to align at. + * @param size size of rectangle to align. + * @param outerBounds boundaries. + * @return true if can be aligned. */ public boolean canBeAligned(final Point point, final Dimension size, @@ -117,9 +106,9 @@ public enum Alignment { /** * Get the relative Position of Rectangle to Point with respect to the alignment. * - * @param toAlign size of Rectangle to align. - * @param alignAt point to align at. - * @return top/left position of aligned rectangle + * @param toAlign size of Rectangle to align. + * @param alignAt point to align at. + * @return top/left position of aligned rectangle */ public Point relativePos(final Dimension toAlign, final Point alignAt) { return alignOutside(toAlign, new Rectangle(alignAt.x, alignAt.y, 0, 0)); @@ -128,9 +117,9 @@ public enum Alignment { /** * Align Rectangle outside other rectangle with respect to the alignment. * - * @param toAlign size of rectangle to align - * @param innerBounds bounds of inside rectangle - * @return top/left point of aligned rectangle + * @param toAlign size of rectangle to align + * @param innerBounds bounds of inside rectangle + * @return top/left point of aligned rectangle */ public Point alignOutside(final Dimension toAlign, final Rectangle innerBounds) { @@ -143,7 +132,6 @@ public enum Alignment { * * @return the index. */ - public int getIndex() { return this.ordinal(); } @@ -153,84 +141,80 @@ public enum Alignment { * * @return Alignment opposite on the compass. */ - - @SuppressWarnings("Duplicates") public Alignment opposite() { switch (this) { - case NORTH: + case NORTH : return SOUTH; - case NORTH_EAST: + case NORTH_EAST : return SOUTH_WEST; - case EAST: + case EAST : return WEST; - case SOUTH_EAST: + case SOUTH_EAST : return NORTH_WEST; - case SOUTH: + case SOUTH : return NORTH; - case SOUTH_WEST: + case SOUTH_WEST : return NORTH_EAST; - case WEST: + case WEST : return EAST; - case NORTH_WEST: + case NORTH_WEST : return SOUTH_EAST; - case CENTER: + case CENTER : return CENTER; - default: + default : throw new IllegalArgumentException(); } } - @SuppressWarnings("Duplicates") public Alignment anticlockwise() { switch (this) { - case NORTH: + case NORTH : return NORTH_WEST; - case NORTH_EAST: + case NORTH_EAST : return NORTH; - case EAST: + case EAST : return NORTH_EAST; - case SOUTH_EAST: + case SOUTH_EAST : return EAST; - case SOUTH: + case SOUTH : return SOUTH_EAST; - case SOUTH_WEST: + case SOUTH_WEST : return SOUTH; - case WEST: + case WEST : return SOUTH_WEST; - case NORTH_WEST: + case NORTH_WEST : return WEST; - case CENTER: + case CENTER : return CENTER; - default: + default : throw new IllegalArgumentException(); } } - @SuppressWarnings("Duplicates") public Alignment clockwise() { switch (this) { - case NORTH: + case NORTH : return NORTH_EAST; - case NORTH_EAST: + case NORTH_EAST : return EAST; - case EAST: + case EAST : return SOUTH_EAST; - case SOUTH_EAST: + case SOUTH_EAST : return SOUTH; - case SOUTH: + case SOUTH : return SOUTH_WEST; - case SOUTH_WEST: + case SOUTH_WEST : return WEST; - case WEST: + case WEST : return NORTH_WEST; - case NORTH_WEST: + case NORTH_WEST : return NORTH; - case CENTER: + case CENTER : return CENTER; - default: + default : throw new IllegalArgumentException(); } } @@ -239,32 +223,31 @@ public enum Alignment { return maskInsets(insets, 0); } - public Insets maskInsets(final Insets insets, final int maskValue) { return maskInsets(insets.top, insets.left, insets.bottom, insets.right, maskValue); } public Insets maskInsets(final int top, final int left, final int bottom, final int right, final int mask) { switch (this) { - case NORTH: + case NORTH : return new Insets(top, mask, mask, mask); - case NORTH_EAST: + case NORTH_EAST : return new Insets(top, mask, mask, right); - case EAST: + case EAST : return new Insets(mask, mask, mask, right); - case SOUTH_EAST: + case SOUTH_EAST : return new Insets(mask, mask, bottom, right); - case SOUTH: + case SOUTH : return new Insets(mask, mask, bottom, mask); - case SOUTH_WEST: + case SOUTH_WEST : return new Insets(mask, left, bottom, mask); - case WEST: + case WEST : return new Insets(mask, left, mask, mask); - case NORTH_WEST: + case NORTH_WEST : return new Insets(top, left, mask, mask); - case CENTER: + case CENTER : return new Insets(mask, mask, mask, mask); - default: + default : throw new IllegalArgumentException(); } } @@ -289,9 +272,9 @@ public enum Alignment { /** * Align Rectangle inside other rectangle with respect to the alignment. * - * @param toAlign size of rectangle to align - * @param outerBounds bounds of outer rectangle - * @return top/left point of aligned rectangle + * @param toAlign size of rectangle to align + * @param outerBounds bounds of outer rectangle + * @return top/left point of aligned rectangle */ public Point alignInside(final Dimension toAlign, final Rectangle outerBounds) { diff --git a/utils/src/main/java/com/github/weisj/darklaf/util/AlignmentExt.java b/utils/src/main/java/com/github/weisj/darklaf/util/AlignmentExt.java index 476aa462..04b84a79 100644 --- a/utils/src/main/java/com/github/weisj/darklaf/util/AlignmentExt.java +++ b/utils/src/main/java/com/github/weisj/darklaf/util/AlignmentExt.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.util; @@ -52,36 +53,35 @@ public enum AlignmentExt { return maskInsets(insets, 0); } - public Insets maskInsets(final Insets insets, final int maskValue) { return maskInsets(insets.top, insets.left, insets.bottom, insets.right, maskValue); } public Insets maskInsets(final int top, final int left, final int bottom, final int right, final int mask) { switch (this) { - case NORTH: - case NORTH_EAST: - case EAST: - case SOUTH_EAST: - case SOUTH: - case SOUTH_WEST: - case WEST: - case NORTH_WEST: - case CENTER: + case NORTH : + case NORTH_EAST : + case EAST : + case SOUTH_EAST : + case SOUTH : + case SOUTH_WEST : + case WEST : + case NORTH_WEST : + case CENTER : return parent.maskInsets(top, left, bottom, right, mask); - case LEFT: + case LEFT : return new Insets(top, left, bottom, mask); - case MIDDLE_HORIZONTAL: + case MIDDLE_HORIZONTAL : return new Insets(top, mask, bottom, mask); - case RIGHT: + case RIGHT : return new Insets(top, mask, bottom, right); - case TOP: + case TOP : return new Insets(top, left, mask, right); - case MIDDLE_VERTICAL: + case MIDDLE_VERTICAL : return new Insets(mask, left, mask, right); - case BOTTOM: + case BOTTOM : return new Insets(mask, left, bottom, right); - default: + default : throw new IllegalArgumentException(); } } diff --git a/utils/src/main/java/com/github/weisj/darklaf/util/AlignmentHelper.java b/utils/src/main/java/com/github/weisj/darklaf/util/AlignmentHelper.java index e63cd80e..75018008 100644 --- a/utils/src/main/java/com/github/weisj/darklaf/util/AlignmentHelper.java +++ b/utils/src/main/java/com/github/weisj/darklaf/util/AlignmentHelper.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.util; @@ -51,12 +52,10 @@ final class AlignmentHelper { /** * Create mapper from component mapper. * - * @param mapperX x component mapper. - * @param mapperY y component mapper. - * @return mapper that aligns a rectangle relative to other rectangle. + * @param mapperX x component mapper. + * @param mapperY y component mapper. + * @return mapper that aligns a rectangle relative to other rectangle. */ - - static BiFunction align(final Mapper mapperX, final Mapper mapperY) { return (d, p) -> new Point(mapperX.apply(d, p), mapperY.apply(d, p)); @@ -65,6 +64,5 @@ final class AlignmentHelper { /** * Helper interface to avoid long type names. */ - private interface Mapper extends BiFunction { - } + private interface Mapper extends BiFunction {} } diff --git a/utils/src/main/java/com/github/weisj/darklaf/util/ColorUtil.java b/utils/src/main/java/com/github/weisj/darklaf/util/ColorUtil.java index cb221e1c..0b97dfba 100644 --- a/utils/src/main/java/com/github/weisj/darklaf/util/ColorUtil.java +++ b/utils/src/main/java/com/github/weisj/darklaf/util/ColorUtil.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.util; @@ -30,28 +31,23 @@ import java.awt.*; */ public final class ColorUtil { - private ColorUtil() { } - public static Color shift(final Color c, final double d) { return new Color(shift(c.getRed(), d), shift(c.getGreen(), d), shift(c.getBlue(), d), c.getAlpha()); } - private static int shift(final int colorComponent, final double d) { int n = (int) ((double) colorComponent * d); return n > 255 ? 255 : (Math.max(n, 0)); } - public static Color toAlpha(final Color color, final double alpha) { return toAlpha(color, (int) (alpha * 255)); } - public static Color toAlpha(final Color color, final int a) { Color c = color != null ? color : Color.black; return new Color(c.getRed(), c.getGreen(), c.getBlue(), Math.min(Math.max(0, a), 255)); diff --git a/utils/src/main/java/com/github/weisj/darklaf/util/Pair.java b/utils/src/main/java/com/github/weisj/darklaf/util/Pair.java index d4cec7c2..67e98a13 100644 --- a/utils/src/main/java/com/github/weisj/darklaf/util/Pair.java +++ b/utils/src/main/java/com/github/weisj/darklaf/util/Pair.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.util; @@ -28,7 +29,6 @@ public class Pair { private T first; private H second; - public Pair(final T first, final H second) { this.first = first; this.second = second; diff --git a/utils/src/main/java/com/github/weisj/darklaf/util/PropertyKey.java b/utils/src/main/java/com/github/weisj/darklaf/util/PropertyKey.java index 3324070c..307311dc 100644 --- a/utils/src/main/java/com/github/weisj/darklaf/util/PropertyKey.java +++ b/utils/src/main/java/com/github/weisj/darklaf/util/PropertyKey.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.util; diff --git a/utils/src/main/java/com/github/weisj/darklaf/util/PropertyValue.java b/utils/src/main/java/com/github/weisj/darklaf/util/PropertyValue.java index 4fd2325c..409d9b5f 100644 --- a/utils/src/main/java/com/github/weisj/darklaf/util/PropertyValue.java +++ b/utils/src/main/java/com/github/weisj/darklaf/util/PropertyValue.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.util; diff --git a/utils/src/main/java/com/github/weisj/darklaf/util/Scale.java b/utils/src/main/java/com/github/weisj/darklaf/util/Scale.java index 526612bb..cdf47936 100644 --- a/utils/src/main/java/com/github/weisj/darklaf/util/Scale.java +++ b/utils/src/main/java/com/github/weisj/darklaf/util/Scale.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.util; @@ -38,47 +39,38 @@ public class Scale { SCALE = SCALE_X; } - public static int scale(final int i) { return (int) (SCALE * i); } - public static float scale(final float f) { return (float) (SCALE * f); } - public static double scale(final double d) { return SCALE * d; } - public static int scaleWidth(final int i) { return (int) (SCALE_X * i); } - public static float scaleWidth(final float f) { return (float) (SCALE_X * f); } - public static double scaleWidth(final double d) { return SCALE_X * d; } - public static int scaleHeight(final int i) { return (int) (SCALE_Y * i); } - public static float scaleHeight(final float f) { return (float) (SCALE_Y * f); } - public static double scaleHeight(final double d) { return SCALE_Y * d; } diff --git a/utils/src/main/java/com/github/weisj/darklaf/util/StringUtil.java b/utils/src/main/java/com/github/weisj/darklaf/util/StringUtil.java index 0fcba0d1..e757a508 100644 --- a/utils/src/main/java/com/github/weisj/darklaf/util/StringUtil.java +++ b/utils/src/main/java/com/github/weisj/darklaf/util/StringUtil.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.util; @@ -33,16 +34,12 @@ import java.util.List; */ public final class StringUtil { - - private StringUtil() { - } - + private StringUtil() {} public static String toUpperCase(final String a) { return a == null ? null : toUpperCase((CharSequence) a).toString(); } - public static CharSequence toUpperCase(final CharSequence s) { if (s == null) { throw new NullPointerException("CharSequence can't be null"); @@ -61,7 +58,6 @@ public final class StringUtil { return answer; } - public static char toUpperCase(final char a) { if (a < 'a') { return a; @@ -130,7 +126,6 @@ public final class StringUtil { return a == b || toUpperCase(a) == toUpperCase(b) || toLowerCase(a) == toLowerCase(b); } - public static char toLowerCase(final char a) { if (a >= 'A' && (a < 'a' || a > 'z')) { return a <= 'Z' ? (char) (a + 32) : Character.toLowerCase(a); @@ -189,7 +184,6 @@ public final class StringUtil { return s.trim().length() == 0; } - public static String repeat(final String s, final int count) { if (count <= 0) return ""; if (count == 1) return s; diff --git a/utils/src/main/java/com/github/weisj/darklaf/util/SystemInfo.java b/utils/src/main/java/com/github/weisj/darklaf/util/SystemInfo.java index 3ef2e4ac..454b371c 100644 --- a/utils/src/main/java/com/github/weisj/darklaf/util/SystemInfo.java +++ b/utils/src/main/java/com/github/weisj/darklaf/util/SystemInfo.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.util; diff --git a/windows/build.gradle.kts b/windows/build.gradle.kts index ac77d94a..9fbc559c 100644 --- a/windows/build.gradle.kts +++ b/windows/build.gradle.kts @@ -1,3 +1,5 @@ +import com.github.vlsi.gradle.properties.dsl.props + plugins { `jni-library` } @@ -37,3 +39,18 @@ library { ) } } + +val skipAutostyle by props() + +if (!skipAutostyle) { + autostyle { + cpp { + licenseHeader(File("${project.rootDir}/LICENSE").readText()) + trimTrailingWhitespace() + endWithNewline() + eclipse { + configFile("darklaf_cpp.eclipseformat.xml") + } + } + } +} diff --git a/darklaf_cpp.eclipseformat.xml b/windows/darklaf_cpp.eclipseformat.xml similarity index 93% rename from darklaf_cpp.eclipseformat.xml rename to windows/darklaf_cpp.eclipseformat.xml index e94a08ac..09e4c03c 100644 --- a/darklaf_cpp.eclipseformat.xml +++ b/windows/darklaf_cpp.eclipseformat.xml @@ -1,4 +1,28 @@ + - + - + - + - - + + @@ -111,7 +135,7 @@ - + @@ -122,7 +146,7 @@ - + @@ -234,7 +258,7 @@ - + diff --git a/windows/gradle.properties b/windows/gradle.properties index d86e620f..46219f26 100644 --- a/windows/gradle.properties +++ b/windows/gradle.properties @@ -1 +1,25 @@ +# +# MIT License +# +# Copyright (c) 2020 Jannis Weis +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# defaultLibraryName = darklaf-windows.dll diff --git a/windows/src/main/cpp/Decorations.cpp b/windows/src/main/cpp/Decorations.cpp index 0bcfe1db..a4b6165c 100644 --- a/windows/src/main/cpp/Decorations.cpp +++ b/windows/src/main/cpp/Decorations.cpp @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ #include "Decorations.h" #include "com_github_weisj_darklaf_platform_windows_JNIDecorationsWindows.h" @@ -28,13 +29,15 @@ #include #include -std::map wrapper_map = std::map(); +std::map wrapper_map = std::map(); LRESULT HitTestNCA(HWND hWnd, WPARAM wParam, LPARAM lParam, WindowWrapper *wrapper) { - if (wrapper->popup_menu) return HTCLIENT; + if (wrapper->popup_menu) + return HTCLIENT; // Get the point coordinates for the hit test. - POINT ptMouse = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)}; + POINT ptMouse = { GET_X_LPARAM(lParam), + GET_Y_LPARAM(lParam) }; // Get the window rectangle. RECT rcWindow; @@ -65,17 +68,20 @@ LRESULT HitTestNCA(HWND hWnd, WPARAM wParam, LPARAM lParam, WindowWrapper *wrapp } // Hit test (HTTOPLEFT, ... HTBOTTOMRIGHT) - LRESULT hitTests[3][3] = { - {HTTOPLEFT, HTTOP, HTTOPRIGHT}, - {HTLEFT, HTNOWHERE, HTRIGHT}, - {HTBOTTOMLEFT, HTBOTTOM, HTBOTTOMRIGHT}, - }; + LRESULT hitTests[3][3] = { { HTTOPLEFT, + HTTOP, + HTTOPRIGHT }, + { HTLEFT, + HTNOWHERE, + HTRIGHT }, + { HTBOTTOMLEFT, + HTBOTTOM, + HTBOTTOMRIGHT }, }; LRESULT hit = hitTests[uRow][uCol]; if (hit == HTNOWHERE || !wrapper->resizable) { //Handle window drag. - if (ptMouse.y < rcWindow.top + wrapper->height - && ptMouse.x >= rcWindow.left + wrapper->left + if (ptMouse.y < rcWindow.top + wrapper->height && ptMouse.x >= rcWindow.left + wrapper->left && ptMouse.x <= rcWindow.right - wrapper->right) { return HTCAPTION; @@ -91,20 +97,24 @@ LRESULT HitTestNCA(HWND hWnd, WPARAM wParam, LPARAM lParam, WindowWrapper *wrapp bool Maximized(HWND hwnd) { WINDOWPLACEMENT placement; - if (!GetWindowPlacement(hwnd, &placement)) return false; + if (!GetWindowPlacement(hwnd, &placement)) + return false; return placement.showCmd == SW_MAXIMIZE; } -void AdjustMaximizedClientArea(HWND window, RECT& rect) +void AdjustMaximizedClientArea(HWND window, RECT &rect) { - if (!Maximized(window)) return; + if (!Maximized(window)) + return; auto monitor = MonitorFromWindow(window, MONITOR_DEFAULTTONULL); - if (!monitor) return; + if (!monitor) + return; - MONITORINFO monitor_info{}; + MONITORINFO monitor_info {}; monitor_info.cbSize = sizeof(monitor_info); - if (!GetMonitorInfoW(monitor, &monitor_info)) return; + if (!GetMonitorInfoW(monitor, &monitor_info)) + return; rect = monitor_info.rcWork; } @@ -114,13 +124,13 @@ void AdjustMinMaxInfo(HWND hwnd, LPARAM lParam) HMONITOR hPrimaryMonitor = MonitorFromWindow(nullptr, MONITOR_DEFAULTTOPRIMARY); HMONITOR hTargetMonitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST); - MONITORINFO primaryMonitorInfo{sizeof(MONITORINFO)}; - MONITORINFO targetMonitorInfo{sizeof(MONITORINFO)}; + MONITORINFO primaryMonitorInfo { sizeof(MONITORINFO) }; + MONITORINFO targetMonitorInfo { sizeof(MONITORINFO) }; GetMonitorInfo(hPrimaryMonitor, &primaryMonitorInfo); GetMonitorInfo(hTargetMonitor, &targetMonitorInfo); - MINMAXINFO *min_max_info = reinterpret_cast(lParam); + MINMAXINFO *min_max_info = reinterpret_cast(lParam); RECT max_rect = primaryMonitorInfo.rcWork; RECT target_rect = targetMonitorInfo.rcWork; min_max_info->ptMaxSize.x = target_rect.right - target_rect.left; @@ -148,7 +158,8 @@ LRESULT CALLBACK WindowWrapper::WindowProc(_In_ HWND hwnd, _In_ UINT uMsg, _In_ } else if (uMsg == WM_NCCALCSIZE) { - if (wParam == TRUE) { + if (wParam == TRUE) + { NCCALCSIZE_PARAMS& params = *reinterpret_cast(lParam); AdjustMaximizedClientArea(handle, params.rgrc[0]); return TRUE; @@ -198,7 +209,7 @@ Java_com_github_weisj_darklaf_platform_windows_JNIDecorationsWindows_setResizabl JNIEXPORT void JNICALL Java_com_github_weisj_darklaf_platform_windows_JNIDecorationsWindows_updateValues(JNIEnv *env, jclass obj, jlong hwnd, - jint l, jint r, jint h) + jint l, jint r, jint h) { HWND handle = reinterpret_cast(hwnd); auto wrap = wrapper_map[handle]; @@ -223,7 +234,10 @@ Java_com_github_weisj_darklaf_platform_windows_JNIDecorationsWindows_setBackgrou void ExtendClientFrame(HWND handle) { - MARGINS margins = {1, 1, 1, 1}; + MARGINS margins = { 1, + 1, + 1, + 1 }; DwmExtendFrameIntoClientArea(handle, &margins); } @@ -237,7 +251,8 @@ bool InstallDecorations(HWND handle, bool is_popup) { //Prevent multiple installations overriding the real window procedure. auto it = wrapper_map.find(handle); - if (it != wrapper_map.end()) return false; + if (it != wrapper_map.end()) + return false; SetupWindowStyle(handle); ExtendClientFrame(handle); @@ -248,7 +263,7 @@ bool InstallDecorations(HWND handle, bool is_popup) wrapper->prev_proc = proc; wrapper->popup_menu = is_popup; wrapper_map[handle] = wrapper; - SetWindowLongPtr(handle, GWLP_WNDPROC, (LONG_PTR)WindowWrapper::WindowProc); + SetWindowLongPtr(handle, GWLP_WNDPROC, (LONG_PTR) WindowWrapper::WindowProc); UINT flags = SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED; SetWindowPos(handle, NULL, 0, 0, 0, 0, flags); return true; diff --git a/windows/src/main/cpp/Decorations.h b/windows/src/main/cpp/Decorations.h index cbacd65b..6cb20e9a 100644 --- a/windows/src/main/cpp/Decorations.h +++ b/windows/src/main/cpp/Decorations.h @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ #include #include @@ -27,17 +28,17 @@ class WindowWrapper { -public: - bool resizable = true; - bool popup_menu = false; - bool moving = false; - bool move_mode = false; - WNDPROC prev_proc; - HBRUSH bgBrush; + public: + bool resizable = true; + bool popup_menu = false; + bool moving = false; + bool move_mode = false; + WNDPROC prev_proc; + HBRUSH bgBrush; - int left = 0; - int right = 0; - int height = 0; + int left = 0; + int right = 0; + int height = 0; - static LRESULT CALLBACK WindowProc(_In_ HWND hwnd, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam); + static LRESULT CALLBACK WindowProc(_In_ HWND hwnd, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam); }; diff --git a/windows/src/main/cpp/ThemeInfo.cpp b/windows/src/main/cpp/ThemeInfo.cpp index bcac0bd5..d30ee431 100644 --- a/windows/src/main/cpp/ThemeInfo.cpp +++ b/windows/src/main/cpp/ThemeInfo.cpp @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ #include "com_github_weisj_darklaf_platform_windows_JNIThemeInfoWindows.h" @@ -49,7 +50,6 @@ #define FONT_SCALE_DEFAULT_VALUE 100 #define ACCENT_COLOR_DEFAULT_VALUE 0 - void ModifyFlags(DWORD &flags) { #ifdef _WIN64 @@ -61,29 +61,32 @@ void ModifyFlags(DWORD &flags) DWORD RegGetDword(HKEY hKey, const LPCSTR subKey, const LPCSTR value) { - DWORD data{}; + DWORD data {}; DWORD dataSize = sizeof(data); DWORD flags = RRF_RT_REG_DWORD; ModifyFlags(flags); LONG retCode = ::RegGetValue(hKey, subKey, value, flags, nullptr, &data, &dataSize); - if (retCode != ERROR_SUCCESS) throw retCode; + if (retCode != ERROR_SUCCESS) + throw retCode; return data; } std::string RegGetString(HKEY hKey, const LPCSTR subKey, const LPCSTR value) { - DWORD dataSize{}; + DWORD dataSize {}; DWORD flags = RRF_RT_REG_SZ; ModifyFlags(flags); LONG retCode = ::RegGetValue(hKey, subKey, value, flags, nullptr, nullptr, &dataSize); - if (retCode != ERROR_SUCCESS) throw retCode; + if (retCode != ERROR_SUCCESS) + throw retCode; std::string data; DWORD stringLengthInChars = dataSize / sizeof(char); data.resize(stringLengthInChars); retCode = ::RegGetValue(hKey, subKey, value, flags, nullptr, &data[0], &dataSize); - if (retCode != ERROR_SUCCESS) throw retCode; + if (retCode != ERROR_SUCCESS) + throw retCode; return data; } @@ -104,14 +107,16 @@ bool IsDarkMode() { try { - bool appsUseDark = (0 == RegGetDword(HKEY_CURRENT_USER, DARK_MODE_PATH, DARK_MODE_KEY)); + bool appsUseDark = (0 == RegGetDword(HKEY_CURRENT_USER, DARK_MODE_PATH, + DARK_MODE_KEY)); bool isHighContrast = IsHighContrastMode(); - if (!isHighContrast) return appsUseDark; + if (!isHighContrast) + return appsUseDark; - std::string themeValue = RegGetString(HKEY_CURRENT_USER, HIGH_CONTRAST_PATH, HIGH_CONTRAST_THEME_KEY); + std::string themeValue = RegGetString(HKEY_CURRENT_USER, + HIGH_CONTRAST_PATH, HIGH_CONTRAST_THEME_KEY); return (strcmp(themeValue.c_str(), HIGH_CONTRAST_LIGHT_THEME) != 0); - } - catch (LONG e) + } catch (LONG e) { return DARK_MODE_DEFAULT_VALUE; } @@ -122,8 +127,7 @@ unsigned int GetTextScaleFactor() try { return RegGetDword(HKEY_CURRENT_USER, FONT_SCALE_PATH, FONT_SCALE_KEY); - } - catch (LONG e) + } catch (LONG e) { return FONT_SCALE_DEFAULT_VALUE; } @@ -150,9 +154,9 @@ int GetAccentColor() { try { - return RegGetDword(HKEY_CURRENT_USER, ACCENT_COLOR_PATH, ACCENT_COLOR_KEY); - } - catch (LONG e) + return RegGetDword(HKEY_CURRENT_USER, ACCENT_COLOR_PATH, + ACCENT_COLOR_KEY); + } catch (LONG e) { return ACCENT_COLOR_DEFAULT_VALUE; } @@ -182,81 +186,88 @@ Java_com_github_weisj_darklaf_platform_windows_JNIThemeInfoWindows_getAccentColo return (jint) GetAccentColor(); } - -struct EventHandler { - JavaVM *jvm; - JNIEnv *env; - jobject callback; - HANDLE eventHandle; - std::thread notificationLoop; - std::atomic running = FALSE; - - void runCallBack() - { - jclass runnableClass = env->GetObjectClass(callback); - jmethodID runMethodId = env->GetMethodID(runnableClass, "run", "()V"); - if (runMethodId) { - env->CallVoidMethod(callback, runMethodId); - } - } - - bool awaitPreferenceChange() - { - if (!RegisterRegistryEvent(FONT_SCALE_PATH, eventHandle)) return FALSE; - if (!RegisterRegistryEvent(DARK_MODE_PATH, eventHandle)) return FALSE; - if (!RegisterRegistryEvent(HIGH_CONTRAST_PATH, eventHandle)) return FALSE; - if (!RegisterRegistryEvent(ACCENT_COLOR_PATH, eventHandle)) return FALSE; - return WaitForSingleObject(eventHandle, INFINITE) != WAIT_FAILED; - } - - void run() - { - int getEnvStat = jvm->GetEnv((void **)&env, JNI_VERSION_1_6); - if (getEnvStat == JNI_EDETACHED) +struct EventHandler +{ + JavaVM *jvm; + JNIEnv *env; + jobject callback; + HANDLE eventHandle; + std::thread notificationLoop; + std::atomic running = FALSE; + + void runCallBack() { - if (jvm->AttachCurrentThread((void **) &env, NULL) != 0) return; + jclass runnableClass = env->GetObjectClass(callback); + jmethodID runMethodId = env->GetMethodID(runnableClass, "run", "()V"); + if (runMethodId) + { + env->CallVoidMethod(callback, runMethodId); + } } - else if (getEnvStat == JNI_EVERSION) + + bool awaitPreferenceChange() { - return; + if (!RegisterRegistryEvent(FONT_SCALE_PATH, eventHandle)) + return FALSE; + if (!RegisterRegistryEvent(DARK_MODE_PATH, eventHandle)) + return FALSE; + if (!RegisterRegistryEvent(HIGH_CONTRAST_PATH, eventHandle)) + return FALSE; + if (!RegisterRegistryEvent(ACCENT_COLOR_PATH, eventHandle)) + return FALSE; + return WaitForSingleObject(eventHandle, INFINITE) != WAIT_FAILED; } - while(running && awaitPreferenceChange()) + + void run() { - if (running) + int getEnvStat = jvm->GetEnv((void**) &env, JNI_VERSION_1_6); + if (getEnvStat == JNI_EDETACHED) + { + if (jvm->AttachCurrentThread((void**) &env, NULL) != 0) + return; + } + else if (getEnvStat == JNI_EVERSION) { - runCallBack(); - if (env->ExceptionCheck()) + return; + } + while (running && awaitPreferenceChange()) + { + if (running) { - env->ExceptionDescribe(); - break; + runCallBack(); + if (env->ExceptionCheck()) + { + env->ExceptionDescribe(); + break; + } } } + jvm->DetachCurrentThread(); } - jvm->DetachCurrentThread(); - } - void stop() - { - running = FALSE; - SetEvent(eventHandle); - notificationLoop.join(); - } + void stop() + { + running = FALSE; + SetEvent(eventHandle); + notificationLoop.join(); + } - EventHandler(JavaVM *jvm_, jobject callback_, HANDLE eventHandle_) - { - jvm = jvm_; - callback = callback_; - eventHandle = eventHandle_; - running = TRUE; - notificationLoop = std::thread(&EventHandler::run, this); - } + EventHandler(JavaVM *jvm_, jobject callback_, HANDLE eventHandle_) + { + jvm = jvm_; + callback = callback_; + eventHandle = eventHandle_; + running = TRUE; + notificationLoop = std::thread(&EventHandler::run, this); + } }; JNIEXPORT jlong JNICALL Java_com_github_weisj_darklaf_platform_windows_JNIThemeInfoWindows_createEventHandler(JNIEnv *env, jclass obj, jobject callback) { JavaVM *jvm; - if (env->GetJavaVM(&jvm) == 0) { + if (env->GetJavaVM(&jvm) == 0) + { jobject callbackRef = env->NewGlobalRef(callback); HANDLE event = CreateEvent(NULL, FALSE, FALSE, NULL); EventHandler* eventHandler = new EventHandler(jvm, callbackRef, event); @@ -269,7 +280,8 @@ JNIEXPORT void JNICALL Java_com_github_weisj_darklaf_platform_windows_JNIThemeInfoWindows_deleteEventHandler(JNIEnv *env, jclass obj, jlong eventHandler) { EventHandler *handler = reinterpret_cast(eventHandler); - if (handler) { + if (handler) + { env->DeleteGlobalRef(handler->callback); handler->stop(); delete handler; diff --git a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/JNIDecorationsWindows.java b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/JNIDecorationsWindows.java index f84505ea..47ceb31d 100644 --- a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/JNIDecorationsWindows.java +++ b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/JNIDecorationsWindows.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.platform.windows; diff --git a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/JNIThemeInfoWindows.java b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/JNIThemeInfoWindows.java index 152be6da..fdc66809 100644 --- a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/JNIThemeInfoWindows.java +++ b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/JNIThemeInfoWindows.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.platform.windows; @@ -56,8 +57,8 @@ public class JNIThemeInfoWindows { /** * Create a monitor event handler. * - * @param callback the event callback. - * @return the event handler pointer. + * @param callback the event callback. + * @return the event handler pointer. */ public static native long createEventHandler(final Runnable callback); diff --git a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/PointerUtil.java b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/PointerUtil.java index 6a69455b..4075c901 100644 --- a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/PointerUtil.java +++ b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/PointerUtil.java @@ -20,21 +20,23 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.platform.windows; -import com.sun.jna.Native; +import java.awt.*; import javax.swing.*; -import java.awt.*; + +import com.sun.jna.Native; public class PointerUtil { /** * Get the window handle for the window the given component descends from. * - * @param component the component. - * @return the handle. + * @param component the component. + * @return the handle. */ public static long getHWND(final Component component) { Window window = component instanceof Window ? (Window) component diff --git a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsDecorationsProvider.java b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsDecorationsProvider.java index 937ff956..31dd8603 100644 --- a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsDecorationsProvider.java +++ b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsDecorationsProvider.java @@ -20,19 +20,21 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.platform.windows; +import java.awt.*; +import java.util.Properties; + +import javax.swing.*; + import com.github.weisj.darklaf.PropertyLoader; import com.github.weisj.darklaf.icons.IconLoader; import com.github.weisj.darklaf.platform.decorations.CustomTitlePane; import com.github.weisj.darklaf.platform.decorations.DecorationsProvider; import com.github.weisj.darklaf.platform.windows.ui.WindowsTitlePane; -import javax.swing.*; -import java.awt.*; -import java.util.Properties; - public class WindowsDecorationsProvider implements DecorationsProvider { @Override @@ -79,10 +81,16 @@ public class WindowsDecorationsProvider implements DecorationsProvider { public void loadDecorationProperties(final Properties properties, final UIDefaults currentDefaults) { IconLoader iconLoader = IconLoader.get(WindowsDecorationsProvider.class); PropertyLoader.putProperties(PropertyLoader.loadProperties(WindowsDecorationsProvider.class, - "windows_decorations", ""), - properties, currentDefaults, iconLoader); + "windows_decorations", + ""), + properties, + currentDefaults, + iconLoader); PropertyLoader.putProperties(PropertyLoader.loadProperties(WindowsDecorationsProvider.class, - "windows_icons", ""), - properties, currentDefaults, iconLoader); + "windows_icons", + ""), + properties, + currentDefaults, + iconLoader); } } diff --git a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsLibrary.java b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsLibrary.java index cc2ed17c..b5c37215 100644 --- a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsLibrary.java +++ b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsLibrary.java @@ -20,15 +20,16 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.platform.windows; -import com.github.weisj.darklaf.platform.NativeUtil; -import com.github.weisj.darklaf.util.SystemInfo; - import java.util.logging.Level; import java.util.logging.Logger; +import com.github.weisj.darklaf.platform.NativeUtil; +import com.github.weisj.darklaf.util.SystemInfo; + public class WindowsLibrary { private static final Logger LOGGER = Logger.getLogger(WindowsLibrary.class.getName()); @@ -52,11 +53,9 @@ public class WindowsLibrary { } try { if (SystemInfo.isX86) { - NativeUtil.loadLibraryFromJar( - "/com/github/weisj/darklaf/platform/darklaf-windows/windows-x86/darklaf-windows.dll"); + NativeUtil.loadLibraryFromJar("/com/github/weisj/darklaf/platform/darklaf-windows/windows-x86/darklaf-windows.dll"); } else if (SystemInfo.isX64) { - NativeUtil.loadLibraryFromJar( - "/com/github/weisj/darklaf/platform/darklaf-windows/windows-x86-64/darklaf-windows.dll"); + NativeUtil.loadLibraryFromJar("/com/github/weisj/darklaf/platform/darklaf-windows/windows-x86-64/darklaf-windows.dll"); } else { LOGGER.warning("Could not determine jre model '" + SystemInfo.jreArchitecture @@ -66,9 +65,11 @@ public class WindowsLibrary { loaded = true; LOGGER.info("Loaded darklaf-windows.dll. Native features are enabled."); } catch (Throwable e) { - //Library not found, SecurityManager prevents library loading etc. - LOGGER.log(Level.SEVERE, "Could not load decorations library darklaf-windows.dll." + - " Native features will be disabled", e); + // Library not found, SecurityManager prevents library loading etc. + LOGGER.log(Level.SEVERE, + "Could not load decorations library darklaf-windows.dll." + + " Native features will be disabled", + e); } } diff --git a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsPreferenceMonitor.java b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsPreferenceMonitor.java index cfb4b3e1..1d618ab6 100644 --- a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsPreferenceMonitor.java +++ b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsPreferenceMonitor.java @@ -20,6 +20,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.platform.windows; diff --git a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsThemePreferenceProvider.java b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsThemePreferenceProvider.java index 99efca41..3a59e79e 100644 --- a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsThemePreferenceProvider.java +++ b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsThemePreferenceProvider.java @@ -20,14 +20,15 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ package com.github.weisj.darklaf.platform.windows; -import com.github.weisj.darklaf.theme.info.*; - import java.awt.*; import java.util.function.Consumer; +import com.github.weisj.darklaf.theme.info.*; + public class WindowsThemePreferenceProvider implements ThemePreferenceProvider { private final PreferredThemeStyle fallbackStyle = new PreferredThemeStyle(ContrastRule.STANDARD, diff --git a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java index c66bee96..27f40e1f 100644 --- a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java +++ b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java @@ -20,10 +20,22 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. + * */ - package com.github.weisj.darklaf.platform.windows.ui; +import java.awt.*; +import java.awt.event.*; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.List; + +import javax.accessibility.AccessibleContext; +import javax.swing.*; +import javax.swing.plaf.UIResource; + +import sun.awt.SunToolkit; + import com.github.weisj.darklaf.icons.ScaledIcon; import com.github.weisj.darklaf.icons.ToggleIcon; import com.github.weisj.darklaf.platform.decorations.CustomTitlePane; @@ -31,16 +43,6 @@ import com.github.weisj.darklaf.platform.windows.JNIDecorationsWindows; import com.github.weisj.darklaf.platform.windows.PointerUtil; import com.github.weisj.darklaf.util.PropertyKey; import com.github.weisj.darklaf.util.Scale; -import sun.awt.SunToolkit; - -import javax.accessibility.AccessibleContext; -import javax.swing.*; -import javax.swing.plaf.UIResource; -import java.awt.*; -import java.awt.event.*; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.List; /** * @author Konstantin Bulenkov @@ -68,8 +70,7 @@ public class WindowsTitlePane extends CustomTitlePane { } @Override - public void componentRemoved(final ContainerEvent e) { - } + public void componentRemoved(final ContainerEvent e) {} }; private boolean oldResizable; private PropertyChangeListener propertyChangeListener; @@ -132,7 +133,6 @@ public class WindowsTitlePane extends CustomTitlePane { return createButton(accessibleName, icon, action, false); } - private static JButton createButton(final String accessibleName, final Icon icon, final Action action, final boolean close) { JButton button = new JButton() { @@ -171,10 +171,10 @@ public class WindowsTitlePane extends CustomTitlePane { @Override public Insets getWindowSizeAdjustment() { - //Compensate for the insets of the native window peer that include the decorations. + // Compensate for the insets of the native window peer that include the decorations. Insets insets = window != null && windowHandle != 0 - ? window.getInsets() - : new Insets(0, 0, 0, 0); + ? window.getInsets() + : new Insets(0, 0, 0, 0); insets.set(-insets.top, -insets.left, -insets.bottom, -insets.right); return insets; } @@ -284,7 +284,7 @@ public class WindowsTitlePane extends CustomTitlePane { protected void addMenuBar(final JMenuBar menuBar) { if (menuBar != null) { this.menuBar = menuBar; - //Otherwise, a white bar will appear where the menuBar used to be. + // Otherwise, a white bar will appear where the menuBar used to be. menuBar.setPreferredSize(new Dimension(0, 0)); menuBar.setOpaque(false); add(menuBar); @@ -299,21 +299,21 @@ public class WindowsTitlePane extends CustomTitlePane { private void determineColors() { switch (getDecorationStyle()) { - case JRootPane.ERROR_DIALOG: + case JRootPane.ERROR_DIALOG : activeBackground = UIManager.getColor("Windows.OptionPane.errorDialog.titlePane.background"); activeForeground = UIManager.getColor("Windows.OptionPane.errorDialog.titlePane.foreground"); break; - case JRootPane.QUESTION_DIALOG: - case JRootPane.COLOR_CHOOSER_DIALOG: - case JRootPane.FILE_CHOOSER_DIALOG: + case JRootPane.QUESTION_DIALOG : + case JRootPane.COLOR_CHOOSER_DIALOG : + case JRootPane.FILE_CHOOSER_DIALOG : activeBackground = UIManager.getColor("Windows.OptionPane.questionDialog.titlePane.background"); activeForeground = UIManager.getColor("Windows.OptionPane.questionDialog.titlePane.foreground"); break; - case JRootPane.WARNING_DIALOG: + case JRootPane.WARNING_DIALOG : activeBackground = UIManager.getColor("Windows.OptionPane.warningDialog.titlePane.background"); activeForeground = UIManager.getColor("Windows.OptionPane.warningDialog.titlePane.foreground"); break; - default: //JRootPane.Frame + default : // JRootPane.Frame activeBackground = UIManager.getColor("Windows.TitlePane.background"); activeForeground = UIManager.getColor("Windows.TitlePane.foreground"); break; @@ -335,16 +335,15 @@ public class WindowsTitlePane extends CustomTitlePane { windowIconButton.setComponentPopupMenu(createMenu()); windowIconButton.putClientProperty("JButton.variant", "onlyLabel"); windowIconButton.addActionListener(e -> windowIconButton - .getComponentPopupMenu() - .show(windowIconButton, - windowIconButton.getWidth() / 2, - windowIconButton.getHeight() / 2)); + .getComponentPopupMenu() + .show(windowIconButton, + windowIconButton.getWidth() / 2, + windowIconButton.getHeight() / 2)); windowIconButton.setFocusable(false); windowIconButton.setBorderPainted(false); return windowIconButton; } - private JPopupMenu createMenu() { JPopupMenu menu = new JPopupMenu(); if (getDecorationStyle() == JRootPane.FRAME) { @@ -354,21 +353,29 @@ public class WindowsTitlePane extends CustomTitlePane { } private void addMenuItems(final JPopupMenu menu) { - menu.add(new JMenuItem(restoreAction) {{ - setDisabledIcon(restoreIcon); - }}); - menu.add(new JMenuItem(minimizeAction) {{ - setDisabledIcon(minimizeIcon); - }}); + menu.add(new JMenuItem(restoreAction) { + { + setDisabledIcon(restoreIcon); + } + }); + menu.add(new JMenuItem(minimizeAction) { + { + setDisabledIcon(minimizeIcon); + } + }); if (Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH)) { - menu.add(new JMenuItem(maximizeAction) {{ - setDisabledIcon(maximizeIcon); - }}); + menu.add(new JMenuItem(maximizeAction) { + { + setDisabledIcon(maximizeIcon); + } + }); } menu.addSeparator(); - menu.add(new JMenuItem(closeAction) {{ - setDisabledIcon(closeIcon); - }}); + menu.add(new JMenuItem(closeAction) { + { + setDisabledIcon(closeIcon); + } + }); } private void close() { @@ -378,7 +385,6 @@ public class WindowsTitlePane extends CustomTitlePane { } } - private Window getWindow() { return window; } @@ -424,7 +430,6 @@ public class WindowsTitlePane extends CustomTitlePane { windowIconButton = createWindowIcon(); } - private LayoutManager createLayout() { return new TitlePaneLayout(); } @@ -564,9 +569,8 @@ public class WindowsTitlePane extends CustomTitlePane { } protected boolean isLeftToRight(final Window window) { - return (window == null) ? - getRootPane().getComponentOrientation().isLeftToRight() : - window.getComponentOrientation().isLeftToRight(); + return (window == null) ? getRootPane().getComponentOrientation().isLeftToRight() + : window.getComponentOrientation().isLeftToRight(); } private void updateSystemIcon() { @@ -587,7 +591,8 @@ public class WindowsTitlePane extends CustomTitlePane { Scale.scaleHeight(ICON_SIZE), Image.SCALE_AREA_AVERAGING)); } else { - systemIcon = new ScaledIcon(SunToolkit.getScaledIconImage(icons, Scale.scaleWidth(ICON_SIZE), + systemIcon = new ScaledIcon(SunToolkit.getScaledIconImage(icons, + Scale.scaleWidth(ICON_SIZE), Scale.scaleHeight(ICON_SIZE))); } if (windowIconButton != null) { @@ -608,7 +613,7 @@ public class WindowsTitlePane extends CustomTitlePane { private class MinimizeAction extends AbstractAction { public MinimizeAction() { - //UIManager.getString("Minimize", getLocale()) + // UIManager.getString("Minimize", getLocale()) super("Minimize", minimizeIcon); } @@ -664,11 +669,9 @@ public class WindowsTitlePane extends CustomTitlePane { } private class TitlePaneLayout implements LayoutManager { - public void addLayoutComponent(final String name, final Component c) { - } + public void addLayoutComponent(final String name, final Component c) {} - public void removeLayoutComponent(final Component c) { - } + public void removeLayoutComponent(final Component c) {} @Override public Dimension preferredLayoutSize(final Container parent) { @@ -690,7 +693,6 @@ public class WindowsTitlePane extends CustomTitlePane { minimizeButton.setBounds(Integer.MIN_VALUE, Integer.MIN_VALUE, 0, 0); maximizeToggleButton.setBounds(Integer.MIN_VALUE, Integer.MIN_VALUE, 0, 0); - int w = getWidth(); int x; int start = 0; @@ -700,9 +702,11 @@ public class WindowsTitlePane extends CustomTitlePane { int right = 0; if (windowIconButton.getIcon() != null) { - int windowButtonWidth = windowIconButton.getIcon() != null ? - Math.max(windowIconButton.getIcon().getIconHeight(), - windowIconButton.getIcon().getIconWidth()) : ICON_WIDTH; + int windowButtonWidth = windowIconButton.getIcon() != null ? Math.max(windowIconButton.getIcon() + .getIconHeight(), + windowIconButton.getIcon() + .getIconWidth()) + : ICON_WIDTH; windowButtonWidth = Math.min(ICON_WIDTH, windowButtonWidth); windowIconButton.setBounds(start + PAD / 2, y, windowButtonWidth, height); start += windowButtonWidth + PAD; @@ -811,5 +815,4 @@ public class WindowsTitlePane extends CustomTitlePane { setActive(false); } } - } diff --git a/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/windows_decorations.properties b/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/windows_decorations.properties index 7076cd7d..3adcd92e 100644 --- a/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/windows_decorations.properties +++ b/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/windows_decorations.properties @@ -21,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# Windows.TitlePane.minimize.icon = icons/window/minimize.svg[themed] Windows.TitlePane.minimizeInactive.icon = icons/window/minimizeInactive.svg[themed] Windows.TitlePane.maximize.icon = icons/window/maximize.svg[themed] diff --git a/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/windows_icons.properties b/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/windows_icons.properties index 0adfe263..03d16b65 100644 --- a/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/windows_icons.properties +++ b/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/windows_icons.properties @@ -1,4 +1,3 @@ -# suppress inspection "UnusedProperty" for whole file # # MIT License # @@ -22,6 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # +# Windows.Icons.windowClose.color = %windowButton Windows.Icons.windowCloseHover.color = %windowCloseHovered Windows.Icons.windowCloseInactive.color = %windowButtonDisabled