[Gvsig_desarrolladores] Re: FNullGeometry

Angel Rodriguez Fernandez anxelin en hotmail.com
Jue Jul 12 20:16:26 CEST 2007


Muchas gracias Álvaro, quedo arreglado.

Lo de no enviar a la lista fue que le dí a reenviar sin más sin fijarme a quien se lo enviaba. 

Eso sí, la función "public void addGeometry(IGeometry geom, Object[] row)" que pones tiene una variable que no está definida (fieldWidth), yo lo arregle haciendo lo que dices al principio

Un saludo
Anxo

  ----- Original Message ----- 
  From: Alvaro Zabala 
  To: Lista de Desarrolladores de gvSIG 
  Sent: Thursday, July 12, 2007 7:24 PM
  Subject: Re: [Gvsig_desarrolladores] Re: FNullGeometry


  Ultima corrección (cosas de las tardes de verano en visperas de vacaciones ;) )

  además de lo indicado en el correo anterior, hay que añadir los siguientes cambios a MemoryDriver para que todo funcione correctamente; 

  public long getRowCount() throws DriverException {
    return m_TableModel.getRowCount();
   }

  Esto hace que la tabla te muestre el nº correcto de filas alfanuméricas (antes te incluia la geometria null, ahora no) 

  public void addGeometry(IGeometry geom, Object[] row) {
    if (geom == null) {
     return; // No añadimos nada
    }
    if(! (geom instanceof FNullGeometry)){
      Rectangle2D boundsShp = geom.getBounds(); 
      memShapeInfo.addShapeInfo (boundsShp, geom.getGeometryType());
      arrayGeometries.add(geom);
     if (fullExtent == null) {
      fullExtent = boundsShp;
     } else {
      fullExtent.add(boundsShp);
     } 
      
    }
  //  Rectangle2D boundsShp = geom.getBounds();
  //  memShapeInfo.addShapeInfo(boundsShp, geom.getGeometryType());
  //  arrayGeometries.add(geom);
    if (fieldWidth==null) {
     initializeFieldWidth(row); 
    }
    actualizeFieldWidth(row);
    m_TableModel.addRow(row);

    try {
     fullExtent = getFullExtent();
    } catch (IOException e) {
     e.printStackTrace();
    }

    m_Position++;
   }


  Y aquí un código de ejemplo de uso:

  public void execute(String actionCommand) {
    View v = (View) PluginServices.getMDIManager().getActiveWindow();
    MapControl mapCtrl = v.getMapControl();
            
       
          // DRIVER DEFINITION (SHAPE TYPE AND FIELDS)
          ConcreteMemoryDriver driver = new ConcreteMemoryDriver();
          driver.setShapeType(FShape.LINE);
          
    ArrayList arrayFields = new ArrayList(); 
    arrayFields.add("ID");
    Value[] auxRow = new Value[1];
    
    driver.getTableModel().setColumnIdentifiers(arrayFields.toArray());
          
          
    // GEOMETRY DEFINITION
          GeneralPathX gp = new GeneralPathX(); 
          
          gp.moveTo(20,80);
          gp.lineTo(80,60);
          gp.lineTo(100, 140);
          
          FShape shp = new FPolyline2D(gp);
          
          
          // ATRIBUTES
          auxRow[0] = ValueFactory.createValue(0);
          Value[] auxRow2 = new Value[1];
          auxRow2[0] = ValueFactory.createValue(1);
          FNullGeometry nula = new FNullGeometry();
          
          // ADD RECORD
          driver.addShape(shp, auxRow);
          driver.addGeometry(nula, auxRow2);
           

          // CREATE AND ADD LAYER
       FLayer lyr;
       String layerName = "Example";
    lyr = LayerFactory.createLayer (layerName,driver, mapCtrl.getProjection());

    if (lyr != null) {
     lyr.setVisible(true);
     mapCtrl.getMapContext().getLayers().addLayer(lyr);
              
    }
          
    
   }


  Espero que ya sí funcione todo. 

  Un saludo.



------------------------------------------------------------------------------


  _______________________________________________
  gvSIG_desarrolladores mailing list
  gvSIG_desarrolladores en runas.cap.gva.es
  http://runas.cap.gva.es/mailman/listinfo/gvsig_desarrolladores
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: http://runas.cap.gva.es/pipermail/gvsig_desarrolladores/attachments/20070712/a279fcf3/attachment.htm


Más información sobre la lista de distribución gvSIG_desarrolladores