fun generate(proj: Projection?): Boolean { setNeedToRegenerate(true) if (proj == null) { Debug.message("omgraphic", "OMRect: null projection in generate!") return false } when (renderType) { RENDERTYPE_XY -> setShape( createBoxShape( Math.min(x2, x1) as Int, Math.min(y2, y1) as Int, Math.abs(x2 - x1) as Int, Math.abs(y2 - y1) as Int ) ) RENDERTYPE_OFFSET -> { if (!proj.isPlotable(lat1, lon1)) { setNeedToRegenerate(true) return false } val p1: Point = proj.forward(lat1, lon1, Point()) as Point setShape( createBoxShape( Math.min(p1.x + x1, p1.x + x2) as Int, Math.min(p1.y + y1, p1.y + y2) as Int, Math.abs(x2 - x1) as Int, Math.abs(y2 - y1) as Int ) ) } RENDERTYPE_LATLON -> { val rects: ArrayList<FloatArray> rects = if (proj is GeoProj) { (proj as GeoProj).forwardRect( Double(lat1, lon1), Double(lat2, lon2), lineType, nsegs, !isClear(fillPaint) ) } else { proj.forwardRect( java.awt.geom.Point2D.Double(lon1, lat1), java.awt.geom.Point2D.Double(lon2, lat2) ) } val size: Int = rects.size() var projectedShape: java.awt.geom.GeneralPath? = null var i = 0 while (i < size) { val gp: java.awt.geom.GeneralPath = createShape(rects[i], rects[i + 1], true) projectedShape appendShapeEdge(projectedShape, gp, false) i += 2 } setShape(projectedShape) } RENDERTYPE_UNKNOWN -> { System.err.println("OMRect.generate(): invalid RenderType") return false } } setLabelLocation(getShape(), proj) setNeedToRegenerate(false) return true }
Prepare the rectangle for rendering .