public TableArea(ControlEnvironment environment, TableModel model) { this.environment = environment; this.model = model; if (environment == null) throw new NullPointerException("environment may not be null"); if (model == null) throw new NullPointerException("model may not be null"); this.appearance = new DefaultTableAppearance(environment); this.initialHotPointX = appearance.getInitialHotPointX(model); // refresh(); }
public TableArea( ControlEnvironment environment, TableModel model, TableAppearance appearance, TableClickHandler clickHandler, String name) { this.environment = environment; this.model = model; this.appearance = appearance != null ? appearance : new DefaultTableAppearance(environment); this.name = name != null ? name : ""; this.clickHandler = clickHandler; this.initialHotPointX = appearance.getInitialHotPointX(model); if (environment == null) throw new NullPointerException("environment may not be null"); if (model == null) throw new NullPointerException("model may not be null"); if (appearance == null) throw new NullPointerException("appearance may not be null"); // if (clickHandler == null) // throw new NullPointerException("clickHandler may not be null"); if (name == null) throw new NullPointerException("name may not be null"); // refresh(); }
public void refresh(boolean refreshModel) { if (model == null) { colWidth = null; cellShift = 0; hotPointX = 0; hotPointY = 0; environment.onAreaNewContent(this); environment.onAreaNewHotPoint(this); return; } if (refreshModel) model.refresh(); final int colCount = model.getColCount(); final int rowCount = model.getRowCount(); if (colCount <= 0 || rowCount <= 0) { colWidth = null; cellShift = 0; hotPointX = 0; hotPointY = 0; environment.onAreaNewContent(this); environment.onAreaNewHotPoint(this); return; } initialHotPointX = appearance.getInitialHotPointX(model); colWidth = new int[colCount]; int totalWidth = initialHotPointX; for (int i = 0; i < colCount; ++i) { final int width = appearance.getColWidth(model, i); colWidth[i] = width >= 1 ? width : 1; totalWidth += (colWidth[i] + 1); } if (hotPointY > rowCount) hotPointY = rowCount; if (hotPointY < rowCount && hotPointX >= totalWidth) hotPointX = totalWidth - 1; // totalWidth may not be zero as always we have at least one column here; if (hotPointY == rowCount) hotPointX = 0; environment.onAreaNewContent(this); environment.onAreaNewHotPoint(this); }