Add setter for background color of overlay components
This commit is contained in:
@@ -38,10 +38,22 @@ import net.runelite.client.ui.overlay.RenderableEntity;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class BackgroundComponent implements RenderableEntity
|
public class BackgroundComponent implements RenderableEntity
|
||||||
{
|
{
|
||||||
|
public static final Color DEFAULT_BACKGROUND_COLOR = new Color(70, 61, 50, 156);
|
||||||
|
|
||||||
private static final int BORDER_OFFSET = 2;
|
private static final int BORDER_OFFSET = 2;
|
||||||
private static final Color BACKGROUND_COLOR = new Color(70, 61, 50, 156);
|
|
||||||
private static final Color OUTSIDE_STROKE_COLOR = new Color(56, 48, 35, 255);
|
private static final int OUTSIDE_STROKE_RED_OFFSET = 14;
|
||||||
private static final Color INSIDE_STROKE_COLOR = new Color(90, 82, 69, 255);
|
private static final int OUTSIDE_STROKE_GREEN_OFFSET = 13;
|
||||||
|
private static final int OUTSIDE_STROKE_BLUE_OFFSET = 15;
|
||||||
|
private static final int OUTSIDE_STROKE_ALPHA = 255;
|
||||||
|
|
||||||
|
private static final int INSIDE_STROKE_RED_OFFSET = 20;
|
||||||
|
private static final int INSIDE_STROKE_GREEN_OFFSET = 21;
|
||||||
|
private static final int INSIDE_STROKE_BLUE_OFFSET = 19;
|
||||||
|
private static final int INSIDE_STROKE_ALPHA = 255;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
private Color backgroundColor = DEFAULT_BACKGROUND_COLOR;
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
private Rectangle rectangle = new Rectangle();
|
private Rectangle rectangle = new Rectangle();
|
||||||
@@ -49,20 +61,34 @@ public class BackgroundComponent implements RenderableEntity
|
|||||||
@Override
|
@Override
|
||||||
public Dimension render(Graphics2D graphics, Point parent)
|
public Dimension render(Graphics2D graphics, Point parent)
|
||||||
{
|
{
|
||||||
|
Color outsideStrokeColor = new Color(
|
||||||
|
Math.max(0, backgroundColor.getRed() - OUTSIDE_STROKE_RED_OFFSET),
|
||||||
|
Math.max(0, backgroundColor.getGreen() - OUTSIDE_STROKE_GREEN_OFFSET),
|
||||||
|
Math.max(0, backgroundColor.getBlue() - OUTSIDE_STROKE_BLUE_OFFSET),
|
||||||
|
OUTSIDE_STROKE_ALPHA
|
||||||
|
);
|
||||||
|
|
||||||
|
Color insideStrokeColor = new Color(
|
||||||
|
Math.min(255, backgroundColor.getRed() + INSIDE_STROKE_RED_OFFSET),
|
||||||
|
Math.min(255, backgroundColor.getGreen() + INSIDE_STROKE_GREEN_OFFSET),
|
||||||
|
Math.min(255, backgroundColor.getBlue() + INSIDE_STROKE_BLUE_OFFSET),
|
||||||
|
INSIDE_STROKE_ALPHA
|
||||||
|
);
|
||||||
|
|
||||||
// Render background
|
// Render background
|
||||||
graphics.setColor(BACKGROUND_COLOR);
|
graphics.setColor(backgroundColor);
|
||||||
graphics.fill(rectangle);
|
graphics.fill(rectangle);
|
||||||
|
|
||||||
// Render outside stroke
|
// Render outside stroke
|
||||||
final Rectangle outsideStroke = new Rectangle(rectangle);
|
final Rectangle outsideStroke = new Rectangle(rectangle);
|
||||||
outsideStroke.grow(-BORDER_OFFSET / 2,- BORDER_OFFSET / 2);
|
outsideStroke.grow(-BORDER_OFFSET / 2,- BORDER_OFFSET / 2);
|
||||||
graphics.setColor(OUTSIDE_STROKE_COLOR);
|
graphics.setColor(outsideStrokeColor);
|
||||||
graphics.draw(outsideStroke);
|
graphics.draw(outsideStroke);
|
||||||
|
|
||||||
// Render inside stroke
|
// Render inside stroke
|
||||||
final Rectangle insideStroke = new Rectangle(rectangle);
|
final Rectangle insideStroke = new Rectangle(rectangle);
|
||||||
insideStroke.grow(-BORDER_OFFSET, -BORDER_OFFSET);
|
insideStroke.grow(-BORDER_OFFSET, -BORDER_OFFSET);
|
||||||
graphics.setColor(INSIDE_STROKE_COLOR);
|
graphics.setColor(insideStrokeColor);
|
||||||
graphics.draw(insideStroke);
|
graphics.draw(insideStroke);
|
||||||
return new Dimension(rectangle.getSize());
|
return new Dimension(rectangle.getSize());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ public class ImagePanelComponent implements RenderableEntity
|
|||||||
@Setter
|
@Setter
|
||||||
private Color titleColor = Color.WHITE;
|
private Color titleColor = Color.WHITE;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
private Color backgroundColor = BackgroundComponent.DEFAULT_BACKGROUND_COLOR;
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
private BufferedImage image;
|
private BufferedImage image;
|
||||||
|
|
||||||
@@ -77,6 +80,7 @@ public class ImagePanelComponent implements RenderableEntity
|
|||||||
|
|
||||||
// Render background
|
// Render background
|
||||||
final BackgroundComponent backgroundComponent = new BackgroundComponent();
|
final BackgroundComponent backgroundComponent = new BackgroundComponent();
|
||||||
|
backgroundComponent.setBackgroundColor(backgroundColor);
|
||||||
backgroundComponent.setRectangle(new Rectangle(position.x, position.y, dimension.width, dimension.height));
|
backgroundComponent.setRectangle(new Rectangle(position.x, position.y, dimension.width, dimension.height));
|
||||||
backgroundComponent.render(graphics, parent);
|
backgroundComponent.render(graphics, parent);
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,9 @@ public class InfoBoxComponent implements RenderableEntity
|
|||||||
@Setter
|
@Setter
|
||||||
private Color color = Color.WHITE;
|
private Color color = Color.WHITE;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
private Color backgroundColor = BackgroundComponent.DEFAULT_BACKGROUND_COLOR;
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
private Point position = new Point();
|
private Point position = new Point();
|
||||||
|
|
||||||
@@ -60,6 +63,7 @@ public class InfoBoxComponent implements RenderableEntity
|
|||||||
final FontMetrics metrics = graphics.getFontMetrics();
|
final FontMetrics metrics = graphics.getFontMetrics();
|
||||||
final Rectangle bounds = new Rectangle(position.x, position.y, BOX_SIZE, BOX_SIZE);
|
final Rectangle bounds = new Rectangle(position.x, position.y, BOX_SIZE, BOX_SIZE);
|
||||||
final BackgroundComponent backgroundComponent = new BackgroundComponent();
|
final BackgroundComponent backgroundComponent = new BackgroundComponent();
|
||||||
|
backgroundComponent.setBackgroundColor(backgroundColor);
|
||||||
backgroundComponent.setRectangle(bounds);
|
backgroundComponent.setRectangle(bounds);
|
||||||
backgroundComponent.render(graphics, parent);
|
backgroundComponent.render(graphics, parent);
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,9 @@ public class PanelComponent implements RenderableEntity
|
|||||||
@Setter
|
@Setter
|
||||||
private Color titleColor = Color.WHITE;
|
private Color titleColor = Color.WHITE;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
private Color backgroundColor = BackgroundComponent.DEFAULT_BACKGROUND_COLOR;
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
private Point position = new Point();
|
private Point position = new Point();
|
||||||
|
|
||||||
@@ -98,6 +101,7 @@ public class PanelComponent implements RenderableEntity
|
|||||||
|
|
||||||
// Render background
|
// Render background
|
||||||
final BackgroundComponent backgroundComponent = new BackgroundComponent();
|
final BackgroundComponent backgroundComponent = new BackgroundComponent();
|
||||||
|
backgroundComponent.setBackgroundColor(backgroundColor);
|
||||||
backgroundComponent.setRectangle(new Rectangle(position.x, position.y, dimension.width, dimension.height));
|
backgroundComponent.setRectangle(new Rectangle(position.x, position.y, dimension.width, dimension.height));
|
||||||
backgroundComponent.render(graphics, parent);
|
backgroundComponent.render(graphics, parent);
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,9 @@ public class TooltipComponent implements RenderableEntity
|
|||||||
@Setter
|
@Setter
|
||||||
private String text;
|
private String text;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
private Color backgroundColor = BackgroundComponent.DEFAULT_BACKGROUND_COLOR;
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
private Point position = new Point();
|
private Point position = new Point();
|
||||||
|
|
||||||
@@ -92,6 +95,7 @@ public class TooltipComponent implements RenderableEntity
|
|||||||
final Rectangle tooltipBackground = new Rectangle(x, y,
|
final Rectangle tooltipBackground = new Rectangle(x, y,
|
||||||
tooltipWidth + OFFSET * 2, tooltipHeight + OFFSET * 2);
|
tooltipWidth + OFFSET * 2, tooltipHeight + OFFSET * 2);
|
||||||
final BackgroundComponent backgroundComponent = new BackgroundComponent();
|
final BackgroundComponent backgroundComponent = new BackgroundComponent();
|
||||||
|
backgroundComponent.setBackgroundColor(backgroundColor);
|
||||||
backgroundComponent.setRectangle(tooltipBackground);
|
backgroundComponent.setRectangle(tooltipBackground);
|
||||||
backgroundComponent.render(graphics, parent);
|
backgroundComponent.render(graphics, parent);
|
||||||
graphics.setColor(Color.WHITE);
|
graphics.setColor(Color.WHITE);
|
||||||
|
|||||||
Reference in New Issue
Block a user