Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/barteo/emulator/app/ui/awt/AwtDisplayComponent.java


1   /*
2    *  MicroEmulator
3    *  Copyright (C) 2001-2003 Bartek Teodorczyk <barteo@it.pl>
4    *
5    *  This library is free software; you can redistribute it and/or
6    *  modify it under the terms of the GNU Lesser General Public
7    *  License as published by the Free Software Foundation; either
8    *  version 2.1 of the License, or (at your option) any later version.
9    *
10   *  This library is distributed in the hope that it will be useful,
11   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   *  Lesser General Public License for more details.
14   *
15   *  You should have received a copy of the GNU Lesser General Public
16   *  License along with this library; if not, write to the Free Software
17   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   */
19   
20  package com.barteo.emulator.app.ui.awt;
21  
22  import java.awt.Component;
23  import java.awt.Graphics;
24  
25  import com.barteo.emulator.DisplayComponent;
26  import com.barteo.emulator.app.ui.DisplayRepaintListener;
27  import com.barteo.emulator.device.Device;
28  import com.barteo.emulator.device.DeviceFactory;
29  import com.barteo.emulator.device.MutableImage;
30  import com.barteo.emulator.device.applet.AppletDeviceDisplay;
31  import com.barteo.emulator.device.applet.AppletMutableImage;
32  
33  
34  public class AwtDisplayComponent implements DisplayComponent
35  {
36    private Component deviceCanvas;
37    private AppletMutableImage displayImage = null;
38  
39  
40    AwtDisplayComponent(Component deviceCanvas)
41    {
42      this.deviceCanvas = deviceCanvas;
43    }
44  
45  
46    public void addDisplayRepaintListener(DisplayRepaintListener l)
47    {
48    }
49  
50  
51    public void removeDisplayRepaintListener(DisplayRepaintListener l)
52    {
53    }
54  
55  
56    public MutableImage getDisplayImage()
57    {
58      return displayImage;
59    }
60  
61  
62    public void paint(Graphics g) 
63    {
64      if (displayImage != null) {
65        g.drawImage(displayImage.getImage(), 0, 0, null);
66      }
67    }
68  
69    
70    public void repaint() 
71    {
72      Device device = DeviceFactory.getDevice();
73    
74      if (device != null) {
75        if (displayImage == null) {
76          displayImage = new AppletMutableImage(device.getDeviceDisplay().getFullWidth(), device.getDeviceDisplay().getFullHeight());
77        }
78    
79        Graphics gc = displayImage.getImage().getGraphics();
80        ((AppletDeviceDisplay) device.getDeviceDisplay()).paint(gc);
81      }
82    
83      deviceCanvas.repaint();
84    }
85    
86  }