java.lang.Object
org.gvsig.app.project.documents.layout.fframes.FFrame
org.gvsig.app.project.documents.layout.fframes.FFrameView
All Implemented Interfaces:
Cloneable, IFFrame, IFFrameUseFMap, IFFrameUseProject, LayoutPanelListener, org.gvsig.fmap.mapcontext.rendering.symbols.IPrintable, org.gvsig.tools.dispose.Disposable, org.gvsig.tools.lang.Cloneable, org.gvsig.tools.observer.Observable, org.gvsig.tools.persistence.Persistent
Direct Known Subclasses:
FFrameOverView

public class FFrameView extends FFrame implements IFFrameUseProject, IFFrameUseFMap, LayoutPanelListener
FFrame used for embedding a View in the Layout. The View is not actually inserted on the Layout, but it is used together with the MapContext in order do draw an image which is then painted on the FFrame. Therefore, no MapControl is used in current implementation, but a similar behavior is simulated by the FFrameView. The original MapContext is cloned when assigned to the FFrameView, which is then used for drawing. The FFrameView and the associated View can be synchronized, depending on the values of getTypeScale() and getLinked(). The main synchronization logic is kept on two internal classes: FFrameView.OwnMapContextListener and FFrameView.ViewDocListener. The first one listens for events on the FFrameView and synchronizes the View accordingly. The second one listens for events on the View and synchronizes the FFrameView accordingly. There synchronization process is flagged using b_updating and b_updating, in order to avoid incurring on infinite synchronization loops.
  • Field Details

    • PERSISTENCE_DEFINITION_NAME

      public static final String PERSISTENCE_DEFINITION_NAME
      See Also:
    • PRESENTATION

      public static final int PRESENTATION
      See Also:
    • DRAFT

      public static final int DRAFT
      See Also:
    • syncLayers

      protected boolean syncLayers
    • syncExtents

      protected boolean syncExtents
    • quality

      protected int quality
    • viewDocument

      protected org.gvsig.app.project.documents.view.ViewDocument viewDocument
    • mapContext

      protected org.gvsig.fmap.mapcontext.MapContext mapContext
    • mapUnits

      protected int mapUnits
    • m_image

      protected BufferedImage m_image
    • mapAT

      protected AffineTransform mapAT
    • project

      protected org.gvsig.app.project.Project project
    • scaleAnt

      protected double scaleAnt
    • origin

      protected Point origin
    • p1

      protected Point2D p1
    • p2

      protected Point2D p2
    • grid

      protected IFFrame grid
    • showGrid

      protected boolean showGrid
    • b_validCache

      protected boolean b_validCache
    • b_drawing

      protected boolean b_drawing
    • geomManager

      protected static final org.gvsig.fmap.geom.GeometryManager geomManager
    • originalGraphicsAT

      protected AffineTransform originalGraphicsAT
    • originalClip

      protected Rectangle originalClip
  • Constructor Details

    • FFrameView

      public FFrameView()
      Creates a new FFrameView object.
  • Method Details

    • toString

      public String toString()
      Returns a description of the FFrame
      Overrides:
      toString in class Object
      Returns:
      Description.
    • setScale

      public void setScale(double d)
      Sets the scale of the MapContext contained in this FFrameView
      Specified by:
      setScale in interface IFFrameUseFMap
      Parameters:
      d - Scale to be set
    • setNewEnvelope

      public void setNewEnvelope(org.gvsig.fmap.geom.primitive.Envelope r)
      Sets a new Envelope on the MapContext contained in this FFrameView
      Specified by:
      setNewEnvelope in interface IFFrameUseFMap
      Parameters:
      r - Envelope to be set
    • getDrawPaperDPI

      protected double getDrawPaperDPI()
      Calculates the resolution (measured on dots per inch, DPI) to be considered to draw the FFrameView on screen. It is calculated by dividing the width (in pixels) of the FFrame divided by the width in inches of the paper.
      Returns:
    • getMapContext

      public org.gvsig.fmap.mapcontext.MapContext getMapContext()
      Returns the MapContext contained in this FFrameView, which is usually a clone of the associated View. This MapContext may be synchronized with the View one, depending on the scale type that has been set (see {getTypeScale().
      Specified by:
      getMapContext in interface IFFrameUseFMap
      Returns:
      The mapContext object
    • setQuality

      public void setQuality(int q)
      Sets the quality of the visualization of the FFrame on screen. Valid values include DRAFT and PRESENTATION. Draft will disable the frame normal drawing, which will be replaced by an empty rectangle only showing the name of the frame.
      Parameters:
      q - Integer representing the quality.
    • getQuality

      public int getQuality()
      Gets the quality of the visualization of the FFrame on screen. Valid values include DRAFT and PRESENTATION. Draft will disable the frame normal drawing, which will be replaced by an empty rectangle only showing the name of the frame.
      Returns:
    • setViewMapContext

      public void setViewMapContext(org.gvsig.fmap.mapcontext.MapContext viewMapContext)
      Sets the MapContext associated with this FFrameView, which will be used to clone the layers and synchronize the FFrameView with the associated View
      Parameters:
      viewMapContext -
    • setView

      public void setView(org.gvsig.app.project.documents.view.ViewDocument viewDocument)
      Sets the View associated with this FFrameView, which will be used to clone the MapContext and the layers. It will also used to synchronize the FFrameView with the associated View, depending on the selected scale type
      Parameters:
      viewDocument -
    • getView

      public org.gvsig.app.project.documents.view.ViewDocument getView()
      Gets the associated View
      Returns:
      The associated view
    • draw

      public void draw(Graphics2D g, AffineTransform at, Rectangle2D visibleLayoutDocRect, BufferedImage imgBase)
      Draws the FFrameView on the provided Graphics, according to the provided affine transform and the visible rectangle.
      Specified by:
      draw in interface IFFrame
      Specified by:
      draw in class FFrame
      Parameters:
      g - Graphics2D
      at - Affine transform to translate sheet coordinates (in cm) to screen coordinates (in pixels)
      visibleLayoutDocRect - visible rectangle
      imgBase - Image used to speed up the drawing process
    • getVisibleEnvelope

      protected org.gvsig.fmap.geom.primitive.Envelope getVisibleEnvelope(Rectangle2D.Double fframeViewRect, Rectangle2D.Double visiblefframeViewRect)
      Gets the visible envelope, in map coordinates
      Parameters:
      fframeViewRect - Rectangle defining the bounding box of the FFrameView, in screen coordinates
      visiblefframeViewRect - Rectangle defining the bounding box of the visible area of the fframeView, in screen coordinates
      Returns:
    • drawPresentation

      protected void drawPresentation(Graphics2D g, AffineTransform affineTransform, Rectangle2D.Double fframeViewRect, Rectangle2D.Double visibleRect, BufferedImage imgBase) throws Exception
      Throws:
      Exception
    • createImage

      protected void createImage(AffineTransform affineTransform, int width, int height, Point mapOrigin) throws org.gvsig.fmap.dal.exception.ReadException, org.gvsig.fmap.mapcontext.MapContextException
      Throws:
      org.gvsig.fmap.dal.exception.ReadException
      org.gvsig.fmap.mapcontext.MapContextException
    • drawImage

      protected void drawImage(Graphics2D g, BufferedImage image, Rectangle2D.Double visibleRectangle)
    • preDraw

      protected void preDraw(Graphics2D g, Rectangle2D.Double fframeViewRect, Rectangle2D.Double visibleRect)
    • postDraw

      protected void postDraw(Graphics2D g, Rectangle2D.Double fframeViewRect, AffineTransform at)
    • postDraw

      @Deprecated protected void postDraw(Graphics2D g, Rectangle2D.Double rectangleLayout, Rectangle2D rectangleView, BufferedImage imgBase, Rectangle originalClip, AffineTransform at)
      Parameters:
      g -
      rectangleLayout -
      rectangleView -
      imgBase -
      originalClip -
      at -
    • preDraw

      @Deprecated protected Rectangle preDraw(Graphics2D g, Rectangle2D.Double rectangleLayout)
      Deprecated.
      Parameters:
      g -
      rectangleLayout -
      Returns:
    • print

      public void print(Graphics2D g, AffineTransform at, org.gvsig.fmap.geom.Geometry geom, org.gvsig.compat.print.PrintAttributes printAttributes)
      Specified by:
      print in interface org.gvsig.fmap.mapcontext.rendering.symbols.IPrintable
    • print

      protected void print(Graphics2D g, AffineTransform at, org.gvsig.compat.print.PrintAttributes printAttributes)
    • setMapUnits

      public void setMapUnits(int i)
      Rellena la unidad de medida en la que está la vista.
      Parameters:
      i - entero que representa la unidad de medida de la vista.
    • getMapUnits

      public int getMapUnits()
      Obtiene la unidad de medida en la que está la vista.
      Returns:
      Unidad de medida.
    • getScale

      public double getScale()
      Devuelve la escala según el tipo de escala que se haya seleccionado al añadida la vista.
      Returns:
      escala.
    • setBufferedImage

      public void setBufferedImage(BufferedImage bi)
      Inserta la imagen para repintar el FFrameView.
      Parameters:
      bi - Imagen para repintar.
    • getBufferedImage

      public BufferedImage getBufferedImage()
      Devuelve la imagen para repintar.
      Specified by:
      getBufferedImage in interface IFFrameUseFMap
      Returns:
      Imagen para repintar.
    • getATMap

      public AffineTransform getATMap()
      Devuelve la MAtriz de transformación utilizada por la FFrameView.
      Specified by:
      getATMap in interface IFFrameUseFMap
      Returns:
      MAtriz de transformación.
    • setATMap

      public void setATMap(AffineTransform transform)
      Inserta la matriz de transformación.
      Specified by:
      setATMap in interface IFFrameUseFMap
      Parameters:
      transform - Matriz de transformación.
    • setProject

      public void setProject(org.gvsig.app.project.Project p)
      Inserta el proyecto.
      Specified by:
      setProject in interface IFFrameUseProject
      Parameters:
      p - Proyecto.
    • getNameFFrame

      public String getNameFFrame()
      Description copied from interface: IFFrame
      Devuelve el nombre que representa al tipo de FFrame.
      Specified by:
      getNameFFrame in interface IFFrame
      Returns:
      nombre del elemento.
      See Also:
    • getName

      public String getName()
      Description copied from interface: IFFrame
      Devuelve el nombre que representa al fframe.
      Specified by:
      getName in interface IFFrame
      Returns:
      String nombre del FFrame.
    • compare

      public boolean compare(Object arg0)
    • updateScaleCtrl

      public void updateScaleCtrl()
    • fullExtent

      public void fullExtent() throws org.gvsig.fmap.dal.exception.ReadException
      Description copied from interface: IFFrameUseFMap
      Zooms to the extent containing all the layers loaded in the map.
      Specified by:
      fullExtent in interface IFFrameUseFMap
      Throws:
      org.gvsig.fmap.dal.exception.ReadException
    • setPointsToZoom

      public void setPointsToZoom(Point2D px1, Point2D px2)
      Specified by:
      setPointsToZoom in interface IFFrameUseFMap
    • movePoints

      public void movePoints(Point2D px1, Point2D px2)
      Specified by:
      movePoints in interface IFFrameUseFMap
    • clone

      public FFrameView clone() throws CloneNotSupportedException
      Specified by:
      clone in interface org.gvsig.tools.lang.Cloneable
      Overrides:
      clone in class FFrame
      Throws:
      CloneNotSupportedException
    • setGrid

      public void setGrid(IFFrame grid)
    • getGrid

      public IFFrame getGrid()
    • setRotation

      public void setRotation(double rotation)
      Description copied from class: FFrame
      Sets the rotation of the frame, measured in arc degrees
      Specified by:
      setRotation in interface IFFrame
      Overrides:
      setRotation in class FFrame
      Parameters:
      rotation - Rotation to apply to the frame
    • showGrid

      public void showGrid(boolean b)
    • isShowGrid

      public boolean isShowGrid()
    • refreshOriginalExtent

      public void refreshOriginalExtent()
      Specified by:
      refreshOriginalExtent in interface IFFrameUseFMap
    • registerPersistent

      public static void registerPersistent()
    • loadFromState

      public void loadFromState(org.gvsig.tools.persistence.PersistentState state) throws org.gvsig.tools.persistence.exception.PersistenceException
      Specified by:
      loadFromState in interface org.gvsig.tools.persistence.Persistent
      Overrides:
      loadFromState in class FFrame
      Throws:
      org.gvsig.tools.persistence.exception.PersistenceException
    • saveToState

      public void saveToState(org.gvsig.tools.persistence.PersistentState state) throws org.gvsig.tools.persistence.exception.PersistenceException
      Specified by:
      saveToState in interface org.gvsig.tools.persistence.Persistent
      Overrides:
      saveToState in class FFrame
      Throws:
      org.gvsig.tools.persistence.exception.PersistenceException
    • setBoundBox

      public void setBoundBox(Rectangle2D r)
      Description copied from class: FFrame
      Sets the bounding box in centimeters of this FFrame, using paper coordinates.
      Specified by:
      setBoundBox in interface IFFrame
      Overrides:
      setBoundBox in class FFrame
      Parameters:
      r - Rectangle in centimeters
    • getMapRotation

      public double getMapRotation()
      Gets the rotation of the frame
      Returns:
      Rotation in degrees
    • invalidateLayout

      protected void invalidateLayout()
    • invalidateToc

      protected void invalidateToc()
    • refreshToc

      protected void refreshToc()
    • refresh

      public void refresh()
      Description copied from interface: IFFrameUseFMap
      Invalidates the FFrameView cache, which will cause the FFrame to be repainted on the next drawing cycle.
      Specified by:
      refresh in interface IFFrameUseFMap
    • createListeners

      protected void createListeners()
    • addAllListeners

      protected void addAllListeners()
    • resetAllListeners

      protected void resetAllListeners()
    • removeAllListeners

      protected void removeAllListeners()
    • removeOwnListeners

      protected void removeOwnListeners()
    • removeViewListeners

      protected void removeViewListeners()
    • dispose

      public void dispose()
      Specified by:
      dispose in interface org.gvsig.tools.dispose.Disposable
      Overrides:
      dispose in class FFrame
    • frameRemoved

      public void frameRemoved()
      Description copied from interface: IFFrame
      This method is called when the FFrame has been removed from the Layout
      Specified by:
      frameRemoved in interface IFFrame
      Overrides:
      frameRemoved in class FFrame
    • frameAdded

      public void frameAdded()
      Description copied from interface: IFFrame
      This method is called when the FFrame has been added to the Layout
      Specified by:
      frameAdded in interface IFFrame
      Overrides:
      frameAdded in class FFrame
    • setHasToc

      public void setHasToc(boolean hasToc)
    • setTocModel

      protected void setTocModel()
    • doSetSelected

      protected void doSetSelected(int selectedStatus)
      Overrides:
      doSetSelected in class FFrame
    • getLayerSynced

      public boolean getLayerSynced()
      Description copied from interface: IFFrameUseFMap
      Gets the synchronization mode for layers. If true, layers will be synchronized between the FFrameView and the associated View, so any change in the FFrameView (layer added or removed, visibility changed, symbology change, etc) will be propagated to the associated View, and vice versa.
      Specified by:
      getLayerSynced in interface IFFrameUseFMap
      Returns:
      true if the layers are synchronized between the FFrameView and the View, false otherwise.
    • setLayerSynced

      public void setLayerSynced(boolean synced)
      Description copied from interface: IFFrameUseFMap
      Sets the synchronization mode for map layers. If true, layers will be synchronized between the FFrameView and the associated View, so any change in the FFrameView (layer added or removed, visibility changed, symbology change, etc) will be propagated to the associated View, and vice versa.
      Specified by:
      setLayerSynced in interface IFFrameUseFMap
      Parameters:
      synced - true to enable layers synchronization between the FFrameView and the View, false otherwise.
    • getExtentSynced

      public boolean getExtentSynced()
      Description copied from interface: IFFrameUseFMap
      Gets the synchronization mode for the map extent. If true, the map extent will be synchronized between the FFrameView and the associated View, so any change in the FFrameView (pan, zoom in, zoom out...) will be propagated to the associated View, and vice versa.
      Specified by:
      getExtentSynced in interface IFFrameUseFMap
      Returns:
      true if the map extent is synchronized between the FFrameView and the View, false otherwise.
    • setExtentSynced

      public void setExtentSynced(boolean synced)
      Description copied from interface: IFFrameUseFMap
      Sets the synchronization mode for the map extent. If true, the map extent will be synchronized between the FFrameView and the associated View, so any change in the FFrameView (pan, zoom in, zoom out...) will be propagated to the associated View, and vice versa.
      Specified by:
      setExtentSynced in interface IFFrameUseFMap
      Parameters:
      synced - true to enable extent synchronization between the FFrameView and the View, false otherwise.
    • isPan

      public static boolean isPan(org.gvsig.fmap.geom.primitive.Envelope oldEnvelope, org.gvsig.fmap.geom.primitive.Envelope newEnvelope)
      Returns true if the newEnvelope represents a pan operation on oldEnvelope, (both extents have the same height and width)
      Parameters:
      oldEnvelope -
      newEnvelope -
      Returns:
    • calculateNewExtent

      protected org.gvsig.fmap.geom.primitive.Envelope calculateNewExtent()
      Calculates the new extent for the FFrame. It is necessary to avoid scale changes when a pan is triggered from the view, as the different size factors from View/FFrameView introduces scale changes even for pans
      Returns:
    • isDrawing

      protected boolean isDrawing()
    • isUpdating

      protected boolean isUpdating()
    • skipFirstChangeExtent

      protected boolean skipFirstChangeExtent()
    • isSyncLayers

      protected boolean isSyncLayers()
    • beginUpdate

      protected void beginUpdate()
    • endUpdate

      protected void endUpdate()
    • getScaleType

      public IFFrameUseFMap.SCALE_TYPE getScaleType()
      Description copied from interface: IFFrameUseFMap
      Specified by:
      getScaleType in interface IFFrameUseFMap
      Returns:
      The scale type
    • getFixedScale

      public Double getFixedScale()
    • getFixedExtent

      public org.gvsig.fmap.geom.primitive.Envelope getFixedExtent()
    • setExtent

      public void setExtent(org.gvsig.fmap.geom.primitive.Envelope extent)
    • setScaleType

      public void setScaleType(IFFrameUseFMap.SCALE_TYPE scaleType)
      Description copied from interface: IFFrameUseFMap
      Specified by:
      setScaleType in interface IFFrameUseFMap
    • setScaleType

      public void setScaleType(IFFrameUseFMap.SCALE_TYPE scaleType, double fixedScale)
    • setScaleType

      public void setScaleType(IFFrameUseFMap.SCALE_TYPE scaleType, org.gvsig.fmap.geom.primitive.Envelope fixedExtent)
    • getTypeScale

      @Deprecated public int getTypeScale()
      Deprecated.
      Description copied from interface: IFFrameUseFMap
      Kept for the moment for backward-compatibility, it will be removed on the future.
      Specified by:
      getTypeScale in interface IFFrameUseFMap
    • setLinked

      @Deprecated public void setLinked(boolean b)
      Deprecated.
      Description copied from interface: IFFrameUseFMap
      Kept for the moment for backward-compatibility, it will be removed on the future.
      Specified by:
      setLinked in interface IFFrameUseFMap
    • getLinked

      @Deprecated public boolean getLinked()
      Deprecated.
      Description copied from interface: IFFrameUseFMap
      Kept for the moment for backward-compatibility, it will be removed on the future.
      Specified by:
      getLinked in interface IFFrameUseFMap
    • windowActivated

      public void windowActivated()
      Specified by:
      windowActivated in interface LayoutPanelListener
    • windowClosed

      public void windowClosed()
      Specified by:
      windowClosed in interface LayoutPanelListener
    • setPersistIndependent

      public void setPersistIndependent(boolean b)
    • isPersistIndependent

      public boolean isPersistIndependent()