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; }
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; }
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(); } }
if (scroll != null) { final Rectangle bounds = scroll.getBounds(); bounds.translate(0, scroll.getHeight() - height); bounds.height = height; final JRootPane rootPane = SwingUtilities.getRootPane(myParent);
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); } }
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; }
location.setLocation(snapCorner.getX() + translation.x, snapCorner.getY() + translation.y); final Point padding = OverlayUtil.padPosition(overlayPosition, dimension, PADDING); snapCorner.translate(padding.x, padding.y);
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); }
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; }
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))); }
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)); }
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; }
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; }
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(); }
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);
rect.translate(-pt.x, -pt.y); viewport.scrollRectToVisible(rect);
numPlanes = size; Rectangle rectangle = new Rectangle(); rectangle.translate(OFFSET_X, OFFSET_Y);
numEmblems = size; Rectangle rectangle = new Rectangle(); rectangle.translate(OFFSET_X, OFFSET_Y);
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); } }