| package org.eclipse.nebula.widgets.nattable.core.geometry |
| |
| import java.math.BigDecimal |
| |
| class PixelRectangleInvariants { |
| |
| def static PixelRectangle intersect(PixelRectangle rect1, PixelRectangle rect2) { |
| val startX = rect1.x.max(rect2.x) |
| val startY = rect1.y.max(rect2.y) |
| val endX = rect1.x + rect1.width.min(rect2.x + rect2.width) |
| val endY = rect1.y + rect1.height.min(rect2.y + rect2.height) |
| new PixelRectangle(startX, startY, new BigDecimal(0).max(endX - startX), new BigDecimal(0).max(endY - startY)) |
| } |
| |
| def static boolean isEmpty(PixelRectangle rect) { |
| rect.width == 0 || rect.height == 0 |
| } |
| |
| } |