@Override public void MetaFunction(metadslx.core.MetaFunction _this) { super.MetaFunction(_this); MetaFunctionType type = MetaFactory.instance().createMetaFunctionType(); ((ModelObject) type).mUnSet(MetaDescriptor.MetaFunctionType.ParameterTypesProperty); ((ModelObject) type) .mLazySet( MetaDescriptor.MetaFunctionType.ParameterTypesProperty, Lazy.create( () -> new ModelMultiList<>( (ModelObject) _this, MetaDescriptor.MetaFunctionType.ParameterTypesProperty, _this .getParameters() .stream() .map(p -> p.getType()) .collect(java.util.stream.Collectors.toList())), true)); ((ModelObject) type) .mLazySet( MetaDescriptor.MetaFunctionType.ReturnTypeProperty, Lazy.create(() -> _this.getReturnType(), true)); ((ModelObject) _this).mSet(MetaDescriptor.MetaFunction.TypeProperty, type); }
/** ****************** update functions ****************** */ public void addObject(String objStr, boolean bFirstRound) { String predStr; String paramStr; boolean bObjectFound = false; int bracketIdx = objStr.indexOf('('); int bracket2Idx = objStr.indexOf(')'); predStr = objStr.substring(0, bracketIdx); paramStr = objStr.substring(bracketIdx + 1, bracket2Idx); Iterator It = modelObjects.iterator(); while (It.hasNext()) { ModelObject modelObject = (ModelObject) It.next(); // System.out.println("modelObject.getName(): " + modelObject.getName()); if (modelObject.getName().equals(predStr)) { bObjectFound = true; modelObject.add(paramStr, bFirstRound); } } // // Object not found - create new modelObject if (!bObjectFound) { // TODO: put this in a file for reading int numInst; if (predStr.equals("player")) numInst = 21; else numInst = 1; ModelObject newObject = new ModelObject(predStr, numInst); newObject.add(paramStr, bFirstRound); // System.out.println("Adding new object: " + predStr + ", param: " + paramStr); modelObjects.add(newObject); } }
public String returnString() { String modelString = new String(""); Iterator It = modelObjects.iterator(); while (It.hasNext()) { ModelObject modelObject = (ModelObject) It.next(); modelString = modelString + modelObject.returnString(); } return modelString; }
@Override public void MetaBinaryExpression(metadslx.core.MetaBinaryExpression _this) { super.MetaBinaryExpression(_this); ((ModelObject) _this) .mLazyAdd( MetaDescriptor.MetaBoundExpression.ArgumentsProperty, Lazy.create(() -> _this.getLeft(), true)); ((ModelObject) _this) .mLazyAdd( MetaDescriptor.MetaBoundExpression.ArgumentsProperty, Lazy.create(() -> _this.getRight(), true)); }
private void addAll(ModelObject modelObject, Model model) { if (!model.contains(modelObject)) { model.add(modelObject); modelObject.setModel(model); for (ModelObject refFrom : modelObject.getReferencesFrom()) { addAll(refFrom, model); } for (ModelObject refTo : modelObject.getReferencesTo()) { addAll(refTo, model); } } }
@Override public void MetaNewCollectionExpression(metadslx.core.MetaNewCollectionExpression _this) { super.MetaNewCollectionExpression(_this); ((ModelObject) _this) .mLazySetChild( MetaDescriptor.MetaNewCollectionExpression.ValuesProperty, MetaDescriptor.MetaExpression.ExpectedTypeProperty, Lazy.create(() -> _this.getTypeReference().getInnerType(), true)); }
public FullModel(Diff diff, Path file) throws CompareException { this.diff = diff; System.out.println("Reading model " + file.getFileName().toString()); try { FileReader in = new FileReader(file.toFile()); BufferedReader reader = new BufferedReader(in); String line = reader.readLine(); while (line != null) { ModelObject modelObject = new ModelObject(this.diff, this, line.trim()); if (modelObject.getId() != -1) { add(modelObject); } line = reader.readLine(); } reader.close(); in = new FileReader(file.toFile()); reader = new BufferedReader(in); try { line = reader.readLine(); while (line != null) { if (line.startsWith("#")) { if (line.contains("=")) { String idString = line.substring(1, line.indexOf("=")); long id = Long.parseLong(idString); ModelObject modelObject = get(id); modelObject.fill(line); } } line = reader.readLine(); } } finally { reader.close(); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
private void floodFill( SubModel subModel, ModelObject firstUnlabelled, Set<ModelObject> unplaced, Set<ModelObject> todo) { subModel.add(firstUnlabelled); unplaced.remove(firstUnlabelled); for (ModelObject object : firstUnlabelled.getReferencesTo()) { if (!subModel.contains(object)) { if (!todo.contains(object)) { todo.add(object); } } } for (ModelObject object : firstUnlabelled.getReferencesFrom()) { if (!subModel.contains(object)) { if (!todo.contains(object)) { todo.add(object); } } } }
@Override public void modify(ModelObject modelObject) { SkeletonControl skeletonControl = modelObject.getModelSpatial().getControl(SkeletonControl.class); Node headNode = skeletonControl.getAttachmentsNode("head"); float width = 1.6f; float height = (width * (4f / 5)); Quad quad = new Quad(width, height, true); Spatial plane = new Geometry(null, quad); plane.setLocalTranslation((width / -2), 0.3f, -0.73f); JMonkeyUtil.setLocalRotation(plane, new Vector3f(0, -0.7f, 1)); Material material = MaterialFactory.generateUnshadedMaterial("Models/cow/resources/baron.png"); material.getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Off); plane.setMaterial(material); headNode.attachChild(plane); }
@Test public void testRefreshView() { view = new ViewObject(); model = new ModelObject(); view = new ViewObject(); class Profil { private String nom; private Integer id; public Profil(String nom, Integer id) { this.nom = nom; this.id = id; } public String getNom() { return nom; } public void setNom(String nom) { this.nom = nom; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } } Profil profil = new Profil("nom", 1); List<Object> profils = new ArrayList<Object>(); profils.add(profil); Profil profil2 = new Profil("nom2", 2); profils.add(profil2); model.setProfils(profils); model.setName("NewName"); model.setChoice("initChoice2"); appController.bindModel(view, model); model.setProfil(model.getProfils().get(1)); appController.refreshView(view); // The test established on the textfield's refresh Assert.assertEquals(view.getNameTextField().getText(), model.getName()); // The test established on the jradiobutton's refresh Assert.assertTrue(view.getJradiobutton2().isSelected()); // The test established on the jcombobox's refresh Assert.assertEquals(view.getProfilComboBox().getSelectedItem(), profil2); // The test established on the jspinner's refresh }
@Test public void testBindModel() { model = new ModelObject(); view = new ViewObject(); class Profil { private String nom; private Integer id; public Profil(String nom, Integer id) { this.nom = nom; this.id = id; } public String getNom() { return nom; } public void setNom(String nom) { this.nom = nom; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } @Override public String toString() { return this.getNom(); } } Profil profil = new Profil("nom", 1); List<Object> profils = new ArrayList<Object>(); profils.add(profil); model.setProfils(profils); JTextField jtextfield = (JTextField) view.getNameTextField(); appController.bindModel(view, model); // The test on JTextField Component JTextField jtextfield2 = new JTextField(); JFrame frame = new JFrame(); frame.add(jtextfield); frame.add(jtextfield2); frame.setVisible(true); jtextfield.setText("Nom"); jtextfield.requestFocus(); jtextfield2.requestFocus(); Assert.assertTrue(jtextfield.getListeners(FocusListener.class).length != 0); // this thread is defined to wait until the focus event get fired try { Thread.sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } // The test established on JTextField binding model Assert.assertTrue(model.getName().equals("Nom")); // The test established on JCheckBox binding model JCheckBox jcheckbox1 = (JCheckBox) view.getJcheckbox1(); JCheckBox jcheckbox2 = (JCheckBox) view.getJcheckbox2(); jcheckbox1.doClick(); jcheckbox2.doClick(); List<String> checked = new ArrayList<String>(); checked.add(jcheckbox1.getText()); checked.add(jcheckbox2.getText()); Assert.assertEquals(model.getChoices(), checked); // The test established on JRadioButton JRadioButton jradiobutton1 = (JRadioButton) view.getJradiobutton1(); JRadioButton jradiobutton2 = (JRadioButton) view.getJradiobutton2(); jradiobutton1.doClick(); Assert.assertEquals(model.getChoice(), model.getInitChoice1()); jradiobutton2.doClick(); Assert.assertEquals(model.getChoice(), model.getInitChoice2()); // The test established on JLabel binding model JLabel jlabel = (JLabel) view.getJlabel(); Assert.assertEquals(jlabel.getText(), model.getLabelInitValue()); // The test established on JList binding model JList jlist = (JList) view.getJlist(); Assert.assertTrue(jlist.getVisibleRowCount() != 0); // The test established on JTable binding model JTable jtable = (JTable) view.getTable(); Assert.assertTrue(view.getTable().getRowCount() == 1); // The test established on JSpinner binding model JSpinner jspinner = view.getJspinner(); Assert.assertEquals(jspinner.getValue(), model.getProfils().get(0)); // The test established on JComboBox binding model JComboBox jcombobox = (JComboBox) view.getProfilComboBox(); Assert.assertTrue(view.getProfilComboBox().getItemCount() == 1); }
public SettingsScreen() { this.setTitle("Settings Screen"); ModelObject.getInstance() .addStateTransition(currentScreenName, Config.getInstance().BACK_ACTION, "HomeScreen"); }