You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2021/08/18 17:56:17 UTC

[GitHub] [netbeans] eirikbakke opened a new pull request #3116: [NETBEANS-5931] Consolidate duplicated logic to set rendering hints

eirikbakke opened a new pull request #3116:
URL: https://github.com/apache/netbeans/pull/3116


   There is a lot of duplicated logic around the NetBeans codebase relating to the setting of rendering hints on Graphics2D objects. This PR is an attempt to consolidate this logic into a single utility method.
   
   The PR for this issue will also fix a minor issue where non-editable text values in the property sheet ended up not being anti-aliased. See attached screenshot. With the new utility method, this becomes a one-line fix.
   
   ![NoAntialiasing](https://user-images.githubusercontent.com/886243/129948234-4b2d2729-ee1d-4e01-8dbd-fc76fa6b64bb.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] eirikbakke commented on pull request #3116: [NETBEANS-5931] Consolidate duplicated logic to set rendering hints

Posted by GitBox <gi...@apache.org>.
eirikbakke commented on pull request #3116:
URL: https://github.com/apache/netbeans/pull/3116#issuecomment-912603861


   I have now run this patch on a while on my Windows IDE (Windows LAF), and also tested it on MacOS (Aqua LAF) and Linux (on both the GTK+ and FlatLAF Dark LAFs). Text rendering looks good/unchanged.
   
   Removing the "work-in-progress" label from this PR; I think it should be safe to merge at this point.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] eirikbakke commented on a change in pull request #3116: [NETBEANS-5931] Consolidate duplicated logic to set rendering hints

Posted by GitBox <gi...@apache.org>.
eirikbakke commented on a change in pull request #3116:
URL: https://github.com/apache/netbeans/pull/3116#discussion_r692129857



##########
File path: platform/openide.awt/src/org/openide/awt/GraphicsUtils.java
##########
@@ -0,0 +1,91 @@
+/*
+ * 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.openide.awt;
+
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.Toolkit;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import javax.swing.UIManager;
+
+public final class GraphicsUtils {
+    private GraphicsUtils() {
+    }
+
+    private static final boolean antialias =
+        // System property to automatically turn on antialiasing for html strings
+        Boolean.getBoolean("nb.cellrenderer.antialiasing") // NOI18N
+         ||Boolean.getBoolean("swing.aatext") // NOI18N
+         ||(isGTK() && gtkShouldAntialias()) // NOI18N
+         || isAqua();

Review comment:
       I don't think nb.cellrenderer.antialasing or swing.aatext, or the isAqua() conditions are relevant or needed anymore. But I've left them in.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] eirikbakke commented on a change in pull request #3116: [NETBEANS-5931] Consolidate duplicated logic to set rendering hints

Posted by GitBox <gi...@apache.org>.
eirikbakke commented on a change in pull request #3116:
URL: https://github.com/apache/netbeans/pull/3116#discussion_r692132260



##########
File path: platform/openide.awt/src/org/openide/awt/GraphicsUtils.java
##########
@@ -0,0 +1,91 @@
+/*
+ * 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.openide.awt;
+
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.Toolkit;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import javax.swing.UIManager;
+
+public final class GraphicsUtils {
+    private GraphicsUtils() {
+    }
+
+    private static final boolean antialias =
+        // System property to automatically turn on antialiasing for html strings
+        Boolean.getBoolean("nb.cellrenderer.antialiasing") // NOI18N
+         ||Boolean.getBoolean("swing.aatext") // NOI18N
+         ||(isGTK() && gtkShouldAntialias()) // NOI18N
+         || isAqua();
+    private static Boolean gtkAA;
+    private static Map<Object,Object> hintsMap;
+
+    private static boolean isAqua () {
+        return "Aqua".equals(UIManager.getLookAndFeel().getID());
+    }
+
+    private static boolean isGTK () {
+        return "GTK".equals(UIManager.getLookAndFeel().getID());
+    }
+
+    private static final boolean gtkShouldAntialias() {
+        if (gtkAA == null) {
+            Object o = Toolkit.getDefaultToolkit().getDesktopProperty("gnome.Xft/Antialias"); //NOI18N

Review comment:
       Nowadays, I think this condition is already incorporated by JDK, and put into the awt.font.desktophints property (since https://bugs.openjdk.java.net/browse/JDK-5030990 ). But it doesn't hurt to leave it.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] eirikbakke commented on a change in pull request #3116: [NETBEANS-5931] Consolidate duplicated logic to set rendering hints

Posted by GitBox <gi...@apache.org>.
eirikbakke commented on a change in pull request #3116:
URL: https://github.com/apache/netbeans/pull/3116#discussion_r692126377



##########
File path: platform/o.n.swing.plaf/src/org/netbeans/swing/plaf/util/UIUtils.java
##########
@@ -25,21 +25,12 @@
 import java.awt.*;
 import java.lang.reflect.Method;
 import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
 
 /** XP color scheme installer.
  *
  * @author  Dafe Simonek
  */
 public final class UIUtils {
-    private static HashMap<RenderingHints.Key, Object> hintsMap = null;
-    private static final boolean noAntialias =
-        Boolean.getBoolean("nb.no.antialias"); //NOI18N

Review comment:
       This property will no longer be respected. I think that's fine; it doesn't seem official, or needed anymore.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] eirikbakke merged pull request #3116: [NETBEANS-5931] Consolidate duplicated logic to set rendering hints

Posted by GitBox <gi...@apache.org>.
eirikbakke merged pull request #3116:
URL: https://github.com/apache/netbeans/pull/3116


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] eirikbakke commented on a change in pull request #3116: [NETBEANS-5931] Consolidate duplicated logic to set rendering hints

Posted by GitBox <gi...@apache.org>.
eirikbakke commented on a change in pull request #3116:
URL: https://github.com/apache/netbeans/pull/3116#discussion_r691500085



##########
File path: ide/csl.api/src/org/netbeans/modules/csl/editor/completion/MethodParamsTipPaintComponent.java
##########
@@ -51,20 +51,8 @@ public MethodParamsTipPaintComponent(List<List<String>> params, int idx, JTextCo
     }
     
     public @Override void paint(Graphics g) {
-        Object value = (Map) (Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints")); //NOI18N
-        Map renderingHints = (value instanceof Map) ? (java.util.Map) value : null;
-        if (renderingHints != null && g instanceof Graphics2D) {
-            Graphics2D g2d = (Graphics2D) g;
-            RenderingHints oldHints = g2d.getRenderingHints();
-            g2d.setRenderingHints(renderingHints);
-            try {
-                super.paint(g2d);
-            } finally {
-                g2d.setRenderingHints(oldHints);
-            }
-        } else {
-            super.paint(g);
-        }
+        GraphicsUtils.configureRenderingHints(g);
+        super.paint(g);

Review comment:
       The other example of a change in behavior is code that previously just took hints from awt.font.desktophints, but which now ends up doing the whole "isGTK() && gtkShouldAntialias()" etc. condition that is found in some existing places. Arguably doing the same in every place is better.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] matthiasblaesing commented on pull request #3116: [NETBEANS-5931] Consolidate duplicated logic to set rendering hints

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on pull request #3116:
URL: https://github.com/apache/netbeans/pull/3116#issuecomment-913224283


   I eyeballed this and to me this looks like a good cleanup. The amount of duplicate code and differing implementations was interesting, but I think the consolidation makes it easier to reason about the graphics state and unify hacks into a single place.
   
   I had this running on my IDE at home for a few days and prepared a test build to use at work. I hope I see nothing special :-)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] eirikbakke commented on a change in pull request #3116: [NETBEANS-5931] Consolidate duplicated logic to set rendering hints

Posted by GitBox <gi...@apache.org>.
eirikbakke commented on a change in pull request #3116:
URL: https://github.com/apache/netbeans/pull/3116#discussion_r692129857



##########
File path: platform/openide.awt/src/org/openide/awt/GraphicsUtils.java
##########
@@ -0,0 +1,91 @@
+/*
+ * 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.openide.awt;
+
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.Toolkit;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import javax.swing.UIManager;
+
+public final class GraphicsUtils {
+    private GraphicsUtils() {
+    }
+
+    private static final boolean antialias =
+        // System property to automatically turn on antialiasing for html strings
+        Boolean.getBoolean("nb.cellrenderer.antialiasing") // NOI18N
+         ||Boolean.getBoolean("swing.aatext") // NOI18N
+         ||(isGTK() && gtkShouldAntialias()) // NOI18N
+         || isAqua();

Review comment:
       I don't think nb.cellrenderer.antialasing or swing.aatext, or the isAqua() conditions are relevant or needed anymore (on Java 1.6 and above, where awt.font.desktophints is defined). But I've left them in.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] eirikbakke commented on pull request #3116: [NETBEANS-5931] Consolidate duplicated logic to set rendering hints

Posted by GitBox <gi...@apache.org>.
eirikbakke commented on pull request #3116:
URL: https://github.com/apache/netbeans/pull/3116#issuecomment-901938214


   OK, I have reviewed the whole diff again myself, and everything seems to be as intended. Will remove the "work-in-progress" tag once I have tested the patch in my working IDE for a while.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] eirikbakke commented on a change in pull request #3116: [NETBEANS-5931] Consolidate duplicated logic to set rendering hints

Posted by GitBox <gi...@apache.org>.
eirikbakke commented on a change in pull request #3116:
URL: https://github.com/apache/netbeans/pull/3116#discussion_r692120089



##########
File path: platform/api.visual/src/org/netbeans/api/visual/widget/SceneComponent.java
##########
@@ -101,12 +101,7 @@ public void paint (Graphics g) {
 //        System.out.println ("CLIP: " + g.getClipBounds ());
 //        long s = System.currentTimeMillis ();
         Graphics2D gr = (Graphics2D) g;
-
-        Object props = Toolkit.getDefaultToolkit ().getDesktopProperty ("awt.font.desktophints"); // NOI18N
-        if (props instanceof Map)
-            gr.addRenderingHints ((Map) props);
-        gr.setRenderingHint (RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
-        gr.setRenderingHint (RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

Review comment:
       Here's another case with a slight change in behavior from before. Previously, standard text antialiasing would be applied, but now, subpixel antaliasing might be applied on Windows if it's enabled in the rest of the IDE. I think that's good.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] neilcsmith-net commented on a change in pull request #3116: [NETBEANS-5931] Consolidate duplicated logic to set rendering hints

Posted by GitBox <gi...@apache.org>.
neilcsmith-net commented on a change in pull request #3116:
URL: https://github.com/apache/netbeans/pull/3116#discussion_r691490412



##########
File path: ide/csl.api/src/org/netbeans/modules/csl/editor/completion/MethodParamsTipPaintComponent.java
##########
@@ -51,20 +51,8 @@ public MethodParamsTipPaintComponent(List<List<String>> params, int idx, JTextCo
     }
     
     public @Override void paint(Graphics g) {
-        Object value = (Map) (Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints")); //NOI18N
-        Map renderingHints = (value instanceof Map) ? (java.util.Map) value : null;
-        if (renderingHints != null && g instanceof Graphics2D) {
-            Graphics2D g2d = (Graphics2D) g;
-            RenderingHints oldHints = g2d.getRenderingHints();
-            g2d.setRenderingHints(renderingHints);
-            try {
-                super.paint(g2d);
-            } finally {
-                g2d.setRenderingHints(oldHints);
-            }
-        } else {
-            super.paint(g);
-        }
+        GraphicsUtils.configureRenderingHints(g);
+        super.paint(g);

Review comment:
       This isn't the same behaviour.  Should it be?  What are the implications of not being?
   
   Another method could be `GraphicsUtils.withRenderingHints(Graphics g, Consumer<Graphics> paint)` that sets and resets around the paint task?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] matthiasblaesing commented on pull request #3116: [NETBEANS-5931] Consolidate duplicated logic to set rendering hints

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on pull request #3116:
URL: https://github.com/apache/netbeans/pull/3116#issuecomment-929530000


   The cycle is short, so I suggest to work on this now. I now ran a few weeks with this PR merged and did not see problems. I have a small followup change, that uses this and improves the look of the unittest bar and would like to get this done :-).
   
   From my POV is needed here:
   - rebase this onto current master (there are conflicts and IMHO rebasing gives cleaner results than merging master)
   - document the new method in `apichanges.xml`. For the name might it make sense to name the method "configureDefaultRenderingHints"? And an implementation note that describes what that means?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] eirikbakke merged pull request #3116: [NETBEANS-5931] Consolidate duplicated logic to set rendering hints

Posted by GitBox <gi...@apache.org>.
eirikbakke merged pull request #3116:
URL: https://github.com/apache/netbeans/pull/3116


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] eirikbakke commented on a change in pull request #3116: [NETBEANS-5931] Consolidate duplicated logic to set rendering hints

Posted by GitBox <gi...@apache.org>.
eirikbakke commented on a change in pull request #3116:
URL: https://github.com/apache/netbeans/pull/3116#discussion_r691498855



##########
File path: ide/csl.api/src/org/netbeans/modules/csl/editor/completion/MethodParamsTipPaintComponent.java
##########
@@ -51,20 +51,8 @@ public MethodParamsTipPaintComponent(List<List<String>> params, int idx, JTextCo
     }
     
     public @Override void paint(Graphics g) {
-        Object value = (Map) (Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints")); //NOI18N
-        Map renderingHints = (value instanceof Map) ? (java.util.Map) value : null;
-        if (renderingHints != null && g instanceof Graphics2D) {
-            Graphics2D g2d = (Graphics2D) g;
-            RenderingHints oldHints = g2d.getRenderingHints();
-            g2d.setRenderingHints(renderingHints);
-            try {
-                super.paint(g2d);
-            } finally {
-                g2d.setRenderingHints(oldHints);
-            }
-        } else {
-            super.paint(g);
-        }
+        GraphicsUtils.configureRenderingHints(g);
+        super.paint(g);

Review comment:
       Yes, here is one example of a change in behavior. My inclination here is that resetting the hints is unnecessary, and that it would be worth simplifying the code. In the worst case, some other painting code ends up using the leftover hints--but they are the correct hints that should be used throughout the IDE in any case. Any code that wishes to use explicitly different hints had better set their own hints.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] matthiasblaesing commented on pull request #3116: [NETBEANS-5931] Consolidate duplicated logic to set rendering hints

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on pull request #3116:
URL: https://github.com/apache/netbeans/pull/3116#issuecomment-929530000


   The cycle is short, so I suggest to work on this now. I now ran a few weeks with this PR merged and did not see problems. I have a small followup change, that uses this and improves the look of the unittest bar and would like to get this done :-).
   
   From my POV is needed here:
   - rebase this onto current master (there are conflicts and IMHO rebasing gives cleaner results than merging master)
   - document the new method in `apichanges.xml`. For the name might it make sense to name the method "configureDefaultRenderingHints"? And an implementation note that describes what that means?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] eirikbakke commented on a change in pull request #3116: [NETBEANS-5931] Consolidate duplicated logic to set rendering hints

Posted by GitBox <gi...@apache.org>.
eirikbakke commented on a change in pull request #3116:
URL: https://github.com/apache/netbeans/pull/3116#discussion_r691503067



##########
File path: ide/csl.api/src/org/netbeans/modules/csl/editor/completion/MethodParamsTipPaintComponent.java
##########
@@ -51,20 +51,8 @@ public MethodParamsTipPaintComponent(List<List<String>> params, int idx, JTextCo
     }
     
     public @Override void paint(Graphics g) {
-        Object value = (Map) (Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints")); //NOI18N
-        Map renderingHints = (value instanceof Map) ? (java.util.Map) value : null;
-        if (renderingHints != null && g instanceof Graphics2D) {
-            Graphics2D g2d = (Graphics2D) g;
-            RenderingHints oldHints = g2d.getRenderingHints();
-            g2d.setRenderingHints(renderingHints);
-            try {
-                super.paint(g2d);
-            } finally {
-                g2d.setRenderingHints(oldHints);
-            }
-        } else {
-            super.paint(g);
-        }
+        GraphicsUtils.configureRenderingHints(g);
+        super.paint(g);

Review comment:
       I also added the "put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)" hint, which enables anti-aliasing for non-text things such as diagonal lines and curves. Some existing sites did this already (presumably the ones that actually needed it).




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] eirikbakke commented on pull request #3116: [NETBEANS-5931] Consolidate duplicated logic to set rendering hints

Posted by GitBox <gi...@apache.org>.
eirikbakke commented on pull request #3116:
URL: https://github.com/apache/netbeans/pull/3116#issuecomment-929618760


   Great, I'll rebase and apply the suggested changes...


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] eirikbakke commented on pull request #3116: [NETBEANS-5931] Consolidate duplicated logic to set rendering hints

Posted by GitBox <gi...@apache.org>.
eirikbakke commented on pull request #3116:
URL: https://github.com/apache/netbeans/pull/3116#issuecomment-913231072


   Great, thank you for testing!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] eirikbakke commented on pull request #3116: [NETBEANS-5931] Consolidate duplicated logic to set rendering hints

Posted by GitBox <gi...@apache.org>.
eirikbakke commented on pull request #3116:
URL: https://github.com/apache/netbeans/pull/3116#issuecomment-930575848


   Thanks--will merge! The remaining travis errors seem to be unrelated (all in the "Test groovy modules" series).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] eirikbakke commented on pull request #3116: [NETBEANS-5931] Consolidate duplicated logic to set rendering hints

Posted by GitBox <gi...@apache.org>.
eirikbakke commented on pull request #3116:
URL: https://github.com/apache/netbeans/pull/3116#issuecomment-929670777






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] eirikbakke commented on a change in pull request #3116: [NETBEANS-5931] Consolidate duplicated logic to set rendering hints

Posted by GitBox <gi...@apache.org>.
eirikbakke commented on a change in pull request #3116:
URL: https://github.com/apache/netbeans/pull/3116#discussion_r692125306



##########
File path: platform/o.n.core/src/org/netbeans/beaninfo/editors/FontEditor.java
##########
@@ -140,10 +136,7 @@ public void paintValue (Graphics g, Rectangle rectangle) {
     }
 
     private void paintText (Graphics g, Rectangle rectangle, String text) {
-        if( antialias && g instanceof Graphics2D ) {
-            ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
-            ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
-        }
+        GraphicsUtils.configureRenderingHints(g);

Review comment:
       Here's another spot where the new behavior might end up enabling subpixel antialiasing, vs. the old standard antialiasing. That's good.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] eirikbakke commented on pull request #3116: [NETBEANS-5931] Consolidate duplicated logic to set rendering hints

Posted by GitBox <gi...@apache.org>.
eirikbakke commented on pull request #3116:
URL: https://github.com/apache/netbeans/pull/3116#issuecomment-929670777


   I force-pushed a revised version of these two commits:
   * Rebased to master to fix merge conflict.
   * Added apichanges.xml entry.
   * Renamed the new method to configureDefaultRenderingHints.
   * Added Javadoc to the new configureDefaultRenderingHints.
   
   Now just waiting for the build and tests to finish...


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] eirikbakke edited a comment on pull request #3116: [NETBEANS-5931] Consolidate duplicated logic to set rendering hints

Posted by GitBox <gi...@apache.org>.
eirikbakke edited a comment on pull request #3116:
URL: https://github.com/apache/netbeans/pull/3116#issuecomment-912603861


   I have now run this patch for a while on my Windows IDE (Windows LAF), and also tested it on MacOS (Aqua LAF) and Linux (on both the GTK+ and FlatLAF Dark LAFs). Text rendering looks good/unchanged.
   
   Removing the "work-in-progress" label from this PR; I think it should be safe to merge at this point.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] eirikbakke commented on a change in pull request #3116: [NETBEANS-5931] Consolidate duplicated logic to set rendering hints

Posted by GitBox <gi...@apache.org>.
eirikbakke commented on a change in pull request #3116:
URL: https://github.com/apache/netbeans/pull/3116#discussion_r692126974



##########
File path: platform/o.n.swing.tabcontrol/src/org/netbeans/swing/tabcontrol/plaf/ColorUtil.java
##########
@@ -38,8 +39,6 @@
     private static Map<RenderingHints.Key, Object> hintsMap = null;
     private static final boolean noGpCache = Boolean.getBoolean(
             "netbeans.winsys.nogpcache");  //NOI18N
-    private static final boolean noAntialias = 
-        Boolean.getBoolean("nb.no.antialias"); //NOI18N

Review comment:
       This property will no longer be respected. I think that's fine; it doesn't seem official, or needed anymore.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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