private FGEArea computeHalfPlaneIntersection(FGEHalfPlane hp) { if (hp.containsArea(this)) { return this.clone(); } if (computeLineIntersection(hp.line) instanceof FGEEmptyArea) { return new FGEEmptyArea(); } else { if (logger.isLoggable(Level.FINE)) { logger.fine("computeHalfPlaneIntersection() for rectangle when halfplane cross rectangle"); } FGEArea a = computeLineIntersection(hp.line); Vector<FGEPoint> pts = new Vector<FGEPoint>(); if (a instanceof FGEUnionArea && ((FGEUnionArea) a).isUnionOfPoints() && ((FGEUnionArea) a).getObjects().size() == 2) { pts.add((FGEPoint) ((FGEUnionArea) a).getObjects().firstElement()); pts.add((FGEPoint) ((FGEUnionArea) a).getObjects().elementAt(1)); } else if (a instanceof FGESegment) { pts.add(((FGESegment) a).getP1()); pts.add(((FGESegment) a).getP2()); } FGEPoint ne, nw, se, sw; ne = new FGEPoint(x + width, y); nw = new FGEPoint(x, y); se = new FGEPoint(x + width, y + height); sw = new FGEPoint(x, y + height); if (hp.containsPoint(ne) && !pts.contains(ne)) { pts.add(ne); } if (hp.containsPoint(nw) && !pts.contains(nw)) { pts.add(nw); } if (hp.containsPoint(se) && !pts.contains(se)) { pts.add(se); } if (hp.containsPoint(sw) && !pts.contains(sw)) { pts.add(sw); } if (getIsFilled()) { return FGEPolygon.makeArea(Filling.FILLED, pts); } else { return new FGEUnionArea(pts); } } }