Package it.freedomotic.model.object

Examples of it.freedomotic.model.object.EnvObject


     *
     * @param message
     */
    public static void message(String message) {
        Payload payload = FreedomoticStompHelper.parseMessage(message);
        final EnvObject obj = EnvironmentsController.getInstance().getObject(payload.getStatements("object.name").get(0).getValue());
//  //TODO: This way is not very efficient, as we are ignoring the message and retrieving the data again.
//    ObjectResourceProxy objectResource;   
//    final EnvObject new_obj;  
//   
//    objectResource = GWT.create(ObjectResourceProxy.class);
//    // Set up the contact resource
//    objectResource.getClientResource().setReference("v1/environment/objects/"+payload.getStatements("object.name").get(0).getValue());
//   
//    objectResource.retrieveObject(new Result<EnvObject>() {
//      public void onFailure(Throwable caught) {
//          //TODO: Handle the error
//      }      
//    @Override
//    public void onSuccess(EnvObject result) {
//      for (Behavior bh: obj.getBehaviors())
//      {                
//        Behavior resultBehavior = result.getBehavior(bh.getName());       
//        if (bh instanceof BooleanBehavior)
//        {         
//          ((BooleanBehavior) bh).setValue(((BooleanBehavior)resultBehavior).getValue());
//        }
//        else if (bh instanceof RangedIntBehavior)
//        {         
//          ((RangedIntBehavior) bh).setValue(((RangedIntBehavior)resultBehavior).getValue());
//        }
//        else if (bh instanceof ListBehavior)
//        {
//          ((ListBehavior) bh).setSelected(((ListBehavior)resultBehavior).getSelected()); 
//        }             
//      }
//      obj.setCurrentRepresentation(result.getCurrentRepresentationIndex());   
//    }
//    });

//  This should be the correct way, but the problem is with behavior linked changes. Review this way if the messages change

        Iterator it = payload.iterator();
        while (it.hasNext()) {
            Statement st = (Statement) it.next();
            if (st.getAttribute().equalsIgnoreCase("object.currentRepresentation")) {
                if (obj.getCurrentRepresentationIndex() != Integer.parseInt(st.getValue())) {
                    obj.setCurrentRepresentation(Integer.parseInt(st.getValue()));
                }
            } else if (st.getAttribute().startsWith("object.behavior")) {
                Behavior bh = obj.getBehavior(st.getAttribute().split("object.behavior.")[1]);
                if (bh instanceof BooleanBehavior) {
                    boolean bl = Boolean.parseBoolean(st.getValue());
                    if (bl != ((BooleanBehavior) bh).getValue()) {
                        ((BooleanBehavior) bh).setValue(bl);
                        //Window.alert(obj.toString());
View Full Code Here


        String xml;

        try {
            xml = DOMValidateDTD.validate(file, Info.getApplicationPath() + "/config/validator/object.dtd");

            EnvObject pojo = (EnvObject) xstream.fromXML(xml);
            EnvObjectLogic objectLogic = null;

            try {
                objectLogic = EnvObjectFactory.create(pojo);
                LOG.config("Created a new logic for " + objectLogic.getPojo().getName()
View Full Code Here

        EnvObjectLogic envObjectLogic = obj;

        if (MAKE_UNIQUE) {
            //defensive copy to not affect the passed object with the changes
            EnvObject pojoCopy = SerialClone.clone(obj.getPojo());
            pojoCopy.setName(obj.getPojo().getName() + "-" + UidGenerator.getNextStringUid());
            pojoCopy.setProtocol(obj.getPojo().getProtocol());
            pojoCopy.setPhisicalAddress("unknown");
            pojoCopy.getCurrentRepresentation().getOffset().setX(obj.getPojo().getCurrentRepresentation().getOffset().getX() + 30);
            pojoCopy.getCurrentRepresentation().getOffset().setY(obj.getPojo().getCurrentRepresentation().getOffset().getY() + 30);
            pojoCopy.setUUID(UUID.randomUUID().toString());

            try {
                envObjectLogic = EnvObjectFactory.create(pojoCopy);
            } catch (DaoLayerException ex) {
                LOG.warning(ex.getMessage());
View Full Code Here

            final Collection<EnvObjectLogic> objectList = EnvObjectPersistence
                    .getObjectList();

            for (EnvObjectLogic object : objectList) {

                final EnvObject pojo = object.getPojo();
                final Matcher matcher = pattern.matcher(pojo.getType());

                if (matcher.matches()) {
                    // TODO Look at this setProperty later
                    userLevelCommand.setProperty(Command.PROPERTY_OBJECT, pojo.getName());
                    applyToSingleObject(userLevelCommand);
                }
            }
        }

        String includeTags = userLevelCommand.getProperty(Command.PROPERTY_OBJECT_INCLUDETAGS);
        String excludeTags = userLevelCommand.getProperty(Command.PROPERTY_OBJECT_EXCLUDETAGS);
        if (includeTags != null || excludeTags != null) {
            // prepare includ set
            includeTags += "";
            String tags[] = includeTags.split(",");
            Set<String> includeSearch = new HashSet<String>();
            for (String tag : tags) {
                if (!tag.isEmpty()) {
                    includeSearch.add(tag.trim());
                }
            }
            //prepare exclude set (remove tags listed in include set too)
            excludeTags += "";
            tags = excludeTags.split(",");
            Set<String> excludeSearch = new HashSet<String>();
            for (String tag : tags) {
                if (!tag.isEmpty() && !includeSearch.contains(tag)) {
                    excludeSearch.add(tag.trim());
                }
            }

            Set<String> testSet = new HashSet<String>();
            Set<String> extestSet = new HashSet<String>();

            for (EnvObjectLogic object : EnvObjectPersistence.getObjectList()) {
                final EnvObject pojo = object.getPojo();
                boolean apply;
                testSet.clear();
                extestSet.clear();

                // applies to objects that do not contain any exclused tag
                testSet.addAll(excludeSearch);
                testSet.retainAll(pojo.getTagsList());
                // if object contains forbidden tags, testSet is not empty
                apply = testSet.isEmpty();
                // if above is false, skip check for admitted tags.
                if (apply && !includeSearch.isEmpty()) {
                    // AND operation between searchSet and object's tag list
                    testSet.addAll(includeSearch);
                    testSet.retainAll(pojo.getTagsList());
                    // if object contains ANY of admitted tags, tastSet is populated
                    apply = !testSet.isEmpty();
                }

                if (apply) {

                    // TODO Look at this setProperty later
                    userLevelCommand.setProperty(Command.PROPERTY_OBJECT, pojo.getName());
                    applyToSingleObject(userLevelCommand);
                }
            }
        }
    }
View Full Code Here

   
    public ObjectEditor(final EnvObjectLogic obj) {
        this.object = obj;
        oldName = object.getPojo().getName();

        EnvObject pojo = obj.getPojo();
        //AVOID the paint of the value over sliders that will conflic with double values
        UIManager.put("Slider.paintValue", false);
        initComponents();
        setSize(600, 400);

        if (obj.getPojo().getActAs().equalsIgnoreCase("virtual")) {
            btnVirtual.setSelected(true);
        }
       
        UUIDtxt.setText(object.getPojo().getUUID());
        checkIfVirtual();
        txtName.setText(pojo.getName());
        txtDescription.setText(pojo.getDescription());
        txtTags.setText(pojo.getTagsString());
        populateProtocol();
        populateEnvironment();
        txtAddress.setText(pojo.getPhisicalAddress());

        Integer x = (int) pojo.getCurrentRepresentation().getOffset().getX();
        Integer y = (int) pojo.getCurrentRepresentation().getOffset().getY();
        Integer rotation = (int) pojo.getCurrentRepresentation().getRotation();
        SpinnerModel modelX =
                new SpinnerNumberModel(0, //initial value
                -100, //min
                (int) obj.getEnvironment().getPojo().getWidth() + 100, //max= env dimension + 1 meter
                1); //step
        SpinnerModel modelY =
                new SpinnerNumberModel(0, //initial value
                -100, //min
                (int) obj.getEnvironment().getPojo().getWidth() + 100, //max
                1); //step
        spnX.setModel(modelX);
        spnY.setModel(modelY);
        spnX.setValue((Integer) x);
        spnY.setValue((Integer) y);

        SpinnerModel scaleWidthModel =
                new SpinnerNumberModel(new Double(pojo.getCurrentRepresentation().getScaleX()), //initial value
                new Double(0.1), //min
                new Double(10.0), //max
                new Double(0.1)); //step
        spnScaleWidth.setModel(scaleWidthModel);

        SpinnerModel scaleHeightModel =
                new SpinnerNumberModel(new Double(pojo.getCurrentRepresentation().getScaleY()), //initial value
                new Double(0.1), //min
                new Double(10.0), //max
                new Double(0.1)); //step
        spnScaleHeight.setModel(scaleHeightModel);
        spnRotation.setValue(rotation);

        tabObjectEditor.addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
                if (tabObjectEditor.getSelectedComponent().equals(tabAutomations)) {
                    populateAutomationsTab();
                }
            }
        });

        //population combo box representation
        DefaultComboBoxModel representationsModel = new DefaultComboBoxModel();

        for (EnvObjectLogic object : EnvObjectPersistence.getObjectList()) {
            for (Representation rep : object.getPojo().getRepresentations()) {
                representationsModel.addElement(rep);
            }
        }

        if ((pojo.getActAs() != null)
                && !pojo.getActAs().isEmpty()
                && !pojo.getActAs().equalsIgnoreCase("unimplemented")) {
            setTitle(pojo.getName() + " (" + pojo.getActAs() + " " + pojo.getSimpleType() + ")");
        } else {
            setTitle(pojo.getName() + " (" + pojo.getSimpleType() + ")");
        }

//        controlPanel = new PropertiesPanel_1(0, 1);
//        tabControls.add(controlPanel);
        tabControls.setLayout(new BoxLayout(tabControls, BoxLayout.PAGE_AXIS));
View Full Code Here

    private void btnOkActionPerformed(java.awt.event.ActionEvent evt)    {//GEN-FIRST:event_btnOkActionPerformed

        if ((!txtProtocol.getSelectedItem().toString().equals(""))
                && (!txtAddress.getText().equals(""))) {
            EnvObject pojo = object.getPojo();
            pojo.setProtocol(txtProtocol.getSelectedItem().toString());
            pojo.setPhisicalAddress(txtAddress.getText());
            pojo.setDescription(txtDescription.getText());
            pojo.getTagsList().clear();
            object.addTags(txtTags.getText());
            txtTags.setText(pojo.getTagsString());
            if (!(oldName.equals(txtName.getText().trim()))) {
                object.rename(txtName.getText().trim());
            }

            if (btnVirtual.isSelected()) {
                pojo.setActAs("virtual");
            } else {
                pojo.setActAs("");
            }

            //object.setChanged(true);
            saveRepresentationChanges();
View Full Code Here

        return null;
    }

    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;
    }
View Full Code Here

    zoneDataProvider.refresh();
  }
     
     public static void message(String message) {      
    Payload payload = FreedomoticStompHelper.parseMessage(message);
    final EnvObject obj = EnvironmentController.getInstance().getObject(payload.getStatements("object.name").get(0).getValue());
//  //TODO: This way is not very efficient, as we are ignoring the message and retrieving the data again.
//    ObjectResourceProxy objectResource;   
//    final EnvObject new_obj;  
//   
//    objectResource = GWT.create(ObjectResourceProxy.class);
//    // Set up the contact resource
//    objectResource.getClientResource().setReference("v1/environment/objects/"+payload.getStatements("object.name").get(0).getValue());
//   
//    objectResource.retrieveObject(new Result<EnvObject>() {
//      public void onFailure(Throwable caught) {
//          //TODO: Handle the error
//      }      
//    @Override
//    public void onSuccess(EnvObject result) {
//      for (Behavior bh: obj.getBehaviors())
//      {                
//        Behavior resultBehavior = result.getBehavior(bh.getName());       
//        if (bh instanceof BooleanBehavior)
//        {         
//          ((BooleanBehavior) bh).setValue(((BooleanBehavior)resultBehavior).getValue());
//        }
//        else if (bh instanceof RangedIntBehavior)
//        {         
//          ((RangedIntBehavior) bh).setValue(((RangedIntBehavior)resultBehavior).getValue());
//        }
//        else if (bh instanceof ListBehavior)
//        {
//          ((ListBehavior) bh).setSelected(((ListBehavior)resultBehavior).getSelected()); 
//        }             
//      }
//      obj.setCurrentRepresentation(result.getCurrentRepresentationIndex());   
//    }
//    });
     
//  This should be the correct way, but the problem is with behavior linked changes. Review this way if the messages change
   
    Iterator it = payload.iterator();
        while (it.hasNext()) {
            Statement st = (Statement) it.next();             
      if (st.getAttribute().equalsIgnoreCase("object.currentRepresentation"))
      {                 
        if (obj.getCurrentRepresentationIndex() !=  Integer.parseInt(st.getValue()))
        {
          obj.setCurrentRepresentation(Integer.parseInt(st.getValue()));         
        }                       
      }                             
      else if (!st.getAttribute().equalsIgnoreCase("object.name"))
      {
        Behavior bh = obj.getBehavior(st.getAttribute());              
        if (bh instanceof BooleanBehavior)
        {
          boolean bl = Boolean.parseBoolean(st.getValue());
          if (bl !=((BooleanBehavior)bh).getValue())
          {
View Full Code Here

TOP

Related Classes of it.freedomotic.model.object.EnvObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.