本文整理了Java中java.awt.Rectangle.translate
方法的一些代码示例,展示了Rectangle.translate
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Rectangle.translate
方法的具体详情如下:
包路径:java.awt.Rectangle
类名称:Rectangle
方法名:translate
[英]Translates this Rectangle
the indicated distance, to the right along the x coordinate axis, and downward along the y coordinate axis.
[中]将该Rectangle
转换为指示距离,沿x坐标轴向右,沿y坐标轴向下。
代码示例来源:origin: runelite/runelite
OverlayBounds translated(final int x, final int y)
{
final OverlayBounds translated = new OverlayBounds(this);
translated.getTopRight().translate(x, 0);
translated.getTopCenter().translate(x / 2, 0);
translated.getBottomLeft().translate(0, y);
translated.getBottomRight().translate(x, y);
translated.getAboveChatboxRight().translate(x, y);
translated.getCanvasTopRight().translate(x, 0);
return translated;
}
代码示例来源:origin: log4j/log4j
public boolean inCheckBoxHitRegion(MouseEvent e) {
TreePath path = tree.getPathForLocation(e.getX(),
e.getY());
if (path == null) {
return false;
}
CategoryNode node = (CategoryNode) path.getLastPathComponent();
boolean rv = false;
if (true) {
// offset and lastRow DefaultTreeCellEditor
// protected members
Rectangle bounds = tree.getRowBounds(lastRow);
Dimension checkBoxOffset =
renderer.getCheckBoxOffset();
bounds.translate(offset + checkBoxOffset.width,
checkBoxOffset.height);
rv = bounds.contains(e.getPoint());
}
return true;
}
代码示例来源:origin: JetBrains/ideavim
private void positionPanel() {
if (parent == null) return;
Container scroll = SwingUtilities.getAncestorOfClass(JScrollPane.class, parent);
int height = (int)getPreferredSize().getHeight();
if (scroll != null) {
Rectangle bounds = scroll.getBounds();
bounds.translate(0, scroll.getHeight() - height);
bounds.height = height;
Point pos = SwingUtilities.convertPoint(scroll.getParent(), bounds.getLocation(), oldGlass);
bounds.setLocation(pos);
setBounds(bounds);
repaint();
}
}
代码示例来源:origin: JetBrains/ideavim
if (scroll != null) {
final Rectangle bounds = scroll.getBounds();
bounds.translate(0, scroll.getHeight() - height);
bounds.height = height;
final JRootPane rootPane = SwingUtilities.getRootPane(myParent);
代码示例来源:origin: JetBrains/ideavim
private void positionPanel() {
final JComponent contentComponent = myEditor.getContentComponent();
Container scroll = SwingUtilities.getAncestorOfClass(JScrollPane.class, contentComponent);
setSize(scroll.getSize());
myLineHeight = myText.getFontMetrics(myText.getFont()).getHeight();
int count = countLines(myText.getText());
int visLines = getSize().height / myLineHeight - 1;
int lines = Math.min(count, visLines);
setSize(getSize().width, lines * myLineHeight + myLabel.getPreferredSize().height +
getBorder().getBorderInsets(this).top * 2);
int height = getSize().height;
Rectangle bounds = scroll.getBounds();
bounds.translate(0, scroll.getHeight() - height);
bounds.height = height;
Point pos = SwingUtilities.convertPoint(scroll.getParent(), bounds.getLocation(),
SwingUtilities.getRootPane(contentComponent).getGlassPane());
bounds.setLocation(pos);
setBounds(bounds);
myScrollPane.getVerticalScrollBar().setValue(0);
if (!Options.getInstance().isSet("more")) {
// FIX
scrollOffset(100000);
}
else {
scrollOffset(0);
}
}
代码示例来源:origin: runelite/runelite
intersectionRectangle.translate(getBounds().x, getBounds().y);
intersectionRectangle.translate(transformed.x, transformed.y);
代码示例来源:origin: magefree/mage
public static Rectangle translatePosition(int index, Rectangle r, Configuration conf) {
Rectangle rect = new Rectangle(r);
rect.translate((cardDimensions.frameWidth + GAP_X) * conf.dx[index],
(cardDimensions.frameHeight + GAP_Y) * conf.dy[index]);
return rect;
}
代码示例来源:origin: runelite/runelite
location.setLocation(snapCorner.getX() + translation.x, snapCorner.getY() + translation.y);
final Point padding = OverlayUtil.padPosition(overlayPosition, dimension, PADDING);
snapCorner.translate(padding.x, padding.y);
代码示例来源:origin: ron190/jsql-injection
private BufferedImage makeDragTabImage(DnDTabbedPane tabbedPane) {
Rectangle rect = tabbedPane.getBoundsAt(tabbedPane.dragTabIndex);
BufferedImage image = new BufferedImage(tabbedPane.getWidth(), tabbedPane.getHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics g2 = image.createGraphics();
tabbedPane.paint(g2);
g2.dispose();
if (rect.x < 0) {
rect.translate(-rect.x, 0);
}
if (rect.y < 0) {
rect.translate(0, -rect.y);
}
if (rect.x + rect.width > image.getWidth()) {
rect.width = image.getWidth() - rect.x;
}
if (rect.y + rect.height > image.getHeight()) {
rect.height = image.getHeight() - rect.y;
}
return image.getSubimage(rect.x, rect.y, rect.width, rect.height);
}
代码示例来源:origin: camunda/camunda-bpm-platform
public boolean inCheckBoxHitRegion(MouseEvent e) {
TreePath path = tree.getPathForLocation(e.getX(),
e.getY());
if (path == null) {
return false;
}
CategoryNode node = (CategoryNode) path.getLastPathComponent();
boolean rv = false;
if (true) {
// offset and lastRow DefaultTreeCellEditor
// protected members
Rectangle bounds = tree.getRowBounds(lastRow);
Dimension checkBoxOffset =
renderer.getCheckBoxOffset();
bounds.translate(offset + checkBoxOffset.width,
checkBoxOffset.height);
rv = bounds.contains(e.getPoint());
}
return true;
}
代码示例来源:origin: magefree/mage
private void loadCardsMany(CardsView showCards, BigCard bigCard, UUID gameId) {
int rowsOfCards = 20;
int columns = 1;
if (showCards != null && !showCards.isEmpty()) {
Rectangle rectangle = new Rectangle(cardDimension.width, cardDimension.height);
int count = 0;
for (CardView card : showCards.values()) {
addCard(card, bigCard, gameId, rectangle);
if (count >= rowsOfCards) {
rectangle.translate(cardDimension.width, -(rowsOfCards * verticalCardOffset));
columns++;
count = 0;
} else {
rectangle.translate(0, verticalCardOffset);
count++;
}
}
}
cardArea.setPreferredSize(new Dimension(cardDimension.width * columns, cardDimension.height + (rowsOfCards * verticalCardOffset)));
}
代码示例来源:origin: magefree/mage
private void loadCardsFew(CardsView showCards, BigCard bigCard, UUID gameId) {
Rectangle rectangle = new Rectangle(cardDimension.width, cardDimension.height);
for (CardView card : showCards.values()) {
addCard(card, bigCard, gameId, rectangle);
rectangle.translate(cardDimension.width, 0);
}
cardArea.setPreferredSize(new Dimension(cardDimension.width * showCards.size(), cardDimension.height));
}
代码示例来源:origin: ron190/jsql-injection
public Rectangle getTabAreaBounds() {
Rectangle tabbedRect = this.getBounds();
int xx = tabbedRect.x;
int yy = tabbedRect.y;
Rectangle compRect = Optional.ofNullable(this.getSelectedComponent()).map(Component::getBounds).orElseGet(Rectangle::new);
int tabPlacement = this.getTabPlacement();
if (isTopBottomTabPlacement(tabPlacement)) {
tabbedRect.height = tabbedRect.height - compRect.height;
if (tabPlacement == BOTTOM) {
tabbedRect.y += compRect.y + compRect.height;
}
} else {
tabbedRect.width = tabbedRect.width - compRect.width;
if (tabPlacement == RIGHT) {
tabbedRect.x += compRect.x + compRect.width;
}
}
tabbedRect.translate(-xx, -yy);
return tabbedRect;
}
代码示例来源:origin: magefree/mage
public int showTokens() {
jLayeredPane.removeAll();
List<Token> tokens = getTokens(currentPage, currentSet);
if (tokens != null && tokens.size() > 0) {
int size = tokens.size();
Rectangle rectangle = new Rectangle();
rectangle.translate(OFFSET_X, OFFSET_Y);
for (int i = 0; i < min(conf.CARDS_PER_PAGE / 2, size); i++) {
Token token = tokens.get(i);
addToken(token, bigCard, null, rectangle);
rectangle = CardPosition.translatePosition(i, rectangle, conf);
}
// calculate the x offset of the second (right) page
int second_page_x = (conf.WIDTH - 2 * LEFT_RIGHT_PAGES_WIDTH)
- (cardDimensions.frameWidth + CardPosition.GAP_X) * conf.CARD_COLUMNS + CardPosition.GAP_X - OFFSET_X;
rectangle.setLocation(second_page_x, OFFSET_Y);
for (int i = conf.CARDS_PER_PAGE / 2; i < min(conf.CARDS_PER_PAGE, size); i++) {
Token token = tokens.get(i);
addToken(token, bigCard, null, rectangle);
rectangle = CardPosition.translatePosition(i - conf.CARDS_PER_PAGE / 2, rectangle, conf);
}
jLayeredPane.repaint();
return tokens.size();
}
return 0;
}
代码示例来源:origin: magefree/mage
public void showCards() {
jLayeredPane.removeAll();
// stats info
updateCardStats(currentSet, true);
List<CardInfo> cards = getCards(currentPage, currentSet);
int size = cards.size();
Rectangle rectangle = new Rectangle();
rectangle.translate(OFFSET_X, OFFSET_Y);
for (int i = 0; i < min(conf.CARDS_PER_PAGE / 2, size); i++) {
Card card = cards.get(i).getMockCard();
addCard(new CardView(card), bigCard, null, rectangle);
rectangle = CardPosition.translatePosition(i, rectangle, conf);
}
// calculate the x offset of the second (right) page
int second_page_x = (conf.WIDTH - 2 * LEFT_RIGHT_PAGES_WIDTH)
- (cardDimensions.frameWidth + CardPosition.GAP_X) * conf.CARD_COLUMNS + CardPosition.GAP_X - OFFSET_X;
rectangle.setLocation(second_page_x, OFFSET_Y);
for (int i = conf.CARDS_PER_PAGE / 2; i < min(conf.CARDS_PER_PAGE, size); i++) {
Card card = cards.get(i).getMockCard();
addCard(new CardView(card), bigCard, null, rectangle);
rectangle = CardPosition.translatePosition(i - conf.CARDS_PER_PAGE / 2, rectangle, conf);
}
jLayeredPane.repaint();
}
代码示例来源:origin: magefree/mage
int dyOffset = Math.max(permWithAttachments.getHeight() / 10, ATTACHMENT_MIN_DY_OFFSET); // calculate y offset
if (VerticalIndex == 1) {
rectangleBaseCard.translate(Math.max(permWithAttachments.getWidth() / 10, ATTACHMENTS_MIN_DX_OFFSET), dyOffset); // do it once
} else {
rectangleBaseCard.translate(0, dyOffset);
代码示例来源:origin: ron190/jsql-injection
rect.translate(-pt.x, -pt.y);
viewport.scrollRectToVisible(rect);
代码示例来源:origin: magefree/mage
numPlanes = size;
Rectangle rectangle = new Rectangle();
rectangle.translate(OFFSET_X, OFFSET_Y);
代码示例来源:origin: magefree/mage
numEmblems = size;
Rectangle rectangle = new Rectangle();
rectangle.translate(OFFSET_X, OFFSET_Y);
代码示例来源:origin: magefree/mage
private void groupAttachments(BattlefieldPanel battlefieldPanel, JLayeredPane mainPanel, Map<UUID, MagePermanent> permanents, PermanentView permanentWithAttachmentsView) {
MagePermanent permWithAttachments = permanents.get(permanentWithAttachmentsView.getId());
if (permWithAttachments == null) {
return;
}
// Calculate how many vertical columns are needed and number of attachements
AttachmentLayoutInfos attachmentLayoutInfos = calculateNeededNumberOfVerticalColumns(0, battlefieldPanel, permanents, permanentWithAttachmentsView);
int position = battlefieldPanel.getPosition(permWithAttachments); // relative position within the layer
// permWithAttachments.getLinks().clear();
Rectangle rectangleBaseCard = permWithAttachments.getBounds();
if (!Plugins.instance.isCardPluginLoaded()) {
permWithAttachments.getLinks().clear();
for (UUID attachmentId : permanentWithAttachmentsView.getAttachments()) {
MagePermanent link = permanents.get(attachmentId);
if (link != null) {
permWithAttachments.getLinks().add(link);
rectangleBaseCard.translate(20, 20);
link.setBounds(rectangleBaseCard);
battlefieldPanel.setPosition(link, ++position);
}
}
} else {
layoutAttachements(rectangleBaseCard.getX(), attachmentLayoutInfos.getColumns(),
attachmentLayoutInfos.getAttachments(), permanentWithAttachmentsView, permanents, battlefieldPanel, mainPanel, rectangleBaseCard);
mainPanel.setComponentZOrder(permWithAttachments, 0);
}
}
内容来源于网络,如有侵权,请联系作者删除!