_
+-------------------------------+ ...........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
javax.JViewPort.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)
addImpl
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. 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 interface Container
comp
- 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.
ArrayIndexOutOfBoundsException
- If the specified index is invalid.
createLayoutManager
protected LayoutManager createLayoutManager()
Creates the LayoutManager that is used for this viewport. Override
this method if you want to use a custom LayoutManager.
- a LayoutManager to use for this viewport
getInsets
public final Insets getInsets()
Get the component's insets, which are calculated from
the
JComponent
property. If the border is
null
,
calls
Container.getInsets()
.
- getInsets in interface JComponent
- The component's current insets
getInsets
public final Insets getInsets(Insets insets)
Get the component's insets, which are calculated from the
JComponent
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 interface JComponent
insets
- Return value object to reuse, if possible
- The component's current insets
getUI
public ViewportUI getUI()
This method returns the viewport's UI delegate.
- The viewport's UI delegate.
getUIClassID
public String getUIClassID()
This method returns the String ID of the UI class of Separator.
- getUIClassID in interface JComponent
- The UI class' String ID.
getViewPosition
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.
getViewSize
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.
isOptimizedDrawingEnabled
public boolean isOptimizedDrawingEnabled()
Return
true
if the component can guarantee that none of its
children will overlap in Z-order. This is a hint to the painting system.
The default is to return
true
, but some components such as
JLayeredPane
should override this to return
false
.
- isOptimizedDrawingEnabled in interface JComponent
- Whether the component tiles its children
paint
public void paint(Graphics g)
- paint in interface JComponent
g
- The graphics context to paint with
paintImmediately
reshape
public void reshape(int x,
int y,
int w,
int h)
Moves and resizes the component.
- reshape in interface JComponent
x
- the new horizontal locationy
- the new vertial locationw
- the new widthh
- the new height
setUI
public void setUI(ViewportUI ui)
This method sets the viewport's UI delegate.
ui
- The viewport's UI delegate.
updateUI
public void updateUI()
This method resets the UI used to the Look and Feel defaults..
- updateUI in interface JComponent
JViewport.java --
Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.