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

jadex.bpmn.model.io.SVisualWriterHelper Maven / Gradle / Ivy

The newest version!
package jadex.bpmn.model.io;

import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.io.PrintStream;
import java.util.Collection;

public class SVisualWriterHelper
{
	/**
	 *  Writes the start of the visual section.
	 *  @param out The stream.
	 */
	public static final void beginVisualSection(PrintStream out)
	{
		out.println(SBpmnModelWriter.getIndent(1) + "");
		out.println(SBpmnModelWriter.getIndent(2) + "");
	}
	
	/**
	 *  Writes a visual BPMN shape.
	 * 
	 * 	@param bpmnid ID of the BPMN element.
	 * 	@param bounds Bounds of the shape.
	 * 	@param altbounds Alternate bounds of the shape.
	 * 	@param intparams Parameters marked as internal.
	 *	@param expanded Flag if shape is expanded (can be null if not applicable)
	 * 	@param out The stream.
	 */
	public static final void writeBpmnShape(String bpmnid, Rectangle2D bounds, Rectangle2D altbounds, Collection intparams, Boolean expanded, PrintStream out)
	{
		out.print(SBpmnModelWriter.getIndent(3));
		out.print("");
		
		if (bounds != null)
		{
			out.print(SBpmnModelWriter.getIndent(4));
			out.print("");
		}
		
		if (altbounds != null)
		{
			out.print(SBpmnModelWriter.getIndent(4));
			out.print("");
		}
		
		if (intparams != null && intparams.size() > 0)
		{
			out.print(SBpmnModelWriter.getIndent(4));
			out.println("");
			for (String intparam : intparams)
			{
				out.print(SBpmnModelWriter.getIndent(5));
				out.print("");
				out.print(intparam);
				out.println("");
			}
			out.print(SBpmnModelWriter.getIndent(4));
			out.println("");
		}
		
		//FIXME: Necessary?
//		out.print(SBpmnModelWriter.getIndent(4));
//		out.println("");
		
		out.print(SBpmnModelWriter.getIndent(3));
		out.println("");
	}
	
	/**
	 *  Writes a visual edge.
	 * 	
	 * 	@param bpmnid ID of the BPMN edge element.
	 * 	@param dataedge Flag whether this is a data edge.
	 * 	@param points Control points, if any.
	 * 	@param out The stream
	 */
	public static final void writeEdge(String bpmnid, boolean dataedge, Collection points, PrintStream out)
	{
		String ns = "bpmndi";
		String tagname = "BPMNEdge";
		String refname = "bpmnElement";
		String typestring = "";
		if (dataedge)
		{
			ns = "di";
			tagname = "Edge";
			refname = "jadexElement";
			typestring = " type=\"data\"";
		}
		
		out.print(SBpmnModelWriter.getIndent(3));
		out.print("<" + ns + ":" + tagname + typestring + " " + refname + "=\"");
		out.print(bpmnid);
		out.println("\">");
		
		if (points != null)
		{
			for (Point2D point : points)
			{
				out.print(SBpmnModelWriter.getIndent(4));
				out.print("");
			}
		}
		
//		System.out.println(vmodel.getView().getState(edge).getLabelBounds());
		//FIXME: Necessary?
//		out.print(SBpmnModelWriter.getIndent(4));
//		out.println("");
		
		out.print(SBpmnModelWriter.getIndent(3));
		out.println("");
	}
	
	/**
	 *  Writes the end of the visual section.
	 *  @param out The stream.
	 */
	public static final void endVisualSection(PrintStream out)
	{
		out.println(SBpmnModelWriter.getIndent(2) + "");
		out.println(SBpmnModelWriter.getIndent(1) + "");
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy