@Override public void updated(PropertyUpdateEvent<PPath> e) { switch (e.key) { case SNAP_X: gridVisual.setWidth((Integer) path.get(PPath.SNAP_X)); repaint(); break; case SNAP_Y: gridVisual.setHeight((Integer) path.get(PPath.SNAP_Y)); repaint(); break; case PRECISION: for (SmoothPathSegment s : spsMap.values()) s.validate(); arrow.validate(); break; case CLOSED: case SMOOTH: // TODO: Optimize updatePointList(); break; case BACKGROUND_ROOM: ResourceReference<Room> r = path.get(PPath.BACKGROUND_ROOM); setRoom(r == null ? null : r.get()); } }
public PathEditor(Path p) { enableEvents(AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK); properties = new PropertyMap<PPathEditor>(PPathEditor.class, pepv, DEFS); binVisual = new BinVisual(container, 128, 512, 512); put(BIN_LAYER, binVisual); int sx = p.get(PPath.SNAP_X); int sy = p.get(PPath.SNAP_Y); gridVisual = new GridVisual(false, sx, sy); put(GRID_LAYER, gridVisual); path = p; path.reference.updateSource.addListener(this); path.properties.updateSource.addListener(ppl); path.points.updateSource.addListener(pll); int s = path.points.size(); pvList = new ArrayList<PointVisual>(s); pvMap = new HashMap<PathPoint, PointVisual>(Math.max((int) (s / .75f) + 1, 16)); updatePointList(); ResourceReference<Room> r = path.get(PPath.BACKGROUND_ROOM); setRoom(r == null ? null : r.get()); }