Interface IContainer

All Known Implementing Classes:
BaseContainer, MapContainer

public interface IContainer
A 2D drawing container with a world coordinate system and conversion to pixel (screen) coordinates. Implementations are typically Swing components that render one or more IDrawables.
  • Field Details

    • FIXED_ZOOM_FACTOR

      static final double FIXED_ZOOM_FACTOR
      The factor used for fixed zooms.
      See Also:
  • Method Details

    • addLayer

      void addLayer(Layer layer)
      Add a z layer for containing items rendered on this container..
      Parameters:
      layer - the layer to add.
    • getAnnotationLayer

      Layer getAnnotationLayer()
      Get the annotation layer for this container.
      Returns:
      the annotation layer for this container. All drawing tools draw on the annotation layer, which is kept on top.
    • getConnectionLayer

      Layer getConnectionLayer()
      Get the connection layer for this container.
      Returns:
      the connection layer for this container. Connection items are drawn on first, i.e. connections are under other items.
    • getDefaultLayer

      Layer getDefaultLayer()
      Get the default user content layer for this container.
      Returns:
      the default user content layer (never null after construction)
    • getLayerByName

      Layer getLayerByName(String name)
      Gets an z layer by name. Do not use for the annotation layer or connection layer-- for that use getAnnotationLayer() or getConnectionLayer().
      Parameters:
      name - the name of the layer.
      Returns:
      the z layer, or null.
    • localToWorld

      void localToWorld(Point pp, Point2D.Double wp)
      This converts a screen or pixel point to a world point.
      Parameters:
      pp - contains the local (screen-pixel) point.
      wp - will hold the resultant world point.
    • worldToLocal

      void worldToLocal(Point pp, Point2D.Double wp)
      This converts a world point to a screen or pixel point.
      Parameters:
      pp - will hold the resultant local (screen-pixel) point.
      wp - contains world point.
    • worldToLocal

      void worldToLocal(Rectangle r, Rectangle2D.Double wr)
      This converts a world rectangle to a screen or pixel rectangle.
      Parameters:
      r - will hold the resultant local (screen-pixel) rectangle.
      wr - contains the world rectangle.
    • localToWorld

      void localToWorld(Rectangle r, Rectangle2D.Double wr)
      This converts a screen or local rectangle to a world rectangle.
      Parameters:
      r - contains the local (screen-pixel) rectangle.
      wr - will hold the resultant world rectangle.
    • worldToLocal

      void worldToLocal(Polygon polygon, WorldPolygon worldPolygon)
      This converts a world polygon to a screen or pixel polygon.
      Parameters:
      polygon - will hold the resultant local (screen-pixel) polygon.
      worldPolygon - contains the world polygon.
    • localToWorld

      void localToWorld(Polygon polygon, WorldPolygon worldPolygon)
      This converts a screen or local polygon to a world polygon.
      Parameters:
      polygon - contains the local (screen-pixel) polygon.
      worldPolygon - will hold the resultant world polygon.
    • worldToLocal

      void worldToLocal(Point pp, double wx, double wy)
      This converts a world point to a screen or pixel point.
      Parameters:
      pp - will hold the resultant local (screen-pixel) point.
      wx - the world x coordinate.
      wy - the world y coordinate.
    • pan

      void pan(int dh, int dv)
      Pan the container.
      Parameters:
      dh - the horizontal step in pixels.
      dv - the vertical step in pixels.
    • recenter

      void recenter(Point pp)
      Recenter the container at the point of a click.
      Parameters:
      pp - the point in question. It will be the new center.
    • prepareToZoom

      void prepareToZoom()
      Begin preparations for a zoom.
    • restoreDefaultWorld

      void restoreDefaultWorld()
      Restore the default world. This gets us back to the original zoom level.
    • resetWorldSystem

      void resetWorldSystem(Rectangle2D.Double worldSystem)
      Reset the world system to a new value. Resets the default and previous world systems as well.
      Parameters:
      worldSystem - the new world system.
    • scale

      void scale(double scaleFactor)
      Convenience routine to scale the container.
      Parameters:
      scaleFactor - the scale factor.
    • undoLastZoom

      void undoLastZoom()
      Undo that last zoom.
    • rubberBanded

      void rubberBanded(Rectangle b)
      This is called when we have completed a rubber banding. pane.
      Parameters:
      b - The rubber band bounds.
    • getItemAtPoint

      AItem getItemAtPoint(Point lp)
      Find an item, if any, at the point.
      Parameters:
      lp - The pixel point in question.
      Returns:
      the topmost satisfying item, or null.
    • getEnclosedItems

      ArrayList<AItem> getEnclosedItems(Rectangle rect)
      Obtain a collection of all enclosed items across all lists.
      Parameters:
      rect - the rectangle in question.
      Returns:
      all items on all item lists enclosed by the rectangle.
    • getItemsAtPoint

      ArrayList<AItem> getItemsAtPoint(Point lp)
      Find all items, if any, at the point.
      Parameters:
      lp - the pixel point in question.
      Returns:
      all items across all item lists that contain the given point. It may be an empty vector, but it won't be null.
    • anySelectedItems

      boolean anySelectedItems()
      Check whether at least one item on any item list is selected.
      Returns:
      true if at least one item on any item list is selected.
    • deleteSelectedItems

      void deleteSelectedItems()
      Delete all selected items, across all item lists.
    • getSelectedItems

      List<AItem> getSelectedItems()
      Get all selected items, across all item lists.
      Returns:
      a list of all currently selected items; never null
    • selectAllItems

      void selectAllItems(boolean select)
      Select or deselect all items, across all item lists.
      Parameters:
      select - the selection flag.
    • zoom

      void zoom(double xmin, double xmax, double ymin, double ymax)
      Zooms to the specified area.
      Parameters:
      xmin - minimum x coordinate.
      xmax - maximum x coordinate.
      ymin - minimum y coordinate.
      ymax - maximum y coordinate.
    • getToolBar

      AToolBar getToolBar()
      Get this container's tool bar interface.
      Returns:
      this container's tool bar, or null.
    • setToolBar

      void setToolBar(AToolBar toolBar)
      Set this container's tool bar.
      Parameters:
      toolBar - the new toolbar interface.
    • updateStatusText

      default void updateStatusText(Point pp, Point2D.Double wp)
      Update the status text in the toolbar, if any. This is a convenience method that calls getToolBar().updateStatusText() if a toolbar is present.
      Parameters:
      pp - the pixel point to include in the status text.
      wp - the world point to include in the status text.
    • getHoverWindow

      default HoverInfoWindow getHoverWindow()
      Get the hover info window for this container, if any.
      Returns:
      the hover info window for this container, or null.
    • feedbackTrigger

      void feedbackTrigger(MouseEvent mouseEvent, boolean dragging)
      Convenience method to update the location string in the toolbar.
      Parameters:
      mouseEvent - the causal event.
      dragging - true if we are dragging
    • getView

      BaseView getView()
      Get the view (internal frame) that holds this container.
      Returns:
      the view (internal frame) that holds this container.
    • setView

      void setView(BaseView view)
      Set the container's view.
      Parameters:
      view - the view to set.
    • setFeedbackPane

      void setFeedbackPane(FeedbackPane feedbackPane)
      Sets the feedback pane. This is an optional alternative to a HUD.
      Parameters:
      feedbackPane - the feedback pane.
    • getFeedbackPane

      FeedbackPane getFeedbackPane()
      Get the optional feedback pane.
      Returns:
      the feedbackPane
    • getFeedbackControl

      FeedbackControl getFeedbackControl()
      Return the object that controls the container's feedback. You can and and remove feedback providers using this object.
      Returns:
      the object that controls the container's feedback.
    • setDirty

      void setDirty(boolean dirty)
      Convenience method for setting the dirty flag for all items on all item lists.
      Parameters:
      dirty - the new value of the dirty flag.
    • refresh

      void refresh()
      Refresh the container.
    • getComponent

      Component getComponent()
      Get the underlying JComponent
      Returns:
      the underlying component
    • getImage

      BufferedImage getImage()
      Get the background image.
      Returns:
      the fully painted background image.
    • setAfterDraw

      void setAfterDraw(IDrawable afterDraw)
      Set the after-draw drawable for this container.
      Parameters:
      afterDraw - the new after-draw drawable.
    • setBeforeDraw

      void setBeforeDraw(IDrawable beforeDraw)
      Set the before-draw drawable.
      Parameters:
      beforeDraw - the new before-draw drawable.
    • getWorldSystem

      Rectangle2D.Double getWorldSystem()
      Get the current world system.

      Note: implementations may return the live, mutable rectangle backing the container's viewport, not a defensive copy (unlike setWorldSystem(java.awt.geom.Rectangle2D.Double) and resetWorldSystem, which both copy). Mutating the returned rectangle directly can silently change the container's viewport without going through setDirty/ refresh. Callers that need to keep a stable snapshot should copy it themselves.

      Returns:
      the world system; may be the container's live instance
    • setWorldSystem

      void setWorldSystem(Rectangle2D.Double wr)
      Set the world system (does not cause redraw)
      Parameters:
      wr - the new world system
    • approximateZoomFactor

      double approximateZoomFactor()
      Get the approximate zoom factor based on the current and default world systems.
      Returns:
      the approximate zoom factor
    • prepareForExit

      void prepareForExit()
      Prepare for exiting the application. This is called from the main frame when the user tries to exit. It gives the container a chance to do things like prompt to save unsaved work or dispose of resources.