Compare commits

..

95 Commits
0.44 ... 0.46

Author SHA1 Message Date
Karl Tauber
073a25f381 release 0.46 2020-12-20 18:42:23 +01:00
Karl Tauber
40592ab876 FlatUIUtils: fixed javadoc warnings 2020-12-20 18:34:13 +01:00
Karl Tauber
bbfe624b51 Merge pull request #222 into master
AnimatedIcon
2020-12-20 18:26:09 +01:00
Karl Tauber
a2af9e4c65 JIDE: RangeSlider: clicking on track now immediately moves the thumb to mouse location and starts dragging the thumb 2020-12-20 18:24:40 +01:00
Karl Tauber
0123a8895f JIDE: updated UI defaults dumps for commit ef065d31a0 (support TristateCheckBox) 2020-12-20 17:33:42 +01:00
Karl Tauber
53854a4d13 Slider: snap to ticks is now done while dragging the thumb 2020-12-20 17:32:01 +01:00
Karl Tauber
4fdd44858f Slider: clicking on track now immediately moves the thumb to mouse location and starts dragging the thumb 2020-12-20 13:32:10 +01:00
Karl Tauber
3c58879ce5 Slider: fixed painting of colored track if JSlider.inverted is true 2020-12-19 17:01:34 +01:00
Karl Tauber
a7c6a881b3 Extras: FlatTriStateCheckBox reworked 2020-12-19 16:13:12 +01:00
Karl Tauber
ef065d31a0 JIDE: support TristateCheckBox 2020-12-19 13:34:53 +01:00
Karl Tauber
d059d6b448 README.md: new projects using FlatLaf:
- jEnTunnel
- JPass
- Linotte
- MEKA
- Shutter Encoder
- ThunderFocus
- lectureStudio
2020-12-18 16:05:56 +01:00
Karl Tauber
2d0a6f1bec README.md: new projects using FlatLaf:
- JOSM
- Novel-Grabber
- Android Tool
2020-12-18 16:04:43 +01:00
Karl Tauber
a3cc5a1938 README.md: added descriptions to projects using FlatLaf 2020-12-18 14:34:40 +01:00
Karl Tauber
435068515a always reset our graphics rendering hints
(this is usually not necessary because each component gets its own instance of Graphics when painting, but resetting may avoid side effects if our paint methods are invoked directly)
2020-12-18 13:35:17 +01:00
Karl Tauber
956001dbd7 avoid painting text with our rendering hints enabled to avoid antialiased text in some components if text antialiasing is disabled in system (issue #227) 2020-12-18 12:22:27 +01:00
Karl Tauber
460f0d9dee UIScale: fixed NPE in getSystemScaleFactor(Graphics2D) when using Batik SVGGraphics2D (issue #226) 2020-12-15 11:25:00 +01:00
Karl Tauber
5155ec93c9 ToolTip: fixed drop shadow for wide tooltips (issue #224; regression since fixed issue #142) 2020-12-15 11:19:30 +01:00
Karl Tauber
8bb8883e22 IntelliJ Themes: added flag whether a theme is dark to FlatAllIJThemes.INFOS. (issue #221) 2020-12-12 18:54:42 +01:00
Karl Tauber
ffb7a6dfbb README.md:
- added demo download section
- added link to javadoc of extras components
2020-12-12 14:45:08 +01:00
Karl Tauber
176de6f245 README.md: simplified download sections of subprojects 2020-12-12 14:21:07 +01:00
Karl Tauber
11f9740dbf Extras: added support for JComponent.outline client property (issue #117) 2020-12-12 13:59:58 +01:00
Karl Tauber
42a91ba26c Extras: renamed SVG utility class from com.formdev.flatlaf.extras.SVGUtils to com.formdev.flatlaf.extras.FlatSVGUtils 2020-12-12 12:21:48 +01:00
Karl Tauber
234003e2b1 Extras: Renamed tri-state check box class from
`com.formdev.flatlaf.extras.TriStateCheckBox` to
`com.formdev.flatlaf.extras.components.FlatTriStateCheckBox`
2020-12-12 00:33:51 +01:00
Karl Tauber
534384438b Extras: added extension class for JTabbedPane (issue #117) 2020-12-11 23:44:52 +01:00
Karl Tauber
ab51f35d5d Extras: added extension classes for JEditorPane, JSpinner, JTextArea and JTextPane; added minimumWidth and roundRect properties (issue #117) 2020-12-11 18:05:58 +01:00
Karl Tauber
511a4044d7 Extras: added extension classes for JButton and JToggleButton (issue #117) 2020-12-11 17:18:35 +01:00
Karl Tauber
821efaff40 Extras: removed duplicate enums in text components (issue #117) 2020-12-11 14:01:42 +01:00
Karl Tauber
91bc994532 Extras: made enums in text components public (issue #117) 2020-12-11 13:39:51 +01:00
Karl Tauber
1323b46ac7 Extras: added extension class for JProgressBar (issue #117) 2020-12-11 13:28:55 +01:00
Karl Tauber
3a8b30ca8e Extras: removed extension interfaces and moved methods to components classes because:
- Javadoc for components that implement extension interfaces are useless because they do not include default methods from the extension interface
- GUI builders do not recognize default methods from the extension interface and it is not possible to edit extension properties in GUI builder
- the idea of adding the extension interface to own components can be also achieved by changing superclass of own component

(issue #117)
2020-12-11 13:24:14 +01:00
Karl Tauber
923d58519f Extras: added extension interfaces and classes for JComboBox, JFormattedTextField, JPasswordField, JScrollBar, JScrollPane and JTextField (issue #117) 2020-12-10 20:30:27 +01:00
Karl Tauber
eabb1f84f6 Table and TableHeader: fixed missing right vertical grid line if using table as row header in scroll pane (issues #152 and #46) 2020-12-09 23:04:04 +01:00
Karl Tauber
cfbe44b946 TableHeader: fixed position of column separators in right-to-left component orientation; do not paint anything if column count is zero 2020-12-09 00:33:01 +01:00
Karl Tauber
81c35eab46 SwingX: fixed striping background highlighting color (e.g. alternating table rows) in dark themes
Table: made grid lines slightly darker/lighter
2020-12-07 12:28:31 +01:00
Karl Tauber
a1c7c29113 FlatComponents2Test: added SwingX JXTable and JXTreeTable to test extended/customized tables 2020-12-07 12:21:34 +01:00
Karl Tauber
1293e2a074 AnimatedIcon added (for future animations) (issue #66) 2020-12-05 17:57:06 +01:00
Karl Tauber
b5deca7f22 release 0.45 2020-12-05 14:32:02 +01:00
Karl Tauber
604ba236c0 Merge pull request #217 into master
MenuBar.underlineSelectionColor
2020-12-05 12:00:50 +01:00
Karl Tauber
14df490b2a MenuBar: support different underline menu selection style UI defaults for MenuBar and MenuItem. (PR #217; issue #216) 2020-12-05 11:56:38 +01:00
Karl Tauber
dd2f73e8ad Merge pull request #214 into master
Slider redesign
2020-12-04 22:43:05 +01:00
Karl Tauber
56bfdc8ef9 Slider: updated CHANGELOG.md 2020-12-04 22:29:32 +01:00
Karl Tauber
91dbf1e144 Sider: text baseline layout in FlatComponentsTest 2020-12-04 21:08:12 +01:00
Karl Tauber
e07ae90d09 TabbedPane: no longer add (internal) tab close button component as child to JTabbedPane (issue #219) 2020-11-29 01:32:38 +01:00
Karl Tauber
5ef0c9aae1 Table: fixed unstable grid line thickness when scaled on HiDPI screens (issue #152) 2020-11-28 23:20:58 +01:00
Karl Tauber
aefed7c481 Table: do not paint last vertical grid line if auto-resize mode is not off (issue #46) 2020-11-28 23:15:37 +01:00
Karl Tauber
0d66d9f9a3 FlatCheckBoxIcon:
- added parameter `Component c` to all paint methods so that subclasses can access component states
- extracted methods to get colors and selected/indeterminate state
2020-11-28 12:29:13 +01:00
Karl Tauber
d0ffc4f979 TabbedPane: support hiding tab area if it contains only one tab 2020-11-28 11:21:46 +01:00
mmatessi
f149d2b7cd MenuBar.underlineSelectionColor 2020-11-27 19:14:28 +01:00
Karl Tauber
21a12b8dd4 added Flat*Laf.installLafInfo() methods to add a Laf to the set of available Lafs
uses `UIManager.installLookAndFeel( new UIManager.LookAndFeelInfo(...) )`
2020-11-23 22:14:42 +01:00
Karl Tauber
6c8b8e8949 Popup: allow forcing to heavy weight popup windows (issue #189) 2020-11-23 18:09:44 +01:00
Karl Tauber
539737d1c5 ScrollBar: fixed NPE in NetBeans GUI builder when using JCalendar component (issue #194) 2020-11-23 17:19:04 +01:00
Karl Tauber
33ff5828da IntelliJ Themes:
- added "Gradianto Nature Green" theme
- updated "Arc Dark", "Cyan", "Dark purple", "Gradianto", "Gray", "Gruvbox" and "One Dark" themes
2020-11-22 17:10:11 +01:00
Karl Tauber
1fb0783808 Slider: fixed slider colors in IntelliJ themes 2020-11-21 18:18:06 +01:00
Karl Tauber
b5e7aa8553 Slider: fixed painting issues:
- needle of directional thumb was not painted while dragging
- artifacts on HiDPI screen while dragging
- cut off focus indicator on HiDPI screen
2020-11-21 18:18:06 +01:00
Karl Tauber
1d3ce76b27 Slider: replaced Slider.thumbWidth with Slider.thumbSize to support non-square sized thumbs (as used in Windows 10) 2020-11-21 18:18:06 +01:00
Karl Tauber
0101171159 UIDefaultsLoader: added fadein(), fadeout(), fade() and spin() color functions (inspired by Less CSS) 2020-11-21 18:18:06 +01:00
Karl Tauber
8b8ed0b9ff Slider:
- compute useful baseline for horizontal orientation so that the track is vertically centered
- no baseline for vertical orientation
2020-11-21 18:18:06 +01:00
Karl Tauber
413b60e630 Slider:
- changed default color to bluish
- made track thinner (2px, was 3px)
- made thumb larger (12px, was 11px)
- added thumb outline focus indicator (4px wide)
- slider component height increased from 11px to 20px
- support painting thumb border
- support different colors for thumb background and colored track
2020-11-21 18:18:06 +01:00
Karl Tauber
10b2a94c70 JIDE: RangeSlider: avoid that middle track is painted over first thumb 2020-11-21 18:18:06 +01:00
Karl Tauber
e337e5bbd8 JIDE: RangeSlider:
- updated with latest changes from FlatSliderUI
- use static FlatSliderUI methods for thumb painting
- hover/pressed feedback on single thumb
- hover/pressed feedback on middle track and both thumbs
- added JSlider components to FlatRangeSliderTest for easier testing/comparing
2020-11-21 18:18:06 +01:00
Karl Tauber
6e55e0a183 Slider:
- hover feedback only when mouse is over thumb
- pressed feedback added
- separate disabled colors for track and thumb
- made private fields protected
2020-11-21 18:18:06 +01:00
Karl Tauber
8ee1d26935 Merge branch into master 2020-11-21 17:53:17 +01:00
Karl Tauber
80bdf69eaf GitHub Actions: build on all branches; produce snapshots only on master branch; disable Travis CI 2020-11-21 17:31:52 +01:00
Karl Tauber
18e838bffd GitHub Actions: exclude javadoc and sources from build artifacts 2020-11-21 15:21:33 +01:00
Karl Tauber
d95b1b0ec4 GitHub Actions: upload build artifacts 2020-11-21 15:08:07 +01:00
Karl Tauber
d16a3c117b GitHub Actions: 3rd attempt to test release job without publishing 2020-11-21 14:45:02 +01:00
Karl Tauber
d04ec982ab GitHub Actions: 2nd attempt to test release job without publishing 2020-11-21 14:42:09 +01:00
Karl Tauber
cce99c803e GitHub Actions: test release job without publishing 2020-11-21 14:32:36 +01:00
Karl Tauber
19ed538573 GitHub Actions: added secrets for snapshot and release jobs 2020-11-21 14:24:56 +01:00
Karl Tauber
a1f78345e6 GitHub Actions: use separate jobs for snapshots and releases to be sure that build succeeded for all Java versions 2020-11-21 14:04:32 +01:00
Karl Tauber
f8c7ccf064 GitHub Actions: run if tags are pushed 2020-11-21 13:38:21 +01:00
Karl Tauber
4d5242cd61 GitHub Actions: fixed typo in snapshot step condition 2020-11-21 12:06:18 +01:00
Karl Tauber
7ad176f98d GitHub Actions: info step added 2020-11-21 12:02:08 +01:00
Karl Tauber
57df7d28b5 GitHub Actions: added steps for snapshots and releases 2020-11-21 11:51:41 +01:00
Karl Tauber
f784ff2c84 GitHub Actions: test also against Java 9 2020-11-21 01:57:37 +01:00
Karl Tauber
a0f6affb68 GitHub Actions: cache gradle wrapper; fixed key for caching gradle cache 2020-11-21 01:37:28 +01:00
Karl Tauber
0c679167fa GitHub Actions: cache gradle dependencies 2020-11-21 00:48:27 +01:00
Karl Tauber
4fe707e519 GitHub Actions: initial commit 2020-11-21 00:19:46 +01:00
Karl Tauber
d83704b7cb FlatPaintingTest: added test case for circular components 2020-11-20 11:57:24 +01:00
Karl Tauber
2177ee45cc FlatUIUtils: replaced quadratic curves with bezier curves in createRoundRectanglePath() to get perfect circle when using large arcs
(currently only used for SwingX)
2020-11-20 11:50:03 +01:00
Karl Tauber
ccd4f99aea Window decorations: removed 1px window border if window is in full-screen mode (issue #212) 2020-11-20 10:12:28 +01:00
Karl Tauber
cd6b55c846 Demo: Alt+UP and Alt+DOWN now switch to previous/next theme 2020-11-20 00:40:10 +01:00
Karl Tauber
d923c8df81 Window decorations: title bar was not hidden if window is in full-screen mode (issue #212) 2020-11-18 23:31:04 +01:00
Karl Tauber
59879f493e FlatTestFrame: fixed exception when using FlatPropertiesLaf and changing scale factor, which re-sets the current Laf 2020-11-18 18:45:13 +01:00
Karl Tauber
06cab0d4b5 updated svgSalamander to version 1.1.2.4 2020-11-18 18:34:12 +01:00
Karl Tauber
a16db38a6f Testing: FlatBaselineTest added 2020-11-18 18:32:08 +01:00
Karl Tauber
de93e19a80 JIDE: RangeSlider: updated UI defaults dumps 2020-11-17 12:13:01 +01:00
Karl Tauber
47bb7d0de7 JIDE: RangeSlider: added to CHANGELOG.md and README.md 2020-11-16 22:26:49 +01:00
Karl Tauber
896e808db4 JIDE: RangeSlider: removed nested panel from FlatRangeSliderTest 2020-11-16 22:19:09 +01:00
Karl Tauber
6fe6d1ffa0 JIDE: RangeSlider: reordered methods and slightly changed formatting to make it easier to compare with FlatRangeSliderUI 2020-11-16 22:04:08 +01:00
Karl Tauber
4c6f7a66e2 Merge pull request #209 into master
Add RangeSlider support
2020-11-16 21:25:50 +01:00
mmatessi
f57dbf94c8 FlatJideOssDefaultsAddon reformat 2020-11-13 09:47:32 +01:00
mmatessi
c0f15d2e6f FlatRangeSliderUI fix change label foreground 2020-11-13 09:42:26 +01:00
mmatessi
cb525fafb6 FlatSliderUI extends BasicSliderUI 2020-11-12 13:02:16 +01:00
mmatessi
5cae3a8141 add RangeSlider support 2020-11-11 16:57:40 +01:00
196 changed files with 8981 additions and 1627 deletions

142
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,142 @@
# https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: CI
on:
push:
branches:
- '*'
tags:
- '[0-9]*'
pull_request:
branches:
- '*'
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
# test against
# - Java 1.8 (minimum requirement)
# - Java 9 (first version with JPMS)
# - Java LTS versions (11, 17, ...)
# - lastest Java version(s)
java:
- 1.8
- 9
- 11 # LTS
- 14
- 15
steps:
- uses: actions/checkout@v2
- name: Setup Java ${{ matrix.java }}
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- name: Cache Gradle wrapper
uses: actions/cache@v1
with:
path: ~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
- name: Cache Gradle cache
uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}
restore-keys: ${{ runner.os }}-gradle
- name: Build with Gradle
run: ./gradlew build
- name: Upload artifacts
uses: actions/upload-artifact@v2
if: matrix.java == '11'
with:
name: FlatLaf-build-artifacts
path: |
flatlaf-core/build/libs
flatlaf-demo/build/libs
flatlaf-extras/build/libs
flatlaf-intellij-themes/build/libs
flatlaf-jide-oss/build/libs
flatlaf-swingx/build/libs
!**/*-javadoc.jar
!**/*-sources.jar
snapshot:
runs-on: ubuntu-latest
needs: build
if: |
github.event_name == 'push' &&
github.ref == 'refs/heads/master' &&
github.repository == 'JFormDesigner/FlatLaf'
steps:
- uses: actions/checkout@v2
- name: Setup Java 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache Gradle wrapper
uses: actions/cache@v1
with:
path: ~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
- name: Cache Gradle cache
uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}
restore-keys: ${{ runner.os }}-gradle
- name: Publish snapshot to oss.jfrog.org
run: ./gradlew artifactoryPublish
env:
BINTRAY_USER: ${{ secrets.BINTRAY_USER }}
BINTRAY_KEY: ${{ secrets.BINTRAY_KEY }}
release:
runs-on: ubuntu-latest
needs: build
if: |
github.event_name == 'push' &&
startsWith( github.ref, 'refs/tags/' ) &&
github.repository == 'JFormDesigner/FlatLaf'
steps:
- uses: actions/checkout@v2
- name: Setup Java 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache Gradle wrapper
uses: actions/cache@v1
with:
path: ~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
- name: Cache Gradle cache
uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}
restore-keys: ${{ runner.os }}-gradle
- name: Release a new stable version to bintray
run: ./gradlew bintrayUpload -Drelease=true
env:
BINTRAY_USER: ${{ secrets.BINTRAY_USER }}
BINTRAY_KEY: ${{ secrets.BINTRAY_KEY }}

View File

@@ -1,40 +0,0 @@
language: java
sudo: false
jdk:
- openjdk8
- openjdk9
- openjdk11
- openjdk14
- openjdk15
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
before_install:
- ./gradlew --version
- java -version
stages:
- name: test
- name: snapshot
if: branch = master AND type IN (push) AND tag IS blank
- name: release
if: type IN (push) AND tag IS present
jobs:
include:
# publish snapshot to oss.jfrog.org
- stage: snapshot
jdk: openjdk11
script: ./gradlew artifactoryPublish
# release a new stable version to bintray
- stage: release
jdk: openjdk11
script: ./gradlew bintrayUpload -Drelease=true

View File

@@ -1,6 +1,77 @@
FlatLaf Change Log
==================
## 0.46
#### New features and improvements
- Slider and JIDE RangeSlider: Clicking on track now immediately moves the thumb
to mouse location and starts dragging the thumb. Use `UIManager.put(
"Slider.scrollOnTrackClick", true )` to enable old behavior that scrolls the
thumb when clicking on track.
- Slider: Snap to ticks is now done while dragging the thumb. Use
`UIManager.put( "Slider.snapToTicksOnReleased", true )` to enable old behavior
that snaps to ticks on mouse released.
- Extras: Added standard component extension classes that provides easy access
to FlatLaf specific client properties (see package
`com.formdev.flatlaf.extras.components`).
- Extras: Renamed tri-state check box class from
`com.formdev.flatlaf.extras.TriStateCheckBox` to
`com.formdev.flatlaf.extras.components.FlatTriStateCheckBox`. Also
changed/improved API and added javadoc.
- Extras: Renamed SVG utility class from `com.formdev.flatlaf.extras.SVGUtils`
to `com.formdev.flatlaf.extras.FlatSVGUtils`.
- IntelliJ Themes: Added flag whether a theme is dark to
`FlatAllIJThemes.INFOS`. (issue #221)
- JIDE Common Layer: Support `TristateCheckBox`.
#### Fixed bugs
- Slider: Fixed painting of colored track if `JSlider.inverted` is `true`.
- Table and TableHeader: Fixed missing right vertical grid line if using table
as row header in scroll pane. (issues #152 and #46)
- TableHeader: Fixed position of column separators in right-to-left component
orientation.
- ToolTip: Fixed drop shadow for wide tooltips on Windows and Java 9+. (issue
#224)
- SwingX: Fixed striping background highlighting color (e.g. alternating table
rows) in dark themes.
- Fixed: If text antialiasing is disabled (in OS system settings or via
`-Dawt.useSystemAAFontSettings=off`), then some components still did use
antialiasing to render text (not-editable ComboBox, ProgressBar, Slider,
TabbedPane and multiline ToolTip). (issue #227)
## 0.45
#### New features and improvements
- Slider: New design, added hover and pressed feedback and improved customizing.
(PR #214)
- JIDE Common Layer: Support `RangeSlider`. (PR #209)
- IntelliJ Themes:
- Added "Gradianto Nature Green" theme.
- Updated "Arc Dark", "Cyan", "Dark purple", "Gradianto", "Gray", "Gruvbox"
and "One Dark" themes.
- TabbedPane: Support hiding tab area if it contains only one tab. (set client
property `JTabbedPane.hideTabAreaWithOneTab` to `true`)
- MenuBar: Support different underline menu selection style UI defaults for
`MenuBar` and `MenuItem`. (PR #217; issue #216)
#### Fixed bugs
- Table: Do not paint last vertical grid line if auto-resize mode is not off.
(issue #46)
- Table: Fixed unstable grid line thickness when scaled on HiDPI screens. (issue
#152)
- TabbedPane: No longer add (internal) tab close button component as child to
`JTabbedPane`. (issue #219)
- Custom window decorations: Title bar was not hidden if window is in
full-screen mode. (issue #212)
## 0.44
#### New features and improvements

View File

@@ -76,36 +76,76 @@ Addons
Projects using FlatLaf
----------------------
- [NetBeans](https://netbeans.apache.org/) 11.3
- [Apache NetBeans](https://netbeans.apache.org/) 11.3 - IDE for Java, PHP, HTML
and much more
- [jclasslib bytecode viewer](https://github.com/ingokegel/jclasslib) 5.5
- [KeyStore Explorer](https://keystore-explorer.org/) 5.4.3
- [OWASP Zed Attack Proxy (ZAP)](https://www.zaproxy.org/) (in weekly releases)
- ![New](images/new.svg) [jAlbum](https://jalbum.net/) 21 (commercial)
- ![New](images/new.svg) [OWASP ZAP](https://www.zaproxy.org/) 2.10 - the worlds
most widely used web app scanner
- ![New](images/new.svg) [JOSM](https://josm.openstreetmap.de/) - an extensible
editor for [OpenStreetMap](https://www.openstreetmap.org/) (requires FlatLaf
JOSM plugin)
- [jAlbum](https://jalbum.net/) 21 (commercial) - creates photo album websites
- [XMLmind XML Editor](https://www.xmlmind.com/xmleditor/) 9.3 (commercial)
- [Total Validator](https://www.totalvalidator.com/) 15 (commercial)
- [j-lawyer](https://github.com/jlawyerorg/j-lawyer-org)
- [Total Validator](https://www.totalvalidator.com/) 15 (commercial) - checks
your website
- [j-lawyer](https://github.com/jlawyerorg/j-lawyer-org) - Kanzleisoftware
- [MegaMek](https://github.com/MegaMek/megamek) v0.47.4 and
[MekHQ](https://github.com/MegaMek/mekhq) v0.47.5
[MekHQ](https://github.com/MegaMek/mekhq) v0.47.5 - a turn-based sci-fi board
game
- [GUIslice Builder](https://github.com/ImpulseAdventure/GUIslice-Builder)
0.13.b024
- [Rest Suite](https://github.com/supanadit/restsuite)
- [ControllerBuddy](https://github.com/bwRavencl/ControllerBuddy)
- [SpringRemote](https://github.com/HaleyWang/SpringRemote)
0.13.b024 - GUI builder for
[GUIslice](https://github.com/ImpulseAdventure/GUIslice), a lightweight GUI
framework for embedded displays
- [Rest Suite](https://github.com/supanadit/restsuite) - Rest API testing
- [ControllerBuddy](https://github.com/bwRavencl/ControllerBuddy) - advanced
gamepad mapping software
- [SpringRemote](https://github.com/HaleyWang/SpringRemote) - remote Linux SSH
connections manager
- ![New](images/new.svg) [jEnTunnel](https://github.com/ggrandes/jentunnel) -
manage SSH Tunnels made easy
- [mendelson AS2](https://sourceforge.net/projects/mec-as2/),
[AS4](https://sourceforge.net/projects/mendelson-as4/) and
[OFTP2](https://sourceforge.net/projects/mendelson-oftp2/) (open-source) and
[mendelson AS2](https://mendelson-e-c.com/as2/),
[AS4](https://mendelson-e-c.com/as4/) and
[OFTP2](https://mendelson-e-c.com/oftp2) (commercial)
- [MeteoInfo](https://github.com/meteoinfo/MeteoInfo) 2.2
- [lsfusion platform](https://github.com/lsfusion/platform)
- [MeteoInfo](https://github.com/meteoinfo/MeteoInfo) 2.2 - GIS and scientific
computation environment for meteorological community
- [lsfusion platform](https://github.com/lsfusion/platform) - information
systems development platform
- ![New](images/new.svg) [JPass](https://github.com/gaborbata/jpass) - password
manager with strong encryption
- [Jes - Die Java-E<>R](https://www.jes-eur.de)
- [Mapton](https://mapton.org/) 2.0
([source code](https://github.com/trixon/mapton)) based on NetBeans platform
- [Pseudo Assembler IDE](https://github.com/tomasz-herman/PseudoAssemblerIDE)
- [Sound Analysis](https://github.com/tomasz-herman/SoundAnalysis)
- [RemoteLight](https://github.com/Drumber/RemoteLight) - Multifunctional LED
Control Software
([source code](https://github.com/trixon/mapton)) based on NetBeans platform -
some kind of map application
- [Pseudo Assembler IDE](https://github.com/tomasz-herman/PseudoAssemblerIDE) -
IDE for Pseudo-Assembler
- ![New](images/new.svg) [Linotte](https://github.com/cpc6128/LangageLinotte)
3.1 - French programming language created to learn programming
- ![New](images/new.svg) [MEKA](https://github.com/Waikato/meka) 1.9.3 -
multi-label classifiers and evaluation procedures using the Weka machine
learning framework
- ![New](images/new.svg) [Shutter Encoder](https://www.shutterencoder.com/) 14.2
([source code](https://github.com/paulpacifico/shutter-encoder)) -
professional video converter and compression tool (screenshots show **old**
look)
- [Sound Analysis](https://github.com/tomasz-herman/SoundAnalysis) - analyze
sound files in time or frequency domain
- [RemoteLight](https://github.com/Drumber/RemoteLight) - multifunctional LED
control software
- ![New](images/new.svg)
[ThunderFocus](https://github.com/marcocipriani01/ThunderFocus) -
Arduino-based telescope focuser
- ![New](images/new.svg)
[Novel-Grabber](https://github.com/Flameish/Novel-Grabber) - download novels
from any webnovel and lightnovel site
- ![New](images/new.svg) [lectureStudio](https://www.lecturestudio.org/)
4.3.1060 - digitize your lectures with ease
- ![New](images/new.svg)
[Android Tool](https://github.com/fast-geek/Android-Tool) - makes popular adb
and fastboot commands easier to use
- and more...

View File

@@ -14,8 +14,8 @@
* limitations under the License.
*/
val releaseVersion = "0.44"
val developmentVersion = "0.45-SNAPSHOT"
val releaseVersion = "0.46"
val developmentVersion = "0.47-SNAPSHOT"
version = if( java.lang.Boolean.getBoolean( "release" ) ) releaseVersion else developmentVersion
@@ -48,7 +48,7 @@ extra["bintray.dryRun"] = false
// if true, uploaded artifacts are visible to all
// if false, only visible to owner when logged into bintray
extra["bintray.publish"] = true
extra["bintray.publish"] = false
allprojects {

View File

@@ -130,6 +130,15 @@ public interface FlatClientProperties
*/
String MINIMUM_HEIGHT = "JComponent.minimumHeight";
/**
* Paint the component with round edges.
* <p>
* <strong>Components</strong> {@link javax.swing.JComboBox}, {@link javax.swing.JSpinner},
* {@link javax.swing.JTextField}, {@link javax.swing.JFormattedTextField} and {@link javax.swing.JPasswordField}<br>
* <strong>Value type</strong> {@link java.lang.Boolean}
*/
String COMPONENT_ROUND_RECT = "JComponent.roundRect";
/**
* Specifies the outline color of the component border.
* <p>
@@ -161,15 +170,6 @@ public interface FlatClientProperties
*/
String OUTLINE_WARNING = "warning";
/**
* Paint the component with round edges.
* <p>
* <strong>Components</strong> {@link javax.swing.JComboBox}, {@link javax.swing.JSpinner},
* {@link javax.swing.JTextField}, {@link javax.swing.JFormattedTextField} and {@link javax.swing.JPasswordField}<br>
* <strong>Value type</strong> {@link java.lang.Boolean}
*/
String COMPONENT_ROUND_RECT = "JComponent.roundRect";
//---- Popup --------------------------------------------------------------
/**
@@ -181,6 +181,15 @@ public interface FlatClientProperties
*/
String POPUP_DROP_SHADOW_PAINTED = "Popup.dropShadowPainted";
/**
* Specifies whether a heavy weight window should be used if the component is shown in a popup
* or if the component is the owner of another component that is shown in a popup.
* <p>
* <strong>Component</strong> {@link javax.swing.JComponent}<br>
* <strong>Value type</strong> {@link java.lang.Boolean}
*/
String POPUP_FORCE_HEAVY_WEIGHT = "Popup.forceHeavyWeight";
//---- JProgressBar -------------------------------------------------------
/**
@@ -210,7 +219,7 @@ public interface FlatClientProperties
*/
String MENU_BAR_EMBEDDED = "JRootPane.menuBarEmbedded";
//---- JScrollBar ---------------------------------------------------------
//---- JScrollBar / JScrollPane -------------------------------------------
/**
* Specifies whether the decrease/increase arrow buttons of a scrollbar are shown.
@@ -254,6 +263,14 @@ public interface FlatClientProperties
*/
String TABBED_PANE_HAS_FULL_BORDER = "JTabbedPane.hasFullBorder";
/**
* Specifies whether the tab area should be hidden if it contains only one tab.
* <p>
* <strong>Component</strong> {@link javax.swing.JTabbedPane}<br>
* <strong>Value type</strong> {@link java.lang.Boolean}
*/
String TABBED_PANE_HIDE_TAB_AREA_WITH_ONE_TAB = "JTabbedPane.hideTabAreaWithOneTab";
/**
* Specifies the minimum width of a tab.
* <p>
@@ -332,7 +349,7 @@ public interface FlatClientProperties
* Specifies the callback that is invoked when a tab close button is clicked.
* The callback is responsible for closing the tab.
* <p>
* Either use a {@link java.util.function.IntConsumer} that received the tab index as parameter:
* Either use a {@link java.util.function.IntConsumer} that receives the tab index as parameter:
* <pre>{@code
* myTabbedPane.putClientProperty( "JTabbedPane.tabCloseCallback",
* (IntConsumer) tabIndex -> {
@@ -340,7 +357,7 @@ public interface FlatClientProperties
* } );
* }</pre>
* Or use a {@link java.util.function.BiConsumer}&lt;javax.swing.JTabbedPane, Integer&gt;
* that received the tabbed pane and the tab index as parameters:
* that receives the tabbed pane and the tab index as parameters:
* <pre>{@code
* myTabbedPane.putClientProperty( "JTabbedPane.tabCloseCallback",
* (BiConsumer<JTabbedPane, Integer>) (tabbedPane, tabIndex) -> {

View File

@@ -18,21 +18,28 @@ package com.formdev.flatlaf;
/**
* A Flat LaF that has a dark color scheme and looks like Darcula LaF.
*
* The UI defaults are loaded from FlatDarculaLaf.properties, FlatDarkLaf.properties and FlatLaf.properties
* <p>
* The UI defaults are loaded from {@code FlatDarculaLaf.properties},
* {@code FlatDarkLaf.properties} and {@code FlatLaf.properties}.
*
* @author Karl Tauber
*/
public class FlatDarculaLaf
extends FlatDarkLaf
{
public static boolean install( ) {
public static final String NAME = "FlatLaf Darcula";
public static boolean install() {
return install( new FlatDarculaLaf() );
}
public static void installLafInfo() {
installLafInfo( NAME, FlatDarculaLaf.class );
}
@Override
public String getName() {
return "FlatLaf Darcula";
return NAME;
}
@Override

View File

@@ -16,23 +16,41 @@
package com.formdev.flatlaf;
import javax.swing.UIManager;
/**
* A Flat LaF that has a dark color scheme.
*
* The UI defaults are loaded from FlatDarkLaf.properties and FlatLaf.properties
* <p>
* The UI defaults are loaded from {@code FlatDarkLaf.properties} and {@code FlatLaf.properties}.
*
* @author Karl Tauber
*/
public class FlatDarkLaf
extends FlatLaf
{
public static boolean install( ) {
public static final String NAME = "FlatLaf Dark";
/**
* Sets the application look and feel to this LaF
* using {@link UIManager#setLookAndFeel(javax.swing.LookAndFeel)}.
*/
public static boolean install() {
return install( new FlatDarkLaf() );
}
/**
* Adds this look and feel to the set of available look and feels.
* <p>
* Useful if your application uses {@link UIManager#getInstalledLookAndFeels()}
* to query available LaFs and display them to the user in a combobox.
*/
public static void installLafInfo() {
installLafInfo( NAME, FlatDarkLaf.class );
}
@Override
public String getName() {
return "FlatLaf Dark";
return NAME;
}
@Override

View File

@@ -18,21 +18,28 @@ package com.formdev.flatlaf;
/**
* A Flat LaF that has a light color scheme and looks like IntelliJ LaF.
*
* The UI defaults are loaded from FlatIntelliJLaf.properties, FlatLightLaf.properties and FlatLaf.properties
* <p>
* The UI defaults are loaded from {@code FlatIntelliJLaf.properties},
* {@code FlatLightLaf.properties} and {@code FlatLaf.properties}.
*
* @author Karl Tauber
*/
public class FlatIntelliJLaf
extends FlatLightLaf
{
public static boolean install( ) {
public static final String NAME = "FlatLaf IntelliJ";
public static boolean install() {
return install( new FlatIntelliJLaf() );
}
public static void installLafInfo() {
installLafInfo( NAME, FlatIntelliJLaf.class );
}
@Override
public String getName() {
return "FlatLaf IntelliJ";
return NAME;
}
@Override

View File

@@ -50,9 +50,9 @@ import javax.swing.LookAndFeel;
import javax.swing.PopupFactory;
import javax.swing.SwingUtilities;
import javax.swing.UIDefaults;
import javax.swing.UIDefaults.ActiveValue;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.UIDefaults.ActiveValue;
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.FontUIResource;
import javax.swing.plaf.UIResource;
@@ -94,6 +94,10 @@ public abstract class FlatLaf
private Boolean oldFrameWindowDecorated;
private Boolean oldDialogWindowDecorated;
/**
* Sets the application look and feel to the given LaF
* using {@link UIManager#setLookAndFeel(javax.swing.LookAndFeel)}.
*/
public static boolean install( LookAndFeel newLookAndFeel ) {
try {
UIManager.setLookAndFeel( newLookAndFeel );
@@ -104,6 +108,16 @@ public abstract class FlatLaf
}
}
/**
* Adds the given look and feel to the set of available look and feels.
* <p>
* Useful if your application uses {@link UIManager#getInstalledLookAndFeels()}
* to query available LaFs and display them to the user in a combobox.
*/
public static void installLafInfo( String lafName, Class<? extends LookAndFeel> lafClass ) {
UIManager.installLookAndFeel( new UIManager.LookAndFeelInfo( lafName, lafClass.getName() ) );
}
/**
* Returns the look and feel identifier.
* <p>

View File

@@ -16,23 +16,41 @@
package com.formdev.flatlaf;
import javax.swing.UIManager;
/**
* A Flat LaF that has a light color scheme.
*
* The UI defaults are loaded from FlatLightLaf.properties and FlatLaf.properties
* <p>
* The UI defaults are loaded from {@code FlatLightLaf.properties} and {@code FlatLaf.properties}.
*
* @author Karl Tauber
*/
public class FlatLightLaf
extends FlatLaf
{
public static boolean install( ) {
public static final String NAME = "FlatLaf Light";
/**
* Sets the application look and feel to this LaF
* using {@link UIManager#setLookAndFeel(javax.swing.LookAndFeel)}.
*/
public static boolean install() {
return install( new FlatLightLaf() );
}
/**
* Adds this look and feel to the set of available look and feels.
* <p>
* Useful if your application uses {@link UIManager#getInstalledLookAndFeels()}
* to query available LaFs and display them to the user in a combobox.
*/
public static void installLafInfo() {
installLafInfo( NAME, FlatLightLaf.class );
}
@Override
public String getName() {
return "FlatLaf Light";
return NAME;
}
@Override

View File

@@ -88,6 +88,10 @@ public class FlatPropertiesLaf
return dark;
}
public Properties getProperties() {
return properties;
}
@Override
protected ArrayList<Class<?>> getLafClassesForDefaultsLoading() {
ArrayList<Class<?>> lafClasses = new ArrayList<>();

View File

@@ -475,7 +475,9 @@ public class IntelliJTheme
}
}
/** Rename UI default keys (key --> value). */
private static Map<String, String> uiKeyMapping = new HashMap<>();
/** Copy UI default keys (value --> key). */
private static Map<String, String> uiKeyCopying = new HashMap<>();
private static Map<String, String> uiKeyInverseMapping = new HashMap<>();
private static Map<String, String> checkboxKeyMapping = new HashMap<>();
@@ -529,6 +531,9 @@ public class IntelliJTheme
// Slider
uiKeyMapping.put( "Slider.trackWidth", "" ); // ignore (used in Material Theme UI Lite)
uiKeyCopying.put( "Slider.trackValueColor", "ProgressBar.foreground" );
uiKeyCopying.put( "Slider.thumbColor", "ProgressBar.foreground" );
uiKeyCopying.put( "Slider.trackColor", "ProgressBar.background" );
// TitlePane
uiKeyCopying.put( "TitlePane.inactiveBackground", "TitlePane.background" );

View File

@@ -586,13 +586,17 @@ class UIDefaultsLoader
case "darken": return parseColorHSLIncreaseDecrease( 2, false, params, resolver, reportError );
case "saturate": return parseColorHSLIncreaseDecrease( 1, true, params, resolver, reportError );
case "desaturate": return parseColorHSLIncreaseDecrease( 1, false, params, resolver, reportError );
case "fadein": return parseColorHSLIncreaseDecrease( 3, true, params, resolver, reportError );
case "fadeout": return parseColorHSLIncreaseDecrease( 3, false, params, resolver, reportError );
case "fade": return parseColorFade( params, resolver, reportError );
case "spin": return parseColorSpin( params, resolver, reportError );
}
throw new IllegalArgumentException( "unknown color function '" + value + "'" );
}
/**
* Syntax: rgb(red,green,blue) or rgba(red,green,blue,alpha) or rgba(color,alpha)
* Syntax: rgb(red,green,blue) or rgba(red,green,blue,alpha)
* - red: an integer 0-255 or a percentage 0-100%
* - green: an integer 0-255 or a percentage 0-100%
* - blue: an integer 0-255 or a percentage 0-100%
@@ -603,6 +607,8 @@ class UIDefaultsLoader
{
if( hasAlpha && params.size() == 2 ) {
// syntax rgba(color,alpha), which allows adding alpha to any color
// NOTE: this syntax is deprecated
// use fade(color,alpha) instead
String colorStr = params.get( 0 );
int alpha = parseInteger( params.get( 1 ), 0, 255, true );
@@ -639,7 +645,8 @@ class UIDefaultsLoader
/**
* Syntax: lighten(color,amount[,options]) or darken(color,amount[,options]) or
* saturate(color,amount[,options]) or desaturate(color,amount[,options])
* saturate(color,amount[,options]) or desaturate(color,amount[,options]) or
* fadein(color,amount[,options]) or fadeout(color,amount[,options])
* - color: a color (e.g. #f00) or a color function
* - amount: percentage 0-100%
* - options: [relative] [autoInverse] [noAutoInverse] [lazy] [derived]
@@ -679,6 +686,59 @@ class UIDefaultsLoader
};
}
// parse base color, apply function and create derived color
return parseFunctionBaseColor( colorStr, function, derived, resolver, reportError );
}
/**
* Syntax: fade(color,amount[,options])
* - color: a color (e.g. #f00) or a color function
* - amount: percentage 0-100%
* - options: [derived]
*/
private static Object parseColorFade( List<String> params, Function<String, String> resolver, boolean reportError ) {
String colorStr = params.get( 0 );
int amount = parsePercentage( params.get( 1 ) );
boolean derived = false;
if( params.size() > 2 ) {
String options = params.get( 2 );
derived = options.contains( "derived" );
}
// create function
ColorFunction function = new ColorFunctions.Fade( amount );
// parse base color, apply function and create derived color
return parseFunctionBaseColor( colorStr, function, derived, resolver, reportError );
}
/**
* Syntax: spin(color,angle[,options])
* - color: a color (e.g. #f00) or a color function
* - angle: number of degrees to rotate
* - options: [derived]
*/
private static Object parseColorSpin( List<String> params, Function<String, String> resolver, boolean reportError ) {
String colorStr = params.get( 0 );
int amount = parseInteger( params.get( 1 ), true );
boolean derived = false;
if( params.size() > 2 ) {
String options = params.get( 2 );
derived = options.contains( "derived" );
}
// create function
ColorFunction function = new ColorFunctions.HSLIncreaseDecrease( 0, true, amount, false, false );
// parse base color, apply function and create derived color
return parseFunctionBaseColor( colorStr, function, derived, resolver, reportError );
}
private static Object parseFunctionBaseColor( String colorStr, ColorFunction function,
boolean derived, Function<String, String> resolver, boolean reportError )
{
// parse base color
String resolvedColorStr = resolver.apply( colorStr );
ColorUIResource baseColor = (ColorUIResource) parseColorOrFunction( resolvedColorStr, resolver, reportError );

View File

@@ -0,0 +1,55 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.icons;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import com.formdev.flatlaf.util.AnimatedIcon;
/**
* Base class for animated icons that scales width and height, creates and initializes
* a scaled graphics context for icon painting.
* <p>
* Subclasses do not need to scale icon painting.
* <p>
* This class does not store any state information (needed for animation) in its instance.
* Instead a client property is set on the painted component.
* This makes it possible to use a share icon instance for multiple components.
*
* @author Karl Tauber
*/
public abstract class FlatAnimatedIcon
extends FlatAbstractIcon
implements AnimatedIcon
{
public FlatAnimatedIcon( int width, int height, Color color ) {
super( width, height, color );
}
@Override
public void paintIcon( Component c, Graphics g, int x, int y ) {
super.paintIcon( c, g, x, y );
AnimatedIcon.AnimationSupport.saveIconLocation( this, c, x, y );
}
@Override
protected void paintIcon( Component c, Graphics2D g ) {
AnimatedIcon.AnimationSupport.paintIcon( this, c, g, 0, 0 );
}
}

View File

@@ -129,78 +129,101 @@ public class FlatCheckBoxIcon
}
@Override
protected void paintIcon( Component c, Graphics2D g2 ) {
boolean indeterminate = c instanceof JComponent && clientPropertyEquals( (JComponent) c, SELECTED_STATE, SELECTED_STATE_INDETERMINATE );
boolean selected = indeterminate || (c instanceof AbstractButton && ((AbstractButton)c).isSelected());
protected void paintIcon( Component c, Graphics2D g ) {
boolean indeterminate = isIndeterminate( c );
boolean selected = indeterminate || isSelected( c );
boolean isFocused = FlatUIUtils.isPermanentFocusOwner( c );
// paint focused border
if( isFocused && focusWidth > 0 && FlatButtonUI.isFocusPainted( c ) ) {
g2.setColor( focusColor );
paintFocusBorder( g2 );
g.setColor( getFocusColor( c ) );
paintFocusBorder( c, g );
}
// paint border
g2.setColor( FlatButtonUI.buttonStateColor( c,
selected ? selectedBorderColor : borderColor,
disabledBorderColor,
selected && selectedFocusedBorderColor != null ? selectedFocusedBorderColor : focusedBorderColor,
hoverBorderColor,
null ) );
paintBorder( g2 );
g.setColor( getBorderColor( c, selected ) );
paintBorder( c, g );
// paint background
g2.setColor( FlatUIUtils.deriveColor( FlatButtonUI.buttonStateColor( c,
selected ? selectedBackground : background,
disabledBackground,
(selected && selectedFocusedBackground != null) ? selectedFocusedBackground : focusedBackground,
(selected && selectedHoverBackground != null) ? selectedHoverBackground : hoverBackground,
(selected && selectedPressedBackground != null) ? selectedPressedBackground : pressedBackground ),
background ) );
paintBackground( g2 );
g.setColor( FlatUIUtils.deriveColor( getBackground( c, selected ), background ) );
paintBackground( c, g );
// paint checkmark
if( selected || indeterminate ) {
g2.setColor( c.isEnabled()
? ((selected && isFocused && selectedFocusedCheckmarkColor != null)
? selectedFocusedCheckmarkColor
: checkmarkColor)
: disabledCheckmarkColor );
g.setColor( getCheckmarkColor( c, selected, isFocused ) );
if( indeterminate )
paintIndeterminate( g2 );
paintIndeterminate( c, g );
else
paintCheckmark( g2 );
paintCheckmark( c, g );
}
}
protected void paintFocusBorder( Graphics2D g2 ) {
protected void paintFocusBorder( Component c, Graphics2D g ) {
// the outline focus border is painted outside of the icon
int wh = ICON_SIZE - 1 + (focusWidth * 2);
int arcwh = arc + (focusWidth * 2);
g2.fillRoundRect( -focusWidth + 1, -focusWidth, wh, wh, arcwh, arcwh );
g.fillRoundRect( -focusWidth + 1, -focusWidth, wh, wh, arcwh, arcwh );
}
protected void paintBorder( Graphics2D g2 ) {
protected void paintBorder( Component c, Graphics2D g ) {
int arcwh = arc;
g2.fillRoundRect( 1, 0, 14, 14, arcwh, arcwh );
g.fillRoundRect( 1, 0, 14, 14, arcwh, arcwh );
}
protected void paintBackground( Graphics2D g2 ) {
protected void paintBackground( Component c, Graphics2D g ) {
int arcwh = arc - 1;
g2.fillRoundRect( 2, 1, 12, 12, arcwh, arcwh );
g.fillRoundRect( 2, 1, 12, 12, arcwh, arcwh );
}
protected void paintCheckmark( Graphics2D g2 ) {
protected void paintCheckmark( Component c, Graphics2D g ) {
Path2D.Float path = new Path2D.Float();
path.moveTo( 4.5f, 7.5f );
path.lineTo( 6.6f, 10f );
path.lineTo( 11.25f, 3.5f );
g2.setStroke( new BasicStroke( 1.9f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND ) );
g2.draw( path );
g.setStroke( new BasicStroke( 1.9f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND ) );
g.draw( path );
}
protected void paintIndeterminate( Graphics2D g2 ) {
g2.fill( new RoundRectangle2D.Float( 3.75f, 5.75f, 8.5f, 2.5f, 2f, 2f ) );
protected void paintIndeterminate( Component c, Graphics2D g ) {
g.fill( new RoundRectangle2D.Float( 3.75f, 5.75f, 8.5f, 2.5f, 2f, 2f ) );
}
protected boolean isIndeterminate( Component c ) {
return c instanceof JComponent && clientPropertyEquals( (JComponent) c, SELECTED_STATE, SELECTED_STATE_INDETERMINATE );
}
protected boolean isSelected( Component c ) {
return c instanceof AbstractButton && ((AbstractButton)c).isSelected();
}
protected Color getFocusColor( Component c ) {
return focusColor;
}
protected Color getBorderColor( Component c, boolean selected ) {
return FlatButtonUI.buttonStateColor( c,
selected ? selectedBorderColor : borderColor,
disabledBorderColor,
selected && selectedFocusedBorderColor != null ? selectedFocusedBorderColor : focusedBorderColor,
hoverBorderColor,
null );
}
protected Color getBackground( Component c, boolean selected ) {
return FlatButtonUI.buttonStateColor( c,
selected ? selectedBackground : background,
disabledBackground,
(selected && selectedFocusedBackground != null) ? selectedFocusedBackground : focusedBackground,
(selected && selectedHoverBackground != null) ? selectedHoverBackground : hoverBackground,
(selected && selectedPressedBackground != null) ? selectedPressedBackground : pressedBackground );
}
protected Color getCheckmarkColor( Component c, boolean selected, boolean isFocused ) {
return c.isEnabled()
? ((selected && isFocused && selectedFocusedCheckmarkColor != null)
? selectedFocusedCheckmarkColor
: checkmarkColor)
: disabledCheckmarkColor;
}
}

View File

@@ -16,6 +16,7 @@
package com.formdev.flatlaf.icons;
import java.awt.Component;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
@@ -36,25 +37,25 @@ public class FlatRadioButtonIcon
protected final int centerDiameter = getUIInt( "RadioButton.icon.centerDiameter", 8, style );
@Override
protected void paintFocusBorder( Graphics2D g2 ) {
protected void paintFocusBorder( Component c, Graphics2D g ) {
// the outline focus border is painted outside of the icon
int wh = ICON_SIZE + (focusWidth * 2);
g2.fillOval( -focusWidth, -focusWidth, wh, wh );
g.fillOval( -focusWidth, -focusWidth, wh, wh );
}
@Override
protected void paintBorder( Graphics2D g2 ) {
g2.fillOval( 0, 0, 15, 15 );
protected void paintBorder( Component c, Graphics2D g ) {
g.fillOval( 0, 0, 15, 15 );
}
@Override
protected void paintBackground( Graphics2D g2 ) {
g2.fillOval( 1, 1, 13, 13 );
protected void paintBackground( Component c, Graphics2D g ) {
g.fillOval( 1, 1, 13, 13 );
}
@Override
protected void paintCheckmark( Graphics2D g2 ) {
protected void paintCheckmark( Component c, Graphics2D g ) {
float xy = (ICON_SIZE - centerDiameter) / 2f;
g2.fill( new Ellipse2D.Float( xy, xy, centerDiameter, centerDiameter ) );
g.fill( new Ellipse2D.Float( xy, xy, centerDiameter, centerDiameter ) );
}
}

View File

@@ -166,8 +166,7 @@ public class FlatArrowButton
@Override
public void paint( Graphics g ) {
Graphics2D g2 = (Graphics2D)g;
FlatUIUtils.setRenderingHints( g2 );
Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g );
// paint hover or pressed background
if( isEnabled() ) {
@@ -179,7 +178,7 @@ public class FlatArrowButton
if( background != null ) {
g.setColor( deriveBackground( background ) );
paintBackground( g2 );
paintBackground( (Graphics2D) g );
}
}
@@ -191,7 +190,9 @@ public class FlatArrowButton
? hoverForeground
: foreground))
: disabledForeground ) );
paintArrow( g2 );
paintArrow( (Graphics2D) g );
FlatUIUtils.resetRenderingHints( g, oldRenderingHints );
}
protected void paintBackground( Graphics2D g ) {

View File

@@ -352,7 +352,7 @@ public class FlatComboBoxUI
FlatUIUtils.paintParentBackground( g, c );
Graphics2D g2 = (Graphics2D) g;
FlatUIUtils.setRenderingHints( g2 );
Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g2 );
int width = c.getWidth();
int height = c.getHeight();
@@ -386,6 +386,9 @@ public class FlatComboBoxUI
g2.fill( new Rectangle2D.Float( lx, focusWidth, lw, height - 1 - (focusWidth * 2)) );
}
// avoid that the "current value" renderer is invoked with enabled antialiasing
FlatUIUtils.resetRenderingHints( g2, oldRenderingHints );
paint( g, c );
}

View File

@@ -39,6 +39,7 @@ import javax.swing.UIManager;
import javax.swing.plaf.basic.BasicHTML;
import javax.swing.text.View;
import com.formdev.flatlaf.FlatLaf;
import com.formdev.flatlaf.util.DerivedColor;
import com.formdev.flatlaf.util.Graphics2DProxy;
import com.formdev.flatlaf.util.HiDPIUtils;
import com.formdev.flatlaf.util.SystemInfo;
@@ -55,7 +56,7 @@ import com.formdev.flatlaf.util.SystemInfo;
* @uiDefault MenuItem.underlineSelectionBackground Color
* @uiDefault MenuItem.underlineSelectionCheckBackground Color
* @uiDefault MenuItem.underlineSelectionColor Color
* @uiDefault MenuItem.underlineSelectionHeight Color
* @uiDefault MenuItem.underlineSelectionHeight int
*
* @author Karl Tauber
*/
@@ -246,8 +247,11 @@ public class FlatMenuItemRenderer
g.setColor( Color.orange ); g.drawRect( arrowRect.x, arrowRect.y, arrowRect.width - 1, arrowRect.height - 1 );
debug*/
paintBackground( g, selectionBackground );
paintIcon( g, iconRect, getIconForPainting() );
boolean underlineSelection = isUnderlineSelection();
paintBackground( g, underlineSelection ? underlineSelectionBackground : selectionBackground );
if( underlineSelection && isArmedOrSelected( menuItem ) )
paintUnderlineSelection( g, underlineSelectionColor, underlineSelectionHeight );
paintIcon( g, iconRect, getIconForPainting(), underlineSelection ? underlineSelectionCheckBackground : checkBackground );
paintText( g, textRect, menuItem.getText(), selectionForeground, disabledForeground );
paintAccelerator( g, accelRect, getAcceleratorText(), acceleratorForeground, acceleratorSelectionForeground, disabledForeground );
if( !isTopLevelMenu( menuItem ) )
@@ -257,36 +261,36 @@ debug*/
protected void paintBackground( Graphics g, Color selectionBackground ) {
boolean armedOrSelected = isArmedOrSelected( menuItem );
if( menuItem.isOpaque() || armedOrSelected ) {
int width = menuItem.getWidth();
int height = menuItem.getHeight();
// paint background
g.setColor( armedOrSelected
? (isUnderlineSelection()
? deriveBackground( underlineSelectionBackground )
: selectionBackground)
? deriveBackground( selectionBackground )
: menuItem.getBackground() );
g.fillRect( 0, 0, width, height );
g.fillRect( 0, 0, menuItem.getWidth(), menuItem.getHeight() );
}
}
// paint underline
if( armedOrSelected && isUnderlineSelection() ) {
int underlineHeight = scale( underlineSelectionHeight );
g.setColor( underlineSelectionColor );
if( isTopLevelMenu( menuItem ) ) {
// paint underline at bottom
g.fillRect( 0, height - underlineHeight, width, underlineHeight );
} else if( menuItem.getComponentOrientation().isLeftToRight() ) {
// paint underline at left side
g.fillRect( 0, 0, underlineHeight, height );
} else {
// paint underline at right side
g.fillRect( width - underlineHeight, 0, underlineHeight, height );
}
}
protected void paintUnderlineSelection( Graphics g, Color underlineSelectionColor, int underlineSelectionHeight ) {
int width = menuItem.getWidth();
int height = menuItem.getHeight();
int underlineHeight = scale( underlineSelectionHeight );
g.setColor( underlineSelectionColor );
if( isTopLevelMenu( menuItem ) ) {
// paint underline at bottom
g.fillRect( 0, height - underlineHeight, width, underlineHeight );
} else if( menuItem.getComponentOrientation().isLeftToRight() ) {
// paint underline at left side
g.fillRect( 0, 0, underlineHeight, height );
} else {
// paint underline at right side
g.fillRect( width - underlineHeight, 0, underlineHeight, height );
}
}
protected Color deriveBackground( Color background ) {
if( !(background instanceof DerivedColor) )
return background;
Color baseColor = menuItem.isOpaque()
? menuItem.getBackground()
: FlatUIUtils.getParentBackground( menuItem );
@@ -294,12 +298,12 @@ debug*/
return FlatUIUtils.deriveColor( background, baseColor );
}
protected void paintIcon( Graphics g, Rectangle iconRect, Icon icon ) {
protected void paintIcon( Graphics g, Rectangle iconRect, Icon icon, Color checkBackground ) {
// if checkbox/radiobutton menu item is selected and also has a custom icon,
// then use filled icon background to indicate selection (instead of using checkIcon)
if( menuItem.isSelected() && checkIcon != null && icon != checkIcon ) {
Rectangle r = FlatUIUtils.addInsets( iconRect, scale( checkMargins ) );
g.setColor( deriveBackground( isUnderlineSelection() ? underlineSelectionCheckBackground : checkBackground ) );
g.setColor( deriveBackground( checkBackground ) );
g.fillRect( r.x, r.y, r.width, r.height );
}

View File

@@ -62,6 +62,12 @@ import javax.swing.plaf.basic.BasicMenuUI;
* @uiDefault MenuItem.iconTextGap int
* @uiDefault MenuBar.hoverBackground Color
*
* <!-- FlatMenuRenderer -->
*
* @uiDefault MenuBar.underlineSelectionBackground Color
* @uiDefault MenuBar.underlineSelectionColor Color
* @uiDefault MenuBar.underlineSelectionHeight int
*
* @author Karl Tauber
*/
public class FlatMenuUI
@@ -147,6 +153,10 @@ public class FlatMenuUI
protected class FlatMenuRenderer
extends FlatMenuItemRenderer
{
protected final Color menuBarUnderlineSelectionBackground = FlatUIUtils.getUIColor( "MenuBar.underlineSelectionBackground", underlineSelectionBackground );
protected final Color menuBarUnderlineSelectionColor = FlatUIUtils.getUIColor( "MenuBar.underlineSelectionColor", underlineSelectionColor );
protected final int menuBarUnderlineSelectionHeight = FlatUIUtils.getUIInt( "MenuBar.underlineSelectionHeight", underlineSelectionHeight );
protected FlatMenuRenderer( JMenuItem menuItem, Icon checkIcon, Icon arrowIcon,
Font acceleratorFont, String acceleratorDelimiter )
{
@@ -155,6 +165,9 @@ public class FlatMenuUI
@Override
protected void paintBackground( Graphics g, Color selectionBackground ) {
if( isUnderlineSelection() && ((JMenu)menuItem).isTopLevelMenu() )
selectionBackground = menuBarUnderlineSelectionBackground;
ButtonModel model = menuItem.getModel();
if( model.isRollover() && !model.isArmed() && !model.isSelected() &&
model.isEnabled() && ((JMenu)menuItem).isTopLevelMenu() )
@@ -164,5 +177,15 @@ public class FlatMenuUI
} else
super.paintBackground( g, selectionBackground );
}
@Override
protected void paintUnderlineSelection( Graphics g, Color underlineSelectionColor, int underlineSelectionHeight ) {
if( ((JMenu)menuItem).isTopLevelMenu() ) {
underlineSelectionColor = menuBarUnderlineSelectionColor;
underlineSelectionHeight = menuBarUnderlineSelectionHeight;
}
super.paintUnderlineSelection( g, underlineSelectionColor, underlineSelectionHeight );
}
}
}

View File

@@ -68,19 +68,17 @@ public class FlatPopupFactory
y = pt.y;
}
if( !isDropShadowPainted( owner, contents ) )
return new NonFlashingPopup( getPopupForScreenOfOwner( owner, contents, x, y, false ), contents );
boolean forceHeavyWeight = isOptionEnabled( owner, contents, FlatClientProperties.POPUP_FORCE_HEAVY_WEIGHT, "Popup.forceHeavyWeight" );
if( !isOptionEnabled( owner, contents, FlatClientProperties.POPUP_DROP_SHADOW_PAINTED, "Popup.dropShadowPainted" ) )
return new NonFlashingPopup( getPopupForScreenOfOwner( owner, contents, x, y, forceHeavyWeight ), contents );
// macOS and Linux adds drop shadow to heavy weight popups
if( SystemInfo.isMacOS || SystemInfo.isLinux ) {
Popup popup = getPopupForScreenOfOwner( owner, contents, x, y, true );
if( popup == null )
popup = getPopupForScreenOfOwner( owner, contents, x, y, false );
return new NonFlashingPopup( popup, contents );
}
if( SystemInfo.isMacOS || SystemInfo.isLinux )
return new NonFlashingPopup( getPopupForScreenOfOwner( owner, contents, x, y, true ), contents );
// create drop shadow popup
return new DropShadowPopup( getPopupForScreenOfOwner( owner, contents, x, y, false ), owner, contents );
return new DropShadowPopup( getPopupForScreenOfOwner( owner, contents, x, y, forceHeavyWeight ), owner, contents );
}
/**
@@ -155,24 +153,20 @@ public class FlatPopupFactory
popup.show();
}
private boolean isDropShadowPainted( Component owner, Component contents ) {
Boolean b = isDropShadowPainted( owner );
if( b != null )
return b;
private boolean isOptionEnabled( Component owner, Component contents, String clientKey, String uiKey ) {
if( owner instanceof JComponent ) {
Boolean b = FlatClientProperties.clientPropertyBooleanStrict( (JComponent) owner, clientKey, null );
if( b != null )
return b;
}
b = isDropShadowPainted( contents );
if( b != null )
return b;
if( contents instanceof JComponent ) {
Boolean b = FlatClientProperties.clientPropertyBooleanStrict( (JComponent) contents, clientKey, null );
if( b != null )
return b;
}
return UIManager.getBoolean( "Popup.dropShadowPainted" );
}
private Boolean isDropShadowPainted( Component c ) {
if( !(c instanceof JComponent) )
return null;
Object value = ((JComponent)c).getClientProperty( FlatClientProperties.POPUP_DROP_SHADOW_PAINTED );
return (value instanceof Boolean ) ? (Boolean) value : null;
return UIManager.getBoolean( uiKey );
}
/**
@@ -277,16 +271,17 @@ public class FlatPopupFactory
// increase tooltip size if necessary because it may be too small on HiDPI screens
// https://bugs.openjdk.java.net/browse/JDK-8213535
if( contents instanceof JToolTip ) {
if( contents instanceof JToolTip && popupWindow == null ) {
Container parent = contents.getParent();
if( parent instanceof JPanel ) {
Dimension prefSize = parent.getPreferredSize();
if( !prefSize.equals( parent.getSize() ) ) {
Container panel = SwingUtilities.getAncestorOfClass( Panel.class, parent );
if( panel != null )
panel.setSize( prefSize ); // for medium weight popup
else
parent.setSize( prefSize ); // for light weight popup
Container mediumWeightPanel = SwingUtilities.getAncestorOfClass( Panel.class, parent );
Container c = (mediumWeightPanel != null)
? mediumWeightPanel // medium weight popup
: parent; // light weight popup
c.setSize( prefSize );
c.validate();
}
}
}

View File

@@ -155,7 +155,7 @@ public class FlatProgressBarUI
? 0
: Math.min( UIScale.scale( this.arc ), horizontal ? height : width );
FlatUIUtils.setRenderingHints( (Graphics2D) g );
Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g );
// paint track
RoundRectangle2D.Float trackShape = new RoundRectangle2D.Float( x, y, width, height, arc, arc );
@@ -163,6 +163,7 @@ public class FlatProgressBarUI
((Graphics2D)g).fill( trackShape );
// paint progress
int amountFull = 0;
if( progressBar.isIndeterminate() ) {
boxRect = getBox( boxRect );
if( boxRect != null ) {
@@ -170,11 +171,8 @@ public class FlatProgressBarUI
((Graphics2D)g).fill( new RoundRectangle2D.Float( boxRect.x, boxRect.y,
boxRect.width, boxRect.height, arc, arc ) );
}
if( progressBar.isStringPainted() )
paintString( g, x, y, width, height, 0, insets );
} else {
int amountFull = getAmountFull( insets, width, height );
amountFull = getAmountFull( insets, width, height );
RoundRectangle2D.Float progressShape = horizontal
? new RoundRectangle2D.Float( c.getComponentOrientation().isLeftToRight() ? x : x + (width - amountFull),
@@ -189,10 +187,12 @@ public class FlatProgressBarUI
((Graphics2D)g).fill( area );
} else
((Graphics2D)g).fill( progressShape );
if( progressBar.isStringPainted() )
paintString( g, x, y, width, height, amountFull, insets );
}
FlatUIUtils.resetRenderingHints( g, oldRenderingHints );
if( progressBar.isStringPainted() )
paintString( g, x, y, width, height, amountFull, insets );
}
@Override

View File

@@ -285,6 +285,7 @@ public class FlatRootPaneUI
@Override
public void layoutContainer( Container parent ) {
JRootPane rootPane = (JRootPane) parent;
boolean isFullScreen = FlatUIUtils.isFullScreen( rootPane );
Insets insets = rootPane.getInsets();
int x = insets.left;
@@ -298,7 +299,7 @@ public class FlatRootPaneUI
rootPane.getGlassPane().setBounds( x, y, width, height );
int nextY = 0;
if( titlePane != null ) {
if( !isFullScreen && titlePane != null ) {
Dimension prefSize = titlePane.getPreferredSize();
titlePane.setBounds( 0, 0, width, prefSize.height );
nextY += prefSize.height;
@@ -306,7 +307,7 @@ public class FlatRootPaneUI
JMenuBar menuBar = rootPane.getJMenuBar();
if( menuBar != null && menuBar.isVisible() ) {
if( titlePane != null && titlePane.isMenuBarEmbedded() ) {
if( !isFullScreen && titlePane != null && titlePane.isMenuBarEmbedded() ) {
titlePane.validate();
menuBar.setBounds( titlePane.getMenuBarBounds() );
} else {
@@ -356,7 +357,7 @@ public class FlatRootPaneUI
@Override
public Insets getBorderInsets( Component c, Insets insets ) {
if( isWindowMaximized( c ) ) {
if( isWindowMaximized( c ) || FlatUIUtils.isFullScreen( c ) ) {
// hide border if window is maximized
insets.top = insets.left = insets.bottom = insets.right = 0;
return insets;
@@ -366,7 +367,7 @@ public class FlatRootPaneUI
@Override
public void paintBorder( Component c, Graphics g, int x, int y, int width, int height ) {
if( isWindowMaximized( c ) )
if( isWindowMaximized( c ) || FlatUIUtils.isFullScreen( c ) )
return;
Container parent = c.getParent();

View File

@@ -19,7 +19,6 @@ package com.formdev.flatlaf.ui;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.event.MouseAdapter;
@@ -142,6 +141,12 @@ public class FlatScrollBarUI
buttonDisabledArrowColor = UIManager.getColor( "ScrollBar.buttonDisabledArrowColor" );
hoverButtonBackground = UIManager.getColor( "ScrollBar.hoverButtonBackground" );
pressedButtonBackground = UIManager.getColor( "ScrollBar.pressedButtonBackground" );
// fallback (e.g. when used in NetBeans GUI builder)
if( trackInsets == null )
trackInsets = new Insets( 0, 0, 0, 0 );
if( thumbInsets == null )
thumbInsets = new Insets( 0, 0, 0, 0 );
}
@Override
@@ -215,8 +220,9 @@ public class FlatScrollBarUI
@Override
public void paint( Graphics g, JComponent c ) {
FlatUIUtils.setRenderingHints( (Graphics2D) g );
Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g );
super.paint( g, c );
FlatUIUtils.resetRenderingHints( g, oldRenderingHints );
}
@Override

View File

@@ -18,17 +18,23 @@ package com.formdev.flatlaf.ui;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.MouseListener;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.event.MouseEvent;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Path2D;
import java.awt.geom.RoundRectangle2D;
import javax.swing.JComponent;
import javax.swing.JSlider;
import javax.swing.LookAndFeel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicSliderUI;
import com.formdev.flatlaf.util.HiDPIUtils;
import com.formdev.flatlaf.util.UIScale;
/**
@@ -49,29 +55,46 @@ import com.formdev.flatlaf.util.UIScale;
* <!-- FlatSliderUI -->
*
* @uiDefault Slider.trackWidth int
* @uiDefault Slider.thumbWidth int
* @uiDefault Slider.thumbSize Dimension
* @uiDefault Slider.focusWidth int
* @uiDefault Slider.trackValueColor Color optional; defaults to Slider.thumbColor
* @uiDefault Slider.trackColor Color
* @uiDefault Slider.thumbColor Color
* @uiDefault Slider.thumbBorderColor Color optional; if null, no border is painted
* @uiDefault Slider.focusedColor Color optional; defaults to Component.focusColor
* @uiDefault Slider.hoverColor Color optional; defaults to Slider.focusedColor
* @uiDefault Slider.disabledForeground Color used for track and thumb is disabled
* @uiDefault Slider.focusedThumbBorderColor Color optional; defaults to Component.focusedBorderColor
* @uiDefault Slider.hoverThumbColor Color optional
* @uiDefault Slider.pressedThumbColor Color optional
* @uiDefault Slider.disabledTrackColor Color
* @uiDefault Slider.disabledThumbColor Color
* @uiDefault Slider.disabledThumbBorderColor Color optional; defaults to Component.disabledBorderColor
*
* @author Karl Tauber
*/
public class FlatSliderUI
extends BasicSliderUI
{
private int trackWidth;
private int thumbWidth;
protected int trackWidth;
protected Dimension thumbSize;
protected int focusWidth;
private Color trackColor;
private Color thumbColor;
private Color focusColor;
private Color hoverColor;
private Color disabledForeground;
protected Color trackValueColor;
protected Color trackColor;
protected Color thumbColor;
protected Color thumbBorderColor;
protected Color focusBaseColor;
protected Color focusedColor;
protected Color focusedThumbBorderColor;
protected Color hoverThumbColor;
protected Color pressedThumbColor;
protected Color disabledTrackColor;
protected Color disabledThumbColor;
protected Color disabledThumbBorderColor;
private MouseListener hoverListener;
private boolean hover;
protected boolean thumbHover;
protected boolean thumbPressed;
private Object[] oldRenderingHints;
public static ComponentUI createUI( JComponent c ) {
return new FlatSliderUI();
@@ -81,24 +104,6 @@ public class FlatSliderUI
super( null );
}
@Override
protected void installListeners( JSlider slider ) {
super.installListeners( slider );
hoverListener = new FlatUIUtils.HoverListener( slider, h -> {
hover = h;
} );
slider.addMouseListener( hoverListener );
}
@Override
protected void uninstallListeners( JSlider slider ) {
super.uninstallListeners( slider );
slider.removeMouseListener( hoverListener );
hoverListener = null;
}
@Override
protected void installDefaults( JSlider slider ) {
super.installDefaults( slider );
@@ -106,24 +111,65 @@ public class FlatSliderUI
LookAndFeel.installProperty( slider, "opaque", false );
trackWidth = UIManager.getInt( "Slider.trackWidth" );
thumbWidth = UIManager.getInt( "Slider.thumbWidth" );
thumbSize = UIManager.getDimension( "Slider.thumbSize" );
if( thumbSize == null ) {
// fallback for compatibility with old versions
int thumbWidth = UIManager.getInt( "Slider.thumbWidth" );
thumbSize = new Dimension( thumbWidth, thumbWidth );
}
focusWidth = FlatUIUtils.getUIInt( "Slider.focusWidth", 4 );
trackValueColor = FlatUIUtils.getUIColor( "Slider.trackValueColor", "Slider.thumbColor" );
trackColor = UIManager.getColor( "Slider.trackColor" );
thumbColor = UIManager.getColor( "Slider.thumbColor" );
focusColor = FlatUIUtils.getUIColor( "Slider.focusedColor", "Component.focusColor" );
hoverColor = FlatUIUtils.getUIColor( "Slider.hoverColor", focusColor );
disabledForeground = UIManager.getColor( "Slider.disabledForeground" );
thumbBorderColor = UIManager.getColor( "Slider.thumbBorderColor" );
focusBaseColor = UIManager.getColor( "Component.focusColor" );
focusedColor = FlatUIUtils.getUIColor( "Slider.focusedColor", focusBaseColor );
focusedThumbBorderColor = FlatUIUtils.getUIColor( "Slider.focusedThumbBorderColor", "Component.focusedBorderColor" );
hoverThumbColor = UIManager.getColor( "Slider.hoverThumbColor" );
pressedThumbColor = UIManager.getColor( "Slider.pressedThumbColor" );
disabledTrackColor = UIManager.getColor( "Slider.disabledTrackColor" );
disabledThumbColor = UIManager.getColor( "Slider.disabledThumbColor" );
disabledThumbBorderColor = FlatUIUtils.getUIColor( "Slider.disabledThumbBorderColor", "Component.disabledBorderColor" );
}
@Override
protected void uninstallDefaults( JSlider slider ) {
super.uninstallDefaults( slider );
trackValueColor = null;
trackColor = null;
thumbColor = null;
focusColor = null;
hoverColor = null;
disabledForeground = null;
thumbBorderColor = null;
focusBaseColor = null;
focusedColor = null;
focusedThumbBorderColor = null;
hoverThumbColor = null;
pressedThumbColor = null;
disabledTrackColor = null;
disabledThumbColor = null;
disabledThumbBorderColor = null;
}
@Override
protected TrackListener createTrackListener( JSlider slider ) {
return new FlatTrackListener();
}
@Override
public int getBaseline( JComponent c, int width, int height ) {
if( c == null )
throw new NullPointerException();
if( width < 0 || height < 0 )
throw new IllegalArgumentException();
// no baseline for vertical orientation
if( slider.getOrientation() == JSlider.VERTICAL )
return -1;
// compute a baseline so that the track is vertically centered
FontMetrics fm = slider.getFontMetrics( slider.getFont() );
return trackRect.y + Math.round( (trackRect.height - fm.getHeight()) / 2f ) + fm.getAscent() - 1;
}
@Override
@@ -153,14 +199,50 @@ public class FlatSliderUI
@Override
protected Dimension getThumbSize() {
return new Dimension( UIScale.scale( thumbWidth ), UIScale.scale( thumbWidth ) );
return calcThumbSize( slider, thumbSize, focusWidth );
}
public static Dimension calcThumbSize( JSlider slider, Dimension thumbSize, int focusWidth ) {
int fw = UIScale.scale( focusWidth );
int w = UIScale.scale( thumbSize.width ) + fw + fw;
int h = UIScale.scale( thumbSize.height ) + fw + fw;
return (slider.getOrientation() == JSlider.HORIZONTAL)
? new Dimension( w, h )
: new Dimension( h, w );
}
@Override
public void paint( Graphics g, JComponent c ) {
FlatUIUtils.setRenderingHints( (Graphics2D) g );
oldRenderingHints = FlatUIUtils.setRenderingHints( g );
/*debug
g.setColor( Color.gray );
g.drawRect( 0, 0, c.getWidth() - 1, c.getHeight() - 1 );
g.setColor( Color.orange );
g.drawRect( focusRect.x, focusRect.y, focusRect.width - 1, focusRect.height - 1 );
g.setColor( Color.magenta );
g.drawRect( contentRect.x, contentRect.y, contentRect.width - 1, contentRect.height - 1 );
g.setColor( Color.blue );
g.drawRect( trackRect.x, trackRect.y, trackRect.width - 1, trackRect.height - 1 );
g.setColor( Color.red );
g.drawRect( thumbRect.x, thumbRect.y, thumbRect.width - 1, thumbRect.height - 1 );
g.setColor( Color.green );
g.drawRect( tickRect.x, tickRect.y, tickRect.width - 1, tickRect.height - 1 );
g.setColor( Color.red );
g.drawRect( labelRect.x, labelRect.y, labelRect.width - 1, labelRect.height - 1 );
debug*/
super.paint( g, c );
FlatUIUtils.resetRenderingHints( g, oldRenderingHints );
oldRenderingHints = null;
}
@Override
public void paintLabels( Graphics g ) {
FlatUIUtils.runWithoutRenderingHints( g, oldRenderingHints, () -> {
super.paintLabels( g );
} );
}
@Override
@@ -201,50 +283,308 @@ public class FlatSliderUI
}
if( coloredTrack != null ) {
g.setColor( FlatUIUtils.deriveColor( FlatUIUtils.isPermanentFocusOwner( slider ) ? focusColor : (hover ? hoverColor : thumbColor), thumbColor ) );
if( slider.getInverted() ) {
RoundRectangle2D temp = track;
track = coloredTrack;
coloredTrack = temp;
}
g.setColor( trackValueColor );
((Graphics2D)g).fill( coloredTrack );
}
g.setColor( enabled ? trackColor : disabledForeground );
g.setColor( enabled ? trackColor : disabledTrackColor );
((Graphics2D)g).fill( track );
}
@Override
public void paintThumb( Graphics g ) {
g.setColor( FlatUIUtils.deriveColor( slider.isEnabled()
? (FlatUIUtils.isPermanentFocusOwner( slider ) ? focusColor : (hover ? hoverColor : thumbColor))
: disabledForeground,
thumbColor ) );
Color color = stateColor( slider, thumbHover, thumbPressed,
thumbColor, disabledThumbColor, null, hoverThumbColor, pressedThumbColor );
color = FlatUIUtils.deriveColor( color, thumbColor );
if( isRoundThumb() )
g.fillOval( thumbRect.x, thumbRect.y, thumbRect.width, thumbRect.height );
else {
double w = thumbRect.width;
double h = thumbRect.height;
double wh = w / 2;
Color borderColor = (thumbBorderColor != null)
? stateColor( slider, false, false, thumbBorderColor, disabledThumbBorderColor, focusedThumbBorderColor, null, null )
: null;
Path2D thumb = FlatUIUtils.createPath( 0,0, w,0, w,(h - wh), wh,h, 0,(h - wh) );
Color focusedColor = FlatUIUtils.deriveColor( this.focusedColor, focusBaseColor );
paintThumb( g, slider, thumbRect, isRoundThumb(), color, borderColor, focusedColor, focusWidth );
}
public static void paintThumb( Graphics g, JSlider slider, Rectangle thumbRect, boolean roundThumb,
Color thumbColor, Color thumbBorderColor, Color focusedColor, int focusWidth )
{
double systemScaleFactor = UIScale.getSystemScaleFactor( (Graphics2D) g );
if( systemScaleFactor != 1 && systemScaleFactor != 2 ) {
// paint at scale 1x to avoid clipping on right and bottom edges at 125%, 150% or 175%
HiDPIUtils.paintAtScale1x( (Graphics2D) g, thumbRect.x, thumbRect.y, thumbRect.width, thumbRect.height,
(g2d, x2, y2, width2, height2, scaleFactor) -> {
paintThumbImpl( g, slider, x2, y2, width2, height2,
roundThumb, thumbColor, thumbBorderColor, focusedColor,
(float) (focusWidth * scaleFactor) );
} );
return;
}
paintThumbImpl( g, slider, thumbRect.x, thumbRect.y, thumbRect.width, thumbRect.height,
roundThumb, thumbColor, thumbBorderColor, focusedColor, focusWidth );
}
private static void paintThumbImpl( Graphics g, JSlider slider, int x, int y, int width, int height,
boolean roundThumb, Color thumbColor, Color thumbBorderColor, Color focusedColor, float focusWidth )
{
int fw = Math.round( UIScale.scale( focusWidth ) );
int tx = x + fw;
int ty = y + fw;
int tw = width - fw - fw;
int th = height - fw - fw;
boolean focused = FlatUIUtils.isPermanentFocusOwner( slider );
if( roundThumb ) {
// paint thumb focus border
if( focused ) {
g.setColor( focusedColor );
((Graphics2D)g).fill( createRoundThumbShape( x, y, width, height ) );
}
if( thumbBorderColor != null ) {
// paint thumb border
g.setColor( thumbBorderColor );
((Graphics2D)g).fill( createRoundThumbShape( tx, ty, tw, th ) );
// paint thumb background
float lw = UIScale.scale( 1f );
g.setColor( thumbColor );
((Graphics2D)g).fill( createRoundThumbShape( tx + lw, ty + lw,
tw - lw - lw, th - lw - lw ) );
} else {
// paint thumb background
g.setColor( thumbColor );
((Graphics2D)g).fill( createRoundThumbShape( tx, ty, tw, th ) );
}
} else {
Graphics2D g2 = (Graphics2D) g.create();
try {
g2.translate( thumbRect.x, thumbRect.y );
g2.translate( x, y );
if( slider.getOrientation() == JSlider.VERTICAL ) {
if( slider.getComponentOrientation().isLeftToRight() ) {
g2.translate( 0, thumbRect.height );
g2.translate( 0, height );
g2.rotate( Math.toRadians( 270 ) );
} else {
g2.translate( thumbRect.width, 0 );
g2.translate( width, 0 );
g2.rotate( Math.toRadians( 90 ) );
}
// rotate thumb width/height
int temp = tw;
tw = th;
th = temp;
}
// paint thumb focus border
if( focused ) {
g2.setColor( focusedColor );
g2.fill( createDirectionalThumbShape( 0, 0,
tw + fw + fw, th + fw + fw + (fw * 0.4142f), fw ) );
}
if( thumbBorderColor != null ) {
// paint thumb border
g2.setColor( thumbBorderColor );
g2.fill( createDirectionalThumbShape( fw, fw, tw, th, 0 ) );
// paint thumb background
float lw = UIScale.scale( 1f );
g2.setColor( thumbColor );
g2.fill( createDirectionalThumbShape( fw + lw, fw + lw,
tw - lw - lw, th - lw - lw - (lw * 0.4142f), 0 ) );
} else {
// paint thumb background
g2.setColor( thumbColor );
g2.fill( createDirectionalThumbShape( fw, fw, tw, th, 0 ) );
}
g2.fill( thumb );
} finally {
g2.dispose();
}
}
}
private boolean isRoundThumb() {
public static Shape createRoundThumbShape( float x, float y, float w, float h ) {
if( w == h )
return new Ellipse2D.Float( x, y, w, h );
else {
float arc = Math.min( w, h );
return new RoundRectangle2D.Float( x, y, w, h, arc, arc );
}
}
public static Shape createDirectionalThumbShape( float x, float y, float w, float h, float arc ) {
float wh = w / 2;
Path2D path = new Path2D.Float();
path.moveTo( x + wh, y + h );
path.lineTo( x, y + (h - wh) );
path.lineTo( x, y + arc );
path.quadTo( x, y, x + arc, y );
path.lineTo( x + (w - arc), y );
path.quadTo( x + w, y, x + w, y + arc );
path.lineTo( x + w, y + (h - wh) );
path.closePath();
return path;
}
public static Color stateColor( JSlider slider, boolean hover, boolean pressed,
Color enabledColor, Color disabledColor, Color focusedColor, Color hoverColor, Color pressedColor )
{
if( disabledColor != null && !slider.isEnabled() )
return disabledColor;
if( pressedColor != null && pressed )
return pressedColor;
if( hoverColor != null && hover )
return hoverColor;
if( focusedColor != null && FlatUIUtils.isPermanentFocusOwner( slider ) )
return focusedColor;
return enabledColor;
}
protected boolean isRoundThumb() {
return !slider.getPaintTicks() && !slider.getPaintLabels();
}
@Override
public void setThumbLocation( int x, int y ) {
if( !isRoundThumb() ) {
// the needle of the directional thumb is painted outside of thumbRect
// --> must increase repaint rectangle
// set new thumb location and compute union of old and new thumb bounds
Rectangle r = new Rectangle( thumbRect );
thumbRect.setLocation( x, y );
SwingUtilities.computeUnion( thumbRect.x, thumbRect.y, thumbRect.width, thumbRect.height, r );
// increase union rectangle for repaint
int extra = (int) Math.ceil( UIScale.scale( focusWidth ) * 0.4142f );
if( slider.getOrientation() == JSlider.HORIZONTAL )
r.height += extra;
else {
r.width += extra;
if( !slider.getComponentOrientation().isLeftToRight() )
r.x -= extra;
}
slider.repaint( r );
} else
super.setThumbLocation( x, y );
}
//---- class FlatTrackListener --------------------------------------------
protected class FlatTrackListener
extends TrackListener
{
@Override
public void mouseEntered( MouseEvent e ) {
setThumbHover( isOverThumb( e ) );
super.mouseEntered( e );
}
@Override
public void mouseExited( MouseEvent e ) {
setThumbHover( false );
super.mouseExited( e );
}
@Override
public void mouseMoved( MouseEvent e ) {
setThumbHover( isOverThumb( e ) );
super.mouseMoved( e );
}
@Override
public void mousePressed( MouseEvent e ) {
setThumbPressed( isOverThumb( e ) );
if( !slider.isEnabled() )
return;
// use "old" behavior when clicking on track
if( UIManager.getBoolean( "Slider.scrollOnTrackClick" ) ) {
super.mousePressed( e );
return;
}
// "new" behavior set thumb to mouse location when clicking on track
int x = e.getX();
int y = e.getY();
// clicked on thumb --> let super class do the work
calculateGeometry();
if( thumbRect.contains( x, y ) ) {
super.mousePressed( e );
return;
}
if( UIManager.getBoolean( "Slider.onlyLeftMouseButtonDrag" ) &&
!SwingUtilities.isLeftMouseButton( e ) )
return;
// move the mouse event coordinates to the center of the thumb
int tx = thumbRect.x + (thumbRect.width / 2) - x;
int ty = thumbRect.y + (thumbRect.height / 2) - y;
e.translatePoint( tx, ty );
// invoke super mousePressed() to start dragging thumb
super.mousePressed( e );
// move the mouse event coordinates back to current mouse location
e.translatePoint( -tx, -ty );
// invoke mouseDragged() to update thumb location
mouseDragged( e );
setThumbPressed( true );
}
@Override
public void mouseReleased( MouseEvent e ) {
setThumbPressed( false );
super.mouseReleased( e );
}
@Override
public void mouseDragged( MouseEvent e ) {
super.mouseDragged( e );
if( isDragging() &&
slider.getSnapToTicks() &&
slider.isEnabled() &&
!UIManager.getBoolean( "Slider.snapToTicksOnReleased" ) )
{
calculateThumbLocation();
slider.repaint();
}
}
protected void setThumbHover( boolean hover ) {
if( hover != thumbHover ) {
thumbHover = hover;
slider.repaint( thumbRect );
}
}
protected void setThumbPressed( boolean pressed ) {
if( pressed != thumbPressed ) {
thumbPressed = pressed;
slider.repaint( thumbRect );
}
}
protected boolean isOverThumb( MouseEvent e ) {
return e != null && slider.isEnabled() && thumbRect.contains( e.getX(), e.getY() );
}
}
}

View File

@@ -264,7 +264,7 @@ public class FlatSpinnerUI
FlatUIUtils.paintParentBackground( g, c );
Graphics2D g2 = (Graphics2D) g;
FlatUIUtils.setRenderingHints( g2 );
Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g2 );
int width = c.getWidth();
int height = c.getHeight();
@@ -303,6 +303,8 @@ public class FlatSpinnerUI
}
paint( g, c );
FlatUIUtils.resetRenderingHints( g, oldRenderingHints );
}
//---- class Handler ------------------------------------------------------

View File

@@ -20,7 +20,6 @@ import java.awt.Color;
import java.awt.Container;
import java.awt.Cursor;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
@@ -148,10 +147,12 @@ public class FlatSplitPaneUI
if( "plain".equals( style ) )
return;
FlatUIUtils.setRenderingHints( (Graphics2D) g );
Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g );
g.setColor( gripColor );
paintGrip( g, 0, 0, getWidth(), getHeight() );
FlatUIUtils.resetRenderingHints( g, oldRenderingHints );
}
protected void paintGrip( Graphics g, int x, int y, int width, int height ) {

View File

@@ -226,6 +226,8 @@ public class FlatTabbedPaneUI
private boolean rolloverTabClose;
private boolean pressedTabClose;
private Object[] oldRenderingHints;
public static ComponentUI createUI( JComponent c ) {
return new FlatTabbedPaneUI();
}
@@ -362,11 +364,6 @@ public class FlatTabbedPaneUI
protected void installComponents() {
super.installComponents();
// create tab close button
tabCloseButton = new TabCloseButton();
tabCloseButton.setVisible( false );
tabPane.add( tabCloseButton );
// find scrollable tab viewport
tabViewport = null;
if( isScrollTabLayout() ) {
@@ -393,11 +390,7 @@ public class FlatTabbedPaneUI
super.uninstallComponents();
if( tabCloseButton != null ) {
tabPane.remove( tabCloseButton );
tabCloseButton = null;
}
tabCloseButton = null;
tabViewport = null;
}
@@ -693,6 +686,26 @@ public class FlatTabbedPaneUI
return Math.max( tabHeight, scale( clientPropertyInt( tabPane, TABBED_PANE_TAB_HEIGHT, this.tabHeight ) ) );
}
@Override
protected int calculateMaxTabWidth( int tabPlacement ) {
return hideTabArea() ? 0 : super.calculateMaxTabWidth( tabPlacement );
}
@Override
protected int calculateMaxTabHeight( int tabPlacement ) {
return hideTabArea() ? 0 : super.calculateMaxTabHeight( tabPlacement );
}
@Override
protected int calculateTabAreaWidth( int tabPlacement, int vertRunCount, int maxTabWidth ) {
return hideTabArea() ? 0 : super.calculateTabAreaWidth( tabPlacement, vertRunCount, maxTabWidth );
}
@Override
protected int calculateTabAreaHeight( int tabPlacement, int horizRunCount, int maxTabHeight ) {
return hideTabArea() ? 0 : super.calculateTabAreaHeight( tabPlacement, horizRunCount, maxTabHeight );
}
@Override
protected Insets getTabInsets( int tabPlacement, int tabIndex ) {
Object value = getTabClientProperty( tabIndex, TABBED_PANE_TAB_INSETS );
@@ -752,7 +765,7 @@ public class FlatTabbedPaneUI
*/
@Override
protected Insets getContentBorderInsets( int tabPlacement ) {
if( contentSeparatorHeight == 0 || !clientPropertyBoolean( tabPane, TABBED_PANE_SHOW_CONTENT_SEPARATOR, true ) )
if( hideTabArea() || contentSeparatorHeight == 0 || !clientPropertyBoolean( tabPane, TABBED_PANE_SHOW_CONTENT_SEPARATOR, true ) )
return new Insets( 0, 0, 0, 0 );
boolean hasFullBorder = clientPropertyBoolean( tabPane, TABBED_PANE_HAS_FULL_BORDER, this.hasFullBorder );
@@ -780,13 +793,19 @@ public class FlatTabbedPaneUI
@Override
public void update( Graphics g, JComponent c ) {
FlatUIUtils.setRenderingHints( (Graphics2D) g );
oldRenderingHints = FlatUIUtils.setRenderingHints( g );
super.update( g, c );
FlatUIUtils.resetRenderingHints( g, oldRenderingHints );
oldRenderingHints = null;
}
@Override
public void paint( Graphics g, JComponent c ) {
if( hideTabArea() )
return;
ensureCurrentLayout();
int tabPlacement = tabPane.getTabPlacement();
@@ -860,27 +879,29 @@ public class FlatTabbedPaneUI
{
g.setFont( font );
// html
View view = getTextViewForTab( tabIndex );
if( view != null ) {
view.paint( g, textRect );
return;
}
FlatUIUtils.runWithoutRenderingHints( g, oldRenderingHints, () -> {
// html
View view = getTextViewForTab( tabIndex );
if( view != null ) {
view.paint( g, textRect );
return;
}
// plain text
Color color;
if( tabPane.isEnabled() && tabPane.isEnabledAt( tabIndex ) ) {
color = tabPane.getForegroundAt( tabIndex );
if( isSelected && (color instanceof UIResource) && selectedForeground != null )
color = selectedForeground;
} else
color = disabledForeground;
// plain text
Color color;
if( tabPane.isEnabled() && tabPane.isEnabledAt( tabIndex ) ) {
color = tabPane.getForegroundAt( tabIndex );
if( isSelected && (color instanceof UIResource) && selectedForeground != null )
color = selectedForeground;
} else
color = disabledForeground;
int mnemIndex = FlatLaf.isShowMnemonics() ? tabPane.getDisplayedMnemonicIndexAt( tabIndex ) : -1;
int mnemIndex = FlatLaf.isShowMnemonics() ? tabPane.getDisplayedMnemonicIndexAt( tabIndex ) : -1;
g.setColor( color );
FlatUIUtils.drawStringUnderlineCharAt( tabPane, g, title, mnemIndex,
textRect.x, textRect.y + metrics.getAscent() );
g.setColor( color );
FlatUIUtils.drawStringUnderlineCharAt( tabPane, g, title, mnemIndex,
textRect.x, textRect.y + metrics.getAscent() );
} );
}
@Override
@@ -911,6 +932,12 @@ public class FlatTabbedPaneUI
}
protected void paintTabCloseButton( Graphics g, int tabIndex, int x, int y, int w, int h ) {
// create tab close button
if( tabCloseButton == null ) {
tabCloseButton = new TabCloseButton();
tabCloseButton.setVisible( false );
}
// update state of tab close button
boolean rollover = (tabIndex == getRolloverTab());
ButtonModel bm = tabCloseButton.getModel();
@@ -1226,6 +1253,13 @@ public class FlatTabbedPaneUI
return UIManager.getBoolean( "ScrollPane.smoothScrolling" );
}
protected boolean hideTabArea() {
return tabPane.getTabCount() == 1 &&
leadingComponent == null &&
trailingComponent == null &&
clientPropertyBoolean( tabPane, TABBED_PANE_HIDE_TAB_AREA_WITH_ONE_TAB, false );
}
protected int getTabsPopupPolicy() {
Object value = tabPane.getClientProperty( TABBED_PANE_TABS_POPUP_POLICY );
@@ -2193,6 +2227,7 @@ public class FlatTabbedPaneUI
case TABBED_PANE_SHOW_TAB_SEPARATORS:
case TABBED_PANE_SHOW_CONTENT_SEPARATOR:
case TABBED_PANE_HAS_FULL_BORDER:
case TABBED_PANE_HIDE_TAB_AREA_WITH_ONE_TAB:
case TABBED_PANE_MINIMUM_TAB_WIDTH:
case TABBED_PANE_MAXIMUM_TAB_WIDTH:
case TABBED_PANE_TAB_HEIGHT:

View File

@@ -31,6 +31,7 @@ import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ScrollPaneConstants;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.border.Border;
@@ -98,10 +99,13 @@ public class FlatTableHeaderUI
@Override
public void paint( Graphics g, JComponent c ) {
if( header.getColumnModel().getColumnCount() <= 0 )
return;
// do not paint borders if JTableHeader.setDefaultRenderer() was used
TableCellRenderer defaultRenderer = header.getDefaultRenderer();
boolean paintBorders = isSystemDefaultRenderer( defaultRenderer );
if( !paintBorders && header.getColumnModel().getColumnCount() > 0 ) {
if( !paintBorders ) {
// check whether the renderer delegates to the system default renderer
Component rendererComponent = defaultRenderer.getTableCellRendererComponent(
header.getTable(), "", false, false, -1, 0 );
@@ -145,6 +149,9 @@ public class FlatTableHeaderUI
float bottomLineIndent = lineWidth * 3;
TableColumnModel columnModel = header.getColumnModel();
int columnCount = columnModel.getColumnCount();
int sepCount = columnCount;
if( hideLastVerticalLine() )
sepCount--;
Graphics2D g2 = (Graphics2D) g.create();
try {
@@ -157,23 +164,30 @@ public class FlatTableHeaderUI
// paint column separator lines
g2.setColor( separatorColor );
int sepCount = columnCount;
if( header.getTable() != null && header.getTable().getAutoResizeMode() != JTable.AUTO_RESIZE_OFF && !isVerticalScrollBarVisible() )
sepCount--;
float y = topLineIndent;
float h = height - bottomLineIndent;
if( header.getComponentOrientation().isLeftToRight() ) {
int x = 0;
for( int i = 0; i < sepCount; i++ ) {
x += columnModel.getColumn( i ).getWidth();
g2.fill( new Rectangle2D.Float( x - lineWidth, topLineIndent, lineWidth, height - bottomLineIndent ) );
g2.fill( new Rectangle2D.Float( x - lineWidth, y, lineWidth, h ) );
}
// paint trailing separator (on right side)
if( !hideTrailingVerticalLine() )
g2.fill( new Rectangle2D.Float( header.getWidth() - lineWidth, y, lineWidth, h ) );
} else {
int x = width;
Rectangle cellRect = header.getHeaderRect( 0 );
int x = cellRect.x + cellRect.width;
for( int i = 0; i < sepCount; i++ ) {
x -= columnModel.getColumn( i ).getWidth();
g2.fill( new Rectangle2D.Float( x - (i < sepCount - 1 ? lineWidth : 0),
topLineIndent, lineWidth, height - bottomLineIndent ) );
g2.fill( new Rectangle2D.Float( x - (i < sepCount - 1 ? lineWidth : 0), y, lineWidth, h ) );
}
// paint trailing separator (on left side)
if( !hideTrailingVerticalLine() )
g2.fill( new Rectangle2D.Float( 0, y, lineWidth, h ) );
}
} finally {
g2.dispose();
@@ -230,20 +244,30 @@ public class FlatTableHeaderUI
return size;
}
private boolean isVerticalScrollBarVisible() {
JScrollPane scrollPane = getScrollPane();
return (scrollPane != null && scrollPane.getVerticalScrollBar() != null)
? scrollPane.getVerticalScrollBar().isVisible()
: false;
protected boolean hideLastVerticalLine() {
Container viewport = header.getParent();
Container viewportParent = (viewport != null) ? viewport.getParent() : null;
if( !(viewportParent instanceof JScrollPane) )
return false;
Rectangle cellRect = header.getHeaderRect( header.getColumnModel().getColumnCount() - 1 );
// using component orientation of scroll pane here because it is also used in FlatTableUI
JScrollPane scrollPane = (JScrollPane) viewportParent;
return scrollPane.getComponentOrientation().isLeftToRight()
? cellRect.x + cellRect.width >= viewport.getWidth()
: cellRect.x <= 0;
}
private JScrollPane getScrollPane() {
Container parent = header.getParent();
if( parent == null )
return null;
protected boolean hideTrailingVerticalLine() {
Container viewport = header.getParent();
Container viewportParent = (viewport != null) ? viewport.getParent() : null;
if( !(viewportParent instanceof JScrollPane) )
return false;
parent = parent.getParent();
return (parent instanceof JScrollPane) ? (JScrollPane) parent : null;
JScrollPane scrollPane = (JScrollPane) viewportParent;
return viewport == scrollPane.getColumnHeader() &&
scrollPane.getCorner( ScrollPaneConstants.UPPER_TRAILING_CORNER ) == null;
}
//---- class FlatTableCellHeaderRenderer ----------------------------------

View File

@@ -17,17 +17,25 @@
package com.formdev.flatlaf.ui;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.geom.Rectangle2D;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JScrollPane;
import javax.swing.JViewport;
import javax.swing.LookAndFeel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicTableUI;
import javax.swing.table.TableCellRenderer;
import com.formdev.flatlaf.util.Graphics2DProxy;
import com.formdev.flatlaf.util.UIScale;
/**
@@ -203,4 +211,94 @@ public class FlatTableUI
table.setSelectionForeground( selectionInactiveForeground );
}
}
@Override
public void paint( Graphics g, JComponent c ) {
boolean horizontalLines = table.getShowHorizontalLines();
boolean verticalLines = table.getShowVerticalLines();
if( horizontalLines || verticalLines ) {
// fix grid painting issues in BasicTableUI
// - do not paint last vertical grid line if line is on right edge of scroll pane
// - fix unstable grid line thickness when scaled at 125%, 150%, 175%, 225%, ...
// which paints either 1px or 2px lines depending on location
boolean hideLastVerticalLine = hideLastVerticalLine();
int tableWidth = table.getWidth();
double systemScaleFactor = UIScale.getSystemScaleFactor( (Graphics2D) g );
double lineThickness = (1. / systemScaleFactor) * (int) systemScaleFactor;
// Java 8 uses drawLine() to paint grid lines
// Java 9+ uses fillRect() to paint grid lines
g = new Graphics2DProxy( (Graphics2D) g ) {
@Override
public void drawLine( int x1, int y1, int x2, int y2 ) {
// do not paint last vertical line
if( hideLastVerticalLine && verticalLines &&
x1 == x2 && y1 == 0 && x1 == tableWidth - 1 &&
wasInvokedFromPaintGrid() )
return;
super.drawLine( x1, y1, x2, y2 );
}
@Override
public void fillRect( int x, int y, int width, int height ) {
// do not paint last vertical line
if( hideLastVerticalLine && verticalLines &&
width == 1 && y == 0 && x == tableWidth - 1 &&
wasInvokedFromPaintGrid() )
return;
// reduce line thickness to avoid unstable painted line thickness
if( lineThickness != 1 ) {
if( horizontalLines && height == 1 && wasInvokedFromPaintGrid() ) {
super.fill( new Rectangle2D.Double( x, y, width, lineThickness ) );
return;
}
if( verticalLines && width == 1 && y == 0 && wasInvokedFromPaintGrid() ) {
super.fill( new Rectangle2D.Double( x, y, lineThickness, height ) );
return;
}
}
super.fillRect( x, y, width, height );
}
private boolean wasInvokedFromPaintGrid() {
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
for( int i = 0; i < 10 || i < stackTrace.length; i++ ) {
if( "javax.swing.plaf.basic.BasicTableUI".equals( stackTrace[i].getClassName() ) &&
"paintGrid".equals( stackTrace[i].getMethodName() ) )
return true;
}
return false;
}
};
}
super.paint( g, c );
}
protected boolean hideLastVerticalLine() {
Container viewport = SwingUtilities.getUnwrappedParent( table );
Container viewportParent = (viewport != null) ? viewport.getParent() : null;
if( !(viewportParent instanceof JScrollPane) )
return false;
// do not hide last vertical line if table is smaller than viewport
if( table.getX() + table.getWidth() < viewport.getWidth() )
return false;
// in left-to-right:
// - do not hide last vertical line if table used as row header in scroll pane
// in right-to-left:
// - hide last vertical line if table used as row header in scroll pane
// - do not hide last vertical line if table is in center and scroll pane has row header
JScrollPane scrollPane = (JScrollPane) viewportParent;
JViewport rowHeader = scrollPane.getRowHeader();
return scrollPane.getComponentOrientation().isLeftToRight()
? (viewport != rowHeader)
: (viewport == rowHeader || rowHeader == null);
}
}

View File

@@ -106,13 +106,15 @@ public class FlatToolBarSeparatorUI
float lineWidth = scale( 1f );
float offset = scale( 2f );
FlatUIUtils.setRenderingHints( (Graphics2D) g );
Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g );
g.setColor( separatorColor );
if( isVertical( c ) )
((Graphics2D)g).fill( new Rectangle2D.Float( Math.round( (width - lineWidth) / 2f ), offset, lineWidth, height - (offset * 2) ) );
else
((Graphics2D)g).fill( new Rectangle2D.Float( offset, Math.round( (height - lineWidth) / 2f ), width - (offset * 2), lineWidth ) );
FlatUIUtils.resetRenderingHints( g, oldRenderingHints );
}
private boolean isVertical( JComponent c ) {

View File

@@ -116,7 +116,6 @@ public class FlatToolTipUI
FontMetrics fm = c.getFontMetrics( c.getFont() );
Insets insets = c.getInsets();
FlatUIUtils.setRenderingHints( (Graphics2D) g );
g.setColor( c.getForeground() );
List<String> lines = StringUtils.split( ((JToolTip)c).getTipText(), '\n' );

View File

@@ -23,11 +23,14 @@ import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.Insets;
import java.awt.KeyboardFocusManager;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.Shape;
import java.awt.Window;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.MouseAdapter;
@@ -181,6 +184,16 @@ public class FlatUIUtils
keyboardFocusManager.getActiveWindow() == SwingUtilities.windowForComponent( c );
}
/**
* Returns whether the given component is in a window that is in full-screen mode.
*/
public static boolean isFullScreen( Component c ) {
GraphicsConfiguration gc = c.getGraphicsConfiguration();
GraphicsDevice gd = (gc != null) ? gc.getDevice() : null;
Window fullScreenWindow = (gd != null) ? gd.getFullScreenWindow() : null;
return (fullScreenWindow != null && fullScreenWindow == SwingUtilities.windowForComponent( c ));
}
public static Boolean isRoundRect( Component c ) {
return (c instanceof JComponent)
? FlatClientProperties.clientPropertyBooleanStrict(
@@ -227,10 +240,57 @@ public class FlatUIUtils
/**
* Sets rendering hints used for painting.
*/
public static void setRenderingHints( Graphics2D g ) {
g.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
g.setRenderingHint( RenderingHints.KEY_STROKE_CONTROL,
public static Object[] setRenderingHints( Graphics g ) {
Graphics2D g2 = (Graphics2D) g;
Object[] oldRenderingHints = new Object[] {
g2.getRenderingHint( RenderingHints.KEY_ANTIALIASING ),
g2.getRenderingHint( RenderingHints.KEY_STROKE_CONTROL ),
};
g2.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
g2.setRenderingHint( RenderingHints.KEY_STROKE_CONTROL,
MAC_USE_QUARTZ ? RenderingHints.VALUE_STROKE_PURE : RenderingHints.VALUE_STROKE_NORMALIZE );
return oldRenderingHints;
}
/**
* Resets rendering hints previously set with {@link #setRenderingHints}.
*/
public static void resetRenderingHints( Graphics g, Object[] oldRenderingHints ) {
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint( RenderingHints.KEY_ANTIALIASING, oldRenderingHints[0] );
g2.setRenderingHint( RenderingHints.KEY_STROKE_CONTROL, oldRenderingHints[1] );
}
/**
* Temporary resets rendering hints set with {@link #setRenderingHints}
* and runs the given runnable.
* <p>
* This is intended for painting text while rendering hints are set.
* <p>
* If text antialiasing is disabled (in OS system settings or via
* {@code -Dawt.useSystemAAFontSettings=off}), but general antialiasing is enabled,
* then text is still painted using some kind of "grayscale" antialiasing,
* which may make the text look bold (depends on font and font size).
* To avoid this, temporary disable general antialiasing.
* This does not affect text rendering if text antialiasing is enabled (usually the default).
*/
public static void runWithoutRenderingHints( Graphics g, Object[] oldRenderingHints, Runnable runnable ) {
if( oldRenderingHints == null ) {
runnable.run();
return;
}
Graphics2D g2 = (Graphics2D) g;
Object[] oldRenderingHints2 = new Object[] {
g2.getRenderingHint( RenderingHints.KEY_ANTIALIASING ),
g2.getRenderingHint( RenderingHints.KEY_STROKE_CONTROL ),
};
resetRenderingHints( g2, oldRenderingHints );
runnable.run();
resetRenderingHints( g2, oldRenderingHints2 );
}
public static Color deriveColor( Color color, Color baseColor ) {
@@ -506,15 +566,31 @@ public class FlatUIUtils
float x2 = x + width;
float y2 = y + height;
// same constant as in java.awt.geom.EllipseIterator.CtrlVal used to paint circles
double c = 0.5522847498307933;
double ci = 1. - c;
double ciTopLeft = arcTopLeft * ci;
double ciTopRight = arcTopRight * ci;
double ciBottomLeft = arcBottomLeft * ci;
double ciBottomRight = arcBottomRight * ci;
Path2D rect = new Path2D.Float();
rect.moveTo( x2 - arcTopRight, y );
rect.quadTo( x2, y, x2, y + arcTopRight );
rect.lineTo( x2, y2 - arcBottomRight );
rect.quadTo( x2, y2, x2 - arcBottomRight, y2 );
rect.lineTo( x + arcBottomLeft, y2 );
rect.quadTo( x, y2, x, y2 - arcBottomLeft );
rect.lineTo( x, y + arcTopLeft );
rect.quadTo( x, y, x + arcTopLeft, y );
rect.moveTo( x2 - arcTopRight, y );
rect.curveTo( x2 - ciTopRight, y,
x2, y + ciTopRight,
x2, y + arcTopRight );
rect.lineTo( x2, y2 - arcBottomRight );
rect.curveTo( x2, y2 - ciBottomRight,
x2 - ciBottomRight, y2,
x2 - arcBottomRight, y2 );
rect.lineTo( x + arcBottomLeft, y2 );
rect.curveTo( x + ciBottomLeft, y2,
x, y2 - ciBottomLeft,
x, y2 - arcBottomLeft );
rect.lineTo( x, y + arcTopLeft );
rect.curveTo( x, y + ciTopLeft,
x + ciTopLeft, y,
x + arcTopLeft, y );
rect.closePath();
return rect;

View File

@@ -256,6 +256,8 @@ public abstract class FlatWindowResizer
@Override
protected boolean isWindowResizable() {
if( FlatUIUtils.isFullScreen( resizeComp ) )
return false;
if( window instanceof Frame )
return ((Frame)window).isResizable() && (((Frame)window).getExtendedState() & Frame.MAXIMIZED_BOTH) == 0;
if( window instanceof Dialog )
@@ -429,9 +431,9 @@ public abstract class FlatWindowResizer
protected void paintComponent( Graphics g ) {
super.paintChildren( g );
// this is necessary because Dialog.setResizable() does not fire events
if( isDialog() )
updateVisibility();
// for dialogs: necessary because Dialog.setResizable() does not fire events
// for frames: necessary because GraphicsDevice.setFullScreenWindow() does not fire events
updateVisibility();
/*debug
int width = getWidth();

View File

@@ -0,0 +1,249 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.util;
import java.awt.Component;
import java.awt.Graphics;
import javax.swing.Icon;
import javax.swing.JComponent;
import com.formdev.flatlaf.util.Animator.Interpolator;
/**
* Icon that automatically animates painting on component value changes.
* <p>
* {@link #getValue(Component)} returns the value of the component.
* If the value changes, then {@link #paintIconAnimated(Component, Graphics, int, int, float)}
* is invoked multiple times with animated value (from old value to new value).
* <p>
* Example for an animated icon:
* <pre>
* private class AnimatedMinimalTestIcon
* implements AnimatedIcon
* {
* &#64;Override public int getIconWidth() { return 100; }
* &#64;Override public int getIconHeight() { return 20; }
*
* &#64;Override
* public void paintIconAnimated( Component c, Graphics g, int x, int y, float animatedValue ) {
* int w = getIconWidth();
* int h = getIconHeight();
*
* g.setColor( Color.red );
* g.drawRect( x, y, w - 1, h - 1 );
* g.fillRect( x, y, Math.round( w * animatedValue ), h );
* }
*
* &#64;Override
* public float getValue( Component c ) {
* return ((AbstractButton)c).isSelected() ? 1 : 0;
* }
* }
*
* // sample usage
* JCheckBox checkBox = new JCheckBox( "test" );
* checkBox.setIcon( new AnimatedMinimalTestIcon() );
* </pre>
*
* Animation works only if the component passed to {@link #paintIcon(Component, Graphics, int, int)}
* is a instance of {@link JComponent}.
* A client property is set on the component to store the animation state.
*
* @author Karl Tauber
*/
public interface AnimatedIcon
extends Icon
{
@Override
public default void paintIcon( Component c, Graphics g, int x, int y ) {
AnimationSupport.paintIcon( this, c, g, x, y );
}
/**
* Paints the icon for the given animated value.
*
* @param c the component that this icon belongs to
* @param g the graphics context
* @param x the x coordinate of the icon
* @param y the y coordinate of the icon
* @param animatedValue the animated value, which is either equal to what {@link #getValue(Component)}
* returned, or somewhere between the previous value and the latest value
* that {@link #getValue(Component)} returned
*/
void paintIconAnimated( Component c, Graphics g, int x, int y, float animatedValue );
/**
* Gets the value of the component.
* <p>
* This can be any value and depends on the component.
* If the value changes, then this class animates from the old value to the new one.
* <p>
* For a toggle button this could be {@code 0} for off and {@code 1} for on.
*/
float getValue( Component c );
/**
* Returns whether animation is enabled for this icon (default is {@code true}).
*/
default boolean isAnimationEnabled() {
return true;
}
/**
* Returns the duration of the animation in milliseconds (default is 150).
*/
default int getAnimationDuration() {
return 150;
}
/**
* Returns the resolution of the animation in milliseconds (default is 10).
* Resolution is the amount of time between timing events.
*/
default int getAnimationResolution() {
return 10;
}
/**
* Returns the interpolator for the animation.
* Default is {@link CubicBezierEasing#STANDARD_EASING}.
*/
default Interpolator getAnimationInterpolator() {
return CubicBezierEasing.STANDARD_EASING;
}
/**
* Returns the client property key used to store the animation support.
*/
default Object getClientPropertyKey() {
return getClass();
}
//---- class AnimationSupport ---------------------------------------------
/**
* Animation support class that stores the animation state and implements the animation.
*/
class AnimationSupport
{
private float startValue;
private float targetValue;
private float animatedValue;
private float fraction;
private Animator animator;
// last x,y coordinates of the icon needed to repaint while animating
private int x;
private int y;
public static void paintIcon( AnimatedIcon icon, Component c, Graphics g, int x, int y ) {
if( !isAnimationEnabled( icon, c ) ) {
// paint without animation if animation is disabled or
// component is not a JComponent and therefore does not support
// client properties, which are required to keep animation state
paintIconImpl( icon, c, g, x, y, null );
return;
}
JComponent jc = (JComponent) c;
Object key = icon.getClientPropertyKey();
AnimationSupport as = (AnimationSupport) jc.getClientProperty( key );
if( as == null ) {
// painted first time --> do not animate, but remember current component value
as = new AnimationSupport();
as.startValue = as.targetValue = as.animatedValue = icon.getValue( c );
as.x = x;
as.y = y;
jc.putClientProperty( key, as );
} else {
// get component value
float value = icon.getValue( c );
if( value != as.targetValue ) {
// value changed --> (re)start animation
if( as.animator == null ) {
// create animator
AnimationSupport as2 = as;
as.animator = new Animator( icon.getAnimationDuration(), fraction -> {
// check whether component was removed while animation is running
if( !c.isDisplayable() ) {
as2.animator.stop();
return;
}
// compute animated value
as2.animatedValue = as2.startValue + ((as2.targetValue - as2.startValue) * fraction);
as2.fraction = fraction;
// repaint icon
c.repaint( as2.x, as2.y, icon.getIconWidth(), icon.getIconHeight() );
}, () -> {
as2.startValue = as2.animatedValue = as2.targetValue;
as2.animator = null;
} );
}
if( as.animator.isRunning() ) {
// if animation is still running, restart it from the current
// animated value to the new target value with reduced duration
as.animator.cancel();
int duration2 = (int) (icon.getAnimationDuration() * as.fraction);
if( duration2 > 0 )
as.animator.setDuration( duration2 );
as.startValue = as.animatedValue;
} else {
// new animation
as.animator.setDuration( icon.getAnimationDuration() );
as.animator.setResolution( icon.getAnimationResolution() );
as.animator.setInterpolator( icon.getAnimationInterpolator() );
as.animatedValue = as.startValue;
}
as.targetValue = value;
as.animator.start();
}
as.x = x;
as.y = y;
}
paintIconImpl( icon, c, g, x, y, as );
}
private static void paintIconImpl( AnimatedIcon icon, Component c, Graphics g, int x, int y, AnimationSupport as ) {
float value = (as != null) ? as.animatedValue : icon.getValue( c );
icon.paintIconAnimated( c, g, x, y, value );
}
private static boolean isAnimationEnabled( AnimatedIcon icon, Component c ) {
return Animator.useAnimation() && icon.isAnimationEnabled() && c instanceof JComponent;
}
public static void saveIconLocation( AnimatedIcon icon, Component c, int x, int y ) {
if( !isAnimationEnabled( icon, c ) )
return;
AnimationSupport as = (AnimationSupport) ((JComponent)c).getClientProperty( icon.getClientPropertyKey() );
if( as != null ) {
as.x = x;
as.y = y;
}
}
}
}

View File

@@ -28,11 +28,12 @@ public class ColorFunctions
public static Color applyFunctions( Color color, ColorFunction... functions ) {
float[] hsl = HSLColor.fromRGB( color );
float alpha = color.getAlpha() / 255f;
float[] hsla = { hsl[0], hsl[1], hsl[2], alpha * 100 };
for( ColorFunction function : functions )
function.apply( hsl );
function.apply( hsla );
return HSLColor.toRGB( hsl, alpha );
return HSLColor.toRGB( hsla[0], hsla[1], hsla[2], hsla[3] / 100 );
}
public static float clamp( float value ) {
@@ -43,16 +44,48 @@ public class ColorFunctions
: value);
}
/**
* Returns a color that is a mixture of two colors.
*
* @param color1 first color
* @param color2 second color
* @param weight the weight (in range 0-1) to mix the two colors.
* Larger weight uses more of first color, smaller weight more of second color.
* @return mixture of colors
*/
public static Color mix( Color color1, Color color2, float weight ) {
if( weight >= 1 )
return color1;
if( weight <= 0 )
return color2;
int r1 = color1.getRed();
int g1 = color1.getGreen();
int b1 = color1.getBlue();
int a1 = color1.getAlpha();
int r2 = color2.getRed();
int g2 = color2.getGreen();
int b2 = color2.getBlue();
int a2 = color2.getAlpha();
return new Color(
Math.round( r2 + ((r1 - r2) * weight) ),
Math.round( g2 + ((g1 - g2) * weight) ),
Math.round( b2 + ((b1 - b2) * weight) ),
Math.round( a2 + ((a1 - a2) * weight) ) );
}
//---- interface ColorFunction --------------------------------------------
public interface ColorFunction {
void apply( float[] hsl );
void apply( float[] hsla );
}
//---- class HSLIncreaseDecrease ------------------------------------------
/**
* Increase or decrease hue, saturation or luminance of a color in the HSL color space
* Increase or decrease hue, saturation, luminance or alpha of a color in the HSL color space
* by an absolute or relative amount.
*/
public static class HSLIncreaseDecrease
@@ -75,18 +108,45 @@ public class ColorFunctions
}
@Override
public void apply( float[] hsl ) {
public void apply( float[] hsla ) {
float amount2 = increase ? amount : -amount;
amount2 = autoInverse && shouldInverse( hsl ) ? -amount2 : amount2;
hsl[hslIndex] = clamp( relative
? (hsl[hslIndex] * ((100 + amount2) / 100))
: (hsl[hslIndex] + amount2) );
if( hslIndex == 0 ) {
// hue is range 0-360
hsla[0] = (hsla[0] + amount2) % 360;
return;
}
amount2 = autoInverse && shouldInverse( hsla ) ? -amount2 : amount2;
hsla[hslIndex] = clamp( relative
? (hsla[hslIndex] * ((100 + amount2) / 100))
: (hsla[hslIndex] + amount2) );
}
protected boolean shouldInverse( float[] hsl ) {
protected boolean shouldInverse( float[] hsla ) {
return increase
? hsl[hslIndex] >= 50
: hsl[hslIndex] < 50;
? hsla[hslIndex] >= 50
: hsla[hslIndex] < 50;
}
}
//---- class HSLIncreaseDecrease ------------------------------------------
/**
* Set the alpha of a color.
*/
public static class Fade
implements ColorFunction
{
public final float amount;
public Fade( float amount ) {
this.amount = amount;
}
@Override
public void apply( float[] hsla ) {
hsla[3] = clamp( amount );
}
}
}

View File

@@ -24,6 +24,13 @@ package com.formdev.flatlaf.util;
public class CubicBezierEasing
implements Animator.Interpolator
{
/**
* Standard easing as specified in Material design (0.4, 0, 0.2, 1).
*
* @see <a href="https://material.io/design/motion/speed.html#easing">https://material.io/design/motion/speed.html#easing</a>
*/
public static final CubicBezierEasing STANDARD_EASING = new CubicBezierEasing( 0.4f, 0f, 0.2f, 1f );
// common cubic-bezier easing functions (same as in CSS)
// https://developer.mozilla.org/en-US/docs/Web/CSS/easing-function
public static final CubicBezierEasing EASE = new CubicBezierEasing( 0.25f, 0.1f, 0.25f, 1f );

View File

@@ -113,7 +113,7 @@ public class UIScale
}
public static double getSystemScaleFactor( Graphics2D g ) {
return isSystemScalingEnabled() ? g.getDeviceConfiguration().getDefaultTransform().getScaleX() : 1;
return isSystemScalingEnabled() ? getSystemScaleFactor( g.getDeviceConfiguration() ) : 1;
}
public static double getSystemScaleFactor( GraphicsConfiguration gc ) {

View File

@@ -237,11 +237,15 @@ Separator.foreground=#515151
#---- Slider ----
Slider.trackValueColor=#4A88C7
Slider.trackColor=#646464
Slider.thumbColor=#A6A6A6
Slider.thumbColor=$Slider.trackValueColor
Slider.tickColor=#888
Slider.hoverColor=darken($Slider.thumbColor,15%,derived)
Slider.disabledForeground=#4c5052
Slider.focusedColor=fade($Component.focusColor,70%,derived)
Slider.hoverThumbColor=darken($Slider.thumbColor,10%,derived)
Slider.pressedThumbColor=darken($Slider.thumbColor,15%,derived)
Slider.disabledTrackColor=#4c5052
Slider.disabledThumbColor=$Slider.disabledTrackColor
#---- SplitPane ----
@@ -271,7 +275,7 @@ TabbedPane.closePressedForeground=$TabbedPane.closeHoverForeground
#---- Table ----
Table.gridColor=lighten($Table.background,3%)
Table.gridColor=lighten($Table.background,5%)
#---- TableHeader ----

View File

@@ -506,8 +506,9 @@ Separator.stripeIndent=1
#---- Slider ----
Slider.focusInsets=0,0,0,0
Slider.trackWidth=3
Slider.thumbWidth=11
Slider.trackWidth=2
Slider.thumbSize=12,12
Slider.focusWidth=4
#---- Spinner ----
@@ -681,7 +682,7 @@ TitlePane.foreground=@foreground
TitlePane.inactiveForeground=@disabledText
TitlePane.closeHoverBackground=#e81123
TitlePane.closePressedBackground=rgba($TitlePane.closeHoverBackground,60%)
TitlePane.closePressedBackground=fade($TitlePane.closeHoverBackground,60%)
TitlePane.closeHoverForeground=#fff
TitlePane.closePressedForeground=#fff

View File

@@ -249,11 +249,15 @@ Separator.foreground=#d1d1d1
#---- Slider ----
Slider.trackValueColor=#1E82E6
Slider.trackColor=#c4c4c4
Slider.thumbColor=#6e6e6e
Slider.thumbColor=$Slider.trackValueColor
Slider.tickColor=#888
Slider.hoverColor=lighten($Slider.thumbColor,15%,derived)
Slider.disabledForeground=#c0c0c0
Slider.focusedColor=fade($Component.focusColor,50%,derived)
Slider.hoverThumbColor=lighten($Slider.thumbColor,10%,derived)
Slider.pressedThumbColor=lighten($Slider.thumbColor,15%,derived)
Slider.disabledTrackColor=#c0c0c0
Slider.disabledThumbColor=$Slider.disabledTrackColor
#---- SplitPane ----
@@ -283,7 +287,7 @@ TabbedPane.closePressedForeground=$TabbedPane.closeHoverForeground
#---- Table ----
Table.gridColor=darken($Table.background,3%)
Table.gridColor=darken($Table.background,5%)
#---- TableHeader ----

View File

@@ -35,6 +35,11 @@ Button.default.hoverBorderColor=null
HelpButton.hoverBorderColor=null
#---- Slider ----
Slider.focusedColor=fade($Component.focusColor,40%,derived)
#---- ToggleButton ----
ToggleButton.startBackground=$ToggleButton.background
@@ -60,6 +65,8 @@ ToggleButton.endBackground=$ToggleButton.background
[Cobalt_2]CheckBox.icon.background=#002946
[Cobalt_2]CheckBox.icon.checkmarkColor=#002946
[Dark_purple]Slider.focusedColor=fade($Component.focusColor,70%,derived)
[Dracula]ProgressBar.selectionBackground=#fff
[Dracula]ProgressBar.selectionForeground=#fff
@@ -81,6 +88,15 @@ ToggleButton.endBackground=$ToggleButton.background
[High_contrast]ToggleButton.disabledSelectedBackground=#444
[High_contrast]ToggleButton.toolbar.selectedBackground=#fff
[One_Dark]Slider.focusedColor=fade(#568af2,40%)
[Solarized_Dark]Slider.focusedColor=fade($Component.focusColor,80%,derived)
[vuesion-theme]Slider.trackValueColor=#ececee
[vuesion-theme]Slider.trackColor=#303a45
[vuesion-theme]Slider.thumbColor=#ececee
[vuesion-theme]Slider.focusedColor=fade(#ececee,20%)
# Material Theme UI Lite

View File

@@ -2,3 +2,12 @@ FlatLaf Demo
============
This sub-project contains the FlatLaf Demo source code.
Download
--------
[![Download Demo](https://download.formdev.com/flatlaf/images/download-demo.svg)](https://download.formdev.com/flatlaf/flatlaf-demo-latest.jar)
Run demo with `java -jar flatlaf-demo-<version>.jar` (or double-click it).
Requires Java 8 or newer.

View File

@@ -136,6 +136,16 @@ class ControlBar
registerSwitchToLookAndFeel( KeyEvent.VK_F12, MetalLookAndFeel.class.getName() );
registerSwitchToLookAndFeel( KeyEvent.VK_F11, NimbusLookAndFeel.class.getName() );
// register Alt+UP and Alt+DOWN to switch to previous/next theme
((JComponent)frame.getContentPane()).registerKeyboardAction(
e -> frame.themesPanel.selectPreviousTheme(),
KeyStroke.getKeyStroke( KeyEvent.VK_UP, KeyEvent.ALT_DOWN_MASK ),
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
((JComponent)frame.getContentPane()).registerKeyboardAction(
e -> frame.themesPanel.selectNextTheme(),
KeyStroke.getKeyStroke( KeyEvent.VK_DOWN, KeyEvent.ALT_DOWN_MASK ),
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
// register ESC key to close frame
((JComponent)frame.getContentPane()).registerKeyboardAction(
e -> {

View File

@@ -32,7 +32,7 @@ import com.formdev.flatlaf.demo.intellijthemes.*;
import com.formdev.flatlaf.extras.FlatAnimatedLafChange;
import com.formdev.flatlaf.extras.FlatSVGIcon;
import com.formdev.flatlaf.extras.FlatUIDefaultsInspector;
import com.formdev.flatlaf.extras.SVGUtils;
import com.formdev.flatlaf.extras.FlatSVGUtils;
import com.formdev.flatlaf.ui.JBRCustomDecorations;
import net.miginfocom.layout.ConstraintParser;
import net.miginfocom.layout.LC;
@@ -59,7 +59,7 @@ class DemoFrame
updateFontMenuItems();
controlBar.initialize( this, tabbedPane );
setIconImages( SVGUtils.createWindowIconImages( "/com/formdev/flatlaf/demo/FlatLaf.svg" ) );
setIconImages( FlatSVGUtils.createWindowIconImages( "/com/formdev/flatlaf/demo/FlatLaf.svg" ) );
if( tabIndex >= 0 && tabIndex < tabbedPane.getTabCount() && tabIndex != tabbedPane.getSelectedIndex() )
tabbedPane.setSelectedIndex( tabIndex );
@@ -749,6 +749,6 @@ class DemoFrame
private JCheckBoxMenuItem animatedLafChangeMenuItem;
private JTabbedPane tabbedPane;
private ControlBar controlBar;
private IJThemesPanel themesPanel;
IJThemesPanel themesPanel;
// JFormDesigner - End of variables declaration //GEN-END:variables
}

View File

@@ -117,6 +117,7 @@ new FormModel {
name: "themesPanel"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
"JavaCodeGenerator.variableModifiers": 0
}
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "East"

View File

@@ -18,6 +18,7 @@ package com.formdev.flatlaf.demo.extras;
import javax.swing.*;
import com.formdev.flatlaf.extras.*;
import com.formdev.flatlaf.extras.components.FlatTriStateCheckBox;
import net.miginfocom.swing.*;
/**
@@ -63,7 +64,7 @@ public class ExtrasPanel
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
label4 = new JLabel();
label1 = new JLabel();
triStateCheckBox1 = new TriStateCheckBox();
triStateCheckBox1 = new FlatTriStateCheckBox();
triStateLabel1 = new JLabel();
label2 = new JLabel();
svgIconsPanel = new JPanel();
@@ -124,7 +125,7 @@ public class ExtrasPanel
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
private JLabel label4;
private JLabel label1;
private TriStateCheckBox triStateCheckBox1;
private FlatTriStateCheckBox triStateCheckBox1;
private JLabel triStateLabel1;
private JLabel label2;
private JPanel svgIconsPanel;

View File

@@ -21,7 +21,7 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.TriStateCheckBox" ) {
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "triStateCheckBox1"
"text": "Three States"
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "triStateCheckBox1Changed", false ) )

View File

@@ -49,7 +49,9 @@ public class IJThemesClassGenerator
}
Path out = new File( toPath, "FlatAllIJThemes.java" ).toPath();
String allThemes = CLASS_HEADER + ALL_THEMES_TEMPLATE.replace( "${allInfos}", allInfos );
String allThemes = (CLASS_HEADER + ALL_THEMES_TEMPLATE)
.replace( "${subPackage}", "" )
.replace( "${allInfos}", allInfos );
writeFile( out, allThemes );
System.out.println( markdownTable );
@@ -88,7 +90,7 @@ public class IJThemesClassGenerator
String themeClass = "Flat" + buf + "IJTheme";
String themeFile = resourceName;
String classBody = CLASS_HEADER + CLASS_TEMPLATE
String classBody = (CLASS_HEADER + CLASS_TEMPLATE)
.replace( "${subPackage}", subPackage )
.replace( "${themeClass}", themeClass )
.replace( "${themeFile}", themeFile )
@@ -106,7 +108,8 @@ public class IJThemesClassGenerator
allInfos.append( THEME_TEMPLATE
.replace( "${subPackage}", subPackage )
.replace( "${themeClass}", themeClass )
.replace( "${themeName}", themeName ) );
.replace( "${themeName}", themeName )
.replace( "${dark}", Boolean.toString( ti.dark ) ) );
markdownTable.append( String.format( "[%s](%s) | `com.formdev.flatlaf.intellijthemes%s.%s`\n",
themeName, ti.sourceCodeUrl, subPackage, themeClass ) );
@@ -138,6 +141,8 @@ public class IJThemesClassGenerator
" * limitations under the License.\n" +
" */\n" +
"\n" +
"package com.formdev.flatlaf.intellijthemes${subPackage};\n" +
"\n" +
"//\n" +
"// DO NOT MODIFY\n" +
"// Generated with com.formdev.flatlaf.demo.intellijthemes.IJThemesClassGenerator\n" +
@@ -145,8 +150,6 @@ public class IJThemesClassGenerator
"\n";
private static final String CLASS_TEMPLATE =
"package com.formdev.flatlaf.intellijthemes${subPackage};\n" +
"\n" +
"import com.formdev.flatlaf.IntelliJTheme;\n" +
"\n" +
"/**\n" +
@@ -155,7 +158,9 @@ public class IJThemesClassGenerator
"public class ${themeClass}\n" +
" extends IntelliJTheme.ThemeLaf\n" +
"{\n" +
" public static boolean install( ) {\n" +
" public static final String NAME = \"${themeName}\";\n" +
"\n" +
" public static boolean install() {\n" +
" try {\n" +
" return install( new ${themeClass}() );\n" +
" } catch( RuntimeException ex ) {\n" +
@@ -163,19 +168,21 @@ public class IJThemesClassGenerator
" }\n" +
" }\n" +
"\n" +
" public static void installLafInfo() {\n" +
" installLafInfo( NAME, ${themeClass}.class );\n" +
" }\n" +
"\n" +
" public ${themeClass}() {\n" +
" super( Utils.loadTheme( \"${themeFile}\" ) );\n" +
" }\n" +
"\n" +
" @Override\n" +
" public String getName() {\n" +
" return \"${themeName}\";\n" +
" return NAME;\n" +
" }\n" +
"}\n";
private static final String ALL_THEMES_TEMPLATE =
"package com.formdev.flatlaf.intellijthemes;\n" +
"\n" +
"import javax.swing.UIManager.LookAndFeelInfo;\n" +
"\n" +
"/**\n" +
@@ -183,11 +190,28 @@ public class IJThemesClassGenerator
" */\n" +
"public class FlatAllIJThemes\n" +
"{\n" +
" public static final LookAndFeelInfo[] INFOS = {\n" +
" public static final FlatIJLookAndFeelInfo[] INFOS = {\n" +
"${allInfos}\n" +
" };\n" +
"\n" +
" //---- class FlatIJLookAndFeelInfo ----------------------------------------\n" +
"\n" +
" public static class FlatIJLookAndFeelInfo\n" +
" extends LookAndFeelInfo\n" +
" {\n" +
" private final boolean dark;\n" +
"\n" +
" public FlatIJLookAndFeelInfo( String name, String className, boolean dark ) {\n" +
" super( name, className );\n" +
" this.dark = dark;\n" +
" }\n" +
"\n" +
" public boolean isDark() {\n" +
" return dark;\n" +
" }\n" +
" }\n" +
"}\n";
private static final String THEME_TEMPLATE =
" new LookAndFeelInfo( \"${themeName}\", \"com.formdev.flatlaf.intellijthemes${subPackage}.${themeClass}\" ),";
" new FlatIJLookAndFeelInfo( \"${themeName}\", \"com.formdev.flatlaf.intellijthemes${subPackage}.${themeClass}\", ${dark} ),";
}

View File

@@ -220,6 +220,17 @@ public class IJThemesPanel
}
}
public void selectPreviousTheme() {
int sel = themesList.getSelectedIndex();
if( sel > 0 )
themesList.setSelectedIndex( sel - 1 );
}
public void selectNextTheme() {
int sel = themesList.getSelectedIndex();
themesList.setSelectedIndex( sel + 1 );
}
private void themesListValueChanged( ListSelectionEvent e ) {
IJThemeInfo themeInfo = themesList.getSelectedValue();
boolean bundledTheme = (themeInfo != null && themeInfo.resourceName != null);

View File

@@ -4,14 +4,14 @@
"license": "MIT",
"licenseFile": "arc-themes.LICENSE.txt",
"sourceCodeUrl": "https://gitlab.com/zlamalp/arc-theme-idea",
"sourceCodePath": "blob/master/resources/arc-theme.theme.json"
"sourceCodePath": "blob/master/arc-theme-idea-light/resources/arc-theme.theme.json"
},
"arc-theme-orange.theme.json": {
"name": "Arc - Orange",
"license": "MIT",
"licenseFile": "arc-themes.LICENSE.txt",
"sourceCodeUrl": "https://gitlab.com/zlamalp/arc-theme-idea",
"sourceCodePath": "blob/master/resources/arc-theme-orange.theme.json"
"sourceCodePath": "blob/master/arc-theme-idea-light/resources/arc-theme-orange.theme.json"
},
"arc_theme_dark.theme.json": {
"name": "Arc Dark",
@@ -19,7 +19,7 @@
"license": "MIT",
"licenseFile": "arc-themes.LICENSE.txt",
"sourceCodeUrl": "https://gitlab.com/zlamalp/arc-theme-idea",
"sourceCodePath": "blob/master/resources/arc_theme_dark.theme.json"
"sourceCodePath": "blob/master/arc-theme-idea-dark/resources/arc_theme_dark.theme.json"
},
"arc_theme_dark_orange.theme.json": {
"name": "Arc Dark - Orange",
@@ -27,7 +27,7 @@
"license": "MIT",
"licenseFile": "arc-themes.LICENSE.txt",
"sourceCodeUrl": "https://gitlab.com/zlamalp/arc-theme-idea",
"sourceCodePath": "blob/master/resources/arc_theme_dark_orange.theme.json"
"sourceCodePath": "blob/master/arc-theme-idea-dark/resources/arc_theme_dark_orange.theme.json"
},
"Carbon.theme.json": {
"name": "Carbon",
@@ -74,7 +74,7 @@
"license": "MIT",
"licenseFile": "Dracula.LICENSE.txt",
"sourceCodeUrl": "https://github.com/dracula/jetbrains",
"sourceCodePath": "blob/master/src/main/resources/themes/Dracula.theme.json"
"sourceCodePath": "blob/master/src/main/resources/themes/dracula.theme.json"
},
"Gradianto_dark_fuchsia.theme.json": {
"name": "Gradianto Dark Fuchsia",
@@ -100,6 +100,14 @@
"sourceCodeUrl": "https://github.com/thvardhan/Gradianto",
"sourceCodePath": "blob/master/src/main/resources/Gradianto_midnight_blue.theme.json"
},
"Gradianto_Nature_Green.theme.json": {
"name": "Gradianto Nature Green",
"dark": true,
"license": "MIT",
"licenseFile": "Gradianto.LICENSE.txt",
"sourceCodeUrl": "https://github.com/thvardhan/Gradianto",
"sourceCodePath": "blob/master/src/main/resources/Gradianto_Nature_Green.theme.json"
},
"Gray.theme.json": {
"name": "Gray",
"license": "MIT",

View File

@@ -7,9 +7,12 @@ This sub-project provides some additional components and classes:
An icon that displays SVG using
[svgSalamander](https://github.com/JFormDesigner/svgSalamander).\
![FlatSVGIcon.png](../images/extras-FlatSVGIcon.png)
- [TriStateCheckBox](https://www.javadoc.io/doc/com.formdev/flatlaf-extras/latest/com/formdev/flatlaf/extras/TriStateCheckBox.html):
- [FlatTriStateCheckBox](https://www.javadoc.io/doc/com.formdev/flatlaf-extras/latest/com/formdev/flatlaf/extras/components/FlatTriStateCheckBox.html):
A tri-state check box.\
![TriStateCheckBox.png](../images/extras-TriStateCheckBox.png)
- Extension classes of standard Swing components that provide easy access to
FlatLaf specific client properties (see package
[com.formdev.flatlaf.extras.components](https://www.javadoc.io/doc/com.formdev/flatlaf-extras/latest/com/formdev/flatlaf/extras/components/package-summary.html)).
- [FlatAnimatedLafChange](https://www.javadoc.io/doc/com.formdev/flatlaf-extras/latest/com/formdev/flatlaf/extras/FlatAnimatedLafChange.html):
Animated Laf (theme) changing.
- [FlatInspector](#ui-inspector): A simple UI inspector that shows information
@@ -35,10 +38,8 @@ Otherwise download `flatlaf-extras-<version>.jar` here:
[![Download](https://api.bintray.com/packages/jformdesigner/flatlaf/flatlaf-extras/images/download.svg)](https://bintray.com/jformdesigner/flatlaf/flatlaf-extras/_latestVersion)
You also need `flatlaf-<version>.jar` and `svgSalamander-<version>.jar`, which
you can download here:
If SVG classes are used, `svgSalamander-<version>.jar` is also required:
[![Download](https://api.bintray.com/packages/jformdesigner/flatlaf/flatlaf/images/download.svg)](https://bintray.com/jformdesigner/flatlaf/flatlaf/_latestVersion)
[![Download](https://api.bintray.com/packages/jformdesigner/svgSalamander/svgSalamander/images/download.svg)](https://bintray.com/jformdesigner/svgSalamander/svgSalamander/_latestVersion)

View File

@@ -22,7 +22,7 @@ plugins {
dependencies {
implementation( project( ":flatlaf-core" ) )
implementation( "com.formdev:svgSalamander:1.1.2.3" )
implementation( "com.formdev:svgSalamander:1.1.2.4" )
}
flatlafModuleInfo {
@@ -40,6 +40,7 @@ tasks {
this as StandardJavadocDocletOptions
use( true )
tags = listOf( "uiDefault", "clientProperty" )
addStringOption( "Xdoclint:all,-missing", "-Xdoclint:all,-missing" )
}
isFailOnError = false
}

View File

@@ -24,7 +24,6 @@ import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.KeyboardFocusManager;
import java.awt.LayoutManager;
@@ -348,8 +347,9 @@ public class FlatInspector
@Override
protected void paintBorder( Graphics g ) {
FlatUIUtils.setRenderingHints( (Graphics2D) g );
Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g );
super.paintBorder( g );
FlatUIUtils.resetRenderingHints( g, oldRenderingHints );
}
};
c.setBackground( new Color( 255, 0, 0, 32 ) );

View File

@@ -34,7 +34,7 @@ import com.kitfox.svg.SVGException;
*
* @author Karl Tauber
*/
public class SVGUtils
public class FlatSVGUtils
{
/**
* Creates from the given SVG a list of icon images with different sizes that
@@ -131,7 +131,7 @@ public class SVGUtils
*/
private static SVGDiagram loadSVG( String svgName ) {
try {
URL url = SVGUtils.class.getResource( svgName );
URL url = FlatSVGUtils.class.getResource( svgName );
return SVGCache.getSVGUniverse().getDiagram( url.toURI() );
} catch( URISyntaxException ex ) {
throw new RuntimeException( ex );

View File

@@ -1,141 +0,0 @@
/*
* Copyright 2019 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.ItemEvent;
import javax.swing.JCheckBox;
import javax.swing.LookAndFeel;
import javax.swing.UIManager;
import com.formdev.flatlaf.FlatLaf;
/**
* A tri-state check box.
* <p>
* To display the third state, this component requires an LaF that supports painting
* the indeterminate state if client property {@code "JButton.selectedState"} has the
* value {@code "indeterminate"}.
* <p>
* FlatLaf and Mac Aqua LaF support the third state.
* For other LaFs a magenta rectangle is painted around the component for the third state.
*
* @author Karl Tauber
*/
public class TriStateCheckBox
extends JCheckBox
{
public enum State { INDETERMINATE, SELECTED, UNSELECTED }
private State state;
private boolean thirdStateEnabled = true;
public TriStateCheckBox() {
this( null );
}
public TriStateCheckBox( String text ) {
this( text, State.INDETERMINATE );
}
public TriStateCheckBox( String text, State initialState ) {
super( text );
setModel( new ToggleButtonModel() {
@Override
public boolean isSelected() {
return state != State.UNSELECTED;
}
@Override
public void setSelected( boolean b ) {
switch( state ) {
case INDETERMINATE: setState( State.SELECTED ); break;
case SELECTED: setState( State.UNSELECTED ); break;
case UNSELECTED: setState( thirdStateEnabled ? State.INDETERMINATE : State.SELECTED ); break;
}
fireStateChanged();
fireItemStateChanged( new ItemEvent( this, ItemEvent.ITEM_STATE_CHANGED, this,
isSelected() ? ItemEvent.SELECTED : ItemEvent.DESELECTED ) );
}
} );
setState( initialState );
}
public State getState() {
return state;
}
public void setState( State state ) {
if( this.state == state )
return;
State oldState = this.state;
this.state = state;
putClientProperty( "JButton.selectedState", state == State.INDETERMINATE ? "indeterminate" : null );
firePropertyChange( "state", oldState, state );
repaint();
}
public Boolean getValue() {
switch( state ) {
default:
case INDETERMINATE: return null;
case SELECTED: return true;
case UNSELECTED: return false;
}
}
public void setValue( Boolean value ) {
setState( value == null ? State.INDETERMINATE : (value ? State.SELECTED : State.UNSELECTED) );
}
public boolean isThirdStateEnabled() {
return thirdStateEnabled;
}
public void setThirdStateEnabled( boolean thirdStateEnabled ) {
this.thirdStateEnabled = thirdStateEnabled;
if( state == State.INDETERMINATE )
setState( State.UNSELECTED );
}
@Override
public void setSelected( boolean b ) {
setState( b ? State.SELECTED : State.UNSELECTED );
}
@Override
protected void paintComponent( Graphics g ) {
super.paintComponent( g );
if( state == State.INDETERMINATE && !isThirdStateSupported() ) {
g.setColor( Color.magenta );
g.drawRect( 0, 0, getWidth() - 1, getHeight() - 1 );
}
}
private boolean isThirdStateSupported() {
LookAndFeel laf = UIManager.getLookAndFeel();
return laf instanceof FlatLaf || laf.getClass().getName().equals( "com.apple.laf.AquaLookAndFeel" );
}
}

View File

@@ -0,0 +1,120 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import java.awt.Color;
import javax.swing.JButton;
/**
* Subclass of {@link JButton} that provides easy access to FlatLaf specific client properties.
*
* @author Karl Tauber
*/
public class FlatButton
extends JButton
implements FlatComponentExtension
{
// NOTE: enum names must be equal to allowed strings
public enum ButtonType { none, square, roundRect, tab, help, toolBarButton };
/**
* Returns type of a button.
*/
public ButtonType getButtonType() {
return getClientPropertyEnumString( BUTTON_TYPE, ButtonType.class, null, ButtonType.none );
}
/**
* Specifies type of a button.
*/
public void setButtonType( ButtonType buttonType ) {
if( buttonType == ButtonType.none )
buttonType = null;
putClientPropertyEnumString( BUTTON_TYPE, buttonType );
}
/**
* Returns whether the button preferred size will be made square (quadratically).
*/
public boolean isSquareSize() {
return getClientPropertyBoolean( SQUARE_SIZE, false );
}
/**
* Specifies whether the button preferred size will be made square (quadratically).
*/
public void setSquareSize( boolean squareSize ) {
putClientPropertyBoolean( SQUARE_SIZE, squareSize, false );
}
/**
* Returns minimum width of a component.
*/
public int getMinimumWidth() {
return getClientPropertyInt( MINIMUM_WIDTH, "Button.minimumWidth" );
}
/**
* Specifies minimum width of a component.
*/
public void setMinimumWidth( int minimumWidth ) {
putClientProperty( MINIMUM_WIDTH, (minimumWidth >= 0) ? minimumWidth : null );
}
/**
* Returns minimum height of a component.
*/
public int getMinimumHeight() {
return getClientPropertyInt( MINIMUM_HEIGHT, 0 );
}
/**
* Specifies minimum height of a component.
*/
public void setMinimumHeight( int minimumHeight ) {
putClientProperty( MINIMUM_HEIGHT, (minimumHeight >= 0) ? minimumHeight : null );
}
/**
* Returns the outline color of the component border.
*/
public Object getOutline() {
return getClientProperty( OUTLINE );
}
/**
* Specifies the outline color of the component border.
* <p>
* Allowed Values are:
* <ul>
* <li>{@code null}
* <li>string {@code "error"}
* <li>string {@code "warning"}
* <li>any color (type {@link Color})
* <li>an array of two colors (type {@link Color}[2]) where the first color
* is for focused state and the second for unfocused state
* </ul>
*/
public void setOutline( Object outline ) {
putClientProperty( OUTLINE, outline );
}
}

View File

@@ -0,0 +1,100 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import java.awt.Color;
import javax.swing.JComboBox;
/**
* Subclass of {@link JComboBox} that provides easy access to FlatLaf specific client properties.
*
* @author Karl Tauber
*/
public class FlatComboBox<E>
extends JComboBox<E>
implements FlatComponentExtension
{
/**
* Returns the placeholder text that is only painted if the editable combo box is empty.
*/
public String getPlaceholderText() {
return (String) getClientProperty( PLACEHOLDER_TEXT );
}
/**
* Sets the placeholder text that is only painted if the editable combo box is empty.
*/
public void setPlaceholderText( String placeholderText ) {
putClientProperty( PLACEHOLDER_TEXT, placeholderText );
}
/**
* Returns minimum width of a component.
*/
public int getMinimumWidth() {
return getClientPropertyInt( MINIMUM_WIDTH, "ComboBox.minimumWidth" );
}
/**
* Specifies minimum width of a component.
*/
public void setMinimumWidth( int minimumWidth ) {
putClientProperty( MINIMUM_WIDTH, (minimumWidth >= 0) ? minimumWidth : null );
}
/**
* Returns whether the component is painted with round edges.
*/
public boolean isRoundRect() {
return getClientPropertyBoolean( COMPONENT_ROUND_RECT, false );
}
/**
* Specifies whether the component is painted with round edges.
*/
public void setRoundRect( boolean roundRect ) {
putClientPropertyBoolean( COMPONENT_ROUND_RECT, roundRect, false );
}
/**
* Returns the outline color of the component border.
*/
public Object getOutline() {
return getClientProperty( OUTLINE );
}
/**
* Specifies the outline color of the component border.
* <p>
* Allowed Values are:
* <ul>
* <li>{@code null}
* <li>string {@code "error"}
* <li>string {@code "warning"}
* <li>any color (type {@link Color})
* <li>an array of two colors (type {@link Color}[2]) where the first color
* is for focused state and the second for unfocused state
* </ul>
*/
public void setOutline( Object outline ) {
putClientProperty( OUTLINE, outline );
}
}

View File

@@ -0,0 +1,99 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import java.awt.Color;
import java.awt.Insets;
import javax.swing.JComponent;
import javax.swing.UIManager;
/**
* Base interface for all FlatLaf component extensions.
* Extensions use client properties to store property values in components.
*
* @author Karl Tauber
*/
public interface FlatComponentExtension
{
/**
* Overrides {@link JComponent#getClientProperty(Object)}.
*/
Object getClientProperty( Object key );
/**
* Overrides {@link JComponent#putClientProperty(Object, Object)}.
*/
void putClientProperty( Object key, Object value );
default boolean getClientPropertyBoolean( Object key, String defaultValueKey ) {
Object value = getClientProperty( key );
return (value instanceof Boolean) ? (boolean) value : UIManager.getBoolean( defaultValueKey );
}
default boolean getClientPropertyBoolean( Object key, boolean defaultValue ) {
Object value = getClientProperty( key );
return (value instanceof Boolean) ? (boolean) value : defaultValue;
}
default void putClientPropertyBoolean( Object key, boolean value, boolean defaultValue ) {
putClientProperty( key, (value != defaultValue) ? value : null );
}
default int getClientPropertyInt( Object key, String defaultValueKey ) {
Object value = getClientProperty( key );
return (value instanceof Integer) ? (int) value : UIManager.getInt( defaultValueKey );
}
default int getClientPropertyInt( Object key, int defaultValue ) {
Object value = getClientProperty( key );
return (value instanceof Integer) ? (int) value : defaultValue;
}
default Color getClientPropertyColor( Object key, String defaultValueKey ) {
Object value = getClientProperty( key );
return (value instanceof Color) ? (Color) value : UIManager.getColor( defaultValueKey );
}
default Insets getClientPropertyInsets( Object key, String defaultValueKey ) {
Object value = getClientProperty( key );
return (value instanceof Insets) ? (Insets) value : UIManager.getInsets( defaultValueKey );
}
default <T extends Enum<T>> T getClientPropertyEnumString( Object key, Class<T> enumType,
String defaultValueKey, T defaultValue )
{
Object value = getClientProperty( key );
if( !(value instanceof String) && defaultValueKey != null )
value = UIManager.getString( defaultValueKey );
if( value instanceof String ) {
try {
return Enum.valueOf( enumType, (String) value );
} catch( IllegalArgumentException ex ) {
ex.printStackTrace();
}
}
return defaultValue;
}
default <T extends Enum<T>> void putClientPropertyEnumString( Object key, Enum<T> value ) {
putClientProperty( key, (value != null) ? value.toString() : null );
}
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import javax.swing.JEditorPane;
/**
* Subclass of {@link JEditorPane} that provides easy access to FlatLaf specific client properties.
*
* @author Karl Tauber
*/
public class FlatEditorPane
extends JEditorPane
implements FlatComponentExtension
{
/**
* Returns minimum width of a component.
*/
public int getMinimumWidth() {
return getClientPropertyInt( MINIMUM_WIDTH, "Component.minimumWidth" );
}
/**
* Specifies minimum width of a component.
*/
public void setMinimumWidth( int minimumWidth ) {
putClientProperty( MINIMUM_WIDTH, (minimumWidth >= 0) ? minimumWidth : null );
}
}

View File

@@ -0,0 +1,117 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import java.awt.Color;
import javax.swing.JFormattedTextField;
import com.formdev.flatlaf.extras.components.FlatTextField.SelectAllOnFocusPolicy;
/**
* Subclass of {@link JFormattedTextField} that provides easy access to FlatLaf specific client properties.
*
* @author Karl Tauber
*/
public class FlatFormattedTextField
extends JFormattedTextField
implements FlatComponentExtension
{
/**
* Returns the placeholder text that is only painted if the text field is empty.
*/
public String getPlaceholderText() {
return (String) getClientProperty( PLACEHOLDER_TEXT );
}
/**
* Sets the placeholder text that is only painted if the text field is empty.
*/
public void setPlaceholderText( String placeholderText ) {
putClientProperty( PLACEHOLDER_TEXT, placeholderText );
}
/**
* Returns whether all text is selected when the text component gains focus.
*/
public SelectAllOnFocusPolicy getSelectAllOnFocusPolicy() {
return getClientPropertyEnumString( SELECT_ALL_ON_FOCUS_POLICY, SelectAllOnFocusPolicy.class,
"TextComponent.selectAllOnFocusPolicy", SelectAllOnFocusPolicy.once );
}
/**
* Specifies whether all text is selected when the text component gains focus.
*/
public void setSelectAllOnFocusPolicy( SelectAllOnFocusPolicy selectAllOnFocusPolicy ) {
putClientPropertyEnumString( SELECT_ALL_ON_FOCUS_POLICY, selectAllOnFocusPolicy );
}
/**
* Returns minimum width of a component.
*/
public int getMinimumWidth() {
return getClientPropertyInt( MINIMUM_WIDTH, "Component.minimumWidth" );
}
/**
* Specifies minimum width of a component.
*/
public void setMinimumWidth( int minimumWidth ) {
putClientProperty( MINIMUM_WIDTH, (minimumWidth >= 0) ? minimumWidth : null );
}
/**
* Returns whether the component is painted with round edges.
*/
public boolean isRoundRect() {
return getClientPropertyBoolean( COMPONENT_ROUND_RECT, false );
}
/**
* Specifies whether the component is painted with round edges.
*/
public void setRoundRect( boolean roundRect ) {
putClientPropertyBoolean( COMPONENT_ROUND_RECT, roundRect, false );
}
/**
* Returns the outline color of the component border.
*/
public Object getOutline() {
return getClientProperty( OUTLINE );
}
/**
* Specifies the outline color of the component border.
* <p>
* Allowed Values are:
* <ul>
* <li>{@code null}
* <li>string {@code "error"}
* <li>string {@code "warning"}
* <li>any color (type {@link Color})
* <li>an array of two colors (type {@link Color}[2]) where the first color
* is for focused state and the second for unfocused state
* </ul>
*/
public void setOutline( Object outline ) {
putClientProperty( OUTLINE, outline );
}
}

View File

@@ -0,0 +1,117 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import java.awt.Color;
import javax.swing.JPasswordField;
import com.formdev.flatlaf.extras.components.FlatTextField.SelectAllOnFocusPolicy;
/**
* Subclass of {@link JPasswordField} that provides easy access to FlatLaf specific client properties.
*
* @author Karl Tauber
*/
public class FlatPasswordField
extends JPasswordField
implements FlatComponentExtension
{
/**
* Returns the placeholder text that is only painted if the text field is empty.
*/
public String getPlaceholderText() {
return (String) getClientProperty( PLACEHOLDER_TEXT );
}
/**
* Sets the placeholder text that is only painted if the text field is empty.
*/
public void setPlaceholderText( String placeholderText ) {
putClientProperty( PLACEHOLDER_TEXT, placeholderText );
}
/**
* Returns whether all text is selected when the text component gains focus.
*/
public SelectAllOnFocusPolicy getSelectAllOnFocusPolicy() {
return getClientPropertyEnumString( SELECT_ALL_ON_FOCUS_POLICY, SelectAllOnFocusPolicy.class,
"TextComponent.selectAllOnFocusPolicy", SelectAllOnFocusPolicy.once );
}
/**
* Specifies whether all text is selected when the text component gains focus.
*/
public void setSelectAllOnFocusPolicy( SelectAllOnFocusPolicy selectAllOnFocusPolicy ) {
putClientPropertyEnumString( SELECT_ALL_ON_FOCUS_POLICY, selectAllOnFocusPolicy );
}
/**
* Returns minimum width of a component.
*/
public int getMinimumWidth() {
return getClientPropertyInt( MINIMUM_WIDTH, "Component.minimumWidth" );
}
/**
* Specifies minimum width of a component.
*/
public void setMinimumWidth( int minimumWidth ) {
putClientProperty( MINIMUM_WIDTH, (minimumWidth >= 0) ? minimumWidth : null );
}
/**
* Returns whether the component is painted with round edges.
*/
public boolean isRoundRect() {
return getClientPropertyBoolean( COMPONENT_ROUND_RECT, false );
}
/**
* Specifies whether the component is painted with round edges.
*/
public void setRoundRect( boolean roundRect ) {
putClientPropertyBoolean( COMPONENT_ROUND_RECT, roundRect, false );
}
/**
* Returns the outline color of the component border.
*/
public Object getOutline() {
return getClientProperty( OUTLINE );
}
/**
* Specifies the outline color of the component border.
* <p>
* Allowed Values are:
* <ul>
* <li>{@code null}
* <li>string {@code "error"}
* <li>string {@code "warning"}
* <li>any color (type {@link Color})
* <li>an array of two colors (type {@link Color}[2]) where the first color
* is for focused state and the second for unfocused state
* </ul>
*/
public void setOutline( Object outline ) {
putClientProperty( OUTLINE, outline );
}
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import javax.swing.JProgressBar;
/**
* Subclass of {@link JProgressBar} that provides easy access to FlatLaf specific client properties.
*
* @author Karl Tauber
*/
public class FlatProgressBar
extends JProgressBar
implements FlatComponentExtension
{
/**
* Returns whether the progress bar has always the larger height even if no string is painted.
*/
public boolean isLargeHeight() {
return getClientPropertyBoolean( PROGRESS_BAR_LARGE_HEIGHT, false );
}
/**
* Specifies whether the progress bar has always the larger height even if no string is painted.
*/
public void setLargeHeight( boolean largeHeight ) {
putClientPropertyBoolean( PROGRESS_BAR_LARGE_HEIGHT, largeHeight, false );
}
/**
* Returns whether the progress bar is paint with square edges.
*/
public boolean isSquare() {
return getClientPropertyBoolean( PROGRESS_BAR_SQUARE, false );
}
/**
* Specifies whether the progress bar is paint with square edges.
*/
public void setSquare( boolean square ) {
putClientPropertyBoolean( PROGRESS_BAR_SQUARE, square, false );
}
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import javax.swing.JScrollBar;
/**
* Subclass of {@link JScrollBar} that provides easy access to FlatLaf specific client properties.
*
* @author Karl Tauber
*/
public class FlatScrollBar
extends JScrollBar
implements FlatComponentExtension
{
/**
* Returns whether the decrease/increase arrow buttons of a scrollbar are shown.
*/
public boolean isShowButtons() {
return getClientPropertyBoolean( SCROLL_BAR_SHOW_BUTTONS, "ScrollBar.showButtons" );
}
/**
* Specifies whether the decrease/increase arrow buttons of a scrollbar are shown.
*/
public void setShowButtons( boolean showButtons ) {
putClientProperty( SCROLL_BAR_SHOW_BUTTONS, showButtons );
}
}

View File

@@ -0,0 +1,85 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import java.awt.Color;
import javax.swing.JScrollPane;
/**
* Subclass of {@link JScrollPane} that provides easy access to FlatLaf specific client properties.
*
* @author Karl Tauber
*/
public class FlatScrollPane
extends JScrollPane
implements FlatComponentExtension
{
/**
* Returns whether the decrease/increase arrow buttons of a scrollbar are shown.
*/
public boolean isShowButtons() {
return getClientPropertyBoolean( SCROLL_BAR_SHOW_BUTTONS, "ScrollBar.showButtons" );
}
/**
* Specifies whether the decrease/increase arrow buttons of a scrollbar are shown.
*/
public void setShowButtons( boolean showButtons ) {
putClientProperty( SCROLL_BAR_SHOW_BUTTONS, showButtons );
}
/**
* Returns whether the scroll pane uses smooth scrolling.
*/
public boolean isSmoothScrolling() {
return getClientPropertyBoolean( SCROLL_PANE_SMOOTH_SCROLLING, "ScrollPane.smoothScrolling" );
}
/**
* Specifies whether the scroll pane uses smooth scrolling.
*/
public void setSmoothScrolling( boolean smoothScrolling ) {
putClientProperty( SCROLL_PANE_SMOOTH_SCROLLING, smoothScrolling );
}
/**
* Returns the outline color of the component border.
*/
public Object getOutline() {
return getClientProperty( OUTLINE );
}
/**
* Specifies the outline color of the component border.
* <p>
* Allowed Values are:
* <ul>
* <li>{@code null}
* <li>string {@code "error"}
* <li>string {@code "warning"}
* <li>any color (type {@link Color})
* <li>an array of two colors (type {@link Color}[2]) where the first color
* is for focused state and the second for unfocused state
* </ul>
*/
public void setOutline( Object outline ) {
putClientProperty( OUTLINE, outline );
}
}

View File

@@ -0,0 +1,85 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import java.awt.Color;
import javax.swing.JSpinner;
/**
* Subclass of {@link JSpinner} that provides easy access to FlatLaf specific client properties.
*
* @author Karl Tauber
*/
public class FlatSpinner
extends JSpinner
implements FlatComponentExtension
{
/**
* Returns minimum width of a component.
*/
public int getMinimumWidth() {
return getClientPropertyInt( MINIMUM_WIDTH, "Component.minimumWidth" );
}
/**
* Specifies minimum width of a component.
*/
public void setMinimumWidth( int minimumWidth ) {
putClientProperty( MINIMUM_WIDTH, (minimumWidth >= 0) ? minimumWidth : null );
}
/**
* Returns whether the component is painted with round edges.
*/
public boolean isRoundRect() {
return getClientPropertyBoolean( COMPONENT_ROUND_RECT, false );
}
/**
* Specifies whether the component is painted with round edges.
*/
public void setRoundRect( boolean roundRect ) {
putClientPropertyBoolean( COMPONENT_ROUND_RECT, roundRect, false );
}
/**
* Returns the outline color of the component border.
*/
public Object getOutline() {
return getClientProperty( OUTLINE );
}
/**
* Specifies the outline color of the component border.
* <p>
* Allowed Values are:
* <ul>
* <li>{@code null}
* <li>string {@code "error"}
* <li>string {@code "warning"}
* <li>any color (type {@link Color})
* <li>an array of two colors (type {@link Color}[2]) where the first color
* is for focused state and the second for unfocused state
* </ul>
*/
public void setOutline( Object outline ) {
putClientProperty( OUTLINE, outline );
}
}

View File

@@ -0,0 +1,537 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import java.awt.Component;
import java.awt.Insets;
import java.util.function.BiConsumer;
import javax.swing.JComponent;
import javax.swing.JTabbedPane;
import javax.swing.SwingConstants;
/**
* Subclass of {@link JTabbedPane} that provides easy access to FlatLaf specific client properties.
*
* @author Karl Tauber
*/
public class FlatTabbedPane
extends JTabbedPane
implements FlatComponentExtension
{
/**
* Returns whether separators are shown between tabs.
*/
public boolean isShowTabSeparators() {
return getClientPropertyBoolean( TABBED_PANE_SHOW_TAB_SEPARATORS, "TabbedPane.showTabSeparators" );
}
/**
* Specifies whether separators are shown between tabs.
*/
public void setShowTabSeparators( boolean showTabSeparators ) {
putClientProperty( TABBED_PANE_SHOW_TAB_SEPARATORS, showTabSeparators );
}
/**
* Returns whether the separator between tabs area and content area should be shown.
*/
public boolean isShowContentSeparators() {
return getClientPropertyBoolean( TABBED_PANE_SHOW_CONTENT_SEPARATOR, true );
}
/**
* Specifies whether the separator between tabs area and content area should be shown.
*/
public void setShowContentSeparators( boolean showContentSeparators ) {
putClientPropertyBoolean( TABBED_PANE_SHOW_CONTENT_SEPARATOR, showContentSeparators, true );
}
/**
* Returns whether a full border is painted around a tabbed pane.
*/
public boolean isHasFullBorder() {
return getClientPropertyBoolean( TABBED_PANE_HAS_FULL_BORDER, "TabbedPane.hasFullBorder" );
}
/**
* Specifies whether a full border is painted around a tabbed pane.
*/
public void setHasFullBorder( boolean hasFullBorder ) {
putClientProperty( TABBED_PANE_HAS_FULL_BORDER, hasFullBorder );
}
/**
* Returns whether the tab area should be hidden if it contains only one tab.
*/
public boolean isHideTabAreaWithOneTab() {
return getClientPropertyBoolean( TABBED_PANE_HIDE_TAB_AREA_WITH_ONE_TAB, false );
}
/**
* Specifies whether the tab area should be hidden if it contains only one tab.
*/
public void setHideTabAreaWithOneTab( boolean hideTabAreaWithOneTab ) {
putClientPropertyBoolean( TABBED_PANE_HIDE_TAB_AREA_WITH_ONE_TAB, hideTabAreaWithOneTab, false );
}
/**
* Returns the minimum width of a tab.
*/
public int getMinimumTabWidth() {
return getClientPropertyInt( TABBED_PANE_MINIMUM_TAB_WIDTH, "TabbedPane.minimumTabWidth" );
}
/**
* Specifies the minimum width of a tab.
*/
public void setMinimumTabWidth( int minimumTabWidth ) {
putClientProperty( TABBED_PANE_MINIMUM_TAB_WIDTH, (minimumTabWidth >= 0) ? minimumTabWidth : null );
}
/**
* Returns the minimum width of the tab at the given tab index.
*/
public int getMinimumTabWidth( int tabIndex ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
return clientPropertyInt( c, TABBED_PANE_MINIMUM_TAB_WIDTH, 0 );
}
/**
* Specifies the minimum width of the tab at the given tab index.
*/
public void setMinimumTabWidth( int tabIndex, int minimumTabWidth ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
c.putClientProperty( TABBED_PANE_MINIMUM_TAB_WIDTH, (minimumTabWidth >= 0) ? minimumTabWidth : null );
}
/**
* Returns the maximum width of a tab.
*/
public int getMaximumTabWidth() {
return getClientPropertyInt( TABBED_PANE_MAXIMUM_TAB_WIDTH, "TabbedPane.maximumTabWidth" );
}
/**
* Specifies the maximum width of a tab.
* <p>
* Applied only if tab does not have a custom tab component
* (see {@link javax.swing.JTabbedPane#setTabComponentAt(int, java.awt.Component)}).
*/
public void setMaximumTabWidth( int maximumTabWidth ) {
putClientProperty( TABBED_PANE_MAXIMUM_TAB_WIDTH, (maximumTabWidth >= 0) ? maximumTabWidth : null );
}
/**
* Returns the maximum width of the tab at the given tab index.
*/
public int getMaximumTabWidth( int tabIndex ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
return clientPropertyInt( c, TABBED_PANE_MAXIMUM_TAB_WIDTH, 0 );
}
/**
* Specifies the maximum width of the tab at the given tab index.
* <p>
* Applied only if tab does not have a custom tab component
* (see {@link javax.swing.JTabbedPane#setTabComponentAt(int, java.awt.Component)}).
*/
public void setMaximumTabWidth( int tabIndex, int maximumTabWidth ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
c.putClientProperty( TABBED_PANE_MAXIMUM_TAB_WIDTH, (maximumTabWidth >= 0) ? maximumTabWidth : null );
}
/**
* Returns the height of a tab.
*/
public int getTabHeight() {
return getClientPropertyInt( TABBED_PANE_TAB_HEIGHT, "TabbedPane.tabHeight" );
}
/**
* Specifies the height of a tab.
*/
public void setTabHeight( int tabHeight ) {
putClientProperty( TABBED_PANE_TAB_HEIGHT, (tabHeight >= 0) ? tabHeight : null );
}
/**
* Returns the insets of a tab.
*/
public Insets getTabInsets() {
return getClientPropertyInsets( TABBED_PANE_TAB_INSETS, "TabbedPane.tabInsets" );
}
/**
* Specifies the insets of a tab.
*/
public void setTabInsets( Insets tabInsets ) {
putClientProperty( TABBED_PANE_TAB_INSETS, tabInsets );
}
/**
* Returns the insets of the tab at the given tab index.
*/
public Insets getTabInsets( int tabIndex ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
return (Insets) c.getClientProperty( TABBED_PANE_TAB_INSETS );
}
/**
* Specifies the insets of the tab at the given tab index.
*/
public void setTabInsets( int tabIndex, Insets tabInsets ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
c.putClientProperty( TABBED_PANE_TAB_INSETS, tabInsets );
}
/**
* Returns the insets of the tab area.
*/
public Insets getTabAreaInsets() {
return getClientPropertyInsets( TABBED_PANE_TAB_AREA_INSETS, "TabbedPane.tabAreaInsets" );
}
/**
* Specifies the insets of the tab area.
*/
public void setTabAreaInsets( Insets tabAreaInsets ) {
putClientProperty( TABBED_PANE_TAB_AREA_INSETS, tabAreaInsets );
}
/**
* Returns whether all tabs are closable.
*/
public boolean isTabsClosable() {
return getClientPropertyBoolean( TABBED_PANE_TAB_CLOSABLE, false );
}
/**
* Specifies whether all tabs are closable.
* If set to {@code true}, all tabs in that tabbed pane are closable.
* To make individual tabs closable, use {@link #setTabClosable(int, boolean)}.
* <p>
* Note that you have to specify a callback (see {@link #setTabCloseCallback(BiConsumer)})
* that is invoked when the user clicks a tab close button.
* The callback is responsible for closing the tab.
*/
public void setTabsClosable( boolean tabClosable ) {
putClientPropertyBoolean( TABBED_PANE_TAB_CLOSABLE, tabClosable, false );
}
/**
* Returns whether the tab at the given tab index is closable.
*/
public Boolean isTabClosable( int tabIndex ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
Object value = c.getClientProperty( TABBED_PANE_TAB_CLOSABLE );
return (value instanceof Boolean) ? (boolean) value : isTabsClosable();
}
/**
* Specifies whether the tab at the given tab index is closable.
* To make all tabs closable, use {@link #setTabsClosable(boolean)}.
* <p>
* Note that you have to specify a callback (see {@link #setTabCloseCallback(BiConsumer)})
* that is invoked when the user clicks a tab close button.
* The callback is responsible for closing the tab.
*/
public void setTabClosable( int tabIndex, boolean tabClosable ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
c.putClientProperty( TABBED_PANE_TAB_CLOSABLE, tabClosable );
}
/**
* Returns the tooltip text used for tab close buttons.
*/
public String getTabCloseToolTipText() {
return (String) getClientProperty( TABBED_PANE_TAB_CLOSE_TOOLTIPTEXT );
}
/**
* Specifies the tooltip text used for tab close buttons.
*/
public void setTabCloseToolTipText( String tabCloseToolTipText ) {
putClientProperty( TABBED_PANE_TAB_CLOSE_TOOLTIPTEXT, tabCloseToolTipText );
}
/**
* Returns the tooltip text used for tab close button at the given tab index.
*/
public String getTabCloseToolTipText( int tabIndex ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
return (String) c.getClientProperty( TABBED_PANE_TAB_CLOSE_TOOLTIPTEXT );
}
/**
* Specifies the tooltip text used for tab close button at the given tab index.
*/
public void setTabCloseToolTipText( int tabIndex, String tabCloseToolTipText ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
c.putClientProperty( TABBED_PANE_TAB_CLOSE_TOOLTIPTEXT, tabCloseToolTipText );
}
/**
* Returns the callback that is invoked when a tab close button is clicked.
* The callback is responsible for closing the tab.
*/
@SuppressWarnings( "unchecked" )
public BiConsumer<JTabbedPane, Integer> getTabCloseCallback() {
return (BiConsumer<JTabbedPane, Integer>) getClientProperty( TABBED_PANE_TAB_CLOSE_CALLBACK );
}
/**
* Specifies the callback that is invoked when a tab close button is clicked.
* The callback is responsible for closing the tab.
* <p>
* Use a {@link java.util.function.BiConsumer}&lt;javax.swing.JTabbedPane, Integer&gt;
* that receives the tabbed pane and the tab index as parameters:
* <pre>{@code
* myTabbedPane.setTabCloseCallback( (tabbedPane, tabIndex) -> {
* // close tab here
* } );
* }</pre>
* If you need to check whether a modifier key (e.g. Alt or Shift) was pressed
* while the user clicked the tab close button, use {@link java.awt.EventQueue#getCurrentEvent}
* to get current event, check whether it is a {@link java.awt.event.MouseEvent}
* and invoke its methods. E.g.
* <pre>{@code
* AWTEvent e = EventQueue.getCurrentEvent();
* boolean shift = (e instanceof MouseEvent) ? ((MouseEvent)e).isShiftDown() : false;
* }</pre>
*/
public void setTabCloseCallback( BiConsumer<JTabbedPane, Integer> tabCloseCallback ) {
putClientProperty( TABBED_PANE_TAB_CLOSE_CALLBACK, tabCloseCallback );
}
/**
* Returns the callback that is invoked when the tab close button at the given tab index is clicked.
* The callback is responsible for closing the tab.
*/
@SuppressWarnings( "unchecked" )
public BiConsumer<JTabbedPane, Integer> getTabCloseCallback( int tabIndex ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
return (BiConsumer<JTabbedPane, Integer>) c.getClientProperty( TABBED_PANE_TAB_CLOSE_CALLBACK );
}
/**
* Specifies the callback that is invoked when the tab close button at the given tab index is clicked.
* The callback is responsible for closing the tab.
*
* @see #setTabCloseCallback(BiConsumer)
*/
public void setTabCloseCallback( int tabIndex, BiConsumer<JTabbedPane, Integer> tabCloseCallback ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
c.putClientProperty( TABBED_PANE_TAB_CLOSE_CALLBACK, tabCloseCallback );
}
// NOTE: enum names must be equal to allowed strings
public enum TabsPopupPolicy { never, asNeeded };
/**
* Returns the display policy for the "more tabs" button,
* which shows a popup menu with the (partly) hidden tabs.
*/
public TabsPopupPolicy getTabsPopupPolicy() {
return getClientPropertyEnumString( TABBED_PANE_TABS_POPUP_POLICY, TabsPopupPolicy.class,
"TabbedPane.tabsPopupPolicy", TabsPopupPolicy.asNeeded );
}
/**
* Specifies the display policy for the "more tabs" button,
* which shows a popup menu with the (partly) hidden tabs.
*/
public void setTabsPopupPolicy( TabsPopupPolicy tabsPopupPolicy ) {
putClientPropertyEnumString( TABBED_PANE_TABS_POPUP_POLICY, tabsPopupPolicy );
}
// NOTE: enum names must be equal to allowed strings
public enum ScrollButtonsPolicy { never, asNeeded, asNeededSingle };
/**
* Returns the display policy for the forward/backward scroll arrow buttons.
*/
public ScrollButtonsPolicy getScrollButtonsPolicy() {
return getClientPropertyEnumString( TABBED_PANE_SCROLL_BUTTONS_POLICY, ScrollButtonsPolicy.class,
"TabbedPane.scrollButtonsPolicy", ScrollButtonsPolicy.asNeededSingle );
}
/**
* Specifies the display policy for the forward/backward scroll arrow buttons.
*/
public void setScrollButtonsPolicy( ScrollButtonsPolicy scrollButtonsPolicy ) {
putClientPropertyEnumString( TABBED_PANE_SCROLL_BUTTONS_POLICY, scrollButtonsPolicy );
}
// NOTE: enum names must be equal to allowed strings
public enum ScrollButtonsPlacement { both, trailing };
/**
* Returns the placement of the forward/backward scroll arrow buttons.
*/
public ScrollButtonsPlacement getScrollButtonsPlacement() {
return getClientPropertyEnumString( TABBED_PANE_SCROLL_BUTTONS_PLACEMENT, ScrollButtonsPlacement.class,
"TabbedPane.scrollButtonsPlacement", ScrollButtonsPlacement.both );
}
/**
* Specifies the placement of the forward/backward scroll arrow buttons.
*/
public void setScrollButtonsPlacement( ScrollButtonsPlacement scrollButtonsPlacement ) {
putClientPropertyEnumString( TABBED_PANE_SCROLL_BUTTONS_PLACEMENT, scrollButtonsPlacement );
}
// NOTE: enum names must be equal to allowed strings
public enum TabAreaAlignment { leading, trailing, center, fill };
/**
* Returns the alignment of the tab area.
*/
public TabAreaAlignment getTabAreaAlignment() {
return getClientPropertyEnumString( TABBED_PANE_TAB_AREA_ALIGNMENT, TabAreaAlignment.class,
"TabbedPane.tabAreaAlignment", TabAreaAlignment.leading );
}
/**
* Specifies the alignment of the tab area.
*/
public void setTabAreaAlignment( TabAreaAlignment tabAreaAlignment ) {
putClientPropertyEnumString( TABBED_PANE_TAB_AREA_ALIGNMENT, tabAreaAlignment );
}
// NOTE: enum names must be equal to allowed strings
public enum TabAlignment { leading, trailing, center };
/**
* Returns the horizontal alignment of the tab title and icon.
*/
public TabAlignment getTabAlignment() {
return getClientPropertyEnumString( TABBED_PANE_TAB_ALIGNMENT, TabAlignment.class,
"TabbedPane.tabAlignment", TabAlignment.center );
}
/**
* Specifies the horizontal alignment of the tab title and icon.
*/
public void setTabAlignment( TabAlignment tabAlignment ) {
putClientPropertyEnumString( TABBED_PANE_TAB_ALIGNMENT, tabAlignment );
}
// NOTE: enum names must be equal to allowed strings
public enum TabWidthMode { preferred, equal, compact };
/**
* Returns how the tabs should be sized.
*/
public TabWidthMode getTabWidthMode() {
return getClientPropertyEnumString( TABBED_PANE_TAB_WIDTH_MODE, TabWidthMode.class,
"TabbedPane.tabWidthMode", TabWidthMode.preferred );
}
/**
* Specifies how the tabs should be sized.
*/
public void setTabWidthMode( TabWidthMode tabWidthMode ) {
putClientPropertyEnumString( TABBED_PANE_TAB_WIDTH_MODE, tabWidthMode );
}
/**
* Returns the tab icon placement (relative to tab title).
*/
public int getTabIconPlacement() {
return getClientPropertyInt( TABBED_PANE_TAB_ICON_PLACEMENT, SwingConstants.LEADING );
}
/**
* Specifies the tab icon placement (relative to tab title).
* <p>
* Allowed Values are:
* <ul>
* <li>{@link SwingConstants#LEADING} (default)
* <li>{@link SwingConstants#TRAILING}
* <li>{@link SwingConstants#TOP}
* <li>{@link SwingConstants#BOTTOM}
* </ul>
*/
public void setTabIconPlacement( int tabIconPlacement ) {
putClientProperty( TABBED_PANE_TAB_ICON_PLACEMENT, (tabIconPlacement >= 0) ? tabIconPlacement : null );
}
/**
* Returns a component that will be placed at the leading edge of the tabs area.
*/
public Component getLeadingComponent() {
return (Component) getClientProperty( TABBED_PANE_LEADING_COMPONENT );
}
/**
* Specifies a component that will be placed at the leading edge of the tabs area.
* <p>
* For top and bottom tab placement, the layed out component size will be
* the preferred component width and the tab area height.<br>
* For left and right tab placement, the layed out component size will be
* the tab area width and the preferred component height.
*/
public void setLeadingComponent( Component leadingComponent ) {
putClientProperty( TABBED_PANE_LEADING_COMPONENT, leadingComponent );
}
/**
* Returns a component that will be placed at the trailing edge of the tabs area.
*/
public Component getTrailingComponent() {
return (Component) getClientProperty( TABBED_PANE_TRAILING_COMPONENT );
}
/**
* Specifies a component that will be placed at the trailing edge of the tabs area.
* <p>
* For top and bottom tab placement, the layed out component size will be
* the available horizontal space (minimum is preferred component width) and the tab area height.<br>
* For left and right tab placement, the layed out component size will be
* the tab area width and the available vertical space (minimum is preferred component height).
*/
public void setTrailingComponent( Component trailingComponent ) {
putClientProperty( TABBED_PANE_TRAILING_COMPONENT, trailingComponent );
}
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import javax.swing.JTextArea;
/**
* Subclass of {@link JTextArea} that provides easy access to FlatLaf specific client properties.
*
* @author Karl Tauber
*/
public class FlatTextArea
extends JTextArea
implements FlatComponentExtension
{
/**
* Returns minimum width of a component.
*/
public int getMinimumWidth() {
return getClientPropertyInt( MINIMUM_WIDTH, "Component.minimumWidth" );
}
/**
* Specifies minimum width of a component.
*/
public void setMinimumWidth( int minimumWidth ) {
putClientProperty( MINIMUM_WIDTH, (minimumWidth >= 0) ? minimumWidth : null );
}
}

View File

@@ -0,0 +1,119 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import java.awt.Color;
import javax.swing.JTextField;
/**
* Subclass of {@link JTextField} that provides easy access to FlatLaf specific client properties.
*
* @author Karl Tauber
*/
public class FlatTextField
extends JTextField
implements FlatComponentExtension
{
/**
* Returns the placeholder text that is only painted if the text field is empty.
*/
public String getPlaceholderText() {
return (String) getClientProperty( PLACEHOLDER_TEXT );
}
/**
* Sets the placeholder text that is only painted if the text field is empty.
*/
public void setPlaceholderText( String placeholderText ) {
putClientProperty( PLACEHOLDER_TEXT, placeholderText );
}
// NOTE: enum names must be equal to allowed strings
public enum SelectAllOnFocusPolicy { never, once, always };
/**
* Returns whether all text is selected when the text component gains focus.
*/
public SelectAllOnFocusPolicy getSelectAllOnFocusPolicy() {
return getClientPropertyEnumString( SELECT_ALL_ON_FOCUS_POLICY, SelectAllOnFocusPolicy.class,
"TextComponent.selectAllOnFocusPolicy", SelectAllOnFocusPolicy.once );
}
/**
* Specifies whether all text is selected when the text component gains focus.
*/
public void setSelectAllOnFocusPolicy( SelectAllOnFocusPolicy selectAllOnFocusPolicy ) {
putClientPropertyEnumString( SELECT_ALL_ON_FOCUS_POLICY, selectAllOnFocusPolicy );
}
/**
* Returns minimum width of a component.
*/
public int getMinimumWidth() {
return getClientPropertyInt( MINIMUM_WIDTH, "Component.minimumWidth" );
}
/**
* Specifies minimum width of a component.
*/
public void setMinimumWidth( int minimumWidth ) {
putClientProperty( MINIMUM_WIDTH, (minimumWidth >= 0) ? minimumWidth : null );
}
/**
* Returns whether the component is painted with round edges.
*/
public boolean isRoundRect() {
return getClientPropertyBoolean( COMPONENT_ROUND_RECT, false );
}
/**
* Specifies whether the component is painted with round edges.
*/
public void setRoundRect( boolean roundRect ) {
putClientPropertyBoolean( COMPONENT_ROUND_RECT, roundRect, false );
}
/**
* Returns the outline color of the component border.
*/
public Object getOutline() {
return getClientProperty( OUTLINE );
}
/**
* Specifies the outline color of the component border.
* <p>
* Allowed Values are:
* <ul>
* <li>{@code null}
* <li>string {@code "error"}
* <li>string {@code "warning"}
* <li>any color (type {@link Color})
* <li>an array of two colors (type {@link Color}[2]) where the first color
* is for focused state and the second for unfocused state
* </ul>
*/
public void setOutline( Object outline ) {
putClientProperty( OUTLINE, outline );
}
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import javax.swing.JTextPane;
/**
* Subclass of {@link JTextPane} that provides easy access to FlatLaf specific client properties.
*
* @author Karl Tauber
*/
public class FlatTextPane
extends JTextPane
implements FlatComponentExtension
{
/**
* Returns minimum width of a component.
*/
public int getMinimumWidth() {
return getClientPropertyInt( MINIMUM_WIDTH, "Component.minimumWidth" );
}
/**
* Specifies minimum width of a component.
*/
public void setMinimumWidth( int minimumWidth ) {
putClientProperty( MINIMUM_WIDTH, (minimumWidth >= 0) ? minimumWidth : null );
}
}

View File

@@ -0,0 +1,163 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import java.awt.Color;
import javax.swing.JToggleButton;
import com.formdev.flatlaf.extras.components.FlatButton.ButtonType;
/**
* Subclass of {@link JToggleButton} that provides easy access to FlatLaf specific client properties.
*
* @author Karl Tauber
*/
public class FlatToggleButton
extends JToggleButton
implements FlatComponentExtension
{
/**
* Returns type of a button.
*/
public ButtonType getButtonType() {
return getClientPropertyEnumString( BUTTON_TYPE, ButtonType.class, null, ButtonType.none );
}
/**
* Specifies type of a button.
*/
public void setButtonType( ButtonType buttonType ) {
if( buttonType == ButtonType.none )
buttonType = null;
putClientPropertyEnumString( BUTTON_TYPE, buttonType );
}
/**
* Returns whether the button preferred size will be made square (quadratically).
*/
public boolean isSquareSize() {
return getClientPropertyBoolean( SQUARE_SIZE, false );
}
/**
* Specifies whether the button preferred size will be made square (quadratically).
*/
public void setSquareSize( boolean squareSize ) {
putClientPropertyBoolean( SQUARE_SIZE, squareSize, false );
}
/**
* Returns minimum width of a component.
*/
public int getMinimumWidth() {
return getClientPropertyInt( MINIMUM_WIDTH, "ToggleButton.minimumWidth" );
}
/**
* Specifies minimum width of a component.
*/
public void setMinimumWidth( int minimumWidth ) {
putClientProperty( MINIMUM_WIDTH, (minimumWidth >= 0) ? minimumWidth : null );
}
/**
* Returns minimum height of a component.
*/
public int getMinimumHeight() {
return getClientPropertyInt( MINIMUM_HEIGHT, 0 );
}
/**
* Specifies minimum height of a component.
*/
public void setMinimumHeight( int minimumHeight ) {
putClientProperty( MINIMUM_HEIGHT, (minimumHeight >= 0) ? minimumHeight : null );
}
/**
* Returns the outline color of the component border.
*/
public Object getOutline() {
return getClientProperty( OUTLINE );
}
/**
* Specifies the outline color of the component border.
* <p>
* Allowed Values are:
* <ul>
* <li>{@code null}
* <li>string {@code "error"}
* <li>string {@code "warning"}
* <li>any color (type {@link Color})
* <li>an array of two colors (type {@link Color}[2]) where the first color
* is for focused state and the second for unfocused state
* </ul>
*/
public void setOutline( Object outline ) {
putClientProperty( OUTLINE, outline );
}
/**
* Returns height of underline if toggle button type is {@link ButtonType#tab}.
*/
public int getTabUnderlineHeight() {
return getClientPropertyInt( TAB_BUTTON_UNDERLINE_HEIGHT, "ToggleButton.tab.underlineHeight" );
}
/**
* Specifies height of underline if toggle button type is {@link ButtonType#tab}.
*/
public void setTabUnderlineHeight( int tabUnderlineHeight ) {
putClientProperty( TAB_BUTTON_UNDERLINE_HEIGHT, (tabUnderlineHeight >= 0) ? tabUnderlineHeight : null );
}
/**
* Returns color of underline if toggle button type is {@link ButtonType#tab}.
*/
public Color getTabUnderlineColor() {
return getClientPropertyColor( TAB_BUTTON_UNDERLINE_COLOR, "ToggleButton.tab.underlineColor" );
}
/**
* Specifies color of underline if toggle button type is {@link ButtonType#tab}.
*/
public void setTabUnderlineColor( Color tabUnderlineColor ) {
putClientProperty( TAB_BUTTON_UNDERLINE_COLOR, tabUnderlineColor );
}
/**
* Returns background color if selected and toggle button type is {@link ButtonType#tab}.
*/
public Color getTabSelectedBackground() {
return getClientPropertyColor( TAB_BUTTON_SELECTED_BACKGROUND, "ToggleButton.tab.selectedBackground" );
}
/**
* Specifies background color if selected and toggle button type is {@link ButtonType#tab}.
*/
public void setTabSelectedBackground( Color tabSelectedBackground ) {
putClientProperty( TAB_BUTTON_SELECTED_BACKGROUND, tabSelectedBackground );
}
}

View File

@@ -0,0 +1,255 @@
/*
* Copyright 2019 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.ItemEvent;
import javax.swing.JCheckBox;
import javax.swing.LookAndFeel;
import javax.swing.UIManager;
import com.formdev.flatlaf.FlatLaf;
/**
* A tri-state check box.
* <p>
* The initial state is {@link State#INDETERMINATE}.
* <p>
* By default the third state is allowed and clicking on the checkbox cycles thru all
* three states. If you want that the user can cycle only thru two states, disallow
* intermediate state using {@link #setAllowIndeterminate(boolean)}. Then you can still
* set the indeterminate state via API if necessary, but the user can not.
* <p>
* The default state cycle order is {@link State#UNSELECTED} to {@link State#INDETERMINATE}
* to {@link State#SELECTED}.
* This is the same order as used by macOS, win32, IntelliJ IDEA and on the web as recommended by W3C in
* <a href="https://www.w3.org/TR/wai-aria-practices-1.1/examples/checkbox/checkbox-2/checkbox-2.html">Tri-State Checkbox Example</a>).
* <p>
* If {@link #isAltStateCycleOrder()} returns {@code true},
* the state cycle order is {@link State#UNSELECTED} to {@link State#SELECTED}
* to {@link State#INDETERMINATE}. This order is used by Windows 10 UWP apps.
* <p>
* If you prefer the alternative state cycle order for all tri-state check boxes, enable it using:
* <pre>
* UIManager.put( "FlatTriStateCheckBox.altStateCycleOrder", true );
* </pre>
* <p>
* To display the third state, this component requires an LaF that supports painting
* the indeterminate state if client property {@code "JButton.selectedState"} has the
* value {@code "indeterminate"}.
* FlatLaf and macOS Aqua LaF support the third state.
* For other LaFs a magenta rectangle is painted around the component for the third state.
*
* @author Karl Tauber
*/
public class FlatTriStateCheckBox
extends JCheckBox
{
public enum State { UNSELECTED, INDETERMINATE, SELECTED }
private State state;
private boolean allowIndeterminate = true;
private boolean altStateCycleOrder = UIManager.getBoolean( "FlatTriStateCheckBox.altStateCycleOrder" );
public FlatTriStateCheckBox() {
this( null );
}
public FlatTriStateCheckBox( String text ) {
this( text, State.INDETERMINATE );
}
public FlatTriStateCheckBox( String text, State initialState ) {
super( text );
setModel( new ToggleButtonModel() {
@Override
public boolean isSelected() {
return state != State.UNSELECTED;
}
@Override
public void setSelected( boolean b ) {
setState( nextState( state ) );
fireStateChanged();
fireItemStateChanged( new ItemEvent( this, ItemEvent.ITEM_STATE_CHANGED, this,
isSelected() ? ItemEvent.SELECTED : ItemEvent.DESELECTED ) );
}
} );
setState( initialState );
}
/**
* Returns the state as {@link State} enum.
* <p>
* Alternatively you can use {@link #getChecked()} to get all three states as {@link Boolean}
* or {@link #isIndeterminate()} to check only for indeterminate state.
*/
public State getState() {
return state;
}
/**
* Sets the state as {@link State} enum.
*/
public void setState( State state ) {
if( this.state == state )
return;
State oldState = this.state;
this.state = state;
putClientProperty( SELECTED_STATE, (state == State.INDETERMINATE) ? SELECTED_STATE_INDETERMINATE : null );
firePropertyChange( "state", oldState, state );
repaint();
}
/**
* Returns the next state that follows the given state, depending on
* {@link #isAllowIndeterminate()} and {@link #isAltStateCycleOrder()}.
*/
protected State nextState( State state ) {
if( !altStateCycleOrder ) {
// default cycle order: UNSELECTED --> INDETERMINATE --> SELECTED
switch( state ) {
default:
case UNSELECTED: return allowIndeterminate ? State.INDETERMINATE : State.SELECTED;
case INDETERMINATE: return State.SELECTED;
case SELECTED: return State.UNSELECTED;
}
} else {
// alternative cycle order: INDETERMINATE --> UNSELECTED --> SELECTED
switch( state ) {
default:
case UNSELECTED: return State.SELECTED;
case INDETERMINATE: return State.UNSELECTED;
case SELECTED: return allowIndeterminate ? State.INDETERMINATE : State.UNSELECTED;
}
}
}
/**
* Returns the state as {@link Boolean}.
* Returns {@code null} if the state is {@link State#INDETERMINATE}.
* <p>
* Alternatively you can use {@link #getState()} to get state as {@link State} enum
* or {@link #isIndeterminate()} to check only for indeterminate state.
*/
public Boolean getChecked() {
switch( state ) {
default:
case UNSELECTED: return false;
case INDETERMINATE: return null;
case SELECTED: return true;
}
}
/**
* Sets the state as {@link Boolean}.
* Passing {@code null} sets state to {@link State#INDETERMINATE}.
*/
public void setChecked( Boolean value ) {
setState( (value == null) ? State.INDETERMINATE : (value ? State.SELECTED : State.UNSELECTED) );
}
@Override
public void setSelected( boolean b ) {
setState( b ? State.SELECTED : State.UNSELECTED );
}
/**
* Returns whether state is indeterminate.
*/
public boolean isIndeterminate() {
return state == State.INDETERMINATE;
}
/**
* Sets indeterminate state.
*/
public void setIndeterminate( boolean indeterminate ) {
if( indeterminate )
setState( State.INDETERMINATE );
else if( state == State.INDETERMINATE )
setState( State.UNSELECTED );
}
/**
* Returns whether indeterminate state is allowed.
* <p>
* This affects only the user when clicking on the checkbox.
* Setting state to indeterminate via API is always allowed.
*/
public boolean isAllowIndeterminate() {
return allowIndeterminate;
}
/**
* Sets whether indeterminate state is allowed.
* <p>
* This affects only the user when clicking on the checkbox.
* Setting state to indeterminate via API is always allowed.
*/
public void setAllowIndeterminate( boolean allowIndeterminate ) {
this.allowIndeterminate = allowIndeterminate;
}
/**
* Returns whether alternative state cycle order should be used.
*/
public boolean isAltStateCycleOrder() {
return altStateCycleOrder;
}
/**
* Sets whether alternative state cycle order should be used.
*/
public void setAltStateCycleOrder( boolean altStateCycleOrder ) {
this.altStateCycleOrder = altStateCycleOrder;
}
@Override
protected void paintComponent( Graphics g ) {
super.paintComponent( g );
if( state == State.INDETERMINATE && !isIndeterminateStateSupported() )
paintIndeterminateState( g );
}
/**
* Paints the indeterminate state if the current LaF does not support displaying
* the indeterminate state.
* The default implementation draws a magenta rectangle around the component.
*/
protected void paintIndeterminateState( Graphics g ) {
g.setColor( Color.magenta );
g.drawRect( 0, 0, getWidth() - 1, getHeight() - 1 );
}
/**
* Returns whether the current LaF supports displaying the indeterminate state.
* Returns {@code true} for FlatLaf and macOS Aqua.
*/
protected boolean isIndeterminateStateSupported() {
LookAndFeel laf = UIManager.getLookAndFeel();
return laf instanceof FlatLaf || laf.getClass().getName().equals( "com.apple.laf.AquaLookAndFeel" );
}
}

View File

@@ -25,10 +25,6 @@ Otherwise download `flatlaf-intellij-themes-<version>.jar` here:
[![Download](https://api.bintray.com/packages/jformdesigner/flatlaf/flatlaf-intellij-themes/images/download.svg)](https://bintray.com/jformdesigner/flatlaf/flatlaf-intellij-themes/_latestVersion)
You also need `flatlaf-<version>.jar`, which you can download here:
[![Download](https://api.bintray.com/packages/jformdesigner/flatlaf/flatlaf/images/download.svg)](https://bintray.com/jformdesigner/flatlaf/flatlaf/_latestVersion)
How to use?
-----------
@@ -60,6 +56,7 @@ Name | Class
[Gradianto Dark Fuchsia](https://github.com/thvardhan/Gradianto) | `com.formdev.flatlaf.intellijthemes.FlatGradiantoDarkFuchsiaIJTheme`
[Gradianto Deep Ocean](https://github.com/thvardhan/Gradianto) | `com.formdev.flatlaf.intellijthemes.FlatGradiantoDeepOceanIJTheme`
[Gradianto Midnight Blue](https://github.com/thvardhan/Gradianto) | `com.formdev.flatlaf.intellijthemes.FlatGradiantoMidnightBlueIJTheme`
[Gradianto Nature Green](https://github.com/thvardhan/Gradianto) | `com.formdev.flatlaf.intellijthemes.FlatGradiantoNatureGreenIJTheme`
[Gray](https://github.com/OlyaB/GreyTheme) | `com.formdev.flatlaf.intellijthemes.FlatGrayIJTheme`
[Gruvbox Dark Hard](https://github.com/Vincent-P/gruvbox-intellij-theme) | `com.formdev.flatlaf.intellijthemes.FlatGruvboxDarkHardIJTheme`
[Gruvbox Dark Medium](https://github.com/Vincent-P/gruvbox-intellij-theme) | `com.formdev.flatlaf.intellijthemes.FlatGruvboxDarkMediumIJTheme`

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.formdev.flatlaf.intellijthemes;
//
// DO NOT MODIFY
// Generated with com.formdev.flatlaf.demo.intellijthemes.IJThemesClassGenerator
//
package com.formdev.flatlaf.intellijthemes;
import javax.swing.UIManager.LookAndFeelInfo;
/**
@@ -28,64 +28,82 @@ import javax.swing.UIManager.LookAndFeelInfo;
*/
public class FlatAllIJThemes
{
public static final LookAndFeelInfo[] INFOS = {
new LookAndFeelInfo( "Arc", "com.formdev.flatlaf.intellijthemes.FlatArcIJTheme" ),
new LookAndFeelInfo( "Arc - Orange", "com.formdev.flatlaf.intellijthemes.FlatArcOrangeIJTheme" ),
new LookAndFeelInfo( "Arc Dark", "com.formdev.flatlaf.intellijthemes.FlatArcDarkIJTheme" ),
new LookAndFeelInfo( "Arc Dark - Orange", "com.formdev.flatlaf.intellijthemes.FlatArcDarkOrangeIJTheme" ),
new LookAndFeelInfo( "Carbon", "com.formdev.flatlaf.intellijthemes.FlatCarbonIJTheme" ),
new LookAndFeelInfo( "Cobalt 2", "com.formdev.flatlaf.intellijthemes.FlatCobalt2IJTheme" ),
new LookAndFeelInfo( "Cyan light", "com.formdev.flatlaf.intellijthemes.FlatCyanLightIJTheme" ),
new LookAndFeelInfo( "Dark Flat", "com.formdev.flatlaf.intellijthemes.FlatDarkFlatIJTheme" ),
new LookAndFeelInfo( "Dark purple", "com.formdev.flatlaf.intellijthemes.FlatDarkPurpleIJTheme" ),
new LookAndFeelInfo( "Dracula", "com.formdev.flatlaf.intellijthemes.FlatDraculaIJTheme" ),
new LookAndFeelInfo( "Gradianto Dark Fuchsia", "com.formdev.flatlaf.intellijthemes.FlatGradiantoDarkFuchsiaIJTheme" ),
new LookAndFeelInfo( "Gradianto Deep Ocean", "com.formdev.flatlaf.intellijthemes.FlatGradiantoDeepOceanIJTheme" ),
new LookAndFeelInfo( "Gradianto Midnight Blue", "com.formdev.flatlaf.intellijthemes.FlatGradiantoMidnightBlueIJTheme" ),
new LookAndFeelInfo( "Gray", "com.formdev.flatlaf.intellijthemes.FlatGrayIJTheme" ),
new LookAndFeelInfo( "Gruvbox Dark Hard", "com.formdev.flatlaf.intellijthemes.FlatGruvboxDarkHardIJTheme" ),
new LookAndFeelInfo( "Gruvbox Dark Medium", "com.formdev.flatlaf.intellijthemes.FlatGruvboxDarkMediumIJTheme" ),
new LookAndFeelInfo( "Gruvbox Dark Soft", "com.formdev.flatlaf.intellijthemes.FlatGruvboxDarkSoftIJTheme" ),
new LookAndFeelInfo( "Hiberbee Dark", "com.formdev.flatlaf.intellijthemes.FlatHiberbeeDarkIJTheme" ),
new LookAndFeelInfo( "High contrast", "com.formdev.flatlaf.intellijthemes.FlatHighContrastIJTheme" ),
new LookAndFeelInfo( "Light Flat", "com.formdev.flatlaf.intellijthemes.FlatLightFlatIJTheme" ),
new LookAndFeelInfo( "Material Design Dark", "com.formdev.flatlaf.intellijthemes.FlatMaterialDesignDarkIJTheme" ),
new LookAndFeelInfo( "Monocai", "com.formdev.flatlaf.intellijthemes.FlatMonocaiIJTheme" ),
new LookAndFeelInfo( "Nord", "com.formdev.flatlaf.intellijthemes.FlatNordIJTheme" ),
new LookAndFeelInfo( "One Dark", "com.formdev.flatlaf.intellijthemes.FlatOneDarkIJTheme" ),
new LookAndFeelInfo( "Solarized Dark", "com.formdev.flatlaf.intellijthemes.FlatSolarizedDarkIJTheme" ),
new LookAndFeelInfo( "Solarized Light", "com.formdev.flatlaf.intellijthemes.FlatSolarizedLightIJTheme" ),
new LookAndFeelInfo( "Spacegray", "com.formdev.flatlaf.intellijthemes.FlatSpacegrayIJTheme" ),
new LookAndFeelInfo( "Vuesion", "com.formdev.flatlaf.intellijthemes.FlatVuesionIJTheme" ),
new LookAndFeelInfo( "Arc Dark (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatArcDarkIJTheme" ),
new LookAndFeelInfo( "Arc Dark Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatArcDarkContrastIJTheme" ),
new LookAndFeelInfo( "Atom One Dark (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatAtomOneDarkIJTheme" ),
new LookAndFeelInfo( "Atom One Dark Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatAtomOneDarkContrastIJTheme" ),
new LookAndFeelInfo( "Atom One Light (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatAtomOneLightIJTheme" ),
new LookAndFeelInfo( "Atom One Light Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatAtomOneLightContrastIJTheme" ),
new LookAndFeelInfo( "Dracula (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatDraculaIJTheme" ),
new LookAndFeelInfo( "Dracula Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatDraculaContrastIJTheme" ),
new LookAndFeelInfo( "GitHub (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatGitHubIJTheme" ),
new LookAndFeelInfo( "GitHub Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatGitHubContrastIJTheme" ),
new LookAndFeelInfo( "Light Owl (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatLightOwlIJTheme" ),
new LookAndFeelInfo( "Light Owl Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatLightOwlContrastIJTheme" ),
new LookAndFeelInfo( "Material Darker (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialDarkerIJTheme" ),
new LookAndFeelInfo( "Material Darker Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialDarkerContrastIJTheme" ),
new LookAndFeelInfo( "Material Deep Ocean (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialDeepOceanIJTheme" ),
new LookAndFeelInfo( "Material Deep Ocean Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialDeepOceanContrastIJTheme" ),
new LookAndFeelInfo( "Material Lighter (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialLighterIJTheme" ),
new LookAndFeelInfo( "Material Lighter Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialLighterContrastIJTheme" ),
new LookAndFeelInfo( "Material Oceanic (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialOceanicIJTheme" ),
new LookAndFeelInfo( "Material Oceanic Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialOceanicContrastIJTheme" ),
new LookAndFeelInfo( "Material Palenight (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialPalenightIJTheme" ),
new LookAndFeelInfo( "Material Palenight Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialPalenightContrastIJTheme" ),
new LookAndFeelInfo( "Monokai Pro (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMonokaiProIJTheme" ),
new LookAndFeelInfo( "Monokai Pro Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMonokaiProContrastIJTheme" ),
new LookAndFeelInfo( "Night Owl (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatNightOwlIJTheme" ),
new LookAndFeelInfo( "Night Owl Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatNightOwlContrastIJTheme" ),
new LookAndFeelInfo( "Solarized Dark (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatSolarizedDarkIJTheme" ),
new LookAndFeelInfo( "Solarized Dark Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatSolarizedDarkContrastIJTheme" ),
new LookAndFeelInfo( "Solarized Light (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatSolarizedLightIJTheme" ),
new LookAndFeelInfo( "Solarized Light Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatSolarizedLightContrastIJTheme" ),
public static final FlatIJLookAndFeelInfo[] INFOS = {
new FlatIJLookAndFeelInfo( "Arc", "com.formdev.flatlaf.intellijthemes.FlatArcIJTheme", false ),
new FlatIJLookAndFeelInfo( "Arc - Orange", "com.formdev.flatlaf.intellijthemes.FlatArcOrangeIJTheme", false ),
new FlatIJLookAndFeelInfo( "Arc Dark", "com.formdev.flatlaf.intellijthemes.FlatArcDarkIJTheme", true ),
new FlatIJLookAndFeelInfo( "Arc Dark - Orange", "com.formdev.flatlaf.intellijthemes.FlatArcDarkOrangeIJTheme", true ),
new FlatIJLookAndFeelInfo( "Carbon", "com.formdev.flatlaf.intellijthemes.FlatCarbonIJTheme", true ),
new FlatIJLookAndFeelInfo( "Cobalt 2", "com.formdev.flatlaf.intellijthemes.FlatCobalt2IJTheme", true ),
new FlatIJLookAndFeelInfo( "Cyan light", "com.formdev.flatlaf.intellijthemes.FlatCyanLightIJTheme", false ),
new FlatIJLookAndFeelInfo( "Dark Flat", "com.formdev.flatlaf.intellijthemes.FlatDarkFlatIJTheme", true ),
new FlatIJLookAndFeelInfo( "Dark purple", "com.formdev.flatlaf.intellijthemes.FlatDarkPurpleIJTheme", true ),
new FlatIJLookAndFeelInfo( "Dracula", "com.formdev.flatlaf.intellijthemes.FlatDraculaIJTheme", true ),
new FlatIJLookAndFeelInfo( "Gradianto Dark Fuchsia", "com.formdev.flatlaf.intellijthemes.FlatGradiantoDarkFuchsiaIJTheme", true ),
new FlatIJLookAndFeelInfo( "Gradianto Deep Ocean", "com.formdev.flatlaf.intellijthemes.FlatGradiantoDeepOceanIJTheme", true ),
new FlatIJLookAndFeelInfo( "Gradianto Midnight Blue", "com.formdev.flatlaf.intellijthemes.FlatGradiantoMidnightBlueIJTheme", true ),
new FlatIJLookAndFeelInfo( "Gradianto Nature Green", "com.formdev.flatlaf.intellijthemes.FlatGradiantoNatureGreenIJTheme", true ),
new FlatIJLookAndFeelInfo( "Gray", "com.formdev.flatlaf.intellijthemes.FlatGrayIJTheme", false ),
new FlatIJLookAndFeelInfo( "Gruvbox Dark Hard", "com.formdev.flatlaf.intellijthemes.FlatGruvboxDarkHardIJTheme", true ),
new FlatIJLookAndFeelInfo( "Gruvbox Dark Medium", "com.formdev.flatlaf.intellijthemes.FlatGruvboxDarkMediumIJTheme", true ),
new FlatIJLookAndFeelInfo( "Gruvbox Dark Soft", "com.formdev.flatlaf.intellijthemes.FlatGruvboxDarkSoftIJTheme", true ),
new FlatIJLookAndFeelInfo( "Hiberbee Dark", "com.formdev.flatlaf.intellijthemes.FlatHiberbeeDarkIJTheme", true ),
new FlatIJLookAndFeelInfo( "High contrast", "com.formdev.flatlaf.intellijthemes.FlatHighContrastIJTheme", true ),
new FlatIJLookAndFeelInfo( "Light Flat", "com.formdev.flatlaf.intellijthemes.FlatLightFlatIJTheme", false ),
new FlatIJLookAndFeelInfo( "Material Design Dark", "com.formdev.flatlaf.intellijthemes.FlatMaterialDesignDarkIJTheme", true ),
new FlatIJLookAndFeelInfo( "Monocai", "com.formdev.flatlaf.intellijthemes.FlatMonocaiIJTheme", true ),
new FlatIJLookAndFeelInfo( "Nord", "com.formdev.flatlaf.intellijthemes.FlatNordIJTheme", true ),
new FlatIJLookAndFeelInfo( "One Dark", "com.formdev.flatlaf.intellijthemes.FlatOneDarkIJTheme", true ),
new FlatIJLookAndFeelInfo( "Solarized Dark", "com.formdev.flatlaf.intellijthemes.FlatSolarizedDarkIJTheme", true ),
new FlatIJLookAndFeelInfo( "Solarized Light", "com.formdev.flatlaf.intellijthemes.FlatSolarizedLightIJTheme", false ),
new FlatIJLookAndFeelInfo( "Spacegray", "com.formdev.flatlaf.intellijthemes.FlatSpacegrayIJTheme", true ),
new FlatIJLookAndFeelInfo( "Vuesion", "com.formdev.flatlaf.intellijthemes.FlatVuesionIJTheme", true ),
new FlatIJLookAndFeelInfo( "Arc Dark (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatArcDarkIJTheme", true ),
new FlatIJLookAndFeelInfo( "Arc Dark Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatArcDarkContrastIJTheme", true ),
new FlatIJLookAndFeelInfo( "Atom One Dark (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatAtomOneDarkIJTheme", true ),
new FlatIJLookAndFeelInfo( "Atom One Dark Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatAtomOneDarkContrastIJTheme", true ),
new FlatIJLookAndFeelInfo( "Atom One Light (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatAtomOneLightIJTheme", false ),
new FlatIJLookAndFeelInfo( "Atom One Light Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatAtomOneLightContrastIJTheme", false ),
new FlatIJLookAndFeelInfo( "Dracula (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatDraculaIJTheme", true ),
new FlatIJLookAndFeelInfo( "Dracula Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatDraculaContrastIJTheme", true ),
new FlatIJLookAndFeelInfo( "GitHub (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatGitHubIJTheme", false ),
new FlatIJLookAndFeelInfo( "GitHub Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatGitHubContrastIJTheme", false ),
new FlatIJLookAndFeelInfo( "Light Owl (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatLightOwlIJTheme", false ),
new FlatIJLookAndFeelInfo( "Light Owl Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatLightOwlContrastIJTheme", false ),
new FlatIJLookAndFeelInfo( "Material Darker (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialDarkerIJTheme", true ),
new FlatIJLookAndFeelInfo( "Material Darker Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialDarkerContrastIJTheme", true ),
new FlatIJLookAndFeelInfo( "Material Deep Ocean (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialDeepOceanIJTheme", true ),
new FlatIJLookAndFeelInfo( "Material Deep Ocean Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialDeepOceanContrastIJTheme", true ),
new FlatIJLookAndFeelInfo( "Material Lighter (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialLighterIJTheme", false ),
new FlatIJLookAndFeelInfo( "Material Lighter Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialLighterContrastIJTheme", false ),
new FlatIJLookAndFeelInfo( "Material Oceanic (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialOceanicIJTheme", true ),
new FlatIJLookAndFeelInfo( "Material Oceanic Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialOceanicContrastIJTheme", true ),
new FlatIJLookAndFeelInfo( "Material Palenight (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialPalenightIJTheme", true ),
new FlatIJLookAndFeelInfo( "Material Palenight Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialPalenightContrastIJTheme", true ),
new FlatIJLookAndFeelInfo( "Monokai Pro (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMonokaiProIJTheme", true ),
new FlatIJLookAndFeelInfo( "Monokai Pro Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMonokaiProContrastIJTheme", true ),
new FlatIJLookAndFeelInfo( "Night Owl (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatNightOwlIJTheme", true ),
new FlatIJLookAndFeelInfo( "Night Owl Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatNightOwlContrastIJTheme", true ),
new FlatIJLookAndFeelInfo( "Solarized Dark (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatSolarizedDarkIJTheme", true ),
new FlatIJLookAndFeelInfo( "Solarized Dark Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatSolarizedDarkContrastIJTheme", true ),
new FlatIJLookAndFeelInfo( "Solarized Light (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatSolarizedLightIJTheme", false ),
new FlatIJLookAndFeelInfo( "Solarized Light Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatSolarizedLightContrastIJTheme", false ),
};
//---- class FlatIJLookAndFeelInfo ----------------------------------------
public static class FlatIJLookAndFeelInfo
extends LookAndFeelInfo
{
private final boolean dark;
public FlatIJLookAndFeelInfo( String name, String className, boolean dark ) {
super( name, className );
this.dark = dark;
}
public boolean isDark() {
return dark;
}
}
}

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.formdev.flatlaf.intellijthemes;
//
// DO NOT MODIFY
// Generated with com.formdev.flatlaf.demo.intellijthemes.IJThemesClassGenerator
//
package com.formdev.flatlaf.intellijthemes;
import com.formdev.flatlaf.IntelliJTheme;
/**
@@ -29,7 +29,9 @@ import com.formdev.flatlaf.IntelliJTheme;
public class FlatArcDarkIJTheme
extends IntelliJTheme.ThemeLaf
{
public static boolean install( ) {
public static final String NAME = "Arc Dark";
public static boolean install() {
try {
return install( new FlatArcDarkIJTheme() );
} catch( RuntimeException ex ) {
@@ -37,12 +39,16 @@ public class FlatArcDarkIJTheme
}
}
public static void installLafInfo() {
installLafInfo( NAME, FlatArcDarkIJTheme.class );
}
public FlatArcDarkIJTheme() {
super( Utils.loadTheme( "arc_theme_dark.theme.json" ) );
}
@Override
public String getName() {
return "Arc Dark";
return NAME;
}
}

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.formdev.flatlaf.intellijthemes;
//
// DO NOT MODIFY
// Generated with com.formdev.flatlaf.demo.intellijthemes.IJThemesClassGenerator
//
package com.formdev.flatlaf.intellijthemes;
import com.formdev.flatlaf.IntelliJTheme;
/**
@@ -29,7 +29,9 @@ import com.formdev.flatlaf.IntelliJTheme;
public class FlatArcDarkOrangeIJTheme
extends IntelliJTheme.ThemeLaf
{
public static boolean install( ) {
public static final String NAME = "Arc Dark - Orange";
public static boolean install() {
try {
return install( new FlatArcDarkOrangeIJTheme() );
} catch( RuntimeException ex ) {
@@ -37,12 +39,16 @@ public class FlatArcDarkOrangeIJTheme
}
}
public static void installLafInfo() {
installLafInfo( NAME, FlatArcDarkOrangeIJTheme.class );
}
public FlatArcDarkOrangeIJTheme() {
super( Utils.loadTheme( "arc_theme_dark_orange.theme.json" ) );
}
@Override
public String getName() {
return "Arc Dark - Orange";
return NAME;
}
}

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.formdev.flatlaf.intellijthemes;
//
// DO NOT MODIFY
// Generated with com.formdev.flatlaf.demo.intellijthemes.IJThemesClassGenerator
//
package com.formdev.flatlaf.intellijthemes;
import com.formdev.flatlaf.IntelliJTheme;
/**
@@ -29,7 +29,9 @@ import com.formdev.flatlaf.IntelliJTheme;
public class FlatArcIJTheme
extends IntelliJTheme.ThemeLaf
{
public static boolean install( ) {
public static final String NAME = "Arc";
public static boolean install() {
try {
return install( new FlatArcIJTheme() );
} catch( RuntimeException ex ) {
@@ -37,12 +39,16 @@ public class FlatArcIJTheme
}
}
public static void installLafInfo() {
installLafInfo( NAME, FlatArcIJTheme.class );
}
public FlatArcIJTheme() {
super( Utils.loadTheme( "arc-theme.theme.json" ) );
}
@Override
public String getName() {
return "Arc";
return NAME;
}
}

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.formdev.flatlaf.intellijthemes;
//
// DO NOT MODIFY
// Generated with com.formdev.flatlaf.demo.intellijthemes.IJThemesClassGenerator
//
package com.formdev.flatlaf.intellijthemes;
import com.formdev.flatlaf.IntelliJTheme;
/**
@@ -29,7 +29,9 @@ import com.formdev.flatlaf.IntelliJTheme;
public class FlatArcOrangeIJTheme
extends IntelliJTheme.ThemeLaf
{
public static boolean install( ) {
public static final String NAME = "Arc - Orange";
public static boolean install() {
try {
return install( new FlatArcOrangeIJTheme() );
} catch( RuntimeException ex ) {
@@ -37,12 +39,16 @@ public class FlatArcOrangeIJTheme
}
}
public static void installLafInfo() {
installLafInfo( NAME, FlatArcOrangeIJTheme.class );
}
public FlatArcOrangeIJTheme() {
super( Utils.loadTheme( "arc-theme-orange.theme.json" ) );
}
@Override
public String getName() {
return "Arc - Orange";
return NAME;
}
}

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.formdev.flatlaf.intellijthemes;
//
// DO NOT MODIFY
// Generated with com.formdev.flatlaf.demo.intellijthemes.IJThemesClassGenerator
//
package com.formdev.flatlaf.intellijthemes;
import com.formdev.flatlaf.IntelliJTheme;
/**
@@ -29,7 +29,9 @@ import com.formdev.flatlaf.IntelliJTheme;
public class FlatCarbonIJTheme
extends IntelliJTheme.ThemeLaf
{
public static boolean install( ) {
public static final String NAME = "Carbon";
public static boolean install() {
try {
return install( new FlatCarbonIJTheme() );
} catch( RuntimeException ex ) {
@@ -37,12 +39,16 @@ public class FlatCarbonIJTheme
}
}
public static void installLafInfo() {
installLafInfo( NAME, FlatCarbonIJTheme.class );
}
public FlatCarbonIJTheme() {
super( Utils.loadTheme( "Carbon.theme.json" ) );
}
@Override
public String getName() {
return "Carbon";
return NAME;
}
}

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.formdev.flatlaf.intellijthemes;
//
// DO NOT MODIFY
// Generated with com.formdev.flatlaf.demo.intellijthemes.IJThemesClassGenerator
//
package com.formdev.flatlaf.intellijthemes;
import com.formdev.flatlaf.IntelliJTheme;
/**
@@ -29,7 +29,9 @@ import com.formdev.flatlaf.IntelliJTheme;
public class FlatCobalt2IJTheme
extends IntelliJTheme.ThemeLaf
{
public static boolean install( ) {
public static final String NAME = "Cobalt 2";
public static boolean install() {
try {
return install( new FlatCobalt2IJTheme() );
} catch( RuntimeException ex ) {
@@ -37,12 +39,16 @@ public class FlatCobalt2IJTheme
}
}
public static void installLafInfo() {
installLafInfo( NAME, FlatCobalt2IJTheme.class );
}
public FlatCobalt2IJTheme() {
super( Utils.loadTheme( "Cobalt_2.theme.json" ) );
}
@Override
public String getName() {
return "Cobalt 2";
return NAME;
}
}

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.formdev.flatlaf.intellijthemes;
//
// DO NOT MODIFY
// Generated with com.formdev.flatlaf.demo.intellijthemes.IJThemesClassGenerator
//
package com.formdev.flatlaf.intellijthemes;
import com.formdev.flatlaf.IntelliJTheme;
/**
@@ -29,7 +29,9 @@ import com.formdev.flatlaf.IntelliJTheme;
public class FlatCyanLightIJTheme
extends IntelliJTheme.ThemeLaf
{
public static boolean install( ) {
public static final String NAME = "Cyan light";
public static boolean install() {
try {
return install( new FlatCyanLightIJTheme() );
} catch( RuntimeException ex ) {
@@ -37,12 +39,16 @@ public class FlatCyanLightIJTheme
}
}
public static void installLafInfo() {
installLafInfo( NAME, FlatCyanLightIJTheme.class );
}
public FlatCyanLightIJTheme() {
super( Utils.loadTheme( "Cyan.theme.json" ) );
}
@Override
public String getName() {
return "Cyan light";
return NAME;
}
}

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.formdev.flatlaf.intellijthemes;
//
// DO NOT MODIFY
// Generated with com.formdev.flatlaf.demo.intellijthemes.IJThemesClassGenerator
//
package com.formdev.flatlaf.intellijthemes;
import com.formdev.flatlaf.IntelliJTheme;
/**
@@ -29,7 +29,9 @@ import com.formdev.flatlaf.IntelliJTheme;
public class FlatDarkFlatIJTheme
extends IntelliJTheme.ThemeLaf
{
public static boolean install( ) {
public static final String NAME = "Dark Flat";
public static boolean install() {
try {
return install( new FlatDarkFlatIJTheme() );
} catch( RuntimeException ex ) {
@@ -37,12 +39,16 @@ public class FlatDarkFlatIJTheme
}
}
public static void installLafInfo() {
installLafInfo( NAME, FlatDarkFlatIJTheme.class );
}
public FlatDarkFlatIJTheme() {
super( Utils.loadTheme( "DarkFlatTheme.theme.json" ) );
}
@Override
public String getName() {
return "Dark Flat";
return NAME;
}
}

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.formdev.flatlaf.intellijthemes;
//
// DO NOT MODIFY
// Generated with com.formdev.flatlaf.demo.intellijthemes.IJThemesClassGenerator
//
package com.formdev.flatlaf.intellijthemes;
import com.formdev.flatlaf.IntelliJTheme;
/**
@@ -29,7 +29,9 @@ import com.formdev.flatlaf.IntelliJTheme;
public class FlatDarkPurpleIJTheme
extends IntelliJTheme.ThemeLaf
{
public static boolean install( ) {
public static final String NAME = "Dark purple";
public static boolean install() {
try {
return install( new FlatDarkPurpleIJTheme() );
} catch( RuntimeException ex ) {
@@ -37,12 +39,16 @@ public class FlatDarkPurpleIJTheme
}
}
public static void installLafInfo() {
installLafInfo( NAME, FlatDarkPurpleIJTheme.class );
}
public FlatDarkPurpleIJTheme() {
super( Utils.loadTheme( "DarkPurple.theme.json" ) );
}
@Override
public String getName() {
return "Dark purple";
return NAME;
}
}

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.formdev.flatlaf.intellijthemes;
//
// DO NOT MODIFY
// Generated with com.formdev.flatlaf.demo.intellijthemes.IJThemesClassGenerator
//
package com.formdev.flatlaf.intellijthemes;
import com.formdev.flatlaf.IntelliJTheme;
/**
@@ -29,7 +29,9 @@ import com.formdev.flatlaf.IntelliJTheme;
public class FlatDraculaIJTheme
extends IntelliJTheme.ThemeLaf
{
public static boolean install( ) {
public static final String NAME = "Dracula";
public static boolean install() {
try {
return install( new FlatDraculaIJTheme() );
} catch( RuntimeException ex ) {
@@ -37,12 +39,16 @@ public class FlatDraculaIJTheme
}
}
public static void installLafInfo() {
installLafInfo( NAME, FlatDraculaIJTheme.class );
}
public FlatDraculaIJTheme() {
super( Utils.loadTheme( "Dracula.theme.json" ) );
}
@Override
public String getName() {
return "Dracula";
return NAME;
}
}

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.formdev.flatlaf.intellijthemes;
//
// DO NOT MODIFY
// Generated with com.formdev.flatlaf.demo.intellijthemes.IJThemesClassGenerator
//
package com.formdev.flatlaf.intellijthemes;
import com.formdev.flatlaf.IntelliJTheme;
/**
@@ -29,7 +29,9 @@ import com.formdev.flatlaf.IntelliJTheme;
public class FlatGradiantoDarkFuchsiaIJTheme
extends IntelliJTheme.ThemeLaf
{
public static boolean install( ) {
public static final String NAME = "Gradianto Dark Fuchsia";
public static boolean install() {
try {
return install( new FlatGradiantoDarkFuchsiaIJTheme() );
} catch( RuntimeException ex ) {
@@ -37,12 +39,16 @@ public class FlatGradiantoDarkFuchsiaIJTheme
}
}
public static void installLafInfo() {
installLafInfo( NAME, FlatGradiantoDarkFuchsiaIJTheme.class );
}
public FlatGradiantoDarkFuchsiaIJTheme() {
super( Utils.loadTheme( "Gradianto_dark_fuchsia.theme.json" ) );
}
@Override
public String getName() {
return "Gradianto Dark Fuchsia";
return NAME;
}
}

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.formdev.flatlaf.intellijthemes;
//
// DO NOT MODIFY
// Generated with com.formdev.flatlaf.demo.intellijthemes.IJThemesClassGenerator
//
package com.formdev.flatlaf.intellijthemes;
import com.formdev.flatlaf.IntelliJTheme;
/**
@@ -29,7 +29,9 @@ import com.formdev.flatlaf.IntelliJTheme;
public class FlatGradiantoDeepOceanIJTheme
extends IntelliJTheme.ThemeLaf
{
public static boolean install( ) {
public static final String NAME = "Gradianto Deep Ocean";
public static boolean install() {
try {
return install( new FlatGradiantoDeepOceanIJTheme() );
} catch( RuntimeException ex ) {
@@ -37,12 +39,16 @@ public class FlatGradiantoDeepOceanIJTheme
}
}
public static void installLafInfo() {
installLafInfo( NAME, FlatGradiantoDeepOceanIJTheme.class );
}
public FlatGradiantoDeepOceanIJTheme() {
super( Utils.loadTheme( "Gradianto_deep_ocean.theme.json" ) );
}
@Override
public String getName() {
return "Gradianto Deep Ocean";
return NAME;
}
}

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.formdev.flatlaf.intellijthemes;
//
// DO NOT MODIFY
// Generated with com.formdev.flatlaf.demo.intellijthemes.IJThemesClassGenerator
//
package com.formdev.flatlaf.intellijthemes;
import com.formdev.flatlaf.IntelliJTheme;
/**
@@ -29,7 +29,9 @@ import com.formdev.flatlaf.IntelliJTheme;
public class FlatGradiantoMidnightBlueIJTheme
extends IntelliJTheme.ThemeLaf
{
public static boolean install( ) {
public static final String NAME = "Gradianto Midnight Blue";
public static boolean install() {
try {
return install( new FlatGradiantoMidnightBlueIJTheme() );
} catch( RuntimeException ex ) {
@@ -37,12 +39,16 @@ public class FlatGradiantoMidnightBlueIJTheme
}
}
public static void installLafInfo() {
installLafInfo( NAME, FlatGradiantoMidnightBlueIJTheme.class );
}
public FlatGradiantoMidnightBlueIJTheme() {
super( Utils.loadTheme( "Gradianto_midnight_blue.theme.json" ) );
}
@Override
public String getName() {
return "Gradianto Midnight Blue";
return NAME;
}
}

View File

@@ -0,0 +1,54 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.intellijthemes;
//
// DO NOT MODIFY
// Generated with com.formdev.flatlaf.demo.intellijthemes.IJThemesClassGenerator
//
import com.formdev.flatlaf.IntelliJTheme;
/**
* @author Karl Tauber
*/
public class FlatGradiantoNatureGreenIJTheme
extends IntelliJTheme.ThemeLaf
{
public static final String NAME = "Gradianto Nature Green";
public static boolean install() {
try {
return install( new FlatGradiantoNatureGreenIJTheme() );
} catch( RuntimeException ex ) {
return false;
}
}
public static void installLafInfo() {
installLafInfo( NAME, FlatGradiantoNatureGreenIJTheme.class );
}
public FlatGradiantoNatureGreenIJTheme() {
super( Utils.loadTheme( "Gradianto_Nature_Green.theme.json" ) );
}
@Override
public String getName() {
return NAME;
}
}

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.formdev.flatlaf.intellijthemes;
//
// DO NOT MODIFY
// Generated with com.formdev.flatlaf.demo.intellijthemes.IJThemesClassGenerator
//
package com.formdev.flatlaf.intellijthemes;
import com.formdev.flatlaf.IntelliJTheme;
/**
@@ -29,7 +29,9 @@ import com.formdev.flatlaf.IntelliJTheme;
public class FlatGrayIJTheme
extends IntelliJTheme.ThemeLaf
{
public static boolean install( ) {
public static final String NAME = "Gray";
public static boolean install() {
try {
return install( new FlatGrayIJTheme() );
} catch( RuntimeException ex ) {
@@ -37,12 +39,16 @@ public class FlatGrayIJTheme
}
}
public static void installLafInfo() {
installLafInfo( NAME, FlatGrayIJTheme.class );
}
public FlatGrayIJTheme() {
super( Utils.loadTheme( "Gray.theme.json" ) );
}
@Override
public String getName() {
return "Gray";
return NAME;
}
}

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.formdev.flatlaf.intellijthemes;
//
// DO NOT MODIFY
// Generated with com.formdev.flatlaf.demo.intellijthemes.IJThemesClassGenerator
//
package com.formdev.flatlaf.intellijthemes;
import com.formdev.flatlaf.IntelliJTheme;
/**
@@ -29,7 +29,9 @@ import com.formdev.flatlaf.IntelliJTheme;
public class FlatGruvboxDarkHardIJTheme
extends IntelliJTheme.ThemeLaf
{
public static boolean install( ) {
public static final String NAME = "Gruvbox Dark Hard";
public static boolean install() {
try {
return install( new FlatGruvboxDarkHardIJTheme() );
} catch( RuntimeException ex ) {
@@ -37,12 +39,16 @@ public class FlatGruvboxDarkHardIJTheme
}
}
public static void installLafInfo() {
installLafInfo( NAME, FlatGruvboxDarkHardIJTheme.class );
}
public FlatGruvboxDarkHardIJTheme() {
super( Utils.loadTheme( "gruvbox_dark_hard.theme.json" ) );
}
@Override
public String getName() {
return "Gruvbox Dark Hard";
return NAME;
}
}

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.formdev.flatlaf.intellijthemes;
//
// DO NOT MODIFY
// Generated with com.formdev.flatlaf.demo.intellijthemes.IJThemesClassGenerator
//
package com.formdev.flatlaf.intellijthemes;
import com.formdev.flatlaf.IntelliJTheme;
/**
@@ -29,7 +29,9 @@ import com.formdev.flatlaf.IntelliJTheme;
public class FlatGruvboxDarkMediumIJTheme
extends IntelliJTheme.ThemeLaf
{
public static boolean install( ) {
public static final String NAME = "Gruvbox Dark Medium";
public static boolean install() {
try {
return install( new FlatGruvboxDarkMediumIJTheme() );
} catch( RuntimeException ex ) {
@@ -37,12 +39,16 @@ public class FlatGruvboxDarkMediumIJTheme
}
}
public static void installLafInfo() {
installLafInfo( NAME, FlatGruvboxDarkMediumIJTheme.class );
}
public FlatGruvboxDarkMediumIJTheme() {
super( Utils.loadTheme( "gruvbox_dark_medium.theme.json" ) );
}
@Override
public String getName() {
return "Gruvbox Dark Medium";
return NAME;
}
}

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.formdev.flatlaf.intellijthemes;
//
// DO NOT MODIFY
// Generated with com.formdev.flatlaf.demo.intellijthemes.IJThemesClassGenerator
//
package com.formdev.flatlaf.intellijthemes;
import com.formdev.flatlaf.IntelliJTheme;
/**
@@ -29,7 +29,9 @@ import com.formdev.flatlaf.IntelliJTheme;
public class FlatGruvboxDarkSoftIJTheme
extends IntelliJTheme.ThemeLaf
{
public static boolean install( ) {
public static final String NAME = "Gruvbox Dark Soft";
public static boolean install() {
try {
return install( new FlatGruvboxDarkSoftIJTheme() );
} catch( RuntimeException ex ) {
@@ -37,12 +39,16 @@ public class FlatGruvboxDarkSoftIJTheme
}
}
public static void installLafInfo() {
installLafInfo( NAME, FlatGruvboxDarkSoftIJTheme.class );
}
public FlatGruvboxDarkSoftIJTheme() {
super( Utils.loadTheme( "gruvbox_dark_soft.theme.json" ) );
}
@Override
public String getName() {
return "Gruvbox Dark Soft";
return NAME;
}
}

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.formdev.flatlaf.intellijthemes;
//
// DO NOT MODIFY
// Generated with com.formdev.flatlaf.demo.intellijthemes.IJThemesClassGenerator
//
package com.formdev.flatlaf.intellijthemes;
import com.formdev.flatlaf.IntelliJTheme;
/**
@@ -29,7 +29,9 @@ import com.formdev.flatlaf.IntelliJTheme;
public class FlatHiberbeeDarkIJTheme
extends IntelliJTheme.ThemeLaf
{
public static boolean install( ) {
public static final String NAME = "Hiberbee Dark";
public static boolean install() {
try {
return install( new FlatHiberbeeDarkIJTheme() );
} catch( RuntimeException ex ) {
@@ -37,12 +39,16 @@ public class FlatHiberbeeDarkIJTheme
}
}
public static void installLafInfo() {
installLafInfo( NAME, FlatHiberbeeDarkIJTheme.class );
}
public FlatHiberbeeDarkIJTheme() {
super( Utils.loadTheme( "HiberbeeDark.theme.json" ) );
}
@Override
public String getName() {
return "Hiberbee Dark";
return NAME;
}
}

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.formdev.flatlaf.intellijthemes;
//
// DO NOT MODIFY
// Generated with com.formdev.flatlaf.demo.intellijthemes.IJThemesClassGenerator
//
package com.formdev.flatlaf.intellijthemes;
import com.formdev.flatlaf.IntelliJTheme;
/**
@@ -29,7 +29,9 @@ import com.formdev.flatlaf.IntelliJTheme;
public class FlatHighContrastIJTheme
extends IntelliJTheme.ThemeLaf
{
public static boolean install( ) {
public static final String NAME = "High contrast";
public static boolean install() {
try {
return install( new FlatHighContrastIJTheme() );
} catch( RuntimeException ex ) {
@@ -37,12 +39,16 @@ public class FlatHighContrastIJTheme
}
}
public static void installLafInfo() {
installLafInfo( NAME, FlatHighContrastIJTheme.class );
}
public FlatHighContrastIJTheme() {
super( Utils.loadTheme( "HighContrast.theme.json" ) );
}
@Override
public String getName() {
return "High contrast";
return NAME;
}
}

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.formdev.flatlaf.intellijthemes;
//
// DO NOT MODIFY
// Generated with com.formdev.flatlaf.demo.intellijthemes.IJThemesClassGenerator
//
package com.formdev.flatlaf.intellijthemes;
import com.formdev.flatlaf.IntelliJTheme;
/**
@@ -29,7 +29,9 @@ import com.formdev.flatlaf.IntelliJTheme;
public class FlatLightFlatIJTheme
extends IntelliJTheme.ThemeLaf
{
public static boolean install( ) {
public static final String NAME = "Light Flat";
public static boolean install() {
try {
return install( new FlatLightFlatIJTheme() );
} catch( RuntimeException ex ) {
@@ -37,12 +39,16 @@ public class FlatLightFlatIJTheme
}
}
public static void installLafInfo() {
installLafInfo( NAME, FlatLightFlatIJTheme.class );
}
public FlatLightFlatIJTheme() {
super( Utils.loadTheme( "LightFlatTheme.theme.json" ) );
}
@Override
public String getName() {
return "Light Flat";
return NAME;
}
}

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.formdev.flatlaf.intellijthemes;
//
// DO NOT MODIFY
// Generated with com.formdev.flatlaf.demo.intellijthemes.IJThemesClassGenerator
//
package com.formdev.flatlaf.intellijthemes;
import com.formdev.flatlaf.IntelliJTheme;
/**
@@ -29,7 +29,9 @@ import com.formdev.flatlaf.IntelliJTheme;
public class FlatMaterialDesignDarkIJTheme
extends IntelliJTheme.ThemeLaf
{
public static boolean install( ) {
public static final String NAME = "Material Design Dark";
public static boolean install() {
try {
return install( new FlatMaterialDesignDarkIJTheme() );
} catch( RuntimeException ex ) {
@@ -37,12 +39,16 @@ public class FlatMaterialDesignDarkIJTheme
}
}
public static void installLafInfo() {
installLafInfo( NAME, FlatMaterialDesignDarkIJTheme.class );
}
public FlatMaterialDesignDarkIJTheme() {
super( Utils.loadTheme( "MaterialTheme.theme.json" ) );
}
@Override
public String getName() {
return "Material Design Dark";
return NAME;
}
}

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.formdev.flatlaf.intellijthemes;
//
// DO NOT MODIFY
// Generated with com.formdev.flatlaf.demo.intellijthemes.IJThemesClassGenerator
//
package com.formdev.flatlaf.intellijthemes;
import com.formdev.flatlaf.IntelliJTheme;
/**
@@ -29,7 +29,9 @@ import com.formdev.flatlaf.IntelliJTheme;
public class FlatMonocaiIJTheme
extends IntelliJTheme.ThemeLaf
{
public static boolean install( ) {
public static final String NAME = "Monocai";
public static boolean install() {
try {
return install( new FlatMonocaiIJTheme() );
} catch( RuntimeException ex ) {
@@ -37,12 +39,16 @@ public class FlatMonocaiIJTheme
}
}
public static void installLafInfo() {
installLafInfo( NAME, FlatMonocaiIJTheme.class );
}
public FlatMonocaiIJTheme() {
super( Utils.loadTheme( "Monocai.theme.json" ) );
}
@Override
public String getName() {
return "Monocai";
return NAME;
}
}

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.formdev.flatlaf.intellijthemes;
//
// DO NOT MODIFY
// Generated with com.formdev.flatlaf.demo.intellijthemes.IJThemesClassGenerator
//
package com.formdev.flatlaf.intellijthemes;
import com.formdev.flatlaf.IntelliJTheme;
/**
@@ -29,7 +29,9 @@ import com.formdev.flatlaf.IntelliJTheme;
public class FlatNordIJTheme
extends IntelliJTheme.ThemeLaf
{
public static boolean install( ) {
public static final String NAME = "Nord";
public static boolean install() {
try {
return install( new FlatNordIJTheme() );
} catch( RuntimeException ex ) {
@@ -37,12 +39,16 @@ public class FlatNordIJTheme
}
}
public static void installLafInfo() {
installLafInfo( NAME, FlatNordIJTheme.class );
}
public FlatNordIJTheme() {
super( Utils.loadTheme( "nord.theme.json" ) );
}
@Override
public String getName() {
return "Nord";
return NAME;
}
}

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.formdev.flatlaf.intellijthemes;
//
// DO NOT MODIFY
// Generated with com.formdev.flatlaf.demo.intellijthemes.IJThemesClassGenerator
//
package com.formdev.flatlaf.intellijthemes;
import com.formdev.flatlaf.IntelliJTheme;
/**
@@ -29,7 +29,9 @@ import com.formdev.flatlaf.IntelliJTheme;
public class FlatOneDarkIJTheme
extends IntelliJTheme.ThemeLaf
{
public static boolean install( ) {
public static final String NAME = "One Dark";
public static boolean install() {
try {
return install( new FlatOneDarkIJTheme() );
} catch( RuntimeException ex ) {
@@ -37,12 +39,16 @@ public class FlatOneDarkIJTheme
}
}
public static void installLafInfo() {
installLafInfo( NAME, FlatOneDarkIJTheme.class );
}
public FlatOneDarkIJTheme() {
super( Utils.loadTheme( "one_dark.theme.json" ) );
}
@Override
public String getName() {
return "One Dark";
return NAME;
}
}

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