Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Multiline chart titles
elliotkatz
I am trying to display a left-aligned two-line chart title:
e.g.
Chart Main Title
Chart Subititle.
I know that I can embed a newline in the string, but the second line needs to have a different font than the first line.
My code:
public static void configureTitleBlockTest(TitleBlock tb) throws Exception
{
FontDefinition origFont = tb.getLabel().getCaption().getFont();
tb.getLabel().getCaption().setValue("");
FontDefinition f1 = FontDefinitionImpl.copyInstance(origFont);
f1.setSize(14);
f1.setBold(true);
f1.getAlignment().setHorizontalAlignment(HorizontalAlignment.LEFT_LITERAL);
Insets in1 = InsetsImpl.create(10, 10, 10, 10);
TitleBlock t1 = ((TitleBlock) TitleBlockImpl.create());
// tb.setInsets(in1);
tb.getLabel().getCaption().setValue("First line");
tb.getLabel().getCaption().setFont(f1);
tb.setAnchor(Anchor.NORTH_LITERAL);
FontDefinition f2 = FontDefinitionImpl.copyInstance(origFont);
f2.setSize(8);
f2.setBold(false);
f2.setItalic(true);
f2.getAlignment().setHorizontalAlignment(HorizontalAlignment.LEFT_LITERAL);
Insets in2 = InsetsImpl.create(15, 10, 10, 10);
TitleBlock t2 = ((TitleBlock) TitleBlockImpl.create());
t2.setInsets(in2);
t2.getLabel().getCaption().setValue("Second line");
t2.getLabel().getCaption().setFont(f2);
t2.setAnchor(Anchor.NORTH_LITERAL);
tb.add(t2);
}
What happens is that the first line is left-aligned, but the second line is centered, even though I specified a left alignment.
What am I doing wrong?
Find more posts tagged with
Comments
There are no comments yet