Copyright © 2005 Scientific Applications. All Rights Reserved.

com.sciapp.table
Class AdvancedJScrollPane

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JScrollPane
                  extended by com.sciapp.table.AdvancedJScrollPane
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, ScrollPaneConstants

public class AdvancedJScrollPane
extends JScrollPane

This subclass of JScrollPane ensures that the scrollpane will adjust correctly to the last (dummy) column added by AdvancedJTable.

See Also:
Serialized Form

Nested Class Summary
 class AdvancedJScrollPane.LockedTextField
          LockedTextField is a textfield suitable when locked rows/columns are in place.
 
Nested classes/interfaces inherited from class javax.swing.JScrollPane
JScrollPane.AccessibleJScrollPane, JScrollPane.ScrollBar
 
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.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  boolean containsViewable
          flag that is true if the scrollpane is configured to use a viewable resizer, false otherwise
protected  LockedTableModel lockedTableModel
          the locked table column model
 
Fields inherited from class javax.swing.JScrollPane
columnHeader, horizontalScrollBar, horizontalScrollBarPolicy, lowerLeft, lowerRight, rowHeader, upperLeft, upperRight, verticalScrollBar, verticalScrollBarPolicy, viewport
 
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 javax.swing.ScrollPaneConstants
COLUMN_HEADER, HORIZONTAL_SCROLLBAR, HORIZONTAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_NEVER, HORIZONTAL_SCROLLBAR_POLICY, LOWER_LEADING_CORNER, LOWER_LEFT_CORNER, LOWER_RIGHT_CORNER, LOWER_TRAILING_CORNER, ROW_HEADER, UPPER_LEADING_CORNER, UPPER_LEFT_CORNER, UPPER_RIGHT_CORNER, UPPER_TRAILING_CORNER, VERTICAL_SCROLLBAR, VERTICAL_SCROLLBAR_ALWAYS, VERTICAL_SCROLLBAR_AS_NEEDED, VERTICAL_SCROLLBAR_NEVER, VERTICAL_SCROLLBAR_POLICY, VIEWPORT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
AdvancedJScrollPane()
          Creates an empty (no viewport view) AdvancedJScrollPane where both horizontal and vertical scrollbars appear when needed.
AdvancedJScrollPane(Component view)
          Creates an AdvancedJScrollPane that displays the contents of the specified component, where both horizontal and vertical scrollbars appear whenever the component's contents are larger than the view.
AdvancedJScrollPane(Component view, int vsbPolicy, int hsbPolicy)
          Creates an AdvancedJScrollPane that displays the view component in a viewport whose view position can be controlled with a pair of scrollbars.
AdvancedJScrollPane(int vsbPolicy, int hsbPolicy)
          Creates an empty (no viewport view) AdvancedJScrollPane with specified scrollbar policies.
 
Method Summary
 int convertBackX(int x)
          Coverts an x-coordinate back from the ordinate system that is modified by locked rows/columns.
 int convertBackY(int y)
          Coverts an y-coordinate back from the ordinate system that is modified by locked rows/columns.
 int convertX(int x)
          Coverts an x-coordinate to the ordinate system that is modified by locked rows/columns.
 int convertX(int x, int delta)
          Coverts an x-coordinate to the ordinate system that is modified by locked rows/columns.
 int convertY(int y)
          Coverts a y-coordinate to the ordinate system that is modified by locked rows/columns.
protected  LockedTableModel createDefaultLockedModel()
          Creates and returns the default locked table model.
 JScrollBar createHorizontalScrollBar()
          Returns a specialized horizontal scrollbar which is a subclass of JScrollPane.ScrollBar.
 void doLayout()
          Causes this container to lay out its components.
 boolean getContainsViewable()
          Determines whether the scrollpane is configured to use a viewable resizer.
 LockedTableModel getLockedModel()
          Returns the locked table model.
 void layout()
          Causes this container to lay out its components.
 Component prepareEditorComponent(TableCellEditor editor, Component c, int row, int column)
          Prepares and returns a table cell editor component suitable for locked rows/columns.
 void setColumnHeader(JViewport viewport)
          Removes the old columnHeader, if it exists.
 void setColumnHeaderView(Component view)
          Creates a column-header viewport if necessary, sets its view, and then adds the column-header viewport to the scrollpane.
 void setContainsViewable(boolean containsViewable)
          Enables/disables the viewable resizer functionality in the scrollpane.
 void setLockedModel(LockedTableModel lockedTableModel)
          Assigns a new locked table model.
 void setRowHeader(JViewport viewport)
          Removes the old rowHeader, if it exists.
 void setRowHeaderView(Component view)
          Creates a row-header viewport if necessary, sets its view and then adds the row-header viewport to the scrollpane.
 void setViewport(JViewport viewport)
          Removes the old viewport (if there is one); forces the viewPosition of the new viewport to be in the +x,+y quadrant; syncs up the row and column headers (if there are any) with the new viewport; and finally syncs the scrollbars and headers with the new viewport.
 void setViewportView(Component view)
          Creates a viewport if necessary and then sets its view.
 void validateTree()
          Recursively descends the container tree and recomputes the layout for any subtrees marked as needing it (those marked as invalid).
 
Methods inherited from class javax.swing.JScrollPane
createVerticalScrollBar, createViewport, getAccessibleContext, getColumnHeader, getCorner, getHorizontalScrollBar, getHorizontalScrollBarPolicy, getRowHeader, getUI, getUIClassID, getVerticalScrollBar, getVerticalScrollBarPolicy, getViewport, getViewportBorder, getViewportBorderBounds, isValidateRoot, isWheelScrollingEnabled, paramString, setComponentOrientation, setCorner, setHorizontalScrollBar, setHorizontalScrollBarPolicy, setLayout, setUI, setVerticalScrollBar, setVerticalScrollBarPolicy, setViewportBorder, setWheelScrollingEnabled, updateUI
 
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, 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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, 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
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, transferFocusBackward, transferFocusDownCycle, validate
 
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, 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

lockedTableModel

protected LockedTableModel lockedTableModel
the locked table column model


containsViewable

protected boolean containsViewable
flag that is true if the scrollpane is configured to use a viewable resizer, false otherwise

Constructor Detail

AdvancedJScrollPane

public AdvancedJScrollPane()
Creates an empty (no viewport view) AdvancedJScrollPane where both horizontal and vertical scrollbars appear when needed.


AdvancedJScrollPane

public AdvancedJScrollPane(int vsbPolicy,
                           int hsbPolicy)
Creates an empty (no viewport view) AdvancedJScrollPane with specified scrollbar policies. The available policy settings are listed at setVerticalScrollBarPolicy(int) and setHorizontalScrollBarPolicy(int).


AdvancedJScrollPane

public AdvancedJScrollPane(Component view)
Creates an AdvancedJScrollPane that displays the contents of the specified component, where both horizontal and vertical scrollbars appear whenever the component's contents are larger than the view.


AdvancedJScrollPane

public AdvancedJScrollPane(Component view,
                           int vsbPolicy,
                           int hsbPolicy)
Creates an AdvancedJScrollPane that displays the view component in a viewport whose view position can be controlled with a pair of scrollbars. The scrollbar policies specify when the scrollbars are displayed, For example, if vsbPolicy is VERTICAL_SCROLLBAR_AS_NEEDED then the vertical scrollbar only appears if the view doesn't fit vertically. The available policy settings are listed at setVerticalScrollBarPolicy(int) and setHorizontalScrollBarPolicy(int).

Method Detail

convertBackX

public int convertBackX(int x)
Coverts an x-coordinate back from the ordinate system that is modified by locked rows/columns.

Parameters:
x - the x-coordinate to convert
Returns:
the converted x-coordinate

convertBackY

public int convertBackY(int y)
Coverts an y-coordinate back from the ordinate system that is modified by locked rows/columns.

Parameters:
y - the y-coordinate to convert
Returns:
the converted y-coordinate

convertX

public int convertX(int x)
Coverts an x-coordinate to the ordinate system that is modified by locked rows/columns.

Parameters:
x - the x-coordinate to convert
Returns:
the converted x-coordinate

convertX

public int convertX(int x,
                    int delta)
Coverts an x-coordinate to the ordinate system that is modified by locked rows/columns.

Parameters:
x - the x-coordinate to convert
delta - the distance a column was dragged
Returns:
the converted x-coordinate

convertY

public int convertY(int y)
Coverts a y-coordinate to the ordinate system that is modified by locked rows/columns.

Parameters:
y - the y-coordinate to convert
Returns:
the converted y-coordinate

createDefaultLockedModel

protected LockedTableModel createDefaultLockedModel()
Creates and returns the default locked table model.

Returns:
a new instance of DefaultLockedTableModel.

createHorizontalScrollBar

public JScrollBar createHorizontalScrollBar()
Returns a specialized horizontal scrollbar which is a subclass of JScrollPane.ScrollBar.

Overrides:
createHorizontalScrollBar in class JScrollPane
Returns:
a specialized horizontal scrollbar.
See Also:
JScrollBar

doLayout

public void doLayout()
Causes this container to lay out its components.

Overrides:
doLayout in class Container
See Also:
LayoutManager.layoutContainer(java.awt.Container), Container.setLayout(java.awt.LayoutManager), Container.validate()

getContainsViewable

public boolean getContainsViewable()
Determines whether the scrollpane is configured to use a viewable resizer.

Returns:
true if the scrollpane is configured to use a viewable resizer, false otherwise

getLockedModel

public LockedTableModel getLockedModel()
Returns the locked table model.

Returns:
the locked table model.

layout

public void layout()
Causes this container to lay out its components.

Overrides:
layout in class Container

prepareEditorComponent

public Component prepareEditorComponent(TableCellEditor editor,
                                        Component c,
                                        int row,
                                        int column)
Prepares and returns a table cell editor component suitable for locked rows/columns.

Parameters:
editor - the table's cell editor that prepared the component
c - the component being edited, as it came from the JTable.prepareEditor method
row - the row of the cell to edit, where 0 is the first
column - the column of the cell to edit, where 0 is the first
Returns:
the editor component suitable for locked rows/columns

setColumnHeader

public void setColumnHeader(JViewport viewport)
Removes the old columnHeader, if it exists. If the new columnHeader isn't null, sync the x coordinate of the its viewPosition with the viewport (if there is one) and then add it to the scrollpane.

Most applications will find it more convenient to use setRowHeaderView to add a row header component and its viewport to the scrollpane.

Overrides:
setColumnHeader in class JScrollPane
See Also:
JScrollPane.getColumnHeader(), JScrollPane.setColumnHeaderView(java.awt.Component)

setColumnHeaderView

public void setColumnHeaderView(Component view)
Creates a column-header viewport if necessary, sets its view, and then adds the column-header viewport to the scrollpane. For example:
 JScrollPane scrollpane = new JScrollPane();
 scrollpane.setViewportView(myBigComponentToScroll);
 scrollpane.setColumnHeaderView(myBigComponentsColumnHeader);
 

Overrides:
setColumnHeaderView in class JScrollPane
Parameters:
view - the component to display as the column header
See Also:
JScrollPane.setColumnHeader(javax.swing.JViewport), JViewport.setView(java.awt.Component)

setContainsViewable

public void setContainsViewable(boolean containsViewable)
Enables/disables the viewable resizer functionality in the scrollpane.

Parameters:
containsViewable - true if the scrollpane is configured to use a viewable resizer, false otherwise

setLockedModel

public void setLockedModel(LockedTableModel lockedTableModel)
Assigns a new locked table model.

Parameters:
lockedTableModel - the locked table model to assign.

setRowHeader

public void setRowHeader(JViewport viewport)
Removes the old rowHeader, if it exists. If the new rowHeader isn't null, syncs the y coordinate of its viewPosition with the viewport (if there is one) and then adds it to the scrollpane.

Most applications will find it more convenient to use setRowHeaderView to add a row header component and its viewport to the scrollpane.

Overrides:
setRowHeader in class JScrollPane
Parameters:
viewport - the new row header to be used; if null the old row header is still removed and the new rowHeader is set to null
See Also:
JScrollPane.getRowHeader(), JScrollPane.setRowHeaderView(java.awt.Component)

setRowHeaderView

public void setRowHeaderView(Component view)
Creates a row-header viewport if necessary, sets its view and then adds the row-header viewport to the scrollpane. For example:
 JScrollPane scrollpane = new JScrollPane();
 scrollpane.setViewportView(myBigComponentToScroll);
 scrollpane.setRowHeaderView(myBigComponentsRowHeader);
 

Overrides:
setRowHeaderView in class JScrollPane
Parameters:
view - the component to display as the row header
See Also:
JScrollPane.setRowHeader(javax.swing.JViewport), JViewport.setView(java.awt.Component)

setViewport

public void setViewport(JViewport viewport)
Removes the old viewport (if there is one); forces the viewPosition of the new viewport to be in the +x,+y quadrant; syncs up the row and column headers (if there are any) with the new viewport; and finally syncs the scrollbars and headers with the new viewport.

Most applications will find it more convenient to use setViewportView to add a viewport and a view to the scrollpane.

Overrides:
setViewport in class JScrollPane
Parameters:
viewport - the new viewport to be used; if viewport is null, the old viewport is still removed and the new viewport is set to null
See Also:
JScrollPane.createViewport(), JScrollPane.getViewport(), JScrollPane.setViewportView(java.awt.Component)

setViewportView

public void setViewportView(Component view)
Creates a viewport if necessary and then sets its view. Applications that don't provide the view directly to the JScrollPane constructor should use this method to specify the scrollable child that's going to be displayed in the scrollpane. For example:
 JScrollPane scrollpane = new JScrollPane();
 scrollpane.setViewportView(myBigComponentToScroll);
 
Applications should not add children directly to the scrollpane.

Overrides:
setViewportView in class JScrollPane
Parameters:
view - the component to add to the viewport
See Also:
JScrollPane.setViewport(javax.swing.JViewport), JViewport.setView(java.awt.Component)

validateTree

public void validateTree()
Recursively descends the container tree and recomputes the layout for any subtrees marked as needing it (those marked as invalid). Synchronization should be provided by the method that calls this one: validate.

Overrides:
validateTree in class Container

Copyright © 2005 Scientific Applications. All Rights Reserved.