Search in sources :

Example 86 with Rectangle

use of java.awt.Rectangle in project darkFunction-Editor by darkFunction.

the class AnimationCell method draw.

public void draw(final Graphics g, final Rectangle destRect) {
    if (vImage == null)
        return;
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsConfiguration gc = ge.getDefaultScreenDevice().getDefaultConfiguration();
    int valid = vImage.validate(gc);
    if (valid == VolatileImage.IMAGE_INCOMPATIBLE) {
        rebuild();
    }
    if (vImage != null) {
        Rectangle r = destRect;
        g.drawImage(vImage, r.x, r.y, r.width, r.height, null);
    }
}
Also used : Rectangle(java.awt.Rectangle) GraphicsEnvironment(java.awt.GraphicsEnvironment) Point(java.awt.Point) GraphicsConfiguration(java.awt.GraphicsConfiguration)

Example 87 with Rectangle

use of java.awt.Rectangle in project darkFunction-Editor by darkFunction.

the class AnimationStripPanel method paintComponent.

@Override
public void paintComponent(Graphics g) {
    super.paintComponent(g);
    // slots
    for (int i = 0; i < slotList.size(); ++i) {
        Slot slot = slotList.get(i);
        slot.draw(g);
    }
    // dragged slots
    for (int i = 0; i < slotList.size(); ++i) {
        Slot draggedSlot = slotList.get(i);
        if (draggedSlot.isDragged() && draggedSlot.getDragImage() != null) {
            g.drawImage(draggedSlot.getDragImage(), mousePoint.x, draggedSlot.getRect().y, null);
            if (insertBeforeSlotIndex >= 0) {
                g.setColor(Color.RED);
                int insertXPos = 0;
                if (insertBeforeSlotIndex < slotList.size()) {
                    insertXPos = slotList.get(insertBeforeSlotIndex).getRect().x;
                } else if (insertBeforeSlotIndex == slotList.size()) {
                    // last slot, draw inser marker at end
                    Rectangle slotRect = slotList.get(insertBeforeSlotIndex - 1).getRect();
                    insertXPos = slotRect.x + slotRect.width;
                }
                g.fillRect(insertXPos - 1, 0, 3, this.getHeight());
            }
        }
    }
    // animation marker
    g.setColor(Color.BLUE);
    for (int i = 0; i < slotList.size(); ++i) {
        if (i == currentSlotInAnimation) {
            Slot slot = slotList.get(i);
            Rectangle r = slot.getRect();
            g.drawRect(r.x, r.y, r.width, r.height);
        }
    }
}
Also used : Rectangle(java.awt.Rectangle) Point(java.awt.Point)

Example 88 with Rectangle

use of java.awt.Rectangle in project pcgen by PCGen.

the class EquipmentModels method prepareScrollPane.

private static JScrollPane prepareScrollPane(JTable table) {
    JScrollPane pane = new JScrollPane(table);
    Dimension size = table.getPreferredSize();
    // account for the header which has not been prepared yet
    size.height += 30;
    final int decorationHeight = 80;
    final int decorationWidth = 70;
    Rectangle screenBounds = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
    if (size.height > screenBounds.height - decorationHeight) {
        size.height = screenBounds.height - decorationHeight;
    }
    if (size.width > screenBounds.width - decorationWidth) {
        size.width = screenBounds.width - decorationWidth;
    }
    pane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    pane.setPreferredSize(size);
    return pane;
}
Also used : JScrollPane(javax.swing.JScrollPane) Rectangle(java.awt.Rectangle) Dimension(java.awt.Dimension)

Example 89 with Rectangle

use of java.awt.Rectangle in project pcgen by PCGen.

the class PCGVer2Creator method appendPortraitLine.

private void appendPortraitLine(StringBuilder buffer) {
    buffer.append(IOConstants.TAG_PORTRAIT).append(':');
    buffer.append(EntityEncoder.encode(charDisplay.getPortraitPath()));
    buffer.append(IOConstants.LINE_SEP);
    Rectangle rect = charDisplay.getPortraitThumbnailRect();
    if (rect != null) {
        buffer.append(IOConstants.TAG_PORTRAIT_THUMBNAIL_RECT).append(':');
        buffer.append(rect.x).append(',');
        buffer.append(rect.y).append(',');
        buffer.append(rect.width).append(',');
        buffer.append(rect.height);
        buffer.append(IOConstants.LINE_SEP);
    }
}
Also used : Rectangle(java.awt.Rectangle)

Example 90 with Rectangle

use of java.awt.Rectangle in project pcgen by PCGen.

the class Utility method setComponentRelativeLocation.

/**
	 * Centres the dialog over the component ensuring that the dialog will be
	 * within the usable area of the screen (i.e. excluding native task bars,
	 * menus bars etc).
	 *
	 * @param parent The component over which the dialog should be centred.
	 * @param dialog The dialog to be positioned.
	 */
public static void setComponentRelativeLocation(Component parent, Component dialog) {
    // First make sure it is not too big
    resizeComponentToScreen(dialog);
    // Get the maximum window size to account for taskbars etc
    Rectangle screenBounds = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
    Point centreOfParent = new Point(parent.getWidth() / 2, parent.getHeight() / 2);
    SwingUtilities.convertPointToScreen(centreOfParent, parent);
    // Default to centre of parent
    Point location = new Point(centreOfParent.x - (dialog.getWidth() / 2), centreOfParent.y - (dialog.getHeight() / 2));
    // Adjust so it fits on the screen
    if ((location.x + dialog.getWidth()) > (screenBounds.width + screenBounds.x)) {
        location.x -= (location.x + dialog.getWidth()) - (screenBounds.width + screenBounds.x);
    }
    if (location.x < screenBounds.x) {
        location.x = screenBounds.x;
    }
    if ((location.y + dialog.getHeight()) > (screenBounds.height + screenBounds.y)) {
        location.y -= (location.y + dialog.getHeight()) - (screenBounds.height + screenBounds.y);
    }
    if (location.y < screenBounds.y) {
        location.y = screenBounds.y;
    }
    dialog.setLocation(location);
}
Also used : Rectangle(java.awt.Rectangle) Point(java.awt.Point)

Aggregations

Rectangle (java.awt.Rectangle)809 Point (java.awt.Point)201 Dimension (java.awt.Dimension)81 BufferedImage (java.awt.image.BufferedImage)68 Graphics2D (java.awt.Graphics2D)65 Color (java.awt.Color)48 Insets (java.awt.Insets)47 ArrayList (java.util.ArrayList)37 Font (java.awt.Font)29 Test (org.junit.Test)28 IOException (java.io.IOException)27 GraphicsConfiguration (java.awt.GraphicsConfiguration)23 Paint (java.awt.Paint)23 GradientPaint (java.awt.GradientPaint)22 FontMetrics (java.awt.FontMetrics)21 Graphics (java.awt.Graphics)21 Rectangle2D (java.awt.geom.Rectangle2D)21 Robot (java.awt.Robot)19 File (java.io.File)19 PeakResult (gdsc.smlm.results.PeakResult)18