mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-12 23:07:15 -06:00
@@ -5,6 +5,7 @@ FlatLaf Change Log
|
||||
|
||||
#### New features and improvements
|
||||
|
||||
- Slider: New design and improved customizing. (PR #214)
|
||||
- JIDE Common Layer: Support `RangeSlider`. (PR #209)
|
||||
- IntelliJ Themes:
|
||||
- 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<>();
|
||||
/** Copy UI default keys (value --> key). */
|
||||
private static Map<String, String> uiKeyCopying = new HashMap<>();
|
||||
private static Map<String, String> uiKeyInverseMapping = new HashMap<>();
|
||||
private static Map<String, String> checkboxKeyMapping = new HashMap<>();
|
||||
@@ -529,6 +531,9 @@ public class IntelliJTheme
|
||||
|
||||
// Slider
|
||||
uiKeyMapping.put( "Slider.trackWidth", "" ); // ignore (used in Material Theme UI Lite)
|
||||
uiKeyCopying.put( "Slider.trackValueColor", "ProgressBar.foreground" );
|
||||
uiKeyCopying.put( "Slider.thumbColor", "ProgressBar.foreground" );
|
||||
uiKeyCopying.put( "Slider.trackColor", "ProgressBar.background" );
|
||||
|
||||
// TitlePane
|
||||
uiKeyCopying.put( "TitlePane.inactiveBackground", "TitlePane.background" );
|
||||
|
||||
@@ -586,13 +586,17 @@ class UIDefaultsLoader
|
||||
case "darken": return parseColorHSLIncreaseDecrease( 2, false, params, resolver, reportError );
|
||||
case "saturate": return parseColorHSLIncreaseDecrease( 1, true, params, resolver, reportError );
|
||||
case "desaturate": return parseColorHSLIncreaseDecrease( 1, false, params, resolver, reportError );
|
||||
case "fadein": return parseColorHSLIncreaseDecrease( 3, true, params, resolver, reportError );
|
||||
case "fadeout": return parseColorHSLIncreaseDecrease( 3, false, params, resolver, reportError );
|
||||
case "fade": return parseColorFade( params, resolver, reportError );
|
||||
case "spin": return parseColorSpin( params, resolver, reportError );
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException( "unknown color function '" + value + "'" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Syntax: rgb(red,green,blue) or rgba(red,green,blue,alpha) or rgba(color,alpha)
|
||||
* Syntax: rgb(red,green,blue) or rgba(red,green,blue,alpha)
|
||||
* - red: an integer 0-255 or a percentage 0-100%
|
||||
* - green: an integer 0-255 or a percentage 0-100%
|
||||
* - blue: an integer 0-255 or a percentage 0-100%
|
||||
@@ -603,6 +607,8 @@ class UIDefaultsLoader
|
||||
{
|
||||
if( hasAlpha && params.size() == 2 ) {
|
||||
// syntax rgba(color,alpha), which allows adding alpha to any color
|
||||
// NOTE: this syntax is deprecated
|
||||
// use fade(color,alpha) instead
|
||||
String colorStr = params.get( 0 );
|
||||
int alpha = parseInteger( params.get( 1 ), 0, 255, true );
|
||||
|
||||
@@ -639,7 +645,8 @@ class UIDefaultsLoader
|
||||
|
||||
/**
|
||||
* Syntax: lighten(color,amount[,options]) or darken(color,amount[,options]) or
|
||||
* saturate(color,amount[,options]) or desaturate(color,amount[,options])
|
||||
* saturate(color,amount[,options]) or desaturate(color,amount[,options]) or
|
||||
* fadein(color,amount[,options]) or fadeout(color,amount[,options])
|
||||
* - color: a color (e.g. #f00) or a color function
|
||||
* - amount: percentage 0-100%
|
||||
* - options: [relative] [autoInverse] [noAutoInverse] [lazy] [derived]
|
||||
@@ -679,6 +686,59 @@ class UIDefaultsLoader
|
||||
};
|
||||
}
|
||||
|
||||
// parse base color, apply function and create derived color
|
||||
return parseFunctionBaseColor( colorStr, function, derived, resolver, reportError );
|
||||
}
|
||||
|
||||
/**
|
||||
* Syntax: fade(color,amount[,options])
|
||||
* - color: a color (e.g. #f00) or a color function
|
||||
* - amount: percentage 0-100%
|
||||
* - options: [derived]
|
||||
*/
|
||||
private static Object parseColorFade( List<String> params, Function<String, String> resolver, boolean reportError ) {
|
||||
String colorStr = params.get( 0 );
|
||||
int amount = parsePercentage( params.get( 1 ) );
|
||||
boolean derived = false;
|
||||
|
||||
if( params.size() > 2 ) {
|
||||
String options = params.get( 2 );
|
||||
derived = options.contains( "derived" );
|
||||
}
|
||||
|
||||
// create function
|
||||
ColorFunction function = new ColorFunctions.Fade( amount );
|
||||
|
||||
// parse base color, apply function and create derived color
|
||||
return parseFunctionBaseColor( colorStr, function, derived, resolver, reportError );
|
||||
}
|
||||
|
||||
/**
|
||||
* Syntax: spin(color,angle[,options])
|
||||
* - color: a color (e.g. #f00) or a color function
|
||||
* - angle: number of degrees to rotate
|
||||
* - options: [derived]
|
||||
*/
|
||||
private static Object parseColorSpin( List<String> params, Function<String, String> resolver, boolean reportError ) {
|
||||
String colorStr = params.get( 0 );
|
||||
int amount = parseInteger( params.get( 1 ), true );
|
||||
boolean derived = false;
|
||||
|
||||
if( params.size() > 2 ) {
|
||||
String options = params.get( 2 );
|
||||
derived = options.contains( "derived" );
|
||||
}
|
||||
|
||||
// create function
|
||||
ColorFunction function = new ColorFunctions.HSLIncreaseDecrease( 0, true, amount, false, false );
|
||||
|
||||
// parse base color, apply function and create derived color
|
||||
return parseFunctionBaseColor( colorStr, function, derived, resolver, reportError );
|
||||
}
|
||||
|
||||
private static Object parseFunctionBaseColor( String colorStr, ColorFunction function,
|
||||
boolean derived, Function<String, String> resolver, boolean reportError )
|
||||
{
|
||||
// parse base color
|
||||
String resolvedColorStr = resolver.apply( colorStr );
|
||||
ColorUIResource baseColor = (ColorUIResource) parseColorOrFunction( resolvedColorStr, resolver, reportError );
|
||||
|
||||
@@ -18,17 +18,23 @@ package com.formdev.flatlaf.ui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Shape;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import java.awt.geom.Path2D;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JSlider;
|
||||
import javax.swing.LookAndFeel;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.basic.BasicSliderUI;
|
||||
import com.formdev.flatlaf.util.HiDPIUtils;
|
||||
import com.formdev.flatlaf.util.UIScale;
|
||||
|
||||
/**
|
||||
@@ -49,29 +55,44 @@ import com.formdev.flatlaf.util.UIScale;
|
||||
* <!-- FlatSliderUI -->
|
||||
*
|
||||
* @uiDefault Slider.trackWidth int
|
||||
* @uiDefault Slider.thumbWidth int
|
||||
* @uiDefault Slider.thumbSize Dimension
|
||||
* @uiDefault Slider.focusWidth int
|
||||
* @uiDefault Slider.trackValueColor Color optional; defaults to Slider.thumbColor
|
||||
* @uiDefault Slider.trackColor Color
|
||||
* @uiDefault Slider.thumbColor Color
|
||||
* @uiDefault Slider.thumbBorderColor Color optional; if null, no border is painted
|
||||
* @uiDefault Slider.focusedColor Color optional; defaults to Component.focusColor
|
||||
* @uiDefault Slider.hoverColor Color optional; defaults to Slider.focusedColor
|
||||
* @uiDefault Slider.disabledForeground Color used for track and thumb is disabled
|
||||
* @uiDefault Slider.focusedThumbBorderColor Color optional; defaults to Component.focusedBorderColor
|
||||
* @uiDefault Slider.hoverThumbColor Color optional
|
||||
* @uiDefault Slider.pressedThumbColor Color optional
|
||||
* @uiDefault Slider.disabledTrackColor Color
|
||||
* @uiDefault Slider.disabledThumbColor Color
|
||||
* @uiDefault Slider.disabledThumbBorderColor Color optional; defaults to Component.disabledBorderColor
|
||||
*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
public class FlatSliderUI
|
||||
extends BasicSliderUI
|
||||
{
|
||||
private int trackWidth;
|
||||
private int thumbWidth;
|
||||
protected int trackWidth;
|
||||
protected Dimension thumbSize;
|
||||
protected int focusWidth;
|
||||
|
||||
private Color trackColor;
|
||||
private Color thumbColor;
|
||||
private Color focusColor;
|
||||
private Color hoverColor;
|
||||
private Color disabledForeground;
|
||||
protected Color trackValueColor;
|
||||
protected Color trackColor;
|
||||
protected Color thumbColor;
|
||||
protected Color thumbBorderColor;
|
||||
protected Color focusBaseColor;
|
||||
protected Color focusedColor;
|
||||
protected Color focusedThumbBorderColor;
|
||||
protected Color hoverThumbColor;
|
||||
protected Color pressedThumbColor;
|
||||
protected Color disabledTrackColor;
|
||||
protected Color disabledThumbColor;
|
||||
protected Color disabledThumbBorderColor;
|
||||
|
||||
private MouseListener hoverListener;
|
||||
private boolean hover;
|
||||
protected boolean thumbHover;
|
||||
protected boolean thumbPressed;
|
||||
|
||||
public static ComponentUI createUI( JComponent c ) {
|
||||
return new FlatSliderUI();
|
||||
@@ -81,24 +102,6 @@ public class FlatSliderUI
|
||||
super( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void installListeners( JSlider slider ) {
|
||||
super.installListeners( slider );
|
||||
|
||||
hoverListener = new FlatUIUtils.HoverListener( slider, h -> {
|
||||
hover = h;
|
||||
} );
|
||||
slider.addMouseListener( hoverListener );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void uninstallListeners( JSlider slider ) {
|
||||
super.uninstallListeners( slider );
|
||||
|
||||
slider.removeMouseListener( hoverListener );
|
||||
hoverListener = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void installDefaults( JSlider slider ) {
|
||||
super.installDefaults( slider );
|
||||
@@ -106,24 +109,65 @@ public class FlatSliderUI
|
||||
LookAndFeel.installProperty( slider, "opaque", false );
|
||||
|
||||
trackWidth = UIManager.getInt( "Slider.trackWidth" );
|
||||
thumbWidth = UIManager.getInt( "Slider.thumbWidth" );
|
||||
thumbSize = UIManager.getDimension( "Slider.thumbSize" );
|
||||
if( thumbSize == null ) {
|
||||
// fallback for compatibility with old versions
|
||||
int thumbWidth = UIManager.getInt( "Slider.thumbWidth" );
|
||||
thumbSize = new Dimension( thumbWidth, thumbWidth );
|
||||
}
|
||||
focusWidth = FlatUIUtils.getUIInt( "Slider.focusWidth", 4 );
|
||||
|
||||
trackValueColor = FlatUIUtils.getUIColor( "Slider.trackValueColor", "Slider.thumbColor" );
|
||||
trackColor = UIManager.getColor( "Slider.trackColor" );
|
||||
thumbColor = UIManager.getColor( "Slider.thumbColor" );
|
||||
focusColor = FlatUIUtils.getUIColor( "Slider.focusedColor", "Component.focusColor" );
|
||||
hoverColor = FlatUIUtils.getUIColor( "Slider.hoverColor", focusColor );
|
||||
disabledForeground = UIManager.getColor( "Slider.disabledForeground" );
|
||||
thumbBorderColor = UIManager.getColor( "Slider.thumbBorderColor" );
|
||||
focusBaseColor = UIManager.getColor( "Component.focusColor" );
|
||||
focusedColor = FlatUIUtils.getUIColor( "Slider.focusedColor", focusBaseColor );
|
||||
focusedThumbBorderColor = FlatUIUtils.getUIColor( "Slider.focusedThumbBorderColor", "Component.focusedBorderColor" );
|
||||
hoverThumbColor = UIManager.getColor( "Slider.hoverThumbColor" );
|
||||
pressedThumbColor = UIManager.getColor( "Slider.pressedThumbColor" );
|
||||
disabledTrackColor = UIManager.getColor( "Slider.disabledTrackColor" );
|
||||
disabledThumbColor = UIManager.getColor( "Slider.disabledThumbColor" );
|
||||
disabledThumbBorderColor = FlatUIUtils.getUIColor( "Slider.disabledThumbBorderColor", "Component.disabledBorderColor" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void uninstallDefaults( JSlider slider ) {
|
||||
super.uninstallDefaults( slider );
|
||||
|
||||
trackValueColor = null;
|
||||
trackColor = null;
|
||||
thumbColor = null;
|
||||
focusColor = null;
|
||||
hoverColor = null;
|
||||
disabledForeground = null;
|
||||
thumbBorderColor = null;
|
||||
focusBaseColor = null;
|
||||
focusedColor = null;
|
||||
focusedThumbBorderColor = null;
|
||||
hoverThumbColor = null;
|
||||
pressedThumbColor = null;
|
||||
disabledTrackColor = null;
|
||||
disabledThumbColor = null;
|
||||
disabledThumbBorderColor = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TrackListener createTrackListener( JSlider slider ) {
|
||||
return new FlatTrackListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBaseline( JComponent c, int width, int height ) {
|
||||
if( c == null )
|
||||
throw new NullPointerException();
|
||||
if( width < 0 || height < 0 )
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
// no baseline for vertical orientation
|
||||
if( slider.getOrientation() == JSlider.VERTICAL )
|
||||
return -1;
|
||||
|
||||
// compute a baseline so that the track is vertically centered
|
||||
FontMetrics fm = slider.getFontMetrics( slider.getFont() );
|
||||
return trackRect.y + Math.round( (trackRect.height - fm.getHeight()) / 2f ) + fm.getAscent() - 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -153,13 +197,35 @@ public class FlatSliderUI
|
||||
|
||||
@Override
|
||||
protected Dimension getThumbSize() {
|
||||
return new Dimension( UIScale.scale( thumbWidth ), UIScale.scale( thumbWidth ) );
|
||||
return calcThumbSize( slider, thumbSize, focusWidth );
|
||||
}
|
||||
|
||||
public static Dimension calcThumbSize( JSlider slider, Dimension thumbSize, int focusWidth ) {
|
||||
int fw = UIScale.scale( focusWidth );
|
||||
int w = UIScale.scale( thumbSize.width ) + fw + fw;
|
||||
int h = UIScale.scale( thumbSize.height ) + fw + fw;
|
||||
return (slider.getOrientation() == JSlider.HORIZONTAL)
|
||||
? new Dimension( w, h )
|
||||
: new Dimension( h, w );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint( Graphics g, JComponent c ) {
|
||||
FlatUIUtils.setRenderingHints( (Graphics2D) g );
|
||||
|
||||
/*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 );
|
||||
}
|
||||
|
||||
@@ -201,50 +267,248 @@ public class FlatSliderUI
|
||||
}
|
||||
|
||||
if( coloredTrack != null ) {
|
||||
g.setColor( FlatUIUtils.deriveColor( FlatUIUtils.isPermanentFocusOwner( slider ) ? focusColor : (hover ? hoverColor : thumbColor), thumbColor ) );
|
||||
g.setColor( trackValueColor );
|
||||
((Graphics2D)g).fill( coloredTrack );
|
||||
}
|
||||
|
||||
g.setColor( enabled ? trackColor : disabledForeground );
|
||||
g.setColor( enabled ? trackColor : disabledTrackColor );
|
||||
((Graphics2D)g).fill( track );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintThumb( Graphics g ) {
|
||||
g.setColor( FlatUIUtils.deriveColor( slider.isEnabled()
|
||||
? (FlatUIUtils.isPermanentFocusOwner( slider ) ? focusColor : (hover ? hoverColor : thumbColor))
|
||||
: disabledForeground,
|
||||
thumbColor ) );
|
||||
Color color = stateColor( slider, thumbHover, thumbPressed,
|
||||
thumbColor, disabledThumbColor, null, hoverThumbColor, pressedThumbColor );
|
||||
color = FlatUIUtils.deriveColor( color, thumbColor );
|
||||
|
||||
if( isRoundThumb() )
|
||||
g.fillOval( thumbRect.x, thumbRect.y, thumbRect.width, thumbRect.height );
|
||||
else {
|
||||
double w = thumbRect.width;
|
||||
double h = thumbRect.height;
|
||||
double wh = w / 2;
|
||||
Color borderColor = (thumbBorderColor != null)
|
||||
? stateColor( slider, false, false, thumbBorderColor, disabledThumbBorderColor, focusedThumbBorderColor, null, null )
|
||||
: null;
|
||||
|
||||
Path2D thumb = FlatUIUtils.createPath( 0,0, w,0, w,(h - wh), wh,h, 0,(h - wh) );
|
||||
Color focusedColor = FlatUIUtils.deriveColor( this.focusedColor, focusBaseColor );
|
||||
|
||||
paintThumb( g, slider, thumbRect, isRoundThumb(), color, borderColor, focusedColor, focusWidth );
|
||||
}
|
||||
|
||||
public static void paintThumb( Graphics g, JSlider slider, Rectangle thumbRect, boolean roundThumb,
|
||||
Color thumbColor, Color thumbBorderColor, Color focusedColor, int focusWidth )
|
||||
{
|
||||
double systemScaleFactor = UIScale.getSystemScaleFactor( (Graphics2D) g );
|
||||
if( systemScaleFactor != 1 && systemScaleFactor != 2 ) {
|
||||
// paint at scale 1x to avoid clipping on right and bottom edges at 125%, 150% or 175%
|
||||
HiDPIUtils.paintAtScale1x( (Graphics2D) g, thumbRect.x, thumbRect.y, thumbRect.width, thumbRect.height,
|
||||
(g2d, x2, y2, width2, height2, scaleFactor) -> {
|
||||
paintThumbImpl( g, slider, x2, y2, width2, height2,
|
||||
roundThumb, thumbColor, thumbBorderColor, focusedColor,
|
||||
(float) (focusWidth * scaleFactor) );
|
||||
} );
|
||||
return;
|
||||
}
|
||||
|
||||
paintThumbImpl( g, slider, thumbRect.x, thumbRect.y, thumbRect.width, thumbRect.height,
|
||||
roundThumb, thumbColor, thumbBorderColor, focusedColor, focusWidth );
|
||||
|
||||
}
|
||||
|
||||
private static void paintThumbImpl( Graphics g, JSlider slider, int x, int y, int width, int height,
|
||||
boolean roundThumb, Color thumbColor, Color thumbBorderColor, Color focusedColor, float focusWidth )
|
||||
{
|
||||
int fw = Math.round( UIScale.scale( focusWidth ) );
|
||||
int tx = x + fw;
|
||||
int ty = y + fw;
|
||||
int tw = width - fw - fw;
|
||||
int th = height - fw - fw;
|
||||
boolean focused = FlatUIUtils.isPermanentFocusOwner( slider );
|
||||
|
||||
if( roundThumb ) {
|
||||
// paint thumb focus border
|
||||
if( focused ) {
|
||||
g.setColor( focusedColor );
|
||||
((Graphics2D)g).fill( createRoundThumbShape( x, y, width, height ) );
|
||||
}
|
||||
|
||||
if( thumbBorderColor != null ) {
|
||||
// paint thumb border
|
||||
g.setColor( thumbBorderColor );
|
||||
((Graphics2D)g).fill( createRoundThumbShape( tx, ty, tw, th ) );
|
||||
|
||||
// paint thumb background
|
||||
float lw = UIScale.scale( 1f );
|
||||
g.setColor( thumbColor );
|
||||
((Graphics2D)g).fill( createRoundThumbShape( tx + lw, ty + lw,
|
||||
tw - lw - lw, th - lw - lw ) );
|
||||
} else {
|
||||
// paint thumb background
|
||||
g.setColor( thumbColor );
|
||||
((Graphics2D)g).fill( createRoundThumbShape( tx, ty, tw, th ) );
|
||||
}
|
||||
} else {
|
||||
Graphics2D g2 = (Graphics2D) g.create();
|
||||
try {
|
||||
g2.translate( thumbRect.x, thumbRect.y );
|
||||
g2.translate( x, y );
|
||||
if( slider.getOrientation() == JSlider.VERTICAL ) {
|
||||
if( slider.getComponentOrientation().isLeftToRight() ) {
|
||||
g2.translate( 0, thumbRect.height );
|
||||
g2.translate( 0, height );
|
||||
g2.rotate( Math.toRadians( 270 ) );
|
||||
} else {
|
||||
g2.translate( thumbRect.width, 0 );
|
||||
g2.translate( width, 0 );
|
||||
g2.rotate( Math.toRadians( 90 ) );
|
||||
}
|
||||
|
||||
// rotate thumb width/height
|
||||
int temp = tw;
|
||||
tw = th;
|
||||
th = temp;
|
||||
}
|
||||
|
||||
// paint thumb focus border
|
||||
if( focused ) {
|
||||
g2.setColor( focusedColor );
|
||||
g2.fill( createDirectionalThumbShape( 0, 0,
|
||||
tw + fw + fw, th + fw + fw + (fw * 0.4142f), fw ) );
|
||||
}
|
||||
|
||||
if( thumbBorderColor != null ) {
|
||||
// paint thumb border
|
||||
g2.setColor( thumbBorderColor );
|
||||
g2.fill( createDirectionalThumbShape( fw, fw, tw, th, 0 ) );
|
||||
|
||||
// paint thumb background
|
||||
float lw = UIScale.scale( 1f );
|
||||
g2.setColor( thumbColor );
|
||||
g2.fill( createDirectionalThumbShape( fw + lw, fw + lw,
|
||||
tw - lw - lw, th - lw - lw - (lw * 0.4142f), 0 ) );
|
||||
} else {
|
||||
// paint thumb background
|
||||
g2.setColor( thumbColor );
|
||||
g2.fill( createDirectionalThumbShape( fw, fw, tw, th, 0 ) );
|
||||
}
|
||||
g2.fill( thumb );
|
||||
} finally {
|
||||
g2.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isRoundThumb() {
|
||||
public static Shape createRoundThumbShape( float x, float y, float w, float h ) {
|
||||
if( w == h )
|
||||
return new Ellipse2D.Float( x, y, w, h );
|
||||
else {
|
||||
float arc = Math.min( w, h );
|
||||
return new RoundRectangle2D.Float( x, y, w, h, arc, arc );
|
||||
}
|
||||
}
|
||||
|
||||
public static Shape createDirectionalThumbShape( float x, float y, float w, float h, float arc ) {
|
||||
float wh = w / 2;
|
||||
|
||||
Path2D path = new Path2D.Float();
|
||||
path.moveTo( x + wh, y + h );
|
||||
path.lineTo( x, y + (h - wh) );
|
||||
path.lineTo( x, y + arc );
|
||||
path.quadTo( x, y, x + arc, y );
|
||||
path.lineTo( x + (w - arc), y );
|
||||
path.quadTo( x + w, y, x + w, y + arc );
|
||||
path.lineTo( x + w, y + (h - wh) );
|
||||
path.closePath();
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
public static Color stateColor( JSlider slider, boolean hover, boolean pressed,
|
||||
Color enabledColor, Color disabledColor, Color focusedColor, Color hoverColor, Color pressedColor )
|
||||
{
|
||||
if( disabledColor != null && !slider.isEnabled() )
|
||||
return disabledColor;
|
||||
if( pressedColor != null && pressed )
|
||||
return pressedColor;
|
||||
if( hoverColor != null && hover )
|
||||
return hoverColor;
|
||||
if( focusedColor != null && FlatUIUtils.isPermanentFocusOwner( slider ) )
|
||||
return focusedColor;
|
||||
return enabledColor;
|
||||
}
|
||||
|
||||
protected boolean isRoundThumb() {
|
||||
return !slider.getPaintTicks() && !slider.getPaintLabels();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setThumbLocation( int x, int y ) {
|
||||
if( !isRoundThumb() ) {
|
||||
// the needle of the directional thumb is painted outside of thumbRect
|
||||
// --> must increase repaint rectangle
|
||||
|
||||
// set new thumb location and compute union of old and new thumb bounds
|
||||
Rectangle r = new Rectangle( thumbRect );
|
||||
thumbRect.setLocation( x, y );
|
||||
SwingUtilities.computeUnion( thumbRect.x, thumbRect.y, thumbRect.width, thumbRect.height, r );
|
||||
|
||||
// increase union rectangle for repaint
|
||||
int extra = (int) Math.ceil( UIScale.scale( focusWidth ) * 0.4142f );
|
||||
if( slider.getOrientation() == JSlider.HORIZONTAL )
|
||||
r.height += extra;
|
||||
else {
|
||||
r.width += extra;
|
||||
if( !slider.getComponentOrientation().isLeftToRight() )
|
||||
r.x -= extra;
|
||||
}
|
||||
|
||||
slider.repaint( r );
|
||||
} else
|
||||
super.setThumbLocation( x, y );
|
||||
}
|
||||
|
||||
//---- class FlatTrackListener --------------------------------------------
|
||||
|
||||
protected class FlatTrackListener
|
||||
extends TrackListener
|
||||
{
|
||||
@Override
|
||||
public void mouseEntered( MouseEvent e ) {
|
||||
setThumbHover( isOverThumb( e ) );
|
||||
super.mouseEntered( e );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited( MouseEvent e ) {
|
||||
setThumbHover( false );
|
||||
super.mouseExited( e );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMoved( MouseEvent e ) {
|
||||
setThumbHover( isOverThumb( e ) );
|
||||
super.mouseMoved( e );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed( MouseEvent e ) {
|
||||
setThumbPressed( isOverThumb( e ) );
|
||||
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 ) {
|
||||
float[] hsl = HSLColor.fromRGB( color );
|
||||
float alpha = color.getAlpha() / 255f;
|
||||
float[] hsla = { hsl[0], hsl[1], hsl[2], alpha * 100 };
|
||||
|
||||
for( ColorFunction function : functions )
|
||||
function.apply( hsl );
|
||||
function.apply( hsla );
|
||||
|
||||
return HSLColor.toRGB( hsl, alpha );
|
||||
return HSLColor.toRGB( hsla[0], hsla[1], hsla[2], hsla[3] / 100 );
|
||||
}
|
||||
|
||||
public static float clamp( float value ) {
|
||||
@@ -46,13 +47,13 @@ public class ColorFunctions
|
||||
//---- interface ColorFunction --------------------------------------------
|
||||
|
||||
public interface ColorFunction {
|
||||
void apply( float[] hsl );
|
||||
void apply( float[] hsla );
|
||||
}
|
||||
|
||||
//---- class HSLIncreaseDecrease ------------------------------------------
|
||||
|
||||
/**
|
||||
* Increase or decrease hue, saturation or luminance of a color in the HSL color space
|
||||
* Increase or decrease hue, saturation, luminance or alpha of a color in the HSL color space
|
||||
* by an absolute or relative amount.
|
||||
*/
|
||||
public static class HSLIncreaseDecrease
|
||||
@@ -75,18 +76,45 @@ public class ColorFunctions
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply( float[] hsl ) {
|
||||
public void apply( float[] hsla ) {
|
||||
float amount2 = increase ? amount : -amount;
|
||||
amount2 = autoInverse && shouldInverse( hsl ) ? -amount2 : amount2;
|
||||
hsl[hslIndex] = clamp( relative
|
||||
? (hsl[hslIndex] * ((100 + amount2) / 100))
|
||||
: (hsl[hslIndex] + amount2) );
|
||||
|
||||
if( hslIndex == 0 ) {
|
||||
// hue is range 0-360
|
||||
hsla[0] = (hsla[0] + amount2) % 360;
|
||||
return;
|
||||
}
|
||||
|
||||
amount2 = autoInverse && shouldInverse( hsla ) ? -amount2 : amount2;
|
||||
hsla[hslIndex] = clamp( relative
|
||||
? (hsla[hslIndex] * ((100 + amount2) / 100))
|
||||
: (hsla[hslIndex] + amount2) );
|
||||
}
|
||||
|
||||
protected boolean shouldInverse( float[] hsl ) {
|
||||
protected boolean shouldInverse( float[] hsla ) {
|
||||
return increase
|
||||
? hsl[hslIndex] >= 50
|
||||
: hsl[hslIndex] < 50;
|
||||
? hsla[hslIndex] >= 50
|
||||
: hsla[hslIndex] < 50;
|
||||
}
|
||||
}
|
||||
|
||||
//---- class HSLIncreaseDecrease ------------------------------------------
|
||||
|
||||
/**
|
||||
* Set the alpha of a color.
|
||||
*/
|
||||
public static class Fade
|
||||
implements ColorFunction
|
||||
{
|
||||
public final float amount;
|
||||
|
||||
public Fade( float amount ) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply( float[] hsla ) {
|
||||
hsla[3] = clamp( amount );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,11 +237,15 @@ Separator.foreground=#515151
|
||||
|
||||
#---- Slider ----
|
||||
|
||||
Slider.trackValueColor=#4A88C7
|
||||
Slider.trackColor=#646464
|
||||
Slider.thumbColor=#A6A6A6
|
||||
Slider.thumbColor=$Slider.trackValueColor
|
||||
Slider.tickColor=#888
|
||||
Slider.hoverColor=darken($Slider.thumbColor,15%,derived)
|
||||
Slider.disabledForeground=#4c5052
|
||||
Slider.focusedColor=fade($Component.focusColor,70%,derived)
|
||||
Slider.hoverThumbColor=darken($Slider.thumbColor,10%,derived)
|
||||
Slider.pressedThumbColor=darken($Slider.thumbColor,15%,derived)
|
||||
Slider.disabledTrackColor=#4c5052
|
||||
Slider.disabledThumbColor=$Slider.disabledTrackColor
|
||||
|
||||
|
||||
#---- SplitPane ----
|
||||
|
||||
@@ -506,8 +506,9 @@ Separator.stripeIndent=1
|
||||
#---- Slider ----
|
||||
|
||||
Slider.focusInsets=0,0,0,0
|
||||
Slider.trackWidth=3
|
||||
Slider.thumbWidth=11
|
||||
Slider.trackWidth=2
|
||||
Slider.thumbSize=12,12
|
||||
Slider.focusWidth=4
|
||||
|
||||
|
||||
#---- Spinner ----
|
||||
@@ -681,7 +682,7 @@ TitlePane.foreground=@foreground
|
||||
TitlePane.inactiveForeground=@disabledText
|
||||
|
||||
TitlePane.closeHoverBackground=#e81123
|
||||
TitlePane.closePressedBackground=rgba($TitlePane.closeHoverBackground,60%)
|
||||
TitlePane.closePressedBackground=fade($TitlePane.closeHoverBackground,60%)
|
||||
TitlePane.closeHoverForeground=#fff
|
||||
TitlePane.closePressedForeground=#fff
|
||||
|
||||
|
||||
@@ -249,11 +249,15 @@ Separator.foreground=#d1d1d1
|
||||
|
||||
#---- Slider ----
|
||||
|
||||
Slider.trackValueColor=#1E82E6
|
||||
Slider.trackColor=#c4c4c4
|
||||
Slider.thumbColor=#6e6e6e
|
||||
Slider.thumbColor=$Slider.trackValueColor
|
||||
Slider.tickColor=#888
|
||||
Slider.hoverColor=lighten($Slider.thumbColor,15%,derived)
|
||||
Slider.disabledForeground=#c0c0c0
|
||||
Slider.focusedColor=fade($Component.focusColor,50%,derived)
|
||||
Slider.hoverThumbColor=lighten($Slider.thumbColor,10%,derived)
|
||||
Slider.pressedThumbColor=lighten($Slider.thumbColor,15%,derived)
|
||||
Slider.disabledTrackColor=#c0c0c0
|
||||
Slider.disabledThumbColor=$Slider.disabledTrackColor
|
||||
|
||||
|
||||
#---- SplitPane ----
|
||||
|
||||
@@ -35,6 +35,11 @@ Button.default.hoverBorderColor=null
|
||||
HelpButton.hoverBorderColor=null
|
||||
|
||||
|
||||
#---- Slider ----
|
||||
|
||||
Slider.focusedColor=fade($Component.focusColor,40%,derived)
|
||||
|
||||
|
||||
#---- ToggleButton ----
|
||||
|
||||
ToggleButton.startBackground=$ToggleButton.background
|
||||
@@ -60,6 +65,8 @@ ToggleButton.endBackground=$ToggleButton.background
|
||||
[Cobalt_2]CheckBox.icon.background=#002946
|
||||
[Cobalt_2]CheckBox.icon.checkmarkColor=#002946
|
||||
|
||||
[Dark_purple]Slider.focusedColor=fade($Component.focusColor,70%,derived)
|
||||
|
||||
[Dracula]ProgressBar.selectionBackground=#fff
|
||||
[Dracula]ProgressBar.selectionForeground=#fff
|
||||
|
||||
@@ -81,6 +88,15 @@ ToggleButton.endBackground=$ToggleButton.background
|
||||
[High_contrast]ToggleButton.disabledSelectedBackground=#444
|
||||
[High_contrast]ToggleButton.toolbar.selectedBackground=#fff
|
||||
|
||||
[One_Dark]Slider.focusedColor=fade(#568af2,40%)
|
||||
|
||||
[Solarized_Dark]Slider.focusedColor=fade($Component.focusColor,80%,derived)
|
||||
|
||||
[vuesion-theme]Slider.trackValueColor=#ececee
|
||||
[vuesion-theme]Slider.trackColor=#303a45
|
||||
[vuesion-theme]Slider.thumbColor=#ececee
|
||||
[vuesion-theme]Slider.focusedColor=fade(#ececee,20%)
|
||||
|
||||
|
||||
# Material Theme UI Lite
|
||||
|
||||
|
||||
@@ -18,11 +18,11 @@ package com.formdev.flatlaf.jideoss.ui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.geom.Path2D;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
import java.util.Dictionary;
|
||||
import java.util.Enumeration;
|
||||
@@ -31,6 +31,7 @@ import javax.swing.JSlider;
|
||||
import javax.swing.LookAndFeel;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import com.formdev.flatlaf.ui.FlatSliderUI;
|
||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||
import com.formdev.flatlaf.util.UIScale;
|
||||
import com.jidesoft.plaf.basic.BasicRangeSliderUI;
|
||||
@@ -41,16 +42,23 @@ import com.jidesoft.plaf.basic.BasicRangeSliderUI;
|
||||
public class FlatRangeSliderUI
|
||||
extends BasicRangeSliderUI
|
||||
{
|
||||
private int trackWidth;
|
||||
private int thumbWidth;
|
||||
protected int trackWidth;
|
||||
protected Dimension thumbSize;
|
||||
protected int focusWidth;
|
||||
|
||||
private Color trackColor;
|
||||
private Color thumbColor;
|
||||
private Color focusColor;
|
||||
private Color hoverColor;
|
||||
private Color disabledForeground;
|
||||
|
||||
private Rectangle firstThumbRect;
|
||||
protected Color trackValueColor;
|
||||
protected Color trackColor;
|
||||
protected Color thumbColor;
|
||||
protected Color thumbBorderColor;
|
||||
protected Color focusedColor;
|
||||
protected Color focusedThumbBorderColor;
|
||||
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 ) {
|
||||
return new FlatRangeSliderUI();
|
||||
@@ -97,24 +105,57 @@ public class FlatRangeSliderUI
|
||||
LookAndFeel.installProperty( slider, "opaque", false );
|
||||
|
||||
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" );
|
||||
thumbColor = UIManager.getColor( "Slider.thumbColor" );
|
||||
focusColor = FlatUIUtils.getUIColor( "Slider.focusedColor", "Component.focusColor" );
|
||||
hoverColor = FlatUIUtils.getUIColor( "Slider.hoverColor", focusColor );
|
||||
disabledForeground = UIManager.getColor( "Slider.disabledForeground" );
|
||||
thumbBorderColor = UIManager.getColor( "Slider.thumbBorderColor" );
|
||||
focusedColor = FlatUIUtils.getUIColor( "Slider.focusedColor", "Component.focusColor" );
|
||||
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
|
||||
protected void uninstallDefaults( JSlider slider ) {
|
||||
super.uninstallDefaults( slider );
|
||||
|
||||
trackValueColor = null;
|
||||
trackColor = null;
|
||||
thumbColor = null;
|
||||
focusColor = null;
|
||||
hoverColor = null;
|
||||
disabledForeground = null;
|
||||
thumbBorderColor = null;
|
||||
focusedColor = 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
|
||||
@@ -144,30 +185,30 @@ public class FlatRangeSliderUI
|
||||
|
||||
@Override
|
||||
protected Dimension getThumbSize() {
|
||||
return new Dimension( UIScale.scale( thumbWidth ), UIScale.scale( thumbWidth ) );
|
||||
return FlatSliderUI.calcThumbSize( slider, thumbSize, focusWidth );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint( Graphics g, JComponent c ) {
|
||||
FlatUIUtils.setRenderingHints( (Graphics2D) g );
|
||||
|
||||
second = false;
|
||||
super.paint( g, c );
|
||||
|
||||
Rectangle clip = g.getClipBounds();
|
||||
|
||||
firstThumbRect = new Rectangle( thumbRect );
|
||||
|
||||
second = true;
|
||||
/*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 );
|
||||
Point p = adjustThumbForHighValue();
|
||||
|
||||
if( clip.intersects( thumbRect ) ) {
|
||||
paintTrack( g );
|
||||
paintThumb( g );
|
||||
}
|
||||
|
||||
g.drawRect( thumbRect.x, thumbRect.y, thumbRect.width - 1, thumbRect.height - 1 );
|
||||
restoreThumbForLowValue( p );
|
||||
second = false;
|
||||
debug*/
|
||||
|
||||
super.paint( g, c );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -181,89 +222,70 @@ public class FlatRangeSliderUI
|
||||
float tw = UIScale.scale( (float) trackWidth );
|
||||
float arc = tw;
|
||||
|
||||
// get rectangle of second thumb
|
||||
Point p = adjustThumbForHighValue();
|
||||
Rectangle thumbRect2 = new Rectangle( thumbRect );
|
||||
restoreThumbForLowValue( p );
|
||||
|
||||
RoundRectangle2D coloredTrack = null;
|
||||
RoundRectangle2D track;
|
||||
if( slider.getOrientation() == JSlider.HORIZONTAL ) {
|
||||
float y = trackRect.y + (trackRect.height - tw) / 2f;
|
||||
if( enabled ) {
|
||||
if( slider.getComponentOrientation().isLeftToRight() ) {
|
||||
int cw = thumbRect.x + (thumbRect.width / 2) - trackRect.x;
|
||||
if( second ) {
|
||||
track = new RoundRectangle2D.Float( trackRect.x + cw, y, trackRect.width - cw, tw, arc, arc );
|
||||
int firstCw = firstThumbRect.x + (firstThumbRect.width / 2) - trackRect.x;
|
||||
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 );
|
||||
Rectangle thumbRect1 = thumbRect;
|
||||
if( !slider.getComponentOrientation().isLeftToRight() ) {
|
||||
Rectangle temp = thumbRect1;
|
||||
thumbRect1 = thumbRect2;
|
||||
thumbRect2 = temp;
|
||||
}
|
||||
} 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 {
|
||||
float x = trackRect.x + (trackRect.width - tw) / 2f;
|
||||
if( enabled ) {
|
||||
int ch = thumbRect.y + (thumbRect.height / 2) - trackRect.y;
|
||||
if( second ) {
|
||||
int firstCh = firstThumbRect.y + (firstThumbRect.height / 2) - trackRect.y;
|
||||
track = new RoundRectangle2D.Float( x, trackRect.y, tw, ch, arc, arc );
|
||||
coloredTrack = new RoundRectangle2D.Float( x, trackRect.y + ch, tw, firstCh - ch, 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 );
|
||||
int cy = thumbRect2.y + (thumbRect2.height / 2);
|
||||
int ch = thumbRect.y - thumbRect2.y;
|
||||
coloredTrack = new RoundRectangle2D.Float( x, cy, tw, ch, arc, arc );
|
||||
}
|
||||
track = new RoundRectangle2D.Float( x, trackRect.y, tw, trackRect.height, arc, arc );
|
||||
}
|
||||
|
||||
g.setColor( enabled ? trackColor : disabledTrackColor );
|
||||
((Graphics2D)g).fill( track );
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
g.setColor( enabled ? trackColor : disabledForeground );
|
||||
((Graphics2D)g).fill( track );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintThumb( Graphics g ) {
|
||||
g.setColor( FlatUIUtils.deriveColor( slider.isEnabled()
|
||||
? (FlatUIUtils.isPermanentFocusOwner( slider ) ? focusColor : (hover ? hoverColor : thumbColor))
|
||||
: disabledForeground,
|
||||
thumbColor ) );
|
||||
boolean thumbHover = hover && ((!second && rollover1) || (second && rollover2));
|
||||
boolean thumbPressed = (!second && pressed1) || (second && pressed2);
|
||||
|
||||
if( isRoundThumb() )
|
||||
g.fillOval( thumbRect.x, thumbRect.y, thumbRect.width, thumbRect.height );
|
||||
else {
|
||||
double w = thumbRect.width;
|
||||
double h = thumbRect.height;
|
||||
double wh = w / 2;
|
||||
Color color = FlatSliderUI.stateColor( slider, thumbHover, thumbPressed,
|
||||
thumbColor, disabledThumbColor, null, hoverThumbColor, pressedThumbColor );
|
||||
color = FlatUIUtils.deriveColor( color, thumbColor );
|
||||
|
||||
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();
|
||||
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();
|
||||
}
|
||||
}
|
||||
FlatSliderUI.paintThumb( g, slider, thumbRect, isRoundThumb(), color, borderColor, focusedColor, focusWidth );
|
||||
}
|
||||
|
||||
private boolean isRoundThumb() {
|
||||
protected boolean isRoundThumb() {
|
||||
return !slider.getPaintTicks() && !slider.getPaintLabels();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -841,23 +841,28 @@ SeparatorUI com.formdev.flatlaf.ui.FlatSeparatorUI
|
||||
#---- Slider ----
|
||||
|
||||
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.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.foreground #bbbbbb javax.swing.plaf.ColorUIResource [UI]
|
||||
Slider.highlight #242424 javax.swing.plaf.ColorUIResource [UI]
|
||||
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.minimumVerticalSize 21,36 java.awt.Dimension
|
||||
Slider.onlyLeftMouseButtonDrag true
|
||||
Slider.pressedThumbColor #2e6296 com.formdev.flatlaf.util.DerivedColor [UI] darken(15% autoInverse)
|
||||
Slider.shadow #646464 javax.swing.plaf.ColorUIResource [UI]
|
||||
Slider.thumbColor #a6a6a6 javax.swing.plaf.ColorUIResource [UI]
|
||||
Slider.thumbWidth 11
|
||||
Slider.thumbColor #4a88c7 javax.swing.plaf.ColorUIResource [UI]
|
||||
Slider.thumbSize 12,12 javax.swing.plaf.DimensionUIResource [UI]
|
||||
Slider.tickColor #888888 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
|
||||
SliderUI com.formdev.flatlaf.ui.FlatSliderUI
|
||||
|
||||
|
||||
@@ -846,23 +846,28 @@ SeparatorUI com.formdev.flatlaf.ui.FlatSeparatorUI
|
||||
#---- Slider ----
|
||||
|
||||
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.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.foreground #000000 javax.swing.plaf.ColorUIResource [UI]
|
||||
Slider.highlight #ffffff javax.swing.plaf.ColorUIResource [UI]
|
||||
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.minimumVerticalSize 21,36 java.awt.Dimension
|
||||
Slider.onlyLeftMouseButtonDrag true
|
||||
Slider.pressedThumbColor #125ca5 com.formdev.flatlaf.util.DerivedColor [UI] lighten(15% autoInverse)
|
||||
Slider.shadow #c4c4c4 javax.swing.plaf.ColorUIResource [UI]
|
||||
Slider.thumbColor #6e6e6e javax.swing.plaf.ColorUIResource [UI]
|
||||
Slider.thumbWidth 11
|
||||
Slider.thumbColor #1e82e6 javax.swing.plaf.ColorUIResource [UI]
|
||||
Slider.thumbSize 12,12 javax.swing.plaf.DimensionUIResource [UI]
|
||||
Slider.tickColor #888888 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
|
||||
SliderUI com.formdev.flatlaf.ui.FlatSliderUI
|
||||
|
||||
|
||||
@@ -833,24 +833,30 @@ SeparatorUI com.formdev.flatlaf.ui.FlatSeparatorUI
|
||||
#---- Slider ----
|
||||
|
||||
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.focusInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI]
|
||||
Slider.focusWidth 4
|
||||
Slider.focusedColor #97c3f3 javax.swing.plaf.ColorUIResource [UI]
|
||||
Slider.font [active] $defaultFont [UI]
|
||||
Slider.foreground #ff0000 javax.swing.plaf.ColorUIResource [UI]
|
||||
Slider.highlight #ffffff javax.swing.plaf.ColorUIResource [UI]
|
||||
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.minimumVerticalSize 21,36 java.awt.Dimension
|
||||
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.thumbColor #880000 javax.swing.plaf.ColorUIResource [UI]
|
||||
Slider.thumbWidth 11
|
||||
Slider.thumbBorderColor #ff0000 javax.swing.plaf.ColorUIResource [UI]
|
||||
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.trackColor #00bb00 javax.swing.plaf.ColorUIResource [UI]
|
||||
Slider.trackWidth 3
|
||||
Slider.trackColor #88ff88 javax.swing.plaf.ColorUIResource [UI]
|
||||
Slider.trackWidth 2
|
||||
Slider.verticalSize 21,200 java.awt.Dimension
|
||||
SliderUI com.formdev.flatlaf.ui.FlatSliderUI
|
||||
|
||||
|
||||
@@ -286,6 +286,7 @@ public class FlatComponentsTest
|
||||
JLabel sliderLabel = new JLabel();
|
||||
JSlider slider1 = new JSlider();
|
||||
JSlider slider6 = new JSlider();
|
||||
JLabel sliderLabel2 = new JLabel();
|
||||
slider3 = new JSlider();
|
||||
JSlider slider5 = new JSlider();
|
||||
JLabel progressBarLabel = new JLabel();
|
||||
@@ -1200,12 +1201,16 @@ public class FlatComponentsTest
|
||||
|
||||
//---- slider1 ----
|
||||
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.setEnabled(false);
|
||||
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.setMinorTickSpacing(10);
|
||||
@@ -1214,7 +1219,7 @@ public class FlatComponentsTest
|
||||
slider3.setPaintLabels(true);
|
||||
slider3.setValue(30);
|
||||
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.setMinorTickSpacing(10);
|
||||
@@ -1223,7 +1228,7 @@ public class FlatComponentsTest
|
||||
slider5.setPaintLabels(true);
|
||||
slider5.setEnabled(false);
|
||||
slider5.setValue(30);
|
||||
add(slider5, "cell 1 20 3 1,aligny top,growy 0");
|
||||
add(slider5, "cell 1 20 3 1");
|
||||
|
||||
//---- progressBarLabel ----
|
||||
progressBarLabel.setText("JProgressBar:");
|
||||
|
||||
@@ -1141,14 +1141,20 @@ new FormModel {
|
||||
name: "slider1"
|
||||
"value": 30
|
||||
}, 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" ) {
|
||||
name: "slider6"
|
||||
"enabled": false
|
||||
"value": 30
|
||||
}, 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" ) {
|
||||
name: "slider3"
|
||||
@@ -1162,7 +1168,7 @@ new FormModel {
|
||||
}
|
||||
addEvent( new FormEvent( "javax.swing.event.ChangeListener", "stateChanged", "changeProgress", false ) )
|
||||
}, 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" ) {
|
||||
name: "slider5"
|
||||
@@ -1173,7 +1179,7 @@ new FormModel {
|
||||
"enabled": false
|
||||
"value": 30
|
||||
}, 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" ) {
|
||||
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.JLabel;
|
||||
import javax.swing.JSlider;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
@@ -50,13 +51,19 @@ public class FlatRangeSliderTest
|
||||
}
|
||||
|
||||
private void paintLabels() {
|
||||
horizontalRangeSlider.setPaintLabels( paintLabel.isSelected() );
|
||||
verticalRangeSlider.setPaintLabels( paintLabel.isSelected() );
|
||||
boolean selected = paintLabel.isSelected();
|
||||
horizontalRangeSlider.setPaintLabels( selected );
|
||||
verticalRangeSlider.setPaintLabels( selected );
|
||||
horizontalSlider.setPaintLabels( selected );
|
||||
verticalSlider.setPaintLabels( selected );
|
||||
}
|
||||
|
||||
private void paintTicks() {
|
||||
horizontalRangeSlider.setPaintTicks( paintTick.isSelected() );
|
||||
verticalRangeSlider.setPaintTicks( paintTick.isSelected() );
|
||||
boolean selected = paintTick.isSelected();
|
||||
horizontalRangeSlider.setPaintTicks( selected );
|
||||
verticalRangeSlider.setPaintTicks( selected );
|
||||
horizontalSlider.setPaintTicks( selected );
|
||||
verticalSlider.setPaintTicks( selected );
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
@@ -64,8 +71,14 @@ public class FlatRangeSliderTest
|
||||
JLabel tabbedPaneLabel = new JLabel();
|
||||
JLabel horizontalLabel = new JLabel();
|
||||
horizontalRangeSlider = new RangeSlider();
|
||||
horizontalSlider = new JSlider();
|
||||
horizontalRangeSlider2 = new RangeSlider();
|
||||
horizontalSlider2 = new JSlider();
|
||||
JLabel verticalLabel = new JLabel();
|
||||
verticalRangeSlider = new RangeSlider();
|
||||
verticalSlider = new JSlider();
|
||||
verticalRangeSlider2 = new RangeSlider();
|
||||
verticalSlider2 = new JSlider();
|
||||
paintTick = new JCheckBox();
|
||||
paintLabel = new JCheckBox();
|
||||
|
||||
@@ -74,10 +87,13 @@ public class FlatRangeSliderTest
|
||||
"insets dialog,hidemode 3",
|
||||
// columns
|
||||
"[left]" +
|
||||
"[fill]",
|
||||
"[240,left]",
|
||||
// rows
|
||||
"[fill]" +
|
||||
"[center]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[grow,fill]" +
|
||||
"[]"));
|
||||
|
||||
@@ -88,57 +104,92 @@ public class FlatRangeSliderTest
|
||||
//---- horizontalLabel ----
|
||||
horizontalLabel.setText("Horizontal");
|
||||
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.setText("Vertical");
|
||||
add(verticalLabel, "cell 0 2,aligny top,growy 0");
|
||||
add(verticalLabel, "cell 0 5,aligny top,growy 0");
|
||||
|
||||
//---- verticalRangeSlider ----
|
||||
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.setText("PaintTicks");
|
||||
paintTick.setMnemonic('T');
|
||||
paintTick.setSelected(true);
|
||||
paintTick.addActionListener(e -> paintTicks());
|
||||
add(paintTick, "cell 0 3 2 1");
|
||||
add(paintTick, "cell 0 6 2 1");
|
||||
|
||||
//---- paintLabel ----
|
||||
paintLabel.setText("PaintLabels");
|
||||
paintLabel.setMnemonic('L');
|
||||
paintLabel.setSelected(true);
|
||||
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
|
||||
|
||||
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
|
||||
private RangeSlider horizontalRangeSlider;
|
||||
private JSlider horizontalSlider;
|
||||
private RangeSlider horizontalRangeSlider2;
|
||||
private JSlider horizontalSlider2;
|
||||
private RangeSlider verticalRangeSlider;
|
||||
private JSlider verticalSlider;
|
||||
private RangeSlider verticalRangeSlider2;
|
||||
private JSlider verticalSlider2;
|
||||
private JCheckBox paintTick;
|
||||
private JCheckBox paintLabel;
|
||||
// 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 ) {
|
||||
"$layoutConstraints": "insets dialog,hidemode 3"
|
||||
"$columnConstraints": "[left][fill]"
|
||||
"$rowConstraints": "[fill][center][grow,fill][]"
|
||||
"$columnConstraints": "[left][240,left]"
|
||||
"$rowConstraints": "[fill][center][][][][grow,fill][]"
|
||||
} ) {
|
||||
name: "this"
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
@@ -26,26 +26,105 @@ new FormModel {
|
||||
} )
|
||||
add( new FormComponent( "com.jidesoft.swing.RangeSlider" ) {
|
||||
name: "horizontalRangeSlider"
|
||||
"lowValue": 30
|
||||
"highValue": 80
|
||||
"majorTickSpacing": 10
|
||||
"minorTickSpacing": 5
|
||||
"paintTicks": true
|
||||
"paintLabels": true
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
}, 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" ) {
|
||||
name: "verticalLabel"
|
||||
"text": "Vertical"
|
||||
}, 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" ) {
|
||||
name: "verticalRangeSlider"
|
||||
"orientation": 1
|
||||
"lowValue": 30
|
||||
"highValue": 80
|
||||
"majorTickSpacing": 10
|
||||
"minorTickSpacing": 5
|
||||
"paintTicks": true
|
||||
"paintLabels": true
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
}, 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" ) {
|
||||
name: "paintTick"
|
||||
@@ -57,7 +136,7 @@ new FormModel {
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "paintTicks", false ) )
|
||||
}, 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" ) {
|
||||
name: "paintLabel"
|
||||
@@ -69,7 +148,7 @@ new FormModel {
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "paintLabels", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 3 2 1"
|
||||
"value": "cell 0 6 2 1"
|
||||
} )
|
||||
}, new FormLayoutConstraints( null ) {
|
||||
"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.ui.FlatLineBorder;
|
||||
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.DerivedColor;
|
||||
import com.formdev.flatlaf.util.StringUtils;
|
||||
@@ -399,13 +400,18 @@ public class UIDefaultsDump
|
||||
HSLIncreaseDecrease func = (HSLIncreaseDecrease) function;
|
||||
String name;
|
||||
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 2: name = func.increase ? "lighten" : "darken"; break;
|
||||
case 3: name = func.increase ? "fadein" : "fadeout"; break;
|
||||
default: throw new IllegalArgumentException();
|
||||
}
|
||||
out.printf( "%s(%.0f%%%s%s)", name, func.amount,
|
||||
(func.relative ? " relative" : ""),
|
||||
(func.autoInverse ? " autoInverse" : "") );
|
||||
} else if( function instanceof Fade ) {
|
||||
Fade func = (Fade) function;
|
||||
out.printf( "fade(%.0f%%)", func.amount );
|
||||
} else
|
||||
throw new IllegalArgumentException( "unknown color function: " + function );
|
||||
}
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
com.formdev.flatlaf.testing.jideoss.FlatJideOssDefaultsTestAddon
|
||||
com.formdev.flatlaf.testing.swingx.FlatSwingXDefaultsTestAddon
|
||||
|
||||
@@ -257,12 +257,15 @@ Separator.stripeIndent=5
|
||||
|
||||
#---- Slider ----
|
||||
|
||||
Slider.trackColor=#0b0
|
||||
Slider.thumbColor=#800
|
||||
Slider.trackColor=#8f8
|
||||
Slider.thumbColor=#faa
|
||||
Slider.thumbBorderColor=#f00
|
||||
Slider.tickColor=#f00
|
||||
Slider.focusedColor=$Component.focusColor
|
||||
Slider.hoverColor=#00f
|
||||
Slider.disabledForeground=#008
|
||||
Slider.hoverThumbColor=#00f
|
||||
Slider.pressedThumbColor=#0f0
|
||||
Slider.disabledTrackColor=#ff8
|
||||
Slider.disabledThumbColor=#880
|
||||
|
||||
|
||||
#---- 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%",
|
||||
"alpha", "0-100%" );
|
||||
|
||||
String colorParamDesc = "a color (e.g. #f00), a reference (e.g. $Other.key) or a color function";
|
||||
String[] hslIncreaseDecreaseParams = {
|
||||
"color", "a color (e.g. #f00), a reference (e.g. $Other.key) or a color function",
|
||||
"color", colorParamDesc,
|
||||
"amount", "0-100%",
|
||||
"options", "(optional) [relative] [autoInverse] [noAutoInverse] [lazy] [derived]"
|
||||
};
|
||||
@@ -345,6 +346,17 @@ class FlatCompletionProvider
|
||||
addFunction( "darken", hslIncreaseDecreaseParams );
|
||||
addFunction( "saturate", 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 ) {
|
||||
|
||||
@@ -581,24 +581,29 @@ Separator.stripeIndent
|
||||
Separator.stripeWidth
|
||||
SeparatorUI
|
||||
Slider.background
|
||||
Slider.disabledForeground
|
||||
Slider.disabledThumbColor
|
||||
Slider.disabledTrackColor
|
||||
Slider.focus
|
||||
Slider.focusInputMap
|
||||
Slider.focusInputMap.RightToLeft
|
||||
Slider.focusInsets
|
||||
Slider.focusWidth
|
||||
Slider.focusedColor
|
||||
Slider.font
|
||||
Slider.foreground
|
||||
Slider.highlight
|
||||
Slider.horizontalSize
|
||||
Slider.hoverColor
|
||||
Slider.hoverThumbColor
|
||||
Slider.minimumHorizontalSize
|
||||
Slider.minimumVerticalSize
|
||||
Slider.onlyLeftMouseButtonDrag
|
||||
Slider.pressedThumbColor
|
||||
Slider.shadow
|
||||
Slider.thumbColor
|
||||
Slider.thumbWidth
|
||||
Slider.thumbSize
|
||||
Slider.tickColor
|
||||
Slider.trackColor
|
||||
Slider.trackValueColor
|
||||
Slider.trackWidth
|
||||
Slider.verticalSize
|
||||
SliderUI
|
||||
|
||||
@@ -40,3 +40,12 @@ Prop.colorFunc5=lighten(#fe1289,20%)
|
||||
Prop.colorFunc6=darken(#fe1289,20%)
|
||||
Prop.colorFunc7=lighten($Prop.colorFunc4,20%,relative autoInverse)
|
||||
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