Tree implementation

This commit is contained in:
Karl Tauber
2019-09-03 10:02:32 +02:00
parent df01532598
commit 92bcc35354
6 changed files with 86 additions and 5 deletions

View File

@@ -246,7 +246,8 @@ public abstract class FlatLaf
return parseInstance( value );
// insets
if( key.endsWith( ".margin" ) || key.endsWith( ".padding" ) || key.endsWith( "Insets" ) )
if( key.endsWith( ".margin" ) || key.endsWith( ".padding" ) ||
key.endsWith( "Margins" ) || key.endsWith( "Insets" ) )
return parseInsets( value );
// size

View File

@@ -0,0 +1,61 @@
/*
* 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.ui;
import javax.swing.JComponent;
import javax.swing.LookAndFeel;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicTreeUI;
import com.formdev.flatlaf.util.UIScale;
/**
* Provides the Flat LaF UI delegate for {@link javax.swing.JTree}.
*
* TODO document used UI defaults of superclass
*
* @uiDefault Tree.border Border
*
* @author Karl Tauber
*/
public class FlatTreeUI
extends BasicTreeUI
{
public static ComponentUI createUI( JComponent c ) {
return new FlatTreeUI();
}
@Override
protected void installDefaults() {
super.installDefaults();
LookAndFeel.installBorder( tree, "Tree.border" );
// scale
int rowHeight = FlatUIUtils.getUIInt( "Tree.rowHeight", 16 );
if( rowHeight > 0 )
LookAndFeel.installProperty( tree, "rowHeight", UIScale.scale( rowHeight ) );
setLeftChildIndent( UIScale.scale( getLeftChildIndent() ) );
setRightChildIndent( UIScale.scale( getRightChildIndent() ) );
}
@Override
protected void uninstallDefaults() {
super.uninstallDefaults();
LookAndFeel.uninstallBorder( tree );
}
}

View File

@@ -26,6 +26,7 @@
@selectionForeground=@foreground
@disabledText=777777
@textComponentBackground=45494A
@cellFocusColor=000000
@icon=adadad
@@ -173,7 +174,6 @@ TabbedPane.contentAreaColor=323232
Table.background=@textComponentBackground
Table.gridColor=4F5152
Table.focusSelectedCellHighlightBorder=2,3,2,3,78c0ff
#---- TableHeader ----
@@ -185,3 +185,5 @@ TableHeader.bottomSeparatorColor=585858
#---- Tree ----
Tree.background=@textComponentBackground
Tree.hash=505355

View File

@@ -44,6 +44,7 @@ TableHeaderUI=com.formdev.flatlaf.ui.FlatTableHeaderUI
TextAreaUI=com.formdev.flatlaf.ui.FlatTextAreaUI
TextFieldUI=com.formdev.flatlaf.ui.FlatTextFieldUI
TextPaneUI=com.formdev.flatlaf.ui.FlatTextPaneUI
TreeUI=com.formdev.flatlaf.ui.FlatTreeUI
#---- variables ----
@@ -99,8 +100,8 @@ FormattedTextField.margin=@textComponentMargin
#---- List ----
List.cellNoFocusBorder=1,6,1,6
List.focusCellHighlightBorder=1,6,1,6,@selectionBackground
List.focusSelectedCellHighlightBorder=1,6,1,6,@selectionBackground
List.focusCellHighlightBorder=1,6,1,6,@cellFocusColor
List.focusSelectedCellHighlightBorder=1,6,1,6,@cellFocusColor
#---- Menu ----
@@ -225,7 +226,7 @@ Table.ascendingSortIcon=com.formdev.flatlaf.icons.FlatAscendingSortIcon
Table.descendingSortIcon=com.formdev.flatlaf.icons.FlatDescendingSortIcon
Table.sortIconColor=@icon
Table.cellNoFocusBorder=2,3,2,3
Table.focusSelectedCellHighlightBorder=2,3,2,3,@foreground
Table.focusSelectedCellHighlightBorder=2,3,2,3,@cellFocusColor
#---- TableHeader ----
@@ -256,6 +257,15 @@ TextPane.margin=@textComponentMargin
#---- Tree ----
Tree.border=1,1,1,1
Tree.textBackground=@@Tree.background
Tree.selectionBorderColor=@cellFocusColor
Tree.rendererMargins=1,2,1,2
Tree.paintLines=false
Tree.leftChildIndent=7
Tree.rightChildIndent=11
Tree.rowHeight=0
Tree.expandedIcon=com.formdev.flatlaf.icons.FlatTreeExpandedIcon
Tree.collapsedIcon=com.formdev.flatlaf.icons.FlatTreeCollapsedIcon
Tree.leafIcon=com.formdev.flatlaf.icons.FlatTreeLeafIcon

View File

@@ -26,6 +26,7 @@
@selectionForeground=ffffff
@disabledText=999999
@textComponentBackground=ffffff
@cellFocusColor=000000
@icon=afafaf
@@ -184,3 +185,5 @@ TableHeader.bottomSeparatorColor=e5e5e5
#---- Tree ----
Tree.background=@textComponentBackground
Tree.hash=E6E6E6

View File

@@ -19,6 +19,7 @@
@background=ccffcc
@selectionBackground=00aa00
@textComponentBackground=ffffff
@cellFocusColor=ff0000
@icon=afafaf
@@ -197,3 +198,6 @@ TableHeader.bottomSeparatorColor=00ff00
#---- Tree ----
Tree.background=fff0ff
Tree.paintLines=true
Tree.hash=ff0000