Exemplo n.º 1
0
  /** DOCUMENT ME! */
  public void performAction() {
    myWizardComponents.getFinishButton().setEnabled(false);

    Annotation_FieldSelect panel1 = (Annotation_FieldSelect) myWizardComponents.getWizardPanel(0);
    Annotation_ConfigureLabel panel2 =
        (Annotation_ConfigureLabel) myWizardComponents.getWizardPanel(1);

    SelectableDataSource source;
    Annotation_Mapping mapping = new Annotation_Mapping();

    try {
      source = this.layerAnnotation.getRecordset();

      mapping.setColumnText(source.getFieldIndexByName(panel1.getField()));

      if (!panel2.getAngleFieldName().equals(ConfigureLabel.TEXT_FOR_DEFAULT_VALUE)) {
        mapping.setColumnRotate(source.getFieldIndexByName(panel2.getAngleFieldName()));
      }

      if (!panel2.getColorFieldName().equals(ConfigureLabel.TEXT_FOR_DEFAULT_VALUE)) {
        mapping.setColumnColor(source.getFieldIndexByName(panel2.getColorFieldName()));
      }

      if (!panel2.getSizeFieldName().equals(ConfigureLabel.TEXT_FOR_DEFAULT_VALUE)) {
        mapping.setColumnHeight(source.getFieldIndexByName(panel2.getSizeFieldName()));
      }

      if (!panel2.getFontFieldName().equals(ConfigureLabel.TEXT_FOR_DEFAULT_VALUE)) {
        mapping.setColumnTypeFont(source.getFieldIndexByName(panel2.getFontFieldName()));
      }
    } catch (ReadDriverException e) {
      NotificationManager.addError(e);
    }

    try {
      this.layerAnnotation.setMapping(mapping);
      // AttrInTableLabelingStrategy labeling = new
      // AttrInTableLabelingStrategy();
      ((Annotation_Legend) layerAnnotation.getLegend())
          .setUnits(panel2.getCmbUnits().getSelectedUnitIndex());
      // this.layerAnnotation.setLabelingStrategy(labeling);
      // ((FSymbol)
      // this.layerAnnotation.getLegend().getDefaultSymbol()).setFontSizeInPixels(panel2.sizeUnitsInPixels());
      saveToShp(map, this.layerAnnotation, panel1.getDuplicate());
    } catch (LegendLayerException e) {
      NotificationManager.addError(e);
    } catch (ReadDriverException e) {
      NotificationManager.addError(e);
    }

    this.myWizardComponents.getCancelAction().performAction();
  }
Exemplo n.º 2
0
  private Map loadValuesFromSource(
      SelectableDataSource source, String keyFieldName, ArrayList fieldsPositions)
      throws ReadDriverException {
    HashMap values = new HashMap();
    int row, i;
    Value[] rowValues;
    Value key;
    int keyPos = source.getFieldIndexByName(keyFieldName);
    long rowCount = source.getRowCount();
    for (row = 0; row < rowCount; row++) {
      key = source.getFieldValue(row, keyPos);
      if (values.containsKey(key)) {
        continue;
      }
      rowValues = new Value[fieldsPositions.size()];

      for (i = 0; i < fieldsPositions.size(); i++) {
        rowValues[i] = source.getFieldValue(row, ((Integer) fieldsPositions.get(i)).intValue());
      }

      values.put(key, rowValues);
    }

    return values;
  }