Ejemplo n.º 1
0
 public void execute(String actionCommand) {
   IProjectView model = vista.getModel();
   MapContext mapa = model.getMapContext();
   logger.debug("Comand : " + actionCommand);
   if (actionCommand.equals("INVERT_SELECTION")) {
     FLayer[] actives = mapa.getLayers().getActives();
     for (int i = 0; i < actives.length; i++) {
       FLayer lyr = actives[i];
       if (lyr.isAvailable() && lyr instanceof SingleLayer) {
         SingleLayer lyrSingle = (SingleLayer) lyr;
         DataStore ds = lyrSingle.getDataStore();
         if (ds instanceof FeatureStore) {
           try {
             ((FeatureStore) ds).getFeatureSelection().reverse();
             ((ProjectDocument) vista.getModel()).setModified(true);
           } catch (DataException e) {
             e.printStackTrace();
             NotificationManager.addError(e);
           }
         } else {
           // TODO Not supported yet
         }
       }
     }
     ((ProjectDocument) vista.getModel()).setModified(true);
   }
 }
Ejemplo n.º 2
0
  public boolean isVisible() {
    IWindow f = PluginServices.getMDIManager().getActiveWindow();

    if (f != null && f instanceof View) {
      vista = (View) f;
      IProjectView model = vista.getModel();
      MapContext mapa = model.getMapContext();

      return hasVectorLayers(mapa.getLayers());
    }
    return false;
  }
Ejemplo n.º 3
0
  public boolean isEnabled() {
    IProjectView model = vista.getModel();
    MapContext mapa = model.getMapContext();

    for (int i = 0; i < mapa.getLayers().getActives().length; i++) {
      FLayer lyr = mapa.getLayers().getActives()[i];
      if (lyr.isAvailable() && lyr instanceof FLyrVect) { // && !lyr.isEditing()) {
        return true;
      }
    }
    return false;
  }
Ejemplo n.º 4
0
  /**
   * Replace a layer identified by its name, by another.
   *
   * @param layerName the name of the layer to be replaced
   * @param layer the new layer
   */
  public void replaceLayer(String layerName, FLayer layer) throws LoadLayerException {
    FLayer lyr;
    FLayer parent;
    for (int i = 0; i < layers.size(); i++) {
      lyr = ((FLayer) layers.get(i));

      if (lyr.getName().compareToIgnoreCase(layerName) == 0) {
        parent = lyr.getParentLayer();
        removeLayer(i);
        if (parent != null) {
          // Notificamos a la capa que va a ser añadida
          if (layer instanceof FLyrDefault) {
            ((FLyrDefault) layer).wakeUp();
          }
        }

        if (layer instanceof FLayers) {
          FLayers layers = (FLayers) layer;
          fmap.addAsCollectionListener(layers);
        }
        callLayerAdding(LayerCollectionEvent.createLayerAddingEvent(layer));

        layers.add(i, layer);
        layer.setParentLayer(this);

        callLayerAdded(LayerCollectionEvent.createLayerAddedEvent(layer));
        break;
      }
    }
  }
Ejemplo n.º 5
0
 /**
  * Constructor
  *
  * @param vista vista actual de la aplicacion.
  */
 public PrincipalComponentPanel(View vista) {
   super(ButtonsPanel.BUTTONS_ACCEPTCANCEL);
   view = vista;
   m_MapContext = vista.getModel().getMapContext();
   layers = m_MapContext.getLayers();
   Inicializar();
 }
Ejemplo n.º 6
0
 /**
  * Adds a layer on an specified position in this node.
  *
  * @param pos position in the inner list where the layer will be added
  * @param layer a layer
  */
 private void doAddLayer(int pos, FLayer layer) {
   layers.add(pos, layer);
   layer.setParentLayer(this);
   IProjection layerProj = layer.getProjection();
   if (layerProj != null && fmap != null) {
     IProjection mapContextProj = fmap.getProjection();
     // TODO REVISAR ESTO !!!!
     // Esta condición puede que no fuese exacta para todos los casos
     if (!layerProj.getAbrev().equals(mapContextProj.getAbrev())) {
       ICoordTrans ct = layerProj.getCT(mapContextProj);
       layer.setCoordTrans(ct);
     } else {
       layer.setCoordTrans(null);
     }
   }
   this.updateDrawVersion();
 }
Ejemplo n.º 7
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");
    }
  }
Ejemplo n.º 8
0
  /**
   * Adds a layer in an specified position in this node.
   *
   * @param layer a layer
   */
  public void addLayer(int pos, FLayer layer) {
    try {
      // Notificamos a la capa que va a ser añadida
      if (layer instanceof FLyrDefault) {
        ((FLyrDefault) layer).wakeUp();
      }

      if (layer instanceof FLayers) {
        FLayers layers = (FLayers) layer;
        fmap.addAsCollectionListener(layers);
      }
      callLayerAdding(LayerCollectionEvent.createLayerAddingEvent(layer));

      doAddLayer(pos, layer);

      callLayerAdded(LayerCollectionEvent.createLayerAddedEvent(layer));
    } catch (CancelationException e) {
      logger.warn(e.getMessage());
    } catch (LoadLayerException e) {
      layer.setAvailable(false);
      layer.addError(e);
    }
  }
  public void draw(
      BufferedImage image, Graphics2D g, ViewPort viewPort, Cancellable cancel, double dpi)
      throws ReadException {
    double scale = viewPort.getScale();
    //		double fontScaleFactor = FConstant.FONT_HEIGHT_SCALE_FACTOR;

    SimpleTextSymbol sym = new SimpleTextSymbol();

    sym.setFont(getFont());

    sym.setUnit(unit);
    sym.setReferenceSystem(referenceSystem);
    if (zoom == null
        || (zoom.isUserDefined()
            && (scale >= zoom.getMaxScale())
            && (scale <= zoom.getMinScale()))) {
      FeatureSet set = null;
      DisposableIterator iterator = null;
      try {
        // limit the labeling to the visible extent
        ArrayList fields = new ArrayList();
        int heightPos = -1;
        int rotationPos = -1;
        int textPos = -1;
        int colorPos = -1;
        int geomPos = -1;

        if (!this.usesFixedSize()) {
          if (getHeightField() != null) {
            heightPos = fields.size();
            fields.add(getHeightField());
          }
        }
        if (getRotationField() != null) {
          rotationPos = fields.size();
          fields.add(getRotationField());
        }
        if (getTextField() != null) {
          textPos = fields.size();
          fields.add(getTextField());
        }

        if (!this.usesFixedColor() && getColorField() != null) {
          colorPos = fields.size();
          fields.add(getColorField());
        }

        FeatureStore featureStore = layer.getFeatureStore();

        geomPos = fields.size();
        String geomName = featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName();
        fields.add(geomName);

        FeatureQuery featureQuery = featureStore.createFeatureQuery();

        featureQuery.setAttributeNames((String[]) fields.toArray(new String[fields.size()]));
        // TODO no set filter y layer is contained totaly in viewPort
        ContainsEnvelopeEvaluator iee =
            new ContainsEnvelopeEvaluator(
                viewPort.getAdjustedExtent(),
                viewPort.getProjection(),
                featureStore.getDefaultFeatureType(),
                geomName);
        featureQuery.setFilter(iee);

        set = featureStore.getFeatureSet(featureQuery);

        //				ReadableVectorial source = layer.getSource();
        //				SelectableDataSource recordSet = source.getRecordset();
        iterator = set.fastIterator();
        CreateLabelsOperationContext cloc = new CreateLabelsOperationContext();
        cloc.setDublicates(true);
        cloc.setPosition(0);
        while (iterator.hasNext()) {
          if (cancel.isCanceled()) {
            return;
          }
          Feature feature = (Feature) iterator.next();
          //				for(int i=bs.nextSetBit(0); i>=0 && !cancel.isCanceled(); i=bs.nextSetBit(i+1)) {
          //					Value[] vv = recordSet.getRow(i);
          double size;
          Color color = null;
          if (useFixedSize) {
            // uses fixed size
            size = fixedSize; // * fontScaleFactor;
            //					} else if (idHeightField != -1) {
          } else if (heightFieldName != null) {
            // text size is defined in the table
            try {
              //							Object obj=feature.get(idHeightField);
              Object obj = feature.get(heightPos);
              if (obj != null) {
                size = ((Number) obj).doubleValue(); // * fontScaleFactor;
              } else {
                size = 0;
              }
            } catch (ClassCastException ccEx) {
              //							if (!NullValue.class.equals(feature.get(idHeightField).getClass())) {
              if (!NullValue.class.equals(feature.get(heightPos).getClass())) {

                throw new ReadException("Unknown", ccEx);
              }
              // a null value
              //							Logger.getAnonymousLogger().
              //								warning("Null text height value for text
              // '"+feature.get(idTextField).toString()+"'");
              Logger.getAnonymousLogger()
                  .warning(
                      "Null text height value for text '" + feature.get(textPos).toString() + "'");

              continue;
            }
          } else {
            // otherwise will use the size in the symbol
            size = sym.getFont().getSize();
          }

          size =
              CartographicSupportToolkit.getCartographicLength(
                  this, size, viewPort, MapContext.getScreenDPI());
          //													  dpi);
          //								toScreenUnitYAxis(this,
          //												  size,
          //												  viewPort
          //												 );

          if (size <= MIN_TEXT_SIZE) {
            // label is too small to be readable, will be skipped
            // this speeds up the rendering in wider zooms
            continue;
          }

          sym.setFontSize(size);

          if (useFixedColor) {
            color = fixedColor;
            //					} else if (idColorField != -1) {
          } else if (colorFieldName != null) {
            // text size is defined in the table
            try {
              //							color = new Color(feature.getInt(idColorField));
              color = new Color(feature.getInt(colorPos));
            } catch (ClassCastException ccEx) {
              //							if (feature.get(idColorField) != null) {
              if (feature.get(colorPos) != null) {
                throw new ReadException("Unknown", ccEx);
              }
              // a null value
              //							Logger.getAnonymousLogger().
              //								warning(
              //									"Null color value for text '"
              //											+ feature.getString(idTextField)
              //											+ "'");
              Logger.getAnonymousLogger()
                  .warning("Null color value for text '" + feature.getString(textFieldName) + "'");

              continue;
            }
          } else {
            color = sym.getTextColor();
          }

          sym.setTextColor(color);

          double rotation = 0D;
          //					if (idRotationField!= -1) {
          if (rotationFieldName != null) {
            // text rotation is defined in the table
            //						rotation = -Math.toRadians(((Number)
            // feature.get(idRotationField)).doubleValue());
            rotation = -Math.toRadians(((Number) feature.get(rotationPos)).doubleValue());
          }

          Geometry geom = feature.getDefaultGeometry();
          //					Object obj=feature.get(idTextField);
          Object obj = feature.get(textPos);
          if (obj != null) {
            sym.setText(obj.toString());
          }
          sym.setRotation(rotation);

          FLabel[] aux = (FLabel[]) geom.invokeOperation(CreateLabels.CODE, cloc);
          //					FLabel[] aux = geom.createLabels(0, true);
          for (int j = 0; j < aux.length; j++) {
            Point p =
                geomManager.createPoint(
                    aux[j].getOrig().getX(), aux[j].getOrig().getY(), SUBTYPES.GEOM2D);
            p.transform(viewPort.getAffineTransform());
            if (properties == null) {
              sym.draw(g, null, p, cancel);
            } else {
              sym.print(g, null, p, properties);
            }
          }
        }

      } catch (GeometryOperationNotSupportedException e) {
        throw new ReadException("Could not draw annotation in the layer.", e);
      } catch (GeometryOperationException e) {
        throw new ReadException("Could not draw annotation in the layer.", e);
      } catch (BaseException e) {
        throw new ReadException("Could not draw annotation in the layer.", e);
      } finally {
        if (iterator != null) {
          iterator.dispose();
        }
        if (set != null) {
          set.dispose();
        }
      }
    }
  }
Ejemplo n.º 10
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;
    }
  }
Ejemplo n.º 11
0
  /**
   * Checks all layers (each one as a sub-node of this node <i>collection of layers</i>) of this
   * collection and draws their requested properties. If a node is a group of layers (<code>
   * ComposedLayer</code>), executes it's drawn.
   *
   * <p>All nodes which could group with the composed layer <code>group</code>, will be drawn
   * together. And once the <code>
   * group</code> is drawn, will be set to <code>null</code> if hasn't a parent layer.
   *
   * <p>The particular implementation depends on the kind of each layer and composed layer. And this
   * process can be cancelled at any time by the shared object <code>cancel</code>.
   *
   * <p>According the print quality, labels will be printed in different resolution:
   *
   * <ul>
   *   <li><b>PrintQuality.DRAFT</b>: 72 dpi (dots per inch).
   *   <li><b>PrintQuality.NORMAL</b>: 300 dpi (dots per inch).
   *   <li><b>PrintQuality.HIGH</b>: 600 dpi (dots per inch).
   * </ul>
   *
   * @param g for rendering 2-dimensional shapes, text and images on the Java(tm) platform
   * @param viewPort the information for drawing the layers
   * @param cancel shared object that determines if this layer can continue being drawn
   * @param scale the scale of the view. Must be between {@linkplain FLayer#getMinScale()} and
   *     {@linkplain FLayer#getMaxScale()}.
   * @param properties properties that will be print
   * @param group a composed layer pending to paint; if this parameter is <code>null</code>, the
   *     composed layer
   * @return <code>null</code> if the layers in <code>group</code> had been drawn or were <code>null
   *     </code>; otherwise, the <code>group</code>
   * @see FLayer#print(Graphics2D, ViewPort, Cancellable, double, PrintAttributes)
   * @throws ReadDriverException if fails the driver reading the data.
   */
  public ComposedLayer print_old(
      Graphics2D g,
      ViewPort viewPort,
      Cancellable cancel,
      double scale,
      PrintAttributes properties,
      ComposedLayer group)
      throws ReadException {
    double dpi = 72;

    int resolution = properties.getPrintQuality();
    if (resolution == PrintAttributes.PRINT_QUALITY_NORMAL) {
      dpi = 300;
    } else if (resolution == PrintAttributes.PRINT_QUALITY_HIGH) {
      dpi = 600;
    } else if (resolution == PrintAttributes.PRINT_QUALITY_DRAFT) {
      dpi = 72;
    }

    // TODO: A la hora de imprimir, isWithinScale falla, porque está
    // calculando la escala en pantalla, no para el layout.
    // Revisar esto.

    // TODO: We have to check when we have to call the drawLabels method when exists a ComposedLayer
    // group.
    for (int i = 0; i < layers.size(); i++) {
      FLayer lyr = (FLayer) layers.get(i);
      if (!lyr.isVisible() || !lyr.isWithinScale(scale)) {
        continue;
      }

      try {

        ///// CHEMA ComposedLayer
        // Checks for draw group (ComposedLayer)
        if (group != null) {
          if (lyr instanceof FLayers) {
            group = ((FLayers) lyr).print_old(g, viewPort, cancel, scale, properties, group);
          } else {
            // If layer can be added to the group, does it
            if (lyr instanceof ILabelable
                && ((ILabelable) lyr).isLabeled()
                && ((ILabelable) lyr).getLabelingStrategy() != null
                && ((ILabelable) lyr).getLabelingStrategy().shouldDrawLabels(scale)) {
              group.add(lyr);
            } else {
              // draw the 'pending to draw' layer group
              group.print(g, viewPort, cancel, scale, properties);

              // gets a new group instance
              if (lyr instanceof ILabelable
                  && ((ILabelable) lyr).isLabeled()
                  && ((ILabelable) lyr).getLabelingStrategy() != null
                  && ((ILabelable) lyr).getLabelingStrategy().shouldDrawLabels(scale)) {
                group = lyr.newComposedLayer();
              } else {
                group = null;
              }
              // if layer hasn't group, draws it inmediately
              if (group == null) {
                if (lyr instanceof FLayers) {
                  group = ((FLayers) lyr).print_old(g, viewPort, cancel, scale, properties, group);
                } else {
                  lyr.print(g, viewPort, cancel, scale, properties);
                  if (lyr instanceof ILabelable
                      && ((ILabelable) lyr).isLabeled()
                      && ((ILabelable) lyr).getLabelingStrategy() != null
                      && ((ILabelable) lyr).getLabelingStrategy().shouldDrawLabels(scale)) {
                    ILabelable lLayer = (ILabelable) lyr;
                    lLayer.drawLabels(null, g, viewPort, cancel, scale, dpi);
                  }
                }
              } else {
                // add the layer to the group
                group.setMapContext(fmap);
                group.add(lyr);
              }
            }
          }
        } else {
          // gets a new group instance
          group = lyr.newComposedLayer();
          // if layer hasn't group, draws it inmediately
          if (group == null) {
            if (lyr instanceof FLayers) {
              group = ((FLayers) lyr).print_old(g, viewPort, cancel, scale, properties, group);
            } else {
              lyr.print(g, viewPort, cancel, scale, properties);
              if (lyr instanceof ILabelable && ((ILabelable) lyr).isLabeled()) {
                ILabelable lLayer = (ILabelable) lyr;

                lLayer.drawLabels(null, g, viewPort, cancel, scale, dpi);
              }
            }
          } else {
            // add the layer to the group
            group.setMapContext(fmap);
            group.add(lyr);
          }
        }
        ///// CHEMA ComposedLayer

      } catch (Exception e) {
        String mesg =
            Messages.getString("error_printing_layer")
                + " "
                + lyr.getName()
                + ": "
                + e.getMessage();
        fmap.addLayerError(mesg);
        logger.error(mesg, e);
      }
    }

    ///// CHEMA ComposedLayer
    if (group != null && this.getParentLayer() == null) {
      // si tenemos un grupo pendiente de pintar, pintamos
      group.print(g, viewPort, cancel, scale, properties);
      group = null;
    }
    ///// CHEMA ComposedLayer

    //		if (getVirtualLayers() != null) {
    //			getVirtualLayers().print( g, viewPort, cancel, scale, properties);
    //		}

    ///// CHEMA ComposedLayer
    return group;
    ///// CHEMA ComposedLayer
  }
Ejemplo n.º 12
0
 public void endDraw(Graphics2D g, ViewPort viewPort) {
   LayerDrawEvent afterEvent =
       new LayerDrawEvent(this, g, viewPort, LayerDrawEvent.LAYER_AFTER_DRAW);
   fmap.fireLayerDrawingEvent(afterEvent);
 }
Ejemplo n.º 13
0
 public void beginDraw(Graphics2D g, ViewPort viewPort) {
   LayerDrawEvent beforeEvent =
       new LayerDrawEvent(this, g, viewPort, LayerDrawEvent.LAYER_BEFORE_DRAW);
   fmap.fireLayerDrawingEvent(beforeEvent);
 }