private Ptg bothMoveRefPtg(RefPtgBase rptg) { final int refCol = rptg.getColumn(); final int refRow = rptg.getRow(); if (_firstRow <= refRow && refRow <= _lastRow && _firstCol <= refCol && refCol <= _lastCol) { // ptg being moved completely enclose the ref. // - move the area ref along with the rows/columns regardless of destination rptgSetRowCol(rptg, refRow + _rowAmount, refCol + _colAmount); return rptg; } // else rules for adjusting area may also depend on the destination of the moved rows final int destFirstRowIndex = _firstRow + _rowAmount; final int destLastRowIndex = _lastRow + _rowAmount; final int destFirstColIndex = _firstCol + _colAmount; final int destLastColIndex = _lastCol + _colAmount; // ref is outside source area // check for clashes with destination if (destLastRowIndex < refRow || refRow < destFirstRowIndex || destLastColIndex < refCol || refCol < destFirstColIndex) { // destination row/col are completely outside ref return null; } if (destFirstRowIndex <= refRow && refRow <= destLastRowIndex && destFirstColIndex <= refCol && refCol <= destLastColIndex) { // destination rows enclose the area (possibly exactly) return createDeletedRef(rptg); } throw new IllegalStateException( "Situation not covered: row(" + _firstRow + ", " + _lastRow + ", " + _rowAmount + ", " + refRow + "), column(" + _firstCol + ", " + _lastCol + ", " + _colAmount + ", " + refCol + ")"); }
private Ptg rptgSetRowCol(RefPtgBase rptg, int rowNum, int colNum) { if (rowNum > _ver.getLastRowIndex() || rowNum < 0) { return createDeletedRef(rptg); // out of bound } else { rptg.setRow(rowNum); } if (colNum > _ver.getLastColumnIndex() || colNum < 0) { return createDeletedRef(rptg); // out of bound } else { rptg.setColumn(colNum); } return rptg; }
private Ptg rptgSetRow(RefPtgBase rptg, int rowNum) { if (rowNum > _ver.getLastRowIndex() || rowNum < 0) { return createDeletedRef(rptg); // out of bound } else { rptg.setRow(rowNum); return rptg; } }
private Ptg colMoveRefPtg(RefPtgBase rptg) { final int refRow = rptg.getRow(); if (_firstRow > refRow || refRow > _lastRow) { // out of the boundary return null; } int refCol = rptg.getColumn(); if (_firstCol <= refCol && refCol <= _lastCol) { // Cols being moved completely enclose the ref. // - move the area ref along with the cols regardless of destination // rptg.setCol(refCol + _amountToMove); // return rptg; return rptgSetCol(rptg, refCol + _colAmount); } // else rules for adjusting area may also depend on the destination of the moved cols int destFirstColIndex = _firstCol + _colAmount; int destLastColIndex = _lastCol + _colAmount; // ref is outside source cols // check for clashes with destination if (destLastColIndex < refCol || refCol < destFirstColIndex) { // destination cols are completely outside ref return null; } if (destFirstColIndex <= refCol && refCol <= destLastColIndex) { // destination cols enclose the area (possibly exactly) return createDeletedRef(rptg); } throw new IllegalStateException( "Situation not covered: (" + _firstCol + ", " + _lastCol + ", " + _colAmount + ", " + refCol + ")"); }