Пример #1
0
  public void setXMLEntity(XMLEntity xml) {
    setDescription(xml.getStringProperty("desc"));
    setIsShapeVisible(xml.getBooleanProperty("isShapeVisible"));

    markerSymbol =
        (AbstractMarkerSymbol) SymbologyFactory.createSymbolFromXML(xml.getChild(0), null);
    markerFillProperties =
        (SimpleMarkerFillPropertiesStyle)
            SymbologyFactory.createStyleFromXML(xml.getChild(1), null);

    if (xml.contains("unit")) { // remove this line when done
      // measure unit (for outline)
      setUnit(xml.getIntProperty("unit"));

      // reference system (for outline)
      setReferenceSystem(xml.getIntProperty("referenceSystem"));
    }

    if (xml.contains("hasOutline")) {
      XMLEntity outlineXML = xml.firstChild("id", "outline symbol");
      if (outlineXML != null) {
        setOutline((ILineSymbol) SymbologyFactory.createSymbolFromXML(outlineXML, "outline"));
      }
    }
  }
Пример #2
0
 public void initializeValues() {
   PluginServices ps = PluginServices.getPluginServices(this);
   XMLEntity xml = ps.getPersistentXML();
   if (xml.contains(PROJECTS_FOLDER_PROPERTY_NAME)) {
     txtProjectsFolder.setText(xml.getStringProperty(PROJECTS_FOLDER_PROPERTY_NAME));
   }
   if (xml.contains(DATA_FOLDER_PROPERTY_NAME)) {
     txtDataFolder.setText(xml.getStringProperty(DATA_FOLDER_PROPERTY_NAME));
   }
   if (xml.contains(TEMPLATES_FOLDER_PROPERTY_NAME)) {
     txtTemplatesFolder.setText(xml.getStringProperty(TEMPLATES_FOLDER_PROPERTY_NAME));
   }
   if (xml.contains(SYMBOL_LIBRARY_FOLDER_PROPERTY_NAME)) {
     txtSymbolLibraryFolder.setText(xml.getStringProperty(SYMBOL_LIBRARY_FOLDER_PROPERTY_NAME));
   }
 }
Пример #3
0
  public void addElement(Object element, String elementName, Object containerFolder) {
    if (element instanceof ISymbol) {
      ISymbol sym = (ISymbol) element;
      if (containerFolder == null) {
        containerFolder = rootDir;
      }

      String fExtension = SymbolLibrary.SYMBOL_FILE_EXTENSION;
      File targetFile =
          new File(((File) containerFolder).getAbsolutePath() + File.separator + elementName);
      // save it
      XMLEntity xml = sym.getXMLEntity();
      if (!targetFile.getAbsolutePath().toLowerCase().endsWith(fExtension))
        targetFile = new File(targetFile.getAbsolutePath() + fExtension);
      if (targetFile.exists()) {
        int resp =
            JOptionPane.showConfirmDialog(
                (Component) PluginServices.getMainFrame(),
                PluginServices.getText(this, "fichero_ya_existe_seguro_desea_guardarlo"),
                PluginServices.getText(this, "guardar"),
                JOptionPane.YES_NO_OPTION);
        if (resp != JOptionPane.YES_OPTION) {
          return;
        }
      }
      FileWriter writer;
      try {
        writer = new FileWriter(targetFile.getAbsolutePath());
        Marshaller m = new Marshaller(writer);
        m.setEncoding("ISO-8859-1");
        m.marshal(xml.getXmlTag());

      } catch (Exception ex) {
        NotificationManager.addError(PluginServices.getText(this, "save_error"), ex);
      }
    } else {
      throw new IllegalArgumentException(
          PluginServices.getText(this, "adding_a_non_symbol_as_element"));
    }
  }
Пример #4
0
  /**
   * Binds the information in the XML entity argument to create and return an <code>ExtentHistory
   * </code> object.
   *
   * @param xml an XML entity of a <code>ExtentHistory</code>
   * @return an <code>ExtentHistory</code> object with the information of the <code>xml</code>
   *     argument
   * @see #getXMLEntity()
   */
  public static ExtentHistory createFromXML(XMLEntity xml) {
    ExtentHistory eh = new ExtentHistory();
    eh.num = xml.getIntProperty("num");
    eh.NUMREC = xml.getIntProperty("numrec");

    for (int i = 0; i < eh.NUMREC; i++) {
      try {
        eh.extents[i] =
            new Rectangle2D.Double(
                xml.getDoubleProperty("extent" + i + "X"),
                xml.getDoubleProperty("extent" + i + "Y"),
                xml.getDoubleProperty("extent" + i + "W"),
                xml.getDoubleProperty("extent" + i + "H"));
      } catch (Exception e) {
        /// System.out.println("En las ExtentHistory =" + e); //TODO o se captura de alguna forma o
        // se mete un nuevo parametro en el xml para saber exactamente cuantos rectágulos se han
        // añadido.
      }
    }

    return eh;
  }
Пример #5
0
  /**
   * Inserts layers and properties to this collection of layers.
   *
   * <p>This root node has the same properties that return <code>FlyrDefault#getXMLEntity()</code>
   * adding:
   *
   * <ul>
   *   <li><i>numLayers</i> : number of first-level layers of this collection
   *   <li><i>LayerNames</i> : an array list with the name of the first-level layers of this
   *       collection <code>FLayer.getXMLEntity()</code>
   * </ul>
   *
   * @see FLyrDefault#setXMLEntity()
   * @see FLyrDefault#getXMLEntity()
   * @see CopyOfFLayers#addLayerFromXML(XMLEntity, String)
   * @param xml an <code>XMLEntity</code> with the information
   * @throws XMLException if there is an error setting the object.
   */
  public void setXMLEntity(XMLEntity xml) throws XMLException {
    super.setXMLEntity(xml);
    // LoadLayerException loadLayerException=new LoadLayerException();

    String[] s = xml.getStringArrayProperty("LayerNames");
    // try {
    fmap.clearErrors();
    int numLayers = xml.getIntProperty("numLayers");
    Iterator iter = xml.findChildren("tagName", "layer");
    XMLEntity xmlLayer;
    while (iter.hasNext()) {
      xmlLayer = (XMLEntity) iter.next();
      try {
        this.addLayerFromXML(xmlLayer, null);
      } catch (LoadLayerException e) {
        throw new XMLLayerException(getName(), e);
      }
    }
    if (numLayers != this.layers.size()) {
      logger.warn(this.getName() + ": layer count no match");
    }
  }
Пример #6
0
 /**
  * Reads the stored toolbars' status from plugin-persinstence.xml, and sets the toolbars
  * accordingly.
  */
 private void getPersistedStatus() {
   PluginServices ps = PluginServices.getPluginServices(this);
   XMLEntity xml = ps.getPersistentXML();
   XMLEntity child = null;
   for (int i = xml.getChildrenCount() - 1; i >= 0; i--) {
     if (xml.getChild(i).getName().equals("Toolbars")) child = xml.getChild(i).getChild(0);
   }
   if (child != null) {
     SelectableToolBar[] toolBars = PluginServices.getMainFrame().getToolbars();
     for (int i = toolBars.length - 1; i >= 0; i--) {
       if (child.contains(toolBars[i].getName()))
         toolBars[i].setAndamiVisibility(
             child.getStringProperty(toolBars[i].getName()).equals("visible"));
     }
   }
 }
Пример #7
0
  /**
   * Returns an XML entity with information of this object. All information is stored as properties:
   * <br>
   *
   * <p><b>Properties:</b>
   *
   * <ul>
   *   <li><i>className</i>: name of this class.
   *   <li><i>num</i>: number of extents registered.
   *   <li><i>numrec</i>: maximum number of extents that can register.
   *   <li><i>extentiX</i>: X coordinate of the upper left corner of the rectangle that defines the
   *       area.
   *   <li><i>extentiY</i>: Y coordinate of the upper left corner of the rectangle that defines the
   *       area.
   *   <li><i>extentiW</i>: width of the rectangle that defines the area.
   *   <li><i>extentiH</i>: height of the rectangle that defines the area.
   * </ul>
   *
   * @return XML entity that represents this object
   * @see #createFromXML(XMLEntity)
   * @see #get()
   * @see #put(Rectangle2D)
   */
  public XMLEntity getXMLEntity() {
    XMLEntity xml = new XMLEntity();
    xml.putProperty("className", this.getClass().getName());
    xml.putProperty("num", num);
    xml.putProperty("numrec", NUMREC);

    for (int i = 0; i < NUMREC; i++) {
      if (extents[i] != null) {
        xml.putProperty("extent" + i + "X", extents[i].getX());
        xml.putProperty("extent" + i + "Y", extents[i].getY());
        xml.putProperty("extent" + i + "W", extents[i].getWidth());
        xml.putProperty("extent" + i + "H", extents[i].getHeight());
      }
    }

    return xml;
  }
Пример #8
0
  /**
   * Returns an entity that represents this collection of layers stored as a tree-node with children
   * that are also layers.
   *
   * <p>The root node has the same properties that <code>FlyrDefault#getXMLEntity()</code> returns,
   * and adds:
   *
   * <ul>
   *   <li><i>numLayers</i> : number of layers of this collection (direct children of this node)
   *   <li><i>LayerNames</i> : an array list with the name of the layers of this collection (direct
   *       children of this node) <code>FLayer.getXMLEntity()</code>
   * </ul>
   *
   * <p>All XML elements returned represent the information about this layer.
   *
   * @return an XML entity with information to this collection of layers
   * @throws XMLException if there is any error creating the XML from the layers.
   */
  public XMLEntity getXMLEntity() throws XMLException {
    XMLEntity xml = super.getXMLEntity();
    xml.putProperty("numLayers", layers.size());

    String[] s = new String[layers.size()];

    for (int i = 0; i < layers.size(); i++) {
      s[i] = ((FLayer) layers.get(i)).getName();
    }

    xml.putProperty("LayerNames", s);

    for (int i = 0; i < layers.size(); i++) {
      try {
        XMLEntity xmlLayer = ((FLayer) layers.get(i)).getXMLEntity();
        xmlLayer.putProperty("tagName", "layer");
        xml.addChild(xmlLayer);
      } catch (XMLException e) {
        e.printStackTrace();
      }
    }

    return xml;
  }
Пример #9
0
  public void storeValues() throws StoreException {
    File f;
    String path, propertyName;
    PluginServices ps = PluginServices.getPluginServices(this);
    XMLEntity xml = ps.getPersistentXML();

    // Projects folder
    propertyName = PROJECTS_FOLDER_PROPERTY_NAME;
    path = txtProjectsFolder.getText();

    if (path.equals("")) {
      if (xml.contains(propertyName)) {
        xml.remove(propertyName);
      }
      prefs.remove(propertyName);
    } else {
      f = new File(path);
      if (f.exists()) {
        if (xml.contains(propertyName)) {
          xml.remove(propertyName);
        }
        xml.putProperty(propertyName, f.getAbsolutePath());
        prefs.put(propertyName, f.getAbsolutePath());
      }
    }

    // Data folder
    propertyName = DATA_FOLDER_PROPERTY_NAME;
    path = txtDataFolder.getText();

    if (path.equals("")) {
      if (xml.contains(propertyName)) {
        xml.remove(propertyName);
      }
      prefs.remove(propertyName);
    } else {
      f = new File(path);
      if (f.exists()) {
        if (xml.contains(propertyName)) {
          xml.remove(propertyName);
        }
        xml.putProperty(propertyName, f.getAbsolutePath());
        prefs.put(propertyName, f.getAbsolutePath());
      }
    }

    // Templates folder
    propertyName = TEMPLATES_FOLDER_PROPERTY_NAME;
    path = txtTemplatesFolder.getText();

    if (path.equals("")) {
      if (xml.contains(propertyName)) {
        xml.remove(propertyName);
      }
      prefs.remove(propertyName);
    } else {
      f = new File(path);
      if (f.exists()) {
        if (xml.contains(propertyName)) {
          xml.remove(propertyName);
        }
        xml.putProperty(propertyName, f.getAbsolutePath());
        prefs.put(propertyName, f.getAbsolutePath());
      }
    }

    // Symbol library folder
    propertyName = SYMBOL_LIBRARY_FOLDER_PROPERTY_NAME;
    path = txtSymbolLibraryFolder.getText();

    if (path.equals("")) {
      if (xml.contains(propertyName)) {
        xml.remove(propertyName);
      }
      prefs.remove(propertyName);
    } else {
      f = new File(path);
      if (f.exists()) {
        if (xml.contains(propertyName)) {
          xml.remove(propertyName);
        }
        xml.putProperty(propertyName, f.getAbsolutePath());
        prefs.put(propertyName, f.getAbsolutePath());
      }
    }
  }
Пример #10
0
  public FolderingPage() {
    super();
    setParentID(GeneralPage.id);
    icon = PluginServices.getIconTheme().get("folder-icon");

    btnFileChooserAction =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String path;
            if (e.getSource().equals(btnSelectProjectsFolder)) {
              path = txtProjectsFolder.getText();
            } else if (e.getSource().equals(btnSelectDataFolder)) {
              path = txtDataFolder.getText();
            } else if (e.getSource().equals(btnSelectSymbolLibraryFolder)) {
              path = txtSymbolLibraryFolder.getText();
            } else {
              path = txtTemplatesFolder.getText();
            }

            // The file filter for the JFileChooser
            FileFilter def =
                new FileFilter() {
                  public boolean accept(File f) {
                    return (f.isDirectory());
                  }

                  public String getDescription() {
                    return null;
                  }
                };

            File file = new File(path);
            JFileChooser fc;
            if (file.exists()) {
              fc = new JFileChooser(file);
            } else {
              fc = new JFileChooser();
            }

            fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            fc.setMultiSelectionEnabled(false);
            fc.setAcceptAllFileFilterUsed(false);
            fc.addChoosableFileFilter(def);
            int result = fc.showOpenDialog(FolderingPage.this);

            if (result == JFileChooser.APPROVE_OPTION && (file = fc.getSelectedFile()) != null) {
              if (e.getSource().equals(btnSelectProjectsFolder)) {
                txtProjectsFolder.setText(file.getAbsolutePath());
              } else if (e.getSource().equals(btnSelectDataFolder)) {
                txtDataFolder.setText(file.getAbsolutePath());
              } else if (e.getSource().equals(btnSelectSymbolLibraryFolder)) {
                txtSymbolLibraryFolder.setText(file.getAbsolutePath());
              } else {
                txtTemplatesFolder.setText(file.getAbsolutePath());
              }
            }
          }
        };
    btnSelectProjectsFolder = new JButton(PluginServices.getText(this, "browse"));
    btnSelectProjectsFolder.addActionListener(btnFileChooserAction);
    btnSelectDataFolder = new JButton(PluginServices.getText(this, "browse"));
    btnSelectDataFolder.addActionListener(btnFileChooserAction);
    btnSelectTemplatesFolder = new JButton(PluginServices.getText(this, "browse"));
    btnSelectTemplatesFolder.addActionListener(btnFileChooserAction);
    btnSelectSymbolLibraryFolder = new JButton(PluginServices.getText(this, "browse"));
    btnSelectSymbolLibraryFolder.addActionListener(btnFileChooserAction);

    JLabel lblProjectsFolder =
        new JLabel(
            "<html><b>"
                + PluginServices.getText(this, "options.foldering.projects_folder")
                + "</b></html>");
    addComponent(lblProjectsFolder);
    addComponent(txtProjectsFolder = new JTextField(30), btnSelectProjectsFolder);
    addComponent(new JLabel(" "));

    JLabel lblDataFolder =
        new JLabel(
            "<html><b>"
                + PluginServices.getText(this, "options.foldering.data_folder")
                + "</b></html>");
    addComponent(lblDataFolder);
    addComponent(txtDataFolder = new JTextField(30), btnSelectDataFolder);
    addComponent(new JLabel(" "));

    JLabel lblTemplatesFolder =
        new JLabel(
            "<html><b>"
                + PluginServices.getText(this, "options.foldering.template_folder")
                + "</b></html>");
    addComponent(lblTemplatesFolder);
    addComponent(txtTemplatesFolder = new JTextField(30), btnSelectTemplatesFolder);
    addComponent(new JLabel(" "));

    JLabel lblSymbolLibraryFolder =
        new JLabel(
            "<html><b>"
                + PluginServices.getText(this, "options.foldering.symbol_library_folder")
                + "</b></html>");
    addComponent(lblSymbolLibraryFolder);
    addComponent(txtSymbolLibraryFolder = new JTextField(30), btnSelectSymbolLibraryFolder);
    addComponent(new JLabel(" "));
    PluginServices ps = PluginServices.getPluginServices(this);
    XMLEntity xml = ps.getPersistentXML();

    if (xml.contains(PROJECTS_FOLDER_PROPERTY_NAME)) {
      prefs.put(
          PROJECTS_FOLDER_PROPERTY_NAME, xml.getStringProperty(PROJECTS_FOLDER_PROPERTY_NAME));
    }

    if (xml.contains(DATA_FOLDER_PROPERTY_NAME)) {
      prefs.put(DATA_FOLDER_PROPERTY_NAME, xml.getStringProperty(DATA_FOLDER_PROPERTY_NAME));
    }

    if (xml.contains(TEMPLATES_FOLDER_PROPERTY_NAME)) {
      prefs.put(
          TEMPLATES_FOLDER_PROPERTY_NAME, xml.getStringProperty(TEMPLATES_FOLDER_PROPERTY_NAME));
    }

    if (xml.contains(SYMBOL_LIBRARY_FOLDER_PROPERTY_NAME)) {
      prefs.put(
          SYMBOL_LIBRARY_FOLDER_PROPERTY_NAME,
          xml.getStringProperty(SYMBOL_LIBRARY_FOLDER_PROPERTY_NAME));
    }
  }
  public void setXMLEntity(XMLEntity xml) {
    if (xml.contains("TextField")) {
      setTextField(xml.getStringProperty("TextField"));
    }

    if (xml.contains("HeightField")) {
      setHeightField(xml.getStringProperty("HeightField"));
    }

    if (xml.contains("ColorField")) {
      setColorField(xml.getStringProperty("ColorField"));
    }

    if (xml.contains("RotationField")) {
      setRotationField(xml.getStringProperty("RotationField"));
    }

    if (xml.contains("Unit")) {
      setUnit(xml.getIntProperty("Unit"));
    }

    if (xml.contains("fontName")) {
      Font font =
          new Font(
              xml.getStringProperty("fontName"),
              xml.getIntProperty("fontStyle"),
              xml.getIntProperty("fontSize"));
      setFont(font);
    }
    if (xml.contains("useFixedSize")) {
      useFixedSize = xml.getBooleanProperty("useFixedSize");
      fixedSize = xml.getDoubleProperty("fixedSize");
    }
    if (xml.contains("useFixedColor")) {
      useFixedColor = xml.getBooleanProperty("useFixedColor");
      fixedColor = StringUtilities.string2Color(xml.getStringProperty("fixedColor"));
    }
    if (xml.contains("referenceSystem")) {
      referenceSystem = xml.getIntProperty("referenceSystem");
    }
  }
  public XMLEntity getXMLEntity() {
    XMLEntity xml = new XMLEntity();
    xml.putProperty("className", getClassName());
    xml.putProperty("labelingStrategy", "labelingStrategy");

    try {
      if (getHeightField() != null) {
        xml.putProperty("HeightField", getHeightField());
      }
    } catch (DataException e) {
      Logger.getAnonymousLogger()
          .log(Level.SEVERE, "Acessing TextHeight field.\n" + e.getMessage());
    }

    try {
      if (getColorField() != null) {
        xml.putProperty("ColorField", getColorField());
      }
    } catch (DataException e) {
      Logger.getAnonymousLogger()
          .log(Level.SEVERE, "Acessing ColorField field.\n" + e.getMessage());
    }

    try {
      if (getTextField() != null) {
        xml.putProperty("TextField", getTextField());
      }
    } catch (DataException e) {
      Logger.getAnonymousLogger().log(Level.SEVERE, "Acessing TextField field.\n" + e.getMessage());
    }

    try {
      if (getRotationField() != null) {
        xml.putProperty("RotationField", getRotationField());
      }
    } catch (DataException e) {
      Logger.getAnonymousLogger()
          .log(Level.SEVERE, "Acessing RotationField field.\n" + e.getMessage());
    }

    if (getFont() != null) {
      xml.putProperty("fontSize", getFont().getSize());
      xml.putProperty("fontName", getFont().getName());
      xml.putProperty("fontStyle", getFont().getStyle());
    }
    if (getColorFont() != null) {
      xml.putProperty("Color", StringUtilities.color2String(getColorFont()));
    }
    xml.putProperty("useFixedSize", useFixedSize);
    xml.putProperty("useFixedColor", useFixedColor);
    xml.putProperty("fixedColor", StringUtilities.color2String(fixedColor));
    xml.putProperty("fixedSize", fixedSize);
    xml.putProperty("Unit", unit);
    xml.putProperty("referenceSystem", referenceSystem);
    return xml;
  }
Пример #13
0
  public XMLEntity getXMLEntity() {
    XMLEntity xml = new XMLEntity();
    xml.putProperty("className", getClassName());
    xml.putProperty("isShapeVisible", isShapeVisible());
    // color (necessite)
    if (getFillColor() != null)
      xml.putProperty("color", StringUtilities.color2String(getFillColor()));
    xml.putProperty("desc", getDescription());
    xml.putProperty("referenceSystem", getReferenceSystem());
    xml.putProperty("unit", getUnit());
    xml.addChild(markerSymbol.getXMLEntity());
    xml.addChild(markerFillProperties.getXMLEntity());

    if (getOutline() != null) {
      XMLEntity outlineXML = getOutline().getXMLEntity();
      outlineXML.putProperty("id", "outline symbol");
      xml.addChild(outlineXML);
    }
    xml.putProperty("hasOutline", hasOutline());
    return xml;
  }
Пример #14
0
  /**
   * Save the status of the provided toolbar.
   *
   * @param toolbarName The toolbar name whose status wants to be saved.
   * @param visible Whether or not the toolbar is visible.
   */
  private void persistStatus(String toolbarName, boolean visible) {
    PluginServices ps = PluginServices.getPluginServices(this);
    XMLEntity xml = ps.getPersistentXML();
    XMLEntity child = null;
    for (int i = xml.getChildrenCount() - 1; i >= 0; i--) {
      if (xml.getChild(i).getName().equals("Toolbars")) child = xml.getChild(i).getChild(0);
    }
    if (child == null) {
      XMLEntity toolbars = new XMLEntity();
      toolbars.setName("Toolbars");
      child = new XMLEntity();
      toolbars.addChild(child);
      xml.addChild(toolbars);
    }

    if (visible) {
      child.putProperty(toolbarName, "visible");
    } else {
      child.putProperty(toolbarName, "hidden");
    }
    ps.setPersistentXML(xml);
  }
Пример #15
0
  /**
   * Adds the layer with the information in an XML entity and the specified name, to this collection
   * of layers.
   *
   * <p>This method really executes the addition, considering the kind of layer (<code>FLyrVect
   * </code>, <code>FLyrAnnotation</code>, <code>FLyrRaster</code>, a collection of layers (<code>
   * FLayers</code>), or another kind of layer (<code>FLayer</code>)), and the driver in the layer.
   *
   * @param xml tree-node structure with information about layers
   * @param name name of the layer to add
   * @throws LoadLayerException if fails loading this layer.
   */
  private void addLayerFromXML(XMLEntity xml, String name) throws LoadLayerException {
    FLayer layer = null;

    try {
      if (name == null) {
        name = xml.getName();
      }

      String className = xml.getStringProperty("className");
      Class clase = Class.forName(className);
      layer = (FLayer) clase.newInstance();
      if (FLayers.class.isAssignableFrom(clase)) {
        ((FLayers) layer).setMapContext(getMapContext());
        ((FLayers) layer).setParentLayer(this);
        //			layer = new FLayers(getMapContext(),this);
        layer.setXMLEntity(xml);
      } else {
        // Capas Nuevas (externas)
        layer.setName(name);
        layer.setXMLEntity(xml);
        layer.load();
      }

      //		//TODO VCN FLyrAnnotation es un parche para no tener que duplicar todo el código de aqí y
      // de los diferentes métodos de LayerFactory,
      //		//ya que los drivers de una FLyrAnnotation no sabemos cual es puede ser cualquier Driver
      // Vectorial.
      //		if (className.equals(FLyrVect.class.getName())){// ||
      // className.equals(FLyrAnnotation.class.getName())) {
      //			String type = xml.getStringProperty("type");
      //			if ("vectorial".equals(type)){
      //				//String recordsetName = xml.getChild(i).getStringProperty("recordset-name");
      //				IProjection proj = null;
      //				if (xml.contains("proj")) {
      //					proj = CRSFactory.getCRS(xml.getStringProperty("proj"));
      //				}
      //				else
      //				{
      //					proj = this.getMapContext().getViewPort().getProjection();
      //				}
      //				if (xml.contains("file")) {
      //					Driver d;
      //					try {
      //						d = LayerFactory.getDM().getDriver(xml.getStringProperty("driverName"));
      //					} catch (DriverLoadException e1) {
      //						throw new DriverLayerException(name,e1);
      //					}
      //					layer = LayerFactory.createLayer(name, (VectorialFileDriver) d,
      //							new File(xml.getStringProperty("file")),
      //							proj);
      //
      //
      //				}
      //				if (xml.contains("db")) {
      //
      //					String driverName = xml.getStringProperty("db");
      //					IVectorialDatabaseDriver driver;
      //					try {
      //						driver = (IVectorialDatabaseDriver) LayerFactory.getDM().getDriver(driverName);
      //						//Hay que separar la carga de los datos del XMLEntity del load.
      //						driver.setXMLEntity(xml.getChild(2));
      //
      //						boolean loadOk = false;
      //						((DefaultJDBCDriver)driver).load();
      //						if (((DefaultJDBCDriver)driver).getConnection() != null) {
      //							loadOk = true;
      //						}
      //						layer = LayerFactory.createDBLayer(driver, name, proj);
      //						if (!loadOk) {
      //							layer.setAvailable(false);
      //						}
      //
      //					} catch (DriverLoadException e) {
      //						throw new DriverLayerException(name,e);
      //					} catch (XMLException e) {
      //						throw new DriverLayerException(name,e);
      //					} catch (ReadException e) {
      //						throw new DriverLayerException(name,e);
      //					}
      //
      //				}
      //				// Clases con algun driver genérico creado por otro
      //				// programador
      //				if (xml.contains("other")) {
      //
      //					String driverName = xml.getStringProperty("other");
      //					VectorialDriver driver = null;
      //					try {
      //						driver = (VectorialDriver) LayerFactory.getDM().getDriver(driverName);
      //					} catch (DriverLoadException e) {
      //						// Si no existe ese driver, no pasa nada.
      //						// Puede que el desarrollador no quiera que
      //						// aparezca en el cuadro de diálogo y ha metido
      //						// el jar con sus clases en nuestro directorio lib.
      //						// Intentamos cargar esa clase "a pelo".
      //						if (xml.getChild(2).contains("className"))
      //						{
      //							String className2 = xml.getChild(2).getStringProperty("className");
      //							try {
      //								driver = (VectorialDriver) Class.forName(className2).newInstance();
      //							} catch (Exception e1) {
      //								throw new DriverLayerException(name,e);
      //							}
      //						}
      //					} catch (NullPointerException npe) {
      //						// Si no existe ese driver, no pasa nada.
      //						// Puede que el desarrollador no quiera que
      //						// aparezca en el cuadro de diálogo y ha metido
      //						// el jar con sus clases en nuestro directorio lib.
      //						// Intentamos cargar esa clase "a pelo".
      //						if (xml.getChild(2).contains("className"))
      //						{
      //							String className2 = xml.getChild(2).getStringProperty("className");
      //							try {
      //								driver = (VectorialDriver) Class.forName(className2).newInstance();
      //							} catch (Exception e1) {
      //								throw new DriverLayerException(name,e1);
      //							}
      //						}
      //					}
      //					if (driver instanceof IPersistence)
      //					{
      //						IPersistence persist = (IPersistence) driver;
      //						persist.setXMLEntity(xml.getChild(2));
      //					}
      //					layer = LayerFactory.createLayer(name, driver, proj);
      //				}
      //
      //			}
      //
      //			//TODO VCN FLyrAnnotation es un parche para no tener que duplicar todo el código de aqí y
      // de los diferentes métodos de LayerFactory,
      //			//ya que los drivers de una FLyrAnnotation no sabemos cual es puede ser cualquier Driver
      // Vectorial.
      //			if (className.equals(FLyrAnnotation.class.getName())){
      //				layer=FLyrAnnotation.createLayerFromVect((FLyrVect)layer);
      //			}
      //
      //
      //			layer.setXMLEntity(xml);
      //
      //		} else {
      //			Class clase = LayerFactory.getLayerClassForLayerClassName(className);
      //			layer = (FLayer) clase.newInstance();
      //			if (clase.isAssignableFrom(FLayers.class)) {
      //				((FLayers)layer).setMapContext(getMapContext());
      //				((FLayers)layer).setParentLayer(this);
      ////				layer = new FLayers(getMapContext(),this);
      //				layer.setXMLEntity(xml);
      //			} else {
      //				// Capas Nuevas (externas)
      //				layer.setName(name);
      //				layer.setXMLEntity(xml);
      //				layer.load();
      //			}
      //		}
      this.addLayer(layer);
      logger.debug("layer: " + layer.getName() + " loaded");
      // Comprobar que la proyección es la misma que la de FMap
      // Si no lo es, es una capa que está reproyectada al vuelo
      IProjection proj = layer.getProjection();
      if ((proj != null)) {
        if (!proj.getFullCode().equals(getMapContext().getProjection().getFullCode())) {
          ICoordTrans ct = proj.getCT(getMapContext().getProjection());
          // TODO: REVISAR CON LUIS
          // Se lo fijamos a todas, luego cada una que se reproyecte
          // si puede, o que no haga nada

          layer.setCoordTrans(ct);
        }
      }
    } catch (XMLException e) {
      fmap.addLayerError(xml.getStringProperty("name"));
      throw new LoadLayerException(name, e);
    } catch (ClassNotFoundException e) {
      fmap.addLayerError(xml.getStringProperty("name"));
      throw new LoadLayerException(name, e);
    } catch (InstantiationException e) {
      fmap.addLayerError(xml.getStringProperty("name"));
      throw new LoadLayerException(name, e);
    } catch (IllegalAccessException e) {
      fmap.addLayerError(xml.getStringProperty("name"));
      throw new LoadLayerException(name, e);
    } catch (LoadLayerException e) {
      fmap.addLayerError(xml.getStringProperty("name"));
      throw e;
    }
  }