Class JZoomport

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class JZoomport extends JComponent
See Also:
  • Constructor Details

  • Method Details

    • processKeyBinding

      protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed)
      The zoomed component is not part of the Swing component hierarchy, so its key bindings would never be consulted. This forwards WHEN_FOCUSED bindings of the zoomed component when this zoomport has focus, similar to how a view inside JScrollPane receives them directly.
      Overrides:
      processKeyBinding in class JComponent
    • getZoom

      public final double getZoom()
      Returns current zoom factor
      Returns:
      double zoom factor
    • setZoom

      public final void setZoom(double zoom)
      Sets zoom value
    • fitZoom

      public final void fitZoom()
      Sets zoom value to fit canvas and center
    • fitZoom

      public final void fitZoom(int hpadding, int vpadding)
      Sets zoom value to fit canvas and center. Also adds some padding
    • setZoomAroundCenter

      public final void setZoomAroundCenter(double zoom)
      Sets zoom value keeping the center still
    • getLocationOnCanvas

      public Point2D.Double getLocationOnCanvas(Point2D panelLocation)
    • getLocationOnPanel

      public Point2D.Double getLocationOnPanel(Point2D canvasLocation)
    • recalculateBounds

      public void recalculateBounds()
      If the zoomable element changes size when zoom or viewport size changes this has to be implemented for proper operation.
    • paint

      public void paint(Graphics g)
      Overrides:
      paint in class JComponent
    • setViewPosition

      public void setViewPosition(Point point)
    • setViewPosX

      public void setViewPosX(double viewPosX)
    • setViewPosY

      public void setViewPosY(double viewPosY)
    • getViewPositionX

      public double getViewPositionX()
    • getViewPositionY

      public double getViewPositionY()
    • getViewPositionPoint

      public Point2D getViewPositionPoint()
    • getCanvasX

      public int getCanvasX()
    • getCanvasY

      public int getCanvasY()
    • getCanvasPoint

      public Point getCanvasPoint()
    • getPaneWidth

      public int getPaneWidth()
    • getPaneHeight

      public int getPaneHeight()
    • getMinZoom

      public double getMinZoom()
    • setMinZoom

      public void setMinZoom(double minZoom)
    • getMaxZoom

      public double getMaxZoom()
    • setMaxZoom

      public void setMaxZoom(double maxZoom)
    • getZoomPresets

      public double[] getZoomPresets()
    • setZoomPresets

      public void setZoomPresets(double[] zoomPresets)
    • getZoomFactor

      public double getZoomFactor()
    • setZoomFactor

      public void setZoomFactor(double zoomFactor)
    • recenter

      public void recenter()
    • isUpdateScrollbarX

      public boolean isUpdateScrollbarX()
    • setUpdateScrollbarX

      public void setUpdateScrollbarX(boolean updateScrollbarX)
    • isUpdateScrollbarY

      public boolean isUpdateScrollbarY()
    • setUpdateScrollbarY

      public void setUpdateScrollbarY(boolean updateScrollbarY)
    • getToZoom

      public JComponent getToZoom()