<commit_before>package org.helioviewer.jhv.plugins.eve.radio;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.DataBufferByte;
import java.awt.image.Raster;

import org.helioviewer.jhv.base.Region;
import org.helioviewer.jhv.base.logging.Log;
import org.helioviewer.jhv.base.time.TimeUtils;
import org.helioviewer.jhv.timelines.draw.DrawController;
import org.helioviewer.jhv.timelines.draw.TimeAxis;
import org.helioviewer.jhv.timelines.draw.YAxis;
import org.helioviewer.jhv.viewmodel.imagedata.ImageData;
import org.helioviewer.jhv.viewmodel.imagedata.ImageDataHandler;
import org.helioviewer.jhv.viewmodel.imagedata.SingleChannelByte8ImageData;
import org.helioviewer.jhv.viewmodel.metadata.XMLMetaDataContainer;
import org.helioviewer.jhv.viewmodel.view.jp2view.JP2ViewCallisto;
import org.helioviewer.jhv.viewmodel.view.jp2view.image.ResolutionSet;

class DownloadedJPXData implements ImageDataHandler {

    private JP2ViewCallisto view;

    private long startDate;
    private long endDate;
    private double startFreq;
    private double endFreq;
    private int jp2Width;
    private int jp2Height;

    private BufferedImage bufferedImage;
    private Region region;
    private boolean downloadJPXFailed = false;

    public DownloadedJPXData(JP2ViewCallisto _view, long start) {
        if (_view != null) { // null for empty
            try {
                ResolutionSet.ResolutionLevel resLevel = _view.getResolutionLevel(0, 0);
                jp2Width = resLevel.width;
                jp2Height = resLevel.height;

                XMLMetaDataContainer hvMetaData = new XMLMetaDataContainer();

                hvMetaData.parseXML(_view.getXMLMetaData());
                endFreq = hvMetaData.tryGetDouble("STARTFRQ");
                startFreq = hvMetaData.tryGetDouble("END-FREQ");
                startDate = TimeUtils.parse(hvMetaData.get("DATE-OBS"));
                endDate = TimeUtils.parse(hvMetaData.get("DATE-END"));
                hvMetaData.destroyXML();

                if (startDate == start && endDate <= start + TimeUtils.DAY_IN_MILLIS) {
                    view = _view;
                    view.setDataHandler(this);
                    return;
                }
            } catch (Exception e) {
                Log.error("Some of the metadata could not be read: " + _view.getURI() + " " + e);
            }
            _view.abolish();
        }<commit_msg>Optional get for radio metadata<commit_after>package org.helioviewer.jhv.plugins.eve.radio;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.DataBufferByte;
import java.awt.image.Raster;

import org.helioviewer.jhv.base.Region;
import org.helioviewer.jhv.base.logging.Log;
import org.helioviewer.jhv.base.time.TimeUtils;
import org.helioviewer.jhv.timelines.draw.DrawController;
import org.helioviewer.jhv.timelines.draw.TimeAxis;
import org.helioviewer.jhv.timelines.draw.YAxis;
import org.helioviewer.jhv.viewmodel.imagedata.ImageData;
import org.helioviewer.jhv.viewmodel.imagedata.ImageDataHandler;
import org.helioviewer.jhv.viewmodel.imagedata.SingleChannelByte8ImageData;
import org.helioviewer.jhv.viewmodel.metadata.MetaDataException;
import org.helioviewer.jhv.viewmodel.metadata.XMLMetaDataContainer;
import org.helioviewer.jhv.viewmodel.view.jp2view.JP2ViewCallisto;
import org.helioviewer.jhv.viewmodel.view.jp2view.image.ResolutionSet;

class DownloadedJPXData implements ImageDataHandler {

    private JP2ViewCallisto view;

    private long startDate;
    private long endDate;
    private double startFreq;
    private double endFreq;
    private int jp2Width;
    private int jp2Height;

    private BufferedImage bufferedImage;
    private Region region;
    private boolean downloadJPXFailed = false;

    public DownloadedJPXData(JP2ViewCallisto _view, long start) {
        if (_view != null) { // null for empty
            try {
                ResolutionSet.ResolutionLevel resLevel = _view.getResolutionLevel(0, 0);
                jp2Width = resLevel.width;
                jp2Height = resLevel.height;

                XMLMetaDataContainer hvMetaData = new XMLMetaDataContainer();

                hvMetaData.parseXML(_view.getXMLMetaData());
                endFreq = hvMetaData.getDouble("STARTFRQ").orElseThrow(MetaDataException::new);
                startFreq = hvMetaData.getDouble("END-FREQ").orElseThrow(MetaDataException::new);
                startDate = TimeUtils.parse(hvMetaData.getString("DATE-OBS").orElseThrow(MetaDataException::new));
                endDate = TimeUtils.parse(hvMetaData.getString("DATE-END").orElseThrow(MetaDataException::new));
                hvMetaData.destroyXML();

                if (startDate == start && endDate <= start + TimeUtils.DAY_IN_MILLIS) {
                    view = _view;
                    view.setDataHandler(this);
                    return;
                }
            } catch (Exception e) {
                Log.error("Some of the metadata could not be read: " + _view.getURI() + " " + e);
            }
            _view.abolish();
        }
{'fraction_non_alphanumeric': 0.09664876874652842, 'fraction_numerical': 0.0051842251434919455, 'mean_word_length': 3.0014814814814814, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6540737', 'n_tokens_mistral': 1747, 'n_tokens_neox': 1665, 'n_words': 280}