Statistics
| Revision:

root / branches / v061 / libraries / libCq CMS for java.old / src / org / cresques / px / PxRect.java @ 5047

History | View | Annotate | Download (3 KB)

1 2809 nacho
/*
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 2 luisw
package org.cresques.px;
25
26 2809 nacho
import org.cresques.geo.ViewPortData;
27
28 2 luisw
import java.awt.Color;
29
import java.awt.Graphics2D;
30
import java.awt.geom.AffineTransform;
31
32
33
public class PxRect extends PxObj implements IPoint, ISize, Colored {
34 2809 nacho
    private int px = 0;
35
    private int py = 0;
36
    private int pw = 0;
37
    private int ph = 0;
38
    private Color pc;
39
    private Color filColor = null;
40 2 luisw
41 2809 nacho
    public PxRect(IPoint p, ISize s, Color color, Color fc) {
42
        x(p.x());
43
        y(p.y());
44
        w(s.w());
45
        h(s.h());
46
        c(color);
47
        fillColor(fc);
48
        extent = new Extent(x(), y(), x() + w(), y() + h());
49
    }
50 2 luisw
51 2809 nacho
    public PxRect(int x, int y, int w, int h, Color color, Color fc) {
52
        x(x);
53
        y(y);
54
        w(w);
55
        h(h);
56
        c(color);
57
        fillColor(fc);
58
        extent = new Extent(x(), y(), x() + w(), y() + h());
59
    }
60 2 luisw
61 2809 nacho
    public int x() {
62
        return px;
63
    }
64
65
    public int x(int x) {
66
        px = x;
67
68
        return px;
69
    }
70
71
    public int y() {
72
        return py;
73
    }
74
75
    public int y(int y) {
76
        py = y;
77
78
        return py;
79
    }
80
81
    public int w() {
82
        return pw;
83
    }
84
85
    public int w(int w) {
86
        pw = w;
87
88
        return pw;
89
    }
90
91
    public int h() {
92
        return ph;
93
    }
94
95
    public int h(int h) {
96
        ph = h;
97
98
        return ph;
99
    }
100
101
    public Color c() {
102
        return pc;
103
    }
104
105
    public Color c(Color color) {
106
        pc = color;
107
108
        return pc;
109
    }
110
111
    public Color fillColor() {
112
        return filColor;
113
    }
114
115
    public Color fillColor(Color c) {
116
        filColor = c;
117
118
        return filColor;
119
    }
120
121
    /*        public void draw(Graphics2D g) {
122
                    draw(g, g.getTransform(), null);
123
            }
124

125
            public void draw(Graphics2D g, AffineTransform mat, Extent sz) {
126
    */
127
    public void draw(Graphics2D g, ViewPortData vp) {
128
        AffineTransform msave = g.getTransform();
129
        g.setTransform(vp.mat);
130
131
        if (fillColor() != null) {
132
            g.setColor(fillColor());
133
            g.fillRect(x(), y(), w(), h());
134
        }
135
136
        g.setColor(c());
137
        g.drawRect(x(), y(), w(), h());
138
        g.setTransform(msave);
139
    }
140
}