本文整理匯總了Java中javax.swing.JViewport.getExtentSize方法的典型用法代碼示例。如果您正苦於以下問題:Java JViewport.getExtentSize方法的具體用法?Java JViewport.getExtentSize怎麽用?Java JViewport.getExtentSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JViewport
的用法示例。
在下文中一共展示了JViewport.getExtentSize方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: changed
import javax.swing.JViewport; //導入方法依賴的package包/類
private void changed() {
JViewport viewport = sp.getViewport();
Point viewPosition = viewport.getViewPosition();
if (viewPosition.x > 0) {
try {
Rectangle textRect = editorPane.getUI().modelToView(editorPane, editorPane.getDocument().getLength());
int textLength = textRect.x + textRect.width;
int viewLength = viewport.getExtentSize().width;
//System.out.println("Utilities.createSingleLineEditor(): spLength = "+sp.getSize().width+", viewLength = "+viewLength+", textLength = "+textLength+", viewPosition = "+viewPosition);
if (textLength < (viewPosition.x + viewLength)) {
viewPosition.x = Math.max(textLength - viewLength, 0);
viewport.setViewPosition(viewPosition);
//System.out.println("Utilities.createSingleLineEditor(): setting new view position = "+viewPosition);
}
} catch (BadLocationException blex) {
Exceptions.printStackTrace(blex);
}
}
}
示例2: computeVisibleSpan
import javax.swing.JViewport; //導入方法依賴的package包/類
private int[] computeVisibleSpan() {
Component parent = pane.getParent();
if (parent instanceof JLayeredPane) {
parent = parent.getParent();
}
if (parent instanceof JViewport) {
JViewport vp = (JViewport) parent;
Point start = vp.getViewPosition();
Dimension size = vp.getExtentSize();
Point end = new Point((int) (start.getX() + size.getWidth()), (int) (start.getY() + size.getHeight()));
int startPosition = pane.viewToModel(start);
int endPosition = pane.viewToModel(end);
if (parentWithListener != vp) {
vp.addChangeListener(WeakListeners.change(this, vp));
parentWithListener = vp;
}
return new int[] {startPosition, endPosition};
}
return new int[] {0, pane.getDocument().getLength()};
}
示例3: autoscroll
import javax.swing.JViewport; //導入方法依賴的package包/類
/** notify the Component to autoscroll */
public void autoscroll(Point cursorLoc) {
JViewport viewport = getViewport();
Point viewPos = viewport.getViewPosition();
int viewHeight = viewport.getExtentSize().height;
if ((cursorLoc.y - viewPos.y) <= realInsets.top) {
// scroll up
viewport.setViewPosition(new Point(viewPos.x, Math.max(viewPos.y - realInsets.top, 0)));
} else if (((viewPos.y + viewHeight) - cursorLoc.y) <= realInsets.bottom) {
// scroll down
viewport.setViewPosition(
new Point(viewPos.x, Math.min(viewPos.y + realInsets.bottom, this.getHeight() - viewHeight))
);
}
}
示例4: actionPerformed
import javax.swing.JViewport; //導入方法依賴的package包/類
@Override
public void actionPerformed(ActionEvent evt) {
Component component = ZoomMenu.this.jgraph.getParent();
while (component != null && !(component instanceof JViewport)) {
component = component.getParent();
}
if (component != null) {
final JViewport viewport = (JViewport) component;
Rectangle2D graphBounds = ZoomMenu.this.jgraph.getGraphBounds();
Dimension viewportBounds = viewport.getExtentSize();
double scale =
Math.min(viewportBounds.width / graphBounds.getWidth(), viewportBounds.height
/ graphBounds.getHeight());
ZoomMenu.this.jgraph.setScale(Math.min(scale, 1.0));
ZoomMenu.this.jgraph.scrollRectToVisible(graphBounds.getBounds());
setActionsEnabled();
}
}
示例5: validateThird
import javax.swing.JViewport; //導入方法依賴的package包/類
public void validateThird() {
JViewport viewport = this.pane.getViewport();
JScrollBar scroller = this.pane.getHorizontalScrollBar();
if (!scroller.getComponentOrientation().equals(ComponentOrientation.RIGHT_TO_LEFT)) {
throw new Error("unexpected component orientation");
}
int value = scroller.getValue();
if (value != 0) {
throw new Error("unexpected scroll value");
}
int extent = viewport.getExtentSize().width;
if (extent != scroller.getVisibleAmount()) {
throw new Error("unexpected visible amount");
}
int size = viewport.getViewSize().width;
if (size != scroller.getMaximum()) {
throw new Error("unexpected maximum");
}
int pos = size - extent - value;
if (pos != viewport.getViewPosition().x) {
throw new Error("unexpected position");
}
}
示例6: autoscroll
import javax.swing.JViewport; //導入方法依賴的package包/類
/** Performs autoscroll operation.
*/
public void autoscroll(Point cursorLoc) {
JViewport viewport = getViewport();
if (viewport == null) {
return;
}
Point viewPos = viewport.getViewPosition();
int viewHeight = viewport.getExtentSize().height;
int viewWidth = viewport.getExtentSize().width;
// perform scrolling
if ((cursorLoc.y - viewPos.y) < insets.top) {
// scroll up
viewport.setViewPosition(new Point(viewPos.x, Math.max(viewPos.y - scrollUnits.top, 0)));
} else if (((viewPos.y + viewHeight) - cursorLoc.y) < insets.bottom) {
// scroll down
viewport.setViewPosition(
new Point(viewPos.x, Math.min(viewPos.y + scrollUnits.bottom, comp.getHeight() - viewHeight))
);
} else if ((cursorLoc.x - viewPos.x) < insets.left) {
// scroll left
viewport.setViewPosition(new Point(Math.max(viewPos.x - scrollUnits.left, 0), viewPos.y));
} else if (((viewPos.x + viewWidth) - cursorLoc.x) < insets.right) {
// scroll right
viewport.setViewPosition(
new Point(Math.min(viewPos.x + scrollUnits.right, comp.getWidth() - viewWidth), viewPos.y)
);
}
}
示例7: adjustTreeScrollBar
import javax.swing.JViewport; //導入方法依賴的package包/類
private void adjustTreeScrollBar(int treeViewWidth) {
DebugTreeView tView = getTreeView();
if (tView == null) {
scrollBarPanel.setVisible(false);
return;
}
JViewport viewport = tView.getViewport();
Point point = viewport.getViewPosition();
if (point.y < 0) {
viewport.setViewPosition(new Point(point.x, 0));
}
Dimension viewSize = viewport.getExtentSize();
Dimension treeSize = viewport.getViewSize();
if (treeViewWidth < 0) {
treeViewWidth = treeSize.width;
}
int unitHeight = tView.getUnitHeight();
if (unitHeight > 0) {
JScrollBar sbar = mainScrollPane.getVerticalScrollBar();
if (sbar.getUnitIncrement() != unitHeight) {
sbar.setUnitIncrement(unitHeight);
}
}
if (treeViewWidth <= viewSize.width) {
scrollBarPanel.setVisible(false);
} else {
treeScrollBar.setMaximum(treeViewWidth);
treeScrollBar.setVisibleAmount(viewSize.width);
if (unitHeight > 0) {
treeScrollBar.setUnitIncrement(unitHeight / 2);
}
treeScrollBar.setBlockIncrement(viewSize.width);
scrollBarPanel.setVisible(true);
} // else
}