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

net.vectorpublish.desktop.vp.split.SplitStep Maven / Gradle / Ivy

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

import java.util.List;

import net.vectorpublish.desktop.vp.History;
import net.vectorpublish.desktop.vp.History.HistoryStep;
import net.vectorpublish.desktop.vp.api.vpd.ModificationContext;
import net.vectorpublish.desktop.vp.api.vpd.ModificationContext.LayerNodeImpl;
import net.vectorpublish.desktop.vp.api.vpd.VectorPublishNode;
import net.vectorpublish.desktop.vp.split.bean.SplitData;

public class SplitStep extends HistoryStep {

	public SplitStep(History history, HistoryStep before, SplitData data) {
		history.super(before, data);
	}

	@Override
	protected void execute(ModificationContext ctx) {
		List indexs = data.getPath();
		VectorPublishNode parent = ctx.getDocument().findByIndex(indexs);
		if (parent instanceof LayerNodeImpl) {
			SplitNode sn = new SplitNode(ctx, (LayerNodeImpl) parent, data.getBorder(), data.getPercent(), data.isVertical());
			ctx.setSelection(sn);
		} else {
			SplitNode sn = new SplitNode(ctx, data.getBorder(), data.getPercent(), data.isVertical());
			ctx.setSelection(sn);
		}
	}

	@Override
	protected void rollback(ModificationContext ctx) {
		List indexs = data.getPath();
		VectorPublishNode parent = ctx.getDocument().findByIndex(indexs);
		SplitNode splitNode = (SplitNode) parent.getChildAt(parent.getChildCount()-1);
		splitNode.removeFromParent(ctx);
		ctx.setSelection(parent);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy