*/
public class FeatureRenderer
{
+ AlignmentPanel ap;
AlignViewport av;
Color resBoxColour;
float transparency = 1.0f;
// A higher level for grouping features of a
// particular type
- Hashtable featureGroups = null;
+ Hashtable featureGroups = new Hashtable();
// This is actually an Integer held in the hashtable,
// Retrieved using the key feature type
* @param av
* DOCUMENT ME!
*/
- public FeatureRenderer(AlignViewport av)
+ public FeatureRenderer(AlignmentPanel ap)
{
- this.av = av;
+ this.ap = ap;
+ this.av = ap.av;
}
+
public void transferSettings(FeatureRenderer fr)
{
- renderOrder = fr.renderOrder;
- featureGroups = fr.featureGroups;
- featureColours = fr.featureColours;
- transparency = fr.transparency;
- featureOrder = fr.featureOrder;
+ this.renderOrder = fr.renderOrder;
+ this.featureGroups = fr.featureGroups;
+ this.featureColours = fr.featureColours;
+ this.transparency = fr.transparency;
+ this.featureOrder = fr.featureOrder;
}
BufferedImage offscreenImage;
}
}
- if (sequenceFeatures == null)
+ if (sequenceFeatures == null || sfSize==0)
{
return initialCol;
}
SequenceFeature[] sequenceFeatures;
int sfSize, sfindex, spos, epos;
- public void drawSequence(Graphics g, SequenceI seq,
+ synchronized public void drawSequence(Graphics g, SequenceI seq,
int start, int end, int y1)
{
+
if (seq.getDatasetSequence().getSequenceFeatures() == null
|| seq.getDatasetSequence().getSequenceFeatures().length == 0)
{
}
sequenceFeatures = seq.getDatasetSequence().getSequenceFeatures();
- sfSize = sequenceFeatures.length;
}
if (lastSeq == null || seq != lastSeq
{
lastSeq = seq;
sequenceFeatures = seq.getDatasetSequence().getSequenceFeatures();
- sfSize = sequenceFeatures.length;
}
if (transparency != 1 && g != null)
epos = lastSeq.findPosition(end);
}
+ sfSize = sequenceFeatures.length;
String type;
for (int renderIndex = 0; renderIndex < renderOrder.length; renderIndex++)
{
// current feature to render
for (sfindex = 0; sfindex < sfSize; sfindex++)
{
- if (sequenceFeatures.length <= sfindex)
- {
- continue;
- }
if (!sequenceFeatures[sfindex].type.equals(type))
{
continue;
if (featureGroups != null
&& sequenceFeatures[sfindex].featureGroup != null
&&
- featureGroups.containsKey(sequenceFeatures[sfindex].featureGroup)
+ sequenceFeatures[sfindex].featureGroup.length()!=0
+ && featureGroups.containsKey(sequenceFeatures[sfindex].featureGroup)
&&
! ( (Boolean) featureGroups.get(sequenceFeatures[sfindex].
featureGroup)).
* them. Then fires a PropertyChangeEvent on the changeSupport object.
*
*/
- synchronized void findAllFeatures()
+ void findAllFeatures()
{
- findAllFeatures(true); // add all new features as visible
- if (!firing) {
- firing=true;
- changeSupport.firePropertyChange("changeSupport",null,null);
- firing=false;
+ synchronized (firing)
+ {
+ if (firing.equals(Boolean.FALSE)) {
+ firing=Boolean.TRUE;
+ findAllFeatures(true); // add all new features as visible
+ changeSupport.firePropertyChange("changeSupport",null,null);
+ firing=Boolean.FALSE;
+ }
}
}
/**
{
if (!av.featuresDisplayed.containsKey(features[index].getType()))
{
+
+ if(featureGroups.containsKey(features[index].getType()))
+ {
+ boolean visible = ( (Boolean) featureGroups.get(
+ features[index].featureGroup)).booleanValue();
+
+ if(!visible)
+ {
+ index++;
+ continue;
+ }
+ }
+
+
if (! (features[index].begin == 0 && features[index].end == 0))
{
// If beginning and end are 0, the feature is for the whole sequence
updateRenderOrder(allfeatures);
findingFeatures = false;
}
- protected boolean firing=false;
+ protected Boolean firing=Boolean.FALSE;
/**
* replaces the current renderOrder with the unordered features in allfeatures.
* The ordering of any types in both renderOrder and allfeatures is preserved,
}
public Color getColour(String featureType)
{
- if (featureColours.get(featureType) == null)
+ if (!featureColours.containsKey(featureType))
{
jalview.schemes.UserColourScheme ucs = new
jalview.schemes.UserColourScheme();
static String lastFeatureGroupAdded;
static String lastDescriptionAdded;
- public boolean createNewFeatures(SequenceI[] sequences,
- SequenceFeature[] features)
- {
- return amendFeatures(sequences, features, true, null);
- }
-
int featureIndex = 0;
boolean amendFeatures(final SequenceI[] sequences,
final SequenceFeature[] features,
boolean newFeatures,
final AlignmentPanel ap)
{
- findAllFeatures();
featureIndex = 0;
{
public void mousePressed(MouseEvent evt)
{
- colour.setBackground(
- JColorChooser.showDialog(Desktop.desktop,
- "Select Feature Colour",
- colour.getBackground()));
+ Color col = JColorChooser.showDialog(Desktop.desktop,
+ "Select Feature Colour",
+ colour.getBackground());
+ if (col != null)
+ colour.setBackground(col);
+
}
});
sf.type = lastFeatureAdded;
sf.featureGroup = lastFeatureGroupAdded;
sf.description = lastDescriptionAdded;
+
setColour(sf.type, colour.getBackground());
+ av.featuresDisplayed.put(sf.type,
+ new Integer(colour.getBackground().getRGB()));
+
try
{
sf.begin = ( (Integer) start.getValue()).intValue();
ffile.parseDescriptionHTML(sf, false);
}
}
- else
+ else //NEW FEATURES ADDED
{
if (reply == JOptionPane.OK_OPTION
- && name.getText() != null
- && source.getText() != null)
+ && lastFeatureAdded.length()>0)
{
for (int i = 0; i < sequences.length; i++)
{
features[i].type = lastFeatureAdded;
- features[i].featureGroup = lastFeatureGroupAdded;
+ if (lastFeatureGroupAdded!=null)
+ features[i].featureGroup = lastFeatureGroupAdded;
features[i].description = lastDescriptionAdded;
sequences[i].addSequenceFeature(features[i]);
ffile.parseDescriptionHTML(features[i], false);
av.featuresDisplayed = new Hashtable();
}
- if (featureGroups == null)
+ if (lastFeatureGroupAdded != null)
{
- featureGroups = new Hashtable();
+ if (featureGroups == null)
+ featureGroups = new Hashtable();
+ featureGroups.put(lastFeatureGroupAdded, new Boolean(true));
}
-
Color col = colour.getBackground();
setColour(lastFeatureAdded, colour.getBackground());
-
- if(lastFeatureGroupAdded!=null)
- {
- featureGroups.put(lastFeatureGroupAdded, new Boolean(true));
- av.featuresDisplayed.put(lastFeatureGroupAdded,
+ av.featuresDisplayed.put(lastFeatureAdded,
new Integer(col.getRGB()));
- }
- findAllFeatures();
+
+ findAllFeatures(false);
+
+ ap.paintAlignment(true);
+
return true;
}
}
}
- findAllFeatures();
+ ap.paintAlignment(true);
return true;
}