class PreviewUIModelImpl implements PreviewUIModel {

    private final PreviewModel previewModel;
    //Data
    private float visibilityRatio = 1f;
    private PreviewPreset currentPreset;
    private boolean refreshing;

    public PreviewUIModelImpl(PreviewModel model) {
        previewModel = model;

        if (UIUtils.isDarkLookAndFeel()) {
            currentPreset = new BlackBackground();
        } else {
            currentPreset = new DefaultPreset();
        }
        model.getProperties().applyPreset(currentPreset);
    }

    @Override
    public PreviewModel getPreviewModel() {
        return previewModel;
    }

    @Override
    public Workspace getWorkspace() {
        return previewModel.getWorkspace();
    }

    @Override
    public PreviewPreset getCurrentPreset() {
        return currentPreset;
    }

    public void setCurrentPreset(PreviewPreset preset) {
        currentPreset = preset;
    }

    @Override
    public float getVisibilityRatio() {
        return visibilityRatio;
    }

    public void setVisibilityRatio(float visibilityRatio) {
        this.visibilityRatio = visibilityRatio;
    }

    @Override
    public boolean isRefreshing() {
        return refreshing;
    }

    public void setRefreshing(boolean refreshing) {
        this.refreshing = refreshing;
    }

    private void setCurrentPresetBasedOnString(String className, String displayName) {
        // Retrieve preset, either default (by class) or user (by name)
        PreviewUIController controller = Lookup.getDefault().lookup(PreviewUIController.class);
        PreviewPreset[] defaultPresets = controller.getDefaultPresets();
        Optional<PreviewPreset> preset =
            Arrays.stream(defaultPresets).filter(p -> p.getClass().getName().equals(className)).findFirst();
        if (preset.isPresent()) {
            setCurrentPreset(preset.get());
        } else {
            PreviewPreset[] userPresets = controller.getUserPresets();
            preset = Arrays.stream(userPresets).filter(p -> p.getName().equals(displayName)).findFirst();
            preset.ifPresent(this::setCurrentPreset);
        }
    }

    protected void writeXML(XMLStreamWriter writer) throws XMLStreamException {
        if (currentPreset != null) {
            writer.writeStartElement("currentpreset");
            writer.writeAttribute("class", currentPreset.getClass().getName());
            writer.writeAttribute("name", currentPreset.getName());
            writer.writeEndElement();
        }
        writer.writeStartElement("visibilityratio");
        writer.writeAttribute("value", visibilityRatio + "");
        writer.writeEndElement();
    }

    protected void readXML(XMLStreamReader reader) throws XMLStreamException {<FILL_FUNCTION_BODY>}
}

        boolean end = false;
        while (reader.hasNext() && !end) {
            int type = reader.next();

            switch (type) {
                case XMLStreamReader.START_ELEMENT:
                    String name = reader.getLocalName();
                    if ("currentpreset".equalsIgnoreCase(name)) {
                        String presetClass = reader.getAttributeValue(null, "class");
                        String presetName = reader.getAttributeValue(null, "name");

                        setCurrentPresetBasedOnString(presetClass, presetName);
                    } else if ("visibilityratio".equalsIgnoreCase(name)) {
                        String value = reader.getAttributeValue(null, "value");
                        visibilityRatio = Float.parseFloat(value);
                    }
                    break;
                case XMLStreamReader.CHARACTERS:
                    break;
                case XMLStreamReader.END_ELEMENT:
                    if ("previewuimodel".equalsIgnoreCase(reader.getLocalName())) {
                        end = true;
                    }
                    break;
            }
        }
    
<no_super_class>