Package simplesheet.model.selection

Examples of simplesheet.model.selection.CellPosition


        }
        Rectangle clipRc = fixRectangle(oldRc, borderInsets);

        //calc rectangle
        SheetModel model = table.getModel();
        CellPosition origin0 = getTopLeft(clipRc);
        CellPosition originN = getBottomRight(clipRc);
        if(origin0 == null || originN == null) {
            //no cells
            return;
        }
       
        int yBase = borderInsets.top;
        for (int iRow = 0; iRow < origin0.row; iRow++) {
            yBase += model.getRow(iRow).getHeight();
        }
        int xBase = borderInsets.left;
        for (int iCol = 0; iCol < origin0.col; iCol++) {
            xBase += model.getColumn(iCol).getWidth();
        }

        Spanned spanned[] = new Spanned[originN.col - origin0.col + 1];

        for (int iRow = origin0.row; iRow <= originN.row; iRow++) {
            int xLocalBase = xBase;
            for (int iCol = origin0.col; iCol <= originN.col; ) { /// increment at end
                //check if spanned
                int index = iCol - origin0.col;
                if(spanned[index] != null) {
                   spanned[index].rows--;
                   iCol += spanned[index].cols;
                   xLocalBase += spanned[index].width;

                   if(spanned[index].rows == 0) {
                       spanned[index] = null;
                   }
                   continue;
                }
               
                //define dimensions
                CellPosition origin = model.getOrigin(new CellPosition(iRow, iCol));
                Dimension size = model.getSize(origin);
                Rectangle rc = new Rectangle();
                //y offset for spanned cells may be > 0
                rc.y = yBase;
                for(int i=0; i < iRow-origin.row; i++) {
View Full Code Here


     * @param rc
     * @return nearest cell in top left rect point, or null if no cell specified
     */
    private CellPosition getTopLeft(Rectangle rc) {
        Point topLeft = new Point(rc.x, rc.y);
        CellPosition pos = table.getCellAtPoint(topLeft);
        if(pos == null) {
            return null;
        }
        return table.getModel().getOrigin(pos);
    }
View Full Code Here

     * @param rc
     * @return nearest cell in bottom right rect point, or null if no cell specified
     */
    private CellPosition getBottomRight(Rectangle rc) {
        Point bottomLeft = new Point(rc.x + rc.width, rc.y + rc.height);
        CellPosition pos = table.getCellAtPoint(bottomLeft);
        if(pos == null) {
            return null;
        }
        SheetModel model = table.getModel();
        CellPosition originN = model.getOrigin(pos);
        Dimension sizeN = model.getSize(originN);
        return new CellPosition(originN.row + sizeN.height-1, originN.col + sizeN.width-1);
    }
View Full Code Here

        return new CellPosition(originN.row + sizeN.height-1, originN.col + sizeN.width-1);
    }

   
    private void paintCell(Graphics g, Rectangle cellRect, CellPosition pos) {
        CellPosition editingCell = table.getEditingCell();
        if (editingCell != null && editingCell.equals(pos)) {
            Component component = table.getEditorComponent();
            component.setBounds(cellRect);
            component.validate();
        } else {
            drawGrid(g, cellRect);
View Full Code Here

    private void recalcColWidth(Graphics g, int iCol) {
        int maxWidth = 0;
        SheetModel model = table.getModel();
        CellRenderer renderer = table.getDefaultRenderer();
        for(int iRow=0; iRow<model.getRowCount(); /* ath the end*/) {
            CellPosition pos = model.getOrigin(new CellPosition(iRow, iCol));
            Dimension size = model.getSize(pos);
            if(size.height > 1 || size.width > 1) {
                iRow += size.height;
                continue;
            }
View Full Code Here

    private void recalcRowHeight(Graphics g, int iRow) {
        int maxHeight = 0;
        SheetModel model = table.getModel();
        CellRenderer renderer = table.getDefaultRenderer();
        for(int iCol=0; iCol<model.getColumnCount(); /* ath the end*/) {
            CellPosition pos = model.getOrigin(new CellPosition(iRow, iCol));
            Dimension size = model.getSize(pos);
            if(size.height > 1 || size.width > 1) {
                iCol += size.width;
                continue;
            }
View Full Code Here

TOP

Related Classes of simplesheet.model.selection.CellPosition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.