本文整理汇总了Java中java.awt.Rectangle.add方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle.add方法的具体用法?Java Rectangle.add怎么用?Java Rectangle.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Rectangle
的用法示例。
在下文中一共展示了Rectangle.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import java.awt.Rectangle; //导入方法依赖的package包/类
/**
* Main processing method for the Selector object
*/
public synchronized void run() {
try {
lyricsArea.getStyledDocument().setCharacterAttributes(0,
lyricsArea.getStyledDocument().getLength(),
notSelectStyle, false);
lyricsArea.getStyledDocument().setCharacterAttributes(in,
out - in, selectStyle, false);
Rectangle r = lyricsArea.modelToView(in);
r.add(lyricsArea.modelToView(out));
lyricsArea.scrollRectToVisible(r);
if (!lyricsArea.isEditable()) {
preventFireUpdate = true;
lyricsArea.getCaret().setDot(in);
lyricsArea.getCaret().moveDot(out);
preventFireUpdate = false;
}
} catch (Exception ignored) {
}
}
示例2: 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;
}
示例3: setPreviewBounds
import java.awt.Rectangle; //导入方法依赖的package包/类
/**
*
*/
public void setPreviewBounds(Rectangle bounds) {
if ((bounds == null && previewBounds != null) || (bounds != null && previewBounds == null)
|| (bounds != null && previewBounds != null && !bounds.equals(previewBounds))) {
Rectangle dirty = null;
if (isVisible()) {
dirty = previewBounds;
if (dirty != null) {
dirty.add(bounds);
} else {
dirty = bounds;
}
}
previewBounds = bounds;
if (dirty != null) {
graphComponent.getGraphControl().repaint(dirty.x - 1, dirty.y - 1, dirty.width + 2,
dirty.height + 2);
}
}
}
示例4: mouseDragged
import java.awt.Rectangle; //导入方法依赖的package包/类
public void mouseDragged(MouseEvent e) {
if (!e.isMetaDown()) {
scrollAtEdge(e.getPoint(), 15);
}
if (selectionRect != null) {
// FIXME: inefficient, could be done with only one new Rectangle
final Rectangle repaintRect =
new Rectangle(selectionRect.x-1, selectionRect.y-1,
selectionRect.width+3, selectionRect.height+3);
selectionRect.x = Math.min(e.getX(), anchor.x);
selectionRect.y = Math.min(e.getY(), anchor.y);
selectionRect.width = Math.abs(e.getX() - anchor.x);
selectionRect.height = Math.abs(e.getY() - anchor.y);
repaintRect.add(
new Rectangle(selectionRect.x-1, selectionRect.y-1,
selectionRect.width+3, selectionRect.height+3));
view.repaint(repaintRect);
}
}
示例5: update
import java.awt.Rectangle; //导入方法依赖的package包/类
/**
* Calculates the dirty area and causes the canvas to be repainted.
*/
private void update(MouseEvent e) {
if (this.dragOrigVertex != null) {
Rectangle dirty =
getScreenBounds(this.dragOrigVertex).getBounds();
if (this.dragCurrPoint != null) {
dirty.add(this.dragCurrPoint);
}
if (this.dragCurrVertex != null) {
dirty.add(this.dragCurrVertex.getBounds());
}
if (e != null) {
Point point = e.getPoint();
this.dragCurrPoint = point;
this.dragCurrVertex = vertexAt(point);
dirty.add(point);
}
if (this.dragCurrVertex != null) {
dirty.add(getScreenBounds(this.dragCurrVertex));
}
dirty.x -= 1;
dirty.y -= 1;
dirty.width += 2;
dirty.height += 2;
this.canvas.repaint(dirty);
}
}
示例6: getBoundingBox
import java.awt.Rectangle; //导入方法依赖的package包/类
/**
* Returns the bounding box for the rotated rectangle.
*/
public static mxRectangle getBoundingBox(mxRectangle rect, double rotation)
{
mxRectangle result = null;
if (rect != null && rotation != 0)
{
double rad = Math.toRadians(rotation);
double cos = Math.cos(rad);
double sin = Math.sin(rad);
mxPoint cx = new mxPoint(rect.getX() + rect.getWidth() / 2,
rect.getY() + rect.getHeight() / 2);
mxPoint p1 = new mxPoint(rect.getX(), rect.getY());
mxPoint p2 = new mxPoint(rect.getX() + rect.getWidth(), rect.getY());
mxPoint p3 = new mxPoint(p2.getX(), rect.getY() + rect.getHeight());
mxPoint p4 = new mxPoint(rect.getX(), p3.getY());
p1 = getRotatedPoint(p1, cos, sin, cx);
p2 = getRotatedPoint(p2, cos, sin, cx);
p3 = getRotatedPoint(p3, cos, sin, cx);
p4 = getRotatedPoint(p4, cos, sin, cx);
Rectangle tmp = new Rectangle((int) p1.getX(), (int) p1.getY(), 0,
0);
tmp.add(p2.getPoint());
tmp.add(p3.getPoint());
tmp.add(p4.getPoint());
result = new mxRectangle(tmp);
}
else if (rect != null)
{
result = (mxRectangle) rect.clone();
}
return result;
}
示例7: SelectionShape
import java.awt.Rectangle; //导入方法依赖的package包/类
public SelectionShape(Point startPoint, Point endPoint, SelectionTypes selectionType)
{
this.startPoint = startPoint;
this.endPoint = endPoint;
this.freeHandSelectionPointList = new ArrayList<Point>();
this.freeHandTranslatedSelectionPointList = new ArrayList<Point>();
this.freeHandSelectionConnected = false;
this.selectionType = selectionType;
Rectangle selectionRectangle = new Rectangle(startPoint);
selectionRectangle.add(endPoint);
this.selectionRectangle = selectionRectangle;
}
示例8: mouseDragged
import java.awt.Rectangle; //导入方法依赖的package包/类
public void mouseDragged(MouseEvent e) {
if( !toggle.isSelected() )return;
Rectangle shape = new Rectangle( start.x, start.y, 0, 0);
shape.add(e.getPoint());
// if( shape.width<=10 || shape.height<=10 )return;
//System.out.println( shape.width +"\t"+ shape.height );
sc.setShape( shape);
}
示例9: boundingBox
import java.awt.Rectangle; //导入方法依赖的package包/类
public Rectangle boundingBox() {
final Rectangle r = piece.boundingBox();
r.add(piece.boundingBox());
final Dimension d = getImageSize();
r.add(new Rectangle(xOffset, yOffset, d.width, d.height));
return r;
}
示例10: getBoundingBox
import java.awt.Rectangle; //导入方法依赖的package包/类
/**
* Returns the bounding box for the rotated rectangle.
*/
public static mxRectangle getBoundingBox(mxRectangle rect, double rotation) {
mxRectangle result = null;
if (rect != null && rotation != 0) {
double rad = Math.toRadians(rotation);
double cos = Math.cos(rad);
double sin = Math.sin(rad);
mxPoint cx =
new mxPoint(rect.getX() + rect.getWidth() / 2, rect.getY() + rect.getHeight() / 2);
mxPoint p1 = new mxPoint(rect.getX(), rect.getY());
mxPoint p2 = new mxPoint(rect.getX() + rect.getWidth(), rect.getY());
mxPoint p3 = new mxPoint(p2.getX(), rect.getY() + rect.getHeight());
mxPoint p4 = new mxPoint(rect.getX(), p3.getY());
p1 = getRotatedPoint(p1, cos, sin, cx);
p2 = getRotatedPoint(p2, cos, sin, cx);
p3 = getRotatedPoint(p3, cos, sin, cx);
p4 = getRotatedPoint(p4, cos, sin, cx);
Rectangle tmp = new Rectangle((int) p1.getX(), (int) p1.getY(), 0, 0);
tmp.add(p2.getPoint());
tmp.add(p3.getPoint());
tmp.add(p4.getPoint());
result = new mxRectangle(tmp);
} else if (rect != null) {
result = (mxRectangle) rect.clone();
}
return result;
}
示例11: mouseDragged
import java.awt.Rectangle; //导入方法依赖的package包/类
public void mouseDragged(MouseEvent e) {
if( !zoomIn.isSelected() && !zoomOut.isSelected() )return;
Rectangle shape = new Rectangle( start.x, start.y, 0, 0);
shape.add(e.getPoint());
// if( shape.width<=10 || shape.height<=10 )return;
//System.out.println( shape.width +"\t"+ shape.height );
sc.setShape( shape);
}
示例12: getSelectedBox
import java.awt.Rectangle; //导入方法依赖的package包/类
public Rectangle getSelectedBox() {
Rectangle rect = null;
for (Region r : selectedRegions) {
final Rectangle sel = r.getSelectionRect();
if (rect == null) {
rect = sel;
}
else {
rect.add(sel);
}
}
return rect;
}
示例13: 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();
}
示例14: toBounds
import java.awt.Rectangle; //导入方法依赖的package包/类
/**
* Converts a list of points to the minimal rectangle containing all of
* them.
*/
static public Rectangle toBounds(List<Point2D> points) {
Rectangle bounds = new Rectangle();
for (Point2D point : points) {
bounds.add(point);
}
return bounds;
}
示例15: setBounds
import java.awt.Rectangle; //导入方法依赖的package包/类
/**
*
*/
public void setBounds(Rectangle value)
{
if ((bounds == null && value != null)
|| (bounds != null && value == null)
|| (bounds != null && value != null && !bounds.equals(value)))
{
Rectangle tmp = bounds;
if (tmp != null)
{
if (value != null)
{
tmp.add(value);
}
}
else
{
tmp = value;
}
bounds = value;
if (tmp != null)
{
graphComponent.getGraphControl().repaint(tmp);
}
}
}