This is an automated email from the ASF dual-hosted git repository.

mbien pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new a79bf74082 FlatLaf: use NetBeans folder icons in NB Explorer component 
instead of FlatLaf outlined folder icons (e.g. Projects or Files views)
     new 1b16acb909 Merge pull request #5760 from 
DevCharly/flatlaf-explorer-folder-icons
a79bf74082 is described below

commit a79bf740828ea2af998ff7b5ebd9bdaf73d95b5d
Author: Karl Tauber <k...@jformdesigner.com>
AuthorDate: Tue Apr 11 19:03:55 2023 +0200

    FlatLaf: use NetBeans folder icons in NB Explorer component instead of 
FlatLaf outlined folder icons (e.g. Projects or Files views)
    
    patch from 
https://gist.github.com/eirikbakke/5587bd548a668cb0588c3fdc7d9e9f48
---
 .../netbeans/swing/laf/flatlaf/FlatLaf.properties  |  6 ++
 .../swing/laf/flatlaf/icons/NBFlatAdapterIcon.java | 68 ++++++++++++++++++++++
 .../laf/flatlaf/icons/NBFlatTreeClosedIcon.java    | 26 +++++++++
 .../laf/flatlaf/icons/NBFlatTreeOpenIcon.java      | 26 +++++++++
 4 files changed, 126 insertions(+)

diff --git 
a/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLaf.properties
 
b/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLaf.properties
index 72b253d074..14e9814aa5 100644
--- 
a/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLaf.properties
+++ 
b/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLaf.properties
@@ -36,6 +36,12 @@ TabbedPane.tabHeight=30
 TabbedPane.inactiveUnderlineColor = $TabbedContainer.editor.contentBorderColor
 
 
+#---- Tree ----
+
+Tree.closedIcon = org.netbeans.swing.laf.flatlaf.icons.NBFlatTreeClosedIcon
+Tree.openIcon = org.netbeans.swing.laf.flatlaf.icons.NBFlatTreeOpenIcon
+
+
 #---- TabbedContainer ----
 
 TabbedContainer.editor.contentBorderColor=$Component.borderColor
diff --git 
a/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/icons/NBFlatAdapterIcon.java
 
b/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/icons/NBFlatAdapterIcon.java
new file mode 100644
index 0000000000..6d7b1cea0a
--- /dev/null
+++ 
b/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/icons/NBFlatAdapterIcon.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.netbeans.swing.laf.flatlaf.icons;
+
+import com.formdev.flatlaf.util.UIScale;
+import java.awt.Component;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.swing.plaf.UIResource;
+import org.openide.util.ImageUtilities;
+
+/**
+ * Adapter class which allows a NetBeans-loaded PNG or SVG icon to be used as 
a FlatLAF
+ * configuration setting. Respects FlatLAF's own scaling properties, as in
+ * {@code com.formdev.flatlaf.icons.FlatAbstractIcon}.
+ */
+abstract class NBFlatAdapterIcon implements Icon, UIResource {
+    private final Icon delegate;
+
+    public NBFlatAdapterIcon(String resourcePath) {
+        if (resourcePath == null) {
+            throw new NullPointerException();
+        }
+        Image delegateImg = ImageUtilities.loadImage(resourcePath);
+        this.delegate = delegateImg == null ? new ImageIcon() : 
ImageUtilities.image2Icon(delegateImg);
+    }
+
+    @Override
+    public void paintIcon(Component c, Graphics g, int x, int y) {
+        Graphics2D g2 = (Graphics2D) g.create();
+        try {
+            g2.translate(x, y);
+            UIScale.scaleGraphics(g2);
+            delegate.paintIcon(c, g2, 0, 0);
+        } finally {
+            g2.dispose();
+        }
+    }
+
+    @Override
+    public int getIconWidth() {
+        return UIScale.scale(delegate.getIconWidth());
+    }
+
+    @Override
+    public int getIconHeight() {
+        return UIScale.scale(delegate.getIconHeight());
+    }
+}
diff --git 
a/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/icons/NBFlatTreeClosedIcon.java
 
b/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/icons/NBFlatTreeClosedIcon.java
new file mode 100644
index 0000000000..4863184bba
--- /dev/null
+++ 
b/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/icons/NBFlatTreeClosedIcon.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.netbeans.swing.laf.flatlaf.icons;
+
+public class NBFlatTreeClosedIcon extends NBFlatAdapterIcon {
+    public NBFlatTreeClosedIcon() {
+        // Will load the SVG version if available.
+        super("org/netbeans/swing/plaf/resources/hidpi-folder-closed.png");
+    }
+}
diff --git 
a/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/icons/NBFlatTreeOpenIcon.java
 
b/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/icons/NBFlatTreeOpenIcon.java
new file mode 100644
index 0000000000..1e75d74523
--- /dev/null
+++ 
b/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/icons/NBFlatTreeOpenIcon.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.netbeans.swing.laf.flatlaf.icons;
+
+public class NBFlatTreeOpenIcon extends NBFlatAdapterIcon {
+    public NBFlatTreeOpenIcon() {
+        // Will load the SVG version if available.
+        super("org/netbeans/swing/plaf/resources/hidpi-folder-open.png");
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to