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