1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: CanvasClonedSprite.java,v $
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 ************************************************************************/
32 import com
.sun
.star
.rendering
.*;
33 import com
.sun
.star
.geometry
.*;
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
,
44 private JavaCanvas canvas
;
46 private java
.awt
.geom
.Point2D
.Double outputPosition
;
47 private SpriteRep spriteRep
;
48 private SpriteBase original
;
50 //----------------------------------------------------------------------------------
52 public CanvasClonedSprite( JavaCanvas _canvas
,
55 CanvasUtils
.printLog( "CanvasClonesSprite constructor called!" );
59 if( _original
instanceof SpriteBase
)
61 original
= (SpriteBase
)_original
;
65 outputPosition
= new java
.awt
.geom
.Point2D
.Double(0.0,0.0);
67 // TODO: throw on error here!
70 //----------------------------------------------------------------------------------
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
90 //----------------------------------------------------------------------------------
105 //----------------------------------------------------------------------------------
109 // ==================
112 public synchronized void setPriority( double nPriority
)
117 public synchronized void setAlpha( double _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
,
137 if( spriteRep
!= null )
139 spriteRep
.moveSprite( outputPosition
);
143 public synchronized void transform( AffineMatrix2D aTransformation
) throws com
.sun
.star
.lang
.IllegalArgumentException
148 public synchronized void clip( XPolyPolygon2D aClip
)
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 //----------------------------------------------------------------------------------
174 public String
getImplementationName()
179 public String
[] getSupportedServiceNames()
181 return new String
[] { s_serviceName
};
184 public boolean supportsService( String serviceName
)
186 return serviceName
.equals( s_serviceName
);