Beispiel #1
0
  /**
   * This function takes an OMGraphicList and loads each one with the array representing the records
   * in the dbf file. Each graphics stores the graphic in its object slot.
   */
  public void loadDbfModelIntoGraphics(OMGraphicList list) {
    if (list != null && dbfModel.getRowCount() > 0) {
      int numgraphics = list.size();

      for (int i = 0; i < numgraphics; i++) {
        try {
          OMGraphic omg = list.getOMGraphicAt(i);
          Integer recnum = (Integer) (omg.getAttribute(ShapeConstants.SHAPE_INDEX_ATTRIBUTE));
          // OFF BY ONE!!! The shape record numbers
          // assigned to the records start with 0, while
          // everything else we do starts with 0. The DbfTableModel
          // follows java convention and starts at 0. The integer
          // stored in the OMG should know it too.
          Object inforec = dbfModel.getRecord(recnum.intValue());
          omg.putAttribute(ShapeConstants.SHAPE_DBF_INFO_ATTRIBUTE, inforec);
        } catch (ClassCastException cce) {
          if (Debug.debugging("shape")) {
            cce.printStackTrace();
          }
        } catch (NullPointerException npe) {
          npe.printStackTrace();
        }
      }
    }
  }