update dev300-m58
[ooovba.git] / canvas / source / java / CanvasClonedSprite.java
blobd76d2e694a7839e88406e31dfb576efec4bdf840
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: CanvasClonedSprite.java,v $
10 * $Revision: 1.7 $
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.geom.*;
38 public class CanvasClonedSprite
39 extends com.sun.star.lib.uno.helper.ComponentBase
40 implements com.sun.star.rendering.XSprite,
41 com.sun.star.lang.XServiceInfo,
42 SpriteBase
44 private JavaCanvas canvas;
45 private double alpha;
46 private java.awt.geom.Point2D.Double outputPosition;
47 private SpriteRep spriteRep;
48 private SpriteBase original;
50 //----------------------------------------------------------------------------------
52 public CanvasClonedSprite( JavaCanvas _canvas,
53 XSprite _original )
55 CanvasUtils.printLog( "CanvasClonesSprite constructor called!" );
57 canvas = _canvas;
59 if( _original instanceof SpriteBase )
61 original = (SpriteBase)_original;
64 alpha = 0.0;
65 outputPosition = new java.awt.geom.Point2D.Double(0.0,0.0);
67 // TODO: throw on error here!
70 //----------------------------------------------------------------------------------
73 // SpriteBase
74 // ==========
76 public SpriteRep getSpriteRep()
78 if( spriteRep == null )
80 spriteRep = new SpriteRep( original.getSpriteRep() );
82 spriteRep.moveSprite( outputPosition );
83 spriteRep.setSpriteAlpha( alpha );
85 // TODO: Check for spriteRep.buffer != null here, throw otherwise
87 return spriteRep;
90 //----------------------------------------------------------------------------------
93 // XComponent
94 // ==========
96 public void dispose()
98 canvas = null;
99 spriteRep = null;
100 original = null;
102 super.dispose();
105 //----------------------------------------------------------------------------------
108 // XSprite impl
109 // ==================
112 public synchronized void setPriority( double nPriority )
114 // TODO
117 public synchronized void setAlpha( double _alpha )
119 alpha = _alpha;
121 if( spriteRep != null )
123 spriteRep.setSpriteAlpha( alpha );
127 public synchronized void move( RealPoint2D _aNewPos,
128 ViewState _viewState,
129 RenderState _renderState )
131 // transform given point with concatenated transformation
132 AffineTransform transform = CanvasUtils.ViewConcatRenderTransform( _viewState, _renderState );
133 transform.transform( new java.awt.geom.Point2D.Double(_aNewPos.X,
134 _aNewPos.Y),
135 outputPosition );
137 if( spriteRep != null )
139 spriteRep.moveSprite( outputPosition );
143 public synchronized void transform( AffineMatrix2D aTransformation ) throws com.sun.star.lang.IllegalArgumentException
145 // TODO
148 public synchronized void clip( XPolyPolygon2D aClip )
150 // TODO
153 public synchronized void show()
155 canvas.showSprite( this );
156 canvas.updateScreen( false );
159 public synchronized void hide()
161 canvas.hideSprite( this );
163 //----------------------------------------------------------------------------------
165 private static final String s_implName = "XSprite.java.impl";
166 private static final String s_serviceName = "com.sun.star.rendering.Sprite";
168 //----------------------------------------------------------------------------------
171 // XServiceInfo impl
172 // =================
174 public String getImplementationName()
176 return s_implName;
179 public String [] getSupportedServiceNames()
181 return new String [] { s_serviceName };
184 public boolean supportsService( String serviceName )
186 return serviceName.equals( s_serviceName );