本文整理匯總了Java中java.awt.Rectangle.setBounds方法的典型用法代碼示例。如果您正苦於以下問題:Java Rectangle.setBounds方法的具體用法?Java Rectangle.setBounds怎麽用?Java Rectangle.setBounds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.Rectangle
的用法示例。
在下文中一共展示了Rectangle.setBounds方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getClipBounds
import java.awt.Rectangle; //導入方法依賴的package包/類
public Rectangle getClipBounds(Rectangle r) {
if (clipState != CLIP_DEVICE) {
if (transformState <= TRANSFORM_INT_TRANSLATE) {
if (usrClip instanceof Rectangle) {
r.setBounds((Rectangle) usrClip);
} else {
r.setFrame(usrClip.getBounds2D());
}
r.translate(-transX, -transY);
} else {
r.setFrame(getClip().getBounds2D());
}
} else if (r == null) {
throw new NullPointerException("null rectangle parameter");
}
return r;
}
示例2: mousePressed
import java.awt.Rectangle; //導入方法依賴的package包/類
public void mousePressed(MouseEvent e) {
super.mousePressed(e);
if (!toolBar.isEnabled()) {
return;
}
pressedInBumps = false;
Rectangle bumpRect = new Rectangle();
if (toolBar.getOrientation() == JToolBar.HORIZONTAL) {
int x = MetalUtils.isLeftToRight(toolBar) ? 0 : toolBar.getSize().width-14;
bumpRect.setBounds(x, 0, 14, toolBar.getSize().height);
} else { // vertical
bumpRect.setBounds(0, 0, toolBar.getSize().width, 14);
}
if (bumpRect.contains(e.getPoint())) {
pressedInBumps = true;
Point dragOffset = e.getPoint();
if (!MetalUtils.isLeftToRight(toolBar)) {
dragOffset.x -= (toolBar.getSize().width
- toolBar.getPreferredSize().width);
}
setDragOffset(dragOffset);
}
}
示例3: mousePressed
import java.awt.Rectangle; //導入方法依賴的package包/類
@Override
public void mousePressed(MouseEvent e) {
super.mousePressed(e);
if (!this.toolBar.isEnabled()) {
return;
}
this.pressedToolbarHandler = false;
Rectangle bumpRect = new Rectangle();
if (this.toolBar.getOrientation() == SwingConstants.HORIZONTAL) {
int x = RapidLookTools.isLeftToRight(this.toolBar) ? 0 : this.toolBar.getSize().width - 14;
bumpRect.setBounds(x, 0, 14, this.toolBar.getSize().height);
} else { // vertical
bumpRect.setBounds(0, 0, this.toolBar.getSize().width, 14);
}
if (bumpRect.contains(e.getPoint())) {
this.pressedToolbarHandler = true;
Point dragOffset = e.getPoint();
if (!RapidLookTools.isLeftToRight(this.toolBar)) {
dragOffset.x -= (this.toolBar.getSize().width - this.toolBar.getPreferredSize().width);
}
setDragOffset(dragOffset);
}
}
示例4: getBB
import java.awt.Rectangle; //導入方法依賴的package包/類
private Rectangle getBB() {
final Rectangle bb = piece.boundingBox();
final Point pos = piece.getPosition();
bb.x += pos.x;
bb.y += pos.y;
final int circleDiameter = 2*circleRadius;
final Rectangle pr = new Rectangle();
for (final Point p: pointList) {
pr.setBounds(
p.x - circleRadius, p.y - circleRadius, circleDiameter, circleDiameter
);
bb.add(pr);
}
bb.x -= pos.x;
bb.y -= pos.y;
return bb;
}
示例5: getMyBoundingBox
import java.awt.Rectangle; //導入方法依賴的package包/類
/**
* Return the boundingBox including the trail
*/
public Rectangle getMyBoundingBox() {
if (myBoundingBox == null) {
final Rectangle bb = piece.boundingBox();
final Point pos = piece.getPosition();
bb.x += pos.x;
bb.y += pos.y;
final int circleDiameter = 2*circleRadius;
final Rectangle pr = new Rectangle();
for (final Point p: pointList) {
pr.setBounds(
p.x - circleRadius, p.y - circleRadius, circleDiameter, circleDiameter
);
bb.add(pr);
}
bb.x -= pos.x;
bb.y -= pos.y;
myBoundingBox = bb;
}
return myBoundingBox;
}
示例6: paintCell
import java.awt.Rectangle; //導入方法依賴的package包/類
/**
* narysowanie komorki
*
* @param row - wiersz
* @param column - kolumna
* @param g - kontekt graficzny
* @param area - obszar do narysowania
*/
private void paintCell(int row, int column, Graphics g, Rectangle area) {
int verticalMargin = table.getRowMargin();
int horizontalMargin = table.getColumnModel().getColumnMargin();
Color oldColor = g.getColor();
g.setColor(table.getGridColor());
g.drawLine(area.x + area.width - 1, area.y, area.x + area.width - 1, area.y + area.height - 1);
g.drawLine(area.x, area.y + area.height - 1, area.x + area.width - 1, area.y + area.height - 1);
g.setColor(oldColor);
area.setBounds(area.x + horizontalMargin / 2, area.y + verticalMargin
/ 2, area.width - horizontalMargin, area.height
- verticalMargin);
TableCellRenderer renderer = table.getCellRenderer(row, column);
Component component = table.prepareRenderer(renderer, row, column);
if (component.getParent() == null) {
rendererPane.add(component);
}
rendererPane.paintComponent(g, component, table, area.x, area.y, area.width, area.height, true);
}
示例7: recalculateSize
import java.awt.Rectangle; //導入方法依賴的package包/類
public void recalculateSize(Point p) {
if (dragMode != null && !p.equals(gesturePoint)) {
Rectangle oldtDragRect = new Rectangle();
oldtDragRect.setBounds(currentDragRect);
dragMode.recalculateSize(p);
int x = currentDragRect.x;
int y = currentDragRect.y;
int w = currentDragRect.width;
int h = currentDragRect.height;
if (bounds != null && !bounds.contains(currentDragRect)) {
if (h + y > bounds.height + bounds.y) {
if (y == oldtDragRect.y) {
h = (bounds.height + bounds.y) - y;
} else {
y = (bounds.height + bounds.y) - h;
}
}
if (w + x > bounds.width + bounds.x ) {
if (x == oldtDragRect.x) {
w = (bounds.width + bounds.x) - x;
} else {
x = (bounds.width + bounds.x) - w;
}
}
if (x < bounds.x) {
x = bounds.x;
}
if (y < bounds.y) {
y = bounds.y;
}
currentDragRect.setBounds(x,y,w,h);
}
if (w <= 3 || h <= 3 && !(dragMode instanceof MoveMode)) {
currentDragRect.setBounds(oldtDragRect);
}
}
}
示例8: getNodeDimensions
import java.awt.Rectangle; //導入方法依賴的package包/類
@Override
public Rectangle getNodeDimensions(Object value, int row, int depth,
boolean expanded, Rectangle bounds) {
int wid = Outline.this.getColumnModel().getColumn(0).getPreferredWidth();
bounds.setBounds (0, row * getRowHeight(), wid, getRowHeight());
return bounds;
}
示例9: calculateUsedArea
import java.awt.Rectangle; //導入方法依賴的package包/類
public Rectangle calculateUsedArea(int[] array) {
Rectangle r = new Rectangle(0, 0, 0, 0);
int x, y;
int map_left = MAP_WIDTH;
int map_right = 0;
int map_upper = MAP_HEIGHT;
int map_lower = 0;
for (y = 0; y < MAP_HEIGHT; y++) {
for (x = 0; x < MAP_WIDTH; x++) {
if (MAP_WIDTH * x + y < array.length) {
if (array[MAP_WIDTH * x + y] != 255) {
if (x < map_left)
map_left = x;
if (y < map_upper)
map_upper = y;
if (x > map_right)
map_right = x;
if (y > map_lower)
map_lower = y;
}
}
}
}
if (map_right < map_left || map_lower < map_upper) {
map_left = 0;
map_upper = 0;
map_lower = 1;
map_right = 1;
}
r.setBounds(map_left, map_upper, map_right, map_lower);
return r;
}
示例10: getCloseButtonRectangle
import java.awt.Rectangle; //導入方法依賴的package包/類
public void getCloseButtonRectangle(JComponent jc,
final Rectangle rect,
Rectangle bounds) {
rect.setBounds(-20, -20, 0, 0);
}
示例11: shift
import java.awt.Rectangle; //導入方法依賴的package包/類
private void shift(Graphics g, int idx, int idy, int width, int height) {
Rectangle areaToRepaint = new Rectangle();
if (idx == 0) {
// Vertical shift
if (idy > 0) {
// --- Shift down --------------------------------------
g.copyArea(0, 0, width, height - idy, 0, idy);
areaToRepaint.setBounds(0, 0, width, idy);
} else {
// --- Shift up ----------------------------------------
g.copyArea(0, -idy, width, height + idy, 0, idy);
areaToRepaint.setBounds(0, height + idy, width, -idy);
}
} else if (idy == 0) {
// Horizontal shift
if (idx > 0) {
// --- Shift right -------------------------------------
g.copyArea(0, 0, width - idx, height, idx, 0);
areaToRepaint.setBounds(0, 0, idx, height);
} else {
// --- Shift left --------------------------------------
g.copyArea(-idx, 0, width + idx, height, idx, 0);
areaToRepaint.setBounds(width + idx, 0, -idx, height);
}
} else {
// Diagonal shift
if (idx > 0) {
// Shift right
if (idy > 0) {
// --- Shift right down ------------------------
g.copyArea(0, 0, width - idx, height - idy, idx, idy);
areaToRepaint.setBounds(0, 0, width, idy);
paintContents(g, areaToRepaint);
areaToRepaint.setBounds(0, idy, idx, height - idy);
} else {
// --- Shift right up --------------------------
g.copyArea(0, -idy, width - idx, height + idy, idx, idy);
areaToRepaint.setBounds(0, height + idy, width, -idy);
paintContents(g, areaToRepaint);
areaToRepaint.setBounds(0, 0, idx, height + idy);
}
} else {
// Shift left
if (idy > 0) {
// --- Shift left down -------------------------
g.copyArea(-idx, 0, width + idx, height - idy, idx, idy);
areaToRepaint.setBounds(0, 0, width, idy);
paintContents(g, areaToRepaint);
areaToRepaint.setBounds(width + idx, idy, -idx, height - idy);
} else {
// --- Shift left up ---------------------------
g.copyArea(-idx, -idy, width + idx, height + idy, idx, idy);
areaToRepaint.setBounds(0, height + idy, width, -idy);
paintContents(g, areaToRepaint);
areaToRepaint.setBounds(width + idx, 0, -idx, height + idy);
}
}
}
paintContents(g, areaToRepaint);
}
示例12: computeRegions
import java.awt.Rectangle; //導入方法依賴的package包/類
/**
* Compute the source region and destination dimensions taking any
* parameter settings into account.
*/
private static void computeRegions(Rectangle sourceBounds,
Dimension destSize,
ImageWriteParam p) {
ImageWriteParam param;
int periodX = 1;
int periodY = 1;
if (p != null) {
int[] sourceBands = p.getSourceBands();
if (sourceBands != null &&
(sourceBands.length != 1 ||
sourceBands[0] != 0)) {
throw new IllegalArgumentException("Cannot sub-band image!");
}
// Get source region and subsampling factors
Rectangle sourceRegion = p.getSourceRegion();
if (sourceRegion != null) {
// Clip to actual image bounds
sourceRegion = sourceRegion.intersection(sourceBounds);
sourceBounds.setBounds(sourceRegion);
}
// Adjust for subsampling offsets
int gridX = p.getSubsamplingXOffset();
int gridY = p.getSubsamplingYOffset();
sourceBounds.x += gridX;
sourceBounds.y += gridY;
sourceBounds.width -= gridX;
sourceBounds.height -= gridY;
// Get subsampling factors
periodX = p.getSourceXSubsampling();
periodY = p.getSourceYSubsampling();
}
// Compute output dimensions
destSize.setSize((sourceBounds.width + periodX - 1)/periodX,
(sourceBounds.height + periodY - 1)/periodY);
if (destSize.width <= 0 || destSize.height <= 0) {
throw new IllegalArgumentException("Empty source region!");
}
}
示例13: changeSize
import java.awt.Rectangle; //導入方法依賴的package包/類
/**
* Changes the size of the box with the specified offsets.
*
* @param left - how much should the object be modified on the left side
* @param top - how much should the object be modified on the top part
* @param right - how much should the object be modified on the right side
* @param bottom - how much should the object be modified on the bottom part
* @param boxPosOrig - the initial position of the selected box in image
* coordinates
*/
private void changeSize(int left, int top, int right, int bottom, Rectangle bboxOrigPos) {
bboxOrigPos.setBounds(bboxOrigPos.x + left, bboxOrigPos.y + top, bboxOrigPos.width + right - left, bboxOrigPos.height + bottom - top);
}