From cfefacbbbe53e7e4a2db4e0c90c3156af6a51687 Mon Sep 17 00:00:00 2001 From: Roman Kennke Date: Thu, 1 Mar 2007 01:01:00 +0000 Subject: 2007-03-01 Roman Kennke * java/awt/Canvas.java (graphicsConfiguration): Removed duplicate (from Component) field. (Canvas(GraphicsConfiguration)): Set the Component's graphicsConfig field. (getGraphicsConfigurationImpl): Removed. * java/awt/Component.java (getGraphicsConfiguration): Moved implementation here. Synchronize on tree lock to prevent threading nastiness. Don't query peer and instead return the setting of the graphicsConfig field. (getGraphicsConfigurationImpl): Removed. * java/awt/Window.java (graphicsConfiguration): Removed duplicate (from Component) field. (Window): Set the Component's graphicsConfig field. (Window(GraphicsConfiguration)): Set the Component's graphicsConfig field. (Window(Window,GraphicsConfiguration)): Set the Component's graphicsConfig field. (getGraphicsConfigurationImpl): Removed. (getGraphicsConfiguration): Fetch the local graphics env here if not already done and return that. --- java/awt/Canvas.java | 14 +------------- java/awt/Component.java | 39 +++++++++++++++++---------------------- java/awt/Window.java | 32 ++++++++++++++------------------ 3 files changed, 32 insertions(+), 53 deletions(-) (limited to 'java') diff --git a/java/awt/Canvas.java b/java/awt/Canvas.java index 843fded44..95db1f57e 100644 --- a/java/awt/Canvas.java +++ b/java/awt/Canvas.java @@ -74,11 +74,6 @@ public class Canvas */ private static transient long next_canvas_number; - /** - * The graphics configuration associated with the canvas. - */ - transient GraphicsConfiguration graphicsConfiguration; - /** * The buffer strategy associated with this canvas. */ @@ -100,14 +95,7 @@ public class Canvas */ public Canvas(GraphicsConfiguration graphicsConfiguration) { - this.graphicsConfiguration = graphicsConfiguration; - } - - GraphicsConfiguration getGraphicsConfigurationImpl() - { - if (graphicsConfiguration != null) - return graphicsConfiguration; - return super.getGraphicsConfigurationImpl(); + this.graphicsConfig = graphicsConfiguration; } /** diff --git a/java/awt/Component.java b/java/awt/Component.java index 7f2cbb423..f8bed1761 100644 --- a/java/awt/Component.java +++ b/java/awt/Component.java @@ -726,7 +726,23 @@ public abstract class Component */ public GraphicsConfiguration getGraphicsConfiguration() { - return getGraphicsConfigurationImpl(); + GraphicsConfiguration conf = null; + synchronized (getTreeLock()) + { + if (graphicsConfig != null) + { + conf = graphicsConfig; + } + else + { + Component par = getParent(); + if (par != null) + { + conf = parent.getGraphicsConfiguration(); + } + } + } + return conf; } /** @@ -5433,27 +5449,6 @@ p *
  • the set of backward traversal keys this.peer = peer; } - /** - * Implementation method that allows classes such as Canvas and Window to - * override the graphics configuration without violating the published API. - * - * @return the graphics configuration - */ - GraphicsConfiguration getGraphicsConfigurationImpl() - { - if (peer != null) - { - GraphicsConfiguration config = peer.getGraphicsConfiguration(); - if (config != null) - return config; - } - - if (parent != null) - return parent.getGraphicsConfiguration(); - - return null; - } - /** * Translate an AWT 1.1 event ({@link AWTEvent}) into an AWT 1.0 * event ({@link Event}). diff --git a/java/awt/Window.java b/java/awt/Window.java index 41dff5577..2a59375ce 100644 --- a/java/awt/Window.java +++ b/java/awt/Window.java @@ -87,7 +87,6 @@ public class Window extends Container implements Accessible private transient WindowListener windowListener; private transient WindowFocusListener windowFocusListener; private transient WindowStateListener windowStateListener; - private transient GraphicsConfiguration graphicsConfiguration; private transient boolean shown; @@ -132,13 +131,13 @@ public class Window extends Container implements Accessible setLayout(new BorderLayout()); GraphicsEnvironment g = GraphicsEnvironment.getLocalGraphicsEnvironment(); - graphicsConfiguration = g.getDefaultScreenDevice().getDefaultConfiguration(); + graphicsConfig = g.getDefaultScreenDevice().getDefaultConfiguration(); } Window(GraphicsConfiguration gc) { this(); - graphicsConfiguration = gc; + graphicsConfig = gc; } /** @@ -204,19 +203,11 @@ public class Window extends Container implements Accessible throw new IllegalArgumentException ("gc must be from a screen device"); if (gc == null) - graphicsConfiguration = GraphicsEnvironment.getLocalGraphicsEnvironment() - .getDefaultScreenDevice() - .getDefaultConfiguration(); + graphicsConfig = GraphicsEnvironment.getLocalGraphicsEnvironment() + .getDefaultScreenDevice() + .getDefaultConfiguration(); else - graphicsConfiguration = gc; - } - - GraphicsConfiguration getGraphicsConfigurationImpl() - { - if (graphicsConfiguration != null) - return graphicsConfiguration; - - return super.getGraphicsConfigurationImpl(); + graphicsConfig = gc; } /** @@ -1073,9 +1064,14 @@ public class Window extends Container implements Accessible */ public GraphicsConfiguration getGraphicsConfiguration() { - if (graphicsConfiguration != null) return graphicsConfiguration; - if (peer != null) return peer.getGraphicsConfiguration(); - return null; + GraphicsConfiguration conf = graphicsConfig; + if (conf == null) + { + conf = GraphicsEnvironment.getLocalGraphicsEnvironment() + .getDefaultScreenDevice().getDefaultConfiguration(); + graphicsConfig = conf; + } + return conf; } protected void processWindowFocusEvent(WindowEvent event) -- cgit v1.2.1