package org.helioviewer.jhv.viewmodel.view.fitsview;

import java.net.URI;

import org.helioviewer.jhv.viewmodel.metadata.HelioviewerMetaData;
import org.helioviewer.jhv.viewmodel.metadata.XMLMetaDataContainer;
import org.helioviewer.jhv.viewmodel.view.AbstractView;

public class FITSView extends AbstractView {

    private final String xml;
    private final URI uri;

    public FITSView(URI _uri) throws Exception {
        uri = _uri;
        if (!uri.getScheme().equalsIgnoreCase("file"))
            throw new Exception("FITS does not support the " + uri.getScheme() + " protocol");

        FITSImage fits = new FITSImage(uri.toURL().toString());
        xml = fits.xml;

        XMLMetaDataContainer hvMetaData = new XMLMetaDataContainer();
        hvMetaData.parseXML(xml);
        HelioviewerMetaData m = new HelioviewerMetaData(hvMetaData, 0);
        hvMetaData.destroyXML();

        _metaData = m;
        imageData = fits.imageData;
        imageData.setRegion(_metaData.getPhysicalRegion());
        imageData.setMetaData(_metaData);
    }

    public String getXMLMetaData() {
        return xml;
    }

    @Override
    public String getName() {
        if (_metaData instanceof HelioviewerMetaData) {
            return ((HelioviewerMetaData) _metaData).getFullName();
        } else {
            String name = uri.getPath();
            return name.substring(name.lastIndexOf('/') + 1, name.lastIndexOf('.'));
        }
    }

    @Override
    public URI getURI() {
        return uri;
    }

}

@@ -69,16 +69,57 @@
 t.URI;%0A%0A
+import org.helioviewer.jhv.base.lut.LUT;%0A
 import o
@@ -1552,10 +1552,212 @@
 %0A    %7D%0A%0A
+    @Override%0A    public LUT getDefaultLUT() %7B%0A        if (_metaData instanceof HelioviewerMetaData) %7B%0A            return LUT.get((HelioviewerMetaData) _metaData);%0A        %7D%0A        return null;%0A    %7D%0A%0A
 %7D%0A

Fix FITS LUT