Spec-Zone .ru
спецификации, руководства, описания, API
|
|
JavaTM 2 Platform Standard Edition |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--javax.swing.JComponent | +--javax.swing.JViewport
The "viewport" or "porthole" through which you see the underlying information. When you scroll, what moves is the viewport. Its like peering through a camera's viewfinder. Moving the viewfinder upwards brings new things into view at the top of the picture and loses things that were at the bottom.
NOTE:We have implemented a faster scrolling algorithm that does not require a buffer to draw in. The algorithm works as follows:
This approach can cause slower times than the backing store approach when the viewport is obscured by another window, or partially offscreen. When another window obscures the viewport the copyArea will copy garbage and a paint event will be generated by the system to inform us we need to paint the newly exposed region. The only way to handle this is to repaint the whole viewport, which can cause slower performance than the backing store case. In most applications very rarely will the user be scrolling while the viewport is obscured by another window or offscreen, so this optimization is usually worth the performance hit when obscured.
To turn this behavior on, put the client property "EnableWindowBlit" (a method will added to enable/disable this in the future).
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
JScrollPane
, Serialized FormInner Class Summary | |
protected class |
JViewport.AccessibleJViewport
The class used to obtain the accessible role for this object. |
protected class |
JViewport.ViewListener
A listener for the view. |
Inner classes inherited from class javax.swing.JComponent |
JComponent.AccessibleJComponent |
Field Summary | |
protected boolean |
backingStore
True when this viewport is maintaining an offscreen image of its contents, so that some scrolling can take place using fast "bit-blit" operations instead of by accessing the view object to construct the display. |
protected Image |
backingStoreImage
The view image used for a backing store. |
protected boolean |
isViewSizeSet
True when the viewport dimensions have been determined. |
protected Point |
lastPaintPosition
The last viewPosition that we've painted, so we know how much of the backing store image is valid. |
protected boolean |
scrollUnderway
The scrollUnderway flag is used for components like JList. |
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 |
Constructor Summary | |
JViewport()
Create a JViewport |
Method Summary | |
void |
addChangeListener(ChangeListener l)
Add a ChangeListener to the list that's notified each time the view's size, position, or the viewport's extent size has changed. |
protected void |
addImpl(Component child,
Object constraints,
int index)
Sets the Viewport's one lightweight child, which can be null. |
protected boolean |
computeBlit(int dx,
int dy,
Point blitFrom,
Point blitTo,
Dimension blitSize,
Rectangle blitPaint)
Computes the parameters for a blit where the backing store image currently contains oldLoc in the upper left hand corner and we're scrolling to newLoc. |
protected LayoutManager |
createLayoutManager()
Subclassers can override this to install a different layout manager (or null) in the constructor. |
protected JViewport.ViewListener |
createViewListener()
Create a listener for the view. |
protected void |
firePropertyChange(String propertyName,
Object oldValue,
Object newValue)
Notifies listeners of a property change. |
protected void |
fireStateChanged()
|
AccessibleContext |
getAccessibleContext()
Get the AccessibleContext associated with this JComponent |
Dimension |
getExtentSize()
Returns the size of the visible part of the view in view coordinates. |
Insets |
getInsets()
Returns the insets (border) dimensions as (0,0,0,0), since borders are not supported on a JViewport. |
Insets |
getInsets(Insets insets)
Returns an Insets object containing this JViewport's inset values. |
Component |
getView()
Returns the Viewport's one child or null. |
Point |
getViewPosition()
Returns the view coordinates that appear in the upper left hand corner of the viewport, 0,0 if there's no view. |
Rectangle |
getViewRect()
Return a rectangle whose origin is getViewPosition and size is getExtentSize(). |
Dimension |
getViewSize()
If the view's size hasn't been explicitly set, return the preferred size, otherwise return the view's current size. |
boolean |
isBackingStoreEnabled()
Returns true if this viewport is maintaining an offscreen image of its contents. |
boolean |
isOptimizedDrawingEnabled()
The JViewport overrides the default implementation of this method (in JComponent) to return false. |
void |
paint(Graphics g)
Depending on whether the backingStore is enabled, either paint the image through the backing store or paint just the recently exposed part, using the backing store to "blit" the remainder. |
protected String |
paramString()
Returns a string representation of this JViewport. |
void |
remove(Component child)
Removes the Viewport's one lightweight child. |
void |
removeChangeListener(ChangeListener l)
Remove a ChangeListener from the list that's notified each time the views size, position, or the viewports extent size has changed. |
void |
repaint(long tm,
int x,
int y,
int w,
int h)
We always repaint in our parent coordinate system to make sure only one paint is performed by the RepaintManager. |
void |
reshape(int x,
int y,
int w,
int h)
Sets the bounds of this viewport. |
void |
scrollRectToVisible(Rectangle contentRect)
Overridden to scroll the view so that Rectangle within the view becomes visible. |
void |
setBackingStoreEnabled(boolean x)
If true if this viewport will maintain an offscreen image of its contents. |
void |
setBorder(Border border)
The viewport "scrolls" it's child (called the "view") by the normal parent/child clipping (typically the view is moved in the opposite direction of the scroll). |
void |
setExtentSize(Dimension newExtent)
Set the size of the visible part of the view using view coordinates. |
void |
setView(Component view)
Sets the Viewport's one lightweight child ( view ),
which can be null. |
void |
setViewPosition(Point p)
Sets the view coordinates that appear in the upper left hand corner of the viewport, does nothing if there's no view. |
void |
setViewSize(Dimension newSize)
Sets the view coordinates that appear in the upper left hand corner of the viewport, and the size of the view. |
Dimension |
toViewCoordinates(Dimension size)
Convert a size in pixel coordinates to view coordinates. |
Point |
toViewCoordinates(Point p)
Convert a point in pixel coordinates to view coordinates. |
Methods inherited from class java.awt.Container |
add,
add,
add,
add,
add,
addContainerListener,
countComponents,
deliverEvent,
doLayout,
findComponentAt,
findComponentAt,
getComponent,
getComponentAt,
getComponentAt,
getComponentCount,
getComponents,
getLayout,
insets,
invalidate,
isAncestorOf,
layout,
list,
list,
locate,
minimumSize,
paintComponents,
preferredSize,
print,
printComponents,
processContainerEvent,
processEvent,
remove,
removeAll,
removeContainerListener,
setCursor,
setLayout,
validate,
validateTree |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
protected boolean isViewSizeSet
protected Point lastPaintPosition
protected boolean backingStore
protected transient Image backingStoreImage
protected boolean scrollUnderway
Constructor Detail |
public JViewport()
Method Detail |
protected void addImpl(Component child, Object constraints, int index)
child
- the Component ______________constraints
- the Object ______________index
- the int ______________setView(java.awt.Component)
public void remove(Component child)
setView(java.awt.Component)
public void scrollRectToVisible(Rectangle contentRect)
contentRect
- the Rectangle to displaypublic final void setBorder(Border border)
border
- the Border to setpublic final Insets getInsets()
setBorder(javax.swing.border.Border)
public final Insets getInsets(Insets insets)
insets
- the Insets object which can be reused.getInsets()
public boolean isOptimizedDrawingEnabled()
public void paint(Graphics g)
The term "blit" is the pronounced version of the PDP-10 BLT (BLock Transfer) instruction, which copied a block of bits. (In case you were curious.)
g
- the Graphics context within which to paintpublic void reshape(int x, int y, int w, int h)
x
- left edge of the originy
- top edge of the originw
- width in pixelsh
- height in pixelsJComponent.reshape(int, int, int, int)
public boolean isBackingStoreEnabled()
public void setBackingStoreEnabled(boolean x)
public Component getView()
setView(java.awt.Component)
public void setView(Component view)
view
),
which can be null.getView()
public Dimension getViewSize()
public void setViewSize(Dimension newSize)
newSize
- a Dimension object specifying the size and
location of the new view coordinates, or null if there
is no viewpublic Point getViewPosition()
public void setViewPosition(Point p)
p
- a Point object giving the upper left coordinatespublic Rectangle getViewRect()
protected boolean computeBlit(int dx, int dy, Point blitFrom, Point blitTo, Dimension blitSize, Rectangle blitPaint)
public Dimension getExtentSize()
public Dimension toViewCoordinates(Dimension size)
size
- a Dimension object using pixel coordinatespublic Point toViewCoordinates(Point p)
p
- a Point object using pixel coordinatespublic void setExtentSize(Dimension newExtent)
newExtent
- a Dimension object specifying the size of the viewprotected JViewport.ViewListener createViewListener()
protected LayoutManager createLayoutManager()
public void addChangeListener(ChangeListener l)
l
- the ChangeListener to addremoveChangeListener(javax.swing.event.ChangeListener)
,
setViewPosition(java.awt.Point)
,
setViewSize(java.awt.Dimension)
,
setExtentSize(java.awt.Dimension)
public void removeChangeListener(ChangeListener l)
l
- the ChangeListener to removeaddChangeListener(javax.swing.event.ChangeListener)
protected void fireStateChanged()
public void repaint(long tm, int x, int y, int w, int h)
tm
- maximum time in milliseconds before updatex
- the x coordinate (pixels over from left)y
- the y coordinate (pixels down from top)width
- the widthheight
- the heightComponent.update(java.awt.Graphics)
protected String paramString()
null
.protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
windowBlit
ivar (putClientProperty is final).propertyName
- The programmatic name of the property that was changed.oldValue
- The old value of the property.newValue
- The new value of the property.PropertyChangeSupport
public AccessibleContext getAccessibleContext()
|
JavaTM 2 Platform Standard Edition |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |