Skip to content

Commit

Permalink
#56 Adds text to image Instructions.
Browse files Browse the repository at this point in the history
  • Loading branch information
tuomount committed Jul 22, 2017
1 parent f7ecc81 commit 9ebf1c3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 9ebf1c3

Please sign in to comment.