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);
}