int x, int y)
{
final String type = check.type;
+ final Object typeCol = fr.getFeatureStyle(type);
java.awt.PopupMenu men = new PopupMenu("Settings for " + type);
java.awt.MenuItem scr = new MenuItem("Sort by Score");
men.add(scr);
{
// graduated colourschemes for those where minmax exists for the
// positional features
- MenuItem mxcol = new MenuItem("Graduated Colour");
+ MenuItem mxcol = new MenuItem(
+ (typeCol instanceof Color) ? "Graduated Colour"
+ : "Single Colour");
men.add(mxcol);
mxcol.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
- new FeatureColourChooser(me, type);
- // write back the current colour object to update the table
- check.updateColor(fr.getFeatureStyle(type));
+ if (typeCol instanceof Color)
+ {
+ new FeatureColourChooser(me, type);
+ // write back the current colour object to update the table
+ check.updateColor(fr.getFeatureStyle(type));
+ }
+ else
+ {
+ new UserDefinedColours(me, check.type,
+ ((GraduatedColor) typeCol));
+ }
}
});
}
}
- public void setUserColour(String feature, Color col)
+ public void setUserColour(String feature, Object originalColour)
{
- fr.setColour(feature, col);
+ if (originalColour instanceof Color
+ || originalColour instanceof GraduatedColor)
+ {
+ fr.setColour(feature, originalColour);
+ }
+ else
+ {
+ throw new Error(
+ "Implementation error: Unsupported feature colour object.");
+ }
refreshTable();
}
- public void refreshTable() {
+
+ public void refreshTable()
+ {
featurePanel.removeAll();
resetTable(false);
ap.paintAlignment(true);
{
this.popupSort(check, fr.minmax, evt.getX(), evt.getY());
}
- if (fr.featureLinks != null
- && fr.featureLinks.containsKey(check.type))
+ if (fr.featureLinks != null && fr.featureLinks.containsKey(check.type))
{
if (evt.getX() > check.stringWidth + 20)
{
if (fcol instanceof Color)
{
new UserDefinedColours(this, check.type, (Color) fcol);
- } else {
+ }
+ else
+ {
new FeatureColourChooser(this, check.type);
// write back the current colour object to update the table
check.updateColor(fr.getFeatureStyle(check.type));
class MyCheckbox extends Checkbox
{
public String type;
+
public int stringWidth;
boolean hasLink;
else
{
String vlabel = type;
- if (gcol.getThreshType()!=AnnotationColourGradient.NO_THRESHOLD)
+ if (gcol.getThreshType() != AnnotationColourGradient.NO_THRESHOLD)
{
- vlabel += " "+((gcol.getThreshType()==AnnotationColourGradient.ABOVE_THRESHOLD) ? "(>)" : "(<)");
+ vlabel += " "
+ + ((gcol.getThreshType() == AnnotationColourGradient.ABOVE_THRESHOLD) ? "(>)"
+ : "(<)");
}
- if (gcol.isColourByLabel()) {
+ if (gcol.isColourByLabel())
+ {
setBackground(Color.white);
vlabel += " (by Label)";
- } else {
+ }
+ else
+ {
setBackground(gcol.getMinColor());
}
this.setLabel(vlabel);
public MyCheckbox(String type, boolean selected, boolean b,
Object featureStyle)
{
- this(type,selected,b);
+ this(type, selected, b);
updateColor(featureStyle);
}
if (gcol.isColourByLabel())
{
g.setColor(Color.white);
- g.fillRect(d.width/2, 0,d.width/2, d.height);
- /*g.setColor(Color.black);
- Font f=g.getFont().deriveFont(9);
- g.setFont(f);
-
- // g.setFont(g.getFont().deriveFont(
- // AffineTransform.getScaleInstance(
- // width/g.getFontMetrics().stringWidth("Label"),
- // height/g.getFontMetrics().getHeight())));
- g.drawString("Label", width/2, 0); */
+ g.fillRect(d.width / 2, 0, d.width / 2, d.height);
+ /*
+ * g.setColor(Color.black); Font f=g.getFont().deriveFont(9);
+ * g.setFont(f);
+ *
+ * // g.setFont(g.getFont().deriveFont( //
+ * AffineTransform.getScaleInstance( //
+ * width/g.getFontMetrics().stringWidth("Label"), //
+ * height/g.getFontMetrics().getHeight()))); g.drawString("Label",
+ * width/2, 0);
+ */
}
else
{
Color maxCol = gcol.getMaxColor();
g.setColor(maxCol);
- g.fillRect(d.width/2, 0,d.width/2, d.height);
-
+ g.fillRect(d.width / 2, 0, d.width / 2, d.height);
+
}
}
String originalLabel;
- Color originalColour;
+ Object originalColour;
int R = 0, G = 0, B = 0;
setTargetColour(fr.colourPanel.getBackground());
dialog.setVisible(true);
}
+
public UserDefinedColours(Component caller, Color col1, Frame alignframe)
{
this(caller, col1, alignframe, "Select Colour");
}
+
/**
* Makes a dialog to choose the colour
- * @param caller - handles events
- * @param col1 - original colour
- * @param alignframe - the parent Frame for the dialog
- * @param title - window title
+ *
+ * @param caller
+ * - handles events
+ * @param col1
+ * - original colour
+ * @param alignframe
+ * - the parent Frame for the dialog
+ * @param title
+ * - window title
*/
- public UserDefinedColours(Component caller, Color col1, Frame alignframe, String title)
+ public UserDefinedColours(Component caller, Color col1, Frame alignframe,
+ String title)
{
this.caller = caller;
originalColour = col1;
dialog.setVisible(true);
}
+ /**
+ * feature colour chooser
+ *
+ * @param caller
+ * @param label
+ * @param colour
+ */
public UserDefinedColours(Object caller, String label, Color colour)
{
+ this(caller, label, colour, colour);
+ }
+
+ /**
+ * feature colour chooser when changing style to single color
+ *
+ * @param me
+ * @param type
+ * @param graduatedColor
+ */
+ public UserDefinedColours(FeatureSettings me, String type,
+ GraduatedColor graduatedColor)
+ {
+ this(me, type, graduatedColor, graduatedColor.getMaxColor());
+ }
+
+ private UserDefinedColours(Object caller, String label, Object ocolour,
+ Color colour)
+ {
this.caller = caller;
- originalColour = colour;
+ originalColour = ocolour;
originalLabel = label;
init();
remove(buttonPanel);
okcancelPanel.setBounds(new Rectangle(0, 113, 400, 35));
frame.setTitle("User Defined Colours - " + label);
frame.setSize(420, 200);
- }
-
+ }
+
void setForDialog(String title, Container alignframe)
{
init();
remove(buttonPanel);
if (alignframe instanceof Frame)
{
- dialog = new Dialog((Frame)alignframe, title, true);
+ dialog = new Dialog((Frame) alignframe, title, true);
}
- else {
-// if (alignframe instanceof JVDialog){
-// // not 1.1 compatible!
-// dialog = new Dialog(((JVDialog)alignframe), title, true);
-// } else {
+ else
+ {
+ // if (alignframe instanceof JVDialog){
+ // // not 1.1 compatible!
+ // dialog = new Dialog(((JVDialog)alignframe), title, true);
+ // } else {
throw new Error("Unsupported owner for User Colour scheme dialog.");
}
{
final Button button = new Button();
Color col = Color.white;
- if (oldColourScheme!=null)
- {
- try
- {
- col = oldColourScheme.findColour(aa.charAt(0), -1);
- } catch (Exception ex)
+ if (oldColourScheme != null)
{
- }
+ try
+ {
+ col = oldColourScheme.findColour(aa.charAt(0), -1);
+ } catch (Exception ex)
+ {
+ }
}
button.setBackground(col);
oldColours.addElement(col);
}
else if (caller instanceof FeatureColourChooser)
{
- if (originalLabel.indexOf("inimum")>-1)
+ if (originalLabel.indexOf("inimum") > -1)
{
- ((FeatureColourChooser) caller).minColour_actionPerformed(getColor());
- } else {
- ((FeatureColourChooser) caller).maxColour_actionPerformed(getColor());
+ ((FeatureColourChooser) caller)
+ .minColour_actionPerformed(getColor());
+ }
+ else
+ {
+ ((FeatureColourChooser) caller)
+ .maxColour_actionPerformed(getColor());
}
}
if (originalLabel.equals("Min Colour"))
{
((AnnotationColourChooser) caller)
- .minColour_actionPerformed(originalColour);
+ .minColour_actionPerformed((Color) originalColour);
}
else
{
((AnnotationColourChooser) caller)
- .maxColour_actionPerformed(originalColour);
+ .maxColour_actionPerformed((Color) originalColour);
}
}
else if (caller instanceof FeatureRenderer)
else if (caller instanceof FeatureColourChooser)
{
- if (originalLabel.indexOf("inimum")>-1)
+ if (originalLabel.indexOf("inimum") > -1)
+ {
+ ((FeatureColourChooser) caller)
+ .minColour_actionPerformed((Color) originalColour);
+ }
+ else
{
- ((FeatureColourChooser) caller).minColour_actionPerformed(originalColour);
- } else {
- ((FeatureColourChooser) caller).maxColour_actionPerformed(originalColour);
+ ((FeatureColourChooser) caller)
+ .maxColour_actionPerformed((Color) originalColour);
}
}
if (dialog != null)