Statistics
| Revision:

root / branches / Mobile_Compatible_Hito_1 / libProjectionCresques / src / org / gvsig / projection / cresques / px / PxRect.java @ 21932

History | View | Annotate | Download (3.24 KB)

1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.gvsig.projection.cresques.px;
25

    
26
import java.awt.Color;
27
import java.awt.Graphics2D;
28
import java.awt.geom.AffineTransform;
29

    
30
import org.gvsig.projection.geo.ViewPortData;
31
import org.gvsig.projection.px.Extent;
32
import org.gvsig.projection.px.PxObj;
33

    
34

    
35
public class PxRect extends PxObj implements IPoint, ISize, Colored {
36
    private int px = 0;
37
    private int py = 0;
38
    private int pw = 0;
39
    private int ph = 0;
40
    private Color pc;
41
    private Color filColor = null;
42

    
43
    public PxRect(IPoint p, ISize s, Color color, Color fc) {
44
        x(p.x());
45
        y(p.y());
46
        w(s.w());
47
        h(s.h());
48
        c(color);
49
        fillColor(fc);
50
        extent = new Extent(x(), y(), x() + w(), y() + h());
51
    }
52

    
53
    public PxRect(int x, int y, int w, int h, Color color, Color fc) {
54
        x(x);
55
        y(y);
56
        w(w);
57
        h(h);
58
        c(color);
59
        fillColor(fc);
60
        extent = new Extent(x(), y(), x() + w(), y() + h());
61
    }
62

    
63
    public int x() {
64
        return px;
65
    }
66

    
67
    public int x(int x) {
68
        px = x;
69

    
70
        return px;
71
    }
72

    
73
    public int y() {
74
        return py;
75
    }
76

    
77
    public int y(int y) {
78
        py = y;
79

    
80
        return py;
81
    }
82

    
83
    public int w() {
84
        return pw;
85
    }
86

    
87
    public int w(int w) {
88
        pw = w;
89

    
90
        return pw;
91
    }
92

    
93
    public int h() {
94
        return ph;
95
    }
96

    
97
    public int h(int h) {
98
        ph = h;
99

    
100
        return ph;
101
    }
102

    
103
    public Color c() {
104
        return pc;
105
    }
106

    
107
    public Color c(Color color) {
108
        pc = color;
109

    
110
        return pc;
111
    }
112

    
113
    public Color fillColor() {
114
        return filColor;
115
    }
116

    
117
    public Color fillColor(Color c) {
118
        filColor = c;
119

    
120
        return filColor;
121
    }
122

    
123
    /*        public void draw(Graphics2D g) {
124
                    draw(g, g.getTransform(), null);
125
            }
126

127
            public void draw(Graphics2D g, AffineTransform mat, Extent sz) {
128
    */
129
    public void draw(Graphics2D g, ViewPortData vp) {
130
        AffineTransform msave = g.getTransform();
131
        g.setTransform(vp.mat);
132

    
133
        if (fillColor() != null) {
134
            g.setColor(fillColor());
135
            g.fillRect(x(), y(), w(), h());
136
        }
137

    
138
        g.setColor(c());
139
        g.drawRect(x(), y(), w(), h());
140
        g.setTransform(msave);
141
    }
142
}