下面两端代码,你可以参考以下,使用类似Path这样的概念来进行鼠标落点判断。
private void updateSelection() {
Canvas c;
List l;
c = getLayer().getCanvas();
l = c.getGraphicsIntersecting(getBounds());
if (l.contains(this) == false) {
l.add(this);
}
c.setSelectedGraphics(l);
}
public boolean intersects(java.awt.Rectangle r1) {
Rectangle r2;
do
uble d3;
do
uble d4;
do
uble d5;
do
uble d6;
int i7;
int i8;
Shape s9;
if (intersects(r1)) {
if (isSelected()) {
return true;
}
updateOutlinesIfNecessary();
r2 = getShape().getBounds();
d3 = ((double) r1.x) - ((double) r2.x);
d4 = (((double) r1.y) - ((double) r2.y)) - ((double) ascent);
d5 = (double) r1.width;
d6 = (double) r1.height;
i7 = 0;
i8 = outlines.size();
while (i7 < i8) {
s9 = (java.awt.Shape) outlines.get(i7);
if ((s9 != null) &&
(s9.intersects(d3, d4, d5, d6))) {
return true;
}
d4 = d4 - ((double) ((ascent + descent) + leading));
i7++;
}
return false;
}
return false;
}