Author: allain.lalonde
Date: Tue Jul 14 13:37:05 2009
New Revision: 467

Modified:
     
piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/pswing/PSwing.java

Log:
Fixed Issue 83; Guessed that the ellipses were caused my Mac's ability to  
do subpixel font rendering and MS's inability to do so. MS was probably  
rounding down to the next pixel and macs were not, allowing the text to be  
a couple pixels longer. Disabling it seems to do the trick.

Modified:  
piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/pswing/PSwing.java
==============================================================================
---  
piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/pswing/PSwing.java
         
(original)
+++  
piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/pswing/PSwing.java
         
Tue Jul 14 13:37:05 2009
@@ -364,43 +364,24 @@
       *
       * @param g2 graphics context for rendering the JComponent
       */
-    public void paint( Graphics2D g2 ) {
-        if( component.getBounds().isEmpty() ) {
+    public void paint(Graphics2D g2) {
+        if (component.getBounds().isEmpty()) {
              // The component has not been initialized yet.
              return;
          }

-        PSwingRepaintManager manager =  
(PSwingRepaintManager)RepaintManager.currentManager( component );
-        manager.lockRepaint( component );
+        PSwingRepaintManager manager = (PSwingRepaintManager)  
RepaintManager.currentManager(component);
+        manager.lockRepaint(component);
+
+        RenderingHints oldHints = g2.getRenderingHints();
+
+        g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
+                RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
+        component.paint(g2);
+
+        g2.setRenderingHints(oldHints);

-        Graphics2D bufferedGraphics = null;
-        if( !isBufferValid() ) {
-            // Get the graphics context associated with a new buffered  
image.
-            // Use TYPE_INT_ARGB_PRE so that transparent components look  
good on Windows.
-            buffer = new BufferedImage( component.getWidth(),  
component.getHeight(), BufferedImage.TYPE_INT_ARGB_PRE );
-            bufferedGraphics = buffer.createGraphics();
-        }
-        else {
-            // Use the graphics context associated with the existing  
buffered image
-            bufferedGraphics = buffer.createGraphics();
-            // Clear the buffered image to prevent artifacts on Macintosh
-            bufferedGraphics.setBackground( BUFFER_BACKGROUND_COLOR );
-            bufferedGraphics.clearRect( 0, 0, component.getWidth(),  
component.getHeight() );
-        }
-
-        // Start with the rendering hints from the provided graphics  
context
-        bufferedGraphics.setRenderingHints( g2.getRenderingHints() );
-
-        //PSwing sometimes causes JComponent text to render with "..."  
when fractional font metrics are enabled.  These are now always disabled  
for the offscreen buffer.
-        bufferedGraphics.setRenderingHint(  
RenderingHints.KEY_FRACTIONALMETRICS,  
RenderingHints.VALUE_FRACTIONALMETRICS_OFF );
-
-        // Draw the component to the buffer
-        component.paint( bufferedGraphics );
-
-        // Draw the buffer to g2's associated drawing surface
-        g2.drawRenderedImage( buffer, IDENTITY_TRANSFORM );
-
-        manager.unlockRepaint( component );
+        manager.unlockRepaint(component);
      }

      public void setVisible(boolean visible) {

--~--~---------~--~----~------------~-------~--~----~
Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to