1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: LinePolyPolygon.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 import com
.sun
.star
.rendering
.*;
33 import com
.sun
.star
.geometry
.*;
35 public class LinePolyPolygon
36 extends com
.sun
.star
.lib
.uno
.helper
.ComponentBase
37 implements com
.sun
.star
.lang
.XServiceInfo
,
38 com
.sun
.star
.rendering
.XLinePolyPolygon2D
40 private java
.awt
.geom
.GeneralPath path
;
42 //----------------------------------------------------------------------------------
44 public LinePolyPolygon( RealPoint2D
[][] points
)
46 setPoints( points
, 0 );
49 public java
.awt
.geom
.GeneralPath
getJavaPath()
54 //----------------------------------------------------------------------------------
57 // XPolyPolygon implementation
58 // ===========================
60 public synchronized void addPolyPolygon( RealPoint2D position
, XPolyPolygon2D polyPolygon
)
64 public synchronized int getNumberOfPolygons( )
69 public synchronized int getNumberOfPolygonPoints( int polygon
)
74 public synchronized FillRule
getFillRule( )
76 if( path
.getWindingRule() == java
.awt
.geom
.GeneralPath
.WIND_EVEN_ODD
)
77 return FillRule
.EVEN_ODD
;
79 return FillRule
.NON_ZERO
;
82 public synchronized void setFillRule( FillRule fillRule
)
84 if( fillRule
== FillRule
.EVEN_ODD
)
85 path
.setWindingRule( java
.awt
.geom
.GeneralPath
.WIND_EVEN_ODD
);
87 path
.setWindingRule( java
.awt
.geom
.GeneralPath
.WIND_NON_ZERO
);
90 public synchronized boolean isClosed( int index
)
96 public synchronized void setClosed( int index
, boolean closedState
)
101 //----------------------------------------------------------------------------------
104 // XLinePolyPolygon implementation
105 // ===============================
107 public synchronized RealPoint2D
[][] getPoints( int nPolygonIndex
, int nNumberOfPolygons
, int nPointIndex
, int nNumberOfPoints
)
109 // TODO: Implement subsetting
111 // double [] points = new double[6];
113 // // BAH! Use util.Vector here!
115 // // find number of subpaths
116 // PathIterator aIter = path.getPathIterator( new AffineTransform() );
117 // int nNumSubPaths = 0;
118 // while( !aIter.isDone() )
120 // if( aIter.currentSegment(points) == SEG_MOVETO )
126 // Point2D [][] aRes = new Point2D[nNumSubPaths][];
127 // aIter = path.getPathIterator( new AffineTransform() );
128 // while( !aIter.isDone() )
130 // switch( aIter.currentSegment(points) )
142 // CanvasUtils.printLog( "LinePolyPolygon.getPoints(): unexpected path type" );
148 // double [] points = new double[6];
153 public synchronized void setPoints( RealPoint2D
[][] points
, int nPolygonIndex
)
155 if( nPolygonIndex
!= 0 )
156 CanvasUtils
.printLog( "LinePolyPolygon.setPoints: subset not yet implemented!" );
158 path
= CanvasUtils
.makeGenPathFromLinePoints( points
);
161 public synchronized RealPoint2D
getPoint( int nPolygonIndex
, int nPointIndex
)
166 public synchronized void setPoint( RealPoint2D point
, int nPolygonIndex
, int nPointIndex
)
168 CanvasUtils
.printLog( "LinePolyPolygon.setPoint: not yet implemented!" );
171 //----------------------------------------------------------------------------------
178 private static final String s_implName
= "XLinePolyPolygon2D.java.impl";
179 private static final String s_serviceName
= "com.sun.star.rendering.LinePolyPolygon2D";
181 public String
getImplementationName()
186 public String
[] getSupportedServiceNames()
188 return new String
[] { s_serviceName
};
191 public boolean supportsService( String serviceName
)
193 return serviceName
.equals( s_serviceName
);