diff options
author | thb <thb@openoffice.org> | 2010-01-25 22:42:19 +0100 |
---|---|---|
committer | thb <thb@openoffice.org> | 2010-01-25 22:42:19 +0100 |
commit | 9f35771929499d655b248fdf8b6bd75e27caf017 (patch) | |
tree | 99f83929cea4af56d1a5ac6b37bb07119d0a2974 /canvas | |
parent | 0c770cb000ec05eb522b928dbf975ebe8324c480 (diff) |
#i105937# Removed demo-quality java canvas. no longer maintained.
Diffstat (limited to 'canvas')
29 files changed, 0 insertions, 6868 deletions
diff --git a/canvas/source/java/BackBuffer.java b/canvas/source/java/BackBuffer.java deleted file mode 100644 index c71a523f35d9..000000000000 --- a/canvas/source/java/BackBuffer.java +++ /dev/null @@ -1,115 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: BackBuffer.java,v $ - * $Revision: 1.6 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// Java AWT -import java.awt.*; -import java.awt.image.*; - -public class BackBuffer -{ - private BufferedImage backBuffer; - //private VolatileImage backBuffer; - private Graphics2D backBufferGraphics; - private Graphics2D referenceDevice; - - public BackBuffer( Graphics2D _referenceDevice, - int width, - int height ) - { - referenceDevice = _referenceDevice; - setSize( width, height ); - } - - public Graphics2D getGraphics() - { - return backBufferGraphics; - } - - public void setSize( int width, - int height ) - { - if( backBuffer != null && - width == backBuffer.getWidth() && - height == backBuffer.getHeight() ) - { - return; - } - - if( backBufferGraphics != null ) - backBufferGraphics.dispose(); - - if( backBuffer != null ) - backBuffer.flush(); - - // TODO: Maybe VolatileImage with another BufferedImage as a backup is - // a tad faster here. - backBuffer = referenceDevice.getDeviceConfiguration().createCompatibleImage(width, - height); -// backBuffer = referenceDevice.getDeviceConfiguration().createCompatibleVolatileImage(width, -// height); - - backBufferGraphics = backBuffer.createGraphics(); - CanvasUtils.initGraphics( backBufferGraphics ); - - // clear the buffer to white (to have a defined state here) - backBufferGraphics.setColor( java.awt.Color.white ); - backBufferGraphics.fillRect( 0,0,width,height ); - } - - public void redraw( Graphics2D graph ) - { - if( graph != null && - backBuffer != null ) - { - CanvasUtils.printLog("BackBuffer.redraw(): using buffer of size (" + - backBuffer.getWidth() + "," + backBuffer.getHeight() + ")" ); - - graph.drawImage(backBuffer, 0, 0, null); - - // TODO: this is just twiddled to work. I cannot be sure - // that this volatile backbuffer will survive in the first - // place, nor that it wise to leave it in VRAM. - - // only flush non-volatile images - // CanvasUtils.postRenderImageTreatment( backBuffer ); - } - } - - public java.awt.Image getBackBuffer() - { - return backBuffer; - } - - public void dispose() - { - backBufferGraphics.dispose(); - backBuffer.flush(); - } -} diff --git a/canvas/source/java/BezierPolyPolygon.java b/canvas/source/java/BezierPolyPolygon.java deleted file mode 100644 index 54a061477ab8..000000000000 --- a/canvas/source/java/BezierPolyPolygon.java +++ /dev/null @@ -1,154 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: BezierPolyPolygon.java,v $ - * $Revision: 1.7 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// Canvas -import com.sun.star.rendering.*; -import com.sun.star.geometry.*; - -public class BezierPolyPolygon - extends com.sun.star.lib.uno.helper.ComponentBase - implements com.sun.star.lang.XServiceInfo, - com.sun.star.rendering.XBezierPolyPolygon2D -{ - private java.awt.geom.GeneralPath path; - - //---------------------------------------------------------------------------------- - - public BezierPolyPolygon( RealBezierSegment2D[][] points ) - { - setBezierSegments( points, 0 ); - } - - public java.awt.geom.GeneralPath getJavaPath() - { - return path; - } - - //---------------------------------------------------------------------------------- - - // - // XPolyPolygon implementation - // =========================== - // - public void addPolyPolygon( RealPoint2D position, XPolyPolygon2D polyPolygon ) - { - } - - public int getNumberOfPolygons( ) - { - return 0; - } - - public int getNumberOfPolygonPoints( int polygon ) - { - return 0; - } - - public FillRule getFillRule( ) - { - if( path.getWindingRule() == java.awt.geom.GeneralPath.WIND_EVEN_ODD ) - return FillRule.EVEN_ODD; - else - return FillRule.NON_ZERO; - } - - public void setFillRule( FillRule fillRule ) - { - if( fillRule == FillRule.EVEN_ODD ) - path.setWindingRule( java.awt.geom.GeneralPath.WIND_EVEN_ODD ); - else - path.setWindingRule( java.awt.geom.GeneralPath.WIND_NON_ZERO ); - } - - public boolean isClosed( int index ) - { - // TODO - return false; - } - - public void setClosed( int index, boolean closedState ) - { - // TODO - } - - //---------------------------------------------------------------------------------- - - // - // XBezierPolyPolygon implementation - // ================================= - // - public RealBezierSegment2D[][] getBezierSegments( int nPolygonIndex, int nNumberOfPolygons, int nPointIndex, int nNumberOfPoints ) - { - return null; - } - - public void setBezierSegments( RealBezierSegment2D[][] points, int nPolygonIndex ) - { - if( nPolygonIndex != 0 ) - CanvasUtils.printLog( "LinePolyPolygon.setPoints: subset not yet implemented!" ); - - path = CanvasUtils.makeGenPathFromBezierPoints( points ); - } - - public RealBezierSegment2D getBezierSegment( int nPolygonIndex, int nPointIndex ) - { - return null; - } - - public void setBezierSegment( RealBezierSegment2D point, int nPolygonIndex, int nPointIndex ) - { - CanvasUtils.printLog( "LinePolyPolygon.setPoint: not yet implemented!" ); - } - - //---------------------------------------------------------------------------------- - - // - // XServiceInfo impl - // ================= - // - - private static final String s_implName = "XBezierPolyPolygon2D.java.impl"; - private static final String s_serviceName = "com.sun.star.rendering.BezierPolyPolygon2D"; - - public String getImplementationName() - { - return s_implName; - } - - public String [] getSupportedServiceNames() - { - return new String [] { s_serviceName }; - } - - public boolean supportsService( String serviceName ) - { - return serviceName.equals( s_serviceName ); - } -} diff --git a/canvas/source/java/BitmapCanvas.java b/canvas/source/java/BitmapCanvas.java deleted file mode 100644 index 374a0d71c4fc..000000000000 --- a/canvas/source/java/BitmapCanvas.java +++ /dev/null @@ -1,139 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: BitmapCanvas.java,v $ - * $Revision: 1.6 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// UNO -import com.sun.star.uno.UnoRuntime; -import com.sun.star.uno.XComponentContext; -import com.sun.star.uno.AnyConverter; -import com.sun.star.uno.IQueryInterface; -import com.sun.star.lang.XInitialization; -import com.sun.star.lib.uno.helper.WeakBase; - -// OOo AWT -import com.sun.star.awt.*; - -// Canvas -import com.sun.star.rendering.*; -import com.sun.star.geometry.*; - -// Java AWT -import java.awt.*; -import java.awt.image.*; -import java.awt.geom.*; - -public class BitmapCanvas - extends CanvasBase - implements com.sun.star.rendering.XBitmapCanvas, - com.sun.star.lang.XServiceInfo -{ - private Graphics2D graphics; - - public Graphics2D getGraphics() - { - return graphics; - } - - //---------------------------------------------------------------------------------- - - public BitmapCanvas( Graphics2D _graphics ) - { - graphics = _graphics; - } - - //---------------------------------------------------------------------------------- - - // - // XBitmapCanvas impl - // ================== - // - - public synchronized void copyRect( com.sun.star.rendering.XBitmapCanvas sourceCanvas, - com.sun.star.geometry.RealRectangle2D sourceRect, - com.sun.star.rendering.ViewState sourceViewState, - com.sun.star.rendering.RenderState sourceRenderState, - com.sun.star.geometry.RealRectangle2D destRect, - com.sun.star.rendering.ViewState destViewState, - com.sun.star.rendering.RenderState destRenderState ) - { - // TODO: create temp image when transform is non-trivial - - if( sourceCanvas == this ) - { - // copy rectangle within the canvas - graphics.copyArea((int)sourceRect.X1, - (int)sourceRect.Y1, - (int)(sourceRect.X2 - sourceRect.X1), - (int)(sourceRect.Y2 - sourceRect.Y1), - (int)(destRect.X1 - sourceRect.X1), - (int)(destRect.Y1 - sourceRect.Y1) ); - } - else - { - if( sourceCanvas instanceof JavaCanvas ) - { - // cache - CanvasUtils.setupGraphicsState( graphics, destViewState, destRenderState, CanvasUtils.alsoSetupPaint ); - - // TODO: really extract correct source rect here - BufferedImage backBuffer = ((BufferedGraphics2D)((JavaCanvas)sourceCanvas).getGraphics()).getBackBuffer(); - graphics.drawImage( backBuffer, 0, 0, null ); - CanvasUtils.postRenderImageTreatment( backBuffer ); - - } - // TODO: foreign canvas - } - } - - //---------------------------------------------------------------------------------- - - private static final String s_implName = "XBitmapCanvas.java.impl"; - private static final String s_serviceName = "com.sun.star.rendering.BitmapCanvas"; - - //---------------------------------------------------------------------------------- - - // - // XServiceInfo impl - // ================= - // - public String getImplementationName() - { - return s_implName; - } - - public String [] getSupportedServiceNames() - { - return new String [] { s_serviceName }; - } - - public boolean supportsService( String serviceName ) - { - return serviceName.equals( s_serviceName ); - } -} diff --git a/canvas/source/java/BufferedGraphics2D.java b/canvas/source/java/BufferedGraphics2D.java deleted file mode 100644 index 235de2018d80..000000000000 --- a/canvas/source/java/BufferedGraphics2D.java +++ /dev/null @@ -1,603 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: BufferedGraphics2D.java,v $ - * $Revision: 1.4 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// Java AWT -import java.awt.*; -import java.awt.geom.*; -import java.awt.image.*; -import java.awt.image.renderable.*; -import java.awt.font.*; -import java.text.*; -import java.util.*; - - -public class BufferedGraphics2D - extends java.awt.Graphics2D -{ - // TODO: Somehow, get rid of this duplicate graphics (the graphics member, - // and this object itself, extending a Graphics2D) - private Graphics2D graphics; - private BufferedImage backBuffer; - private Graphics2D backBufferGraphics; - - //---------------------------------------------------------------------------------- - - public BufferedGraphics2D( java.awt.Graphics2D _graphics, int width, int height ) - { - setGraphics( _graphics, Math.max(1,width), Math.max(1,height) ); - } - - public void redraw( Graphics2D graph ) - { - if( graph != null && - backBuffer != null ) - { - CanvasUtils.printLog("BufferedGraphics2D.redraw: using buffer of size (" + - backBuffer.getWidth() + "," + backBuffer.getHeight() + ")" ); - - // set transform to identity - graph.setTransform( new AffineTransform() ); - graph.drawImage(backBuffer, 0, 0, null); - CanvasUtils.postRenderImageTreatment( backBuffer ); - } - } - - public BufferedImage getBackBuffer() - { - return backBuffer; - } - - public void setSize( int width, int height ) - { - if( backBuffer != null && - width == backBuffer.getWidth() && - height == backBuffer.getHeight() ) - { - return; - } - - if( backBufferGraphics != null ) - backBufferGraphics.dispose(); - - if( backBuffer != null ) - backBuffer.flush(); - - // TODO: Maybe VolatileImage with another BufferedImage as a backup is - // a tad faster here. - backBuffer = graphics.getDeviceConfiguration().createCompatibleImage(width, - height); - - backBufferGraphics = backBuffer.createGraphics(); - CanvasUtils.initGraphics( backBufferGraphics ); - - // clear the buffer to white (to have a defined state here) - backBufferGraphics.setColor( java.awt.Color.white ); - backBufferGraphics.fillRect( 0,0,width,height ); - } - - public void setGraphics( Graphics2D _graphics, int width, int height ) - { - if( graphics != null ) - graphics.dispose(); - - graphics = _graphics; - - setSize(width,height); - } - - //---------------------------------------------------------------------------------- - - // - // Graphics - // ======== - // - public void clearRect(int x, int y, int width, int height) - { - graphics.clearRect(x,y,width,height); - backBufferGraphics.clearRect(x,y,width,height); - } - - public void clipRect(int x, int y, int width, int height) - { - graphics.clipRect(x,y,width,height); - backBufferGraphics.clipRect(x,y,width,height); - } - - public void copyArea(int x, int y, int width, int height, int dx, int dy) - { - graphics.copyArea(x,y,width,height,dx,dy); - backBufferGraphics.copyArea(x,y,width,height,dx,dy); - } - - public Graphics create() - { - return null; - } - - public Graphics create(int x, int y, int width, int height) - { - return null; - } - - public void dispose() - { - graphics.dispose(); - backBufferGraphics.dispose(); - backBuffer.flush(); - } - - public void draw3DRect(int x, int y, int width, int height, boolean raised) - { - graphics.draw3DRect(x,y,width,height,raised); - backBufferGraphics.draw3DRect(x,y,width,height,raised); - } - - public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) - { - graphics.drawArc(x,y,width,height,startAngle,arcAngle); - backBufferGraphics.drawArc(x,y,width,height,startAngle,arcAngle); - } - - public void drawBytes(byte[] data, int offset, int length, int x, int y) - { - graphics.drawBytes(data,offset,length,x,y); - backBufferGraphics.drawBytes(data,offset,length,x,y); - } - - public void drawChars(char[] data, int offset, int length, int x, int y) - { - graphics.drawChars(data,offset,length,x,y); - backBufferGraphics.drawChars(data,offset,length,x,y); - } - - public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer) - { - backBufferGraphics.drawImage(img,x,y,bgcolor,observer); - return graphics.drawImage(img,x,y,bgcolor,observer); - } - - public boolean drawImage(Image img, int x, int y, ImageObserver observer) - { - backBufferGraphics.drawImage(img,x,y,observer); - return graphics.drawImage(img,x,y,observer); - } - - public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) - { - backBufferGraphics.drawImage(img,x,y,width,height,bgcolor,observer); - return graphics.drawImage(img,x,y,width,height,bgcolor,observer); - } - - public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer) - { - backBufferGraphics.drawImage(img,x,y,width,height,observer); - return graphics.drawImage(img,x,y,width,height,observer); - } - - public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) - { - backBufferGraphics.drawImage(img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,bgcolor,observer); - return graphics.drawImage(img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,bgcolor,observer); - } - - public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) - { - backBufferGraphics.drawImage(img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,observer); - return graphics.drawImage(img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,observer); - } - - public void drawLine(int x1, int y1, int x2, int y2) - { - graphics.drawLine(x1,y1,x2,y2); - backBufferGraphics.drawLine(x1,y1,x2,y2); - } - - public void drawOval(int x, int y, int width, int height) - { - graphics.drawOval(x,y,width,height); - backBufferGraphics.drawOval(x,y,width,height); - } - - public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) - { - graphics.drawPolygon(xPoints,yPoints,nPoints); - backBufferGraphics.drawPolygon(xPoints,yPoints,nPoints); - } - - public void drawPolygon(Polygon p) - { - graphics.drawPolygon(p); - backBufferGraphics.drawPolygon(p); - } - - public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints) - { - graphics.drawPolyline(xPoints,yPoints,nPoints); - backBufferGraphics.drawPolyline(xPoints,yPoints,nPoints); - } - - public void drawRect(int x, int y, int width, int height) - { - graphics.drawRect(x,y,width,height); - backBufferGraphics.drawRect(x,y,width,height); - } - - public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) - { - graphics.drawRoundRect(x,y,width,height,arcWidth,arcHeight); - backBufferGraphics.drawRoundRect(x,y,width,height,arcWidth,arcHeight); - } - - public void drawString(AttributedCharacterIterator iterator, int x, int y) - { - graphics.drawString(iterator,x,y); - backBufferGraphics.drawString(iterator,x,y); - } - - public void drawString(String str, int x, int y) - { - graphics.drawString(str,x,y); - backBufferGraphics.drawString(str,x,y); - } - - public void fill3DRect(int x, int y, int width, int height, boolean raised) - { - graphics.fill3DRect(x,y,width,height,raised); - backBufferGraphics.fill3DRect(x,y,width,height,raised); - } - - public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) - { - graphics.fillArc(x,y,width,height,startAngle,arcAngle); - backBufferGraphics.fillArc(x,y,width,height,startAngle,arcAngle); - } - - public void fillOval(int x, int y, int width, int height) - { - graphics.fillOval(x,y,width,height); - backBufferGraphics.fillOval(x,y,width,height); - } - - public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) - { - graphics.fillPolygon(xPoints,yPoints,nPoints); - backBufferGraphics.fillPolygon(xPoints,yPoints,nPoints); - } - - public void fillPolygon(Polygon p) - { - graphics.fillPolygon(p); - backBufferGraphics.fillPolygon(p); - } - - public void fillRect(int x, int y, int width, int height) - { - graphics.fillRect(x,y,width,height); - backBufferGraphics.fillRect(x,y,width,height); - } - - public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) - { - graphics.fillRoundRect(x,y,width,height,arcWidth,arcHeight); - backBufferGraphics.fillRoundRect(x,y,width,height,arcWidth,arcHeight); - } - - public Shape getClip() - { - return graphics.getClip(); - } - - public Rectangle getClipBounds() - { - return graphics.getClipBounds(); - } - - public Rectangle getClipBounds(Rectangle r) - { - return graphics.getClipBounds(r); - } - - public Rectangle getClipRect() - { - return graphics.getClipRect(); - } - - public Color getColor() - { - return getColor(); - } - - public Font getFont() - { - return getFont(); - } - - public FontMetrics getFontMetrics() - { - return getFontMetrics(); - } - - public FontMetrics getFontMetrics(Font f) - { - return getFontMetrics(f); - } - - public boolean hitClip(int x, int y, int width, int height) - { - return graphics.hitClip(x,y,width,height); - } - - public void setClip(int x, int y, int width, int height) - { - graphics.setClip(x,y,width,height); - backBufferGraphics.setClip(x,y,width,height); - } - - public void setClip(Shape clip) - { - graphics.setClip(clip); - backBufferGraphics.setClip(clip); - } - - public void setColor(Color c) - { - graphics.setColor(c); - backBufferGraphics.setColor(c); - } - - public void setFont(Font font) - { - graphics.setFont(font); - backBufferGraphics.setFont(font); - } - - public void setPaintMode() - { - graphics.setPaintMode(); - backBufferGraphics.setPaintMode(); - } - - public void setXORMode(Color c1) - { - graphics.setXORMode(c1); - backBufferGraphics.setXORMode(c1); - } - - public String toString() - { - return graphics.toString(); - } - - public void translate(int x, int y) - { - graphics.translate(x,y); - backBufferGraphics.translate(x,y); - } - - //---------------------------------------------------------------------------------- - - // - // Graphics2D - // ========== - // - public void addRenderingHints(Map hints) - { - graphics.addRenderingHints(hints); - backBufferGraphics.addRenderingHints(hints); - } - - public void clip(Shape s) - { - graphics.clip(s); - backBufferGraphics.clip(s); - } - - public void draw(Shape s) - { - graphics.draw(s); - backBufferGraphics.draw(s); - } - - public void drawGlyphVector(GlyphVector g, float x, float y) - { - graphics.drawGlyphVector(g,x,y); - backBufferGraphics.drawGlyphVector(g,x,y); - } - - public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y) - { - graphics.drawImage(img,op,x,y); - backBufferGraphics.drawImage(img,op,x,y); - } - - public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs) - { - backBufferGraphics.drawImage(img,xform,obs); - return graphics.drawImage(img,xform,obs); - } - - public void drawRenderableImage(RenderableImage img, AffineTransform xform) - { - graphics.drawRenderableImage(img,xform); - backBufferGraphics.drawRenderableImage(img,xform); - } - - public void drawRenderedImage(RenderedImage img, AffineTransform xform) - { - graphics.drawRenderedImage(img,xform); - backBufferGraphics.drawRenderedImage(img,xform); - } - - public void drawString(AttributedCharacterIterator iterator, float x, float y) - { - graphics.drawString(iterator,x,y); - backBufferGraphics.drawString(iterator,x,y); - } - - public void drawString(String s, float x, float y) - { - graphics.drawString(s,x,y); - backBufferGraphics.drawString(s,x,y); - } - - public void fill(Shape s) - { - graphics.fill(s); - backBufferGraphics.fill(s); - } - - public Color getBackground() - { - return graphics.getBackground(); - } - - public Composite getComposite() - { - return graphics.getComposite(); - } - - public GraphicsConfiguration getDeviceConfiguration() - { - return graphics.getDeviceConfiguration(); - } - - public FontRenderContext getFontRenderContext() - { - return graphics.getFontRenderContext(); - } - - public Paint getPaint() - { - return graphics.getPaint(); - } - - public Object getRenderingHint(RenderingHints.Key hintKey) - { - return graphics.getRenderingHint(hintKey); - } - - public RenderingHints getRenderingHints() - { - return graphics.getRenderingHints(); - } - - public Stroke getStroke() - { - return graphics.getStroke(); - } - - public AffineTransform getTransform() - { - return graphics.getTransform(); - } - - public boolean hit(Rectangle rect, Shape s, boolean onStroke) - { - return graphics.hit(rect,s,onStroke); - } - - public void rotate(double theta) - { - graphics.rotate(theta); - backBufferGraphics.rotate(theta); - } - - public void rotate(double theta, double x, double y) - { - graphics.rotate(theta,x,y); - backBufferGraphics.rotate(theta,x,y); - } - - public void scale(double sx, double sy) - { - graphics.scale(sx,sy); - backBufferGraphics.scale(sx,sy); - } - - public void setBackground(Color color) - { - graphics.setBackground(color); - backBufferGraphics.setBackground(color); - } - - public void setComposite(Composite comp) - { - graphics.setComposite(comp); - backBufferGraphics.setComposite(comp); - } - - public void setPaint(Paint paint) - { - graphics.setPaint(paint); - backBufferGraphics.setPaint(paint); - } - - public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue) - { - graphics.setRenderingHint(hintKey,hintValue); - backBufferGraphics.setRenderingHint(hintKey,hintValue); - } - - public void setRenderingHints(Map hints) - { - graphics.setRenderingHints(hints); - backBufferGraphics.setRenderingHints(hints); - } - - public void setStroke(Stroke s) - { - graphics.setStroke(s); - backBufferGraphics.setStroke(s); - } - - public void setTransform(AffineTransform Tx) - { - graphics.setTransform(Tx); - backBufferGraphics.setTransform(Tx); - } - - public void shear(double shx, double shy) - { - graphics.shear(shx,shy); - backBufferGraphics.shear(shx,shy); - } - - public void transform(AffineTransform Tx) - { - graphics.transform(Tx); - backBufferGraphics.transform(Tx); - } - - public void translate(double tx, double ty) - { - graphics.translate(tx,ty); - backBufferGraphics.translate(tx,ty); - } -} diff --git a/canvas/source/java/CanvasBase.java b/canvas/source/java/CanvasBase.java deleted file mode 100644 index 5f086e268069..000000000000 --- a/canvas/source/java/CanvasBase.java +++ /dev/null @@ -1,344 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: CanvasBase.java,v $ - * $Revision: 1.8 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// Canvas -import com.sun.star.rendering.*; -import com.sun.star.geometry.*; - -// Java AWT -import java.awt.*; -import java.awt.geom.*; - -public abstract class CanvasBase - extends com.sun.star.lib.uno.helper.ComponentBase - implements com.sun.star.rendering.XCanvas -{ - // to be overridden - public abstract Graphics2D getGraphics(); - - //---------------------------------------------------------------------------------- - - // - // XCanvas interface - // ================= - // - public synchronized void clear() - { - Graphics2D graphics = getGraphics(); - // TODO(F3): retrieve true dimensions of the Graphics - graphics.clearRect(0,0,1000,1000); - } - - public synchronized void drawPoint( RealPoint2D aPoint, - ViewState viewState, - RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException - { - // cache - Graphics2D graphics = getGraphics(); - - // initialize the Graphics2D - CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint ); - - // calculate the domain value for a single device pixel. we're - // using delta mapping here, to avoid later subtraction of two - // mapped values (as we really only need a transformed size, - // not a transformed point). - AffineTransform transform = graphics.getTransform(); - AffineTransform inverse; - try - { - inverse = transform.createInverse(); - } - catch( NoninvertibleTransformException e ) - { - // transformation not invertible. Nothing to render then. - return; - } - - java.awt.geom.Point2D.Double pointSize = new java.awt.geom.Point2D.Double(1.0,1.0); - java.awt.geom.Point2D.Double domainPointSize = new java.awt.geom.Point2D.Double(); - inverse.deltaTransform( pointSize, domainPointSize ); - - // render a circle one device pixel wide - Ellipse2D.Double ellipse = new Ellipse2D.Double(aPoint.X, aPoint.Y, domainPointSize.x, domainPointSize.y); - - // render, at last - graphics.fill( ellipse ); - - CanvasUtils.printLog( "XCanvas: drawPoint called" ); - } - - public synchronized void drawLine( RealPoint2D aStartPoint, - RealPoint2D aEndPoint, - ViewState viewState, - RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException - { - // cache - Graphics2D graphics = getGraphics(); - - // initialize the Graphics2D - CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint ); - graphics.setStroke( new BasicStroke() ); - - // setup line object - Line2D.Double line = new Line2D.Double(aStartPoint.X, aStartPoint.Y, aEndPoint.X, aEndPoint.Y); - - // render, at last - graphics.draw( line ); - - CanvasUtils.printLog( "XCanvas: drawLine called" ); - } - - public synchronized void drawBezier( RealBezierSegment2D aBezierSegment, - RealPoint2D aEndPoint, - ViewState viewState, - RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException - { - // cache - Graphics2D graphics = getGraphics(); - - // initialize the Graphics2D - CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint ); - graphics.setStroke( new BasicStroke() ); - - // setup bezier object - CubicCurve2D.Double curve = new CubicCurve2D.Double(aBezierSegment.Px, aBezierSegment.Py, - aBezierSegment.C1x, aBezierSegment.C1y, - aBezierSegment.C2x, aBezierSegment.C2y, - aEndPoint.X, aEndPoint.Y); - - // render, at last - graphics.draw( curve ); - - CanvasUtils.printLog( "XCanvas: drawbezier called" ); - } - - public synchronized XCachedPrimitive drawPolyPolygon( XPolyPolygon2D xPolyPolygon, - ViewState viewState, - RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException - { - CanvasUtils.printLog( "CanvasBase.drawPolyPolygon() called" ); - - // cache - Graphics2D graphics = getGraphics(); - - // initialize the Graphics2D - CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint ); - graphics.setStroke( new BasicStroke() ); - - // render the polygon - // TODO: maybe use Graphics.drawPolyline here! - graphics.draw( CanvasUtils.makeGeneralPath(xPolyPolygon) ); - - CanvasUtils.printLog( "XCanvas: drawPolyPolygon called" ); - - return null; - } - - public synchronized XCachedPrimitive strokePolyPolygon( XPolyPolygon2D xPolyPolygon, - ViewState viewState, - RenderState renderState, - StrokeAttributes strokeAttributes ) throws com.sun.star.lang.IllegalArgumentException - { - // cache - Graphics2D graphics = getGraphics(); - - // initialize the Graphics2D - CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint ); - CanvasUtils.applyStrokeAttributes( graphics, strokeAttributes ); - - // stroke the polygon - graphics.draw( CanvasUtils.makeGeneralPath(xPolyPolygon) ); - - CanvasUtils.printLog( "XCanvas: strokePolyPolygon called" ); - - return null; - } - - public synchronized XCachedPrimitive strokeTexturedPolyPolygon( XPolyPolygon2D xPolyPolygon, - ViewState viewState, - RenderState renderState, - Texture[] textures, - StrokeAttributes strokeAttributes ) throws com.sun.star.lang.IllegalArgumentException, VolatileContentDestroyedException - { - return null; - } - - public synchronized XCachedPrimitive strokeTextureMappedPolyPolygon( XPolyPolygon2D xPolyPolygon, - ViewState viewState, - RenderState renderState, - Texture[] textures, - com.sun.star.geometry.XMapping2D xMapping, - StrokeAttributes strokeAttributes ) throws com.sun.star.lang.IllegalArgumentException, VolatileContentDestroyedException - { - return null; - } - - public synchronized XPolyPolygon2D queryStrokeShapes( com.sun.star.rendering.XPolyPolygon2D xPolyPolygon, - com.sun.star.rendering.ViewState viewState, - com.sun.star.rendering.RenderState renderState, - com.sun.star.rendering.StrokeAttributes strokeAttributes ) throws com.sun.star.lang.IllegalArgumentException - { - return null; - } - - public synchronized XCachedPrimitive fillPolyPolygon( com.sun.star.rendering.XPolyPolygon2D xPolyPolygon, - com.sun.star.rendering.ViewState viewState, - com.sun.star.rendering.RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException - { - CanvasUtils.printLog( "CanvasBase.fillPolyPolygon() called" ); - - // cache - Graphics2D graphics = getGraphics(); - - // initialize the Graphics2D - CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint ); - - // fill the polygon - graphics.fill( CanvasUtils.makeGeneralPath(xPolyPolygon) ); - - CanvasUtils.printLog( "XCanvas: fillPolyPolygon called" ); - - return null; - } - - public synchronized XCachedPrimitive fillTexturedPolyPolygon( com.sun.star.rendering.XPolyPolygon2D xPolyPolygon, - com.sun.star.rendering.ViewState viewState, - com.sun.star.rendering.RenderState renderState, - com.sun.star.rendering.Texture [] textures ) throws com.sun.star.lang.IllegalArgumentException - { - return null; - } - - public synchronized XCachedPrimitive fillTextureMappedPolyPolygon( XPolyPolygon2D xPolyPolygon, - ViewState viewState, - RenderState renderState, - Texture[] textures, - com.sun.star.geometry.XMapping2D xMapping ) throws com.sun.star.lang.IllegalArgumentException, VolatileContentDestroyedException - { - return null; - } - - public synchronized XCanvasFont createFont( FontRequest fontRequest, com.sun.star.beans.PropertyValue[] extraFontProperties, com.sun.star.geometry.Matrix2D fontMatrix ) throws com.sun.star.lang.IllegalArgumentException - { - // TODO: support extra arguments - return new CanvasFont( fontRequest, this ); - } - - public FontInfo[] queryAvailableFonts( FontInfo aFilter, com.sun.star.beans.PropertyValue[] aFontProperties ) throws com.sun.star.lang.IllegalArgumentException - { - // TODO - return null; - } - - public XCachedPrimitive drawText( StringContext text, XCanvasFont xFont, ViewState viewState, RenderState renderState, byte textDirection ) throws com.sun.star.lang.IllegalArgumentException - { - CanvasUtils.printLog( "CanvasBase.drawText() called" ); - - // cache - Graphics2D graphics = getGraphics(); - - CanvasUtils.printLog( "XCanvas: drawText called" ); - - CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint ); - CanvasUtils.setupGraphicsFont( graphics, viewState, renderState, xFont ); - - CanvasUtils.printLog( "XCanvas: drawText rendering \""+ text.Text.substring(text.StartPosition, text.StartPosition+text.Length) + "\"" ); - - graphics.drawString( text.Text.substring(text.StartPosition, text.StartPosition+text.Length), (float)0.0, (float)0.0 ); - return null; - } - - public XCachedPrimitive drawTextLayout( XTextLayout layoutetText, ViewState viewState, RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException - { - CanvasUtils.printLog( "CanvasBase.drawOffsettedText() called" ); - - // cache - Graphics2D graphics = getGraphics(); - - CanvasUtils.printLog( "XCanvas: drawOffsettedText called" ); - - CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint ); - CanvasUtils.setupGraphicsFont( graphics, viewState, renderState, layoutetText.getFont() ); - - CanvasUtils.printLog( "XCanvas: drawOffsettedText canvas setup done" ); - - if( layoutetText instanceof TextLayout ) - { - ((TextLayout)layoutetText).draw( graphics ); - } - else - { - CanvasUtils.printLog( "drawTextLayout: mismatching TextLayout object." ); - throw new com.sun.star.lang.IllegalArgumentException(); - } - - return null; - } - - public synchronized XCachedPrimitive drawBitmap( com.sun.star.rendering.XBitmap xBitmap, - com.sun.star.rendering.ViewState viewState, - com.sun.star.rendering.RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException - { - CanvasUtils.printLog( "CanvasBase.drawBitmap() called" ); - - // cache - Graphics2D graphics = getGraphics(); - - CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint ); - - java.awt.image.BufferedImage bitmap = CanvasUtils.getBufferedImage( xBitmap ); - - if( !graphics.drawImage(bitmap, 0, 0, null) ) - CanvasUtils.printLog( "CanvasBase.drawBitmap: image paint incomplete" ); - - CanvasUtils.postRenderImageTreatment( bitmap ); - - return null; - } - - public synchronized XCachedPrimitive drawBitmapModulated( com.sun.star.rendering.XBitmap xBitmap, - com.sun.star.rendering.ViewState viewState, - com.sun.star.rendering.RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException - { - CanvasUtils.printLog( "CanvasBase.drawBitmapModulated() called" ); - - // TODO(F3): Implement channel modulation - return drawBitmap(xBitmap, - viewState, - renderState); - } - - public synchronized XGraphicDevice getDevice() - { - CanvasUtils.printLog( "CanvasBase.getDevice() called" ); - return new CanvasGraphicDevice( getGraphics() ); - } -} diff --git a/canvas/source/java/CanvasBitmap.java b/canvas/source/java/CanvasBitmap.java deleted file mode 100644 index e55d96b76472..000000000000 --- a/canvas/source/java/CanvasBitmap.java +++ /dev/null @@ -1,255 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: CanvasBitmap.java,v $ - * $Revision: 1.8 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// Canvas -import com.sun.star.rendering.*; -import com.sun.star.geometry.*; - -public class CanvasBitmap - extends CanvasBase - implements com.sun.star.lang.XServiceInfo, - com.sun.star.rendering.XBitmapCanvas, - com.sun.star.rendering.XIntegerBitmap -{ - private java.awt.image.BufferedImage bitmap; - private java.awt.Graphics2D graphics; - - public CanvasBitmap( java.awt.image.BufferedImage _bitmap ) - { - bitmap = _bitmap; - graphics = bitmap.createGraphics(); - } - - public CanvasBitmap( IntegerSize2D mySize ) - { - bitmap = new java.awt.image.BufferedImage(mySize.Width, mySize.Height, - java.awt.image.BufferedImage.TYPE_4BYTE_ABGR); - graphics = bitmap.createGraphics(); - } - - public CanvasBitmap( RealSize2D newSize, boolean beFast, CanvasBitmap source ) - { -// java.awt.geom.AffineTransform transform = new java.awt.geom.AffineTransform(); -// transform.scale( newSize.width/size.Width, newSize.height/size.Height ); - -// // TODO: Maybe keep the image returned via -// // bitmap.getScaledInstance, and do scaling lazy. -// bitmap = new java.awt.image.BufferedImage((int)(newSize.width+.5), -// (int)(newSize.height+.5), -// java.awt.image.BufferedImage.TYPE_4BYTE_ABGR); - -// java.awt.image.AffineTransformOp transformer = -// new java.awt.image.AffineTransformOp( transform, -// java.awt.image.AffineTransformOp.TYPE_BILINEAR); - -// transformer.filter(source.getBufferedImage(), bitmap); - } - - public synchronized java.awt.image.BufferedImage getBufferedImage() - { - return bitmap; - } - - public java.awt.Graphics2D getGraphics() - { - return graphics; - } - - // - // XBitmap implementation - // ====================== - // - - public synchronized IntegerSize2D getSize() - { - return new IntegerSize2D( bitmap.getWidth(), - bitmap.getHeight() ); - } - - //---------------------------------------------------------------------------------- - - public synchronized XBitmapCanvas queryBitmapCanvas() - { - return this; - } - - //---------------------------------------------------------------------------------- - - public synchronized com.sun.star.rendering.XBitmap getScaledBitmap( RealSize2D newSize, boolean beFast ) throws com.sun.star.lang.IllegalArgumentException, VolatileContentDestroyedException - { - return new CanvasBitmap( newSize, beFast, this ); - } - - //---------------------------------------------------------------------------------- - - public synchronized boolean hasAlpha() - { - // TODO - return false; - } - - //---------------------------------------------------------------------------------- - - // - // XBitmapCanvas impl - // ================== - // - - public synchronized void copyRect( com.sun.star.rendering.XBitmapCanvas sourceCanvas, - com.sun.star.geometry.RealRectangle2D sourceRect, - com.sun.star.rendering.ViewState sourceViewState, - com.sun.star.rendering.RenderState sourceRenderState, - com.sun.star.geometry.RealRectangle2D destRect, - com.sun.star.rendering.ViewState destViewState, - com.sun.star.rendering.RenderState destRenderState ) - { - CanvasUtils.printLog( "JavaCanvas.copyRect() called" ); - - // TODO: create temp image when transform is non-trivial - - if( sourceCanvas == this ) - { - // copy rectangle within the canvas - getGraphics().copyArea((int)sourceRect.X1, - (int)sourceRect.Y1, - (int)(sourceRect.X2 - sourceRect.X1), - (int)(sourceRect.Y2 - sourceRect.Y1), - (int)(destRect.X1 - sourceRect.X1), - (int)(destRect.Y1 - sourceRect.Y1) ); - } - else - { - if( sourceCanvas instanceof JavaCanvas ) - { - // cache - CanvasUtils.setupGraphicsState( getGraphics(), destViewState, destRenderState, CanvasUtils.alsoSetupPaint ); - - java.awt.Image backBuffer = ((JavaCanvas)sourceCanvas).backBuffer.getBackBuffer(); - - // TODO: really extract correct source rect here - getGraphics().drawImage( backBuffer, 0, 0, null); - CanvasUtils.postRenderImageTreatment( backBuffer ); - } - // TODO: foreign canvas - } - } - - //---------------------------------------------------------------------------------- - - // - // XIntegerBitmap implementation - // ============================= - // - - public synchronized byte[] getData( IntegerBitmapLayout[] bitmapLayout, - IntegerRectangle2D rect ) - { - int [] pixelData = bitmap.getRGB( rect.X1, rect.Y1, rect.X2 - rect.X1, rect.Y1 - rect.Y2, null, 0, 0 ); - - return CanvasUtils.int2byte( pixelData ); - } - - //---------------------------------------------------------------------------------- - - public synchronized void setData( byte[] data, IntegerBitmapLayout bitmapLayout, com.sun.star.geometry.IntegerRectangle2D rect ) - { - int [] pixelData = CanvasUtils.byte2int( data ); - bitmap.setRGB( rect.X1, rect.Y1, rect.X2 - rect.X1, rect.Y2 - rect.Y1, pixelData, 0, bitmap.getWidth() ); - } - - //---------------------------------------------------------------------------------- - - public synchronized void setPixel( byte[] color, IntegerBitmapLayout bitmapLayout, com.sun.star.geometry.IntegerPoint2D pos ) - { - if( color.length != 4 ) - CanvasUtils.printLog( "CanvasBitmap.setPixel: Wrong color format" ); - - int pixel = color[0] + (color[1] + (color[2] + color[3]*256)*256)*256; - bitmap.setRGB( pos.X, pos.Y, pixel ); - } - - //---------------------------------------------------------------------------------- - - public synchronized byte[] getPixel( IntegerBitmapLayout[] bitmapLayout, - IntegerPoint2D pos ) - { - int pixel = bitmap.getRGB( pos.X, pos.Y ); - - byte[] res = new byte[4]; - res[0] = (byte)(pixel & 255); - res[1] = (byte)((pixel/256) & 255); - res[2] = (byte)((pixel/256/256) & 255); - res[3] = (byte)((pixel/256/256/256) & 255); - - return res; - } - - //---------------------------------------------------------------------------------- - - public synchronized XBitmapPalette getPalette() - { - return null; - } - - //---------------------------------------------------------------------------------- - - public synchronized IntegerBitmapLayout getMemoryLayout() - { - // TODO: finish that one - IntegerBitmapLayout layout = new IntegerBitmapLayout(); - - return layout; - } - - //---------------------------------------------------------------------------------- - - // - // XServiceInfo impl - // ================= - // - - private static final String s_implName = "XIntegerBitmap.java.impl"; - private static final String s_serviceName = "com.sun.star.rendering.IntegerBitmap"; - - public String getImplementationName() - { - return s_implName; - } - - public String [] getSupportedServiceNames() - { - return new String [] { s_serviceName }; - } - - public boolean supportsService( String serviceName ) - { - return serviceName.equals( s_serviceName ); - } -} diff --git a/canvas/source/java/CanvasClonedSprite.java b/canvas/source/java/CanvasClonedSprite.java deleted file mode 100644 index 0976f0adbbaa..000000000000 --- a/canvas/source/java/CanvasClonedSprite.java +++ /dev/null @@ -1,188 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: CanvasClonedSprite.java,v $ - * $Revision: 1.7 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// Canvas -import com.sun.star.rendering.*; -import com.sun.star.geometry.*; - -// Java AWT -import java.awt.geom.*; - -public class CanvasClonedSprite - extends com.sun.star.lib.uno.helper.ComponentBase - implements com.sun.star.rendering.XSprite, - com.sun.star.lang.XServiceInfo, - SpriteBase -{ - private JavaCanvas canvas; - private double alpha; - private java.awt.geom.Point2D.Double outputPosition; - private SpriteRep spriteRep; - private SpriteBase original; - - //---------------------------------------------------------------------------------- - - public CanvasClonedSprite( JavaCanvas _canvas, - XSprite _original ) - { - CanvasUtils.printLog( "CanvasClonesSprite constructor called!" ); - - canvas = _canvas; - - if( _original instanceof SpriteBase ) - { - original = (SpriteBase)_original; - } - - alpha = 0.0; - outputPosition = new java.awt.geom.Point2D.Double(0.0,0.0); - - // TODO: throw on error here! - } - - //---------------------------------------------------------------------------------- - - // - // SpriteBase - // ========== - // - public SpriteRep getSpriteRep() - { - if( spriteRep == null ) - { - spriteRep = new SpriteRep( original.getSpriteRep() ); - - spriteRep.moveSprite( outputPosition ); - spriteRep.setSpriteAlpha( alpha ); - - // TODO: Check for spriteRep.buffer != null here, throw otherwise - } - return spriteRep; - } - - //---------------------------------------------------------------------------------- - - // - // XComponent - // ========== - // - public void dispose() - { - canvas = null; - spriteRep = null; - original = null; - - super.dispose(); - } - - //---------------------------------------------------------------------------------- - - // - // XSprite impl - // ================== - // - - public synchronized void setPriority( double nPriority ) - { - // TODO - } - - public synchronized void setAlpha( double _alpha ) - { - alpha = _alpha; - - if( spriteRep != null ) - { - spriteRep.setSpriteAlpha( alpha ); - } - } - - public synchronized void move( RealPoint2D _aNewPos, - ViewState _viewState, - RenderState _renderState ) - { - // transform given point with concatenated transformation - AffineTransform transform = CanvasUtils.ViewConcatRenderTransform( _viewState, _renderState ); - transform.transform( new java.awt.geom.Point2D.Double(_aNewPos.X, - _aNewPos.Y), - outputPosition ); - - if( spriteRep != null ) - { - spriteRep.moveSprite( outputPosition ); - } - } - - public synchronized void transform( AffineMatrix2D aTransformation ) throws com.sun.star.lang.IllegalArgumentException - { - // TODO - } - - public synchronized void clip( XPolyPolygon2D aClip ) - { - // TODO - } - - public synchronized void show() - { - canvas.showSprite( this ); - canvas.updateScreen( false ); - } - - public synchronized void hide() - { - canvas.hideSprite( this ); - } - //---------------------------------------------------------------------------------- - - private static final String s_implName = "XSprite.java.impl"; - private static final String s_serviceName = "com.sun.star.rendering.Sprite"; - - //---------------------------------------------------------------------------------- - - // - // XServiceInfo impl - // ================= - // - public String getImplementationName() - { - return s_implName; - } - - public String [] getSupportedServiceNames() - { - return new String [] { s_serviceName }; - } - - public boolean supportsService( String serviceName ) - { - return serviceName.equals( s_serviceName ); - } -} diff --git a/canvas/source/java/CanvasCustomSprite.java b/canvas/source/java/CanvasCustomSprite.java deleted file mode 100644 index 3440f2f60dcd..000000000000 --- a/canvas/source/java/CanvasCustomSprite.java +++ /dev/null @@ -1,207 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: CanvasCustomSprite.java,v $ - * $Revision: 1.7 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// Canvas -import com.sun.star.rendering.*; -import com.sun.star.geometry.*; - -// Java AWT -import java.awt.*; -import java.awt.geom.*; - -public class CanvasCustomSprite - extends com.sun.star.lib.uno.helper.ComponentBase - implements com.sun.star.rendering.XCustomSprite, - com.sun.star.lang.XServiceInfo, - SpriteBase -{ - private JavaCanvas canvas; - private RealSize2D spriteSize; - private Graphics2D referenceGraphics; - private double alpha; - private java.awt.geom.Point2D.Double outputPosition; - private SpriteRep spriteRep; - - //---------------------------------------------------------------------------------- - - public CanvasCustomSprite( RealSize2D _spriteSize, - JavaCanvas _canvas, - Graphics2D _referenceGraphics ) - { - CanvasUtils.printLog( "CanvasCustomSprite constructor called, size is (" + _spriteSize.Width + ", " + _spriteSize.Height + ")" ); - - canvas = _canvas; - spriteSize = _spriteSize; - referenceGraphics = _referenceGraphics; - alpha = 0.0; - outputPosition = new java.awt.geom.Point2D.Double(0.0,0.0); - } - - //---------------------------------------------------------------------------------- - - // - // SpriteBase - // ========== - // - public synchronized SpriteRep getSpriteRep() - { - if( spriteRep == null ) - { - spriteRep = new SpriteRep(); - - spriteRep.setupBuffer(referenceGraphics, (int)(spriteSize.Width+.5), (int)(spriteSize.Height+.5) ); - - spriteRep.moveSprite( outputPosition ); - spriteRep.setSpriteAlpha( alpha ); - } - return spriteRep; - } - - //---------------------------------------------------------------------------------- - - // - // XComponent - // ========== - // - public void dispose() - { - if( spriteRep != null ) - spriteRep.dispose(); - - canvas = null; - referenceGraphics = null; - spriteRep = null; - - super.dispose(); - } - - //---------------------------------------------------------------------------------- - - // - // XCustomSprite impl - // ================== - // - - public synchronized void setPriority( double nPriority ) - { - // TODO - } - - public synchronized void setAlpha( double _alpha ) - { - CanvasUtils.printLog( "CanvasCustomSprite.setAlpha() called" ); - - alpha = _alpha; - - if( spriteRep != null ) - { - spriteRep.setSpriteAlpha( alpha ); - } - } - - public synchronized void move( RealPoint2D _aNewPos, - ViewState _viewState, - RenderState _renderState ) - { - CanvasUtils.printLog( "CanvasCustomSprite.move() called" ); - - // transform given point with concatenated transformation - AffineTransform transform = CanvasUtils.ViewConcatRenderTransform( _viewState, _renderState ); - transform.transform( new java.awt.geom.Point2D.Double(_aNewPos.X, - _aNewPos.Y), - outputPosition ); - - if( spriteRep != null ) - { - spriteRep.moveSprite( outputPosition ); - } - } - - public synchronized void transform( AffineMatrix2D aTransformation ) throws com.sun.star.lang.IllegalArgumentException - { - // TODO - } - - public synchronized void clip( XPolyPolygon2D aClip ) - { - // TODO - } - - public synchronized void show() - { - CanvasUtils.printLog( "CanvasCustomSprite.show() called" ); - - canvas.showSprite( this ); - canvas.updateScreen( false ); - } - - public synchronized void hide() - { - CanvasUtils.printLog( "CanvasCustomSprite.hide() called" ); - - canvas.hideSprite( this ); - - // do _not_ dispose clear SpriteRep, since we cannot actively - // repaint ourselves - } - - public synchronized com.sun.star.rendering.XCanvas getContentCanvas() - { - CanvasUtils.printLog( "CanvasCustomSprite.getContentCanvas() called" ); - - return getSpriteRep().getContentCanvas(); - } - - //---------------------------------------------------------------------------------- - - private static final String s_implName = "XCustomSprite.java.impl"; - private static final String s_serviceName = "com.sun.star.rendering.CustomSprite"; - - //---------------------------------------------------------------------------------- - - // - // XServiceInfo impl - // ================= - // - public String getImplementationName() - { - return s_implName; - } - - public String [] getSupportedServiceNames() - { - return new String [] { s_serviceName }; - } - - public boolean supportsService( String serviceName ) - { - return serviceName.equals( s_serviceName ); - } -} diff --git a/canvas/source/java/CanvasFont.java b/canvas/source/java/CanvasFont.java deleted file mode 100644 index c8f0d76395ba..000000000000 --- a/canvas/source/java/CanvasFont.java +++ /dev/null @@ -1,119 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: CanvasFont.java,v $ - * $Revision: 1.7 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// Canvas -import com.sun.star.rendering.*; - -public class CanvasFont - extends com.sun.star.lib.uno.helper.ComponentBase - implements com.sun.star.lang.XServiceInfo, - com.sun.star.rendering.XCanvasFont -{ - private CanvasBase associatedCanvas; - private com.sun.star.rendering.FontRequest fontRequest; - private java.awt.Font font; - - //---------------------------------------------------------------------------------- - - public CanvasFont( com.sun.star.rendering.FontRequest _fontRequest, - CanvasBase _canvas ) - { - associatedCanvas = _canvas; - fontRequest = _fontRequest; - - // TODO: Use proper attributes here, first of all, use fractional point font size - font = new java.awt.Font( fontRequest.FontDescription.FamilyName, java.awt.Font.PLAIN, (int)(fontRequest.CellSize + .5) ); - } - - public java.awt.Font getFont() - { - return font; - } - - //---------------------------------------------------------------------------------- - - // - // XCanvasFont implementation - // =========================== - // - - public XTextLayout createTextLayout( StringContext aText, byte nDirection, long nRandomSeed ) - { - return new TextLayout( aText, nDirection, nRandomSeed, this, associatedCanvas ); - } - - public FontRequest getFontRequest( ) - { - return fontRequest; - } - - public FontMetrics getFontMetrics( ) - { - // TODO - return null; - } - - public double[] getAvailableSizes( ) - { - // TODO - return null; - } - - public com.sun.star.beans.PropertyValue[] getExtraFontProperties( ) - { - // TODO - return null; - } - - //---------------------------------------------------------------------------------- - - // - // XServiceInfo impl - // ================= - // - - private static final String s_implName = "CanvasFont.java.impl"; - private static final String s_serviceName = "com.sun.star.rendering.XCanvasFont"; - - public String getImplementationName() - { - return s_implName; - } - - public String [] getSupportedServiceNames() - { - return new String [] { s_serviceName }; - } - - public boolean supportsService( String serviceName ) - { - return serviceName.equals( s_serviceName ); - } -} diff --git a/canvas/source/java/CanvasGraphicDevice.java b/canvas/source/java/CanvasGraphicDevice.java deleted file mode 100644 index 1c9c99b7a408..000000000000 --- a/canvas/source/java/CanvasGraphicDevice.java +++ /dev/null @@ -1,225 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: CanvasGraphicDevice.java,v $ - * $Revision: 1.8 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// Canvas -import com.sun.star.rendering.*; -import com.sun.star.geometry.*; - -// Java AWT -import java.awt.*; - -public class CanvasGraphicDevice - extends com.sun.star.lib.uno.helper.ComponentBase - implements com.sun.star.lang.XServiceInfo, - com.sun.star.beans.XPropertySet, - com.sun.star.rendering.XGraphicDevice -{ - private java.awt.Graphics2D graphics; - private java.awt.GraphicsConfiguration graphicsConfig; - - //---------------------------------------------------------------------------------- - - public CanvasGraphicDevice( java.awt.Graphics2D _graphics ) - { - graphics = _graphics; - graphicsConfig = graphics.getDeviceConfiguration(); - } - - //---------------------------------------------------------------------------------- - - // - // GraphicsDevice implementation - // ============================= - // - public synchronized XBufferController getBufferController() - { - // Use java.awt.image.BufferStrategy to implement XBufferController - CanvasUtils.printLog( "CanvasGraphicDevice.getBufferController!" ); - return null; - } - - public synchronized XColorSpace getDeviceColorSpace() - { - CanvasUtils.printLog( "CanvasGraphicDevice.getDeviceColorSpace!" ); - return null; - } - - public synchronized com.sun.star.geometry.RealSize2D getPhysicalResolution() - { - CanvasUtils.printLog( "CanvasGraphicDevice.getPhysicalResolution!" ); - // TODO: getDefaultTransform + getNormalizingTransform - return new com.sun.star.geometry.RealSize2D(100,100); - } - - public synchronized com.sun.star.geometry.RealSize2D getPhysicalSize() - { - CanvasUtils.printLog( "CanvasGraphicDevice.getSize!" ); - java.awt.Rectangle bounds = graphicsConfig.getBounds(); - - return new com.sun.star.geometry.RealSize2D(bounds.width, bounds.height); - } - - public synchronized XLinePolyPolygon2D createCompatibleLinePolyPolygon( RealPoint2D[][] points ) - { - CanvasUtils.printLog( "createCompatibleLinePolyPolygon" ); - return new LinePolyPolygon( points ); - } - - public synchronized XBezierPolyPolygon2D createCompatibleBezierPolyPolygon( RealBezierSegment2D[][] points ) - { - CanvasUtils.printLog( "createCompatibleBezierPolyPolygon" ); - return new BezierPolyPolygon( points ); - } - - public synchronized com.sun.star.rendering.XBitmap createCompatibleBitmap( IntegerSize2D size ) - { - CanvasUtils.printLog( "createCompatibleBitmap called with size (" + size.Width + ", " + size.Height + ")" ); - return new CanvasBitmap( graphicsConfig.createCompatibleImage( size.Width, - size.Height, - Transparency.OPAQUE ) ); - } - - public synchronized com.sun.star.rendering.XVolatileBitmap createVolatileBitmap( IntegerSize2D size ) - { - CanvasUtils.printLog( "createVolatileBitmap called with size (" + size.Width + ", " + size.Height + ")" ); - //return new CanvasBitmap( graphicsConfig.createCompatibleVolatileImage( size.Width, size.Height ) ); - return null; - } - - public synchronized com.sun.star.rendering.XBitmap createCompatibleAlphaBitmap( IntegerSize2D size ) - { - CanvasUtils.printLog( "createCompatibleBitmap called with size (" + size.Width + ", " + size.Height + ")" ); - return new CanvasBitmap( graphicsConfig.createCompatibleImage( size.Width, - size.Height, - Transparency.TRANSLUCENT ) ); - } - - public synchronized com.sun.star.rendering.XVolatileBitmap createVolatileAlphaBitmap( IntegerSize2D size ) - { - CanvasUtils.printLog( "createVolatileBitmap called with size (" + size.Width + ", " + size.Height + ")" ); - //return new CanvasBitmap( graphicsConfig.createCompatibleVolatileImage( size.Width, size.Height ) ); - return null; - } - - public synchronized com.sun.star.rendering.XParametricPolyPolygon2DFactory getParametricPolyPolygonFactory() - { - // TODO - return null; - } - - public synchronized com.sun.star.beans.XPropertySetInfo getPropertySetInfo() - { - // This is a stealth property set - return null; - } - - public synchronized void setPropertyValue( String aPropertyName, java.lang.Object aValue ) throws com.sun.star.beans.PropertyVetoException - { - // all our properties are read-only - throw new com.sun.star.beans.PropertyVetoException(); - } - - public synchronized java.lang.Object getPropertyValue( String PropertyName ) throws com.sun.star.beans.UnknownPropertyException - { - if( PropertyName == "DeviceHandle" ) - return graphics; - - throw new com.sun.star.beans.UnknownPropertyException(); - } - - public synchronized void addPropertyChangeListener( String aPropertyName, com.sun.star.beans.XPropertyChangeListener xListener ) throws com.sun.star.beans.UnknownPropertyException - { - if( aPropertyName == "DeviceHandle" ) - return; - - throw new com.sun.star.beans.UnknownPropertyException(); - } - - public synchronized void removePropertyChangeListener( String aPropertyName, com.sun.star.beans.XPropertyChangeListener aListener ) throws com.sun.star.beans.UnknownPropertyException - { - if( aPropertyName == "DeviceHandle" ) - return; - - throw new com.sun.star.beans.UnknownPropertyException(); - } - - public synchronized void addVetoableChangeListener( String PropertyName, com.sun.star.beans.XVetoableChangeListener aListener ) throws com.sun.star.beans.UnknownPropertyException - { - if( PropertyName == "DeviceHandle" ) - return; - - throw new com.sun.star.beans.UnknownPropertyException(); - } - - public synchronized void removeVetoableChangeListener( String PropertyName, com.sun.star.beans.XVetoableChangeListener aListener ) throws com.sun.star.beans.UnknownPropertyException - { - if( PropertyName == "DeviceHandle" ) - return; - - throw new com.sun.star.beans.UnknownPropertyException(); - } - - - public synchronized boolean hasFullScreenMode() - { - return graphicsConfig.getDevice().isFullScreenSupported(); - } - - public synchronized boolean enterFullScreenMode( boolean bEnter ) - { - return false; - } - - //---------------------------------------------------------------------------------- - - // - // XServiceInfo impl - // ================= - // - - private static final String s_implName = "XGraphicsDevice.java.impl"; - private static final String s_serviceName = "com.sun.star.rendering.GraphicsDevice"; - - public String getImplementationName() - { - return s_implName; - } - - public String [] getSupportedServiceNames() - { - return new String [] { s_serviceName }; - } - - public boolean supportsService( String serviceName ) - { - return serviceName.equals( s_serviceName ); - } - -} diff --git a/canvas/source/java/CanvasSprite.java b/canvas/source/java/CanvasSprite.java deleted file mode 100644 index 630b9ed386aa..000000000000 --- a/canvas/source/java/CanvasSprite.java +++ /dev/null @@ -1,311 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: CanvasSprite.java,v $ - * $Revision: 1.7 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// Canvas -import com.sun.star.rendering.*; -import com.sun.star.geometry.*; - -// Java AWT -import java.awt.*; -import java.awt.geom.*; - -public class CanvasSprite - extends com.sun.star.lib.uno.helper.ComponentBase - implements com.sun.star.rendering.XAnimatedSprite, - com.sun.star.lang.XServiceInfo, - SpriteBase -{ - private XAnimation spriteAnimation; - private JavaCanvas canvas; - private Graphics2D referenceGraphics; - private SpriteRunner runner; - private ViewState viewState; - private double alpha; - private java.awt.geom.Point2D.Double outputPosition; - private SpriteRep spriteRep; - - //---------------------------------------------------------------------------------- - - public CanvasSprite( XAnimation _animation, JavaCanvas _canvas, Graphics2D _referenceGraphics ) - { - CanvasUtils.printLog( "CanvasSprite constructor called!" ); - - spriteAnimation = _animation; - canvas = _canvas; - referenceGraphics = _referenceGraphics; - alpha = 0.0; - outputPosition = new java.awt.geom.Point2D.Double(0.0,0.0); - - runner = new SpriteRunner( this, spriteAnimation, canvas ); - } - - public synchronized ViewState getViewState() - { - return viewState; - } - - //---------------------------------------------------------------------------------- - - // - // SpriteBase - // ========== - // - public synchronized SpriteRep getSpriteRep() - { - if( spriteRep == null ) - { - spriteRep = new SpriteRep(); - - setupSpriteBuffering( CanvasUtils.makeTransform( getViewState().AffineTransform ) ); - - spriteRep.moveSprite( outputPosition ); - spriteRep.setSpriteAlpha( alpha ); - - // render initial sprite content - updateAnimation(); - } - return spriteRep; - } - - //---------------------------------------------------------------------------------- - - // - // XComponent - // ========== - // - public void dispose() - { - // end the animation thread - if( runner != null ) - { - runner.quit(); - try - { - runner.join(0); // and wait until it's really over - } - catch( java.lang.InterruptedException e ) {} - } - - if( spriteRep != null ) - spriteRep.dispose(); - - canvas = null; - spriteAnimation = null; - runner = null; - referenceGraphics = null; - spriteRep = null; - - super.dispose(); - } - - //---------------------------------------------------------------------------------- - - // - // XSprite impl - // ============ - // - - public synchronized void startAnimation( double speed ) - { - runner.startAnimation( speed ); - } - - public synchronized void stopAnimation() - { - runner.stopAnimation(); - } - - public synchronized void resetAnimation() - { - runner.resetAnimation(); - } - - public synchronized void updateAnimation() - { - // only call render explicitely, if animation not - // running. Otherwise, next animation render will update - // anyway. - if( spriteRep != null && - !runner.isAnimationActive() ) - { - spriteRep.renderAnimation( spriteAnimation, getViewState(), runner.getCurrentT() ); - } - } - - public synchronized void setPriority( double nPriority ) - { - // TODO - } - - public synchronized void setAlpha( double _alpha ) - { - alpha = _alpha; - - if( spriteRep != null ) - { - spriteRep.setSpriteAlpha( alpha ); - } - } - - public synchronized void move( com.sun.star.geometry.RealPoint2D _aNewPos, - com.sun.star.rendering.ViewState _viewState, - com.sun.star.rendering.RenderState _renderState ) - { - // transform given point with concatenated transformation - AffineTransform transform = CanvasUtils.ViewConcatRenderTransform( _viewState, _renderState ); - transform.transform( new java.awt.geom.Point2D.Double(_aNewPos.X, - _aNewPos.Y), - outputPosition ); - - if( spriteRep != null ) - { - spriteRep.moveSprite( outputPosition ); - } - } - - public synchronized void transform( AffineMatrix2D aTransformation ) throws com.sun.star.lang.IllegalArgumentException - { - // TODO - } - - public synchronized void clip( XPolyPolygon2D aClip ) - { - // TODO - } - - public synchronized void show() - { - canvas.showSprite( this ); - canvas.updateScreen( false ); - } - - public synchronized void hide() - { - canvas.hideSprite( this ); - - // dispose and clear SpriteRep, animation content can be - // regenerated at any time - if( spriteRep != null ) - spriteRep.dispose(); - - spriteRep = null; - } - - public synchronized void setViewState( ViewState _viewState ) - { - viewState = CanvasUtils.createAnimationViewState(_viewState, - getAnimationAttributes()); - - CanvasUtils.printTransform( CanvasUtils.makeTransform( viewState.AffineTransform ), - "CanvasSprite.setViewState" ); - - if( spriteRep != null ) - { - // calculate bounds of view-transformed animation output rectangle - setupSpriteBuffering( CanvasUtils.makeTransform(getViewState().AffineTransform) ); - updateAnimation(); - } - } - - public synchronized AnimationAttributes getAnimationAttributes() - { - return spriteAnimation.getAnimationAttributes(); - } - - public synchronized void setAll( RealPoint2D _aNewPos, - ViewState _viewState, - RenderState _renderState, - double _alpha, - boolean bUpdateAnimation ) - { - alpha = _alpha; - - // transform given point with concatenated transformation - AffineTransform transform = CanvasUtils.ViewConcatRenderTransform( _viewState, _renderState ); - transform.transform( new java.awt.geom.Point2D.Double(_aNewPos.X, - _aNewPos.Y), - outputPosition ); - - if( spriteRep != null ) - { - spriteRep.setSpriteAlpha( alpha ); - spriteRep.moveSprite( outputPosition ); - - if( bUpdateAnimation ) - updateAnimation(); - } - } - - //---------------------------------------------------------------------------------- - - private void setupSpriteBuffering( AffineTransform _viewTransform ) - { - // determine bounds of view-transformed animation output rectangle - com.sun.star.geometry.RealSize2D animSize = getAnimationAttributes().UntransformedSize; - - java.awt.geom.Rectangle2D.Double aTransformedBounds = - CanvasUtils.calcTransformedRectBounds( new java.awt.geom.Rectangle2D.Double(0.0,0.0, - animSize.Width, - animSize.Height), - _viewTransform ); - CanvasUtils.printTransform( _viewTransform, "setupSpriteBuffering" ); - CanvasUtils.printLog( "setupSpriteBuffering: bounds are (" + aTransformedBounds.width + ", " + aTransformedBounds.height + ")" ); - - // create a buffer of the appropriate size - spriteRep.setupBuffer(referenceGraphics, (int)(aTransformedBounds.width+.5), - (int)(aTransformedBounds.height+.5) ); - } - - //---------------------------------------------------------------------------------- - - private static final String s_implName = "XSprite.java.impl"; - private static final String s_serviceName = "com.sun.star.rendering.Sprite"; - - //---------------------------------------------------------------------------------- - - // - // XServiceInfo impl - // ================= - // - public String getImplementationName() - { - return s_implName; - } - - public String [] getSupportedServiceNames() - { - return new String [] { s_serviceName }; - } - - public boolean supportsService( String serviceName ) - { - return serviceName.equals( s_serviceName ); - } -} diff --git a/canvas/source/java/CanvasTest_perftest.java b/canvas/source/java/CanvasTest_perftest.java deleted file mode 100644 index 035fce6b38b3..000000000000 --- a/canvas/source/java/CanvasTest_perftest.java +++ /dev/null @@ -1,679 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: CanvasTest_perftest.java,v $ - * $Revision: 1.6 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// UNO -import com.sun.star.uno.UnoRuntime; -import com.sun.star.uno.XComponentContext; -import com.sun.star.uno.AnyConverter; -import com.sun.star.uno.IQueryInterface; -import com.sun.star.lang.XInitialization; -import com.sun.star.lib.uno.helper.WeakBase; - -// OOo AWT -import com.sun.star.awt.*; - -// Canvas -import com.sun.star.rendering.*; - -// Java AWT -import java.awt.*; -import java.awt.image.*; -import java.awt.geom.*; - -public class CanvasTest - extends CanvasBase - implements com.sun.star.awt.XWindow, - com.sun.star.rendering.XSpriteCanvas, - com.sun.star.lang.XServiceInfo, - com.sun.star.lang.XInitialization -{ - private WindowAdapter dummyFrame; - private BackBuffer backBuffer; - private java.awt.image.BufferStrategy bufferStrategy; - - private java.awt.Font fpsFont; - private long lastTime; - - - // TEST ONLY { - private static int testWidth = 1600; - private static int testHeight = 1200; - private BufferedImage backgroundBuffer; - private BufferedImage buffer; - private BufferedImage buffer2; - private Graphics2D backBufGraphics; - private Graphics2D bufferGraphics; - private Graphics2D buffer2Graphics; - private float currAlpha; - // TEST ONLY } - - - - public Graphics2D getGraphics() - { - return backBuffer.getGraphics(); - } - - //---------------------------------------------------------------------------------- - - // - // XInitialization - // =============== - // - public void initialize( java.lang.Object[] arguments ) - { - CanvasUtils.printLog( "CanvasTest.initialize called!" ); - - // Do that as the very first thing. The Java2D internal - // classes choose their render path at initialization time, - // thus this must happen before doing _any_ GUI. - - // TODO: Put those flags into javarc/java.ini, we're maybe - // coming late into a running JVM! - - // now, we're getting slightly system dependent here. - String os = (String) System.getProperty("os.name"); - - CanvasUtils.printLog( "System detected: " + os ); - - // tweak some speed knobs... - if( os.startsWith("Windows") ) - { - System.setProperty("sun.java2d.translaccel", "true"); - System.setProperty("sun.java2d.ddforcevram", "true"); - //System.setProperty("sun.java2d.accthreshold", "0"); - - CanvasUtils.printLog( "Optimizing for Windows" ); - } - else - { - System.setProperty("sun.java2d.opengl", "true"); - - CanvasUtils.printLog( "Optimizing for Unix" ); - } - - /* we're initialized with the following array of anys: - - arguments[0] = pointer to VCL window - arguments[1] = Integer (operating system window handle) - arguments[2] = com.sun.star.awt.Rectangle (position and size within that OS window) - arguments[3] = boolean (fullsize window or not) - - We then generate a dummy Java frame with that window as the - parent, to fake a root window for the Java implementation. - */ - try - { - com.sun.star.awt.Rectangle boundRect = (com.sun.star.awt.Rectangle) arguments[2]; - - //boolean isFullScreen = arguments[1]; - boolean isFullScreen = true; - //AnyConverter.toBoolean( arguments[3] ) ); - - // fake a root for Java in VCL window. Pass the flag - // whether we shall run fullscreen, too. - dummyFrame = new WindowAdapter( AnyConverter.toInt( arguments[1] ), isFullScreen ); - - if( isFullScreen ) - { - // blow window up to fullscreen. Otherwise, we cannot clear the whole screen, - // which results in ugly flickering - Dimension screenSize = dummyFrame.frame.getToolkit().getScreenSize(); - boundRect.X = 0; - boundRect.Y = 0; - boundRect.Width = screenSize.width-1; - boundRect.Height = screenSize.height-1; - } - - dummyFrame.setPosSize( boundRect.X, boundRect.Y, boundRect.Width, boundRect.Height, (short)0 ); - CanvasUtils.printLog( "Window size: " + boundRect.Width + ", " + boundRect.Height ); - - // TEST - if( true ) - { - backBuffer = new BackBuffer( (Graphics2D) dummyFrame.frame.getGraphics(), - Math.max(1,boundRect.Width), - Math.max(1,boundRect.Height) ); - } - else - { - backBuffer = new BackBuffer( (Graphics2D) dummyFrame.frame.getGraphics(), - 10, 10 ); - } - - // TODO: Maybe delay double buffer init until first sprite creation - dummyFrame.frame.createBufferStrategy(2); - bufferStrategy = dummyFrame.frame.getBufferStrategy(); - - if( bufferStrategy.getCapabilities().isPageFlipping() ) - CanvasUtils.printLog( "CanvasTest.initialize double buffering is using page flipping!" ); - else - CanvasUtils.printLog( "CanvasTest.initialize double buffering is using blitting!" ); - - lastTime = System.currentTimeMillis(); - fpsFont = new java.awt.Font( "Times", Font.PLAIN, 20 ); - - - if( false ) - { - // TEST ONLY { - Graphics2D frameGraphics= (Graphics2D) dummyFrame.frame.getGraphics(); - backgroundBuffer = frameGraphics.getDeviceConfiguration().createCompatibleImage(testWidth,testHeight); // TODO: size dynamic - buffer = frameGraphics.getDeviceConfiguration().createCompatibleImage(testWidth,testHeight, - Transparency.TRANSLUCENT); - buffer2 = frameGraphics.getDeviceConfiguration().createCompatibleImage(testWidth,testHeight, - Transparency.TRANSLUCENT); - bufferGraphics = (Graphics2D)buffer.getGraphics(); - buffer2Graphics = (Graphics2D)buffer2.getGraphics(); - backBufGraphics = (Graphics2D)backgroundBuffer.getGraphics(); - currAlpha = 0.1f; - - // init content - Font font = new Font( "Times", Font.PLAIN, 100 ); - - bufferGraphics.setComposite( AlphaComposite.getInstance(AlphaComposite.CLEAR)); - bufferGraphics.fillRect( 0,0,testWidth,testHeight ); - - bufferGraphics.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER)); - bufferGraphics.setColor( Color.red ); - bufferGraphics.fillRect( 0,0,testWidth/2,testHeight/2 ); - bufferGraphics.setColor( Color.green ); - bufferGraphics.fillRect( testWidth/2,0,testWidth,testHeight/2 ); - bufferGraphics.setColor( Color.blue ); - bufferGraphics.fillRect( 0,testHeight/2,testWidth/2,testHeight ); - - buffer2Graphics.setColor( Color.red ); - buffer2Graphics.fillRect( 0,0,testWidth/2,testHeight/2 ); - buffer2Graphics.setColor( Color.green ); - buffer2Graphics.fillRect( testWidth/2,0,testWidth,testHeight/2 ); - buffer2Graphics.setColor( Color.blue ); - buffer2Graphics.fillRect( 0,testHeight/2,testWidth/2,testHeight ); - - backBufGraphics.setColor( Color.white ); - backBufGraphics.fillRect(0,0,testWidth,testHeight); - backBufGraphics.setColor( Color.red ); - backBufGraphics.setFont( font ); - int i, turns=15; - for(i=0; i<turns; ++i) - { - backBufGraphics.drawString( "Crossfade test", testWidth*i/turns, testHeight*i/turns ); - } - // TEST ONLY } - } - - CanvasUtils.printLog( "CanvasTest.initialize finished!" ); - } - catch( com.sun.star.lang.IllegalArgumentException e ) - { - CanvasUtils.printLog( "Cannot create EmbeddedFrame within VCL window hierarchy!" ); - } - } - - //---------------------------------------------------------------------------------- - - // - // XComponent - // ========== - // - public void dispose() - { - CanvasUtils.printLog( "CanvasTest: disposed!" ); - - // destroy all active sprites - java.util.Set entries = activeSprites.entrySet(); - java.util.Iterator iter = entries.iterator(); - - while( iter.hasNext() ) - { - java.util.Map.Entry entry = (java.util.Map.Entry)iter.next(); - if( entry.getValue() != null ) - ((SpriteRep)entry.getValue()).dispose(); - } - - if( bufferStrategy != null ) - bufferStrategy.getDrawGraphics().dispose(); // really necessary? - - if( dummyFrame != null ) - dummyFrame.dispose(); - - if( backBuffer != null) - backBuffer.dispose(); - - bufferStrategy = null; - dummyFrame = null; - backBuffer = null; - - super.dispose(); - } - - //---------------------------------------------------------------------------------- - - public CanvasTest( XComponentContext xContext ) - { - CanvasUtils.printLog( "CanvasTest constructor called!" ); - activeSprites = new java.util.HashMap( 33 ); - } - - //---------------------------------------------------------------------------------- - - // - // XWindow interface - // ================= - // - // This is delegated to WindowAdapter! - // - public synchronized void setPosSize( int X, int Y, int Width, int Height, short Flags ) - { - if( dummyFrame != null ) - { - dummyFrame.setPosSize( X, Y, Width, Height, Flags ); - - Width = Math.max(1,Width); - Height= Math.max(1,Height); - - CanvasUtils.printLog( "CanvasTest graphics set to " + Width + "," + Height ); - backBuffer.setSize(Width,Height); - } - } - - public synchronized com.sun.star.awt.Rectangle getPosSize( ) - { - if( dummyFrame != null ) - return dummyFrame.getPosSize(); - - return new com.sun.star.awt.Rectangle(); - } - - public synchronized void setVisible( boolean visible ) - { - if( dummyFrame != null ) - dummyFrame.setVisible( visible ); - } - - public synchronized void setEnable( boolean enable ) - { - if( dummyFrame != null ) - dummyFrame.setEnable( enable ); - } - - public synchronized void setFocus() - { - if( dummyFrame != null ) - dummyFrame.setFocus(); - } - - public synchronized void addWindowListener( XWindowListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.addWindowListener( xListener ); - } - - public synchronized void removeWindowListener( XWindowListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.removeWindowListener( xListener ); - } - - public synchronized void addFocusListener( XFocusListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.addFocusListener( xListener ); - } - - public synchronized void removeFocusListener( XFocusListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.removeFocusListener( xListener ); - } - - public synchronized void addKeyListener( XKeyListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.addKeyListener( xListener ); - } - - public synchronized void removeKeyListener( XKeyListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.removeKeyListener( xListener ); - } - - public synchronized void addMouseListener( XMouseListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.addMouseListener( xListener ); - } - - public synchronized void removeMouseListener( XMouseListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.removeMouseListener( xListener ); - } - - public synchronized void addMouseMotionListener( XMouseMotionListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.addMouseMotionListener( xListener ); - } - - public synchronized void removeMouseMotionListener( XMouseMotionListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.removeMouseMotionListener( xListener ); - } - - public synchronized void addPaintListener( XPaintListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.addPaintListener( xListener ); - } - - public synchronized void removePaintListener( XPaintListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.removePaintListener( xListener ); - } - - //---------------------------------------------------------------------------------- - - // - // XBitmapCanvas impl - // ================== - // - - public synchronized void copyRect( com.sun.star.rendering.XBitmapCanvas sourceCanvas, - com.sun.star.rendering.Rectangle2D sourceRect, - com.sun.star.rendering.ViewState sourceViewState, - com.sun.star.rendering.RenderState sourceRenderState, - com.sun.star.rendering.Rectangle2D destRect, - com.sun.star.rendering.ViewState destViewState, - com.sun.star.rendering.RenderState destRenderState ) - { - CanvasUtils.printLog( "CanvasTest.copyRect() called" ); - - // TODO: create temp image when transform is non-trivial - - if( sourceCanvas == this ) - { - // copy rectangle within the canvas - getGraphics().copyArea((int)sourceRect.x1, - (int)sourceRect.y1, - (int)(sourceRect.x2 - sourceRect.x1), - (int)(sourceRect.y2 - sourceRect.y1), - (int)(destRect.x1 - sourceRect.x1), - (int)(destRect.y1 - sourceRect.y1) ); - } - else - { - if( sourceCanvas instanceof CanvasTest ) - { - // cache - CanvasUtils.setupGraphicsState( getGraphics(), destViewState, destRenderState, CanvasUtils.alsoSetupPaint ); - - java.awt.Image backBuffer = ((CanvasTest)sourceCanvas).backBuffer.getBackBuffer(); - - // TODO: really extract correct source rect here - getGraphics().drawImage( backBuffer, 0, 0, null); - CanvasUtils.postRenderImageTreatment( backBuffer ); - } - // TODO: foreign canvas - } - } - - //---------------------------------------------------------------------------------- - - // a map of SpriteReps, with Sprite object as keys. Contains all - // active (i.e. visible) sprites, the SpriteReps are used to - // repaint the sprite content at any time. - private java.util.HashMap activeSprites; - - // - // XSpriteCanvas impl - // ================== - // - - public synchronized com.sun.star.rendering.XAnimatedSprite createSpriteFromAnimation( XAnimation animation ) - { - CanvasUtils.printLog( "CanvasTest.createSpriteFromAnimation called" ); - - return new CanvasSprite( animation, this, (Graphics2D)dummyFrame.frame.getGraphics() ); - } - - public synchronized XAnimatedSprite createSpriteFromBitmaps( com.sun.star.rendering.XBitmap[] animationBitmaps, - short interpolationMode ) - { - return null; - } - - public synchronized XCustomSprite createCustomSprite( Size2D spriteSize ) - { - CanvasUtils.printLog( "CanvasTest.createCustomSprite called" ); - - return new CanvasCustomSprite( spriteSize, this, (Graphics2D)dummyFrame.frame.getGraphics() ); - } - - public synchronized XSprite createClonedSprite( XSprite original ) - { - return new CanvasClonedSprite( this, original ); - } - - public synchronized void updateScreen() - { - redrawAllLayers(); - } - - //---------------------------------------------------------------------------------- - - // - // XSpriteCanvas helper - // ==================== - // - public synchronized void renderAnimation( CanvasSprite sprite, XAnimation animation, double t ) - { - SpriteRep spriteRep = (SpriteRep)activeSprites.get( sprite ); - if( spriteRep != null ) - { - //Graphics2D graph = getWindowGraphics(); - - // TODO: ensure update of graphics object externally, e.g. when - // VCL moves the toplevel window. - //java.awt.Rectangle bounds = dummyFrame.frame.getBounds(); - //graphics.setGraphics(graph, bounds.width, bounds.height); - - spriteRep.renderAnimation( animation, sprite.getViewState(), t ); - } - else - { - CanvasUtils.printLog( "CanvasTest.renderAnimation sprite not active!" ); - } - } - - public synchronized void showSprite( SpriteBase sprite ) - { - CanvasUtils.printLog( "CanvasTest.showSprite() called" ); - - SpriteRep spriteRep = (SpriteRep)activeSprites.get( sprite ); - if( spriteRep != null ) - { - CanvasUtils.printLog( "CanvasTest.showSprite sprite already active!" ); - } - else - { - spriteRep = sprite.getSpriteRep(); - - // a valid SpriteRep for a given Sprite in the - // activeSprites hash denotes 'sprite active' - activeSprites.put( sprite, spriteRep ); - - // TODO: TEMP! Just for testing! Set empty cursor for presentation -// dummyFrame.frame.setCursor( dummyFrame.frame.getToolkit().createCustomCursor(new java.awt.image.BufferedImage(0,0, -// java.awt.image.BufferedImage.TYPE_INT_RGB), -// new java.awt.Point(0,0), -// "") ); - } - } - - public synchronized void hideSprite( SpriteBase sprite ) - { - CanvasUtils.printLog( "CanvasTest.hideSprite() called" ); - - SpriteRep spriteRep = (SpriteRep)activeSprites.get( sprite ); - if( spriteRep != null ) - { - activeSprites.put( sprite, null ); - redrawAllLayers(); - } - else - { - CanvasUtils.printLog( "CanvasTest.hideSprite sprite not active!" ); - } - } - - private void redrawAllLayers() - { - // fetch the Graphics object to draw into (we're doing double - // buffering here, the content is later shown via - // bufferStrategy.show(). - Graphics2D graph = null; - - try - { - graph = (Graphics2D)bufferStrategy.getDrawGraphics(); - - GraphicsDevice device = graph.getDeviceConfiguration().getDevice(); - CanvasUtils.printLog( "Available vram: " + device.getAvailableAcceleratedMemory() ); - - if( false ) - { - // TEST ONLY { - // repaint background - graph.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER) ); - graph.drawImage(backgroundBuffer, 0, 0, null); - //backgroundBuffer.flush(); - - // alpha-composite foreground on top of that - graph.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER, currAlpha) ); - - graph.drawImage(buffer, 0, 0, null); - //buffer.flush(); - - currAlpha += 0.1f; if( currAlpha > 1.0 ) currAlpha = 0.1f; - // TEST ONLY } - } - - if( true ) - { - // repaint background - backBuffer.redraw( graph ); - - // repaint all active sprites - java.util.Set entries = activeSprites.entrySet(); - java.util.Iterator iter = entries.iterator(); - while( iter.hasNext() ) - { - java.util.Map.Entry entry = (java.util.Map.Entry)iter.next(); - if( entry.getValue() != null ) - ((SpriteRep)entry.getValue()).redraw(graph); - } - } - - long currTime = System.currentTimeMillis(); - graph.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER) ); - graph.setFont( fpsFont ); - graph.setColor( java.awt.Color.black ); - - try - { - String fps = new String( String.valueOf(1000.0/(currTime-lastTime)) ); - graph.drawString( fps.substring(0,5) + " fps", 0, 20); - CanvasUtils.printLog( fps.substring(0,5) + " fps" ); - } - catch( Exception e ) - { - graph.drawString( "0 fps", 0, 20); - } - - lastTime = currTime; - } - finally - { - if( graph != null ) - graph.dispose(); - } - - bufferStrategy.show(); - } - - //---------------------------------------------------------------------------------- - - private static final String s_implName = "XCanvas.java.impl"; - private static final String s_serviceName = "com.sun.star.rendering.Canvas"; - - //---------------------------------------------------------------------------------- - - // - // XServiceInfo impl - // ================= - // - public synchronized String getImplementationName() - { - return s_implName; - } - - public synchronized String [] getSupportedServiceNames() - { - return new String [] { s_serviceName }; - } - - public synchronized boolean supportsService( String serviceName ) - { - return serviceName.equals( s_serviceName ); - } - - public static com.sun.star.lang.XSingleServiceFactory __getServiceFactory( - String implName, - com.sun.star.lang.XMultiServiceFactory multiFactory, - com.sun.star.registry.XRegistryKey regKey ) - { - if (implName.equals( s_implName )) - { - return com.sun.star.comp.loader.FactoryHelper.getServiceFactory( - CanvasTest.class, s_serviceName, multiFactory, regKey ); - } - return null; - } - - public static boolean __writeRegistryServiceInfo( - com.sun.star.registry.XRegistryKey regKey ) - { - return com.sun.star.comp.loader.FactoryHelper.writeRegistryServiceInfo( - s_implName, s_serviceName, regKey ); - } -} diff --git a/canvas/source/java/CanvasUtils.java b/canvas/source/java/CanvasUtils.java deleted file mode 100644 index 423bb6954e06..000000000000 --- a/canvas/source/java/CanvasUtils.java +++ /dev/null @@ -1,630 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: CanvasUtils.java,v $ - * $Revision: 1.7 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// UNO -import com.sun.star.uno.UnoRuntime; - -// Canvas -import com.sun.star.rendering.*; -import com.sun.star.geometry.*; - -// Java AWT -import java.awt.*; -import java.awt.geom.*; - -public class CanvasUtils -{ - // - // Canvas utilities - // ================ - // - public static java.awt.geom.AffineTransform makeTransform( AffineMatrix2D ooTransform ) - { - return new AffineTransform( ooTransform.m00, - ooTransform.m10, - ooTransform.m01, - ooTransform.m11, - ooTransform.m02, - ooTransform.m12 ); - } - - public static AffineMatrix2D makeAffineMatrix2D( java.awt.geom.AffineTransform transform ) - { - double[] matrix = new double[6]; - transform.getMatrix( matrix ); - - return new AffineMatrix2D( matrix[0], matrix[2], matrix[4], - matrix[1], matrix[3], matrix[5] ); - } - - public static void initGraphics( Graphics2D graphics ) - { - if( graphics != null ) - { - java.awt.RenderingHints hints = new java.awt.RenderingHints(null); - boolean hq = true; - - if( hq ) - { - hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_FRACTIONALMETRICS, - java.awt.RenderingHints.VALUE_FRACTIONALMETRICS_ON ) ); -// hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_ALPHA_INTERPOLATION, -// java.awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY) ); - hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_ALPHA_INTERPOLATION, - java.awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED) ); -// hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_INTERPOLATION, -// java.awt.RenderingHints.VALUE_INTERPOLATION_BICUBIC) ); - hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_INTERPOLATION, - java.awt.RenderingHints.VALUE_INTERPOLATION_BILINEAR) ); -// hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_RENDERING, -// java.awt.RenderingHints.VALUE_RENDER_QUALITY) ); - hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_RENDERING, - java.awt.RenderingHints.VALUE_RENDER_SPEED) ); -// hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_STROKE_CONTROL, -// java.awt.RenderingHints.VALUE_STROKE_NORMALIZE) ); - hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_STROKE_CONTROL, - java.awt.RenderingHints.VALUE_STROKE_DEFAULT) ); - hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_ANTIALIASING, - java.awt.RenderingHints.VALUE_ANTIALIAS_ON) ); - } - else - { - hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_ALPHA_INTERPOLATION, - java.awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED) ); - hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_INTERPOLATION, - java.awt.RenderingHints.VALUE_INTERPOLATION_BILINEAR) ); - hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_RENDERING, - java.awt.RenderingHints.VALUE_RENDER_SPEED) ); - hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_STROKE_CONTROL, - java.awt.RenderingHints.VALUE_STROKE_DEFAULT) ); - hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_ANTIALIASING, - java.awt.RenderingHints.VALUE_ANTIALIAS_OFF) ); - } - - // the least common denominator standard - hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_FRACTIONALMETRICS, - java.awt.RenderingHints.VALUE_FRACTIONALMETRICS_ON) ); - hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_TEXT_ANTIALIASING, - java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON) ); - - graphics.setRenderingHints( hints ); - } - } - - //---------------------------------------------------------------------------------- - - public static java.awt.geom.GeneralPath makeGenPathFromBezierPoints( RealBezierSegment2D [][] points ) - { - java.awt.geom.GeneralPath path = new java.awt.geom.GeneralPath(); - - // extract every polygon into GeneralPath object - for( int i=0; i<points.length; ++i ) - { - if( points[i].length > 0 ) - path.moveTo((float) points[i][0].Px, (float) points[i][0].Py); - - for( int j=1; j<points[i].length; ++j ) - { - CanvasUtils.printLog( "makeGenPathFromBezierPoints: point added." ); - path.curveTo((float)(points[i][j-1].C1x), (float)(points[i][j-1].C1y), - (float)(points[i][j-1].C2x), (float)(points[i][j-1].C2y), - (float) points[i][j].Px, (float) points[i][j].Py ); - } - - // TODO: closePath? - } - - return path; - } - - public static java.awt.geom.GeneralPath makeGenPathFromBezierPoly( com.sun.star.rendering.XBezierPolyPolygon2D poly ) - { - try - { - com.sun.star.geometry.RealBezierSegment2D [][] points = poly.getBezierSegments(0,-1,0,-1); - - return makeGenPathFromBezierPoints( points ); - } - catch( com.sun.star.lang.IndexOutOfBoundsException e ) - { - } - - return new java.awt.geom.GeneralPath(); - } - - public static java.awt.geom.GeneralPath makeGenPathFromLinePoints( RealPoint2D [][] points ) - { - java.awt.geom.GeneralPath path = new java.awt.geom.GeneralPath(); - - // extract every polygon into GeneralPath object - for( int i=0; i<points.length; ++i ) - { - if( points[i].length > 0 ) - path.moveTo((float) points[i][0].X, (float) points[i][0].Y); - - for( int j=1; j<points[i].length; ++j ) - { - CanvasUtils.printLog( "makeGenPathFromLinePoints: point (" + - points[i][j].X + "," + points[i][j].Y + ") added." ); - path.lineTo((float) points[i][j].X, (float) points[i][j].Y ); - } - - // TODO: closePath? - } - - return path; - } - - public static java.awt.geom.GeneralPath makeGenPathFromLinePoly( com.sun.star.rendering.XLinePolyPolygon2D poly ) - { - try - { - com.sun.star.geometry.RealPoint2D [][] points = poly.getPoints(0,-1,0,-1); - - return makeGenPathFromLinePoints( points ); - } - catch( com.sun.star.lang.IndexOutOfBoundsException e ) - { - } - - return new java.awt.geom.GeneralPath(); - } - - public static java.awt.geom.GeneralPath makeGeneralPath( com.sun.star.rendering.XPolyPolygon2D poly ) - { - if( poly instanceof BezierPolyPolygon ) - { - CanvasUtils.printLog( "makeGeneralPath: bezier impl used." ); - return ((BezierPolyPolygon)poly).getJavaPath(); - } - - if( poly instanceof LinePolyPolygon ) - { - CanvasUtils.printLog( "makeGeneralPath: line impl used." ); - return ((LinePolyPolygon)poly).getJavaPath(); - } - - XBezierPolyPolygon2D bezierPoly = (XBezierPolyPolygon2D) UnoRuntime.queryInterface(XBezierPolyPolygon2D.class, poly); - - if( bezierPoly != null ) - { - // extract polygon data. Prefer bezier interface, because - // that's the more high-level data. - return makeGenPathFromBezierPoly( bezierPoly ); - } - - XLinePolyPolygon2D linePoly = (XLinePolyPolygon2D) UnoRuntime.queryInterface(XLinePolyPolygon2D.class, poly); - - if( linePoly != null ) - { - // extract polygon data. Fallback to line polygon, if no - // curves are available. - return makeGenPathFromLinePoly( linePoly ); - } - - // Only opaque general interface. No chance to get to the - // data. Empty path, then - CanvasUtils.printLog( "makeGeneralPath: Cannot access polygon data, given interface has class" + poly.getClass().getName() ); - return new GeneralPath(); - } - - public static java.awt.image.BufferedImage getBufferedImage( com.sun.star.rendering.XBitmap bitmap ) - { - if( bitmap instanceof CanvasBitmap ) - { - CanvasUtils.printLog( "getBufferedImage: CanvasBitmap impl used." ); - return ((CanvasBitmap)bitmap).getBufferedImage(); - } - - XIntegerBitmap integerBitmap = (XIntegerBitmap) UnoRuntime.queryInterface(XIntegerBitmap.class, bitmap); - - if( integerBitmap != null ) - { - // extract bitmap data. TODO. - return null; - } - - // check other types. TODO. - return null; - } - - public static byte [] int2byte( int [] input ) - { - byte [] output = new byte[4*input.length]; - - int i, j; - for( i=0, j=0; i<input.length; ++i ) - { - output[j] = (byte)(input[i] & 255); - output[j+1] = (byte)((input[i]/256) & 255); - output[j+2] = (byte)((input[i]/256/256) & 255); - output[j+3] = (byte)((input[i]/256/256/256) & 255); - j += 4; - } - - return output; - } - - public static int [] byte2int( byte [] input ) - { - int [] output = new int[(input.length+3)/4]; - - int i, j; - for( i=0,j=0; j<output.length; ++j ) - { - output[j] = input[i] + (input[i+1] + (input[i+2] + input[i+3]*256)*256)*256; - i += 4; - } - - return output; - } - - public static int javaRuleFromCompositeOp( byte compositeOp ) - { - // TODO: Finish mapping of Canvas and Java compositing magics - int rule = java.awt.AlphaComposite.SRC_OVER; - switch( compositeOp ) - { - case com.sun.star.rendering.CompositeOperation.CLEAR: - CanvasUtils.printLog( "javaRuleFromCompositeOp: clear selected" ); - rule = java.awt.AlphaComposite.CLEAR; - break; - - case com.sun.star.rendering.CompositeOperation.SOURCE: - CanvasUtils.printLog( "javaRuleFromCompositeOp: src selected" ); - rule = java.awt.AlphaComposite.SRC; - break; - - case com.sun.star.rendering.CompositeOperation.DESTINATION: - CanvasUtils.printLog( "javaRuleFromCompositeOp: dst selected" ); - rule = java.awt.AlphaComposite.DST; - break; - - case com.sun.star.rendering.CompositeOperation.OVER: - CanvasUtils.printLog( "javaRuleFromCompositeOp: over selected" ); - rule = java.awt.AlphaComposite.SRC_OVER; - break; - - case com.sun.star.rendering.CompositeOperation.UNDER: - CanvasUtils.printLog( "javaRuleFromCompositeOp: under selected" ); - rule = java.awt.AlphaComposite.DST_OVER; - break; - - case com.sun.star.rendering.CompositeOperation.INSIDE: - CanvasUtils.printLog( "javaRuleFromCompositeOp: inside selected" ); - rule = java.awt.AlphaComposite.CLEAR; - break; - - case com.sun.star.rendering.CompositeOperation.INSIDE_REVERSE: - CanvasUtils.printLog( "javaRuleFromCompositeOp: inReverse selected" ); - rule = java.awt.AlphaComposite.CLEAR; - break; - - case com.sun.star.rendering.CompositeOperation.OUTSIDE: - CanvasUtils.printLog( "javaRuleFromCompositeOp: outside selected" ); - rule = java.awt.AlphaComposite.CLEAR; - break; - - case com.sun.star.rendering.CompositeOperation.OUTSIDE_REVERSE: - CanvasUtils.printLog( "javaRuleFromCompositeOp: outReverse selected" ); - rule = java.awt.AlphaComposite.CLEAR; - break; - - case com.sun.star.rendering.CompositeOperation.XOR: - CanvasUtils.printLog( "javaRuleFromCompositeOp: xor selected" ); - rule = java.awt.AlphaComposite.CLEAR; - break; - - case com.sun.star.rendering.CompositeOperation.ADD: - CanvasUtils.printLog( "javaRuleFromCompositeOp: add selected" ); - rule = java.awt.AlphaComposite.CLEAR; - break; - - case com.sun.star.rendering.CompositeOperation.SATURATE: - CanvasUtils.printLog( "javaRuleFromCompositeOp: saturate selected" ); - rule = java.awt.AlphaComposite.CLEAR; - break; - - default: - CanvasUtils.printLog( "javaRuleFromCompositeOp: Unexpected compositing rule" ); - break; - } - - return rule; - } - - public static java.awt.AlphaComposite makeAlphaComposite( byte compositeOp ) - { - return java.awt.AlphaComposite.getInstance( javaRuleFromCompositeOp( compositeOp ) ); - } - - public static java.awt.AlphaComposite makeAlphaCompositeAlpha( byte compositeOp, double alpha ) - { - return java.awt.AlphaComposite.getInstance( javaRuleFromCompositeOp( compositeOp ), (float)alpha ); - } - - // when given to setupGraphicsState, makes that method to also - // setup the Paint with the color specified in the render state. - public static final byte alsoSetupPaint=0; - - // when given to setupGraphicsState, makes that method to _not_ - // setup the Paint with the color specified in the render state. - public static final byte dontSetupPaint=1; - - public static java.awt.geom.AffineTransform ViewConcatRenderTransform( ViewState viewState, - RenderState renderState ) - { - // calculate overall affine transform - AffineTransform transform = makeTransform( viewState.AffineTransform ); - transform.concatenate( makeTransform( renderState.AffineTransform ) ); - - printTransform( transform, "ViewConcatRenderTransform" ); - - return transform; - } - - public static void setupGraphicsState( java.awt.Graphics2D graphics, - ViewState viewState, - RenderState renderState, - byte paintTouchMode ) - { - // calculate overall affine transform - graphics.setTransform( ViewConcatRenderTransform(viewState, renderState ) ); - - // setup overall clip polyPolygon - if( viewState.Clip != null ) - { - Area clipArea = new Area( makeGeneralPath( viewState.Clip ) ); - - if( renderState.Clip != null ) - clipArea.intersect( new Area( makeGeneralPath( renderState.Clip ) ) ); - - graphics.setClip( clipArea ); - } - else if( renderState.Clip != null ) - { - Area clipArea = new Area( makeGeneralPath( renderState.Clip ) ); - graphics.setClip( clipArea ); - } - else - { - // TODO: HACK! Use true visible area here! - graphics.setClip( new java.awt.Rectangle(-1000000,-1000000,2000000,2000000) ); - } - - // setup current output color - // TODO: Complete color handling here - if( paintTouchMode == alsoSetupPaint ) - { - switch( renderState.DeviceColor.length ) - { - case 3: - CanvasUtils.printLog( "setupGraphicsState: Color(" + - renderState.DeviceColor[0] + "," + - renderState.DeviceColor[1] + "," + - renderState.DeviceColor[2] + ") set." ); - graphics.setColor( new Color( (float)renderState.DeviceColor[0], - (float)renderState.DeviceColor[1], - (float)renderState.DeviceColor[2] ) ); - break; - - case 4: - CanvasUtils.printLog( "setupGraphicsState: Color(" + - renderState.DeviceColor[0] + "," + - renderState.DeviceColor[1] + "," + - renderState.DeviceColor[2] + "," + - renderState.DeviceColor[3] + ") set." ); - graphics.setColor( new Color( (float)renderState.DeviceColor[0], - (float)renderState.DeviceColor[1], - (float)renderState.DeviceColor[2], - (float)renderState.DeviceColor[3] ) ); - break; - - default: - CanvasUtils.printLog( "setupGraphicsState: unexpected number of " + - renderState.DeviceColor.length + " color components!" ); - break; - } - } - - // setup current composite mode - graphics.setComposite( makeAlphaComposite( renderState.CompositeOperation ) ); - } - - public static void applyStrokeAttributes( java.awt.Graphics2D graphics, - StrokeAttributes attributes ) - { - int cap = java.awt.BasicStroke.CAP_BUTT; - - if( attributes.StartCapType != attributes.EndCapType ) - CanvasUtils.printLog( "applyStrokeAttributes: different start and end caps are not yet supported!" ); - - if( attributes.LineArray.length != 0 ) - CanvasUtils.printLog( "applyStrokeAttributes: multi-strokes are not yet supported!" ); - - if( attributes.StartCapType == PathCapType.BUTT ) - cap = java.awt.BasicStroke.CAP_BUTT; - else if( attributes.StartCapType == PathCapType.ROUND ) - cap = java.awt.BasicStroke.CAP_ROUND; - else if( attributes.StartCapType == PathCapType.SQUARE ) - cap = java.awt.BasicStroke.CAP_SQUARE; - - int join = java.awt.BasicStroke.JOIN_MITER; - - if( attributes.JoinType == PathJoinType.MITER ) - cap = java.awt.BasicStroke.JOIN_MITER; - else if( attributes.JoinType == PathJoinType.ROUND ) - cap = java.awt.BasicStroke.JOIN_ROUND; - else if( attributes.JoinType == PathJoinType.BEVEL ) - cap = java.awt.BasicStroke.JOIN_BEVEL; - else - CanvasUtils.printLog( "applyStrokeAttributes: current join type not yet supported!" ); - - float [] dashArray = null; - - if( attributes.DashArray.length != 0 ) - { - dashArray = new float [attributes.DashArray.length]; - - for( int i=0; i<attributes.DashArray.length; ++i ) - dashArray[i] = (float)attributes.DashArray[i]; - } - - graphics.setStroke( new java.awt.BasicStroke( (float)attributes.StrokeWidth, - cap, - join, - (float)attributes.MiterLimit, - dashArray, - 0) ); - } - - public static void setupGraphicsFont( java.awt.Graphics2D graphics, - ViewState viewState, - RenderState renderState, - com.sun.star.rendering.XCanvasFont xFont ) - { - if( xFont instanceof CanvasFont ) - { - CanvasUtils.printLog( "setupGraphicsFont: font impl used." ); - graphics.setFont( ((CanvasFont)xFont).getFont() ); - } - else - { - CanvasUtils.printLog( "setupGraphicsFont: creating Java font anew." ); - CanvasFont canvasFont; - canvasFont = new CanvasFont( xFont.getFontRequest(), null ); - graphics.setFont( canvasFont.getFont() ); - } - } - - static java.awt.geom.Rectangle2D.Double calcTransformedRectBounds( java.awt.geom.Rectangle2D.Double aRect, - AffineTransform aTransform ) - { - // transform rect by given transformation - java.awt.geom.Point2D.Double aPointTopLeft = new java.awt.geom.Point2D.Double(aRect.x, aRect.y); - aTransform.transform(aPointTopLeft, aPointTopLeft); - - java.awt.geom.Point2D.Double aPointTopRight = new java.awt.geom.Point2D.Double(aRect.x + aRect.width, - aRect.y); - aTransform.transform(aPointTopRight, aPointTopRight); - - java.awt.geom.Point2D.Double aPointBottomLeft = new java.awt.geom.Point2D.Double(aRect.x, - aRect.y + aRect.height); - aTransform.transform(aPointBottomLeft, aPointBottomLeft); - - java.awt.geom.Point2D.Double aPointBottomRight = new java.awt.geom.Point2D.Double(aRect.x + aRect.width, - aRect.y + aRect.height); - aTransform.transform(aPointBottomRight, aPointBottomRight); - - // calc bounding rect of those four points - java.awt.geom.Point2D.Double aResTopLeft = new java.awt.geom.Point2D.Double( Math.min(aPointTopLeft.x, - Math.min(aPointTopRight.x, - Math.min(aPointBottomLeft.x,aPointBottomRight.x))), - Math.min(aPointTopLeft.y, - Math.min(aPointTopRight.y, - Math.min(aPointBottomLeft.y,aPointBottomRight.y))) ); - - java.awt.geom.Point2D.Double aResBottomRight = new java.awt.geom.Point2D.Double( Math.max(aPointTopLeft.x, - Math.max(aPointTopRight.x, - Math.max(aPointBottomLeft.x,aPointBottomRight.x))), - Math.max(aPointTopLeft.y, - Math.max(aPointTopRight.y, - Math.max(aPointBottomLeft.y,aPointBottomRight.y))) ); - return new java.awt.geom.Rectangle2D.Double( aResTopLeft.x, aResTopLeft.y, - aResBottomRight.x - aResTopLeft.x, - aResBottomRight.y - aResTopLeft.y ); - } - - // Create a corrected view transformation out of the give one, - // which ensures that the rectangle given by (0,0) and - // attributes.untransformedSize is mapped with its left,top corner - // to (0,0) again. This is required to properly render sprite - // animations to buffer bitmaps. - public static ViewState createAnimationViewState( ViewState inputViewState, - AnimationAttributes attributes ) - { - // TODO: Properly respect clip here. Might have to be transformed, too. - - AffineTransform aViewTransform = makeTransform( inputViewState.AffineTransform ); - - // transform Rect(0,0,attributes.untransformedSize) by - // viewTransform - java.awt.geom.Rectangle2D.Double aTransformedRect = - calcTransformedRectBounds( new java.awt.geom.Rectangle2D.Double(0.0, 0.0, - attributes.UntransformedSize.Width, - attributes.UntransformedSize.Height), - aViewTransform ); - - printTransform( aViewTransform, "createAnimationViewState" ); - - CanvasUtils.printLog( "createAnimationViewState: transformed origin is: (" + aTransformedRect.x + ", " + aTransformedRect.y + ")" ); - - // now move resulting left,top point of bounds to (0,0) - AffineTransform animationViewTransform = new AffineTransform(); - animationViewTransform.translate( -aTransformedRect.x, -aTransformedRect.y ); - animationViewTransform.concatenate( aViewTransform ); - - printTransform( animationViewTransform, "createAnimationViewState" ); - - return new ViewState( makeAffineMatrix2D( animationViewTransform ), inputViewState.Clip ); - } - - public static void postRenderImageTreatment( Image buffer ) - { - // TODO: This is specific to Sun's JREs 1.4 and upwards. Make this more portable - buffer.flush(); // as long as we force images to VRAM, - // we need to flush them afterwards, to - // avoid eating up all VRAM. - } - - public static void printTransform( AffineTransform transform, - String stringPrefix ) - { - CanvasUtils.printLog( stringPrefix + ": Transform is" ); - double [] matrix = new double[6]; - transform.getMatrix(matrix); - int i; - for( i=0; i<6; ++i ) - System.err.print( matrix[i] + ", " ); - CanvasUtils.printLog( "" ); - } - - public static void preCondition( boolean bCondition, - String methodName ) - { - if( !bCondition ) - printLog("Precondition violated: " + methodName); - } - - public static void printLog( String s ) - { - System.err.println( s ); - } -} diff --git a/canvas/source/java/JavaCanvas.java b/canvas/source/java/JavaCanvas.java deleted file mode 100644 index c4090d06ee0f..000000000000 --- a/canvas/source/java/JavaCanvas.java +++ /dev/null @@ -1,678 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: JavaCanvas.java,v $ - * $Revision: 1.9 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// UNO -import com.sun.star.uno.XComponentContext; -import com.sun.star.uno.AnyConverter; - -// OOo AWT -import com.sun.star.awt.*; - -// Canvas -import com.sun.star.rendering.*; -import com.sun.star.geometry.*; - -// Java AWT -import java.awt.*; - -public class JavaCanvas - extends CanvasBase - implements com.sun.star.awt.XWindow, - com.sun.star.rendering.XSpriteCanvas, - com.sun.star.rendering.XIntegerBitmap, - com.sun.star.lang.XServiceInfo, - com.sun.star.lang.XInitialization -{ - private WindowAdapter dummyFrame; - public BackBuffer backBuffer; - private java.awt.image.BufferStrategy bufferStrategy; - - private java.awt.Font fpsFont; - private long lastTime; - private com.sun.star.awt.Rectangle boundRect; - - public Graphics2D getGraphics() - { - return backBuffer.getGraphics(); - } - - //---------------------------------------------------------------------------------- - - // - // XInitialization - // =============== - // - public void initialize( java.lang.Object[] arguments ) - { - CanvasUtils.printLog( "JavaCanvas.initialize called!" ); - - // Do that as the very first thing. The Java2D internal - // classes choose their render path at initialization time, - // thus this must happen before doing _any_ GUI. - - // TODO: Put those flags into javarc/java.ini, we're maybe - // coming late into a running JVM! - - // now, we're getting slightly system dependent here. - String os = (String) System.getProperty("os.name"); - - CanvasUtils.printLog( "System detected: " + os ); - - // tweak some speed knobs... -// if( os.startsWith("Windows") ) -// { -// System.setProperty("sun.java2d.translaccel", "true"); -// System.setProperty("sun.java2d.ddforcevram", "true"); -// //System.setProperty("sun.java2d.accthreshold", "0"); - -// CanvasUtils.printLog( "Optimizing for Windows" ); -// } -// else -// { -// System.setProperty("sun.java2d.opengl", "true"); - -// CanvasUtils.printLog( "Optimizing for Unix" ); -// } - - /* we're initialized with the following array of anys: - - arguments[0] = pointer to VCL window - arguments[1] = Integer (operating system window handle) - arguments[2] = com.sun.star.awt.Rectangle (position and size within that OS window) - arguments[3] = boolean (fullsize window or not) - - We then generate a dummy Java frame with that window as the - parent, to fake a root window for the Java implementation. - */ - try - { - boundRect = (com.sun.star.awt.Rectangle) arguments[2]; - - //boolean isFullScreen = arguments[1]; - boolean isFullScreen = true; - //AnyConverter.toBoolean( arguments[3] ) ); - - // fake a root for Java in VCL window. Pass the flag - // whether we shall run fullscreen, too. - dummyFrame = new WindowAdapter( AnyConverter.toInt( arguments[1] ), isFullScreen ); - - if( isFullScreen ) - { - // blow window up to fullscreen. Otherwise, we cannot clear the whole screen, - // which results in ugly flickering - Dimension screenSize = dummyFrame.frame.getToolkit().getScreenSize(); - boundRect.X = 0; - boundRect.Y = 0; - boundRect.Width = screenSize.width-1; - boundRect.Height = screenSize.height-1; - } - - dummyFrame.setPosSize( boundRect.X, boundRect.Y, boundRect.Width, boundRect.Height, (short)0 ); - CanvasUtils.printLog( "Window size: " + boundRect.Width + ", " + boundRect.Height ); - - backBuffer = new BackBuffer( (Graphics2D) dummyFrame.frame.getGraphics(), - Math.max(1,boundRect.Width), - Math.max(1,boundRect.Height) ); - - // TODO: Maybe delay double buffer init until first sprite creation - dummyFrame.frame.createBufferStrategy(2); - bufferStrategy = dummyFrame.frame.getBufferStrategy(); - - if( bufferStrategy.getCapabilities().isPageFlipping() ) - CanvasUtils.printLog( "JavaCanvas.initialize double buffering is using page flipping!" ); - else - CanvasUtils.printLog( "JavaCanvas.initialize double buffering is using blitting!" ); - - lastTime = System.currentTimeMillis(); - fpsFont = new java.awt.Font( "Times", Font.PLAIN, 20 ); - - CanvasUtils.printLog( "JavaCanvas.initialize finished!" ); - } - catch( com.sun.star.lang.IllegalArgumentException e ) - { - CanvasUtils.printLog( "Cannot create EmbeddedFrame within VCL window hierarchy!" ); - } - } - - //---------------------------------------------------------------------------------- - - // - // XComponent - // ========== - // - public void dispose() - { - CanvasUtils.printLog( "JavaCanvas: disposed!" ); - - // destroy all active sprites - java.util.Set entries = activeSprites.entrySet(); - java.util.Iterator iter = entries.iterator(); - - while( iter.hasNext() ) - { - java.util.Map.Entry entry = (java.util.Map.Entry)iter.next(); - if( entry.getValue() != null ) - ((SpriteRep)entry.getValue()).dispose(); - } - - if( bufferStrategy != null ) - bufferStrategy.getDrawGraphics().dispose(); // really necessary? - - if( dummyFrame != null ) - dummyFrame.dispose(); - - if( backBuffer != null) - backBuffer.dispose(); - - bufferStrategy = null; - dummyFrame = null; - backBuffer = null; - - super.dispose(); - } - - //---------------------------------------------------------------------------------- - - public JavaCanvas( XComponentContext xContext ) - { - CanvasUtils.printLog( "JavaCanvas constructor called!" ); - activeSprites = new java.util.HashMap( 33 ); - } - - //---------------------------------------------------------------------------------- - - // - // XWindow interface - // ================= - // - // This is delegated to WindowAdapter! - // - public synchronized void setPosSize( int X, int Y, int Width, int Height, short Flags ) - { - if( dummyFrame != null ) - { - dummyFrame.setPosSize( X, Y, Width, Height, Flags ); - - Width = Math.max(1,Width); - Height= Math.max(1,Height); - - CanvasUtils.printLog( "JavaCanvas graphics set to " + Width + "," + Height ); - backBuffer.setSize(Width,Height); - } - } - - public synchronized com.sun.star.awt.Rectangle getPosSize( ) - { - if( dummyFrame != null ) - return dummyFrame.getPosSize(); - - return new com.sun.star.awt.Rectangle(); - } - - public synchronized void setVisible( boolean visible ) - { - if( dummyFrame != null ) - dummyFrame.setVisible( visible ); - } - - public synchronized void setEnable( boolean enable ) - { - if( dummyFrame != null ) - dummyFrame.setEnable( enable ); - } - - public synchronized void setFocus() - { - if( dummyFrame != null ) - dummyFrame.setFocus(); - } - - public synchronized void addWindowListener( XWindowListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.addWindowListener( xListener ); - } - - public synchronized void removeWindowListener( XWindowListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.removeWindowListener( xListener ); - } - - public synchronized void addFocusListener( XFocusListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.addFocusListener( xListener ); - } - - public synchronized void removeFocusListener( XFocusListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.removeFocusListener( xListener ); - } - - public synchronized void addKeyListener( XKeyListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.addKeyListener( xListener ); - } - - public synchronized void removeKeyListener( XKeyListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.removeKeyListener( xListener ); - } - - public synchronized void addMouseListener( XMouseListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.addMouseListener( xListener ); - } - - public synchronized void removeMouseListener( XMouseListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.removeMouseListener( xListener ); - } - - public synchronized void addMouseMotionListener( XMouseMotionListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.addMouseMotionListener( xListener ); - } - - public synchronized void removeMouseMotionListener( XMouseMotionListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.removeMouseMotionListener( xListener ); - } - - public synchronized void addPaintListener( XPaintListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.addPaintListener( xListener ); - } - - public synchronized void removePaintListener( XPaintListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.removePaintListener( xListener ); - } - - //---------------------------------------------------------------------------------- - - // - // XBitmapCanvas impl - // ================== - // - - public synchronized void copyRect( com.sun.star.rendering.XBitmapCanvas sourceCanvas, - com.sun.star.geometry.RealRectangle2D sourceRect, - com.sun.star.rendering.ViewState sourceViewState, - com.sun.star.rendering.RenderState sourceRenderState, - com.sun.star.geometry.RealRectangle2D destRect, - com.sun.star.rendering.ViewState destViewState, - com.sun.star.rendering.RenderState destRenderState ) - { - CanvasUtils.printLog( "JavaCanvas.copyRect() called" ); - - // TODO: create temp image when transform is non-trivial - - if( sourceCanvas == this ) - { - // copy rectangle within the canvas - getGraphics().copyArea((int)sourceRect.X1, - (int)sourceRect.Y1, - (int)(sourceRect.X2 - sourceRect.X1), - (int)(sourceRect.Y2 - sourceRect.Y1), - (int)(destRect.X1 - sourceRect.X1), - (int)(destRect.Y1 - sourceRect.Y1) ); - } - else - { - if( sourceCanvas instanceof JavaCanvas ) - { - // cache - CanvasUtils.setupGraphicsState( getGraphics(), destViewState, destRenderState, CanvasUtils.alsoSetupPaint ); - - java.awt.Image backBuffer = ((JavaCanvas)sourceCanvas).backBuffer.getBackBuffer(); - - // TODO: really extract correct source rect here - getGraphics().drawImage( backBuffer, 0, 0, null); - CanvasUtils.postRenderImageTreatment( backBuffer ); - } - // TODO: foreign canvas - } - } - - //---------------------------------------------------------------------------------- - - // a map of SpriteReps, with Sprite object as keys. Contains all - // active (i.e. visible) sprites, the SpriteReps are used to - // repaint the sprite content at any time. - private java.util.HashMap activeSprites; - - // - // XSpriteCanvas impl - // ================== - // - - public synchronized com.sun.star.rendering.XAnimatedSprite createSpriteFromAnimation( XAnimation animation ) - { - CanvasUtils.printLog( "JavaCanvas.createSpriteFromAnimation called" ); - - return new CanvasSprite( animation, this, (Graphics2D)dummyFrame.frame.getGraphics() ); - } - - public synchronized XAnimatedSprite createSpriteFromBitmaps( com.sun.star.rendering.XBitmap[] animationBitmaps, - byte interpolationMode ) - { - return null; - } - - public synchronized XCustomSprite createCustomSprite( RealSize2D spriteSize ) - { - CanvasUtils.printLog( "JavaCanvas.createCustomSprite called" ); - - return new CanvasCustomSprite( spriteSize, this, (Graphics2D)dummyFrame.frame.getGraphics() ); - } - - public synchronized XSprite createClonedSprite( XSprite original ) - { - return new CanvasClonedSprite( this, original ); - } - - public synchronized boolean updateScreen( boolean bUpdateAll ) - { - redrawAllLayers(); - - return true; - } - - // - // XBitmap implementation - // ====================== - // - - public synchronized IntegerSize2D getSize() - { - return new IntegerSize2D( boundRect.Width, - boundRect.Height ); - } - - //---------------------------------------------------------------------------------- - - public synchronized XBitmapCanvas queryBitmapCanvas() - { - return this; - } - - //---------------------------------------------------------------------------------- - - public synchronized com.sun.star.rendering.XBitmap getScaledBitmap( RealSize2D newSize, boolean beFast ) throws com.sun.star.lang.IllegalArgumentException, VolatileContentDestroyedException - { - // TODO - return null; - } - - //---------------------------------------------------------------------------------- - - public synchronized boolean hasAlpha() - { - // TODO - return false; - } - - //---------------------------------------------------------------------------------- - - // - // XIntegerBitmap implementation - // ============================= - // - - public synchronized byte[] getData( IntegerBitmapLayout[] bitmapLayout, - IntegerRectangle2D rect ) - { - // TODO - return null; - } - - //---------------------------------------------------------------------------------- - - public synchronized void setData( byte[] data, IntegerBitmapLayout bitmapLayout, com.sun.star.geometry.IntegerRectangle2D rect ) - { - // TODO - } - - //---------------------------------------------------------------------------------- - - public synchronized void setPixel( byte[] color, IntegerBitmapLayout bitmapLayout, com.sun.star.geometry.IntegerPoint2D pos ) - { - // TODO - } - - //---------------------------------------------------------------------------------- - - public synchronized byte[] getPixel( IntegerBitmapLayout[] bitmapLayout, - IntegerPoint2D pos ) - { - // TODO - return null; - } - - //---------------------------------------------------------------------------------- - - public synchronized XBitmapPalette getPalette() - { - // TODO - return null; - } - - //---------------------------------------------------------------------------------- - - public synchronized IntegerBitmapLayout getMemoryLayout() - { - // TODO: finish that one - IntegerBitmapLayout layout = new IntegerBitmapLayout(); - - return layout; - } - - //---------------------------------------------------------------------------------- - - // - // XSpriteCanvas helper - // ==================== - // - public synchronized void renderAnimation( CanvasSprite sprite, XAnimation animation, double t ) - { - SpriteRep spriteRep = (SpriteRep)activeSprites.get( sprite ); - if( spriteRep != null ) - { - //Graphics2D graph = getWindowGraphics(); - - // TODO: ensure update of graphics object externally, e.g. when - // VCL moves the toplevel window. - //java.awt.Rectangle bounds = dummyFrame.frame.getBounds(); - //graphics.setGraphics(graph, bounds.width, bounds.height); - - spriteRep.renderAnimation( animation, sprite.getViewState(), t ); - } - else - { - CanvasUtils.printLog( "JavaCanvas.renderAnimation sprite not active!" ); - } - } - - public synchronized void showSprite( SpriteBase sprite ) - { - CanvasUtils.printLog( "JavaCanvas.showSprite() called" ); - - SpriteRep spriteRep = (SpriteRep)activeSprites.get( sprite ); - if( spriteRep != null ) - { - CanvasUtils.printLog( "JavaCanvas.showSprite sprite already active!" ); - } - else - { - spriteRep = sprite.getSpriteRep(); - - // a valid SpriteRep for a given Sprite in the - // activeSprites hash denotes 'sprite active' - activeSprites.put( sprite, spriteRep ); - - // TODO: TEMP! Just for testing! Set empty cursor for presentation -// dummyFrame.frame.setCursor( dummyFrame.frame.getToolkit().createCustomCursor(new java.awt.image.BufferedImage(0,0, -// java.awt.image.BufferedImage.TYPE_INT_RGB), -// new java.awt.Point(0,0), -// "") ); - } - } - - public synchronized void hideSprite( SpriteBase sprite ) - { - CanvasUtils.printLog( "JavaCanvas.hideSprite() called" ); - - SpriteRep spriteRep = (SpriteRep)activeSprites.get( sprite ); - if( spriteRep != null ) - { - activeSprites.put( sprite, null ); - redrawAllLayers(); - } - else - { - CanvasUtils.printLog( "JavaCanvas.hideSprite sprite not active!" ); - } - } - - private void redrawAllLayers() - { - // fetch the Graphics object to draw into (we're doing double - // buffering here, the content is later shown via - // bufferStrategy.show(). - Graphics2D graph = null; - - try - { - graph = (Graphics2D)bufferStrategy.getDrawGraphics(); - - GraphicsDevice device = graph.getDeviceConfiguration().getDevice(); - CanvasUtils.printLog( "Available vram: " + device.getAvailableAcceleratedMemory() ); - - // repaint background - backBuffer.redraw( graph ); - - // repaint all active sprites - java.util.Set entries = activeSprites.entrySet(); - java.util.Iterator iter = entries.iterator(); - while( iter.hasNext() ) - { - java.util.Map.Entry entry = (java.util.Map.Entry)iter.next(); - if( entry.getValue() != null ) - ((SpriteRep)entry.getValue()).redraw(graph); - } - - long currTime = System.currentTimeMillis(); - graph.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER) ); - graph.setFont( fpsFont ); - graph.setColor( java.awt.Color.black ); - - try - { - String fps = new String( String.valueOf(1000.0/(currTime-lastTime)) ); - graph.drawString( fps.substring(0,5) + " fps", 0, 20); - CanvasUtils.printLog( fps.substring(0,5) + " fps" ); - } - catch( Exception e ) - { - graph.drawString( "0 fps", 0, 20); - } - - lastTime = currTime; - } - catch( Exception e ) - { - CanvasUtils.printLog( "Exception thrown in redrawAllLayers" ); - } - finally - { - if( graph != null ) - graph.dispose(); - } - - bufferStrategy.show(); - } - - //---------------------------------------------------------------------------------- - - private static final String s_implName = "XCanvas.java.impl"; - private static final String s_serviceName = "com.sun.star.rendering.JavaCanvas"; - - //---------------------------------------------------------------------------------- - - // - // XServiceInfo impl - // ================= - // - public synchronized String getImplementationName() - { - return s_implName; - } - - public synchronized String [] getSupportedServiceNames() - { - return new String [] { s_serviceName }; - } - - public synchronized boolean supportsService( String serviceName ) - { - return serviceName.equals( s_serviceName ); - } - - public static com.sun.star.lang.XSingleServiceFactory __getServiceFactory( - String implName, - com.sun.star.lang.XMultiServiceFactory multiFactory, - com.sun.star.registry.XRegistryKey regKey ) - { - if (implName.equals( s_implName )) - { - return com.sun.star.comp.loader.FactoryHelper.getServiceFactory( - JavaCanvas.class, s_serviceName, multiFactory, regKey ); - } - return null; - } - - public static boolean __writeRegistryServiceInfo( - com.sun.star.registry.XRegistryKey regKey ) - { - return com.sun.star.comp.loader.FactoryHelper.writeRegistryServiceInfo( - s_implName, s_serviceName, regKey ); - } -} diff --git a/canvas/source/java/LinePolyPolygon.java b/canvas/source/java/LinePolyPolygon.java deleted file mode 100644 index 4c67f387a8de..000000000000 --- a/canvas/source/java/LinePolyPolygon.java +++ /dev/null @@ -1,195 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: LinePolyPolygon.java,v $ - * $Revision: 1.7 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// Canvas -import com.sun.star.rendering.*; -import com.sun.star.geometry.*; - -public class LinePolyPolygon - extends com.sun.star.lib.uno.helper.ComponentBase - implements com.sun.star.lang.XServiceInfo, - com.sun.star.rendering.XLinePolyPolygon2D -{ - private java.awt.geom.GeneralPath path; - - //---------------------------------------------------------------------------------- - - public LinePolyPolygon( RealPoint2D[][] points ) - { - setPoints( points, 0 ); - } - - public java.awt.geom.GeneralPath getJavaPath() - { - return path; - } - - //---------------------------------------------------------------------------------- - - // - // XPolyPolygon implementation - // =========================== - // - public synchronized void addPolyPolygon( RealPoint2D position, XPolyPolygon2D polyPolygon ) - { - } - - public synchronized int getNumberOfPolygons( ) - { - return 0; - } - - public synchronized int getNumberOfPolygonPoints( int polygon ) - { - return 0; - } - - public synchronized FillRule getFillRule( ) - { - if( path.getWindingRule() == java.awt.geom.GeneralPath.WIND_EVEN_ODD ) - return FillRule.EVEN_ODD; - else - return FillRule.NON_ZERO; - } - - public synchronized void setFillRule( FillRule fillRule ) - { - if( fillRule == FillRule.EVEN_ODD ) - path.setWindingRule( java.awt.geom.GeneralPath.WIND_EVEN_ODD ); - else - path.setWindingRule( java.awt.geom.GeneralPath.WIND_NON_ZERO ); - } - - public synchronized boolean isClosed( int index ) - { - // TODO - return false; - } - - public synchronized void setClosed( int index, boolean closedState ) - { - // TODO - } - - //---------------------------------------------------------------------------------- - - // - // XLinePolyPolygon implementation - // =============================== - // - public synchronized RealPoint2D[][] getPoints( int nPolygonIndex, int nNumberOfPolygons, int nPointIndex, int nNumberOfPoints ) - { - // TODO: Implement subsetting - -// double [] points = new double[6]; - -// // BAH! Use util.Vector here! - -// // find number of subpaths -// PathIterator aIter = path.getPathIterator( new AffineTransform() ); -// int nNumSubPaths = 0; -// while( !aIter.isDone() ) -// { -// if( aIter.currentSegment(points) == SEG_MOVETO ) -// ++nNumSubPaths; - -// aIter.next(); -// } - -// Point2D [][] aRes = new Point2D[nNumSubPaths][]; -// aIter = path.getPathIterator( new AffineTransform() ); -// while( !aIter.isDone() ) -// { -// switch( aIter.currentSegment(points) ) -// { -// case SEG_MOVETO: -// break; - -// case SEG_LINETO: -// break; - -// case SEG_CLOSE: -// break; - -// default: -// CanvasUtils.printLog( "LinePolyPolygon.getPoints(): unexpected path type" ); -// break; -// } - -// aIter.next(); -// } -// double [] points = new double[6]; - - return null; - } - - public synchronized void setPoints( RealPoint2D[][] points, int nPolygonIndex ) - { - if( nPolygonIndex != 0 ) - CanvasUtils.printLog( "LinePolyPolygon.setPoints: subset not yet implemented!" ); - - path = CanvasUtils.makeGenPathFromLinePoints( points ); - } - - public synchronized RealPoint2D getPoint( int nPolygonIndex, int nPointIndex ) - { - return null; - } - - public synchronized void setPoint( RealPoint2D point, int nPolygonIndex, int nPointIndex ) - { - CanvasUtils.printLog( "LinePolyPolygon.setPoint: not yet implemented!" ); - } - - //---------------------------------------------------------------------------------- - - // - // XServiceInfo impl - // ================= - // - - private static final String s_implName = "XLinePolyPolygon2D.java.impl"; - private static final String s_serviceName = "com.sun.star.rendering.LinePolyPolygon2D"; - - public String getImplementationName() - { - return s_implName; - } - - public String [] getSupportedServiceNames() - { - return new String [] { s_serviceName }; - } - - public boolean supportsService( String serviceName ) - { - return serviceName.equals( s_serviceName ); - } -} diff --git a/canvas/source/java/SpriteBase.java b/canvas/source/java/SpriteBase.java deleted file mode 100644 index d275275454c4..000000000000 --- a/canvas/source/java/SpriteBase.java +++ /dev/null @@ -1,37 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: SpriteBase.java,v $ - * $Revision: 1.6 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// Canvas - -public interface SpriteBase -{ - // to be overridden - public SpriteRep getSpriteRep(); -} diff --git a/canvas/source/java/SpriteRep.java b/canvas/source/java/SpriteRep.java deleted file mode 100644 index 62755dd01ec0..000000000000 --- a/canvas/source/java/SpriteRep.java +++ /dev/null @@ -1,178 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: SpriteRep.java,v $ - * $Revision: 1.7 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// Canvas -import com.sun.star.rendering.*; - -// Java AWT -import java.awt.*; -import java.awt.geom.*; - -public class SpriteRep -{ - private java.awt.image.BufferedImage buffer; - private CanvasBitmap canvasBitmap; - private double alpha; - private java.awt.geom.Point2D.Double outputPosition; - private boolean bufferOwned; - - //---------------------------------------------------------------------------------- - - // TODO: Everything in this class - // TODO: Implement lifetime control for buffer object, which is shared between SpriteReps - public SpriteRep() - { - CanvasUtils.printLog( "SpriteRep constructor called!" ); - - alpha = 0.0; - outputPosition = new java.awt.geom.Point2D.Double(0.0,0.0); - bufferOwned = true; // the buffer member is our own, and has to be disposed - } - - public SpriteRep( SpriteRep original ) - { - CanvasUtils.printLog( "SpriteRep clone constructor called!" ); - - alpha = 0.0; - outputPosition = new java.awt.geom.Point2D.Double(0.0,0.0); - cloneBuffer( original ); - bufferOwned = false; // the buffer member is not our own, and must not be disposed - } - - //---------------------------------------------------------------------------------- - - public synchronized void renderAnimation( XAnimation animation, ViewState viewState, double t ) - { - if( canvasBitmap != null ) - { - // clear buffer with all transparent - Graphics2D bitmapGraphics = canvasBitmap.getGraphics(); - - // before that, setup _everything_ we might have changed in CanvasUtils.setupGraphicsState - bitmapGraphics.setColor( new Color( 0.0f, 0.0f, 0.0f, 1.0f ) ); - bitmapGraphics.setComposite( - java.awt.AlphaComposite.getInstance(java.awt.AlphaComposite.CLEAR)); - bitmapGraphics.setTransform( new AffineTransform() ); - bitmapGraphics.setClip( new java.awt.Rectangle(0,0,buffer.getWidth(),buffer.getHeight()) ); - bitmapGraphics.fillRect(0,0,buffer.getWidth(),buffer.getHeight()); - - try - { - // now push the animation at time instance t into the - // virginal graphics - animation.render(canvasBitmap, viewState, t); - } - catch( com.sun.star.lang.IllegalArgumentException e ) - { - CanvasUtils.printLog( "Cannot create EmbeddedFrame within VCL window hierarchy!" ); - } - } - } - - public synchronized void setSpriteAlpha( double _alpha ) - { - CanvasUtils.printLog("SpriteRep.setSpriteAlpha called with alpha=" + alpha); - alpha = _alpha; - } - - public synchronized void moveSprite( java.awt.geom.Point2D.Double aNewPos ) - { - outputPosition = aNewPos; - CanvasUtils.printLog( "SpriteRep.moveSprite: moving to (" + outputPosition.x + ", " + outputPosition.y + ")" ); - } - - public synchronized void redraw( Graphics2D output ) - { - if( buffer != null ) - { - CanvasUtils.printLog( "SpriteRep.redraw: compositing with alpha=" + alpha ); - output.setComposite( java.awt.AlphaComposite.getInstance(java.awt.AlphaComposite.SRC_OVER, (float)alpha) ); - - output.drawImage( buffer, - (int)(outputPosition.getX() + .5), - (int)(outputPosition.getY() + .5), - null ); - - //CanvasUtils.postRenderImageTreatment( buffer ); - - CanvasUtils.printLog( "SpriteRep.redraw called, output rect is (" + - outputPosition.getX() + ", " + - outputPosition.getY() + ", " + - buffer.getWidth() + ", " + - buffer.getHeight() + ")" ); - } - } - - public synchronized void setupBuffer( java.awt.Graphics2D graphics, int width, int height ) - { - if( canvasBitmap != null ) - canvasBitmap.dispose(); - - if( buffer != null ) - buffer.flush(); - - buffer = graphics.getDeviceConfiguration().createCompatibleImage(Math.max(1,width), - Math.max(1,height), - Transparency.TRANSLUCENT); - canvasBitmap = new CanvasBitmap( buffer ); - CanvasUtils.initGraphics( canvasBitmap.getGraphics() ); - - CanvasUtils.printLog( "SpriteRep.setupBuffer called, with dimensions (" + width + ", " + height + ")" ); - } - - public synchronized void cloneBuffer( SpriteRep original ) - { - buffer = original.buffer; - } - - public synchronized com.sun.star.rendering.XCanvas getContentCanvas() - { - CanvasUtils.printLog( "SpriteRep.getContentCanvas() called" ); - - Graphics2D graphics = canvasBitmap.getGraphics(); - graphics.setTransform( new AffineTransform() ); - graphics.setComposite( AlphaComposite.getInstance(AlphaComposite.CLEAR)); - graphics.fillRect( 0,0,buffer.getWidth(),buffer.getHeight() ); - - return canvasBitmap; - } - - public void dispose() - { - if( canvasBitmap != null ) - canvasBitmap.dispose(); - - if( buffer != null && bufferOwned ) - buffer.flush(); - - canvasBitmap = null; - buffer = null; - } -} diff --git a/canvas/source/java/SpriteRunner.java b/canvas/source/java/SpriteRunner.java deleted file mode 100644 index 4a75125e377a..000000000000 --- a/canvas/source/java/SpriteRunner.java +++ /dev/null @@ -1,203 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: SpriteRunner.java,v $ - * $Revision: 1.7 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// Canvas -import com.sun.star.rendering.*; - -// -// HOWTO get a Graphics2D from a window -// - -// import javax.swing.*; -// import java.awt.*; -// import java.awt.geom.*; - -// public class Stroke1 extends JFrame { -// Stroke drawingStroke = new BasicStroke(5); -// Rectangle2D rect = -// new Rectangle2D.Double(20, 40, 100, 40); - -// public void paint(Graphics g) { -// Graphics2D g2d = (Graphics2D)g; -// g2d.setStroke(drawingStroke); -// g2d.draw(rect); -// } - -// public static void main(String args[]) { -// JFrame frame = new Stroke1(); -// frame.setDefaultCloseOperation(EXIT_ON_CLOSE); -// frame.setSize(200, 100); -// frame.show(); -// } -// } - - -public class SpriteRunner - extends Thread -{ - private CanvasSprite sprite; - private XAnimation spriteAnimation; - private JavaCanvas canvas; - private double startTime; - private double currentSpeed; - private double currentT; - private boolean animationActive; - private boolean stayAlive; - - //---------------------------------------------------------------------------------- - - public SpriteRunner( CanvasSprite _sprite, XAnimation _animation, JavaCanvas _canvas ) - { - CanvasUtils.printLog( "SpriteRunner constructor called!" ); - - sprite = _sprite; - spriteAnimation = _animation; - canvas = _canvas; - startTime = 0.0; - currentSpeed = 0.0; - currentT = 0.0; - animationActive = false; - stayAlive = true; - - // Set priority to lower-than-normal, as this thread runs the - // animation in a busy loop. - setPriority( MIN_PRIORITY ); - } - - //---------------------------------------------------------------------------------- - - // - // Thread - // ====== - // - // Overriding - // - public void run() - { - // perform the animation rendering (as fast as possible, for now) - - while( stayAlive ) - { - while( animationActive ) - { - // to determine the current animation step to render, calc the - // elapsed time since this animation was started - double elapsedTime = getCurrentTime() - startTime; - - // the frame to render is determined by mapping the cycle - // duration (currentSpeed) to the [0,1] range of the animation. - currentT = (elapsedTime % currentSpeed) / currentSpeed; - - // delegate animation rendering to SpriteCanvas, as - // only this instance can enforce consistency (on-time - // saving of background etc.) - canvas.renderAnimation( sprite, spriteAnimation, currentT ); - - // TODO: Consolidate _all_ sprites per canvas into one - // thread, call updateScreen() only after all sprites - // have been processed. - - //Make changes visible - canvas.updateScreen( false ); - - // TODO: Evaluate vs. setPriority and other means -// try -// { -// // give other tasks some time to breathe (10ms - this is only meant symbolically) -// sleep(10); -// } catch( InterruptedException e ) { } - } - - // wait until animation is activated again - try - { - wait(); - } - catch( InterruptedException e ) { } - catch( IllegalMonitorStateException e ) { } - } - } - - public synchronized void startAnimation( double speed ) - { - resetAnimation(); - currentSpeed = speed; - - // start us, if not done already - if( !isAlive() ) - start(); - - // enable animation thread - animationActive = true; - - try - { - notify(); - } catch( IllegalMonitorStateException e ) { } - } - - public synchronized void stopAnimation() - { - // stop animation after the current frame has been completely - // rendered - animationActive = false; - } - - public synchronized void resetAnimation() - { - startTime = getCurrentTime(); - } - - public synchronized boolean isAnimationActive() - { - return animationActive; - } - - public synchronized void quit() - { - stayAlive = false; - stopAnimation(); - } - - public synchronized double getCurrentT() - { - return currentT; - } - - //---------------------------------------------------------------------------------- - - // helper - static double getCurrentTime() - { - // determine current time in seconds - java.util.Calendar cal = new java.util.GregorianCalendar(); - return cal.getTimeInMillis() / 1000.0; - } -} diff --git a/canvas/source/java/TextLayout.java b/canvas/source/java/TextLayout.java deleted file mode 100644 index 5495fa7e90be..000000000000 --- a/canvas/source/java/TextLayout.java +++ /dev/null @@ -1,208 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: TextLayout.java,v $ - * $Revision: 1.6 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// Canvas -import com.sun.star.rendering.*; - -public class TextLayout - extends com.sun.star.lib.uno.helper.ComponentBase - implements com.sun.star.lang.XServiceInfo, - com.sun.star.rendering.XTextLayout -{ - private double[] advancements; - private StringContext text; - private byte direction; - private CanvasBase associatedCanvas; - private CanvasFont font; - - //---------------------------------------------------------------------------------- - - public TextLayout( StringContext aText, - byte nDirection, - long nRandomSeed, - CanvasFont _font, - CanvasBase _canvas ) - { - text = aText; - direction = nDirection; - associatedCanvas = _canvas; - font = _font; - } - - // - // XTextLayout implementation - // ========================== - // - - public XPolyPolygon2D[] queryTextShapes( ) - { - // TODO - return null; - } - - public com.sun.star.geometry.RealRectangle2D[] queryInkMeasures( ) - { - // TODO - return null; - } - - public com.sun.star.geometry.RealRectangle2D[] queryMeasures( ) - { - // TODO - return null; - } - - public double[] queryLogicalAdvancements( ) - { - // TODO - return null; - } - - public void applyLogicalAdvancements( double[] aAdvancements ) throws com.sun.star.lang.IllegalArgumentException - { - if( aAdvancements.length != text.Length ) - throw new com.sun.star.lang.IllegalArgumentException(); - - advancements = aAdvancements; - } - - public com.sun.star.geometry.RealRectangle2D queryTextBounds( ) - { - // TODO - return null; - } - - public double justify( double nSize ) throws com.sun.star.lang.IllegalArgumentException - { - // TODO - return 0; - } - - public double combinedJustify( XTextLayout[] aNextLayouts, double nSize ) throws com.sun.star.lang.IllegalArgumentException - { - // TODO - return 0; - } - - public TextHit getTextHit( /*IN*/com.sun.star.geometry.RealPoint2D aHitPoint ) - { - // TODO - return null; - } - - public Caret getCaret( int nInsertionIndex, boolean bExcludeLigatures ) throws com.sun.star.lang.IndexOutOfBoundsException - { - // TODO - return null; - } - - public int getNextInsertionIndex( int nStartIndex, int nCaretAdvancement, boolean bExcludeLigatures ) throws com.sun.star.lang.IndexOutOfBoundsException - { - // TODO - return 0; - } - - public XPolyPolygon2D queryVisualHighlighting( int nStartIndex, int nEndIndex ) throws com.sun.star.lang.IndexOutOfBoundsException - { - // TODO - return null; - } - - public XPolyPolygon2D queryLogicalHighlighting( int nStartIndex, int nEndIndex ) throws com.sun.star.lang.IndexOutOfBoundsException - { - // TODO - return null; - } - - public double getBaselineOffset( ) - { - // TODO - return 0.0; - } - - public byte getMainTextDirection( ) - { - return direction; - } - - public XCanvasFont getFont( ) - { - return font; - } - - public StringContext getText( ) - { - return text; - } - - public boolean draw( java.awt.Graphics2D graphics ) - { - // TODO: use proper advancement. Text direction need not be horizontal! - // TODO: given text string need not have a one-to-one relationship between code point and glyph (offset)! - graphics.drawString( text.Text.substring(text.StartPosition, text.StartPosition + 1), (float)0.0, (float)0.0 ); - for( int i=1; i<advancements.length && i<text.Length; ++i ) - { - CanvasUtils.printLog( "XCanvas: drawOffsettedText rendering a \"" + - text.Text.substring(text.StartPosition + i, - text.StartPosition + i + 1) + - "\" (position " + (text.StartPosition + i) + - " of " + text.Text + ", offset " + advancements[i] + ")" ); - - graphics.drawString( text.Text.substring(text.StartPosition + i, text.StartPosition + i + 1), (float)advancements[i-1], (float)0.0 ); - } - - return true; - } - - //---------------------------------------------------------------------------------- - - // - // XServiceInfo impl - // ================= - // - - private static final String s_implName = "CanvasFont.java.impl"; - private static final String s_serviceName = "com.sun.star.rendering.XCanvasFont"; - - public String getImplementationName() - { - return s_implName; - } - - public String [] getSupportedServiceNames() - { - return new String [] { s_serviceName }; - } - - public boolean supportsService( String serviceName ) - { - return serviceName.equals( s_serviceName ); - } -} diff --git a/canvas/source/java/aqua/WindowAdapter.java b/canvas/source/java/aqua/WindowAdapter.java deleted file mode 100644 index 781e12269f73..000000000000 --- a/canvas/source/java/aqua/WindowAdapter.java +++ /dev/null @@ -1,205 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: WindowAdapter.java,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// UNO -import com.sun.star.uno.UnoRuntime; -import com.sun.star.uno.XComponentContext; -import com.sun.star.uno.AnyConverter; -import com.sun.star.lang.XInitialization; -import com.sun.star.lib.uno.helper.WeakBase; - -// OOo AWT -import com.sun.star.awt.*; - -// system-dependent stuff -import sun.awt.*; - -//Apple specifics -import apple.awt.*; - - -public class WindowAdapter -// defacto implementing the interface, but not deriving from it, since -// we're no real XInterface here -// implements com.sun.star.awt.XWindow -{ - public java.awt.Frame frame; - private boolean fullscreen; - - public WindowAdapter( int windowHandle, - boolean _fullscreen ) - { - fullscreen = false; - - if( _fullscreen ) - { - // create a normal Java frame, and set it into fullscreen mode - frame = new javax.swing.JFrame( "Presentation" ); - frame.setUndecorated( true ); - frame.setVisible( true ); - - java.awt.Graphics2D graphics = (java.awt.Graphics2D)frame.getGraphics(); - if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() ) - { - CanvasUtils.printLog( "WindowAdapter(Aqua): entering fullscreen mode" ); - graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( frame ); - fullscreen = true; - } - else - { - CanvasUtils.printLog( "WindowAdapter(Aqua): fullscreen not supported" ); - } - - graphics.dispose(); - } - else - { - // we're initialized with the operating system window handle - // as the parameter. We then generate a dummy Java frame with - // that window as the parent, to fake a root window for the - // Java implementation. - - // now, we're getting slightly system dependent here. - String os = (String) System.getProperty("os.name"); - - // create the embedded frame - if( os.startsWith("Mac OS X") ) - frame = new apple.awt.CEmbeddedFrame( windowHandle ); - else - throw new com.sun.star.uno.RuntimeException(); - - -// frame = new javax.swing.JFrame( "Test window" ); - -// // resize it according to the given bounds -// frame.setBounds( boundRect ); -// frame.setVisible( true ); - } - } - - //---------------------------------------------------------------------------------- - - public void dispose() - { - if( fullscreen ) - { - java.awt.Graphics2D graphics = (java.awt.Graphics2D)frame.getGraphics(); - if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() ) - { - CanvasUtils.printLog( "WindowAdapter(Aqua): leaving fullscreen mode" ); - graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( null ); - } - graphics.dispose(); - } - - if( frame != null ) - frame.dispose(); - } - - //---------------------------------------------------------------------------------- - - // - // XWindow interface - // ================= - // - public void setPosSize( int X, int Y, int Width, int Height, short Flags ) - { - frame.setBounds( new java.awt.Rectangle( X, Y, Width, Height ) ); - } - - public com.sun.star.awt.Rectangle getPosSize( ) - { - java.awt.Rectangle bounds = frame.getBounds(); - - return new com.sun.star.awt.Rectangle( bounds.x, bounds.y, bounds.width, bounds.height ); - } - - public void setVisible( boolean visible ) - { - frame.setVisible( visible ); - } - - public void setEnable( boolean enable ) - { - frame.setEnabled( enable ); - } - - public void setFocus() - { - } - - public void addWindowListener( XWindowListener xListener ) - { - } - - public void removeWindowListener( XWindowListener xListener ) - { - } - - public void addFocusListener( XFocusListener xListener ) - { - } - - public void removeFocusListener( XFocusListener xListener ) - { - } - - public void addKeyListener( XKeyListener xListener ) - { - } - - public void removeKeyListener( XKeyListener xListener ) - { - } - - public void addMouseListener( XMouseListener xListener ) - { - } - - public void removeMouseListener( XMouseListener xListener ) - { - } - - public void addMouseMotionListener( XMouseMotionListener xListener ) - { - } - - public void removeMouseMotionListener( XMouseMotionListener xListener ) - { - } - - public void addPaintListener( XPaintListener xListener ) - { - } - - public void removePaintListener( XPaintListener xListener ) - { - } -} diff --git a/canvas/source/java/java_Service.java b/canvas/source/java/java_Service.java deleted file mode 100644 index 6fcaa1581ca8..000000000000 --- a/canvas/source/java/java_Service.java +++ /dev/null @@ -1,118 +0,0 @@ - -import com.sun.star.uno.UnoRuntime; -import com.sun.star.uno.XComponentContext; -import com.sun.star.awt.*; - -public class java_Service - extends com.sun.star.lib.uno.helper.WeakBase - implements com.sun.star.lang.XServiceInfo, foo.XBar -{ - private XToolkit m_xToolkit; - private XVclWindowPeer m_xPeer; - private javax.swing.JFrame m_frame; - - public java_Service( XComponentContext xContext ) - { - try - { - m_xToolkit = - (XToolkit) UnoRuntime.queryInterface( - XToolkit.class, - xContext.getServiceManager().createInstanceWithContext( - "com.sun.star.awt.Toolkit", xContext ) ); - } - catch (com.sun.star.uno.Exception exc) - { - throw new com.sun.star.uno.RuntimeException( - "exception occured gettin toolkit: " + exc, this ); - } - } - - // XBar impl - public void raiseAndCloseWindows( foo.XBar [] seq ) - throws com.sun.star.uno.Exception - { - for ( int nPos = 0; nPos < seq.length; ++nPos ) - seq[ nPos ].raiseWindows( "called by Java code" ); - - // modal dialog before closing - javax.swing.JOptionPane.showMessageDialog( - null, "[Java] all windows created." ); - - for ( int nPos = 0; nPos < seq.length; ++nPos ) - seq[ nPos ].closeWindows(); - } - - public void raiseWindows( String msg ) - throws com.sun.star.uno.Exception - { - // create java frame - m_frame = new javax.swing.JFrame( - "[java frame created by Java code] " + msg ); - m_frame.setSize( 500, 50 ); - m_frame.setLocation( 200, 500 ); - m_frame.setVisible( true ); - - // create office workwindow - m_xPeer = (XVclWindowPeer) UnoRuntime.queryInterface( - XVclWindowPeer.class, - m_xToolkit.createWindow( - new WindowDescriptor( - WindowClass.TOP, "workwindow", null, (short) -1, - new Rectangle( 800, 500, 500, 50 ), - WindowAttribute.SHOW | - WindowAttribute.BORDER | - WindowAttribute.SIZEABLE | - WindowAttribute.MOVEABLE | - WindowAttribute.CLOSEABLE ) ) ); - m_xPeer.setProperty( - "Title", "[office window created by Java code] " + msg ); - } - - public void closeWindows() - throws com.sun.star.uno.Exception - { - m_frame.dispose(); - m_xPeer.dispose(); - } - - - private static final String s_implName = "foo.java.impl"; - private static final String s_serviceName = "foo.java"; - - // XServiceInfo impl - public String getImplementationName() - { - return s_implName; - } - - public String [] getSupportedServiceNames() - { - return new String [] { s_serviceName }; - } - - public boolean supportsService( String serviceName ) - { - return serviceName.equals( s_serviceName ); - } - - public static com.sun.star.lang.XSingleServiceFactory __getServiceFactory( - String implName, - com.sun.star.lang.XMultiServiceFactory multiFactory, - com.sun.star.registry.XRegistryKey regKey ) - { - if (implName.equals( s_implName )) - { - return com.sun.star.comp.loader.FactoryHelper.getServiceFactory( - java_Service.class, s_serviceName, multiFactory, regKey ); - } - return null; - } - - public static boolean __writeRegistryServiceInfo( - com.sun.star.registry.XRegistryKey regKey ) - { - return com.sun.star.comp.loader.FactoryHelper.writeRegistryServiceInfo( - s_implName, s_serviceName, regKey ); - } -} diff --git a/canvas/source/java/makefile.mk b/canvas/source/java/makefile.mk deleted file mode 100644 index 9a06b3939c64..000000000000 --- a/canvas/source/java/makefile.mk +++ /dev/null @@ -1,97 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2008 by Sun Microsystems, Inc. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# $RCSfile: makefile.mk,v $ -# -# $Revision: 1.11 $ -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -# Builds the Java Canvas implementation. - -PRJNAME = canvas -PRJ = ..$/.. -TARGET = javacanvas -PACKAGE = canvas - -USE_JAVAVER:=TRUE - -# --- Settings ----------------------------------------------------- - -.INCLUDE: settings.mk - -.IF "$(SOLAR_JAVA)"=="TRUE" -# Since Canvas needs newer features like -# e.g. java.awt.image.BufferStrategy, -# disabled for now for everything <1.4 -.IF "$(JAVANUMVER:s/.//)" >= "000100040000" - -JAVAFILES = \ - SpriteBase.java \ - JavaCanvas.java \ - CanvasGraphicDevice.java \ - CanvasUtils.java \ - CanvasFont.java \ - CanvasBitmap.java \ - CanvasSprite.java \ - CanvasCustomSprite.java \ - CanvasClonedSprite.java \ - TextLayout.java \ - BackBuffer.java \ - LinePolyPolygon.java \ - BezierPolyPolygon.java \ - SpriteRunner.java - -.IF "$(GUIBASE)"=="unx" - -JAVAFILES += x11/WindowAdapter.java - -.ELIF "$(GUIBASE)"=="aqua" - -JAVAFILES += aqua/WindowAdapter.java - -.ELSE - -JAVAFILES += win/WindowAdapter.java - -.ENDIF # "$(GUIBASE)"=="unx" - -JARFILES = jurt.jar unoil.jar ridl.jar juh.jar java_uno.jar -#JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) - -JARTARGET = $(TARGET).uno.jar -JARCOMPRESS = TRUE -#JARCLASSDIRS = $(PACKAGE) -CUSTOMMANIFESTFILE = manifest - -.ENDIF # "$(JAVANUMVER:s/.//)" >= "000100040000" -.ENDIF # "$(SOLAR_JAVA)"=="TRUE" - -# --- Targets ------------------------------------------------------ - -.INCLUDE: target.mk - -#dist: $(JAVA_FILES:b:+".class") -# +jar -cvfm $(CLASSDIR)/JavaCanvas.jar $(JARMANIFEST) $(JAVACLASSFILES) diff --git a/canvas/source/java/manifest b/canvas/source/java/manifest deleted file mode 100644 index 6ddc3ab0ae51..000000000000 --- a/canvas/source/java/manifest +++ /dev/null @@ -1 +0,0 @@ -RegistrationClassName: JavaCanvas diff --git a/canvas/source/java/perftest/PerfTest.java b/canvas/source/java/perftest/PerfTest.java deleted file mode 100644 index 0534ce3dad0b..000000000000 --- a/canvas/source/java/perftest/PerfTest.java +++ /dev/null @@ -1,317 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: PerfTest.java,v $ - * $Revision: 1.4 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -import java.awt.*; -import java.awt.image.*; -import java.awt.geom.*; - - -public class PerfTest -{ - // the frame object we're generating. TODO: Remove public access. - private Frame frame; - private boolean fullscreen; - - public PerfTest() - { - fullscreen = false; - - // create a normal Java frame, and set it into fullscreen mode - frame = new javax.swing.JFrame( "PerformanceTest" ); - frame.setBounds( new Rectangle(0,0,1600,1200) ); - frame.setUndecorated( true ); - frame.setVisible( true ); - - Graphics2D graphics = (Graphics2D)frame.getGraphics(); - if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() ) - { - System.err.println( "entering fullscreen mode" ); - graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( frame ); - fullscreen = true; - } - else - { - System.err.println( "fullscreen not supported" ); - } - - graphics.dispose(); - } - - //---------------------------------------------------------------------------------- - - public void dispose() - { - if( fullscreen ) - { - Graphics2D graphics = (Graphics2D)frame.getGraphics(); - if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() ) - { - System.err.println( "leaving fullscreen mode" ); - graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( null ); - } - graphics.dispose(); - } - - if( frame != null ) - frame.dispose(); - } - - //---------------------------------------------------------------------------------- - - public static void initGraphics( Graphics2D graphics ) - { - if( graphics != null ) - { - RenderingHints hints = new RenderingHints(null); - boolean hq = true; - - if( hq ) - { - hints.add( new RenderingHints( RenderingHints.KEY_FRACTIONALMETRICS, - RenderingHints.VALUE_FRACTIONALMETRICS_ON ) ); -// hints.add( new RenderingHints( RenderingHints.KEY_ALPHA_INTERPOLATION, -// RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY) ); - hints.add( new RenderingHints( RenderingHints.KEY_ALPHA_INTERPOLATION, - RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED) ); -// hints.add( new RenderingHints( RenderingHints.KEY_INTERPOLATION, -// RenderingHints.VALUE_INTERPOLATION_BICUBIC) ); - hints.add( new RenderingHints( RenderingHints.KEY_INTERPOLATION, - RenderingHints.VALUE_INTERPOLATION_BILINEAR) ); -// hints.add( new RenderingHints( RenderingHints.KEY_RENDERING, -// RenderingHints.VALUE_RENDER_QUALITY) ); - hints.add( new RenderingHints( RenderingHints.KEY_RENDERING, - RenderingHints.VALUE_RENDER_SPEED) ); -// hints.add( new RenderingHints( RenderingHints.KEY_STROKE_CONTROL, -// RenderingHints.VALUE_STROKE_NORMALIZE) ); - hints.add( new RenderingHints( RenderingHints.KEY_STROKE_CONTROL, - RenderingHints.VALUE_STROKE_DEFAULT) ); - hints.add( new RenderingHints( RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON) ); - } - else - { - hints.add( new RenderingHints( RenderingHints.KEY_ALPHA_INTERPOLATION, - RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED) ); - hints.add( new RenderingHints( RenderingHints.KEY_INTERPOLATION, - RenderingHints.VALUE_INTERPOLATION_BILINEAR) ); - hints.add( new RenderingHints( RenderingHints.KEY_RENDERING, - RenderingHints.VALUE_RENDER_SPEED) ); - hints.add( new RenderingHints( RenderingHints.KEY_STROKE_CONTROL, - RenderingHints.VALUE_STROKE_DEFAULT) ); - hints.add( new RenderingHints( RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_OFF) ); - } - - // the least common denominator standard - hints.add( new RenderingHints( RenderingHints.KEY_FRACTIONALMETRICS, - RenderingHints.VALUE_FRACTIONALMETRICS_ON) ); - hints.add( new RenderingHints( RenderingHints.KEY_TEXT_ANTIALIASING, - RenderingHints.VALUE_TEXT_ANTIALIAS_ON) ); - - graphics.setRenderingHints( hints ); - } - } - - public void run() - { - frame.createBufferStrategy(2); - BufferStrategy bufferStrategy = frame.getBufferStrategy(); - - if( bufferStrategy.getCapabilities().isPageFlipping() ) - System.err.println( "double buffering is using page flipping" ); - else - System.err.println( "double buffering is using blitting" ); - - int width = 1600; - int height = 1200; - Graphics2D graphics = (Graphics2D)frame.getGraphics(); - VolatileImage backBuffer = graphics.getDeviceConfiguration().createCompatibleVolatileImage(width,height); // TODO: size dynamic - BufferedImage buffer = graphics.getDeviceConfiguration().createCompatibleImage(width,height, - Transparency.TRANSLUCENT); - BufferedImage buffer2 = graphics.getDeviceConfiguration().createCompatibleImage(width,height, - Transparency.TRANSLUCENT); - BufferedImage buffer3 = graphics.getDeviceConfiguration().createCompatibleImage(width,height, - Transparency.TRANSLUCENT); - - GraphicsDevice device = graphics.getDeviceConfiguration().getDevice(); - System.err.println( "Images generated. Available vram: " + device.getAvailableAcceleratedMemory() ); - - Graphics2D bufferGraphics = (Graphics2D)buffer.getGraphics(); - Graphics2D buffer2Graphics = (Graphics2D)buffer2.getGraphics(); - Graphics2D buffer3Graphics = (Graphics2D)buffer3.getGraphics(); - Graphics2D backBufGraphics = (Graphics2D)backBuffer.getGraphics(); - - System.err.println( "Image graphics generated. Available vram: " + device.getAvailableAcceleratedMemory() ); - - // init Graphics - initGraphics( graphics ); - initGraphics( bufferGraphics ); - initGraphics( buffer2Graphics ); - initGraphics( backBufGraphics ); - - // init content - Font font = new Font( "Times", Font.PLAIN, 100 ); - Font fpsFont = new Font( "Times", Font.PLAIN, 20 ); - - bufferGraphics.setComposite( AlphaComposite.getInstance(AlphaComposite.CLEAR)); - bufferGraphics.fillRect( 0,0,width,height ); - - bufferGraphics.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER)); - bufferGraphics.setColor( Color.red ); - bufferGraphics.fillRect( 0,0,width/2,height/2 ); - bufferGraphics.setColor( Color.green ); - bufferGraphics.fillRect( width/2,0,width,height/2 ); - bufferGraphics.setColor( Color.blue ); - bufferGraphics.fillRect( 0,height/2,width/2,height ); - - buffer2Graphics.setColor( Color.red ); - buffer2Graphics.fillRect( 0,0,width/2,height/2 ); - buffer2Graphics.setColor( Color.green ); - buffer2Graphics.fillRect( width/2,0,width,height/2 ); - buffer2Graphics.setColor( Color.blue ); - buffer2Graphics.fillRect( 0,height/2,width/2,height ); - - buffer3Graphics.setColor( Color.blue ); - buffer3Graphics.fillRect( 0,0,width/2,height/2 ); - buffer3Graphics.setColor( Color.white ); - buffer3Graphics.fillRect( width/2,0,width,height/2 ); - buffer3Graphics.setColor( Color.gray ); - buffer3Graphics.fillRect( 0,height/2,width/2,height ); - - backBufGraphics.setColor( Color.white ); - backBufGraphics.fillRect(0,0,width,height); - backBufGraphics.setColor( Color.red ); - backBufGraphics.setFont( font ); - int i, turns=15; - for(i=0; i<turns; ++i) - { - backBufGraphics.drawString( "Crossfade test", width*i/turns, height*i/turns ); - } - - System.err.println( "Images filled with content. Available vram: " + device.getAvailableAcceleratedMemory() ); - - long lastTime = System.currentTimeMillis(); - int turn, numTurns = 100; - for(turn=0; turn<numTurns; ++turn) - { - // fetch the Graphics object to draw into (we're doing double - // buffering here, the content is later shown via - // bufferStrategy.show(). - Graphics2D graph = null; - - try - { - graph = (Graphics2D)bufferStrategy.getDrawGraphics(); - - try - { - // repaint background - graph.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER) ); - graph.drawImage(backBuffer, 0, 0, null); - - // alpha-composite foreground on top of that - float alpha = turn/(float)numTurns; - graph.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha) ); - - graph.drawImage(buffer, 0, 0, null); - buffer.flush(); - graph.drawImage(buffer2, 100, 100, null); - buffer2.flush(); - - long currTime = System.currentTimeMillis(); - graph.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER) ); - graph.setFont( fpsFont ); - graph.setColor( Color.black ); - String fps = new String( String.valueOf(1000.0/(currTime-lastTime)) ); - System.err.println( "Images composited. Framerate: " + fps + " fps" ); - graph.drawString( fps.substring(0,5) + " fps", 0, 20); - lastTime = currTime; - - System.err.println( "Available vram: " + device.getAvailableAcceleratedMemory() ); - } - catch( Exception e ) - { - } - - System.err.println( "Turn: " + turn ); - } - finally - { - if( graph != null ) - graph.dispose(); - } - - bufferStrategy.show(); - } - - try - { - Thread.sleep(2000); - } - catch( Exception e ) - { - } - } - - //---------------------------------------------------------------------------------- - - public static void main(String[] args) - { - // now, we're getting slightly system dependent here. - String os = (String) System.getProperty("os.name"); - - System.err.println( "System detected: " + os ); - - // tweak some speed knobs... - if( os.startsWith("Windows") ) - { - System.setProperty("sun.java2d.translaccel", "true"); - System.setProperty("sun.java2d.ddforcevram", "true"); - //System.setProperty("sun.java2d.accthreshold", "0"); - - System.err.println( "Optimizing for Windows" ); - } - else - { - System.setProperty("sun.java2d.opengl", "true"); - - System.err.println( "Optimizing for Unix" ); - } - - PerfTest test = new PerfTest(); - - test.run(); - - test.dispose(); - } - - //---------------------------------------------------------------------------------- - -} diff --git a/canvas/source/java/perftest/WindowAdapter.java b/canvas/source/java/perftest/WindowAdapter.java deleted file mode 100644 index 982bbd92d04b..000000000000 --- a/canvas/source/java/perftest/WindowAdapter.java +++ /dev/null @@ -1,200 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: WindowAdapter.java,v $ - * $Revision: 1.4 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -import sun.awt.*; -import com.sun.star.awt.*; - - -public class WindowAdapter -// defacto implementing the interface, but not deriving from it, since -// we're no real XInterface here -// implements com.sun.star.awt.XWindow -{ - // the frame object we're generating. TODO: Remove public access. - public java.awt.Frame frame; - private boolean fullscreen; - - public WindowAdapter( int windowHandle, - boolean _fullscreen ) - { - CanvasUtils.printLog( "WindowAdapter(X11): constructor called" ); - fullscreen = false; - - if( _fullscreen ) - { - // create a normal Java frame, and set it into fullscreen mode - frame = new javax.swing.JFrame( "Presentation" ); - frame.setUndecorated( true ); - frame.setVisible( true ); - - java.awt.Graphics2D graphics = (java.awt.Graphics2D)frame.getGraphics(); - if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() ) - { - CanvasUtils.printLog( "WindowAdapter(X11): entering fullscreen mode" ); - graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( frame ); - fullscreen = true; - } - else - { - CanvasUtils.printLog( "WindowAdapter(X11): fullscreen not supported" ); - } - - graphics.dispose(); - } - else - { - // we're initialized with the operating system window handle - // as the parameter. We then generate a dummy Java frame with - // that window as the parent, to fake a root window for the - // Java implementation. - - // now, we're getting slightly system dependent here. - String os = (String) System.getProperty("os.name"); - - System.err.println("WindowAdapter created"); - - // create the embedded frame - if( os.startsWith("Linux") ) - { - // create a java frame from that - // TODO: Maybe that's the reason why we crash on Linux 1.5beta - // immediately: Try XAWT here, or naked X: sun.awt.X11.XEmbeddedFrame - - //frame = new sun.awt.motif.MEmbeddedFrame( windowHandle ); - //frame = new sun.awt.X11.XEmbeddedFrame( windowHandle ); // cannot currently compile - CanvasUtils.printLog( "WindowAdapter(X11): no frame created for now" ); - frame = null; - } - else - { - throw new com.sun.star.uno.RuntimeException(); - } - } - } - - //---------------------------------------------------------------------------------- - - public void dispose() - { - if( fullscreen ) - { - java.awt.Graphics2D graphics = (java.awt.Graphics2D)frame.getGraphics(); - if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() ) - { - CanvasUtils.printLog( "WindowAdapter(X11): leaving fullscreen mode" ); - graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( null ); - } - graphics.dispose(); - } - - if( frame != null ) - frame.dispose(); - } - - //---------------------------------------------------------------------------------- - - // - // XWindow interface - // ================= - // - public void setPosSize( int X, int Y, int Width, int Height, short Flags ) - { - frame.setBounds( new java.awt.Rectangle( X, Y, Width, Height ) ); - } - - public com.sun.star.awt.Rectangle getPosSize( ) - { - java.awt.Rectangle bounds = frame.getBounds(); - - return new com.sun.star.awt.Rectangle( bounds.x, bounds.y, bounds.width, bounds.height ); - } - - public void setVisible( boolean visible ) - { - frame.setVisible( visible ); - } - - public void setEnable( boolean enable ) - { - frame.setEnabled( enable ); - } - - public void setFocus() - { - } - - public void addWindowListener( XWindowListener xListener ) - { - } - - public void removeWindowListener( XWindowListener xListener ) - { - } - - public void addFocusListener( XFocusListener xListener ) - { - } - - public void removeFocusListener( XFocusListener xListener ) - { - } - - public void addKeyListener( XKeyListener xListener ) - { - } - - public void removeKeyListener( XKeyListener xListener ) - { - } - - public void addMouseListener( XMouseListener xListener ) - { - } - - public void removeMouseListener( XMouseListener xListener ) - { - } - - public void addMouseMotionListener( XMouseMotionListener xListener ) - { - } - - public void removeMouseMotionListener( XMouseMotionListener xListener ) - { - } - - public void addPaintListener( XPaintListener xListener ) - { - } - - public void removePaintListener( XPaintListener xListener ) - { - } -} diff --git a/canvas/source/java/perftest/makefile.mk b/canvas/source/java/perftest/makefile.mk deleted file mode 100644 index 3049887d5a06..000000000000 --- a/canvas/source/java/perftest/makefile.mk +++ /dev/null @@ -1,59 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2008 by Sun Microsystems, Inc. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# $RCSfile: makefile.mk,v $ -# -# $Revision: 1.6 $ -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -# Builds the Java Canvas implementation. - -PRJNAME = canvas -PRJ = ../../.. -TARGET = PerfTest -PACKAGE = test - -# --- Settings ----------------------------------------------------- - -.INCLUDE: settings.mk - -JAVAFILES = \ - PerfTest.java - -JARFILES = jurt.jar unoil.jar ridl.jar juh.jar java_uno.jar -JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) - -JARTARGET = $(TARGET).jar -JARCOMPRESS = TRUE -#JARCLASSDIRS = $(PACKAGE) -CUSTOMMANIFESTFILE = manifest - -# --- Targets ------------------------------------------------------ - -.INCLUDE: target.mk - -#dist: $(JAVA_FILES:b:+".class") -# +jar -cvfm $(CLASSDIR)/PerfTest.jar $(JARMANIFEST) $(JAVACLASSFILES) diff --git a/canvas/source/java/perftest/manifest b/canvas/source/java/perftest/manifest deleted file mode 100644 index 805a87d47b57..000000000000 --- a/canvas/source/java/perftest/manifest +++ /dev/null @@ -1 +0,0 @@ -RegistrationClassName: PerfTest diff --git a/canvas/source/java/win/WindowAdapter.java b/canvas/source/java/win/WindowAdapter.java deleted file mode 100644 index fe3a83b17e67..000000000000 --- a/canvas/source/java/win/WindowAdapter.java +++ /dev/null @@ -1,202 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: WindowAdapter.java,v $ - * $Revision: 1.4 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// UNO -import com.sun.star.uno.UnoRuntime; -import com.sun.star.uno.XComponentContext; -import com.sun.star.uno.AnyConverter; -import com.sun.star.lang.XInitialization; -import com.sun.star.lib.uno.helper.WeakBase; - -// OOo AWT -import com.sun.star.awt.*; - -// system-dependent stuff -import sun.awt.*; - - -public class WindowAdapter -// defacto implementing the interface, but not deriving from it, since -// we're no real XInterface here -// implements com.sun.star.awt.XWindow -{ - public java.awt.Frame frame; - private boolean fullscreen; - - public WindowAdapter( int windowHandle, - boolean _fullscreen ) - { - fullscreen = false; - - if( _fullscreen ) - { - // create a normal Java frame, and set it into fullscreen mode - frame = new javax.swing.JFrame( "Presentation" ); - frame.setUndecorated( true ); - frame.setVisible( true ); - - java.awt.Graphics2D graphics = (java.awt.Graphics2D)frame.getGraphics(); - if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() ) - { - CanvasUtils.printLog( "WindowAdapter(Win32): entering fullscreen mode" ); - graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( frame ); - fullscreen = true; - } - else - { - CanvasUtils.printLog( "WindowAdapter(Win32): fullscreen not supported" ); - } - - graphics.dispose(); - } - else - { - // we're initialized with the operating system window handle - // as the parameter. We then generate a dummy Java frame with - // that window as the parent, to fake a root window for the - // Java implementation. - - // now, we're getting slightly system dependent here. - String os = (String) System.getProperty("os.name"); - - // create the embedded frame - if( os.startsWith("Windows") ) - frame = new sun.awt.windows.WEmbeddedFrame( windowHandle ); - else - throw new com.sun.star.uno.RuntimeException(); - - -// frame = new javax.swing.JFrame( "Test window" ); - -// // resize it according to the given bounds -// frame.setBounds( boundRect ); -// frame.setVisible( true ); - } - } - - //---------------------------------------------------------------------------------- - - public void dispose() - { - if( fullscreen ) - { - java.awt.Graphics2D graphics = (java.awt.Graphics2D)frame.getGraphics(); - if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() ) - { - CanvasUtils.printLog( "WindowAdapter(Win32): leaving fullscreen mode" ); - graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( null ); - } - graphics.dispose(); - } - - if( frame != null ) - frame.dispose(); - } - - //---------------------------------------------------------------------------------- - - // - // XWindow interface - // ================= - // - public void setPosSize( int X, int Y, int Width, int Height, short Flags ) - { - frame.setBounds( new java.awt.Rectangle( X, Y, Width, Height ) ); - } - - public com.sun.star.awt.Rectangle getPosSize( ) - { - java.awt.Rectangle bounds = frame.getBounds(); - - return new com.sun.star.awt.Rectangle( bounds.x, bounds.y, bounds.width, bounds.height ); - } - - public void setVisible( boolean visible ) - { - frame.setVisible( visible ); - } - - public void setEnable( boolean enable ) - { - frame.setEnabled( enable ); - } - - public void setFocus() - { - } - - public void addWindowListener( XWindowListener xListener ) - { - } - - public void removeWindowListener( XWindowListener xListener ) - { - } - - public void addFocusListener( XFocusListener xListener ) - { - } - - public void removeFocusListener( XFocusListener xListener ) - { - } - - public void addKeyListener( XKeyListener xListener ) - { - } - - public void removeKeyListener( XKeyListener xListener ) - { - } - - public void addMouseListener( XMouseListener xListener ) - { - } - - public void removeMouseListener( XMouseListener xListener ) - { - } - - public void addMouseMotionListener( XMouseMotionListener xListener ) - { - } - - public void removeMouseMotionListener( XMouseMotionListener xListener ) - { - } - - public void addPaintListener( XPaintListener xListener ) - { - } - - public void removePaintListener( XPaintListener xListener ) - { - } -} diff --git a/canvas/source/java/x11/WindowAdapter.java b/canvas/source/java/x11/WindowAdapter.java deleted file mode 100644 index e45999eb50c0..000000000000 --- a/canvas/source/java/x11/WindowAdapter.java +++ /dev/null @@ -1,200 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: WindowAdapter.java,v $ - * $Revision: 1.5 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -import com.sun.star.awt.*; - - -public class WindowAdapter -// defacto implementing the interface, but not deriving from it, since -// we're no real XInterface here -// implements com.sun.star.awt.XWindow -{ - // the frame object we're generating. TODO: Remove public access. - public java.awt.Frame frame; - private boolean fullscreen; - - public WindowAdapter( int windowHandle, - boolean _fullscreen ) - { - CanvasUtils.printLog( "WindowAdapter(X11): constructor called" ); - fullscreen = false; - - if( _fullscreen ) - { - // create a normal Java frame, and set it into fullscreen mode - frame = new javax.swing.JFrame( "Presentation" ); - frame.setUndecorated( true ); - frame.setVisible( true ); - - java.awt.Graphics2D graphics = (java.awt.Graphics2D)frame.getGraphics(); - if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() ) - { - CanvasUtils.printLog( "WindowAdapter(X11): entering fullscreen mode" ); - graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( frame ); - fullscreen = true; - } - else - { - CanvasUtils.printLog( "WindowAdapter(X11): fullscreen not supported" ); - } - - graphics.dispose(); - } - else - { - // we're initialized with the operating system window handle - // as the parameter. We then generate a dummy Java frame with - // that window as the parent, to fake a root window for the - // Java implementation. - - // now, we're getting slightly system dependent here. - String os = (String) System.getProperty("os.name"); - - System.err.println("WindowAdapter created"); - - // create the embedded frame - if( os.startsWith("Linux") ) - { - // create a java frame from that - // TODO: Maybe that's the reason why we crash on Linux 1.5beta - // immediately: Try XAWT here, or naked X: sun.awt.X11.XEmbeddedFrame - - // TODO - //frame = new sun.awt.motif.MEmbeddedFrame( windowHandle ); // Crashes 1.5, because class is unknown - //frame = new sun.awt.X11.XEmbeddedFrame( windowHandle ); // cannot currently compile, because class is not in 1.4. - CanvasUtils.printLog( "WindowAdapter(X11): no frame created for now" ); - frame = null; // disabled for now - } - else - { - throw new com.sun.star.uno.RuntimeException(); - } - } - } - - //---------------------------------------------------------------------------------- - - public void dispose() - { - if( fullscreen ) - { - java.awt.Graphics2D graphics = (java.awt.Graphics2D)frame.getGraphics(); - if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() ) - { - CanvasUtils.printLog( "WindowAdapter(X11): leaving fullscreen mode" ); - graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( null ); - } - graphics.dispose(); - } - - if( frame != null ) - frame.dispose(); - } - - //---------------------------------------------------------------------------------- - - // - // XWindow interface - // ================= - // - public void setPosSize( int X, int Y, int Width, int Height, short Flags ) - { - frame.setBounds( new java.awt.Rectangle( X, Y, Width, Height ) ); - } - - public com.sun.star.awt.Rectangle getPosSize( ) - { - java.awt.Rectangle bounds = frame.getBounds(); - - return new com.sun.star.awt.Rectangle( bounds.x, bounds.y, bounds.width, bounds.height ); - } - - public void setVisible( boolean visible ) - { - frame.setVisible( visible ); - } - - public void setEnable( boolean enable ) - { - frame.setEnabled( enable ); - } - - public void setFocus() - { - } - - public void addWindowListener( XWindowListener xListener ) - { - } - - public void removeWindowListener( XWindowListener xListener ) - { - } - - public void addFocusListener( XFocusListener xListener ) - { - } - - public void removeFocusListener( XFocusListener xListener ) - { - } - - public void addKeyListener( XKeyListener xListener ) - { - } - - public void removeKeyListener( XKeyListener xListener ) - { - } - - public void addMouseListener( XMouseListener xListener ) - { - } - - public void removeMouseListener( XMouseListener xListener ) - { - } - - public void addMouseMotionListener( XMouseMotionListener xListener ) - { - } - - public void removeMouseMotionListener( XMouseMotionListener xListener ) - { - } - - public void addPaintListener( XPaintListener xListener ) - { - } - - public void removePaintListener( XPaintListener xListener ) - { - } -} |