package com.ilex.ims.wim.client; /** * The WIMCircle is the wim version of the OMCircle that will be able to rotate * based on the angle, in radians, passed in. * Creation date: (10/24/01 10:07:09 AM) * @author: Administrator */ import java.awt.*; import java.util.Vector; import java.io.Serializable; import com.bbn.openmap.LatLonPoint; import com.bbn.openmap.MoreMath; import com.bbn.openmap.util.Debug; import com.bbn.openmap.proj.*; public class WimCircle extends com.bbn.openmap.omGraphics.OMCircle { /** the angle by which the image is to be rotated, in radians */ protected double rotationAngle; // Render correct stuff for Cylindrical projections. not // accessible until we finalize the api... private boolean correctPolar = false; private boolean correctFill = false; private int[][] fill_xpoints = null; private int[][] fill_ypoints = null; /** * WimCircle constructor comment. */ public WimCircle() { super(); } /** * WimCircle constructor comment. * @param latPoint float * @param lonPoint float * @param radius float */ public WimCircle(float latPoint, float lonPoint, float radius) { super(latPoint, lonPoint, radius); } /** * WimCircle constructor comment. * @param latPoint float * @param lonPoint float * @param radius float * @param units com.bbn.openmap.proj.Length */ public WimCircle(float latPoint, float lonPoint, float radius, com.bbn.openmap.proj.Length units) { super(latPoint, lonPoint, radius, units); } /** * WimCircle constructor comment. * @param latPoint float * @param lonPoint float * @param radius float * @param units com.bbn.openmap.proj.Length * @param nverts int */ public WimCircle(float latPoint, float lonPoint, float radius, com.bbn.openmap.proj.Length units, int nverts) { super(latPoint, lonPoint, radius, units, nverts); } /** * WimCircle constructor comment. * @param latPoint float * @param lonPoint float * @param w int * @param h int */ public WimCircle(float latPoint, float lonPoint, int w, int h) { super(latPoint, lonPoint, w, h); } /** * WimCircle constructor comment. * @param latPoint float * @param lonPoint float * @param offset_x1 int * @param offset_y1 int * @param w int * @param h int */ public WimCircle(float latPoint, float lonPoint, int offset_x1, int offset_y1, int w, int h) { super(latPoint, lonPoint, offset_x1, offset_y1, w, h); } /** * WimCircle constructor comment. * @param x1 int * @param y1 int * @param w int * @param h int */ public WimCircle(int x1, int y1, int w, int h) { super(x1, y1, w, h); } /** * WimCircle constructor comment. * @param center com.bbn.openmap.LatLonPoint * @param radius float * @param units com.bbn.openmap.proj.Length * @param nverts int */ public WimCircle(com.bbn.openmap.LatLonPoint center, float radius, com.bbn.openmap.proj.Length units, int nverts) { super(center, radius, units, nverts); } /** * Create alternate x,y coordinate arrays for rendering graphics * the encompass a pole in the Cylindrical projection. */ private void doPolarFillCorrection(int[][] xpoints, int[][] ypoints, int j, int y1) { if (fill_xpoints == null) fill_xpoints = new int[xpoints.length][0]; if (fill_ypoints == null) fill_ypoints = new int[ypoints.length][0]; int len = xpoints[j].length; int[] alt_xpts = new int[len + 2]; int[] alt_ypts = new int[len + 2]; System.arraycopy(xpoints[j], 0, alt_xpts, 0, len); System.arraycopy(ypoints[j], 0, alt_ypts, 0, len); alt_xpts[len] = alt_xpts[len-1]; alt_xpts[len+1] = alt_xpts[0]; alt_ypts[len] = y1; alt_ypts[len+1] = alt_ypts[len]; fill_xpoints[j] = alt_xpts; fill_ypoints[j] = alt_ypts; } private int[] getfill_x(int i) { return fill_xpoints[i]; } private int[] getfill_y(int i) { return fill_ypoints[i]; } /** * Paint the circle. * * @param g Graphics context to render into */ public void render(Graphics g) { if (getNeedToRegenerate() || !isVisible()) return; // LatLon circle if (renderType == RENDERTYPE_LATLON) { // safety: grab local reference of projected points int[][] xpts = xpoints; int[][] ypts = ypoints; int len = xpts.length; setGraphicsForFill(g); for (int i = 0; i < len; i++) { // fill the polygon if (!isClear(getFillPaint())) { if (!correctFill) { g.fillPolygon(xpts[i], ypts[i], xpts[i].length); } else { int[] alt_xpts = getfill_x(i); int[] alt_ypts = getfill_y(i); g.fillPolygon(alt_xpts, alt_ypts, alt_xpts.length); } } // draw the polygon if (!isClear(getDisplayPaint())) { setGraphicsForEdge(g); // Projection library connects the circle for us. g.drawPolyline(xpts[i], ypts[i], xpts[i].length); } } } // draw XY circle or ellipse else { int x = x1 - width / 2; int y = y1 - height / 2; int h = height; int w = width; if (h == 0) h++; if (w == 0) w++; if (g instanceof Graphics2D && rotationAngle != DEFAULT_ROTATIONANGLE) { //rotate about the circle from the center point ((Graphics2D) g).rotate(rotationAngle, x, y); } // debugging printouts if (!isClear(getFillPaint())) { setGraphicsForFill(g); g.fillOval(x, y, w, h); } if (!isClear(getDisplayPaint())) { setGraphicsForEdge(g); g.drawOval(x, y, w, h); } } } public void setRotationAngle( double angle ) { rotationAngle = angle; } }