package org.ndexbio.cx2.aspect.element.core;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;

public class VisualPropertyTable {
	
	private Map<String, Object> visualProperties;
	
	private static final String imagePositionPattern = "^NODE_IMAGE_[0-9]+_POSITION$";
	
	@JsonAnyGetter
	public Map<String, Object> getVisualProperties() {
		return visualProperties;
	}
	
	@JsonAnySetter
	public void addRaw(String key, Object e) {
		if 	( e instanceof Map<?,?>) {
			if (key.equals("EDGE_LABEL_FONT_FACE") ||
					key.equals("NODE_LABEL_FONT_FACE")) {
				visualProperties.put(key, FontFace.createFromMap((Map<String,String>)e));
			} else if ( key.equals("NODE_LABEL_POSITION")) {
				visualProperties.put(key,LabelPosition.createFromMap((Map<String,Object>)e));
			} else if ( key.matches(imagePositionPattern)) {
				visualProperties.put(key, ObjectPosition.createFromMap((Map<String,Object>)e));
			} else 
				visualProperties.put(key, e);
		} else if ( e instanceof List<?>) {
			if ( key.equals("EDGE_CONTROL_POINTS")) {
				List<Map<String,Object>> rawPoints = (List<Map<String,Object>>)e;
				visualProperties.put(key, 
						rawPoints.stream()
						.map(p -> { return EdgeControlPoint.createFromMap(p);})
						.collect(Collectors.toList()));
			} else
				visualProperties.put(key, e);
		} else 
		   visualProperties.put(key,e);
	}

	public VisualPropertyTable() {
		visualProperties = new HashMap<>();
	}
	
	@JsonIgnore() 
	public Object get(String visualPropertyName) {
		return visualProperties.get(visualPropertyName);
	}
	
}

@@ -398,22 +398,21 @@
 es;%0A%09%0A%09p
-rivate
+ublic
  static 

Change the imagePositionPattern to public.