* true: The text of the figure has changed.<br>
* false: No text change
*/
public static boolean synchronizeText(TitleFigure figure)
{
DisplayObject client = figure.getClient();
if (client == null)
{
figure.setText("");
return false;
}
String format = figure.getTitleFormat();
if (format == null)
{
format = "$text";
}
StringBuffer sb = new StringBuffer();
int n = format.length();
for (int i = 0; i < n;)
{
char c = format.charAt(i);
if (format.startsWith("$name", i))
{
sb.append(client.getName());
i += 5;
}
else if (format.startsWith("$text", i))
{
String t = null;
if (DisplayObjectPlugin.getInstance().isTitleModeText())
{
if (figure.isVerboseDisplay())
{
// Display text or name, whichever is defined
t = client.getDisplayText();
}
else
{
// Display text only when explicitely defined
t = client.getDisplayName();
}
}
else
{
// Display object name only in verbose mode
if (figure.isVerboseDisplay())
{
t = client.getName();
}
}
if (t != null)
{
sb.append(t);