mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-13 07:17:13 -06:00
@@ -5,6 +5,7 @@ FlatLaf Change Log
|
|||||||
|
|
||||||
#### New features and improvements
|
#### New features and improvements
|
||||||
|
|
||||||
|
- Slider: New design and improved customizing. (PR #214)
|
||||||
- JIDE Common Layer: Support `RangeSlider`. (PR #209)
|
- JIDE Common Layer: Support `RangeSlider`. (PR #209)
|
||||||
- IntelliJ Themes:
|
- IntelliJ Themes:
|
||||||
- Added "Gradianto Nature Green" theme.
|
- Added "Gradianto Nature Green" theme.
|
||||||
|
|||||||
@@ -475,7 +475,9 @@ public class IntelliJTheme
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Rename UI default keys (key --> value). */
|
||||||
private static Map<String, String> uiKeyMapping = new HashMap<>();
|
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> uiKeyCopying = new HashMap<>();
|
||||||
private static Map<String, String> uiKeyInverseMapping = new HashMap<>();
|
private static Map<String, String> uiKeyInverseMapping = new HashMap<>();
|
||||||
private static Map<String, String> checkboxKeyMapping = new HashMap<>();
|
private static Map<String, String> checkboxKeyMapping = new HashMap<>();
|
||||||
@@ -529,6 +531,9 @@ public class IntelliJTheme
|
|||||||
|
|
||||||
// Slider
|
// Slider
|
||||||
uiKeyMapping.put( "Slider.trackWidth", "" ); // ignore (used in Material Theme UI Lite)
|
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
|
// TitlePane
|
||||||
uiKeyCopying.put( "TitlePane.inactiveBackground", "TitlePane.background" );
|
uiKeyCopying.put( "TitlePane.inactiveBackground", "TitlePane.background" );
|
||||||
|
|||||||
@@ -586,13 +586,17 @@ class UIDefaultsLoader
|
|||||||
case "darken": return parseColorHSLIncreaseDecrease( 2, false, params, resolver, reportError );
|
case "darken": return parseColorHSLIncreaseDecrease( 2, false, params, resolver, reportError );
|
||||||
case "saturate": return parseColorHSLIncreaseDecrease( 1, true, params, resolver, reportError );
|
case "saturate": return parseColorHSLIncreaseDecrease( 1, true, params, resolver, reportError );
|
||||||
case "desaturate": return parseColorHSLIncreaseDecrease( 1, false, 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 + "'" );
|
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%
|
* - red: an integer 0-255 or a percentage 0-100%
|
||||||
* - green: 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%
|
* - blue: an integer 0-255 or a percentage 0-100%
|
||||||
@@ -603,6 +607,8 @@ class UIDefaultsLoader
|
|||||||
{
|
{
|
||||||
if( hasAlpha && params.size() == 2 ) {
|
if( hasAlpha && params.size() == 2 ) {
|
||||||
// syntax rgba(color,alpha), which allows adding alpha to any color
|
// 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 );
|
String colorStr = params.get( 0 );
|
||||||
int alpha = parseInteger( params.get( 1 ), 0, 255, true );
|
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
|
* 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
|
* - color: a color (e.g. #f00) or a color function
|
||||||
* - amount: percentage 0-100%
|
* - amount: percentage 0-100%
|
||||||
* - options: [relative] [autoInverse] [noAutoInverse] [lazy] [derived]
|
* - 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
|
// parse base color
|
||||||
String resolvedColorStr = resolver.apply( colorStr );
|
String resolvedColorStr = resolver.apply( colorStr );
|
||||||
ColorUIResource baseColor = (ColorUIResource) parseColorOrFunction( resolvedColorStr, resolver, reportError );
|
ColorUIResource baseColor = (ColorUIResource) parseColorOrFunction( resolvedColorStr, resolver, reportError );
|
||||||
|
|||||||
@@ -18,17 +18,23 @@ package com.formdev.flatlaf.ui;
|
|||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
|
import java.awt.FontMetrics;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Graphics2D;
|
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.Path2D;
|
||||||
import java.awt.geom.RoundRectangle2D;
|
import java.awt.geom.RoundRectangle2D;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JSlider;
|
import javax.swing.JSlider;
|
||||||
import javax.swing.LookAndFeel;
|
import javax.swing.LookAndFeel;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.plaf.ComponentUI;
|
import javax.swing.plaf.ComponentUI;
|
||||||
import javax.swing.plaf.basic.BasicSliderUI;
|
import javax.swing.plaf.basic.BasicSliderUI;
|
||||||
|
import com.formdev.flatlaf.util.HiDPIUtils;
|
||||||
import com.formdev.flatlaf.util.UIScale;
|
import com.formdev.flatlaf.util.UIScale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -49,29 +55,44 @@ import com.formdev.flatlaf.util.UIScale;
|
|||||||
* <!-- FlatSliderUI -->
|
* <!-- FlatSliderUI -->
|
||||||
*
|
*
|
||||||
* @uiDefault Slider.trackWidth int
|
* @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.trackColor Color
|
||||||
* @uiDefault Slider.thumbColor 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.focusedColor Color optional; defaults to Component.focusColor
|
||||||
* @uiDefault Slider.hoverColor Color optional; defaults to Slider.focusedColor
|
* @uiDefault Slider.focusedThumbBorderColor Color optional; defaults to Component.focusedBorderColor
|
||||||
* @uiDefault Slider.disabledForeground Color used for track and thumb is disabled
|
* @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
|
* @author Karl Tauber
|
||||||
*/
|
*/
|
||||||
public class FlatSliderUI
|
public class FlatSliderUI
|
||||||
extends BasicSliderUI
|
extends BasicSliderUI
|
||||||
{
|
{
|
||||||
private int trackWidth;
|
protected int trackWidth;
|
||||||
private int thumbWidth;
|
protected Dimension thumbSize;
|
||||||
|
protected int focusWidth;
|
||||||
|
|
||||||
private Color trackColor;
|
protected Color trackValueColor;
|
||||||
private Color thumbColor;
|
protected Color trackColor;
|
||||||
private Color focusColor;
|
protected Color thumbColor;
|
||||||
private Color hoverColor;
|
protected Color thumbBorderColor;
|
||||||
private Color disabledForeground;
|
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;
|
protected boolean thumbHover;
|
||||||
private boolean hover;
|
protected boolean thumbPressed;
|
||||||
|
|
||||||
public static ComponentUI createUI( JComponent c ) {
|
public static ComponentUI createUI( JComponent c ) {
|
||||||
return new FlatSliderUI();
|
return new FlatSliderUI();
|
||||||
@@ -81,24 +102,6 @@ public class FlatSliderUI
|
|||||||
super( null );
|
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
|
@Override
|
||||||
protected void installDefaults( JSlider slider ) {
|
protected void installDefaults( JSlider slider ) {
|
||||||
super.installDefaults( slider );
|
super.installDefaults( slider );
|
||||||
@@ -106,24 +109,65 @@ public class FlatSliderUI
|
|||||||
LookAndFeel.installProperty( slider, "opaque", false );
|
LookAndFeel.installProperty( slider, "opaque", false );
|
||||||
|
|
||||||
trackWidth = UIManager.getInt( "Slider.trackWidth" );
|
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" );
|
trackColor = UIManager.getColor( "Slider.trackColor" );
|
||||||
thumbColor = UIManager.getColor( "Slider.thumbColor" );
|
thumbColor = UIManager.getColor( "Slider.thumbColor" );
|
||||||
focusColor = FlatUIUtils.getUIColor( "Slider.focusedColor", "Component.focusColor" );
|
thumbBorderColor = UIManager.getColor( "Slider.thumbBorderColor" );
|
||||||
hoverColor = FlatUIUtils.getUIColor( "Slider.hoverColor", focusColor );
|
focusBaseColor = UIManager.getColor( "Component.focusColor" );
|
||||||
disabledForeground = UIManager.getColor( "Slider.disabledForeground" );
|
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
|
@Override
|
||||||
protected void uninstallDefaults( JSlider slider ) {
|
protected void uninstallDefaults( JSlider slider ) {
|
||||||
super.uninstallDefaults( slider );
|
super.uninstallDefaults( slider );
|
||||||
|
|
||||||
|
trackValueColor = null;
|
||||||
trackColor = null;
|
trackColor = null;
|
||||||
thumbColor = null;
|
thumbColor = null;
|
||||||
focusColor = null;
|
thumbBorderColor = null;
|
||||||
hoverColor = null;
|
focusBaseColor = null;
|
||||||
disabledForeground = 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
|
@Override
|
||||||
@@ -153,13 +197,35 @@ public class FlatSliderUI
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Dimension getThumbSize() {
|
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
|
@Override
|
||||||
public void paint( Graphics g, JComponent c ) {
|
public void paint( Graphics g, JComponent c ) {
|
||||||
FlatUIUtils.setRenderingHints( (Graphics2D) g );
|
FlatUIUtils.setRenderingHints( (Graphics2D) 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 );
|
||||||
|
debug*/
|
||||||
|
|
||||||
super.paint( g, c );
|
super.paint( g, c );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,50 +267,248 @@ public class FlatSliderUI
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( coloredTrack != null ) {
|
if( coloredTrack != null ) {
|
||||||
g.setColor( FlatUIUtils.deriveColor( FlatUIUtils.isPermanentFocusOwner( slider ) ? focusColor : (hover ? hoverColor : thumbColor), thumbColor ) );
|
g.setColor( trackValueColor );
|
||||||
((Graphics2D)g).fill( coloredTrack );
|
((Graphics2D)g).fill( coloredTrack );
|
||||||
}
|
}
|
||||||
|
|
||||||
g.setColor( enabled ? trackColor : disabledForeground );
|
g.setColor( enabled ? trackColor : disabledTrackColor );
|
||||||
((Graphics2D)g).fill( track );
|
((Graphics2D)g).fill( track );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paintThumb( Graphics g ) {
|
public void paintThumb( Graphics g ) {
|
||||||
g.setColor( FlatUIUtils.deriveColor( slider.isEnabled()
|
Color color = stateColor( slider, thumbHover, thumbPressed,
|
||||||
? (FlatUIUtils.isPermanentFocusOwner( slider ) ? focusColor : (hover ? hoverColor : thumbColor))
|
thumbColor, disabledThumbColor, null, hoverThumbColor, pressedThumbColor );
|
||||||
: disabledForeground,
|
color = FlatUIUtils.deriveColor( color, thumbColor );
|
||||||
thumbColor ) );
|
|
||||||
|
|
||||||
if( isRoundThumb() )
|
Color borderColor = (thumbBorderColor != null)
|
||||||
g.fillOval( thumbRect.x, thumbRect.y, thumbRect.width, thumbRect.height );
|
? stateColor( slider, false, false, thumbBorderColor, disabledThumbBorderColor, focusedThumbBorderColor, null, null )
|
||||||
else {
|
: null;
|
||||||
double w = thumbRect.width;
|
|
||||||
double h = thumbRect.height;
|
|
||||||
double wh = w / 2;
|
|
||||||
|
|
||||||
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();
|
Graphics2D g2 = (Graphics2D) g.create();
|
||||||
try {
|
try {
|
||||||
g2.translate( thumbRect.x, thumbRect.y );
|
g2.translate( x, y );
|
||||||
if( slider.getOrientation() == JSlider.VERTICAL ) {
|
if( slider.getOrientation() == JSlider.VERTICAL ) {
|
||||||
if( slider.getComponentOrientation().isLeftToRight() ) {
|
if( slider.getComponentOrientation().isLeftToRight() ) {
|
||||||
g2.translate( 0, thumbRect.height );
|
g2.translate( 0, height );
|
||||||
g2.rotate( Math.toRadians( 270 ) );
|
g2.rotate( Math.toRadians( 270 ) );
|
||||||
} else {
|
} else {
|
||||||
g2.translate( thumbRect.width, 0 );
|
g2.translate( width, 0 );
|
||||||
g2.rotate( Math.toRadians( 90 ) );
|
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 {
|
} finally {
|
||||||
g2.dispose();
|
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();
|
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 ) );
|
||||||
|
super.mousePressed( e );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseReleased( MouseEvent e ) {
|
||||||
|
setThumbPressed( false );
|
||||||
|
super.mouseReleased( e );
|
||||||
|
}
|
||||||
|
|
||||||
|
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() );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,11 +28,12 @@ public class ColorFunctions
|
|||||||
public static Color applyFunctions( Color color, ColorFunction... functions ) {
|
public static Color applyFunctions( Color color, ColorFunction... functions ) {
|
||||||
float[] hsl = HSLColor.fromRGB( color );
|
float[] hsl = HSLColor.fromRGB( color );
|
||||||
float alpha = color.getAlpha() / 255f;
|
float alpha = color.getAlpha() / 255f;
|
||||||
|
float[] hsla = { hsl[0], hsl[1], hsl[2], alpha * 100 };
|
||||||
|
|
||||||
for( ColorFunction function : functions )
|
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 ) {
|
public static float clamp( float value ) {
|
||||||
@@ -46,13 +47,13 @@ public class ColorFunctions
|
|||||||
//---- interface ColorFunction --------------------------------------------
|
//---- interface ColorFunction --------------------------------------------
|
||||||
|
|
||||||
public interface ColorFunction {
|
public interface ColorFunction {
|
||||||
void apply( float[] hsl );
|
void apply( float[] hsla );
|
||||||
}
|
}
|
||||||
|
|
||||||
//---- class HSLIncreaseDecrease ------------------------------------------
|
//---- 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.
|
* by an absolute or relative amount.
|
||||||
*/
|
*/
|
||||||
public static class HSLIncreaseDecrease
|
public static class HSLIncreaseDecrease
|
||||||
@@ -75,18 +76,45 @@ public class ColorFunctions
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply( float[] hsl ) {
|
public void apply( float[] hsla ) {
|
||||||
float amount2 = increase ? amount : -amount;
|
float amount2 = increase ? amount : -amount;
|
||||||
amount2 = autoInverse && shouldInverse( hsl ) ? -amount2 : amount2;
|
|
||||||
hsl[hslIndex] = clamp( relative
|
if( hslIndex == 0 ) {
|
||||||
? (hsl[hslIndex] * ((100 + amount2) / 100))
|
// hue is range 0-360
|
||||||
: (hsl[hslIndex] + amount2) );
|
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
|
return increase
|
||||||
? hsl[hslIndex] >= 50
|
? hsla[hslIndex] >= 50
|
||||||
: hsl[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 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -237,11 +237,15 @@ Separator.foreground=#515151
|
|||||||
|
|
||||||
#---- Slider ----
|
#---- Slider ----
|
||||||
|
|
||||||
|
Slider.trackValueColor=#4A88C7
|
||||||
Slider.trackColor=#646464
|
Slider.trackColor=#646464
|
||||||
Slider.thumbColor=#A6A6A6
|
Slider.thumbColor=$Slider.trackValueColor
|
||||||
Slider.tickColor=#888
|
Slider.tickColor=#888
|
||||||
Slider.hoverColor=darken($Slider.thumbColor,15%,derived)
|
Slider.focusedColor=fade($Component.focusColor,70%,derived)
|
||||||
Slider.disabledForeground=#4c5052
|
Slider.hoverThumbColor=darken($Slider.thumbColor,10%,derived)
|
||||||
|
Slider.pressedThumbColor=darken($Slider.thumbColor,15%,derived)
|
||||||
|
Slider.disabledTrackColor=#4c5052
|
||||||
|
Slider.disabledThumbColor=$Slider.disabledTrackColor
|
||||||
|
|
||||||
|
|
||||||
#---- SplitPane ----
|
#---- SplitPane ----
|
||||||
|
|||||||
@@ -506,8 +506,9 @@ Separator.stripeIndent=1
|
|||||||
#---- Slider ----
|
#---- Slider ----
|
||||||
|
|
||||||
Slider.focusInsets=0,0,0,0
|
Slider.focusInsets=0,0,0,0
|
||||||
Slider.trackWidth=3
|
Slider.trackWidth=2
|
||||||
Slider.thumbWidth=11
|
Slider.thumbSize=12,12
|
||||||
|
Slider.focusWidth=4
|
||||||
|
|
||||||
|
|
||||||
#---- Spinner ----
|
#---- Spinner ----
|
||||||
@@ -681,7 +682,7 @@ TitlePane.foreground=@foreground
|
|||||||
TitlePane.inactiveForeground=@disabledText
|
TitlePane.inactiveForeground=@disabledText
|
||||||
|
|
||||||
TitlePane.closeHoverBackground=#e81123
|
TitlePane.closeHoverBackground=#e81123
|
||||||
TitlePane.closePressedBackground=rgba($TitlePane.closeHoverBackground,60%)
|
TitlePane.closePressedBackground=fade($TitlePane.closeHoverBackground,60%)
|
||||||
TitlePane.closeHoverForeground=#fff
|
TitlePane.closeHoverForeground=#fff
|
||||||
TitlePane.closePressedForeground=#fff
|
TitlePane.closePressedForeground=#fff
|
||||||
|
|
||||||
|
|||||||
@@ -249,11 +249,15 @@ Separator.foreground=#d1d1d1
|
|||||||
|
|
||||||
#---- Slider ----
|
#---- Slider ----
|
||||||
|
|
||||||
|
Slider.trackValueColor=#1E82E6
|
||||||
Slider.trackColor=#c4c4c4
|
Slider.trackColor=#c4c4c4
|
||||||
Slider.thumbColor=#6e6e6e
|
Slider.thumbColor=$Slider.trackValueColor
|
||||||
Slider.tickColor=#888
|
Slider.tickColor=#888
|
||||||
Slider.hoverColor=lighten($Slider.thumbColor,15%,derived)
|
Slider.focusedColor=fade($Component.focusColor,50%,derived)
|
||||||
Slider.disabledForeground=#c0c0c0
|
Slider.hoverThumbColor=lighten($Slider.thumbColor,10%,derived)
|
||||||
|
Slider.pressedThumbColor=lighten($Slider.thumbColor,15%,derived)
|
||||||
|
Slider.disabledTrackColor=#c0c0c0
|
||||||
|
Slider.disabledThumbColor=$Slider.disabledTrackColor
|
||||||
|
|
||||||
|
|
||||||
#---- SplitPane ----
|
#---- SplitPane ----
|
||||||
|
|||||||
@@ -35,6 +35,11 @@ Button.default.hoverBorderColor=null
|
|||||||
HelpButton.hoverBorderColor=null
|
HelpButton.hoverBorderColor=null
|
||||||
|
|
||||||
|
|
||||||
|
#---- Slider ----
|
||||||
|
|
||||||
|
Slider.focusedColor=fade($Component.focusColor,40%,derived)
|
||||||
|
|
||||||
|
|
||||||
#---- ToggleButton ----
|
#---- ToggleButton ----
|
||||||
|
|
||||||
ToggleButton.startBackground=$ToggleButton.background
|
ToggleButton.startBackground=$ToggleButton.background
|
||||||
@@ -60,6 +65,8 @@ ToggleButton.endBackground=$ToggleButton.background
|
|||||||
[Cobalt_2]CheckBox.icon.background=#002946
|
[Cobalt_2]CheckBox.icon.background=#002946
|
||||||
[Cobalt_2]CheckBox.icon.checkmarkColor=#002946
|
[Cobalt_2]CheckBox.icon.checkmarkColor=#002946
|
||||||
|
|
||||||
|
[Dark_purple]Slider.focusedColor=fade($Component.focusColor,70%,derived)
|
||||||
|
|
||||||
[Dracula]ProgressBar.selectionBackground=#fff
|
[Dracula]ProgressBar.selectionBackground=#fff
|
||||||
[Dracula]ProgressBar.selectionForeground=#fff
|
[Dracula]ProgressBar.selectionForeground=#fff
|
||||||
|
|
||||||
@@ -81,6 +88,15 @@ ToggleButton.endBackground=$ToggleButton.background
|
|||||||
[High_contrast]ToggleButton.disabledSelectedBackground=#444
|
[High_contrast]ToggleButton.disabledSelectedBackground=#444
|
||||||
[High_contrast]ToggleButton.toolbar.selectedBackground=#fff
|
[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
|
# Material Theme UI Lite
|
||||||
|
|
||||||
|
|||||||
@@ -18,11 +18,11 @@ package com.formdev.flatlaf.jideoss.ui;
|
|||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
|
import java.awt.FontMetrics;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.geom.Path2D;
|
|
||||||
import java.awt.geom.RoundRectangle2D;
|
import java.awt.geom.RoundRectangle2D;
|
||||||
import java.util.Dictionary;
|
import java.util.Dictionary;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
@@ -31,6 +31,7 @@ import javax.swing.JSlider;
|
|||||||
import javax.swing.LookAndFeel;
|
import javax.swing.LookAndFeel;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.plaf.ComponentUI;
|
import javax.swing.plaf.ComponentUI;
|
||||||
|
import com.formdev.flatlaf.ui.FlatSliderUI;
|
||||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||||
import com.formdev.flatlaf.util.UIScale;
|
import com.formdev.flatlaf.util.UIScale;
|
||||||
import com.jidesoft.plaf.basic.BasicRangeSliderUI;
|
import com.jidesoft.plaf.basic.BasicRangeSliderUI;
|
||||||
@@ -41,16 +42,23 @@ import com.jidesoft.plaf.basic.BasicRangeSliderUI;
|
|||||||
public class FlatRangeSliderUI
|
public class FlatRangeSliderUI
|
||||||
extends BasicRangeSliderUI
|
extends BasicRangeSliderUI
|
||||||
{
|
{
|
||||||
private int trackWidth;
|
protected int trackWidth;
|
||||||
private int thumbWidth;
|
protected Dimension thumbSize;
|
||||||
|
protected int focusWidth;
|
||||||
|
|
||||||
private Color trackColor;
|
protected Color trackValueColor;
|
||||||
private Color thumbColor;
|
protected Color trackColor;
|
||||||
private Color focusColor;
|
protected Color thumbColor;
|
||||||
private Color hoverColor;
|
protected Color thumbBorderColor;
|
||||||
private Color disabledForeground;
|
protected Color focusedColor;
|
||||||
|
protected Color focusedThumbBorderColor;
|
||||||
private Rectangle firstThumbRect;
|
protected Color hoverTrackColor;
|
||||||
|
protected Color hoverThumbColor;
|
||||||
|
protected Color pressedTrackColor;
|
||||||
|
protected Color pressedThumbColor;
|
||||||
|
protected Color disabledTrackColor;
|
||||||
|
protected Color disabledThumbColor;
|
||||||
|
protected Color disabledThumbBorderColor;
|
||||||
|
|
||||||
public static ComponentUI createUI( JComponent c ) {
|
public static ComponentUI createUI( JComponent c ) {
|
||||||
return new FlatRangeSliderUI();
|
return new FlatRangeSliderUI();
|
||||||
@@ -97,24 +105,57 @@ public class FlatRangeSliderUI
|
|||||||
LookAndFeel.installProperty( slider, "opaque", false );
|
LookAndFeel.installProperty( slider, "opaque", false );
|
||||||
|
|
||||||
trackWidth = UIManager.getInt( "Slider.trackWidth" );
|
trackWidth = UIManager.getInt( "Slider.trackWidth" );
|
||||||
thumbWidth = UIManager.getInt( "Slider.thumbWidth" );
|
thumbSize = UIManager.getDimension( "Slider.thumbSize" );
|
||||||
|
focusWidth = FlatUIUtils.getUIInt( "Slider.focusWidth", 4 );
|
||||||
|
|
||||||
|
trackValueColor = FlatUIUtils.getUIColor( "Slider.trackValueColor", "Slider.thumbColor" );
|
||||||
trackColor = UIManager.getColor( "Slider.trackColor" );
|
trackColor = UIManager.getColor( "Slider.trackColor" );
|
||||||
thumbColor = UIManager.getColor( "Slider.thumbColor" );
|
thumbColor = UIManager.getColor( "Slider.thumbColor" );
|
||||||
focusColor = FlatUIUtils.getUIColor( "Slider.focusedColor", "Component.focusColor" );
|
thumbBorderColor = UIManager.getColor( "Slider.thumbBorderColor" );
|
||||||
hoverColor = FlatUIUtils.getUIColor( "Slider.hoverColor", focusColor );
|
focusedColor = FlatUIUtils.getUIColor( "Slider.focusedColor", "Component.focusColor" );
|
||||||
disabledForeground = UIManager.getColor( "Slider.disabledForeground" );
|
focusedThumbBorderColor = FlatUIUtils.getUIColor( "Slider.focusedThumbBorderColor", "Component.focusedBorderColor" );
|
||||||
|
hoverTrackColor = FlatUIUtils.getUIColor( "Slider.hoverTrackColor", "Slider.hoverThumbColor" );
|
||||||
|
hoverThumbColor = UIManager.getColor( "Slider.hoverThumbColor" );
|
||||||
|
pressedTrackColor = FlatUIUtils.getUIColor( "Slider.pressedTrackColor", "Slider.pressedThumbColor" );
|
||||||
|
pressedThumbColor = UIManager.getColor( "Slider.pressedThumbColor" );
|
||||||
|
disabledTrackColor = UIManager.getColor( "Slider.disabledTrackColor" );
|
||||||
|
disabledThumbColor = UIManager.getColor( "Slider.disabledThumbColor" );
|
||||||
|
disabledThumbBorderColor = FlatUIUtils.getUIColor( "Slider.disabledThumbBorderColor", "Component.disabledBorderColor" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void uninstallDefaults( JSlider slider ) {
|
protected void uninstallDefaults( JSlider slider ) {
|
||||||
super.uninstallDefaults( slider );
|
super.uninstallDefaults( slider );
|
||||||
|
|
||||||
|
trackValueColor = null;
|
||||||
trackColor = null;
|
trackColor = null;
|
||||||
thumbColor = null;
|
thumbColor = null;
|
||||||
focusColor = null;
|
thumbBorderColor = null;
|
||||||
hoverColor = null;
|
focusedColor = null;
|
||||||
disabledForeground = null;
|
focusedThumbBorderColor = null;
|
||||||
|
hoverTrackColor = null;
|
||||||
|
hoverThumbColor = null;
|
||||||
|
pressedTrackColor = null;
|
||||||
|
pressedThumbColor = null;
|
||||||
|
disabledTrackColor = null;
|
||||||
|
disabledThumbColor = null;
|
||||||
|
disabledThumbBorderColor = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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
|
@Override
|
||||||
@@ -144,30 +185,30 @@ public class FlatRangeSliderUI
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Dimension getThumbSize() {
|
protected Dimension getThumbSize() {
|
||||||
return new Dimension( UIScale.scale( thumbWidth ), UIScale.scale( thumbWidth ) );
|
return FlatSliderUI.calcThumbSize( slider, thumbSize, focusWidth );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paint( Graphics g, JComponent c ) {
|
public void paint( Graphics g, JComponent c ) {
|
||||||
FlatUIUtils.setRenderingHints( (Graphics2D) g );
|
FlatUIUtils.setRenderingHints( (Graphics2D) g );
|
||||||
|
|
||||||
second = false;
|
/*debug
|
||||||
super.paint( g, c );
|
g.setColor( Color.gray );
|
||||||
|
g.drawRect( 0, 0, c.getWidth() - 1, c.getHeight() - 1 );
|
||||||
Rectangle clip = g.getClipBounds();
|
g.setColor( Color.orange );
|
||||||
|
g.drawRect( focusRect.x, focusRect.y, focusRect.width - 1, focusRect.height - 1 );
|
||||||
firstThumbRect = new Rectangle( thumbRect );
|
g.setColor( Color.magenta );
|
||||||
|
g.drawRect( contentRect.x, contentRect.y, contentRect.width - 1, contentRect.height - 1 );
|
||||||
second = true;
|
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 );
|
||||||
Point p = adjustThumbForHighValue();
|
Point p = adjustThumbForHighValue();
|
||||||
|
g.drawRect( thumbRect.x, thumbRect.y, thumbRect.width - 1, thumbRect.height - 1 );
|
||||||
if( clip.intersects( thumbRect ) ) {
|
|
||||||
paintTrack( g );
|
|
||||||
paintThumb( g );
|
|
||||||
}
|
|
||||||
|
|
||||||
restoreThumbForLowValue( p );
|
restoreThumbForLowValue( p );
|
||||||
second = false;
|
debug*/
|
||||||
|
|
||||||
|
super.paint( g, c );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -181,89 +222,70 @@ public class FlatRangeSliderUI
|
|||||||
float tw = UIScale.scale( (float) trackWidth );
|
float tw = UIScale.scale( (float) trackWidth );
|
||||||
float arc = tw;
|
float arc = tw;
|
||||||
|
|
||||||
|
// get rectangle of second thumb
|
||||||
|
Point p = adjustThumbForHighValue();
|
||||||
|
Rectangle thumbRect2 = new Rectangle( thumbRect );
|
||||||
|
restoreThumbForLowValue( p );
|
||||||
|
|
||||||
RoundRectangle2D coloredTrack = null;
|
RoundRectangle2D coloredTrack = null;
|
||||||
RoundRectangle2D track;
|
RoundRectangle2D track;
|
||||||
if( slider.getOrientation() == JSlider.HORIZONTAL ) {
|
if( slider.getOrientation() == JSlider.HORIZONTAL ) {
|
||||||
float y = trackRect.y + (trackRect.height - tw) / 2f;
|
float y = trackRect.y + (trackRect.height - tw) / 2f;
|
||||||
if( enabled ) {
|
if( enabled ) {
|
||||||
if( slider.getComponentOrientation().isLeftToRight() ) {
|
Rectangle thumbRect1 = thumbRect;
|
||||||
int cw = thumbRect.x + (thumbRect.width / 2) - trackRect.x;
|
if( !slider.getComponentOrientation().isLeftToRight() ) {
|
||||||
if( second ) {
|
Rectangle temp = thumbRect1;
|
||||||
track = new RoundRectangle2D.Float( trackRect.x + cw, y, trackRect.width - cw, tw, arc, arc );
|
thumbRect1 = thumbRect2;
|
||||||
int firstCw = firstThumbRect.x + (firstThumbRect.width / 2) - trackRect.x;
|
thumbRect2 = temp;
|
||||||
coloredTrack = new RoundRectangle2D.Float( trackRect.x + firstCw, y, cw - firstCw, tw, arc, arc );
|
|
||||||
} else
|
|
||||||
track = new RoundRectangle2D.Float( trackRect.x, y, cw, tw, arc, arc );
|
|
||||||
} else {
|
|
||||||
int cw = trackRect.x + trackRect.width - thumbRect.x - (thumbRect.width / 2);
|
|
||||||
if( second ) {
|
|
||||||
int firstCw = trackRect.x + trackRect.width - firstThumbRect.x - (firstThumbRect.width / 2);
|
|
||||||
track = new RoundRectangle2D.Float( trackRect.x, y, trackRect.width - cw, tw, arc, arc );
|
|
||||||
coloredTrack = new RoundRectangle2D.Float( trackRect.x + trackRect.width - cw, y, cw - firstCw, tw, arc, arc );
|
|
||||||
} else
|
|
||||||
track = new RoundRectangle2D.Float( trackRect.x + trackRect.width - cw, y, cw, tw, arc, arc );
|
|
||||||
}
|
}
|
||||||
} else
|
|
||||||
track = new RoundRectangle2D.Float( trackRect.x, y, trackRect.width, tw, arc, arc );
|
int cx = thumbRect1.x + (thumbRect1.width / 2);
|
||||||
|
int cw = thumbRect2.x - thumbRect1.x;
|
||||||
|
coloredTrack = new RoundRectangle2D.Float( cx, y, cw, tw, arc, arc );
|
||||||
|
}
|
||||||
|
track = new RoundRectangle2D.Float( trackRect.x, y, trackRect.width, tw, arc, arc );
|
||||||
} else {
|
} else {
|
||||||
float x = trackRect.x + (trackRect.width - tw) / 2f;
|
float x = trackRect.x + (trackRect.width - tw) / 2f;
|
||||||
if( enabled ) {
|
if( enabled ) {
|
||||||
int ch = thumbRect.y + (thumbRect.height / 2) - trackRect.y;
|
int cy = thumbRect2.y + (thumbRect2.height / 2);
|
||||||
if( second ) {
|
int ch = thumbRect.y - thumbRect2.y;
|
||||||
int firstCh = firstThumbRect.y + (firstThumbRect.height / 2) - trackRect.y;
|
coloredTrack = new RoundRectangle2D.Float( x, cy, tw, ch, arc, arc );
|
||||||
track = new RoundRectangle2D.Float( x, trackRect.y, tw, ch, arc, arc );
|
}
|
||||||
coloredTrack = new RoundRectangle2D.Float( x, trackRect.y + ch, tw, firstCh - ch, arc, arc );
|
track = new RoundRectangle2D.Float( x, trackRect.y, tw, trackRect.height, arc, arc );
|
||||||
} else
|
|
||||||
track = new RoundRectangle2D.Float( x, trackRect.y + ch, tw, trackRect.height - ch, arc, arc );
|
|
||||||
} else
|
|
||||||
track = new RoundRectangle2D.Float( x, trackRect.y, tw, trackRect.height, arc, arc );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g.setColor( enabled ? trackColor : disabledTrackColor );
|
||||||
|
((Graphics2D)g).fill( track );
|
||||||
|
|
||||||
if( coloredTrack != null ) {
|
if( coloredTrack != null ) {
|
||||||
g.setColor( FlatUIUtils.deriveColor( FlatUIUtils.isPermanentFocusOwner( slider ) ? focusColor : (hover ? hoverColor : thumbColor), thumbColor ) );
|
boolean trackHover = hover && rollover1 && rollover2;
|
||||||
|
boolean trackPressed = pressed1 && pressed2;
|
||||||
|
|
||||||
|
Color color = FlatSliderUI.stateColor( slider, trackHover, trackPressed,
|
||||||
|
trackValueColor, null, null, hoverTrackColor, pressedTrackColor );
|
||||||
|
|
||||||
|
g.setColor( FlatUIUtils.deriveColor( color, trackValueColor ) );
|
||||||
((Graphics2D)g).fill( coloredTrack );
|
((Graphics2D)g).fill( coloredTrack );
|
||||||
}
|
}
|
||||||
|
|
||||||
g.setColor( enabled ? trackColor : disabledForeground );
|
|
||||||
((Graphics2D)g).fill( track );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paintThumb( Graphics g ) {
|
public void paintThumb( Graphics g ) {
|
||||||
g.setColor( FlatUIUtils.deriveColor( slider.isEnabled()
|
boolean thumbHover = hover && ((!second && rollover1) || (second && rollover2));
|
||||||
? (FlatUIUtils.isPermanentFocusOwner( slider ) ? focusColor : (hover ? hoverColor : thumbColor))
|
boolean thumbPressed = (!second && pressed1) || (second && pressed2);
|
||||||
: disabledForeground,
|
|
||||||
thumbColor ) );
|
|
||||||
|
|
||||||
if( isRoundThumb() )
|
Color color = FlatSliderUI.stateColor( slider, thumbHover, thumbPressed,
|
||||||
g.fillOval( thumbRect.x, thumbRect.y, thumbRect.width, thumbRect.height );
|
thumbColor, disabledThumbColor, null, hoverThumbColor, pressedThumbColor );
|
||||||
else {
|
color = FlatUIUtils.deriveColor( color, thumbColor );
|
||||||
double w = thumbRect.width;
|
|
||||||
double h = thumbRect.height;
|
|
||||||
double wh = w / 2;
|
|
||||||
|
|
||||||
Path2D thumb = FlatUIUtils.createPath( 0,0, w,0, w,(h - wh), wh,h, 0,(h - wh) );
|
Color borderColor = (thumbBorderColor != null)
|
||||||
|
? FlatSliderUI.stateColor( slider, false, false, thumbBorderColor, disabledThumbBorderColor, focusedThumbBorderColor, null, null )
|
||||||
|
: null;
|
||||||
|
|
||||||
Graphics2D g2 = (Graphics2D) g.create();
|
FlatSliderUI.paintThumb( g, slider, thumbRect, isRoundThumb(), color, borderColor, focusedColor, focusWidth );
|
||||||
try {
|
|
||||||
g2.translate( thumbRect.x, thumbRect.y );
|
|
||||||
if( slider.getOrientation() == JSlider.VERTICAL ) {
|
|
||||||
if( slider.getComponentOrientation().isLeftToRight() ) {
|
|
||||||
g2.translate( 0, thumbRect.height );
|
|
||||||
g2.rotate( Math.toRadians( 270 ) );
|
|
||||||
} else {
|
|
||||||
g2.translate( thumbRect.width, 0 );
|
|
||||||
g2.rotate( Math.toRadians( 90 ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
g2.fill( thumb );
|
|
||||||
} finally {
|
|
||||||
g2.dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isRoundThumb() {
|
protected boolean isRoundThumb() {
|
||||||
return !slider.getPaintTicks() && !slider.getPaintLabels();
|
return !slider.getPaintTicks() && !slider.getPaintLabels();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -841,23 +841,28 @@ SeparatorUI com.formdev.flatlaf.ui.FlatSeparatorUI
|
|||||||
#---- Slider ----
|
#---- Slider ----
|
||||||
|
|
||||||
Slider.background #3c3f41 javax.swing.plaf.ColorUIResource [UI]
|
Slider.background #3c3f41 javax.swing.plaf.ColorUIResource [UI]
|
||||||
Slider.disabledForeground #4c5052 javax.swing.plaf.ColorUIResource [UI]
|
Slider.disabledThumbColor #4c5052 javax.swing.plaf.ColorUIResource [UI]
|
||||||
|
Slider.disabledTrackColor #4c5052 javax.swing.plaf.ColorUIResource [UI]
|
||||||
Slider.focus #7e7e7e javax.swing.plaf.ColorUIResource [UI]
|
Slider.focus #7e7e7e javax.swing.plaf.ColorUIResource [UI]
|
||||||
Slider.focusInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI]
|
Slider.focusInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI]
|
||||||
|
Slider.focusWidth 4
|
||||||
|
Slider.focusedColor #b33d6185 com.formdev.flatlaf.util.DerivedColor [UI] fade(70%)
|
||||||
Slider.font [active] $defaultFont [UI]
|
Slider.font [active] $defaultFont [UI]
|
||||||
Slider.foreground #bbbbbb javax.swing.plaf.ColorUIResource [UI]
|
Slider.foreground #bbbbbb javax.swing.plaf.ColorUIResource [UI]
|
||||||
Slider.highlight #242424 javax.swing.plaf.ColorUIResource [UI]
|
Slider.highlight #242424 javax.swing.plaf.ColorUIResource [UI]
|
||||||
Slider.horizontalSize 200,21 java.awt.Dimension
|
Slider.horizontalSize 200,21 java.awt.Dimension
|
||||||
Slider.hoverColor #808080 com.formdev.flatlaf.util.DerivedColor [UI] darken(15% autoInverse)
|
Slider.hoverThumbColor #346faa com.formdev.flatlaf.util.DerivedColor [UI] darken(10% autoInverse)
|
||||||
Slider.minimumHorizontalSize 36,21 java.awt.Dimension
|
Slider.minimumHorizontalSize 36,21 java.awt.Dimension
|
||||||
Slider.minimumVerticalSize 21,36 java.awt.Dimension
|
Slider.minimumVerticalSize 21,36 java.awt.Dimension
|
||||||
Slider.onlyLeftMouseButtonDrag true
|
Slider.onlyLeftMouseButtonDrag true
|
||||||
|
Slider.pressedThumbColor #2e6296 com.formdev.flatlaf.util.DerivedColor [UI] darken(15% autoInverse)
|
||||||
Slider.shadow #646464 javax.swing.plaf.ColorUIResource [UI]
|
Slider.shadow #646464 javax.swing.plaf.ColorUIResource [UI]
|
||||||
Slider.thumbColor #a6a6a6 javax.swing.plaf.ColorUIResource [UI]
|
Slider.thumbColor #4a88c7 javax.swing.plaf.ColorUIResource [UI]
|
||||||
Slider.thumbWidth 11
|
Slider.thumbSize 12,12 javax.swing.plaf.DimensionUIResource [UI]
|
||||||
Slider.tickColor #888888 javax.swing.plaf.ColorUIResource [UI]
|
Slider.tickColor #888888 javax.swing.plaf.ColorUIResource [UI]
|
||||||
Slider.trackColor #646464 javax.swing.plaf.ColorUIResource [UI]
|
Slider.trackColor #646464 javax.swing.plaf.ColorUIResource [UI]
|
||||||
Slider.trackWidth 3
|
Slider.trackValueColor #4a88c7 javax.swing.plaf.ColorUIResource [UI]
|
||||||
|
Slider.trackWidth 2
|
||||||
Slider.verticalSize 21,200 java.awt.Dimension
|
Slider.verticalSize 21,200 java.awt.Dimension
|
||||||
SliderUI com.formdev.flatlaf.ui.FlatSliderUI
|
SliderUI com.formdev.flatlaf.ui.FlatSliderUI
|
||||||
|
|
||||||
|
|||||||
@@ -846,23 +846,28 @@ SeparatorUI com.formdev.flatlaf.ui.FlatSeparatorUI
|
|||||||
#---- Slider ----
|
#---- Slider ----
|
||||||
|
|
||||||
Slider.background #f2f2f2 javax.swing.plaf.ColorUIResource [UI]
|
Slider.background #f2f2f2 javax.swing.plaf.ColorUIResource [UI]
|
||||||
Slider.disabledForeground #c0c0c0 javax.swing.plaf.ColorUIResource [UI]
|
Slider.disabledThumbColor #c0c0c0 javax.swing.plaf.ColorUIResource [UI]
|
||||||
|
Slider.disabledTrackColor #c0c0c0 javax.swing.plaf.ColorUIResource [UI]
|
||||||
Slider.focus #9e9e9e javax.swing.plaf.ColorUIResource [UI]
|
Slider.focus #9e9e9e javax.swing.plaf.ColorUIResource [UI]
|
||||||
Slider.focusInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI]
|
Slider.focusInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI]
|
||||||
|
Slider.focusWidth 4
|
||||||
|
Slider.focusedColor #8097c3f3 com.formdev.flatlaf.util.DerivedColor [UI] fade(50%)
|
||||||
Slider.font [active] $defaultFont [UI]
|
Slider.font [active] $defaultFont [UI]
|
||||||
Slider.foreground #000000 javax.swing.plaf.ColorUIResource [UI]
|
Slider.foreground #000000 javax.swing.plaf.ColorUIResource [UI]
|
||||||
Slider.highlight #ffffff javax.swing.plaf.ColorUIResource [UI]
|
Slider.highlight #ffffff javax.swing.plaf.ColorUIResource [UI]
|
||||||
Slider.horizontalSize 200,21 java.awt.Dimension
|
Slider.horizontalSize 200,21 java.awt.Dimension
|
||||||
Slider.hoverColor #949494 com.formdev.flatlaf.util.DerivedColor [UI] lighten(15% autoInverse)
|
Slider.hoverThumbColor #1569bc com.formdev.flatlaf.util.DerivedColor [UI] lighten(10% autoInverse)
|
||||||
Slider.minimumHorizontalSize 36,21 java.awt.Dimension
|
Slider.minimumHorizontalSize 36,21 java.awt.Dimension
|
||||||
Slider.minimumVerticalSize 21,36 java.awt.Dimension
|
Slider.minimumVerticalSize 21,36 java.awt.Dimension
|
||||||
Slider.onlyLeftMouseButtonDrag true
|
Slider.onlyLeftMouseButtonDrag true
|
||||||
|
Slider.pressedThumbColor #125ca5 com.formdev.flatlaf.util.DerivedColor [UI] lighten(15% autoInverse)
|
||||||
Slider.shadow #c4c4c4 javax.swing.plaf.ColorUIResource [UI]
|
Slider.shadow #c4c4c4 javax.swing.plaf.ColorUIResource [UI]
|
||||||
Slider.thumbColor #6e6e6e javax.swing.plaf.ColorUIResource [UI]
|
Slider.thumbColor #1e82e6 javax.swing.plaf.ColorUIResource [UI]
|
||||||
Slider.thumbWidth 11
|
Slider.thumbSize 12,12 javax.swing.plaf.DimensionUIResource [UI]
|
||||||
Slider.tickColor #888888 javax.swing.plaf.ColorUIResource [UI]
|
Slider.tickColor #888888 javax.swing.plaf.ColorUIResource [UI]
|
||||||
Slider.trackColor #c4c4c4 javax.swing.plaf.ColorUIResource [UI]
|
Slider.trackColor #c4c4c4 javax.swing.plaf.ColorUIResource [UI]
|
||||||
Slider.trackWidth 3
|
Slider.trackValueColor #1e82e6 javax.swing.plaf.ColorUIResource [UI]
|
||||||
|
Slider.trackWidth 2
|
||||||
Slider.verticalSize 21,200 java.awt.Dimension
|
Slider.verticalSize 21,200 java.awt.Dimension
|
||||||
SliderUI com.formdev.flatlaf.ui.FlatSliderUI
|
SliderUI com.formdev.flatlaf.ui.FlatSliderUI
|
||||||
|
|
||||||
|
|||||||
@@ -833,24 +833,30 @@ SeparatorUI com.formdev.flatlaf.ui.FlatSeparatorUI
|
|||||||
#---- Slider ----
|
#---- Slider ----
|
||||||
|
|
||||||
Slider.background #ccffcc javax.swing.plaf.ColorUIResource [UI]
|
Slider.background #ccffcc javax.swing.plaf.ColorUIResource [UI]
|
||||||
Slider.disabledForeground #000088 javax.swing.plaf.ColorUIResource [UI]
|
Slider.disabledThumbColor #888800 javax.swing.plaf.ColorUIResource [UI]
|
||||||
|
Slider.disabledTrackColor #ffff88 javax.swing.plaf.ColorUIResource [UI]
|
||||||
Slider.focus #696969 javax.swing.plaf.ColorUIResource [UI]
|
Slider.focus #696969 javax.swing.plaf.ColorUIResource [UI]
|
||||||
Slider.focusInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI]
|
Slider.focusInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI]
|
||||||
|
Slider.focusWidth 4
|
||||||
Slider.focusedColor #97c3f3 javax.swing.plaf.ColorUIResource [UI]
|
Slider.focusedColor #97c3f3 javax.swing.plaf.ColorUIResource [UI]
|
||||||
Slider.font [active] $defaultFont [UI]
|
Slider.font [active] $defaultFont [UI]
|
||||||
Slider.foreground #ff0000 javax.swing.plaf.ColorUIResource [UI]
|
Slider.foreground #ff0000 javax.swing.plaf.ColorUIResource [UI]
|
||||||
Slider.highlight #ffffff javax.swing.plaf.ColorUIResource [UI]
|
Slider.highlight #ffffff javax.swing.plaf.ColorUIResource [UI]
|
||||||
Slider.horizontalSize 200,21 java.awt.Dimension
|
Slider.horizontalSize 200,21 java.awt.Dimension
|
||||||
Slider.hoverColor #0000ff javax.swing.plaf.ColorUIResource [UI]
|
Slider.hoverThumbColor #0000ff javax.swing.plaf.ColorUIResource [UI]
|
||||||
|
Slider.hoverTrackColor #4444ff javax.swing.plaf.ColorUIResource [UI]
|
||||||
Slider.minimumHorizontalSize 36,21 java.awt.Dimension
|
Slider.minimumHorizontalSize 36,21 java.awt.Dimension
|
||||||
Slider.minimumVerticalSize 21,36 java.awt.Dimension
|
Slider.minimumVerticalSize 21,36 java.awt.Dimension
|
||||||
Slider.onlyLeftMouseButtonDrag true
|
Slider.onlyLeftMouseButtonDrag true
|
||||||
|
Slider.pressedThumbColor #00ff00 javax.swing.plaf.ColorUIResource [UI]
|
||||||
|
Slider.pressedTrackColor #88ff88 javax.swing.plaf.ColorUIResource [UI]
|
||||||
Slider.shadow #a0a0a0 javax.swing.plaf.ColorUIResource [UI]
|
Slider.shadow #a0a0a0 javax.swing.plaf.ColorUIResource [UI]
|
||||||
Slider.thumbColor #880000 javax.swing.plaf.ColorUIResource [UI]
|
Slider.thumbBorderColor #ff0000 javax.swing.plaf.ColorUIResource [UI]
|
||||||
Slider.thumbWidth 11
|
Slider.thumbColor #ffaaaa javax.swing.plaf.ColorUIResource [UI]
|
||||||
|
Slider.thumbSize 12,12 javax.swing.plaf.DimensionUIResource [UI]
|
||||||
Slider.tickColor #ff0000 javax.swing.plaf.ColorUIResource [UI]
|
Slider.tickColor #ff0000 javax.swing.plaf.ColorUIResource [UI]
|
||||||
Slider.trackColor #00bb00 javax.swing.plaf.ColorUIResource [UI]
|
Slider.trackColor #88ff88 javax.swing.plaf.ColorUIResource [UI]
|
||||||
Slider.trackWidth 3
|
Slider.trackWidth 2
|
||||||
Slider.verticalSize 21,200 java.awt.Dimension
|
Slider.verticalSize 21,200 java.awt.Dimension
|
||||||
SliderUI com.formdev.flatlaf.ui.FlatSliderUI
|
SliderUI com.formdev.flatlaf.ui.FlatSliderUI
|
||||||
|
|
||||||
|
|||||||
@@ -286,6 +286,7 @@ public class FlatComponentsTest
|
|||||||
JLabel sliderLabel = new JLabel();
|
JLabel sliderLabel = new JLabel();
|
||||||
JSlider slider1 = new JSlider();
|
JSlider slider1 = new JSlider();
|
||||||
JSlider slider6 = new JSlider();
|
JSlider slider6 = new JSlider();
|
||||||
|
JLabel sliderLabel2 = new JLabel();
|
||||||
slider3 = new JSlider();
|
slider3 = new JSlider();
|
||||||
JSlider slider5 = new JSlider();
|
JSlider slider5 = new JSlider();
|
||||||
JLabel progressBarLabel = new JLabel();
|
JLabel progressBarLabel = new JLabel();
|
||||||
@@ -1200,12 +1201,16 @@ public class FlatComponentsTest
|
|||||||
|
|
||||||
//---- slider1 ----
|
//---- slider1 ----
|
||||||
slider1.setValue(30);
|
slider1.setValue(30);
|
||||||
add(slider1, "cell 1 19 3 1,aligny top,grow 100 0");
|
add(slider1, "cell 1 19 3 1,growx");
|
||||||
|
|
||||||
//---- slider6 ----
|
//---- slider6 ----
|
||||||
slider6.setEnabled(false);
|
slider6.setEnabled(false);
|
||||||
slider6.setValue(30);
|
slider6.setValue(30);
|
||||||
add(slider6, "cell 1 19 3 1,aligny top,growy 0");
|
add(slider6, "cell 1 19 3 1");
|
||||||
|
|
||||||
|
//---- sliderLabel2 ----
|
||||||
|
sliderLabel2.setText("baseline");
|
||||||
|
add(sliderLabel2, "cell 0 20,alignx right,growx 0");
|
||||||
|
|
||||||
//---- slider3 ----
|
//---- slider3 ----
|
||||||
slider3.setMinorTickSpacing(10);
|
slider3.setMinorTickSpacing(10);
|
||||||
@@ -1214,7 +1219,7 @@ public class FlatComponentsTest
|
|||||||
slider3.setPaintLabels(true);
|
slider3.setPaintLabels(true);
|
||||||
slider3.setValue(30);
|
slider3.setValue(30);
|
||||||
slider3.addChangeListener(e -> changeProgress());
|
slider3.addChangeListener(e -> changeProgress());
|
||||||
add(slider3, "cell 1 20 3 1,aligny top,grow 100 0");
|
add(slider3, "cell 1 20 3 1,growx");
|
||||||
|
|
||||||
//---- slider5 ----
|
//---- slider5 ----
|
||||||
slider5.setMinorTickSpacing(10);
|
slider5.setMinorTickSpacing(10);
|
||||||
@@ -1223,7 +1228,7 @@ public class FlatComponentsTest
|
|||||||
slider5.setPaintLabels(true);
|
slider5.setPaintLabels(true);
|
||||||
slider5.setEnabled(false);
|
slider5.setEnabled(false);
|
||||||
slider5.setValue(30);
|
slider5.setValue(30);
|
||||||
add(slider5, "cell 1 20 3 1,aligny top,growy 0");
|
add(slider5, "cell 1 20 3 1");
|
||||||
|
|
||||||
//---- progressBarLabel ----
|
//---- progressBarLabel ----
|
||||||
progressBarLabel.setText("JProgressBar:");
|
progressBarLabel.setText("JProgressBar:");
|
||||||
|
|||||||
@@ -1141,14 +1141,20 @@ new FormModel {
|
|||||||
name: "slider1"
|
name: "slider1"
|
||||||
"value": 30
|
"value": 30
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 1 19 3 1,aligny top,grow 100 0"
|
"value": "cell 1 19 3 1,growx"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JSlider" ) {
|
add( new FormComponent( "javax.swing.JSlider" ) {
|
||||||
name: "slider6"
|
name: "slider6"
|
||||||
"enabled": false
|
"enabled": false
|
||||||
"value": 30
|
"value": 30
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 1 19 3 1,aligny top,growy 0"
|
"value": "cell 1 19 3 1"
|
||||||
|
} )
|
||||||
|
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||||
|
name: "sliderLabel2"
|
||||||
|
"text": "baseline"
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 0 20,alignx right,growx 0"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JSlider" ) {
|
add( new FormComponent( "javax.swing.JSlider" ) {
|
||||||
name: "slider3"
|
name: "slider3"
|
||||||
@@ -1162,7 +1168,7 @@ new FormModel {
|
|||||||
}
|
}
|
||||||
addEvent( new FormEvent( "javax.swing.event.ChangeListener", "stateChanged", "changeProgress", false ) )
|
addEvent( new FormEvent( "javax.swing.event.ChangeListener", "stateChanged", "changeProgress", false ) )
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 1 20 3 1,aligny top,grow 100 0"
|
"value": "cell 1 20 3 1,growx"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JSlider" ) {
|
add( new FormComponent( "javax.swing.JSlider" ) {
|
||||||
name: "slider5"
|
name: "slider5"
|
||||||
@@ -1173,7 +1179,7 @@ new FormModel {
|
|||||||
"enabled": false
|
"enabled": false
|
||||||
"value": 30
|
"value": 30
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 1 20 3 1,aligny top,growy 0"
|
"value": "cell 1 20 3 1"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||||
name: "progressBarLabel"
|
name: "progressBarLabel"
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* 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.testing.jideoss;
|
||||||
|
|
||||||
|
import com.formdev.flatlaf.FlatDefaultsAddon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JIDE Common Layer addon for FlatLaf for testing.
|
||||||
|
* <p>
|
||||||
|
* Finds JIDE Common Layer addon .properties file for the given LaF class
|
||||||
|
* in the same package as this class.
|
||||||
|
*
|
||||||
|
* @author Karl Tauber
|
||||||
|
*/
|
||||||
|
public class FlatJideOssDefaultsTestAddon
|
||||||
|
extends FlatDefaultsAddon
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -18,6 +18,7 @@ package com.formdev.flatlaf.testing.jideoss;
|
|||||||
|
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JSlider;
|
||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
@@ -50,13 +51,19 @@ public class FlatRangeSliderTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void paintLabels() {
|
private void paintLabels() {
|
||||||
horizontalRangeSlider.setPaintLabels( paintLabel.isSelected() );
|
boolean selected = paintLabel.isSelected();
|
||||||
verticalRangeSlider.setPaintLabels( paintLabel.isSelected() );
|
horizontalRangeSlider.setPaintLabels( selected );
|
||||||
|
verticalRangeSlider.setPaintLabels( selected );
|
||||||
|
horizontalSlider.setPaintLabels( selected );
|
||||||
|
verticalSlider.setPaintLabels( selected );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void paintTicks() {
|
private void paintTicks() {
|
||||||
horizontalRangeSlider.setPaintTicks( paintTick.isSelected() );
|
boolean selected = paintTick.isSelected();
|
||||||
verticalRangeSlider.setPaintTicks( paintTick.isSelected() );
|
horizontalRangeSlider.setPaintTicks( selected );
|
||||||
|
verticalRangeSlider.setPaintTicks( selected );
|
||||||
|
horizontalSlider.setPaintTicks( selected );
|
||||||
|
verticalSlider.setPaintTicks( selected );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
@@ -64,8 +71,14 @@ public class FlatRangeSliderTest
|
|||||||
JLabel tabbedPaneLabel = new JLabel();
|
JLabel tabbedPaneLabel = new JLabel();
|
||||||
JLabel horizontalLabel = new JLabel();
|
JLabel horizontalLabel = new JLabel();
|
||||||
horizontalRangeSlider = new RangeSlider();
|
horizontalRangeSlider = new RangeSlider();
|
||||||
|
horizontalSlider = new JSlider();
|
||||||
|
horizontalRangeSlider2 = new RangeSlider();
|
||||||
|
horizontalSlider2 = new JSlider();
|
||||||
JLabel verticalLabel = new JLabel();
|
JLabel verticalLabel = new JLabel();
|
||||||
verticalRangeSlider = new RangeSlider();
|
verticalRangeSlider = new RangeSlider();
|
||||||
|
verticalSlider = new JSlider();
|
||||||
|
verticalRangeSlider2 = new RangeSlider();
|
||||||
|
verticalSlider2 = new JSlider();
|
||||||
paintTick = new JCheckBox();
|
paintTick = new JCheckBox();
|
||||||
paintLabel = new JCheckBox();
|
paintLabel = new JCheckBox();
|
||||||
|
|
||||||
@@ -74,10 +87,13 @@ public class FlatRangeSliderTest
|
|||||||
"insets dialog,hidemode 3",
|
"insets dialog,hidemode 3",
|
||||||
// columns
|
// columns
|
||||||
"[left]" +
|
"[left]" +
|
||||||
"[fill]",
|
"[240,left]",
|
||||||
// rows
|
// rows
|
||||||
"[fill]" +
|
"[fill]" +
|
||||||
"[center]" +
|
"[center]" +
|
||||||
|
"[]" +
|
||||||
|
"[]" +
|
||||||
|
"[]" +
|
||||||
"[grow,fill]" +
|
"[grow,fill]" +
|
||||||
"[]"));
|
"[]"));
|
||||||
|
|
||||||
@@ -88,57 +104,92 @@ public class FlatRangeSliderTest
|
|||||||
//---- horizontalLabel ----
|
//---- horizontalLabel ----
|
||||||
horizontalLabel.setText("Horizontal");
|
horizontalLabel.setText("Horizontal");
|
||||||
add(horizontalLabel, "cell 0 1");
|
add(horizontalLabel, "cell 0 1");
|
||||||
add(horizontalRangeSlider, "cell 1 1");
|
|
||||||
|
//---- horizontalRangeSlider ----
|
||||||
|
horizontalRangeSlider.setLowValue(30);
|
||||||
|
horizontalRangeSlider.setHighValue(80);
|
||||||
|
horizontalRangeSlider.setMajorTickSpacing(10);
|
||||||
|
horizontalRangeSlider.setMinorTickSpacing(5);
|
||||||
|
horizontalRangeSlider.setPaintTicks(true);
|
||||||
|
horizontalRangeSlider.setPaintLabels(true);
|
||||||
|
add(horizontalRangeSlider, "cell 1 1,growx");
|
||||||
|
|
||||||
|
//---- horizontalSlider ----
|
||||||
|
horizontalSlider.setMinorTickSpacing(5);
|
||||||
|
horizontalSlider.setPaintTicks(true);
|
||||||
|
horizontalSlider.setMajorTickSpacing(10);
|
||||||
|
horizontalSlider.setPaintLabels(true);
|
||||||
|
horizontalSlider.setValue(30);
|
||||||
|
add(horizontalSlider, "cell 1 2,growx");
|
||||||
|
|
||||||
|
//---- horizontalRangeSlider2 ----
|
||||||
|
horizontalRangeSlider2.setLowValue(30);
|
||||||
|
horizontalRangeSlider2.setHighValue(80);
|
||||||
|
add(horizontalRangeSlider2, "cell 1 3,growx");
|
||||||
|
|
||||||
|
//---- horizontalSlider2 ----
|
||||||
|
horizontalSlider2.setValue(30);
|
||||||
|
add(horizontalSlider2, "cell 1 4,growx");
|
||||||
|
|
||||||
//---- verticalLabel ----
|
//---- verticalLabel ----
|
||||||
verticalLabel.setText("Vertical");
|
verticalLabel.setText("Vertical");
|
||||||
add(verticalLabel, "cell 0 2,aligny top,growy 0");
|
add(verticalLabel, "cell 0 5,aligny top,growy 0");
|
||||||
|
|
||||||
//---- verticalRangeSlider ----
|
//---- verticalRangeSlider ----
|
||||||
verticalRangeSlider.setOrientation(SwingConstants.VERTICAL);
|
verticalRangeSlider.setOrientation(SwingConstants.VERTICAL);
|
||||||
add(verticalRangeSlider, "cell 1 2,alignx left,growx 0");
|
verticalRangeSlider.setLowValue(30);
|
||||||
|
verticalRangeSlider.setHighValue(80);
|
||||||
|
verticalRangeSlider.setMajorTickSpacing(10);
|
||||||
|
verticalRangeSlider.setMinorTickSpacing(5);
|
||||||
|
verticalRangeSlider.setPaintTicks(true);
|
||||||
|
verticalRangeSlider.setPaintLabels(true);
|
||||||
|
add(verticalRangeSlider, "cell 1 5,alignx left,growx 0");
|
||||||
|
|
||||||
|
//---- verticalSlider ----
|
||||||
|
verticalSlider.setMinorTickSpacing(5);
|
||||||
|
verticalSlider.setPaintTicks(true);
|
||||||
|
verticalSlider.setMajorTickSpacing(10);
|
||||||
|
verticalSlider.setPaintLabels(true);
|
||||||
|
verticalSlider.setOrientation(SwingConstants.VERTICAL);
|
||||||
|
verticalSlider.setValue(30);
|
||||||
|
add(verticalSlider, "cell 1 5");
|
||||||
|
|
||||||
|
//---- verticalRangeSlider2 ----
|
||||||
|
verticalRangeSlider2.setOrientation(SwingConstants.VERTICAL);
|
||||||
|
verticalRangeSlider2.setLowValue(30);
|
||||||
|
verticalRangeSlider2.setHighValue(80);
|
||||||
|
add(verticalRangeSlider2, "cell 1 5");
|
||||||
|
|
||||||
|
//---- verticalSlider2 ----
|
||||||
|
verticalSlider2.setOrientation(SwingConstants.VERTICAL);
|
||||||
|
verticalSlider2.setValue(30);
|
||||||
|
add(verticalSlider2, "cell 1 5");
|
||||||
|
|
||||||
//---- paintTick ----
|
//---- paintTick ----
|
||||||
paintTick.setText("PaintTicks");
|
paintTick.setText("PaintTicks");
|
||||||
paintTick.setMnemonic('T');
|
paintTick.setMnemonic('T');
|
||||||
paintTick.setSelected(true);
|
paintTick.setSelected(true);
|
||||||
paintTick.addActionListener(e -> paintTicks());
|
paintTick.addActionListener(e -> paintTicks());
|
||||||
add(paintTick, "cell 0 3 2 1");
|
add(paintTick, "cell 0 6 2 1");
|
||||||
|
|
||||||
//---- paintLabel ----
|
//---- paintLabel ----
|
||||||
paintLabel.setText("PaintLabels");
|
paintLabel.setText("PaintLabels");
|
||||||
paintLabel.setMnemonic('L');
|
paintLabel.setMnemonic('L');
|
||||||
paintLabel.setSelected(true);
|
paintLabel.setSelected(true);
|
||||||
paintLabel.addActionListener(e -> paintLabels());
|
paintLabel.addActionListener(e -> paintLabels());
|
||||||
add(paintLabel, "cell 0 3 2 1");
|
add(paintLabel, "cell 0 6 2 1");
|
||||||
// JFormDesigner - End of component initialization //GEN-END:initComponents
|
// JFormDesigner - End of component initialization //GEN-END:initComponents
|
||||||
|
|
||||||
horizontalRangeSlider.setOrientation( SwingConstants.HORIZONTAL );
|
|
||||||
horizontalRangeSlider.setMinimum( 0 );
|
|
||||||
horizontalRangeSlider.setMaximum( 100 );
|
|
||||||
horizontalRangeSlider.setLowValue( 10 );
|
|
||||||
horizontalRangeSlider.setHighValue( 90 );
|
|
||||||
horizontalRangeSlider.setLabelTable( horizontalRangeSlider.createStandardLabels( 10 ) );
|
|
||||||
horizontalRangeSlider.setMinorTickSpacing( 5 );
|
|
||||||
horizontalRangeSlider.setMajorTickSpacing( 10 );
|
|
||||||
horizontalRangeSlider.setPaintTicks( true );
|
|
||||||
horizontalRangeSlider.setPaintLabels( true );
|
|
||||||
|
|
||||||
verticalRangeSlider.setOrientation( SwingConstants.VERTICAL );
|
|
||||||
verticalRangeSlider.setMinimum( 0 );
|
|
||||||
verticalRangeSlider.setMaximum( 100 );
|
|
||||||
verticalRangeSlider.setLowValue( 10 );
|
|
||||||
verticalRangeSlider.setHighValue( 90 );
|
|
||||||
verticalRangeSlider.setLabelTable( horizontalRangeSlider.createStandardLabels( 10 ) );
|
|
||||||
verticalRangeSlider.setMinorTickSpacing( 5 );
|
|
||||||
verticalRangeSlider.setMajorTickSpacing( 10 );
|
|
||||||
verticalRangeSlider.setPaintTicks( true );
|
|
||||||
verticalRangeSlider.setPaintLabels( true );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
|
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
|
||||||
private RangeSlider horizontalRangeSlider;
|
private RangeSlider horizontalRangeSlider;
|
||||||
|
private JSlider horizontalSlider;
|
||||||
|
private RangeSlider horizontalRangeSlider2;
|
||||||
|
private JSlider horizontalSlider2;
|
||||||
private RangeSlider verticalRangeSlider;
|
private RangeSlider verticalRangeSlider;
|
||||||
|
private JSlider verticalSlider;
|
||||||
|
private RangeSlider verticalRangeSlider2;
|
||||||
|
private JSlider verticalSlider2;
|
||||||
private JCheckBox paintTick;
|
private JCheckBox paintTick;
|
||||||
private JCheckBox paintLabel;
|
private JCheckBox paintLabel;
|
||||||
// JFormDesigner - End of variables declaration //GEN-END:variables
|
// JFormDesigner - End of variables declaration //GEN-END:variables
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ new FormModel {
|
|||||||
}
|
}
|
||||||
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||||
"$layoutConstraints": "insets dialog,hidemode 3"
|
"$layoutConstraints": "insets dialog,hidemode 3"
|
||||||
"$columnConstraints": "[left][fill]"
|
"$columnConstraints": "[left][240,left]"
|
||||||
"$rowConstraints": "[fill][center][grow,fill][]"
|
"$rowConstraints": "[fill][center][][][][grow,fill][]"
|
||||||
} ) {
|
} ) {
|
||||||
name: "this"
|
name: "this"
|
||||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||||
@@ -26,26 +26,105 @@ new FormModel {
|
|||||||
} )
|
} )
|
||||||
add( new FormComponent( "com.jidesoft.swing.RangeSlider" ) {
|
add( new FormComponent( "com.jidesoft.swing.RangeSlider" ) {
|
||||||
name: "horizontalRangeSlider"
|
name: "horizontalRangeSlider"
|
||||||
|
"lowValue": 30
|
||||||
|
"highValue": 80
|
||||||
|
"majorTickSpacing": 10
|
||||||
|
"minorTickSpacing": 5
|
||||||
|
"paintTicks": true
|
||||||
|
"paintLabels": true
|
||||||
auxiliary() {
|
auxiliary() {
|
||||||
"JavaCodeGenerator.variableLocal": false
|
"JavaCodeGenerator.variableLocal": false
|
||||||
}
|
}
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 1 1"
|
"value": "cell 1 1,growx"
|
||||||
|
} )
|
||||||
|
add( new FormComponent( "javax.swing.JSlider" ) {
|
||||||
|
name: "horizontalSlider"
|
||||||
|
"minorTickSpacing": 5
|
||||||
|
"paintTicks": true
|
||||||
|
"majorTickSpacing": 10
|
||||||
|
"paintLabels": true
|
||||||
|
"value": 30
|
||||||
|
auxiliary() {
|
||||||
|
"JavaCodeGenerator.variableLocal": false
|
||||||
|
}
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 1 2,growx"
|
||||||
|
} )
|
||||||
|
add( new FormComponent( "com.jidesoft.swing.RangeSlider" ) {
|
||||||
|
name: "horizontalRangeSlider2"
|
||||||
|
"lowValue": 30
|
||||||
|
"highValue": 80
|
||||||
|
auxiliary() {
|
||||||
|
"JavaCodeGenerator.variableLocal": false
|
||||||
|
}
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 1 3,growx"
|
||||||
|
} )
|
||||||
|
add( new FormComponent( "javax.swing.JSlider" ) {
|
||||||
|
name: "horizontalSlider2"
|
||||||
|
"value": 30
|
||||||
|
auxiliary() {
|
||||||
|
"JavaCodeGenerator.variableLocal": false
|
||||||
|
}
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 1 4,growx"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||||
name: "verticalLabel"
|
name: "verticalLabel"
|
||||||
"text": "Vertical"
|
"text": "Vertical"
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 0 2,aligny top,growy 0"
|
"value": "cell 0 5,aligny top,growy 0"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "com.jidesoft.swing.RangeSlider" ) {
|
add( new FormComponent( "com.jidesoft.swing.RangeSlider" ) {
|
||||||
name: "verticalRangeSlider"
|
name: "verticalRangeSlider"
|
||||||
"orientation": 1
|
"orientation": 1
|
||||||
|
"lowValue": 30
|
||||||
|
"highValue": 80
|
||||||
|
"majorTickSpacing": 10
|
||||||
|
"minorTickSpacing": 5
|
||||||
|
"paintTicks": true
|
||||||
|
"paintLabels": true
|
||||||
auxiliary() {
|
auxiliary() {
|
||||||
"JavaCodeGenerator.variableLocal": false
|
"JavaCodeGenerator.variableLocal": false
|
||||||
}
|
}
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 1 2,alignx left,growx 0"
|
"value": "cell 1 5,alignx left,growx 0"
|
||||||
|
} )
|
||||||
|
add( new FormComponent( "javax.swing.JSlider" ) {
|
||||||
|
name: "verticalSlider"
|
||||||
|
"minorTickSpacing": 5
|
||||||
|
"paintTicks": true
|
||||||
|
"majorTickSpacing": 10
|
||||||
|
"paintLabels": true
|
||||||
|
"orientation": 1
|
||||||
|
"value": 30
|
||||||
|
auxiliary() {
|
||||||
|
"JavaCodeGenerator.variableLocal": false
|
||||||
|
}
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 1 5"
|
||||||
|
} )
|
||||||
|
add( new FormComponent( "com.jidesoft.swing.RangeSlider" ) {
|
||||||
|
name: "verticalRangeSlider2"
|
||||||
|
"orientation": 1
|
||||||
|
"lowValue": 30
|
||||||
|
"highValue": 80
|
||||||
|
auxiliary() {
|
||||||
|
"JavaCodeGenerator.variableLocal": false
|
||||||
|
}
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 1 5"
|
||||||
|
} )
|
||||||
|
add( new FormComponent( "javax.swing.JSlider" ) {
|
||||||
|
name: "verticalSlider2"
|
||||||
|
"orientation": 1
|
||||||
|
"value": 30
|
||||||
|
auxiliary() {
|
||||||
|
"JavaCodeGenerator.variableLocal": false
|
||||||
|
}
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 1 5"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||||
name: "paintTick"
|
name: "paintTick"
|
||||||
@@ -57,7 +136,7 @@ new FormModel {
|
|||||||
}
|
}
|
||||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "paintTicks", false ) )
|
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "paintTicks", false ) )
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 0 3 2 1"
|
"value": "cell 0 6 2 1"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||||
name: "paintLabel"
|
name: "paintLabel"
|
||||||
@@ -69,7 +148,7 @@ new FormModel {
|
|||||||
}
|
}
|
||||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "paintLabels", false ) )
|
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "paintLabels", false ) )
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 0 3 2 1"
|
"value": "cell 0 6 2 1"
|
||||||
} )
|
} )
|
||||||
}, new FormLayoutConstraints( null ) {
|
}, new FormLayoutConstraints( null ) {
|
||||||
"location": new java.awt.Point( 0, 0 )
|
"location": new java.awt.Point( 0, 0 )
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ import com.formdev.flatlaf.intellijthemes.FlatAllIJThemes;
|
|||||||
import com.formdev.flatlaf.testing.FlatTestLaf;
|
import com.formdev.flatlaf.testing.FlatTestLaf;
|
||||||
import com.formdev.flatlaf.ui.FlatLineBorder;
|
import com.formdev.flatlaf.ui.FlatLineBorder;
|
||||||
import com.formdev.flatlaf.util.ColorFunctions.ColorFunction;
|
import com.formdev.flatlaf.util.ColorFunctions.ColorFunction;
|
||||||
|
import com.formdev.flatlaf.util.ColorFunctions.Fade;
|
||||||
import com.formdev.flatlaf.util.ColorFunctions.HSLIncreaseDecrease;
|
import com.formdev.flatlaf.util.ColorFunctions.HSLIncreaseDecrease;
|
||||||
import com.formdev.flatlaf.util.DerivedColor;
|
import com.formdev.flatlaf.util.DerivedColor;
|
||||||
import com.formdev.flatlaf.util.StringUtils;
|
import com.formdev.flatlaf.util.StringUtils;
|
||||||
@@ -399,13 +400,18 @@ public class UIDefaultsDump
|
|||||||
HSLIncreaseDecrease func = (HSLIncreaseDecrease) function;
|
HSLIncreaseDecrease func = (HSLIncreaseDecrease) function;
|
||||||
String name;
|
String name;
|
||||||
switch( func.hslIndex ) {
|
switch( func.hslIndex ) {
|
||||||
case 2: name = func.increase ? "lighten" : "darken"; break;
|
case 0: name = "spin"; break;
|
||||||
case 1: name = func.increase ? "saturate" : "desaturate"; break;
|
case 1: name = func.increase ? "saturate" : "desaturate"; break;
|
||||||
|
case 2: name = func.increase ? "lighten" : "darken"; break;
|
||||||
|
case 3: name = func.increase ? "fadein" : "fadeout"; break;
|
||||||
default: throw new IllegalArgumentException();
|
default: throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
out.printf( "%s(%.0f%%%s%s)", name, func.amount,
|
out.printf( "%s(%.0f%%%s%s)", name, func.amount,
|
||||||
(func.relative ? " relative" : ""),
|
(func.relative ? " relative" : ""),
|
||||||
(func.autoInverse ? " autoInverse" : "") );
|
(func.autoInverse ? " autoInverse" : "") );
|
||||||
|
} else if( function instanceof Fade ) {
|
||||||
|
Fade func = (Fade) function;
|
||||||
|
out.printf( "fade(%.0f%%)", func.amount );
|
||||||
} else
|
} else
|
||||||
throw new IllegalArgumentException( "unknown color function: " + function );
|
throw new IllegalArgumentException( "unknown color function: " + function );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
|
com.formdev.flatlaf.testing.jideoss.FlatJideOssDefaultsTestAddon
|
||||||
com.formdev.flatlaf.testing.swingx.FlatSwingXDefaultsTestAddon
|
com.formdev.flatlaf.testing.swingx.FlatSwingXDefaultsTestAddon
|
||||||
|
|||||||
@@ -257,12 +257,15 @@ Separator.stripeIndent=5
|
|||||||
|
|
||||||
#---- Slider ----
|
#---- Slider ----
|
||||||
|
|
||||||
Slider.trackColor=#0b0
|
Slider.trackColor=#8f8
|
||||||
Slider.thumbColor=#800
|
Slider.thumbColor=#faa
|
||||||
|
Slider.thumbBorderColor=#f00
|
||||||
Slider.tickColor=#f00
|
Slider.tickColor=#f00
|
||||||
Slider.focusedColor=$Component.focusColor
|
Slider.focusedColor=$Component.focusColor
|
||||||
Slider.hoverColor=#00f
|
Slider.hoverThumbColor=#00f
|
||||||
Slider.disabledForeground=#008
|
Slider.pressedThumbColor=#0f0
|
||||||
|
Slider.disabledTrackColor=#ff8
|
||||||
|
Slider.disabledThumbColor=#880
|
||||||
|
|
||||||
|
|
||||||
#---- SplitPane ----
|
#---- SplitPane ----
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
#---- RangeSlider ----
|
||||||
|
|
||||||
|
Slider.hoverTrackColor=#44f
|
||||||
|
Slider.pressedTrackColor=#8f8
|
||||||
@@ -336,8 +336,9 @@ class FlatCompletionProvider
|
|||||||
"lightness", "0-100%",
|
"lightness", "0-100%",
|
||||||
"alpha", "0-100%" );
|
"alpha", "0-100%" );
|
||||||
|
|
||||||
|
String colorParamDesc = "a color (e.g. #f00), a reference (e.g. $Other.key) or a color function";
|
||||||
String[] hslIncreaseDecreaseParams = {
|
String[] hslIncreaseDecreaseParams = {
|
||||||
"color", "a color (e.g. #f00), a reference (e.g. $Other.key) or a color function",
|
"color", colorParamDesc,
|
||||||
"amount", "0-100%",
|
"amount", "0-100%",
|
||||||
"options", "(optional) [relative] [autoInverse] [noAutoInverse] [lazy] [derived]"
|
"options", "(optional) [relative] [autoInverse] [noAutoInverse] [lazy] [derived]"
|
||||||
};
|
};
|
||||||
@@ -345,6 +346,17 @@ class FlatCompletionProvider
|
|||||||
addFunction( "darken", hslIncreaseDecreaseParams );
|
addFunction( "darken", hslIncreaseDecreaseParams );
|
||||||
addFunction( "saturate", hslIncreaseDecreaseParams );
|
addFunction( "saturate", hslIncreaseDecreaseParams );
|
||||||
addFunction( "desaturate", hslIncreaseDecreaseParams );
|
addFunction( "desaturate", hslIncreaseDecreaseParams );
|
||||||
|
addFunction( "fadein", hslIncreaseDecreaseParams );
|
||||||
|
addFunction( "fadeout", hslIncreaseDecreaseParams );
|
||||||
|
|
||||||
|
addFunction( "fade",
|
||||||
|
"color", colorParamDesc,
|
||||||
|
"amount", "0-100%",
|
||||||
|
"options", "(optional) [derived]" );
|
||||||
|
addFunction( "spin",
|
||||||
|
"color", colorParamDesc,
|
||||||
|
"angle", "number of degrees to rotate",
|
||||||
|
"options", "(optional) [derived]" );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addFunction( String name, String... paramNamesAndDescs ) {
|
private void addFunction( String name, String... paramNamesAndDescs ) {
|
||||||
|
|||||||
@@ -581,24 +581,29 @@ Separator.stripeIndent
|
|||||||
Separator.stripeWidth
|
Separator.stripeWidth
|
||||||
SeparatorUI
|
SeparatorUI
|
||||||
Slider.background
|
Slider.background
|
||||||
Slider.disabledForeground
|
Slider.disabledThumbColor
|
||||||
|
Slider.disabledTrackColor
|
||||||
Slider.focus
|
Slider.focus
|
||||||
Slider.focusInputMap
|
Slider.focusInputMap
|
||||||
Slider.focusInputMap.RightToLeft
|
Slider.focusInputMap.RightToLeft
|
||||||
Slider.focusInsets
|
Slider.focusInsets
|
||||||
|
Slider.focusWidth
|
||||||
|
Slider.focusedColor
|
||||||
Slider.font
|
Slider.font
|
||||||
Slider.foreground
|
Slider.foreground
|
||||||
Slider.highlight
|
Slider.highlight
|
||||||
Slider.horizontalSize
|
Slider.horizontalSize
|
||||||
Slider.hoverColor
|
Slider.hoverThumbColor
|
||||||
Slider.minimumHorizontalSize
|
Slider.minimumHorizontalSize
|
||||||
Slider.minimumVerticalSize
|
Slider.minimumVerticalSize
|
||||||
Slider.onlyLeftMouseButtonDrag
|
Slider.onlyLeftMouseButtonDrag
|
||||||
|
Slider.pressedThumbColor
|
||||||
Slider.shadow
|
Slider.shadow
|
||||||
Slider.thumbColor
|
Slider.thumbColor
|
||||||
Slider.thumbWidth
|
Slider.thumbSize
|
||||||
Slider.tickColor
|
Slider.tickColor
|
||||||
Slider.trackColor
|
Slider.trackColor
|
||||||
|
Slider.trackValueColor
|
||||||
Slider.trackWidth
|
Slider.trackWidth
|
||||||
Slider.verticalSize
|
Slider.verticalSize
|
||||||
SliderUI
|
SliderUI
|
||||||
|
|||||||
@@ -40,3 +40,12 @@ Prop.colorFunc5=lighten(#fe1289,20%)
|
|||||||
Prop.colorFunc6=darken(#fe1289,20%)
|
Prop.colorFunc6=darken(#fe1289,20%)
|
||||||
Prop.colorFunc7=lighten($Prop.colorFunc4,20%,relative autoInverse)
|
Prop.colorFunc7=lighten($Prop.colorFunc4,20%,relative autoInverse)
|
||||||
Prop.colorFunc8=lighten(Prop.colorFunc4,20%,lazy)
|
Prop.colorFunc8=lighten(Prop.colorFunc4,20%,lazy)
|
||||||
|
Prop.colorFunc9=fadein(#ff000000,30%)
|
||||||
|
Prop.colorFunc10=fadeout(#ff0000,40%)
|
||||||
|
Prop.colorFunc11=fade(#ff0000,50%)
|
||||||
|
|
||||||
|
Prop.colorFunc12=#f00
|
||||||
|
Prop.colorFunc13=spin($Prop.colorFunc12,40)
|
||||||
|
Prop.colorFunc14=spin($Prop.colorFunc12,-40)
|
||||||
|
Prop.colorFunc15=spin($Prop.colorFunc12,400)
|
||||||
|
Prop.colorFunc16=spin($Prop.colorFunc12,-400)
|
||||||
|
|||||||
Reference in New Issue
Block a user