javauis/lcdui_qt/src/javax/microedition/lcdui/Graphics.java
changeset 76 4ad59aaee882
parent 61 bf7ee68962da
child 78 71ad690e91f5
equal deleted inserted replaced
69:773449708c84 76:4ad59aaee882
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2009, 2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
   108     int[] currentClip = new int[4];
   108     int[] currentClip = new int[4];
   109     int currentStrokeStyle;
   109     int currentStrokeStyle;
   110     
   110     
   111     private com.nokia.mj.impl.rt.support.Finalizer finalizer;
   111     private com.nokia.mj.impl.rt.support.Finalizer finalizer;
   112 
   112 
   113     //Constructor
   113     // Constructor
   114     Graphics(Buffer buffer, Rectangle clipRect)
   114     Graphics(Buffer buffer, Rectangle clipRect)
   115     {
   115     {
   116         finalizer = ((finalizer != null) ? finalizer
   116         finalizer = ((finalizer != null) ? finalizer
   117                      : new com.nokia.mj.impl.rt.support.Finalizer()
   117                      : new com.nokia.mj.impl.rt.support.Finalizer()
   118         {
   118         {
   121                 if(finalizer != null)
   121                 if(finalizer != null)
   122                 {
   122                 {
   123                     finalizer = null;
   123                     finalizer = null;
   124                     if(!ESWTUIThreadRunner.isDisposed())
   124                     if(!ESWTUIThreadRunner.isDisposed())
   125                     {
   125                     {
   126                         ESWTUIThreadRunner.safeSyncExec(new Runnable()
   126                         dispose();
   127                         {
       
   128                             public void run()
       
   129                             {
       
   130                                 dispose();
       
   131                             }
       
   132                         });
       
   133 
       
   134                     }
   127                     }
   135                 }
   128                 }
   136             }
   129             }
   137         });
   130         });
   138         currentClip[0] = clipRect.x;
   131         currentClip[0] = clipRect.x;
   141         currentClip[3] = clipRect.height;
   134         currentClip[3] = clipRect.height;
   142         setDefaultSettings();
   135         setDefaultSettings();
   143         graphicsBuffer = buffer;
   136         graphicsBuffer = buffer;
   144     }
   137     }
   145 
   138 
   146 
       
   147 
       
   148     /**
   139     /**
   149      * Disposes objects with native counterparts
   140      * Disposes objects with native counterparts
   150      */
   141      */
   151     void dispose()
   142     void dispose()
   152     {
   143     {
   160      * Resets Graphics state to initial.
   151      * Resets Graphics state to initial.
   161      * Reset does not set the clip.
   152      * Reset does not set the clip.
   162      */
   153      */
   163     void reset()
   154     void reset()
   164     {
   155     {
   165     	synchronized(graphicsBuffer) {
   156         synchronized(graphicsBuffer) {
   166     		// setDefaultSettings() must be called 
   157             // setDefaultSettings() must be called 
   167     		// before the setGraphicsDefaults() since
   158             // before the setGraphicsDefaults() since
   168     		// graphicsBuffer (Buffer implementation) uses 
   159             // graphicsBuffer (Buffer implementation) uses 
   169     		// the member values of this instance when setting the defaults
   160             // the member values of this instance when setting the defaults
   170     		setDefaultSettings();
   161             setDefaultSettings();
   171     		graphicsBuffer.setGraphicsDefaults(this);
   162             graphicsBuffer.setGraphicsDefaults(this);
   172     	}
   163         }
   173     }
   164     }
   174 
   165 
   175     void setDefaultSettings() 
   166     void setDefaultSettings() 
   176     {
   167     {
   177         currentFont = Buffer.defaultFont;
   168         currentFont = Buffer.defaultFont;