+ FeatureColourPanel colourPanel;
+
+ class FeatureColourPanel extends Panel
+ {
+ String label = "";
+
+ private Color maxCol;
+
+ private boolean isColourByLabel, isGcol;
+
+ /**
+ * render a feature style in the amend feature dialog box
+ */
+ public void updateColor(Object newcol)
+ {
+
+ Color bg, col = null;
+ GraduatedColor gcol = null;
+ String vlabel = "";
+ if (newcol instanceof Color)
+ {
+ isGcol = false;
+ col = (Color) newcol;
+ gcol = null;
+ }
+ else if (newcol instanceof GraduatedColor)
+ {
+ isGcol = true;
+ gcol = (GraduatedColor) newcol;
+ col = null;
+ }
+ else
+ {
+ throw new Error(MessageManager.getString("error.invalid_colour_for_mycheckbox"));
+ }
+ if (col != null)
+ {
+ setBackground(bg = col);
+ }
+ else
+ {
+ if (gcol.getThreshType() != AnnotationColourGradient.NO_THRESHOLD)
+ {
+ vlabel += " "
+ + ((gcol.getThreshType() == AnnotationColourGradient.ABOVE_THRESHOLD) ? "(>)"
+ : "(<)");
+ }
+ if (isColourByLabel = gcol.isColourByLabel())
+ {
+ setBackground(bg = Color.white);
+ vlabel += " (by Label)";
+ }
+ else
+ {
+ setBackground(bg = gcol.getMinColor());
+ maxCol = gcol.getMaxColor();
+ }
+ }
+ label = vlabel;
+ setBackground(bg);
+ repaint();
+ }
+
+ FeatureColourPanel()
+ {
+ super(null);
+ }
+
+ public void paint(Graphics g)
+ {
+ Dimension d = getSize();
+ if (isGcol)
+ {
+ if (isColourByLabel)
+ {
+ g.setColor(Color.white);
+ g.fillRect(d.width / 2, 0, d.width / 2, d.height);
+ g.setColor(Color.black);
+ Font f = new Font("Verdana", Font.PLAIN, 10);
+ g.setFont(f);
+ g.drawString(MessageManager.getString("label.label"), 0, 0);
+ }
+ else
+ {
+ g.setColor(maxCol);
+ g.fillRect(d.width / 2, 0, d.width / 2, d.height);
+
+ }
+ }
+ }
+
+ }