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

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

1
README.md

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

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.LineEndings
import com.github.vlsi.gradle.properties.dsl.props
@ -5,6 +7,7 @@ import com.github.vlsi.gradle.publishing.dsl.simplifyXml
import com.github.vlsi.gradle.publishing.dsl.versionFromResolution
plugins {
id("com.github.autostyle")
id("com.github.vlsi.crlf")
id("com.github.vlsi.gradle-extensions")
id("com.github.vlsi.stage-vote-release")
@ -13,6 +16,7 @@ plugins {
val skipJavadoc by props()
val enableMavenLocal by props()
val enableGradleMetadata by props()
val skipAutostyle by props()
val String.v: String get() = rootProject.extra["$this.version"] as String
@ -40,6 +44,18 @@ releaseParams {
}
}
fun BaseFormatExtension.license() {
licenseHeader(File("${project.rootDir}/LICENSE").readText()) {
filter {
exclude("**/org/pbjar/jxlayer/*")
}
copyrightStyle("bat", DefaultCopyrightStyle.REM)
copyrightStyle("cmd", DefaultCopyrightStyle.REM)
}
trimTrailingWhitespace()
endWithNewline()
}
allprojects {
group = "com.github.weisj"
version = buildVersion
@ -51,6 +67,34 @@ allprojects {
mavenCentral()
}
if (!skipAutostyle) {
apply(plugin = "com.github.autostyle")
autostyle {
kotlinGradle {
ktlint()
}
format("configs") {
filter {
include("**/*.sh", "**/*.bsh", "**/*.cmd", "**/*.bat")
include("**/*.properties", "**/*.yml")
include("**/*.xsd", "**/*.xsl", "**/*.xml")
// Autostyle does not support gitignore yet https://github.com/autostyle/autostyle/issues/13
exclude("out/**")
if (project == rootProject) {
exclude("gradlew*")
} else {
exclude("bin/**")
}
}
license()
}
format("markdown") {
filter.include("**/*.md")
endWithNewline()
}
}
}
tasks.withType<AbstractArchiveTask>().configureEach {
// Ensure builds are reproducible
isPreserveFileTimestamps = false
@ -107,6 +151,19 @@ allprojects {
}
}
if (!skipAutostyle) {
autostyle {
java {
importOrder("java", "javax", "org", "com")
removeUnusedImports()
license()
eclipse {
configFile("${project.rootDir}/darklaf_java.eclipseformat.xml")
}
}
}
}
apply(plugin = "maven-publish")
val generatePomFile by props()
@ -173,7 +230,7 @@ allprojects {
configure<PublishingExtension> {
if (project.path.startsWith(":darklaf-dependencies-bom") ||
project.path == ":") {
project.path == ":") {
// We don't it to Central for now
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 {
`java-library`
id("com.github.johnrengelman.shadow")
@ -23,18 +20,6 @@ dependencies {
testImplementation("org.swinglabs:swingx")
}
tasks.jar {
CrLfSpec(LineEndings.LF).run {
into("META-INF") {
filteringCharset = "UTF-8"
textFrom("licenses/NOTICE.txt")
textFrom("licenses/DARCULA_LICENSE.txt")
textFrom("licenses/PBJAR_LICENSE.txt")
textFrom("licenses/INTELLIJ_LICENSE.txt")
}
}
}
val makeDocumentation by tasks.registering(JavaExec::class) {
group = "Development"
description = "Builds the documentation"
@ -66,10 +51,13 @@ tasks.shadowJar {
abstract class DemoTask : JavaExec() {
init {
setMain("UIDemo")
main = "UIDemo"
}
@Option(option = "class", description = "Specifies the main class to run (e.g. UIDemo, ui.table.TableDemo, ui.button.ButtonDemo, ...)")
@Option(
option = "class",
description = "Specifies the main class to run (e.g. UIDemo, ui.table.TableDemo, ui.button.ButtonDemo, ...)"
)
override fun setMain(mainClassName: String?) = super.setMain(mainClassName)
}
@ -86,6 +74,7 @@ val runDemo by tasks.registering(DemoTask::class) {
val value = System.getProperty(name) ?: default
value?.let { systemProperty(name, it) }
}
val props = System.getProperties()
@Suppress("UNCHECKED_CAST")
for (e in props.propertyNames() as `java.util`.Enumeration<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"?>
<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">
<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>
<organization>
<name>com.github.weisj</name>
<url>https://github.com/weisj</url>
</organization>
<licenses>
<license>
<name>MIT</name>
<url>https://github.com/weisJ/darklaf/blob/master/LICENSE</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<name>Jannis Weis</name>
</developer>
</developers>
<scm>
<connection>scm:git:git://github.com/weisJ/darklaf.git</connection>
<developerConnection>scm:git:ssh://git@github.com:weisj/darklaf.git</developerConnection>
<!--
~ 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.
~
-->
<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">
<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>
</scm>
<issueManagement>
<system>GitHub</system>
<url>https://github.com/weisJ/darklaf/issues</url>
</issueManagement>
<dependencies>
<dependency>
<groupId>com.github.weisj</groupId>
<artifactId>darklaf-native-utils</artifactId>
<version>1.4.3.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.github.weisj</groupId>
<artifactId>darklaf-utils</artifactId>
<version>1.4.3.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.github.weisj</groupId>
<artifactId>darklaf-decorations-base</artifactId>
<version>1.4.3.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.github.weisj</groupId>
<artifactId>darklaf-windows</artifactId>
<version>1.4.3.1</version>
<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>
<organization>
<name>com.github.weisj</name>
<url>https://github.com/weisj</url>
</organization>
<licenses>
<license>
<name>MIT</name>
<url>https://github.com/weisJ/darklaf/blob/master/LICENSE</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<name>Jannis Weis</name>
</developer>
</developers>
<scm>
<connection>scm:git:git://github.com/weisJ/darklaf.git</connection>
<developerConnection>scm:git:ssh://git@github.com:weisj/darklaf.git</developerConnection>
<url>https://github.com/weisJ/darklaf</url>
</scm>
<issueManagement>
<system>GitHub</system>
<url>https://github.com/weisJ/darklaf/issues</url>
</issueManagement>
<dependencies>
<dependency>
<groupId>com.github.weisj</groupId>
<artifactId>darklaf-native-utils</artifactId>
<version>1.4.3.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.github.weisj</groupId>
<artifactId>darklaf-utils</artifactId>
<version>1.4.3.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.github.weisj</groupId>
<artifactId>darklaf-decorations-base</artifactId>
<version>1.4.3.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.github.weisj</groupId>
<artifactId>darklaf-windows</artifactId>
<version>1.4.3.1</version>
<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>

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

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

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

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

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

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

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

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

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

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

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,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
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,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.weisj.darklaf.components;
import com.github.weisj.darklaf.ui.colorchooser.ColorListener;
import com.github.weisj.darklaf.util.GraphicsContext;
import com.github.weisj.darklaf.util.GraphicsUtil;
import com.github.weisj.darklaf.util.TimerUtil;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.Ellipse2D;
import java.awt.image.BufferedImage;
import javax.swing.*;
import com.github.weisj.darklaf.ui.colorchooser.ColorListener;
import com.github.weisj.darklaf.util.GraphicsContext;
import com.github.weisj.darklaf.util.GraphicsUtil;
import com.github.weisj.darklaf.util.TimerUtil;
public class DefaultColorPipette extends ColorPipetteBase {
private static final int SIZE = 36;
private static final int DIALOG_SIZE = 50;
@ -196,7 +198,7 @@ public class DefaultColorPipette extends ColorPipetteBase {
GraphicsUtil.setupStrokePainting(g2);
Graphics2D g = (Graphics2D) g2;
//Draw region to be recognised as inside the window.
// Draw region to be recognised as inside the window.
g.setColor(Color.WHITE);
GraphicsContext config = GraphicsUtil.paintWithAlpha(g, 0.005f);
Point p = MouseInfo.getPointerInfo().getLocation();

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

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,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.weisj.darklaf.components;
import com.github.weisj.darklaf.ui.scrollpane.ScrollLayoutManagerDelegate;
import java.awt.*;
import javax.swing.*;
import javax.swing.plaf.ScrollPaneUI;
import java.awt.*;
import com.github.weisj.darklaf.ui.scrollpane.ScrollLayoutManagerDelegate;
/**
* Scroll pane that displays its content beneath the scrollbar.
@ -54,7 +56,7 @@ public class OverlayScrollPane extends JLayeredPane {
* scrolling in underway or the mouse is over the scrollbar position.
*
* @param view the component to display in the scrollable viewport
* @see JScrollPane#setViewportView
* @see JScrollPane#setViewportView
*/
public OverlayScrollPane(final JComponent view) {
this(view, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
@ -64,7 +66,8 @@ public class OverlayScrollPane extends JLayeredPane {
* Creates a JScrollIndicator that displays the view component in a viewport whose view position can be controlled
* with a pair of scrollbars. The scrollbar policies specify when the scrollbars are displayed, For example, if
* vsbPolicy is JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED then the vertical scrollbar only appears if the view
* doesn't fit vertically. The available policy settings are listed at {@link JScrollPane#setVerticalScrollBarPolicy(int)}
* doesn't fit vertically. The available policy settings are listed at
* {@link JScrollPane#setVerticalScrollBarPolicy(int)}
* and {@link JScrollPane#setHorizontalScrollBarPolicy}.
*
* @param view the view of the component.
@ -89,7 +92,6 @@ public class OverlayScrollPane extends JLayeredPane {
*
* @return the scrollPane
*/
public JScrollPane getScrollPane() {
return scrollPane;
}
@ -111,7 +113,6 @@ public class OverlayScrollPane extends JLayeredPane {
controlPanel.showHorizontalScrollBar(policy != JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
}
public JScrollBar getVerticalScrollBar() {
return scrollPane.verticalScrollBar;
}
@ -121,7 +122,6 @@ public class OverlayScrollPane extends JLayeredPane {
return scrollPane.getPreferredSize();
}
public JScrollBar getHorizontalScrollBar() {
return scrollPane.horizontalScrollBar;
}
@ -148,7 +148,6 @@ public class OverlayScrollPane extends JLayeredPane {
private JScrollBar verticalScrollBar;
private JScrollBar horizontalScrollBar;
protected OScrollPane(final JComponent view, final int vsbPolicy, final int hsbPolicy) {
super(view, vsbPolicy, hsbPolicy);
}
@ -294,12 +293,9 @@ public class OverlayScrollPane extends JLayeredPane {
&& scrollPane.verticalScrollBar.getBounds().contains(x, y);
}
@Override
public boolean isOpaque() {
return false;
}
}
}

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

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

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

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

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

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,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.weisj.darklaf.components.border;
import com.github.weisj.darklaf.util.ImageUtil;
import javax.swing.border.Border;
import java.awt.*;
import java.awt.geom.RoundRectangle2D;
import java.awt.image.BufferedImage;
@ -37,17 +34,24 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import javax.swing.border.Border;
import com.github.weisj.darklaf.util.ImageUtil;
/**
* Implements a DropShadow for components. In general, the DropShadowBorder will work with any rectangular components
* that do not have a default border installed as part of the look and feel, or otherwise. For example, DropShadowBorder
* works wonderfully with JPanel, but horribly with JComboBox.
* <p>
* Note: {@code DropShadowBorder} should usually be added to non-opaque components, otherwise the background is likely
* to bleed through.</p>
* <p>Note: Since generating drop shadows is relatively expensive operation,
* to bleed through.
* </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
* 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 Jannis Weis
@ -63,18 +67,15 @@ public class DropShadowBorder implements Border, Serializable {
private boolean showBottomShadow;
private boolean showRightShadow;
public DropShadowBorder() {
this(Color.BLACK, 5);
}
public DropShadowBorder(final Color shadowColor, final int shadowSize) {
this(shadowColor, shadowSize, .5f, 12, false, true,
true, true);
}
public DropShadowBorder(final Color shadowColor, final int shadowSize,
final float shadowOpacity, final int cornerSize, final boolean showTopShadow,
final boolean showLeftShadow, final boolean showBottomShadow,
@ -89,7 +90,6 @@ public class DropShadowBorder implements Border, Serializable {
setShowRightShadow(showRightShadow);
}
@Override
public void paintBorder(final Component c, final Graphics graphics,
final int x, final int y, final int width, final int height) {
@ -102,14 +102,14 @@ public class DropShadowBorder implements Border, Serializable {
Graphics2D g2 = (Graphics2D) graphics.create();
try {
//The location and size of the shadows depends on which shadows are being
//drawn. For instance, if the left & bottom shadows are being drawn, then
//the left shadow extends all the way down to the corner, a corner is drawn,
//and then the bottom shadow begins at the corner. If, however, only the
//bottom shadow is drawn, then the bottom-left corner is drawn to the
//right of the corner, and the bottom shadow is somewhat shorter than before.
// The location and size of the shadows depends on which shadows are being
// drawn. For instance, if the left & bottom shadows are being drawn, then
// the left shadow extends all the way down to the corner, a corner is drawn,
// and then the bottom shadow begins at the corner. If, however, only the
// bottom shadow is drawn, then the bottom-left corner is drawn to the
// right of the corner, and the bottom shadow is somewhat shorter than before.
int shadowOffset = 2; //the distance between the shadow and the edge
int shadowOffset = 2; // the distance between the shadow and the edge
Point topLeftShadowPoint = null;
if (showLeftShadow || showTopShadow) {
@ -166,9 +166,8 @@ public class DropShadowBorder implements Border, Serializable {
if (showLeftShadow) {
assert topLeftShadowPoint != null && bottomLeftShadowPoint != null;
Rectangle leftShadowRect =
new Rectangle(x, topLeftShadowPoint.y + shadowSize, shadowSize,
bottomLeftShadowPoint.y - topLeftShadowPoint.y - shadowSize);
Rectangle leftShadowRect = new Rectangle(x, topLeftShadowPoint.y + shadowSize, shadowSize,
bottomLeftShadowPoint.y - topLeftShadowPoint.y - shadowSize);
g2.drawImage(images[Position.LEFT.ordinal()],
leftShadowRect.x, leftShadowRect.y,
leftShadowRect.width, leftShadowRect.height, null);
@ -176,10 +175,11 @@ public class DropShadowBorder implements Border, Serializable {
if (showBottomShadow) {
assert bottomLeftShadowPoint != null && bottomRightShadowPoint != null;
Rectangle bottomShadowRect =
new Rectangle(bottomLeftShadowPoint.x + shadowSize, y + height - shadowSize,
bottomRightShadowPoint.x - bottomLeftShadowPoint.x - shadowSize,
shadowSize);
Rectangle bottomShadowRect = new Rectangle(bottomLeftShadowPoint.x + shadowSize,
y + height - shadowSize,
bottomRightShadowPoint.x - bottomLeftShadowPoint.x
- shadowSize,
shadowSize);
g2.drawImage(images[Position.BOTTOM.ordinal()],
bottomShadowRect.x, bottomShadowRect.y,
bottomShadowRect.width, bottomShadowRect.height, null);
@ -187,9 +187,10 @@ public class DropShadowBorder implements Border, Serializable {
if (showRightShadow) {
assert topRightShadowPoint != null && bottomRightShadowPoint != null;
Rectangle rightShadowRect =
new Rectangle(x + width - shadowSize, topRightShadowPoint.y + shadowSize, shadowSize,
bottomRightShadowPoint.y - topRightShadowPoint.y - shadowSize);
Rectangle rightShadowRect = new Rectangle(x + width - shadowSize, topRightShadowPoint.y + shadowSize,
shadowSize,
bottomRightShadowPoint.y - topRightShadowPoint.y
- shadowSize);
g2.drawImage(images[Position.RIGHT.ordinal()],
rightShadowRect.x, rightShadowRect.y,
rightShadowRect.width, rightShadowRect.height, null);
@ -197,9 +198,9 @@ public class DropShadowBorder implements Border, Serializable {
if (showTopShadow) {
assert topLeftShadowPoint != null && topRightShadowPoint != null;
Rectangle topShadowRect =
new Rectangle(topLeftShadowPoint.x + shadowSize, y,
topRightShadowPoint.x - topLeftShadowPoint.x - shadowSize, shadowSize);
Rectangle topShadowRect = new Rectangle(topLeftShadowPoint.x + shadowSize, y,
topRightShadowPoint.x - topLeftShadowPoint.x - shadowSize,
shadowSize);
g2.drawImage(images[Position.TOP.ordinal()],
topShadowRect.x, topShadowRect.y,
topShadowRect.width, topShadowRect.height, null);
@ -231,25 +232,25 @@ public class DropShadowBorder implements Border, Serializable {
@SuppressWarnings("SuspiciousNameCombination")
private BufferedImage[] getImages(final Graphics2D g2) {
//first, check to see if an image for this size has already been rendered
//if so, use the cache. Else, draw and save
// first, check to see if an image for this size has already been rendered
// if so, use the cache. Else, draw and save
BufferedImage[] images = CACHE.get(getBorderHash(shadowSize, shadowOpacity, shadowColor));
if (images == null) {
images = new BufferedImage[Position.count()];
/*
* To draw a drop shadow, I have to:
* 1) Create a rounded rectangle
* 2) Create a BufferedImage to draw the rounded rect in
* 3) Translate the graphics for the image, so that the rectangle
* is centered in the drawn space. The border around the rectangle
* needs to be shadowWidth wide, so that there is space for the
* shadow to be drawn.
* 4) Draw the rounded rect as shadowColor, with an opacity of shadowOpacity
* 5) Create the BLUR_KERNEL
* 6) Blur the image
* 7) copy off the corners, sides, etc into images to be used for
* drawing the Border
* 1) Create a rounded rectangle
* 2) Create a BufferedImage to draw the rounded rect in
* 3) Translate the graphics for the image, so that the rectangle
* is centered in the drawn space. The border around the rectangle
* needs to be shadowWidth wide, so that there is space for the
* shadow to be drawn.
* 4) Draw the rounded rect as shadowColor, with an opacity of shadowOpacity
* 5) Create the BLUR_KERNEL
* 6) Blur the image
* 7) copy off the corners, sides, etc into images to be used for
* drawing the Border
*/
int rectWidth = cornerSize + 1;
RoundRectangle2D rect = new RoundRectangle2D.Double(0, 0, rectWidth, rectWidth, cornerSize, cornerSize);
@ -328,10 +329,9 @@ public class DropShadowBorder implements Border, Serializable {
}
/**
* Returns a new BufferedImage that represents a subregion of the given BufferedImage. (Note that this method does
* Returns a new BufferedImage that represents a subregion of the given BufferedImage. (Note that this method does
* not use BufferedImage.getSubimage(), which will defeat image acceleration strategies on later JDKs.)
*/
private BufferedImage getSubImage(final BufferedImage img, final int x, final int y, final int w, final int h) {
BufferedImage ret = ImageUtil.createCompatibleTranslucentImage(w, h);
Graphics2D g2 = ret.createGraphics();
@ -437,12 +437,17 @@ public class DropShadowBorder implements Border, Serializable {
}
private enum Position {
TOP, TOP_LEFT, LEFT, BOTTOM_LEFT,
BOTTOM, BOTTOM_RIGHT, RIGHT, TOP_RIGHT;
TOP,
TOP_LEFT,
LEFT,
BOTTOM_LEFT,
BOTTOM,
BOTTOM_RIGHT,
RIGHT,
TOP_RIGHT;
static int count() {
return 8;
}
}
}

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

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,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.weisj.darklaf.components.color;
import java.awt.*;
import java.awt.event.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
import javax.swing.*;
import com.github.weisj.darklaf.components.tooltip.ToolTipContext;
import com.github.weisj.darklaf.ui.DarkPopupFactory;
import com.github.weisj.darklaf.ui.tooltip.DarkTooltipBorder;
@ -30,12 +38,6 @@ import com.github.weisj.darklaf.ui.tooltip.DarkTooltipUI;
import com.github.weisj.darklaf.util.Alignment;
import com.github.weisj.darklaf.util.DarkUIUtil;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
public class PopupColorChooser extends JToolTip {
protected DarkTooltipBorder border;
@ -128,17 +130,17 @@ public class PopupColorChooser extends JToolTip {
protected ToolTipContext createToolTipContext() {
return new ToolTipContext()
.setAlignment(Alignment.CENTER)
.setCenterAlignment(Alignment.SOUTH)
.setUseBestFit(true)
.setToolTipInsets(new Insets(2, 2, 2, 2))
.setFallBackPositionProvider(c -> {
Window window = DarkUIUtil.getWindow(c.getTarget());
Dimension size = c.getToolTip().getPreferredSize();
Rectangle bounds = window.getBounds();
return new Point(bounds.x + (bounds.width - size.width) / 2,
bounds.y + (bounds.height - size.height) / 2);
});
.setAlignment(Alignment.CENTER)
.setCenterAlignment(Alignment.SOUTH)
.setUseBestFit(true)
.setToolTipInsets(new Insets(2, 2, 2, 2))
.setFallBackPositionProvider(c -> {
Window window = DarkUIUtil.getWindow(c.getTarget());
Dimension size = c.getToolTip().getPreferredSize();
Rectangle bounds = window.getBounds();
return new Point(bounds.x + (bounds.width - size.width) / 2,
bounds.y + (bounds.height - size.height) / 2);
});
}
@Override

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,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.weisj.darklaf.components.color;
import com.github.weisj.darklaf.decorators.MouseClickListener;
import com.github.weisj.darklaf.icons.EmptyIcon;
import com.github.weisj.darklaf.icons.SolidColorIcon;
import javax.swing.*;
import java.awt.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Supplier;
import javax.swing.*;
import com.github.weisj.darklaf.decorators.MouseClickListener;
import com.github.weisj.darklaf.icons.EmptyIcon;
import com.github.weisj.darklaf.icons.SolidColorIcon;
public class QuickColorChooser extends JPanel {
private final SolidColorIcon icon;

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,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.weisj.darklaf.components.color;
import java.awt.*;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;
import javax.swing.*;
import com.github.weisj.darklaf.color.DarkColorModel;
import com.github.weisj.darklaf.color.DarkColorModelHSB;
import com.github.weisj.darklaf.color.DarkColorModelHSL;
@ -40,12 +48,6 @@ import com.github.weisj.darklaf.ui.text.DarkTextUI;
import com.github.weisj.darklaf.util.ColorUtil;
import com.github.weisj.darklaf.util.DarkUIUtil;
import javax.swing.*;
import java.awt.*;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;
public class SmallColorChooser extends JPanel {
private static final DarkColorModel[] COLOR_MODELS = new DarkColorModel[]{DarkColorModelRGB.getInstance(),
@ -106,13 +108,13 @@ public class SmallColorChooser extends JPanel {
hexField.getDocument().addDocumentListener((UpdateDocumentListener) () -> {
try {
String hexStr = String.format("%1$-" + 8 + "s",
hexField.getText()).replaceAll(" ", "F");
hexField.getText())
.replaceAll(" ", "F");
int[] rgb = new int[]{Integer.valueOf(hexStr.substring(0, 2), 16),
Integer.valueOf(hexStr.substring(2, 4), 16),
Integer.valueOf(hexStr.substring(4, 6), 16)};
setColor(hexField, DarkColorModelRGB.getInstance(), rgb);
} catch (NumberFormatException | IndexOutOfBoundsException ignore) {
}
} catch (NumberFormatException | IndexOutOfBoundsException ignore) {}
});
}

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

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

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

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

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

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

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

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,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.weisj.darklaf.components.tabframe;
public interface TabFramePopupUI {
}
public interface TabFramePopupUI {}

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

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

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

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

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,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.weisj.darklaf.components.tabframe;
import javax.swing.*;
import javax.swing.plaf.PanelUI;
import java.awt.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.swing.*;
import javax.swing.plaf.PanelUI;
/**
* Tabbed Popup Component for {@link JTabFrame}.
*
@ -125,7 +127,7 @@ public class TabbedPopup extends PanelPopup {
* Gets the currently selected component from the TabbedPane.
*
* @return the selected component.
* @see #getTabbedPane()
* @see #getTabbedPane()
*/
public Component getContentPane() {
return tabbedPane.getSelectedComponent();
@ -150,7 +152,7 @@ public class TabbedPopup extends PanelPopup {
* TabbedPane.
*
* @return a collection of components.
* @see #getTabbedPane()
* @see #getTabbedPane()
*/
public Collection<Component> getContentPanes() {
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,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.weisj.darklaf.components.tabframe;
import com.github.weisj.darklaf.ui.splitpane.DarkSplitPaneUI;
import java.awt.*;
import javax.swing.*;
import javax.swing.plaf.basic.BasicSplitPaneDivider;
import javax.swing.plaf.basic.BasicSplitPaneUI;
import java.awt.*;
import com.github.weisj.darklaf.ui.splitpane.DarkSplitPaneUI;
public class ToggleSplitPane extends JSplitPane {
@ -49,7 +51,6 @@ public class ToggleSplitPane extends JSplitPane {
putClientProperty(DarkSplitPaneUI.KEY_STYLE, DarkSplitPaneUI.STYLE_INVISIBLE);
}
public boolean isResizable() {
return resizable;
}
@ -148,7 +149,6 @@ public class ToggleSplitPane extends JSplitPane {
}
}
@Override
public void setDividerLocation(final int location) {
if (isInLayout) return;
@ -165,7 +165,6 @@ public class ToggleSplitPane extends JSplitPane {
isInLayout = false;
}
@Override
public int getMaximumDividerLocation() {
int max = getOrientation() == HORIZONTAL_SPLIT ? getWidth() : getHeight();
@ -176,8 +175,7 @@ public class ToggleSplitPane extends JSplitPane {
public int getMinimumDividerLocation() {
Component comp = getRightComponent();
return comp == null ? 0 : getOrientation() == HORIZONTAL_SPLIT
? comp.getMinimumSize().width
: comp.getMinimumSize().height;
? comp.getMinimumSize().width
: comp.getMinimumSize().height;
}
}

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,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
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,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
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,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.weisj.darklaf.components.text;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.text.BadLocationException;
import javax.swing.text.Highlighter;
import javax.swing.text.JTextComponent;
import java.awt.*;
public class LineHighlighter implements Highlighter.HighlightPainter, ChangeListener {
private JTextComponent component;
@ -49,9 +51,9 @@ public class LineHighlighter implements Highlighter.HighlightPainter, ChangeList
}
/*
* You can reset the line color at any time
* You can reset the line color at any time
*
* @param color the color of the background line
* @param color the color of the background line
*/
public void setColor(final Color color) {
this.color = color;
@ -82,11 +84,11 @@ public class LineHighlighter implements Highlighter.HighlightPainter, ChangeList
}
/*
* Caret position has changed, remove the highlight
* Caret position has changed, remove the highlight
*/
private void resetHighlight() {
// Use invokeLater to make sure updates to the Document are completed,
// otherwise Undo processing causes the modelToView method to loop.
// Use invokeLater to make sure updates to the Document are completed,
// otherwise Undo processing causes the modelToView method to loop.
if (component == null) return;
SwingUtilities.invokeLater(() -> {
try {
@ -96,7 +98,7 @@ public class LineHighlighter implements Highlighter.HighlightPainter, ChangeList
if (view == null) return;
Rectangle currentView = view.getBounds();
// Remove the highlighting from the previously highlighted line
// Remove the highlighting from the previously highlighted line
if (lastView != null && lastView.y != currentView.y) {
if (lastView.isEmpty()) {
component.repaint();
@ -105,8 +107,7 @@ public class LineHighlighter implements Highlighter.HighlightPainter, ChangeList
}
lastView = currentView;
}
} catch (BadLocationException ignored) {
}
} catch (BadLocationException ignored) {}
});
}
}

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

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

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

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

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

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,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
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,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
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,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.weisj.darklaf.components.text;
@ -31,7 +32,7 @@ public class SearchTextField extends JTextField {
public static final int SEARCH = 0;
/**
* Constructs a new <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.
*/
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
* 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
* <code>createDefaultModel</code> method
* @param text the initial string to display, or <code>null</code>
* @param columns the number of columns to use to calculate the preferred width &gt;= 0; if <code>columns</code> is
* set to zero, the preferred width will be whatever naturally results from the component
* implementation
* @param doc the text storage to use; if this is <code>null</code>, a default will be
* provided by calling the
* <code>createDefaultModel</code> method
* @param text the initial string to display, or <code>null</code>
* @param columns the number of columns to use to calculate the preferred width &gt;= 0; if
* <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
*/
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.
*
* @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,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.weisj.darklaf.components.text;
import javax.swing.text.Document;
import java.util.List;
import javax.swing.text.Document;
/**
* {@link SearchTextField} that has a popup that displays the search history. A search entry is added
*
@ -36,7 +38,7 @@ public class SearchTextFieldWithHistory extends SearchTextField {
protected final TextFieldHistoryPopup history;
/**
* Constructs a new <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.
*/
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
* 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
* <code>createDefaultModel</code> method
* @param text the initial string to display, or <code>null</code>
* @param columns the number of columns to use to calculate the preferred width &gt;= 0; if <code>columns</code> is
* set to zero, the preferred width will be whatever naturally results from the component
* implementation
* @param doc the text storage to use; if this is <code>null</code>, a default will be
* provided by calling the
* <code>createDefaultModel</code> method
* @param text the initial string to display, or <code>null</code>
* @param columns the number of columns to use to calculate the preferred width &gt;= 0; if
* <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
*/
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.
*
* @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
* wrapped inside a scroll pane.
*
* <p>Note: A value of less than or equal to 0 indicates that the height should not be limited.
* <p>
* Note: A value of less than or equal to 0 indicates that the height should not be limited.
*
* @param maximumHeight the max height to use.
*/
@ -128,9 +133,9 @@ public class SearchTextFieldWithHistory extends SearchTextField {
* Add entry to the history. If the size is greater than the capacity the oldest entry will be deleted.
*
* @param entry the entry to add.
* @see #getLength() getLength
* @see #setCapacity(int) setCapacity
* @see #getCapacity() getCapacity
* @see #getLength() getLength
* @see #setCapacity(int) setCapacity
* @see #getCapacity() getCapacity
*/
public void addEntry(final String entry) {
history.addEntry(entry);
@ -140,7 +145,7 @@ public class SearchTextFieldWithHistory extends SearchTextField {
* Get the capacity of the history.
*
* @return the capacity.
* @see #setCapacity(int) setCapacity()
* @see #setCapacity(int) setCapacity()
*/
public int getCapacity() {
return history.getCapacity();
@ -149,7 +154,7 @@ public class SearchTextFieldWithHistory extends SearchTextField {
/**
* Set the capacity of the history. If the size grows larger than the capacity the oldest entry will be deleted.
*
* @param capacity the capacity.
* @param capacity the capacity.
* @throws IllegalArgumentException if capacity is negative
*/
public void setCapacity(final int capacity) throws IllegalArgumentException {

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,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.weisj.darklaf.components.text;
import java.awt.*;
import java.util.*;
import java.util.List;
import javax.swing.*;
import com.github.weisj.darklaf.components.ScrollPopupMenu;
import com.github.weisj.darklaf.decorators.PlainAction;
import com.github.weisj.darklaf.util.StringUtil;
import javax.swing.*;
import java.awt.*;
import java.util.List;
import java.util.*;
/**
* @author Jannis Weis
*/
@ -73,7 +75,7 @@ public class TextFieldHistoryPopup extends ScrollPopupMenu implements SearchList
* Get the capacity of the history.
*
* @return the capacity.
* @see #setCapacity(int) setCapacity()
* @see #setCapacity(int) setCapacity()
*/
public int getCapacity() {
return capacity;
@ -82,7 +84,7 @@ public class TextFieldHistoryPopup extends ScrollPopupMenu implements SearchList
/**
* Set the capacity of the history. If the size grows larger than the capacity the oldest entry will be deleted.
*
* @param capacity the capacity.
* @param capacity the capacity.
* @throws IllegalArgumentException if capacity is negative
*/
public void setCapacity(final int capacity) throws IllegalArgumentException {
@ -111,9 +113,9 @@ public class TextFieldHistoryPopup extends ScrollPopupMenu implements SearchList
* Add entry to the history. If the size is greater than the capacity the oldest entry will be deleted.
*
* @param entry the entry to add.
* @see #getLength() getLength
* @see #setCapacity(int) setCapacity
* @see #getCapacity() getCapacity
* @see #getLength() getLength
* @see #setCapacity(int) setCapacity
* @see #getCapacity() getCapacity
*/
public void addEntry(final String entry) {
history.remove(entry);

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

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

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

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

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

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

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

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

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

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

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,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.weisj.darklaf.decorators;
public interface CellRenderer {
}
public interface CellRenderer {}

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

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

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

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

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

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

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,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.weisj.darklaf.decorators;
@ -31,7 +32,6 @@ public class MouseResponder implements MouseListener {
private final Consumer<MouseEvent> consumer;
public MouseResponder(final Consumer<MouseEvent> 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,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.weisj.darklaf.decorators;
import javax.swing.*;
import java.awt.event.ActionEvent;
import javax.swing.*;
/**
* @author Jannis Weis
*/

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

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,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.weisj.darklaf.platform;
import java.awt.*;
import java.util.Properties;
import javax.swing.*;
import com.github.weisj.darklaf.DarkLaf;
import com.github.weisj.darklaf.LafManager;
import com.github.weisj.darklaf.platform.decorations.CustomTitlePane;
@ -32,10 +38,6 @@ import com.github.weisj.darklaf.platform.windows.WindowsDecorationsProvider;
import com.github.weisj.darklaf.util.PropertyValue;
import com.github.weisj.darklaf.util.SystemInfo;
import javax.swing.*;
import java.awt.*;
import java.util.Properties;
public class DecorationsHandler {
public static final String DECORATIONS_FLAG = DarkLaf.SYSTEM_PROPERTY_PREFIX + "decorations";
@ -54,19 +56,19 @@ public class DecorationsHandler {
protected DecorationsHandler() {
try {
//Extend for different platforms.
// Extend for different platforms.
boolean enableDecorations = isNativeDecorationsEnabled();
if (SystemInfo.isWindows10 && enableDecorations) {
//Decorations are in the Windows10 visuals. Disable for older version.
// Decorations are in the Windows10 visuals. Disable for older version.
decorationsProvider = new WindowsDecorationsProvider();
} else if (SystemInfo.isMacOSYosemite && enableDecorations) {
//Compiled binary needs at least macOS 10.10 (Yosemite).
// Compiled binary needs at least macOS 10.10 (Yosemite).
decorationsProvider = new MacOSDecorationsProvider();
} else {
decorationsProvider = new DefaultDecorationsProvider();
}
} catch (Throwable e) {
//If decorations modules are not available disable them.
// If decorations modules are not available disable them.
decorationsProvider = new DefaultDecorationsProvider();
}
}

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

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

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

Loading…
Cancel
Save