+ 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("Invalid color 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)
+ {
+ int width=getWidth(),height=getHeight();
+ if (isGcol) {
+ if (isColourByLabel)
+ {
+ g.setColor(Color.white);
+ g.fillRect(width/2, 0,width/2, height);
+ g.setColor(Color.black);
+ Font f=new Font("Verdana", Font.PLAIN,
+ 10);
+ g.setFont(f);
+ g.drawString("Label", 0, 0);
+ }
+ else
+ {
+ g.setColor(maxCol);
+ g.fillRect(width/2, 0,width/2, height);
+
+ }
+ }
+ }
+
+ }