Ejemplo n.º 1
0
  /**
   * Inicializa.
   *
   * @param sds Capa.
   */
  public void create(SelectableDataSource sds, BitSet bitset) {
    // if (layer instanceof AlphanumericData) {
    try {
      if (sds == null) {
        DbaseFileHeaderNIO myHeader = DbaseFileHeaderNIO.createNewDbaseHeader();
        myHeader.setNumRecords(geometries.length);
        dbfWrite = new DbaseFileWriterNIO(myHeader, (FileChannel) getWriteChannel(dbfPath));
        enteros = new Value[1];
      } else {
        // VectorialFileAdapter
        // vfa=(VectorialFileAdapter)((SingleLayer)lv).getSource();
        DbaseFileHeaderNIO myHeader;

        myHeader = DbaseFileHeaderNIO.createDbaseHeader(sds);

        myHeader.setNumRecords(geometries.length);
        dbfWrite = new DbaseFileWriterNIO(myHeader, (FileChannel) getWriteChannel(dbfPath));
        record = new Object[sds.getFieldCount()];
      }

      createdbf(sds, bitset);
      System.out.println("Acabado DBF");
    } catch (IOException e) {
      e.printStackTrace();

      // /} catch (DriverException e1) {
      // e1.printStackTrace();
    } catch (ReadDriverException e2) {
      e2.printStackTrace();
    }

    // return true;
    // }
    // return false;
  }
Ejemplo n.º 2
0
 private DefaultCancellableMonitorable createCancelMonitor() {
   DefaultCancellableMonitorable monitor = new DefaultCancellableMonitorable();
   monitor.setInitialStep(0);
   monitor.setDeterminatedProcess(true);
   int clipSteps = 0;
   try {
     if (onlyClipLayerSelection) {
       FBitSet selection = overlayLayer.getRecordset().getSelection();
       clipSteps = selection.cardinality();
     } else {
       clipSteps = overlayLayer.getSource().getShapeCount();
     }
     int firstSteps = 0;
     if (onlyFirstLayerSelection) {
       FBitSet selection = firstLayer.getRecordset().getSelection();
       firstSteps = selection.cardinality();
     } else {
       firstSteps = firstLayer.getSource().getShapeCount();
     }
     int totalSteps = clipSteps + firstSteps;
     monitor.setFinalStep(totalSteps);
   } catch (ReadDriverException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return monitor;
 }
Ejemplo n.º 3
0
  /**
   * Rellena los registros del dbf.
   *
   * @param sds DOCUMENT ME!
   */
  private void createdbf(SelectableDataSource sds, BitSet bitset) {
    int i = 0;

    // for (int i = 0; i < fgs.length; i++) {
    try {
      if (sds == null) {
        for (int j = 0; j < geometries.length; j++) {
          enteros[0] = ValueFactory.createValue((double) i);
          dbfWrite.write(enteros);
          i++;
        }
      } else {
        for (int j = bitset.nextSetBit(0); j >= 0; j = bitset.nextSetBit(j + 1)) {
          for (int r = 0; r < sds.getFieldCount(); r++) {
            record[r] = sds.getFieldValue(j, r);
          }

          dbfWrite.write(record);
        }
      }
    } catch (IOException e1) {
      e1.printStackTrace();
    } catch (ReadDriverException e) {
      e.printStackTrace();
    }
  }
Ejemplo n.º 4
0
  public ILayerDefinition createLayerDefinition() {
    try {
      if (resultLayerDefinition == null) {
        resultLayerDefinition = criteria.createLayerDefinition(fields_functions);
        resultLayerDefinition.setShapeType(firstLayer.getShapeType());
      }

    } catch (ReadDriverException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return resultLayerDefinition;
  }
Ejemplo n.º 5
0
 private void init() {
   try {
     sds = ies.getRecordset();
     fieldDescriptors = sds.getFieldsDescription();
     fieldDescriptor = fieldDescriptors[selectedIndex];
     interpreter.declareBean("sds", sds, SelectableDataSource.class);
     indexRow = new Index();
     interpreter.declareBean("indexRow", indexRow, Index.class);
   } catch (BSFException e) {
     e.printStackTrace();
   } catch (ReadDriverException e) {
     e.printStackTrace();
   }
 }
Ejemplo n.º 6
0
  public SaveSelection(FLyrVect layer) {
    this.layer = layer;
    pksSelected = new ArrayList<String>();

    if (!isDBLayer()) {
      error = true;
    }

    try {
      storeOriginalSelection();
    } catch (ReadDriverException e) {
      logger.error(e.getStackTrace(), e);
      error = true;
    }
  }
Ejemplo n.º 7
0
  public boolean restoreSelection() {

    if (pksSelected.isEmpty() || error) {
      return error;
    }

    try {
      doRestoreSelection();
      error = false;
    } catch (ReadDriverException e) {
      logger.error(e.getStackTrace(), e);
      error = true;
    }

    return error;
  }
Ejemplo n.º 8
0
  @Override
  public void export(MapContext mapContext, FLyrVect layer) {
    try {
      JFileChooser jfc = new JFileChooser(lastPath);
      SimpleFileFilter filterShp =
          new SimpleFileFilter("dxf", PluginServices.getText(this, "dxf_files"));
      jfc.setFileFilter(filterShp);
      if (jfc.showSaveDialog((Component) PluginServices.getMainFrame())
          == JFileChooser.APPROVE_OPTION) {
        File newFile = jfc.getSelectedFile();
        String path = newFile.getAbsolutePath();
        if (!(path.toLowerCase().endsWith(".dxf"))) {
          path = path + ".dxf";
        }
        newFile = new File(path);

        DxfWriter writer = (DxfWriter) LayerFactory.getWM().getWriter("DXF Writer");
        SHPLayerDefinition lyrDef = new SHPLayerDefinition();
        SelectableDataSource sds = layer.getRecordset();
        FieldDescription[] fieldsDescrip = sds.getFieldsDescription();
        lyrDef.setFieldsDesc(fieldsDescrip);
        lyrDef.setFile(newFile);
        lyrDef.setName(newFile.getName());
        lyrDef.setShapeType(layer.getShapeType());
        writer.setFile(newFile);
        writer.initialize(lyrDef);
        writer.setProjection(layer.getProjection());
        DxfFieldsMapping fieldsMapping = new DxfFieldsMapping();
        // TODO: Recuperar aqu� los campos del cuadro de di�logo.
        writer.setFieldMapping(fieldsMapping);
        DXFMemoryDriver dxfDriver = new DXFMemoryDriver();
        dxfDriver.open(newFile);
        writeFeatures(mapContext, layer, writer, dxfDriver);
        String fileName = newFile.getAbsolutePath();
        lastPath = fileName.substring(0, fileName.lastIndexOf(File.separatorChar));
      }

    } catch (ReadDriverException e) {
      NotificationManager.addError(e.getMessage(), e);
    } catch (InitializeWriterException e) {
      NotificationManager.addError(e.getMessage(), e);
    } catch (DriverLoadException e) {
      NotificationManager.addError(e.getMessage(), e);
    }
  }
  /** @see com.iver.andami.plugins.IExtension#isEnabled() */
  public boolean isEnabled() {

    try {
      if (EditionUtilities.getEditionStatus()
          == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE) {
        view = (View) PluginServices.getMDIManager().getActiveWindow();
        mapControl = view.getMapControl();
        if (CADExtension.getEditionManager().getActiveLayerEdited() == null) return false;
        FLyrVect lv = (FLyrVect) CADExtension.getEditionManager().getActiveLayerEdited().getLayer();
        if (polygon.isApplicable(lv.getShapeType())) {
          return true;
        }
      }
    } catch (ReadDriverException e) {
      NotificationManager.addError(e.getMessage(), e);
    }
    return false;
  }