java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
furbelow.Panner
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
FieldsFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
attach
(int x, int y) "Attach" to the panned component at the given location within the component.protected Dimension
void
detach()
protected Dimension
getDrawingSize
(JComponent component) Ensure the maximum size always has the correct aspect ratio.Ensure the minimum size always has the correct aspect ratio.Returns the preferred size, which will be the set preferred size or the current size with an appropriate aspect ratio applied.Return the actual thumbnail bounds, accounting for extra space required for this component's border and to maintain proper aspect ratio.Return a rectangle within the current component content bounds equivalent to the visible rectangle within the panned component's content bounds.boolean
boolean
void
Paint the panned component in a thumbnail.void
setBounds
(int x, int y, int w, int h) void
setCentered
(boolean set) Set the thumbnail alignment within the available space.void
setIncludeBorder
(boolean border) void
setPannedComponent
(JComponent panned) Set the component being panned.void
setPreserveAspect
(boolean preserve) void
setTransparency
(float t) void
setViewportCenter
(Point where) Sets the center point of the current viewport.Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
MINIMUM_WIDTH
public static final int MINIMUM_WIDTH- See Also:
-
MINIMUM_HEIGHT
public static final int MINIMUM_HEIGHT- See Also:
-
-
Constructor Details
-
Panner
public Panner() -
Panner
-
-
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
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
-
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
Set the component being panned. -
check
-
getThumbnailBounds
Return the actual thumbnail bounds, accounting for extra space required for this component's border and to maintain proper aspect ratio. -
getViewportBounds
Return a rectangle within the current component content bounds equivalent to the visible rectangle within the panned component's content bounds. -
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 classJComponent
-
getMaximumSize
Ensure the maximum size always has the correct aspect ratio.- Overrides:
getMaximumSize
in classJComponent
-
getMinimumSize
Ensure the minimum size always has the correct aspect ratio.- Overrides:
getMinimumSize
in classJComponent
-
setBounds
public void setBounds(int x, int y, int w, int h) -
paint
Paint the panned component in a thumbnail.- Overrides:
paint
in classJComponent
-