import java.awt.*;
import java.awt.datatransfer.*;
import java.awt.event.*;
+import java.awt.geom.AffineTransform;
import java.awt.image.*;
import javax.swing.*;
int x = 0;
int graphExtras = 0;
int offset = 0;
-
+ Font baseFont = g.getFont();
+ FontMetrics baseMetrics = fm;
+ int ofontH = fontHeight;
+ boolean visible = true;
if (aa != null)
{
hasHiddenRows = false;
for (int i = 0; i < aa.length; i++)
{
+ visible = true;
g.setColor(Color.black);
if (!aa[i].visible)
groupSize++;
}
}
-
if (groupSize * (fontHeight + 8) < aa[i].height)
{
graphExtras = (aa[i].height - (groupSize * (fontHeight + 8))) / 2;
}
-
- for (int gg = 0; gg < aa.length; gg++)
+ else
{
- if (aa[gg].graphGroup == aa[i].graphGroup)
+ // scale font to fit
+ float h = aa[i].height / (float) groupSize, s;
+ if (h < 9)
{
- x = width - fm.stringWidth(aa[gg].label) - 3;
- g.drawString(aa[gg].label, x, y - graphExtras);
- if (aa[gg].annotations[0] != null)
+ visible = false;
+ }
+ else
+ {
+ fontHeight = -8 + (int) h;
+ s = ((float) fontHeight) / (float) ofontH;
+ Font f = baseFont.deriveFont(AffineTransform
+ .getScaleInstance(s, s));
+ g.setFont(f);
+ fm = g.getFontMetrics();
+ graphExtras = (aa[i].height - (groupSize * (fontHeight + 8))) / 2;
+ }
+ }
+ if (visible)
+ {
+ for (int gg = 0; gg < aa.length; gg++)
+ {
+ if (aa[gg].graphGroup == aa[i].graphGroup)
{
- g.setColor(aa[gg].annotations[0].colour);
+ x = width - fm.stringWidth(aa[gg].label) - 3;
+ g.drawString(aa[gg].label, x, y - graphExtras);
+
+ if (aa[gg]._linecolour != null)
+ {
+
+ g.setColor(aa[gg]._linecolour);
+ g.drawLine(x, y - graphExtras + 3,
+ x + fm.stringWidth(aa[gg].label), y - graphExtras
+ + 3);
+ }
+
+ g.setColor(Color.black);
+ graphExtras += fontHeight + 8;
}
-
- g.drawLine(x, y - graphExtras - 3,
- x + fm.stringWidth(aa[gg].label), y - graphExtras - 3);
-
- g.setColor(Color.black);
- graphExtras += fontHeight + 8;
}
}
+ g.setFont(baseFont);
+ fm = baseMetrics;
+ fontHeight = ofontH;
}
else
{