package simulator.interfaces.html; import java.util.HashMap; import java.util.Map; import models.algebra.Constant; import models.dataConstraintModel.MapTerm; public class HtmlElement { private final String type; private final String id; private String text; private Map<String, String> styles; //多分ここにもwebsocketのインスタンスが必要になりそう? //styleなどが変更されたときに通知しなければならないから //それかそれぞれのreceiverのほうにその処理を作るか HtmlElement(String type, String id, String text){ this.type = type; this.id = id; this.text = text; styles = new HashMap<>(); } public void setStyle(String property, String value) { styles.put(property, value); } public void resetStyle(String property) { styles.remove(property); } public MapTerm toMap() { MapTerm res = new MapTerm(); res.insert("type", new Constant(type)); res.insert("id", new Constant(id)); res.insert("text", new Constant(text)); MapTerm stylesMap = new MapTerm(); for(String prop : styles.keySet()) { stylesMap.insert(prop, new Constant(styles.get(prop))); } res.insert("styles", stylesMap); return res; } public String getType() { return type; } public String getId() { return id; } public String getText() { return text; } public void setText(String text) { this.text = text; } }