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);
}
}
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);
}
}
}
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;
}
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);
}
}
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);
}
Aggregations