svn-gvsig-desktop / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / px / PxRect.java @ 2407
History | View | Annotate | Download (2.46 KB)
1 | 2249 | igbrotru | /*
|
---|---|---|---|
2 | 2312 | igbrotru | * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
|
3 | *
|
||
4 | * Copyright (C) 2004-5.
|
||
5 | 2249 | igbrotru | *
|
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 | 2312 | igbrotru | *
|
22 | * cresques@gmail.com
|
||
23 | 2249 | igbrotru | */
|
24 | |||
25 | 2 | luisw | package org.cresques.px; |
26 | |||
27 | import java.awt.Color; |
||
28 | import java.awt.Graphics2D; |
||
29 | import java.awt.geom.AffineTransform; |
||
30 | |||
31 | 91 | luisw | import org.cresques.geo.ViewPortData; |
32 | 2 | luisw | |
33 | |||
34 | public class PxRect extends PxObj implements IPoint, ISize, Colored { |
||
35 | private int px=0, py=0; |
||
36 | private int pw=0, ph=0; |
||
37 | private Color pc; |
||
38 | private Color filColor = null; |
||
39 | public PxRect(IPoint p, ISize s, Color color, Color fc) { |
||
40 | x(p.x()); y(p.y()); |
||
41 | w(s.w()); h(s.h()); |
||
42 | c(color); |
||
43 | fillColor(fc); |
||
44 | extent = new Extent(x(), y(), x()+w(), y()+h());
|
||
45 | } |
||
46 | public PxRect(int x, int y, int w, int h, Color color, Color fc) { |
||
47 | x(x); y(y); |
||
48 | w(w); h(h); |
||
49 | c(color); |
||
50 | fillColor(fc); |
||
51 | extent = new Extent(x(), y(), x()+w(), y()+h());
|
||
52 | } |
||
53 | public int x() {return px;} |
||
54 | public int x(int x) {px = x; return px;} |
||
55 | public int y() {return py;} |
||
56 | public int y(int y) {py = y; return py;} |
||
57 | |||
58 | public int w() {return pw;} |
||
59 | public int w(int w) {pw = w; return pw;} |
||
60 | public int h() {return ph;} |
||
61 | public int h(int h) {ph = h; return ph;} |
||
62 | |||
63 | public Color c() {return pc;} |
||
64 | public Color c(Color color) {pc = color; return pc;} |
||
65 | |||
66 | public Color fillColor() {return filColor;} |
||
67 | public Color fillColor(Color c) {filColor = c; return filColor;} |
||
68 | |||
69 | /* public void draw(Graphics2D g) {
|
||
70 | draw(g, g.getTransform(), null);
|
||
71 | }
|
||
72 | |||
73 | public void draw(Graphics2D g, AffineTransform mat, Extent sz) {
|
||
74 | 91 | luisw | */ public void draw(Graphics2D g, ViewPortData vp) { |
75 | 2 | luisw | AffineTransform msave=g.getTransform();
|
76 | g.setTransform(vp.mat); |
||
77 | if (fillColor() != null) { |
||
78 | g.setColor(fillColor()); |
||
79 | g.fillRect(x(), y(), w(), h()); |
||
80 | } |
||
81 | g.setColor(c()); |
||
82 | g.drawRect(x(), y(), w(), h()); |
||
83 | g.setTransform(msave); |
||
84 | } |
||
85 | } |