com.zfqjava.swing
Class JLineBar

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--com.zfqjava.swing.JLineBar
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.Scrollable, java.io.Serializable

public class JLineBar
extends javax.swing.JComponent
implements javax.accessibility.Accessible, javax.swing.Scrollable

JLineBar provides a bar represents the line number of the text component.

See Also:
Serialized Form

Inner Class Summary
protected  class JLineBar.AccessibleJLineBar
          This class implements accessibility support for the JLineBar class.
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
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
JLineBar()
          Constructs a JLineBar.
JLineBar(int lineCount)
          Constructs a JLineBar with a specified line count.
JLineBar(int lineCount, javax.swing.ListSelectionModel selectionModel)
          Constructs a JLineBar with a selection model and a specified line count.
JLineBar(javax.swing.ListSelectionModel selectionModel)
          Constructs a JLineBar with a selection model.
 
Method Summary
 void addListSelectionListener(javax.swing.event.ListSelectionListener listener)
          Adds a listener to the list that's notified each time a change to the selection occurs.
protected  javax.swing.ListSelectionModel createSelectionModel()
          Returns an instance of DefaultListSelectionModel.
protected  void fireSelectionValueChanged(int firstIndex, int lastIndex, boolean isAdjusting)
          Notifies JLineBar ListSelectionListeners that the selection model has changed.
 javax.accessibility.AccessibleContext getAccessibleContext()
          Gets the AccessibleContext associated with this JLineBar.
 java.awt.Component getForComponent()
          Returns the component that the JTextFinder attach.
 java.awt.Rectangle getHeaderRect(int line)
          Returns the rectangle containing the header tile at line.
 javax.swing.Icon getIconAt(int lineno)
          Returns the icon at the specify line.
 int getLineCount()
          Gets the current line count number.
 int getLineHeight()
          Returns the line height.
 int getLineHeight(int lineno)
          Returns the line height for the specified line number
 int getLineWidth()
          Returns the line width.
 javax.swing.event.ListSelectionListener[] getListSelectionListeners()
          Returns an array of all the ListSelectionListeners added to this JLineBar with addListSelectionListener().
 java.awt.Dimension getPreferredScrollableViewportSize()
          Returns the preferred size of the viewport for a view component.
 boolean getResizingAllowed()
          Returns true if the user is allowed to resize rows by dragging between their headers, false otherwise.
 int getResizingLine()
          Returns the resizing line.
 int getScrollableBlockIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
          Components that display logical rows or columns should compute the scroll increment that will completely expose one block of rows or columns, depending on the value of orientation.
 boolean getScrollableTracksViewportHeight()
          Return true if a viewport should always force the height of this Scrollable to match the height of the viewport.
 boolean getScrollableTracksViewportWidth()
          Return true if a viewport should always force the width of this Scrollable to match the width of the viewport.
 int getScrollableUnitIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
          Components that display logical rows or columns should compute the scroll increment that will completely expose one new row or column, depending on the value of orientation.
 int getSelectedLine()
          Returns the selected line number.
 int[] getSelectedLines()
          Returns the selected lines number array.
 int getSelectionMode()
          Returns whether single-item or multiple-item selections are allowed.
 javax.swing.ListSelectionModel getSelectionModel()
          Returns the value of the current selection model.
 com.zfqjava.swing.plaf.LineBarUI getUI()
          Returns the look and feel (L&F) object that renders this component.
 java.lang.String getUIClassID()
          Returns a string that specifies the name of the L&F class that renders this component.
 boolean isFixedLineHeight()
          Determines the JLineBar has a fixed line height.
protected  java.lang.String paramString()
          Returns a string representation of this JLineBar.
 void removeListSelectionListener(javax.swing.event.ListSelectionListener listener)
          Removes a listener from the list that's notified each time a change to the selection occurs.
 void setForComponent(java.awt.Component c)
          Sets the component that the JTextFinder attach.
 void setIconAt(javax.swing.Icon icon, int lineno)
          Sets the icon at the specify line.
 void setLineCount(int lineCount)
          Sets the current line count number.
 void setLineHeight(int lineHeight)
          Sets the line height.
 void setLineHeight(int lineno, int lineHeight)
          Sets the line height for the specified line number.
 void setLineWidth(int lineWidth)
          Sets the line width.
 void setResizingAllowed(boolean resizingAllowed)
          Sets whether the user can resize rows by dragging between headers.
 void setResizingLine(int line)
          Sets the resizing line.
 void setSelectedLine(int lineno)
          Sets the selected line number.
 void setSelectedLines(int[] lines)
          Sets the selected lines number array.
 void setSelectionMode(int selectionMode)
          Determines whether single-item or multiple-item selections are allowed.
 void setSelectionModel(javax.swing.ListSelectionModel selectionModel)
          Sets the selectionModel for the list to a non-null ListSelectionModel implementation.
 void setUI(com.zfqjava.swing.plaf.LineBarUI ui)
          Sets the look and feel (L&F) object that renders this component.
 void updateUI()
          Resets the UI property with a value from the current look and feel.
 
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, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JLineBar

public JLineBar()
Constructs a JLineBar.
See Also:
JLineBar()

JLineBar

public JLineBar(int lineCount)
Constructs a JLineBar with a specified line count.
Parameters:
lineCount - a specified line count
See Also:
JLineBar()

JLineBar

public JLineBar(javax.swing.ListSelectionModel selectionModel)
Constructs a JLineBar with a selection model.
Parameters:
selectionModel - a selection model
See Also:
JLineBar()

JLineBar

public JLineBar(int lineCount,
                javax.swing.ListSelectionModel selectionModel)
Constructs a JLineBar with a selection model and a specified line count.
Parameters:
lineCount - a specified line count
selectionModel - a selection model
See Also:
JLineBar()
Method Detail

updateUI

public void updateUI()
Resets the UI property with a value from the current look and feel.
Overrides:
updateUI in class javax.swing.JComponent
See Also:
JComponent.updateUI()

getUI

public com.zfqjava.swing.plaf.LineBarUI getUI()
Returns the look and feel (L&F) object that renders this component.
Returns:
the LineBarUI object that renders this component

setUI

public void setUI(com.zfqjava.swing.plaf.LineBarUI ui)
Sets the look and feel (L&F) object that renders this component.
Parameters:
ui - the LineBarUI L&F object
See Also:
UIDefaults.getUI(javax.swing.JComponent)

getUIClassID

public java.lang.String getUIClassID()
Returns a string that specifies the name of the L&F class that renders this component.
Overrides:
getUIClassID in class javax.swing.JComponent
Returns:
"LineBarUI"
See Also:
JComponent.getUIClassID(), UIDefaults.getUI(javax.swing.JComponent)

createSelectionModel

protected javax.swing.ListSelectionModel createSelectionModel()
Returns an instance of DefaultListSelectionModel. This method is used by the constructor to initialize the selectionModel property.
Returns:
the ListSelectionModel used by this JList.
See Also:
setSelectionModel(javax.swing.ListSelectionModel), DefaultListSelectionModel

getSelectionModel

public javax.swing.ListSelectionModel getSelectionModel()
Returns the value of the current selection model. The selection model handles the task of making single selections, selections of contiguous ranges, and non-contiguous selections.
Returns:
the ListSelectionModel that implements list selections
See Also:
setSelectionModel(javax.swing.ListSelectionModel), ListSelectionModel

setSelectionModel

public void setSelectionModel(javax.swing.ListSelectionModel selectionModel)
Sets the selectionModel for the list to a non-null ListSelectionModel implementation. The selection model handles the task of making single selections, selections of contiguous ranges, and non-contiguous selections.

This is a JavaBeans bound property.

Parameters:
selectionModel - the ListSelectionModel that implements the selections
Throws:
java.lang.IllegalArgumentException - if selectionModel is null
See Also:
getSelectionModel()

setSelectionMode

public void setSelectionMode(int selectionMode)
Determines whether single-item or multiple-item selections are allowed. The following selectionMode values are allowed:
Parameters:
selectionMode - an integer specifying the type of selections that are permissible
See Also:
getSelectionMode()

getSelectionMode

public int getSelectionMode()
Returns whether single-item or multiple-item selections are allowed.
Returns:
the value of the selectionMode property
See Also:
setSelectionMode(int)

setResizingAllowed

public void setResizingAllowed(boolean resizingAllowed)
Sets whether the user can resize rows by dragging between headers.
Parameters:
resizingAllowed - true if table view should allow resizing
Since:
JDataGrid 1.1
See Also:
getResizingAllowed()

getResizingAllowed

public boolean getResizingAllowed()
Returns true if the user is allowed to resize rows by dragging between their headers, false otherwise. The default is true. You can resize rows programmatically regardless of this setting.
Returns:
the resizingAllowed property
Since:
JDataGrid 1.1
See Also:
setResizingAllowed(boolean)

setResizingLine

public void setResizingLine(int line)
Sets the resizing line.
Parameters:
line - the line being resizing
Since:
JDataGrid 1.1
See Also:
getResizingLine()

getResizingLine

public int getResizingLine()
Returns the resizing line.
Returns:
the resizing line
Since:
JDataGrid 1.1
See Also:
setResizingLine(int)

setForComponent

public void setForComponent(java.awt.Component c)
Sets the component that the JTextFinder attach.
Parameters:
c - the component to attach
Since:
JDataGrid 1.1
See Also:
getForComponent()

getForComponent

public java.awt.Component getForComponent()
Returns the component that the JTextFinder attach.
Returns:
the component to attach
Since:
JDataGrid 1.1
See Also:
setForComponent(java.awt.Component)

getSelectedLine

public int getSelectedLine()
Returns the selected line number.
Returns:
the selected line number
See Also:
setSelectedLine(int)

setSelectedLine

public void setSelectedLine(int lineno)
Sets the selected line number.
Parameters:
lineno - the line number to select
See Also:
getSelectedLine()

getSelectedLines

public int[] getSelectedLines()
Returns the selected lines number array.
Returns:
the selected lines number array
See Also:
setSelectedLines(int[])

setSelectedLines

public void setSelectedLines(int[] lines)
Sets the selected lines number array.
Parameters:
lines - the lines number array to select
See Also:
getSelectedLines()

getLineCount

public int getLineCount()
Gets the current line count number.
Returns:
the current line count number
See Also:
setLineCount(int)

setLineCount

public void setLineCount(int lineCount)
Sets the current line count number.
Parameters:
count - the line count to select
See Also:
getLineCount()

setLineHeight

public void setLineHeight(int lineHeight)
Sets the line height.
Parameters:
lineHeight - the line height
See Also:
getLineHeight()

getLineHeight

public int getLineHeight()
Returns the line height.
See Also:
setLineHeight(int)

setLineHeight

public void setLineHeight(int lineno,
                          int lineHeight)
Sets the line height for the specified line number.
Parameters:
lineno - the specified line number
lineHeight - the line height
See Also:
setLineHeight(int), getLineHeight(int), getLineHeight()

getLineHeight

public int getLineHeight(int lineno)
Returns the line height for the specified line number
Parameters:
lineno - the specified line number
See Also:
setLineHeight(int,int), setLineHeight(int), setLineHeight(int)

isFixedLineHeight

public boolean isFixedLineHeight()
Determines the JLineBar has a fixed line height.
Returns:
true if the JLineBar has a fixed line height, false otherwise

setLineWidth

public void setLineWidth(int lineWidth)
Sets the line width.
Parameters:
lineWidth - the line width
See Also:
getLineWidth()

getLineWidth

public int getLineWidth()
Returns the line width.
See Also:
setLineWidth(int)

getHeaderRect

public java.awt.Rectangle getHeaderRect(int line)
Returns the rectangle containing the header tile at line. When the line parameter is out of bounds this method uses the same conventions as the JTable method getCellRect.
Returns:
the rectangle containing the header tile at line
See Also:
JTable.getCellRect(int, int, boolean)

setIconAt

public void setIconAt(javax.swing.Icon icon,
                      int lineno)
Sets the icon at the specify line.
Parameters:
icon - the icon to set at the line bar
lineno - the line number that the icon to set
See Also:
getIconAt(int)

getIconAt

public javax.swing.Icon getIconAt(int lineno)
Returns the icon at the specify line.
Parameters:
lineno - the line number that the icon to set
Returns:
the icon at the specify line
See Also:
setIconAt(javax.swing.Icon, int)

fireSelectionValueChanged

protected void fireSelectionValueChanged(int firstIndex,
                                         int lastIndex,
                                         boolean isAdjusting)
Notifies JLineBar ListSelectionListeners that the selection model has changed. It's used to forward ListSelectionEvents from the selectionModel to the ListSelectionListeners added directly to the JLineBar.
Parameters:
firstIndex - the first selected index
lastIndex - the last selected index
isAdjusting - true if multiple changes are being made
See Also:
addListSelectionListener(javax.swing.event.ListSelectionListener), removeListSelectionListener(javax.swing.event.ListSelectionListener), EventListenerList

addListSelectionListener

public void addListSelectionListener(javax.swing.event.ListSelectionListener listener)
Adds a listener to the list that's notified each time a change to the selection occurs. Listeners added directly to the JLineBar will have their ListSelectionEvent.getSource() == this JLineBar (instead of the ListSelectionModel).
Parameters:
listener - the ListSelectionListener to add
See Also:
getSelectionModel(), getListSelectionListeners()

removeListSelectionListener

public void removeListSelectionListener(javax.swing.event.ListSelectionListener listener)
Removes a listener from the list that's notified each time a change to the selection occurs.
Parameters:
listener - the ListSelectionListener to remove
See Also:
addListSelectionListener(javax.swing.event.ListSelectionListener), getSelectionModel()

getListSelectionListeners

public javax.swing.event.ListSelectionListener[] getListSelectionListeners()
Returns an array of all the ListSelectionListeners added to this JLineBar with addListSelectionListener().
Returns:
all of the ListSelectionListeners added or an empty array if no listeners have been added
See Also:
addListSelectionListener(javax.swing.event.ListSelectionListener)

getPreferredScrollableViewportSize

public java.awt.Dimension getPreferredScrollableViewportSize()
Returns the preferred size of the viewport for a view component. For example the preferredSize of a JLineBar component is the size required to accommodate all of the cells in its list however the value of preferredScrollableViewportSize is the size required for JLineBar.getVisibleRowCount() rows. A component without any properties that would effect the viewport size should just return getPreferredSize() here.
Specified by:
getPreferredScrollableViewportSize in interface javax.swing.Scrollable
Returns:
The preferredSize of a JViewport whose view is this Scrollable.
See Also:
JComponent.getPreferredSize()

getScrollableUnitIncrement

public int getScrollableUnitIncrement(java.awt.Rectangle visibleRect,
                                      int orientation,
                                      int direction)
Components that display logical rows or columns should compute the scroll increment that will completely expose one new row or column, depending on the value of orientation. Ideally, components should handle a partially exposed row or column by returning the distance required to completely expose the item.

Scrolling containers, like JScrollPane, will use this method each time the user requests a unit scroll.

Specified by:
getScrollableUnitIncrement in interface javax.swing.Scrollable
Parameters:
visibleRect - The view area visible within the viewport
orientation - Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
direction - Less than zero to scroll up/left, greater than zero for down/right.
Returns:
The "unit" increment for scrolling in the specified direction. This value should always be positive.
See Also:
JScrollBar.setUnitIncrement(int)

getScrollableBlockIncrement

public int getScrollableBlockIncrement(java.awt.Rectangle visibleRect,
                                       int orientation,
                                       int direction)
Components that display logical rows or columns should compute the scroll increment that will completely expose one block of rows or columns, depending on the value of orientation.

Scrolling containers, like JScrollPane, will use this method each time the user requests a block scroll.

Specified by:
getScrollableBlockIncrement in interface javax.swing.Scrollable
Parameters:
visibleRect - The view area visible within the viewport
orientation - Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
direction - Less than zero to scroll up/left, greater than zero for down/right.
Returns:
The "block" increment for scrolling in the specified direction. This value should always be positive.
See Also:
JScrollBar.setBlockIncrement(int)

getScrollableTracksViewportWidth

public boolean getScrollableTracksViewportWidth()
Return true if a viewport should always force the width of this Scrollable to match the width of the viewport. For example a normal text view that supported line wrapping would return true here, since it would be undesirable for wrapped lines to disappear beyond the right edge of the viewport. Note that returning true for a Scrollable whose ancestor is a JScrollPane effectively disables horizontal scrolling.

Scrolling containers, like JViewport, will use this method each time they are validated.

Specified by:
getScrollableTracksViewportWidth in interface javax.swing.Scrollable
Returns:
True if a viewport should force the Scrollables width to match its own.

getScrollableTracksViewportHeight

public boolean getScrollableTracksViewportHeight()
Return true if a viewport should always force the height of this Scrollable to match the height of the viewport. For example a columnar text view that flowed text in left to right columns could effectively disable vertical scrolling by returning true here.

Scrolling containers, like JViewport, will use this method each time they are validated.

Specified by:
getScrollableTracksViewportHeight in interface javax.swing.Scrollable
Returns:
True if a viewport should force the Scrollables height to match its own.

paramString

protected java.lang.String paramString()
Returns a string representation of this JLineBar. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.
Overrides:
paramString in class javax.swing.JComponent
Returns:
a string representation of this JLineBar.

getAccessibleContext

public javax.accessibility.AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this JLineBar. For JLineBars, the AccessibleContext takes the form of an AccessibleJLineBar. A new AccessibleJLineBar instance is created if necessary.
Specified by:
getAccessibleContext in interface javax.accessibility.Accessible
Overrides:
getAccessibleContext in class javax.swing.JComponent
Returns:
an AccessibleJLineBar that serves as the AccessibleContext of this JLineBar


Copyright © 2001-2003 Extreme Component, Inc. All rights reserved.