List of usage examples for javafx.beans.property ReadOnlyObjectWrapper ReadOnlyObjectWrapper
public ReadOnlyObjectWrapper(T initialValue)
From source file:org.simmi.GeneSetHead.java
License:asdf
private void importStuff() throws IOException, UnavailableServiceException { boolean fail = true; /*try {/*from ww w.j a va 2 s.co m*/ FileOpenService fos = (FileOpenService)ServiceManager.lookup("javax.jnlp.FileOpenService"); FileContents fc = fos.openFileDialog(null, null); is = fc.getInputStream(); } catch( Exception e ) { fail = true; }*/ Path zipp = null; if (fail && zipp == null) { FileChooser fc = new FileChooser(); File f = fc.showOpenDialog(app.getOwner()); if (f != null) zipp = f.toPath(); } //if( is != null ) { /*ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] bab = new byte[1024]; int rd = is.read( bab ); while( rd > 0 ) { baos.write(bab, 0, rd); rd = is.read( bab ); } baos.close(); zipf = baos.toByteArray();*/ /*ZipInputStream zipm = new ZipInputStream( new ByteArrayInputStream( zipf ) ); ZipEntry ze = zipm.getNextEntry(); while( ze != null ) { String zname = ze.getName(); if( zname.equals("unresolved.blastout") ) { unresolvedmap = loadunresolvedmap( new InputStreamReader( zipm ) ); } else if( zname.equals("namemap.txt") ) { namemap = loadnamemap( new InputStreamReader( zipm ) ); } else if( ze.getName().equals("designations.txt") ) { designations = loadDesignations( new InputStreamReader(zipm), deset ); } else if( ze.getName().equals("plasmids.txt") ) { plasmids = loadPlasmids( new InputStreamReader(zipm) ); } ze = zipm.getNextEntry(); } if( designations == null ) designations = new TreeMap<String,String>(); //List<Set<String>> uclusterlist = null;*/ if (zipp != null) { geneset.loadStuff(zipp); //syncolorcomb = new JComboBox(); syncolorcomb.getItems().clear(); syncolorcomb.getItems().add(""); for (String spec : geneset.speccontigMap.keySet()) { syncolorcomb.getItems().add(spec); } syncolorcomb.getItems().add("All"); /* * is = GeneSet.class.getResourceAsStream(""); Map<String,String> komap * = koMapping( new FileReader("/home/sigmar/asgard-bio/data/ko"), * funclist, genelist ); for( Function f : funclist ) { if( * komap.containsKey( f.ec ) ) { for( String gn : f.geneentries ) { Gene * g = refmap.get(gn); if( g.keggid == null ) g.keggid = * komap.get(f.ec); } } } */ geneset.updateShareNum(geneset.specList); Set<String> allecs = new HashSet<>(); for (Function f : geneset.funclist) { if (f.getEc() != null) allecs.add(f.getEc()); } for (String val : geneset.pathwaymap.keySet()) { Set<String> set = geneset.pathwaymap.get(val); for (String s : set) { if (allecs.contains(s)) { combo.getItems().add(val); break; } } } Set<String> set = new TreeSet<>(); for (Gene g : geneset.genelist) { Tegeval tv = g.tegeval; if (tv.eval <= 0.00001 && tv.teg != null && tv.teg.startsWith("[") && tv.teg.endsWith("]")) set.add(tv.teg); } for (String sp : set) { specombo.getItems().add(sp); } if (geneset.uclusterlist != null) geneset.clusterMap = Serifier.initClusterNew(geneset.uclusterlist, null, null); //table.tableChanged( new TableModelEvent( table.getModel() ) ); //ftable.tableChanged( new TableModelEvent( ftable.getModel() ) ); //table.setModel( nullmodel ); //ftable.setModel( nullmodel ); //table.setModel( groupModel ); //ftable.setModel( ftablemodel ); //ftable.setItems( geneset.f); for (String spec : geneset.specList) { TableColumn<GeneGroup, Teginfo> speccol = new TableColumn(spec); //speccol.getStyleClass().add("tabstyle"); speccol.setCellFactory(cell -> { final TableCell<GeneGroup, Teginfo> tc = new TableCell<GeneGroup, Teginfo>() { @Override protected void updateItem(Teginfo item, boolean empty) { super.updateItem(item, empty); if (item == null || item.toString().length() == 0 || empty) { setText(null); setStyle(""); //getStyleClass().remove("tabcellstyle"); } else { setText(item.toString()); cellRender(this, item, 0); //getStyleClass().add("tabcellstyle"); /*if( (this.getTableRow() != null && getTableRow().isSelected()) || isSelected() ) { //setTextFill( javafx.scene.paint.Color.WHITE ); setStyle("-fx-background-color: darkgreen"); } else { //setTextFill( javafx.scene.paint.Color.BLACK ); setStyle("-fx-background-color: green"); }*/ } } }; return tc; }); speccol.setCellValueFactory(cellValue -> { GeneGroup gg = cellValue.getValue(); Teginfo tes = gg.getTes(spec); return new ReadOnlyObjectWrapper(tes); //return new SimpleStringProperty( tes != null ? tes.toString() : "" ); //Teginfo ret = geneset.getGroupTes( cellValue.getValue(), spec ); //return new ObservableValue<String>( ret.toString() ); //return ret; }); table.getColumns().add(speccol); TableColumn<Gene, Teg> gspeccol = new TableColumn(spec); gspeccol.setComparator((o1, o2) -> { if (o1 == null) { if (o2 == null) { return 0; } else return -1; } else if (o1 instanceof Tegeval) { if (o2 == null || o2 instanceof Teginfo) { return 1; } } else { if (o2 == null) { return 1; } else if (o2 instanceof Tegeval) { return -1; } } return o1.compareTo(o2); }); gspeccol.setCellFactory(cell -> { final TableCell<Gene, Teg> tc = new TableCell<Gene, Teg>() { @Override protected void updateItem(Teg item, boolean empty) { super.updateItem(item, empty); if (item == null || item.toString().length() == 0 || empty) { setText(""); setStyle(""); } else { boolean render = cellRenderGene(this, item); setText(item.toString()); if (!render) setStyle(""); //getStyleClass().add("tabcellstyle"); /*if( (this.getTableRow() != null && getTableRow().isSelected()) || isSelected() ) { //setTextFill( javafx.scene.paint.Color.WHITE ); setStyle("-fx-background-color: white"); } else { //setTextFill( javafx.scene.paint.Color.BLACK ); setStyle("-fx-background-color: black"); }*/ } } }; return tc; }); gspeccol.setCellValueFactory(cellValue -> { Gene g = cellValue.getValue(); //Teginfo tes = g.tegeval;//getTes( spec ); if (spec.equals(g.getSpecies())) { return new ReadOnlyObjectWrapper(g.tegeval); } else { GeneGroup gg = g.getGeneGroup(); Set<String> specset = gg.getSpecies(); if (specset.contains(spec)) { Teginfo ti = gg.getGenes(spec); return new ReadOnlyObjectWrapper(ti); } } //return new SimpleStringProperty( tes != null ? tes.toString() : "" ); //Teginfo ret = geneset.getGroupTes( cellValue.getValue(), spec ); //return new ObservableValue<String>( ret.toString() ); //return ret; return null; }); /*gspeccol.setCellValueFactory( cellValue -> { return new SimpleStringProperty( cellValue.getValue().toString() ); //Teginfo ret = geneset.getGroupTes( cellValue.getValue(), spec ); //return new ObservableValue<String>( ret.toString() ); //return ret; });*/ gtable.getColumns().add(gspeccol); } ObservableList<Function> ofunc = FXCollections.observableList(geneset.funclist); ffilteredData = new FilteredList<>(ofunc, p -> true); fsortedData = new SortedList<>(ffilteredData); fsortedData.comparatorProperty().bind(ftable.comparatorProperty()); ftable.setItems(fsortedData); ObservableList<GeneGroup> ogenegroup = FXCollections.observableList(geneset.allgenegroups); filteredData = new FilteredList<>(ogenegroup, p -> true); sortedData = new SortedList<>(filteredData); sortedData.comparatorProperty().bind(table.comparatorProperty()); table.setItems(sortedData); ObservableList<Gene> ogene = FXCollections.observableList(geneset.genelist); gtable.setItems(ogene); int me = 0; int mu = 0; for (Gene g : geneset.genelist) { if (g.getGeneGroup() != null) me++; else mu++; } System.err.println(me + " " + mu); } String userhome = System.getProperty("user.home"); File f = new File(userhome); File idf = new File(f, "idspec.txt"); BufferedWriter bw = new BufferedWriter(new FileWriter(idf)); //Files.newBufferedWriter(idf.toPath(), OpenOption.); for (String id : geneset.refmap.keySet()) { Gene g = geneset.refmap.get(id); bw.write(id + "\t" + g.getSpecies() + "\n"); } bw.close(); }