コード例 #1
0
 /*
  * (non-Javadoc)
  *
  * @see javax.swing.table.TableModel#getValueAt(int, int)
  */
 public Object getValueAt(int rowIndex, int columnIndex) {
   final ConstructionRow row = this.rows.get(rowIndex);
   switch (columnIndex) {
     case 0:
       return row.getCanvas();
     case 1:
       return new BrickReportElement(row.getCut());
     case 2:
       return row.getCutCount();
     case 3:
       return row.getCutDescription();
   }
   return null;
 }
コード例 #2
0
 @Override
 public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
   final ConstructionRow row = this.rows.get(rowIndex);
   switch (columnIndex) {
     case 0:
       row.setCanvas((java.awt.Image) aValue);
       break;
     case 1:
       row.setCut((com.stoneworks.Brick) aValue);
       break;
     case 2:
       row.setCutCount(Integer.valueOf(aValue.toString()));
       break;
     case 3:
       row.setCutDescription((String) aValue);
       break;
   }
 }
コード例 #3
0
 private void getInventory(Image canvasImage) {
   for (Brick b : this.canvas.getBricks()) {
     boolean found = false;
     int foundOnRow = 0;
     int foundQuantity = 0;
     for (int i = 0; i < this.getRowCount(); i++) {
       final ConstructionRow row = this.rows.get(i);
       // TODO: I don't like this here...need a more robust solution
       // for equals in Brick
       if (row.getCut().getDescription().equals(b.getDescription())) {
         found = true;
         foundOnRow = i;
         foundQuantity = row.getCutCount();
         break;
       }
     }
     if (found) {
       this.setValueAt(foundQuantity + 1, foundOnRow, 2);
     } else {
       Brick newBrick = new Brick(b.getCuttable(), this.colorAssigned(b.getDescription()));
       this.rows.add(new ConstructionRow(canvasImage, 1, newBrick.getDescription(), newBrick));
     }
   }
 }