Created
April 2, 2023 00:34
-
-
Save eirikbakke/5587bd548a668cb0588c3fdc7d9e9f48 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 35f1470f953212ca84c5a0de98b0d0d5eff735e9 | |
Author: Eirik Bakke <[email protected]> | |
Date: Mon Aug 9 14:20:47 2021 +0200 | |
Use the regular NetBeans SVG folder icons in FlatLAF. | |
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 be48cc194d..8144aabbea 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"); | |
+ } | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment