public boolean removeGroupAt ( int groupIndex ) { try { final int startIndex = firstInGroup ( groupIndex ) ; final int lastIndex = lastInGroup ( groupIndex ) ; final int ptsToRemoveCount = ( lastIndex - startIndex + 2 ) / 2 ; int rest = this . pointCoordinates . length / 2 - ptsToRemoveCount ; if ( rest > 0 ) { // Remove the points rest *= 2 ; final double [ ] newPts = new double [ rest ] ; System . arraycopy ( this . pointCoordinates , 0 , newPts , 0 , startIndex ) ; System . arraycopy ( this . pointCoordinates , lastIndex + 2 , newPts , startIndex , rest - startIndex ) ; this . pointCoordinates = newPts ; // Remove the group if ( this . partIndexes != null ) { // Shift the group's indexes for ( int i = groupIndex ; i < this . partIndexes . length ; ++ i ) { this . partIndexes [ i ] -= ptsToRemoveCount * 2 ; } // Removing the group int [ ] newGroups = null ; if ( this . partIndexes . length > 1 ) { newGroups = new int [ this . partIndexes . length - 1 ] ; if ( groupIndex == 0 ) { System . arraycopy ( this . partIndexes , 1 , newGroups , 0 , this . partIndexes . length - 1 ) ; } else { System . arraycopy ( this . partIndexes , 0 , newGroups , 0 , groupIndex - 1 ) ; System . arraycopy ( this . partIndexes , groupIndex , newGroups , groupIndex - 1 , this . partIndexes . length - groupIndex ) ; } } this . partIndexes = newGroups ; } } else { // Remove all the points this . pointCoordinates = null ; this . partIndexes = null ; } fireShapeChanged ( ) ; fireElementChanged ( ) ; return true ; } catch ( IndexOutOfBoundsException exception ) { // } return false ; }
Remove the specified group .