public void render(Component c, Graphics g, int x, int y, int width, int height) { if (!(c.getParent() instanceof JViewport)) { return; } JViewport viewport = (JViewport) c.getParent(); width = viewport.getWidth(); height = viewport.getHeight(); x = viewport.getViewRect().x; y = viewport.getViewRect().y; if (isHide(width, height)) { return; } Instant now = Instant.now(); int imageWidth = characterBase.getWidth(); int imageHeight = characterBase.getHeight(); int margin = ImageUtil.defaultScale(30); int charaX = width - imageWidth - margin + x; int charaY = height - imageHeight + y; Graphics2D g2d = JBSwingUtilities.runGlobalCGTransform((JComponent) c, g); CharacterPosition position = CharacterPosition.of(charaX, charaY); g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f)); ImageUtil.drawImage(g2d, characterBase, charaX, charaY); faceRenderer.render(now, g2d, position, riho); g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1)); emotionRenderer.render(now, g2d, position, riho); }
static JList findJList(ListPopup popup) { Set<Component> lists = JBSwingUtilities.uiTraverser().preOrderTraversal(popup.getContent()) .filter(new FilteringIterator.InstanceOf<>(JList.class)).toSet(); if ( lists.size() != 1 ) { throw new IllegalStateException("Expected exactly one JList"); } return (JList)lists.iterator().next(); }
ExtendedKeyboardActionDispatcher(ListPopup popup) { this.popup = popup; Set<Component> lists = JBSwingUtilities.uiTraverser().preOrderTraversal(popup.getContent()) .filter(new FilteringIterator.InstanceOf<>(JList.class)).toSet(); if ( lists.size() != 1 ) { list = null; } else { list = (JList)lists.iterator().next(); } }
public static void createTemporaryBackgroundTransform(JPanel root, String tmp, Disposable disposable) { PaintersHelper paintersHelper = new PaintersHelper(root); PaintersHelper.initWallpaperPainter(tmp, paintersHelper); Disposer.register(disposable, JBSwingUtilities.addGlobalCGTransform((t, v) -> { if (!UIUtil.isAncestor(root, t)) return v; return MyGraphics.wrap(v, paintersHelper, t); })); }
@Override protected void processMouseMotionEvent(MouseEvent e) { if (SystemInfo.isMac && JBSwingUtilities.isRightMouseButton(e) && e.getID() == MouseEvent.MOUSE_DRAGGED) return; super.processMouseMotionEvent(e); }
@Override protected Graphics getComponentGraphics(final Graphics graphics) { return JBSwingUtilities.runGlobalCGTransform(this, super.getComponentGraphics(graphics)); }
@Override protected Graphics getComponentGraphics(Graphics graphics) { return JBSwingUtilities.runGlobalCGTransform(this, super.getComponentGraphics(graphics)); }
@Override protected Graphics getComponentGraphics(Graphics g) { return JBSwingUtilities.runGlobalCGTransform(this, super.getComponentGraphics(g)); }