javauis/lcdui_akn/javalcdui/javasrc.nokialcdui/com/nokia/mid/ui/CanvasGraphicsItem.java
branchRCL_3
changeset 21 4376525cdefb
parent 14 04becd199f91
child 24 6c158198356e
equal deleted inserted replaced
19:71c436fe3ce0 21:4376525cdefb
    26 import com.nokia.mid.ui.CanvasItem;
    26 import com.nokia.mid.ui.CanvasItem;
    27 import com.nokia.mid.ui.CanvasGraphicsItemPainter;
    27 import com.nokia.mid.ui.CanvasGraphicsItemPainter;
    28 
    28 
    29 import com.nokia.mj.impl.rt.legacy.NativeError;
    29 import com.nokia.mj.impl.rt.legacy.NativeError;
    30 import com.nokia.mj.impl.rt.legacy.ToolkitInvoker;
    30 import com.nokia.mj.impl.rt.legacy.ToolkitInvoker;
       
    31 import com.nokia.mj.impl.rt.support.Finalizer;
       
    32 
    31 /**
    33 /**
    32  * <P>
    34  * <P>
    33  * A <code>CanvasGraphicsItem</code> is a drawable component that is used with a
    35  * A <code>CanvasGraphicsItem</code> is a drawable component that is used with a
    34  * parent object; with <code>Canvas</code>. The <code>CanvasGraphicsItem</code>
    36  * parent object; with <code>Canvas</code>. The <code>CanvasGraphicsItem</code>
    35  * may be added to and removed from <code>Canvas</code> through
    37  * may be added to and removed from <code>Canvas</code> through
    84     ToolkitInvoker iToolkitInvoker;
    86     ToolkitInvoker iToolkitInvoker;
    85 
    87 
    86     // LCDUI Toolkit object.
    88     // LCDUI Toolkit object.
    87     Object iToolkit;
    89     Object iToolkit;
    88 
    90 
       
    91     //Object finalizer
       
    92     private Finalizer mFinalizer;
       
    93 
    89     private com.nokia.mid.ui.CanvasGraphicsItemPainter iItemPainter;
    94     private com.nokia.mid.ui.CanvasGraphicsItemPainter iItemPainter;
    90 
    95 
    91     /**
    96     /**
    92      * Creates a new <code>CanvasGraphicsItem</code> object with the given
    97      * Creates a new <code>CanvasGraphicsItem</code> object with the given
    93      * initial size.
    98      * initial size.
   147         iVisible = false;
   152         iVisible = false;
   148 
   153 
   149         // Construction was successful. Store handle and register for
   154         // Construction was successful. Store handle and register for
   150         // finalization.
   155         // finalization.
   151         iHandle = handle;
   156         iHandle = handle;
       
   157 
       
   158         mFinalizer = new Finalizer()
       
   159         {
       
   160             public void finalizeImpl()
       
   161             {
       
   162                 registeredFinalize();
       
   163             }
       
   164         };
   152     }
   165     }
   153 
   166 
   154     /**
   167     /**
   155      * Set the parent object of this <code>CanvasGraphicsItem</code>.
   168      * Set the parent object of this <code>CanvasGraphicsItem</code>.
   156      *
   169      *
   458     public final void repaint()
   471     public final void repaint()
   459     {
   472     {
   460         iItemPainter.Repaint(0, 0, getWidth(), getHeight());
   473         iItemPainter.Repaint(0, 0, getWidth(), getHeight());
   461     }
   474     }
   462 
   475 
       
   476     /*
       
   477      * Disposes the Landmark native peer object, if the handles are valid.
       
   478      * Invalid (negative) handles indicate that their creation failed in the
       
   479      * first place.
       
   480      */
       
   481     final void registeredFinalize()
       
   482     {
       
   483         synchronized (iToolkit)
       
   484         {
       
   485             if (iHandle > 0)
       
   486             {
       
   487                 _dispose(getToolkitHandle(), iHandle);
       
   488                 iHandle = 0;
       
   489             }
       
   490         }
       
   491     }
       
   492 
   463     void Repaint(Graphics aGraphics)
   493     void Repaint(Graphics aGraphics)
   464     {
   494     {
   465         paint(aGraphics);
   495         paint(aGraphics);
   466     }
   496     }
   467 
   497