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


Java Rectangle.union方法代码示例

本文整理汇总了Java中java.awt.Rectangle.union方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle.union方法的具体用法?Java Rectangle.union怎么用?Java Rectangle.union使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Rectangle的用法示例。


在下文中一共展示了Rectangle.union方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: computeMouseMoveIgnoredArea

import java.awt.Rectangle; //导入方法依赖的package包/类
private Rectangle computeMouseMoveIgnoredArea(Rectangle toolTipBounds, Rectangle blockBounds, Rectangle cursorBounds) {
    Rectangle _toolTipBounds = new Rectangle(toolTipBounds);
    extendBounds(_toolTipBounds);
    
    Rectangle area = new Rectangle();
    Rectangle.union(_toolTipBounds, cursorBounds, area);
    if (blockBounds != null) {
        area.x = blockBounds.x;
        area.width = blockBounds.width;
    }
    area.x -= cursorBounds.width;
    area.width += 2 * cursorBounds.width;
    
    if (LOG.isLoggable(Level.FINE)) {
        LOG.log(Level.FINE, "toolTip.bounds={0}, blockBounds={1}, cursorBounds={2}, mouseMoveIgnoredArea={3}", new Object [] { _toolTipBounds, blockBounds, cursorBounds, area });
    }
    
    return area;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ToolTipSupport.java

示例2: moveRectangle

import java.awt.Rectangle; //导入方法依赖的package包/类
private void moveRectangle(int aDeltaX, int aDeltaY) {
    if (theStartRectangle == null)
        return;

    Insets insets = getInsets();
    Rectangle newRect = new Rectangle(theStartRectangle);
    newRect.x += aDeltaX;
    newRect.y += aDeltaY;
    newRect.x = Math.min(Math.max(newRect.x, insets.left), getWidth()
            - insets.right - newRect.width);
    newRect.y = Math.min(Math.max(newRect.y, insets.right), getHeight()
            - insets.bottom - newRect.height);
    Rectangle clip = new Rectangle();
    Rectangle.union(theRectangle, newRect, clip);
    clip.grow(2, 2);
    theRectangle = newRect;
    paintImmediately(clip);
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:19,代码来源:ScrollPanePreview.java

示例3: updateFinderBounds

import java.awt.Rectangle; //导入方法依赖的package包/类
/**
 * 
 */
public void updateFinderBounds(Rectangle bounds, boolean repaint)
{
	if (bounds != null && !bounds.equals(finderBounds))
	{
		Rectangle old = new Rectangle(finderBounds);
		finderBounds = bounds;

		// LATER: Fix repaint region to be smaller
		if (repaint)
		{
			old = old.union(finderBounds);
			old.grow(3, 3);
			repaint(old);
		}
	}
}
 
开发者ID:GDSRS,项目名称:TrabalhoFinalEDA2,代码行数:20,代码来源:mxGraphOutline.java

示例4: updateClusterBounds

import java.awt.Rectangle; //导入方法依赖的package包/类
public void updateClusterBounds(){      
    Rectangle boundRect=null;
    
    for(NodeWidget nw : this.members){
        if(boundRect==null){
            boundRect = nw.convertLocalToScene(nw.getBounds());  
        } else {
            boundRect = boundRect.union(nw.convertLocalToScene(nw.getBounds()));
        }  
    }
    if(boundRect==null) return;
    for(Widget w : this.getChildren()) {
        if(w instanceof LoopClusterWidget) {            
            LoopClusterWidget lc = (LoopClusterWidget)w;
            lc.updateClusterBounds();
            boundRect = boundRect.union(w.convertLocalToScene(w.getBounds()));
        }
    }
   
    boundRect.grow(INSET, INSET);
    this.setPreferredBounds(boundRect);               
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:23,代码来源:LoopClusterWidget.java

示例5: getScreenBounds

import java.awt.Rectangle; //导入方法依赖的package包/类
private Rectangle getScreenBounds() throws HeadlessException {
  Rectangle virtualBounds = new Rectangle();
  GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
  GraphicsDevice[] gs = ge.getScreenDevices();

  if (gs.length == 0 || gs.length == 1) {
      return new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
  }
 
  for (GraphicsDevice gd : gs) {
      virtualBounds = virtualBounds.union(gd.getDefaultConfiguration().getBounds());
  }

  return virtualBounds;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:HintsUI.java

示例6: updateRectangularSelectionPaintRect

import java.awt.Rectangle; //导入方法依赖的package包/类
private void updateRectangularSelectionPaintRect() {
    // Repaint current rect
    JTextComponent c = component;
    Rectangle repaintRect = rsPaintRect;
    if (rsDotRect == null || rsMarkRect == null) {
        return;
    }
    Rectangle newRect = new Rectangle();
    if (rsDotRect.x < rsMarkRect.x) { // Swap selection to left
        newRect.x = rsDotRect.x; // -1 to make the visual selection non-empty
        newRect.width = rsMarkRect.x - newRect.x;
    } else { // Extend or shrink on right
        newRect.x = rsMarkRect.x;
        newRect.width = rsDotRect.x - newRect.x;
    }
    if (rsDotRect.y < rsMarkRect.y) {
        newRect.y = rsDotRect.y;
        newRect.height = (rsMarkRect.y + rsMarkRect.height) - newRect.y;
    } else {
        newRect.y = rsMarkRect.y;
        newRect.height = (rsDotRect.y + rsDotRect.height) - newRect.y;
    }
    if (newRect.width < 2) {
        newRect.width = 2;
    }
    rsPaintRect = newRect;

    // Repaint merged region with original rect
    if (repaintRect == null) {
        repaintRect = rsPaintRect;
    } else {
        repaintRect = repaintRect.union(rsPaintRect);
    }
    c.repaint(repaintRect);
    
    updateRectangularSelectionPositionBlocks();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:BaseCaret.java

示例7: getPreferredButtonSize

import java.awt.Rectangle; //导入方法依赖的package包/类
/**
 * Returns the preferred size of the button.
 *
 * @param b an instance of {@code AbstractButton}
 * @param textIconGap a gap between text and icon
 * @return the preferred size of the button
 */
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();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:43,代码来源:BasicGraphicsUtils.java

示例8: 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();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:36,代码来源:BasicGraphicsUtils.java

示例9: scrollToCurrent

import java.awt.Rectangle; //导入方法依赖的package包/类
private void scrollToCurrent() {
    try {
        Rectangle r1 = currentComp.modelToView(currentStart);
        Rectangle r2 = currentComp.modelToView(currentStart);
        Rectangle r = r1.union(r2);
        currentComp.scrollRectToVisible(r);
    } catch (BadLocationException blex) {
        BugtrackingManager.LOG.log(Level.INFO, blex.getMessage(), blex);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:FindSupport.java

示例10: mouseMoved

import java.awt.Rectangle; //导入方法依赖的package包/类
@Override
public void mouseMoved(MouseEvent e) {
    JTable table = (JTable) e.getSource();
    Point pt = e.getPoint();
    int prev_row = this.row;
    int prev_col = this.col;
    this.row = table.rowAtPoint(pt);
    this.col = table.columnAtPoint(pt);
    if (this.row != prev_row || this.col != prev_col) {
        Rectangle r = table.getCellRect(this.row, this.col, false);
        r = r.union(table.getCellRect(prev_row, prev_col, false));
        table.repaint(r);
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:15,代码来源:LibrariesTable.java

示例11: update

import java.awt.Rectangle; //导入方法依赖的package包/类
/** 
 * Updates the bounds of the rubber band,
 * and optionally repaints the dirty area.
 */
private void update(int x, int y, int width, int height) {
    Rectangle dirty = (Rectangle) this.bounds.clone();
    this.bounds.setBounds(x, y, width, height);
    dirty = dirty.union(this.bounds);
    // make sure the dirty area includes the contour of the rubber band
    dirty.x -= 1;
    dirty.y -= 1;
    dirty.height += 2;
    dirty.width += 2;
    this.canvas.repaint(dirty);
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:16,代码来源:JGraphUI.java

示例12: paint

import java.awt.Rectangle; //导入方法依赖的package包/类
/**
 * Paints a highlight.
 *
 * @param g the graphics context
 * @param offs0 the starting model offset >= 0
 * @param offs1 the ending model offset >= offs1
 * @param bounds the bounding box for the highlight
 * @param c the editor
 */
public void paint(Graphics g, int offs0, int offs1, Shape bounds, JTextComponent c) {
    Rectangle alloc = bounds.getBounds();
    try {
        // --- determine locations ---
        TextUI mapper = c.getUI();
        Rectangle p0 = mapper.modelToView(c, offs0);
        Rectangle p1 = mapper.modelToView(c, offs1);

        // --- render ---
        Color color = getColor();

        if (color == null) {
            g.setColor(c.getSelectionColor());
        }
        else {
            g.setColor(color);
        }
        boolean firstIsDot = false;
        boolean secondIsDot = false;
        if (c.isEditable()) {
            int dot = c.getCaretPosition();
            firstIsDot = (offs0 == dot);
            secondIsDot = (offs1 == dot);
        }
        if (p0.y == p1.y) {
            // same line, render a rectangle
            Rectangle r = p0.union(p1);
            if (r.width > 0) {
                if (firstIsDot) {
                    r.x++;
                    r.width--;
                }
                else if (secondIsDot) {
                    r.width--;
                }
            }
            g.fillRect(r.x, r.y, r.width, r.height);
        } else {
            // different lines
            int p0ToMarginWidth = alloc.x + alloc.width - p0.x;
            if (firstIsDot && p0ToMarginWidth > 0) {
                p0.x++;
                p0ToMarginWidth--;
            }
            g.fillRect(p0.x, p0.y, p0ToMarginWidth, p0.height);
            if ((p0.y + p0.height) != p1.y) {
                g.fillRect(alloc.x, p0.y + p0.height, alloc.width,
                           p1.y - (p0.y + p0.height));
            }
            if (secondIsDot && p1.x > alloc.x) {
                p1.x--;
            }
            g.fillRect(alloc.x, p1.y, (p1.x - alloc.x), p1.height);
        }
    } catch (BadLocationException e) {
        // can't render
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:68,代码来源:WindowsTextUI.java

示例13: paint

import java.awt.Rectangle; //导入方法依赖的package包/类
/**
 * Paints a highlight.
 *
 * @param g the graphics context
 * @param offs0 the starting model offset >= 0
 * @param offs1 the ending model offset >= offs1
 * @param bounds the bounding box for the highlight
 * @param c the editor
 */
@SuppressWarnings("deprecation")
public void paint(Graphics g, int offs0, int offs1, Shape bounds, JTextComponent c) {
    Rectangle alloc = bounds.getBounds();
    try {
        // --- determine locations ---
        TextUI mapper = c.getUI();
        Rectangle p0 = mapper.modelToView(c, offs0);
        Rectangle p1 = mapper.modelToView(c, offs1);

        // --- render ---
        Color color = getColor();

        if (color == null) {
            g.setColor(c.getSelectionColor());
        }
        else {
            g.setColor(color);
        }
        boolean firstIsDot = false;
        boolean secondIsDot = false;
        if (c.isEditable()) {
            int dot = c.getCaretPosition();
            firstIsDot = (offs0 == dot);
            secondIsDot = (offs1 == dot);
        }
        if (p0.y == p1.y) {
            // same line, render a rectangle
            Rectangle r = p0.union(p1);
            if (r.width > 0) {
                if (firstIsDot) {
                    r.x++;
                    r.width--;
                }
                else if (secondIsDot) {
                    r.width--;
                }
            }
            g.fillRect(r.x, r.y, r.width, r.height);
        } else {
            // different lines
            int p0ToMarginWidth = alloc.x + alloc.width - p0.x;
            if (firstIsDot && p0ToMarginWidth > 0) {
                p0.x++;
                p0ToMarginWidth--;
            }
            g.fillRect(p0.x, p0.y, p0ToMarginWidth, p0.height);
            if ((p0.y + p0.height) != p1.y) {
                g.fillRect(alloc.x, p0.y + p0.height, alloc.width,
                           p1.y - (p0.y + p0.height));
            }
            if (secondIsDot && p1.x > alloc.x) {
                p1.x--;
            }
            g.fillRect(alloc.x, p1.y, (p1.x - alloc.x), p1.height);
        }
    } catch (BadLocationException e) {
        // can't render
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:69,代码来源:WindowsTextUI.java

示例14: unionBounds

import java.awt.Rectangle; //导入方法依赖的package包/类
public Rectangle unionBounds(Rectangle bounds) {
    return isVisible() ? bounds.union(getPopupBounds()) : bounds;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:CompletionLayoutPopup.java

示例15: executeWithUnitOutForAnimation

import java.awt.Rectangle; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void executeWithUnitOutForAnimation(JLabel unitLabel) {
    final SwingGUI gui = (SwingGUI)getGUI();
    final float scale = gui.getMapScale();
    final int movementRatio = (int)(Math.pow(2, this.speed + 1) * scale);
    final Rectangle r1 = gui.getTileBounds(this.sourceTile);
    final Rectangle r2 = gui.getTileBounds(this.destinationTile);
    final Rectangle bounds = r1.union(r2);
    final double xratio = ImageLibrary.TILE_SIZE.width
        / (double)ImageLibrary.TILE_SIZE.height;

    // Tile positions should be valid at this point.
    final Point srcP = gui.getTilePosition(this.sourceTile);
    if (srcP == null) {
        logger.warning("Failed move animation for " + this.unit
            + " at source tile: " + this.sourceTile);
        return;
    }
    final Point dstP = gui.getTilePosition(this.destinationTile);
    if (dstP == null) {
        logger.warning("Failed move animation for " + this.unit
            + " at destination tile: " + this.destinationTile);
        return;
    }
        
    final int labelWidth = unitLabel.getWidth();
    final int labelHeight = unitLabel.getHeight();
    final Point srcPoint = gui.calculateUnitLabelPositionInTile(labelWidth,
        labelHeight, srcP);
    final Point dstPoint = gui.calculateUnitLabelPositionInTile(labelWidth,
        labelHeight, dstP);
    final int stepX = (srcPoint.getX() == dstPoint.getX()) ? 0
        : (srcPoint.getX() > dstPoint.getX()) ? -1 : 1;
    final int stepY = (srcPoint.getY() == dstPoint.getY()) ? 0
        : (srcPoint.getY() > dstPoint.getY()) ? -1 : 1;

    int dropFrames = 0;
    Point point = srcPoint;
    while (!point.equals(dstPoint)) {
        long time = System.currentTimeMillis();
        point.x += stepX * xratio * movementRatio;
        point.y += stepY * movementRatio;
        if ((stepX < 0 && point.x < dstPoint.x)
            || (stepX > 0 && point.x > dstPoint.x)) {
            point.x = dstPoint.x;
        }
        if ((stepY < 0 && point.y < dstPoint.y)
            || (stepY > 0 && point.y > dstPoint.y)) {
            point.y = dstPoint.y;
        }
        if (dropFrames <= 0) {
            unitLabel.setLocation(point);
            gui.paintImmediatelyCanvasIn(bounds);
            int timeTaken = (int)(System.currentTimeMillis()-time);
            final int waitTime = ANIMATION_DELAY - timeTaken;
            if (waitTime > 0) {
                Utils.delay(waitTime, "Animation interrupted.");
                dropFrames = 0;
            } else {
                dropFrames = timeTaken / ANIMATION_DELAY - 1;
            }
        } else {
            dropFrames--;
        }
    }
    gui.refresh();
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:71,代码来源:UnitMoveAnimation.java


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