Java Code Examples for net.runelite.api.widgets.Widget#getHeight()

The following examples show how to use net.runelite.api.widgets.Widget#getHeight() . 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: LightBoxOverlay.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private void highlightWidget(Graphics2D graphics, Widget window, Widget widget)
{
	net.runelite.api.Point canvasLocation = widget.getCanvasLocation();

	if (canvasLocation == null)
	{
		return;
	}

	// Don't draw outside the light box window
	net.runelite.api.Point windowLocation = window.getCanvasLocation();

	if (windowLocation.getY() > canvasLocation.getY()
		|| windowLocation.getY() + window.getHeight() < canvasLocation.getY() + widget.getHeight())
	{
		return;
	}

	Area widgetArea = new Area(new Rectangle(canvasLocation.getX(), canvasLocation.getY(), widget.getWidth(), widget.getHeight()));

	OverlayUtil.renderHoverableArea(graphics, widgetArea, client.getMouseCanvasPosition(),
		HIGHLIGHT_FILL_COLOR, HIGHLIGHT_BORDER_COLOR, HIGHLIGHT_HOVER_BORDER_COLOR);
}
 
Example 2
Source File: WidgetOverlay.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public Dimension render(Graphics2D graphics)
{
	final Widget widget = client.getWidget(widgetInfo);
	final Rectangle bounds = super.getBounds();
	final Rectangle parent = getParentBounds(widget);

	if (parent.isEmpty())
	{
		return null;
	}

	int x = bounds.x;
	int y = bounds.y;
	x = Math.max(parent.x, x);
	y = Math.max(parent.y, y);
	x = Math.min((int)parent.getMaxX() - bounds.width, x);
	y = Math.min((int)parent.getMaxY() - bounds.height, y);
	bounds.setLocation(x, y);
	widget.setOriginalX(0);
	widget.setOriginalY(0);
	widget.setRelativeX(bounds.x - parent.x);
	widget.setRelativeY(bounds.y - parent.y);
	return new Dimension(widget.getWidth(), widget.getHeight());
}
 
Example 3
Source File: ClueScrollPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
void scrollToWidget(WidgetInfo list, WidgetInfo scrollbar, Widget... toHighlight)
{
	final Widget parent = client.getWidget(list);
	int averageCentralY = 0;
	int nonnullCount = 0;
	for (Widget widget : toHighlight)
	{
		if (widget != null)
		{
			averageCentralY += widget.getRelativeY() + widget.getHeight() / 2;
			nonnullCount += 1;
		}
	}
	if (nonnullCount == 0)
	{
		return;
	}
	averageCentralY /= nonnullCount;
	final int newScroll = Math.max(0, Math.min(parent.getScrollHeight(),
		averageCentralY - parent.getHeight() / 2));

	client.runScript(
		ScriptID.UPDATE_SCROLLBAR,
		scrollbar.getId(),
		list.getId(),
		newScroll
	);
}
 
Example 4
Source File: ClueScrollPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
void scrollToWidget(WidgetInfo list, WidgetInfo scrollbar, Widget ... toHighlight)
{
	final Widget parent = client.getWidget(list);
	int averageCentralY = 0;
	int nonnullCount = 0;
	for (Widget widget : toHighlight)
	{
		if (widget != null)
		{
			averageCentralY += widget.getRelativeY() + widget.getHeight() / 2;
			nonnullCount += 1;
		}
	}
	if (nonnullCount == 0)
	{
		return;
	}
	averageCentralY /= nonnullCount;
	final int newScroll = Math.max(0, Math.min(parent.getScrollHeight(),
		averageCentralY - parent.getHeight() / 2));

	client.runScript(
		ScriptID.UPDATE_SCROLLBAR,
		scrollbar.getId(),
		list.getId(),
		newScroll
	);
}
 
Example 5
Source File: MusicPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
private void updateList(Widget musicList, String filter)
{
	if (tracks == null)
	{
		tracks = Arrays.stream(musicList.getDynamicChildren())
			.sorted(Comparator.comparing(Widget::getRelativeY))
			.collect(Collectors.toList());
	}

	tracks.forEach(w -> w.setHidden(true));

	Collection<Widget> relevantTracks = tracks.stream()
		.filter(w -> w.getText().toLowerCase().contains(filter))
		.filter(w -> currentMusicFilter == MusicState.ALL || w.getTextColor() == currentMusicFilter.getColor())
		.collect(Collectors.toList());

	// Original music track list has a little offset
	int y = 3;

	for (Widget track : relevantTracks)
	{
		track.setHidden(false);
		track.setOriginalY(y);
		track.revalidate();

		y += track.getHeight();
	}

	y += 3;

	int newHeight = 0;

	if (musicList.getScrollHeight() > 0)
	{
		newHeight = (musicList.getScrollY() * y) / musicList.getScrollHeight();
	}

	musicList.setScrollHeight(y);
	musicList.revalidateScroll();

	client.runScript(
		ScriptID.UPDATE_SCROLLBAR,
		WidgetInfo.MUSIC_TRACK_SCROLLBAR.getId(),
		WidgetInfo.MUSIC_TRACK_LIST.getId(),
		newHeight
	);
}
 
Example 6
Source File: TabInterface.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
private void updateBounds()
{
	Widget itemContainer = client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER);
	if (itemContainer == null)
	{
		return;
	}

	int height = itemContainer.getHeight();

	// If player isn't using normal bank tabs
	if (itemContainer.getRelativeY() == 0)
	{
		height -= (TAB_HEIGHT + MARGIN);
	}

	bounds.setSize(TAB_WIDTH + MARGIN * 2, height);
	bounds.setLocation(MARGIN, TAB_HEIGHT + MARGIN);

	Widget incinerator = client.getWidget(WidgetInfo.BANK_INCINERATOR);

	if (incinerator != null && !incinerator.isHidden())
	{
		incinerator.setOriginalHeight(INCINERATOR_HEIGHT);
		incinerator.setOriginalWidth(INCINERATOR_WIDTH);
		incinerator.setOriginalY(INCINERATOR_HEIGHT);

		Widget child = incinerator.getDynamicChildren()[0];
		child.setOriginalHeight(INCINERATOR_HEIGHT);
		child.setOriginalWidth(INCINERATOR_WIDTH);
		child.setWidthMode(WidgetSizeMode.ABSOLUTE);
		child.setHeightMode(WidgetSizeMode.ABSOLUTE);
		child.setType(WidgetType.GRAPHIC);
		child.setSpriteId(TabSprites.INCINERATOR.getSpriteId());
		incinerator.revalidate();

		bounds.setSize(TAB_WIDTH + MARGIN * 2, height - incinerator.getHeight());
	}

	if (upButton != null)
	{
		Point p = upButton.getCanvasLocation();
		canvasBounds.setBounds(p.getX(), p.getY() + BUTTON_HEIGHT, bounds.width, maxTabs * TAB_HEIGHT + maxTabs * MARGIN);
	}
}
 
Example 7
Source File: ClueScrollPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
void highlightWidget(Graphics2D graphics, Widget toHighlight, Widget container, Rectangle padding, String text)
{
	padding = Objects.requireNonNullElse(padding, new Rectangle());

	Point canvasLocation = toHighlight.getCanvasLocation();

	if (canvasLocation == null)
	{
		return;
	}

	Point windowLocation = container.getCanvasLocation();

	if (windowLocation.getY() > canvasLocation.getY() + toHighlight.getHeight()
		|| windowLocation.getY() + container.getHeight() < canvasLocation.getY())
	{
		return;
	}

	// Visible area of widget
	Area widgetArea = new Area(
		new Rectangle(
			canvasLocation.getX() - padding.x,
			Math.max(canvasLocation.getY(), windowLocation.getY()) - padding.y,
			toHighlight.getWidth() + padding.x + padding.width,
			Math.min(
				Math.min(windowLocation.getY() + container.getHeight() - canvasLocation.getY(), toHighlight.getHeight()),
				Math.min(canvasLocation.getY() + toHighlight.getHeight() - windowLocation.getY(), toHighlight.getHeight())) + padding.y + padding.height
		));

	OverlayUtil.renderHoverableArea(graphics, widgetArea, client.getMouseCanvasPosition(),
		HIGHLIGHT_FILL_COLOR, HIGHLIGHT_BORDER_COLOR, HIGHLIGHT_HOVER_BORDER_COLOR);

	if (text == null)
	{
		return;
	}

	FontMetrics fontMetrics = graphics.getFontMetrics();

	textComponent.setPosition(new java.awt.Point(
		canvasLocation.getX() + toHighlight.getWidth() / 2 - fontMetrics.stringWidth(text) / 2,
		canvasLocation.getY() + fontMetrics.getHeight()));
	textComponent.setText(text);
	textComponent.render(graphics);
}
 
Example 8
Source File: QuestListPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
private void updateFilter(String filter)
{
	filter = filter.toLowerCase();
	final Widget container = client.getWidget(WidgetInfo.QUESTLIST_CONTAINER);

	final Widget freeList = client.getWidget(QuestContainer.FREE_QUESTS.widgetInfo);
	final Widget memberList = client.getWidget(QuestContainer.MEMBER_QUESTS.widgetInfo);
	final Widget miniList = client.getWidget(QuestContainer.MINI_QUESTS.widgetInfo);

	if (container == null || freeList == null || memberList == null || miniList == null)
	{
		return;
	}

	updateList(QuestContainer.FREE_QUESTS, filter);
	updateList(QuestContainer.MEMBER_QUESTS, filter);
	updateList(QuestContainer.MINI_QUESTS, filter);

	memberList.setOriginalY(freeList.getOriginalY() + freeList.getOriginalHeight() + (freeList.getOriginalHeight() == 0 ? 0 : ENTRY_PADDING));
	miniList.setOriginalY(memberList.getOriginalY() + memberList.getOriginalHeight() + (memberList.getOriginalHeight() == 0 ? 0 : ENTRY_PADDING));

	// originalHeight is changed within updateList so revalidate all lists
	freeList.revalidate();
	memberList.revalidate();
	miniList.revalidate();

	int y = miniList.getRelativeY() + miniList.getHeight() + 10;

	int newHeight;
	if (container.getScrollHeight() > 0)
	{
		newHeight = (container.getScrollY() * y) / container.getScrollHeight();
	}
	else
	{
		newHeight = 0;
	}

	container.setScrollHeight(y);
	container.revalidateScroll();

	clientThread.invokeLater(() ->
		client.runScript(
			ScriptID.UPDATE_SCROLLBAR,
			WidgetInfo.QUESTLIST_SCROLLBAR.getId(),
			WidgetInfo.QUESTLIST_CONTAINER.getId(),
			newHeight
		));
}
 
Example 9
Source File: QuestListPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
private void updateList(QuestContainer questContainer, String filter)
{
	Widget list = client.getWidget(questContainer.widgetInfo);
	if (list == null)
	{
		return;
	}

	Collection<QuestWidget> quests = questSet.get(questContainer);

	if (quests != null &&
		// Check to make sure the list hasn't been rebuild since we were last her
		// Do this by making sure the list's dynamic children are the same as when we last saw them
		quests.stream().noneMatch(w ->
		{
			Widget codeWidget = w.getQuest();
			if (codeWidget == null)
			{
				return false;
			}
			return list.getChild(codeWidget.getIndex()) == codeWidget;
		}))
	{
		quests = null;
	}

	if (quests == null)
	{
		// Find all of the widgets that we care about, sorting by their Y value
		quests = Arrays.stream(list.getDynamicChildren())
			.sorted(Comparator.comparing(Widget::getRelativeY))
			.filter(w -> !QUEST_HEADERS.contains(w.getText()))
			.map(w -> new QuestWidget(w, Text.removeTags(w.getText()).toLowerCase()))
			.collect(Collectors.toList());
		questSet.put(questContainer, quests);
	}

	// offset because of header
	int y = 20;
	for (QuestWidget questInfo : quests)
	{
		Widget quest = questInfo.getQuest();
		QuestState questState = QuestState.getByColor(quest.getTextColor());

		boolean hidden;
		if (!filter.isEmpty())
		{
			// If searching, show result regardless of filtered state
			hidden = !questInfo.getTitle().contains(filter);
		}
		else
		{
			// Otherwise hide if it doesn't match the filter state
			if (currentFilterState == QuestState.NOT_COMPLETED)
			{
				hidden = questState == QuestState.COMPLETE;
			}
			else
			{
				hidden = currentFilterState != QuestState.ALL && questState != currentFilterState;
			}
		}

		quest.setHidden(hidden);
		quest.setOriginalY(y);
		quest.revalidate();

		if (!hidden)
		{
			y += quest.getHeight();
		}
	}

	long hiddenCount = quests.stream()
		.filter(q -> q.getQuest().isHidden())
		.count();
	list.setOriginalHeight(hiddenCount == quests.size() ? 0 : y);
}
 
Example 10
Source File: ChatboxTextMenuInput.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected void open()
{
	Widget container = chatboxPanelManager.getContainerWidget();

	Widget prompt = container.createChild(-1, WidgetType.TEXT);
	prompt.setText(title);
	prompt.setTextColor(0x800000);
	prompt.setFontId(FontID.QUILL_8);
	prompt.setXPositionMode(WidgetPositionMode.ABSOLUTE_CENTER);
	prompt.setOriginalX(0);
	prompt.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP);
	prompt.setOriginalY(8);
	prompt.setOriginalHeight(24);
	prompt.setXTextAlignment(WidgetTextAlignment.CENTER);
	prompt.setYTextAlignment(WidgetTextAlignment.CENTER);
	prompt.setWidthMode(WidgetSizeMode.MINUS);
	prompt.revalidate();

	int y = prompt.getRelativeX() + prompt.getHeight() + 6;
	int height = container.getHeight() - y - 8;
	int step = height / options.size();
	int maxStep = options.size() >= 3 ? 25 : 30;
	if (step > maxStep)
	{
		int ds = step - maxStep;
		step = maxStep;
		y += (ds * options.size()) / 2;
	}

	for (Entry option : options)
	{
		Widget optWidget = container.createChild(-1, WidgetType.TEXT);
		optWidget.setText(option.text);
		optWidget.setFontId(FontID.QUILL_8);
		optWidget.setXPositionMode(WidgetPositionMode.ABSOLUTE_CENTER);
		optWidget.setOriginalX(0);
		optWidget.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP);
		optWidget.setOriginalY(y);
		optWidget.setOriginalHeight(24);
		optWidget.setXTextAlignment(WidgetTextAlignment.CENTER);
		optWidget.setYTextAlignment(WidgetTextAlignment.CENTER);
		optWidget.setWidthMode(WidgetSizeMode.MINUS);
		optWidget.setAction(0, "Continue");
		optWidget.setOnOpListener((JavaScriptCallback) ev -> callback(option));
		optWidget.setOnMouseOverListener((JavaScriptCallback) ev -> optWidget.setTextColor(0xFFFFFF));
		optWidget.setOnMouseLeaveListener((JavaScriptCallback) ev -> optWidget.setTextColor(0));
		optWidget.setHasListener(true);
		optWidget.revalidate();

		y += step;
	}
}
 
Example 11
Source File: MusicPlugin.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void updateList(Widget musicList, String filter)
{
	if (tracks == null)
	{
		tracks = Arrays.stream(musicList.getDynamicChildren())
			.sorted(Comparator.comparing(Widget::getRelativeY))
			.collect(Collectors.toList());
	}

	tracks.forEach(w -> w.setHidden(true));

	Collection<Widget> relevantTracks = tracks.stream()
		.filter(w -> w.getText().toLowerCase().contains(filter))
		.filter(w -> currentMusicFilter == MusicState.ALL || w.getTextColor() == currentMusicFilter.getColor())
		.collect(Collectors.toList());

	// Original music track list has a little offset
	int y = 3;

	for (Widget track : relevantTracks)
	{
		track.setHidden(false);
		track.setOriginalY(y);
		track.revalidate();

		y += track.getHeight();
	}

	y += 3;

	int newHeight = 0;

	if (musicList.getScrollHeight() > 0)
	{
		newHeight = (musicList.getScrollY() * y) / musicList.getScrollHeight();
	}

	musicList.setScrollHeight(y);
	musicList.revalidateScroll();

	client.runScript(
		ScriptID.UPDATE_SCROLLBAR,
		WidgetInfo.MUSIC_TRACK_SCROLLBAR.getId(),
		WidgetInfo.MUSIC_TRACK_LIST.getId(),
		newHeight
	);
}
 
Example 12
Source File: TabInterface.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void updateBounds()
{
	Widget itemContainer = client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER);
	if (itemContainer == null)
	{
		return;
	}

	int height = itemContainer.getHeight();

	// If player isn't using normal bank tabs
	if (itemContainer.getRelativeY() == 0)
	{
		height -= (TAB_HEIGHT + MARGIN);
	}

	bounds.setSize(TAB_WIDTH + MARGIN * 2, height);
	bounds.setLocation(MARGIN, TAB_HEIGHT + MARGIN);

	Widget incinerator = client.getWidget(WidgetInfo.BANK_INCINERATOR);

	if (incinerator != null && !incinerator.isHidden())
	{
		incinerator.setOriginalHeight(INCINERATOR_HEIGHT);
		incinerator.setOriginalWidth(INCINERATOR_WIDTH);
		incinerator.setOriginalY(INCINERATOR_HEIGHT);

		Widget child = incinerator.getDynamicChildren()[0];
		child.setOriginalHeight(INCINERATOR_HEIGHT);
		child.setOriginalWidth(INCINERATOR_WIDTH);
		child.setWidthMode(WidgetSizeMode.ABSOLUTE);
		child.setHeightMode(WidgetSizeMode.ABSOLUTE);
		child.setType(WidgetType.GRAPHIC);
		child.setSpriteId(TabSprites.INCINERATOR.getSpriteId());
		incinerator.revalidate();

		bounds.setSize(TAB_WIDTH + MARGIN * 2, height - incinerator.getHeight());
	}

	if (upButton != null)
	{
		Point p = upButton.getCanvasLocation();
		canvasBounds.setBounds(p.getX(), p.getY() + BUTTON_HEIGHT, bounds.width, maxTabs * TAB_HEIGHT + maxTabs * MARGIN);
	}
}
 
Example 13
Source File: ClueScrollPlugin.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
void highlightWidget(Graphics2D graphics, Widget toHighlight, Widget container, Rectangle padding, String text)
{
	padding = MoreObjects.firstNonNull(padding, new Rectangle());

	Point canvasLocation = toHighlight.getCanvasLocation();

	if (canvasLocation == null)
	{
		return;
	}

	Point windowLocation = container.getCanvasLocation();

	if (windowLocation.getY() > canvasLocation.getY() + toHighlight.getHeight()
		|| windowLocation.getY() + container.getHeight() < canvasLocation.getY())
	{
		return;
	}

	// Visible area of widget
	Area widgetArea = new Area(
		new Rectangle(
			canvasLocation.getX() - padding.x,
			Math.max(canvasLocation.getY(), windowLocation.getY()) - padding.y,
			toHighlight.getWidth() + padding.x + padding.width,
			Math.min(
				Math.min(windowLocation.getY() + container.getHeight() - canvasLocation.getY(), toHighlight.getHeight()),
				Math.min(canvasLocation.getY() + toHighlight.getHeight() - windowLocation.getY(), toHighlight.getHeight())) + padding.y + padding.height
		));

	OverlayUtil.renderHoverableArea(graphics, widgetArea, client.getMouseCanvasPosition(),
		HIGHLIGHT_FILL_COLOR, HIGHLIGHT_BORDER_COLOR, HIGHLIGHT_HOVER_BORDER_COLOR);

	if (text == null)
	{
		return;
	}

	FontMetrics fontMetrics = graphics.getFontMetrics();

	textComponent.setPosition(new java.awt.Point(
		canvasLocation.getX() + toHighlight.getWidth() / 2 - fontMetrics.stringWidth(text) / 2,
		canvasLocation.getY() + fontMetrics.getHeight()));
	textComponent.setText(text);
	textComponent.render(graphics);
}
 
Example 14
Source File: QuestListPlugin.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void updateFilter(String filter)
{
	filter = filter.toLowerCase();
	final Widget container = client.getWidget(WidgetInfo.QUESTLIST_CONTAINER);

	final Widget freeList = client.getWidget(QuestContainer.FREE_QUESTS.widgetInfo);
	final Widget memberList = client.getWidget(QuestContainer.MEMBER_QUESTS.widgetInfo);
	final Widget miniList = client.getWidget(QuestContainer.MINI_QUESTS.widgetInfo);

	if (container == null || freeList == null || memberList == null || miniList == null)
	{
		return;
	}

	updateList(QuestContainer.FREE_QUESTS, filter);
	updateList(QuestContainer.MEMBER_QUESTS, filter);
	updateList(QuestContainer.MINI_QUESTS, filter);

	memberList.setOriginalY(freeList.getOriginalY() + freeList.getOriginalHeight() + ENTRY_PADDING);
	miniList.setOriginalY(memberList.getOriginalY() + memberList.getOriginalHeight() + ENTRY_PADDING);

	// originalHeight is changed within updateList so revalidate all lists
	freeList.revalidate();
	memberList.revalidate();
	miniList.revalidate();

	int y = miniList.getRelativeY() + miniList.getHeight() + 10;

	int newHeight;
	if (container.getScrollHeight() > 0)
	{
		newHeight = (container.getScrollY() * y) / container.getScrollHeight();
	}
	else
	{
		newHeight = 0;
	}

	container.setScrollHeight(y);
	container.revalidateScroll();

	clientThread.invokeLater(() ->
		client.runScript(
			ScriptID.UPDATE_SCROLLBAR,
			WidgetInfo.QUESTLIST_SCROLLBAR.getId(),
			WidgetInfo.QUESTLIST_CONTAINER.getId(),
			newHeight
		));
}
 
Example 15
Source File: QuestListPlugin.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void updateList(QuestContainer questContainer, String filter)
{
	Widget list = client.getWidget(questContainer.widgetInfo);
	if (list == null)
	{
		return;
	}

	Collection<QuestWidget> quests = questSet.get(questContainer);

	if (quests != null)
	{
		// Check to make sure the list hasn't been rebuild since we were last her
		// Do this by making sure the list's dynamic children are the same as when we last saw them
		if (quests.stream().noneMatch(w ->
		{
			Widget codeWidget = w.getQuest();
			if (codeWidget == null)
			{
				return false;
			}
			return list.getChild(codeWidget.getIndex()) == codeWidget;
		}))
		{
			quests = null;
		}
	}

	if (quests == null)
	{
		// Find all of the widgets that we care about, sorting by their Y value
		quests = Arrays.stream(list.getDynamicChildren())
			.sorted(Comparator.comparing(Widget::getRelativeY))
			.filter(w -> !QUEST_HEADERS.contains(w.getText()))
			.map(w -> new QuestWidget(w, Text.removeTags(w.getText()).toLowerCase()))
			.collect(Collectors.toList());
		questSet.put(questContainer, quests);
	}

	// offset because of header
	int y = 20;
	for (QuestWidget questInfo : quests)
	{
		Widget quest = questInfo.getQuest();
		QuestState questState = QuestState.getByColor(quest.getTextColor());

		boolean hidden;
		if (!filter.isEmpty())
		{
			// If searching, show result regardless of filtered state
			hidden = !questInfo.getTitle().contains(filter);
		}
		else
		{
			// Otherwise hide if it doesn't match the filter state
			if (currentFilterState == QuestState.NOT_COMPLETED)
			{
				hidden = questState == QuestState.COMPLETE;
			}
			else
			{
				hidden = currentFilterState != QuestState.ALL && questState != currentFilterState;
			}
		}

		quest.setHidden(hidden);
		quest.setOriginalY(y);
		quest.revalidate();

		if (!hidden)
		{
			y += quest.getHeight();
		}
	}

	list.setOriginalHeight(y);
}
 
Example 16
Source File: Perspective.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Translates two-dimensional ground coordinates within the 3D world to
 * their corresponding coordinates on the Minimap.
 *
 * @param client the game client
 * @param point ground coordinate
 * @param distance max distance from local player to minimap point
 * @return a {@link Point} on screen corresponding to the position in
 * 3D-space
 */
@Nullable
public static Point localToMinimap(@Nonnull Client client, @Nonnull LocalPoint point, int distance)
{
	LocalPoint localLocation = client.getLocalPlayer().getLocalLocation();
	int x = point.getX() / 32 - localLocation.getX() / 32;
	int y = point.getY() / 32 - localLocation.getY() / 32;

	int dist = x * x + y * y;
	if (dist < distance)
	{
		Widget minimapDrawWidget;
		if (client.isResized())
		{
			if (client.getVar(Varbits.SIDE_PANELS) == 1)
			{
				minimapDrawWidget = client.getWidget(WidgetInfo.RESIZABLE_MINIMAP_DRAW_AREA);
			}
			else
			{
				minimapDrawWidget = client.getWidget(WidgetInfo.RESIZABLE_MINIMAP_STONES_DRAW_AREA);
			}
		}
		else
		{
			minimapDrawWidget = client.getWidget(WidgetInfo.FIXED_VIEWPORT_MINIMAP_DRAW_AREA);
		}

		if (minimapDrawWidget == null || minimapDrawWidget.isHidden())
		{
			return null;
		}

		final int angle = client.getMapAngle() & 0x7FF;

		final int sin = SINE[angle];
		final int cos = COSINE[angle];

		final int xx = y * sin + cos * x >> 16;
		final int yy = sin * x - y * cos >> 16;

		Point loc = minimapDrawWidget.getCanvasLocation();
		int miniMapX = loc.getX() + xx + minimapDrawWidget.getWidth() / 2;
		int miniMapY = minimapDrawWidget.getHeight() / 2 + loc.getY() + yy;
		return new Point(miniMapX, miniMapY);
	}

	return null;
}