+ /*
+ * sort feature types by colour order, from 0 (highest)
+ * to 1 (lowest)
+ */
+ Set<String> fr_colours = fr.getAllFeatureColours();
+ String[] sortedTypes = fr_colours
+ .toArray(new String[fr_colours.size()]);
+ Arrays.sort(sortedTypes, new Comparator<String>()
+ {
+ @Override
+ public int compare(String type1, String type2)
+ {
+ return Float.compare(fr.getOrder(type1), fr.getOrder(type2));
+ }
+ });
+
+ /*
+ * save feature colours
+ */
+ for (String featureType : sortedTypes)
+ {
+ FeatureColourI fcol = fr.getFeatureStyle(featureType);
+ Colour col = jalview.project.Jalview2XML.marshalColour(featureType,
+ fcol);
+ ucs.getColour().add(col);
+ }
+
+ /*
+ * save any feature filters
+ */
+ for (String featureType : sortedTypes)
+ {
+ FeatureMatcherSetI filter = fr.getFeatureFilter(featureType);
+ if (filter != null && !filter.isEmpty())
+ {
+ Iterator<FeatureMatcherI> iterator = filter.getMatchers()
+ .iterator();
+ FeatureMatcherI firstMatcher = iterator.next();
+ jalview.xml.binding.jalview.FeatureMatcherSet ms = jalview.project.Jalview2XML
+ .marshalFilter(firstMatcher, iterator, filter.isAnded());
+ Filter filterModel = new Filter();
+ filterModel.setFeatureType(featureType);
+ filterModel.setMatcherSet(ms);
+ ucs.getFilter().add(filterModel);
+ }
+ }
+ JAXBContext jaxbContext = JAXBContext
+ .newInstance(JalviewUserColours.class);
+ Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
+ jaxbMarshaller.marshal(
+ new ObjectFactory().createJalviewUserColours(ucs), out);
+
+ // jaxbMarshaller.marshal(object, pout);
+ // marshaller.marshal(object);
+ out.flush();
+
+ // ucs.marshal(out);
+ out.close();
+ } catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ public void invertSelection()
+ {
+ Object[][] data = ((FeatureTableModel) table.getModel()).getData();
+ for (int i = 0; i < data.length; i++)
+ {
+ data[i][SHOW_COLUMN] = !(Boolean) data[i][SHOW_COLUMN];
+ }
+ updateFeatureRenderer(data, true);
+ table.repaint();
+ }
+
+ public void orderByAvWidth()