public void paint(Graphics g) { if (isVisible()) { try { JTextComponent component = getComponent(); Rectangle r = component.getUI().modelToView(component, getDot()); Color c = g.getColor(); g.setColor(component.getBackground()); g.setXORMode(component.getCaretColor()); r.setBounds(r.x, r.y, g.getFontMetrics().charWidth('w'), g.getFontMetrics().getHeight()); g.fillRect(r.x, r.y, r.width, r.height); g.setPaintMode(); g.setColor(c); } catch (BadLocationException e) { e.printStackTrace(); } } }
private Rectangle getParentBounds(final Widget widget) { if (!client.isClientThread()) { return parentBounds; } if (widget == null || widget.isHidden()) { parentBounds.setBounds(new Rectangle()); return parentBounds; } final Widget parent = widget.getParent(); final Rectangle bounds; if (parent == null) { bounds = new Rectangle(client.getRealDimensions()); } else { bounds = new Rectangle(parent.getCanvasLocation().getX(), parent.getCanvasLocation().getY(), parent.getWidth(), parent.getHeight()); } parentBounds.setBounds(bounds); return bounds; } }
private Collection<WidgetItem> getShopItems(Client client) { Collection<WidgetItem> widgetItems = new ArrayList<>(); Widget shop = client.getWidget(WidgetInfo.SHOP_ITEMS_CONTAINER); if (shop != null && !shop.isHidden()) { Widget[] children = shop.getDynamicChildren(); for (int i = 1; i < children.length; i++) { Widget child = children[i]; // set bounds to same size as default inventory Rectangle bounds = child.getBounds(); bounds.setBounds(bounds.x - 1, bounds.y - 1, 32, 32); widgetItems.add(new WidgetItem(child.getItemId(), child.getItemQuantity(), i - 1, bounds)); } } return widgetItems; } }
private Collection<WidgetItem> getEquippedItems(Client client) { Collection<WidgetItem> widgetItems = new ArrayList<>(); Widget equipment = client.getWidget(WidgetInfo.EQUIPMENT); if (equipment != null && !equipment.isHidden()) { if (slots.isEmpty()) { slots.addAll(Arrays.asList(ALL_EQUIPMENT_WIDGET_INFOS)); } for (WidgetInfo slot : slots) { Widget parentWidget = client.getWidget(slot); Widget itemWidget = parentWidget.getChild(1); // Check if background icon is hidden. if hidden, item is equipped. boolean equipped = parentWidget.getChild(2).isSelfHidden(); // set bounds to same size as default inventory Rectangle bounds = itemWidget.getBounds(); bounds.setBounds(bounds.x - 1, bounds.y - 1, 32, 32); // Index is set to 0 because there is no set in stone order of equipment slots widgetItems.add(new WidgetItem(equipped ? itemWidget.getItemId() : -1, itemWidget.getItemQuantity(), 0, bounds)); } } return widgetItems; } }
bounds.setBounds(bounds.x - 1, bounds.y - 1, 32, 32); widgetItems.add(new WidgetItem(child.getItemId(), child.getItemQuantity(), i, bounds));
/** * Paint UI related overlays to target graphics * @param graphics target graphics */ public void paintOverlays(final Graphics2D graphics) { if (!(client instanceof Client) || withTitleBar) { return; } final Client client = (Client) this.client; final int x = client.getRealDimensions().width - sidebarOpenIcon.getWidth() - 5; // Offset sidebar button if resizable mode logout is visible final Widget logoutButton = client.getWidget(WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE_LOGOUT_BUTTON); final int y = logoutButton != null && !logoutButton.isHidden() && logoutButton.getParent() != null ? logoutButton.getHeight() + logoutButton.getRelativeY() : 5; final BufferedImage image = sidebarOpen ? sidebarClosedIcon : sidebarOpenIcon; final Rectangle sidebarButtonRange = new Rectangle(x - 15, 0, image.getWidth() + 25, client.getRealDimensions().height); final Point mousePosition = new Point( client.getMouseCanvasPosition().getX() + client.getViewportXOffset(), client.getMouseCanvasPosition().getY() + client.getViewportYOffset()); if (sidebarButtonRange.contains(mousePosition.getX(), mousePosition.getY())) { graphics.drawImage(image, x, y, null); } // Update button dimensions sidebarButtonPosition.setBounds(x, y, image.getWidth(), image.getHeight()); }
private Collection<WidgetItem> getBankItems(Client client) { Collection<WidgetItem> widgetItems = new ArrayList<>(); Widget bank = client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER); if (bank != null && !bank.isHidden()) { Widget[] children = bank.getDynamicChildren(); for (int i = 0; i < children.length; i++) { Widget child = children[i]; if (child.getItemId() == ITEM_EMPTY || child.isSelfHidden()) { continue; } // set bounds to same size as default inventory Rectangle bounds = child.getBounds(); bounds.setBounds(bounds.x - 1, bounds.y - 1, 32, 32); // Index is set to 0 because the widget's index does not correlate to the order in the bank widgetItems.add(new WidgetItem(child.getItemId(), child.getItemQuantity(), 0, bounds)); } } return widgetItems; } }
public void setSourceRegion(final Rectangle pSourceRegion) { if (pSourceRegion == null) { sourceRegion = null; } else { if (sourceRegion == null) { sourceRegion = new Rectangle(pSourceRegion); } else { sourceRegion.setBounds(pSourceRegion); } } }
public void setSourceRegion(final Rectangle pSourceRegion) { if (pSourceRegion == null) { sourceRegion = null; } else { if (sourceRegion == null) { sourceRegion = new Rectangle(pSourceRegion); } else { sourceRegion.setBounds(pSourceRegion); } } }
public @Override void setBounds(int x, int y, int w, int h) { if (swingRendering) { super.setBounds(x, y, w, h); } bounds.setBounds(x, y, w, h); }
public void autoScrollTest(Point pt) { Rectangle r = this.getTabAreaBounds(); if (isTopBottomTabPlacement(this.getTabPlacement())) { RECT_BACKWARD.setBounds(r.x, r.y, SCROLL_SIZE, r.height); RECT_FORWARD.setBounds(r.x + r.width - SCROLL_SIZE - BUTTON_SIZE, r.y, SCROLL_SIZE + BUTTON_SIZE, r.height); } else { // if (tabPlacement == LEFT || tabPlacement == RIGHT) { RECT_BACKWARD.setBounds(r.x, r.y, r.width, SCROLL_SIZE); RECT_FORWARD.setBounds(r.x, r.y + r.height - SCROLL_SIZE - BUTTON_SIZE, r.width, SCROLL_SIZE + BUTTON_SIZE); } if (RECT_BACKWARD.contains(pt)) { this.clickArrowButton("scrollTabsBackwardAction"); } else if (RECT_FORWARD.contains(pt)) { this.clickArrowButton("scrollTabsForwardAction"); } }
public Optional<Rectangle> getDropLineRect() { int index = Optional.ofNullable(this.getDropLocation()) .filter(DropLocation::isDroppable) .map(DropLocation::getIndex) .orElse(-1); if (index < 0) { RECT_LINE.setBounds(0, 0, 0, 0); return Optional.empty(); } int a = Math.min(index, 1); // index == 0 ? 0 : 1; Rectangle r = this.getBoundsAt(a * (index - 1)); if (isTopBottomTabPlacement(this.getTabPlacement())) { RECT_LINE.setBounds(r.x - LINE_WIDTH / 2 + r.width * a, r.y, LINE_WIDTH, r.height); } else { RECT_LINE.setBounds(r.x, r.y - LINE_WIDTH / 2 + r.height * a, r.width, LINE_WIDTH); } return Optional.of(RECT_LINE); }
canvasBounds.setBounds(p.getX(), p.getY() + BUTTON_HEIGHT, bounds.width, maxTabs * TAB_HEIGHT + maxTabs * MARGIN);
/** * Disposes of the focusable tip currently displayed, if any. */ public void possiblyDisposeOfTipWindow() { if (tipWindow != null) { tipWindow.dispose(); tipWindow = null; textAreaListener.uninstall(); tipVisibleBounds.setBounds(-1, -1, 0, 0); lastText = null; textArea.requestFocus(); } }
@Override public void mouseDragged(MouseEvent e) { Point tabPt = e.getPoint(); // e.getDragOrigin(); if (Objects.nonNull(this.startPt) && this.startPt.distance(tabPt) > this.gestureMotionThreshold) { DnDTabbedPane src = (DnDTabbedPane) e.getComponent(); TransferHandler th = src.getTransferHandler(); DnDTabbedPane.this.dragTabIndex = src.indexAtLocation(tabPt.x, tabPt.y); th.exportAsDrag(src, e, TransferHandler.MOVE); RECT_LINE.setBounds(0, 0, 0, 0); src.getRootPane().getGlassPane().setVisible(true); src.setDropLocation(new DropLocation(tabPt, -1), null, true); this.startPt = null; } }
/** * Compute the bounds in which the user can move the mouse without the * tip window disappearing. */ private void computeTipVisibleBounds() { // Compute area that the mouse can move in without hiding the // tip window. Note that Java 1.4 can only detect mouse events // in Java windows, not globally. Rectangle r = tipWindow.getBounds(); Point p = r.getLocation(); SwingUtilities.convertPointFromScreen(p, textArea); r.setLocation(p); tipVisibleBounds.setBounds(r.x,r.y-15, r.width,r.height+15*2); }
sourceRegion.setBounds(new Rectangle(0, 0, Integer.MIN_VALUE, Integer.MIN_VALUE));
public void getRectangle(Rectangle r) { synchronized(tempRect) { r.setBounds(tempRect); } }
private static void transformBounds(Rectangle bounds, AffineTransform transform) { if (transform != null) { FourPoint corners = getCornersFromTransformedBounds(bounds, transform); double minX = getMinX(corners); double minY = getMinY(corners); double maxX = getMaxX(corners); double maxY = getMaxY(corners); bounds.setBounds((int) minX, (int) minY, (int) (maxX - minX), (int) (maxY - minY)); } }