Changeset 1545


Ignore:
Timestamp:
11/19/20 13:41:28 (3 years ago)
Author:
bnemhaus
Message:

Expeditee now respects the users antialiasing setting. The previous system

  1. Attempted to respect antialiasing by checking the setting and enabling it if the setting was true
  2. In the process of painting the frame some special items (link marks etc) want to use antialiasing reguardless of setting. This was achieved by turning antialiasing on, doing the thing and then turning it off. This unfortunately meant that, in the scenario that the users antialiasing setting is on, it gets turned off after drawing one of these special items and doesn't get turn on again until all items have been drawn.

The new system still always turns antialiasing on for these special items, but instead of turning it off after, it returns it to the setting it was previously on. This is achieved with two new functions: setTransientAntialiasingOn() and setTransientAntialiasingOff().

On a related note, there was also an issue with some polygons being drawn with a thickness of 0.0f, which was causing them to antialias badly. They now have a thickness of 1.0f.

Location:
trunk/src/org/expeditee
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/gio/GraphicsManager.java

    r1198 r1545  
    156156        public abstract void setAntialiasing(boolean on);
    157157       
     158        public abstract void setTransientAntialiasingOn();
     159        public abstract void setTransientAntialiasingOff();
     160       
    158161        /** Sets the default font for the current rendering surface. */
    159162        public abstract void setFont(Font font);
  • trunk/src/org/expeditee/gio/javafx/JavaFXGraphicsManager.java

    r1198 r1545  
    314314                // TODO: Implement. cts16
    315315        }
     316       
     317        public void setTransientAntialiasingOn() {
     318                // TODO: Implement. Bryce
     319        }
     320       
     321        public void setTransientAntialiasingOff() {
     322                // TODO: Implement. Bryce
     323        }
    316324
    317325        @Override
  • trunk/src/org/expeditee/gio/swing/SwingGraphicsManager.java

    r1540 r1545  
    185185                _surfaceStack.getCurrentSurface().setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
    186186        }
    187 
     187       
     188        private boolean frameUsingAntialiasing = false;
     189       
    188190        @Override
    189191        public void setAntialiasing(boolean on) {
     
    197199
    198200                if (on) {
    199                         if (hasAntialiasing) {
    200                                 //return;
    201                         }
    202201                        surface.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    203                         hasAntialiasing = true;
     202                        frameUsingAntialiasing = true;
    204203                } else {
    205                         if (hasAntialiasing) {
    206                                 //return;
    207                         }
    208204                        surface.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
     205                        frameUsingAntialiasing = false;
    209206                }
    210207        }
    211208       
    212         private static boolean hasAntialiasing = false;
     209        @Override
     210        public void setTransientAntialiasingOn() {
     211                if (!frameUsingAntialiasing) {
     212                        Graphics2D surface = _surfaceStack.getCurrentSurface();
     213                        surface.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
     214                }
     215        }
     216       
     217        @Override
     218        public void setTransientAntialiasingOff() {
     219                if (!frameUsingAntialiasing) {
     220                        Graphics2D surface = _surfaceStack.getCurrentSurface();
     221                        surface.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
     222                }
     223        }
    213224
    214225        @Override
     
    591602        public void refreshRootSurface() {
    592603                Graphics2D rootSurface = (Graphics2D) _jFrame.getContentPane().getGraphics();
    593                 setAntialiasing(rootSurface, true);
     604                rootSurface.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    594605                final java.awt.Font rootSurfaceFont = rootSurface.getFont().deriveFont(40f);
    595606                rootSurface.setFont(rootSurfaceFont);
  • trunk/src/org/expeditee/items/Dot.java

    r1540 r1545  
    2727import org.expeditee.core.Fill;
    2828import org.expeditee.core.Point;
     29import org.expeditee.core.Stroke;
    2930import org.expeditee.core.bounds.AxisAlignedBoxBounds;
    3031import org.expeditee.core.bounds.Bounds;
     
    234235                        } else if (_highlightMode == HighlightMode.Connected) {
    235236                                g.drawRectangle(bounds.getTopLeft(), bounds.getSize(), 0.0f, null, highlightColor, HIGHLIGHT_STROKE, null);
    236                                 System.err.println("Dot::paint:Painting Dot with colour: " + highlightColor);
    237237                        } else if (_highlightMode == HighlightMode.Normal) {
    238238                                g.drawOval(bounds.getCentre(), bounds.getSize(), 0.0f, fill, highlightColor, DOT_STROKE);
    239239                        }
    240                         // System.out.println(_mode.toString());
    241240                }
    242241
  • trunk/src/org/expeditee/items/Item.java

    r1519 r1545  
    105105        public static final Float DEFAULT_THICKNESS = 2f;
    106106
    107         public static final Float MINIMUM_THICKNESS = 0f;
     107        public static final Float MINIMUM_THICKNESS = 1f;
    108108
    109109        public static final Float MINIMUM_PAINT_THICKNESS = 1f;
     
    31703170
    31713171                        // Small circles look rubbish without AA. cts16
    3172                         g.setAntialiasing(true);
     3172                        g.setTransientAntialiasingOn();
    31733173                       
    31743174                        if (hasLink && getLinkMark()) {
     
    31903190                        }
    31913191                       
    3192                         g.setAntialiasing(false);
     3192                        g.setTransientAntialiasingOff();
    31933193                }
    31943194        }
     
    32083208               
    32093209                GraphicsManager g = EcosystemManager.getGraphicsManager();
    3210                 g.setAntialiasing(true);
     3210                g.setTransientAntialiasingOn();
    32113211                Font font = new Font();
    32123212                g.drawString("\uD83D\uDD11", new Point(x,y), font, fontColour);
    3213                 g.setAntialiasing(false);
     3213                g.setTransientAntialiasingOff();
    32143214        }
    32153215       
     
    32183218                if (encryptionLabel != null && encryptionLabel.length() > 0) {
    32193219                        GraphicsManager g = EcosystemManager.getGraphicsManager();
    3220                         g.setAntialiasing(true);
     3220                        g.setTransientAntialiasingOn();
    32213221                        Font font = new Font();
    32223222                        g.drawString("\uD83D\uDD12", new Point(x,y), font, Colour.BLACK);
    3223                         g.setAntialiasing(false);
     3223                        g.setTransientAntialiasingOff();
    32243224                }
    32253225        }
  • trunk/src/org/expeditee/items/Line.java

    r1541 r1545  
    535535                GraphicsManager g = EcosystemManager.getGraphicsManager();
    536536               
    537                 g.setAntialiasing(true);
     537                g.setTransientAntialiasingOn();
    538538                g.drawPolygon(arrow.close(), null, null, 0.0f, arrowFill, arrowColour, arrowStroke);
    539                 g.setAntialiasing(false);
     539                g.setTransientAntialiasingOff();
    540540        }
    541541
Note: See TracChangeset for help on using the changeset viewer.