root / branches / v2_0_0_prep / libraries / libFMap_geometries / src / org / gvsig / fmap / geom / primitive / impl / GeneralPathAdapter.java @ 38597
History | View | Annotate | Download (3.5 KB)
1 | 35472 | jpiera | /* gvSIG. Geographic Information System of the Valencian Government
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2007-2008 Infrastructures and Transports Department
|
||
4 | * of the Valencian Government (CIT)
|
||
5 | *
|
||
6 | * This program is free software; you can redistribute it and/or
|
||
7 | * modify it under the terms of the GNU General Public License
|
||
8 | * as published by the Free Software Foundation; either version 2
|
||
9 | * of the License, or (at your option) any later version.
|
||
10 | *
|
||
11 | * This program is distributed in the hope that it will be useful,
|
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
14 | * GNU General Public License for more details.
|
||
15 | *
|
||
16 | * You should have received a copy of the GNU General Public License
|
||
17 | * along with this program; if not, write to the Free Software
|
||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||
19 | * MA 02110-1301, USA.
|
||
20 | *
|
||
21 | */
|
||
22 | package org.gvsig.fmap.geom.primitive.impl; |
||
23 | |||
24 | import java.awt.Rectangle; |
||
25 | import java.awt.Shape; |
||
26 | import java.awt.geom.AffineTransform; |
||
27 | import java.awt.geom.FlatteningPathIterator; |
||
28 | import java.awt.geom.PathIterator; |
||
29 | import java.awt.geom.Point2D; |
||
30 | import java.awt.geom.Rectangle2D; |
||
31 | |||
32 | import org.gvsig.fmap.geom.primitive.GeneralPathX; |
||
33 | import org.gvsig.fmap.geom.primitive.GeneralPathXIterator; |
||
34 | import org.gvsig.fmap.geom.primitive.GeneralPathXIteratorSimple; |
||
35 | |||
36 | |||
37 | /**
|
||
38 | * @author gvSIG Team
|
||
39 | * @version $Id$
|
||
40 | * @deprecated
|
||
41 | */
|
||
42 | public class GeneralPathAdapter implements Shape { |
||
43 | private AffineTransform affineTransform; |
||
44 | private GeneralPathX generalPathX;
|
||
45 | |||
46 | public GeneralPathAdapter(AffineTransform affineTransform, |
||
47 | GeneralPathX generalPathX) { |
||
48 | super();
|
||
49 | this.affineTransform = affineTransform;
|
||
50 | this.generalPathX = generalPathX;
|
||
51 | } |
||
52 | |||
53 | public Rectangle getBounds() { |
||
54 | return generalPathX.getBounds();
|
||
55 | } |
||
56 | |||
57 | public Rectangle2D getBounds2D() { |
||
58 | return generalPathX.getBounds2D();
|
||
59 | } |
||
60 | |||
61 | public boolean contains(double x, double y) { |
||
62 | return generalPathX.contains(x, y);
|
||
63 | } |
||
64 | |||
65 | public boolean contains(Point2D p) { |
||
66 | return generalPathX.contains(p);
|
||
67 | } |
||
68 | |||
69 | public boolean intersects(double x, double y, double w, double h) { |
||
70 | return generalPathX.intersects(x, y, w, h);
|
||
71 | } |
||
72 | |||
73 | public boolean intersects(Rectangle2D r) { |
||
74 | return generalPathX.intersects(r);
|
||
75 | } |
||
76 | |||
77 | public boolean contains(double x, double y, double w, double h) { |
||
78 | return generalPathX.contains(x, y, w, h);
|
||
79 | } |
||
80 | |||
81 | public boolean contains(Rectangle2D r) { |
||
82 | return generalPathX.contains(r);
|
||
83 | } |
||
84 | |||
85 | public PathIterator getPathIterator(AffineTransform at) { |
||
86 | 37201 | jpiera | AffineTransform applicableTransform = null; |
87 | 35472 | jpiera | |
88 | 37201 | jpiera | if (affineTransform != null){ |
89 | 38597 | cordinyana | if (at != null && at.getType() != AffineTransform.TYPE_IDENTITY){ |
90 | 37201 | jpiera | applicableTransform = (AffineTransform)at.clone();
|
91 | applicableTransform.concatenate(affineTransform); |
||
92 | }else{
|
||
93 | applicableTransform = affineTransform; |
||
94 | 35472 | jpiera | } |
95 | }else{
|
||
96 | applicableTransform = at; |
||
97 | } |
||
98 | |||
99 | if (generalPathX.isSimple()){
|
||
100 | return new GeneralPathXIteratorSimple(generalPathX, applicableTransform); |
||
101 | }else{
|
||
102 | return new GeneralPathXIterator(generalPathX, applicableTransform); |
||
103 | } |
||
104 | } |
||
105 | |||
106 | public PathIterator getPathIterator(AffineTransform at, double flatness) { |
||
107 | return new FlatteningPathIterator(getPathIterator(at), flatness); |
||
108 | } |
||
109 | } |