<commit_before><!DOCTYPE html>

<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">

	<title>Gwt editing javascript - Showcase</title>

	<link href='http://fonts.googleapis.com/css?family=Exo+2:400,300' rel='stylesheet' type='text/css'>

	<link href="../css/style.css" rel="stylesheet" type="text/css">
	<link href="../css/mqueries.css" rel="stylesheet" type="text/css" media="screen">

	<script src="../js/jquery.modernizr.min.js"></script>

	<script type="text/javascript">var isomorphicDir = "../showcase/sc/";</script>
	<script type="text/javascript" src="../showcase/showcase.nocache.js"></script>

	</head>

<body>

<div id="page">

	<header id="header" class="wrapper">

		<div class="header_tagline">
			<h3>Right-mouse context menu.</h3>
			<h4>
				It is possible to add a list of context menu actions to vertices/edges. 
				<br>
				An action can be selected by right-clicking on a vertex/edge and selecting it from the menu.
			</h4>
		</div>

	</header>

	<section id="main">

		<div class="main_inner wrapper clearfix">

 			<ul class="filter">
				<li id="drawPolygon">
					<a href="#">Draw Polygon</a>
				</li>
			</ul>

			<div class="columnsection">

				<div class="column one_half">

					<div id="js-map-element">
						<!-- on load, the map is attached here -->
					</div>

				</div>

				<div class="column one_half">

					<h4>Log:</h4>
					<ul id="log"></ul>

				</div>

			</div>

		</div><!-- END main inner -->

	</section><!-- END #content -->

</div><!-- END #page -->

	<script src="../js/jquery-1.7.1.min.js"></script>

	<script>

		var map; // The map object.
		var editor; // Geometry editor. Holds the central editing service, the renderer, the styling information...
		var service; // The central editing service.
		var factory; // GeometryHandlerFactory for deleting rings
		var deleteFromPoint; // HandlerRegistration for delete from point
		var infoHandler; // HandlerRegistration for delete from point
		var infoHandlerWithHtmlCallback; // HandlerRegistration for delete from point
		var labelHandler; // HandlerRegistration for delete from point
		var labelFlag = false;
		var infoFlag = false;
		var styleService;
		
		
		function deleteVertex(context) {
			context.getService().remove([context.getIndex()]);
			log("Deleted vertex " + context.getIndex())
		}
		            
		function deselectObject(context) {
			context.getService().getIndexStateService().deselect([context.getIndex()]);
			log("Deselected vertex " + context.getIndex())
		}
		
		function zoomIn(context) {
			var position = context.getService().getIndexService().getVertex(context.getService().getGeometry(), context.getIndex());
			var scale = context.getMap().getViewPort().getScale();
			context.getMap().getViewPort().applyScale(2.0 * scale, position);
			position = context.getService().getIndexService().getVertex(context.getService().getGeometry(), context.getIndex());
			scale = context.getMap().getViewPort().getScale();
			log("Zoomed in to vertex " + context.getIndex() + ", scale = " + scale + ",pos = " + position);
		}
		
		function zoomOut(context) {
			var position = context.getService().getIndexService().getVertex(context.getService().getGeometry(), context.getIndex());
			var scale = context.getMap().getViewPort().getScale();
			context.getMap().getViewPort().applyScale(0.5 * scale, position);
			position = context.getService().getIndexService().getVertex(context.getService().getGeometry(), context.getIndex());
			scale = context.getMap().getViewPort().getScale();
			log("Zoomed out to vertex " + context.getIndex() + ", scale = " + scale + ",pos = " + position);
		}
		
		function zoomObject(context) {
			var bbox = Geomajas().getGeometryService().getBounds(context.getService().getGeometry());
			context.getMap().getViewPort().applyBounds(bbox);
			log("Zoomed to object, bbox = " + bbox);
		}
		
		function deleteEdge(context) {
			var prev = context.getService().getIndexService().getPreviousVertex(context.getIndex());
			var next = context.getService().getIndexService().getNextVertex(context.getIndex());
			context.getService().remove([prev, next]);
			log("Deleted edge " + context.getIndex());
		}
		
		function zoomEdge(context) {
			var edge = context.getService().getIndexService().getEdge(context.getService().getGeometry(), context.getIndex());
			var bbox = org.geomajas.jsapi.spatial.Bbox(Math.min(edge[0].getX(),edge[1].getX()), Math.min(edge[0].getY(),edge[1].getY()), 
					Math.abs(edge[1].getX() - edge[0].getX()), Math.abs(edge[1].getY() - edge[0].getY()));
			context.getMap().getViewPort().applyBounds(bbox);
			log("Zoomed to edge, bbox = " + bbox);
		}
		 

		function onGeomajasLoad() {
			map = Geomajas().createMap("app", "mapMain", "js-map-element");
			map.setDefaultCursor('crosshair');
			editor = new org.geomajas.plugin.editing.GeometryEditor();
			editor.setMap(map);
			service = editor.getService();
			styleService = editor.getStyleService();
			// customize context menu when vertex is selected
			var contextMenuRegistry = new org.geomajas.plugin.editing.contextmenu.GeometryContextMenuRegistry(map, editor);
			contextMenuRegistry.addVertexAction(deleteVertex,"delete");
			contextMenuRegistry.addVertexAction(deselectObject,"deselect");
			contextMenuRegistry.addVertexAction(zoomIn,"zoom in");
			contextMenuRegistry.addVertexAction(zoomOut,"zoom out");
			contextMenuRegistry.addEdgeAction(deleteEdge,"delete");
			contextMenuRegistry.addEdgeAction(zoomEdge,"zoom to edge");
			contextMenuRegistry.addGeometryAction(zoomObject,"zoom to full geometry");
		}
		
		function drawPolygon() {
			service.stop();

			styleService.getVertexStyle().setFillColor("blue");
			styleService.getEdgeStyle().setStrokeColor("red");
			styleService.getPointSymbolizerShapeAndSize().setShape("square");
			styleService.getPointSymbolizerShapeAndSize().setSize(12);
			styleService.setCloseRingWhileInserting(true);

			var geometry = new org.geomajas.jsapi.spatial.Geometry("Polygon", 0, 0);
			service.start(geometry);

			service.addEmptyChild();
			var index = service.getIndexService().create("vertex", [0, 0]);
			service.setInsertIndex(index);
			service.setEditingState("inserting");
		}

		$('#drawPolygon').click(function(){
			$(this).addClass('active');
			drawPolygon();
		});


		function log(txt) {
			while($('#log')[0].scrollHeight >= $('#js-map-element').height() - 100) {
				$('#log li:last-child').remove();
			}

			$('#log li').removeClass('first-log-item');
			$("#log").prepend("<li class='first-log-item log-item'>" + txt  + "</li>");
		}

	</script>

</body>

</html><commit_msg>GEP-67: delete edge does not work, skip for now...<commit_after><!DOCTYPE html>

<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">

	<title>Gwt editing javascript - Showcase</title>

	<link href='http://fonts.googleapis.com/css?family=Exo+2:400,300' rel='stylesheet' type='text/css'>

	<link href="../css/style.css" rel="stylesheet" type="text/css">
	<link href="../css/mqueries.css" rel="stylesheet" type="text/css" media="screen">

	<script src="../js/jquery.modernizr.min.js"></script>

	<script type="text/javascript">var isomorphicDir = "../showcase/sc/";</script>
	<script type="text/javascript" src="../showcase/showcase.nocache.js"></script>

	</head>

<body>

<div id="page">

	<header id="header" class="wrapper">

		<div class="header_tagline">
			<h3>Right-mouse context menu.</h3>
			<h4>
				It is possible to add a list of context menu actions to vertices/edges. 
				<br>
				An action can be selected by right-clicking on a vertex/edge and selecting it from the menu.
			</h4>
		</div>

	</header>

	<section id="main">

		<div class="main_inner wrapper clearfix">

 			<ul class="filter">
				<li id="drawPolygon">
					<a href="#">Draw Polygon</a>
				</li>
			</ul>

			<div class="columnsection">

				<div class="column one_half">

					<div id="js-map-element">
						<!-- on load, the map is attached here -->
					</div>

				</div>

				<div class="column one_half">

					<h4>Log:</h4>
					<ul id="log"></ul>

				</div>

			</div>

		</div><!-- END main inner -->

	</section><!-- END #content -->

</div><!-- END #page -->

	<script src="../js/jquery-1.7.1.min.js"></script>

	<script>

		var map; // The map object.
		var editor; // Geometry editor. Holds the central editing service, the renderer, the styling information...
		var service; // The central editing service.
		var factory; // GeometryHandlerFactory for deleting rings
		var deleteFromPoint; // HandlerRegistration for delete from point
		var infoHandler; // HandlerRegistration for delete from point
		var infoHandlerWithHtmlCallback; // HandlerRegistration for delete from point
		var labelHandler; // HandlerRegistration for delete from point
		var labelFlag = false;
		var infoFlag = false;
		var styleService;
		
		
		function deleteVertex(context) {
			context.getService().remove([context.getIndex()]);
			log("Deleted vertex " + context.getIndex())
		}
		            
		function deselectObject(context) {
			context.getService().getIndexStateService().deselect([context.getIndex()]);
			log("Deselected vertex " + context.getIndex())
		}
		
		function zoomIn(context) {
			var position = context.getService().getIndexService().getVertex(context.getService().getGeometry(), context.getIndex());
			var scale = context.getMap().getViewPort().getScale();
			context.getMap().getViewPort().applyScale(2.0 * scale, position);
			position = context.getService().getIndexService().getVertex(context.getService().getGeometry(), context.getIndex());
			scale = context.getMap().getViewPort().getScale();
			log("Zoomed in to vertex " + context.getIndex() + ", scale = " + scale + ",pos = " + position);
		}
		
		function zoomOut(context) {
			var position = context.getService().getIndexService().getVertex(context.getService().getGeometry(), context.getIndex());
			var scale = context.getMap().getViewPort().getScale();
			context.getMap().getViewPort().applyScale(0.5 * scale, position);
			position = context.getService().getIndexService().getVertex(context.getService().getGeometry(), context.getIndex());
			scale = context.getMap().getViewPort().getScale();
			log("Zoomed out to vertex " + context.getIndex() + ", scale = " + scale + ",pos = " + position);
		}
		
		function zoomObject(context) {
			var bbox = Geomajas().getGeometryService().getBounds(context.getService().getGeometry());
			context.getMap().getViewPort().applyBounds(bbox);
			log("Zoomed to object, bbox = " + bbox);
		}
				
		function zoomEdge(context) {
			var edge = context.getService().getIndexService().getEdge(context.getService().getGeometry(), context.getIndex());
			var bbox = org.geomajas.jsapi.spatial.Bbox(Math.min(edge[0].getX(),edge[1].getX()), Math.min(edge[0].getY(),edge[1].getY()), 
					Math.abs(edge[1].getX() - edge[0].getX()), Math.abs(edge[1].getY() - edge[0].getY()));
			context.getMap().getViewPort().applyBounds(bbox);
			log("Zoomed to edge, bbox = " + bbox);
		}

		function onGeomajasLoad() {
			map = Geomajas().createMap("app", "mapMain", "js-map-element");
			map.setDefaultCursor('crosshair');
			editor = new org.geomajas.plugin.editing.GeometryEditor();
			editor.setMap(map);
			service = editor.getService();
			styleService = editor.getStyleService();
			// customize context menu when vertex is selected
			var contextMenuRegistry = new org.geomajas.plugin.editing.contextmenu.GeometryContextMenuRegistry(map, editor);
			contextMenuRegistry.addVertexAction(deleteVertex,"delete");
			contextMenuRegistry.addVertexAction(deselectObject,"deselect");
			contextMenuRegistry.addVertexAction(zoomIn,"zoom in");
			contextMenuRegistry.addVertexAction(zoomOut,"zoom out");
			contextMenuRegistry.addEdgeAction(zoomEdge,"zoom to edge");
			contextMenuRegistry.addGeometryAction(zoomObject,"zoom to full geometry");
		}
		
		function drawPolygon() {
			service.stop();

			styleService.getVertexStyle().setFillColor("blue");
			styleService.getEdgeStyle().setStrokeColor("red");
			styleService.getPointSymbolizerShapeAndSize().setShape("square");
			styleService.getPointSymbolizerShapeAndSize().setSize(12);
			styleService.setCloseRingWhileInserting(true);

			var geometry = new org.geomajas.jsapi.spatial.Geometry("Polygon", 0, 0);
			service.start(geometry);

			service.addEmptyChild();
			var index = service.getIndexService().create("vertex", [0, 0]);
			service.setInsertIndex(index);
			service.setEditingState("inserting");
		}

		$('#drawPolygon').click(function(){
			$(this).addClass('active');
			drawPolygon();
		});


		function log(txt) {
			while($('#log')[0].scrollHeight >= $('#js-map-element').height() - 100) {
				$('#log li:last-child').remove();
			}

			$('#log li').removeClass('first-log-item');
			$("#log").prepend("<li class='first-log-item log-item'>" + txt  + "</li>");
		}

	</script>

</body>

</html>
{'fraction_non_alphanumeric': 0.17360267314702307, 'fraction_numerical': 0.006682867557715674, 'mean_word_length': 4.364154786150713, 'pattern_counts': {'":': 0, '<': 131, '<?xml version=': 0, '>': 133, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1378084', 'n_tokens_mistral': 4669, 'n_tokens_neox': 4031, 'n_words': 793}