本文整理匯總了Java中java.awt.Rectangle.getSize方法的典型用法代碼示例。如果您正苦於以下問題:Java Rectangle.getSize方法的具體用法?Java Rectangle.getSize怎麽用?Java Rectangle.getSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.Rectangle
的用法示例。
在下文中一共展示了Rectangle.getSize方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getPopupLocation
import java.awt.Rectangle; //導入方法依賴的package包/類
private Point getPopupLocation() {
Dimension popupSize = new Dimension((int) this.comboBox.getSize().getWidth(), (int) this.comboBox.getSize()
.getHeight());
Insets insets = getInsets();
popupSize.setSize(popupSize.width - (insets.right + insets.left),
getPopupHeightForRowCount(this.comboBox.getMaximumRowCount()));
Rectangle popupBounds = computePopupBounds(0, this.comboBox.getBounds().height, popupSize.width,
popupSize.height);
Dimension scrollSize = popupBounds.getSize();
Point popupLocation = popupBounds.getLocation();
this.scroller.setMaximumSize(scrollSize);
this.scroller.setPreferredSize(scrollSize);
this.scroller.setMinimumSize(scrollSize);
this.list.revalidate();
return popupLocation;
}
示例2: translateCoordinates
import java.awt.Rectangle; //導入方法依賴的package包/類
/**
* Translates the given rectangle from one window to another.
* Returns null if the translation is failed
*/
static Rectangle translateCoordinates(long src, long dst, Rectangle r,
int scale)
{
Point translatedLoc = translateCoordinates(src, dst, r.getLocation(),
scale);
if (translatedLoc == null)
{
return null;
}
else
{
return new Rectangle(translatedLoc, r.getSize());
}
}
示例3: adjustPopupAndGetBounds
import java.awt.Rectangle; //導入方法依賴的package包/類
protected Rectangle adjustPopupAndGetBounds() {
if (isPopDown != isPopdown()) {
updateContents(true);
}
final Dimension popupSize = getBestPopupSizeForRowCount(comboBox.getMaximumRowCount());
final Rectangle popupBounds = computePopupBounds(0, comboBox.getBounds().height, popupSize.width, popupSize.height);
if (popupBounds == null) return null; // returning null means don't show anything
final Dimension realPopupSize = popupBounds.getSize();
scroller.setMaximumSize(realPopupSize);
scroller.setPreferredSize(realPopupSize);
scroller.setMinimumSize(realPopupSize);
list.invalidate();
final int selectedIndex = comboBox.getSelectedIndex();
if (selectedIndex == -1) {
list.clearSelection();
} else {
list.setSelectedIndex(selectedIndex);
}
list.ensureIndexIsVisible(list.getSelectedIndex());
return popupBounds;
}
示例4: performLayout
import java.awt.Rectangle; //導入方法依賴的package包/類
@Override
protected void performLayout() {
Rectangle rectangle = null;
List<? extends Widget> toFit = widgets != null ? widgets : depScene.getChildren();
if (toFit == null) {
return;
}
for (Widget widget : toFit) {
Rectangle bounds = widget.getBounds();
if (bounds == null) {
continue;
}
if (rectangle == null) {
rectangle = widget.convertLocalToScene(bounds);
} else {
rectangle = rectangle.union(widget.convertLocalToScene(bounds));
}
}
// margin around
if (widgets == null) {
rectangle.grow(5, 5);
} else {
rectangle.grow(25, 25);
}
Dimension dim = rectangle.getSize();
Dimension viewDim = parentScrollPane.getViewportBorderBounds().getSize ();
double zf = Math.min ((double) viewDim.width / dim.width, (double) viewDim.height / dim.height);
if (depScene.isAnimated()) {
if (widgets == null) {
depScene.getSceneAnimator().animateZoomFactor(zf);
} else {
CenteredZoomAnimator cza = new CenteredZoomAnimator(depScene.getSceneAnimator());
cza.setZoomFactor(zf,
new Point((int)rectangle.getCenterX(), (int)rectangle.getCenterY()));
}
} else {
depScene.setMyZoomFactor (zf);
}
}
示例5: getSourceBounds
import java.awt.Rectangle; //導入方法依賴的package包/類
private Rectangle getSourceBounds()
{
Widget source = connection.getSourceAnchor().getRelatedWidget();
if(source != null)
{
Point sourceLocation = source.getLocation();
Rectangle clientArea = source.getClientArea();
return new Rectangle(sourceLocation, clientArea.getSize());
}
return null;
}
示例6: getTargetBounds
import java.awt.Rectangle; //導入方法依賴的package包/類
private Rectangle getTargetBounds()
{
Widget target = connection.getTargetAnchor().getRelatedWidget();
if(target != null)
{
Point targetLocation = target.getLocation();
Rectangle targetArea = target.getClientArea();
return new Rectangle(targetLocation, targetArea.getSize());
}
return null;
}
示例7: show
import java.awt.Rectangle; //導入方法依賴的package包/類
/**
* Create and display the popup at the given bounds.
*
* @param popupBounds location and size of the popup.
* @param displayAboveCaret whether the popup is displayed above the anchor
* bounds or below them (it does not be right above them).
*/
private void show(Rectangle popupBounds, boolean displayAboveCaret) {
// Hide the original popup if exists
if (popup != null) {
popup.hide();
popup = null;
}
// Explicitly set the preferred size
Dimension origPrefSize = getPreferredSize();
Dimension newPrefSize = popupBounds.getSize();
JComponent contComp = getContentComponent();
if (contComp == null){
return;
}
contComp.setPreferredSize(newPrefSize);
showRetainedPreferredSize = newPrefSize.equals(origPrefSize);
PopupFactory factory = PopupFactory.getSharedInstance();
// Lightweight completion popups don't work well on the Mac - trying
// to click on its scrollbars etc. will cause the window to be hidden,
// so force a heavyweight parent by passing in owner==null. (#96717)
JTextComponent owner = layout.getEditorComponent();
if(owner != null && owner.getClientProperty("ForceHeavyweightCompletionPopup") != null) {
owner = null;
}
// #76648: Autocomplete box is too close to text
if(displayAboveCaret && Utilities.isMac()) {
popupBounds.y -= 10;
}
popup = factory.getPopup(owner, contComp, popupBounds.x, popupBounds.y);
popup.show();
this.popupBounds = popupBounds;
this.displayAboveCaret = displayAboveCaret;
}
示例8: computeLastButtonBounds
import java.awt.Rectangle; //導入方法依賴的package包/類
/** Returns bounds of last button in sliding view to which given
* operation belongs. Bounds are relative to desktop layered pane.
*/
private Rectangle computeLastButtonBounds(SlideOperation operation) {
String side = operation.getSide();
SlidingView view = findView(side);
Rectangle screenRect = view.getTabBounds(view.getTopComponents().size() - 1);
Point leftTop = screenRect.getLocation();
if (Constants.BOTTOM.equals(side)) {
leftTop.y += desktop.getHeight() - view.getComponent().getPreferredSize().height;
} else if (Constants.RIGHT.equals(side)) {
leftTop.x += desktop.getWidth() - view.getComponent().getPreferredSize().width;
}
return new Rectangle(leftTop, screenRect.getSize());
}
示例9: showEffect
import java.awt.Rectangle; //導入方法依賴的package包/類
public void showEffect(JLayeredPane pane, Integer layer, SlideOperation operation) {
this.pane = pane;
this.operation = operation;
Component comp = operation.getComponent();
Graphics2D gr2d = (Graphics2D)pane.getGraphics();
Rectangle start = operation.getStartBounds();
Rectangle finish = operation.getFinishBounds();
Dimension finishSize = finish.getSize();
Dimension startSize = start.getSize();
Rectangle current = start;
Image compImage = preparedImage;
/* if (compImage == null) {
if (finishSize.width * finishSize.height > startSize.width * startSize.height) {
compImage = renderCompIntoImage(comp, finishSize, pane);
} else {
compImage = renderCompIntoImage(comp, startSize, pane);
}
}*/
pane.add(stretchedImage, layer);
path = computePath(start, finish);
curIter = 1;
if (compImage != null) {
stretchedImage.setOrigImage(compImage);
} else {
if (finishSize.width * finishSize.height > startSize.width * startSize.height) {
stretchedImage.setComp(comp, finishSize);
} else {
stretchedImage.setComp(comp, startSize);
}
}
stretchedImage.setBoundsAndAlpha(start, initialAlpha);
getTimer().start();
}
示例10: show
import java.awt.Rectangle; //導入方法依賴的package包/類
/**
* Create and display the popup at the given bounds.
*
* @param popupBounds location and size of the popup.
* @param displayAboveCaret whether the popup is displayed above the anchor
* bounds or below them (it does not be right above them).
*/
private void show(Rectangle popupBounds, boolean displayAboveCaret) {
// Hide the original popup if exists
if (popup != null) {
popup.hide();
popup = null;
}
// Explicitly set the preferred size
Dimension origPrefSize = getPreferredSize();
Dimension newPrefSize = popupBounds.getSize();
JComponent contComp = getContentComponent();
if (contComp == null){
return;
}
contComp.setPreferredSize(newPrefSize);
showRetainedPreferredSize = newPrefSize.equals(origPrefSize);
PopupFactory factory = PopupFactory.getSharedInstance();
// Lightweight completion popups don't work well on the Mac - trying
// to click on its scrollbars etc. will cause the window to be hidden,
// so force a heavyweight parent by passing in owner==null. (#96717)
JTextComponent owner = getEditorComponent();
if(owner != null && owner.getClientProperty("ForceHeavyweightCompletionPopup") != null) { //NOI18N
owner = null;
}
// #76648: Autocomplete box is too close to text
if(displayAboveCaret && Utilities.isMac()) {
popupBounds.y -= 10;
}
popup = factory.getPopup(owner, contComp, popupBounds.x, popupBounds.y);
popup.show();
this.popupBounds = popupBounds;
this.displayAboveCaret = displayAboveCaret;
}
示例11: mapSize
import java.awt.Rectangle; //導入方法依賴的package包/類
/**
* @return the size of the map in pixels at 100% zoom,
* including the edge buffer
*/
// FIXME: why synchronized?
public synchronized Dimension mapSize() {
final Rectangle r = new Rectangle(0,0);
for (Board b : boards) r.add(b.bounds());
r.width += edgeBuffer.width;
r.height += edgeBuffer.height;
return r.getSize();
}
示例12: mapSize
import java.awt.Rectangle; //導入方法依賴的package包/類
public Dimension mapSize() {
final Rectangle r = new Rectangle(0,0,200,200);
r.add(new Rectangle(super.mapSize()));
for (GamePiece p : pieces.getPieces()) {
final Rectangle bb = boundingBoxOf(p);
if (bb != null) {
r.add(bb);
}
}
return r.getSize();
}
示例13: getPreferredButtonSize
import java.awt.Rectangle; //導入方法依賴的package包/類
public static Dimension getPreferredButtonSize(AbstractButton b, int textIconGap)
{
if(b.getComponentCount() > 0) {
return null;
}
Icon icon = b.getIcon();
String text = b.getText();
Font font = b.getFont();
FontMetrics fm = b.getFontMetrics(font);
Rectangle iconR = new Rectangle();
Rectangle textR = new Rectangle();
Rectangle viewR = new Rectangle(Short.MAX_VALUE, Short.MAX_VALUE);
SwingUtilities.layoutCompoundLabel(
b, fm, text, icon,
b.getVerticalAlignment(), b.getHorizontalAlignment(),
b.getVerticalTextPosition(), b.getHorizontalTextPosition(),
viewR, iconR, textR, (text == null ? 0 : textIconGap)
);
/* The preferred size of the button is the size of
* the text and icon rectangles plus the buttons insets.
*/
Rectangle r = iconR.union(textR);
Insets insets = b.getInsets();
r.width += insets.left + insets.right;
r.height += insets.top + insets.bottom;
return r.getSize();
}
示例14: translateCoordinates
import java.awt.Rectangle; //導入方法依賴的package包/類
/**
* Translates the given rectangle from one window to another.
* Returns null if the translation is failed
*/
static Rectangle translateCoordinates(long src, long dst, Rectangle r)
{
Point translatedLoc = translateCoordinates(src, dst, r.getLocation());
if (translatedLoc == null)
{
return null;
}
else
{
return new Rectangle(translatedLoc, r.getSize());
}
}
示例15: getSize
import java.awt.Rectangle; //導入方法依賴的package包/類
public Dimension getSize() {
Rectangle bounds = getBounds();
if (bounds != null) {
return bounds.getSize();
} else {
return MIN_SIZE;
}
}