public ColorRenderer()
{
setOpaque(true); // MUST do this for background to show up.
+ setHorizontalTextPosition(SwingConstants.CENTER);
+ setVerticalTextPosition(SwingConstants.CENTER);
}
public Component getTableCellRendererComponent(JTable table,
public static void renderGraduatedColor(JLabel comp, GraduatedColor gcol,
int w, int h)
{
-
+ boolean thr=false;
String tt = "";
String tx = "";
if (gcol.getThreshType() == AnnotationColourGradient.ABOVE_THRESHOLD)
{
- tx += "> ";
+ thr=true;
+ tx += ">";
tt += "Thresholded (Above " + gcol.getThresh() + ") ";
}
if (gcol.getThreshType() == AnnotationColourGradient.BELOW_THRESHOLD)
{
- tx += "< ";
+ thr=true;
+ tx += "<";
tt += "Thresholded (Below " + gcol.getThresh() + ") ";
}
if (gcol.isColourByLabel())
{
tt = "Coloured by label text. " + tt;
+ if (thr)
+ {
+ tx+=" ";
+ }
tx += "Label";
comp.setIcon(null);
}
Color newColor = gcol.getMaxColor();
comp.setBackground(newColor);
// System.err.println("Width is " + w / 2);
- Icon ficon = new FeatureIcon(gcol, comp.getBackground(), w / 2, h);
+ Icon ficon = new FeatureIcon(gcol, comp.getBackground(), w, h, thr);
comp.setIcon(ficon);
// tt+="RGB value: Max (" + newColor.getRed() + ", "
// + newColor.getGreen() + ", " + newColor.getBlue()
// + ")\nMin (" + minCol.getRed() + ", " + minCol.getGreen()
// + ", " + minCol.getBlue() + ")");
}
+ comp.setHorizontalAlignment(SwingConstants.CENTER);
comp.setText(tx);
if (tt.length() > 0)
{
GraduatedColor gcol;
Color backg;
-
+ boolean midspace=false;
int width = 50, height = 20;
+ int s1,e1; // start and end of midpoint band for thresholded symbol
+ Color mpcolour = Color.white;
- FeatureIcon(GraduatedColor gfc, Color bg, int w, int h)
+ FeatureIcon(GraduatedColor gfc, Color bg, int w, int h, boolean mspace)
{
gcol = gfc;
backg = bg;
width = w;
height = h;
+ midspace = mspace;
+ if (midspace)
+ {
+ s1=width/3;
+ e1=s1*2;
+ } else {
+ s1 = width/2;
+ e1 = s1;
+ }
}
public int getIconWidth()
{
Color minCol = gcol.getMinColor();
g.setColor(minCol);
- g.fillRect(0, 0, width, height);
+ g.fillRect(0, 0, s1, height);
+ if (midspace)
+ {
+ g.setColor(Color.white);
+ g.fillRect(s1,0,e1-s1, height);
+ }
+ g.setColor(gcol.getMaxColor());
+ g.fillRect(0,e1, width-e1, height);
}
}
}