synchronized void slideSequences(boolean right, int size)
{
- List<SequenceI> sg = new Vector<SequenceI>();
+ List<SequenceI> sg = new Vector<>();
if (viewport.cursorMode)
{
sg.add(viewport.getAlignment().getSequenceAt(
SequenceGroup sg = viewport.getSelectionGroup();
copiedSequences = new StringBuffer();
- Map<Integer, SequenceI> orderedSeqs = new HashMap<Integer, SequenceI>();
+ Map<Integer, SequenceI> orderedSeqs = new HashMap<>();
for (int i = 0; i < sg.getSize(); i++)
{
SequenceI seq = sg.getSequenceAt(i);
HiddenColumns oldHidden = av
.getAnnotationColumnSelectionState()
.getOldHiddenColumns();
- if (oldHidden != null
- && !oldHidden.getHiddenRegions().isEmpty())
+ if (oldHidden != null)
{
- for (Iterator<int[]> itr = oldHidden.getHiddenRegions()
- .iterator(); itr.hasNext();)
+ for (Iterator<int[]> itr = oldHidden.iterator(); itr.hasNext();)
{
int positions[] = itr.next();
av.hideColumns(positions[0], positions[1]);
import java.awt.event.MouseMotionListener;
import java.util.Arrays;
import java.util.Collections;
-import java.util.Vector;
public class AnnotationLabels extends Panel implements ActionListener,
MouseListener, MouseMotionListener
+ sq.getSequenceAsString() + "\n");
if (av.hasHiddenColumns())
{
- jalview.appletgui.AlignFrame.copiedHiddenColumns = new Vector();
- for (int[] region : av.getAlignment().getHiddenColumns()
- .getHiddenRegions())
- {
- jalview.appletgui.AlignFrame.copiedHiddenColumns
- .addElement(new int[] { region[0], region[1] });
- }
+ av.getAlignment().getHiddenColumns().getHiddenColumnsCopy(
+ jalview.appletgui.AlignFrame.copiedHiddenColumns);
}
}
res = av.getAlignment().getHiddenColumns().adjustForHiddenColumns(res);
reveal = null;
- for (int[] region : av.getAlignment().getHiddenColumns()
- .getHiddenRegions())
+ for (int[] region : av.getAlignment().getHiddenColumns())
{
if (res + 1 == region[0] || res - 1 == region[1])
{
if (av.hasHiddenColumns())
{
HiddenColumns hidden = av.getAlignment().getHiddenColumns();
- for (int[] region : hidden.getHiddenRegions())
+ for (int[] region : hidden)
{
int hideStart = region[0];
int hideEnd = region[1];
import java.util.ArrayList;
import java.util.BitSet;
import java.util.Collections;
+import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import java.util.concurrent.locks.ReentrantReadWriteLock;
-public class HiddenColumns
+public class HiddenColumns implements Iterable<int[]>
{
private static final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
{
if (copy.hiddenColumns != null)
{
- hiddenColumns = new Vector<>(copy.hiddenColumns.size());
- for (int i = 0, j = copy.hiddenColumns.size(); i < j; i++)
- {
- int[] rh, cp;
- rh = copy.hiddenColumns.elementAt(i);
- if (rh != null)
- {
- cp = new int[rh.length];
- System.arraycopy(rh, 0, cp, 0, rh.length);
- hiddenColumns.addElement(cp);
- }
- }
+ hiddenColumns = copy.copyHiddenRegions();
}
}
}
}
}
+ private Vector<int[]> copyHiddenRegions()
+ {
+ Vector<int[]> copy = new Vector<>(hiddenColumns.size());
+ for (int i = 0, j = hiddenColumns.size(); i < j; i++)
+ {
+ int[] rh, cp;
+ rh = hiddenColumns.elementAt(i);
+ if (rh != null)
+ {
+ cp = new int[rh.length];
+ System.arraycopy(rh, 0, cp, 0, rh.length);
+ copy.addElement(cp);
+ }
+ }
+ return copy;
+ }
+
+ private ArrayList<int[]> copyHiddenRegionsToArrayList()
+ {
+ ArrayList<int[]> copy = new ArrayList<>(hiddenColumns.size());
+ for (int i = 0, j = hiddenColumns.size(); i < j; i++)
+ {
+ int[] rh, cp;
+ rh = hiddenColumns.elementAt(i);
+ if (rh != null)
+ {
+ cp = new int[rh.length];
+ System.arraycopy(rh, 0, cp, 0, rh.length);
+ copy.add(cp);
+ }
+ }
+ return copy;
+ }
+
+ public void getHiddenColumnsCopy(Vector<int[]> copy)
+ {
+ try
+ {
+ lock.readLock().lock();
+ copy = copyHiddenRegions();
+ } finally
+ {
+ lock.readLock().unlock();
+ }
+ }
+
+ public void getHiddenColumnsCopy(ArrayList<int[]> copy)
+ {
+ try
+ {
+ lock.readLock().lock();
+ copy = copyHiddenRegionsToArrayList();
+ } finally
+ {
+ lock.readLock().unlock();
+ }
+ }
+
/**
* propagate shift in alignment columns to column selection
*
}
}
+ @Override
+ public Iterator<int[]> iterator()
+ {
+ if (hiddenColumns == null)
+ {
+ return Collections.<int[]> emptyList().iterator();
+ }
+ return hiddenColumns.iterator();
+ }
+
}
public AlignViewControllerI avc;
- List<AlignmentPanel> alignPanels = new ArrayList<AlignmentPanel>();
+ List<AlignmentPanel> alignPanels = new ArrayList<>();
/**
* Last format used to load or save alignments in this window
addKeyListener();
- final List<AlignmentPanel> selviews = new ArrayList<AlignmentPanel>();
- final List<AlignmentPanel> origview = new ArrayList<AlignmentPanel>();
+ final List<AlignmentPanel> selviews = new ArrayList<>();
+ final List<AlignmentPanel> origview = new ArrayList<>();
final String menuLabel = MessageManager
.getString("label.copy_format_from");
ViewSelectionMenu vsel = new ViewSelectionMenu(menuLabel,
origview.clear();
origview.add(alignPanel);
// make an array of all alignment panels except for this one
- List<AlignmentPanel> aps = new ArrayList<AlignmentPanel>(
+ List<AlignmentPanel> aps = new ArrayList<>(
Arrays.asList(Desktop.getAlignmentPanels(null)));
aps.remove(AlignFrame.this.alignPanel);
return aps.toArray(new AlignmentPanel[aps.size()]);
synchronized void slideSequences(boolean right, int size)
{
- List<SequenceI> sg = new ArrayList<SequenceI>();
+ List<SequenceI> sg = new ArrayList<>();
if (viewport.cursorMode)
{
sg.add(viewport.getAlignment().getSequenceAt(
return;
}
- List<SequenceI> invertGroup = new ArrayList<SequenceI>();
+ List<SequenceI> invertGroup = new ArrayList<>();
for (SequenceI seq : viewport.getAlignment().getSequences())
{
ArrayList<int[]> hiddenColumns = null;
if (viewport.hasHiddenColumns())
{
- hiddenColumns = new ArrayList<int[]>();
- int hiddenOffset = viewport.getSelectionGroup().getStartRes(), hiddenCutoff = viewport
- .getSelectionGroup().getEndRes();
+ hiddenColumns = new ArrayList<>();
+ int hiddenOffset = viewport.getSelectionGroup().getStartRes(),
+ hiddenCutoff = viewport.getSelectionGroup().getEndRes();
for (int[] region : viewport.getAlignment().getHiddenColumns()
.getHiddenRegions())
{
}
int alwidth = 0;
- ArrayList<Integer> newGraphGroups = new ArrayList<Integer>();
+ ArrayList<Integer> newGraphGroups = new ArrayList<>();
int fgroup = -1;
if (newAlignment)
*/
protected List<String> getExistingViewNames(List<Component> comps)
{
- List<String> existingNames = new ArrayList<String>();
+ List<String> existingNames = new ArrayList<>();
for (Component comp : comps)
{
if (comp instanceof AlignmentPanel)
List<Component> comps = PaintRefresher.components.get(viewport
.getSequenceSetId());
- List<TreePanel> treePanels = new ArrayList<TreePanel>();
+ List<TreePanel> treePanels = new ArrayList<>();
for (Component comp : comps)
{
if (comp instanceof TreePanel)
@Override
public void run()
{
- final List<JMenuItem> legacyItems = new ArrayList<JMenuItem>();
+ final List<JMenuItem> legacyItems = new ArrayList<>();
try
{
// System.err.println("Building ws menu again "
// TODO: group services by location as well as function and/or
// introduce
// object broker mechanism.
- final Vector<JMenu> wsmenu = new Vector<JMenu>();
+ final Vector<JMenu> wsmenu = new Vector<>();
final IProgressIndicator af = me;
/*
// Java's Transferable for native dnd
evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
Transferable t = evt.getTransferable();
- List<String> files = new ArrayList<String>();
- List<DataSourceType> protocols = new ArrayList<DataSourceType>();
+ List<String> files = new ArrayList<>();
+ List<DataSourceType> protocols = new ArrayList<>();
try
{
/**
* Object[] { String,SequenceI}
*/
- ArrayList<Object[]> filesmatched = new ArrayList<Object[]>();
- ArrayList<String> filesnotmatched = new ArrayList<String>();
+ ArrayList<Object[]> filesmatched = new ArrayList<>();
+ ArrayList<String> filesnotmatched = new ArrayList<>();
for (int i = 0; i < files.size(); i++)
{
String file = files.get(i).toString();
{
return;
}
- List<SequenceI> cdnaSeqs = new ArrayList<SequenceI>();
+ List<SequenceI> cdnaSeqs = new ArrayList<>();
for (SequenceI aaSeq : alignment.getSequences())
{
for (AlignedCodonFrame acf : mappings)
HiddenColumns oldHidden = av
.getAnnotationColumnSelectionState()
.getOldHiddenColumns();
- if (oldHidden != null
- && !oldHidden.getHiddenRegions().isEmpty())
+ if (oldHidden != null)
{
- for (Iterator<int[]> itr = oldHidden.getHiddenRegions()
- .iterator(); itr.hasNext();)
+ for (Iterator<int[]> itr = oldHidden.iterator(); itr.hasNext();)
{
int positions[] = itr.next();
av.hideColumns(positions[0], positions[1]);
.setContents(new StringSelection(output), Desktop.instance);
ArrayList<int[]> hiddenColumns = null;
+
if (av.hasHiddenColumns())
{
- hiddenColumns = new ArrayList<int[]>();
- for (int[] region : av.getAlignment().getHiddenColumns()
- .getHiddenRegions())
- {
- hiddenColumns.add(new int[] { region[0], region[1] });
- }
+ av.getAlignment().getHiddenColumns()
+ .getHiddenColumnsCopy(hiddenColumns);
}
Desktop.jalviewClipboard = new Object[] { seqs, ds, // what is the dataset
}
else
{
- for (int c = 0; c < hidden.getHiddenRegions()
- .size(); c++)
+ for (int[] region : hidden)
{
- int[] region = hidden.getHiddenRegions()
- .get(c);
HiddenColumns hc = new HiddenColumns();
hc.setStart(region[0]);
hc.setEnd(region[1]);
res = av.getAlignment().getHiddenColumns().adjustForHiddenColumns(res);
- for (int[] region : av.getAlignment().getHiddenColumns()
- .getHiddenRegions())
+ for (int[] region : av.getAlignment().getHiddenColumns())
{
if (res + 1 == region[0] || res - 1 == region[1])
{
import java.awt.Shape;
import java.awt.image.BufferedImage;
import java.beans.PropertyChangeEvent;
-import java.util.List;
import javax.swing.JComponent;
}
else
{
- List<int[]> regions = av.getAlignment().getHiddenColumns()
- .getHiddenRegions();
-
int screenY = 0;
int blockStart = startRes;
int blockEnd = endRes;
- for (int[] region : regions)
+ for (int[] region : av.getAlignment().getHiddenColumns())
{
int hideStart = region[0];
int hideEnd = region[1];
if (cs != null && cs.hasHiddenColumns())
{
text.append("VIEW_HIDECOLS\t");
- List<int[]> hc = cs.getHiddenRegions();
boolean comma = false;
- for (int[] r : hc)
+ for (int[] r : cs.getHiddenRegions())
{
if (!comma)
{
StringBuffer colours = new StringBuffer();
StringBuffer graphLine = new StringBuffer();
StringBuffer rowprops = new StringBuffer();
- Hashtable<Integer, String> graphGroup = new Hashtable<Integer, String>();
- Hashtable<Integer, Object[]> graphGroup_refs = new Hashtable<Integer, Object[]>();
+ Hashtable<Integer, String> graphGroup = new Hashtable<>();
+ Hashtable<Integer, Object[]> graphGroup_refs = new Hashtable<>();
BitSet graphGroupSeen = new BitSet();
java.awt.Color color;
BufferedReader in) throws Exception
{
nlinesread = 0;
- ArrayList<Object[]> combineAnnotation_calls = new ArrayList<Object[]>();
- ArrayList<Object[]> deferredAnnotation_calls = new ArrayList<Object[]>();
+ ArrayList<Object[]> combineAnnotation_calls = new ArrayList<>();
+ ArrayList<Object[]> deferredAnnotation_calls = new ArrayList<>();
boolean modified = false;
String groupRef = null;
Hashtable groupRefRows = new Hashtable();
modified = true;
}
// Resolve the groupRefs
- Hashtable<String, SequenceGroup> groupRefLookup = new Hashtable<String, SequenceGroup>();
+ Hashtable<String, SequenceGroup> groupRefLookup = new Hashtable<>();
Enumeration en = groupRefRows.keys();
while (en.hasMoreElements())
// hidden column business
if (getViewport().hasHiddenColumns())
{
- List<int[]> hiddenCols = getViewport().getAlignment()
- .getHiddenColumns()
- .getHiddenRegions();
StringBuilder hiddenColsBuilder = new StringBuilder();
- for (int[] range : hiddenCols)
+ for (int[] range : getViewport().getAlignment().getHiddenColumns())
{
hiddenColsBuilder.append(";").append(range[0]).append("-")
.append(range[1]);
SequenceI[] sqs, FeatureRenderer fr)
{
displayedFeatures = (fr == null) ? null : fr.getFeaturesDisplayed();
- List<SequenceFeaturesPojo> sequenceFeaturesPojo = new ArrayList<SequenceFeaturesPojo>();
+ List<SequenceFeaturesPojo> sequenceFeaturesPojo = new ArrayList<>();
if (sqs == null)
{
return sequenceFeaturesPojo;
public static List<AlignmentAnnotationPojo> annotationToJsonPojo(
Vector<AlignmentAnnotation> annotations)
{
- List<AlignmentAnnotationPojo> jsonAnnotations = new ArrayList<AlignmentAnnotationPojo>();
+ List<AlignmentAnnotationPojo> jsonAnnotations = new ArrayList<>();
if (annotations == null)
{
return jsonAnnotations;
parseHiddenCols(jvSettingsJsonObj);
}
- hiddenSequences = new ArrayList<SequenceI>();
- seqMap = new Hashtable<String, Sequence>();
+ hiddenSequences = new ArrayList<>();
+ seqMap = new Hashtable<>();
for (Iterator<JSONObject> sequenceIter = seqJsonArray.iterator(); sequenceIter
.hasNext();)
{
int endRes = Integer.valueOf(seqGrpObj.get("endRes").toString());
JSONArray sequenceRefs = (JSONArray) seqGrpObj.get("sequenceRefs");
- ArrayList<SequenceI> grpSeqs = new ArrayList<SequenceI>();
+ ArrayList<SequenceI> grpSeqs = new ArrayList<>();
if (sequenceRefs.size() > 0)
{
Iterator<String> seqHashIter = sequenceRefs.iterator();
public void parseHiddenSeqRefsAsList(JSONObject jvSettingsJson)
{
- hiddenSeqRefs = new ArrayList<String>();
+ hiddenSeqRefs = new ArrayList<>();
String hiddenSeqs = (String) jvSettingsJson.get("hiddenSeqs");
if (hiddenSeqs != null && !hiddenSeqs.isEmpty())
{
* Cache a copy of the target sequences so we can mimic successive edits on
* them. This lets us compute mappings for all edits in the set.
*/
- Map<SequenceI, SequenceI> targetCopies = new HashMap<SequenceI, SequenceI>();
+ Map<SequenceI, SequenceI> targetCopies = new HashMap<>();
for (SequenceI seq : mapTo.getSequences())
{
SequenceI ds = seq.getDatasetSequence();
boolean undo, AlignmentI mapTo, List<AlignedCodonFrame> mappings)
{
SequenceI[] sortOrder = command.getSequenceOrder(undo);
- List<SequenceI> mappedOrder = new ArrayList<SequenceI>();
+ List<SequenceI> mappedOrder = new ArrayList<>();
int j = 0;
/*
toSequences, fromGapChar);
}
- for (int[] hidden : hiddencols.getHiddenRegions())
+ for (int[] hidden : hiddencols)
{
mapHiddenColumns(hidden, codonFrames, newHidden, fromSequences,
toSequences, fromGapChar);
public static List<char[]> findCodonsFor(SequenceI seq, int col,
List<AlignedCodonFrame> mappings)
{
- List<char[]> result = new ArrayList<char[]>();
+ List<char[]> result = new ArrayList<>();
int dsPos = seq.findPosition(col);
for (AlignedCodonFrame mapping : mappings)
{
SequenceI sequence, List<AlignedCodonFrame> mappings,
List<SequenceI> filterList)
{
- List<AlignedCodonFrame> result = new ArrayList<AlignedCodonFrame>();
+ List<AlignedCodonFrame> result = new ArrayList<>();
if (sequence == null || mappings == null)
{
return result;