Skip to content

Commit

Permalink
[#528] Modularize markup check into a method.
Browse files Browse the repository at this point in the history
  • Loading branch information
jkcoding7 authored and prmr committed Jun 11, 2024
1 parent 8ccffc2 commit ca53d73
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/org/jetuml/rendering/nodes/TypeNodeRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private void drawName(TypeNode pNode, Rectangle pBounds, int pSplitY, int pNameB
{
boolean italic = false;
String paddedName = "";
if( nameByLine[i].length() > 2 && nameByLine[i].startsWith(ITALIC_MARKUP) && nameByLine[i].endsWith(ITALIC_MARKUP) )
if( containsMarkup(nameByLine[i], ITALIC_MARKUP) )
{
nameByLine[i] = removeMarkup(nameByLine[i]);
italic = true;
Expand Down Expand Up @@ -154,7 +154,7 @@ private static void drawAttribute(TypeNode pNode, Rectangle pBounds, int pSplitY

for( String attribute : attributesByLine )
{
if( attribute.length() > 2 && attribute.startsWith(UNDERLINE_MARKUP) && attribute.endsWith(UNDERLINE_MARKUP) )
if( containsMarkup(attribute, UNDERLINE_MARKUP) )
{
UNDERLINING_STRING_VIEWER.draw(removeMarkup(attribute), pGraphics,
new Rectangle(pBounds.x(), pSplitY + lineSpacing, pBounds.width(), pAttributeBoxHeight));
Expand All @@ -176,12 +176,12 @@ private static void drawMethod(TypeNode pNode, Rectangle pBounds, int pSplitY, i

for( String method : methodsByLine )
{
if( method.length() > 2 && method.startsWith(UNDERLINE_MARKUP) && method.endsWith(UNDERLINE_MARKUP) )
if( containsMarkup(method, UNDERLINE_MARKUP) )
{
UNDERLINING_STRING_VIEWER.draw(removeMarkup(method), pGraphics,
new Rectangle(pBounds.x(), pSplitY + lineSpacing, pBounds.width(), pMethodBoxHeight));
}
else if( method.length() > 2 && method.startsWith(ITALIC_MARKUP) && method.endsWith(ITALIC_MARKUP) )
else if( containsMarkup(method, ITALIC_MARKUP) )
{
ITALIC_STRING_VIEWER.draw(removeMarkup(method), pGraphics,
new Rectangle(pBounds.x(), pSplitY + lineSpacing, pBounds.width(), pMethodBoxHeight));
Expand All @@ -195,6 +195,11 @@ else if( method.length() > 2 && method.startsWith(ITALIC_MARKUP) && method.endsW
}
}

private static boolean containsMarkup(String pText, String pMarkup)
{
return pText.length() > 2 && pText.startsWith(pMarkup) && pText.endsWith(pMarkup);
}

private static String removeMarkup(String pString)
{
StringBuilder result = new StringBuilder(pString);
Expand Down

0 comments on commit ca53d73

Please sign in to comment.