|
QJCC homepage | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent biz.chitec.quarterback.swing.ScalingImagePane
A JComponent-derived panel to show an image scaled to fit with respect to aspect ratio. Image is drawn at the given place in the component. A maximum scale can be given. On resizing the component, the image is rescaled if new scale differs above a threshold from old scale.
ScalingImagePane is aware of its insets and scales and places the image accordingly. So, it can be given a border.
As an additional capability, the painted image can be given a rectangular selection which is automatically
transformed into the image's logic coordinate space. To enable this feature, just use
setRectangleSelectable(true)
. The pane fires property events if a selection is done with
the mouse.
This component makes extensive use of the AWT image drawing capabilities.
Nested Class Summary |
Nested classes inherited from class javax.swing.JComponent |
javax.swing.JComponent.AccessibleJComponent |
Nested classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
private java.awt.Image |
baseimage
The image to be shown |
private double |
currentscale
The current scale in which the image is shown |
private java.awt.Rectangle |
drawrect
|
private int |
horizalign
horizontal alignment of the image |
private int |
imageheight
Height of the image |
private int |
imagewidth
Width of the image. |
private boolean |
isrectangleselectable
|
private boolean |
isrectangleselected
|
private java.awt.Rectangle |
logrect
|
private double |
maximumscale
Maximum scale up to which the image should be enlarged. |
private double |
maxthreshold
Maximum threshold above which the scaling change must grow before rescaling is done. |
private double |
minthreshold
Minimum threshold below which the scaling change must shrink before rescaling is done. |
private java.awt.Rectangle |
phyrect
|
private int |
scaledheight
height of the scaled version of the image |
private int |
scaledwidth
width of the scaled version of the image |
private int |
scaledx
x point where to draw the scaled version of the image |
private int |
scaledy
y point where to draw the scaled version of the image |
private int |
vertalign
vertical alignment of the image |
Fields inherited from class javax.swing.JComponent |
accessibleContext, 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.Container |
|
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface javax.swing.SwingConstants |
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
ScalingImagePane()
Creates a centering ScalingImagePane, maximum scale set to 1, threshold interval (1,1). |
|
ScalingImagePane(int ha,
int va)
Create a scaling image pane with maximum scale 1 (no enlargement) and threshold interval (1,1). |
|
ScalingImagePane(int ha,
int va,
double mxs)
Create a scaling image pane with threshold interval set to (1,1) and no image. |
|
ScalingImagePane(int ha,
int va,
double mxs,
double minth,
double maxth)
Create a scaling image pane without image. |
|
ScalingImagePane(int ha,
int va,
double mxs,
double minth,
double maxth,
java.awt.Image img)
Create a ScalingImagePane. |
Method Summary | |
private void |
endRectangle()
|
private void |
followRectangle(java.awt.event.MouseEvent e)
|
int |
getHorizontalAlignment()
|
java.awt.Image |
getImage()
|
double |
getMaximumScale()
|
double |
getMaximumThreshold()
|
double |
getMinimumThreshold()
|
java.awt.Rectangle |
getSelectedRectangle()
|
int |
getVerticalAlignment()
|
boolean |
isRectangleSelectable()
|
boolean |
isRectangleSelected()
|
void |
paint(java.awt.Graphics g)
Paint the component. |
private void |
refreshLogRect()
|
private void |
refreshPhyRect()
|
void |
rescale()
Rescales the image. |
void |
setHorizontalAlignment(int ha)
|
void |
setImage(java.awt.Image image)
Sets the image. |
void |
setMaximumScale(double newmaxscale)
|
void |
setMaximumThreshold(double nt)
|
void |
setMinimumThreshold(double nt)
|
void |
setRectangleSelectable(boolean b)
|
void |
setVerticalAlignment(int ha)
|
private void |
startRectangle(java.awt.event.MouseEvent e)
|
Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private java.awt.Image baseimage
private double currentscale
private int imagewidth
private int imageheight
private int scaledx
private int scaledy
private int scaledwidth
private int scaledheight
private int horizalign
private int vertalign
private double maximumscale
private double minthreshold
private double maxthreshold
private boolean isrectangleselectable
private java.awt.Rectangle phyrect
private java.awt.Rectangle drawrect
private java.awt.Rectangle logrect
private boolean isrectangleselected
Constructor Detail |
public ScalingImagePane(int ha, int va, double mxs, double minth, double maxth, java.awt.Image img)
If the ScalingImagePane is resized, the scale of the Image is recomputed. New and old scale are compared. If their relation is between the two threshold values, no rescaling is taking place.
ha
- Horizontal alignment: LEFT, CENTER, RIGHTva
- Vertical alignment: TOP, CENTER, BOTTOMmxs
- Maximum scaling factor up to which the image is enlargedminth
- Minimum threshold of scaling factormaxth
- Maximum threshold of scaling factorimg
- The image to be shownpublic ScalingImagePane(int ha, int va, double mxs, double minth, double maxth)
public ScalingImagePane(int ha, int va, double mxs)
public ScalingImagePane(int ha, int va)
public ScalingImagePane()
Method Detail |
public void setHorizontalAlignment(int ha)
public int getHorizontalAlignment()
public void setVerticalAlignment(int ha)
public int getVerticalAlignment()
public void setMaximumScale(double newmaxscale)
public double getMaximumScale()
public void setMinimumThreshold(double nt)
public double getMinimumThreshold()
public void setMaximumThreshold(double nt)
public double getMaximumThreshold()
public void setRectangleSelectable(boolean b)
public boolean isRectangleSelectable()
public boolean isRectangleSelected()
public java.awt.Rectangle getSelectedRectangle()
public void setImage(java.awt.Image image)
public java.awt.Image getImage()
public void rescale()
public void paint(java.awt.Graphics g)
private void startRectangle(java.awt.event.MouseEvent e)
private void followRectangle(java.awt.event.MouseEvent e)
private void endRectangle()
private void refreshLogRect()
private void refreshPhyRect()
|
QJCC homepage | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |