Package furbelow

Class Panner

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class Panner extends JComponent
Component which scales any given JComponent into its bounds. The visible portion of the JComponent (as reported by JComponent.getVisibleRect()) is drawn as a rectangle in the scaled image. Dragging the rectangle will move the visible portion of the panned component within its scrolling context.
See Also:
  • Field Details

  • Constructor Details

    • Panner

      public Panner()
    • Panner

      public Panner(JComponent reference)
  • Method Details

    • setPreserveAspect

      public void setPreserveAspect(boolean preserve)
    • setIncludeBorder

      public void setIncludeBorder(boolean border)
    • setTransparency

      public void setTransparency(float t)
    • attach

      public boolean attach(int x, int y)
      "Attach" to the panned component at the given location within the component. Returns whether the attach was successful.
    • isAttached

      public boolean isAttached()
    • detach

      public void detach()
    • setViewportCenter

      public void setViewportCenter(Point where)
      Sets the center point of the current viewport. Coordinates are relative to the Panner bounds. The viewport bounds will always be contained within the thumbnail image.
      Parameters:
      where -
    • getDrawingSize

      protected Dimension getDrawingSize(JComponent component)
    • setCentered

      public void setCentered(boolean set)
      Set the thumbnail alignment within the available space.
    • isCentered

      public boolean isCentered()
      Returns:
      whether the thumbnail is centered within the available space.
    • setPannedComponent

      public void setPannedComponent(JComponent panned)
      Set the component being panned.
    • check

      protected Dimension check(Dimension size)
    • getThumbnailBounds

      public Rectangle getThumbnailBounds()
      Return the actual thumbnail bounds, accounting for extra space required for this component's border and to maintain proper aspect ratio.
    • getViewportBounds

      public Rectangle getViewportBounds()
      Return a rectangle within the current component content bounds equivalent to the visible rectangle within the panned component's content bounds.
    • getPreferredSize

      public Dimension getPreferredSize()
      Returns the preferred size, which will be the set preferred size or the current size with an appropriate aspect ratio applied. If there is no current panned component, no aspect ratio will be applied.
      Overrides:
      getPreferredSize in class JComponent
    • getMaximumSize

      public Dimension getMaximumSize()
      Ensure the maximum size always has the correct aspect ratio.
      Overrides:
      getMaximumSize in class JComponent
    • getMinimumSize

      public Dimension getMinimumSize()
      Ensure the minimum size always has the correct aspect ratio.
      Overrides:
      getMinimumSize in class JComponent
    • setBounds

      public void setBounds(int x, int y, int w, int h)
      Overrides:
      setBounds in class Component
    • paint

      public void paint(Graphics g)
      Paint the panned component in a thumbnail.
      Overrides:
      paint in class JComponent