mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-10 22:17:13 -06:00
SwingX: flatlaf-swingx subproject created; JXHyperlink support (#8)
This commit is contained in:
34
flatlaf-swingx/build.gradle.kts
Normal file
34
flatlaf-swingx/build.gradle.kts
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
version = rootProject.version
|
||||
|
||||
plugins {
|
||||
`java-library`
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation( project( ":flatlaf-core" ) )
|
||||
implementation( "org.swinglabs.swingx:swingx-all:1.6.5-1" )
|
||||
|
||||
testImplementation( "org.swinglabs.swingx:swingx-beaninfo:1.6.5-1" )
|
||||
testImplementation( "com.miglayout:miglayout-swing:5.2" )
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.swingx;
|
||||
|
||||
import java.io.InputStream;
|
||||
import com.formdev.flatlaf.FlatDefaultsAddon;
|
||||
|
||||
/**
|
||||
* SwingX addon for FlatLaf.
|
||||
*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
public class FlatSwingXDefaultsAddon
|
||||
extends FlatDefaultsAddon
|
||||
{
|
||||
/**
|
||||
* Finds SwingX addon .properties file for the given LaF class
|
||||
* in the same package as this class.
|
||||
*/
|
||||
@Override
|
||||
public InputStream getDefaults( Class<?> lafClass ) {
|
||||
Class<?> addonClass = this.getClass();
|
||||
String propertiesName = "/" + addonClass.getPackage().getName().replace( '.', '/' )
|
||||
+ '/' + lafClass.getSimpleName() + ".properties";
|
||||
return addonClass.getResourceAsStream( propertiesName );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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.swingx.ui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import javax.swing.AbstractButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import org.jdesktop.swingx.plaf.basic.BasicHyperlinkUI;
|
||||
import com.formdev.flatlaf.ui.FlatButtonUI;
|
||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||
import com.formdev.flatlaf.util.UIScale;
|
||||
|
||||
/**
|
||||
* Provides the Flat LaF UI delegate for {@link org.jdesktop.swingx.JXHyperlink}.
|
||||
*
|
||||
* @uiDefault Hyperlink.disabledText Color
|
||||
*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
public class FlatHyperlinkUI
|
||||
extends BasicHyperlinkUI
|
||||
{
|
||||
protected Color disabledText;
|
||||
|
||||
public static ComponentUI createUI( JComponent c ) {
|
||||
return new FlatHyperlinkUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void installDefaults( AbstractButton b ) {
|
||||
super.installDefaults( b );
|
||||
|
||||
disabledText = UIManager.getColor( "Hyperlink.disabledText" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void uninstallDefaults( AbstractButton b ) {
|
||||
super.uninstallDefaults( b );
|
||||
|
||||
disabledText = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint( Graphics g, JComponent c ) {
|
||||
FlatUIUtils.setRenderingHints( (Graphics2D) g );
|
||||
|
||||
super.paint( g, c );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintText( Graphics g, AbstractButton b, Rectangle textRect, String text ) {
|
||||
FlatButtonUI.paintText( g, b, textRect, text, b.isEnabled() ? b.getForeground() : disabledText );
|
||||
|
||||
if( b.getModel().isRollover() )
|
||||
paintUnderline( g, textRect );
|
||||
}
|
||||
|
||||
private void paintUnderline( Graphics g, Rectangle rect ) {
|
||||
int descent = g.getFontMetrics().getDescent();
|
||||
|
||||
((Graphics2D)g).fill( new Rectangle2D.Float(
|
||||
rect.x, (rect.y + rect.height) - descent + UIScale.scale( 1f ),
|
||||
rect.width, UIScale.scale( 1f ) ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
com.formdev.flatlaf.swingx.FlatSwingXDefaultsAddon
|
||||
@@ -0,0 +1,21 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
#---- Hyperlink ----
|
||||
|
||||
Hyperlink.linkColor=589df6
|
||||
Hyperlink.visitedColor=@@Hyperlink.linkColor
|
||||
Hyperlink.disabledText=@disabledText
|
||||
@@ -0,0 +1,19 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
#---- UI delegates ----
|
||||
|
||||
HyperlinkUI=com.formdev.flatlaf.swingx.ui.FlatHyperlinkUI
|
||||
@@ -0,0 +1,21 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
#---- Hyperlink ----
|
||||
|
||||
Hyperlink.linkColor=4a78c2
|
||||
Hyperlink.visitedColor=@@Hyperlink.linkColor
|
||||
Hyperlink.disabledText=@disabledText
|
||||
Reference in New Issue
Block a user