Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Tools for Java
 QCChart2D for Java
 Multiple line legend
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

RunnerGirl

6 Posts

Posted - 02 Apr 2008 :  10:50:51  Show Profile  Reply with Quote
Is there a way to have each legend item have multiple lines? If I don't wrap the lines, the legend goes past the edge of the view. Here's what I have right now:

ChartText sPieStrings[] = new ChartText[data.length];
for (i = 0; i < data.length; i++) {
sPieStrings[i] = new ChartText(pTransform1, font28, data[i].getDowntimeCode() + ", \n" +
(int)(data[i].getDuration()*60) + " min, " +
(int)(data[i].getDuration()/totalDuration*100.0) + "%");
}

ChartAttribute legendAttributes = new ChartAttribute(Color.black, 1,
ChartConstants.LS_SOLID, Color.white);
legendAttributes.setLineFlag(true);
m_oLegend = new StandardLegend(0.52, 0.1, 0.38, 0.5, legendAttributes,
StandardLegend.VERT_DIR);

for (i = 0; i < data.length; i++) {
m_oLegend .addLegendItem(new LegendItem(sPieStrings[i], ChartConstants.SQUARE));
m_oLegend .setChartObjAttributes(attribs[i]);
m_oLegend .setVerticalSpacing(1.0);
m_oLegend .setChartObjScale(pTransform1);
}
m_oLegend .setLegendItemUniformTextColor(Color.black);


Any suggestions?

Thanks!

quinncurtis

1164 Posts

Posted - 02 Apr 2008 :  11:41:16  Show Profile  Reply with Quote
The StandardLegend does not really process multiple line items. Nor is there any type of line breaker that will break up a long text strings into multiple lines.

Assuming you can break up your legend item strings into multiple lines, you can trick the StandardLegend into displaying multiple line items, by inserting the extra lines using a symbol attribute that has the symbol size set to 0. Something like:

ChartAttribute nullsymbol = (ChartAttribute) attribArray[4].clone();
nullsymbol.setSymbolSize(0);
StandardLegend legend = new StandardLegend(0.82, 0.2, 0.99, 0.6, legendAttributes, StandardLegend.VERT_DIR);
legend.addLegendItem("Item #1 First Line",ChartConstants.HBAR, attribArray[4], legendFont);
legend.addLegendItem("Item #1 Second Line", ChartConstants.HBAR, nullsymbol, legendFont);
legend.addLegendItem("CSCO", ChartConstants.HBAR, attribArray[3], legendFont);
legend.addLegendItem("TXN", ChartConstants.HBAR, attribArray[2], legendFont);
legend.addLegendItem("ADI", ChartConstants.HBAR, attribArray[1], legendFont);
legend.addLegendItem("AMAT", ChartConstants.HBAR, attribArray[0], legendFont);
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Quinn-Curtis Forums © 2000-07 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07