import jalview.gui.Help.HelpId;
import jalview.io.JalviewFileChooser;
import jalview.io.JalviewFileView;
-import jalview.schemabinding.version2.Filter;
-import jalview.schemabinding.version2.JalviewUserColours;
-import jalview.schemabinding.version2.MatcherSet;
import jalview.schemes.FeatureColour;
import jalview.util.MessageManager;
import jalview.util.Platform;
import jalview.viewmodel.seqfeatures.FeatureRendererModel.FeatureSettingsBean;
+import jalview.xml.binding.jalview.JalviewUserColours;
+import jalview.xml.binding.jalview.JalviewUserColours.Colour;
+import jalview.xml.binding.jalview.JalviewUserColours.Filter;
+import jalview.xml.binding.jalview.ObjectFactory;
import java.awt.BorderLayout;
import java.awt.Color;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.Marshaller;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
public class FeatureSettings extends JPanel
implements FeatureSettingsControllerI
InputStreamReader in = new InputStreamReader(
new FileInputStream(file), "UTF-8");
- JalviewUserColours jucs = JalviewUserColours.unmarshal(in);
+ JAXBContext jc = JAXBContext
+ .newInstance("jalview.xml.binding.jalview");
+ javax.xml.bind.Unmarshaller um = jc.createUnmarshaller();
+ XMLStreamReader streamReader = XMLInputFactory.newInstance()
+ .createXMLStreamReader(in);
+ JAXBElement<JalviewUserColours> jbe = um.unmarshal(streamReader,
+ JalviewUserColours.class);
+ JalviewUserColours jucs = jbe.getValue();
+
+ // JalviewUserColours jucs = JalviewUserColours.unmarshal(in);
/*
* load feature colours
*/
- for (int i = jucs.getColourCount() - 1; i >= 0; i--)
+ for (int i = jucs.getColour().size() - 1; i >= 0; i--)
{
- jalview.schemabinding.version2.Colour newcol = jucs.getColour(i);
- FeatureColourI colour = Jalview2XML.unmarshalColour(newcol);
+ Colour newcol = jucs.getColour().get(i);
+ FeatureColourI colour = jalview.project.Jalview2XML
+ .parseColour(newcol);
fr.setColour(newcol.getName(), colour);
- fr.setOrder(newcol.getName(), i / (float) jucs.getColourCount());
+ fr.setOrder(newcol.getName(), i / (float) jucs.getColour().size());
}
/*
* load feature filters; loaded filters will replace any that are
* currently defined, other defined filters are left unchanged
*/
- for (int i = 0; i < jucs.getFilterCount(); i++)
+ for (int i = 0; i < jucs.getFilter().size(); i++)
{
- jalview.schemabinding.version2.Filter filterModel = jucs
- .getFilter(i);
+ Filter filterModel = jucs.getFilter().get(i);
String featureType = filterModel.getFeatureType();
- FeatureMatcherSetI filter = Jalview2XML.unmarshalFilter(featureType,
- filterModel.getMatcherSet());
+ FeatureMatcherSetI filter = jalview.project.Jalview2XML
+ .parseFilter(featureType, filterModel.getMatcherSet());
if (!filter.isEmpty())
{
fr.setFeatureFilter(featureType, filter);
for (String featureType : sortedTypes)
{
FeatureColourI fcol = fr.getFeatureStyle(featureType);
- jalview.schemabinding.version2.Colour col = Jalview2XML.marshalColour(
- featureType, fcol);
- ucs.addColour(col);
+ Colour col = jalview.project.Jalview2XML.marshalColour(featureType,
+ fcol);
+ ucs.getColour().add(col);
}
/*
{
Iterator<FeatureMatcherI> iterator = filter.getMatchers().iterator();
FeatureMatcherI firstMatcher = iterator.next();
- MatcherSet ms = Jalview2XML.marshalFilter(firstMatcher, iterator,
+ 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.addFilter(filterModel);
+ 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);
+ // ucs.marshal(out);
out.close();
} catch (Exception ex)
{
if (filters != null)
{
FeatureMatcherSetI filter = Jalview2XML
- .unmarshalFilter(featureType, filters);
+ .parseFilter(featureType, filters);
if (!filter.isEmpty())
{
fr.setFeatureFilter(featureType, filter);
* @param fcol
* @return
*/
- protected static Colour marshalColour(
+ public static Colour marshalColour(
String featureType, FeatureColourI fcol)
{
Colour col = new Colour();
* @param and
* if true, conditions are and-ed, else or-ed
*/
- protected static jalview.xml.binding.jalview.FeatureMatcherSet marshalFilter(
+ public static jalview.xml.binding.jalview.FeatureMatcherSet marshalFilter(
FeatureMatcherI firstMatcher, Iterator<FeatureMatcherI> filters,
boolean and)
{
* @param matcherSetModel
* @return
*/
- protected static FeatureMatcherSetI unmarshalFilter(
+ public static FeatureMatcherSetI parseFilter(
String featureType,
jalview.xml.binding.jalview.FeatureMatcherSet matcherSetModel)
{
FeatureMatcherSetI result = new FeatureMatcherSet();
try
{
- unmarshalFilterConditions(result, matcherSetModel, true);
+ parseFilterConditions(result, matcherSetModel, true);
} catch (IllegalStateException e)
{
// mixing AND and OR conditions perhaps
* @throws IllegalStateException
* if AND and OR conditions are mixed
*/
- protected static void unmarshalFilterConditions(
+ protected static void parseFilterConditions(
FeatureMatcherSetI matcherSet,
jalview.xml.binding.jalview.FeatureMatcherSet matcherSetModel,
boolean and)
* compound condition
*/
List<jalview.xml.binding.jalview.FeatureMatcherSet> matchers = matcherSetModel
- .getCompoundMatcher()
- .getMatcherSet();
+ .getCompoundMatcher().getMatcherSet();
boolean anded = matcherSetModel.getCompoundMatcher().isAnd();
if (matchers.size() == 2)
{
- unmarshalFilterConditions(matcherSet, matchers.get(0), anded);
- unmarshalFilterConditions(matcherSet, matchers.get(1), anded);
+ parseFilterConditions(matcherSet, matchers.get(0), anded);
+ parseFilterConditions(matcherSet, matchers.get(1), anded);
}
else
{
* @param colourModel
* @return
*/
- protected static FeatureColourI unmarshalColour(Colour colourModel)
+ public static FeatureColourI parseColour(Colour colourModel)
{
FeatureColourI colour = null;