mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 06:27:13 -06:00
use FlatUIUtils.createPath() in painting
This commit is contained in:
@@ -19,8 +19,8 @@ package com.formdev.flatlaf.icons;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.Path2D;
|
||||
import javax.swing.UIManager;
|
||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||
|
||||
/**
|
||||
* "ascendingSort" icon for {@link javax.swing.table.JTableHeader}.
|
||||
@@ -40,13 +40,7 @@ public class FlatAscendingSortIcon
|
||||
|
||||
@Override
|
||||
protected void paintIcon( Component c, Graphics2D g ) {
|
||||
Path2D arrow = new Path2D.Float();
|
||||
arrow.moveTo( 0.5, 5 );
|
||||
arrow.lineTo( 9.5, 5 );
|
||||
arrow.lineTo( 5, 0 );
|
||||
arrow.closePath();
|
||||
|
||||
g.setColor( sortIconColor );
|
||||
g.fill( arrow );
|
||||
g.fill( FlatUIUtils.createPath( 0.5,5, 9.5,5, 5,0 ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ package com.formdev.flatlaf.icons;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.Path2D;
|
||||
import javax.swing.UIManager;
|
||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||
|
||||
/**
|
||||
* "descendingSort" icon for {@link javax.swing.table.JTableHeader}.
|
||||
@@ -40,13 +40,7 @@ public class FlatDescendingSortIcon
|
||||
|
||||
@Override
|
||||
protected void paintIcon( Component c, Graphics2D g ) {
|
||||
Path2D arrow = new Path2D.Float();
|
||||
arrow.moveTo( 0.5, 0 );
|
||||
arrow.lineTo( 9.5, 0 );
|
||||
arrow.lineTo( 5, 5 );
|
||||
arrow.closePath();
|
||||
|
||||
g.setColor( sortIconColor );
|
||||
g.fill( arrow );
|
||||
g.fill( FlatUIUtils.createPath( 0.5,0, 9.5,0, 5,5 ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@ package com.formdev.flatlaf.icons;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.Path2D;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.UIManager;
|
||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||
|
||||
/**
|
||||
* "arrow" icon for {@link javax.swing.JMenu}.
|
||||
@@ -45,17 +45,11 @@ public class FlatMenuArrowIcon
|
||||
|
||||
@Override
|
||||
protected void paintIcon( Component c, Graphics2D g ) {
|
||||
Path2D arrow = new Path2D.Float();
|
||||
arrow.moveTo( 0, 0.5 );
|
||||
arrow.lineTo( 0, 9.5 );
|
||||
arrow.lineTo( 5, 5 );
|
||||
arrow.closePath();
|
||||
|
||||
if( !c.getComponentOrientation().isLeftToRight() )
|
||||
g.rotate( Math.toRadians( 180 ), width / 2., height / 2. );
|
||||
|
||||
g.setColor( getArrowColor( c ) );
|
||||
g.fill( arrow );
|
||||
g.fill( FlatUIUtils.createPath( 0,0.5, 0,9.5, 5,5 ) );
|
||||
}
|
||||
|
||||
private Color getArrowColor( Component c ) {
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.formdev.flatlaf.icons;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.Path2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||
|
||||
/**
|
||||
* "Warning" icon for {@link javax.swing.JOptionPane}.
|
||||
@@ -46,11 +47,7 @@ public class FlatOptionPaneWarningIcon
|
||||
|
||||
@Override
|
||||
protected Shape createOutside() {
|
||||
Path2D outside = new Path2D.Float();
|
||||
outside.moveTo( 16, 2 );
|
||||
outside.lineTo( 31, 28 );
|
||||
outside.lineTo( 1, 28 );
|
||||
return outside;
|
||||
return FlatUIUtils.createPath( 16,2, 31,28, 1,28 );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,8 +18,8 @@ package com.formdev.flatlaf.icons;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.Path2D;
|
||||
import javax.swing.UIManager;
|
||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||
|
||||
/**
|
||||
* "collapsed" icon for {@link javax.swing.JTree}.
|
||||
@@ -37,15 +37,9 @@ public class FlatTreeCollapsedIcon
|
||||
|
||||
@Override
|
||||
protected void paintIcon( Component c, Graphics2D g ) {
|
||||
Path2D arrow = new Path2D.Float();
|
||||
arrow.moveTo( 2, 1 );
|
||||
arrow.lineTo( 2, 10 );
|
||||
arrow.lineTo( 10, 5.5 );
|
||||
arrow.closePath();
|
||||
|
||||
if( !c.getComponentOrientation().isLeftToRight() )
|
||||
g.rotate( Math.toRadians( 180 ), width / 2., height / 2. );
|
||||
|
||||
g.fill( arrow );
|
||||
g.fill( FlatUIUtils.createPath( 2,1, 2,10, 10,5.5 ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ package com.formdev.flatlaf.icons;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.Path2D;
|
||||
import javax.swing.UIManager;
|
||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||
|
||||
/**
|
||||
* "expanded" icon for {@link javax.swing.JTree}.
|
||||
@@ -37,12 +37,6 @@ public class FlatTreeExpandedIcon
|
||||
|
||||
@Override
|
||||
protected void paintIcon( Component c, Graphics2D g ) {
|
||||
Path2D arrow = new Path2D.Float();
|
||||
arrow.moveTo( 1, 2 );
|
||||
arrow.lineTo( 10, 2 );
|
||||
arrow.lineTo( 5.5, 10 );
|
||||
arrow.closePath();
|
||||
|
||||
g.fill( arrow );
|
||||
g.fill( FlatUIUtils.createPath( 1,2, 10,2, 5.5,10 ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,38 +136,12 @@ public class FlatArrowButton
|
||||
}
|
||||
|
||||
public static Shape createArrowShape( int direction, int w, int h ) {
|
||||
Path2D arrow = new Path2D.Float();
|
||||
|
||||
switch( direction ) {
|
||||
case NORTH:
|
||||
arrow.moveTo( 0, h );
|
||||
arrow.lineTo( w, h );
|
||||
arrow.lineTo( (w / 2f), 0 );
|
||||
arrow.closePath();
|
||||
break;
|
||||
|
||||
case SOUTH:
|
||||
arrow.moveTo( 0, 0 );
|
||||
arrow.lineTo( w, 0 );
|
||||
arrow.lineTo( (w / 2f), h );
|
||||
arrow.closePath();
|
||||
break;
|
||||
|
||||
case WEST:
|
||||
arrow.moveTo( h, 0 );
|
||||
arrow.lineTo( h, w );
|
||||
arrow.lineTo( 0, (w / 2f) );
|
||||
arrow.closePath();
|
||||
break;
|
||||
|
||||
case EAST:
|
||||
arrow.moveTo( 0, 0 );
|
||||
arrow.lineTo( 0, w );
|
||||
arrow.lineTo( h, (w / 2f) );
|
||||
arrow.closePath();
|
||||
break;
|
||||
case NORTH: return FlatUIUtils.createPath( 0,h, w,h, (w / 2f),0 );
|
||||
case SOUTH: return FlatUIUtils.createPath( 0,0, w,0, (w / 2f),h );
|
||||
case WEST: return FlatUIUtils.createPath( h,0, h,w, 0,(w / 2f) );
|
||||
case EAST: return FlatUIUtils.createPath( 0,0, 0,w, h,(w / 2f) );
|
||||
default: return new Path2D.Float();
|
||||
}
|
||||
|
||||
return arrow;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,13 +179,7 @@ public class FlatSliderUI
|
||||
double h = thumbRect.height;
|
||||
double wh = w / 2;
|
||||
|
||||
Path2D thumb = new Path2D.Float();
|
||||
thumb.moveTo( 0, 0 );
|
||||
thumb.lineTo( w, 0 );
|
||||
thumb.lineTo( w, h - wh );
|
||||
thumb.lineTo( wh, h );
|
||||
thumb.lineTo( 0, h - wh );
|
||||
thumb.closePath();
|
||||
Path2D thumb = FlatUIUtils.createPath( 0,0, w,0, w,(h - wh), wh,h, 0,(h - wh) );
|
||||
|
||||
Graphics2D g2 = (Graphics2D) g.create();
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user