當前位置: 首頁>>代碼示例>>Java>>正文


Java Rectangle類代碼示例

本文整理匯總了Java中java.awt.Rectangle的典型用法代碼示例。如果您正苦於以下問題:Java Rectangle類的具體用法?Java Rectangle怎麽用?Java Rectangle使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Rectangle類屬於java.awt包,在下文中一共展示了Rectangle類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: synchronizeSelectedNodes

import java.awt.Rectangle; //導入依賴的package包/類
/** Synchronize the selected nodes from the manager of this Explorer.
 */
final void synchronizeSelectedNodes() {
    Node[] arr = manager.getSelectedNodes ();
    table.getSelectionModel().clearSelection();
    NodeTableModel ntm = (NodeTableModel)table.getModel();
    int size = ntm.getRowCount();
    int firstSelection = -1;
    for (int i = 0; i < size; i++) {
        Node n = getNodeFromRow(i);
        for (int j = 0; j < arr.length; j++) {
            if (n.equals(arr[j])) {
                table.getSelectionModel().addSelectionInterval(i, i);
                if (firstSelection == -1) {
                    firstSelection = i;
                }
            }
        }
    }
    if (firstSelection >= 0) {
        Rectangle rect = table.getCellRect(firstSelection, 0, true);
        if (!getViewport().getViewRect().contains(rect.getLocation())) {
            rect.height = Math.max(rect.height, getHeight() - 30);
            table.scrollRectToVisible(rect);
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:28,代碼來源:TableView.java

示例2: paint

import java.awt.Rectangle; //導入依賴的package包/類
@Override
public void paint(Graphics g, JComponent c) {
	recalculateIfInsetsChanged();
	recalculateIfOrientationChanged();
	Rectangle clip = g.getClipBounds();

	if (!clip.intersects(trackRect) && slider.getPaintTrack()) {
		calculateGeometry();
	}

	if (slider.getPaintTrack() && clip.intersects(trackRect)) {
		paintTrack(g);
	}
	if (slider.hasFocus() && clip.intersects(focusRect)) {
		paintFocus(g);
	}

	// the ticks are now inside the track so they have to be painted each thumb movement
	paintTicks(g);
	// thumb is always painted due to value below thumb
	paintThumb(g);
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:23,代碼來源:SliderUI.java

示例3: reSetBounds

import java.awt.Rectangle; //導入依賴的package包/類
@Override
public void reSetBounds() {
    PontoElementar[] pontos = getPontos();
    int espacoI = distSelecao;
    int mW = pontos[0].getWidth() + espacoI;
    int mH = pontos[0].getHeight() + espacoI;

    int H = pontos[2].getTop() - pontos[0].getTop() - (mH + espacoI);
    int W = pontos[2].getLeft() - pontos[0].getLeft() - (mW + espacoI);
    int L = pontos[0].getLeft() + mW;
    int T = pontos[0].getTop() + mH;

    if ((W < 10) || (H < 10)) {
        Reposicione();
        return;
    }

    Rectangle ret = new Rectangle(getLeft() - L, getTop() - T, getWidth() - W, getHeight() - H);
    DoFormaResize(ret);
}
 
開發者ID:chcandido,項目名稱:brModelo,代碼行數:21,代碼來源:Forma.java

示例4: getBoundsInRectangle

import java.awt.Rectangle; //導入依賴的package包/類
private Bounds[] getBoundsInRectangle(Rectangle rectangle) {
    List<Bounds> list = new ArrayList<Bounds>();
    double maxX = untranslate(rectangle.getMaxX());
    double minX = untranslate(rectangle.getMinX());
    double maxY = untranslate(rectangle.getMaxY());
    double minY = untranslate(rectangle.getMinY());

    for (Bounds bounds : diagram.getBounds()) {
        if ((bounds.getLeft() <= maxX) && (bounds.getLeft() >= minX)
                && (bounds.getRight() <= maxX)
                && (bounds.getRight() >= minX)) {
            if ((bounds.getTop() <= maxY) && (bounds.getTop() >= minY)
                    && (bounds.getBottom() <= maxY)
                    && (bounds.getBottom() >= minY)) {
                list.add(bounds);
            }
        }
    }

    return list.toArray(new Bounds[list.size()]);
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:22,代碼來源:GEFComponent.java

示例5: mousePressed

import java.awt.Rectangle; //導入依賴的package包/類
@Override
public void mousePressed(MouseEvent e) {
    e.consume();
    switch (mode) {
        case LINES:
            x1 = e.getX();
            y1 = e.getY();
            x2 = -1;
            break;
        case POINTS:
        default:
            colors.add(getForeground());
            lines.add(new Rectangle(e.getX(), e.getY(), -1, -1));
            x1 = e.getX();
            y1 = e.getY();
            repaint();
            break;
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:DrawTest.java

示例6: paintChildren

import java.awt.Rectangle; //導入依賴的package包/類
void paintChildren(ParagraphView pView, Graphics2D g, Shape pAlloc, Rectangle clipBounds,
        int startIndex, int endIndex)
{
    while (startIndex < endIndex) {
        EditorView view = get(startIndex);
        Shape childAlloc = getChildAllocation(startIndex, pAlloc);
        if (view.getClass() == NewlineView.class) {
            // Extend till end of screen (docView's width)
            Rectangle2D.Double childRect = ViewUtils.shape2Bounds(childAlloc);
            DocumentView docView = pView.getDocumentView();
            // Note that op.getVisibleRect() may be obsolete - it does not incorporate
            // possible just performed horizontal scroll while clipBounds already does.
            double maxX = Math.max(
                    Math.max(docView.op.getVisibleRect().getMaxX(), clipBounds.getMaxX()),
                    childRect.getMaxX()
            );
            childRect.width = (maxX - childRect.x);
            childAlloc = childRect;
        }
        view.paint(g, childAlloc, clipBounds);
        startIndex++;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:ParagraphViewChildren.java

示例7: fitWESN

import java.awt.Rectangle; //導入依賴的package包/類
public static double[] fitWESN(double[] wesn, int width, int height) {
	Rectangle rect = new Rectangle(0, 0, width, height);
	double scale = (wesn[1] - wesn[0]) / (double)width;
	double scaleY = (wesn[3] - wesn[2]) / (double)height;
	double x0, y0;
	if(scaleY > scale) {
		scale = scaleY;
		x0 = .5d * (wesn[0] + wesn[1]);
		wesn[0] = x0 - (double)width * .5d * scale;
		wesn[1] = wesn[0] + (double)width * scale;
	} else {
		y0 = .5d * (wesn[2] + wesn[3]);
		wesn[3] = y0 + (double)height * .5d * scale;
		wesn[2] = wesn[3] - (double)height * scale;
	}
	return wesn;
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:18,代碼來源:MapServerA.java

示例8: LabelSeparator

import java.awt.Rectangle; //導入依賴的package包/類
public LabelSeparator(JLabel label)
{
	JSeparator separator = new JSeparator();

	final int height1 = label.getPreferredSize().height;
	final int height2 = separator.getPreferredSize().height;
	final int height3 = (height1 - height2) / 2;
	final int width1 = label.getPreferredSize().width;

	final int[] rows = {height3, height2, height3,};
	final int[] cols = {width1, TableLayout.FILL,};

	setLayout(new TableLayout(rows, cols));

	add(label, new Rectangle(0, 0, 1, 3));
	add(separator, new Rectangle(1, 1, 1, 1));
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:18,代碼來源:LabelSeparator.java

示例9: attach

import java.awt.Rectangle; //導入依賴的package包/類
@Attachment(type = "image/png", fileExtension = "png", value = "att")
public byte[] attach() {
    try {
        BufferedImage image = new Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ImageIO.write(image, "png", baos);
        baos.flush();
        byte[] imageInByte = baos.toByteArray();
        baos.close();
        return imageInByte;
    } catch (AWTException | IOException e) {
        return null;
    }
}
 
開發者ID:allure-framework,項目名稱:allure-java,代碼行數:15,代碼來源:Stepdefs.java

示例10: initScreenBounds

import java.awt.Rectangle; //導入依賴的package包/類
static void initScreenBounds() {

        GraphicsDevice[] devices = GraphicsEnvironment
                .getLocalGraphicsEnvironment()
                .getScreenDevices();

        screenBounds = new Rectangle[devices.length];
        scales = new double[devices.length][2];
        for (int i = 0; i < devices.length; i++) {
            GraphicsConfiguration gc = devices[i].getDefaultConfiguration();
            screenBounds[i] = gc.getBounds();
            AffineTransform tx = gc.getDefaultTransform();
            scales[i][0] = tx.getScaleX();
            scales[i][1] = tx.getScaleY();
        }

        maxBounds = screenBounds[0];
        for (int i = 0; i < screenBounds.length; i++) {
            maxBounds = maxBounds.union(screenBounds[i]);
        }
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:22,代碼來源:RobotMultiDPIScreenTest.java

示例11: add

import java.awt.Rectangle; //導入依賴的package包/類
/**
 * Adds a <code>Rectangle</code> to this <code>RepaintArea</code>.
 * PAINT Rectangles are divided into mostly vertical and mostly horizontal.
 * Each group is unioned together.
 * UPDATE Rectangles are unioned.
 *
 * @param   r   the specified <code>Rectangle</code>
 * @param   id  possible values PaintEvent.UPDATE or PaintEvent.PAINT
 * @since   1.3
 */
public synchronized void add(Rectangle r, int id) {
    // Make sure this new rectangle has positive dimensions
    if (r.isEmpty()) {
        return;
    }
    int addTo = UPDATE;
    if (id == PaintEvent.PAINT) {
        addTo = (r.width > r.height) ? HORIZONTAL : VERTICAL;
    }
    if (paintRects[addTo] != null) {
        paintRects[addTo].add(r);
    } else {
        paintRects[addTo] = new Rectangle(r);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:26,代碼來源:RepaintArea.java

示例12: paintTitle

import java.awt.Rectangle; //導入依賴的package包/類
protected void paintTitle(final Graphics2D g2d, final Font font, final FontMetrics metrics, final Rectangle textRect, final int tabIndex, final String title) {
    final View v = getTextViewForTab(tabIndex);
    if (v != null) {
        v.paint(g2d, textRect);
        return;
    }

    if (title == null) return;

    final Color color = tabPane.getForegroundAt(tabIndex);
    if (color instanceof UIResource) {
        g2d.setColor(getNonSelectedTabTitleColor());
        if (tabPane.getSelectedIndex() == tabIndex) {
            boolean pressed = isPressedAt(tabIndex);
            boolean enabled = tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex);
            Color textColor = getSelectedTabTitleColor(enabled, pressed);
            Color shadowColor = getSelectedTabTitleShadowColor(enabled);
            AquaUtils.paintDropShadowText(g2d, tabPane, font, metrics, textRect.x, textRect.y, 0, 1, textColor, shadowColor, title);
            return;
        }
    } else {
        g2d.setColor(color);
    }
    g2d.setFont(font);
    SwingUtilities2.drawString(tabPane, g2d, title, textRect.x, textRect.y + metrics.getAscent());
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:27,代碼來源:AquaTabbedPaneContrastUI.java

示例13: paintExpandControl

import java.awt.Rectangle; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
protected void paintExpandControl(Graphics g, Rectangle clipBounds,
        Insets insets, Rectangle bounds, TreePath path, int row,
        boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) {
    //modify the paintContext's state to match the state for the row
    //this is a hack in that it requires knowledge of the subsequent
    //method calls. The point is, the context used in drawCentered
    //should reflect the state of the row, not of the tree.
    boolean isSelected = tree.getSelectionModel().isPathSelected(path);
    int state = paintContext.getComponentState();
    if (isSelected) {
        paintContext.setComponentState(state | SynthConstants.SELECTED);
    }
    super.paintExpandControl(g, clipBounds, insets, bounds, path, row,
            isExpanded, hasBeenExpanded, isLeaf);
    paintContext.setComponentState(state);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:SynthTreeUI.java

示例14: findImage

import java.awt.Rectangle; //導入依賴的package包/類
@Override
public ImageFinderResult findImage(Rectangle sourceScreenRect, BufferedImage templateImage, double desiredAccuracy) {
    try {
        BufferedImage capture = new Robot().createScreenCapture(sourceScreenRect);
        Mat sourceMat = CvHelper.convertToMat(capture);
        Mat templateMat = CvHelper.convertToMat(templateImage);
        return this.findImage(sourceMat, templateMat, desiredAccuracy);
    } catch (Exception ex) {
        throw new RuntimeException(String.format(
                "An error ocurred while trying to find an image on screen at (%s, %s, %s, %s)",
                sourceScreenRect.x,
                sourceScreenRect.y,
                sourceScreenRect.width,
                sourceScreenRect.height), ex);
    }
}
 
開發者ID:mcdcorp,項目名稱:opentest,代碼行數:17,代碼來源:ImageFinder.java

示例15: setValue

import java.awt.Rectangle; //導入依賴的package包/類
public void setValue(String in) {
  final StringTokenizer st = new StringTokenizer(in, ",");
  try {
    setValue(new Rectangle(Integer.parseInt(st.nextToken()),
                           Integer.parseInt(st.nextToken()),
                           Integer.parseInt(st.nextToken()),
                           Integer.parseInt(st.nextToken())));
  }
  catch (NumberFormatException e) {
    // This can happen if a VisibilityOption has the same name
    // as a PositionOption, either currently, or due to editing.
    // Don't throw a bug, just log it.
    if (in.indexOf('\t') > 0) {
      ErrorDialog.dataError(new BadDataReport("Map or Chart window with same name as piece Palette", getKey(), e));
    }
    else {
      ErrorDialog.bug(e);
    }
  }
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:21,代碼來源:PositionOption.java


注:本文中的java.awt.Rectangle類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。