1 /* |
1 /* |
2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2005-2009 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". |
33 GC iRealGC = null; |
33 GC iRealGC = null; |
34 Image iBufferedImage = null; |
34 Image iBufferedImage = null; |
35 |
35 |
36 public ESWTScalableGraphics(Display display) |
36 public ESWTScalableGraphics(Display display) |
37 { |
37 { |
38 |
38 |
39 |
39 |
40 iSg = ScalableGraphics.createInstance(); |
40 iSg = ScalableGraphics.createInstance(); |
41 iDisplay = display; |
41 iDisplay = display; |
42 } |
42 } |
43 |
43 |
44 public ESWTScalableGraphics(Display display, Rectangle canvasBounds) |
44 public ESWTScalableGraphics(Display display, Rectangle canvasBounds) |
45 { |
45 { |
46 |
46 |
47 iSg = ScalableGraphics.createInstance(); |
47 iSg = ScalableGraphics.createInstance(); |
48 iDisplay = display; |
48 iDisplay = display; |
49 iCanvasBounds = canvasBounds; |
49 iCanvasBounds = canvasBounds; |
50 } |
50 } |
51 |
51 |
54 iCanvasBounds = canvasBounds; |
54 iCanvasBounds = canvasBounds; |
55 } |
55 } |
56 |
56 |
57 public void bindTarget(GC gc) |
57 public void bindTarget(GC gc) |
58 { |
58 { |
59 |
59 |
60 iRealGC = gc; |
60 iRealGC = gc; |
61 iBufferedImage = new Image(iDisplay, iCanvasBounds); |
61 iBufferedImage = new Image(iDisplay, iCanvasBounds); |
62 iBufferGC = new GC(iBufferedImage); |
62 iBufferGC = new GC(iBufferedImage); |
63 iSg.bindTarget(iBufferGC); |
63 iSg.bindTarget(iBufferGC); |
64 } |
64 } |
65 |
65 |
66 public void releaseTarget() |
66 public void releaseTarget() |
67 { |
67 { |
68 |
68 |
69 |
69 |
70 iSg.releaseTarget(); |
70 iSg.releaseTarget(); |
71 iBufferedImage.dispose(); |
71 iBufferedImage.dispose(); |
72 iBufferGC.dispose(); |
72 iBufferGC.dispose(); |
73 /* iRealGC is disposed in paintControl */ |
73 /* iRealGC is disposed in paintControl */ |
74 iRealGC = null; |
74 iRealGC = null; |
75 } |
75 } |
76 |
76 |
77 public void render(int x, int y, ScalableImage image) |
77 public void render(int x, int y, ScalableImage image) |
78 { |
78 { |
79 |
79 |
80 iSg.render(x,y, image); |
80 iSg.render(x,y, image); |
81 iRealGC.drawImage(iBufferedImage, x, y); |
81 iRealGC.drawImage(iBufferedImage, x, y); |
82 } |
82 } |
83 |
83 |
84 public void setRenderingQuality(int mode) |
84 public void setRenderingQuality(int mode) |
85 { |
85 { |
86 |
86 |
87 iSg.setRenderingQuality(mode); |
87 iSg.setRenderingQuality(mode); |
88 } |
88 } |
89 |
89 |
90 public void setTransparency(float alpha) |
90 public void setTransparency(float alpha) |
91 { |
91 { |
92 |
92 |
93 iSg.setTransparency(alpha); |
93 iSg.setTransparency(alpha); |
94 } |
94 } |
95 } |
95 } |