All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.vectorpublish.desktop.vp.DefaultDocumentWriterImpl Maven / Gradle / Ivy

/*
 * Copyright (c) 2016, Peter Rader. All rights reserved.
 *  ___ ___               __                 ______         __     __  __         __
 * |   |   |.-----..----.|  |_ .-----..----.|   __ \.--.--.|  |--.|  ||__|.-----.|  |--.
 * |   |   ||  -__||  __||   _||  _  ||   _||    __/|  |  ||  _  ||  ||  ||__ --||     |
 *  \_____/ |_____||____||____||_____||__|  |___|   |_____||_____||__||__||_____||__|__|
 *
 * http://www.gnu.org/licenses/gpl-3.0.html
 */
package net.vectorpublish.desktop.vp;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

import javax.inject.Inject;
import javax.inject.Named;

import net.vectorpublish.desktop.vp.HistoryImpl.HistoryWriter;
import net.vectorpublish.desktop.vp.api.io.DocumentWriter;
import net.vectorpublish.desktop.vp.api.io.DrawArea;
import net.vectorpublish.desktop.vp.api.vpd.DocumentNode;
import net.vectorpublish.desktop.vp.io.VPFileReader;

/**
 * The writer for the {@link VPFileReader reader}.
 */
@Named
public class DefaultDocumentWriterImpl implements DocumentWriter {

	@Inject
	private final HistoryImpl history = null;

	@Override
	public void write(File f, DocumentNode doc) throws IOException {
		final FileOutputStream fos = new FileOutputStream(f);
		final ObjectOutputStream os = new ObjectOutputStream(fos);
		os.writeUTF("VPD");
		final DrawArea d = (DrawArea) doc.getParticipant();
		os.writeInt(d.getDimensions().width);
		os.writeInt(d.getDimensions().height);
		final HistoryWriter hw = history.new HistoryWriter(os);
		hw.writeHistorySteps(doc);
		os.close();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy