Search in sources :

Example 1 with InfoBoxComponent

use of net.runelite.client.ui.overlay.components.InfoBoxComponent in project runelite by runelite.

the class InfoBoxOverlay method render.

@Override
public Dimension render(Graphics2D graphics) {
    List<InfoBox> infoBoxes = infoboxManager.getInfoBoxes();
    if (infoBoxes.isEmpty()) {
        return null;
    }
    int width = infoBoxes.size() * (BOXSIZE + SEPARATOR);
    int x = 0;
    for (InfoBox box : infoBoxes) {
        if (!box.render()) {
            continue;
        }
        final InfoBoxComponent infoBoxComponent = new InfoBoxComponent();
        infoBoxComponent.setColor(box.getTextColor());
        infoBoxComponent.setImage(box.getImage());
        infoBoxComponent.setText(box.getText());
        infoBoxComponent.setPosition(new Point(x, 0));
        final Dimension infoBoxBounds = infoBoxComponent.render(graphics);
        if (!Strings.isNullOrEmpty(box.getTooltip())) {
            final Rectangle intersectionRectangle = new Rectangle(infoBoxBounds);
            intersectionRectangle.setLocation(getBounds().getLocation());
            intersectionRectangle.translate(x, 0);
            final Point transformed = OverlayUtil.transformPosition(getPosition(), intersectionRectangle.getSize());
            intersectionRectangle.translate(transformed.x, transformed.y);
            final Client client = clientProvider.get();
            if (client != null && intersectionRectangle.contains(new Point(client.getMouseCanvasPosition().getX(), client.getMouseCanvasPosition().getY()))) {
                tooltipManager.add(new Tooltip(box.getTooltip()));
            }
        }
        x += BOXSIZE + SEPARATOR;
    }
    return new Dimension(width, BOXSIZE);
}
Also used : InfoBoxComponent(net.runelite.client.ui.overlay.components.InfoBoxComponent) Tooltip(net.runelite.client.ui.overlay.tooltip.Tooltip) Rectangle(java.awt.Rectangle) Point(java.awt.Point) Dimension(java.awt.Dimension) Client(net.runelite.api.Client) Point(java.awt.Point)

Aggregations

Dimension (java.awt.Dimension)1 Point (java.awt.Point)1 Rectangle (java.awt.Rectangle)1 Client (net.runelite.api.Client)1 InfoBoxComponent (net.runelite.client.ui.overlay.components.InfoBoxComponent)1 Tooltip (net.runelite.client.ui.overlay.tooltip.Tooltip)1