diff --git a/uk/ac/sanger/artemis/components/AlignmentViewer.java b/uk/ac/sanger/artemis/components/AlignmentViewer.java index 19666975697068eea1cd7a757948defd32395d60..ddd11457c51a32772213f8b193517150e6d3ba72 100644 --- a/uk/ac/sanger/artemis/components/AlignmentViewer.java +++ b/uk/ac/sanger/artemis/components/AlignmentViewer.java @@ -102,18 +102,6 @@ public class AlignmentViewer extends CanvasPanel **/ private Strand orig_query_forward_strand; - /** - * Set by the constructor to be the original reverse strand for the subject - * sequence. - **/ - private Strand orig_subject_reverse_strand; - - /** - * Set by the constructor to be the original reverse strand for the query - * sequence. - **/ - private Strand orig_query_reverse_strand; - /** One of the two Entry objects that we are comparing. */ final private EntryGroup subject_entry_group; @@ -126,7 +114,8 @@ public class AlignmentViewer extends CanvasPanel /** * The objects that are listening for AlignmentSelectionChangeEvents. **/ - private Vector selection_change_listeners = new Vector(); + private Vector<AlignmentSelectionChangeListener> selection_change_listeners = + new Vector<AlignmentSelectionChangeListener>(); /** * The number of shades of red and blue to use for percentage ID colouring. @@ -171,8 +160,7 @@ public class AlignmentViewer extends CanvasPanel private boolean ignore_self_match_flag = false; /** Vector of those objects that are listening for AlignmentEvents */ - private java.util.Vector alignment_event_listeners = - new java.util.Vector (); + private Vector<AlignmentListener> alignment_event_listeners = new Vector<AlignmentListener> (); /** * If true then the FeatureDisplays above and below this AlignmentViewer @@ -866,19 +854,17 @@ public class AlignmentViewer extends CanvasPanel **/ public void alignAt(final AlignMatch align_match) { - final java.util.Vector targets; + final Vector<AlignmentListener> targets; // copied from a book - synchronizing the whole method might cause a // deadlock synchronized(this) { - targets = (java.util.Vector)alignment_event_listeners.clone(); + targets = new Vector<AlignmentListener>(alignment_event_listeners); } for(int i = 0; i < targets.size(); ++i) { - final AlignmentListener listener = - (AlignmentListener)targets.elementAt(i); - + final AlignmentListener listener = targets.elementAt(i); listener.alignMatchChosen(new AlignmentEvent(align_match)); } } @@ -1019,9 +1005,7 @@ public class AlignmentViewer extends CanvasPanel final AlignmentSelectionChangeEvent ev = new AlignmentSelectionChangeEvent(this, matches); - final AlignmentSelectionChangeListener listener = - (AlignmentSelectionChangeListener)selection_change_listeners.elementAt(i); - + final AlignmentSelectionChangeListener listener = selection_change_listeners.elementAt(i); listener.alignmentSelectionChanged(ev); } @@ -1539,7 +1523,7 @@ public class AlignmentViewer extends CanvasPanel * sequences. If the reverse_position argument is true reverse the * complemented match coordinates will be returned. **/ - static int getRealSubjectSequenceStart(final AlignMatch match, + protected static int getRealSubjectSequenceStart(final AlignMatch match, final int sequence_length, final boolean reverse_position) { @@ -1555,7 +1539,7 @@ public class AlignmentViewer extends CanvasPanel * reverse_position argument is true reverse the complemented match * coordinates will be returned. **/ - static int getRealSubjectSequenceEnd(final AlignMatch match, + protected static int getRealSubjectSequenceEnd(final AlignMatch match, final int sequence_length, final boolean reverse_position) { @@ -1571,7 +1555,7 @@ public class AlignmentViewer extends CanvasPanel * reverse_position argument is true reverse the complemented match * coordinates will be returned. **/ - static int getRealQuerySequenceStart(final AlignMatch match, + protected static int getRealQuerySequenceStart(final AlignMatch match, final int sequence_length, final boolean reverse_position) { @@ -1587,7 +1571,7 @@ public class AlignmentViewer extends CanvasPanel * reverse_position argument is true reverse the complemented match * coordinates will be returned. **/ - static int getRealQuerySequenceEnd(final AlignMatch match, + protected static int getRealQuerySequenceEnd(final AlignMatch match, final int sequence_length, final boolean reverse_position) { @@ -1601,7 +1585,7 @@ public class AlignmentViewer extends CanvasPanel * Remove AlignMatch from the all_matches array * @param collection of indexes to be removed from the array */ - private void removeMatches(Vector index) + private void removeMatches(Vector<Integer> index) { AlignMatch tmp_matches[] = new AlignMatch[all_matches.length - index.size()]; int start_old = 0; @@ -1609,7 +1593,7 @@ public class AlignmentViewer extends CanvasPanel for(int i=0; i<index.size(); i++) { - curr_index = ( (Integer)index.get(i) ).intValue(); + curr_index = ( index.get(i) ).intValue(); if(curr_index !=0) System.arraycopy(all_matches, start_old, tmp_matches, @@ -1648,8 +1632,8 @@ public class AlignmentViewer extends CanvasPanel int split_at; int delete_overlaps = -1; - Vector matches_to_split = new Vector(); - Vector removals = new Vector(); + Vector<Integer> matches_to_split = new Vector<Integer>(); + Vector<Integer> removals = new Vector<Integer>(); for(int i=0; i<all_matches.length; i++) { @@ -1710,7 +1694,7 @@ public class AlignmentViewer extends CanvasPanel for(int i=0; i<matches_to_split.size(); i++) { - curr_index = ((Integer)matches_to_split.get(i)).intValue(); + curr_index = matches_to_split.get(i).intValue(); // if(subject) @@ -1851,7 +1835,7 @@ public class AlignmentViewer extends CanvasPanel int match_start; int match_end; int delete_overlaps = -1; - Vector removals = new Vector(); + Vector<Integer> removals = new Vector<Integer>(); for(int i = 0; i < all_matches.length; ++i) { @@ -1926,7 +1910,7 @@ public class AlignmentViewer extends CanvasPanel * no matches. * */ - protected Vector getDifferenceCoords(boolean subject) + protected Vector<Integer[]> getDifferenceCoords(boolean subject) { final int length; final boolean flipped; @@ -1944,7 +1928,6 @@ public class AlignmentViewer extends CanvasPanel AlignMatchComparator comparator = new AlignMatchComparator(subject, length, flipped); - int imatch = 0; final AlignMatch[] sorted_all_matches = new AlignMatch[all_matches.length]; for(int i = 0; i < sorted_all_matches.length; ++i) @@ -1957,7 +1940,7 @@ public class AlignmentViewer extends CanvasPanel Arrays.sort(sorted_all_matches, 0, imatch, comparator); int start = 1; - Vector differences = new Vector(); + Vector<Integer[]> differences = new Vector<Integer[]>(); // find & record regions of no match for(int i = 0; i < imatch; ++i) @@ -2179,7 +2162,7 @@ public class AlignmentViewer extends CanvasPanel /** * Return the reference of the subject FeatureDisplay. **/ - public FeatureDisplay getSubjectDisplay() + private FeatureDisplay getSubjectDisplay() { return subject_feature_display; } @@ -2187,7 +2170,7 @@ public class AlignmentViewer extends CanvasPanel /** * Return the reference of the query FeatureDisplay. **/ - public FeatureDisplay getQueryDisplay() + private FeatureDisplay getQueryDisplay() { return query_feature_display; } @@ -2226,7 +2209,7 @@ public class AlignmentViewer extends CanvasPanel * Return the forward Strand of the subject EntryGroup from when the * Comparator was created. **/ - public Strand getOrigSubjectForwardStrand() + private Strand getOrigSubjectForwardStrand() { return orig_subject_forward_strand; } @@ -2235,29 +2218,11 @@ public class AlignmentViewer extends CanvasPanel * Return the forward Strand of the query EntryGroup from when the * Comparator was created. **/ - public Strand getOrigQueryForwardStrand() + private Strand getOrigQueryForwardStrand() { return orig_query_forward_strand; } - /** - * Return the reverse Strand of the subject EntryGroup from when the - * Comparator was created. - **/ - public Strand getOrigSubjectReverseStrand() - { - return orig_subject_reverse_strand; - } - - /** - * Return the reverse Strand of the query EntryGroup from when the - * Comparator was created. - **/ - public Strand getOrigQueryReverseStrand() - { - return orig_query_reverse_strand; - } - /** * Arrange for the two FeatureDisplay objects to scroll in parallel. **/ @@ -2354,7 +2319,7 @@ public class AlignmentViewer extends CanvasPanel return comparison_data; } - public class AlignMatchComparator implements Comparator + public class AlignMatchComparator implements Comparator<AlignMatch> { final private boolean subject; final private int length; @@ -2368,24 +2333,8 @@ public class AlignmentViewer extends CanvasPanel this.flipped = flipped; } - public int compare(Object o1,Object o2) throws ClassCastException - { -// if(o1 == null && o2 == null) -// return 0; -// else if (o1 == null) -// return 1; -// else if (o2 == null) -// return -1; - - if(!(o1 instanceof AlignMatch)) - throw new ClassCastException(); - - if(!(o2 instanceof AlignMatch)) - throw new ClassCastException(); - - AlignMatch c1 = (AlignMatch)o1; - AlignMatch c2 = (AlignMatch)o2; - + public int compare(AlignMatch c1,AlignMatch c2) throws ClassCastException + { int start1; int start2; @@ -2482,14 +2431,12 @@ public class AlignmentViewer extends CanvasPanel private void colourBox() { - //Dimension d = new Dimension(20, 35); for(int i = 0; i < NUMBER_OF_SHADES; ++i) { banner[i].setBackground(definedColour[i]); banner[i].repaint(); } } - /** * Return an array of colours that will be used for colouring the matches @@ -2522,5 +2469,4 @@ public class AlignmentViewer extends CanvasPanel return definedColour; } } - }