|
1 /* |
|
2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 package com.nokia.microedition.m2g; |
|
19 |
|
20 import javax.microedition.m2g.ScalableGraphics; |
|
21 import javax.microedition.m2g.ScalableImage; |
|
22 import org.eclipse.swt.graphics.GC; |
|
23 import org.eclipse.swt.graphics.Image; |
|
24 import org.eclipse.swt.graphics.Rectangle; |
|
25 import org.eclipse.swt.widgets.*; |
|
26 |
|
27 public class ESWTScalableGraphics |
|
28 { |
|
29 Display iDisplay = null; |
|
30 Rectangle iCanvasBounds = null; |
|
31 ScalableGraphics iSg = null; |
|
32 GC iBufferGC = null; |
|
33 GC iRealGC = null; |
|
34 Image iBufferedImage = null; |
|
35 |
|
36 public ESWTScalableGraphics(Display display) |
|
37 { |
|
38 |
|
39 |
|
40 iSg = ScalableGraphics.createInstance(); |
|
41 iDisplay = display; |
|
42 } |
|
43 |
|
44 public ESWTScalableGraphics(Display display, Rectangle canvasBounds) |
|
45 { |
|
46 |
|
47 iSg = ScalableGraphics.createInstance(); |
|
48 iDisplay = display; |
|
49 iCanvasBounds = canvasBounds; |
|
50 } |
|
51 |
|
52 public void setBounds(Rectangle canvasBounds) |
|
53 { |
|
54 iCanvasBounds = canvasBounds; |
|
55 } |
|
56 |
|
57 public void bindTarget(GC gc) |
|
58 { |
|
59 |
|
60 iRealGC = gc; |
|
61 iBufferedImage = new Image(iDisplay, iCanvasBounds); |
|
62 iBufferGC = new GC(iBufferedImage); |
|
63 iSg.bindTarget(iBufferGC); |
|
64 } |
|
65 |
|
66 public void releaseTarget() |
|
67 { |
|
68 |
|
69 |
|
70 iSg.releaseTarget(); |
|
71 iBufferedImage.dispose(); |
|
72 iBufferGC.dispose(); |
|
73 /* iRealGC is disposed in paintControl */ |
|
74 iRealGC = null; |
|
75 } |
|
76 |
|
77 public void render(int x, int y, ScalableImage image) |
|
78 { |
|
79 |
|
80 iSg.render(x,y, image); |
|
81 iRealGC.drawImage(iBufferedImage, x, y); |
|
82 } |
|
83 |
|
84 public void setRenderingQuality(int mode) |
|
85 { |
|
86 |
|
87 iSg.setRenderingQuality(mode); |
|
88 } |
|
89 |
|
90 public void setTransparency(float alpha) |
|
91 { |
|
92 |
|
93 iSg.setTransparency(alpha); |
|
94 } |
|
95 } |