Revision 2669 branches/CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/px/PxRect.java
PxRect.java | ||
---|---|---|
1 | 1 |
/* |
2 | 2 |
* Cresques Mapping Suite. Graphic Library for constructing mapping applications. |
3 |
* |
|
4 |
* Copyright (C) 2004-5. |
|
5 | 3 |
* |
4 |
* Copyright (C) 2004-5. |
|
5 |
* |
|
6 | 6 |
* This program is free software; you can redistribute it and/or |
7 | 7 |
* modify it under the terms of the GNU General Public License |
8 | 8 |
* as published by the Free Software Foundation; either version 2 |
... | ... | |
18 | 18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
19 | 19 |
* |
20 | 20 |
* For more information, contact: |
21 |
*
|
|
21 |
* |
|
22 | 22 |
* cresques@gmail.com |
23 | 23 |
*/ |
24 |
|
|
25 | 24 |
package org.cresques.px; |
26 | 25 |
|
26 |
import org.cresques.geo.ViewPortData; |
|
27 |
|
|
27 | 28 |
import java.awt.Color; |
28 | 29 |
import java.awt.Graphics2D; |
29 | 30 |
import java.awt.geom.AffineTransform; |
30 | 31 |
|
31 |
import org.cresques.geo.ViewPortData; |
|
32 | 32 |
|
33 |
|
|
34 | 33 |
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;} |
|
34 |
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; |
|
57 | 40 |
|
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;} |
|
41 |
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 |
} |
|
65 | 50 |
|
66 |
public Color fillColor() {return filColor;} |
|
67 |
public Color fillColor(Color c) {filColor = c; return filColor;} |
|
51 |
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 |
} |
|
68 | 60 |
|
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 |
*/ public void draw(Graphics2D g, ViewPortData vp) { |
|
75 |
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 |
} |
|
61 |
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 |
} |
Also available in: Unified diff