| GNU Classpath (0.95) | |
| Prev Class | Next Class | Frames | No Frames |
| Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Objectjava.awt.Componentjava.awt.Containerjavax.swing.JComponentjavax.swing.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 |
|
protected class |
|
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 | |
static int | |
static int | |
static int | |
protected boolean |
|
protected Image |
|
protected boolean | |
protected Point |
|
protected boolean | |
Fields inherited from class javax.swing.JComponent | |
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW, accessibleContext, listenerList, ui | |
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 | |
| |
Method Summary | |
void |
|
protected void | |
protected boolean |
|
protected LayoutManager |
|
protected JViewport.ViewListener |
|
protected void | |
AccessibleContext |
|
ChangeListener[] | |
Dimension | |
Insets |
|
Insets |
|
int | |
ViewportUI |
|
String |
|
Component |
|
Point |
|
Rectangle | |
Dimension |
|
boolean |
|
boolean |
|
void | |
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void | |
void | |
void |
|
Dimension |
|
Point | |
void |
|
Methods inherited from class java.lang.Object | |
clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait | |
protected boolean backingStore
Deprecated. since JDK 1.3
This flag indicates whether we use a backing store for drawing.
protected Image backingStoreImage
The backingstore image used for the backingstore and blit scroll methods.
protected Point lastPaintPosition
The position at which the view has been drawn the last time. This is used to determine the bittable area.
protected void addImpl(Component comp, Object constraints, int index)
This method is called by all theadd()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.
- Parameters:
comp- The component to be added.constraints- The layout constraints for this component, ornullif 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.
- Throws:
ArrayIndexOutOfBoundsException- If the specified index is invalid.
protected boolean computeBlit(int dx, int dy, Point blitFrom, Point blitTo, Dimension blitSize, Rectangle blitPaint)
Computes the parameters for the blitting scroll method.dxanddyspecifiy the X and Y offset by which the viewport is scrolled. All other arguments are output parameters and are filled by this method.blitFromholds the position of the blit rectangle in the viewport rectangle before scrolling,blitTowhere the blitArea is copied to.blitSizeholds the size of the blit area andblitPaintis the area of the view that needs to be painted. This method returnstrueif blitting is possible andfalseif the viewport has to be repainted completetly without blitting.
- Parameters:
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
- Returns:
trueif blitting is possible,falseotherwise
protected LayoutManager createLayoutManager()
Creates the LayoutManager that is used for this viewport. Override this method if you want to use a custom LayoutManager.
- Returns:
- a LayoutManager to use for this viewport
protected JViewport.ViewListener createViewListener()
Creates aJViewport.ViewListenerthat is supposed to listen for size changes on the view component.
- Returns:
- a ViewListener instance
public AccessibleContext getAccessibleContext()
Returns the accessible context for thisJViewport. This will be an instance ofJViewport.AccessibleJViewport.
- Specified by:
- getAccessibleContext in interface Accessible
- Overrides:
- getAccessibleContext in interface JComponent
- Returns:
- the accessible context for this
JViewport
public final Insets getInsets()
Get the component's insets, which are calculated from theJComponent.borderproperty. If the border isnull, callsContainer.getInsets().
- Overrides:
- getInsets in interface JComponent
- Returns:
- The component's current insets
public final Insets getInsets(Insets insets)
Get the component's insets, which are calculated from theJComponent.borderproperty. If the border isnull, callsContainer.getInsets(). The passed-inInsetsvalue will be used as the return value, if possible.
- Overrides:
- getInsets in interface JComponent
- Parameters:
insets- Return value object to reuse, if possible
- Returns:
- The component's current insets
public ViewportUI getUI()
This method returns the viewport's UI delegate.
- Returns:
- The viewport's UI delegate.
public String getUIClassID()
This method returns the String ID of the UI class of Separator.
- Overrides:
- getUIClassID in interface JComponent
- Returns:
- The UI class' String ID.
public Point getViewPosition()
Get the viewport's position in view space. Despite confusing name, this really does return the viewport's (0,0) position in view space, not the view's position.
public Dimension getViewSize()
Returns the viewSize when set, or the preferred size of the set Component view. If no viewSize and no Component view is set an empty Dimension is returned.
public boolean isOptimizedDrawingEnabled()
Overridden to returnfalse, 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.
- Overrides:
- isOptimizedDrawingEnabled in interface JComponent
- Returns:
false
public void paint(Graphics g)
Paint the component. This is a delicate process, and should only be called from the repaint thread, under control of theRepaintManager. Client code should usually callJComponent.repaint()to trigger painting. The body of thepaintcall involves callingJComponent.paintComponent(Graphics),JComponent.paintBorder(Graphics), andJComponent.paintChildren(Graphics)in order. If you want to customize painting behavior, you should override one of these methods rather thanpaint. For more details on the painting sequence, see this article.
- Overrides:
- paint in interface JComponent
- Parameters:
g- The graphics context to paint with
public 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.
- Overrides:
- repaint in interface JComponent
- Parameters:
tm- 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 area
public void reshape(int x, int y, int w, int h)
Moves and resizes the component.
- Overrides:
- reshape in interface JComponent
- Parameters:
x- the new horizontal locationy- the new vertial locationw- the new widthh- the new height
public void scrollRectToVisible(Rectangle contentRect)
Scrolls the view so that contentRect becomes visible.
- Overrides:
- scrollRectToVisible in interface JComponent
- Parameters:
contentRect- the rectangle to make visible within the view
public final void setBorder(Border border)
Set the value of theJComponent.borderproperty.
- Overrides:
- setBorder in interface JComponent
- Parameters:
- See Also:
JComponent.getBorder()