svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.geometry / org.gvsig.fmap.geometry.impl / src / main / java / org / gvsig / fmap / geom / primitive / impl / GeneralPathAdapter.java @ 40559
History | View | Annotate | Download (3.55 KB)
1 | 40559 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40559 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | 40435 | jjdelcerro | *
|
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 | 40559 | jjdelcerro | * as published by the Free Software Foundation; either version 3
|
9 | 40435 | jjdelcerro | * 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 | 40559 | jjdelcerro | * For any additional information, do not hesitate to contact us
|
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | 40435 | jjdelcerro | */
|
24 | package org.gvsig.fmap.geom.primitive.impl; |
||
25 | |||
26 | import java.awt.Rectangle; |
||
27 | import java.awt.Shape; |
||
28 | import java.awt.geom.AffineTransform; |
||
29 | import java.awt.geom.FlatteningPathIterator; |
||
30 | import java.awt.geom.PathIterator; |
||
31 | import java.awt.geom.Point2D; |
||
32 | import java.awt.geom.Rectangle2D; |
||
33 | |||
34 | import org.gvsig.fmap.geom.primitive.GeneralPathX; |
||
35 | import org.gvsig.fmap.geom.primitive.GeneralPathXIterator; |
||
36 | import org.gvsig.fmap.geom.primitive.GeneralPathXIteratorSimple; |
||
37 | |||
38 | |||
39 | /**
|
||
40 | * @author gvSIG Team
|
||
41 | * @version $Id$
|
||
42 | * @deprecated
|
||
43 | */
|
||
44 | public class GeneralPathAdapter implements Shape { |
||
45 | private AffineTransform affineTransform; |
||
46 | private GeneralPathX generalPathX;
|
||
47 | |||
48 | public GeneralPathAdapter(AffineTransform affineTransform, |
||
49 | GeneralPathX generalPathX) { |
||
50 | super();
|
||
51 | this.affineTransform = affineTransform;
|
||
52 | this.generalPathX = generalPathX;
|
||
53 | } |
||
54 | |||
55 | public Rectangle getBounds() { |
||
56 | return generalPathX.getBounds();
|
||
57 | } |
||
58 | |||
59 | public Rectangle2D getBounds2D() { |
||
60 | return generalPathX.getBounds2D();
|
||
61 | } |
||
62 | |||
63 | public boolean contains(double x, double y) { |
||
64 | return generalPathX.contains(x, y);
|
||
65 | } |
||
66 | |||
67 | public boolean contains(Point2D p) { |
||
68 | return generalPathX.contains(p);
|
||
69 | } |
||
70 | |||
71 | public boolean intersects(double x, double y, double w, double h) { |
||
72 | return generalPathX.intersects(x, y, w, h);
|
||
73 | } |
||
74 | |||
75 | public boolean intersects(Rectangle2D r) { |
||
76 | return generalPathX.intersects(r);
|
||
77 | } |
||
78 | |||
79 | public boolean contains(double x, double y, double w, double h) { |
||
80 | return generalPathX.contains(x, y, w, h);
|
||
81 | } |
||
82 | |||
83 | public boolean contains(Rectangle2D r) { |
||
84 | return generalPathX.contains(r);
|
||
85 | } |
||
86 | |||
87 | public PathIterator getPathIterator(AffineTransform at) { |
||
88 | AffineTransform applicableTransform = null; |
||
89 | |||
90 | if (affineTransform != null){ |
||
91 | if (at != null && at.getType() != AffineTransform.TYPE_IDENTITY){ |
||
92 | applicableTransform = (AffineTransform)at.clone();
|
||
93 | applicableTransform.concatenate(affineTransform); |
||
94 | }else{
|
||
95 | applicableTransform = affineTransform; |
||
96 | } |
||
97 | }else{
|
||
98 | applicableTransform = at; |
||
99 | } |
||
100 | |||
101 | if (generalPathX.isSimple()){
|
||
102 | return new GeneralPathXIteratorSimple(generalPathX, applicableTransform); |
||
103 | }else{
|
||
104 | return new GeneralPathXIterator(generalPathX, applicableTransform); |
||
105 | } |
||
106 | } |
||
107 | |||
108 | public PathIterator getPathIterator(AffineTransform at, double flatness) { |
||
109 | return new FlatteningPathIterator(getPathIterator(at), flatness); |
||
110 | } |
||
111 | } |