* Determines whether given {@link Section} is on this Shape's containing widget
*
* @return <code>true</code>, if section is on current shape
*/
public boolean isOnThisShape(Section section) {
Point startPoint = section.startPoint;
Point endPoint = section.endPoint;
int direction;
if (section.isHorizontal()) {
direction = Section.HORIZONTAL;
} else if (section.isVertical()) {
direction = Section.VERTICAL;
} else {
LOG.severe("isOnThisShape -> direction = -1");
direction = -1;
}
if (this.getParent() != null) {
int shapeLeft = this.getRelativeShapeLeft();
int shapeTop = this.getRelativeShapeTop();
int shapeRight = shapeLeft + this.getOffsetWidth();
int shapeBottom = shapeTop + this.getOffsetHeight();
if (direction == Section.HORIZONTAL) {
if (shapeTop <= startPoint.getTop() && shapeBottom >= startPoint.getTop()) {
if ((startPoint.getLeft() >= shapeLeft && startPoint.getLeft() <= shapeRight)
|| (endPoint.getLeft() >= shapeLeft && endPoint.getLeft() <= shapeRight)
|| (startPoint.getLeft() <= shapeLeft && endPoint.getLeft() >= shapeRight)
|| (startPoint.getLeft() >= shapeLeft && endPoint.getLeft() <= shapeRight)) {
return true;
}
}
} else if (direction == Section.VERTICAL) {
if (shapeLeft <= startPoint.getLeft() && shapeRight >= startPoint.getLeft()) {
if ((startPoint.getTop() >= shapeTop && startPoint.getTop() <= shapeBottom)
|| (endPoint.getTop() >= shapeTop && endPoint.getTop() <= shapeBottom)
|| (startPoint.getTop() <= shapeTop && endPoint.getTop() >= shapeBottom)
|| (startPoint.getTop() >= shapeTop && endPoint.getTop() <= shapeBottom)) {
return true;
}
}
}
}