update dev300-m58
[ooovba.git] / canvas / source / java / CanvasGraphicDevice.java
blob7b606be025b26c7b3831dbdc18b266ce97fda2aa
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: CanvasGraphicDevice.java,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // Canvas
32 import com.sun.star.rendering.*;
33 import com.sun.star.geometry.*;
35 // Java AWT
36 import java.awt.*;
38 public class CanvasGraphicDevice
39 extends com.sun.star.lib.uno.helper.ComponentBase
40 implements com.sun.star.lang.XServiceInfo,
41 com.sun.star.beans.XPropertySet,
42 com.sun.star.rendering.XGraphicDevice
44 private java.awt.Graphics2D graphics;
45 private java.awt.GraphicsConfiguration graphicsConfig;
47 //----------------------------------------------------------------------------------
49 public CanvasGraphicDevice( java.awt.Graphics2D _graphics )
51 graphics = _graphics;
52 graphicsConfig = graphics.getDeviceConfiguration();
55 //----------------------------------------------------------------------------------
58 // GraphicsDevice implementation
59 // =============================
61 public synchronized XBufferController getBufferController()
63 // Use java.awt.image.BufferStrategy to implement XBufferController
64 CanvasUtils.printLog( "CanvasGraphicDevice.getBufferController!" );
65 return null;
68 public synchronized XColorSpace getDeviceColorSpace()
70 CanvasUtils.printLog( "CanvasGraphicDevice.getDeviceColorSpace!" );
71 return null;
74 public synchronized com.sun.star.geometry.RealSize2D getPhysicalResolution()
76 CanvasUtils.printLog( "CanvasGraphicDevice.getPhysicalResolution!" );
77 // TODO: getDefaultTransform + getNormalizingTransform
78 return new com.sun.star.geometry.RealSize2D(100,100);
81 public synchronized com.sun.star.geometry.RealSize2D getPhysicalSize()
83 CanvasUtils.printLog( "CanvasGraphicDevice.getSize!" );
84 java.awt.Rectangle bounds = graphicsConfig.getBounds();
86 return new com.sun.star.geometry.RealSize2D(bounds.width, bounds.height);
89 public synchronized XLinePolyPolygon2D createCompatibleLinePolyPolygon( RealPoint2D[][] points )
91 CanvasUtils.printLog( "createCompatibleLinePolyPolygon" );
92 return new LinePolyPolygon( points );
95 public synchronized XBezierPolyPolygon2D createCompatibleBezierPolyPolygon( RealBezierSegment2D[][] points )
97 CanvasUtils.printLog( "createCompatibleBezierPolyPolygon" );
98 return new BezierPolyPolygon( points );
101 public synchronized com.sun.star.rendering.XBitmap createCompatibleBitmap( IntegerSize2D size )
103 CanvasUtils.printLog( "createCompatibleBitmap called with size (" + size.Width + ", " + size.Height + ")" );
104 return new CanvasBitmap( graphicsConfig.createCompatibleImage( size.Width,
105 size.Height,
106 Transparency.OPAQUE ) );
109 public synchronized com.sun.star.rendering.XVolatileBitmap createVolatileBitmap( IntegerSize2D size )
111 CanvasUtils.printLog( "createVolatileBitmap called with size (" + size.Width + ", " + size.Height + ")" );
112 //return new CanvasBitmap( graphicsConfig.createCompatibleVolatileImage( size.Width, size.Height ) );
113 return null;
116 public synchronized com.sun.star.rendering.XBitmap createCompatibleAlphaBitmap( IntegerSize2D size )
118 CanvasUtils.printLog( "createCompatibleBitmap called with size (" + size.Width + ", " + size.Height + ")" );
119 return new CanvasBitmap( graphicsConfig.createCompatibleImage( size.Width,
120 size.Height,
121 Transparency.TRANSLUCENT ) );
124 public synchronized com.sun.star.rendering.XVolatileBitmap createVolatileAlphaBitmap( IntegerSize2D size )
126 CanvasUtils.printLog( "createVolatileBitmap called with size (" + size.Width + ", " + size.Height + ")" );
127 //return new CanvasBitmap( graphicsConfig.createCompatibleVolatileImage( size.Width, size.Height ) );
128 return null;
131 public synchronized com.sun.star.rendering.XParametricPolyPolygon2DFactory getParametricPolyPolygonFactory()
133 // TODO
134 return null;
137 public synchronized com.sun.star.beans.XPropertySetInfo getPropertySetInfo()
139 // This is a stealth property set
140 return null;
143 public synchronized void setPropertyValue( String aPropertyName, java.lang.Object aValue ) throws com.sun.star.beans.PropertyVetoException
145 // all our properties are read-only
146 throw new com.sun.star.beans.PropertyVetoException();
149 public synchronized java.lang.Object getPropertyValue( String PropertyName ) throws com.sun.star.beans.UnknownPropertyException
151 if( PropertyName == "DeviceHandle" )
152 return graphics;
154 throw new com.sun.star.beans.UnknownPropertyException();
157 public synchronized void addPropertyChangeListener( String aPropertyName, com.sun.star.beans.XPropertyChangeListener xListener ) throws com.sun.star.beans.UnknownPropertyException
159 if( aPropertyName == "DeviceHandle" )
160 return;
162 throw new com.sun.star.beans.UnknownPropertyException();
165 public synchronized void removePropertyChangeListener( String aPropertyName, com.sun.star.beans.XPropertyChangeListener aListener ) throws com.sun.star.beans.UnknownPropertyException
167 if( aPropertyName == "DeviceHandle" )
168 return;
170 throw new com.sun.star.beans.UnknownPropertyException();
173 public synchronized void addVetoableChangeListener( String PropertyName, com.sun.star.beans.XVetoableChangeListener aListener ) throws com.sun.star.beans.UnknownPropertyException
175 if( PropertyName == "DeviceHandle" )
176 return;
178 throw new com.sun.star.beans.UnknownPropertyException();
181 public synchronized void removeVetoableChangeListener( String PropertyName, com.sun.star.beans.XVetoableChangeListener aListener ) throws com.sun.star.beans.UnknownPropertyException
183 if( PropertyName == "DeviceHandle" )
184 return;
186 throw new com.sun.star.beans.UnknownPropertyException();
190 public synchronized boolean hasFullScreenMode()
192 return graphicsConfig.getDevice().isFullScreenSupported();
195 public synchronized boolean enterFullScreenMode( boolean bEnter )
197 return false;
200 //----------------------------------------------------------------------------------
203 // XServiceInfo impl
204 // =================
207 private static final String s_implName = "XGraphicsDevice.java.impl";
208 private static final String s_serviceName = "com.sun.star.rendering.GraphicsDevice";
210 public String getImplementationName()
212 return s_implName;
215 public String [] getSupportedServiceNames()
217 return new String [] { s_serviceName };
220 public boolean supportsService( String serviceName )
222 return serviceName.equals( s_serviceName );