java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
org.jpo.gui.swing.PictureController
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
- Direct Known Subclasses:
OverlayedPictureController
The job of this Component is to scale and display a picture.
It notifies the registered parent about status changes so that a description
object can be updated. When the image has been rendered and displayed the
legend of the image is set to the parent with the ready status.
The image is centred on the component to the focusPoint
in the
coordinate space of the image. This translated using the
ScalablePicture.setScaleFactor(double)
to the coordinate space of
the JComponent
- 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
Modifier and TypeFieldDescriptionfinal Point
This point of the picture will be put at the middle of the screen component.Fields 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
ConstructorDescriptionPictureController
(PictureControllerImage pictureControllerImage) Constructs a PicturePane components. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Set image to centre of panel by putting the coordinates of the middle of the original image into the Centre to X and Centre to Y variables by invoking the setCenterLocation method.void
Deals with a Zoom request by changing the doom factorboolean
returns whether the picture should be centered when scaledvoid
we are overriding the default paintComponent method, grabbing the Graphics handle and doing our own drawing here.void
Sets the scale of the picture to the current screen size and centres it there.void
method that moves the image down by 10% of the pixels shown on the screen.void
method that moves the image left by 10% of the pixels shown on the screen.void
method that moves the image right by 10% of the pixels shown on the screen.void
scrollUp()
method that moves the image up by 10% of the pixels shown on the screen.void
setCenterLocation
(int xParameter, int yParameter) method to set the centre of the image to the true coordinates in the picture but doesn't callrepaint()
void
setCenterWhenScaled
(boolean centerWhenScaled) Remembers whether the picture should be centered when scaledvoid
zoomFull()
method that zooms the image to 100%.void
zoomIn()
Multiplies the scale factor so that paint() method scales the image larger.void
zoomOut()
method that zooms out on the image leaving the centre where it is.void
this method sets the desired scaled size of the ScalablePicture to the size of the JPanel and fires off a createScaledPictureInThread request if the ScalablePicture has been loaded or is ready.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, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, 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, paint, paintBorder, paintChildren, 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, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
focusPoint
This point of the picture will be put at the middle of the screen component. The coordinates are in x,y in the coordinate space of the picture.
-
-
Constructor Details
-
PictureController
Constructs a PicturePane components.- Parameters:
pictureControllerImage
- image
-
-
Method Details
-
isCenterWhenScaled
public boolean isCenterWhenScaled()returns whether the picture should be centered when scaled- Returns:
- true if the picture should be centered when scaled
-
setCenterWhenScaled
public void setCenterWhenScaled(boolean centerWhenScaled) Remembers whether the picture should be centered when scaled- Parameters:
centerWhenScaled
- whether the picture should be centered when scaled
-
resetPicture
public void resetPicture()Sets the scale of the picture to the current screen size and centres it there. -
handleZoomRequest
Deals with a Zoom request by changing the doom factor- Parameters:
request
- The request
-
zoomIn
public void zoomIn()Multiplies the scale factor so that paint() method scales the image larger. This method callsScalablePicture.createScaledPictureInThread(int)
which in turn will tell this object by means of the status update that the image is ready and should be repainted. -
zoomOut
public void zoomOut()method that zooms out on the image leaving the centre where it is. This method callsScalablePicture.createScaledPictureInThread(int)
which in turn will tell this object by means of the status update that the image is ready and should be repainted. -
zoomToFit
public void zoomToFit()this method sets the desired scaled size of the ScalablePicture to the size of the JPanel and fires off a createScaledPictureInThread request if the ScalablePicture has been loaded or is ready.- See Also:
-
zoomFull
public void zoomFull()method that zooms the image to 100%. This method callsScalablePicture.createScaledPictureInThread(int)
which in turn will tell this object by means of the status update that the image is ready and should be repainted. -
centerImage
public void centerImage()Set image to centre of panel by putting the coordinates of the middle of the original image into the Centre to X and Centre to Y variables by invoking the setCenterLocation method. This method callsrepaint()
directly since no time-consuming image operations need to take place. -
scrollUp
public void scrollUp()method that moves the image up by 10% of the pixels shown on the screen. This method callsrepaint()
directly since no time-consuming image operations need to take place.- See Also:
-
scrollDown
public void scrollDown()method that moves the image down by 10% of the pixels shown on the screen. This method callsrepaint()
directly since no time-consuming image operations need to take place.- See Also:
-
scrollLeft
public void scrollLeft()method that moves the image left by 10% of the pixels shown on the screen. This method callsrepaint()
directly since no time-consuming image operations need to take place. works just likescrollUp()
.- See Also:
-
scrollRight
public void scrollRight()method that moves the image right by 10% of the pixels shown on the screen. This method callsrepaint()
directly since no time-consuming image operations need to take place. works just likescrollDown()
.- See Also:
-
setCenterLocation
public void setCenterLocation(int xParameter, int yParameter) method to set the centre of the image to the true coordinates in the picture but doesn't callrepaint()
- Parameters:
xParameter
- the x coordinatesyParameter
- the y coordinates
-
paintComponent
we are overriding the default paintComponent method, grabbing the Graphics handle and doing our own drawing here. Essentially this method draws a large background color rectangle. A drawRenderedImage is then painted doing an affine transformation on the scaled image to position it so the desired point is in the middle of the Graphics object. The picture is not scaled here because this is a slow operation and only needs to be done once, while moving the image is something the user is likely to do more often.- Overrides:
paintComponent
in classJComponent
- Parameters:
g
- Graphics
-