<commit_before>/*
 * Copyright (C) 2017 TypeFox and others.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
 */
package io.typefox.sprotty.api

import java.util.List
import java.util.function.Consumer
import org.eclipse.xtend.lib.annotations.Accessors
import org.eclipse.xtend.lib.annotations.ToString

/**
 * Base class for all elements of the diagram model. This is a Java representation of the TypeScript
 * interface {@code SModelElementSchema}, so it is meant to be serialized to JSON so it can be
 * transferred to the client.
 * Each model element must have a unique ID and a type that is used to look up its view.
 */
@Accessors
@ToString(skipNulls = true)
abstract class SModelElement {
	String type
	String id
	List<SModelElement> children
	
	new() {}
	new(Consumer<SModelElement> initializer) {
		initializer.accept(this)
	}
}

/**
 * Base class for the root element of the diagram model tree.
 */
@Accessors
@ToString(skipNulls = true)
class SModelRoot extends SModelElement {
	Bounds canvasBounds
	
	new() {}
	new(Consumer<SModelRoot> initializer) {
		initializer.accept(this)
	}
}

/**
 * Root element for graph-like models.
 */
@Accessors
@ToString(skipNulls = true)
class SGraph extends SModelRoot implements BoundsAware {
	Point position
	Dimension size
	LayoutOptions layoutOptions

	new() {}
	new(Consumer<SGraph> initializer) {
		initializer.accept(this)
	}
}

/**
 * Model element class for nodes, which are connectable entities in a graph. A node can be connected to
 * another node via an SEdge. Such a connection can be direct, i.e. the node is the source or target of
 * the edge, or indirect through a port, i.e. it contains an SPort which is the source or target of the edge.
 */
@Accessors
@ToString(skipNulls = true)
class SNode extends SModelElement implements BoundsAware  {
	Point position
	Dimension size
	String layout
	LayoutOptions layoutOptions
	
	new() {}
	new(Consumer<SNode> initializer) {
		initializer.accept(this)
	}
}

/**
 * A port is a connection point for edges. It should always be contained in an SNode.
 */
@Accessors
@ToString(skipNulls = true)
class SPort extends SModelElement implements BoundsAware  {
	Point position
	Dimension size
	LayoutOptions layoutOptions
	
	new() {}
	new(Consumer<SPort> initializer) {
		initializer.accept(this)
	}
}

/**
 * Model element class for edges, which are the connectors in a graph. An edge has a source and a target,
 * each of which can be either a node or a port. The source and target elements are referenced via their
 * ids and can be resolved with an {@link SModelIndex}.
 */
@Accessors
@ToString(skipNulls = true)
class SEdge extends SModelElement {
	String sourceId
	String targetId
	List<Point> routingPoints
	
	new() {}
	new(Consumer<SEdge> initializer) {
		initializer.accept(this)
	}
}

/**
 * A label can be attached to a node, edge, or port, and contains some text to be rendered in its view.
 */
@Accessors
@ToString(skipNulls = true)
class SLabel extends SModelElement implements BoundsAware, Alignable {
	Point position
	Dimension size
	String text
	Point alignment
	LayoutOptions layoutOptions
	
	new() {}
	new(Consumer<SLabel> initializer) {
		initializer.accept(this)
	}
}

/**
 * A compartment is used to group multiple child elements such as labels of a node. Usually a {@code vbox}
 * or {@code hbox} layout is used to arrange these children.
 */
@Accessors
@ToString(skipNulls = true)
class SCompartment extends SModelElement implements BoundsAware {
	Point position
	Dimension size
	String layout
	LayoutOptions layoutOptions
	
	new() {}
	new(Consumer<SCompartment> initializer) {
		initializer.accept(this)
	}
}

/**
 * Options for client-side layout. This is a union of the different client layout option types,
 * e.g. VBoxLayoutOptions or StackLayoutOptions. It is not used for server layout, which is configured
 * directly in {@link ILayoutEngine} implementations.
 */
@Accessors
@ToString(skipNulls = true)
class LayoutOptions {
	Double paddingLeft	<commit_msg>[server] added button model<commit_after>/*
 * Copyright (C) 2017 TypeFox and others.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
 */
package io.typefox.sprotty.api

import java.util.List
import java.util.function.Consumer
import org.eclipse.xtend.lib.annotations.Accessors
import org.eclipse.xtend.lib.annotations.ToString

/**
 * Base class for all elements of the diagram model. This is a Java representation of the TypeScript
 * interface {@code SModelElementSchema}, so it is meant to be serialized to JSON so it can be
 * transferred to the client.
 * Each model element must have a unique ID and a type that is used to look up its view.
 */
@Accessors
@ToString(skipNulls = true)
abstract class SModelElement {
	String type
	String id
	List<SModelElement> children
	
	new() {}
	new(Consumer<SModelElement> initializer) {
		initializer.accept(this)
	}
}

/**
 * Base class for the root element of the diagram model tree.
 */
@Accessors
@ToString(skipNulls = true)
class SModelRoot extends SModelElement {
	Bounds canvasBounds
	
	new() {}
	new(Consumer<SModelRoot> initializer) {
		initializer.accept(this)
	}
}

/**
 * Root element for graph-like models.
 */
@Accessors
@ToString(skipNulls = true)
class SGraph extends SModelRoot implements BoundsAware {
	Point position
	Dimension size
	LayoutOptions layoutOptions

	new() {}
	new(Consumer<SGraph> initializer) {
		initializer.accept(this)
	}
}

/**
 * Model element class for nodes, which are connectable entities in a graph. A node can be connected to
 * another node via an SEdge. Such a connection can be direct, i.e. the node is the source or target of
 * the edge, or indirect through a port, i.e. it contains an SPort which is the source or target of the edge.
 */
@Accessors
@ToString(skipNulls = true)
class SNode extends SModelElement implements BoundsAware  {
	Point position
	Dimension size
	String layout
	LayoutOptions layoutOptions
	
	new() {}
	new(Consumer<SNode> initializer) {
		initializer.accept(this)
	}
}

/**
 * A port is a connection point for edges. It should always be contained in an SNode.
 */
@Accessors
@ToString(skipNulls = true)
class SPort extends SModelElement implements BoundsAware  {
	Point position
	Dimension size
	LayoutOptions layoutOptions
	
	new() {}
	new(Consumer<SPort> initializer) {
		initializer.accept(this)
	}
}

/**
 * Model element class for edges, which are the connectors in a graph. An edge has a source and a target,
 * each of which can be either a node or a port. The source and target elements are referenced via their
 * ids and can be resolved with an {@link SModelIndex}.
 */
@Accessors
@ToString(skipNulls = true)
class SEdge extends SModelElement {
	String sourceId
	String targetId
	List<Point> routingPoints
	
	new() {}
	new(Consumer<SEdge> initializer) {
		initializer.accept(this)
	}
}

/**
 * A label can be attached to a node, edge, or port, and contains some text to be rendered in its view.
 */
@Accessors
@ToString(skipNulls = true)
class SLabel extends SModelElement implements BoundsAware, Alignable {
	Point position
	Dimension size
	String text
	Point alignment
	LayoutOptions layoutOptions
	
	new() {}
	new(Consumer<SLabel> initializer) {
		initializer.accept(this)
	}
}

/**
 * A compartment is used to group multiple child elements such as labels of a node. Usually a {@code vbox}
 * or {@code hbox} layout is used to arrange these children.
 */
@Accessors
@ToString(skipNulls = true)
class SCompartment extends SModelElement implements BoundsAware {
	Point position
	Dimension size
	String layout
	LayoutOptions layoutOptions
	
	new() {}
	new(Consumer<SCompartment> initializer) {
		initializer.accept(this)
	}
}

/**
 * A compartment is used to group multiple child elements such as labels of a node. Usually a {@code vbox}
 * or {@code hbox} layout is used to arrange these children.
 */
@Accessors
@ToString(skipNulls = true)
class SButton extends SModelElement implements BoundsAware {
	Point position
	Dimension size
	Boolean enabled
	
	new() {}
	new(Consumer<SButton> initializer) {
		initializer.accept(this)
	}
}

/**
 * Options for client-side layout. This is a union of the different client layout option types,
 * e.g. VBoxLayoutOptions or StackLayoutOptions. It is not used for server layout, which is configured
 * directly in {@link ILayoutEngine} implementations.
 */
@Accessors
@ToString(skipNulls = true)
class LayoutOptions {
	Double paddingLeft	
{'fraction_non_alphanumeric': 0.08161630036630037, 'fraction_numerical': 0.0018315018315018315, 'mean_word_length': 4.2727821363910685, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4370504', 'n_tokens_mistral': 2598, 'n_tokens_neox': 2535, 'n_words': 1021}