Table: ascendingSortIcon and descendingSortIcon icons added

This commit is contained in:
Karl Tauber
2019-09-02 17:45:29 +02:00
parent 8754ffe1cb
commit d81e07f03a
6 changed files with 118 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
/*
* Copyright 2019 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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;
/**
* "ascendingSort" icon for {@link javax.swing.table.JTableHeader}.
*
* @uiDefault Table.sortIconColor Color
*
* @author Karl Tauber
*/
public class FlatAscendingSortIcon
extends FlatAbstractIcon
{
protected final Color sortIconColor = UIManager.getColor( "Table.sortIconColor" );
public FlatAscendingSortIcon() {
super( 10, 5, null );
}
@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 );
}
}

View File

@@ -0,0 +1,52 @@
/*
* Copyright 2019 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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;
/**
* "descendingSort" icon for {@link javax.swing.table.JTableHeader}.
*
* @uiDefault Table.sortIconColor Color
*
* @author Karl Tauber
*/
public class FlatDescendingSortIcon
extends FlatAbstractIcon
{
protected final Color sortIconColor = UIManager.getColor( "Table.sortIconColor" );
public FlatDescendingSortIcon() {
super( 10, 5, null );
}
@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 );
}
}

View File

@@ -216,6 +216,13 @@ TabbedPane.tabsOverlapBorder=true
TabbedPane.shadow=@@ComboBox.buttonArrowColor
#---- Table ----
Table.ascendingSortIcon=com.formdev.flatlaf.icons.FlatAscendingSortIcon
Table.descendingSortIcon=com.formdev.flatlaf.icons.FlatDescendingSortIcon
Table.sortIconColor=@icon
#---- TableHeader ----
TableHeader.height=25