?? abstractcells.java
字號:
package entity;import java.util.ArrayList;import java.util.List;/** * @author yangan */public abstract class AbstractCells { private List<Cell> allCells; private List<Value> originalValues; private List<Value> permitValues; private List<Value> forbidValues; private Point begin; private Point end; public AbstractCells(Point begin, Point end, List<Value> policyOringinalValue) { super(); this.begin = begin; this.end = end; this.allCells = new ArrayList<Cell>(); this.permitValues = new ArrayList<Value>(); this.forbidValues = new ArrayList<Value>(); this.originalValues = new ArrayList<Value>(); this.initOriginal(policyOringinalValue); this.initPermit(); } /** * @return Returns the originalValues. * @uml.property name="originalValues" */ public List<Value> getOriginalValues() { return originalValues; } /** * @return Returns the permitValues. * @uml.property name="permitValues" */ public List<Value> getPermitValues() { return permitValues; } /** * @return Returns the forbidValues. * @uml.property name="forbidValues" */ public List<Value> getForbidValues() { return forbidValues; } /** * @return Returns the allCells. * @uml.property name="allCells" */ public List<Cell> getAllCells() { return allCells; } /** * @return Returns the begin. * @uml.property name="begin" */ public Point getBegin() { return begin; } /** * @param begin The begin to set. * @uml.property name="begin" */ public void setBegin(Point begin) { this.begin = begin; } /** * @return Returns the end. * @uml.property name="end" */ public Point getEnd() { return end; } /** * @param end The end to set. * @uml.property name="end" */ public void setEnd(Point end) { this.end = end; } public boolean addCell(Cell cell) { boolean result = this.getAllCells().add(cell); return result; } public boolean addPermitValue(Value value) { boolean result = this.getPermitValues().add(value); return result; } public boolean removePermitValue(Value value) { Value find = null; for (Value element : this.getPermitValues()) { if (element.equals(value)) { find = element; } } boolean result = false; if (find != null) { this.addForbidValue(find); result = this.getPermitValues().remove(find); } return result; } public boolean addOriginalValue(Value value) { boolean result = this.getOriginalValues().add(value); return result; } public boolean addForbidValue(Value value) { boolean result = this.getForbidValues().add(value); return result; } private void initOriginal(List<Value> policyOringinalValue) { Value clone; for (Value value : policyOringinalValue) { clone = value.cloneMe(); originalValues.add(clone); } } private void initPermit() { Value cloneValue; for (Value element : this.getOriginalValues()) { cloneValue = element.cloneMe(); this.addPermitValue(cloneValue); } } private List<Cell> getCellListByValue(Value value) { List<Cell> result = new ArrayList<Cell>(); for (Cell cell : this.getAllCells()) { if (cell.getCellPermitValues().contains(value)) { result.add(cell); } } return result; } public void initAllCellByBeginAndEnd(List<Cell> cellList) { Point point; for (Cell cell : cellList) { point = cell.getPoint(); if (this.initCondition(point)) { this.addCell(cell); cell.addCellsLink(this); } } } protected abstract boolean initCondition(Point point); public void excute() { for (Value value : this.getOriginalValues()) { List<Cell> cellList = this.getCellListByValue(value); if (cellList.size() == 1) { for (Cell cell : cellList) { cell.setSureValue(value); } } } }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -