dsto.dfc.swing.controls
Class DfcBoundingBox

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by dsto.dfc.swing.controls.DfcBoundingBox
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class DfcBoundingBox
extends JComponent

This component can be used to graphically define the size of a rectangle, using only two points; The topLeft, and bottomRight. You can also invert the Y-Axis so that it becomes a cartesian plane instead of your usual computer screen type coordinate system (ie 0,0 is the top left corner, and going down the screen is an increase in Y coordinate.) You can also set a background image by using setBackgroundImage(Image).

See Also:
Serialized Form

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
protected  boolean invertYAxis
           
 
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.Component
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
DfcBoundingBox(BoundedRangeModel x1, BoundedRangeModel y1, BoundedRangeModel x2, BoundedRangeModel y2)
           
DfcBoundingBox(BoundedRangeModel x1, BoundedRangeModel y1, BoundedRangeModel x2, BoundedRangeModel y2, boolean invertYAxis)
           
 
Method Summary
 Image getBackgroundImage()
          retrieve the background image.
 Dimension getMaximumSize()
          Returns the maximum size of this component as the lengths of the range models.
 Dimension getMinimumSize()
          Returns the minimum size of this component as the lengths of the range models
 Dimension getPreferredSize()
          Returns the preferred size of this component as the lengths of the range models.
protected  void paintComponent(Graphics g)
          Overwriting JComponents paintComponent method, so that we can add some lines, and a red outline which highlights the selected region.
 void setBackgroudImage(Image image)
          Set the background image, to the specified iamge.
 void setEnabled(boolean enabled)
          Enable or disable the component.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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, 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, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, 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

invertYAxis

protected boolean invertYAxis
Constructor Detail

DfcBoundingBox

public DfcBoundingBox(BoundedRangeModel x1,
                      BoundedRangeModel y1,
                      BoundedRangeModel x2,
                      BoundedRangeModel y2)
Parameters:
x1 - Top left X-Axis bounded range model.
y1 - Top Left Y-Axis bounded range model.
x2 - Bottom Right X-Axis bounded range model.
y2 - Bottom Right Y-Axis bounded range model.

DfcBoundingBox

public DfcBoundingBox(BoundedRangeModel x1,
                      BoundedRangeModel y1,
                      BoundedRangeModel x2,
                      BoundedRangeModel y2,
                      boolean invertYAxis)
Parameters:
x1 - Top left X-Axis bounded range model.
y1 - Top Left Y-Axis bounded range model.
x2 - Bottom Right X-Axis bounded range model.
y2 - Bottom Right Y-Axis bounded range model.
invertYAxis - If set to true, then the Y-Axis will be inverted.
Method Detail

getBackgroundImage

public Image getBackgroundImage()
retrieve the background image. If there isn't one, it returns null;

Returns:
The background image.

setEnabled

public void setEnabled(boolean enabled)
Enable or disable the component.

Overrides:
setEnabled in class JComponent
Parameters:
enabled - If true, will enable the component, and vice-versa.

setBackgroudImage

public void setBackgroudImage(Image image)
Set the background image, to the specified iamge.

Parameters:
image - The image to use as the background image. The image will be scaled to fit.

paintComponent

protected void paintComponent(Graphics g)
Overwriting JComponents paintComponent method, so that we can add some lines, and a red outline which highlights the selected region.

Overrides:
paintComponent in class JComponent
Parameters:
g - The graphics context that we use to draw onto.

getMaximumSize

public Dimension getMaximumSize()
Returns the maximum size of this component as the lengths of the range models.

Overrides:
getMaximumSize in class JComponent
Returns:
The max size of the component as a Dimension.

getMinimumSize

public Dimension getMinimumSize()
Returns the minimum size of this component as the lengths of the range models

Overrides:
getMinimumSize in class JComponent
Returns:
The min size of the component as a Dimension.

getPreferredSize

public Dimension getPreferredSize()
Returns the preferred size of this component as the lengths of the range models.

Overrides:
getPreferredSize in class JComponent
Returns:
The preferred size of the component as a Dimension.


Copyright © 2008 Commonwealth of Australia