From 13e0baffe070d1598bbd4c96f7ac159c060d21f2 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Tue, 12 Mar 2019 11:47:11 +0000 Subject: [PATCH 1/5] Added support for transparent text and border color customization to TextComponent, added font and alpha customization to the ground items plugin --- .../grounditems/GroundItemsConfig.java | 30 +++++++++-- .../grounditems/GroundItemsOverlay.java | 12 ++++- .../ui/overlay/components/TextComponent.java | 50 +++++++++++++------ 3 files changed, 70 insertions(+), 22 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java index da3db4a3f1..ce698609d3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java @@ -26,9 +26,11 @@ package net.runelite.client.plugins.grounditems; import java.awt.Color; +import net.runelite.client.config.Alpha; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; +import net.runelite.client.config.FontType; import net.runelite.client.plugins.grounditems.config.ItemHighlightMode; import net.runelite.client.plugins.grounditems.config.MenuHighlightMode; import net.runelite.client.plugins.grounditems.config.PriceDisplayMode; @@ -115,16 +117,16 @@ public interface GroundItemsConfig extends Config { return false; } - + @ConfigItem( keyName = "highlightTiles", name = "Highlight Tiles", description = "Configures whether or not to highlight tiles containing ground items", position = 6 ) - default boolean highlightTiles() - { - return false; + default boolean highlightTiles() + { + return false; } @ConfigItem( @@ -199,6 +201,7 @@ public interface GroundItemsConfig extends Config description = "Configures the color for default, non-highlighted items", position = 13 ) + @Alpha default Color defaultColor() { return Color.WHITE; @@ -210,6 +213,7 @@ public interface GroundItemsConfig extends Config description = "Configures the color for highlighted items", position = 14 ) + @Alpha default Color highlightedColor() { return Color.decode("#AA00FF"); @@ -221,6 +225,7 @@ public interface GroundItemsConfig extends Config description = "Configures the color for hidden items in right-click menu and when holding ALT", position = 15 ) + @Alpha default Color hiddenColor() { return Color.GRAY; @@ -232,6 +237,7 @@ public interface GroundItemsConfig extends Config description = "Configures the color for low value items", position = 16 ) + @Alpha default Color lowValueColor() { return Color.decode("#66B2FF"); @@ -254,6 +260,7 @@ public interface GroundItemsConfig extends Config description = "Configures the color for medium value items", position = 18 ) + @Alpha default Color mediumValueColor() { return Color.decode("#99FF99"); @@ -276,6 +283,7 @@ public interface GroundItemsConfig extends Config description = "Configures the color for high value items", position = 20 ) + @Alpha default Color highValueColor() { return Color.decode("#FF9600"); @@ -298,6 +306,7 @@ public interface GroundItemsConfig extends Config description = "Configures the color for insane value items", position = 22 ) + @Alpha default Color insaneValueColor() { return Color.decode("#FF66B2"); @@ -346,4 +355,15 @@ public interface GroundItemsConfig extends Config { return false; } -} + + @ConfigItem( + keyName = "fontType", + name = "Font type", + description = "Configures the font type to use when drawing items", + position = 27 + ) + default FontType fontStyle() + { + return FontType.REGULAR; + } +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java index 1406bb1747..ac1d0e2c1f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java @@ -27,6 +27,7 @@ package net.runelite.client.plugins.grounditems; import java.awt.Color; import java.awt.Dimension; +import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.Polygon; @@ -94,8 +95,6 @@ public class GroundItemsOverlay extends Overlay { return null; } - - final FontMetrics fm = graphics.getFontMetrics(); final Player player = client.getLocalPlayer(); if (player == null || client.getViewportWidget() == null) @@ -103,6 +102,13 @@ public class GroundItemsOverlay extends Overlay return null; } + final Font originalFont = graphics.getFont(); + final Font font = config.fontStyle().getFont(); + + graphics.setFont(font); + + final FontMetrics fm = graphics.getFontMetrics(); + offsetMap.clear(); final LocalPoint localLocation = player.getLocalLocation(); final Point mousePos = client.getMouseCanvasPosition(); @@ -339,6 +345,8 @@ public class GroundItemsOverlay extends Overlay textComponent.render(graphics); } + graphics.setFont(originalFont); + return null; } diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/TextComponent.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/TextComponent.java index 98532a8d7c..fba19f5013 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/TextComponent.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/TextComponent.java @@ -24,11 +24,15 @@ */ package net.runelite.client.ui.overlay.components; +import java.awt.AlphaComposite; import java.awt.Color; +import java.awt.Composite; import java.awt.Dimension; import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.Point; +import java.awt.Shape; +import java.awt.font.GlyphVector; import java.util.regex.Pattern; import lombok.Setter; import net.runelite.client.ui.overlay.RenderableEntity; @@ -43,6 +47,7 @@ public class TextComponent implements RenderableEntity private String text; private Point position = new Point(); private Color color = Color.WHITE; + private Color borderColor = Color.BLACK; public static String textWithoutColTags(String text) { @@ -64,28 +69,43 @@ public class TextComponent implements RenderableEntity final String textWithoutCol = textWithoutColTags(textSplitOnCol); final String colColor = textSplitOnCol.substring(textSplitOnCol.indexOf("=") + 1, textSplitOnCol.indexOf(">")); - // shadow - graphics.setColor(Color.BLACK); - graphics.drawString(textWithoutCol, x + 1, position.y + 1); - - // actual text - graphics.setColor(Color.decode("#" + colColor)); - graphics.drawString(textWithoutCol, x, position.y); + renderText(graphics, x, position.y, textWithoutCol, Color.decode("#" + colColor), borderColor); x += fontMetrics.stringWidth(textWithoutCol); } } else { - // shadow - graphics.setColor(Color.BLACK); - graphics.drawString(text, position.x + 1, position.y + 1); - - // actual text - graphics.setColor(color); - graphics.drawString(text, position.x, position.y); + renderText(graphics, position.x, position.y, text, color, borderColor); } - return new Dimension(fontMetrics.stringWidth(text), fontMetrics.getHeight()); } + + private void renderText(Graphics2D graphics, int x, int y, String text, Color color, Color border) + { + // remember previous composite + Composite originalComposite = graphics.getComposite(); + + // create a vector of the text + GlyphVector vector = graphics.getFont().createGlyphVector(graphics.getFontRenderContext(), text); + + // compute the text shape + Shape stroke = vector.getOutline(x + 1, y + 1); + Shape shape = vector.getOutline(x, y); + + // draw text border + graphics.setColor(border); + graphics.fill(stroke); + + // replace the pixels instead of overlaying + graphics.setComposite(AlphaComposite.Src); + + // draw actual text + graphics.setColor(color); + graphics.fill(shape); + + // reset composite to original + graphics.setComposite(originalComposite); + } + } From ff8a85448077a258139e08efb654b5a7d335748f Mon Sep 17 00:00:00 2001 From: BuildTools Date: Tue, 12 Mar 2019 11:47:11 +0000 Subject: [PATCH 2/5] Added support for transparent text and border color customization to TextComponent, added font and alpha customization to the ground items plugin --- .../grounditems/GroundItemsConfig.java | 30 +++++++++-- .../grounditems/GroundItemsOverlay.java | 12 ++++- .../ui/overlay/components/TextComponent.java | 50 +++++++++++++------ 3 files changed, 70 insertions(+), 22 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java index da3db4a3f1..ce698609d3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java @@ -26,9 +26,11 @@ package net.runelite.client.plugins.grounditems; import java.awt.Color; +import net.runelite.client.config.Alpha; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; +import net.runelite.client.config.FontType; import net.runelite.client.plugins.grounditems.config.ItemHighlightMode; import net.runelite.client.plugins.grounditems.config.MenuHighlightMode; import net.runelite.client.plugins.grounditems.config.PriceDisplayMode; @@ -115,16 +117,16 @@ public interface GroundItemsConfig extends Config { return false; } - + @ConfigItem( keyName = "highlightTiles", name = "Highlight Tiles", description = "Configures whether or not to highlight tiles containing ground items", position = 6 ) - default boolean highlightTiles() - { - return false; + default boolean highlightTiles() + { + return false; } @ConfigItem( @@ -199,6 +201,7 @@ public interface GroundItemsConfig extends Config description = "Configures the color for default, non-highlighted items", position = 13 ) + @Alpha default Color defaultColor() { return Color.WHITE; @@ -210,6 +213,7 @@ public interface GroundItemsConfig extends Config description = "Configures the color for highlighted items", position = 14 ) + @Alpha default Color highlightedColor() { return Color.decode("#AA00FF"); @@ -221,6 +225,7 @@ public interface GroundItemsConfig extends Config description = "Configures the color for hidden items in right-click menu and when holding ALT", position = 15 ) + @Alpha default Color hiddenColor() { return Color.GRAY; @@ -232,6 +237,7 @@ public interface GroundItemsConfig extends Config description = "Configures the color for low value items", position = 16 ) + @Alpha default Color lowValueColor() { return Color.decode("#66B2FF"); @@ -254,6 +260,7 @@ public interface GroundItemsConfig extends Config description = "Configures the color for medium value items", position = 18 ) + @Alpha default Color mediumValueColor() { return Color.decode("#99FF99"); @@ -276,6 +283,7 @@ public interface GroundItemsConfig extends Config description = "Configures the color for high value items", position = 20 ) + @Alpha default Color highValueColor() { return Color.decode("#FF9600"); @@ -298,6 +306,7 @@ public interface GroundItemsConfig extends Config description = "Configures the color for insane value items", position = 22 ) + @Alpha default Color insaneValueColor() { return Color.decode("#FF66B2"); @@ -346,4 +355,15 @@ public interface GroundItemsConfig extends Config { return false; } -} + + @ConfigItem( + keyName = "fontType", + name = "Font type", + description = "Configures the font type to use when drawing items", + position = 27 + ) + default FontType fontStyle() + { + return FontType.REGULAR; + } +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java index 1406bb1747..ac1d0e2c1f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java @@ -27,6 +27,7 @@ package net.runelite.client.plugins.grounditems; import java.awt.Color; import java.awt.Dimension; +import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.Polygon; @@ -94,8 +95,6 @@ public class GroundItemsOverlay extends Overlay { return null; } - - final FontMetrics fm = graphics.getFontMetrics(); final Player player = client.getLocalPlayer(); if (player == null || client.getViewportWidget() == null) @@ -103,6 +102,13 @@ public class GroundItemsOverlay extends Overlay return null; } + final Font originalFont = graphics.getFont(); + final Font font = config.fontStyle().getFont(); + + graphics.setFont(font); + + final FontMetrics fm = graphics.getFontMetrics(); + offsetMap.clear(); final LocalPoint localLocation = player.getLocalLocation(); final Point mousePos = client.getMouseCanvasPosition(); @@ -339,6 +345,8 @@ public class GroundItemsOverlay extends Overlay textComponent.render(graphics); } + graphics.setFont(originalFont); + return null; } diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/TextComponent.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/TextComponent.java index 98532a8d7c..fba19f5013 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/TextComponent.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/TextComponent.java @@ -24,11 +24,15 @@ */ package net.runelite.client.ui.overlay.components; +import java.awt.AlphaComposite; import java.awt.Color; +import java.awt.Composite; import java.awt.Dimension; import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.Point; +import java.awt.Shape; +import java.awt.font.GlyphVector; import java.util.regex.Pattern; import lombok.Setter; import net.runelite.client.ui.overlay.RenderableEntity; @@ -43,6 +47,7 @@ public class TextComponent implements RenderableEntity private String text; private Point position = new Point(); private Color color = Color.WHITE; + private Color borderColor = Color.BLACK; public static String textWithoutColTags(String text) { @@ -64,28 +69,43 @@ public class TextComponent implements RenderableEntity final String textWithoutCol = textWithoutColTags(textSplitOnCol); final String colColor = textSplitOnCol.substring(textSplitOnCol.indexOf("=") + 1, textSplitOnCol.indexOf(">")); - // shadow - graphics.setColor(Color.BLACK); - graphics.drawString(textWithoutCol, x + 1, position.y + 1); - - // actual text - graphics.setColor(Color.decode("#" + colColor)); - graphics.drawString(textWithoutCol, x, position.y); + renderText(graphics, x, position.y, textWithoutCol, Color.decode("#" + colColor), borderColor); x += fontMetrics.stringWidth(textWithoutCol); } } else { - // shadow - graphics.setColor(Color.BLACK); - graphics.drawString(text, position.x + 1, position.y + 1); - - // actual text - graphics.setColor(color); - graphics.drawString(text, position.x, position.y); + renderText(graphics, position.x, position.y, text, color, borderColor); } - return new Dimension(fontMetrics.stringWidth(text), fontMetrics.getHeight()); } + + private void renderText(Graphics2D graphics, int x, int y, String text, Color color, Color border) + { + // remember previous composite + Composite originalComposite = graphics.getComposite(); + + // create a vector of the text + GlyphVector vector = graphics.getFont().createGlyphVector(graphics.getFontRenderContext(), text); + + // compute the text shape + Shape stroke = vector.getOutline(x + 1, y + 1); + Shape shape = vector.getOutline(x, y); + + // draw text border + graphics.setColor(border); + graphics.fill(stroke); + + // replace the pixels instead of overlaying + graphics.setComposite(AlphaComposite.Src); + + // draw actual text + graphics.setColor(color); + graphics.fill(shape); + + // reset composite to original + graphics.setComposite(originalComposite); + } + } From 1f45546dc9f1f4b5067c0720be132af313035045 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Tue, 12 Mar 2019 15:23:05 +0000 Subject: [PATCH 3/5] Replaced the TextComponentTest test --- .../overlay/components/TextComponentTest.java | 155 ++++++++---------- 1 file changed, 68 insertions(+), 87 deletions(-) diff --git a/runelite-client/src/test/java/net/runelite/client/ui/overlay/components/TextComponentTest.java b/runelite-client/src/test/java/net/runelite/client/ui/overlay/components/TextComponentTest.java index 067205bd3b..ca36f014b5 100644 --- a/runelite-client/src/test/java/net/runelite/client/ui/overlay/components/TextComponentTest.java +++ b/runelite-client/src/test/java/net/runelite/client/ui/overlay/components/TextComponentTest.java @@ -1,87 +1,68 @@ -/* - * Copyright (c) 2018, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.ui.overlay.components; - -import java.awt.Color; -import java.awt.FontMetrics; -import java.awt.Graphics2D; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Matchers.eq; -import org.mockito.Mock; -import static org.mockito.Mockito.atLeastOnce; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import org.mockito.runners.MockitoJUnitRunner; - -@RunWith(MockitoJUnitRunner.class) -public class TextComponentTest -{ - @Mock - private Graphics2D graphics; - - @Before - public void before() - { - when(graphics.getFontMetrics()).thenReturn(mock(FontMetrics.class)); - } - - @Test - public void testRender() - { - TextComponent textComponent = new TextComponent(); - textComponent.setText("test"); - textComponent.setColor(Color.RED); - textComponent.render(graphics); - verify(graphics, times(2)).drawString(eq("test"), anyInt(), anyInt()); - verify(graphics, atLeastOnce()).setColor(Color.RED); - } - - @Test - public void testRender2() - { - TextComponent textComponent = new TextComponent(); - textComponent.setText("test"); - textComponent.render(graphics); - verify(graphics, times(2)).drawString(eq("test"), anyInt(), anyInt()); - verify(graphics, atLeastOnce()).setColor(Color.BLUE); - } - - @Test - public void testRender3() - { - TextComponent textComponent = new TextComponent(); - textComponent.setText("test test"); - textComponent.render(graphics); - verify(graphics, atLeastOnce()).drawString(eq("test"), anyInt(), anyInt()); - verify(graphics, atLeastOnce()).drawString(eq(" test"), anyInt(), anyInt()); - verify(graphics, atLeastOnce()).setColor(Color.BLUE); - verify(graphics, atLeastOnce()).setColor(Color.GREEN); - } -} +/* + * Copyright (c) 2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.ui.overlay.components; + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import org.junit.Before; +import org.junit.Test; + +public class TextComponentTest +{ + private Graphics2D graphics; + + @Before + public void before() + { + BufferedImage dest = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); + graphics = (Graphics2D) dest.getGraphics(); + } + + @Test + public void testRender() + { + TextComponent textComponent = new TextComponent(); + textComponent.setText("test"); + textComponent.setColor(Color.RED); + textComponent.render(graphics); + } + + @Test + public void testRender2() + { + TextComponent textComponent = new TextComponent(); + textComponent.setText("test"); + textComponent.render(graphics); + } + + @Test + public void testRender3() + { + TextComponent textComponent = new TextComponent(); + textComponent.setText("test test"); + textComponent.render(graphics); + } +} From dd2c351218ca8aff7f6b44c42f72fc5aeac8f3e3 Mon Sep 17 00:00:00 2001 From: CalebWhiting Date: Thu, 14 Mar 2019 13:13:30 +0000 Subject: [PATCH 4/5] Removed grounditems.fontStyle option --- .../client/plugins/grounditems/GroundItemsConfig.java | 11 ----------- .../plugins/grounditems/GroundItemsOverlay.java | 9 --------- .../ui/overlay/components/TextComponentTest.java | 11 ++++++++++- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java index ce698609d3..1e658f84cd 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java @@ -30,7 +30,6 @@ import net.runelite.client.config.Alpha; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; -import net.runelite.client.config.FontType; import net.runelite.client.plugins.grounditems.config.ItemHighlightMode; import net.runelite.client.plugins.grounditems.config.MenuHighlightMode; import net.runelite.client.plugins.grounditems.config.PriceDisplayMode; @@ -356,14 +355,4 @@ public interface GroundItemsConfig extends Config return false; } - @ConfigItem( - keyName = "fontType", - name = "Font type", - description = "Configures the font type to use when drawing items", - position = 27 - ) - default FontType fontStyle() - { - return FontType.REGULAR; - } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java index ac1d0e2c1f..31a6077d1a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java @@ -27,7 +27,6 @@ package net.runelite.client.plugins.grounditems; import java.awt.Color; import java.awt.Dimension; -import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.Polygon; @@ -102,11 +101,6 @@ public class GroundItemsOverlay extends Overlay return null; } - final Font originalFont = graphics.getFont(); - final Font font = config.fontStyle().getFont(); - - graphics.setFont(font); - final FontMetrics fm = graphics.getFontMetrics(); offsetMap.clear(); @@ -344,9 +338,6 @@ public class GroundItemsOverlay extends Overlay textComponent.setPosition(new java.awt.Point(textX, textY)); textComponent.render(graphics); } - - graphics.setFont(originalFont); - return null; } diff --git a/runelite-client/src/test/java/net/runelite/client/ui/overlay/components/TextComponentTest.java b/runelite-client/src/test/java/net/runelite/client/ui/overlay/components/TextComponentTest.java index ca36f014b5..6bd5ebfaa4 100644 --- a/runelite-client/src/test/java/net/runelite/client/ui/overlay/components/TextComponentTest.java +++ b/runelite-client/src/test/java/net/runelite/client/ui/overlay/components/TextComponentTest.java @@ -27,17 +27,19 @@ package net.runelite.client.ui.overlay.components; import java.awt.Color; import java.awt.Graphics2D; import java.awt.image.BufferedImage; +import org.junit.After; import org.junit.Before; import org.junit.Test; public class TextComponentTest { private Graphics2D graphics; + private BufferedImage dest; @Before public void before() { - BufferedImage dest = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); + dest = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); graphics = (Graphics2D) dest.getGraphics(); } @@ -65,4 +67,11 @@ public class TextComponentTest textComponent.setText("test test"); textComponent.render(graphics); } + + @After + public void after() { + graphics.dispose(); + dest.flush(); + } + } From 51fb57e0b03b80802b078f683ef2e95cba379fb8 Mon Sep 17 00:00:00 2001 From: CalebWhiting Date: Thu, 14 Mar 2019 13:23:24 +0000 Subject: [PATCH 5/5] Formatting fix --- .../client/ui/overlay/components/TextComponentTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runelite-client/src/test/java/net/runelite/client/ui/overlay/components/TextComponentTest.java b/runelite-client/src/test/java/net/runelite/client/ui/overlay/components/TextComponentTest.java index 6bd5ebfaa4..f1677daa4b 100644 --- a/runelite-client/src/test/java/net/runelite/client/ui/overlay/components/TextComponentTest.java +++ b/runelite-client/src/test/java/net/runelite/client/ui/overlay/components/TextComponentTest.java @@ -69,7 +69,8 @@ public class TextComponentTest } @After - public void after() { + public void after() + { graphics.dispose(); dest.flush(); }