@@ -0,0 +1,1114 @@
+package genediagram;%0A%0Aimport java.awt.Font;%0Aimport java.awt.FontMetrics;%0Aimport java.awt.Graphics;%0Aimport java.awt.Graphics2D;%0Aimport java.util.ArrayList;%0Aimport java.util.Collections;%0Aimport javax.swing.JPanel;%0A%0Apublic class StringWidth extends JPanel %7B%0A    %0A    public static int width;%0A    %0A    public void paintComponent(Graphics g) %7B%0A            Graphics2D g2 = (Graphics2D) g;%0A            super.paintComponent(g2);%0A            g2.setFont(new Font(%22Arial%22,0,50));%0A            determineStringWidth(g2);%0A    %7D%0A    %0A    //Method for determining width of longest text string in legend%0A    public void determineStringWidth (Graphics2D g2) %7B%0A            %0A        FontMetrics fm = g2.getFontMetrics();%0A        ArrayList%3CInteger%3E lengths = new ArrayList%3C%3E();%0A%0A            //Determing all string lengths%0A            for (int i=0; i%3CGeneDiagram.colours.size(); i++) %7B%0A                lengths.add(i,fm.stringWidth(GeneDiagram.categories.get(i)));%0A            %7D%0A            %0A            //Determining longest string length%0A            Collections.sort(lengths);%0A            width = lengths.get(lengths.size()-1);%0A    %7D%0A%7D%0A

Create StringWidth.java