当前位置: 首页>>代码示例>>Java>>正文


Java Rectangle.setBounds方法代码示例

本文整理汇总了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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:SunGraphics2D.java

示例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);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:MetalToolBarUI.java

示例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);
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:25,代码来源:ToolBarUI.java

示例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;
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:23,代码来源:Footprint.java

示例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;
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:29,代码来源:Footprint.java

示例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);
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:31,代码来源:SpanTableUI.java

示例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);
        } 
    }
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:40,代码来源:DragManager.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:Outline.java

示例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;
}
 
开发者ID:Detea,项目名称:PekaED,代码行数:41,代码来源:PK2Map.java

示例10: getCloseButtonRectangle

import java.awt.Rectangle; //导入方法依赖的package包/类
public void getCloseButtonRectangle(JComponent jc,
                                    final Rectangle rect,
                                    Rectangle bounds) {
    rect.setBounds(-20, -20, 0, 0);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:6,代码来源:NimbusEditorTabCellRenderer.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:63,代码来源:TransformableCanvasComponent.java

示例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!");
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:47,代码来源:GIFImageWriter.java

示例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);
}
 
开发者ID:buni-rock,项目名称:Pixie,代码行数:14,代码来源:ObjectBBox.java


注:本文中的java.awt.Rectangle.setBounds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。