package com.connor.erp.materialquery.ViewStockOfERP;

import java.awt.Point;
import java.awt.Rectangle;
import javax.swing.JTable;
import javax.swing.plaf.TableUI;
import javax.swing.table.TableModel;

public class CTable extends JTable {
  private static final long serialVersionUID = 1L;
  
  public CMap map;
  
  public CTable(CMap cMap2, TableModel tbl) {
    super(tbl);
    this.map = cMap2;
    setUI((TableUI)new CTUI());
  }
  
  public Rectangle getCellRect(int row, int column, boolean includeSpacing) {
    if (this.map == null)
      return super.getCellRect(row, column, includeSpacing); 
    int sk = this.map.visibleCell(this, row, column);
    Rectangle r1 = super.getCellRect(sk, column, includeSpacing);
    if (this.map.span(this, sk, column) != 1)
      for (int i = 1; i < this.map.span(this, sk, column); i++)
        r1.height += getRowHeight(sk + i);  
    return r1;
  }
  
  public int rowAtPoint(Point p) {
    int x = columnAtPoint(p);
    if (x < 0)
      return x; 
    int y = super.rowAtPoint(p);
    return this.map.visibleCell(this, y, x);
  }
}
