Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libDXF / src / org / gvsig / dxf / px / PxRect.java @ 29630

History | View | Annotate | Download (3.03 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.dxf.px;
25

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

    
30
import org.cresques.geo.ViewPortData;
31
import org.cresques.px.Extent;
32

    
33

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

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

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

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

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

    
69
        return px;
70
    }
71

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

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

    
79
        return py;
80
    }
81

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

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

    
89
        return pw;
90
    }
91

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

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

    
99
        return ph;
100
    }
101

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

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

    
109
        return pc;
110
    }
111

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

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

    
119
        return filColor;
120
    }
121

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

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

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

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