question: public int addPoint ( GrabPoint gp , int position ) { if ( gp == null ) { return - 1 ; } int x = gp . getX ( ) ; int y = gp . getY ( ) ; int renderType = poly . getRenderType ( ) ; Projection proj = getProjection ( ) ; if ( renderType == OMGraphic . RENDERTYPE_LATLON ) { Debug . message ( "eomg" , "EditableOMPoly: adding point to lat/lon poly" ) ; if ( proj != null ) { double [ ] ll = poly . getLatLonArray ( ) ; int actualPosition = ( position == Integer . MAX_VALUE ? ll . length : position * 2 ) ; LatLonPoint llpnt = proj . inverse ( x , y , new LatLonPoint . Double ( ) ) ; if ( Debug . debugging ( "eomp" ) ) { Debug . output ( "EditableOMPoly: adding point to lat/lon poly at " + x + ", " + y + ": " + llpnt + ", at the end of " ) ; for ( int j = 0 ; j < ll . length ; j += 2 ) { Debug . output ( ll [ j ] + ", " + ll [ j + 1 ] ) ; } } double [ ] newll = new double [ ll . length + 2 ] ; double newlat = llpnt . getRadLat ( ) ; double newlon = llpnt . getRadLon ( ) ; if ( actualPosition >= ll . length ) { if ( ll . length != 0 ) { System . arraycopy ( ll , 0 , newll , 0 , ll . length ) ; } newll [ ll . length ] = newlat ; newll [ ll . length + 1 ] = newlon ; position = ll . length / 2 ; } else if ( actualPosition <= 0 ) { System . arraycopy ( ll , 0 , newll , 2 , ll . length ) ; newll [ 0 ] = newlat ; newll [ 1 ] = newlon ; position = 0 ; } else { newll [ actualPosition ] = newlat ; newll [ actualPosition + 1 ] = newlon ; System . arraycopy ( ll , 0 , newll , 0 , actualPosition ) ; System . arraycopy ( ll , actualPosition , newll , actualPosition + 2 , ll . length - actualPosition ) ; } poly . setLocation ( newll , OMGraphic . RADIANS ) ; } } else if ( renderType == OMGraphic . RENDERTYPE_XY ) { Debug . message ( "eomg" , "EditableOMPoly: adding point to x/y poly" ) ; int currentLength = poly . xs . length ; int [ ] newxs = new int [ currentLength + 1 ] ; int [ ] newys = new int [ currentLength + 1 ] ; if ( position >= currentLength ) { System . arraycopy ( poly . xs , 0 , newxs , 0 , currentLength ) ; System . arraycopy ( poly . ys , 0 , newys , 0 , currentLength ) ; newxs [ currentLength ] = x ; newys [ currentLength ] = y ; position = currentLength ; } else if ( position <= 0 ) { System . arraycopy ( poly . xs , 0 , newxs , 1 , currentLength ) ; System . arraycopy ( poly . ys , 0 , newys , 1 , currentLength ) ; newxs [ 0 ] = x ; newys [ 0 ] = y ; position = 0 ; } else { newxs [ position ] = x ; newys [ position ] = y ; System . arraycopy ( poly . xs , 0 , newxs , 0 , position ) ; System . arraycopy ( poly . xs , position , newxs , position + 1 , currentLength - position ) ; System . arraycopy ( poly . ys , 0 , newys , 0 , position ) ; System . arraycopy ( poly . ys , position , newys , position + 1 , currentLength - position ) ; } poly . setLocation ( newxs , newys ) ; } else { Debug . message ( "eomg" , "EditableOMPoly: adding point to offset poly" ) ; int currentLength = poly . xs . length ; int [ ] newxs = new int [ currentLength + 1 ] ; int [ ] newys = new int [ currentLength + 1 ] ; if ( position >= currentLength ) { position = currentLength ; System . arraycopy ( poly . xs , 0 , newxs , 0 , currentLength ) ; System . arraycopy ( poly . ys , 0 , newys , 0 , currentLength ) ; } else if ( position <= 0 ) { position = 0 ; System . arraycopy ( poly . xs , 0 , newxs , 1 , currentLength ) ; System . arraycopy ( poly . ys , 0 , newys , 1 , currentLength ) ; } else { System . arraycopy ( poly . xs , 0 , newxs , 0 , position ) ; System . arraycopy ( poly . xs , position , newxs , position + 1 , currentLength - position ) ; System . arraycopy ( poly . ys , 0 , newys , 0 , position ) ; System . arraycopy ( poly . ys , position , newys , position + 1 , currentLength - position ) ; } int offsetX ; int offsetY ; if ( gpo . getX ( ) == - 1 && gpo . getY ( ) == - 1 ) { offsetX = proj . getWidth ( ) / 2 ; offsetY = proj . getHeight ( ) / 2 ; } else { offsetX = gpo . getX ( ) ; offsetY = gpo . getY ( ) ; } if ( poly . coordMode == OMPoly . COORDMODE_ORIGIN || position == 0 ) { newxs [ position ] = x - offsetX ; newys [ position ] = y - offsetY ; } else { newxs [ position ] = x - offsetX - newxs [ position - 1 ] ; newys [ position ] = y - offsetY - newys [ position - 1 ] ; } if ( position == 0 ) { LatLonPoint llpnt = proj . inverse ( offsetX , offsetY , new LatLonPoint . Double ( ) ) ; poly . lat = llpnt . getRadLat ( ) ; poly . lon = llpnt . getRadLon ( ) ; } poly . setLocation ( poly . lat , poly . lon , OMGraphic . RADIANS , newxs , newys ) ; } OMArrowHead omah = poly . getArrowHead ( ) ; poly . setArrowHead ( null ) ; poly . setArrowHead ( omah ) ; polyGrabPoints . add ( position , gp ) ; if ( gpo != null ) { gpo . addGrabPoint ( gp ) ; } poly . regenerate ( proj ) ; gp . generate ( proj ) ; return position ; }
target:  Add a point at a certain point in the polygon coordinate list. If the position is less than zero, the point will be the starting point. If the position is greater than the list of current points, the point will be added to the end of the poly. This method is convenient because it lets you define the GrabPoint object to use for the node, in case you need a special type of GrabPoint.