|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JViewport
public class JViewport
_
+-------------------------------+ ...........Y1 \
| view | . \
| (this component's child) | . > VY
| | . / = Y2-Y1
| +------------------------------+ ....Y2_/
| | viewport | | .
| | (this component) | | .
| | | | .
| | | | .
| | | | .
| | | | .
| +------------------------------+ ....Y3
| | .
| . | . .
| . | . .
+---------.---------------------+ ...........Y4
. . . .
. . . .
. . . .
X1.......X2.....................X3.......X4
\____ ___/
\/
VX = X2-X1
A viewport is, like all swing components, located at some position in the swing component tree; that location is exactly the same as any other components: the viewport's "bounds".
But in terms of drawing its child, the viewport thinks of itself as
covering a particular position of the view's coordinate space.
For example, the getViewPosition() method returns
the position (VX,VY) shown above, which is an position in
"view space", even though this is implemented by positioning
the underlying child at position (-VX,-VY)
| Nested Class Summary | |
|---|---|
protected class |
JViewport.AccessibleJViewport
Provides accessibility support for JViewport. |
protected class |
JViewport.ViewListener
A ComponentListener that listens for
changes of the view's size. |
| 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 |
backingStore
Deprecated. since JDK 1.3 |
static int |
BACKINGSTORE_SCROLL_MODE
|
protected Image |
backingStoreImage
The backingstore image used for the backingstore and blit scroll methods. |
static int |
BLIT_SCROLL_MODE
|
protected boolean |
isViewSizeSet
|
protected Point |
lastPaintPosition
The position at which the view has been drawn the last time. |
protected boolean |
scrollUnderway
|
static int |
SIMPLE_SCROLL_MODE
|
| 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 | |
|---|---|
JViewport()
|
|
| Method Summary | |
|---|---|
void |
addChangeListener(ChangeListener listener)
|
protected void |
addImpl(Component comp,
Object constraints,
int index)
This method is called by all the add() methods to perform
the actual adding of the component. |
protected boolean |
computeBlit(int dx,
int dy,
Point blitFrom,
Point blitTo,
Dimension blitSize,
Rectangle blitPaint)
Computes the parameters for the blitting scroll method. |
protected LayoutManager |
createLayoutManager()
Creates the LayoutManager that is used for this viewport. |
protected JViewport.ViewListener |
createViewListener()
Creates a JViewport.ViewListener that is supposed to listen for
size changes on the view component. |
protected void |
fireStateChanged()
|
AccessibleContext |
getAccessibleContext()
Returns the accessible context for this JViewport. |
ChangeListener[] |
getChangeListeners()
|
Dimension |
getExtentSize()
|
Insets |
getInsets()
Get the component's insets, which are calculated from the JComponent.border property. |
Insets |
getInsets(Insets insets)
Get the component's insets, which are calculated from the JComponent.border property. |
int |
getScrollMode()
|
ViewportUI |
getUI()
This method returns the viewport's UI delegate. |
String |
getUIClassID()
This method returns the String ID of the UI class of Separator. |
Component |
getView()
|
Point |
getViewPosition()
Get the viewport's position in view space. |
Rectangle |
getViewRect()
|
Dimension |
getViewSize()
Returns the viewSize when set, or the preferred size of the set Component view. |
boolean |
isBackingStoreEnabled()
Deprecated. 1.4 |
boolean |
isOptimizedDrawingEnabled()
Overridden to return false, so the JViewport's paint method
gets called instead of directly calling the children. |
void |
paint(Graphics g)
Paint the component. |
void |
removeChangeListener(ChangeListener listener)
|
void |
repaint(long tm,
int x,
int y,
int w,
int h)
Forward repaint to parent to make sure only one paint is performed by the RepaintManager. |
void |
reshape(int x,
int y,
int w,
int h)
Moves and resizes the component. |
void |
scrollRectToVisible(Rectangle contentRect)
Scrolls the view so that contentRect becomes visible. |
void |
setBackingStoreEnabled(boolean b)
Deprecated. 1.4 |
void |
setBorder(Border border)
Set the value of the JComponent.border property. |
void |
setExtentSize(Dimension newSize)
|
void |
setScrollMode(int mode)
|
void |
setUI(ViewportUI ui)
This method sets the viewport's UI delegate. |
void |
setView(Component v)
|
void |
setViewPosition(Point p)
|
void |
setViewSize(Dimension newSize)
|
Dimension |
toViewCoordinates(Dimension size)
|
Point |
toViewCoordinates(Point p)
|
void |
updateUI()
This method resets the UI used to the Look and Feel defaults.. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int SIMPLE_SCROLL_MODE
public static final int BLIT_SCROLL_MODE
public static final int BACKINGSTORE_SCROLL_MODE
protected boolean scrollUnderway
protected boolean isViewSizeSet
protected boolean backingStore
protected Image backingStoreImage
protected Point lastPaintPosition
| Constructor Detail |
|---|
public JViewport()
| Method Detail |
|---|
public Dimension getExtentSize()
public Dimension toViewCoordinates(Dimension size)
public Point toViewCoordinates(Point p)
public void setExtentSize(Dimension newSize)
public Dimension getViewSize()
public void setViewSize(Dimension newSize)
public Point getViewPosition()
public void setViewPosition(Point p)
public Rectangle getViewRect()
public boolean isBackingStoreEnabled()
public void setBackingStoreEnabled(boolean b)
public void setScrollMode(int mode)
public int getScrollMode()
public Component getView()
public void setView(Component v)
public void reshape(int x,
int y,
int w,
int h)
JComponent
reshape in class JComponentx - the new horizontal locationy - the new vertial locationw - the new widthh - the new heightpublic final Insets getInsets()
JComponentJComponent.border property. If the border is null,
calls Container.getInsets().
getInsets in class JComponentpublic final Insets getInsets(Insets insets)
JComponentJComponent.border property. If the border is null, calls Container.getInsets(). The passed-in Insets value will be
used as the return value, if possible.
getInsets in class JComponentinsets - Return value object to reuse, if possible
public boolean isOptimizedDrawingEnabled()
false, so the JViewport's paint method
gets called instead of directly calling the children. This is necessary
in order to get a useful clipping and translation on the children.
isOptimizedDrawingEnabled in class JComponentfalsepublic void paint(Graphics g)
JComponentPaint the component. This is a delicate process, and should only be
called from the repaint thread, under control of the RepaintManager. Client code should usually call Component.repaint() to
trigger painting.
The body of the paint call involves calling JComponent.paintComponent(java.awt.Graphics), JComponent.paintBorder(java.awt.Graphics), and JComponent.paintChildren(java.awt.Graphics) in
order. If you want to customize painting behavior, you should override
one of these methods rather than paint.
For more details on the painting sequence, see this article.
paint in class JComponentg - The graphics context to paint withJComponent.paintImmediately(Rectangle)public void addChangeListener(ChangeListener listener)
public void removeChangeListener(ChangeListener listener)
public ChangeListener[] getChangeListeners()
public String getUIClassID()
getUIClassID in class JComponentJComponent.setUI(javax.swing.plaf.ComponentUI),
JComponent.updateUI()public void updateUI()
updateUI in class JComponentpublic ViewportUI getUI()
public void setUI(ViewportUI ui)
ui - The viewport's UI delegate.public final void setBorder(Border border)
JComponentJComponent.border property.
setBorder in class JComponentborder - The new value of the propertyJComponent.getBorder()public void scrollRectToVisible(Rectangle contentRect)
scrollRectToVisible in class JComponentcontentRect - the rectangle to make visible within the viewpublic AccessibleContext getAccessibleContext()
JViewport. This
will be an instance of JViewport.AccessibleJViewport.
getAccessibleContext in interface AccessiblegetAccessibleContext in class JComponentJViewport
public void repaint(long tm,
int x,
int y,
int w,
int h)
repaint in class JComponenttm - number of milliseconds to defer the repaint requestx - the X coordinate of the upper left corner of the dirty areay - the Y coordinate of the upper left corner of the dirty areaw - the width of the dirty areah - the height of the dirty areaComponent.update(Graphics)
protected void addImpl(Component comp,
Object constraints,
int index)
Containeradd() methods to perform
the actual adding of the component. Subclasses who wish to perform
their own processing when a component is added should override this
method. Any subclass doing this must call the superclass version of
this method in order to ensure proper functioning of the container.
addImpl in class Containercomp - The component to be added.constraints - The layout constraints for this component, or
null if there are no constraints.index - The index in the component list to insert this child
at, or -1 to add at the end of the list.protected void fireStateChanged()
protected JViewport.ViewListener createViewListener()
JViewport.ViewListener that is supposed to listen for
size changes on the view component.
protected LayoutManager createLayoutManager()
protected boolean computeBlit(int dx,
int dy,
Point blitFrom,
Point blitTo,
Dimension blitSize,
Rectangle blitPaint)
dx
and dy specifiy the X and Y offset by which the viewport
is scrolled. All other arguments are output parameters and are filled by
this method.
blitFrom holds the position of the blit rectangle in the
viewport rectangle before scrolling, blitTo where the blitArea
is copied to.
blitSize holds the size of the blit area and
blitPaint is the area of the view that needs to be painted.
This method returns true if blitting is possible and
false if the viewport has to be repainted completetly without
blitting.
dx - the horizontal deltady - the vertical deltablitFrom - the position from where to blit; set by this methodblitTo - the position where to blit area is copied to; set by this
methodblitSize - the size of the blitted area; set by this methodblitPaint - the area that needs repainting; set by this method
true if blitting is possible,
false otherwise
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||