fun inverseTransform(viewPoint: java.awt.geom.Point2D): java.awt.geom.Point2D? { val viewCenter: java.awt.geom.Point2D = getViewCenter() val viewRadius: Double = getViewRadius() val ratio: Double = getRatio() var dx: Double = viewPoint.getX() - viewCenter.getX() val dy: Double = viewPoint.getY() - viewCenter.getY() dx *= ratio val pointFromCenter: java.awt.geom.Point2D = java.awt.geom.Point2D.Double(dx, dy) val polar: PolarPoint = PolarPoint.cartesianToPolar(pointFromCenter) var radius: Double = polar.getRadius() if (radius > viewRadius) return delegate.inverseTransform(viewPoint) radius /= viewRadius radius = Math.abs(Math.tan(radius)) radius /= Math.PI / 2 radius *= viewRadius val mag = Math.tan(Math.PI / 2 * magnification) radius /= mag polar.setRadius(radius) val projectedPoint: java.awt.geom.Point2D = PolarPoint.polarToCartesian(polar) projectedPoint.setLocation(projectedPoint.getX() / ratio, projectedPoint.getY()) val translatedBack: java.awt.geom.Point2D = java.awt.geom.Point2D.Double( projectedPoint.getX() + viewCenter.getX(), projectedPoint.getY() + viewCenter.getY() ) return delegate.inverseTransform(translatedBack) }
override base class to un-project the fisheye effect