Button: scale border insets

This commit is contained in:
Karl Tauber
2019-08-20 18:18:03 +02:00
parent 5f1c9e76eb
commit aa32e50a51

View File

@@ -25,7 +25,7 @@ import java.awt.Insets;
import java.awt.Paint; import java.awt.Paint;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.plaf.basic.BasicBorders; import javax.swing.plaf.basic.BasicBorders;
import com.formdev.flatlaf.util.UIScale; import static com.formdev.flatlaf.util.UIScale.*;
/** /**
* Border for {@link javax.swing.JButton}. * Border for {@link javax.swing.JButton}.
@@ -43,7 +43,7 @@ public class FlatButtonBorder
float focusWidth = getFocusWidth(); float focusWidth = getFocusWidth();
float lineWidth = getLineWidth(); float lineWidth = getLineWidth();
float arc = UIScale.scale( 6f ); //TODO float arc = scale( 6f ); //TODO
if( c.hasFocus() ) { if( c.hasFocus() ) {
g2.setColor( UIManager.getColor( FlatButtonUI.isDefaultButton( c ) g2.setColor( UIManager.getColor( FlatButtonUI.isDefaultButton( c )
@@ -76,23 +76,23 @@ public class FlatButtonBorder
@Override @Override
public Insets getBorderInsets( Component c, Insets insets ) { public Insets getBorderInsets( Component c, Insets insets ) {
int w = UIScale.round( getFocusWidth() + getLineWidth() ); float ow = getFocusWidth() + getLineWidth();
insets = super.getBorderInsets( c, insets ); insets = super.getBorderInsets( c, insets );
insets.top += w; insets.top = round( scale( (float) insets.top ) + ow );
insets.left += w; insets.left = round( scale( (float) insets.left ) + ow );
insets.bottom += w; insets.bottom = round( scale( (float) insets.bottom ) + ow );
insets.right += w; insets.right = round( scale( (float) insets.right ) + ow );
return insets; return insets;
} }
protected float getFocusWidth() { protected float getFocusWidth() {
//TODO //TODO
return UIScale.scale( 2f ); return scale( 2f );
} }
protected float getLineWidth() { protected float getLineWidth() {
//TODO //TODO
return UIScale.scale( 1f ); return scale( 1f );
} }
} }