Browse Source

Autostyle setup and initial formatting.

pull/139/head
weisj 5 years ago
parent
commit
63e55f0f71
  1. 24
      .github/workflows/documentation.yml
  2. 24
      .github/workflows/gradle-wrapper-validation.yml
  3. 60
      .github/workflows/gradle.yml
  4. 102
      .github/workflows/libs.yml
  5. 1
      README.md
  6. 59
      build.gradle.kts
  7. 23
      core/build.gradle.kts
  8. 26
      core/gradle.properties
  9. 181
      core/pom.xml
  10. 30
      core/src/main/java/com/github/weisj/darklaf/DarkLaf.java
  11. 1
      core/src/main/java/com/github/weisj/darklaf/DarkLafInfo.java
  12. 58
      core/src/main/java/com/github/weisj/darklaf/LafManager.java
  13. 5
      core/src/main/java/com/github/weisj/darklaf/color/DarkColorModel.java
  14. 4
      core/src/main/java/com/github/weisj/darklaf/color/DarkColorModelCMYK.java
  15. 1
      core/src/main/java/com/github/weisj/darklaf/color/DarkColorModelHSB.java
  16. 17
      core/src/main/java/com/github/weisj/darklaf/color/DarkColorModelHSL.java
  17. 1
      core/src/main/java/com/github/weisj/darklaf/color/DarkColorModelRGB.java
  18. 24
      core/src/main/java/com/github/weisj/darklaf/components/ArrowButton.java
  19. 10
      core/src/main/java/com/github/weisj/darklaf/components/ClosableTabComponent.java
  20. 8
      core/src/main/java/com/github/weisj/darklaf/components/ClosableTabbedPane.java
  21. 42
      core/src/main/java/com/github/weisj/darklaf/components/ColorPipetteBase.java
  22. 89
      core/src/main/java/com/github/weisj/darklaf/components/ColoredRadioButton.java
  23. 1
      core/src/main/java/com/github/weisj/darklaf/components/DefaultButton.java
  24. 16
      core/src/main/java/com/github/weisj/darklaf/components/DefaultColorPipette.java
  25. 1
      core/src/main/java/com/github/weisj/darklaf/components/Disposable.java
  26. 11
      core/src/main/java/com/github/weisj/darklaf/components/JXPopupMenu.java
  27. 18
      core/src/main/java/com/github/weisj/darklaf/components/OverlayScrollPane.java
  28. 12
      core/src/main/java/com/github/weisj/darklaf/components/ScrollPopupMenu.java
  29. 1
      core/src/main/java/com/github/weisj/darklaf/components/SelectableTreeNode.java
  30. 1
      core/src/main/java/com/github/weisj/darklaf/components/TabEvent.java
  31. 1
      core/src/main/java/com/github/weisj/darklaf/components/TabListener.java
  32. 1
      core/src/main/java/com/github/weisj/darklaf/components/TabPropertyChangeEvent.java
  33. 51
      core/src/main/java/com/github/weisj/darklaf/components/VolumeSlider.java
  34. 1
      core/src/main/java/com/github/weisj/darklaf/components/alignment/AlignmentStrategy.java
  35. 115
      core/src/main/java/com/github/weisj/darklaf/components/border/BubbleBorder.java
  36. 4
      core/src/main/java/com/github/weisj/darklaf/components/border/DarkBorders.java
  37. 10
      core/src/main/java/com/github/weisj/darklaf/components/border/DarkLineBorder.java
  38. 103
      core/src/main/java/com/github/weisj/darklaf/components/border/DropShadowBorder.java
  39. 7
      core/src/main/java/com/github/weisj/darklaf/components/border/MutableLineBorder.java
  40. 36
      core/src/main/java/com/github/weisj/darklaf/components/color/PopupColorChooser.java
  41. 12
      core/src/main/java/com/github/weisj/darklaf/components/color/QuickColorChooser.java
  42. 20
      core/src/main/java/com/github/weisj/darklaf/components/color/SmallColorChooser.java
  43. 157
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/JTabFrame.java
  44. 12
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/PanelPopup.java
  45. 5
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/PopupContainer.java
  46. 4
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabArea.java
  47. 13
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameContent.java
  48. 147
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameContentPane.java
  49. 6
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFramePopup.java
  50. 4
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFramePopupUI.java
  51. 6
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTab.java
  52. 6
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabContainer.java
  53. 10
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabLabel.java
  54. 1
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabbedPopupUI.java
  55. 6
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameUI.java
  56. 10
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabbedPopup.java
  57. 14
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/ToggleSplitPane.java
  58. 1
      core/src/main/java/com/github/weisj/darklaf/components/text/IconListener.java
  59. 1
      core/src/main/java/com/github/weisj/darklaf/components/text/IndexListener.java
  60. 19
      core/src/main/java/com/github/weisj/darklaf/components/text/LineHighlighter.java
  61. 6
      core/src/main/java/com/github/weisj/darklaf/components/text/NonWrappingEditorPane.java
  62. 6
      core/src/main/java/com/github/weisj/darklaf/components/text/NonWrappingTextArea.java
  63. 6
      core/src/main/java/com/github/weisj/darklaf/components/text/NonWrappingTextPane.java
  64. 6
      core/src/main/java/com/github/weisj/darklaf/components/text/NumberedTextComponent.java
  65. 10
      core/src/main/java/com/github/weisj/darklaf/components/text/NumberingPane.java
  66. 1
      core/src/main/java/com/github/weisj/darklaf/components/text/SearchEvent.java
  67. 1
      core/src/main/java/com/github/weisj/darklaf/components/text/SearchListener.java
  68. 20
      core/src/main/java/com/github/weisj/darklaf/components/text/SearchTextField.java
  69. 37
      core/src/main/java/com/github/weisj/darklaf/components/text/SearchTextFieldWithHistory.java
  70. 22
      core/src/main/java/com/github/weisj/darklaf/components/text/TextFieldHistoryPopup.java
  71. 1
      core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipAware.java
  72. 113
      core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipContext.java
  73. 1
      core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipStyle.java
  74. 5
      core/src/main/java/com/github/weisj/darklaf/components/tooltip/TooltipAwareButton.java
  75. 5
      core/src/main/java/com/github/weisj/darklaf/components/tooltip/TooltipAwareToggleButton.java
  76. 6
      core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateButtonModel.java
  77. 11
      core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateCheckBox.java
  78. 10
      core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateCheckBoxMenuItem.java
  79. 1
      core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateState.java
  80. 10
      core/src/main/java/com/github/weisj/darklaf/components/uiresource/Insets2D.java
  81. 1
      core/src/main/java/com/github/weisj/darklaf/components/uiresource/JButtonUIResource.java
  82. 1
      core/src/main/java/com/github/weisj/darklaf/components/uiresource/JLabelUIResource.java
  83. 4
      core/src/main/java/com/github/weisj/darklaf/components/uiresource/JPanelUIResource.java
  84. 7
      core/src/main/java/com/github/weisj/darklaf/components/uiresource/UIResourceWrapper.java
  85. 10
      core/src/main/java/com/github/weisj/darklaf/decorators/AncestorAdapter.java
  86. 4
      core/src/main/java/com/github/weisj/darklaf/decorators/CellRenderer.java
  87. 12
      core/src/main/java/com/github/weisj/darklaf/decorators/ComponentResizeListener.java
  88. 5
      core/src/main/java/com/github/weisj/darklaf/decorators/HoverListener.java
  89. 2
      core/src/main/java/com/github/weisj/darklaf/decorators/LayoutManagerDelegate.java
  90. 13
      core/src/main/java/com/github/weisj/darklaf/decorators/MouseClickListener.java
  91. 10
      core/src/main/java/com/github/weisj/darklaf/decorators/MouseInputDelegate.java
  92. 4
      core/src/main/java/com/github/weisj/darklaf/decorators/MouseMovementListener.java
  93. 2
      core/src/main/java/com/github/weisj/darklaf/decorators/MouseResponder.java
  94. 4
      core/src/main/java/com/github/weisj/darklaf/decorators/PlainAction.java
  95. 1
      core/src/main/java/com/github/weisj/darklaf/decorators/PopupMenuAdapter.java
  96. 1
      core/src/main/java/com/github/weisj/darklaf/decorators/UpdateDocumentListener.java
  97. 6
      core/src/main/java/com/github/weisj/darklaf/log/LogFormatter.java
  98. 18
      core/src/main/java/com/github/weisj/darklaf/platform/DecorationsHandler.java
  99. 22
      core/src/main/java/com/github/weisj/darklaf/platform/DefaultDecorationsProvider.java
  100. 14
      core/src/main/java/com/github/weisj/darklaf/platform/DefaultThemePreferenceProvider.java
  101. Some files were not shown because too many files have changed in this diff Show More

24
.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 name: Documentation
on: on:
push: push:

24
.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" name: "Validate Gradle Wrapper"
on: [push, pull_request] on: [push, pull_request]

60
.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 name: CI
on: on:
@ -12,29 +36,29 @@ jobs:
name: Windows (Java 11) name: Windows (Java 11)
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
fetch-depth: 10 fetch-depth: 10
- name: Set up JDK 11 - name: Set up JDK 11
uses: actions/setup-java@v1 uses: actions/setup-java@v1
with: with:
java-version: 11 java-version: 11
- name: Build - name: Build
run: ./gradlew build run: ./gradlew build
linux: linux:
name: Linux (Java 8) name: Linux (Java 8)
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
fetch-depth: 10 fetch-depth: 10
- name: Set up JDK 8 - name: Set up JDK 8
uses: actions/setup-java@v1 uses: actions/setup-java@v1
with: with:
java-version: 8 java-version: 8
- name: Build - name: Build
run: ./gradlew build run: ./gradlew build
macos: macos:
name: macOS (Java 11) name: macOS (Java 11)

102
.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 name: Build Native Libraries
on: on:
push: push:
paths: paths:
- '**.cpp' - '**.cpp'
- '**.mm' - '**.mm'
pull_request: pull_request:
paths: paths:
- '**.cpp' - '**.cpp'
- '**.mm' - '**.mm'
release: release:
types: types:
- published - published
schedule: schedule:
- cron: '0 0 1 * *' - cron: '0 0 1 * *'
jobs: jobs:
@ -19,41 +43,41 @@ jobs:
name: Windows (Java 11) name: Windows (Java 11)
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
fetch-depth: 10 fetch-depth: 10
- name: Set up JDK 11 - name: Set up JDK 11
uses: actions/setup-java@v1 uses: actions/setup-java@v1
with: with:
java-version: 11 java-version: 11
- name: Build - name: Build
run: ./gradlew :darklaf-windows:build run: ./gradlew :darklaf-windows:build
- name: Upload x86 artifact - name: Upload x86 artifact
uses: actions/upload-artifact@v1 uses: actions/upload-artifact@v1
with: with:
name: darklaf-windows_x86.dll name: darklaf-windows_x86.dll
path: windows/build/lib/main/release/x86/darklaf-windows.dll path: windows/build/lib/main/release/x86/darklaf-windows.dll
- name: Upload x86-64 artifact - name: Upload x86-64 artifact
uses: actions/upload-artifact@v1 uses: actions/upload-artifact@v1
with: with:
name: darklaf-windows_x86-64.dll name: darklaf-windows_x86-64.dll
path: windows/build/lib/main/release/x86-64/darklaf-windows.dll path: windows/build/lib/main/release/x86-64/darklaf-windows.dll
macOS: macOS:
name: macOS (Java 11) name: macOS (Java 11)
runs-on: macos-latest runs-on: macos-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
fetch-depth: 10 fetch-depth: 10
- name: Set up JDK 11 - name: Set up JDK 11
uses: actions/setup-java@v1 uses: actions/setup-java@v1
with: with:
java-version: 11 java-version: 11
- name: Build - name: Build
run: ./gradlew :darklaf-macos:build run: ./gradlew :darklaf-macos:build
- name: Upload artifact - name: Upload artifact
uses: actions/upload-artifact@v1 uses: actions/upload-artifact@v1
with: with:
name: libdarklaf-macos.dylib name: libdarklaf-macos.dylib
path: macos/build/lib/main/release/stripped/libdarklaf-macos.dylib path: macos/build/lib/main/release/stripped/libdarklaf-macos.dylib

1
README.md

@ -123,4 +123,3 @@ Here is a list of things that currently are not finished or need refinement. Thi
# License # License
This project is licensed under the [MIT license](https://github.com/weisJ/darklaf/blob/master/LICENSE). This project is licensed under the [MIT license](https://github.com/weisJ/darklaf/blob/master/LICENSE).

59
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.CrLfSpec
import com.github.vlsi.gradle.crlf.LineEndings import com.github.vlsi.gradle.crlf.LineEndings
import com.github.vlsi.gradle.properties.dsl.props 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 import com.github.vlsi.gradle.publishing.dsl.versionFromResolution
plugins { plugins {
id("com.github.autostyle")
id("com.github.vlsi.crlf") id("com.github.vlsi.crlf")
id("com.github.vlsi.gradle-extensions") id("com.github.vlsi.gradle-extensions")
id("com.github.vlsi.stage-vote-release") id("com.github.vlsi.stage-vote-release")
@ -13,6 +16,7 @@ plugins {
val skipJavadoc by props() val skipJavadoc by props()
val enableMavenLocal by props() val enableMavenLocal by props()
val enableGradleMetadata by props() val enableGradleMetadata by props()
val skipAutostyle by props()
val String.v: String get() = rootProject.extra["$this.version"] as String 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 { allprojects {
group = "com.github.weisj" group = "com.github.weisj"
version = buildVersion version = buildVersion
@ -51,6 +67,34 @@ allprojects {
mavenCentral() 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<AbstractArchiveTask>().configureEach { tasks.withType<AbstractArchiveTask>().configureEach {
// Ensure builds are reproducible // Ensure builds are reproducible
isPreserveFileTimestamps = false 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") apply(plugin = "maven-publish")
val generatePomFile by props() val generatePomFile by props()
@ -173,7 +230,7 @@ allprojects {
configure<PublishingExtension> { configure<PublishingExtension> {
if (project.path.startsWith(":darklaf-dependencies-bom") || if (project.path.startsWith(":darklaf-dependencies-bom") ||
project.path == ":") { project.path == ":") {
// We don't it to Central for now // We don't it to Central for now
return@configure return@configure
} }

23
core/build.gradle.kts

@ -1,6 +1,3 @@
import com.github.vlsi.gradle.crlf.CrLfSpec
import com.github.vlsi.gradle.crlf.LineEndings
plugins { plugins {
`java-library` `java-library`
id("com.github.johnrengelman.shadow") id("com.github.johnrengelman.shadow")
@ -23,18 +20,6 @@ dependencies {
testImplementation("org.swinglabs:swingx") 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) { val makeDocumentation by tasks.registering(JavaExec::class) {
group = "Development" group = "Development"
description = "Builds the documentation" description = "Builds the documentation"
@ -66,10 +51,13 @@ tasks.shadowJar {
abstract class DemoTask : JavaExec() { abstract class DemoTask : JavaExec() {
init { 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) 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 val value = System.getProperty(name) ?: default
value?.let { systemProperty(name, it) } value?.let { systemProperty(name, it) }
} }
val props = System.getProperties() val props = System.getProperties()
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
for (e in props.propertyNames() as `java.util`.Enumeration<String>) { for (e in props.propertyNames() as `java.util`.Enumeration<String>) {

26
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

181
core/pom.xml

@ -1,81 +1,106 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" <!--
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> ~ MIT License
<modelVersion>4.0.0</modelVersion> ~
<groupId>com.github.weisj</groupId> ~ Copyright (c) 2020 Jannis Weis
<artifactId>darklaf-core</artifactId> ~
<version>1.4.3.1</version> ~ Permission is hereby granted, free of charge, to any person obtaining a copy
<name>Darklaf core</name> ~ of this software and associated documentation files (the "Software"), to deal
<description>A themeable Look and Feel for java swing</description> ~ in the Software without restriction, including without limitation the rights
<url>https://github.com/weisJ/darklaf</url> ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
<organization> ~ copies of the Software, and to permit persons to whom the Software is
<name>com.github.weisj</name> ~ furnished to do so, subject to the following conditions:
<url>https://github.com/weisj</url> ~
</organization> ~ The above copyright notice and this permission notice shall be included in all
<licenses> ~ copies or substantial portions of the Software.
<license> ~
<name>MIT</name> ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
<url>https://github.com/weisJ/darklaf/blob/master/LICENSE</url> ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
<distribution>repo</distribution> ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
</license> ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
</licenses> ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
<developers> ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
<developer> ~ SOFTWARE.
<name>Jannis Weis</name> ~
</developer> -->
</developers> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
<scm> xmlns="http://maven.apache.org/POM/4.0.0"
<connection>scm:git:git://github.com/weisJ/darklaf.git</connection> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<developerConnection>scm:git:ssh://git@github.com:weisj/darklaf.git</developerConnection> <modelVersion>4.0.0</modelVersion>
<groupId>com.github.weisj</groupId>
<artifactId>darklaf-core</artifactId>
<version>1.4.3.1</version>
<name>Darklaf core</name>
<description>A themeable Look and Feel for java swing</description>
<url>https://github.com/weisJ/darklaf</url> <url>https://github.com/weisJ/darklaf</url>
</scm> <organization>
<issueManagement> <name>com.github.weisj</name>
<system>GitHub</system> <url>https://github.com/weisj</url>
<url>https://github.com/weisJ/darklaf/issues</url> </organization>
</issueManagement> <licenses>
<license>
<dependencies> <name>MIT</name>
<dependency> <url>https://github.com/weisJ/darklaf/blob/master/LICENSE</url>
<groupId>com.github.weisj</groupId> <distribution>repo</distribution>
<artifactId>darklaf-native-utils</artifactId> </license>
<version>1.4.3.1</version> </licenses>
<scope>runtime</scope> <developers>
</dependency> <developer>
<dependency> <name>Jannis Weis</name>
<groupId>com.github.weisj</groupId> </developer>
<artifactId>darklaf-utils</artifactId> </developers>
<version>1.4.3.1</version> <scm>
<scope>runtime</scope> <connection>scm:git:git://github.com/weisJ/darklaf.git</connection>
</dependency> <developerConnection>scm:git:ssh://git@github.com:weisj/darklaf.git</developerConnection>
<dependency> <url>https://github.com/weisJ/darklaf</url>
<groupId>com.github.weisj</groupId> </scm>
<artifactId>darklaf-decorations-base</artifactId> <issueManagement>
<version>1.4.3.1</version> <system>GitHub</system>
<scope>runtime</scope> <url>https://github.com/weisJ/darklaf/issues</url>
</dependency> </issueManagement>
<dependency>
<groupId>com.github.weisj</groupId> <dependencies>
<artifactId>darklaf-windows</artifactId> <dependency>
<version>1.4.3.1</version> <groupId>com.github.weisj</groupId>
<scope>runtime</scope> <artifactId>darklaf-native-utils</artifactId>
</dependency> <version>1.4.3.1</version>
<dependency> <scope>runtime</scope>
<groupId>com.github.weisj</groupId> </dependency>
<artifactId>darklaf-macos</artifactId> <dependency>
<version>1.4.3.1</version> <groupId>com.github.weisj</groupId>
<scope>runtime</scope> <artifactId>darklaf-utils</artifactId>
</dependency> <version>1.4.3.1</version>
<dependency> <scope>runtime</scope>
<groupId>com.github.weisj</groupId> </dependency>
<artifactId>darklaf-property-loader</artifactId> <dependency>
<version>1.4.3.1</version> <groupId>com.github.weisj</groupId>
<scope>runtime</scope> <artifactId>darklaf-decorations-base</artifactId>
</dependency> <version>1.4.3.1</version>
<dependency> <scope>runtime</scope>
<groupId>org.swinglabs</groupId> </dependency>
<artifactId>jxlayer</artifactId> <dependency>
<version>3.0.4</version> <groupId>com.github.weisj</groupId>
<scope>runtime</scope> <artifactId>darklaf-windows</artifactId>
</dependency> <version>1.4.3.1</version>
</dependencies> <scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.github.weisj</groupId>
<artifactId>darklaf-macos</artifactId>
<version>1.4.3.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.github.weisj</groupId>
<artifactId>darklaf-property-loader</artifactId>
<version>1.4.3.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.swinglabs</groupId>
<artifactId>jxlayer</artifactId>
<version>3.0.4</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</project> </project>

30
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf; 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.platform.DecorationsHandler;
import com.github.weisj.darklaf.task.*; import com.github.weisj.darklaf.task.*;
import com.github.weisj.darklaf.theme.Theme; 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.ui.popupmenu.DarkPopupMenuUI;
import com.github.weisj.darklaf.util.SystemInfo; 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 * @author Jannis Weis
*/ */
@ -48,13 +50,13 @@ public class DarkLaf extends BasicLookAndFeel {
* All tasks for initializing the ui defaults in order of execution. * All tasks for initializing the ui defaults in order of execution.
*/ */
private static final DefaultsInitTask[] INIT_TASKS = new DefaultsInitTask[]{ private static final DefaultsInitTask[] INIT_TASKS = new DefaultsInitTask[]{
new ThemeDefaultsInitTask(), new ThemeDefaultsInitTask(),
new InputDefaultsInitTask(), new InputDefaultsInitTask(),
new IdeaDefaultsInitTask(), new IdeaDefaultsInitTask(),
new FontDefaultsInitTask(), new FontDefaultsInitTask(),
new UtilityDefaultsInitTask(), new UtilityDefaultsInitTask(),
new SystemDefaultsInitTask(), new SystemDefaultsInitTask(),
new PlatformDefaultsInitTask() new PlatformDefaultsInitTask()
}; };
/* /*
* The base look and feel. This may vary to handle different platform support. * The base look and feel. This may vary to handle different platform support.
@ -143,13 +145,11 @@ public class DarkLaf extends BasicLookAndFeel {
return "Darklaf"; return "Darklaf";
} }
@Override @Override
public String getID() { public String getID() {
return getName(); return getName();
} }
@Override @Override
public String getDescription() { public String getDescription() {
return "Dark Look and feel based on Darcula-LAF"; return "Dark Look and feel based on Darcula-LAF";

1
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf; package com.github.weisj.darklaf;

58
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf; 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.DecorationsHandler;
import com.github.weisj.darklaf.platform.ThemePreferencesHandler; import com.github.weisj.darklaf.platform.ThemePreferencesHandler;
import com.github.weisj.darklaf.task.DefaultsAdjustmentTask; 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.PreferredThemeStyle;
import com.github.weisj.darklaf.theme.info.ThemeProvider; 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. * Manager for the Look and Feel.
* *
@ -78,8 +80,7 @@ public final class LafManager {
LogManager.getLogManager().reset(); LogManager.getLogManager().reset();
} else { } else {
try (InputStream inputStream = DarkLaf.class.getClassLoader() try (InputStream inputStream = DarkLaf.class.getClassLoader()
.getResourceAsStream( .getResourceAsStream("com/github/weisj/darklaf/log/logging.properties")) {
"com/github/weisj/darklaf/log/logging.properties")) {
if (inputStream != null) { if (inputStream != null) {
Logger.getGlobal().fine("Loading logging configuration."); Logger.getGlobal().fine("Loading logging configuration.");
LogManager.getLogManager().readConfiguration(inputStream); LogManager.getLogManager().readConfiguration(inputStream);
@ -143,9 +144,9 @@ public final class LafManager {
* if preferences have changed. * if preferences have changed.
* *
* @param listener the listener to add. * @param listener the listener to add.
* @see ThemePreferenceListener * @see ThemePreferenceListener
* @see #enabledPreferenceChangeReporting(boolean) * @see #enabledPreferenceChangeReporting(boolean)
* @see #isPreferenceChangeReportingEnabled() * @see #isPreferenceChangeReportingEnabled()
*/ */
public static void addThemePreferenceChangeListener(final ThemePreferenceListener listener) { public static void addThemePreferenceChangeListener(final ThemePreferenceListener listener) {
ThemePreferencesHandler.getSharedInstance().addThemePreferenceChangeListener(listener); ThemePreferencesHandler.getSharedInstance().addThemePreferenceChangeListener(listener);
@ -155,9 +156,9 @@ public final class LafManager {
* Removes a {@link ThemePreferenceListener}. * Removes a {@link ThemePreferenceListener}.
* *
* @param listener the listener to add. * @param listener the listener to add.
* @see ThemePreferenceListener * @see ThemePreferenceListener
* @see #enabledPreferenceChangeReporting(boolean) * @see #enabledPreferenceChangeReporting(boolean)
* @see #isPreferenceChangeReportingEnabled() * @see #isPreferenceChangeReportingEnabled()
*/ */
public static void removeThemePreferenceChangeListener(final ThemePreferenceListener listener) { public static void removeThemePreferenceChangeListener(final ThemePreferenceListener listener) {
ThemePreferencesHandler.getSharedInstance().removeThemePreferenceChangeListener(listener); ThemePreferencesHandler.getSharedInstance().removeThemePreferenceChangeListener(listener);
@ -168,8 +169,8 @@ public final class LafManager {
* to determine these values. * to determine these values.
* *
* @return the preferred theme style. * @return the preferred theme style.
* @see #isPreferenceChangeReportingEnabled() * @see #isPreferenceChangeReportingEnabled()
* @see #enabledPreferenceChangeReporting(boolean) * @see #enabledPreferenceChangeReporting(boolean)
*/ */
public static PreferredThemeStyle getPreferredThemeStyle() { public static PreferredThemeStyle getPreferredThemeStyle() {
return ThemePreferencesHandler.getSharedInstance().getPreferredThemeStyle(); return ThemePreferencesHandler.getSharedInstance().getPreferredThemeStyle();
@ -180,7 +181,7 @@ public final class LafManager {
* preferred theme style. * preferred theme style.
* *
* @return the theme provider. * @return the theme provider.
* @see PreferredThemeStyle * @see PreferredThemeStyle
*/ */
public static ThemeProvider getThemeProvider() { public static ThemeProvider getThemeProvider() {
if (themeProvider == null) themeProvider = createDefaultThemeProvider(); if (themeProvider == null) themeProvider = createDefaultThemeProvider();
@ -192,7 +193,7 @@ public final class LafManager {
* preferred theme style. * preferred theme style.
* *
* @param themeProvider the theme provider. * @param themeProvider the theme provider.
* @see PreferredThemeStyle * @see PreferredThemeStyle
*/ */
public static void setThemeProvider(final ThemeProvider themeProvider) { public static void setThemeProvider(final ThemeProvider themeProvider) {
LafManager.themeProvider = themeProvider; LafManager.themeProvider = themeProvider;
@ -208,8 +209,8 @@ public final class LafManager {
/** /**
* Get the associated theme for the given preferred style. * Get the associated theme for the given preferred style.
* *
* @param style the preferred theme style. * @param style the preferred theme style.
* @return the associated Theme or best match if there is none associated. * @return the associated Theme or best match if there is none associated.
*/ */
public static Theme themeForPreferredStyle(final PreferredThemeStyle style) { public static Theme themeForPreferredStyle(final PreferredThemeStyle style) {
return getThemeProvider().getTheme(style); return getThemeProvider().getTheme(style);
@ -310,7 +311,6 @@ public final class LafManager {
setTheme(themeForPreferredStyle(preferredThemeStyle)); setTheme(themeForPreferredStyle(preferredThemeStyle));
} }
/** /**
* Sets the current theme and installs the LaF. If the LaF is already installed the theme is switched. This behaves * 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()} * exactly like {@link #setTheme(Theme)} followed by {@link #install()}
@ -334,7 +334,7 @@ public final class LafManager {
* Overload for {@link #installTheme(Theme)}. * Overload for {@link #installTheme(Theme)}.
* *
* @param theme the theme to install. * @param theme the theme to install.
* @see #installTheme(Theme) installTheme(). * @see #installTheme(Theme) installTheme().
*/ */
public static void install(final Theme theme) { public static void install(final Theme theme) {
installTheme(theme); installTheme(theme);
@ -350,9 +350,9 @@ public final class LafManager {
UIManager.setLookAndFeel(DarkLaf.class.getCanonicalName()); UIManager.setLookAndFeel(DarkLaf.class.getCanonicalName());
updateLaf(); updateLaf();
} catch (final ClassNotFoundException } catch (final ClassNotFoundException
| InstantiationException | InstantiationException
| IllegalAccessException | IllegalAccessException
| UnsupportedLookAndFeelException e) { | UnsupportedLookAndFeelException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }

5
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.color; package com.github.weisj.darklaf.color;
import javax.swing.*;
import java.awt.*; import java.awt.*;
import javax.swing.*;
/** /**
* @author Jannis Weis * @author Jannis Weis
*/ */
@ -34,7 +36,6 @@ public abstract class DarkColorModel {
private final String prefix; private final String prefix;
private final String[] labels; private final String[] labels;
public DarkColorModel(final String name, final String... labels) { public DarkColorModel(final String name, final String... labels) {
this.prefix = "ColorChooser." + name; this.prefix = "ColorChooser." + name;
this.labels = labels; this.labels = labels;

4
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.color; package com.github.weisj.darklaf.color;
@ -74,7 +75,6 @@ public class DarkColorModelCMYK extends DarkColorModel {
return RGBtoCMYK(color.getRed(), color.getGreen(), color.getBlue()); return RGBtoCMYK(color.getRed(), color.getGreen(), color.getBlue());
} }
private static int[] RGBtoCMYK(final int r, final int g, final int b) { 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); double max = DarkColorModelHSL.max(r / 255.0, g / 255.0, b / 255.0);
if (max > 0.0f) { if (max > 0.0f) {
@ -96,12 +96,10 @@ public class DarkColorModelCMYK extends DarkColorModel {
return new Color(rgb[0], rgb[1], rgb[2]); 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) { 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[0] = (int) Math.round(255 * (1 - c) * (1 - k));
rgb[1] = (int) Math.round(255 * (1 - m) * (1 - k)); rgb[1] = (int) Math.round(255 * (1 - m) * (1 - k));
rgb[2] = (int) Math.round(255 * (1 - y) * (1 - k)); rgb[2] = (int) Math.round(255 * (1 - y) * (1 - k));
return rgb; return rgb;
} }
} }

1
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.color; package com.github.weisj.darklaf.color;

17
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.color; package com.github.weisj.darklaf.color;
@ -87,13 +88,13 @@ public class DarkColorModelHSL extends DarkColorModel {
double saturation = (max - min); double saturation = (max - min);
if (saturation > 0.0f) { if (saturation > 0.0f) {
saturation /= (summa > 1.0f) saturation /= (summa > 1.0f)
? 2.0f - summa ? 2.0f - summa
: summa; : summa;
} }
return new double[]{ return new double[]{
getHue(r / 255.0, g / 255.0, b / 255.0, max, min), getHue(r / 255.0, g / 255.0, b / 255.0, max, min),
saturation, saturation,
summa / 2.0 summa / 2.0
}; };
} }
@ -115,7 +116,6 @@ public class DarkColorModelHSL extends DarkColorModel {
return Math.min(min, blue); return Math.min(min, blue);
} }
private static double getHue(final double red, final double green, final double blue, private static double getHue(final double red, final double green, final double blue,
final double max, final double min) { final double max, final double min) {
double hue = max - min; double hue = max - min;
@ -127,7 +127,7 @@ public class DarkColorModelHSL extends DarkColorModel {
} }
} else if (max == green) { } else if (max == green) {
hue = 2.0f + (blue - red) / hue; hue = 2.0f + (blue - red) / hue;
} else /*max == blue*/ { } else /* max == blue */ {
hue = 4.0f + (red - green) / hue; hue = 4.0f + (red - green) / hue;
} }
hue /= 6.0f; 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) { private static int[] HSLtoRGB(final double h, final double saturation, final double lightness) {
double hue = h; double hue = h;
while (hue < 0) hue += 1; while (hue < 0)
hue += 1;
hue = hue - Math.floor(hue); hue = hue - Math.floor(hue);
if (saturation > 0.0f) { if (saturation > 0.0f) {
hue = (hue < 1.0f) ? hue * 6.0f : 0.0f; hue = (hue < 1.0f) ? hue * 6.0f : 0.0f;

1
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.color; package com.github.weisj.darklaf.color;

24
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components; package com.github.weisj.darklaf.components;
import com.github.weisj.darklaf.icons.UIAwareIcon; import java.awt.*;
import com.github.weisj.darklaf.ui.button.DarkButtonUI;
import javax.swing.*; import javax.swing.*;
import javax.swing.plaf.DimensionUIResource; import javax.swing.plaf.DimensionUIResource;
import javax.swing.plaf.basic.BasicArrowButton; 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 * @author Jannis Weis
*/ */
public final class ArrowButton implements SwingConstants { public final class ArrowButton implements SwingConstants {
private ArrowButton() {}
private ArrowButton() {
}
public static JButton createUpDownArrow(final JComponent parent, final int orientation, public static JButton createUpDownArrow(final JComponent parent, final int orientation,
final boolean center) { final boolean center) {
@ -47,25 +46,23 @@ public final class ArrowButton implements SwingConstants {
new Insets(0, 0, 0, 0)); new Insets(0, 0, 0, 0));
} }
public static JButton createUpDownArrow(final JComponent parent, final int orientation, public static JButton createUpDownArrow(final JComponent parent, final int orientation,
final boolean center, final boolean applyInsetsOnSize, final boolean center, final boolean applyInsetsOnSize,
final Insets insets) { final Insets insets) {
UIAwareIcon icon; UIAwareIcon icon;
switch (orientation) { switch (orientation) {
case NORTH: case NORTH :
icon = (UIAwareIcon) UIManager.getIcon("ArrowButton.up.icon"); icon = (UIAwareIcon) UIManager.getIcon("ArrowButton.up.icon");
break; break;
case SOUTH: case SOUTH :
icon = (UIAwareIcon) UIManager.getIcon("ArrowButton.down.icon"); icon = (UIAwareIcon) UIManager.getIcon("ArrowButton.down.icon");
break; break;
default: default :
throw new IllegalStateException("Invalid button orientation: " + orientation); throw new IllegalStateException("Invalid button orientation: " + orientation);
} }
return createUpDownArrow(parent, icon, icon.getDual(), orientation, center, applyInsetsOnSize, insets); return createUpDownArrow(parent, icon, icon.getDual(), orientation, center, applyInsetsOnSize, insets);
} }
public static JButton createUpDownArrow(final JComponent parent, public static JButton createUpDownArrow(final JComponent parent,
final Icon activeIcon, final Icon inactiveIcon, final Icon activeIcon, final Icon inactiveIcon,
final int orientation, final boolean center, final int orientation, final boolean center,
@ -105,13 +102,11 @@ public final class ArrowButton implements SwingConstants {
getIcon().paintIcon(this, g, x, y); getIcon().paintIcon(this, g, x, y);
} }
@Override @Override
public Insets getInsets() { public Insets getInsets() {
return getInsets(new Insets(0, 0, 0, 0)); return getInsets(new Insets(0, 0, 0, 0));
} }
@Override @Override
public Insets getInsets(final Insets i) { public Insets getInsets(final Insets i) {
i.left = insets.left; i.left = insets.left;
@ -121,7 +116,6 @@ public final class ArrowButton implements SwingConstants {
return i; return i;
} }
@Override @Override
public boolean isOpaque() { public boolean isOpaque() {
return false; return false;

10
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components; package com.github.weisj.darklaf.components;
import com.github.weisj.darklaf.ui.button.DarkButtonUI; import java.awt.*;
import com.github.weisj.darklaf.ui.tabbedpane.DarkTabbedPaneUI; import java.awt.event.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.plaf.ComponentUI; 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 * @author Jannis Weis

8
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components; package com.github.weisj.darklaf.components;
import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.beans.PropertyVetoException; import java.beans.PropertyVetoException;
import java.beans.VetoableChangeListener; import java.beans.VetoableChangeListener;
import javax.swing.*;
/** /**
* @author Jannis Weis * @author Jannis Weis
*/ */
@ -86,12 +88,12 @@ public class ClosableTabbedPane extends JTabbedPane {
private void notifyTabListeners(final TabEvent event) { private void notifyTabListeners(final TabEvent event) {
TabListener[] listeners = listenerList.getListeners(TabListener.class); TabListener[] listeners = listenerList.getListeners(TabListener.class);
switch (event.getID()) { switch (event.getID()) {
case TabEvent.TAB_CLOSED: case TabEvent.TAB_CLOSED :
for (TabListener l : listeners) { for (TabListener l : listeners) {
l.tabClosed(event); l.tabClosed(event);
} }
break; break;
case TabEvent.TAB_OPENED: case TabEvent.TAB_OPENED :
for (TabListener l : listeners) { for (TabListener l : listeners) {
l.tabOpened(event); l.tabOpened(event);
} }

42
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components; 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.ColorListener;
import com.github.weisj.darklaf.ui.colorchooser.ColorPipette; import com.github.weisj.darklaf.ui.colorchooser.ColorPipette;
import com.github.weisj.darklaf.ui.rootpane.DarkRootPaneUI; import com.github.weisj.darklaf.ui.rootpane.DarkRootPaneUI;
import com.github.weisj.darklaf.util.DarkUIUtil; 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 { public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener {
protected final JComponent parent; protected final JComponent parent;
protected final Robot robot; protected final Robot robot;
@ -55,7 +55,6 @@ public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener
robot = createRobot(); robot = createRobot();
} }
private static Robot createRobot() { private static Robot createRobot() {
try { try {
return new Robot(); return new Robot();
@ -80,7 +79,6 @@ public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener
return robot.getPixelColor(location.x, location.y); return robot.getPixelColor(location.x, location.y);
} }
protected Color getInitialColor() { protected Color getInitialColor() {
return initialColor; return initialColor;
} }
@ -91,7 +89,6 @@ public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener
setColor(initialColor); setColor(initialColor);
} }
@Override @Override
public Color getColor() { public Color getColor() {
return currentColor; return currentColor;
@ -106,8 +103,8 @@ public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener
Window picker = getOrCreatePickerWindow(); Window picker = getOrCreatePickerWindow();
Toolkit.getDefaultToolkit().addAWTEventListener(this, Toolkit.getDefaultToolkit().addAWTEventListener(this,
AWTEvent.MOUSE_MOTION_EVENT_MASK AWTEvent.MOUSE_MOTION_EVENT_MASK
| AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK
| AWTEvent.KEY_EVENT_MASK); | AWTEvent.KEY_EVENT_MASK);
updateLocation(); updateLocation();
picker.setVisible(true); picker.setVisible(true);
return picker; return picker;
@ -138,7 +135,6 @@ public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener
Toolkit.getDefaultToolkit().removeAWTEventListener(this); Toolkit.getDefaultToolkit().removeAWTEventListener(this);
} }
protected Window getOrCreatePickerWindow() { protected Window getOrCreatePickerWindow() {
if (pickerWindow == null) { if (pickerWindow == null) {
Window owner = SwingUtilities.getWindowAncestor(parent); Window owner = SwingUtilities.getWindowAncestor(parent);
@ -152,7 +148,6 @@ public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener
return pickerWindow; return pickerWindow;
} }
protected Point updateLocation() { protected Point updateLocation() {
PointerInfo pointerInfo = MouseInfo.getPointerInfo(); PointerInfo pointerInfo = MouseInfo.getPointerInfo();
if (pointerInfo == null) return null; if (pointerInfo == null) return null;
@ -169,7 +164,6 @@ public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener
return new PickerWindow(); return new PickerWindow();
} }
protected Window getPickerWindow() { protected Window getPickerWindow() {
return pickerWindow; return pickerWindow;
} }
@ -183,23 +177,23 @@ public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener
public void eventDispatched(final AWTEvent event) { public void eventDispatched(final AWTEvent event) {
if (pickerWindow == null || !pickerWindow.isVisible()) return; if (pickerWindow == null || !pickerWindow.isVisible()) return;
switch (event.getID()) { switch (event.getID()) {
case MouseEvent.MOUSE_PRESSED: case MouseEvent.MOUSE_PRESSED :
((MouseEvent) event).consume(); ((MouseEvent) event).consume();
pickAndClose(); pickAndClose();
break; break;
case MouseEvent.MOUSE_CLICKED: case MouseEvent.MOUSE_CLICKED :
((MouseEvent) event).consume(); ((MouseEvent) event).consume();
break; break;
case KeyEvent.KEY_PRESSED: case KeyEvent.KEY_PRESSED :
downKeyCode = ((KeyEvent) event).getKeyCode(); downKeyCode = ((KeyEvent) event).getKeyCode();
switch (downKeyCode) { switch (downKeyCode) {
case KeyEvent.VK_ESCAPE: case KeyEvent.VK_ESCAPE :
cancelPipette(); cancelPipette();
break; break;
case KeyEvent.VK_ENTER: case KeyEvent.VK_ENTER :
pickAndClose(); pickAndClose();
break; break;
default: default :
break; break;
} }
if (!keyDown) { if (!keyDown) {
@ -207,14 +201,14 @@ public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener
updatePipette(true); updatePipette(true);
} }
break; break;
case KeyEvent.KEY_RELEASED: case KeyEvent.KEY_RELEASED :
keyDown = false; keyDown = false;
Window picker = getPickerWindow(); Window picker = getPickerWindow();
if (picker != null) { if (picker != null) {
picker.repaint(); picker.repaint();
} }
break; break;
default: default :
break; break;
} }
} }

89
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components; 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.DarkLaf;
import com.github.weisj.darklaf.LafManager; import com.github.weisj.darklaf.LafManager;
import com.github.weisj.darklaf.PropertyLoader; 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.theme.Theme;
import com.github.weisj.darklaf.ui.togglebutton.radiobutton.DarkRadioButtonUI; 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 class ColoredRadioButton extends JRadioButton {
public static final Color DEFAULT_FILLED = new Color(0); public static final Color DEFAULT_FILLED = new Color(0);
@ -73,35 +75,35 @@ public class ColoredRadioButton extends JRadioButton {
protected static class ColoredRadioButtonUI extends DarkRadioButtonUI { protected static class ColoredRadioButtonUI extends DarkRadioButtonUI {
private static final String[] PROPERTIES = { private static final String[] PROPERTIES = {
"Icons.RadioButton.activeFillColor", "Icons.RadioButton.activeFillColor",
"Icons.RadioButton.activeBorderColor", "Icons.RadioButton.activeBorderColor",
"Icons.RadioButtonDisabled.inactiveFillColor", "Icons.RadioButtonDisabled.inactiveFillColor",
"Icons.RadioButtonDisabled.inactiveBorderColor", "Icons.RadioButtonDisabled.inactiveBorderColor",
"Icons.RadioButtonFocused.activeFillColor", "Icons.RadioButtonFocused.activeFillColor",
"Icons.RadioButtonFocused.focusBorderColor", "Icons.RadioButtonFocused.focusBorderColor",
"Icons.RadioButtonFocused.glowFocus", "Icons.RadioButtonFocused.glowFocus",
"Icons.RadioButtonFocused.glowOpacity", "Icons.RadioButtonFocused.glowOpacity",
"Icons.RadioButtonSelected.selectedFillColor", "Icons.RadioButtonSelected.selectedFillColor",
"Icons.RadioButtonSelected.selectedBorderColor", "Icons.RadioButtonSelected.selectedBorderColor",
"Icons.RadioButtonSelected.selectionSelectedColor", "Icons.RadioButtonSelected.selectionSelectedColor",
"Icons.RadioButtonSelectedDisabled.inactiveFillColor", "Icons.RadioButtonSelectedDisabled.inactiveFillColor",
"Icons.RadioButtonSelectedDisabled.inactiveBorderColor", "Icons.RadioButtonSelectedDisabled.inactiveBorderColor",
"Icons.RadioButtonSelectedDisabled.selectionDisabledColor", "Icons.RadioButtonSelectedDisabled.selectionDisabledColor",
"Icons.RadioButtonSelectedFocused.selectedFillColor", "Icons.RadioButtonSelectedFocused.selectedFillColor",
"Icons.RadioButtonSelectedFocused.focusSelectedBorderColor", "Icons.RadioButtonSelectedFocused.focusSelectedBorderColor",
"Icons.RadioButtonSelectedFocused.selectionFocusSelectedColor", "Icons.RadioButtonSelectedFocused.selectionFocusSelectedColor",
"Icons.RadioButtonSelectedFocused.glowFocus", "Icons.RadioButtonSelectedFocused.glowFocus",
"Icons.RadioButtonSelectedFocused.glowOpacity" "Icons.RadioButtonSelectedFocused.glowOpacity"
}; };
private static final String[] COLOR_PROPERTIES = { private static final String[] COLOR_PROPERTIES = {
"Icons.RadioButton.activeFillColor", "Icons.RadioButton.activeFillColor",
"Icons.RadioButton.activeBorderColor", "Icons.RadioButton.activeBorderColor",
"Icons.RadioButtonFocused.activeFillColor", "Icons.RadioButtonFocused.activeFillColor",
"Icons.RadioButtonFocused.focusBorderColor", "Icons.RadioButtonFocused.focusBorderColor",
"Icons.RadioButtonSelected.selectedFillColor", "Icons.RadioButtonSelected.selectedFillColor",
"Icons.RadioButtonSelected.selectedBorderColor", "Icons.RadioButtonSelected.selectedBorderColor",
"Icons.RadioButtonSelectedFocused.selectedFillColor", "Icons.RadioButtonSelectedFocused.selectedFillColor",
"Icons.RadioButtonSelectedFocused.focusSelectedBorderColor" "Icons.RadioButtonSelectedFocused.focusSelectedBorderColor"
}; };
private Properties propertyMap; private Properties propertyMap;
@ -129,12 +131,11 @@ public class ColoredRadioButton extends JRadioButton {
theme.loadDefaults(props, defaults); theme.loadDefaults(props, defaults);
Color c = color == DEFAULT_FILLED ? (Color) props.get("widgetFillDefault") : color; Color c = color == DEFAULT_FILLED ? (Color) props.get("widgetFillDefault") : color;
adjustment.applyColors(LafManager.getTheme(), props, c, null); adjustment.applyColors(LafManager.getTheme(), props, c, null);
PropertyLoader.putProperties( PropertyLoader.putProperties(PropertyLoader.loadProperties(DarkLaf.class, "radioButton", "properties/ui/"),
PropertyLoader.loadProperties(DarkLaf.class, "radioButton", "properties/ui/"), props, defaults);
props, defaults); PropertyLoader.putProperties(PropertyLoader.loadProperties(DarkLaf.class, "radioButton",
PropertyLoader.putProperties( "properties/icons/"),
PropertyLoader.loadProperties(DarkLaf.class, "radioButton", "properties/icons/"), props, defaults);
props, defaults);
propertyMap = new Properties(); propertyMap = new Properties();
for (String prop : PROPERTIES) { for (String prop : PROPERTIES) {
propertyMap.put(prop, props.get(prop)); propertyMap.put(prop, props.get(prop));
@ -144,12 +145,12 @@ public class ColoredRadioButton extends JRadioButton {
} }
stateIcon = new StateIcon(new Icon[]{ stateIcon = new StateIcon(new Icon[]{
load(loader, "control/radio.svg"), load(loader, "control/radio.svg"),
load(loader, "control/radioDisabled.svg"), load(loader, "control/radioDisabled.svg"),
load(loader, "control/radioFocused.svg"), load(loader, "control/radioFocused.svg"),
load(loader, "control/radioSelected.svg"), load(loader, "control/radioSelected.svg"),
load(loader, "control/radioSelectedDisabled.svg"), load(loader, "control/radioSelectedDisabled.svg"),
load(loader, "control/radioSelectedFocused.svg") load(loader, "control/radioSelectedFocused.svg")
}); });
} }

1
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components; package com.github.weisj.darklaf.components;

16
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components; 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.*;
import java.awt.event.*; import java.awt.event.*;
import java.awt.geom.Ellipse2D; import java.awt.geom.Ellipse2D;
import java.awt.image.BufferedImage; 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 { public class DefaultColorPipette extends ColorPipetteBase {
private static final int SIZE = 36; private static final int SIZE = 36;
private static final int DIALOG_SIZE = 50; private static final int DIALOG_SIZE = 50;
@ -196,7 +198,7 @@ public class DefaultColorPipette extends ColorPipetteBase {
GraphicsUtil.setupStrokePainting(g2); GraphicsUtil.setupStrokePainting(g2);
Graphics2D g = (Graphics2D) 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); g.setColor(Color.WHITE);
GraphicsContext config = GraphicsUtil.paintWithAlpha(g, 0.005f); GraphicsContext config = GraphicsUtil.paintWithAlpha(g, 0.005f);
Point p = MouseInfo.getPointerInfo().getLocation(); Point p = MouseInfo.getPointerInfo().getLocation();

1
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components; package com.github.weisj.darklaf.components;

11
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components; 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.jdesktop.jxlayer.JXLayer;
import org.pbjar.jxlayer.plaf.ext.TransformUI; import org.pbjar.jxlayer.plaf.ext.TransformUI;
import javax.swing.*; import com.github.weisj.darklaf.util.DarkUIUtil;
import java.awt.*;
import java.awt.geom.AffineTransform;
/** /**
* Popup menu that is aware of {@link org.pbjar.jxlayer.plaf.ext.TransformUI}. * Popup menu that is aware of {@link org.pbjar.jxlayer.plaf.ext.TransformUI}.

18
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components; package com.github.weisj.darklaf.components;
import com.github.weisj.darklaf.ui.scrollpane.ScrollLayoutManagerDelegate; import java.awt.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.plaf.ScrollPaneUI; 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. * 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. * scrolling in underway or the mouse is over the scrollbar position.
* *
* @param view the component to display in the scrollable viewport * @param view the component to display in the scrollable viewport
* @see JScrollPane#setViewportView * @see JScrollPane#setViewportView
*/ */
public OverlayScrollPane(final JComponent view) { public OverlayScrollPane(final JComponent view) {
this(view, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 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 * 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 * 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 * 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}. * and {@link JScrollPane#setHorizontalScrollBarPolicy}.
* *
* @param view the view of the component. * @param view the view of the component.
@ -89,7 +92,6 @@ public class OverlayScrollPane extends JLayeredPane {
* *
* @return the scrollPane * @return the scrollPane
*/ */
public JScrollPane getScrollPane() { public JScrollPane getScrollPane() {
return scrollPane; return scrollPane;
} }
@ -111,7 +113,6 @@ public class OverlayScrollPane extends JLayeredPane {
controlPanel.showHorizontalScrollBar(policy != JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); controlPanel.showHorizontalScrollBar(policy != JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
} }
public JScrollBar getVerticalScrollBar() { public JScrollBar getVerticalScrollBar() {
return scrollPane.verticalScrollBar; return scrollPane.verticalScrollBar;
} }
@ -121,7 +122,6 @@ public class OverlayScrollPane extends JLayeredPane {
return scrollPane.getPreferredSize(); return scrollPane.getPreferredSize();
} }
public JScrollBar getHorizontalScrollBar() { public JScrollBar getHorizontalScrollBar() {
return scrollPane.horizontalScrollBar; return scrollPane.horizontalScrollBar;
} }
@ -148,7 +148,6 @@ public class OverlayScrollPane extends JLayeredPane {
private JScrollBar verticalScrollBar; private JScrollBar verticalScrollBar;
private JScrollBar horizontalScrollBar; private JScrollBar horizontalScrollBar;
protected OScrollPane(final JComponent view, final int vsbPolicy, final int hsbPolicy) { protected OScrollPane(final JComponent view, final int vsbPolicy, final int hsbPolicy) {
super(view, vsbPolicy, hsbPolicy); super(view, vsbPolicy, hsbPolicy);
} }
@ -294,12 +293,9 @@ public class OverlayScrollPane extends JLayeredPane {
&& scrollPane.verticalScrollBar.getBounds().contains(x, y); && scrollPane.verticalScrollBar.getBounds().contains(x, y);
} }
@Override @Override
public boolean isOpaque() { public boolean isOpaque() {
return false; return false;
} }
} }
} }

12
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components; package com.github.weisj.darklaf.components;
import com.github.weisj.darklaf.ui.popupmenu.PopupMenuContainer; import java.awt.*;
import com.github.weisj.darklaf.util.PropertyKey;
import javax.swing.*; import javax.swing.*;
import java.awt.*;
import com.github.weisj.darklaf.ui.popupmenu.PopupMenuContainer;
import com.github.weisj.darklaf.util.PropertyKey;
/** /**
* @author Jannis Weis * @author Jannis Weis
@ -84,7 +86,6 @@ public class ScrollPopupMenu extends JPopupMenu {
posY = y; posY = y;
} }
@Override @Override
public void setVisible(final boolean b) { public void setVisible(final boolean b) {
if (b == isVisible()) { if (b == isVisible()) {
@ -126,8 +127,7 @@ public class ScrollPopupMenu extends JPopupMenu {
} }
@Override @Override
public void pack() { public void pack() {}
}
private boolean isPopupMenu() { private boolean isPopupMenu() {
Component invoker = getInvoker(); Component invoker = getInvoker();

1
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components; package com.github.weisj.darklaf.components;

1
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components; package com.github.weisj.darklaf.components;

1
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components; package com.github.weisj.darklaf.components;

1
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components; package com.github.weisj.darklaf.components;

51
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components; package com.github.weisj.darklaf.components;
import com.github.weisj.darklaf.ui.slider.DarkSliderUI;
import javax.swing.*; import javax.swing.*;
import com.github.weisj.darklaf.ui.slider.DarkSliderUI;
public class VolumeSlider extends JSlider { public class VolumeSlider extends JSlider {
private boolean showVolumeIcon; private boolean showVolumeIcon;
@ -38,79 +39,75 @@ public class VolumeSlider extends JSlider {
this(HORIZONTAL, 0, 100, 50); 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 * 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 <code>SwingConstants.VERTICAL</code> or * {@code 50}. The orientation can be either <code>SwingConstants.VERTICAL</code> or
* <code>SwingConstants.HORIZONTAL</code>. * <code>SwingConstants.HORIZONTAL</code>.
* *
* @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} * @throws IllegalArgumentException if orientation is not one of {@code VERTICAL}, {@code HORIZONTAL}
* @see #setOrientation * @see #setOrientation
*/ */
public VolumeSlider(final int orientation) { public VolumeSlider(final int orientation) {
this(orientation, 0, 100, 50); 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 * Creates a horizontal slider using the specified min and max with an initial value equal to the average of the min
* plus max. * plus max.
* <p> * <p>
* The <code>BoundedRangeModel</code> that holds the slider's data handles any issues that may arise from improperly * The <code>BoundedRangeModel</code> 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. * details.
* *
* @param min the minimum value of the slider * @param min the minimum value of the slider
* @param max the maximum value of the slider * @param max the maximum value of the slider
* @see BoundedRangeModel * @see BoundedRangeModel
* @see #setMinimum * @see #setMinimum
* @see #setMaximum * @see #setMaximum
*/ */
public VolumeSlider(final int min, final int max) { public VolumeSlider(final int min, final int max) {
this(HORIZONTAL, min, max, (min + max) / 2); this(HORIZONTAL, min, max, (min + max) / 2);
} }
/** /**
* Creates a horizontal slider using the specified min, max and value. * Creates a horizontal slider using the specified min, max and value.
* <p> * <p>
* The <code>BoundedRangeModel</code> that holds the slider's data handles any issues that may arise from improperly * The <code>BoundedRangeModel</code> 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. * for details.
* *
* @param min the minimum value of the slider * @param min the minimum value of the slider
* @param max the maximum value of the slider * @param max the maximum value of the slider
* @param value the initial value of the slider * @param value the initial value of the slider
* @see BoundedRangeModel * @see BoundedRangeModel
* @see #setMinimum * @see #setMinimum
* @see #setMaximum * @see #setMaximum
* @see #setValue * @see #setValue
*/ */
public VolumeSlider(final int min, final int max, final int value) { public VolumeSlider(final int min, final int max, final int value) {
this(HORIZONTAL, min, max, value); this(HORIZONTAL, min, max, value);
} }
/** /**
* Creates a slider with the specified orientation and the specified minimum, maximum, and initial values. The * Creates a slider with the specified orientation and the specified minimum, maximum, and initial values. The
* orientation can be either <code>SwingConstants.VERTICAL</code> or * orientation can be either <code>SwingConstants.VERTICAL</code> or
* <code>SwingConstants.HORIZONTAL</code>. * <code>SwingConstants.HORIZONTAL</code>.
* <p> * <p>
* The <code>BoundedRangeModel</code> that holds the slider's data handles any issues that may arise from improperly * The <code>BoundedRangeModel</code> 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. * for details.
* *
* @param orientation the orientation of the slider * @param orientation the orientation of the slider
* @param min the minimum value of the slider * @param min the minimum value of the slider
* @param max the maximum value of the slider * @param max the maximum value of the slider
* @param value the initial value of the slider * @param value the initial value of the slider
* @throws IllegalArgumentException if orientation is not one of {@code VERTICAL}, {@code HORIZONTAL} * @throws IllegalArgumentException if orientation is not one of {@code VERTICAL}, {@code HORIZONTAL}
* @see BoundedRangeModel * @see BoundedRangeModel
* @see #setOrientation * @see #setOrientation
* @see #setMinimum * @see #setMinimum
* @see #setMaximum * @see #setMaximum
* @see #setValue * @see #setValue
*/ */
public VolumeSlider(final int orientation, final int min, final int max, final int value) { public VolumeSlider(final int orientation, final int min, final int max, final int value) {
super(orientation, min, max, value); super(orientation, min, max, value);

1
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.alignment; package com.github.weisj.darklaf.components.alignment;

115
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.border; 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.*;
import java.awt.geom.Area; import java.awt.geom.Area;
import java.awt.geom.Path2D; import java.awt.geom.Path2D;
import java.awt.geom.RoundRectangle2D; 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 * @author Jannis Weis
*/ */
@ -89,10 +91,9 @@ public class BubbleBorder extends AbstractBorder {
/** /**
* Set the border colour. * Set the border colour.
* *
* @param color border colour * @param color border colour
* @return this * @return this
*/ */
public BubbleBorder setColor(final Color color) { public BubbleBorder setColor(final Color color) {
this.color = color; this.color = color;
return this; return this;
@ -110,15 +111,14 @@ public class BubbleBorder extends AbstractBorder {
/** /**
* Set the with of the pointer base. * Set the with of the pointer base.
* *
* @param pointerWidth the width of the pointer base. * @param pointerWidth the width of the pointer base.
* @return this * @return this
*/ */
public BubbleBorder setPointerWidth(final int pointerWidth) { public BubbleBorder setPointerWidth(final int pointerWidth) {
this.pointerWidth = pointerWidth; this.pointerWidth = pointerWidth;
return this; return this;
} }
/** /**
* Get the border thickness. * Get the border thickness.
* *
@ -131,10 +131,9 @@ public class BubbleBorder extends AbstractBorder {
/** /**
* Set the border thickness. * Set the border thickness.
* *
* @param n new thickness * @param n new thickness
* @return this * @return this
*/ */
public BubbleBorder setThickness(final int n) { public BubbleBorder setThickness(final int n) {
thickness = Math.max(n, 0); thickness = Math.max(n, 0);
return setPointerSize(pointerSize); return setPointerSize(pointerSize);
@ -152,10 +151,9 @@ public class BubbleBorder extends AbstractBorder {
/** /**
* Set the pointer size Clips at 0. * Set the pointer size Clips at 0.
* *
* @param size size of pointer. * @param size size of pointer.
* @return this * @return this
*/ */
public BubbleBorder setPointerSize(final int size) { public BubbleBorder setPointerSize(final int size) {
pointerSize = Math.max(size, 0); pointerSize = Math.max(size, 0);
float left = thickness; float left = thickness;
@ -164,23 +162,23 @@ public class BubbleBorder extends AbstractBorder {
float top = thickness; float top = thickness;
switch (pointerSide) { switch (pointerSide) {
case NORTH: case NORTH :
case NORTH_WEST: case NORTH_WEST :
case NORTH_EAST: case NORTH_EAST :
top += pointerSize; top += pointerSize;
break; break;
case SOUTH: case SOUTH :
case SOUTH_WEST: case SOUTH_WEST :
case SOUTH_EAST: case SOUTH_EAST :
bottom += pointerSize; bottom += pointerSize;
break; break;
case WEST: case WEST :
left += pointerSize; left += pointerSize;
break; break;
case EAST: case EAST :
right += pointerSize; right += pointerSize;
break; break;
default: default :
break; break;
} }
insets.set((int) top, (int) left, (int) bottom, (int) right); insets.set((int) top, (int) left, (int) bottom, (int) right);
@ -199,10 +197,9 @@ public class BubbleBorder extends AbstractBorder {
/** /**
* Set the corner radius. * Set the corner radius.
* *
* @param radius radius of corner. * @param radius radius of corner.
* @return this * @return this
*/ */
public BubbleBorder setRadius(final int radius) { public BubbleBorder setRadius(final int radius) {
this.radius = radius; this.radius = radius;
return setPointerSize(pointerSize); 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#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. * Alignment#SOUTH_EAST} and {@link Alignment#SOUTH_WEST} {@link Alignment#CENTER} results in no pointer.
* *
* @param side direction in which the pointer should point. * @param side direction in which the pointer should point.
* @return this. * @return this.
*/ */
public BubbleBorder setPointerSide(final Alignment side) { public BubbleBorder setPointerSide(final Alignment side) {
this.pointerSide = side; this.pointerSide = side;
setPointerSize(pointerSize); setPointerSize(pointerSize);
@ -236,27 +232,26 @@ public class BubbleBorder extends AbstractBorder {
return (float) calculatePointerPad(w, h, Alignment.NORTH_WEST); return (float) calculatePointerPad(w, h, Alignment.NORTH_WEST);
} }
private double calculatePointerPad(final float width, final float height, final Alignment side) { private double calculatePointerPad(final float width, final float height, final Alignment side) {
double pointerPad; double pointerPad;
switch (side) { switch (side) {
case WEST: case WEST :
case EAST: case EAST :
pointerPad = radius + (height - insets.top - insets.bottom - 2 * radius) / 2.0; pointerPad = radius + (height - insets.top - insets.bottom - 2 * radius) / 2.0;
break; break;
case NORTH_WEST: case NORTH_WEST :
case SOUTH_WEST: case SOUTH_WEST :
pointerPad = radius + insets.left + pointerWidth; pointerPad = radius + insets.left + pointerWidth;
break; break;
case NORTH_EAST: case NORTH_EAST :
case SOUTH_EAST: case SOUTH_EAST :
pointerPad = width - radius - insets.right - pointerWidth; pointerPad = width - radius - insets.right - pointerWidth;
break; break;
case SOUTH: case SOUTH :
case NORTH: case NORTH :
pointerPad = radius + (0.5 * (width - insets.left - insets.right - 2 * radius)); pointerPad = radius + (0.5 * (width - insets.left - insets.right - 2 * radius));
break; break;
default: default :
pointerPad = 0; pointerPad = 0;
break; break;
} }
@ -270,13 +265,11 @@ public class BubbleBorder extends AbstractBorder {
paintBorder(g, area); paintBorder(g, area);
} }
@Override @Override
public Insets getBorderInsets(final Component c) { public Insets getBorderInsets(final Component c) {
return new InsetsUIResource(insets.top, insets.left, insets.bottom, insets.right); return new InsetsUIResource(insets.top, insets.left, insets.bottom, insets.right);
} }
@Override @Override
public Insets getBorderInsets(final Component c, final Insets insets) { public Insets getBorderInsets(final Component c, final Insets insets) {
return getBorderInsets(c); return getBorderInsets(c);
@ -294,15 +287,15 @@ public class BubbleBorder extends AbstractBorder {
if (pointerSide != Alignment.CENTER) { if (pointerSide != Alignment.CENTER) {
double pointerPad = calculatePointerPad(w, h, pointerSide); double pointerPad = calculatePointerPad(w, h, pointerSide);
switch (pointerSide) { switch (pointerSide) {
case SOUTH_EAST: case SOUTH_EAST :
case NORTH_EAST: case NORTH_EAST :
if (inner) pointerPad += adj; if (inner) pointerPad += adj;
break; break;
case NORTH_WEST: case NORTH_WEST :
case SOUTH_WEST: case SOUTH_WEST :
if (inner) pointerPad -= adj; if (inner) pointerPad -= adj;
break; break;
default: default :
break; break;
} }
Path2D pointer = creatPointerShape(pointerPad, pSize, pWidth, bubble); Path2D pointer = creatPointerShape(pointerPad, pSize, pWidth, bubble);
@ -326,14 +319,12 @@ public class BubbleBorder extends AbstractBorder {
config.restore(); config.restore();
} }
public RoundRectangle2D.Float calculateBubbleRect(final float x, final float y, public RoundRectangle2D.Float calculateBubbleRect(final float x, final float y,
final float width, final float height) { final float width, final float height) {
return new RoundRectangle2D.Float(x + insets.left, y + insets.top, width - insets.left - insets.right, return new RoundRectangle2D.Float(x + insets.left, y + insets.top, width - insets.left - insets.right,
height - insets.top - insets.bottom, radius, radius); height - insets.top - insets.bottom, radius, radius);
} }
private Path2D creatPointerShape(final double pointerPad, final double pSize, final double pWidth, private Path2D creatPointerShape(final double pointerPad, final double pSize, final double pWidth,
final RoundRectangle2D.Float bubble) { final RoundRectangle2D.Float bubble) {
final double w = pWidth / 2.0; final double w = pWidth / 2.0;
@ -341,31 +332,31 @@ public class BubbleBorder extends AbstractBorder {
double x = bubble.x; double x = bubble.x;
double y = bubble.y; double y = bubble.y;
switch (pointerSide) { switch (pointerSide) {
case WEST: case WEST :
pointer.moveTo(x, y + pointerPad - w); //Top pointer.moveTo(x, y + pointerPad - w); // Top
pointer.lineTo(x - pSize, y + pointerPad); pointer.lineTo(x - pSize, y + pointerPad);
pointer.lineTo(x, y + pointerPad + w);// bottom pointer.lineTo(x, y + pointerPad + w);// bottom
break; break;
case EAST: case EAST :
pointer.moveTo(x + bubble.width, y + pointerPad - w);// top pointer.moveTo(x + bubble.width, y + pointerPad - w);// top
pointer.lineTo(x + bubble.width + pSize, y + pointerPad); pointer.lineTo(x + bubble.width + pSize, y + pointerPad);
pointer.lineTo(x + bubble.width, y + pointerPad + w);// bottom pointer.lineTo(x + bubble.width, y + pointerPad + w);// bottom
break; break;
case NORTH: case NORTH :
case NORTH_WEST: case NORTH_WEST :
case NORTH_EAST: case NORTH_EAST :
pointer.moveTo(x + pointerPad - w, y);// left pointer.moveTo(x + pointerPad - w, y);// left
pointer.lineTo(x + pointerPad, y - pSize); pointer.lineTo(x + pointerPad, y - pSize);
pointer.lineTo(x + pointerPad + w, y);// right pointer.lineTo(x + pointerPad + w, y);// right
break; break;
case SOUTH: case SOUTH :
case SOUTH_WEST: case SOUTH_WEST :
case SOUTH_EAST: case SOUTH_EAST :
pointer.moveTo(x + pointerPad - w, y + bubble.height);// left pointer.moveTo(x + pointerPad - w, y + bubble.height);// left
pointer.lineTo(x + pointerPad, y + bubble.height + pSize); pointer.lineTo(x + pointerPad, y + bubble.height + pSize);
pointer.lineTo(x + pointerPad + w, y + bubble.height);// right pointer.lineTo(x + pointerPad + w, y + bubble.height);// right
break; break;
default: default :
break; break;
} }
pointer.closePath(); pointer.closePath();

4
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.border; package com.github.weisj.darklaf.components.border;
import javax.swing.border.Border;
import java.awt.*; import java.awt.*;
import javax.swing.border.Border;
public final class DarkBorders { public final class DarkBorders {
private static DarkLineBorder sharedBorderEmpty; private static DarkLineBorder sharedBorderEmpty;

10
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.border; 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.DarkLaf;
import com.github.weisj.darklaf.LafManager; import com.github.weisj.darklaf.LafManager;
import com.github.weisj.darklaf.theme.Theme; import com.github.weisj.darklaf.theme.Theme;
import javax.swing.*;
import java.awt.*;
import java.util.function.Function;
public class DarkLineBorder extends MutableLineBorder { public class DarkLineBorder extends MutableLineBorder {
private final String key; private final String key;

103
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.border; 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.*;
import java.awt.geom.RoundRectangle2D; import java.awt.geom.RoundRectangle2D;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
@ -37,17 +34,24 @@ import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; 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 * 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 * 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. * works wonderfully with JPanel, but horribly with JComboBox.
* <p> * <p>
* Note: {@code DropShadowBorder} should usually be added to non-opaque components, otherwise the background is likely * Note: {@code DropShadowBorder} should usually be added to non-opaque components, otherwise the background is likely
* to bleed through.</p> * to bleed through.
* <p>Note: Since generating drop shadows is relatively expensive operation, * </p>
* <p>
* 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 * {@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 * 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.</p> * your app memory in case you tend to create many different borders rapidly.
* </p>
* *
* @author rbair Adaptions made by * @author rbair Adaptions made by
* @author Jannis Weis * @author Jannis Weis
@ -63,18 +67,15 @@ public class DropShadowBorder implements Border, Serializable {
private boolean showBottomShadow; private boolean showBottomShadow;
private boolean showRightShadow; private boolean showRightShadow;
public DropShadowBorder() { public DropShadowBorder() {
this(Color.BLACK, 5); this(Color.BLACK, 5);
} }
public DropShadowBorder(final Color shadowColor, final int shadowSize) { public DropShadowBorder(final Color shadowColor, final int shadowSize) {
this(shadowColor, shadowSize, .5f, 12, false, true, this(shadowColor, shadowSize, .5f, 12, false, true,
true, true); true, true);
} }
public DropShadowBorder(final Color shadowColor, final int shadowSize, public DropShadowBorder(final Color shadowColor, final int shadowSize,
final float shadowOpacity, final int cornerSize, final boolean showTopShadow, final float shadowOpacity, final int cornerSize, final boolean showTopShadow,
final boolean showLeftShadow, final boolean showBottomShadow, final boolean showLeftShadow, final boolean showBottomShadow,
@ -89,7 +90,6 @@ public class DropShadowBorder implements Border, Serializable {
setShowRightShadow(showRightShadow); setShowRightShadow(showRightShadow);
} }
@Override @Override
public void paintBorder(final Component c, final Graphics graphics, public void paintBorder(final Component c, final Graphics graphics,
final int x, final int y, final int width, final int height) { 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(); Graphics2D g2 = (Graphics2D) graphics.create();
try { try {
//The location and size of the shadows depends on which shadows are being // 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 // 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, // 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 // 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 // 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. // 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; Point topLeftShadowPoint = null;
if (showLeftShadow || showTopShadow) { if (showLeftShadow || showTopShadow) {
@ -166,9 +166,8 @@ public class DropShadowBorder implements Border, Serializable {
if (showLeftShadow) { if (showLeftShadow) {
assert topLeftShadowPoint != null && bottomLeftShadowPoint != null; assert topLeftShadowPoint != null && bottomLeftShadowPoint != null;
Rectangle leftShadowRect = Rectangle leftShadowRect = new Rectangle(x, topLeftShadowPoint.y + shadowSize, shadowSize,
new Rectangle(x, topLeftShadowPoint.y + shadowSize, shadowSize, bottomLeftShadowPoint.y - topLeftShadowPoint.y - shadowSize);
bottomLeftShadowPoint.y - topLeftShadowPoint.y - shadowSize);
g2.drawImage(images[Position.LEFT.ordinal()], g2.drawImage(images[Position.LEFT.ordinal()],
leftShadowRect.x, leftShadowRect.y, leftShadowRect.x, leftShadowRect.y,
leftShadowRect.width, leftShadowRect.height, null); leftShadowRect.width, leftShadowRect.height, null);
@ -176,10 +175,11 @@ public class DropShadowBorder implements Border, Serializable {
if (showBottomShadow) { if (showBottomShadow) {
assert bottomLeftShadowPoint != null && bottomRightShadowPoint != null; assert bottomLeftShadowPoint != null && bottomRightShadowPoint != null;
Rectangle bottomShadowRect = Rectangle bottomShadowRect = new Rectangle(bottomLeftShadowPoint.x + shadowSize,
new Rectangle(bottomLeftShadowPoint.x + shadowSize, y + height - shadowSize, y + height - shadowSize,
bottomRightShadowPoint.x - bottomLeftShadowPoint.x - shadowSize, bottomRightShadowPoint.x - bottomLeftShadowPoint.x
shadowSize); - shadowSize,
shadowSize);
g2.drawImage(images[Position.BOTTOM.ordinal()], g2.drawImage(images[Position.BOTTOM.ordinal()],
bottomShadowRect.x, bottomShadowRect.y, bottomShadowRect.x, bottomShadowRect.y,
bottomShadowRect.width, bottomShadowRect.height, null); bottomShadowRect.width, bottomShadowRect.height, null);
@ -187,9 +187,10 @@ public class DropShadowBorder implements Border, Serializable {
if (showRightShadow) { if (showRightShadow) {
assert topRightShadowPoint != null && bottomRightShadowPoint != null; assert topRightShadowPoint != null && bottomRightShadowPoint != null;
Rectangle rightShadowRect = Rectangle rightShadowRect = new Rectangle(x + width - shadowSize, topRightShadowPoint.y + shadowSize,
new Rectangle(x + width - shadowSize, topRightShadowPoint.y + shadowSize, shadowSize, shadowSize,
bottomRightShadowPoint.y - topRightShadowPoint.y - shadowSize); bottomRightShadowPoint.y - topRightShadowPoint.y
- shadowSize);
g2.drawImage(images[Position.RIGHT.ordinal()], g2.drawImage(images[Position.RIGHT.ordinal()],
rightShadowRect.x, rightShadowRect.y, rightShadowRect.x, rightShadowRect.y,
rightShadowRect.width, rightShadowRect.height, null); rightShadowRect.width, rightShadowRect.height, null);
@ -197,9 +198,9 @@ public class DropShadowBorder implements Border, Serializable {
if (showTopShadow) { if (showTopShadow) {
assert topLeftShadowPoint != null && topRightShadowPoint != null; assert topLeftShadowPoint != null && topRightShadowPoint != null;
Rectangle topShadowRect = Rectangle topShadowRect = new Rectangle(topLeftShadowPoint.x + shadowSize, y,
new Rectangle(topLeftShadowPoint.x + shadowSize, y, topRightShadowPoint.x - topLeftShadowPoint.x - shadowSize,
topRightShadowPoint.x - topLeftShadowPoint.x - shadowSize, shadowSize); shadowSize);
g2.drawImage(images[Position.TOP.ordinal()], g2.drawImage(images[Position.TOP.ordinal()],
topShadowRect.x, topShadowRect.y, topShadowRect.x, topShadowRect.y,
topShadowRect.width, topShadowRect.height, null); topShadowRect.width, topShadowRect.height, null);
@ -231,25 +232,25 @@ public class DropShadowBorder implements Border, Serializable {
@SuppressWarnings("SuspiciousNameCombination") @SuppressWarnings("SuspiciousNameCombination")
private BufferedImage[] getImages(final Graphics2D g2) { private BufferedImage[] getImages(final Graphics2D g2) {
//first, check to see if an image for this size has already been rendered // first, check to see if an image for this size has already been rendered
//if so, use the cache. Else, draw and save // if so, use the cache. Else, draw and save
BufferedImage[] images = CACHE.get(getBorderHash(shadowSize, shadowOpacity, shadowColor)); BufferedImage[] images = CACHE.get(getBorderHash(shadowSize, shadowOpacity, shadowColor));
if (images == null) { if (images == null) {
images = new BufferedImage[Position.count()]; images = new BufferedImage[Position.count()];
/* /*
* To draw a drop shadow, I have to: * To draw a drop shadow, I have to:
* 1) Create a rounded rectangle * 1) Create a rounded rectangle
* 2) Create a BufferedImage to draw the rounded rect in * 2) Create a BufferedImage to draw the rounded rect in
* 3) Translate the graphics for the image, so that the rectangle * 3) Translate the graphics for the image, so that the rectangle
* is centered in the drawn space. The border around 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 * needs to be shadowWidth wide, so that there is space for the
* shadow to be drawn. * shadow to be drawn.
* 4) Draw the rounded rect as shadowColor, with an opacity of shadowOpacity * 4) Draw the rounded rect as shadowColor, with an opacity of shadowOpacity
* 5) Create the BLUR_KERNEL * 5) Create the BLUR_KERNEL
* 6) Blur the image * 6) Blur the image
* 7) copy off the corners, sides, etc into images to be used for * 7) copy off the corners, sides, etc into images to be used for
* drawing the Border * drawing the Border
*/ */
int rectWidth = cornerSize + 1; int rectWidth = cornerSize + 1;
RoundRectangle2D rect = new RoundRectangle2D.Double(0, 0, rectWidth, rectWidth, cornerSize, cornerSize); 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.) * 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) { private BufferedImage getSubImage(final BufferedImage img, final int x, final int y, final int w, final int h) {
BufferedImage ret = ImageUtil.createCompatibleTranslucentImage(w, h); BufferedImage ret = ImageUtil.createCompatibleTranslucentImage(w, h);
Graphics2D g2 = ret.createGraphics(); Graphics2D g2 = ret.createGraphics();
@ -437,12 +437,17 @@ public class DropShadowBorder implements Border, Serializable {
} }
private enum Position { private enum Position {
TOP, TOP_LEFT, LEFT, BOTTOM_LEFT, TOP,
BOTTOM, BOTTOM_RIGHT, RIGHT, TOP_RIGHT; TOP_LEFT,
LEFT,
BOTTOM_LEFT,
BOTTOM,
BOTTOM_RIGHT,
RIGHT,
TOP_RIGHT;
static int count() { static int count() {
return 8; return 8;
} }
} }
} }

7
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.border; package com.github.weisj.darklaf.components.border;
import javax.swing.border.AbstractBorder;
import java.awt.*; import java.awt.*;
import javax.swing.border.AbstractBorder;
/** /**
* @author Jannis Weis * @author Jannis Weis
*/ */
@ -41,8 +43,7 @@ public class MutableLineBorder extends AbstractBorder {
this(insets.top, insets.left, insets.bottom, insets.right, color); this(insets.top, insets.left, insets.bottom, insets.right, color);
} }
public MutableLineBorder( public MutableLineBorder(final int top, final int left, final int bottom, final int right, final Color color) {
final int top, final int left, final int bottom, final int right, final Color color) {
this.top = top; this.top = top;
this.left = left; this.left = left;
this.bottom = bottom; this.bottom = bottom;

36
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.color; 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.components.tooltip.ToolTipContext;
import com.github.weisj.darklaf.ui.DarkPopupFactory; import com.github.weisj.darklaf.ui.DarkPopupFactory;
import com.github.weisj.darklaf.ui.tooltip.DarkTooltipBorder; 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.Alignment;
import com.github.weisj.darklaf.util.DarkUIUtil; 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 { public class PopupColorChooser extends JToolTip {
protected DarkTooltipBorder border; protected DarkTooltipBorder border;
@ -128,17 +130,17 @@ public class PopupColorChooser extends JToolTip {
protected ToolTipContext createToolTipContext() { protected ToolTipContext createToolTipContext() {
return new ToolTipContext() return new ToolTipContext()
.setAlignment(Alignment.CENTER) .setAlignment(Alignment.CENTER)
.setCenterAlignment(Alignment.SOUTH) .setCenterAlignment(Alignment.SOUTH)
.setUseBestFit(true) .setUseBestFit(true)
.setToolTipInsets(new Insets(2, 2, 2, 2)) .setToolTipInsets(new Insets(2, 2, 2, 2))
.setFallBackPositionProvider(c -> { .setFallBackPositionProvider(c -> {
Window window = DarkUIUtil.getWindow(c.getTarget()); Window window = DarkUIUtil.getWindow(c.getTarget());
Dimension size = c.getToolTip().getPreferredSize(); Dimension size = c.getToolTip().getPreferredSize();
Rectangle bounds = window.getBounds(); Rectangle bounds = window.getBounds();
return new Point(bounds.x + (bounds.width - size.width) / 2, return new Point(bounds.x + (bounds.width - size.width) / 2,
bounds.y + (bounds.height - size.height) / 2); bounds.y + (bounds.height - size.height) / 2);
}); });
} }
@Override @Override

12
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.color; 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.awt.*;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Supplier; 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 { public class QuickColorChooser extends JPanel {
private final SolidColorIcon icon; private final SolidColorIcon icon;

20
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.color; 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.DarkColorModel;
import com.github.weisj.darklaf.color.DarkColorModelHSB; import com.github.weisj.darklaf.color.DarkColorModelHSB;
import com.github.weisj.darklaf.color.DarkColorModelHSL; 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.ColorUtil;
import com.github.weisj.darklaf.util.DarkUIUtil; 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 { public class SmallColorChooser extends JPanel {
private static final DarkColorModel[] COLOR_MODELS = new DarkColorModel[]{DarkColorModelRGB.getInstance(), private static final DarkColorModel[] COLOR_MODELS = new DarkColorModel[]{DarkColorModelRGB.getInstance(),
@ -106,13 +108,13 @@ public class SmallColorChooser extends JPanel {
hexField.getDocument().addDocumentListener((UpdateDocumentListener) () -> { hexField.getDocument().addDocumentListener((UpdateDocumentListener) () -> {
try { try {
String hexStr = String.format("%1$-" + 8 + "s", 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), int[] rgb = new int[]{Integer.valueOf(hexStr.substring(0, 2), 16),
Integer.valueOf(hexStr.substring(2, 4), 16), Integer.valueOf(hexStr.substring(2, 4), 16),
Integer.valueOf(hexStr.substring(4, 6), 16)}; Integer.valueOf(hexStr.substring(4, 6), 16)};
setColor(hexField, DarkColorModelRGB.getInstance(), rgb); setColor(hexField, DarkColorModelRGB.getInstance(), rgb);
} catch (NumberFormatException | IndexOutOfBoundsException ignore) { } catch (NumberFormatException | IndexOutOfBoundsException ignore) {}
}
}); });
} }

157
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.tabframe; 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.awt.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Objects; 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. * Frame that supports popup components.
* *
@ -71,9 +73,9 @@ public class JTabFrame extends JComponent {
add(content.getComponent()); add(content.getComponent());
int count = Alignment.values().length; int count = Alignment.values().length;
//noinspection unchecked // noinspection unchecked
tabLists = (ArrayList<TabFrameTab>[]) new ArrayList[count]; tabLists = (ArrayList<TabFrameTab>[]) new ArrayList[count];
//noinspection unchecked // noinspection unchecked
popupLists = (ArrayList<TabFramePopup>[]) new ArrayList[count]; popupLists = (ArrayList<TabFramePopup>[]) new ArrayList[count];
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
tabLists[i] = new ArrayList<>(); tabLists[i] = new ArrayList<>();
@ -175,8 +177,8 @@ public class JTabFrame extends JComponent {
/** /**
* Get the number of tabs at the given alignment position. * Get the number of tabs at the given alignment position.
* *
* @param a the alignment position. * @param a the alignment position.
* @return number of tabs. * @return number of tabs.
*/ */
public int getTabCountAt(final Alignment a) { public int getTabCountAt(final Alignment a) {
return tabsForAlignment(a).size(); return tabsForAlignment(a).size();
@ -328,7 +330,7 @@ public class JTabFrame extends JComponent {
tabComp.setOrientation(a); tabComp.setOrientation(a);
getTabContainer(a).add(tabComp.getComponent()); getTabContainer(a).add(tabComp.getComponent());
List<TabFrameTab> tabs = tabsForAlignment(a); List<TabFrameTab> tabs = tabsForAlignment(a);
//Adjust indices for tabs. // Adjust indices for tabs.
Iterator<TabFrameTab> iterator = tabs.listIterator(index); Iterator<TabFrameTab> iterator = tabs.listIterator(index);
while (iterator.hasNext()) { while (iterator.hasNext()) {
TabFrameTab tab = iterator.next(); TabFrameTab tab = iterator.next();
@ -346,8 +348,8 @@ public class JTabFrame extends JComponent {
/** /**
* Get a list of components at the given alignment position. * Get a list of components at the given alignment position.
* *
* @param a the alignment position. * @param a the alignment position.
* @return list of components at position. * @return list of components at position.
*/ */
public List<TabFramePopup> compsForAlignment(final Alignment a) { public List<TabFramePopup> compsForAlignment(final Alignment a) {
return popupLists[a.ordinal()]; return popupLists[a.ordinal()];
@ -356,27 +358,26 @@ public class JTabFrame extends JComponent {
/** /**
* Get the tab container for the given alignment position. * Get the tab container for the given alignment position.
* *
* @param a the alignment position.{@link TabFramePosition#getAlignment()} * @param a the alignment position.{@link TabFramePosition#getAlignment()}
* @return the tab container. * @return the tab container.
*/ */
public JComponent getTabContainer(final Alignment a) { public JComponent getTabContainer(final Alignment a) {
switch (a) { switch (a) {
case NORTH: case NORTH :
case NORTH_EAST: case NORTH_EAST :
return getTopTabContainer(); return getTopTabContainer();
case SOUTH: case SOUTH :
case SOUTH_WEST: case SOUTH_WEST :
return getBottomTabContainer(); return getBottomTabContainer();
case EAST: case EAST :
case SOUTH_EAST: case SOUTH_EAST :
return getRightTabContainer(); return getRightTabContainer();
case WEST: case WEST :
case NORTH_WEST: case NORTH_WEST :
return getLeftTabContainer(); return getLeftTabContainer();
case CENTER: case CENTER :
throw new IllegalArgumentException("invalid alignment: " + a); throw new IllegalArgumentException("invalid alignment: " + a);
default: default :
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
} }
@ -384,8 +385,8 @@ public class JTabFrame extends JComponent {
/** /**
* Get a list of tab components at the given alignment position. * Get a list of tab components at the given alignment position.
* *
* @param a the alignment position. * @param a the alignment position.
* @return list of tab components at position. * @return list of tab components at position.
*/ */
public List<TabFrameTab> tabsForAlignment(final Alignment a) { public List<TabFrameTab> tabsForAlignment(final Alignment a) {
return tabLists[a.ordinal()]; return tabLists[a.ordinal()];
@ -462,9 +463,9 @@ public class JTabFrame extends JComponent {
/** /**
* Get the tab component at the given position. * Get the tab component at the given position.
* *
* @param a the alignment position.{@link TabFramePosition#getAlignment()} * @param a the alignment position.{@link TabFramePosition#getAlignment()}
* @param index the index.{@link TabFramePosition#getIndex()} * @param index the index.{@link TabFramePosition#getIndex()}
* @return the tab component. * @return the tab component.
* @throws IndexOutOfBoundsException if the alignment or index is out of bounds, or the tab doesn't exist. * @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) { 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. * Get the component at the given position.
* *
* @param a the alignment position.{@link TabFramePosition#getAlignment()} * @param a the alignment position.{@link TabFramePosition#getAlignment()}
* @param index the index. {@link TabFramePosition#getIndex()} ()} * @param index the index. {@link TabFramePosition#getIndex()} ()}
* @return the popup component specified by {@link TabFramePopup#getContentPane()}. * @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. * @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) { 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. * Gets the position of the given component or null if it isn't currently added.
* *
* @param c the component to find. * @param c the component to find.
* @return the position in the tabFrame.{@link TabFramePosition} * @return the position in the tabFrame.{@link TabFramePosition}
*/ */
public TabFramePosition findComponent(final Component c) { public TabFramePosition findComponent(final Component c) {
for (Alignment a : Alignment.values()) { for (Alignment a : Alignment.values()) {
@ -529,8 +530,8 @@ public class JTabFrame extends JComponent {
/** /**
* Close a popup. * Close a popup.
* *
* @param a the alignment position of the popup.{@link TabFramePosition#getAlignment()} * @param a the alignment position of the popup.{@link TabFramePosition#getAlignment()}
* @param index the index of the tab.{@link TabFramePosition#getIndex()} * @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. * @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) { public void closeTab(final Alignment a, final int index) {
@ -540,9 +541,9 @@ public class JTabFrame extends JComponent {
/** /**
* Toggles the visibility of a tab. * Toggles the visibility of a tab.
* *
* @param a the alignment position.{@link TabFramePosition#getAlignment()} * @param a the alignment position.{@link TabFramePosition#getAlignment()}
* @param index the index.{@link TabFramePosition#getIndex()} * @param index the index.{@link TabFramePosition#getIndex()}
* @param enabled true if visible. * @param enabled true if visible.
* @throws IndexOutOfBoundsException if the alignment or index is out of bounds, or the tab doesn't exist. * @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) { 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 * 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, * it. After the tab has been disabled enabling it won't restore the open state,
* *
* @param a the alignment position.{@link TabFramePosition#getAlignment()} * @param a the alignment position.{@link TabFramePosition#getAlignment()}
* @param index the index.{@link TabFramePosition#getIndex()} * @param index the index.{@link TabFramePosition#getIndex()}
* @param enabled true if enabled. * @param enabled true if enabled.
* @throws IndexOutOfBoundsException if the alignment or index is out of bounds, or the tab doesn't exist. * @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) { 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. * Get the popup component at the given position that is currently active.
* *
* @param a the alignment position. {@link TabFramePosition#getAlignment()} * @param a the alignment position. {@link TabFramePosition#getAlignment()}
* @return the popup component specified by {@link TabFramePopup#getComponent()}. * @return the popup component specified by {@link TabFramePopup#getComponent()}.
*/ */
public Component getPopupComponentAt(final Alignment a) { public Component getPopupComponentAt(final Alignment a) {
List<TabFramePopup> tabs = compsForAlignment(a); List<TabFramePopup> tabs = compsForAlignment(a);
@ -756,7 +757,7 @@ public class JTabFrame extends JComponent {
*/ */
private void removeTabComp(final Alignment a, final int index) { private void removeTabComp(final Alignment a, final int index) {
List<TabFrameTab> tabs = tabsForAlignment(a); List<TabFrameTab> tabs = tabsForAlignment(a);
//Adjust indices for tabs. // Adjust indices for tabs.
Iterator<TabFrameTab> iterator = tabs.listIterator(index); Iterator<TabFrameTab> iterator = tabs.listIterator(index);
while (iterator.hasNext()) { while (iterator.hasNext()) {
TabFrameTab tab = iterator.next(); TabFrameTab tab = iterator.next();
@ -769,9 +770,9 @@ public class JTabFrame extends JComponent {
/** /**
* Get the popup component at the given position. * Get the popup component at the given position.
* *
* @param a the alignment position.{@link TabFramePosition#getAlignment()} * @param a the alignment position.{@link TabFramePosition#getAlignment()}
* @param index the index.{@link TabFramePosition#getIndex()} * @param index the index.{@link TabFramePosition#getIndex()}
* @return the popup component specified by {@link TabFramePopup#getComponent()}. * @return the popup component specified by {@link TabFramePopup#getComponent()}.
*/ */
public Component getPopupComponentAt(final Alignment a, final int index) { public Component getPopupComponentAt(final Alignment a, final int index) {
List<TabFramePopup> tabs = compsForAlignment(a); List<TabFramePopup> tabs = compsForAlignment(a);
@ -781,8 +782,8 @@ public class JTabFrame extends JComponent {
/** /**
* Get the component at the given position. * Get the component at the given position.
* *
* @param a the alignment position. {@link TabFramePosition#getAlignment()} * @param a the alignment position. {@link TabFramePosition#getAlignment()}
* @return the component specified by {@link TabFramePopup#getContentPane()}. * @return the component specified by {@link TabFramePopup#getContentPane()}.
*/ */
public Component getComponentAt(final Alignment a) { public Component getComponentAt(final Alignment a) {
List<TabFramePopup> tabs = compsForAlignment(a); List<TabFramePopup> tabs = compsForAlignment(a);
@ -792,9 +793,9 @@ public class JTabFrame extends JComponent {
/** /**
* Get the custom tab component at the given position. * Get the custom tab component at the given position.
* *
* @param a the alignment position.{@link TabFramePosition#getAlignment()} * @param a the alignment position.{@link TabFramePosition#getAlignment()}
* @param index the index.{@link TabFramePosition#getIndex()} * @param index the index.{@link TabFramePosition#getIndex()}
* @return the user tab component or null if none is installed. * @return the user tab component or null if none is installed.
*/ */
public Component getUserTabComponentAt(final Alignment a, final int index) { public Component getUserTabComponentAt(final Alignment a, final int index) {
TabFrameTab tab = getTabComponentAt(a, 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 * Get the position of the alignment peer. That being the other position that occupies the same tab container given
* by {@link #getTabContainer(Alignment)}. * by {@link #getTabContainer(Alignment)}.
* <p> * <p>
* NORTH = NORTH_EAST * NORTH = NORTH_EAST
* </p><p> * </p>
* EAST = SOUTH_EAST * <p>
* </p><p> * EAST = SOUTH_EAST
* SOUTH = SOUTH_WEST * </p>
* </p><p> * <p>
* WEST = NORTH_WEST * SOUTH = SOUTH_WEST
* </p>
* <p>
* WEST = NORTH_WEST
* *
* @param a the alignment position.{@link TabFramePosition#getAlignment()} * @param a the alignment position.{@link TabFramePosition#getAlignment()}
* @return the peer position.{@link TabFramePosition#getAlignment()} * @return the peer position.{@link TabFramePosition#getAlignment()}
*/ */
public Alignment getPeer(final Alignment a) { public Alignment getPeer(final Alignment a) {
switch (a) { switch (a) {
case NORTH: case NORTH :
case SOUTH: case SOUTH :
case WEST: case WEST :
case EAST: case EAST :
return a.clockwise(); return a.clockwise();
case NORTH_EAST: case NORTH_EAST :
case NORTH_WEST: case NORTH_WEST :
case SOUTH_EAST: case SOUTH_EAST :
case SOUTH_WEST: case SOUTH_WEST :
return a.anticlockwise(); return a.anticlockwise();
} }
return a; return a;
@ -906,9 +910,9 @@ public class JTabFrame extends JComponent {
/** /**
* Returns whether the given tab is selected. * Returns whether the given tab is selected.
* *
* @param a the alignment position.{@link TabFramePosition#getAlignment()} * @param a the alignment position.{@link TabFramePosition#getAlignment()}
* @param index the index.{@link TabFramePosition#getIndex()} * @param index the index.{@link TabFramePosition#getIndex()}
* @return true if selected. * @return true if selected.
*/ */
public boolean isSelected(final Alignment a, final int index) { public boolean isSelected(final Alignment a, final int index) {
if (a == null) return false; 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. * 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()} * @param a the alignment position.{@link TabFramePosition#getAlignment()}
* @return the current selected index at the alignment position. * @return the current selected index at the alignment position.
*/ */
public int getSelectedIndex(final Alignment a) { public int getSelectedIndex(final Alignment a) {
return selectedIndices[a.ordinal()]; return selectedIndices[a.ordinal()];
@ -986,7 +990,6 @@ public class JTabFrame extends JComponent {
private Alignment a; private Alignment a;
private int index; private int index;
public TabFramePosition(final Alignment a, final int index) { public TabFramePosition(final Alignment a, final int index) {
this.a = a; this.a = a;
this.index = index; this.index = index;

12
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.tabframe; package com.github.weisj.darklaf.components.tabframe;
import com.github.weisj.darklaf.util.Alignment; import java.awt.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.plaf.PanelUI; import javax.swing.plaf.PanelUI;
import java.awt.*;
import com.github.weisj.darklaf.util.Alignment;
/** /**
* Popup Component for {@link JTabFrame}. * Popup Component for {@link JTabFrame}.
* *
* @author Jannis Weis * @author Jannis Weis
* @since 2019 * @since 2019
*/ */
public class PanelPopup extends JPanel implements TabFramePopup { public class PanelPopup extends JPanel implements TabFramePopup {
private Component content; private Component content;
@ -150,7 +152,6 @@ public class PanelPopup extends JPanel implements TabFramePopup {
} }
} }
private boolean isOpen() { private boolean isOpen() {
return open; return open;
} }
@ -176,7 +177,8 @@ public class PanelPopup extends JPanel implements TabFramePopup {
public void setAlignment(final Alignment alignment) { public void setAlignment(final Alignment alignment) {
if (alignment == null || this.alignment == Alignment.CENTER) { if (alignment == null || this.alignment == Alignment.CENTER) {
throw new IllegalArgumentException("Illegal alignment: " + (alignment != null throw new IllegalArgumentException("Illegal alignment: " + (alignment != null
? alignment.toString() : "null")); ? alignment.toString()
: "null"));
} }
Alignment old = this.alignment; Alignment old = this.alignment;
this.alignment = alignment; this.alignment = alignment;

5
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.tabframe; package com.github.weisj.darklaf.components.tabframe;
import java.awt.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border; import javax.swing.border.Border;
import java.awt.*;
/** /**
* Holder component. * Holder component.
@ -59,7 +61,6 @@ public class PopupContainer extends JPanel {
super.setBorder(null); super.setBorder(null);
} }
@Override @Override
public Border getBorder() { public Border getBorder() {
return null; return null;

4
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.tabframe; package com.github.weisj.darklaf.components.tabframe;
import javax.swing.*;
import java.awt.*; import java.awt.*;
import javax.swing.*;
public final class TabArea extends JPanel { public final class TabArea extends JPanel {
public TabArea() { public TabArea() {

13
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.tabframe; package com.github.weisj.darklaf.components.tabframe;
import com.github.weisj.darklaf.util.Alignment;
import java.awt.*; import java.awt.*;
import com.github.weisj.darklaf.util.Alignment;
public interface TabFrameContent { public interface TabFrameContent {
/** /**
@ -54,8 +55,8 @@ public interface TabFrameContent {
/** /**
* Returns whether the given popup is enabled. * Returns whether the given popup is enabled.
* *
* @param a the alignment of the popup. * @param a the alignment of the popup.
* @return true if enabled. * @return true if enabled.
*/ */
boolean isEnabled(Alignment a); boolean isEnabled(Alignment a);
@ -84,8 +85,8 @@ public interface TabFrameContent {
/** /**
* Get the popup container at the given location. * Get the popup container at the given location.
* *
* @param alignment the alignment position. * @param alignment the alignment position.
* @return the popup container. * @return the popup container.
*/ */
PopupContainer getContainer(Alignment alignment); PopupContainer getContainer(Alignment alignment);
} }

147
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.tabframe; package com.github.weisj.darklaf.components.tabframe;
import com.github.weisj.darklaf.decorators.AncestorAdapter; import java.awt.*;
import com.github.weisj.darklaf.util.Alignment; import java.util.function.BiConsumer;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.AncestorEvent; 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}. * Content pane for {@link JTabFrame}.
@ -88,7 +90,6 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent {
bottomSplitter.setLeftComponent(bottomLeftPanel); bottomSplitter.setLeftComponent(bottomLeftPanel);
bottomSplitter.setRightComponent(bottomRightPanel); bottomSplitter.setRightComponent(bottomRightPanel);
topSplit = createSplitPane("topSplit"); topSplit = createSplitPane("topSplit");
bottomSplit = createSplitPane("bottomSplit"); bottomSplit = createSplitPane("bottomSplit");
topSplit.setOrientation(JSplitPane.VERTICAL_SPLIT); 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) { public void setEnabled(final Alignment a, final boolean enabled, final boolean force) {
if (enabled == isEnabled(a) && !force) return; if (enabled == isEnabled(a) && !force) return;
switch (a) { switch (a) {
case NORTH: case NORTH :
changeStatus( changeStatus(enabled, Alignment.NORTH_EAST,
enabled, Alignment.NORTH_EAST, topSplit, topSplitter,
topSplit, topSplitter, new LayoutProportions(VERTICAL_PROP_TOP, 1.0, 0.0, 0.0),
new LayoutProportions(VERTICAL_PROP_TOP, 1.0, 0.0, 0.0), new LayoutWeights(0.0, 0.0, 0.0, 1.0));
new LayoutWeights(0.0, 0.0, 0.0, 1.0));
break; break;
case NORTH_EAST: case NORTH_EAST :
changeStatus( changeStatus(enabled, Alignment.NORTH,
enabled, Alignment.NORTH, topSplit, topSplitter,
topSplit, topSplitter, new LayoutProportions(VERTICAL_PROP_TOP, 0.0, 0.0, 1.0),
new LayoutProportions(VERTICAL_PROP_TOP, 0.0, 0.0, 1.0), new LayoutWeights(0.0, 0.0, 1.0, 0.0));
new LayoutWeights(0.0, 0.0, 1.0, 0.0));
break; break;
case EAST: case EAST :
changeStatus( changeStatus(enabled, Alignment.SOUTH_EAST,
enabled, Alignment.SOUTH_EAST, rightSplit, rightSplitter,
rightSplit, rightSplitter, new LayoutProportions(HORIZONTAL_PROP_RIGHT, 1.0, 1.0, 0.0),
new LayoutProportions(HORIZONTAL_PROP_RIGHT, 1.0, 1.0, 0.0), new LayoutWeights(1.0, 1.0, 0.0, 1.0));
new LayoutWeights(1.0, 1.0, 0.0, 1.0));
break; break;
case SOUTH_EAST: case SOUTH_EAST :
changeStatus( changeStatus(enabled, Alignment.EAST,
enabled, Alignment.EAST, rightSplit, rightSplitter,
rightSplit, rightSplitter, new LayoutProportions(HORIZONTAL_PROP_RIGHT, 0.0, 1.0, 1.0),
new LayoutProportions(HORIZONTAL_PROP_RIGHT, 0.0, 1.0, 1.0), new LayoutWeights(1.0, 1.0, 1.0, 0.0));
new LayoutWeights(1.0, 1.0, 1.0, 0.0));
break; break;
case NORTH_WEST: case NORTH_WEST :
changeStatus( changeStatus(enabled, Alignment.WEST,
enabled, Alignment.WEST, leftSplit, leftSplitter,
leftSplit, leftSplitter, new LayoutProportions(VERTICAL_PROP_TOP, 1.0, 0.0, 0.0),
new LayoutProportions(VERTICAL_PROP_TOP, 1.0, 0.0, 0.0), new LayoutWeights(0.0, 0.0, 0.0, 1.0));
new LayoutWeights(0.0, 0.0, 0.0, 1.0));
break; break;
case WEST: case WEST :
changeStatus( changeStatus(enabled, Alignment.NORTH_WEST,
enabled, Alignment.NORTH_WEST, leftSplit, leftSplitter,
leftSplit, leftSplitter, new LayoutProportions(VERTICAL_PROP_TOP, 0.0, 0.0, 1.0),
new LayoutProportions(VERTICAL_PROP_TOP, 0.0, 0.0, 1.0), new LayoutWeights(0.0, 0.0, 1.0, 0.0));
new LayoutWeights(0.0, 0.0, 1.0, 0.0));
break; break;
case SOUTH_WEST: case SOUTH_WEST :
changeStatus( changeStatus(enabled, Alignment.SOUTH,
enabled, Alignment.SOUTH, bottomSplit, bottomSplitter,
bottomSplit, bottomSplitter, new LayoutProportions(VERTICAL_PROP_BOTTOM, 1.0, 1.0, 0.0),
new LayoutProportions(VERTICAL_PROP_BOTTOM, 1.0, 1.0, 0.0), new LayoutWeights(1.0, 1.0, 0.0, 1.0));
new LayoutWeights(1.0, 1.0, 0.0, 1.0));
break; break;
case SOUTH: case SOUTH :
changeStatus( changeStatus(enabled, Alignment.SOUTH_WEST,
enabled, Alignment.SOUTH_WEST, bottomSplit, bottomSplitter,
bottomSplit, bottomSplitter, new LayoutProportions(VERTICAL_PROP_BOTTOM, 0.0, 1.0, 1.0),
new LayoutProportions(VERTICAL_PROP_BOTTOM, 0.0, 1.0, 1.0), new LayoutWeights(1.0, 1.0, 1.0, 0.0));
new LayoutWeights(1.0, 1.0, 1.0, 0.0));
break; break;
case CENTER: case CENTER :
break; break;
} }
setEnabledFlag(a, enabled); setEnabledFlag(a, enabled);
@ -320,8 +313,8 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent {
/** /**
* Returns whether the corresponding panel is currently enabled/visible. * Returns whether the corresponding panel is currently enabled/visible.
* *
* @param a the position of the panel. * @param a the position of the panel.
* @return true if enabled. * @return true if enabled.
*/ */
public boolean isEnabled(final Alignment a) { public boolean isEnabled(final Alignment a) {
if (a == Alignment.CENTER) { if (a == Alignment.CENTER) {
@ -333,31 +326,31 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent {
public void setComponentAt(final Alignment a, final Component c) { public void setComponentAt(final Alignment a, final Component c) {
switch (a) { switch (a) {
case NORTH: case NORTH :
((PopupContainer) topSplitter.getLeftComponent()).setPopup(c); ((PopupContainer) topSplitter.getLeftComponent()).setPopup(c);
break; break;
case NORTH_EAST: case NORTH_EAST :
((PopupContainer) topSplitter.getRightComponent()).setPopup(c); ((PopupContainer) topSplitter.getRightComponent()).setPopup(c);
break; break;
case EAST: case EAST :
((PopupContainer) rightSplitter.getTopComponent()).setPopup(c); ((PopupContainer) rightSplitter.getTopComponent()).setPopup(c);
break; break;
case SOUTH_EAST: case SOUTH_EAST :
((PopupContainer) rightSplitter.getBottomComponent()).setPopup(c); ((PopupContainer) rightSplitter.getBottomComponent()).setPopup(c);
break; break;
case SOUTH: case SOUTH :
((PopupContainer) bottomSplitter.getRightComponent()).setPopup(c); ((PopupContainer) bottomSplitter.getRightComponent()).setPopup(c);
break; break;
case SOUTH_WEST: case SOUTH_WEST :
((PopupContainer) bottomSplitter.getLeftComponent()).setPopup(c); ((PopupContainer) bottomSplitter.getLeftComponent()).setPopup(c);
break; break;
case WEST: case WEST :
((PopupContainer) leftSplitter.getBottomComponent()).setPopup(c); ((PopupContainer) leftSplitter.getBottomComponent()).setPopup(c);
break; break;
case NORTH_WEST: case NORTH_WEST :
((PopupContainer) leftSplitter.getTopComponent()).setPopup(c); ((PopupContainer) leftSplitter.getTopComponent()).setPopup(c);
break; break;
case CENTER: case CENTER :
break; break;
} }
} }
@ -381,31 +374,31 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent {
public PopupContainer getContainer(final Alignment alignment) { public PopupContainer getContainer(final Alignment alignment) {
PopupContainer popupComponent; PopupContainer popupComponent;
switch (alignment) { switch (alignment) {
case NORTH: case NORTH :
popupComponent = ((PopupContainer) topSplitter.getLeftComponent()); popupComponent = ((PopupContainer) topSplitter.getLeftComponent());
break; break;
case NORTH_EAST: case NORTH_EAST :
popupComponent = ((PopupContainer) topSplitter.getRightComponent()); popupComponent = ((PopupContainer) topSplitter.getRightComponent());
break; break;
case EAST: case EAST :
popupComponent = ((PopupContainer) rightSplitter.getTopComponent()); popupComponent = ((PopupContainer) rightSplitter.getTopComponent());
break; break;
case SOUTH_EAST: case SOUTH_EAST :
popupComponent = ((PopupContainer) rightSplitter.getBottomComponent()); popupComponent = ((PopupContainer) rightSplitter.getBottomComponent());
break; break;
case SOUTH: case SOUTH :
popupComponent = ((PopupContainer) bottomSplitter.getRightComponent()); popupComponent = ((PopupContainer) bottomSplitter.getRightComponent());
break; break;
case SOUTH_WEST: case SOUTH_WEST :
popupComponent = ((PopupContainer) bottomSplitter.getLeftComponent()); popupComponent = ((PopupContainer) bottomSplitter.getLeftComponent());
break; break;
case WEST: case WEST :
popupComponent = ((PopupContainer) leftSplitter.getBottomComponent()); popupComponent = ((PopupContainer) leftSplitter.getBottomComponent());
break; break;
case NORTH_WEST: case NORTH_WEST :
popupComponent = ((PopupContainer) leftSplitter.getTopComponent()); popupComponent = ((PopupContainer) leftSplitter.getTopComponent());
break; break;
default: default :
throw new IllegalArgumentException("CENTER is not supported"); throw new IllegalArgumentException("CENTER is not supported");
} }
return popupComponent; return popupComponent;
@ -414,8 +407,8 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent {
/** /**
* Get the popup component at the position. * Get the popup component at the position.
* *
* @param a the position. * @param a the position.
* @return the popup component at position. * @return the popup component at position.
*/ */
public Component getPopupComponent(final Alignment a) { public Component getPopupComponent(final Alignment a) {
return getContainer(a).getPopup(); return getContainer(a).getPopup();
@ -427,7 +420,6 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent {
protected final double splitDisable; protected final double splitDisable;
protected final double splitterDisable; protected final double splitterDisable;
public LayoutProportions(final double splitRestore, final double splitterPeerDisable, public LayoutProportions(final double splitRestore, final double splitterPeerDisable,
final double splitDisable, final double splitterDisable) { final double splitDisable, final double splitterDisable) {
this.splitRestore = splitRestore; this.splitRestore = splitRestore;
@ -443,7 +435,6 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent {
protected final double splitDisable; protected final double splitDisable;
protected final double splitterPeerDisable; protected final double splitterPeerDisable;
public LayoutWeights(final double splitEnable, final double splitterDisable, public LayoutWeights(final double splitEnable, final double splitterDisable,
final double splitDisable, final double splitterPeerDisable) { final double splitDisable, final double splitterPeerDisable) {
this.splitEnable = splitEnable; this.splitEnable = splitEnable;

6
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.tabframe; package com.github.weisj.darklaf.components.tabframe;
import com.github.weisj.darklaf.util.Alignment; import java.awt.*;
import javax.swing.*; import javax.swing.*;
import java.awt.*;
import com.github.weisj.darklaf.util.Alignment;
public interface TabFramePopup { public interface TabFramePopup {
String KEY_VISIBLE_TAB = "visibleTab"; String KEY_VISIBLE_TAB = "visibleTab";

4
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.tabframe; package com.github.weisj.darklaf.components.tabframe;
public interface TabFramePopupUI { public interface TabFramePopupUI {}
}

6
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.tabframe; package com.github.weisj.darklaf.components.tabframe;
import com.github.weisj.darklaf.util.Alignment;
import java.awt.*; import java.awt.*;
import com.github.weisj.darklaf.util.Alignment;
public interface TabFrameTab { public interface TabFrameTab {
String KEY_SELECTED = "selected"; String KEY_SELECTED = "selected";
String KEY_CONTENT = "content"; String KEY_CONTENT = "content";
@ -125,5 +126,4 @@ public interface TabFrameTab {
* @param tabFrame the TabFrame. * @param tabFrame the TabFrame.
*/ */
void setTabFrame(JTabFrame tabFrame); void setTabFrame(JTabFrame tabFrame);
} }

6
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.tabframe; package com.github.weisj.darklaf.components.tabframe;
import com.github.weisj.darklaf.util.Alignment; import java.awt.*;
import javax.swing.*; import javax.swing.*;
import java.awt.*;
import com.github.weisj.darklaf.util.Alignment;
public class TabFrameTabContainer extends JPanel implements TabFrameTab { public class TabFrameTabContainer extends JPanel implements TabFrameTab {

10
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.tabframe; 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.icons.EmptyIcon;
import com.github.weisj.darklaf.ui.tabframe.DarkTabFrameTabLabelUI; import com.github.weisj.darklaf.ui.tabframe.DarkTabFrameTabLabelUI;
import com.github.weisj.darklaf.util.Alignment; import com.github.weisj.darklaf.util.Alignment;
import javax.swing.*;
import java.awt.*;
import java.util.Objects;
/** /**
* Tab Component for {@link JTabFrame}. * Tab Component for {@link JTabFrame}.
* *

1
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.tabframe; package com.github.weisj.darklaf.components.tabframe;

6
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.tabframe; package com.github.weisj.darklaf.components.tabframe;
import com.github.weisj.darklaf.util.Alignment; import java.awt.*;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import java.awt.*;
import com.github.weisj.darklaf.util.Alignment;
public abstract class TabFrameUI extends ComponentUI { public abstract class TabFrameUI extends ComponentUI {

10
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.tabframe; package com.github.weisj.darklaf.components.tabframe;
import javax.swing.*;
import javax.swing.plaf.PanelUI;
import java.awt.*; import java.awt.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import javax.swing.*;
import javax.swing.plaf.PanelUI;
/** /**
* Tabbed Popup Component for {@link JTabFrame}. * Tabbed Popup Component for {@link JTabFrame}.
* *
@ -125,7 +127,7 @@ public class TabbedPopup extends PanelPopup {
* Gets the currently selected component from the TabbedPane. * Gets the currently selected component from the TabbedPane.
* *
* @return the selected component. * @return the selected component.
* @see #getTabbedPane() * @see #getTabbedPane()
*/ */
public Component getContentPane() { public Component getContentPane() {
return tabbedPane.getSelectedComponent(); return tabbedPane.getSelectedComponent();
@ -150,7 +152,7 @@ public class TabbedPopup extends PanelPopup {
* TabbedPane. * TabbedPane.
* *
* @return a collection of components. * @return a collection of components.
* @see #getTabbedPane() * @see #getTabbedPane()
*/ */
public Collection<Component> getContentPanes() { public Collection<Component> getContentPanes() {
int size = getTabbedPane().getTabCount(); int size = getTabbedPane().getTabCount();

14
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.tabframe; package com.github.weisj.darklaf.components.tabframe;
import com.github.weisj.darklaf.ui.splitpane.DarkSplitPaneUI; import java.awt.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.plaf.basic.BasicSplitPaneDivider; import javax.swing.plaf.basic.BasicSplitPaneDivider;
import javax.swing.plaf.basic.BasicSplitPaneUI; import javax.swing.plaf.basic.BasicSplitPaneUI;
import java.awt.*;
import com.github.weisj.darklaf.ui.splitpane.DarkSplitPaneUI;
public class ToggleSplitPane extends JSplitPane { public class ToggleSplitPane extends JSplitPane {
@ -49,7 +51,6 @@ public class ToggleSplitPane extends JSplitPane {
putClientProperty(DarkSplitPaneUI.KEY_STYLE, DarkSplitPaneUI.STYLE_INVISIBLE); putClientProperty(DarkSplitPaneUI.KEY_STYLE, DarkSplitPaneUI.STYLE_INVISIBLE);
} }
public boolean isResizable() { public boolean isResizable() {
return resizable; return resizable;
} }
@ -148,7 +149,6 @@ public class ToggleSplitPane extends JSplitPane {
} }
} }
@Override @Override
public void setDividerLocation(final int location) { public void setDividerLocation(final int location) {
if (isInLayout) return; if (isInLayout) return;
@ -165,7 +165,6 @@ public class ToggleSplitPane extends JSplitPane {
isInLayout = false; isInLayout = false;
} }
@Override @Override
public int getMaximumDividerLocation() { public int getMaximumDividerLocation() {
int max = getOrientation() == HORIZONTAL_SPLIT ? getWidth() : getHeight(); int max = getOrientation() == HORIZONTAL_SPLIT ? getWidth() : getHeight();
@ -176,8 +175,7 @@ public class ToggleSplitPane extends JSplitPane {
public int getMinimumDividerLocation() { public int getMinimumDividerLocation() {
Component comp = getRightComponent(); Component comp = getRightComponent();
return comp == null ? 0 : getOrientation() == HORIZONTAL_SPLIT return comp == null ? 0 : getOrientation() == HORIZONTAL_SPLIT
? comp.getMinimumSize().width ? comp.getMinimumSize().width
: comp.getMinimumSize().height; : comp.getMinimumSize().height;
} }
} }

1
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.text; package com.github.weisj.darklaf.components.text;

1
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.text; package com.github.weisj.darklaf.components.text;

19
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.text; package com.github.weisj.darklaf.components.text;
import java.awt.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import javax.swing.text.BadLocationException; import javax.swing.text.BadLocationException;
import javax.swing.text.Highlighter; import javax.swing.text.Highlighter;
import javax.swing.text.JTextComponent; import javax.swing.text.JTextComponent;
import java.awt.*;
public class LineHighlighter implements Highlighter.HighlightPainter, ChangeListener { public class LineHighlighter implements Highlighter.HighlightPainter, ChangeListener {
private JTextComponent component; 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) { public void setColor(final Color color) {
this.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() { private void resetHighlight() {
// Use invokeLater to make sure updates to the Document are completed, // Use invokeLater to make sure updates to the Document are completed,
// otherwise Undo processing causes the modelToView method to loop. // otherwise Undo processing causes the modelToView method to loop.
if (component == null) return; if (component == null) return;
SwingUtilities.invokeLater(() -> { SwingUtilities.invokeLater(() -> {
try { try {
@ -96,7 +98,7 @@ public class LineHighlighter implements Highlighter.HighlightPainter, ChangeList
if (view == null) return; if (view == null) return;
Rectangle currentView = view.getBounds(); 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 != null && lastView.y != currentView.y) {
if (lastView.isEmpty()) { if (lastView.isEmpty()) {
component.repaint(); component.repaint();
@ -105,8 +107,7 @@ public class LineHighlighter implements Highlighter.HighlightPainter, ChangeList
} }
lastView = currentView; lastView = currentView;
} }
} catch (BadLocationException ignored) { } catch (BadLocationException ignored) {}
}
}); });
} }
} }

6
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.text; package com.github.weisj.darklaf.components.text;
import java.awt.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import java.awt.*;
/** /**
* JTextPane that keeps the original width of text. * JTextPane that keeps the original width of text.
* *
* @author Jannis Weis * @author Jannis Weis
* @since 2018 * @since 2018
*/ */
public class NonWrappingEditorPane extends JEditorPane { public class NonWrappingEditorPane extends JEditorPane {

6
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.text; package com.github.weisj.darklaf.components.text;
import java.awt.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import java.awt.*;
/** /**
* JTextPane that keeps the original width of text. * JTextPane that keeps the original width of text.
* *
* @author Jannis Weis * @author Jannis Weis
* @since 2018 * @since 2018
*/ */
public class NonWrappingTextArea extends JTextArea { public class NonWrappingTextArea extends JTextArea {

6
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.text; package com.github.weisj.darklaf.components.text;
import java.awt.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import java.awt.*;
/** /**
* JTextPane that keeps the original width of text. * JTextPane that keeps the original width of text.
* *
* @author Jannis Weis * @author Jannis Weis
* @since 2018 * @since 2018
*/ */
public class NonWrappingTextPane extends JTextPane { public class NonWrappingTextPane extends JTextPane {

6
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.text; package com.github.weisj.darklaf.components.text;
import com.github.weisj.darklaf.components.OverlayScrollPane; import java.awt.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.text.JTextComponent; import javax.swing.text.JTextComponent;
import java.awt.*;
import com.github.weisj.darklaf.components.OverlayScrollPane;
public class NumberedTextComponent extends JPanel { public class NumberedTextComponent extends JPanel {

10
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.text; 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.*;
import javax.swing.text.*; import javax.swing.text.*;
import java.util.*;
import java.util.stream.Collectors; import com.github.weisj.darklaf.util.StringUtil;
public class NumberingPane extends JComponent { 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) public Position addIconAtLine(final int lineIndex, final Icon icon, final boolean atTextStart)
throws BadLocationException { throws BadLocationException {
int offset = textComponent.getDocument().getDefaultRootElement().getElement(lineIndex).getStartOffset(); int offset = textComponent.getDocument().getDefaultRootElement().getElement(lineIndex).getStartOffset();
if (atTextStart) { if (atTextStart) {
Document doc = textComponent.getDocument(); Document doc = textComponent.getDocument();

1
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.text; package com.github.weisj.darklaf.components.text;

1
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.text; package com.github.weisj.darklaf.components.text;

20
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.text; package com.github.weisj.darklaf.components.text;
@ -31,7 +32,7 @@ public class SearchTextField extends JTextField {
public static final int SEARCH = 0; public static final int SEARCH = 0;
/** /**
* Constructs a new <code>TextField</code>. A default model is created, the initial string is <code>null</code>, * Constructs a new <code>TextField</code>. A default model is created, the initial string is <code>null</code>,
* and the number of columns is set to 0. * and the number of columns is set to 0.
*/ */
public SearchTextField() { 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 <code>null</code>, a * This is the constructor through which the other constructors feed. If the document is <code>null</code>, a
* default model is created. * default model is created.
* *
* @param doc the text storage to use; if this is <code>null</code>, a default will be provided by calling the * @param doc the text storage to use; if this is <code>null</code>, a default will be
* <code>createDefaultModel</code> method * provided by calling the
* @param text the initial string to display, or <code>null</code> * <code>createDefaultModel</code> method
* @param columns the number of columns to use to calculate the preferred width &gt;= 0; if <code>columns</code> is * @param text the initial string to display, or <code>null</code>
* set to zero, the preferred width will be whatever naturally results from the component * @param columns the number of columns to use to calculate the preferred width &gt;= 0; if
* implementation * <code>columns</code> is
* set to zero, the preferred width will be whatever naturally results from the
* component
* implementation
* @throws IllegalArgumentException if <code>columns</code> &lt; 0 * @throws IllegalArgumentException if <code>columns</code> &lt; 0
*/ */
public SearchTextField(final Document doc, final String text, final int columns) { public SearchTextField(final Document doc, final String text, final int columns) {
@ -88,7 +92,7 @@ public class SearchTextField extends JTextField {
} }
/** /**
* Constructs a new <code>TextField</code> initialized with the specified text and columns. A default model is * Constructs a new <code>TextField</code> initialized with the specified text and columns. A default model is
* created. * created.
* *
* @param text the text to be displayed, or <code>null</code> * @param text the text to be displayed, or <code>null</code>

37
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.text; package com.github.weisj.darklaf.components.text;
import javax.swing.text.Document;
import java.util.List; 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 * {@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; protected final TextFieldHistoryPopup history;
/** /**
* Constructs a new <code>TextField</code>. A default model is created, the initial string is <code>null</code>, * Constructs a new <code>TextField</code>. A default model is created, the initial string is <code>null</code>,
* and the number of columns is set to 0. * and the number of columns is set to 0.
*/ */
public SearchTextFieldWithHistory() { 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 <code>null</code>, a * This is the constructor through which the other constructors feed. If the document is <code>null</code>, a
* default model is created. * default model is created.
* *
* @param doc the text storage to use; if this is <code>null</code>, a default will be provided by calling the * @param doc the text storage to use; if this is <code>null</code>, a default will be
* <code>createDefaultModel</code> method * provided by calling the
* @param text the initial string to display, or <code>null</code> * <code>createDefaultModel</code> method
* @param columns the number of columns to use to calculate the preferred width &gt;= 0; if <code>columns</code> is * @param text the initial string to display, or <code>null</code>
* set to zero, the preferred width will be whatever naturally results from the component * @param columns the number of columns to use to calculate the preferred width &gt;= 0; if
* implementation * <code>columns</code> is
* set to zero, the preferred width will be whatever naturally results from the
* component
* implementation
* @throws IllegalArgumentException if <code>columns</code> &lt; 0 * @throws IllegalArgumentException if <code>columns</code> &lt; 0
*/ */
public SearchTextFieldWithHistory(final Document doc, final String text, final int columns) { public SearchTextFieldWithHistory(final Document doc, final String text, final int columns) {
@ -85,7 +90,7 @@ public class SearchTextFieldWithHistory extends SearchTextField {
} }
/** /**
* Constructs a new <code>TextField</code> initialized with the specified text and columns. A default model is * Constructs a new <code>TextField</code> initialized with the specified text and columns. A default model is
* created. * created.
* *
* @param text the text to be displayed, or <code>null</code> * @param text the text to be displayed, or <code>null</code>
@ -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 * 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. * wrapped inside a scroll pane.
* * <p>
* <p>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. * @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. * 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. * @param entry the entry to add.
* @see #getLength() getLength * @see #getLength() getLength
* @see #setCapacity(int) setCapacity * @see #setCapacity(int) setCapacity
* @see #getCapacity() getCapacity * @see #getCapacity() getCapacity
*/ */
public void addEntry(final String entry) { public void addEntry(final String entry) {
history.addEntry(entry); history.addEntry(entry);
@ -140,7 +145,7 @@ public class SearchTextFieldWithHistory extends SearchTextField {
* Get the capacity of the history. * Get the capacity of the history.
* *
* @return the capacity. * @return the capacity.
* @see #setCapacity(int) setCapacity() * @see #setCapacity(int) setCapacity()
*/ */
public int getCapacity() { public int getCapacity() {
return history.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. * 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 * @throws IllegalArgumentException if capacity is negative
*/ */
public void setCapacity(final int capacity) throws IllegalArgumentException { public void setCapacity(final int capacity) throws IllegalArgumentException {

22
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.text; 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.components.ScrollPopupMenu;
import com.github.weisj.darklaf.decorators.PlainAction; import com.github.weisj.darklaf.decorators.PlainAction;
import com.github.weisj.darklaf.util.StringUtil; import com.github.weisj.darklaf.util.StringUtil;
import javax.swing.*;
import java.awt.*;
import java.util.List;
import java.util.*;
/** /**
* @author Jannis Weis * @author Jannis Weis
*/ */
@ -73,7 +75,7 @@ public class TextFieldHistoryPopup extends ScrollPopupMenu implements SearchList
* Get the capacity of the history. * Get the capacity of the history.
* *
* @return the capacity. * @return the capacity.
* @see #setCapacity(int) setCapacity() * @see #setCapacity(int) setCapacity()
*/ */
public int getCapacity() { public int getCapacity() {
return capacity; 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. * 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 * @throws IllegalArgumentException if capacity is negative
*/ */
public void setCapacity(final int capacity) throws IllegalArgumentException { 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. * 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. * @param entry the entry to add.
* @see #getLength() getLength * @see #getLength() getLength
* @see #setCapacity(int) setCapacity * @see #setCapacity(int) setCapacity
* @see #getCapacity() getCapacity * @see #getCapacity() getCapacity
*/ */
public void addEntry(final String entry) { public void addEntry(final String entry) {
history.remove(entry); history.remove(entry);

1
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.tooltip; package com.github.weisj.darklaf.components.tooltip;

113
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.tooltip; 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.*;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
@ -38,6 +31,15 @@ import java.awt.event.MouseListener;
import java.awt.geom.Area; import java.awt.geom.Area;
import java.util.function.Function; 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 { public class ToolTipContext {
private static ToolTipContext defaultContext; private static ToolTipContext defaultContext;
@ -108,7 +110,6 @@ public class ToolTipContext {
this(null, null, null, null, true, null); this(null, null, null, null, true, null);
} }
/** /**
* Create a new tooltip context to ease the creation of custom tooltips. * 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. * Set the style of the tooltip.
* *
* @param style the tooltip style. * @param style the tooltip style.
* @return this * @return this
* @see ToolTipStyle ToolTipStyle * @see ToolTipStyle ToolTipStyle
*/ */
public ToolTipContext setToolTipStyle(final ToolTipStyle style) { public ToolTipContext setToolTipStyle(final ToolTipStyle style) {
this.style = style; this.style = style;
@ -164,8 +165,8 @@ public class ToolTipContext {
* <p> * <p>
* Default is false. * Default is false.
* *
* @param updatePosition true if it should be recalculated. * @param updatePosition true if it should be recalculated.
* @return this * @return this
*/ */
public ToolTipContext setUpdatePosition(final boolean updatePosition) { public ToolTipContext setUpdatePosition(final boolean updatePosition) {
return this; return this;
@ -177,7 +178,6 @@ public class ToolTipContext {
* @param target the component which the tooltip belongs to. * @param target the component which the tooltip belongs to.
* @param alignment {@link #setAlignment(Alignment)} * @param alignment {@link #setAlignment(Alignment)}
*/ */
public ToolTipContext(final JComponent target, final Alignment alignment) { public ToolTipContext(final JComponent target, final Alignment alignment) {
this(target, alignment, null, null, true, null); this(target, alignment, null, null, true, null);
} }
@ -187,10 +187,10 @@ public class ToolTipContext {
* not {@link Alignment#CENTER}. Default is true * not {@link Alignment#CENTER}. Default is true
* <p> * <p>
* *
* @param alignInside true if the tooltip should be aligned inside. * @param alignInside true if the tooltip should be aligned inside.
* @return this. * @return this.
* @see #setAlignment(Alignment) * @see #setAlignment(Alignment)
* @see #setToolTipRectSupplier(Function) * @see #setToolTipRectSupplier(Function)
*/ */
public ToolTipContext setAlignInside(final boolean alignInside) { public ToolTipContext setAlignInside(final boolean alignInside) {
this.alignInside = 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 * 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)}. * outside of the rectangle or inside depending on {@link #setAlignInside(boolean)}.
* *
* @param alignment the alignment. * @param alignment the alignment.
* @return this. * @return this.
* @see #setToolTipRectSupplier(Function) * @see #setToolTipRectSupplier(Function)
*/ */
public ToolTipContext setAlignment(final Alignment alignment) { public ToolTipContext setAlignment(final Alignment alignment) {
this.alignment = alignment; this.alignment = alignment;
@ -228,8 +228,8 @@ public class ToolTipContext {
* <p> * <p>
* Default is {@link Alignment#NORTH}. * Default is {@link Alignment#NORTH}.
* *
* @param centerAlignment the center alignment. * @param centerAlignment the center alignment.
* @return this * @return this
*/ */
public ToolTipContext setCenterAlignment(final Alignment centerAlignment) { public ToolTipContext setCenterAlignment(final Alignment centerAlignment) {
this.centerAlignment = 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 * Set the alignment strategy which determines how the current mouse position is considered when calculating the
* tooltip location. * tooltip location.
* <p>
* Default will be {@link AlignmentStrategy#COMPONENT_BOTH}.
* *
* <p>Default will be {@link AlignmentStrategy#COMPONENT_BOTH}. * @param alignmentStrategy the alignment strategy.
* * @return this
* @param alignmentStrategy the alignment strategy. * @see AlignmentStrategy
* @return this
* @see AlignmentStrategy
*/ */
public ToolTipContext setAlignmentStrategy(final AlignmentStrategy alignmentStrategy) { public ToolTipContext setAlignmentStrategy(final AlignmentStrategy alignmentStrategy) {
this.alignmentStrategy = alignmentStrategy; this.alignmentStrategy = alignmentStrategy;
@ -264,7 +264,6 @@ public class ToolTipContext {
* @param alignment {@link #setAlignment(Alignment)} * @param alignment {@link #setAlignment(Alignment)}
* @param centerAlignment {@link #setCenterAlignment(Alignment)} * @param centerAlignment {@link #setCenterAlignment(Alignment)}
*/ */
public ToolTipContext(final JComponent target, final Alignment alignment, final Alignment centerAlignment) { public ToolTipContext(final JComponent target, final Alignment alignment, final Alignment centerAlignment) {
this(target, alignment, centerAlignment, null, true, null); this(target, alignment, centerAlignment, null, true, null);
} }
@ -276,7 +275,6 @@ public class ToolTipContext {
* @param alignment {@link #setAlignment(Alignment)} * @param alignment {@link #setAlignment(Alignment)}
* @param alignInside {@link #setAlignInside(boolean)} * @param alignInside {@link #setAlignInside(boolean)}
*/ */
public ToolTipContext(final JComponent target, final Alignment alignment, final boolean alignInside) { public ToolTipContext(final JComponent target, final Alignment alignment, final boolean alignInside) {
this(target, alignment, null, null, alignInside, null); this(target, alignment, null, null, alignInside, null);
} }
@ -289,7 +287,6 @@ public class ToolTipContext {
* @param centerAlignment {@link #setCenterAlignment(Alignment)} * @param centerAlignment {@link #setCenterAlignment(Alignment)}
* @param alignInside {@link #setAlignInside(boolean)} * @param alignInside {@link #setAlignInside(boolean)}
*/ */
public ToolTipContext(final JComponent target, final Alignment alignment, final Alignment centerAlignment, public ToolTipContext(final JComponent target, final Alignment alignment, final Alignment centerAlignment,
final boolean alignInside) { final boolean alignInside) {
this(target, alignment, centerAlignment, null, alignInside, null); this(target, alignment, centerAlignment, null, alignInside, null);
@ -302,7 +299,6 @@ public class ToolTipContext {
* @param alignment {@link #setAlignment(Alignment)} * @param alignment {@link #setAlignment(Alignment)}
* @param alignmentStrategy {@link #setAlignmentStrategy(AlignmentStrategy)} * @param alignmentStrategy {@link #setAlignmentStrategy(AlignmentStrategy)}
*/ */
public ToolTipContext(final JComponent target, final Alignment alignment, public ToolTipContext(final JComponent target, final Alignment alignment,
final AlignmentStrategy alignmentStrategy) { final AlignmentStrategy alignmentStrategy) {
this(target, alignment, null, alignmentStrategy, true, null); this(target, alignment, null, alignmentStrategy, true, null);
@ -316,7 +312,6 @@ public class ToolTipContext {
* @param centerAlignment {@link #setCenterAlignment(Alignment)} * @param centerAlignment {@link #setCenterAlignment(Alignment)}
* @param alignmentStrategy {@link #setAlignmentStrategy(AlignmentStrategy)} * @param alignmentStrategy {@link #setAlignmentStrategy(AlignmentStrategy)}
*/ */
public ToolTipContext(final JComponent target, final Alignment alignment, final Alignment centerAlignment, public ToolTipContext(final JComponent target, final Alignment alignment, final Alignment centerAlignment,
final AlignmentStrategy alignmentStrategy) { final AlignmentStrategy alignmentStrategy) {
this(target, alignment, centerAlignment, alignmentStrategy, true, null); this(target, alignment, centerAlignment, alignmentStrategy, true, null);
@ -330,7 +325,6 @@ public class ToolTipContext {
* @param alignmentStrategy {@link #setAlignmentStrategy(AlignmentStrategy)} * @param alignmentStrategy {@link #setAlignmentStrategy(AlignmentStrategy)}
* @param alignInside {@link #setAlignInside(boolean)} * @param alignInside {@link #setAlignInside(boolean)}
*/ */
public ToolTipContext(final JComponent target, final Alignment alignment, final AlignmentStrategy alignmentStrategy, public ToolTipContext(final JComponent target, final Alignment alignment, final AlignmentStrategy alignmentStrategy,
final boolean alignInside) { final boolean alignInside) {
this(target, alignment, null, alignmentStrategy, alignInside, null); this(target, alignment, null, alignmentStrategy, alignInside, null);
@ -341,8 +335,8 @@ public class ToolTipContext {
* <p> * <p>
* Default is false. * Default is false.
* *
* @param hideOnExit true if tooltip should hide. * @param hideOnExit true if tooltip should hide.
* @return this. * @return this.
*/ */
public ToolTipContext setHideOnExit(final boolean hideOnExit) { public ToolTipContext setHideOnExit(final boolean hideOnExit) {
this.hideOnExit = hideOnExit; this.hideOnExit = hideOnExit;
@ -362,8 +356,8 @@ public class ToolTipContext {
* <p> * <p>
* Default will be the component bounding rectangle. * Default will be the component bounding rectangle.
* *
* @param toolTipRectSupplier rectangle supplier method. * @param toolTipRectSupplier rectangle supplier method.
* @return this * @return this
*/ */
public ToolTipContext setToolTipRectSupplier(final Function<MouseEvent, Rectangle> toolTipRectSupplier) { public ToolTipContext setToolTipRectSupplier(final Function<MouseEvent, Rectangle> toolTipRectSupplier) {
this.toolTipRectSupplier = toolTipRectSupplier; this.toolTipRectSupplier = toolTipRectSupplier;
@ -377,8 +371,8 @@ public class ToolTipContext {
if (toolTip != null) { if (toolTip != null) {
toolTip.putClientProperty(DarkTooltipUI.KEY_POINTER_LOCATION, toolTip.putClientProperty(DarkTooltipUI.KEY_POINTER_LOCATION,
alignment == Alignment.CENTER alignment == Alignment.CENTER
? centerAlignment.opposite() ? centerAlignment.opposite()
: alignInside ? alignment : alignment.opposite()); : alignInside ? alignment : alignment.opposite());
toolTip.putClientProperty(DarkTooltipUI.KEY_INSETS, insets); toolTip.putClientProperty(DarkTooltipUI.KEY_INSETS, insets);
toolTip.putClientProperty(DarkTooltipUI.KEY_STYLE, style); toolTip.putClientProperty(DarkTooltipUI.KEY_STYLE, style);
toolTip.doLayout(); toolTip.doLayout();
@ -391,8 +385,8 @@ public class ToolTipContext {
* <p> * <p>
* Defaults to * Defaults to
* *
* @param insideRect the area to check. * @param insideRect the area to check.
* @return this. * @return this.
*/ */
public ToolTipContext setInsideArea(final Area insideRect) { public ToolTipContext setInsideArea(final Area insideRect) {
this.hotSpotArea = insideRect; this.hotSpotArea = insideRect;
@ -405,8 +399,8 @@ public class ToolTipContext {
* <p> * <p>
* Default is false. * Default is false.
* *
* @param applyInsetsToRect true if they should be applied. * @param applyInsetsToRect true if they should be applied.
* @return this. * @return this.
*/ */
public ToolTipContext setApplyComponentInsetsToRect(final boolean applyInsetsToRect) { public ToolTipContext setApplyComponentInsetsToRect(final boolean applyInsetsToRect) {
this.applyInsetsToRect = applyInsetsToRect; this.applyInsetsToRect = applyInsetsToRect;
@ -414,9 +408,9 @@ public class ToolTipContext {
} }
/** /**
* @param insideRect the rectangle to check. * @param insideRect the rectangle to check.
* @return this * @return this
* @see #setInsideArea(Area) * @see #setInsideArea(Area)
*/ */
public ToolTipContext setInsideArea(final Rectangle insideRect) { public ToolTipContext setInsideArea(final Rectangle insideRect) {
this.hotSpotArea = new Area(insideRect); this.hotSpotArea = new Area(insideRect);
@ -426,8 +420,8 @@ public class ToolTipContext {
/** /**
* Sets insets for the tooltip. * Sets insets for the tooltip.
* *
* @param insets the insets to set. * @param insets the insets to set.
* @return this. * @return this.
*/ */
public ToolTipContext setToolTipInsets(final Insets insets) { public ToolTipContext setToolTipInsets(final Insets insets) {
this.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 * 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. * content rect and not the component bounds.
* *
* @param ignoreBorder true if border insets should be ignored. * @param ignoreBorder true if border insets should be ignored.
* @return this. * @return this.
*/ */
public ToolTipContext setIgnoreBorder(final boolean ignoreBorder) { public ToolTipContext setIgnoreBorder(final boolean ignoreBorder) {
this.ignoreBorder = 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. * Sets whether the tooltip should try its best to fit inside the window/screen.
* *
* @param bestFit true if best fit adjustments should be made. * @param bestFit true if best fit adjustments should be made.
* @return this. * @return this.
*/ */
public ToolTipContext setUseBestFit(final boolean bestFit) { public ToolTipContext setUseBestFit(final boolean bestFit) {
this.bestFit = bestFit; this.bestFit = bestFit;
@ -465,10 +459,10 @@ public class ToolTipContext {
/** /**
* Calculates the tooltip location. * Calculates the tooltip location.
* *
* @param mp the mouse position in the target component coordinate space. * @param mp the mouse position in the target component coordinate space.
* @param mouseEvent the mouse event. * @param mouseEvent the mouse event.
* @return the tooltip location. * @return the tooltip location.
* @see JComponent#getToolTipLocation(MouseEvent) * @see JComponent#getToolTipLocation(MouseEvent)
*/ */
public Point getToolTipLocation(final Point mp, final MouseEvent mouseEvent) { public Point getToolTipLocation(final Point mp, final MouseEvent mouseEvent) {
if (target == null) return null; if (target == null) return null;
@ -529,7 +523,7 @@ public class ToolTipContext {
* Get the tooltip. * Get the tooltip.
* *
* @return the tooltip. * @return the tooltip.
* @see JComponent#createToolTip() * @see JComponent#createToolTip()
*/ */
public JToolTip getToolTip() { public JToolTip getToolTip() {
if (toolTip == null) { if (toolTip == null) {
@ -551,7 +545,6 @@ public class ToolTipContext {
return dim; return dim;
} }
private Point alignCenter(final Dimension dim, final Rectangle rect) { private Point alignCenter(final Dimension dim, final Rectangle rect) {
rect.x += rect.width / 2; rect.x += rect.width / 2;
rect.y += rect.height / 2; rect.y += rect.height / 2;

1
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.tooltip; package com.github.weisj.darklaf.components.tooltip;

5
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.tooltip; package com.github.weisj.darklaf.components.tooltip;
import javax.swing.*;
import com.github.weisj.darklaf.ui.tooltip.DarkTooltipUI; import com.github.weisj.darklaf.ui.tooltip.DarkTooltipUI;
import com.github.weisj.darklaf.util.Alignment; import com.github.weisj.darklaf.util.Alignment;
import javax.swing.*;
public class TooltipAwareButton extends JButton implements ToolTipAware { public class TooltipAwareButton extends JButton implements ToolTipAware {
private ToolTipContext context; private ToolTipContext context;

5
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.tooltip; package com.github.weisj.darklaf.components.tooltip;
import javax.swing.*;
import com.github.weisj.darklaf.ui.tooltip.DarkTooltipUI; import com.github.weisj.darklaf.ui.tooltip.DarkTooltipUI;
import com.github.weisj.darklaf.util.Alignment; import com.github.weisj.darklaf.util.Alignment;
import javax.swing.*;
public class TooltipAwareToggleButton extends JToggleButton implements ToolTipAware { public class TooltipAwareToggleButton extends JToggleButton implements ToolTipAware {
private ToolTipContext context; private ToolTipContext context;

6
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.tristate; package com.github.weisj.darklaf.components.tristate;
import javax.swing.*;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import javax.swing.*;
public class TristateButtonModel extends JToggleButton.ToggleButtonModel { public class TristateButtonModel extends JToggleButton.ToggleButtonModel {
private TristateState state = TristateState.DESELECTED; private TristateState state = TristateState.DESELECTED;
@ -80,7 +82,7 @@ public class TristateButtonModel extends JToggleButton.ToggleButtonModel {
displayState(); displayState();
fireStateChanged(); fireStateChanged();
int indeterminate = 3; int indeterminate = 3;
//noinspection MagicConstant // noinspection MagicConstant
fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED, this, indeterminate)); fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED, this, indeterminate));
} }
} }

11
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.tristate; 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.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.InputEvent; import java.awt.event.InputEvent;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import javax.swing.*;
import javax.swing.event.ChangeListener;
import com.github.weisj.darklaf.DarkLaf;
public class TristateCheckBox extends JCheckBox { public class TristateCheckBox extends JCheckBox {
private final ChangeListener enableListener = e -> TristateCheckBox.this.setFocusable(getModel().isEnabled()); private final ChangeListener enableListener = e -> TristateCheckBox.this.setFocusable(getModel().isEnabled());
@ -74,7 +76,6 @@ public class TristateCheckBox extends JCheckBox {
return (TristateButtonModel) super.getModel(); return (TristateButtonModel) super.getModel();
} }
public String getUIClassID() { public String getUIClassID() {
if (UIManager.getLookAndFeel() instanceof DarkLaf) { if (UIManager.getLookAndFeel() instanceof DarkLaf) {
return "TristateCheckBoxUI"; return "TristateCheckBoxUI";

10
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.tristate; package com.github.weisj.darklaf.components.tristate;
import com.github.weisj.darklaf.DarkLaf;
import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.InputEvent; import java.awt.event.InputEvent;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import javax.swing.*;
import com.github.weisj.darklaf.DarkLaf;
public class TristateCheckBoxMenuItem extends JCheckBoxMenuItem { 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. * Creates a menu item whose properties are taken from the Action supplied.
* *
* @param a the action of the {@code JCheckBoxMenuItem} * @param a the action of the {@code JCheckBoxMenuItem}
* @since 1.3 * @since 1.3
*/ */
public TristateCheckBoxMenuItem(final Action a) { public TristateCheckBoxMenuItem(final Action a) {
this(); this();

1
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.tristate; package com.github.weisj.darklaf.components.tristate;

10
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.uiresource; 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 bottom the inset from the bottom.
* @param right the inset from the right. * @param right the inset from the right.
*/ */
public Insets2D(final double top, final double left, final double bottom, final double right) { public Insets2D(final double top, final double left, final double bottom, final double right) {
this.top = top; this.top = top;
this.left = left; this.left = left;
@ -53,7 +53,7 @@ public final class Insets2D implements Cloneable {
* @param left the inset from the left. * @param left the inset from the left.
* @param bottom the inset from the bottom. * @param bottom the inset from the bottom.
* @param right the inset from the right. * @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) { public void set(final double top, final double left, final double bottom, final double right) {
this.top = top; this.top = top;
@ -62,7 +62,6 @@ public final class Insets2D implements Cloneable {
this.right = right; this.right = right;
} }
@Override @Override
public int hashCode() { public int hashCode() {
double sum1 = left + bottom; double sum1 = left + bottom;
@ -73,7 +72,6 @@ public final class Insets2D implements Cloneable {
return (int) (sum3 * (sum3 + 1) / 2 + val2); return (int) (sum3 * (sum3 + 1) / 2 + val2);
} }
@Override @Override
public boolean equals(final Object obj) { public boolean equals(final Object obj) {
if (obj instanceof Insets2D) { if (obj instanceof Insets2D) {
@ -84,16 +82,12 @@ public final class Insets2D implements Cloneable {
return false; return false;
} }
@Override @Override
public Insets2D clone() { public Insets2D clone() {
return new Insets2D(top, left, bottom, right); return new Insets2D(top, left, bottom, right);
} }
public String toString() { public String toString() {
return getClass().getName() + "[top=" + top + ",left=" + left + ",bottom=" + bottom + ",right=" + right + "]"; return getClass().getName() + "[top=" + top + ",left=" + left + ",bottom=" + bottom + ",right=" + right + "]";
} }
} }

1
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.uiresource; package com.github.weisj.darklaf.components.uiresource;

1
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.uiresource; package com.github.weisj.darklaf.components.uiresource;

4
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.uiresource; package com.github.weisj.darklaf.components.uiresource;
import java.awt.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.plaf.UIResource; import javax.swing.plaf.UIResource;
import java.awt.*;
public class JPanelUIResource extends JPanel implements UIResource { public class JPanelUIResource extends JPanel implements UIResource {

7
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.components.uiresource; package com.github.weisj.darklaf.components.uiresource;
import javax.swing.border.Border;
import java.awt.*; import java.awt.*;
import javax.swing.border.Border;
public class UIResourceWrapper extends JPanelUIResource { public class UIResourceWrapper extends JPanelUIResource {
public UIResourceWrapper(final Component component) { public UIResourceWrapper(final Component component) {
@ -41,8 +43,7 @@ public class UIResourceWrapper extends JPanelUIResource {
} }
@Override @Override
public void setOpaque(final boolean isOpaque) { public void setOpaque(final boolean isOpaque) {}
}
@Override @Override
public boolean isOpaque() { public boolean isOpaque() {

10
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.decorators; package com.github.weisj.darklaf.decorators;
@ -28,14 +29,11 @@ import javax.swing.event.AncestorListener;
public class AncestorAdapter implements AncestorListener { public class AncestorAdapter implements AncestorListener {
@Override @Override
public void ancestorAdded(final AncestorEvent event) { public void ancestorAdded(final AncestorEvent event) {}
}
@Override @Override
public void ancestorRemoved(final AncestorEvent event) { public void ancestorRemoved(final AncestorEvent event) {}
}
@Override @Override
public void ancestorMoved(final AncestorEvent event) { public void ancestorMoved(final AncestorEvent event) {}
}
} }

4
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.decorators; package com.github.weisj.darklaf.decorators;
public interface CellRenderer { public interface CellRenderer {}
}

12
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.decorators; package com.github.weisj.darklaf.decorators;
@ -30,21 +31,18 @@ import java.awt.event.ComponentListener;
* Wrapper interface for resize listener. * Wrapper interface for resize listener.
* *
* @author Jannis Weis * @author Jannis Weis
* @since 2019 * @since 2019
*/ */
public interface ComponentResizeListener extends ComponentListener { public interface ComponentResizeListener extends ComponentListener {
@Override @Override
void componentResized(ComponentEvent e); void componentResized(ComponentEvent e);
@Override @Override
default void componentMoved(final ComponentEvent e) { default void componentMoved(final ComponentEvent e) {}
}
@Override @Override
default void componentShown(final ComponentEvent e) { default void componentShown(final ComponentEvent e) {}
}
@Override @Override
default void componentHidden(final ComponentEvent e) { default void componentHidden(final ComponentEvent e) {}
}
} }

5
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.decorators; package com.github.weisj.darklaf.decorators;
import javax.swing.*;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import javax.swing.*;
/** /**
* @author Jannis Weis * @author Jannis Weis
*/ */
@ -36,7 +38,6 @@ public class HoverListener implements MouseListener {
private boolean hover = false; private boolean hover = false;
private boolean scheduled = false; private boolean scheduled = false;
public HoverListener(final JComponent component) { public HoverListener(final JComponent component) {
this.component = component; this.component = component;
} }

2
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.decorators; package com.github.weisj.darklaf.decorators;
@ -28,7 +29,6 @@ import java.awt.*;
public class LayoutManagerDelegate implements LayoutManager { public class LayoutManagerDelegate implements LayoutManager {
private final LayoutManager delegate; private final LayoutManager delegate;
public LayoutManagerDelegate(final LayoutManager delegate) { public LayoutManagerDelegate(final LayoutManager delegate) {
if (delegate == null) { if (delegate == null) {
throw new IllegalArgumentException("Delegate is null"); throw new IllegalArgumentException("Delegate is null");

13
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.decorators; package com.github.weisj.darklaf.decorators;
@ -33,18 +34,14 @@ public interface MouseClickListener extends MouseListener {
void mouseClicked(MouseEvent e); void mouseClicked(MouseEvent e);
@Override @Override
default void mousePressed(final MouseEvent e) { default void mousePressed(final MouseEvent e) {}
}
@Override @Override
default void mouseReleased(final MouseEvent e) { default void mouseReleased(final MouseEvent e) {}
}
@Override @Override
default void mouseEntered(final MouseEvent e) { default void mouseEntered(final MouseEvent e) {}
}
@Override @Override
default void mouseExited(final MouseEvent e) { default void mouseExited(final MouseEvent e) {}
}
} }

10
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.decorators; package com.github.weisj.darklaf.decorators;
import javax.swing.event.MouseInputListener;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener; import java.awt.event.MouseMotionListener;
import javax.swing.event.MouseInputListener;
public class MouseInputDelegate implements MouseInputListener { public class MouseInputDelegate implements MouseInputListener {
protected MouseListener mouseDelegate; protected MouseListener mouseDelegate;
@ -62,16 +64,14 @@ public class MouseInputDelegate implements MouseInputListener {
public void setMotionDelegate(final MouseMotionListener motionDelegate) { public void setMotionDelegate(final MouseMotionListener motionDelegate) {
this.motionDelegate = motionDelegate; this.motionDelegate = motionDelegate;
if (motionDelegate == null) { if (motionDelegate == null) {
this.motionDelegate = new MouseAdapter() { this.motionDelegate = new MouseAdapter() {};
};
} }
} }
public void setMouseDelegate(final MouseListener delegate) { public void setMouseDelegate(final MouseListener delegate) {
this.mouseDelegate = delegate; this.mouseDelegate = delegate;
if (delegate == null) { if (delegate == null) {
this.mouseDelegate = new MouseAdapter() { this.mouseDelegate = new MouseAdapter() {};
};
} }
} }

4
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.decorators; package com.github.weisj.darklaf.decorators;
@ -29,8 +30,7 @@ import java.awt.event.MouseMotionListener;
public interface MouseMovementListener extends MouseMotionListener { public interface MouseMovementListener extends MouseMotionListener {
@Override @Override
default void mouseDragged(final MouseEvent e) { default void mouseDragged(final MouseEvent e) {}
}
@Override @Override
void mouseMoved(MouseEvent e); void mouseMoved(MouseEvent e);

2
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.decorators; package com.github.weisj.darklaf.decorators;
@ -31,7 +32,6 @@ public class MouseResponder implements MouseListener {
private final Consumer<MouseEvent> consumer; private final Consumer<MouseEvent> consumer;
public MouseResponder(final Consumer<MouseEvent> consumer) { public MouseResponder(final Consumer<MouseEvent> consumer) {
this.consumer = consumer; this.consumer = consumer;
} }

4
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.decorators; package com.github.weisj.darklaf.decorators;
import javax.swing.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import javax.swing.*;
/** /**
* @author Jannis Weis * @author Jannis Weis
*/ */

1
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.decorators; package com.github.weisj.darklaf.decorators;

1
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.decorators; package com.github.weisj.darklaf.decorators;

6
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.log; package com.github.weisj.darklaf.log;
import com.github.weisj.darklaf.util.StringUtil;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.logging.Formatter; import java.util.logging.Formatter;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.LogRecord; import java.util.logging.LogRecord;
import com.github.weisj.darklaf.util.StringUtil;
/** /**
* @author Jannis Weis * @author Jannis Weis
*/ */
@ -98,7 +99,6 @@ public class LogFormatter extends Formatter {
return builder.toString(); return builder.toString();
} }
private String calculateDateString(final long milliseconds) { private String calculateDateString(final long milliseconds) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date(milliseconds); Date date = new Date(milliseconds);

18
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.platform; 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.DarkLaf;
import com.github.weisj.darklaf.LafManager; import com.github.weisj.darklaf.LafManager;
import com.github.weisj.darklaf.platform.decorations.CustomTitlePane; 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.PropertyValue;
import com.github.weisj.darklaf.util.SystemInfo; import com.github.weisj.darklaf.util.SystemInfo;
import javax.swing.*;
import java.awt.*;
import java.util.Properties;
public class DecorationsHandler { public class DecorationsHandler {
public static final String DECORATIONS_FLAG = DarkLaf.SYSTEM_PROPERTY_PREFIX + "decorations"; public static final String DECORATIONS_FLAG = DarkLaf.SYSTEM_PROPERTY_PREFIX + "decorations";
@ -54,19 +56,19 @@ public class DecorationsHandler {
protected DecorationsHandler() { protected DecorationsHandler() {
try { try {
//Extend for different platforms. // Extend for different platforms.
boolean enableDecorations = isNativeDecorationsEnabled(); boolean enableDecorations = isNativeDecorationsEnabled();
if (SystemInfo.isWindows10 && enableDecorations) { 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(); decorationsProvider = new WindowsDecorationsProvider();
} else if (SystemInfo.isMacOSYosemite && enableDecorations) { } 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(); decorationsProvider = new MacOSDecorationsProvider();
} else { } else {
decorationsProvider = new DefaultDecorationsProvider(); decorationsProvider = new DefaultDecorationsProvider();
} }
} catch (Throwable e) { } catch (Throwable e) {
//If decorations modules are not available disable them. // If decorations modules are not available disable them.
decorationsProvider = new DefaultDecorationsProvider(); decorationsProvider = new DefaultDecorationsProvider();
} }
} }

22
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.platform; 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.awt.*;
import java.util.Properties; 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 { public class DefaultDecorationsProvider implements DecorationsProvider {
@Override @Override
public CustomTitlePane createTitlePane(final JRootPane rootPane, final int decorationStyle, final Window window) { public CustomTitlePane createTitlePane(final JRootPane rootPane, final int decorationStyle, final Window window) {
return new CustomTitlePane() { return new CustomTitlePane() {
@Override @Override
public void install() { public void install() {}
}
@Override @Override
public void uninstall() { public void uninstall() {}
}
@Override @Override
public Insets getWindowSizeAdjustment() { public Insets getWindowSizeAdjustment() {
@ -55,10 +55,8 @@ public class DefaultDecorationsProvider implements DecorationsProvider {
} }
@Override @Override
public void initialize() { public void initialize() {}
}
@Override @Override
public void loadDecorationProperties(final Properties properties, final UIDefaults currentDefaults) { public void loadDecorationProperties(final Properties properties, final UIDefaults currentDefaults) {}
}
} }

14
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, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.platform; 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.ColorToneRule;
import com.github.weisj.darklaf.theme.info.ContrastRule; import com.github.weisj.darklaf.theme.info.ContrastRule;
import com.github.weisj.darklaf.theme.info.PreferredThemeStyle; import com.github.weisj.darklaf.theme.info.PreferredThemeStyle;
import com.github.weisj.darklaf.theme.info.ThemePreferenceProvider; import com.github.weisj.darklaf.theme.info.ThemePreferenceProvider;
import java.util.function.Consumer;
public class DefaultThemePreferenceProvider implements ThemePreferenceProvider { public class DefaultThemePreferenceProvider implements ThemePreferenceProvider {
@Override @Override
public PreferredThemeStyle getPreference() { public PreferredThemeStyle getPreference() {
@ -37,16 +38,13 @@ public class DefaultThemePreferenceProvider implements ThemePreferenceProvider {
} }
@Override @Override
public void initialize() { public void initialize() {}
}
@Override @Override
public void setCallback(final Consumer<PreferredThemeStyle> callback) { public void setCallback(final Consumer<PreferredThemeStyle> callback) {}
}
@Override @Override
public void setReporting(final boolean reporting) { public void setReporting(final boolean reporting) {}
}
@Override @Override
public boolean isReporting() { public boolean isReporting() {

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save