Skip to content

Commit

Permalink
Merge PR #577: Rounded outlined icons
Browse files Browse the repository at this point in the history
  • Loading branch information
DevCharly committed Oct 30, 2022
2 parents c3a1b45 + 380dae1 commit 2bfbc9d
Show file tree
Hide file tree
Showing 56 changed files with 525 additions and 207 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -9,6 +9,8 @@ FlatLaf Change Log
- List: Support rounded selection. (PR #547)
- Menus: Support rounded selection. (PR #536)
- Tree: Support rounded selection. (PR #546)
- Icons: New modern rounded outlined icons for `JFileChooser`, `JOptionPane`,
`JPasswordField` and `JTree`. (PR #577)

#### Fixed bugs

Expand Down
Expand Up @@ -16,9 +16,12 @@

package com.formdev.flatlaf.icons;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.Area;
import java.awt.geom.Path2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RoundRectangle2D;
Expand All @@ -36,6 +39,8 @@
public class FlatCapsLockIcon
extends FlatAbstractIcon
{
private Path2D path;

public FlatCapsLockIcon() {
super( 16, 16, UIManager.getColor( "PasswordField.capsLockIconColor" ) );
}
Expand Down Expand Up @@ -63,16 +68,22 @@ protected void paintIcon( Component c, Graphics2D g ) {
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<g fill="none" fill-rule="evenodd">
<rect width="16" height="16" fill="#6E6E6E" rx="3"/>
<rect width="6" height="2" x="5" y="11.5" fill="#FFF"/>
<path fill="#FFF" d="M2,8 L8,2 L14,8 L11,8 L11,10 L5,10 L5,8 L2,8 Z"/>
<rect width="5" height="2" x="5.5" y="11.5" stroke="#FFF" stroke-linejoin="round"/>
<path stroke="#FFF" stroke-linejoin="round" d="M2.5,7.5 L8,2 L13.5,7.5 L10.5,7.5 L10.5,9.5 L5.5,9.5 L5.5,7.5 L2.5,7.5 Z"/>
</g>
</svg>
*/

Path2D path = new Path2D.Float( Path2D.WIND_EVEN_ODD );
path.append( new RoundRectangle2D.Float( 0, 0, 16, 16, 6, 6 ), false );
path.append( new Rectangle2D.Float( 5, 11.5f, 6, 2 ), false );
path.append( FlatUIUtils.createPath( 2,8, 8,2, 14,8, 11,8, 11,10, 5,10, 5,8 ), false );
g.setRenderingHint( RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE );
BasicStroke stroke = new BasicStroke( 1, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND );

if( path == null ) {
path = new Path2D.Float( Path2D.WIND_EVEN_ODD );
path.append( new RoundRectangle2D.Float( 0, 0, 16, 16, 6, 6 ), false );
path.append( new Area( stroke.createStrokedShape( new Rectangle2D.Float( 5.5f, 11.5f, 5, 2 ) ) ), false );
path.append( new Area( stroke.createStrokedShape( FlatUIUtils.createPath(
2.5,7.5, 8,2, 13.5,7.5, 10.5,7.5, 10.5,9.5, 5.5,9.5, 5.5,7.5, 2.5,7.5 ) ) ), false );
}
g.fill( path );
}
}
Expand Up @@ -242,7 +242,7 @@ protected void paintBackground( Component c, Graphics2D g, float borderWidth ) {
}

protected void paintCheckmark( Component c, Graphics2D g ) {
Path2D.Float path = new Path2D.Float();
Path2D.Float path = new Path2D.Float( Path2D.WIND_NON_ZERO, 3 );
path.moveTo( 4.5f, 7.5f );
path.lineTo( 6.6f, 10f );
path.lineTo( 11.25f, 3.5f );
Expand Down
Expand Up @@ -76,7 +76,7 @@ protected void paintIcon( Component c, Graphics2D g2 ) {
}

protected void paintCheckmark( Graphics2D g2 ) {
Path2D.Float path = new Path2D.Float();
Path2D.Float path = new Path2D.Float( Path2D.WIND_NON_ZERO, 3 );
path.moveTo( 4.5f, 7.5f );
path.lineTo( 6.6f, 10f );
path.lineTo( 11.25f, 3.5f );
Expand Down
Expand Up @@ -20,7 +20,6 @@
import java.awt.Component;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D;
import java.awt.geom.Path2D;
import java.util.Map;
import javax.swing.AbstractButton;
Expand Down Expand Up @@ -103,9 +102,11 @@ protected void paintIcon( Component c, Graphics2D g ) {

// paint cross
g.setColor( clearIconColor );
Path2D path = new Path2D.Float( Path2D.WIND_EVEN_ODD );
path.append( new Line2D.Float( 5,5, 11,11 ), false );
path.append( new Line2D.Float( 5,11, 11,5 ), false );
Path2D path = new Path2D.Float( Path2D.WIND_EVEN_ODD, 4 );
path.moveTo( 5, 5 );
path.lineTo( 11, 11 );
path.moveTo( 5, 11 );
path.lineTo( 11, 5 );
g.draw( path );
}
}
Expand Up @@ -39,21 +39,25 @@ protected void paintIcon( Component c, Graphics2D g ) {
/*
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<g fill="none" fill-rule="evenodd">
<rect width="2" height="2" x="2" y="3" fill="#6E6E6E"/>
<rect width="2" height="2" x="2" y="7" fill="#6E6E6E"/>
<rect width="2" height="2" x="2" y="11" fill="#6E6E6E"/>
<rect width="8" height="2" x="6" y="3" fill="#6E6E6E"/>
<rect width="8" height="2" x="6" y="7" fill="#6E6E6E"/>
<rect width="8" height="2" x="6" y="11" fill="#6E6E6E"/>
<rect width="2" height="1" x="2" y="3" fill="#6E6E6E" rx=".5"/>
<rect width="2" height="1" x="2" y="6" fill="#6E6E6E" rx=".5"/>
<rect width="2" height="1" x="2" y="9" fill="#6E6E6E" rx=".5"/>
<rect width="2" height="1" x="2" y="12" fill="#6E6E6E" rx=".5"/>
<rect width="8" height="1" x="6" y="3" fill="#6E6E6E" rx=".5"/>
<rect width="8" height="1" x="6" y="6" fill="#6E6E6E" rx=".5"/>
<rect width="8" height="1" x="6" y="9" fill="#6E6E6E" rx=".5"/>
<rect width="8" height="1" x="6" y="12" fill="#6E6E6E" rx=".5"/>
</g>
</svg>
*/

g.fillRect( 2, 3, 2, 2 );
g.fillRect( 2, 7, 2, 2 );
g.fillRect( 2, 11, 2, 2 );
g.fillRect( 6, 3, 8, 2 );
g.fillRect( 6, 7, 8, 2 );
g.fillRect( 6, 11, 8, 2 );
g.fillRoundRect( 2, 3, 2, 1, 1, 1 );
g.fillRoundRect( 2, 6, 2, 1, 1, 1 );
g.fillRoundRect( 2, 9, 2, 1, 1, 1 );
g.fillRoundRect( 2, 12, 2, 1, 1, 1 );
g.fillRoundRect( 6, 3, 8, 1, 1, 1 );
g.fillRoundRect( 6, 6, 8, 1, 1, 1 );
g.fillRoundRect( 6, 9, 8, 1, 1, 1 );
g.fillRoundRect( 6, 12, 8, 1, 1, 1 );
}
}
Expand Up @@ -16,8 +16,10 @@

package com.formdev.flatlaf.icons;

import java.awt.BasicStroke;
import java.awt.Component;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import javax.swing.UIManager;
import com.formdev.flatlaf.ui.FlatUIUtils;

Expand All @@ -39,10 +41,22 @@ public FlatFileChooserHomeFolderIcon() {
protected void paintIcon( Component c, Graphics2D g ) {
/*
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<polygon fill="#6E6E6E" fill-rule="evenodd" points="2 8 8 2 14 8 12 8 12 13 9 13 9 10 7 10 7 13 4 13 4 8"/>
<g fill="none" fill-rule="evenodd">
<polyline stroke="#6E6E6E" stroke-linejoin="round" points="6.5 13 6.5 9.5 9.5 9.5 9.5 13"/>
<path stroke="#6E6E6E" d="M3.5,6.5 L3.5,12.5 C3.5,13.0522847 3.94771525,13.5 4.5,13.5 L11.5,13.5 C12.0522847,13.5 12.5,13.0522847 12.5,12.5 L12.5,6.5 L12.5,6.5"/>
<polyline stroke="#6E6E6E" stroke-linecap="round" stroke-linejoin="round" points="1.5 8.5 8 2 14.5 8.5"/>
</g>
</svg>
*/

g.fill( FlatUIUtils.createPath( 2,8, 8,2, 14,8, 12,8, 12,13, 9,13, 9,10, 7,10, 7,13, 4,13, 4,8 ) );
g.setRenderingHint( RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE );
g.setStroke( new BasicStroke( 1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND ) );

g.draw( FlatUIUtils.createPath( false, 6.5,13, 6.5,9.5, 9.5,9.5, 9.5,13 ) );
g.draw( FlatUIUtils.createPath( false, 3.5,6.5,
3.5,12.5, FlatUIUtils.QUAD_TO, 3.5,13.5, 4.5,13.5,
11.5,13.5, FlatUIUtils.QUAD_TO, 12.5,13.5, 12.5,12.5,
12.5,6.5 ) );
g.draw( FlatUIUtils.createPath( false, 1.5,8.5, 8,2, 14.5,8.5 ) );
}
}
Expand Up @@ -16,8 +16,11 @@

package com.formdev.flatlaf.icons;

import java.awt.BasicStroke;
import java.awt.Component;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.RoundRectangle2D;
import javax.swing.UIManager;

/**
Expand All @@ -39,17 +42,20 @@ protected void paintIcon( Component c, Graphics2D g ) {
/*
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<g fill="none" fill-rule="evenodd">
<rect width="4" height="4" x="3" y="3" fill="#6E6E6E"/>
<rect width="4" height="4" x="3" y="9" fill="#6E6E6E"/>
<rect width="4" height="4" x="9" y="9" fill="#6E6E6E"/>
<rect width="4" height="4" x="9" y="3" fill="#6E6E6E"/>
<rect width="4" height="4" x="2.5" y="2.5" stroke="#6E6E6E" rx="1.5"/>
<rect width="4" height="4" x="2.5" y="9.5" stroke="#6E6E6E" rx="1.5"/>
<rect width="4" height="4" x="9.5" y="9.5" stroke="#6E6E6E" rx="1.5"/>
<rect width="4" height="4" x="9.5" y="2.5" stroke="#6E6E6E" rx="1.5"/>
</g>
</svg>
*/

g.fillRect( 3, 3, 4, 4 );
g.fillRect( 3, 9, 4, 4 );
g.fillRect( 9, 9, 4, 4 );
g.fillRect( 9, 3, 4, 4 );
g.setRenderingHint( RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE );
g.setStroke( new BasicStroke( 1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND ) );

g.draw( new RoundRectangle2D.Float( 2.5f, 2.5f, 4, 4, 2, 2 ) );
g.draw( new RoundRectangle2D.Float( 2.5f, 9.5f, 4, 4, 2, 2 ) );
g.draw( new RoundRectangle2D.Float( 9.5f, 9.5f, 4, 4, 2, 2 ) );
g.draw( new RoundRectangle2D.Float( 9.5f, 2.5f, 4, 4, 2, 2 ) );
}
}
Expand Up @@ -16,10 +16,13 @@

package com.formdev.flatlaf.icons;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.Line2D;
import javax.swing.UIManager;
import com.formdev.flatlaf.ui.FlatUIUtils;

/**
* "new folder" icon for {@link javax.swing.JFileChooser}.
Expand All @@ -31,6 +34,8 @@
public class FlatFileChooserNewFolderIcon
extends FlatAbstractIcon
{
private final Color greenColor = UIManager.getColor( "Actions.Green" );

public FlatFileChooserNewFolderIcon() {
super( 16, 16, UIManager.getColor( "Actions.Grey" ) );
}
Expand All @@ -40,13 +45,20 @@ protected void paintIcon( Component c, Graphics2D g ) {
/*
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<g fill="none" fill-rule="evenodd">
<polygon fill="#6E6E6E" points="2 3 5.5 3 7 5 14 5 14 8 11 8 11 10 9 10 9 13 2 13"/>
<path fill="#59A869" d="M14,11 L16,11 L16,13 L14,13 L14,15 L12,15 L12,13 L10,13 L10,11 L12,11 L12,9 L14,9 L14,11 Z"/>
<path stroke="#6E6E6E" d="M13,13.5 L3,13.5 C2.17157288,13.5 1.5,12.8284271 1.5,12 L1.5,4 C1.5,3.17157288 2.17157288,2.5 3,2.5 L6.29289322,2.5 C6.42550146,2.5 6.55267842,2.55267842 6.64644661,2.64644661 L8.5,4.5 L8.5,4.5 L13,4.5 C13.8284271,4.5 14.5,5.17157288 14.5,6 L14.5,12 C14.5,12.8284271 13.8284271,13.5 13,13.5 Z"/>
<line x1="5.5" x2="10.5" y1="9" y2="9" stroke="#59A869" stroke-linecap="round"/>
<line x1="8" x2="8" y1="6.5" y2="11.5" stroke="#59A869" stroke-linecap="round"/>
</g>
</svg>
*/

g.fill( FlatUIUtils.createPath( 2,3, 5.5,3, 7,5, 14,5, 14,8, 11,8, 11,10, 9,10, 9,13, 2,13 ) );
g.fill( FlatUIUtils.createPath( 14,11, 16,11, 16,13, 14,13, 14,15, 12,15, 12,13, 10,13, 10,11, 12,11, 12,9, 14,9, 14,11 ) );
g.setRenderingHint( RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE );
g.setStroke( new BasicStroke( 1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND ) );

g.draw( FlatFileViewDirectoryIcon.createFolderPath() );

g.setColor( greenColor );
g.draw( new Line2D.Float( 5.5f, 9, 10.5f, 9 ) );
g.draw( new Line2D.Float( 8, 6.5f, 8, 11.5f ) );
}
}
Expand Up @@ -16,9 +16,12 @@

package com.formdev.flatlaf.icons;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.Line2D;
import javax.swing.UIManager;
import com.formdev.flatlaf.ui.FlatUIUtils;

Expand All @@ -44,15 +47,20 @@ protected void paintIcon( Component c, Graphics2D g ) {
/*
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<g fill="none" fill-rule="evenodd">
<polygon fill="#6E6E6E" points="2 3 5.5 3 7 5 9 5 9 9 13 9 13 5 14 5 14 13 2 13"/>
<path fill="#389FD6" d="M12,4 L12,8 L10,8 L10,4 L8,4 L11,1 L14,4 L12,4 Z"/>
<path stroke="#6E6E6E" d="M13,13.5 L3,13.5 C2.17157288,13.5 1.5,12.8284271 1.5,12 L1.5,4 C1.5,3.17157288 2.17157288,2.5 3,2.5 L6.29289322,2.5 C6.42550146,2.5 6.55267842,2.55267842 6.64644661,2.64644661 L8.5,4.5 L8.5,4.5 L13,4.5 C13.8284271,4.5 14.5,5.17157288 14.5,6 L14.5,12 C14.5,12.8284271 13.8284271,13.5 13,13.5 Z"/>
<line x1="8" x2="8" y1="6.5" y2="11.5" stroke="#389FD6" stroke-linecap="round"/>
<polyline stroke="#389FD6" stroke-linecap="round" stroke-linejoin="round" points="5.5 9 8 6.5 10.5 9"/>
</g>
</svg>
*/

g.fill( FlatUIUtils.createPath( 2,3, 5.5,3, 7,5, 9,5, 9,9, 13,9, 13,5, 14,5, 14,13, 2,13 ) );
g.setRenderingHint( RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE );
g.setStroke( new BasicStroke( 1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND ) );

g.draw( FlatFileViewDirectoryIcon.createFolderPath() );

g.setColor( blueColor );
g.fill( FlatUIUtils.createPath( 12,4, 12,8, 10,8, 10,4, 8,4, 11,1, 14,4, 12,4 ) );
g.draw( new Line2D.Float( 8, 6.5f, 8, 11.5f ) );
g.draw( FlatUIUtils.createPath( false, 5.5,9, 8,6.5, 10.5,9 ) );
}
}
Expand Up @@ -16,10 +16,12 @@

package com.formdev.flatlaf.icons;

import java.awt.BasicStroke;
import java.awt.Component;
import java.awt.Graphics2D;
import java.awt.geom.Path2D;
import java.awt.geom.Rectangle2D;
import java.awt.RenderingHints;
import java.awt.geom.Line2D;
import java.awt.geom.RoundRectangle2D;
import javax.swing.UIManager;

/**
Expand All @@ -41,17 +43,18 @@ protected void paintIcon( Component c, Graphics2D g ) {
/*
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<g fill="none" fill-rule="evenodd">
<path fill="#6E6E6E" d="M2,3 L14,3 L14,11 L2,11 L2,3 Z M4,5 L4,9 L12,9 L12,5 L4,5 Z"/>
<rect width="12" height="2" x="2" y="12" fill="#6E6E6E"/>
<rect width="11" height="7" x="2.5" y="3.5" stroke="#6E6E6E" rx="1"/>
<line x1="8" x2="8" y1="11" y2="12" stroke="#6E6E6E"/>
<line x1="4.5" x2="11.5" y1="12.5" y2="12.5" stroke="#6E6E6E" stroke-linecap="round"/>
</g>
</svg>
*/

Path2D path = new Path2D.Float( Path2D.WIND_EVEN_ODD );
path.append( new Rectangle2D.Float( 2, 3, 12, 8 ), false );
path.append( new Rectangle2D.Float( 4, 5, 8, 4 ), false );
g.fill( path );
g.setRenderingHint( RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE );
g.setStroke( new BasicStroke( 1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND ) );

g.fillRect( 2, 12, 12, 2 );
g.draw( new RoundRectangle2D.Float( 2.5f, 3.5f, 11, 7, 2, 2 ) );
g.drawLine( 8, 11, 8, 12 );
g.draw( new Line2D.Float( 4.5f, 12.5f, 11.5f, 12.5f ) );
}
}
Expand Up @@ -18,6 +18,8 @@

import java.awt.Component;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.Path2D;
import javax.swing.UIManager;
import com.formdev.flatlaf.ui.FlatUIUtils;

Expand All @@ -31,6 +33,8 @@
public class FlatFileViewDirectoryIcon
extends FlatAbstractIcon
{
private Path2D path;

public FlatFileViewDirectoryIcon() {
super( 16, 16, UIManager.getColor( "Objects.Grey" ) );
}
Expand All @@ -39,10 +43,32 @@ public FlatFileViewDirectoryIcon() {
protected void paintIcon( Component c, Graphics2D g ) {
/*
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<polygon fill="#6E6E6E" fill-rule="evenodd" points="1 2 6 2 8 4 15 4 15 13 1 13"/>
<path fill="none" stroke="#6E6E6E" d="M13,13.5 L3,13.5 C2.17157288,13.5 1.5,12.8284271 1.5,12 L1.5,4 C1.5,3.17157288 2.17157288,2.5 3,2.5 L6.29289322,2.5 C6.42550146,2.5 6.55267842,2.55267842 6.64644661,2.64644661 L8.5,4.5 L8.5,4.5 L13,4.5 C13.8284271,4.5 14.5,5.17157288 14.5,6 L14.5,12 C14.5,12.8284271 13.8284271,13.5 13,13.5 Z"/>
</svg>
*/

g.fill( FlatUIUtils.createPath( 1,2, 6,2, 8,4, 15,4, 15,13, 1,13 ) );
g.setRenderingHint( RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE );

if( path == null )
path = createFolderPath();
g.draw( path );
}

static Path2D createFolderPath() {
double arc = 1.5;
double arc2 = 0.5;
return FlatUIUtils.createPath(
// bottom-right
14.5,13.5-arc, FlatUIUtils.QUAD_TO, 14.5,13.5, 14.5-arc,13.5,
// bottom-left
1.5+arc,13.5, FlatUIUtils.QUAD_TO, 1.5,13.5, 1.5,13.5-arc,
// top-left
1.5,2.5+arc, FlatUIUtils.QUAD_TO, 1.5,2.5, 1.5+arc,2.5,
// top-mid-left
6.5-arc2,2.5, FlatUIUtils.QUAD_TO, 6.5,2.5, 6.5+arc2,2.5+arc2,
// top-mid-right
8.5,4.5,
// top-right
14.5-arc,4.5, FlatUIUtils.QUAD_TO, 14.5,4.5, 14.5,4.5+arc );
}
}

0 comments on commit 2bfbc9d

Please sign in to comment.