FlatArrowButton: refactored arrow painting to FlatUIUtils.paintArrow() so that it can be easily used other components (e.g. JideSplitButton)

This commit is contained in:
Karl Tauber
2021-03-19 01:18:13 +01:00
parent 69ac683c8c
commit d39b08c035
6 changed files with 795 additions and 76 deletions

View File

@@ -24,7 +24,6 @@ import java.awt.Shape;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import com.formdev.flatlaf.icons.FlatAbstractIcon;
import com.formdev.flatlaf.ui.FlatArrowButton;
import com.formdev.flatlaf.ui.FlatUIUtils;
/**
@@ -56,14 +55,14 @@ public class FlatMonthDownIcon
@Override
protected void paintIcon( Component c, Graphics2D g ) {
int h = chevron ? 4 : 5;
int w = chevron ? 8 : 9;
int x = Math.round( (width - h) / 2f );
int y = Math.round( (height - w) / 2f );
int w = chevron ? 4 : 5;
int h = chevron ? 8 : 9;
int x = Math.round( (width - w) / 2f );
int y = Math.round( (height - h) / 2f );
g.setColor( c.isEnabled() ? arrowColor : disabledArrowColor );
g.translate( x, y );
Shape arrowShape = FlatArrowButton.createArrowShape( direction, chevron, w, h );
Shape arrowShape = FlatUIUtils.createArrowShape( direction, chevron, w, h );
if( chevron ) {
// chevron arrow
g.setStroke( new BasicStroke( 1f ) );

View File

@@ -36,7 +36,6 @@ import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.UIResource;
import org.jdesktop.swingx.JXTaskPane;
import org.jdesktop.swingx.plaf.basic.BasicTaskPaneUI;
import com.formdev.flatlaf.ui.FlatArrowButton;
import com.formdev.flatlaf.ui.FlatUIUtils;
import com.formdev.flatlaf.util.UIScale;
@@ -223,7 +222,7 @@ public class FlatTaskPaneUI
// create arrow shape
int direction = group.isCollapsed() ? SwingConstants.SOUTH : SwingConstants.NORTH;
Shape arrowShape = FlatArrowButton.createArrowShape( direction, true, cw, ch );
Shape arrowShape = FlatUIUtils.createArrowShape( direction, true, cw, ch );
// fix position of controls
x = group.getComponentOrientation().isLeftToRight() ? (group.getWidth() - width - y) : y;