@Override protected void onCommand(Command c) throws IOException, UnableToExecuteException { // receives a command for notifying a user. for (String username : c.getProperty("notify.users").split(",")) { // user has to be a Person envobject, as we're using his property behavior for (EnvObjectLogic person : getApi().things().findByName(username)) { if (person instanceof GenericPerson) { MessageEvent mess = new MessageEvent(null, c.getProperty("push.message")); mess.setType("notify.user." + username); // insert command properties for (Entry<Object, Object> prop : c.getProperties().entrySet()) { mess.addProperty("reason." + prop.getKey().toString(), prop.getValue().toString()); } // enriches event and sent it to the user's message channel PropertiesBehaviorLogic props = (PropertiesBehaviorLogic) person.getBehavior("properties"); for (String prop : props.getPojo().getPropertiesName()) { mess.addProperty("user." + prop, props.getPojo().getProperty(prop)); } mess.addProperty("user.activity", person.getBehavior("activity").getValueAsString()); mess.addProperty("user.present", person.getBehavior("present").getValueAsString()); notifyEvent(mess); } } } // after that, we use reactions to define notification rules // like: if user (receives a message AND) is online -> speak the message loud // or: if user (receives a message AND) is offline -> send him a notification through his // preferred provider }
/** * @param obj * @return */ protected Shape getCachedShape(EnvObjectLogic obj) { if (cachedShapes.containsKey(obj.getPojo().getUUID())) { return cachedShapes.get(obj.getPojo().getUUID()); } else { return applyShapeModifiers(obj); } }
private Shape applyShapeModifiers(EnvObjectLogic object) { EnvObject obj = object.getPojo(); int x = obj.getCurrentRepresentation().getOffset().getX(); int y = obj.getCurrentRepresentation().getOffset().getY(); Shape shape = TopologyUtils.convertToAWT(obj.getShape()); shape = getTranslatedShape(shape, new Point(x, y)); shape = getRotatedShape(shape, obj.getCurrentRepresentation().getRotation()); cachedShapes.put(object.getPojo().getUUID(), shape); return shape; }
/** @param e */ @Override public void mouseReleased(MouseEvent e) { if (inDrag) { for (Handle handle : handles) { handle.setSelected(false); } // stop dragging an object if (objectEditMode && (selectedObject != null)) { Point coords = toRealCoords(e.getPoint()); selectedObject.setLocation( (int) (coords.getX() - dragDiff.getWidth()), (int) (coords.getY() - (int) dragDiff.getHeight())); } // check if rooms overlap if (roomEditMode && (selectedZone) != null) { setSelectedZone(selectedZone); } } inDrag = false; dragDiff = null; selectedObject = null; originalHandleLocation = null; // removeIndicators(); rebuildShapesCache(); setNeedRepaint(true); }