From 9ebf1c306d7fa38d6fd05a928204257b5e5e13e3 Mon Sep 17 00:00:00 2001 From: Tuomo Untinen Date: Sun, 23 Jul 2017 00:19:54 +0300 Subject: [PATCH] #56 Adds text to image Instructions. --- .../starMap/newsCorp/ImageInstruction.java | 17 ++++++++++++++++- .../starMap/newsCorp/ImageInstructionTest.java | 8 ++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/openRealmOfStars/starMap/newsCorp/ImageInstruction.java b/src/main/java/org/openRealmOfStars/starMap/newsCorp/ImageInstruction.java index fcd889bd1..d9f408965 100644 --- a/src/main/java/org/openRealmOfStars/starMap/newsCorp/ImageInstruction.java +++ b/src/main/java/org/openRealmOfStars/starMap/newsCorp/ImageInstruction.java @@ -46,7 +46,7 @@ public class ImageInstruction { /** * Instructions for texts */ - public static final String TEXT = "text"; + private static final String TEXT = "text"; /** * Instructions for planet */ @@ -132,6 +132,21 @@ public ImageInstruction addBackground(final String backgroundName) { return this; } + /** + * Add text to image instructions. + * These are added as a centered rows. + * @param paramText Text to show in image + * @return ImageInstruction with text + */ + public ImageInstruction addText(final String paramText) { + checkDelim(); + sb.append(TEXT); + sb.append(PARAM_START); + sb.append(sanitizeParameters(paramText)); + sb.append(PARAM_END); + return this; + } + /** * Build actual instructions * @return instruction string diff --git a/src/test/java/org/openRealmOfStars/starMap/newsCorp/ImageInstructionTest.java b/src/test/java/org/openRealmOfStars/starMap/newsCorp/ImageInstructionTest.java index 47a344535..1a1d26d6d 100644 --- a/src/test/java/org/openRealmOfStars/starMap/newsCorp/ImageInstructionTest.java +++ b/src/test/java/org/openRealmOfStars/starMap/newsCorp/ImageInstructionTest.java @@ -38,6 +38,14 @@ public void testBackground() { assertEquals("background(grey gradient)+background(black)", instruction.build()); } + @Test + public void testBackgroundAndText() { + ImageInstruction instruction = new ImageInstruction(); + instruction.addBackground(ImageInstruction.BACKGROUND_STARS); + instruction.addText("Test called background and(+) Text"); + assertEquals("background(stars)+text(Test called background and Text)", instruction.build()); + } + @Test public void testSanitize() { ImageInstruction instruction = new ImageInstruction();