Java Code Examples for net.runelite.api.NPC#getCanvasTextLocation()

The following examples show how to use net.runelite.api.NPC#getCanvasTextLocation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NpcHighlightOverlay.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private void renderTextOverlay(Graphics2D graphics, NPC npc, String text, Color color)
{
	Point textLocation = npc.getCanvasTextLocation(graphics, text, npc.getLogicalHeight() + 40);
	if (textLocation != null)
	{
		OverlayUtil.renderTextLocation(graphics, textLocation, text, color);
	}
}
 
Example 2
Source File: SpawnTimerOverlay.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private void renderNpcOverlay(Graphics2D graphics, NPC actor, String name, Color color)
{
	Point textLocation = actor.getCanvasTextLocation(graphics, name, actor.getLogicalHeight() - 40);

	if (textLocation != null)
	{
		OverlayUtil.renderTextLocation(graphics, textLocation, name, color);
	}
}
 
Example 3
Source File: TargetClickboxOverlay.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
private void renderNpcOverlay(Graphics2D graphics, NPC actor, Color color)
{
	switch (config.renderStyle())
	{
		case SOUTH_WEST_TILE:
			LocalPoint lp1 = LocalPoint.fromWorld(client, actor.getWorldLocation());

			if (lp1 == null)
			{
				return;
			}

			Polygon tilePoly1 = Perspective.getCanvasTilePoly(client, lp1);

			OverlayUtil.renderPolygon(graphics, tilePoly1, color);
			break;

		case TILE:
			int size = 1;
			NPCDefinition composition = actor.getTransformedDefinition();

			if (composition != null)
			{
				size = composition.getSize();
			}

			LocalPoint lp = actor.getLocalLocation();
			Polygon tilePoly = Perspective.getCanvasTileAreaPoly(client, lp, size);

			OverlayUtil.renderPolygon(graphics, tilePoly, color);
			break;

		case HULL:
			Shape objectClickbox = actor.getConvexHull();

			if (objectClickbox == null)
			{
				return;
			}

			OverlayUtil.renderPolygon(graphics, objectClickbox, color);
			break;
		case THIN_OUTLINE:
			modelOutliner.drawOutline(actor, 1, color);
			break;

		case OUTLINE:
			modelOutliner.drawOutline(actor, 2, color);
			break;

		case THIN_GLOW:
			modelOutliner.drawOutline(actor, 4, color, TRANSPARENT);
			break;

		case GLOW:
			modelOutliner.drawOutline(actor, 8, color, TRANSPARENT);
			break;
		case TRUE_LOCATIONS:
			size = 1;
			composition = actor.getTransformedDefinition();

			if (composition != null)
			{
				size = composition.getSize();
			}

			WorldPoint wp = actor.getWorldLocation();
			getSquare(wp, size).forEach(square ->
				drawTile(graphics, square, color, 1, 255, 50));
			break;
	}

	if (config.drawNames())
	{
		String npcName = Text.removeTags(actor.getName());
		Point textLocation = actor.getCanvasTextLocation(graphics, npcName, actor.getLogicalHeight() + 40);

		if (textLocation != null)
		{
			OverlayUtil.renderTextLocation(graphics, textLocation, npcName, color);
		}
	}
}