rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
((Chromosome)chrom.lastElement()).setHaploid(true);
public Vector linkageToChrom(File infile, int type) throws IllegalArgumentException, HaploViewException, PedFileException, IOException{ pedFile = new PedFile(); if (type == PED_FILE){ pedFile.parseLinkage(infile); }else{ pedFile.parseHapMap(infile); } Vector result = pedFile.check(); Vector indList = pedFile.getUnrelatedIndividuals(); Vector indsInTrio = new Vector(); int numMarkers = 0; numSingletons = 0; numTrios = 0; numPeds = pedFile.getNumFamilies(); Individual currentInd; Family currentFamily; Vector chrom = new Vector(); //first time through we deal with trios. for(int x=0; x < indList.size(); x++){ currentInd = (Individual)indList.get(x); boolean haploid = ((currentInd.getGender() == 1) && Chromosome.getDataChrom().equalsIgnoreCase("chrx")); currentFamily = pedFile.getFamily(currentInd.getFamilyID()); if (currentFamily.containsMember(currentInd.getMomID()) && currentFamily.containsMember(currentInd.getDadID())){ //if indiv has both parents Individual mom = currentFamily.getMember(currentInd.getMomID()); Individual dad = currentFamily.getMember(currentInd.getDadID()); if (indList.contains(mom) && indList.contains(dad)){ numMarkers = currentInd.getNumMarkers(); byte[] dadT = new byte[numMarkers]; byte[] dadU = new byte[numMarkers]; byte[] momT = new byte[numMarkers]; byte[] momU = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte kid1, kid2; if (currentInd.getZeroed(i)){ kid1 = 0; kid2 = 0; }else{ kid1 = currentInd.getMarkerA(i); kid2 = currentInd.getMarkerB(i); } byte mom1,mom2; if (currentFamily.getMember(currentInd.getMomID()).getZeroed(i)){ mom1 = 0; mom2 = 0; }else{ mom1 = (currentFamily.getMember(currentInd.getMomID())).getMarkerA(i); mom2 = (currentFamily.getMember(currentInd.getMomID())).getMarkerB(i); } byte dad1,dad2; if (currentFamily.getMember(currentInd.getDadID()).getZeroed(i)){ dad1 = 0; dad2 = 0; }else{ dad1 = (currentFamily.getMember(currentInd.getDadID())).getMarkerA(i); dad2 = (currentFamily.getMember(currentInd.getDadID())).getMarkerB(i); } if(haploid) { if(kid1 == 0) { //kid missing dadU[i] = dad1; if (mom1 == mom2) { momT[i] = mom1; momU[i] = mom1; } else if (mom1 != 0 && mom2 != 0){ momT[i] = (byte)(4+mom1); momU[i] = (byte)(4+mom2); } } else { dadU[i] = dad1; if (mom1 == 0) { momT[i] = kid1; momU[i] = 0; } else if (mom1 == kid1) { momT[i] = mom1; momU[i] = mom2; } else { momT[i] = mom2; momU[i] = mom1; } } }else { if (kid1 == 0 || kid2 == 0) { //kid missing if (dad1 == dad2) { dadT[i] = dad1; dadU[i] = dad1; } else if (dad1 != 0 && dad2 != 0) { dadT[i] = (byte)(4+dad1); dadU[i] = (byte)(4+dad2); } if (mom1 == mom2) { momT[i] = mom1; momU[i] = mom1; } else if (mom1 != 0 && mom2 != 0){ momT[i] = (byte)(4+mom1); momU[i] = (byte)(4+mom2); } } else if (kid1 == kid2) { //kid homozygous if (dad1 == 0) { dadT[i] = kid1; dadU[i] = 0; } else if (dad1 == kid1) { dadT[i] = dad1; dadU[i] = dad2; } else { dadT[i] = dad2; dadU[i] = dad1; } if (mom1 == 0) { momT[i] = kid1; momU[i] = 0; } else if (mom1 == kid1) { momT[i] = mom1; momU[i] = mom2; } else { momT[i] = mom2; momU[i] = mom1; } } else { //kid heterozygous and this if tree's a bitch if (dad1 == 0 && mom1 == 0) { //both missing dadT[i] = 0; dadU[i] = 0; momT[i] = 0; momU[i] = 0; } else if (dad1 == 0 && mom1 != mom2) { //dad missing mom het dadT[i] = 0; dadU[i] = 0; momT[i] = (byte)(4+mom1); momU[i] = (byte)(4+mom2); } else if (mom1 == 0 && dad1 != dad2) { //dad het mom missing dadT[i] = (byte)(4+dad1); dadU[i] = (byte)(4+dad2); momT[i] = 0; momU[i] = 0; } else if (dad1 == 0 && mom1 == mom2) { //dad missing mom hom momT[i] = mom1; momU[i] = mom1; dadU[i] = 0; if (kid1 == mom1) { dadT[i] = kid2; } else { dadT[i] = kid1; } } else if (mom1 == 0 && dad1 == dad2) { //mom missing dad hom dadT[i] = dad1; dadU[i] = dad1; momU[i] = 0; if (kid1 == dad1) { momT[i] = kid2; } else { momT[i] = kid1; } } else if (dad1 == dad2 && mom1 != mom2) { //dad hom mom het dadT[i] = dad1; dadU[i] = dad2; if (kid1 == dad1) { momT[i] = kid2; momU[i] = kid1; } else { momT[i] = kid1; momU[i] = kid2; } } else if (mom1 == mom2 && dad1 != dad2) { //dad het mom hom momT[i] = mom1; momU[i] = mom2; if (kid1 == mom1) { dadT[i] = kid2; dadU[i] = kid1; } else { dadT[i] = kid1; dadU[i] = kid2; } } else if (dad1 == dad2 && mom1 == mom2) { //mom & dad hom dadT[i] = dad1; dadU[i] = dad1; momT[i] = mom1; momU[i] = mom1; } else { //everybody het dadT[i] = (byte)(4+dad1); dadU[i] = (byte)(4+dad2); momT[i] = (byte)(4+mom1); momU[i] = (byte)(4+mom2); } } } } chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momT, mom.getAffectedStatus(),currentInd.getAffectedStatus())); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momU, mom.getAffectedStatus(),currentInd.getAffectedStatus())); if(haploid) { chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadU, dad.getAffectedStatus(),currentInd.getAffectedStatus())); }else if(Chromosome.getDataChrom().equalsIgnoreCase("chrx")){ chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadT, dad.getAffectedStatus(), currentInd.getAffectedStatus())); }else { chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadU, dad.getAffectedStatus(),currentInd.getAffectedStatus())); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadT, dad.getAffectedStatus(), currentInd.getAffectedStatus())); } numTrios++; indsInTrio.add(mom); indsInTrio.add(dad); indsInTrio.add(currentInd); } } } for (int x=0; x<indList.size(); x++){ currentInd = (Individual)indList.get(x); boolean haploid = ((currentInd.getGender() == 1) && Chromosome.getDataChrom().equalsIgnoreCase("chrx")); if (!indsInTrio.contains(currentInd)){ //ind has no parents or kids -- he's a singleton numMarkers = currentInd.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte thisMarkerA, thisMarkerB; if (currentInd.getZeroed(i)){ thisMarkerA = 0; thisMarkerB = 0; }else{ thisMarkerA = currentInd.getMarkerA(i); thisMarkerB = currentInd.getMarkerB(i); } if (thisMarkerA == thisMarkerB || thisMarkerA == 0 || thisMarkerB == 0){ chrom1[i] = thisMarkerA; chrom2[i] = thisMarkerB; }else{ chrom1[i] = (byte)(4+thisMarkerA); chrom2[i] = (byte)(4+thisMarkerB); } } chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom1, currentInd.getAffectedStatus(), -1)); if(!haploid){ chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom2,currentInd.getAffectedStatus(), -1)); } numSingletons++; } } chromosomes = chrom; //wipe clean any existing marker info so we know we're starting with a new file Chromosome.markers = null; return result; }
}else{ ((Chromosome)chrom.lastElement()).setHaploid(true);
public Vector linkageToChrom(File infile, int type) throws IllegalArgumentException, HaploViewException, PedFileException, IOException{ pedFile = new PedFile(); if (type == PED_FILE){ pedFile.parseLinkage(infile); }else{ pedFile.parseHapMap(infile); } Vector result = pedFile.check(); Vector indList = pedFile.getUnrelatedIndividuals(); Vector indsInTrio = new Vector(); int numMarkers = 0; numSingletons = 0; numTrios = 0; numPeds = pedFile.getNumFamilies(); Individual currentInd; Family currentFamily; Vector chrom = new Vector(); //first time through we deal with trios. for(int x=0; x < indList.size(); x++){ currentInd = (Individual)indList.get(x); boolean haploid = ((currentInd.getGender() == 1) && Chromosome.getDataChrom().equalsIgnoreCase("chrx")); currentFamily = pedFile.getFamily(currentInd.getFamilyID()); if (currentFamily.containsMember(currentInd.getMomID()) && currentFamily.containsMember(currentInd.getDadID())){ //if indiv has both parents Individual mom = currentFamily.getMember(currentInd.getMomID()); Individual dad = currentFamily.getMember(currentInd.getDadID()); if (indList.contains(mom) && indList.contains(dad)){ numMarkers = currentInd.getNumMarkers(); byte[] dadT = new byte[numMarkers]; byte[] dadU = new byte[numMarkers]; byte[] momT = new byte[numMarkers]; byte[] momU = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte kid1, kid2; if (currentInd.getZeroed(i)){ kid1 = 0; kid2 = 0; }else{ kid1 = currentInd.getMarkerA(i); kid2 = currentInd.getMarkerB(i); } byte mom1,mom2; if (currentFamily.getMember(currentInd.getMomID()).getZeroed(i)){ mom1 = 0; mom2 = 0; }else{ mom1 = (currentFamily.getMember(currentInd.getMomID())).getMarkerA(i); mom2 = (currentFamily.getMember(currentInd.getMomID())).getMarkerB(i); } byte dad1,dad2; if (currentFamily.getMember(currentInd.getDadID()).getZeroed(i)){ dad1 = 0; dad2 = 0; }else{ dad1 = (currentFamily.getMember(currentInd.getDadID())).getMarkerA(i); dad2 = (currentFamily.getMember(currentInd.getDadID())).getMarkerB(i); } if(haploid) { if(kid1 == 0) { //kid missing dadU[i] = dad1; if (mom1 == mom2) { momT[i] = mom1; momU[i] = mom1; } else if (mom1 != 0 && mom2 != 0){ momT[i] = (byte)(4+mom1); momU[i] = (byte)(4+mom2); } } else { dadU[i] = dad1; if (mom1 == 0) { momT[i] = kid1; momU[i] = 0; } else if (mom1 == kid1) { momT[i] = mom1; momU[i] = mom2; } else { momT[i] = mom2; momU[i] = mom1; } } }else { if (kid1 == 0 || kid2 == 0) { //kid missing if (dad1 == dad2) { dadT[i] = dad1; dadU[i] = dad1; } else if (dad1 != 0 && dad2 != 0) { dadT[i] = (byte)(4+dad1); dadU[i] = (byte)(4+dad2); } if (mom1 == mom2) { momT[i] = mom1; momU[i] = mom1; } else if (mom1 != 0 && mom2 != 0){ momT[i] = (byte)(4+mom1); momU[i] = (byte)(4+mom2); } } else if (kid1 == kid2) { //kid homozygous if (dad1 == 0) { dadT[i] = kid1; dadU[i] = 0; } else if (dad1 == kid1) { dadT[i] = dad1; dadU[i] = dad2; } else { dadT[i] = dad2; dadU[i] = dad1; } if (mom1 == 0) { momT[i] = kid1; momU[i] = 0; } else if (mom1 == kid1) { momT[i] = mom1; momU[i] = mom2; } else { momT[i] = mom2; momU[i] = mom1; } } else { //kid heterozygous and this if tree's a bitch if (dad1 == 0 && mom1 == 0) { //both missing dadT[i] = 0; dadU[i] = 0; momT[i] = 0; momU[i] = 0; } else if (dad1 == 0 && mom1 != mom2) { //dad missing mom het dadT[i] = 0; dadU[i] = 0; momT[i] = (byte)(4+mom1); momU[i] = (byte)(4+mom2); } else if (mom1 == 0 && dad1 != dad2) { //dad het mom missing dadT[i] = (byte)(4+dad1); dadU[i] = (byte)(4+dad2); momT[i] = 0; momU[i] = 0; } else if (dad1 == 0 && mom1 == mom2) { //dad missing mom hom momT[i] = mom1; momU[i] = mom1; dadU[i] = 0; if (kid1 == mom1) { dadT[i] = kid2; } else { dadT[i] = kid1; } } else if (mom1 == 0 && dad1 == dad2) { //mom missing dad hom dadT[i] = dad1; dadU[i] = dad1; momU[i] = 0; if (kid1 == dad1) { momT[i] = kid2; } else { momT[i] = kid1; } } else if (dad1 == dad2 && mom1 != mom2) { //dad hom mom het dadT[i] = dad1; dadU[i] = dad2; if (kid1 == dad1) { momT[i] = kid2; momU[i] = kid1; } else { momT[i] = kid1; momU[i] = kid2; } } else if (mom1 == mom2 && dad1 != dad2) { //dad het mom hom momT[i] = mom1; momU[i] = mom2; if (kid1 == mom1) { dadT[i] = kid2; dadU[i] = kid1; } else { dadT[i] = kid1; dadU[i] = kid2; } } else if (dad1 == dad2 && mom1 == mom2) { //mom & dad hom dadT[i] = dad1; dadU[i] = dad1; momT[i] = mom1; momU[i] = mom1; } else { //everybody het dadT[i] = (byte)(4+dad1); dadU[i] = (byte)(4+dad2); momT[i] = (byte)(4+mom1); momU[i] = (byte)(4+mom2); } } } } chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momT, mom.getAffectedStatus(),currentInd.getAffectedStatus())); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),momU, mom.getAffectedStatus(),currentInd.getAffectedStatus())); if(haploid) { chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadU, dad.getAffectedStatus(),currentInd.getAffectedStatus())); }else if(Chromosome.getDataChrom().equalsIgnoreCase("chrx")){ chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadT, dad.getAffectedStatus(), currentInd.getAffectedStatus())); }else { chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadU, dad.getAffectedStatus(),currentInd.getAffectedStatus())); chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),dadT, dad.getAffectedStatus(), currentInd.getAffectedStatus())); } numTrios++; indsInTrio.add(mom); indsInTrio.add(dad); indsInTrio.add(currentInd); } } } for (int x=0; x<indList.size(); x++){ currentInd = (Individual)indList.get(x); boolean haploid = ((currentInd.getGender() == 1) && Chromosome.getDataChrom().equalsIgnoreCase("chrx")); if (!indsInTrio.contains(currentInd)){ //ind has no parents or kids -- he's a singleton numMarkers = currentInd.getNumMarkers(); byte[] chrom1 = new byte[numMarkers]; byte[] chrom2 = new byte[numMarkers]; for (int i = 0; i < numMarkers; i++){ byte thisMarkerA, thisMarkerB; if (currentInd.getZeroed(i)){ thisMarkerA = 0; thisMarkerB = 0; }else{ thisMarkerA = currentInd.getMarkerA(i); thisMarkerB = currentInd.getMarkerB(i); } if (thisMarkerA == thisMarkerB || thisMarkerA == 0 || thisMarkerB == 0){ chrom1[i] = thisMarkerA; chrom2[i] = thisMarkerB; }else{ chrom1[i] = (byte)(4+thisMarkerA); chrom2[i] = (byte)(4+thisMarkerB); } } chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom1, currentInd.getAffectedStatus(), -1)); if(!haploid){ chrom.add(new Chromosome(currentInd.getFamilyID(),currentInd.getIndividualID(),chrom2,currentInd.getAffectedStatus(), -1)); } numSingletons++; } } chromosomes = chrom; //wipe clean any existing marker info so we know we're starting with a new file Chromosome.markers = null; return result; }
return contentPane.getToolTipText(e);
Point zp = unzoomPoint(e.getPoint()); MouseEvent zoomedEvent = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(), e.getModifiers(), zp.x, zp.y, e.getClickCount(), e.isPopupTrigger(), e.getButton()); return contentPane.getToolTipText(zoomedEvent);
public String getToolTipText(MouseEvent e) { return contentPane.getToolTipText(e); }
ArchitectFrame.getMainInstance().getUserSettings().getPlDotIni().addDataSource(ds);
if (plDotIni.getDataSource(ds.getName()) != null) { plDotIni.removeDataSource(ds); } plDotIni.addDataSource(ds);
public void testSourceDropDownsWithOnlyCatalog() { ArchitectDataSource ds = new ArchitectDataSource(); ds.setDisplayName("testSourceDropDownsWithOnlyCatalog"); ds.setDriverClass("ca.sqlpower.architect.MockJDBCDriver"); ds.setUser("fake"); ds.setPass("fake"); //this creates a mock jdbc database with only catalogs ds.setUrl("jdbc:mock:" + "dbmd.catalogTerm=Catalog" + "&catalogs=cat1,cat2,cat3" + "&tables.cat1=tab1" + "&tables.cat2=tab2" + "&tables.cat3=tab3"); sourcePhysicalRadio.setSelected(true); ArchitectFrame.getMainInstance().getUserSettings().getPlDotIni().addDataSource(ds); sourceDatabaseDropdown.setSelectedItem(ds); flushAWT(); assertFalse(sourceSchemaDropdown.isEnabled()); assertTrue(sourceCatalogDropdown.isEnabled()); }
ArchitectFrame.getMainInstance().getUserSettings().getPlDotIni().addDataSource(ds);
if (plDotIni.getDataSource(ds.getName()) != null) { plDotIni.removeDataSource(ds); } plDotIni.addDataSource(ds);
public void testSourceDropDownsWithSchemaAndCatalog() { ArchitectDataSource ds = new ArchitectDataSource(); ds.setDisplayName("testSourceDropDownsWithSchemaAndCatalog"); ds.setDriverClass("ca.sqlpower.architect.MockJDBCDriver"); ds.setUser("fake"); ds.setPass("fake"); //this creates a mock jdbc database with catalogs and schemas ds.setUrl("jdbc:mock:dbmd.catalogTerm=Catalog&dbmd.schemaTerm=Schema&catalogs=cow_catalog&schemas.cow_catalog=moo_schema,quack_schema&tables.cow_catalog.moo_schema=braaaap,pffft&tables.cow_catalog.quack_schema=duck,goose"); sourcePhysicalRadio.setSelected(true); ArchitectFrame.getMainInstance().getUserSettings().getPlDotIni().addDataSource(ds); sourceDatabaseDropdown.setSelectedItem(ds); flushAWT(); assertTrue(sourceCatalogDropdown.isEnabled()); assertTrue(sourceSchemaDropdown.isEnabled()); }
if (plDotIni.getDataSource(ds.getName()) != null) { plDotIni.removeDataSource(ds); }
public void testTargetDropDownsWithOnlyCatalog() { ArchitectDataSource ds = new ArchitectDataSource(); ds.setDisplayName("testTargetDropDownsWithOnlyCatalog"); ds.setDriverClass("ca.sqlpower.architect.MockJDBCDriver"); ds.setUser("fake"); ds.setPass("fake"); //this creates a mock jdbc database with schemas only ds.setUrl("jdbc:mock:" + "dbmd.catalogTerm=Catalog" + "&catalogs=cat1,cat2,cat3" + "&tables.cat1=tab1" + "&tables.cat2=tab2" + "&tables.cat3=tab3"); plDotIni.addDataSource(ds); targetDatabaseDropdown.setSelectedItem(ds); flushAWT(); assertFalse(targetSchemaDropdown.isEnabled()); assertTrue(targetCatalogDropdown.isEnabled()); }
if (plDotIni.getDataSource(ds.getName()) != null) { plDotIni.removeDataSource(ds); }
public void testTargetDropDownsWithOnlySchema() { ArchitectDataSource ds = new ArchitectDataSource(); ds.setDisplayName("testTargetDropDownsWithOnlySchema"); ds.setDriverClass("ca.sqlpower.architect.MockJDBCDriver"); ds.setUser("fake"); ds.setPass("fake"); //this creates a mock jdbc database with only schemas ds.setUrl("jdbc:mock:dbmd.schemaTerm=Schema&schemas=scheme1,scheme2,scheme3"); plDotIni.addDataSource(ds); targetDatabaseDropdown.setSelectedItem(ds); flushAWT(); assertTrue(targetSchemaDropdown.isEnabled()); assertFalse(targetCatalogDropdown.isEnabled()); }
if (plDotIni.getDataSource(ds.getName()) != null) { plDotIni.removeDataSource(ds); }
public void testTargetDropDownsWithSchemaAndCatalog() { ArchitectDataSource ds = new ArchitectDataSource(); ds.setDisplayName("testTargetDropDownsWithSchemaAndCatalog"); ds.setDriverClass("ca.sqlpower.architect.MockJDBCDriver"); ds.setUser("fake"); ds.setPass("fake"); //this creates a mock jdbc database with schemas and catalogs ds.setUrl("jdbc:mock:dbmd.catalogTerm=Catalog&dbmd.schemaTerm=Schema&catalogs=cow_catalog&schemas.cow_catalog=moo_schema,quack_schema&tables.cow_catalog.moo_schema=braaaap,pffft&tables.cow_catalog.quack_schema=duck,goose"); plDotIni.addDataSource(ds); targetDatabaseDropdown.setSelectedItem(ds); flushAWT(); assertTrue(targetSchemaDropdown.isEnabled()); assertTrue(targetCatalogDropdown.isEnabled()); targetDatabaseDropdown.setSelectedItem(ds); flushAWT(); assertTrue(targetSchemaDropdown.isEnabled()); assertTrue(targetCatalogDropdown.isEnabled()); }
if (plDotIni.getDataSource(ds.getName()) != null) { plDotIni.removeDataSource(ds); }
public void testTargetSchemaUpdateByCatalogChange(){ ArchitectDataSource ds = new ArchitectDataSource(); ds.setDisplayName("testTargetSchemaUpdateByCatalogChange"); ds.setDriverClass("ca.sqlpower.architect.MockJDBCDriver"); ds.setUser("fake"); ds.setPass("fake"); //this creates a mock jdbc database with catalogs and schemas where the catalogs have different schema names from each other ds.setUrl("jdbc:mock:dbmd.catalogTerm=Catalog&dbmd.schemaTerm=Schema&catalogs=farm,zoo,backyard&schemas.farm=birds,mammals&tables.farm.birds=chicken,turkey,hen&tables.farm.mammals=cow,horse,buffalo?&schemas.zoo=birds2,mammals2&tables.zoo.birds2=penguin,flamingo&tables.zoo.mammals2=elephant&schemas.backyard=mammals3&tables.backyard.mammals3=mouse,rat,cat,dog,raccoon"); plDotIni.addDataSource(ds); targetDatabaseDropdown.setSelectedItem(ds); flushAWT(); assertTrue(targetCatalogDropdown.isEnabled()); assertTrue(targetSchemaDropdown.isEnabled()); flushAWT(); SQLObject temp = (SQLObject)(((JComboBox)(targetCatalogDropdown)).getSelectedItem()); try { assertTrue("birds".equals(temp.getChild(0).getPhysicalName())); } catch (ArchitectException e) { System.out.println ("We did not get a schema from the catalog!"); } flushAWT(); ((JComboBox)targetCatalogDropdown).setSelectedIndex(1); temp =(SQLObject) ((JComboBox)targetCatalogDropdown).getSelectedItem(); try { assertTrue("birds2".equals(temp.getChild(0).getPhysicalName())); } catch (ArchitectException e) { System.out.println ("We did not get a schema from the catalog!"); } }
InputStream schemaIS = getClass().getClassLoader().getResourceAsStream( "photovault_schema.xml" ); Database dbModel = new DatabaseIO().read( new InputStreamReader( schemaIS ) ); String driverName = "com.mysql.jdbc.Driver"; String dbUrl = "jdbc:mysql: DataSource ds = null; if ( instanceType == TYPE_EMBEDDED ) { if ( !embeddedDirectory.exists() ) { embeddedDirectory.mkdirs(); } File derbyDir = new File( embeddedDirectory, "derby" ); File photoDir = new File( embeddedDirectory, "photos"); Volume vol = new Volume( "photos", photoDir.getAbsolutePath() ); addVolume( vol ); System.setProperty( "derby.system.home", derbyDir.getAbsolutePath() ); driverName = "org.apache.derby.jdbc.EmbeddedDriver"; dbUrl = "jdbc:derby:photovault;create=true"; EmbeddedDataSource derbyDs = new EmbeddedDataSource(); derbyDs.setDatabaseName( "photovault" ); derbyDs.setCreateDatabase( "create" ); ds = derbyDs; } else { MysqlDataSource mysqlDs = new MysqlDataSource(); mysqlDs.setURL( dbUrl ); mysqlDs.setUser( user ); mysqlDs.setPassword( passwd ); ds = mysqlDs; } Platform platform = PlatformFactory.createNewPlatformInstance( ds ); /* * Do not use delimiters for the database object names in SQL statements. * This is to avoid case sensitivity problems with SQL92 compliant * databases like Derby - non-delimited identifiers are interpreted as case * insensitive. * * I am not sure if this is the correct way to solve the issue, however, * I am not willing to make a big change of schema definitions either. */ platform.getPlatformInfo().setDelimiterToken( "" ); platform.setUsername( user ); platform.setPassword( passwd ); platform.createTables( dbModel, true, true ); DataToDatabaseSink sink = new DataToDatabaseSink( platform, dbModel ); DataReader reader = new DataReader(); reader.setModel( dbModel ); reader.setSink( sink ); InputStream seedDataStream = this.getClass().getClassLoader().getResourceAsStream( "photovault_seed_data.xml" ); try { reader.parse( seedDataStream ); } catch (SAXException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } Random rnd = new Random(); String idStr = ""; StringBuffer idBuf = new StringBuffer(); for ( int n=0; n < 4; n++ ) { int r = rnd.nextInt(); idBuf.append( Integer.toHexString( r ) ); } idStr = idBuf.toString(); DynaBean dbInfo = dbModel.createDynaBeanFor( "database_info", false ); dbInfo.set( "database_id", idStr ); dbInfo.set( "schema_version", new Integer( CURRENT_SCHEMA_VERSION ) ); dbInfo.set( "create_time", new Timestamp( System.currentTimeMillis() ) ); platform.insert( dbModel, dbInfo );
createDatabase( user, passwd, null );
public void createDatabase( String user, String passwd ) { // Get the database schema XML file InputStream schemaIS = getClass().getClassLoader().getResourceAsStream( "photovault_schema.xml" ); Database dbModel = new DatabaseIO().read( new InputStreamReader( schemaIS ) ); // Create the datasource for accessing this database String driverName = "com.mysql.jdbc.Driver"; String dbUrl = "jdbc:mysql://" + getDbHost() + "/" + getDbName(); DataSource ds = null; if ( instanceType == TYPE_EMBEDDED ) { if ( !embeddedDirectory.exists() ) { embeddedDirectory.mkdirs(); } File derbyDir = new File( embeddedDirectory, "derby" ); File photoDir = new File( embeddedDirectory, "photos"); Volume vol = new Volume( "photos", photoDir.getAbsolutePath() ); addVolume( vol ); System.setProperty( "derby.system.home", derbyDir.getAbsolutePath() ); driverName = "org.apache.derby.jdbc.EmbeddedDriver"; dbUrl = "jdbc:derby:photovault;create=true"; EmbeddedDataSource derbyDs = new EmbeddedDataSource(); derbyDs.setDatabaseName( "photovault" ); derbyDs.setCreateDatabase( "create" ); ds = derbyDs; } else { MysqlDataSource mysqlDs = new MysqlDataSource(); mysqlDs.setURL( dbUrl ); mysqlDs.setUser( user ); mysqlDs.setPassword( passwd ); ds = mysqlDs; } Platform platform = PlatformFactory.createNewPlatformInstance( ds ); /* * Do not use delimiters for the database object names in SQL statements. * This is to avoid case sensitivity problems with SQL92 compliant * databases like Derby - non-delimited identifiers are interpreted as case * insensitive. * * I am not sure if this is the correct way to solve the issue, however, * I am not willing to make a big change of schema definitions either. */ platform.getPlatformInfo().setDelimiterToken( "" ); platform.setUsername( user ); platform.setPassword( passwd ); platform.createTables( dbModel, true, true ); // Insert the seed data to database DataToDatabaseSink sink = new DataToDatabaseSink( platform, dbModel ); DataReader reader = new DataReader(); reader.setModel( dbModel ); reader.setSink( sink ); InputStream seedDataStream = this.getClass().getClassLoader().getResourceAsStream( "photovault_seed_data.xml" ); try { reader.parse( seedDataStream ); } catch (SAXException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } // Create the database // TODO: Since the seed has only 48 significant bits this id is not really an // 128-bit random number!!! Random rnd = new Random(); String idStr = ""; StringBuffer idBuf = new StringBuffer(); for ( int n=0; n < 4; n++ ) { int r = rnd.nextInt(); idBuf.append( Integer.toHexString( r ) ); } idStr = idBuf.toString(); DynaBean dbInfo = dbModel.createDynaBeanFor( "database_info", false ); dbInfo.set( "database_id", idStr ); dbInfo.set( "schema_version", new Integer( CURRENT_SCHEMA_VERSION ) ); dbInfo.set( "create_time", new Timestamp( System.currentTimeMillis() ) ); platform.insert( dbModel, dbInfo ); }
fc.setSelectedFile(null);
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command == READ_GENOTYPES){ ReadDataDialog readDialog = new ReadDataDialog("Open new data", this); readDialog.pack(); readDialog.setVisible(true); } else if (command == READ_MARKERS){ //JFileChooser fc = new JFileChooser(System.getProperty("user.dir")); fc.setSelectedFile(null); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { readMarkers(fc.getSelectedFile()); } }else if (command == CUST_BLOCKS){ TweakBlockDefsDialog tweakDialog = new TweakBlockDefsDialog("Customize Blocks", this); tweakDialog.pack(); tweakDialog.setVisible(true); }else if (command == CLEAR_BLOCKS){ colorMenuItems[0].setSelected(true); for (int i = 1; i< colorMenuItems.length; i++){ colorMenuItems[i].setEnabled(false); } changeBlocks(3,1); //blockdef clauses }else if (command.startsWith("block")){ int method = Integer.valueOf(command.substring(5)).intValue(); changeBlocks(method,1); for (int i = 1; i < colorMenuItems.length; i++){ if (method+1 == i){ colorMenuItems[i].setEnabled(true); }else{ colorMenuItems[i].setEnabled(false); } } colorMenuItems[0].setSelected(true); //zooming clauses }else if (command.startsWith("zoom")){ dPrimeDisplay.zoom(Integer.valueOf(command.substring(4)).intValue()); //coloring clauses }else if (command.startsWith("color")){ dPrimeDisplay.refresh(Integer.valueOf(command.substring(5)).intValue()+1); changeKey(Integer.valueOf(command.substring(5)).intValue()+1); //exporting clauses }else if (command == EXPORT_PNG){ //JFileChooser fc = new JFileChooser(System.getProperty("user.dir")); if (fc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION){ export(tabs.getSelectedIndex(), PNG_MODE, fc.getSelectedFile()); } }else if (command == EXPORT_TEXT){ //JFileChooser fc = new JFileChooser(System.getProperty("user.dir")); if (fc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION){ export(tabs.getSelectedIndex(), TXT_MODE, fc.getSelectedFile()); } }else if (command == "Select All"){ checkPanel.selectAll(); }else if (command == "Rescore Markers"){ String cut = hwcut.getText(); if (cut.equals("")){ cut = "0"; } CheckData.hwCut = Double.parseDouble(cut); cut = genocut.getText(); if (cut.equals("")){ cut="0"; } CheckData.failedGenoCut = Integer.parseInt(cut); cut = mendcut.getText(); if (cut.equals("")){ cut="0"; } CheckData.numMendErrCut = Integer.parseInt(cut); checkPanel.redoRatings(); }else if (command == "Tutorial"){ showHelp(); } else if (command == QUIT){ quit(); } else { for (int i = 0; i < viewItems.length; i++) { if (command == viewItems[i]) tabs.setSelectedIndex(i); } } }
prefs.putInt(SwingUserSettings.DIVIDER_LOCATION, splitPane.getDividerLocation());
public void actionPerformed(ActionEvent e) { if (promptForUnsavedModifications()) { JFileChooser chooser = new JFileChooser(); chooser.addChoosableFileFilter(ASUtils.ARCHITECT_FILE_FILTER); int returnVal = chooser.showOpenDialog(ArchitectFrame.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File f = chooser.getSelectedFile(); LoadFileWorker worker; try { worker = new LoadFileWorker(f); recent.putRecentFileName(f.getAbsolutePath()); new Thread(worker).start(); } catch (FileNotFoundException e1) { JOptionPane.showMessageDialog( ArchitectFrame.this, "File not found: "+f.getPath()); } catch (Exception e1) { ASUtils.showExceptionDialog( ArchitectFrame.this, "Error loading file", e1); } } } }
splitPane.setDividerLocation (sprefs.getInt(SwingUserSettings.DIVIDER_LOCATION, 150));
splitPane.setDividerLocation(prefs.getInt(SwingUserSettings.DIVIDER_LOCATION,150));
protected void init() throws ArchitectException { int accelMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); prefs = PrefsUtils.getUserPrefsNode(architectSession); UserSettings us; // must be done right away, because a static // initializer in this class effects BeanUtils // behaviour which the XML Digester relies // upon heavily //TypeMap.getInstance(); contentPane = (JComponent)getContentPane(); try { ConfigFile cf = ConfigFile.getDefaultInstance(); us = cf.read(getArchitectSession()); architectSession.setUserSettings(us); sprefs = architectSession.getUserSettings().getSwingSettings(); } catch (IOException e) { throw new ArchitectException("prefs.read", e); } while (us.getPlDotIni() == null) { String message; String[] options = new String[] {"Browse", "Create"}; if (us.getPlDotIniPath() == null) { message = "location is not set"; } else if (new File(us.getPlDotIniPath()).isFile()) { message = "file \n\n\""+us.getPlDotIniPath()+"\"\n\n could not be read"; } else { message = "file \n\n\""+us.getPlDotIniPath()+"\"\n\n does not exist"; } int choice = JOptionPane.showOptionDialog(null, "The Architect keeps its list of database connections" + "\nin a file called PL.INI. Your PL.INI "+message+"." + "\n\nYou can browse for an existing PL.INI file on your system" + "\nor allow the Architect to create a new one in your home directory." + "\n\nHint: If you are a Power*Loader Suite user, you should browse for" + "\nan existing PL.INI in your Power*Loader installation directory.", "Missing PL.INI", 0, JOptionPane.INFORMATION_MESSAGE, null, options, null); File newPlIniFile; if (choice == 0) { JFileChooser fc = new JFileChooser(); fc.setFileFilter(ASUtils.INI_FILE_FILTER); fc.setDialogTitle("Locate your PL.INI file"); int fcChoice = fc.showOpenDialog(null); if (fcChoice == JFileChooser.APPROVE_OPTION) { newPlIniFile = fc.getSelectedFile(); } else { newPlIniFile = null; } } else { newPlIniFile = new File(System.getProperty("user.home"), "pl.ini"); } if (newPlIniFile != null) try { newPlIniFile.createNewFile(); us.setPlDotIniPath(newPlIniFile.getPath()); } catch (IOException e1) { logger.error("Caught IO exception while creating empty PL.INI at \"" +newPlIniFile.getPath()+"\"", e1); JOptionPane.showMessageDialog(null, "Failed to create file \""+newPlIniFile.getPath()+"\":\n"+e1.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } // Create actions aboutAction = new AboutAction(); newProjectAction = new AbstractAction("New Project", ASUtils.createJLFIcon("general/New","New Project",sprefs.getInt(SwingUserSettings.ICON_SIZE, 24))) { public void actionPerformed(ActionEvent e) { if (promptForUnsavedModifications()) { try { closeProject(getProject()); setProject(new SwingUIProject("New Project")); logger.debug("Glass pane is "+getGlassPane()); } catch (Exception ex) { JOptionPane.showMessageDialog(ArchitectFrame.this, "Can't create new project: "+ex.getMessage()); logger.error("Got exception while creating new project", ex); } } } }; newProjectAction.putValue(AbstractAction.SHORT_DESCRIPTION, "New"); newProjectAction.putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_N, accelMask)); final RecentMenu recent = new RecentMenu(this) { @Override public void loadFile(String fileName) throws IOException { openFile(fileName); } }; openProjectAction = new OpenProjectAction(recent); JMenuItem clearItem = new JMenuItem("Clear Recent Files"); clearItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { recent.clear(); } }); saveProjectAction = new AbstractAction("Save Project", ASUtils.createJLFIcon("general/Save", "Save Project", sprefs.getInt(SwingUserSettings.ICON_SIZE, 24))) { public void actionPerformed(ActionEvent e) { saveOrSaveAs(false, true); } }; saveProjectAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Save"); saveProjectAction.putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_S, accelMask)); saveProjectAsAction = new AbstractAction("Save Project As...", ASUtils.createJLFIcon("general/SaveAs", "Save Project As...", sprefs.getInt(SwingUserSettings.ICON_SIZE, 24))) { public void actionPerformed(ActionEvent e) { saveOrSaveAs(true, true); } }; saveProjectAsAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Save As"); prefAction = new PreferencesAction(); projectSettingsAction = new ProjectSettingsAction(); projectSettingsAction.putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_COMMA, accelMask)); printAction = new PrintAction(); printAction.putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_P, accelMask)); zoomInAction = new ZoomAction(ZOOM_STEP); zoomOutAction = new ZoomAction(ZOOM_STEP * -1.0); zoomNormalAction = new AbstractAction("Reset Zoom", ASUtils.createJLFIcon("general/Zoom", "Reset Zoom", sprefs.getInt(SwingUserSettings.ICON_SIZE, 24))) { public void actionPerformed(ActionEvent e) { playpen.setZoom(1.0); } }; zoomNormalAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Reset Zoom"); undoAction = new UndoAction(); redoAction = new RedoAction(); autoLayoutAction = new AutoLayoutAction(); autoLayout = new FruchtermanReingoldForceLayout(); autoLayoutAction.setLayout(autoLayout); exportDDLAction = new ExportDDLAction(); compareDMAction = new CompareDMAction(); exportPLTransAction = new ExportPLTransAction(); quickStartAction = new QuickStartAction(); deleteSelectedAction = new DeleteSelectedAction(); createIdentifyingRelationshipAction = new CreateRelationshipAction(true); createNonIdentifyingRelationshipAction = new CreateRelationshipAction(false); editRelationshipAction = new EditRelationshipAction(); createTableAction = new CreateTableAction(); editColumnAction = new EditColumnAction(); insertColumnAction = new InsertColumnAction(); editTableAction = new EditTableAction(); searchReplaceAction = new SearchReplaceAction(); searchReplaceAction.putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F, accelMask)); selectAllAction = new SelectAllAction(); selectAllAction.putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_A, accelMask)); menuBar = new JMenuBar(); //Settingup JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic('f'); fileMenu.add(newProjectAction); fileMenu.add(openProjectAction); fileMenu.add(recent); fileMenu.add(clearItem); fileMenu.add(saveProjectAction); fileMenu.add(saveProjectAsAction); fileMenu.add(printAction); fileMenu.add(prefAction); fileMenu.add(projectSettingsAction); fileMenu.add(saveSettingsAction); fileMenu.add(exitAction); menuBar.add(fileMenu); JMenu editMenu = new JMenu("Edit"); editMenu.setMnemonic('e'); editMenu.add(undoAction); editMenu.add(redoAction); editMenu.addSeparator(); editMenu.add(selectAllAction); editMenu.addSeparator(); editMenu.add(searchReplaceAction); menuBar.add(editMenu); // the connections menu is set up when a new project is created (because it depends on the current DBTree) connectionsMenu = new JMenu("Connections"); connectionsMenu.setMnemonic('c'); menuBar.add(connectionsMenu); JMenu etlMenu = new JMenu("ETL"); etlMenu.setMnemonic('l'); JMenu etlSubmenuOne = new JMenu("Power*Loader"); etlSubmenuOne.add(exportPLTransAction); etlSubmenuOne.add(new JMenuItem("PL Transaction File Export")); etlSubmenuOne.add(new JMenuItem("Run Power*Loader")); etlSubmenuOne.add(quickStartAction); etlMenu.add(etlSubmenuOne); menuBar.add(etlMenu); JMenu toolsMenu = new JMenu("Tools"); toolsMenu.setMnemonic('t'); toolsMenu.add(exportDDLAction); toolsMenu.add(compareDMAction); menuBar.add(toolsMenu); JMenu helpMenu = new JMenu("Help"); helpMenu.setMnemonic('h'); helpMenu.add(aboutAction); menuBar.add(helpMenu); setJMenuBar(menuBar); projectBar = new JToolBar(JToolBar.HORIZONTAL); ppBar = new JToolBar(JToolBar.VERTICAL); projectBar.add(newProjectAction); projectBar.add(openProjectAction); projectBar.add(saveProjectAction); projectBar.addSeparator(); projectBar.add(printAction); projectBar.addSeparator(); projectBar.add(undoAction); projectBar.add(redoAction); projectBar.addSeparator(); projectBar.add(exportDDLAction); projectBar.addSeparator(); projectBar.add(compareDMAction); projectBar.addSeparator(); projectBar.add(autoLayoutAction); projectBar.setToolTipText("Project Toolbar"); projectBar.setName("Project Toolbar"); JButton tempButton = null; // shared actions need to report where they are coming from ppBar.setToolTipText("PlayPen Toolbar"); ppBar.setName("PlayPen ToolBar"); ppBar.add(zoomInAction); ppBar.add(zoomOutAction); ppBar.add(zoomNormalAction); ppBar.addSeparator(); tempButton = ppBar.add(deleteSelectedAction); tempButton.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN); ppBar.addSeparator(); tempButton = ppBar.add(createTableAction); tempButton.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN); ppBar.addSeparator(); tempButton = ppBar.add(insertColumnAction); tempButton.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN); tempButton = ppBar.add(editColumnAction); tempButton.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN); ppBar.addSeparator(); ppBar.add(createNonIdentifyingRelationshipAction); ppBar.add(createIdentifyingRelationshipAction); tempButton = ppBar.add(editRelationshipAction); tempButton.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN); Container projectBarPane = getContentPane(); projectBarPane.setLayout(new BorderLayout()); projectBarPane.add(projectBar, BorderLayout.NORTH); JPanel cp = new JPanel(new BorderLayout()); cp.add(ppBar, BorderLayout.EAST); projectBarPane.add(cp, BorderLayout.CENTER); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); cp.add(splitPane, BorderLayout.CENTER); logger.debug("Added splitpane to content pane"); splitPane.setDividerLocation (sprefs.getInt(SwingUserSettings.DIVIDER_LOCATION, 150)); //dbTree.getPreferredSize().width)); Rectangle bounds = new Rectangle(); bounds.x = prefs.getInt(SwingUserSettings.MAIN_FRAME_X, 40); bounds.y = prefs.getInt(SwingUserSettings.MAIN_FRAME_Y, 40); bounds.width = prefs.getInt(SwingUserSettings.MAIN_FRAME_WIDTH, 600); bounds.height = prefs.getInt(SwingUserSettings.MAIN_FRAME_HEIGHT, 440); setBounds(bounds); addWindowListener(afWindowListener = new ArchitectFrameWindowListener()); setProject(new SwingUIProject("New Project")); }
prefs.putInt(SwingUserSettings.DIVIDER_LOCATION, splitPane.getDividerLocation());
public void actionPerformed(ActionEvent e) { if (promptForUnsavedModifications()) { try { closeProject(getProject()); setProject(new SwingUIProject("New Project")); logger.debug("Glass pane is "+getGlassPane()); } catch (Exception ex) { JOptionPane.showMessageDialog(ArchitectFrame.this, "Can't create new project: "+ex.getMessage()); logger.error("Got exception while creating new project", ex); } } }
splitPane.setRightComponent(new JScrollPane(playpen));
splitPane.setRightComponent(new JScrollPane(playpen)); splitPane.setDividerLocation(prefs.getInt(SwingUserSettings.DIVIDER_LOCATION,150));
public void setProject(SwingUIProject p) throws ArchitectException { this.project = p; logger.debug("Setting project to "+project); setTitle(project.getName()+" - Power*Architect"); playpen = project.getPlayPen(); dbTree = project.getSourceDatabases(); setupActions(); setupConnectionsMenu(); splitPane.setLeftComponent(new JScrollPane(dbTree)); splitPane.setRightComponent(new JScrollPane(playpen)); }
RMINotificationListener notifListener = toRMINotificationListener(listener); notifications.put(listener, notifListener); NotificationFilter notifFilter = toJMXNotificationFilter(filter);
public void addNotificationListener(ObjectName objectName, ObjectNotificationListener listener, ObjectNotificationFilter filter, Object handback){ RMINotificationListener notifListener = toRMINotificationListener(listener); notifications.put(listener, notifListener); NotificationFilter notifFilter = toJMXNotificationFilter(filter); try { rmiAdaptor.addNotificationListener(toJMXObjectName(objectName), notifListener, notifFilter, handback); } catch (Exception e) { throw new RuntimeException(e); } }
notifListener, notifFilter, handback);
notifListener, notifFilter, new String());
public void addNotificationListener(ObjectName objectName, ObjectNotificationListener listener, ObjectNotificationFilter filter, Object handback){ RMINotificationListener notifListener = toRMINotificationListener(listener); notifications.put(listener, notifListener); NotificationFilter notifFilter = toJMXNotificationFilter(filter); try { rmiAdaptor.addNotificationListener(toJMXObjectName(objectName), notifListener, notifFilter, handback); } catch (Exception e) { throw new RuntimeException(e); } }
RMINotificationListener notifListener = (RMINotificationListener)notifications.remove(listener);
MyRMINotificationListener notifListener = (MyRMINotificationListener) notifications.remove(listener);
public void removeNotificationListener(ObjectName objectName, ObjectNotificationListener listener, ObjectNotificationFilter filter, Object handback){ RMINotificationListener notifListener = (RMINotificationListener)notifications.remove(listener); assert notifListener != null; try { rmiAdaptor.removeNotificationListener(toJMXObjectName(objectName), notifListener); } catch (Exception e) { throw new RuntimeException(e); } }
notifListener.unexport();
public void removeNotificationListener(ObjectName objectName, ObjectNotificationListener listener, ObjectNotificationFilter filter, Object handback){ RMINotificationListener notifListener = (RMINotificationListener)notifications.remove(listener); assert notifListener != null; try { rmiAdaptor.removeNotificationListener(toJMXObjectName(objectName), notifListener); } catch (Exception e) { throw new RuntimeException(e); } }
private static RMINotificationListener toRMINotificationListener( final ObjectNotificationListener listener){
private static MyRMINotificationListener toRMINotificationListener( final ObjectNotificationListener listener) {
private static RMINotificationListener toRMINotificationListener( final ObjectNotificationListener listener){ return new MyRMINotificationListener(listener); }
throw new RuntimeException("Notifications not supported");
NotificationListener notifListener = toJMXNotificationListener(listener); notifications.put(listener, notifListener); NotificationFilter notifFilter = toJMXNotificationFilter(filter); notifFilters.put(filter, notifFilter); Class[] methodSignature = new Class[]{javax.management.ObjectName.class, NotificationListener.class, NotificationFilter.class, Object.class}; Object[] methodArgs = new Object[]{toJMXObjectName(objectName), notifListener, notifFilter, handback}; callMBeanServer("addNotificationListener", methodSignature, methodArgs);
public void addNotificationListener(ObjectName objectName, ObjectNotificationListener listener, ObjectNotificationFilter filter, Object handback){ throw new RuntimeException("Notifications not supported"); }
if ( !testFile.exists() ) { fail( "could not find test file " + testFile ); }
public void testThumbWithNoInstances() { PhotoInfo photo = PhotoInfo.create(); Thumbnail thumb = photo.getThumbnail(); assertTrue( "getThumbnail should return default thumbnail", thumb == Thumbnail.getDefaultThumbnail() ) ; assertEquals( "No new instances should have been created", 0, photo.getNumInstances() ); // Create a new instance and check that a valid thumbnail is returned after this File testFile = new File( testImgDir, "test1.jpg" ); File instanceFile = Volume.getDefaultVolume().getFilingFname( testFile ); try { FileUtils.copyFile( testFile, instanceFile ); } catch ( IOException e ) { fail( e.getMessage() ); } photo.addInstance( Volume.getDefaultVolume(), instanceFile, ImageInstance.INSTANCE_TYPE_ORIGINAL ); Thumbnail thumb2 = photo.getThumbnail(); assertFalse( "After instance addition, getThumbnail should not return default thumbnail", thumb == thumb2 ); assertEquals( "There should be 2 instances: original & thumbnail", 2, photo.getNumInstances() ); photo.delete(); }
for (int i = 0; i < viewItems.length; i++) { if (command.equals(viewItems[i])) tabs.setSelectedIndex(i);
for (int i = 0; i < tabs.getTabCount(); i++) { if (command.equals(tabs.getTitleAt(i))){ tabs.setSelectedIndex(i); break; }
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command.equals(READ_GENOTYPES)){ ReadDataDialog readDialog = new ReadDataDialog("Open new data", this); readDialog.pack(); readDialog.setVisible(true); } else if (command.equals(READ_MARKERS)){ //JFileChooser fc = new JFileChooser(System.getProperty("user.dir")); fc.setSelectedFile(new File("")); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { readMarkers(fc.getSelectedFile(),null); } }else if (command.equals(READ_ANALYSIS_TRACK)){ fc.setSelectedFile(new File("")); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION){ readAnalysisFile(fc.getSelectedFile()); } }else if (command.equals(DOWNLOAD_GBROWSE)){ GBrowseDialog gbd = new GBrowseDialog(this, "Connect to HapMap Info Server"); gbd.pack(); gbd.setVisible(true); }else if (command.equals(GBROWSE_OPTS)){ GBrowseOptionDialog gbod = new GBrowseOptionDialog(this, "HapMap Info Track Options"); gbod.pack(); gbod.setVisible(true); }else if (command.equals(READ_BLOCKS_FILE)){ fc.setSelectedFile(new File("")); if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION){ readBlocksFile(fc.getSelectedFile()); } }else if (command.equals(CUST_BLOCKS)){ TweakBlockDefsDialog tweakDialog = new TweakBlockDefsDialog("Customize Blocks", this); tweakDialog.pack(); tweakDialog.setVisible(true); }else if (command.equals(CLEAR_BLOCKS)){ changeBlocks(BLOX_NONE); //blockdef clauses }else if (command.startsWith("block")){ int method = Integer.valueOf(command.substring(5)).intValue(); changeBlocks(method); //zooming clauses }else if (command.startsWith("zoom")){ dPrimeDisplay.zoom(Integer.valueOf(command.substring(4)).intValue()); //coloring clauses }else if (command.startsWith("color")){ Options.setLDColorScheme(Integer.valueOf(command.substring(5)).intValue()); dPrimeDisplay.colorDPrime(); changeKey(); //exporting clauses }else if (command.equals(EXPORT_PNG)){ export((HaploviewTab)tabs.getSelectedComponent(), PNG_MODE, 0, Chromosome.getUnfilteredSize()); }else if (command.equals(EXPORT_TEXT)){ export((HaploviewTab)tabs.getSelectedComponent(), TXT_MODE, 0, Chromosome.getUnfilteredSize()); }else if (command.equals(EXPORT_OPTIONS)){ ExportDialog exDialog = new ExportDialog(this); exDialog.pack(); exDialog.setVisible(true); }else if (command.equals("Select All")){ checkPanel.selectAll(); }else if (command.equals("Rescore Markers")){ String cut = cdc.hwcut.getText(); if (cut.equals("")){ cut = "0"; } CheckData.hwCut = Double.parseDouble(cut); cut = cdc.genocut.getText(); if (cut.equals("")){ cut="0"; } CheckData.failedGenoCut = Integer.parseInt(cut); cut = cdc.mendcut.getText(); if (cut.equals("")){ cut="0"; } CheckData.numMendErrCut = Integer.parseInt(cut); cut = cdc.mafcut.getText(); if (cut.equals("")){ cut="0"; } CheckData.mafCut = Double.parseDouble(cut); checkPanel.redoRatings(); JTable jt = checkPanel.getTable(); jt.repaint(); }else if (command.equals("LD Display Spacing")){ ProportionalSpacingDialog spaceDialog = new ProportionalSpacingDialog(this, "Adjust LD Spacing"); spaceDialog.pack(); spaceDialog.setVisible(true); }else if (command.equals("About Haploview")){ JOptionPane.showMessageDialog(this, ABOUT_STRING, "About Haploview", JOptionPane.INFORMATION_MESSAGE); } else if(command.equals("Check for update")) { final SwingWorker worker = new SwingWorker(){ UpdateChecker uc; String unableToConnect; public Object construct() { uc = new UpdateChecker(); try { uc.checkForUpdate(); } catch(IOException ioe) { unableToConnect = ioe.getMessage(); } return null; } public void finished() { window.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); if(uc != null) { if(unableToConnect != null) { JOptionPane.showMessageDialog(window, "An error occured while checking for update.\n " + unableToConnect , "Update Check", JOptionPane.ERROR_MESSAGE); } else if(uc.isNewVersionAvailable()) { UpdateDisplayDialog udp = new UpdateDisplayDialog(window,"Update Check",uc); udp.pack(); udp.setVisible(true); } else { JOptionPane.showMessageDialog(window, "Your version of Haploview is up to date.", "Update Check", JOptionPane.INFORMATION_MESSAGE); } } } }; setCursor(new Cursor(Cursor.WAIT_CURSOR)); worker.start(); }else if (command.equals("Quit")){ quit(); } else { for (int i = 0; i < viewItems.length; i++) { if (command.equals(viewItems[i])) tabs.setSelectedIndex(i); } } }
return "Exit from jManage command prompt mode";
return "Exits from jManage command prompt mode";
public String getShortHelp(){ return "Exit from jManage command prompt mode"; }
series[i].setMaximumItemCount(100);
private void poll() { Properties properties = getNewValues(); if(properties == null) return; long timestamp = Long.parseLong(properties.getProperty("timestamp")); // todo: this is not used String attributes = properties.getProperty("attributes"); String values = properties.getProperty("values"); if(dataset == null){ dataset = new TimeSeriesCollection(); dataset.setDomainIsPointsInTime(false); StringTokenizer tokenizer = new StringTokenizer(displayNames, "|"); series = new TimeSeries[tokenizer.countTokens()]; for(int i=0; tokenizer.hasMoreTokens(); i++){ series[i] = new TimeSeries(tokenizer.nextToken(), Second.class); dataset.addSeries(series[i]); } } /* set the next set of values */ StringTokenizer tokenizer = new StringTokenizer(values, "|"); assert series.length == tokenizer.countTokens(); Second second = new Second(new Date(timestamp)); for(int i=0; i<series.length; i++){ double attrValue = Double.parseDouble(tokenizer.nextToken()); attrValue = scaleUp?attrValue * scaleFactor: attrValue/scaleFactor; series[i].add(second, attrValue); } }
if(authorizedList == null || authorizedList.isEmpty()) return false;
public boolean isAuthorized(ACLContext context, User user) { List authorizedList = getAuthorizedList(context); for(Iterator it=authorizedList.iterator(); it.hasNext(); ){ String authorized = (String)it.next(); if(user.getName().equals(authorized) || user.hasRole(authorized)){ return true; } } return false; }
if (!(thisAllele-5 == a1)){
if (!(thisAllele-4 == a1)){
void prepareMarkerInput(File infile, long md, String[][] hapmapGoodies) throws IOException, HaploViewException{ //this method is called to gather data about the markers used. //It is assumed that the input file is two columns, the first being //the name and the second the absolute position. the maxdist is //used to determine beyond what distance comparisons will not be //made. if the infile param is null, loads up "dummy info" for //situation where no info file exists Vector names = new Vector(); Vector positions = new Vector(); maxdist = md; negMaxdist = -1 * maxdist; try{ if (infile != null){ if (infile.length() < 1){ throw new HaploViewException("Info file is empty or does not exist: " + infile.getName()); } String currentLine; long prevloc = -1000000000; //read the input file: BufferedReader in = new BufferedReader(new FileReader(infile)); int lineCount = 0; while ((currentLine = in.readLine()) != null){ StringTokenizer st = new StringTokenizer(currentLine); if (st.countTokens() > 1){ lineCount++; }else if (st.countTokens() == 1){ //complain if only one field found throw new HaploViewException("Info file format error on line "+lineCount+ ":\n Info file must be of format: <markername> <markerposition>"); }else{ //skip blank lines continue; } String name = st.nextToken(); String l = st.nextToken(); long loc; try{ loc = Long.parseLong(l); }catch (NumberFormatException nfe){ throw new HaploViewException("Info file format error on line "+lineCount+ ":\n\"" + l + "\" should be of type long." + "\n Info file must be of format: <markername> <markerposition>"); } if (loc < prevloc){ throw new HaploViewException("Info file out of order:\n"+ name); } prevloc = loc; names.add(name); positions.add(l); } if (lineCount > Chromosome.getSize()){ throw(new HaploViewException("Info file error:\nMarker number mismatch: too many\nmarkers in info file.")); } if (lineCount < Chromosome.getSize()){ throw(new HaploViewException("Info file error:\nMarker number mismatch: too few\nmarkers in info file.")); } infoKnown=true; } if (hapmapGoodies != null){ //we know some stuff from the hapmap so we'll add it here for (int x=0; x < hapmapGoodies.length; x++){ names.add(hapmapGoodies[x][0]); positions.add(hapmapGoodies[x][1]); } infoKnown = true; } }catch (HaploViewException e){ throw(e); }finally{ double numChroms = chromosomes.size(); Vector markerInfo = new Vector(); double[] numBadGenotypes = new double[Chromosome.getSize()]; percentBadGenotypes = new double[Chromosome.getSize()]; for (int i = 0; i < Chromosome.getSize(); i++){ //to compute maf, browse chrom list and count instances of each allele byte a1 = 0; byte a2 = 0; double numa1 = 0; double numa2 = 0; for (int j = 0; j < chromosomes.size(); j++){ //if there is a data point for this marker on this chromosome byte thisAllele = ((Chromosome)chromosomes.elementAt(j)).getGenotype(i); if (!(thisAllele == 0)){ if (thisAllele >= 5){ numa1+=0.5; numa2+=0.5; if (thisAllele < 9){ if (a1==0){ a1 = (byte)(thisAllele-4); }else if (a2 == 0){ if (!(thisAllele-5 == a1)){ a2 = (byte)(thisAllele-4); } } } }else if (a1 == 0){ a1 = thisAllele; numa1++; }else if (thisAllele == a1){ numa1++; }else{ numa2++; a2 = thisAllele; } } else { numBadGenotypes[i]++; } } if (numa2 > numa1){ byte temp = a1; a1 = a2; a2 = temp; } double maf = numa1/(numa2+numa1); if (maf > 0.5) maf = 1.0-maf; if (infoKnown){ markerInfo.add(new SNP((String)names.elementAt(i), Long.parseLong((String)positions.elementAt(i)), Math.rint(maf*100.0)/100.0, a1, a2)); }else{ markerInfo.add(new SNP("Marker " + String.valueOf(i+1), (i*4000), Math.rint(maf*100.0)/100.0,a1,a2)); } percentBadGenotypes[i] = numBadGenotypes[i]/numChroms; } Chromosome.markers = markerInfo.toArray(); } }
public void adjustDisplay() {
public void adjustDisplay(int dt){
public void adjustDisplay() { //this is called when the controller wants to change the haps //displayed, instead of directly repainting so that none of this math //is done when the screen repaints for other reasons (resizing, focus change, etc) //first filter haps on displaythresh filteredHaplos = new Haplotype[orderedHaplos.length][]; boolean atLeastOneHap = false; int printable = 0; for (int i = 0; i < orderedHaplos.length; i++){ Vector tempVector = new Vector(); for (int j = 0; j < orderedHaplos[i].length; j++){ if (orderedHaplos[i][j].getPercentage()*100 > displayThresh){ tempVector.add(orderedHaplos[i][j]); atLeastOneHap=true; } } if (atLeastOneHap){ printable++; atLeastOneHap=false; } filteredHaplos[i] = new Haplotype[tempVector.size()]; tempVector.copyInto(filteredHaplos[i]); } // if user sets display thresh higher than most common hap in any given block if (!(printable == filteredHaplos.length)) return; //then re-tag try{ filteredHaplos = theData.generateCrossovers(filteredHaplos); }catch (HaploViewException e){ JOptionPane.showMessageDialog(this.getParent(), e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } multidprimeArray = theData.getMultiDprime(); repaint(); }
filteredHaplos = new Haplotype[orderedHaplos.length][]; boolean atLeastOneHap = false;
Haplotype[][] filts; filts = new Haplotype[orderedHaplos.length][]; int numhaps = 0;
public void adjustDisplay() { //this is called when the controller wants to change the haps //displayed, instead of directly repainting so that none of this math //is done when the screen repaints for other reasons (resizing, focus change, etc) //first filter haps on displaythresh filteredHaplos = new Haplotype[orderedHaplos.length][]; boolean atLeastOneHap = false; int printable = 0; for (int i = 0; i < orderedHaplos.length; i++){ Vector tempVector = new Vector(); for (int j = 0; j < orderedHaplos[i].length; j++){ if (orderedHaplos[i][j].getPercentage()*100 > displayThresh){ tempVector.add(orderedHaplos[i][j]); atLeastOneHap=true; } } if (atLeastOneHap){ printable++; atLeastOneHap=false; } filteredHaplos[i] = new Haplotype[tempVector.size()]; tempVector.copyInto(filteredHaplos[i]); } // if user sets display thresh higher than most common hap in any given block if (!(printable == filteredHaplos.length)) return; //then re-tag try{ filteredHaplos = theData.generateCrossovers(filteredHaplos); }catch (HaploViewException e){ JOptionPane.showMessageDialog(this.getParent(), e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } multidprimeArray = theData.getMultiDprime(); repaint(); }
if (orderedHaplos[i][j].getPercentage()*100 > displayThresh){
if (orderedHaplos[i][j].getPercentage()*100 > dt){
public void adjustDisplay() { //this is called when the controller wants to change the haps //displayed, instead of directly repainting so that none of this math //is done when the screen repaints for other reasons (resizing, focus change, etc) //first filter haps on displaythresh filteredHaplos = new Haplotype[orderedHaplos.length][]; boolean atLeastOneHap = false; int printable = 0; for (int i = 0; i < orderedHaplos.length; i++){ Vector tempVector = new Vector(); for (int j = 0; j < orderedHaplos[i].length; j++){ if (orderedHaplos[i][j].getPercentage()*100 > displayThresh){ tempVector.add(orderedHaplos[i][j]); atLeastOneHap=true; } } if (atLeastOneHap){ printable++; atLeastOneHap=false; } filteredHaplos[i] = new Haplotype[tempVector.size()]; tempVector.copyInto(filteredHaplos[i]); } // if user sets display thresh higher than most common hap in any given block if (!(printable == filteredHaplos.length)) return; //then re-tag try{ filteredHaplos = theData.generateCrossovers(filteredHaplos); }catch (HaploViewException e){ JOptionPane.showMessageDialog(this.getParent(), e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } multidprimeArray = theData.getMultiDprime(); repaint(); }
atLeastOneHap=true;
numhaps++;
public void adjustDisplay() { //this is called when the controller wants to change the haps //displayed, instead of directly repainting so that none of this math //is done when the screen repaints for other reasons (resizing, focus change, etc) //first filter haps on displaythresh filteredHaplos = new Haplotype[orderedHaplos.length][]; boolean atLeastOneHap = false; int printable = 0; for (int i = 0; i < orderedHaplos.length; i++){ Vector tempVector = new Vector(); for (int j = 0; j < orderedHaplos[i].length; j++){ if (orderedHaplos[i][j].getPercentage()*100 > displayThresh){ tempVector.add(orderedHaplos[i][j]); atLeastOneHap=true; } } if (atLeastOneHap){ printable++; atLeastOneHap=false; } filteredHaplos[i] = new Haplotype[tempVector.size()]; tempVector.copyInto(filteredHaplos[i]); } // if user sets display thresh higher than most common hap in any given block if (!(printable == filteredHaplos.length)) return; //then re-tag try{ filteredHaplos = theData.generateCrossovers(filteredHaplos); }catch (HaploViewException e){ JOptionPane.showMessageDialog(this.getParent(), e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } multidprimeArray = theData.getMultiDprime(); repaint(); }
if (atLeastOneHap){ printable++; atLeastOneHap=false;
if (numhaps > 1){ printable++; numhaps=0;
public void adjustDisplay() { //this is called when the controller wants to change the haps //displayed, instead of directly repainting so that none of this math //is done when the screen repaints for other reasons (resizing, focus change, etc) //first filter haps on displaythresh filteredHaplos = new Haplotype[orderedHaplos.length][]; boolean atLeastOneHap = false; int printable = 0; for (int i = 0; i < orderedHaplos.length; i++){ Vector tempVector = new Vector(); for (int j = 0; j < orderedHaplos[i].length; j++){ if (orderedHaplos[i][j].getPercentage()*100 > displayThresh){ tempVector.add(orderedHaplos[i][j]); atLeastOneHap=true; } } if (atLeastOneHap){ printable++; atLeastOneHap=false; } filteredHaplos[i] = new Haplotype[tempVector.size()]; tempVector.copyInto(filteredHaplos[i]); } // if user sets display thresh higher than most common hap in any given block if (!(printable == filteredHaplos.length)) return; //then re-tag try{ filteredHaplos = theData.generateCrossovers(filteredHaplos); }catch (HaploViewException e){ JOptionPane.showMessageDialog(this.getParent(), e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } multidprimeArray = theData.getMultiDprime(); repaint(); }
filteredHaplos[i] = new Haplotype[tempVector.size()]; tempVector.copyInto(filteredHaplos[i]);
filts[i] = new Haplotype[tempVector.size()]; tempVector.copyInto(filts[i]);
public void adjustDisplay() { //this is called when the controller wants to change the haps //displayed, instead of directly repainting so that none of this math //is done when the screen repaints for other reasons (resizing, focus change, etc) //first filter haps on displaythresh filteredHaplos = new Haplotype[orderedHaplos.length][]; boolean atLeastOneHap = false; int printable = 0; for (int i = 0; i < orderedHaplos.length; i++){ Vector tempVector = new Vector(); for (int j = 0; j < orderedHaplos[i].length; j++){ if (orderedHaplos[i][j].getPercentage()*100 > displayThresh){ tempVector.add(orderedHaplos[i][j]); atLeastOneHap=true; } } if (atLeastOneHap){ printable++; atLeastOneHap=false; } filteredHaplos[i] = new Haplotype[tempVector.size()]; tempVector.copyInto(filteredHaplos[i]); } // if user sets display thresh higher than most common hap in any given block if (!(printable == filteredHaplos.length)) return; //then re-tag try{ filteredHaplos = theData.generateCrossovers(filteredHaplos); }catch (HaploViewException e){ JOptionPane.showMessageDialog(this.getParent(), e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } multidprimeArray = theData.getMultiDprime(); repaint(); }
if (!(printable == filteredHaplos.length)) return;
if (!(printable == filts.length)){ JOptionPane.showMessageDialog(this.getParent(), "Error: At least one block has too few haplotypes of frequency > " + dt, "Error", JOptionPane.ERROR_MESSAGE); return; }
public void adjustDisplay() { //this is called when the controller wants to change the haps //displayed, instead of directly repainting so that none of this math //is done when the screen repaints for other reasons (resizing, focus change, etc) //first filter haps on displaythresh filteredHaplos = new Haplotype[orderedHaplos.length][]; boolean atLeastOneHap = false; int printable = 0; for (int i = 0; i < orderedHaplos.length; i++){ Vector tempVector = new Vector(); for (int j = 0; j < orderedHaplos[i].length; j++){ if (orderedHaplos[i][j].getPercentage()*100 > displayThresh){ tempVector.add(orderedHaplos[i][j]); atLeastOneHap=true; } } if (atLeastOneHap){ printable++; atLeastOneHap=false; } filteredHaplos[i] = new Haplotype[tempVector.size()]; tempVector.copyInto(filteredHaplos[i]); } // if user sets display thresh higher than most common hap in any given block if (!(printable == filteredHaplos.length)) return; //then re-tag try{ filteredHaplos = theData.generateCrossovers(filteredHaplos); }catch (HaploViewException e){ JOptionPane.showMessageDialog(this.getParent(), e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } multidprimeArray = theData.getMultiDprime(); repaint(); }
displayThresh = dt; filteredHaplos = filts;
public void adjustDisplay() { //this is called when the controller wants to change the haps //displayed, instead of directly repainting so that none of this math //is done when the screen repaints for other reasons (resizing, focus change, etc) //first filter haps on displaythresh filteredHaplos = new Haplotype[orderedHaplos.length][]; boolean atLeastOneHap = false; int printable = 0; for (int i = 0; i < orderedHaplos.length; i++){ Vector tempVector = new Vector(); for (int j = 0; j < orderedHaplos[i].length; j++){ if (orderedHaplos[i][j].getPercentage()*100 > displayThresh){ tempVector.add(orderedHaplos[i][j]); atLeastOneHap=true; } } if (atLeastOneHap){ printable++; atLeastOneHap=false; } filteredHaplos[i] = new Haplotype[tempVector.size()]; tempVector.copyInto(filteredHaplos[i]); } // if user sets display thresh higher than most common hap in any given block if (!(printable == filteredHaplos.length)) return; //then re-tag try{ filteredHaplos = theData.generateCrossovers(filteredHaplos); }catch (HaploViewException e){ JOptionPane.showMessageDialog(this.getParent(), e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } multidprimeArray = theData.getMultiDprime(); repaint(); }
adjustDisplay();
adjustDisplay(displayThresh);
public void getHaps() throws HaploViewException{ if (theData.blocks == null) {return;} Haplotype[][] haplos = theData.generateHaplotypes(theData.blocks, 0); orderedHaplos = new Haplotype[haplos.length][]; for (int i = 0; i < haplos.length; i++) { Vector orderedHaps = new Vector(); //step through each haplotype in this block for (int hapCount = 0; hapCount < haplos[i].length; hapCount++) { if (orderedHaps.size() == 0) { orderedHaps.add(haplos[i][hapCount]); } else { for (int j = 0; j < orderedHaps.size(); j++) { if (((Haplotype)(orderedHaps.elementAt(j))).getPercentage() < haplos[i][hapCount].getPercentage()) { orderedHaps.add(j, haplos[i][hapCount]); break; } if ((j+1) == orderedHaps.size()) { orderedHaps.add(haplos[i][hapCount]); break; } } } } orderedHaplos[i] = new Haplotype[orderedHaps.size()]; orderedHaps.copyInto(orderedHaplos[i]); } adjustDisplay(); }
result = FilteringScore.rangeComparator() .compare(first.getFilteringScore(), second.getFilteringScore());
FilteringScore<?> firstScore = first.getFilteringScore(); FilteringScore<?> secondScore = second.getFilteringScore(); result = FilteringScore.rangeComparator().compare(firstScore, secondScore);
public int compare(CompositeScore<?> first, CompositeScore<?> second) { int result = FilteringScore.nullCompare(first, second); if (result != 0) { return result; } result = FilteringScore.rangeComparator() .compare(first.getFilteringScore(), second.getFilteringScore()); if (result != 0) { return result; } result = OrderingScore.fullComparator() .compare(first.getOrderingScore(), second.getOrderingScore()); if (result != 0) { return result; } result = FilteringScore.fullComparator() .compare(first.getFilteringScore(), second.getFilteringScore()); return result; }
result = OrderingScore.fullComparator() .compare(first.getOrderingScore(), second.getOrderingScore());
if (considerOrdering(firstScore) && considerOrdering(secondScore)) {
public int compare(CompositeScore<?> first, CompositeScore<?> second) { int result = FilteringScore.nullCompare(first, second); if (result != 0) { return result; } result = FilteringScore.rangeComparator() .compare(first.getFilteringScore(), second.getFilteringScore()); if (result != 0) { return result; } result = OrderingScore.fullComparator() .compare(first.getOrderingScore(), second.getOrderingScore()); if (result != 0) { return result; } result = FilteringScore.fullComparator() .compare(first.getFilteringScore(), second.getFilteringScore()); return result; }
if (result != 0) { return result;
result = OrderingScore.fullComparator() .compare(first.getOrderingScore(), second.getOrderingScore()); if (result != 0) { return result; }
public int compare(CompositeScore<?> first, CompositeScore<?> second) { int result = FilteringScore.nullCompare(first, second); if (result != 0) { return result; } result = FilteringScore.rangeComparator() .compare(first.getFilteringScore(), second.getFilteringScore()); if (result != 0) { return result; } result = OrderingScore.fullComparator() .compare(first.getOrderingScore(), second.getOrderingScore()); if (result != 0) { return result; } result = FilteringScore.fullComparator() .compare(first.getFilteringScore(), second.getFilteringScore()); return result; }
result = FilteringScore.fullComparator() .compare(first.getFilteringScore(), second.getFilteringScore());
result = FilteringScore.fullComparator().compare(firstScore, secondScore);
public int compare(CompositeScore<?> first, CompositeScore<?> second) { int result = FilteringScore.nullCompare(first, second); if (result != 0) { return result; } result = FilteringScore.rangeComparator() .compare(first.getFilteringScore(), second.getFilteringScore()); if (result != 0) { return result; } result = OrderingScore.fullComparator() .compare(first.getOrderingScore(), second.getOrderingScore()); if (result != 0) { return result; } result = FilteringScore.fullComparator() .compare(first.getFilteringScore(), second.getFilteringScore()); return result; }
(OrderedProperty<S>[] indexProperties, boolean unique, boolean clustered,
(StorableIndex<S> index,
public static <S extends Storable> OrderingScore<S> evaluate (OrderedProperty<S>[] indexProperties, boolean unique, boolean clustered, Filter<S> filter, OrderingList<S> ordering) { if (indexProperties == null) { throw new IllegalArgumentException("Index properties required"); } // Get filter list early to detect errors. List<PropertyFilter<S>> filterList = PropertyFilterList.get(filter); if (ordering == null) { ordering = OrderingList.emptyList(); } // Ordering properties which match identity filters don't affect order // results. Build up this set to find them quickly. Set<ChainedProperty<S>> identityPropSet = new HashSet<ChainedProperty<S>>(filterList.size()); for (PropertyFilter<S> propFilter : filterList) { if (propFilter.getOperator() == RelOp.EQ) { identityPropSet.add(propFilter.getChainedProperty()); } } OrderingList<S> handledOrdering = OrderingList.emptyList(); OrderingList<S> remainderOrdering = OrderingList.emptyList(); OrderingList<S> freeOrdering = OrderingList.emptyList(); OrderingList<S> unusedOrdering = OrderingList.emptyList(); // Build up list of unused properties that were filtered out. for (int i=0; i<indexProperties.length; i++) { OrderedProperty<S> indexProp = indexProperties[i]; ChainedProperty<S> indexChained = indexProp.getChainedProperty(); if (identityPropSet.contains(indexChained)) { unusedOrdering = unusedOrdering.concat(indexProp.direction(UNSPECIFIED)); } } // If index is unique and every property is matched by an identity // filter, then there won't be any handled or remainder properties. uniquelyCheck: if (unique) { for (int i=0; i<indexProperties.length; i++) { ChainedProperty<S> indexChained = indexProperties[i].getChainedProperty(); if (!identityPropSet.contains(indexChained)) { // Missed a property, so ordering is still relevant. break uniquelyCheck; } } return new OrderingScore<S>(clustered, indexProperties.length, handledOrdering, // no handled properties remainderOrdering, // no remainder properties false, // no need to reverse order freeOrdering, // no free properties unusedOrdering); } Boolean shouldReverseOrder = null; Set<ChainedProperty<S>> seen = new HashSet<ChainedProperty<S>>(); boolean gap = false; int indexPos = 0; calcScore: for (int i=0; i<ordering.size(); i++) { OrderedProperty<S> property = ordering.get(i); ChainedProperty<S> chained = property.getChainedProperty(); if (seen.contains(chained)) { // Redundant property doesn't affect ordering. continue calcScore; } seen.add(chained); if (identityPropSet.contains(chained)) { // Doesn't affect ordering. continue calcScore; } indexPosMatch: while (!gap && indexPos < indexProperties.length) { OrderedProperty<S> indexProp = indexProperties[indexPos]; ChainedProperty<S> indexChained = indexProp.getChainedProperty(); if (chained.equals(indexChained)) { Direction indexDir = indexProp.getDirection(); if (indexDir == UNSPECIFIED) { // Assume index natural order is ascending. indexDir = ASCENDING; } if (shouldReverseOrder != null && shouldReverseOrder) { indexDir = indexDir.reverse(); } if (property.getDirection() == UNSPECIFIED) { // Set handled property direction to match index. property = property.direction(indexDir); } else if (shouldReverseOrder == null) { shouldReverseOrder = indexDir != property.getDirection(); // Any properies already in the list had been // originally unspecified. They might need to be // reversed now. if (shouldReverseOrder) { handledOrdering = handledOrdering.reverseDirections(); } } else if (indexDir != property.getDirection()) { // Direction mismatch, so cannot be handled. break indexPosMatch; } handledOrdering = handledOrdering.concat(property); indexPos++; continue calcScore; } if (identityPropSet.contains(indexChained)) { // Even though ordering did not match index at current // position, the search for handled propertes can continue if // index gap matches an identity filter. indexPos++; continue indexPosMatch; } // Index gap, so cannot be handled. break indexPosMatch; } // Property not handled and not an identity filter. remainderOrdering = remainderOrdering.concat(property); gap = true; } // Walk through all remaining index properties and list them as free. while (indexPos < indexProperties.length) { OrderedProperty<S> freeProp = indexProperties[indexPos]; ChainedProperty<S> freeChained = freeProp.getChainedProperty(); // Don't list as free if already listed as unused. if (!identityPropSet.contains(freeChained)) { if (shouldReverseOrder == null) { freeProp = freeProp.direction(UNSPECIFIED); } else { Direction freePropDir = freePropDir = freeProp.getDirection(); if (freePropDir == UNSPECIFIED) { freePropDir = ASCENDING; } if (shouldReverseOrder) { freeProp = freeProp.direction(freePropDir.reverse()); } } freeOrdering = freeOrdering.concat(freeProp); } indexPos++; } if (shouldReverseOrder == null) { shouldReverseOrder = false; } return new OrderingScore<S>(clustered, indexProperties.length, handledOrdering, remainderOrdering, shouldReverseOrder, freeOrdering, unusedOrdering); }
if (indexProperties == null) { throw new IllegalArgumentException("Index properties required");
if (index == null) { throw new IllegalArgumentException("Index required");
public static <S extends Storable> OrderingScore<S> evaluate (OrderedProperty<S>[] indexProperties, boolean unique, boolean clustered, Filter<S> filter, OrderingList<S> ordering) { if (indexProperties == null) { throw new IllegalArgumentException("Index properties required"); } // Get filter list early to detect errors. List<PropertyFilter<S>> filterList = PropertyFilterList.get(filter); if (ordering == null) { ordering = OrderingList.emptyList(); } // Ordering properties which match identity filters don't affect order // results. Build up this set to find them quickly. Set<ChainedProperty<S>> identityPropSet = new HashSet<ChainedProperty<S>>(filterList.size()); for (PropertyFilter<S> propFilter : filterList) { if (propFilter.getOperator() == RelOp.EQ) { identityPropSet.add(propFilter.getChainedProperty()); } } OrderingList<S> handledOrdering = OrderingList.emptyList(); OrderingList<S> remainderOrdering = OrderingList.emptyList(); OrderingList<S> freeOrdering = OrderingList.emptyList(); OrderingList<S> unusedOrdering = OrderingList.emptyList(); // Build up list of unused properties that were filtered out. for (int i=0; i<indexProperties.length; i++) { OrderedProperty<S> indexProp = indexProperties[i]; ChainedProperty<S> indexChained = indexProp.getChainedProperty(); if (identityPropSet.contains(indexChained)) { unusedOrdering = unusedOrdering.concat(indexProp.direction(UNSPECIFIED)); } } // If index is unique and every property is matched by an identity // filter, then there won't be any handled or remainder properties. uniquelyCheck: if (unique) { for (int i=0; i<indexProperties.length; i++) { ChainedProperty<S> indexChained = indexProperties[i].getChainedProperty(); if (!identityPropSet.contains(indexChained)) { // Missed a property, so ordering is still relevant. break uniquelyCheck; } } return new OrderingScore<S>(clustered, indexProperties.length, handledOrdering, // no handled properties remainderOrdering, // no remainder properties false, // no need to reverse order freeOrdering, // no free properties unusedOrdering); } Boolean shouldReverseOrder = null; Set<ChainedProperty<S>> seen = new HashSet<ChainedProperty<S>>(); boolean gap = false; int indexPos = 0; calcScore: for (int i=0; i<ordering.size(); i++) { OrderedProperty<S> property = ordering.get(i); ChainedProperty<S> chained = property.getChainedProperty(); if (seen.contains(chained)) { // Redundant property doesn't affect ordering. continue calcScore; } seen.add(chained); if (identityPropSet.contains(chained)) { // Doesn't affect ordering. continue calcScore; } indexPosMatch: while (!gap && indexPos < indexProperties.length) { OrderedProperty<S> indexProp = indexProperties[indexPos]; ChainedProperty<S> indexChained = indexProp.getChainedProperty(); if (chained.equals(indexChained)) { Direction indexDir = indexProp.getDirection(); if (indexDir == UNSPECIFIED) { // Assume index natural order is ascending. indexDir = ASCENDING; } if (shouldReverseOrder != null && shouldReverseOrder) { indexDir = indexDir.reverse(); } if (property.getDirection() == UNSPECIFIED) { // Set handled property direction to match index. property = property.direction(indexDir); } else if (shouldReverseOrder == null) { shouldReverseOrder = indexDir != property.getDirection(); // Any properies already in the list had been // originally unspecified. They might need to be // reversed now. if (shouldReverseOrder) { handledOrdering = handledOrdering.reverseDirections(); } } else if (indexDir != property.getDirection()) { // Direction mismatch, so cannot be handled. break indexPosMatch; } handledOrdering = handledOrdering.concat(property); indexPos++; continue calcScore; } if (identityPropSet.contains(indexChained)) { // Even though ordering did not match index at current // position, the search for handled propertes can continue if // index gap matches an identity filter. indexPos++; continue indexPosMatch; } // Index gap, so cannot be handled. break indexPosMatch; } // Property not handled and not an identity filter. remainderOrdering = remainderOrdering.concat(property); gap = true; } // Walk through all remaining index properties and list them as free. while (indexPos < indexProperties.length) { OrderedProperty<S> freeProp = indexProperties[indexPos]; ChainedProperty<S> freeChained = freeProp.getChainedProperty(); // Don't list as free if already listed as unused. if (!identityPropSet.contains(freeChained)) { if (shouldReverseOrder == null) { freeProp = freeProp.direction(UNSPECIFIED); } else { Direction freePropDir = freePropDir = freeProp.getDirection(); if (freePropDir == UNSPECIFIED) { freePropDir = ASCENDING; } if (shouldReverseOrder) { freeProp = freeProp.direction(freePropDir.reverse()); } } freeOrdering = freeOrdering.concat(freeProp); } indexPos++; } if (shouldReverseOrder == null) { shouldReverseOrder = false; } return new OrderingScore<S>(clustered, indexProperties.length, handledOrdering, remainderOrdering, shouldReverseOrder, freeOrdering, unusedOrdering); }
List<PropertyFilter<S>> filterList = PropertyFilterList.get(filter); if (ordering == null) { ordering = OrderingList.emptyList(); } Set<ChainedProperty<S>> identityPropSet = new HashSet<ChainedProperty<S>>(filterList.size()); for (PropertyFilter<S> propFilter : filterList) { if (propFilter.getOperator() == RelOp.EQ) { identityPropSet.add(propFilter.getChainedProperty()); } } OrderingList<S> handledOrdering = OrderingList.emptyList(); OrderingList<S> remainderOrdering = OrderingList.emptyList(); OrderingList<S> freeOrdering = OrderingList.emptyList(); OrderingList<S> unusedOrdering = OrderingList.emptyList(); for (int i=0; i<indexProperties.length; i++) { OrderedProperty<S> indexProp = indexProperties[i]; ChainedProperty<S> indexChained = indexProp.getChainedProperty(); if (identityPropSet.contains(indexChained)) { unusedOrdering = unusedOrdering.concat(indexProp.direction(UNSPECIFIED)); } } uniquelyCheck: if (unique) { for (int i=0; i<indexProperties.length; i++) { ChainedProperty<S> indexChained = indexProperties[i].getChainedProperty(); if (!identityPropSet.contains(indexChained)) { break uniquelyCheck; } } return new OrderingScore<S>(clustered, indexProperties.length, handledOrdering, remainderOrdering, false, freeOrdering, unusedOrdering); } Boolean shouldReverseOrder = null; Set<ChainedProperty<S>> seen = new HashSet<ChainedProperty<S>>(); boolean gap = false; int indexPos = 0; calcScore: for (int i=0; i<ordering.size(); i++) { OrderedProperty<S> property = ordering.get(i); ChainedProperty<S> chained = property.getChainedProperty(); if (seen.contains(chained)) { continue calcScore; } seen.add(chained); if (identityPropSet.contains(chained)) { continue calcScore; } indexPosMatch: while (!gap && indexPos < indexProperties.length) { OrderedProperty<S> indexProp = indexProperties[indexPos]; ChainedProperty<S> indexChained = indexProp.getChainedProperty(); if (chained.equals(indexChained)) { Direction indexDir = indexProp.getDirection(); if (indexDir == UNSPECIFIED) { indexDir = ASCENDING; } if (shouldReverseOrder != null && shouldReverseOrder) { indexDir = indexDir.reverse(); } if (property.getDirection() == UNSPECIFIED) { property = property.direction(indexDir); } else if (shouldReverseOrder == null) { shouldReverseOrder = indexDir != property.getDirection(); if (shouldReverseOrder) { handledOrdering = handledOrdering.reverseDirections(); } } else if (indexDir != property.getDirection()) { break indexPosMatch; } handledOrdering = handledOrdering.concat(property); indexPos++; continue calcScore; } if (identityPropSet.contains(indexChained)) { indexPos++; continue indexPosMatch; } break indexPosMatch; } remainderOrdering = remainderOrdering.concat(property); gap = true; } while (indexPos < indexProperties.length) { OrderedProperty<S> freeProp = indexProperties[indexPos]; ChainedProperty<S> freeChained = freeProp.getChainedProperty(); if (!identityPropSet.contains(freeChained)) { if (shouldReverseOrder == null) { freeProp = freeProp.direction(UNSPECIFIED); } else { Direction freePropDir = freePropDir = freeProp.getDirection(); if (freePropDir == UNSPECIFIED) { freePropDir = ASCENDING; } if (shouldReverseOrder) { freeProp = freeProp.direction(freePropDir.reverse()); } } freeOrdering = freeOrdering.concat(freeProp); } indexPos++; } if (shouldReverseOrder == null) { shouldReverseOrder = false; } return new OrderingScore<S>(clustered, indexProperties.length, handledOrdering, remainderOrdering, shouldReverseOrder, freeOrdering, unusedOrdering);
return evaluate(index.getOrderedProperties(), index.isUnique(), index.isClustered(), filter, ordering);
public static <S extends Storable> OrderingScore<S> evaluate (OrderedProperty<S>[] indexProperties, boolean unique, boolean clustered, Filter<S> filter, OrderingList<S> ordering) { if (indexProperties == null) { throw new IllegalArgumentException("Index properties required"); } // Get filter list early to detect errors. List<PropertyFilter<S>> filterList = PropertyFilterList.get(filter); if (ordering == null) { ordering = OrderingList.emptyList(); } // Ordering properties which match identity filters don't affect order // results. Build up this set to find them quickly. Set<ChainedProperty<S>> identityPropSet = new HashSet<ChainedProperty<S>>(filterList.size()); for (PropertyFilter<S> propFilter : filterList) { if (propFilter.getOperator() == RelOp.EQ) { identityPropSet.add(propFilter.getChainedProperty()); } } OrderingList<S> handledOrdering = OrderingList.emptyList(); OrderingList<S> remainderOrdering = OrderingList.emptyList(); OrderingList<S> freeOrdering = OrderingList.emptyList(); OrderingList<S> unusedOrdering = OrderingList.emptyList(); // Build up list of unused properties that were filtered out. for (int i=0; i<indexProperties.length; i++) { OrderedProperty<S> indexProp = indexProperties[i]; ChainedProperty<S> indexChained = indexProp.getChainedProperty(); if (identityPropSet.contains(indexChained)) { unusedOrdering = unusedOrdering.concat(indexProp.direction(UNSPECIFIED)); } } // If index is unique and every property is matched by an identity // filter, then there won't be any handled or remainder properties. uniquelyCheck: if (unique) { for (int i=0; i<indexProperties.length; i++) { ChainedProperty<S> indexChained = indexProperties[i].getChainedProperty(); if (!identityPropSet.contains(indexChained)) { // Missed a property, so ordering is still relevant. break uniquelyCheck; } } return new OrderingScore<S>(clustered, indexProperties.length, handledOrdering, // no handled properties remainderOrdering, // no remainder properties false, // no need to reverse order freeOrdering, // no free properties unusedOrdering); } Boolean shouldReverseOrder = null; Set<ChainedProperty<S>> seen = new HashSet<ChainedProperty<S>>(); boolean gap = false; int indexPos = 0; calcScore: for (int i=0; i<ordering.size(); i++) { OrderedProperty<S> property = ordering.get(i); ChainedProperty<S> chained = property.getChainedProperty(); if (seen.contains(chained)) { // Redundant property doesn't affect ordering. continue calcScore; } seen.add(chained); if (identityPropSet.contains(chained)) { // Doesn't affect ordering. continue calcScore; } indexPosMatch: while (!gap && indexPos < indexProperties.length) { OrderedProperty<S> indexProp = indexProperties[indexPos]; ChainedProperty<S> indexChained = indexProp.getChainedProperty(); if (chained.equals(indexChained)) { Direction indexDir = indexProp.getDirection(); if (indexDir == UNSPECIFIED) { // Assume index natural order is ascending. indexDir = ASCENDING; } if (shouldReverseOrder != null && shouldReverseOrder) { indexDir = indexDir.reverse(); } if (property.getDirection() == UNSPECIFIED) { // Set handled property direction to match index. property = property.direction(indexDir); } else if (shouldReverseOrder == null) { shouldReverseOrder = indexDir != property.getDirection(); // Any properies already in the list had been // originally unspecified. They might need to be // reversed now. if (shouldReverseOrder) { handledOrdering = handledOrdering.reverseDirections(); } } else if (indexDir != property.getDirection()) { // Direction mismatch, so cannot be handled. break indexPosMatch; } handledOrdering = handledOrdering.concat(property); indexPos++; continue calcScore; } if (identityPropSet.contains(indexChained)) { // Even though ordering did not match index at current // position, the search for handled propertes can continue if // index gap matches an identity filter. indexPos++; continue indexPosMatch; } // Index gap, so cannot be handled. break indexPosMatch; } // Property not handled and not an identity filter. remainderOrdering = remainderOrdering.concat(property); gap = true; } // Walk through all remaining index properties and list them as free. while (indexPos < indexProperties.length) { OrderedProperty<S> freeProp = indexProperties[indexPos]; ChainedProperty<S> freeChained = freeProp.getChainedProperty(); // Don't list as free if already listed as unused. if (!identityPropSet.contains(freeChained)) { if (shouldReverseOrder == null) { freeProp = freeProp.direction(UNSPECIFIED); } else { Direction freePropDir = freePropDir = freeProp.getDirection(); if (freePropDir == UNSPECIFIED) { freePropDir = ASCENDING; } if (shouldReverseOrder) { freeProp = freeProp.direction(freePropDir.reverse()); } } freeOrdering = freeOrdering.concat(freeProp); } indexPos++; } if (shouldReverseOrder == null) { shouldReverseOrder = false; } return new OrderingScore<S>(clustered, indexProperties.length, handledOrdering, remainderOrdering, shouldReverseOrder, freeOrdering, unusedOrdering); }
registerTag("break", BreakTag.class);
public CoreTagLibrary() { registerTag("jelly", JellyTag.class); // core tags registerTag("out", ExprTag.class); registerTag("catch", CatchTag.class); registerTag("forEach", ForEachTag.class); registerTag("set", SetTag.class); registerTag("remove", RemoveTag.class); registerTag("while", WhileTag.class); // conditional tags registerTag("if", IfTag.class); registerTag("choose", ChooseTag.class); registerTag("when", WhenTag.class); registerTag("otherwise", OtherwiseTag.class); registerTag("switch", SwitchTag.class); registerTag("case", CaseTag.class); registerTag("default", DefaultTag.class); // other tags registerTag("include", IncludeTag.class); registerTag("import", ImportTag.class); // extensions to JSTL registerTag("expr", ExprTag.class); registerTag("new", NewTag.class); registerTag("setProperties", SetPropertiesTag.class); registerTag("useBean", UseBeanTag.class); registerTag("useList", UseListTag.class); registerTag("whitespace", WhitespaceTag.class); registerTag("thread", ThreadTag.class); registerTag("file", FileTag.class); registerTag("scope", ScopeTag.class); }
removeChild(m);
protected void ensureNotInMapping(SQLColumn pkcol) throws ArchitectException { if (containsPkColumn(pkcol)) { ColumnMapping m = getMappingByPkCol(pkcol); List fkTies = fkTable.keysOfColumn(m.getFkColumn()); if (fkTies == null || fkTies.size() <= 1) { fkTable.removeColumn(m.getFkColumn()); } removeChild(m); } }
public void populate() throws ArchitectException {
public void populate() {
public void populate() throws ArchitectException { logger.debug("SQLRelationship: populate is a no-op"); }
System.out.println(o.getClass());
public void actionPerformed(ActionEvent e) { if (dbTree == null) { logger.debug("dbtree was null when actionPerformed called"); return; } if ( dbTree.getSelectionPaths() == null ) { logger.debug("dbtree path selection was null when actionPerformed called"); return; } try { Set<SQLObject> sqlObject = new HashSet<SQLObject>(); for ( TreePath tp : dbTree.getSelectionPaths() ) { if ( tp.getLastPathComponent() instanceof SQLDatabase ) { sqlObject.add((SQLDatabase)tp.getLastPathComponent()); } else if ( tp.getLastPathComponent() instanceof SQLCatalog ) { SQLCatalog cat = (SQLCatalog)tp.getLastPathComponent(); sqlObject.add(cat); SQLDatabase db = ArchitectUtils.getAncestor(cat,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } else if ( tp.getLastPathComponent() instanceof SQLSchema ) { SQLSchema sch = (SQLSchema)tp.getLastPathComponent(); sqlObject.add(sch); SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); if ( cat != null && sqlObject.contains(cat)) sqlObject.remove(cat); SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } else if ( tp.getLastPathComponent() instanceof SQLTable ) { SQLTable tab = (SQLTable)tp.getLastPathComponent(); sqlObject.add(tab); SQLSchema sch = ArchitectUtils.getAncestor(tab,SQLSchema.class); if ( sch != null && sqlObject.contains(sch)) sqlObject.remove(sch); SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); if ( cat != null && sqlObject.contains(cat)) sqlObject.remove(cat); SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } else if ( tp.getLastPathComponent() instanceof SQLTable.Folder ) { SQLTable tab = ArchitectUtils.getAncestor((Folder)tp.getLastPathComponent(),SQLTable.class); sqlObject.add(tab); SQLSchema sch = ArchitectUtils.getAncestor(tab,SQLSchema.class); if ( sch != null && sqlObject.contains(sch)) sqlObject.remove(sch); SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); if ( cat != null && sqlObject.contains(cat)) sqlObject.remove(cat); SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } else if ( tp.getLastPathComponent() instanceof SQLColumn ) { SQLTable tab = ((SQLColumn)tp.getLastPathComponent()).getParentTable(); sqlObject.add((SQLColumn)tp.getLastPathComponent()); SQLSchema sch = ArchitectUtils.getAncestor(tab,SQLSchema.class); if ( sch != null && sqlObject.contains(sch)) sqlObject.remove(sch); SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); if ( cat != null && sqlObject.contains(cat)) sqlObject.remove(cat); SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } } final ArrayList<SQLObject> filter = new ArrayList<SQLObject>(); final Set<SQLTable> tables = new HashSet<SQLTable>(); for ( SQLObject o : sqlObject ) { if ( o instanceof SQLColumn){ tables.add(((SQLColumn)o).getParentTable()); } else { tables.addAll(ArchitectUtils.tablesUnder(o)); } if (! (o instanceof Folder)){ filter.add(o); } } profileManager.setCancelled(false); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Profiles"); final CommonCloseAction commonCloseAction = new CommonCloseAction(d); Action closeAction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { profileManager.setCancelled(true); commonCloseAction.actionPerformed(evt); } }; closeAction.putValue(Action.NAME, "Close"); final JDefaultButton closeButton = new JDefaultButton(closeAction); final JPanel progressViewPanel = new JPanel(new BorderLayout()); final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); buttonPanel.add(closeButton); progressViewPanel.add(buttonPanel, BorderLayout.SOUTH); final JProgressBar progressBar = new JProgressBar(); progressBar.setPreferredSize(new Dimension(450,20)); progressViewPanel.add(progressBar, BorderLayout.CENTER); final JLabel workingOn = new JLabel("Profiling:"); progressViewPanel.add(workingOn, BorderLayout.NORTH); ArchitectPanelBuilder.makeJDialogCancellable( d, commonCloseAction); d.getRootPane().setDefaultButton(closeButton); d.setContentPane(progressViewPanel); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); new ProgressWatcher(progressBar,profileManager,workingOn); // XXX This should be its own Action class? new Thread( new Runnable() { public void run() { try { List<SQLTable> toBeProfiled = new ArrayList<SQLTable>(); for (SQLTable t: tables) { if (profileManager.getResult(t)== null) { toBeProfiled.add(t); workingOn.setText("Adding "+t.getName()+ " ("+toBeProfiled.size()+")"); } } profileManager.createProfiles(toBeProfiled, workingOn); progressBar.setVisible(false); JLabel status = new JLabel("Generating reports, Please wait......"); progressViewPanel.add(status, BorderLayout.NORTH); status.setVisible(true); JTabbedPane tabPane = new JTabbedPane(); ProfileTableModel tm = new ProfileTableModel(); for (SQLObject sqo: filter){ tm.addFilter(sqo); } tm.setProfileManager(profileManager); TableModelSearchDecorator searchDecorator = new TableModelSearchDecorator(tm); TableModelSortDecorator tableModelSortDecorator = new TableModelSortDecorator(searchDecorator); final ProfileTable viewTable = new ProfileTable(tableModelSortDecorator); searchDecorator.setTableTextConverter(viewTable); JTableHeader tableHeader = viewTable.getTableHeader(); tableModelSortDecorator.setTableHeader(tableHeader); viewTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); ProfilePanelMouseListener profilePanelMouseListener = new ProfilePanelMouseListener(); profilePanelMouseListener.setTabPane(tabPane); viewTable.addMouseListener( profilePanelMouseListener); JScrollPane editorScrollPane = new JScrollPane(viewTable); editorScrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(800, 600)); editorScrollPane.setMinimumSize(new Dimension(10, 10)); // reset column widths ((ProfileTable) viewTable).initColumnSizes(); JPanel tableViewPane = new JPanel(new BorderLayout()); tableViewPane.add(editorScrollPane,BorderLayout.CENTER); JLabel searchLabel = new JLabel("Search:"); JTextField searchField = new JTextField(searchDecorator.getDoc(),"",25); searchField.setEditable(true); JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); searchPanel.add(searchLabel); searchPanel.add(searchField); tableViewPane.add(searchPanel,BorderLayout.NORTH); ButtonBarBuilder buttonBuilder = new ButtonBarBuilder(); JButton save = new JButton(new SaveProfileAction(d,viewTable,profileManager)); JButton refresh = new JButton(new AbstractAction("Refresh"){ public void actionPerformed(ActionEvent e) { Set<SQLTable> uniqueTables = new HashSet(); for (int i: viewTable.getSelectedRows()) { Object o = viewTable.getValueAt(i,3); System.out.println(o.getClass()); SQLTable table = (SQLTable) o ; uniqueTables.add(table); } try { profileManager.setCancelled(false); profileManager.createProfiles(uniqueTables); } catch (SQLException e1) { throw new RuntimeException(e1); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } } }); JButton delete = new JButton(new AbstractAction("Delete"){ public void actionPerformed(ActionEvent e) { int[] killMe = viewTable.getSelectedRows(); Arrays.sort(killMe); // iterate backwards so the rows don't shift away on us! for (int i = killMe.length-1; i >= 0; i--) { logger.debug("Deleting row "+killMe[i]+": "+viewTable.getValueAt(killMe[i],4)); SQLColumn col = (SQLColumn) viewTable.getValueAt(killMe[i], 4); try { profileManager.remove(col); } catch (ArchitectException e1) { ASUtils.showExceptionDialog(d,"Could delete row of:" + col.getName(), e1); } } } }); JButton deleteAll = new JButton(new AbstractAction("Delete All"){ public void actionPerformed(ActionEvent e) { while ( viewTable.getRowCount() > 0 ) { SQLColumn col = (SQLColumn) viewTable.getValueAt(0, 4); try { profileManager.remove(col); } catch (ArchitectException e1) { ASUtils.showExceptionDialog(d,"Could delete row of:" + col.getName(), e1); } } } }); JButton[] buttonArray = {refresh,delete,deleteAll,save,closeButton}; buttonBuilder.addGriddedButtons(buttonArray); tableViewPane.add(buttonBuilder.getPanel(),BorderLayout.SOUTH); tabPane.addTab("Table View", tableViewPane ); ProfilePanel p = new ProfilePanel(profileManager); tabPane.addTab("Graph View",p); profilePanelMouseListener.setProfilePanel(p); List<SQLTable> list = new ArrayList(tables); p.setTables(list); p.setChartType(ChartTypes.PIE); d.setVisible(false); d.remove(progressViewPanel); d.setContentPane(tabPane); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); } catch (SQLException e) { logger.error("Error in Profile Action ", e); ASUtils.showExceptionDialogNoReport(dbTree, "Error during profile run", e); } catch (ArchitectException e) { logger.error("Error in Profile Action", e); ASUtils.showExceptionDialog(dbTree, "Error during profile run", e); } } }).start(); } catch (Exception ex) { logger.error("Error in Profile Action ", ex); ASUtils.showExceptionDialog(dbTree, "Error during profile run", ex); } }
System.out.println(o.getClass());
public void run() { try { List<SQLTable> toBeProfiled = new ArrayList<SQLTable>(); for (SQLTable t: tables) { if (profileManager.getResult(t)== null) { toBeProfiled.add(t); workingOn.setText("Adding "+t.getName()+ " ("+toBeProfiled.size()+")"); } } profileManager.createProfiles(toBeProfiled, workingOn); progressBar.setVisible(false); JLabel status = new JLabel("Generating reports, Please wait......"); progressViewPanel.add(status, BorderLayout.NORTH); status.setVisible(true); JTabbedPane tabPane = new JTabbedPane(); ProfileTableModel tm = new ProfileTableModel(); for (SQLObject sqo: filter){ tm.addFilter(sqo); } tm.setProfileManager(profileManager); TableModelSearchDecorator searchDecorator = new TableModelSearchDecorator(tm); TableModelSortDecorator tableModelSortDecorator = new TableModelSortDecorator(searchDecorator); final ProfileTable viewTable = new ProfileTable(tableModelSortDecorator); searchDecorator.setTableTextConverter(viewTable); JTableHeader tableHeader = viewTable.getTableHeader(); tableModelSortDecorator.setTableHeader(tableHeader); viewTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); ProfilePanelMouseListener profilePanelMouseListener = new ProfilePanelMouseListener(); profilePanelMouseListener.setTabPane(tabPane); viewTable.addMouseListener( profilePanelMouseListener); JScrollPane editorScrollPane = new JScrollPane(viewTable); editorScrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(800, 600)); editorScrollPane.setMinimumSize(new Dimension(10, 10)); // reset column widths ((ProfileTable) viewTable).initColumnSizes(); JPanel tableViewPane = new JPanel(new BorderLayout()); tableViewPane.add(editorScrollPane,BorderLayout.CENTER); JLabel searchLabel = new JLabel("Search:"); JTextField searchField = new JTextField(searchDecorator.getDoc(),"",25); searchField.setEditable(true); JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); searchPanel.add(searchLabel); searchPanel.add(searchField); tableViewPane.add(searchPanel,BorderLayout.NORTH); ButtonBarBuilder buttonBuilder = new ButtonBarBuilder(); JButton save = new JButton(new SaveProfileAction(d,viewTable,profileManager)); JButton refresh = new JButton(new AbstractAction("Refresh"){ public void actionPerformed(ActionEvent e) { Set<SQLTable> uniqueTables = new HashSet(); for (int i: viewTable.getSelectedRows()) { Object o = viewTable.getValueAt(i,3); System.out.println(o.getClass()); SQLTable table = (SQLTable) o ; uniqueTables.add(table); } try { profileManager.setCancelled(false); profileManager.createProfiles(uniqueTables); } catch (SQLException e1) { throw new RuntimeException(e1); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } } }); JButton delete = new JButton(new AbstractAction("Delete"){ public void actionPerformed(ActionEvent e) { int[] killMe = viewTable.getSelectedRows(); Arrays.sort(killMe); // iterate backwards so the rows don't shift away on us! for (int i = killMe.length-1; i >= 0; i--) { logger.debug("Deleting row "+killMe[i]+": "+viewTable.getValueAt(killMe[i],4)); SQLColumn col = (SQLColumn) viewTable.getValueAt(killMe[i], 4); try { profileManager.remove(col); } catch (ArchitectException e1) { ASUtils.showExceptionDialog(d,"Could delete row of:" + col.getName(), e1); } } } }); JButton deleteAll = new JButton(new AbstractAction("Delete All"){ public void actionPerformed(ActionEvent e) { while ( viewTable.getRowCount() > 0 ) { SQLColumn col = (SQLColumn) viewTable.getValueAt(0, 4); try { profileManager.remove(col); } catch (ArchitectException e1) { ASUtils.showExceptionDialog(d,"Could delete row of:" + col.getName(), e1); } } } }); JButton[] buttonArray = {refresh,delete,deleteAll,save,closeButton}; buttonBuilder.addGriddedButtons(buttonArray); tableViewPane.add(buttonBuilder.getPanel(),BorderLayout.SOUTH); tabPane.addTab("Table View", tableViewPane ); ProfilePanel p = new ProfilePanel(profileManager); tabPane.addTab("Graph View",p); profilePanelMouseListener.setProfilePanel(p); List<SQLTable> list = new ArrayList(tables); p.setTables(list); p.setChartType(ChartTypes.PIE); d.setVisible(false); d.remove(progressViewPanel); d.setContentPane(tabPane); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); } catch (SQLException e) { logger.error("Error in Profile Action ", e); ASUtils.showExceptionDialogNoReport(dbTree, "Error during profile run", e); } catch (ArchitectException e) { logger.error("Error in Profile Action", e); ASUtils.showExceptionDialog(dbTree, "Error during profile run", e); } }
System.out.println(o.getClass());
public void actionPerformed(ActionEvent e) { Set<SQLTable> uniqueTables = new HashSet(); for (int i: viewTable.getSelectedRows()) { Object o = viewTable.getValueAt(i,3); System.out.println(o.getClass()); SQLTable table = (SQLTable) o ; uniqueTables.add(table); } try { profileManager.setCancelled(false); profileManager.createProfiles(uniqueTables); } catch (SQLException e1) { throw new RuntimeException(e1); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } }
super.setUp();
public void setUp() { // Create several photos with different shooting dates // Add them to a collection so that they are easy to delete afterwards Calendar cal = Calendar.getInstance(); photos = new Vector(); uids = new Vector(); cal.set( 2002, 11, 23 ); makePhoto( cal ); cal.set( 2002, 11, 24 ); makePhoto( cal ); makePhoto( cal ); cal.set( 2002, 11, 25 ); makePhoto( cal ); }
playPenInstance.children = new ArrayList();
public static synchronized SQLDatabase getPlayPenInstance() { if (playPenInstance == null) { playPenInstance = new SQLDatabase(); playPenInstance.populated = true; } return playPenInstance; }
getBody().run(context, newOutput);
invokeBody( newOutput);
public void doTag(XMLOutput output) throws Exception { if (var == null) { throw new IllegalArgumentException("The var attribute cannot be null"); } Document document = null; if (xml == null) { SAXContentHandler handler = new SAXContentHandler(); XMLOutput newOutput = new XMLOutput(handler); handler.startDocument(); getBody().run(context, newOutput); handler.endDocument(); document = handler.getDocument(); /* // the following is inefficient as it requires a parse of the text // but is left here in the code to see how it could be done. String text = getBodyText(); if ( log.isDebugEnabled() ) { log.debug( "About to parse: " + text ); } document = getSAXReader().read( new StringReader( text ) ); */ } else { if (xml instanceof String) { document = getSAXReader().read((String) xml); } else if (xml instanceof Reader) { document = getSAXReader().read((Reader) xml); } else if (xml instanceof InputStream) { document = getSAXReader().read((InputStream) xml); } else if (xml instanceof URL) { document = getSAXReader().read((URL) xml); } else { throw new IllegalArgumentException( "Invalid xml argument. Must be a String, Reader, InputStream or URL." + " Was type; " + xml.getClass().getName() + " with value: " + xml); } } context.setVariable(var, document); }
g2.setColor(this.getBackground());
g2.setColor(BG_GREY);
public void paintComponent(Graphics g){ PairwiseLinkage[][] dPrimeTable = theData.filteredDPrimeTable; Vector blocks = theData.blocks; Rectangle visRect = getVisibleRect(); //deal with zooming if (chartSize.getWidth() > (3*visRect.width)){ showWM = true; }else{ showWM = false; } if (zoomLevel == 0){ printDetails = true; } else{ printDetails = false; } Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); if (size.height < pref.height){ setSize(pref); } //okay so this dumb if block is to prevent the ugly repainting //bug when loading markers after the data are already being displayed, //results in a little off-centering for small datasets, but not too bad. if (!forExport){ if (!theData.infoKnown){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); } else { g2.translate((size.width - pref.width) / 2, 0); } } FontMetrics boxFontMetrics = g2.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; if (forExport){ left -= exportStart * boxSize; } FontMetrics metrics; int ascent; g2.setColor(this.getBackground()); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.black); g2.setFont(boldMarkerNameFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); //TODO: finish implementing scaling gizmo /*//deal with adding some space to better display data with large gaps int cumulativeGap[] = new int[Chromosome.getFilteredSize()]; for (int i = 0; i < cumulativeGap.length; i++){ cumulativeGap[i] = 0; } if (theData.infoKnown){ double mean = (((SNP)Chromosome.markers[Chromosome.markers.length-1]).getPosition() - ((SNP)Chromosome.markers[0]).getPosition())/Chromosome.markers.length-1; for (int i = 1; i < cumulativeGap.length; i++){ double sep = Chromosome.getMarker(i).getPosition() - Chromosome.getMarker(i-1).getPosition(); if (sep > mean*10){ cumulativeGap[i] = cumulativeGap[i-1] + (int)(sep/mean)*4; }else{ cumulativeGap[i] = cumulativeGap[i-1]; } } } */ if (theData.infoKnown) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations int lineSpan = (dPrimeTable.length-1) * boxSize; long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left+1, top+1, lineSpan-1, TICK_HEIGHT-1); g2.setColor(Color.black); g2.drawRect(left, top, lineSpan, TICK_HEIGHT); for (int i = 0; i < Chromosome.getFilteredSize(); i++) { double pos = (Chromosome.getFilteredMarker(i).getPosition() - minpos) / spanpos; int xx = (int) (left + lineSpan*pos); g2.setStroke(thickerStroke); g2.drawLine(xx, top, xx, top + TICK_HEIGHT); g2.setStroke(thinnerStroke); g2.drawLine(xx, top + TICK_HEIGHT, left + i*boxSize, top+TICK_BOTTOM); } top += TICK_BOTTOM + TICK_HEIGHT; //// draw the marker names if (printDetails){ widestMarkerName = metrics.stringWidth(Chromosome.getFilteredMarker(0).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(Chromosome.getFilteredMarker(x).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { if (theData.isInBlock[x]){ g2.setFont(boldMarkerNameFont); }else{ g2.setFont(markerNameFont); } g2.drawString(Chromosome.getFilteredMarker(x).getName(),TEXT_GAP, x*boxSize + ascent/3); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } top += blockDispHeight; //// draw the marker numbers if (printDetails){ g2.setFont(markerNumFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < dPrimeTable.length; x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g2.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(theData.infoKnown)){ clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = (visRect.x-clickXShift-(visRect.y + visRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((visRect.x + visRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((visRect.x-clickXShift)+(visRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } if (forExport){ lowX = exportStart; lowY = exportStart; highX = exportStop; highY = exportStop; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g2.setColor(boxColor); g2.fillPolygon(diamond); if(printDetails){ g2.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g2.setColor((val < 50) ? Color.gray : Color.black); if (boxColor == Color.darkGray){ g2.setColor(Color.white); } if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } boolean even = true; //highlight blocks g2.setFont(markerNameFont); ascent = g2.getFontMetrics().getAscent(); //g.setColor(new Color(153,255,153)); g2.setColor(Color.black); //g.setColor(new Color(51,153,51)); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; //big vee around whole thing g2.setStroke(fatStroke); g2.drawLine(left + (2*first) * boxSize/2 - boxRadius, top, left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius); g2.drawLine(left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius, left + (2*last) * boxSize/2+boxRadius, top); for (int j = first; j <= last; j++){ if (theData.isInBlock[j]){ g2.setStroke(fatStroke); }else{ g2.setStroke(dashedFatStroke); } g2.drawLine(left+j*boxSize-boxSize/2, top-blockDispHeight, left+j*boxSize+boxSize/2, top-blockDispHeight); } //lines to connect to block display g2.setStroke(fatStroke); g2.drawLine(left + first*boxSize-boxSize/2, top-1, left+first*boxSize-boxSize/2, top-blockDispHeight); g2.drawLine(left+last*boxSize+boxSize/2, top-1, left+last*boxSize+boxSize/2, top-blockDispHeight); if (printDetails){ String labelString = new String ("Block " + (i+1)); if (theData.infoKnown){ long blockSize = Chromosome.getMarker(last).getPosition() - Chromosome.getMarker(first).getPosition(); labelString += " (" + blockSize/1000 + " kb)"; } g2.drawString(labelString, left+first*boxSize-boxSize/2+TEXT_GAP, top-boxSize/3); } } g2.setStroke(thickerStroke); //see if the user has right-clicked to popup some marker info if(popupExists){ int smallDatasetSlopH = 0; int smallDatasetSlopV = 0; if (pref.getWidth() < visRect.width){ //dumb bug where little datasets popup the box in the wrong place smallDatasetSlopH = (int)(visRect.width - pref.getWidth())/2; smallDatasetSlopV = (int)(visRect.height - pref.getHeight())/2; } g2.setColor(Color.white); g2.fillRect(popupDrawRect.x+1-smallDatasetSlopH, popupDrawRect.y+1-smallDatasetSlopV, popupDrawRect.width-1, popupDrawRect.height-1); g2.setColor(Color.black); g2.drawRect(popupDrawRect.x-smallDatasetSlopH, popupDrawRect.y-smallDatasetSlopV, popupDrawRect.width, popupDrawRect.height); for (int x = 0; x < displayStrings.length; x++){ g.drawString(displayStrings[x],popupDrawRect.x + popupLeftMargin-smallDatasetSlopH, popupDrawRect.y+((x+1)*metrics.getHeight())-smallDatasetSlopV); } } if (showWM && !forExport){ //dataset is big enough to require worldmap if (noImage){ //first time through draw a worldmap if dataset is big: final int WM_BD_GAP = 1; final int WM_BD_HEIGHT = 2; final int WM_BD_TOTAL = WM_BD_HEIGHT + 2*WM_BD_GAP; if (wmMaxWidth == 0){ wmMaxWidth = visRect.width/3; } double scalefactor; scalefactor = (double)(chartSize.width)/wmMaxWidth; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); worldmap = new BufferedImage((int)(chartSize.width/scalefactor)+wmBorder.getBorderInsets(this).left*2, (int)(chartSize.height/scalefactor)+wmBorder.getBorderInsets(this).top*2+WM_BD_TOTAL, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(this.getBackground()); gw2.fillRect(1,1,worldmap.getWidth()-1,worldmap.getHeight()-1); //make a pretty border gw2.setColor(Color.black); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth(),worldmap.getHeight()); wmInteriorRect = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth(), worldmap.getHeight()); double prefBoxSize = boxSize/(scalefactor*((double)wmMaxWidth/(double)(wmMaxWidth-WM_BD_TOTAL))); float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < dPrimeTable.length-1; x++){ for (int y = x+1; y < dPrimeTable.length; y++){ if (dPrimeTable[x][y] == null){ continue; } double xx = (x + y)*prefBoxSize/2+wmBorder.getBorderInsets(this).left; double yy = (y - x)*prefBoxSize/2+wmBorder.getBorderInsets(this).top + WM_BD_TOTAL; smallDiamondX[0] = (float)xx; smallDiamondY[0] = (float)(yy - prefBoxSize/2); smallDiamondX[1] = (float)(xx + prefBoxSize/2); smallDiamondY[1] = (float)yy; smallDiamondX[2] = (float)xx; smallDiamondY[2] = (float)(yy + prefBoxSize/2); smallDiamondX[3] = (float)(xx - prefBoxSize/2); smallDiamondY[3] = (float)yy; gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, smallDiamondX.length); gp.moveTo(smallDiamondX[0],smallDiamondY[0]); for (int i = 1; i < smallDiamondX.length; i++){ gp.lineTo(smallDiamondX[i], smallDiamondY[i]); } gp.closePath(); gw2.setColor(dPrimeTable[x][y].getColor()); gw2.fill(gp); } } //draw block display in worldmap gw2.setColor(this.getBackground()); gw2.fillRect(wmBorder.getBorderInsets(this).left, wmBorder.getBorderInsets(this).top+WM_BD_GAP, wmInteriorRect.width, WM_BD_HEIGHT); gw2.setColor(Color.black); even = true; for (int i = 0; i < blocks.size(); i++){ int first = ((int[])blocks.elementAt(i))[0]; int last = ((int[])blocks.elementAt(i))[((int[])blocks.elementAt(i)).length-1]; int voffset; if (even){ voffset = 0; }else{ voffset = WM_BD_HEIGHT/2; } gw2.fillRect(wmBorder.getBorderInsets(this).left+(int)(prefBoxSize*first), wmBorder.getBorderInsets(this).top+voffset+WM_BD_GAP, (int)((last-first+1)*prefBoxSize), WM_BD_HEIGHT/2); even = !even; } noImage = false; } wmResizeCorner = new Rectangle(visRect.x + worldmap.getWidth() - (worldmap.getWidth()-wmInteriorRect.width)/2, visRect.y + visRect.height - worldmap.getHeight(), (worldmap.getWidth()-wmInteriorRect.width)/2, (worldmap.getHeight() -wmInteriorRect.height)/2); g2.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); wmInteriorRect.x = visRect.x + (worldmap.getWidth() - wmInteriorRect.width); wmInteriorRect.y = visRect.y+visRect.height-worldmap.getHeight() + (worldmap.getHeight() - wmInteriorRect.height); //draw the outline of the viewport g2.setColor(Color.black); double hRatio = wmInteriorRect.getWidth()/pref.getWidth(); double vRatio = wmInteriorRect.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-wmInteriorRect.width; int vBump = worldmap.getHeight()-wmInteriorRect.height; //bump a few pixels to avoid drawing on the border g2.drawRect((int)(visRect.x*hRatio)+hBump/2+visRect.x, (int)(visRect.y*vRatio)+vBump/2+(visRect.y + visRect.height - worldmap.getHeight()), (int)(visRect.width*hRatio), (int)(visRect.height*vRatio)); } //see if we're drawing a worldmap resize rect if (resizeRectExists){ g2.setColor(Color.black); g2.drawRect(resizeWMRect.x, resizeWMRect.y, resizeWMRect.width, resizeWMRect.height); } //see if we're drawing a block selector rect if (blockRectExists){ g2.setColor(Color.black); g2.setStroke(dashedThinStroke); g2.drawRect(blockRect.x, blockRect.y, blockRect.width, blockRect.height); } }
id = Integer.parseInt(acc.toString());
id = acc.getIdentifier().intValue();
public PresentationObject getAccounts(IWContext iwc) { DataTable T = new DataTable(); T.setWidth("100%"); String styp = ""; Collection accounts = null; if (topic > 0) { accounts = MailFinder.getInstance().getTopicAccounts(topic); styp = iwrb.getLocalizedString("list.topic", "topic"); EmailTopic tpc = (EmailTopic) topics.get(String.valueOf(topic)); if(tpc !=null) styp += " " + tpc.getName(); } /*else if (group > 0) { accounts = MailFinder.getInstance().getGroupAccounts(group); styp = iwrb.getLocalizedString("list.group", "group"); EmailGroup grp = (EmailGroup) groups.get(String.valueOf(group)); if(grp!=null) styp += " " + grp.getName(); }*/ String title = iwrb.getLocalizedString("list.accounts", "Accounts"); title += " " + iwrb.getLocalizedString("list.in", "in") + " " + styp + " "; T.addTitle(title); T.setTitlesHorizontal(true); int row = 1; Text tName = tf.format(iwrb.getLocalizedString("name", "Name")); Text tHost = tf.format(iwrb.getLocalizedString("host", "Host")); Text tUser = tf.format(iwrb.getLocalizedString("user", "User")); Text tPass = tf.format(iwrb.getLocalizedString("pass", "Passwd")); Text tProto = tf.format(iwrb.getLocalizedString("protocol", "Protocol")); row++; TextInput name = new TextInput("name"); TextInput host = new TextInput("host"); TextInput user = new TextInput("user"); TextInput pass = new TextInput("pass"); DropdownMenu proto = getProtocolDropdown("proto", ""); //DropdownMenu grps = getGroupDropdown("grp", ""); if (accounts != null && accounts.size() > 0) { java.util.Iterator iter = accounts.iterator(); EmailAccount acc; Link deleteLink; Link accountLink; Link editLink; int id; while (iter.hasNext()) { acc = (EmailAccount) iter.next(); id = Integer.parseInt(acc.toString()); if (id == account && EditObject.equals("account")) { name.setContent(acc.getName()); host.setContent(acc.getHost()); user.setContent(acc.getUser()); pass.setContent(acc.getPassword()); proto.setSelectedElement(String.valueOf(acc.getProtocol())); T.add(tName, 1, row); T.add(name, 2, row++); T.add(tHost, 1, row); T.add(host, 2, row++); T.add(tUser, 1, row); T.add(user, 2, row++); T.add(tPass, 1, row); T.add(pass, 2, row++); T.add(tProto, 1, row); T.add(proto, 2, row++); T.add(new HiddenInput(prmAccountId, String.valueOf(id))); formAdded = true; } else { accountLink = new Link(tf.format(acc.getName())); accountLink.addParameter(prmInstanceId, String.valueOf(instance)); accountLink.addParameter(prmAccountId, id); //accountLink.addParameter(prmGroupId, group); accountLink.addParameter(prmTopicId, topic); editLink = new Link((Image) editImage.clone()); editLink.addParameter(prmInstanceId, String.valueOf(instance)); editLink.addParameter(prmAccountId, id); editLink.addParameter(prmEdit, "account"); //editLink.addParameter(prmGroupId, group); editLink.addParameter(prmTopicId, topic); deleteLink = new Link((Image) deleteImage.clone()); deleteLink.addParameter(prmInstanceId, String.valueOf(instance)); deleteLink.addParameter(prmAccountId, id); deleteLink.addParameter(prmDel, "account"); //deleteLink.addParameter(prmGroupId, group); deleteLink.addParameter(prmTopicId, topic); T.add(accountLink, 1, row); T.add(editLink, 2, row); T.add(deleteLink, 2, row); row++; T.add(tHost, 1, row); T.add(tf.format(acc.getHost()), 2, row++); T.add(tUser, 1, row); T.add(tf.format(acc.getUser()), 2, row++); T.add(tPass, 1, row); T.add(tf.format(acc.getPassword()), 2, row++); T.add(tProto, 1, row); T.add(tf.format(getProtocolName(acc.getProtocol())), 2, row++); } row++; } } if (!formAdded && NewObject.equals("account")) { T.add(tName, 1, row); T.add(name, 2, row++); T.add(tHost, 1, row); T.add(host, 2, row++); T.add(tUser, 1, row); T.add(user, 2, row++); T.add(tPass, 1, row); T.add(pass, 2, row++); T.add(tProto, 1, row); T.add(proto, 2, row++); formAdded = true; } else { Link li = new Link(iwrb.getLocalizedImageButton("new", "New")); li.addParameter(prmInstanceId, String.valueOf(instance)); //li.addParameter(prmGroupId, group); li.addParameter(prmTopicId, topic); li.addParameter(prmNew, "account"); T.addButton(li); } if (formAdded) { T.addButton(new SubmitButton(iwrb.getLocalizedImageButton("save", "Save"), "save", "account")); } return T; }
T.add(getAccountLink(topicID,Integer.parseInt( account.toString()),account.getHost()),3,row);
T.add(getAccountLink(topicID,( account.getIdentifier().intValue()),account.getHost()),3,row);
public PresentationObject getTopicsOverView(IWContext iwc){ Table T = new Table(); int row = 1; T.add(getTopicLink(-1,iwrb.getLocalizedString("new_topic","New topic")),1,row); row++; T.add(tf.format(iwrb.getLocalizedString("name","Name"),tf.HEADER),1,row); T.add(tf.format(iwrb.getLocalizedString("category","Category"),tf.HEADER),2,row); T.add(tf.format(iwrb.getLocalizedString("mail_server","Mail server"),tf.HEADER),3,row); T.add(tf.format(iwrb.getLocalizedString("subscribers","Subscribers"),tf.HEADER),4,row); T.add(tf.format(iwrb.getLocalizedString("welcome","Welcome"),tf.HEADER),5,row); row++; if(!topics.isEmpty()){ Iterator iter = topics.values().iterator(); EmailTopic topic; ICCategory category; EmailAccount account; EmailLetter welcome; Collection welcomes; Collection accounts; int emailCount; int topicID; while(iter.hasNext()){ topic = (EmailTopic) iter.next(); topicID = topic.getIdentifier().intValue(); T.add(getTopicLink(topicID,topic.getName()),1,row); category = (ICCategory) categories.get(Integer.toString(topic.getCategoryId())); T.add(tf.format(category.getName()),2,row); accounts = MailFinder.getInstance().getTopicAccounts(topicID,MailProtocol.SMTP); if(accounts!=null && !accounts.isEmpty()){ account = (EmailAccount) accounts.iterator().next(); T.add(getAccountLink(topicID,Integer.parseInt( account.toString()),account.getHost()),3,row); } else{ T.add(getAccountLink(topicID,-1,"X"),3,row); } emailCount = MailFinder.getInstance().getListEmailsCount(topic.getListId()); T.add((getSubscribersLink(topicID,String.valueOf(emailCount))),4,row); welcomes = MailFinder.getInstance().getEmailLetters(topicID,MailLetter.TYPE_SUBSCRIPTION); if(welcomes!=null && !welcomes.isEmpty()){ welcome = (MailLetter) welcomes.iterator().next(); T.add(getWelcomeLetterLink(Integer.parseInt(welcome.toString()),topicID,welcome.getSubject()),5,row); //T.add(tf.format(welcome.getSubject()),5,row); } else{ T.add(getWelcomeLetterLink(-1,topicID,"X"),5,row); } row++; } } return T; }
T.add(getWelcomeLetterLink(Integer.parseInt(welcome.toString()),topicID,welcome.getSubject()),5,row);
T.add(getWelcomeLetterLink(welcome.getIdentifier().intValue()),topicID,welcome.getSubject()),5,row);
public PresentationObject getTopicsOverView(IWContext iwc){ Table T = new Table(); int row = 1; T.add(getTopicLink(-1,iwrb.getLocalizedString("new_topic","New topic")),1,row); row++; T.add(tf.format(iwrb.getLocalizedString("name","Name"),tf.HEADER),1,row); T.add(tf.format(iwrb.getLocalizedString("category","Category"),tf.HEADER),2,row); T.add(tf.format(iwrb.getLocalizedString("mail_server","Mail server"),tf.HEADER),3,row); T.add(tf.format(iwrb.getLocalizedString("subscribers","Subscribers"),tf.HEADER),4,row); T.add(tf.format(iwrb.getLocalizedString("welcome","Welcome"),tf.HEADER),5,row); row++; if(!topics.isEmpty()){ Iterator iter = topics.values().iterator(); EmailTopic topic; ICCategory category; EmailAccount account; EmailLetter welcome; Collection welcomes; Collection accounts; int emailCount; int topicID; while(iter.hasNext()){ topic = (EmailTopic) iter.next(); topicID = topic.getIdentifier().intValue(); T.add(getTopicLink(topicID,topic.getName()),1,row); category = (ICCategory) categories.get(Integer.toString(topic.getCategoryId())); T.add(tf.format(category.getName()),2,row); accounts = MailFinder.getInstance().getTopicAccounts(topicID,MailProtocol.SMTP); if(accounts!=null && !accounts.isEmpty()){ account = (EmailAccount) accounts.iterator().next(); T.add(getAccountLink(topicID,Integer.parseInt( account.toString()),account.getHost()),3,row); } else{ T.add(getAccountLink(topicID,-1,"X"),3,row); } emailCount = MailFinder.getInstance().getListEmailsCount(topic.getListId()); T.add((getSubscribersLink(topicID,String.valueOf(emailCount))),4,row); welcomes = MailFinder.getInstance().getEmailLetters(topicID,MailLetter.TYPE_SUBSCRIPTION); if(welcomes!=null && !welcomes.isEmpty()){ welcome = (MailLetter) welcomes.iterator().next(); T.add(getWelcomeLetterLink(Integer.parseInt(welcome.toString()),topicID,welcome.getSubject()),5,row); //T.add(tf.format(welcome.getSubject()),5,row); } else{ T.add(getWelcomeLetterLink(-1,topicID,"X"),5,row); } row++; } } return T; }
SQLColumn col = (SQLColumn)t.getValueAt(t.getSelectedRow(),4); Set<SQLTable> tables = new HashSet<SQLTable>(); for (int i =0; i < t.getRowCount(); i++){ tables.add((SQLTable)t.getValueAt(i,3)); } profilePanel.setTables(new ArrayList(tables));
SQLColumn col = (SQLColumn)t.getValueAt(t.getSelectedRow(), t.convertColumnIndexToView( ProfileColumn.valueOf("COLUMN").ordinal()));
public void mouseClicked(MouseEvent evt) { // TODO Auto-generated method stub Object obj = evt.getSource(); if (evt.getClickCount() == 2) { if ( obj instanceof JTable ) { JTable t = (JTable)obj; SQLColumn col = (SQLColumn)t.getValueAt(t.getSelectedRow(),4); Set<SQLTable> tables = new HashSet<SQLTable>(); for (int i =0; i < t.getRowCount(); i++){ tables.add((SQLTable)t.getValueAt(i,3)); } profilePanel.setTables(new ArrayList(tables)); profilePanel.getTableSelector().setSelectedItem(col.getParentTable()); profilePanel.getColumnSelector().setSelectedValue(col,true); tabPane.setSelectedIndex(1); } } }
Object o = viewTable.getValueAt(i,3);
Object o = viewTable.getValueAt(i, viewTable.convertColumnIndexToView( ProfileColumn.valueOf("TABLE").ordinal()));
public void actionPerformed(ActionEvent e) { if (dbTree == null) { logger.debug("dbtree was null when actionPerformed called"); return; } if ( dbTree.getSelectionPaths() == null ) { logger.debug("dbtree path selection was null when actionPerformed called"); return; } try { Set<SQLObject> sqlObject = new HashSet<SQLObject>(); for ( TreePath tp : dbTree.getSelectionPaths() ) { if ( tp.getLastPathComponent() instanceof SQLDatabase ) { sqlObject.add((SQLDatabase)tp.getLastPathComponent()); } else if ( tp.getLastPathComponent() instanceof SQLCatalog ) { SQLCatalog cat = (SQLCatalog)tp.getLastPathComponent(); sqlObject.add(cat); SQLDatabase db = ArchitectUtils.getAncestor(cat,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } else if ( tp.getLastPathComponent() instanceof SQLSchema ) { SQLSchema sch = (SQLSchema)tp.getLastPathComponent(); sqlObject.add(sch); SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); if ( cat != null && sqlObject.contains(cat)) sqlObject.remove(cat); SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } else if ( tp.getLastPathComponent() instanceof SQLTable ) { SQLTable tab = (SQLTable)tp.getLastPathComponent(); sqlObject.add(tab); SQLSchema sch = ArchitectUtils.getAncestor(tab,SQLSchema.class); if ( sch != null && sqlObject.contains(sch)) sqlObject.remove(sch); SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); if ( cat != null && sqlObject.contains(cat)) sqlObject.remove(cat); SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } else if ( tp.getLastPathComponent() instanceof SQLTable.Folder ) { SQLTable tab = ArchitectUtils.getAncestor((Folder)tp.getLastPathComponent(),SQLTable.class); sqlObject.add(tab); SQLSchema sch = ArchitectUtils.getAncestor(tab,SQLSchema.class); if ( sch != null && sqlObject.contains(sch)) sqlObject.remove(sch); SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); if ( cat != null && sqlObject.contains(cat)) sqlObject.remove(cat); SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } else if ( tp.getLastPathComponent() instanceof SQLColumn ) { SQLTable tab = ((SQLColumn)tp.getLastPathComponent()).getParentTable(); sqlObject.add((SQLColumn)tp.getLastPathComponent()); SQLSchema sch = ArchitectUtils.getAncestor(tab,SQLSchema.class); if ( sch != null && sqlObject.contains(sch)) sqlObject.remove(sch); SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); if ( cat != null && sqlObject.contains(cat)) sqlObject.remove(cat); SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } } final ArrayList<SQLObject> filter = new ArrayList<SQLObject>(); final Set<SQLTable> tables = new HashSet<SQLTable>(); for ( SQLObject o : sqlObject ) { if ( o instanceof SQLColumn){ tables.add(((SQLColumn)o).getParentTable()); } else { tables.addAll(ArchitectUtils.tablesUnder(o)); } if (! (o instanceof Folder)){ filter.add(o); } } profileManager.setCancelled(false); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Profiles"); final CommonCloseAction commonCloseAction = new CommonCloseAction(d); Action closeAction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { profileManager.setCancelled(true); commonCloseAction.actionPerformed(evt); } }; closeAction.putValue(Action.NAME, "Close"); final JDefaultButton closeButton = new JDefaultButton(closeAction); final JPanel progressViewPanel = new JPanel(new BorderLayout()); final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); buttonPanel.add(closeButton); progressViewPanel.add(buttonPanel, BorderLayout.SOUTH); final JProgressBar progressBar = new JProgressBar(); progressBar.setPreferredSize(new Dimension(450,20)); progressViewPanel.add(progressBar, BorderLayout.CENTER); final JLabel workingOn = new JLabel("Profiling:"); progressViewPanel.add(workingOn, BorderLayout.NORTH); ArchitectPanelBuilder.makeJDialogCancellable( d, commonCloseAction); d.getRootPane().setDefaultButton(closeButton); d.setContentPane(progressViewPanel); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); new ProgressWatcher(progressBar,profileManager,workingOn); // XXX This should be its own Action class? new Thread( new Runnable() { public void run() { try { List<SQLTable> toBeProfiled = new ArrayList<SQLTable>(); for (SQLTable t: tables) { if (profileManager.getResult(t)== null) { toBeProfiled.add(t); workingOn.setText("Adding "+t.getName()+ " ("+toBeProfiled.size()+")"); } } profileManager.createProfiles(toBeProfiled, workingOn); progressBar.setVisible(false); JLabel status = new JLabel("Generating reports, Please wait......"); progressViewPanel.add(status, BorderLayout.NORTH); status.setVisible(true); JTabbedPane tabPane = new JTabbedPane(); ProfileTableModel tm = new ProfileTableModel(); for (SQLObject sqo: filter){ tm.addFilter(sqo); } tm.setProfileManager(profileManager); TableModelSearchDecorator searchDecorator = new TableModelSearchDecorator(tm); TableModelSortDecorator tableModelSortDecorator = new TableModelSortDecorator(searchDecorator); final ProfileTable viewTable = new ProfileTable(tableModelSortDecorator); searchDecorator.setTableTextConverter(viewTable); JTableHeader tableHeader = viewTable.getTableHeader(); tableModelSortDecorator.setTableHeader(tableHeader); viewTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); ProfilePanelMouseListener profilePanelMouseListener = new ProfilePanelMouseListener(); profilePanelMouseListener.setTabPane(tabPane); viewTable.addMouseListener( profilePanelMouseListener); JScrollPane editorScrollPane = new JScrollPane(viewTable); editorScrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(800, 600)); editorScrollPane.setMinimumSize(new Dimension(10, 10)); // reset column widths ((ProfileTable) viewTable).initColumnSizes(); JPanel tableViewPane = new JPanel(new BorderLayout()); tableViewPane.add(editorScrollPane,BorderLayout.CENTER); JLabel searchLabel = new JLabel("Search:"); JTextField searchField = new JTextField(searchDecorator.getDoc(),"",25); searchField.setEditable(true); JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); searchPanel.add(searchLabel); searchPanel.add(searchField); tableViewPane.add(searchPanel,BorderLayout.NORTH); ButtonBarBuilder buttonBuilder = new ButtonBarBuilder(); JButton save = new JButton(new SaveProfileAction(d,viewTable,profileManager)); JButton refresh = new JButton(new AbstractAction("Refresh"){ public void actionPerformed(ActionEvent e) { Set<SQLTable> uniqueTables = new HashSet(); for (int i: viewTable.getSelectedRows()) { Object o = viewTable.getValueAt(i,3); SQLTable table = (SQLTable) o ; uniqueTables.add(table); } try { profileManager.setCancelled(false); profileManager.createProfiles(uniqueTables); } catch (SQLException e1) { throw new RuntimeException(e1); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } } }); JButton delete = new JButton(new AbstractAction("Delete"){ public void actionPerformed(ActionEvent e) { int[] killMe = viewTable.getSelectedRows(); Arrays.sort(killMe); // iterate backwards so the rows don't shift away on us! for (int i = killMe.length-1; i >= 0; i--) { logger.debug("Deleting row "+killMe[i]+": "+viewTable.getValueAt(killMe[i],4)); SQLColumn col = (SQLColumn) viewTable.getValueAt(killMe[i], 4); try { profileManager.remove(col); } catch (ArchitectException e1) { ASUtils.showExceptionDialog(d,"Could delete row of:" + col.getName(), e1); } } } }); JButton deleteAll = new JButton(new AbstractAction("Delete All"){ public void actionPerformed(ActionEvent e) { while ( viewTable.getRowCount() > 0 ) { SQLColumn col = (SQLColumn) viewTable.getValueAt(0, 4); try { profileManager.remove(col); } catch (ArchitectException e1) { ASUtils.showExceptionDialog(d,"Could delete row of:" + col.getName(), e1); } } } }); JButton[] buttonArray = {refresh,delete,deleteAll,save,closeButton}; buttonBuilder.addGriddedButtons(buttonArray); tableViewPane.add(buttonBuilder.getPanel(),BorderLayout.SOUTH); tabPane.addTab("Table View", tableViewPane ); ProfilePanel p = new ProfilePanel(profileManager); tabPane.addTab("Graph View",p); profilePanelMouseListener.setProfilePanel(p); List<SQLTable> list = new ArrayList(tables); p.setTables(list); p.setChartType(ChartTypes.PIE); d.setVisible(false); d.remove(progressViewPanel); d.setContentPane(tabPane); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); } catch (SQLException e) { logger.error("Error in Profile Action ", e); ASUtils.showExceptionDialogNoReport(dbTree, "Error during profile run", e); } catch (ArchitectException e) { logger.error("Error in Profile Action", e); ASUtils.showExceptionDialog(dbTree, "Error during profile run", e); } } }).start(); } catch (Exception ex) { logger.error("Error in Profile Action ", ex); ASUtils.showExceptionDialog(dbTree, "Error during profile run", ex); } }
logger.debug("Deleting row "+killMe[i]+": "+viewTable.getValueAt(killMe[i],4)); SQLColumn col = (SQLColumn) viewTable.getValueAt(killMe[i], 4);
logger.debug("Deleting row "+ killMe[i]+ ": "+ viewTable.getValueAt(killMe[i], viewTable.convertColumnIndexToView( ProfileColumn.valueOf("COLUMN").ordinal()))); SQLColumn col = (SQLColumn) viewTable.getValueAt(killMe[i], viewTable.convertColumnIndexToView( ProfileColumn.valueOf("COLUMN").ordinal()));
public void actionPerformed(ActionEvent e) { if (dbTree == null) { logger.debug("dbtree was null when actionPerformed called"); return; } if ( dbTree.getSelectionPaths() == null ) { logger.debug("dbtree path selection was null when actionPerformed called"); return; } try { Set<SQLObject> sqlObject = new HashSet<SQLObject>(); for ( TreePath tp : dbTree.getSelectionPaths() ) { if ( tp.getLastPathComponent() instanceof SQLDatabase ) { sqlObject.add((SQLDatabase)tp.getLastPathComponent()); } else if ( tp.getLastPathComponent() instanceof SQLCatalog ) { SQLCatalog cat = (SQLCatalog)tp.getLastPathComponent(); sqlObject.add(cat); SQLDatabase db = ArchitectUtils.getAncestor(cat,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } else if ( tp.getLastPathComponent() instanceof SQLSchema ) { SQLSchema sch = (SQLSchema)tp.getLastPathComponent(); sqlObject.add(sch); SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); if ( cat != null && sqlObject.contains(cat)) sqlObject.remove(cat); SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } else if ( tp.getLastPathComponent() instanceof SQLTable ) { SQLTable tab = (SQLTable)tp.getLastPathComponent(); sqlObject.add(tab); SQLSchema sch = ArchitectUtils.getAncestor(tab,SQLSchema.class); if ( sch != null && sqlObject.contains(sch)) sqlObject.remove(sch); SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); if ( cat != null && sqlObject.contains(cat)) sqlObject.remove(cat); SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } else if ( tp.getLastPathComponent() instanceof SQLTable.Folder ) { SQLTable tab = ArchitectUtils.getAncestor((Folder)tp.getLastPathComponent(),SQLTable.class); sqlObject.add(tab); SQLSchema sch = ArchitectUtils.getAncestor(tab,SQLSchema.class); if ( sch != null && sqlObject.contains(sch)) sqlObject.remove(sch); SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); if ( cat != null && sqlObject.contains(cat)) sqlObject.remove(cat); SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } else if ( tp.getLastPathComponent() instanceof SQLColumn ) { SQLTable tab = ((SQLColumn)tp.getLastPathComponent()).getParentTable(); sqlObject.add((SQLColumn)tp.getLastPathComponent()); SQLSchema sch = ArchitectUtils.getAncestor(tab,SQLSchema.class); if ( sch != null && sqlObject.contains(sch)) sqlObject.remove(sch); SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); if ( cat != null && sqlObject.contains(cat)) sqlObject.remove(cat); SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } } final ArrayList<SQLObject> filter = new ArrayList<SQLObject>(); final Set<SQLTable> tables = new HashSet<SQLTable>(); for ( SQLObject o : sqlObject ) { if ( o instanceof SQLColumn){ tables.add(((SQLColumn)o).getParentTable()); } else { tables.addAll(ArchitectUtils.tablesUnder(o)); } if (! (o instanceof Folder)){ filter.add(o); } } profileManager.setCancelled(false); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Profiles"); final CommonCloseAction commonCloseAction = new CommonCloseAction(d); Action closeAction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { profileManager.setCancelled(true); commonCloseAction.actionPerformed(evt); } }; closeAction.putValue(Action.NAME, "Close"); final JDefaultButton closeButton = new JDefaultButton(closeAction); final JPanel progressViewPanel = new JPanel(new BorderLayout()); final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); buttonPanel.add(closeButton); progressViewPanel.add(buttonPanel, BorderLayout.SOUTH); final JProgressBar progressBar = new JProgressBar(); progressBar.setPreferredSize(new Dimension(450,20)); progressViewPanel.add(progressBar, BorderLayout.CENTER); final JLabel workingOn = new JLabel("Profiling:"); progressViewPanel.add(workingOn, BorderLayout.NORTH); ArchitectPanelBuilder.makeJDialogCancellable( d, commonCloseAction); d.getRootPane().setDefaultButton(closeButton); d.setContentPane(progressViewPanel); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); new ProgressWatcher(progressBar,profileManager,workingOn); // XXX This should be its own Action class? new Thread( new Runnable() { public void run() { try { List<SQLTable> toBeProfiled = new ArrayList<SQLTable>(); for (SQLTable t: tables) { if (profileManager.getResult(t)== null) { toBeProfiled.add(t); workingOn.setText("Adding "+t.getName()+ " ("+toBeProfiled.size()+")"); } } profileManager.createProfiles(toBeProfiled, workingOn); progressBar.setVisible(false); JLabel status = new JLabel("Generating reports, Please wait......"); progressViewPanel.add(status, BorderLayout.NORTH); status.setVisible(true); JTabbedPane tabPane = new JTabbedPane(); ProfileTableModel tm = new ProfileTableModel(); for (SQLObject sqo: filter){ tm.addFilter(sqo); } tm.setProfileManager(profileManager); TableModelSearchDecorator searchDecorator = new TableModelSearchDecorator(tm); TableModelSortDecorator tableModelSortDecorator = new TableModelSortDecorator(searchDecorator); final ProfileTable viewTable = new ProfileTable(tableModelSortDecorator); searchDecorator.setTableTextConverter(viewTable); JTableHeader tableHeader = viewTable.getTableHeader(); tableModelSortDecorator.setTableHeader(tableHeader); viewTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); ProfilePanelMouseListener profilePanelMouseListener = new ProfilePanelMouseListener(); profilePanelMouseListener.setTabPane(tabPane); viewTable.addMouseListener( profilePanelMouseListener); JScrollPane editorScrollPane = new JScrollPane(viewTable); editorScrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(800, 600)); editorScrollPane.setMinimumSize(new Dimension(10, 10)); // reset column widths ((ProfileTable) viewTable).initColumnSizes(); JPanel tableViewPane = new JPanel(new BorderLayout()); tableViewPane.add(editorScrollPane,BorderLayout.CENTER); JLabel searchLabel = new JLabel("Search:"); JTextField searchField = new JTextField(searchDecorator.getDoc(),"",25); searchField.setEditable(true); JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); searchPanel.add(searchLabel); searchPanel.add(searchField); tableViewPane.add(searchPanel,BorderLayout.NORTH); ButtonBarBuilder buttonBuilder = new ButtonBarBuilder(); JButton save = new JButton(new SaveProfileAction(d,viewTable,profileManager)); JButton refresh = new JButton(new AbstractAction("Refresh"){ public void actionPerformed(ActionEvent e) { Set<SQLTable> uniqueTables = new HashSet(); for (int i: viewTable.getSelectedRows()) { Object o = viewTable.getValueAt(i,3); SQLTable table = (SQLTable) o ; uniqueTables.add(table); } try { profileManager.setCancelled(false); profileManager.createProfiles(uniqueTables); } catch (SQLException e1) { throw new RuntimeException(e1); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } } }); JButton delete = new JButton(new AbstractAction("Delete"){ public void actionPerformed(ActionEvent e) { int[] killMe = viewTable.getSelectedRows(); Arrays.sort(killMe); // iterate backwards so the rows don't shift away on us! for (int i = killMe.length-1; i >= 0; i--) { logger.debug("Deleting row "+killMe[i]+": "+viewTable.getValueAt(killMe[i],4)); SQLColumn col = (SQLColumn) viewTable.getValueAt(killMe[i], 4); try { profileManager.remove(col); } catch (ArchitectException e1) { ASUtils.showExceptionDialog(d,"Could delete row of:" + col.getName(), e1); } } } }); JButton deleteAll = new JButton(new AbstractAction("Delete All"){ public void actionPerformed(ActionEvent e) { while ( viewTable.getRowCount() > 0 ) { SQLColumn col = (SQLColumn) viewTable.getValueAt(0, 4); try { profileManager.remove(col); } catch (ArchitectException e1) { ASUtils.showExceptionDialog(d,"Could delete row of:" + col.getName(), e1); } } } }); JButton[] buttonArray = {refresh,delete,deleteAll,save,closeButton}; buttonBuilder.addGriddedButtons(buttonArray); tableViewPane.add(buttonBuilder.getPanel(),BorderLayout.SOUTH); tabPane.addTab("Table View", tableViewPane ); ProfilePanel p = new ProfilePanel(profileManager); tabPane.addTab("Graph View",p); profilePanelMouseListener.setProfilePanel(p); List<SQLTable> list = new ArrayList(tables); p.setTables(list); p.setChartType(ChartTypes.PIE); d.setVisible(false); d.remove(progressViewPanel); d.setContentPane(tabPane); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); } catch (SQLException e) { logger.error("Error in Profile Action ", e); ASUtils.showExceptionDialogNoReport(dbTree, "Error during profile run", e); } catch (ArchitectException e) { logger.error("Error in Profile Action", e); ASUtils.showExceptionDialog(dbTree, "Error during profile run", e); } } }).start(); } catch (Exception ex) { logger.error("Error in Profile Action ", ex); ASUtils.showExceptionDialog(dbTree, "Error during profile run", ex); } }
SQLColumn col = (SQLColumn) viewTable.getValueAt(0, 4);
SQLColumn col = (SQLColumn) viewTable.getValueAt(0, viewTable.convertColumnIndexToView( ProfileColumn.valueOf("COLUMN").ordinal()));
public void actionPerformed(ActionEvent e) { if (dbTree == null) { logger.debug("dbtree was null when actionPerformed called"); return; } if ( dbTree.getSelectionPaths() == null ) { logger.debug("dbtree path selection was null when actionPerformed called"); return; } try { Set<SQLObject> sqlObject = new HashSet<SQLObject>(); for ( TreePath tp : dbTree.getSelectionPaths() ) { if ( tp.getLastPathComponent() instanceof SQLDatabase ) { sqlObject.add((SQLDatabase)tp.getLastPathComponent()); } else if ( tp.getLastPathComponent() instanceof SQLCatalog ) { SQLCatalog cat = (SQLCatalog)tp.getLastPathComponent(); sqlObject.add(cat); SQLDatabase db = ArchitectUtils.getAncestor(cat,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } else if ( tp.getLastPathComponent() instanceof SQLSchema ) { SQLSchema sch = (SQLSchema)tp.getLastPathComponent(); sqlObject.add(sch); SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); if ( cat != null && sqlObject.contains(cat)) sqlObject.remove(cat); SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } else if ( tp.getLastPathComponent() instanceof SQLTable ) { SQLTable tab = (SQLTable)tp.getLastPathComponent(); sqlObject.add(tab); SQLSchema sch = ArchitectUtils.getAncestor(tab,SQLSchema.class); if ( sch != null && sqlObject.contains(sch)) sqlObject.remove(sch); SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); if ( cat != null && sqlObject.contains(cat)) sqlObject.remove(cat); SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } else if ( tp.getLastPathComponent() instanceof SQLTable.Folder ) { SQLTable tab = ArchitectUtils.getAncestor((Folder)tp.getLastPathComponent(),SQLTable.class); sqlObject.add(tab); SQLSchema sch = ArchitectUtils.getAncestor(tab,SQLSchema.class); if ( sch != null && sqlObject.contains(sch)) sqlObject.remove(sch); SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); if ( cat != null && sqlObject.contains(cat)) sqlObject.remove(cat); SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } else if ( tp.getLastPathComponent() instanceof SQLColumn ) { SQLTable tab = ((SQLColumn)tp.getLastPathComponent()).getParentTable(); sqlObject.add((SQLColumn)tp.getLastPathComponent()); SQLSchema sch = ArchitectUtils.getAncestor(tab,SQLSchema.class); if ( sch != null && sqlObject.contains(sch)) sqlObject.remove(sch); SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); if ( cat != null && sqlObject.contains(cat)) sqlObject.remove(cat); SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } } final ArrayList<SQLObject> filter = new ArrayList<SQLObject>(); final Set<SQLTable> tables = new HashSet<SQLTable>(); for ( SQLObject o : sqlObject ) { if ( o instanceof SQLColumn){ tables.add(((SQLColumn)o).getParentTable()); } else { tables.addAll(ArchitectUtils.tablesUnder(o)); } if (! (o instanceof Folder)){ filter.add(o); } } profileManager.setCancelled(false); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Profiles"); final CommonCloseAction commonCloseAction = new CommonCloseAction(d); Action closeAction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { profileManager.setCancelled(true); commonCloseAction.actionPerformed(evt); } }; closeAction.putValue(Action.NAME, "Close"); final JDefaultButton closeButton = new JDefaultButton(closeAction); final JPanel progressViewPanel = new JPanel(new BorderLayout()); final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); buttonPanel.add(closeButton); progressViewPanel.add(buttonPanel, BorderLayout.SOUTH); final JProgressBar progressBar = new JProgressBar(); progressBar.setPreferredSize(new Dimension(450,20)); progressViewPanel.add(progressBar, BorderLayout.CENTER); final JLabel workingOn = new JLabel("Profiling:"); progressViewPanel.add(workingOn, BorderLayout.NORTH); ArchitectPanelBuilder.makeJDialogCancellable( d, commonCloseAction); d.getRootPane().setDefaultButton(closeButton); d.setContentPane(progressViewPanel); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); new ProgressWatcher(progressBar,profileManager,workingOn); // XXX This should be its own Action class? new Thread( new Runnable() { public void run() { try { List<SQLTable> toBeProfiled = new ArrayList<SQLTable>(); for (SQLTable t: tables) { if (profileManager.getResult(t)== null) { toBeProfiled.add(t); workingOn.setText("Adding "+t.getName()+ " ("+toBeProfiled.size()+")"); } } profileManager.createProfiles(toBeProfiled, workingOn); progressBar.setVisible(false); JLabel status = new JLabel("Generating reports, Please wait......"); progressViewPanel.add(status, BorderLayout.NORTH); status.setVisible(true); JTabbedPane tabPane = new JTabbedPane(); ProfileTableModel tm = new ProfileTableModel(); for (SQLObject sqo: filter){ tm.addFilter(sqo); } tm.setProfileManager(profileManager); TableModelSearchDecorator searchDecorator = new TableModelSearchDecorator(tm); TableModelSortDecorator tableModelSortDecorator = new TableModelSortDecorator(searchDecorator); final ProfileTable viewTable = new ProfileTable(tableModelSortDecorator); searchDecorator.setTableTextConverter(viewTable); JTableHeader tableHeader = viewTable.getTableHeader(); tableModelSortDecorator.setTableHeader(tableHeader); viewTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); ProfilePanelMouseListener profilePanelMouseListener = new ProfilePanelMouseListener(); profilePanelMouseListener.setTabPane(tabPane); viewTable.addMouseListener( profilePanelMouseListener); JScrollPane editorScrollPane = new JScrollPane(viewTable); editorScrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(800, 600)); editorScrollPane.setMinimumSize(new Dimension(10, 10)); // reset column widths ((ProfileTable) viewTable).initColumnSizes(); JPanel tableViewPane = new JPanel(new BorderLayout()); tableViewPane.add(editorScrollPane,BorderLayout.CENTER); JLabel searchLabel = new JLabel("Search:"); JTextField searchField = new JTextField(searchDecorator.getDoc(),"",25); searchField.setEditable(true); JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); searchPanel.add(searchLabel); searchPanel.add(searchField); tableViewPane.add(searchPanel,BorderLayout.NORTH); ButtonBarBuilder buttonBuilder = new ButtonBarBuilder(); JButton save = new JButton(new SaveProfileAction(d,viewTable,profileManager)); JButton refresh = new JButton(new AbstractAction("Refresh"){ public void actionPerformed(ActionEvent e) { Set<SQLTable> uniqueTables = new HashSet(); for (int i: viewTable.getSelectedRows()) { Object o = viewTable.getValueAt(i,3); SQLTable table = (SQLTable) o ; uniqueTables.add(table); } try { profileManager.setCancelled(false); profileManager.createProfiles(uniqueTables); } catch (SQLException e1) { throw new RuntimeException(e1); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } } }); JButton delete = new JButton(new AbstractAction("Delete"){ public void actionPerformed(ActionEvent e) { int[] killMe = viewTable.getSelectedRows(); Arrays.sort(killMe); // iterate backwards so the rows don't shift away on us! for (int i = killMe.length-1; i >= 0; i--) { logger.debug("Deleting row "+killMe[i]+": "+viewTable.getValueAt(killMe[i],4)); SQLColumn col = (SQLColumn) viewTable.getValueAt(killMe[i], 4); try { profileManager.remove(col); } catch (ArchitectException e1) { ASUtils.showExceptionDialog(d,"Could delete row of:" + col.getName(), e1); } } } }); JButton deleteAll = new JButton(new AbstractAction("Delete All"){ public void actionPerformed(ActionEvent e) { while ( viewTable.getRowCount() > 0 ) { SQLColumn col = (SQLColumn) viewTable.getValueAt(0, 4); try { profileManager.remove(col); } catch (ArchitectException e1) { ASUtils.showExceptionDialog(d,"Could delete row of:" + col.getName(), e1); } } } }); JButton[] buttonArray = {refresh,delete,deleteAll,save,closeButton}; buttonBuilder.addGriddedButtons(buttonArray); tableViewPane.add(buttonBuilder.getPanel(),BorderLayout.SOUTH); tabPane.addTab("Table View", tableViewPane ); ProfilePanel p = new ProfilePanel(profileManager); tabPane.addTab("Graph View",p); profilePanelMouseListener.setProfilePanel(p); List<SQLTable> list = new ArrayList(tables); p.setTables(list); p.setChartType(ChartTypes.PIE); d.setVisible(false); d.remove(progressViewPanel); d.setContentPane(tabPane); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); } catch (SQLException e) { logger.error("Error in Profile Action ", e); ASUtils.showExceptionDialogNoReport(dbTree, "Error during profile run", e); } catch (ArchitectException e) { logger.error("Error in Profile Action", e); ASUtils.showExceptionDialog(dbTree, "Error during profile run", e); } } }).start(); } catch (Exception ex) { logger.error("Error in Profile Action ", ex); ASUtils.showExceptionDialog(dbTree, "Error during profile run", ex); } }
List<SQLTable> list = new ArrayList(tables); p.setTables(list);
public void actionPerformed(ActionEvent e) { if (dbTree == null) { logger.debug("dbtree was null when actionPerformed called"); return; } if ( dbTree.getSelectionPaths() == null ) { logger.debug("dbtree path selection was null when actionPerformed called"); return; } try { Set<SQLObject> sqlObject = new HashSet<SQLObject>(); for ( TreePath tp : dbTree.getSelectionPaths() ) { if ( tp.getLastPathComponent() instanceof SQLDatabase ) { sqlObject.add((SQLDatabase)tp.getLastPathComponent()); } else if ( tp.getLastPathComponent() instanceof SQLCatalog ) { SQLCatalog cat = (SQLCatalog)tp.getLastPathComponent(); sqlObject.add(cat); SQLDatabase db = ArchitectUtils.getAncestor(cat,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } else if ( tp.getLastPathComponent() instanceof SQLSchema ) { SQLSchema sch = (SQLSchema)tp.getLastPathComponent(); sqlObject.add(sch); SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); if ( cat != null && sqlObject.contains(cat)) sqlObject.remove(cat); SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } else if ( tp.getLastPathComponent() instanceof SQLTable ) { SQLTable tab = (SQLTable)tp.getLastPathComponent(); sqlObject.add(tab); SQLSchema sch = ArchitectUtils.getAncestor(tab,SQLSchema.class); if ( sch != null && sqlObject.contains(sch)) sqlObject.remove(sch); SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); if ( cat != null && sqlObject.contains(cat)) sqlObject.remove(cat); SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } else if ( tp.getLastPathComponent() instanceof SQLTable.Folder ) { SQLTable tab = ArchitectUtils.getAncestor((Folder)tp.getLastPathComponent(),SQLTable.class); sqlObject.add(tab); SQLSchema sch = ArchitectUtils.getAncestor(tab,SQLSchema.class); if ( sch != null && sqlObject.contains(sch)) sqlObject.remove(sch); SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); if ( cat != null && sqlObject.contains(cat)) sqlObject.remove(cat); SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } else if ( tp.getLastPathComponent() instanceof SQLColumn ) { SQLTable tab = ((SQLColumn)tp.getLastPathComponent()).getParentTable(); sqlObject.add((SQLColumn)tp.getLastPathComponent()); SQLSchema sch = ArchitectUtils.getAncestor(tab,SQLSchema.class); if ( sch != null && sqlObject.contains(sch)) sqlObject.remove(sch); SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); if ( cat != null && sqlObject.contains(cat)) sqlObject.remove(cat); SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } } final ArrayList<SQLObject> filter = new ArrayList<SQLObject>(); final Set<SQLTable> tables = new HashSet<SQLTable>(); for ( SQLObject o : sqlObject ) { if ( o instanceof SQLColumn){ tables.add(((SQLColumn)o).getParentTable()); } else { tables.addAll(ArchitectUtils.tablesUnder(o)); } if (! (o instanceof Folder)){ filter.add(o); } } profileManager.setCancelled(false); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Profiles"); final CommonCloseAction commonCloseAction = new CommonCloseAction(d); Action closeAction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { profileManager.setCancelled(true); commonCloseAction.actionPerformed(evt); } }; closeAction.putValue(Action.NAME, "Close"); final JDefaultButton closeButton = new JDefaultButton(closeAction); final JPanel progressViewPanel = new JPanel(new BorderLayout()); final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); buttonPanel.add(closeButton); progressViewPanel.add(buttonPanel, BorderLayout.SOUTH); final JProgressBar progressBar = new JProgressBar(); progressBar.setPreferredSize(new Dimension(450,20)); progressViewPanel.add(progressBar, BorderLayout.CENTER); final JLabel workingOn = new JLabel("Profiling:"); progressViewPanel.add(workingOn, BorderLayout.NORTH); ArchitectPanelBuilder.makeJDialogCancellable( d, commonCloseAction); d.getRootPane().setDefaultButton(closeButton); d.setContentPane(progressViewPanel); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); new ProgressWatcher(progressBar,profileManager,workingOn); // XXX This should be its own Action class? new Thread( new Runnable() { public void run() { try { List<SQLTable> toBeProfiled = new ArrayList<SQLTable>(); for (SQLTable t: tables) { if (profileManager.getResult(t)== null) { toBeProfiled.add(t); workingOn.setText("Adding "+t.getName()+ " ("+toBeProfiled.size()+")"); } } profileManager.createProfiles(toBeProfiled, workingOn); progressBar.setVisible(false); JLabel status = new JLabel("Generating reports, Please wait......"); progressViewPanel.add(status, BorderLayout.NORTH); status.setVisible(true); JTabbedPane tabPane = new JTabbedPane(); ProfileTableModel tm = new ProfileTableModel(); for (SQLObject sqo: filter){ tm.addFilter(sqo); } tm.setProfileManager(profileManager); TableModelSearchDecorator searchDecorator = new TableModelSearchDecorator(tm); TableModelSortDecorator tableModelSortDecorator = new TableModelSortDecorator(searchDecorator); final ProfileTable viewTable = new ProfileTable(tableModelSortDecorator); searchDecorator.setTableTextConverter(viewTable); JTableHeader tableHeader = viewTable.getTableHeader(); tableModelSortDecorator.setTableHeader(tableHeader); viewTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); ProfilePanelMouseListener profilePanelMouseListener = new ProfilePanelMouseListener(); profilePanelMouseListener.setTabPane(tabPane); viewTable.addMouseListener( profilePanelMouseListener); JScrollPane editorScrollPane = new JScrollPane(viewTable); editorScrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(800, 600)); editorScrollPane.setMinimumSize(new Dimension(10, 10)); // reset column widths ((ProfileTable) viewTable).initColumnSizes(); JPanel tableViewPane = new JPanel(new BorderLayout()); tableViewPane.add(editorScrollPane,BorderLayout.CENTER); JLabel searchLabel = new JLabel("Search:"); JTextField searchField = new JTextField(searchDecorator.getDoc(),"",25); searchField.setEditable(true); JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); searchPanel.add(searchLabel); searchPanel.add(searchField); tableViewPane.add(searchPanel,BorderLayout.NORTH); ButtonBarBuilder buttonBuilder = new ButtonBarBuilder(); JButton save = new JButton(new SaveProfileAction(d,viewTable,profileManager)); JButton refresh = new JButton(new AbstractAction("Refresh"){ public void actionPerformed(ActionEvent e) { Set<SQLTable> uniqueTables = new HashSet(); for (int i: viewTable.getSelectedRows()) { Object o = viewTable.getValueAt(i,3); SQLTable table = (SQLTable) o ; uniqueTables.add(table); } try { profileManager.setCancelled(false); profileManager.createProfiles(uniqueTables); } catch (SQLException e1) { throw new RuntimeException(e1); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } } }); JButton delete = new JButton(new AbstractAction("Delete"){ public void actionPerformed(ActionEvent e) { int[] killMe = viewTable.getSelectedRows(); Arrays.sort(killMe); // iterate backwards so the rows don't shift away on us! for (int i = killMe.length-1; i >= 0; i--) { logger.debug("Deleting row "+killMe[i]+": "+viewTable.getValueAt(killMe[i],4)); SQLColumn col = (SQLColumn) viewTable.getValueAt(killMe[i], 4); try { profileManager.remove(col); } catch (ArchitectException e1) { ASUtils.showExceptionDialog(d,"Could delete row of:" + col.getName(), e1); } } } }); JButton deleteAll = new JButton(new AbstractAction("Delete All"){ public void actionPerformed(ActionEvent e) { while ( viewTable.getRowCount() > 0 ) { SQLColumn col = (SQLColumn) viewTable.getValueAt(0, 4); try { profileManager.remove(col); } catch (ArchitectException e1) { ASUtils.showExceptionDialog(d,"Could delete row of:" + col.getName(), e1); } } } }); JButton[] buttonArray = {refresh,delete,deleteAll,save,closeButton}; buttonBuilder.addGriddedButtons(buttonArray); tableViewPane.add(buttonBuilder.getPanel(),BorderLayout.SOUTH); tabPane.addTab("Table View", tableViewPane ); ProfilePanel p = new ProfilePanel(profileManager); tabPane.addTab("Graph View",p); profilePanelMouseListener.setProfilePanel(p); List<SQLTable> list = new ArrayList(tables); p.setTables(list); p.setChartType(ChartTypes.PIE); d.setVisible(false); d.remove(progressViewPanel); d.setContentPane(tabPane); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); } catch (SQLException e) { logger.error("Error in Profile Action ", e); ASUtils.showExceptionDialogNoReport(dbTree, "Error during profile run", e); } catch (ArchitectException e) { logger.error("Error in Profile Action", e); ASUtils.showExceptionDialog(dbTree, "Error during profile run", e); } } }).start(); } catch (Exception ex) { logger.error("Error in Profile Action ", ex); ASUtils.showExceptionDialog(dbTree, "Error during profile run", ex); } }
if ( viewTable.getRowCount() > 0 ) { SQLColumn col = (SQLColumn)viewTable.getValueAt(0, viewTable.convertColumnIndexToView( ProfileColumn.valueOf("COLUMN").ordinal())); p.getTableSelector().setSelectedItem(col.getParentTable()); p.getColumnSelector().setSelectedValue(col,true); }
public void actionPerformed(ActionEvent e) { if (dbTree == null) { logger.debug("dbtree was null when actionPerformed called"); return; } if ( dbTree.getSelectionPaths() == null ) { logger.debug("dbtree path selection was null when actionPerformed called"); return; } try { Set<SQLObject> sqlObject = new HashSet<SQLObject>(); for ( TreePath tp : dbTree.getSelectionPaths() ) { if ( tp.getLastPathComponent() instanceof SQLDatabase ) { sqlObject.add((SQLDatabase)tp.getLastPathComponent()); } else if ( tp.getLastPathComponent() instanceof SQLCatalog ) { SQLCatalog cat = (SQLCatalog)tp.getLastPathComponent(); sqlObject.add(cat); SQLDatabase db = ArchitectUtils.getAncestor(cat,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } else if ( tp.getLastPathComponent() instanceof SQLSchema ) { SQLSchema sch = (SQLSchema)tp.getLastPathComponent(); sqlObject.add(sch); SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); if ( cat != null && sqlObject.contains(cat)) sqlObject.remove(cat); SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } else if ( tp.getLastPathComponent() instanceof SQLTable ) { SQLTable tab = (SQLTable)tp.getLastPathComponent(); sqlObject.add(tab); SQLSchema sch = ArchitectUtils.getAncestor(tab,SQLSchema.class); if ( sch != null && sqlObject.contains(sch)) sqlObject.remove(sch); SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); if ( cat != null && sqlObject.contains(cat)) sqlObject.remove(cat); SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } else if ( tp.getLastPathComponent() instanceof SQLTable.Folder ) { SQLTable tab = ArchitectUtils.getAncestor((Folder)tp.getLastPathComponent(),SQLTable.class); sqlObject.add(tab); SQLSchema sch = ArchitectUtils.getAncestor(tab,SQLSchema.class); if ( sch != null && sqlObject.contains(sch)) sqlObject.remove(sch); SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); if ( cat != null && sqlObject.contains(cat)) sqlObject.remove(cat); SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } else if ( tp.getLastPathComponent() instanceof SQLColumn ) { SQLTable tab = ((SQLColumn)tp.getLastPathComponent()).getParentTable(); sqlObject.add((SQLColumn)tp.getLastPathComponent()); SQLSchema sch = ArchitectUtils.getAncestor(tab,SQLSchema.class); if ( sch != null && sqlObject.contains(sch)) sqlObject.remove(sch); SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); if ( cat != null && sqlObject.contains(cat)) sqlObject.remove(cat); SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); if ( db != null && sqlObject.contains(db)) sqlObject.remove(db); } } final ArrayList<SQLObject> filter = new ArrayList<SQLObject>(); final Set<SQLTable> tables = new HashSet<SQLTable>(); for ( SQLObject o : sqlObject ) { if ( o instanceof SQLColumn){ tables.add(((SQLColumn)o).getParentTable()); } else { tables.addAll(ArchitectUtils.tablesUnder(o)); } if (! (o instanceof Folder)){ filter.add(o); } } profileManager.setCancelled(false); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Profiles"); final CommonCloseAction commonCloseAction = new CommonCloseAction(d); Action closeAction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { profileManager.setCancelled(true); commonCloseAction.actionPerformed(evt); } }; closeAction.putValue(Action.NAME, "Close"); final JDefaultButton closeButton = new JDefaultButton(closeAction); final JPanel progressViewPanel = new JPanel(new BorderLayout()); final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); buttonPanel.add(closeButton); progressViewPanel.add(buttonPanel, BorderLayout.SOUTH); final JProgressBar progressBar = new JProgressBar(); progressBar.setPreferredSize(new Dimension(450,20)); progressViewPanel.add(progressBar, BorderLayout.CENTER); final JLabel workingOn = new JLabel("Profiling:"); progressViewPanel.add(workingOn, BorderLayout.NORTH); ArchitectPanelBuilder.makeJDialogCancellable( d, commonCloseAction); d.getRootPane().setDefaultButton(closeButton); d.setContentPane(progressViewPanel); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); new ProgressWatcher(progressBar,profileManager,workingOn); // XXX This should be its own Action class? new Thread( new Runnable() { public void run() { try { List<SQLTable> toBeProfiled = new ArrayList<SQLTable>(); for (SQLTable t: tables) { if (profileManager.getResult(t)== null) { toBeProfiled.add(t); workingOn.setText("Adding "+t.getName()+ " ("+toBeProfiled.size()+")"); } } profileManager.createProfiles(toBeProfiled, workingOn); progressBar.setVisible(false); JLabel status = new JLabel("Generating reports, Please wait......"); progressViewPanel.add(status, BorderLayout.NORTH); status.setVisible(true); JTabbedPane tabPane = new JTabbedPane(); ProfileTableModel tm = new ProfileTableModel(); for (SQLObject sqo: filter){ tm.addFilter(sqo); } tm.setProfileManager(profileManager); TableModelSearchDecorator searchDecorator = new TableModelSearchDecorator(tm); TableModelSortDecorator tableModelSortDecorator = new TableModelSortDecorator(searchDecorator); final ProfileTable viewTable = new ProfileTable(tableModelSortDecorator); searchDecorator.setTableTextConverter(viewTable); JTableHeader tableHeader = viewTable.getTableHeader(); tableModelSortDecorator.setTableHeader(tableHeader); viewTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); ProfilePanelMouseListener profilePanelMouseListener = new ProfilePanelMouseListener(); profilePanelMouseListener.setTabPane(tabPane); viewTable.addMouseListener( profilePanelMouseListener); JScrollPane editorScrollPane = new JScrollPane(viewTable); editorScrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(800, 600)); editorScrollPane.setMinimumSize(new Dimension(10, 10)); // reset column widths ((ProfileTable) viewTable).initColumnSizes(); JPanel tableViewPane = new JPanel(new BorderLayout()); tableViewPane.add(editorScrollPane,BorderLayout.CENTER); JLabel searchLabel = new JLabel("Search:"); JTextField searchField = new JTextField(searchDecorator.getDoc(),"",25); searchField.setEditable(true); JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); searchPanel.add(searchLabel); searchPanel.add(searchField); tableViewPane.add(searchPanel,BorderLayout.NORTH); ButtonBarBuilder buttonBuilder = new ButtonBarBuilder(); JButton save = new JButton(new SaveProfileAction(d,viewTable,profileManager)); JButton refresh = new JButton(new AbstractAction("Refresh"){ public void actionPerformed(ActionEvent e) { Set<SQLTable> uniqueTables = new HashSet(); for (int i: viewTable.getSelectedRows()) { Object o = viewTable.getValueAt(i,3); SQLTable table = (SQLTable) o ; uniqueTables.add(table); } try { profileManager.setCancelled(false); profileManager.createProfiles(uniqueTables); } catch (SQLException e1) { throw new RuntimeException(e1); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } } }); JButton delete = new JButton(new AbstractAction("Delete"){ public void actionPerformed(ActionEvent e) { int[] killMe = viewTable.getSelectedRows(); Arrays.sort(killMe); // iterate backwards so the rows don't shift away on us! for (int i = killMe.length-1; i >= 0; i--) { logger.debug("Deleting row "+killMe[i]+": "+viewTable.getValueAt(killMe[i],4)); SQLColumn col = (SQLColumn) viewTable.getValueAt(killMe[i], 4); try { profileManager.remove(col); } catch (ArchitectException e1) { ASUtils.showExceptionDialog(d,"Could delete row of:" + col.getName(), e1); } } } }); JButton deleteAll = new JButton(new AbstractAction("Delete All"){ public void actionPerformed(ActionEvent e) { while ( viewTable.getRowCount() > 0 ) { SQLColumn col = (SQLColumn) viewTable.getValueAt(0, 4); try { profileManager.remove(col); } catch (ArchitectException e1) { ASUtils.showExceptionDialog(d,"Could delete row of:" + col.getName(), e1); } } } }); JButton[] buttonArray = {refresh,delete,deleteAll,save,closeButton}; buttonBuilder.addGriddedButtons(buttonArray); tableViewPane.add(buttonBuilder.getPanel(),BorderLayout.SOUTH); tabPane.addTab("Table View", tableViewPane ); ProfilePanel p = new ProfilePanel(profileManager); tabPane.addTab("Graph View",p); profilePanelMouseListener.setProfilePanel(p); List<SQLTable> list = new ArrayList(tables); p.setTables(list); p.setChartType(ChartTypes.PIE); d.setVisible(false); d.remove(progressViewPanel); d.setContentPane(tabPane); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); } catch (SQLException e) { logger.error("Error in Profile Action ", e); ASUtils.showExceptionDialogNoReport(dbTree, "Error during profile run", e); } catch (ArchitectException e) { logger.error("Error in Profile Action", e); ASUtils.showExceptionDialog(dbTree, "Error during profile run", e); } } }).start(); } catch (Exception ex) { logger.error("Error in Profile Action ", ex); ASUtils.showExceptionDialog(dbTree, "Error during profile run", ex); } }
Object o = viewTable.getValueAt(i,3);
Object o = viewTable.getValueAt(i, viewTable.convertColumnIndexToView( ProfileColumn.valueOf("TABLE").ordinal()));
public void run() { try { List<SQLTable> toBeProfiled = new ArrayList<SQLTable>(); for (SQLTable t: tables) { if (profileManager.getResult(t)== null) { toBeProfiled.add(t); workingOn.setText("Adding "+t.getName()+ " ("+toBeProfiled.size()+")"); } } profileManager.createProfiles(toBeProfiled, workingOn); progressBar.setVisible(false); JLabel status = new JLabel("Generating reports, Please wait......"); progressViewPanel.add(status, BorderLayout.NORTH); status.setVisible(true); JTabbedPane tabPane = new JTabbedPane(); ProfileTableModel tm = new ProfileTableModel(); for (SQLObject sqo: filter){ tm.addFilter(sqo); } tm.setProfileManager(profileManager); TableModelSearchDecorator searchDecorator = new TableModelSearchDecorator(tm); TableModelSortDecorator tableModelSortDecorator = new TableModelSortDecorator(searchDecorator); final ProfileTable viewTable = new ProfileTable(tableModelSortDecorator); searchDecorator.setTableTextConverter(viewTable); JTableHeader tableHeader = viewTable.getTableHeader(); tableModelSortDecorator.setTableHeader(tableHeader); viewTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); ProfilePanelMouseListener profilePanelMouseListener = new ProfilePanelMouseListener(); profilePanelMouseListener.setTabPane(tabPane); viewTable.addMouseListener( profilePanelMouseListener); JScrollPane editorScrollPane = new JScrollPane(viewTable); editorScrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(800, 600)); editorScrollPane.setMinimumSize(new Dimension(10, 10)); // reset column widths ((ProfileTable) viewTable).initColumnSizes(); JPanel tableViewPane = new JPanel(new BorderLayout()); tableViewPane.add(editorScrollPane,BorderLayout.CENTER); JLabel searchLabel = new JLabel("Search:"); JTextField searchField = new JTextField(searchDecorator.getDoc(),"",25); searchField.setEditable(true); JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); searchPanel.add(searchLabel); searchPanel.add(searchField); tableViewPane.add(searchPanel,BorderLayout.NORTH); ButtonBarBuilder buttonBuilder = new ButtonBarBuilder(); JButton save = new JButton(new SaveProfileAction(d,viewTable,profileManager)); JButton refresh = new JButton(new AbstractAction("Refresh"){ public void actionPerformed(ActionEvent e) { Set<SQLTable> uniqueTables = new HashSet(); for (int i: viewTable.getSelectedRows()) { Object o = viewTable.getValueAt(i,3); SQLTable table = (SQLTable) o ; uniqueTables.add(table); } try { profileManager.setCancelled(false); profileManager.createProfiles(uniqueTables); } catch (SQLException e1) { throw new RuntimeException(e1); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } } }); JButton delete = new JButton(new AbstractAction("Delete"){ public void actionPerformed(ActionEvent e) { int[] killMe = viewTable.getSelectedRows(); Arrays.sort(killMe); // iterate backwards so the rows don't shift away on us! for (int i = killMe.length-1; i >= 0; i--) { logger.debug("Deleting row "+killMe[i]+": "+viewTable.getValueAt(killMe[i],4)); SQLColumn col = (SQLColumn) viewTable.getValueAt(killMe[i], 4); try { profileManager.remove(col); } catch (ArchitectException e1) { ASUtils.showExceptionDialog(d,"Could delete row of:" + col.getName(), e1); } } } }); JButton deleteAll = new JButton(new AbstractAction("Delete All"){ public void actionPerformed(ActionEvent e) { while ( viewTable.getRowCount() > 0 ) { SQLColumn col = (SQLColumn) viewTable.getValueAt(0, 4); try { profileManager.remove(col); } catch (ArchitectException e1) { ASUtils.showExceptionDialog(d,"Could delete row of:" + col.getName(), e1); } } } }); JButton[] buttonArray = {refresh,delete,deleteAll,save,closeButton}; buttonBuilder.addGriddedButtons(buttonArray); tableViewPane.add(buttonBuilder.getPanel(),BorderLayout.SOUTH); tabPane.addTab("Table View", tableViewPane ); ProfilePanel p = new ProfilePanel(profileManager); tabPane.addTab("Graph View",p); profilePanelMouseListener.setProfilePanel(p); List<SQLTable> list = new ArrayList(tables); p.setTables(list); p.setChartType(ChartTypes.PIE); d.setVisible(false); d.remove(progressViewPanel); d.setContentPane(tabPane); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); } catch (SQLException e) { logger.error("Error in Profile Action ", e); ASUtils.showExceptionDialogNoReport(dbTree, "Error during profile run", e); } catch (ArchitectException e) { logger.error("Error in Profile Action", e); ASUtils.showExceptionDialog(dbTree, "Error during profile run", e); } }
logger.debug("Deleting row "+killMe[i]+": "+viewTable.getValueAt(killMe[i],4)); SQLColumn col = (SQLColumn) viewTable.getValueAt(killMe[i], 4);
logger.debug("Deleting row "+ killMe[i]+ ": "+ viewTable.getValueAt(killMe[i], viewTable.convertColumnIndexToView( ProfileColumn.valueOf("COLUMN").ordinal()))); SQLColumn col = (SQLColumn) viewTable.getValueAt(killMe[i], viewTable.convertColumnIndexToView( ProfileColumn.valueOf("COLUMN").ordinal()));
public void run() { try { List<SQLTable> toBeProfiled = new ArrayList<SQLTable>(); for (SQLTable t: tables) { if (profileManager.getResult(t)== null) { toBeProfiled.add(t); workingOn.setText("Adding "+t.getName()+ " ("+toBeProfiled.size()+")"); } } profileManager.createProfiles(toBeProfiled, workingOn); progressBar.setVisible(false); JLabel status = new JLabel("Generating reports, Please wait......"); progressViewPanel.add(status, BorderLayout.NORTH); status.setVisible(true); JTabbedPane tabPane = new JTabbedPane(); ProfileTableModel tm = new ProfileTableModel(); for (SQLObject sqo: filter){ tm.addFilter(sqo); } tm.setProfileManager(profileManager); TableModelSearchDecorator searchDecorator = new TableModelSearchDecorator(tm); TableModelSortDecorator tableModelSortDecorator = new TableModelSortDecorator(searchDecorator); final ProfileTable viewTable = new ProfileTable(tableModelSortDecorator); searchDecorator.setTableTextConverter(viewTable); JTableHeader tableHeader = viewTable.getTableHeader(); tableModelSortDecorator.setTableHeader(tableHeader); viewTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); ProfilePanelMouseListener profilePanelMouseListener = new ProfilePanelMouseListener(); profilePanelMouseListener.setTabPane(tabPane); viewTable.addMouseListener( profilePanelMouseListener); JScrollPane editorScrollPane = new JScrollPane(viewTable); editorScrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(800, 600)); editorScrollPane.setMinimumSize(new Dimension(10, 10)); // reset column widths ((ProfileTable) viewTable).initColumnSizes(); JPanel tableViewPane = new JPanel(new BorderLayout()); tableViewPane.add(editorScrollPane,BorderLayout.CENTER); JLabel searchLabel = new JLabel("Search:"); JTextField searchField = new JTextField(searchDecorator.getDoc(),"",25); searchField.setEditable(true); JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); searchPanel.add(searchLabel); searchPanel.add(searchField); tableViewPane.add(searchPanel,BorderLayout.NORTH); ButtonBarBuilder buttonBuilder = new ButtonBarBuilder(); JButton save = new JButton(new SaveProfileAction(d,viewTable,profileManager)); JButton refresh = new JButton(new AbstractAction("Refresh"){ public void actionPerformed(ActionEvent e) { Set<SQLTable> uniqueTables = new HashSet(); for (int i: viewTable.getSelectedRows()) { Object o = viewTable.getValueAt(i,3); SQLTable table = (SQLTable) o ; uniqueTables.add(table); } try { profileManager.setCancelled(false); profileManager.createProfiles(uniqueTables); } catch (SQLException e1) { throw new RuntimeException(e1); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } } }); JButton delete = new JButton(new AbstractAction("Delete"){ public void actionPerformed(ActionEvent e) { int[] killMe = viewTable.getSelectedRows(); Arrays.sort(killMe); // iterate backwards so the rows don't shift away on us! for (int i = killMe.length-1; i >= 0; i--) { logger.debug("Deleting row "+killMe[i]+": "+viewTable.getValueAt(killMe[i],4)); SQLColumn col = (SQLColumn) viewTable.getValueAt(killMe[i], 4); try { profileManager.remove(col); } catch (ArchitectException e1) { ASUtils.showExceptionDialog(d,"Could delete row of:" + col.getName(), e1); } } } }); JButton deleteAll = new JButton(new AbstractAction("Delete All"){ public void actionPerformed(ActionEvent e) { while ( viewTable.getRowCount() > 0 ) { SQLColumn col = (SQLColumn) viewTable.getValueAt(0, 4); try { profileManager.remove(col); } catch (ArchitectException e1) { ASUtils.showExceptionDialog(d,"Could delete row of:" + col.getName(), e1); } } } }); JButton[] buttonArray = {refresh,delete,deleteAll,save,closeButton}; buttonBuilder.addGriddedButtons(buttonArray); tableViewPane.add(buttonBuilder.getPanel(),BorderLayout.SOUTH); tabPane.addTab("Table View", tableViewPane ); ProfilePanel p = new ProfilePanel(profileManager); tabPane.addTab("Graph View",p); profilePanelMouseListener.setProfilePanel(p); List<SQLTable> list = new ArrayList(tables); p.setTables(list); p.setChartType(ChartTypes.PIE); d.setVisible(false); d.remove(progressViewPanel); d.setContentPane(tabPane); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); } catch (SQLException e) { logger.error("Error in Profile Action ", e); ASUtils.showExceptionDialogNoReport(dbTree, "Error during profile run", e); } catch (ArchitectException e) { logger.error("Error in Profile Action", e); ASUtils.showExceptionDialog(dbTree, "Error during profile run", e); } }
SQLColumn col = (SQLColumn) viewTable.getValueAt(0, 4);
SQLColumn col = (SQLColumn) viewTable.getValueAt(0, viewTable.convertColumnIndexToView( ProfileColumn.valueOf("COLUMN").ordinal()));
public void run() { try { List<SQLTable> toBeProfiled = new ArrayList<SQLTable>(); for (SQLTable t: tables) { if (profileManager.getResult(t)== null) { toBeProfiled.add(t); workingOn.setText("Adding "+t.getName()+ " ("+toBeProfiled.size()+")"); } } profileManager.createProfiles(toBeProfiled, workingOn); progressBar.setVisible(false); JLabel status = new JLabel("Generating reports, Please wait......"); progressViewPanel.add(status, BorderLayout.NORTH); status.setVisible(true); JTabbedPane tabPane = new JTabbedPane(); ProfileTableModel tm = new ProfileTableModel(); for (SQLObject sqo: filter){ tm.addFilter(sqo); } tm.setProfileManager(profileManager); TableModelSearchDecorator searchDecorator = new TableModelSearchDecorator(tm); TableModelSortDecorator tableModelSortDecorator = new TableModelSortDecorator(searchDecorator); final ProfileTable viewTable = new ProfileTable(tableModelSortDecorator); searchDecorator.setTableTextConverter(viewTable); JTableHeader tableHeader = viewTable.getTableHeader(); tableModelSortDecorator.setTableHeader(tableHeader); viewTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); ProfilePanelMouseListener profilePanelMouseListener = new ProfilePanelMouseListener(); profilePanelMouseListener.setTabPane(tabPane); viewTable.addMouseListener( profilePanelMouseListener); JScrollPane editorScrollPane = new JScrollPane(viewTable); editorScrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(800, 600)); editorScrollPane.setMinimumSize(new Dimension(10, 10)); // reset column widths ((ProfileTable) viewTable).initColumnSizes(); JPanel tableViewPane = new JPanel(new BorderLayout()); tableViewPane.add(editorScrollPane,BorderLayout.CENTER); JLabel searchLabel = new JLabel("Search:"); JTextField searchField = new JTextField(searchDecorator.getDoc(),"",25); searchField.setEditable(true); JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); searchPanel.add(searchLabel); searchPanel.add(searchField); tableViewPane.add(searchPanel,BorderLayout.NORTH); ButtonBarBuilder buttonBuilder = new ButtonBarBuilder(); JButton save = new JButton(new SaveProfileAction(d,viewTable,profileManager)); JButton refresh = new JButton(new AbstractAction("Refresh"){ public void actionPerformed(ActionEvent e) { Set<SQLTable> uniqueTables = new HashSet(); for (int i: viewTable.getSelectedRows()) { Object o = viewTable.getValueAt(i,3); SQLTable table = (SQLTable) o ; uniqueTables.add(table); } try { profileManager.setCancelled(false); profileManager.createProfiles(uniqueTables); } catch (SQLException e1) { throw new RuntimeException(e1); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } } }); JButton delete = new JButton(new AbstractAction("Delete"){ public void actionPerformed(ActionEvent e) { int[] killMe = viewTable.getSelectedRows(); Arrays.sort(killMe); // iterate backwards so the rows don't shift away on us! for (int i = killMe.length-1; i >= 0; i--) { logger.debug("Deleting row "+killMe[i]+": "+viewTable.getValueAt(killMe[i],4)); SQLColumn col = (SQLColumn) viewTable.getValueAt(killMe[i], 4); try { profileManager.remove(col); } catch (ArchitectException e1) { ASUtils.showExceptionDialog(d,"Could delete row of:" + col.getName(), e1); } } } }); JButton deleteAll = new JButton(new AbstractAction("Delete All"){ public void actionPerformed(ActionEvent e) { while ( viewTable.getRowCount() > 0 ) { SQLColumn col = (SQLColumn) viewTable.getValueAt(0, 4); try { profileManager.remove(col); } catch (ArchitectException e1) { ASUtils.showExceptionDialog(d,"Could delete row of:" + col.getName(), e1); } } } }); JButton[] buttonArray = {refresh,delete,deleteAll,save,closeButton}; buttonBuilder.addGriddedButtons(buttonArray); tableViewPane.add(buttonBuilder.getPanel(),BorderLayout.SOUTH); tabPane.addTab("Table View", tableViewPane ); ProfilePanel p = new ProfilePanel(profileManager); tabPane.addTab("Graph View",p); profilePanelMouseListener.setProfilePanel(p); List<SQLTable> list = new ArrayList(tables); p.setTables(list); p.setChartType(ChartTypes.PIE); d.setVisible(false); d.remove(progressViewPanel); d.setContentPane(tabPane); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); } catch (SQLException e) { logger.error("Error in Profile Action ", e); ASUtils.showExceptionDialogNoReport(dbTree, "Error during profile run", e); } catch (ArchitectException e) { logger.error("Error in Profile Action", e); ASUtils.showExceptionDialog(dbTree, "Error during profile run", e); } }
List<SQLTable> list = new ArrayList(tables); p.setTables(list);
public void run() { try { List<SQLTable> toBeProfiled = new ArrayList<SQLTable>(); for (SQLTable t: tables) { if (profileManager.getResult(t)== null) { toBeProfiled.add(t); workingOn.setText("Adding "+t.getName()+ " ("+toBeProfiled.size()+")"); } } profileManager.createProfiles(toBeProfiled, workingOn); progressBar.setVisible(false); JLabel status = new JLabel("Generating reports, Please wait......"); progressViewPanel.add(status, BorderLayout.NORTH); status.setVisible(true); JTabbedPane tabPane = new JTabbedPane(); ProfileTableModel tm = new ProfileTableModel(); for (SQLObject sqo: filter){ tm.addFilter(sqo); } tm.setProfileManager(profileManager); TableModelSearchDecorator searchDecorator = new TableModelSearchDecorator(tm); TableModelSortDecorator tableModelSortDecorator = new TableModelSortDecorator(searchDecorator); final ProfileTable viewTable = new ProfileTable(tableModelSortDecorator); searchDecorator.setTableTextConverter(viewTable); JTableHeader tableHeader = viewTable.getTableHeader(); tableModelSortDecorator.setTableHeader(tableHeader); viewTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); ProfilePanelMouseListener profilePanelMouseListener = new ProfilePanelMouseListener(); profilePanelMouseListener.setTabPane(tabPane); viewTable.addMouseListener( profilePanelMouseListener); JScrollPane editorScrollPane = new JScrollPane(viewTable); editorScrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(800, 600)); editorScrollPane.setMinimumSize(new Dimension(10, 10)); // reset column widths ((ProfileTable) viewTable).initColumnSizes(); JPanel tableViewPane = new JPanel(new BorderLayout()); tableViewPane.add(editorScrollPane,BorderLayout.CENTER); JLabel searchLabel = new JLabel("Search:"); JTextField searchField = new JTextField(searchDecorator.getDoc(),"",25); searchField.setEditable(true); JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); searchPanel.add(searchLabel); searchPanel.add(searchField); tableViewPane.add(searchPanel,BorderLayout.NORTH); ButtonBarBuilder buttonBuilder = new ButtonBarBuilder(); JButton save = new JButton(new SaveProfileAction(d,viewTable,profileManager)); JButton refresh = new JButton(new AbstractAction("Refresh"){ public void actionPerformed(ActionEvent e) { Set<SQLTable> uniqueTables = new HashSet(); for (int i: viewTable.getSelectedRows()) { Object o = viewTable.getValueAt(i,3); SQLTable table = (SQLTable) o ; uniqueTables.add(table); } try { profileManager.setCancelled(false); profileManager.createProfiles(uniqueTables); } catch (SQLException e1) { throw new RuntimeException(e1); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } } }); JButton delete = new JButton(new AbstractAction("Delete"){ public void actionPerformed(ActionEvent e) { int[] killMe = viewTable.getSelectedRows(); Arrays.sort(killMe); // iterate backwards so the rows don't shift away on us! for (int i = killMe.length-1; i >= 0; i--) { logger.debug("Deleting row "+killMe[i]+": "+viewTable.getValueAt(killMe[i],4)); SQLColumn col = (SQLColumn) viewTable.getValueAt(killMe[i], 4); try { profileManager.remove(col); } catch (ArchitectException e1) { ASUtils.showExceptionDialog(d,"Could delete row of:" + col.getName(), e1); } } } }); JButton deleteAll = new JButton(new AbstractAction("Delete All"){ public void actionPerformed(ActionEvent e) { while ( viewTable.getRowCount() > 0 ) { SQLColumn col = (SQLColumn) viewTable.getValueAt(0, 4); try { profileManager.remove(col); } catch (ArchitectException e1) { ASUtils.showExceptionDialog(d,"Could delete row of:" + col.getName(), e1); } } } }); JButton[] buttonArray = {refresh,delete,deleteAll,save,closeButton}; buttonBuilder.addGriddedButtons(buttonArray); tableViewPane.add(buttonBuilder.getPanel(),BorderLayout.SOUTH); tabPane.addTab("Table View", tableViewPane ); ProfilePanel p = new ProfilePanel(profileManager); tabPane.addTab("Graph View",p); profilePanelMouseListener.setProfilePanel(p); List<SQLTable> list = new ArrayList(tables); p.setTables(list); p.setChartType(ChartTypes.PIE); d.setVisible(false); d.remove(progressViewPanel); d.setContentPane(tabPane); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); } catch (SQLException e) { logger.error("Error in Profile Action ", e); ASUtils.showExceptionDialogNoReport(dbTree, "Error during profile run", e); } catch (ArchitectException e) { logger.error("Error in Profile Action", e); ASUtils.showExceptionDialog(dbTree, "Error during profile run", e); } }
if ( viewTable.getRowCount() > 0 ) { SQLColumn col = (SQLColumn)viewTable.getValueAt(0, viewTable.convertColumnIndexToView( ProfileColumn.valueOf("COLUMN").ordinal())); p.getTableSelector().setSelectedItem(col.getParentTable()); p.getColumnSelector().setSelectedValue(col,true); }
public void run() { try { List<SQLTable> toBeProfiled = new ArrayList<SQLTable>(); for (SQLTable t: tables) { if (profileManager.getResult(t)== null) { toBeProfiled.add(t); workingOn.setText("Adding "+t.getName()+ " ("+toBeProfiled.size()+")"); } } profileManager.createProfiles(toBeProfiled, workingOn); progressBar.setVisible(false); JLabel status = new JLabel("Generating reports, Please wait......"); progressViewPanel.add(status, BorderLayout.NORTH); status.setVisible(true); JTabbedPane tabPane = new JTabbedPane(); ProfileTableModel tm = new ProfileTableModel(); for (SQLObject sqo: filter){ tm.addFilter(sqo); } tm.setProfileManager(profileManager); TableModelSearchDecorator searchDecorator = new TableModelSearchDecorator(tm); TableModelSortDecorator tableModelSortDecorator = new TableModelSortDecorator(searchDecorator); final ProfileTable viewTable = new ProfileTable(tableModelSortDecorator); searchDecorator.setTableTextConverter(viewTable); JTableHeader tableHeader = viewTable.getTableHeader(); tableModelSortDecorator.setTableHeader(tableHeader); viewTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); ProfilePanelMouseListener profilePanelMouseListener = new ProfilePanelMouseListener(); profilePanelMouseListener.setTabPane(tabPane); viewTable.addMouseListener( profilePanelMouseListener); JScrollPane editorScrollPane = new JScrollPane(viewTable); editorScrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(800, 600)); editorScrollPane.setMinimumSize(new Dimension(10, 10)); // reset column widths ((ProfileTable) viewTable).initColumnSizes(); JPanel tableViewPane = new JPanel(new BorderLayout()); tableViewPane.add(editorScrollPane,BorderLayout.CENTER); JLabel searchLabel = new JLabel("Search:"); JTextField searchField = new JTextField(searchDecorator.getDoc(),"",25); searchField.setEditable(true); JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); searchPanel.add(searchLabel); searchPanel.add(searchField); tableViewPane.add(searchPanel,BorderLayout.NORTH); ButtonBarBuilder buttonBuilder = new ButtonBarBuilder(); JButton save = new JButton(new SaveProfileAction(d,viewTable,profileManager)); JButton refresh = new JButton(new AbstractAction("Refresh"){ public void actionPerformed(ActionEvent e) { Set<SQLTable> uniqueTables = new HashSet(); for (int i: viewTable.getSelectedRows()) { Object o = viewTable.getValueAt(i,3); SQLTable table = (SQLTable) o ; uniqueTables.add(table); } try { profileManager.setCancelled(false); profileManager.createProfiles(uniqueTables); } catch (SQLException e1) { throw new RuntimeException(e1); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } } }); JButton delete = new JButton(new AbstractAction("Delete"){ public void actionPerformed(ActionEvent e) { int[] killMe = viewTable.getSelectedRows(); Arrays.sort(killMe); // iterate backwards so the rows don't shift away on us! for (int i = killMe.length-1; i >= 0; i--) { logger.debug("Deleting row "+killMe[i]+": "+viewTable.getValueAt(killMe[i],4)); SQLColumn col = (SQLColumn) viewTable.getValueAt(killMe[i], 4); try { profileManager.remove(col); } catch (ArchitectException e1) { ASUtils.showExceptionDialog(d,"Could delete row of:" + col.getName(), e1); } } } }); JButton deleteAll = new JButton(new AbstractAction("Delete All"){ public void actionPerformed(ActionEvent e) { while ( viewTable.getRowCount() > 0 ) { SQLColumn col = (SQLColumn) viewTable.getValueAt(0, 4); try { profileManager.remove(col); } catch (ArchitectException e1) { ASUtils.showExceptionDialog(d,"Could delete row of:" + col.getName(), e1); } } } }); JButton[] buttonArray = {refresh,delete,deleteAll,save,closeButton}; buttonBuilder.addGriddedButtons(buttonArray); tableViewPane.add(buttonBuilder.getPanel(),BorderLayout.SOUTH); tabPane.addTab("Table View", tableViewPane ); ProfilePanel p = new ProfilePanel(profileManager); tabPane.addTab("Graph View",p); profilePanelMouseListener.setProfilePanel(p); List<SQLTable> list = new ArrayList(tables); p.setTables(list); p.setChartType(ChartTypes.PIE); d.setVisible(false); d.remove(progressViewPanel); d.setContentPane(tabPane); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); } catch (SQLException e) { logger.error("Error in Profile Action ", e); ASUtils.showExceptionDialogNoReport(dbTree, "Error during profile run", e); } catch (ArchitectException e) { logger.error("Error in Profile Action", e); ASUtils.showExceptionDialog(dbTree, "Error during profile run", e); } }
Object o = viewTable.getValueAt(i,3);
Object o = viewTable.getValueAt(i, viewTable.convertColumnIndexToView( ProfileColumn.valueOf("TABLE").ordinal()));
public void actionPerformed(ActionEvent e) { Set<SQLTable> uniqueTables = new HashSet(); for (int i: viewTable.getSelectedRows()) { Object o = viewTable.getValueAt(i,3); SQLTable table = (SQLTable) o ; uniqueTables.add(table); } try { profileManager.setCancelled(false); profileManager.createProfiles(uniqueTables); } catch (SQLException e1) { throw new RuntimeException(e1); } catch (ArchitectException e1) { throw new ArchitectRuntimeException(e1); } }
logger.debug("Deleting row "+killMe[i]+": "+viewTable.getValueAt(killMe[i],4)); SQLColumn col = (SQLColumn) viewTable.getValueAt(killMe[i], 4);
logger.debug("Deleting row "+ killMe[i]+ ": "+ viewTable.getValueAt(killMe[i], viewTable.convertColumnIndexToView( ProfileColumn.valueOf("COLUMN").ordinal()))); SQLColumn col = (SQLColumn) viewTable.getValueAt(killMe[i], viewTable.convertColumnIndexToView( ProfileColumn.valueOf("COLUMN").ordinal()));
public void actionPerformed(ActionEvent e) { int[] killMe = viewTable.getSelectedRows(); Arrays.sort(killMe); // iterate backwards so the rows don't shift away on us! for (int i = killMe.length-1; i >= 0; i--) { logger.debug("Deleting row "+killMe[i]+": "+viewTable.getValueAt(killMe[i],4)); SQLColumn col = (SQLColumn) viewTable.getValueAt(killMe[i], 4); try { profileManager.remove(col); } catch (ArchitectException e1) { ASUtils.showExceptionDialog(d,"Could delete row of:" + col.getName(), e1); } } }
SQLColumn col = (SQLColumn) viewTable.getValueAt(0, 4);
SQLColumn col = (SQLColumn) viewTable.getValueAt(0, viewTable.convertColumnIndexToView( ProfileColumn.valueOf("COLUMN").ordinal()));
public void actionPerformed(ActionEvent e) { while ( viewTable.getRowCount() > 0 ) { SQLColumn col = (SQLColumn) viewTable.getValueAt(0, 4); try { profileManager.remove(col); } catch (ArchitectException e1) { ASUtils.showExceptionDialog(d,"Could delete row of:" + col.getName(), e1); } } }
if (value instanceof List) { if (xpCmp != null && (xpCmp.getXpath() != null)) { Collections.sort((List)value, xpCmp); } }
public void doTag(XMLOutput output) throws Exception { if (var == null) { throw new MissingAttributeException( "var" ); } if (select == null) { throw new MissingAttributeException( "select" ); } Object xpathContext = getXPathContext(); Object value = select.evaluate(xpathContext); //log.info( "Evaluated xpath: " + select + " as: " + value + " of type: " + value.getClass().getName() ); context.setVariable(var, value); }
g2.drawImage(gBrowseImage, H_BORDER,V_BORDER,this);
g2.drawImage(gBrowseImage,H_BORDER-GBROWSE_MARGIN,V_BORDER,this);
public void paintComponent(Graphics g){ DPrimeTable dPrimeTable = theData.dpTable; if (Chromosome.getSize() == 0){ //if there are no valid markers return; } Vector blocks = theData.blocks; Rectangle visRect = getVisibleRect(); //deal with zooming if (chartSize.getWidth() > (3*visRect.width)){ showWM = true; }else{ showWM = false; } if (zoomLevel != 0 || Options.getLDColorScheme() == WMF_SCHEME || Options.getLDColorScheme() == RSQ_SCHEME){ printDPrimeValues = false; } else{ printDPrimeValues = true; } Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); g2.setColor(BG_GREY); //if it's a big dataset, resize properly, if it's small make sure to fill whole background if (size.height < pref.height){ g2.fillRect(0,0,pref.width,pref.height); setSize(pref); }else{ g2.fillRect(0,0,size.width, size.height); } g2.setColor(Color.black); //okay so this dumb if block is to prevent the ugly repainting //bug when loading markers after the data are already being displayed, //results in a little off-centering for small datasets, but not too bad. if (!forExport){ if (!theData.infoKnown){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); } else { g2.translate((size.width - pref.width) / 2, 0); } } FontMetrics boxFontMetrics = g2.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; double lineSpan = alignedPositions[alignedPositions.length-1] - alignedPositions[0]; long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; //See http://www.hapmap.org/cgi-perl/gbrowse/gbrowse_img //for more info on GBrowse img. int imgHeight = 0; if (Options.isGBrowseShown() && Chromosome.getDataChrom() != null){ g2.drawImage(gBrowseImage, H_BORDER,V_BORDER,this); // not sure if this is an imageObserver, however imgHeight = gBrowseImage.getHeight(this) + TRACK_GAP; // get height so we can shift everything down } left = H_BORDER; top = V_BORDER + imgHeight; // push the haplotype display down to make room for gbrowse image. if (forExport){ left -= exportStart * boxSize; } FontMetrics metrics; int ascent; g2.setFont(boldMarkerNameFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = getBoundaryMarker(visRect.x-clickXShift-(visRect.y +visRect.height-clickYShift)) - 1; highX = getBoundaryMarker(visRect.x + visRect.width); lowY = getBoundaryMarker((visRect.x-clickXShift)+(visRect.y-clickYShift)) - 1; highY = getBoundaryMarker((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height)); if (lowX < 0) { lowX = 0; } if (highX > Chromosome.getSize()-1){ highX = Chromosome.getSize()-1; } if (lowY < lowX+1){ lowY = lowX+1; } if (highY > Chromosome.getSize()){ highY = Chromosome.getSize(); } if (forExport){ lowX = exportStart; lowY = exportStart; highX = exportStop; highY = exportStop; } if (theData.trackExists){ //draw the analysis track above where the marker positions will be marked g2.setColor(Color.white); g2.fill(new Rectangle2D.Double(left, top, lineSpan, TRACK_HEIGHT)); g2.setColor(Color.black); g2.drawRect(left,top,(int)lineSpan,TRACK_HEIGHT); //get the data into an easier format double positions[] = new double[theData.analysisPositions.size()]; double values[] = new double[theData.analysisPositions.size()]; for (int x = 0; x < positions.length; x++){ positions[x] = ((Double)theData.analysisPositions.elementAt(x)).doubleValue(); values[x] = ((Double)theData.analysisValues.elementAt(x)).doubleValue(); } g2.setColor(Color.black); double min = Double.MAX_VALUE; double max = -min; for (int x = 0; x < positions.length; x++){ if(values[x] < min){ min = values[x]; } if (values[x] > max){ max = values[x]; } } double range = max-min; //todo: this is kinda hideous for (int x = 0; x < positions.length - 1; x++){ if (positions[x] >= minpos && positions[x+1] <= maxpos){ g2.draw(new Line2D.Double(lineSpan * Math.abs((positions[x] - minpos)/spanpos) + left, top + TRACK_PALETTE + TRACK_BUMPER - (TRACK_PALETTE * Math.abs((values[x] - min)/range)), lineSpan * Math.abs((positions[x+1] - minpos)/spanpos) + left, top + TRACK_PALETTE + TRACK_BUMPER - (TRACK_PALETTE * Math.abs((values[x+1] - min)/range)))); } } top += TRACK_HEIGHT + TRACK_GAP; } if (theData.infoKnown) { Color green = new Color(0, 127, 0); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fill(new Rectangle2D.Double(left+1, top+1, lineSpan-1, TICK_HEIGHT-1)); g2.setColor(Color.black); g2.draw(new Rectangle2D.Double(left, top, lineSpan, TICK_HEIGHT)); for (int i = 0; i < Chromosome.getSize(); i++){ double pos = (Chromosome.getMarker(i).getPosition() - minpos) / spanpos; double xx = left + lineSpan*pos; // if we're zoomed, use the line color to indicate whether there is extra data available // (since the marker names are not displayed when zoomed) if (Chromosome.getMarker(i).getExtra() != null && zoomLevel != 0) g2.setColor(green); //draw tick g2.setStroke(thickerStroke); g2.draw(new Line2D.Double(xx, top, xx, top + TICK_HEIGHT)); if (Chromosome.getMarker(i).getExtra() != null && zoomLevel != 0) g2.setStroke(thickerStroke); else g2.setStroke(thinnerStroke); //draw connecting line g2.draw(new Line2D.Double(xx, top + TICK_HEIGHT, left + alignedPositions[i], top+TICK_BOTTOM)); if (Chromosome.getMarker(i).getExtra() != null && zoomLevel != 0) g2.setColor(Color.black); } top += TICK_BOTTOM + TICK_HEIGHT; //// draw the marker names if (printMarkerNames){ widestMarkerName = metrics.stringWidth(Chromosome.getMarker(0).getName()); for (int x = 1; x < Chromosome.getSize(); x++) { int thiswide = metrics.stringWidth(Chromosome.getMarker(x).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < Chromosome.getSize(); x++) { if (theData.isInBlock[x]){ g2.setFont(boldMarkerNameFont); }else{ g2.setFont(markerNameFont); } if (Chromosome.getMarker(x).getExtra() != null) g2.setColor(green); g2.drawString(Chromosome.getMarker(x).getName(),(float)TEXT_GAP, (float)alignedPositions[x] + ascent/3); if (Chromosome.getMarker(x).getExtra() != null) g2.setColor(Color.black); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } top += blockDispHeight; //// draw the marker numbers if (printMarkerNames){ g2.setFont(markerNumFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < Chromosome.getSize(); x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g2.drawString(mark, (float)(left + alignedPositions[x] - metrics.stringWidth(mark)/2), (float)(top + ascent)); } top += boxRadius/2; // give a little space between numbers and boxes } //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(theData.infoKnown)){ clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable.getLDStats(x,y) == null){ continue; } double d = dPrimeTable.getLDStats(x,y).getDPrime(); //double l = dPrimeTable.getLDStats(x,y).getLOD(); Color boxColor = dPrimeTable.getLDStats(x,y).getColor(); // draw markers above int xx = left + (int)((alignedPositions[x] + alignedPositions[y])/2); int yy = top + (int)((alignedPositions[y] - alignedPositions[x]) / 2); diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g2.setColor(boxColor); g2.fillPolygon(diamond); if(printDPrimeValues){ g2.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g2.setColor((val < 50) ? Color.gray : Color.black); if (boxColor == Color.darkGray){ g2.setColor(Color.white); } if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } //highlight blocks g2.setFont(markerNameFont); ascent = g2.getFontMetrics().getAscent(); //g.setColor(new Color(153,255,153)); g2.setColor(Color.black); //g.setColor(new Color(51,153,51)); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; //big vee around whole thing g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left + alignedPositions[first] - boxRadius, top, left + (alignedPositions[first] + alignedPositions[last])/2, top + (alignedPositions[last] - alignedPositions[first])/2 + boxRadius)); g2.draw(new Line2D.Double(left + (alignedPositions[first] + alignedPositions[last])/2, top + (alignedPositions[last] - alignedPositions[first])/2 + boxRadius, left + alignedPositions[last] + boxRadius, top)); for (int j = first; j < last; j++){ g2.setStroke(fatStroke); if (theData.isInBlock[j]){ g2.draw(new Line2D.Double(left+alignedPositions[j]-boxSize/2, top-blockDispHeight, left+alignedPositions[j+1]-boxSize/2, top-blockDispHeight)); }else{ g2.draw(new Line2D.Double(left + alignedPositions[j] + boxSize/2, top-blockDispHeight, left+alignedPositions[j+1]-boxSize/2, top-blockDispHeight)); g2.setStroke(dashedFatStroke); g2.draw(new Line2D.Double(left+alignedPositions[j] - boxSize/2, top-blockDispHeight, left+alignedPositions[j] + boxSize/2, top-blockDispHeight)); } } //cap off the end of the block g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left+alignedPositions[last]-boxSize/2, top-blockDispHeight, left+alignedPositions[last]+boxSize/2, top-blockDispHeight)); //lines to connect to block display g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left + alignedPositions[first]-boxSize/2, top-1, left+alignedPositions[first]-boxSize/2, top-blockDispHeight)); g2.draw(new Line2D.Double(left+alignedPositions[last]+boxSize/2, top-1, left+alignedPositions[last]+boxSize/2, top-blockDispHeight)); if (printMarkerNames){ String labelString = new String ("Block " + (i+1)); if (theData.infoKnown){ long blockSize = Chromosome.getMarker(last).getPosition() - Chromosome.getMarker(first).getPosition(); labelString += " (" + blockSize/1000 + " kb)"; } g2.drawString(labelString, (float)(left+alignedPositions[first]-boxSize/2+TEXT_GAP), (float)(top-boxSize/3)); } } g2.setStroke(thickerStroke); //see if the user has right-clicked to popup some marker info if(popupExists){ //dumb bug where little datasets popup the box in the wrong place int smallDatasetSlopH = 0; int smallDatasetSlopV = 0; if (pref.getHeight() < visRect.height){ smallDatasetSlopV = (int)(visRect.height - pref.getHeight())/2; } if (pref.getWidth() < visRect.width){ smallDatasetSlopH = (int)(visRect.width - pref.getWidth())/2; } g2.setColor(Color.white); g2.fillRect(popupDrawRect.x+1-smallDatasetSlopH, popupDrawRect.y+1-smallDatasetSlopV, popupDrawRect.width-1, popupDrawRect.height-1); g2.setColor(Color.black); g2.drawRect(popupDrawRect.x-smallDatasetSlopH, popupDrawRect.y-smallDatasetSlopV, popupDrawRect.width, popupDrawRect.height); g.setFont(popupFont); for (int x = 0; x < displayStrings.size(); x++){ g.drawString((String)displayStrings.elementAt(x),popupDrawRect.x + popupLeftMargin-smallDatasetSlopH, popupDrawRect.y+((x+1)*metrics.getHeight())-smallDatasetSlopV); } } if (showWM && !forExport){ //dataset is big enough to require worldmap if (wmMaxWidth == 0){ wmMaxWidth = visRect.width/3; } double scalefactor; scalefactor = (double)(chartSize.width)/wmMaxWidth; double prefBoxSize = boxSize/(scalefactor*((double)wmMaxWidth/(double)(wmMaxWidth))); //stick WM_BD in the middle of the blank space at the top of the worldmap final int WM_BD_GAP = (int)(infoHeight/(scalefactor*2)); final int WM_BD_HEIGHT = 2; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); if (noImage){ //first time through draw a worldmap if dataset is big: worldmap = new BufferedImage((int)(chartSize.width/scalefactor)+wmBorder.getBorderInsets(this).left*2, (int)(chartSize.height/scalefactor)+wmBorder.getBorderInsets(this).top*2, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(1,1,worldmap.getWidth()-1,worldmap.getHeight()-1); //make a pretty border gw2.setColor(Color.black); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth(),worldmap.getHeight()); wmInteriorRect = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth(), worldmap.getHeight()); float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < Chromosome.getSize()-1; x++){ for (int y = x+1; y < Chromosome.getSize(); y++){ if (dPrimeTable.getLDStats(x,y) == null){ continue; } double xx = ((alignedPositions[y] + alignedPositions[x])/(scalefactor*2)) + wmBorder.getBorderInsets(this).left; double yy = ((alignedPositions[y] - alignedPositions[x] + infoHeight*2)/(scalefactor*2)) + wmBorder.getBorderInsets(this).top; smallDiamondX[0] = (float)xx; smallDiamondY[0] = (float)(yy - prefBoxSize/2); smallDiamondX[1] = (float)(xx + prefBoxSize/2); smallDiamondY[1] = (float)yy; smallDiamondX[2] = (float)xx; smallDiamondY[2] = (float)(yy + prefBoxSize/2); smallDiamondX[3] = (float)(xx - prefBoxSize/2); smallDiamondY[3] = (float)yy; gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, smallDiamondX.length); gp.moveTo(smallDiamondX[0],smallDiamondY[0]); for (int i = 1; i < smallDiamondX.length; i++){ gp.lineTo(smallDiamondX[i], smallDiamondY[i]); } gp.closePath(); gw2.setColor(dPrimeTable.getLDStats(x,y).getColor()); gw2.fill(gp); } } noImage = false; } //draw block display in worldmap Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(wmBorder.getBorderInsets(this).left, wmBorder.getBorderInsets(this).top+WM_BD_GAP, wmInteriorRect.width, WM_BD_HEIGHT); gw2.setColor(Color.black); boolean even = true; for (int i = 0; i < blocks.size(); i++){ int first = ((int[])blocks.elementAt(i))[0]; int last = ((int[])blocks.elementAt(i))[((int[])blocks.elementAt(i)).length-1]; int voffset; if (even){ voffset = 0; }else{ voffset = WM_BD_HEIGHT/2; } gw2.fillRect(wmBorder.getBorderInsets(this).left - (int)prefBoxSize/2 + (int)(alignedPositions[first]/scalefactor), wmBorder.getBorderInsets(this).top+voffset+WM_BD_GAP, (int)(prefBoxSize + (alignedPositions[last] - alignedPositions[first])/scalefactor), WM_BD_HEIGHT/2); even = !even; } wmResizeCorner = new Rectangle(visRect.x + worldmap.getWidth() - (worldmap.getWidth()-wmInteriorRect.width)/2, visRect.y + visRect.height - worldmap.getHeight(), (worldmap.getWidth()-wmInteriorRect.width)/2, (worldmap.getHeight() -wmInteriorRect.height)/2); g2.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); wmInteriorRect.x = visRect.x + (worldmap.getWidth() - wmInteriorRect.width)/2; wmInteriorRect.y = visRect.y+visRect.height-worldmap.getHeight() + (worldmap.getHeight() - wmInteriorRect.height)/2; //draw the outline of the viewport g2.setColor(Color.black); double hRatio = wmInteriorRect.getWidth()/pref.getWidth(); double vRatio = wmInteriorRect.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-wmInteriorRect.width; int vBump = worldmap.getHeight()-wmInteriorRect.height; //bump a few pixels to avoid drawing on the border g2.drawRect((int)(visRect.x*hRatio)+hBump/2+visRect.x, (int)(visRect.y*vRatio)+vBump/2+(visRect.y + visRect.height - worldmap.getHeight()), (int)(visRect.width*hRatio), (int)(visRect.height*vRatio)); } //see if we're drawing a worldmap resize rect if (resizeRectExists){ g2.setColor(Color.black); g2.drawRect(resizeWMRect.x, resizeWMRect.y, resizeWMRect.width, resizeWMRect.height); } //see if we're drawing a block selector rect if (blockRectExists){ g2.setColor(Color.black); g2.setStroke(dashedThinStroke); g2.drawRect(blockRect.x, blockRect.y, blockRect.width, blockRect.height); } }
return "Count";
return COUNT;
public String getColumnName(int column) { if ( column == 0 ) { return "Count"; } else if ( column == 1 ) { return "Value"; } else { throw new IllegalStateException("Unknown Column Index:"+column); } }
return "Value";
return VALUE;
public String getColumnName(int column) { if ( column == 0 ) { return "Count"; } else if ( column == 1 ) { return "Value"; } else { throw new IllegalStateException("Unknown Column Index:"+column); } }
public void characters(char ch[], int start, int length) throws SAXException {
public void characters(char[] ch, int start, int length) throws SAXException {
public void doTag(XMLOutput output) throws JellyTagException { int idx = name.indexOf(':'); final String localName = (idx >= 0) ? name.substring(idx + 1) : name; outputAttributes = false; XMLOutput newOutput = new XMLOutput(output) { // add an initialize hook to the core content-generating methods public void startElement( String uri, String localName, String qName, Attributes atts) throws SAXException { initialize(); super.startElement(uri, localName, qName, atts); } public void endElement(String uri, String localName, String qName) throws SAXException { initialize(); super.endElement(uri, localName, qName); } public void characters(char ch[], int start, int length) throws SAXException { initialize(); super.characters(ch, start, length); } public void ignorableWhitespace(char ch[], int start, int length) throws SAXException { initialize(); super.ignorableWhitespace(ch, start, length); } public void objectData(Object object) throws SAXException { initialize(); super.objectData( object ); } public void processingInstruction(String target, String data) throws SAXException { initialize(); super.processingInstruction(target, data); } /** * Ensure that the outer start element is generated * before any content is output */ protected void initialize() throws SAXException { if (!outputAttributes) { super.startElement(namespace, localName, name, attributes); outputAttributes = true; } } }; invokeBody(newOutput); try { if (!outputAttributes) { output.startElement(namespace, localName, name, attributes); outputAttributes = true; } output.endElement(namespace, localName, name); attributes.clear(); } catch (SAXException e) { throw new JellyTagException(e); } }
public void ignorableWhitespace(char ch[], int start, int length)
public void ignorableWhitespace(char[] ch, int start, int length)
public void doTag(XMLOutput output) throws JellyTagException { int idx = name.indexOf(':'); final String localName = (idx >= 0) ? name.substring(idx + 1) : name; outputAttributes = false; XMLOutput newOutput = new XMLOutput(output) { // add an initialize hook to the core content-generating methods public void startElement( String uri, String localName, String qName, Attributes atts) throws SAXException { initialize(); super.startElement(uri, localName, qName, atts); } public void endElement(String uri, String localName, String qName) throws SAXException { initialize(); super.endElement(uri, localName, qName); } public void characters(char ch[], int start, int length) throws SAXException { initialize(); super.characters(ch, start, length); } public void ignorableWhitespace(char ch[], int start, int length) throws SAXException { initialize(); super.ignorableWhitespace(ch, start, length); } public void objectData(Object object) throws SAXException { initialize(); super.objectData( object ); } public void processingInstruction(String target, String data) throws SAXException { initialize(); super.processingInstruction(target, data); } /** * Ensure that the outer start element is generated * before any content is output */ protected void initialize() throws SAXException { if (!outputAttributes) { super.startElement(namespace, localName, name, attributes); outputAttributes = true; } } }; invokeBody(newOutput); try { if (!outputAttributes) { output.startElement(namespace, localName, name, attributes); outputAttributes = true; } output.endElement(namespace, localName, name); attributes.clear(); } catch (SAXException e) { throw new JellyTagException(e); } }
* before any content is output
* before any content is output.
public void doTag(XMLOutput output) throws JellyTagException { int idx = name.indexOf(':'); final String localName = (idx >= 0) ? name.substring(idx + 1) : name; outputAttributes = false; XMLOutput newOutput = new XMLOutput(output) { // add an initialize hook to the core content-generating methods public void startElement( String uri, String localName, String qName, Attributes atts) throws SAXException { initialize(); super.startElement(uri, localName, qName, atts); } public void endElement(String uri, String localName, String qName) throws SAXException { initialize(); super.endElement(uri, localName, qName); } public void characters(char ch[], int start, int length) throws SAXException { initialize(); super.characters(ch, start, length); } public void ignorableWhitespace(char ch[], int start, int length) throws SAXException { initialize(); super.ignorableWhitespace(ch, start, length); } public void objectData(Object object) throws SAXException { initialize(); super.objectData( object ); } public void processingInstruction(String target, String data) throws SAXException { initialize(); super.processingInstruction(target, data); } /** * Ensure that the outer start element is generated * before any content is output */ protected void initialize() throws SAXException { if (!outputAttributes) { super.startElement(namespace, localName, name, attributes); outputAttributes = true; } } }; invokeBody(newOutput); try { if (!outputAttributes) { output.startElement(namespace, localName, name, attributes); outputAttributes = true; } output.endElement(namespace, localName, name); attributes.clear(); } catch (SAXException e) { throw new JellyTagException(e); } }
public void characters(char ch[], int start, int length) throws SAXException {
public void characters(char[] ch, int start, int length) throws SAXException {
public void characters(char ch[], int start, int length) throws SAXException { initialize(); super.characters(ch, start, length); }
public void ignorableWhitespace(char ch[], int start, int length)
public void ignorableWhitespace(char[] ch, int start, int length)
public void ignorableWhitespace(char ch[], int start, int length) throws SAXException { initialize(); super.ignorableWhitespace(ch, start, length); }
public void setAttributeValue( String name, String value ) throws JellyTagException {
public void setAttributeValue(String name, String value, String uri) throws JellyTagException {
public void setAttributeValue( String name, String value ) throws JellyTagException { if (outputAttributes) { throw new JellyTagException( "Cannot set the value of attribute: " + name + " as we have already output the startElement() SAX event" ); } // ### we'll assume that all attributes are in no namespace! // ### this is severely limiting! // ### we should be namespace aware int index = attributes.getIndex("", name); if (index >= 0) { attributes.removeAttribute(index); } // treat null values as no attribute if (value != null) { attributes.addAttribute("", name, name, "CDATA", value); } }
int index = attributes.getIndex("", name);
int idx = name.indexOf(':'); final String localName = (idx >= 0) ? name.substring(idx + 1) : name; final String nsUri = (uri != null) ? uri : ""; int index = attributes.getIndex(nsUri, localName);
public void setAttributeValue( String name, String value ) throws JellyTagException { if (outputAttributes) { throw new JellyTagException( "Cannot set the value of attribute: " + name + " as we have already output the startElement() SAX event" ); } // ### we'll assume that all attributes are in no namespace! // ### this is severely limiting! // ### we should be namespace aware int index = attributes.getIndex("", name); if (index >= 0) { attributes.removeAttribute(index); } // treat null values as no attribute if (value != null) { attributes.addAttribute("", name, name, "CDATA", value); } }
attributes.addAttribute("", name, name, "CDATA", value);
attributes.addAttribute(nsUri, localName, name, "CDATA", value);
public void setAttributeValue( String name, String value ) throws JellyTagException { if (outputAttributes) { throw new JellyTagException( "Cannot set the value of attribute: " + name + " as we have already output the startElement() SAX event" ); } // ### we'll assume that all attributes are in no namespace! // ### this is severely limiting! // ### we should be namespace aware int index = attributes.getIndex("", name); if (index >= 0) { attributes.removeAttribute(index); } // treat null values as no attribute if (value != null) { attributes.addAttribute("", name, name, "CDATA", value); } }
pp.contentPane.add(c, 0);
if (c instanceof Relationship) { pp.contentPane.add(c,pp.contentPane.getFirstRelationIndex()); } else { pp.contentPane.add(c, 0); }
public void actionPerformed(ActionEvent e) { List items = pp.getSelectedItems(); Iterator it = items.iterator(); while (it.hasNext()) { PlayPenComponent c = (PlayPenComponent) it.next(); pp.contentPane.remove(c); pp.contentPane.add(c, 0); } pp.repaint(); }
contentPane.add(ppc, contentPane.getComponentCount());
if (ppc instanceof Relationship) { contentPane.add(ppc, contentPane.getComponentCount()); } else { contentPane.add(ppc, contentPane.getFirstRelationIndex()); }
public void dbChildrenInserted(SQLObjectEvent e) { logger.debug("SQLObject children got inserted: "+e); boolean fireEvent = false; SQLObject[] c = e.getChildren(); for (int i = 0; i < c.length; i++) { try { addHierarcyListeners(c[i]); } catch (ArchitectException ex) { logger.error("Couldn't listen to added object", ex); } if (c[i] instanceof SQLTable || (c[i] instanceof SQLRelationship && (((SQLTable.Folder) e.getSource()).getType() == SQLTable.Folder.EXPORTED_KEYS))) { fireEvent = true; PlayPenComponent ppc = removedComponents.get(c[i]); if (ppc != null) { contentPane.add(ppc, contentPane.getComponentCount()); } } } if (fireEvent) { firePropertyChange("model.children", null, null); revalidate(); } }
dbcsPanel.setDbcs(db.getDataSource());
public void showDbcsDialog() { final DBCSPanel dbcsPanel = new DBCSPanel(); DBCS_OkAction okAction = new DBCS_OkAction(dbcsPanel, false); dbcsPanel.setDbcs(db.getDataSource()); Action cancelAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { dbcsPanel.discardChanges(); } }; JDialog d = ArchitectPanelBuilder.createArchitectPanelDialog( dbcsPanel, ArchitectFrame.getMainInstance(), "Target Database Connection", ArchitectPanelBuilder.OK_BUTTON_LABEL, okAction, cancelAction); okAction.setConnectionDialog(d); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); dbcsDialog = d; dbcsDialog.setVisible(true); }
public PostageException(String message, Throwable cause) { super(message, cause);
public PostageException() { super();
public PostageException(String message, Throwable cause) { super(message, cause); }
Iterator iter = selectedPhotos.iterator();
if ( selectedPhotos.size() > 1 ) { int n = JOptionPane.showConfirmDialog( parentFrame, "You have selected " + selectedPhotos.size() + " photos\n" + "Are you sure that you want to\ndisplay all of them at once?", "Open multiple photos", JOptionPane.YES_NO_OPTION ); if ( n != JOptionPane.YES_OPTION ) { return; } } Cursor oldCursor = c.getCursor(); c.setCursor( new Cursor( Cursor.WAIT_CURSOR ) ); Iterator iter = selectedPhotos.iterator();
public void actionPerformed( ActionEvent ev ) { try { Collection selectedPhotos = view.getSelection(); Iterator iter = selectedPhotos.iterator(); while ( iter.hasNext() ) { PhotoInfo photo = (PhotoInfo) iter.next(); JFrame frame = new JFrame( "Photo" ); final JAIPhotoViewer viewer = new JAIPhotoViewer(); frame.getContentPane().add( viewer, BorderLayout.CENTER ); frame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); // This is a WAR for a memory management problem. For // some reason the frame and objects owned by it seem // not to be garbage collected. So we free the large // image buffers to avoid massive memory leak. frame.addWindowListener( new WindowAdapter() { public void windowClosing( WindowEvent e ) { viewer.setPhoto( null ); } } ); viewer.setPhoto( photo ); frame.pack(); frame.setVisible( true ); } } catch ( Throwable e ) { System.err.println( "Out of memory error" ); log.warn( e ); e.printStackTrace(); } }
c.setCursor( oldCursor );
public void actionPerformed( ActionEvent ev ) { try { Collection selectedPhotos = view.getSelection(); Iterator iter = selectedPhotos.iterator(); while ( iter.hasNext() ) { PhotoInfo photo = (PhotoInfo) iter.next(); JFrame frame = new JFrame( "Photo" ); final JAIPhotoViewer viewer = new JAIPhotoViewer(); frame.getContentPane().add( viewer, BorderLayout.CENTER ); frame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); // This is a WAR for a memory management problem. For // some reason the frame and objects owned by it seem // not to be garbage collected. So we free the large // image buffers to avoid massive memory leak. frame.addWindowListener( new WindowAdapter() { public void windowClosing( WindowEvent e ) { viewer.setPhoto( null ); } } ); viewer.setPhoto( photo ); frame.pack(); frame.setVisible( true ); } } catch ( Throwable e ) { System.err.println( "Out of memory error" ); log.warn( e ); e.printStackTrace(); } }
addComponentListener( this );
public JAIPhotoViewer() { super(); createUI(); addComponentListener( this ); }
String expressions = "\nExpected expression: " + expected + "\nActual expression: " + actual;
String expressions = "\nExpected expression: " + expected.getExpressionText() + "\nActual expression: " + actual.getExpressionText();
public void doTag(XMLOutput output) throws Exception { String message = getBodyText(); Object expectedValue = expected.evaluate(context); Object actualValue = actual.evaluate(context); if (expectedValue == null && actualValue == null) { return; } if (actualValue != null && expectedValue.equals(actualValue)) { return; } String expressions = "\nExpected expression: " + expected + "\nActual expression: " + actual; failNotEquals(message, expectedValue, actualValue, expressions); }
if (left.isBound() && right.isBound()) { markBound(); }
BinaryOpFilter(Filter<S> left, Filter<S> right) { super(left == null ? null : left.getStorableType()); if (right == null) { throw new IllegalArgumentException(); } if (left.getStorableType() != right.getStorableType()) { throw new IllegalArgumentException("Type mismatch"); } mLeft = left; mRight = right; }
abstract void dumpTree(Appendable app, int indentLevel) throws IOException;
public void dumpTree(Appendable app) throws IOException { dumpTree(app, 0); }
abstract void dumpTree(Appendable app, int indentLevel) throws IOException;
Tag answer = DynamicTagLibrary.this.createTag(name, attributes); if ( answer == null && parent != null ) { return parent.createTag(name, attributes); } return answer;
return DynamicTagLibrary.this.createTag(name, attributes);
public TagScript createTagScript(final String name, final Attributes attributes) throws Exception { return new TagScript( new TagFactory() { public Tag createTag(String name, Attributes attributes) throws Exception { Tag answer = DynamicTagLibrary.this.createTag(name, attributes); // delegate to my parent instead if ( answer == null && parent != null ) { return parent.createTag(name, attributes); } return answer; } } ); }
Tag answer = DynamicTagLibrary.this.createTag(name, attributes); if ( answer == null && parent != null ) { return parent.createTag(name, attributes); } return answer;
return DynamicTagLibrary.this.createTag(name, attributes);
public Tag createTag(String name, Attributes attributes) throws Exception { Tag answer = DynamicTagLibrary.this.createTag(name, attributes); // delegate to my parent instead if ( answer == null && parent != null ) { return parent.createTag(name, attributes); } return answer; }
public DynamicTag(Script template) { this.template = template;
public DynamicTag() {
public DynamicTag(Script template) { this.template = template; }
long blockSize = Chromosome.getMarker(last).getPosition() - Chromosome.getMarker(first).getPosition();
long blockSize = Chromosome.getFilteredMarker(last).getPosition() - Chromosome.getFilteredMarker(first).getPosition();
public void paintComponent(Graphics g){ PairwiseLinkage[][] dPrimeTable = theData.filteredDPrimeTable; Vector blocks = theData.blocks; Rectangle visRect = getVisibleRect(); //deal with zooming if (chartSize.getWidth() > (3*visRect.width)){ showWM = true; }else{ showWM = false; } if (zoomLevel == 0){ printDetails = true; } else{ printDetails = false; } Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); if (size.height < pref.height){ setSize(pref); } //okay so this dumb if block is to prevent the ugly repainting //bug when loading markers after the data are already being displayed, //results in a little off-centering for small datasets, but not too bad. if (!forExport){ if (!theData.infoKnown){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); } else { g2.translate((size.width - pref.width) / 2, 0); } } FontMetrics boxFontMetrics = g2.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; if (forExport){ left -= exportStart * boxSize; } FontMetrics metrics; int ascent; g2.setColor(BG_GREY); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.black); g2.setFont(boldMarkerNameFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); //TODO: finish implementing scaling gizmo /*//deal with adding some space to better display data with large gaps int cumulativeGap[] = new int[Chromosome.getFilteredSize()]; for (int i = 0; i < cumulativeGap.length; i++){ cumulativeGap[i] = 0; } if (theData.infoKnown){ double mean = (((SNP)Chromosome.markers[Chromosome.markers.length-1]).getPosition() - ((SNP)Chromosome.markers[0]).getPosition())/Chromosome.markers.length-1; for (int i = 1; i < cumulativeGap.length; i++){ double sep = Chromosome.getMarker(i).getPosition() - Chromosome.getMarker(i-1).getPosition(); if (sep > mean*10){ cumulativeGap[i] = cumulativeGap[i-1] + (int)(sep/mean)*4; }else{ cumulativeGap[i] = cumulativeGap[i-1]; } } } */ //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = (visRect.x-clickXShift-(visRect.y + visRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((visRect.x + visRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((visRect.x-clickXShift)+(visRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } if (forExport){ lowX = exportStart; lowY = exportStart; highX = exportStop; highY = exportStop; } int lineSpan = (dPrimeTable.length-1) * boxSize; long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; if (theData.trackExists){ //draw the analysis track above where the marker positions will be marked g2.setColor(Color.white); g2.fillRect(left, top, lineSpan, TRACK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left, top, lineSpan, TRACK_HEIGHT); //get the data into an easier format double positions[] = new double[theData.analysisPositions.size()]; double values[] = new double[theData.analysisPositions.size()]; for (int x = 0; x < positions.length; x++){ positions[x] = ((Double)theData.analysisPositions.elementAt(x)).doubleValue(); values[x] = ((Double)theData.analysisValues.elementAt(x)).doubleValue(); } g2.setColor(Color.black); double min = Double.MAX_VALUE; double max = -min; for (int x = 0; x < positions.length; x++){ if(values[x] < min){ min = values[x]; } if (values[x] > max){ max = values[x]; } } double range = max-min; //todo: this is kinda hideous for (int x = 0; x < positions.length - 1; x++){ if (positions[x] >= minpos && positions[x+1] <= maxpos){ g2.draw(new Line2D.Double(lineSpan * Math.abs((positions[x] - minpos)/spanpos) + left, top + TRACK_PALETTE + TRACK_BUMPER - (TRACK_PALETTE * Math.abs((values[x] - min)/range)), lineSpan * Math.abs((positions[x+1] - minpos)/spanpos) + left, top + TRACK_PALETTE + TRACK_BUMPER - (TRACK_PALETTE * Math.abs((values[x+1] - min)/range)))); } } top += TRACK_HEIGHT + TRACK_GAP; } if (theData.infoKnown) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left+1, top+1, lineSpan-1, TICK_HEIGHT-1); g2.setColor(Color.black); g2.drawRect(left, top, lineSpan, TICK_HEIGHT); for (int i = 0; i < Chromosome.getFilteredSize(); i++){ double pos = (Chromosome.getFilteredMarker(i).getPosition() - minpos) / spanpos; int xx = (int) (left + lineSpan*pos); g2.setStroke(thickerStroke); g2.drawLine(xx, top, xx, top + TICK_HEIGHT); g2.setStroke(thinnerStroke); g2.drawLine(xx, top + TICK_HEIGHT, left + i*boxSize, top+TICK_BOTTOM); } top += TICK_BOTTOM + TICK_HEIGHT; //// draw the marker names if (printDetails){ widestMarkerName = metrics.stringWidth(Chromosome.getFilteredMarker(0).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(Chromosome.getFilteredMarker(x).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { if (theData.isInBlock[x]){ g2.setFont(boldMarkerNameFont); }else{ g2.setFont(markerNameFont); } g2.drawString(Chromosome.getFilteredMarker(x).getName(),TEXT_GAP, x*boxSize + ascent/3); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } top += blockDispHeight; //// draw the marker numbers if (printDetails){ g2.setFont(markerNumFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < dPrimeTable.length; x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g2.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(theData.infoKnown)){ clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g2.setColor(boxColor); g2.fillPolygon(diamond); if(printDetails){ g2.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g2.setColor((val < 50) ? Color.gray : Color.black); if (boxColor == Color.darkGray){ g2.setColor(Color.white); } if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } boolean even = true; //highlight blocks g2.setFont(markerNameFont); ascent = g2.getFontMetrics().getAscent(); //g.setColor(new Color(153,255,153)); g2.setColor(Color.black); //g.setColor(new Color(51,153,51)); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; //big vee around whole thing g2.setStroke(fatStroke); g2.drawLine(left + (2*first) * boxSize/2 - boxRadius, top, left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius); g2.drawLine(left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius, left + (2*last) * boxSize/2+boxRadius, top); for (int j = first; j <= last; j++){ if (theData.isInBlock[j]){ g2.setStroke(fatStroke); }else{ g2.setStroke(dashedFatStroke); } g2.drawLine(left+j*boxSize-boxSize/2, top-blockDispHeight, left+j*boxSize+boxSize/2, top-blockDispHeight); } //lines to connect to block display g2.setStroke(fatStroke); g2.drawLine(left + first*boxSize-boxSize/2, top-1, left+first*boxSize-boxSize/2, top-blockDispHeight); g2.drawLine(left+last*boxSize+boxSize/2, top-1, left+last*boxSize+boxSize/2, top-blockDispHeight); if (printDetails){ String labelString = new String ("Block " + (i+1)); if (theData.infoKnown){ long blockSize = Chromosome.getMarker(last).getPosition() - Chromosome.getMarker(first).getPosition(); labelString += " (" + blockSize/1000 + " kb)"; } g2.drawString(labelString, left+first*boxSize-boxSize/2+TEXT_GAP, top-boxSize/3); } } g2.setStroke(thickerStroke); //see if the user has right-clicked to popup some marker info if(popupExists){ int smallDatasetSlopH = 0; int smallDatasetSlopV = 0; if (pref.getWidth() < visRect.width){ //dumb bug where little datasets popup the box in the wrong place smallDatasetSlopH = (int)(visRect.width - pref.getWidth())/2; smallDatasetSlopV = (int)(visRect.height - pref.getHeight())/2; } g2.setColor(Color.white); g2.fillRect(popupDrawRect.x+1-smallDatasetSlopH, popupDrawRect.y+1-smallDatasetSlopV, popupDrawRect.width-1, popupDrawRect.height-1); g2.setColor(Color.black); g2.drawRect(popupDrawRect.x-smallDatasetSlopH, popupDrawRect.y-smallDatasetSlopV, popupDrawRect.width, popupDrawRect.height); for (int x = 0; x < displayStrings.length; x++){ g.drawString(displayStrings[x],popupDrawRect.x + popupLeftMargin-smallDatasetSlopH, popupDrawRect.y+((x+1)*metrics.getHeight())-smallDatasetSlopV); } } if (showWM && !forExport){ //dataset is big enough to require worldmap final int WM_BD_GAP = 1; final int WM_BD_HEIGHT = 2; final int WM_BD_TOTAL = WM_BD_HEIGHT + 2*WM_BD_GAP; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); if (wmMaxWidth == 0){ wmMaxWidth = visRect.width/3; } double scalefactor; scalefactor = (double)(chartSize.width)/wmMaxWidth; double prefBoxSize = boxSize/(scalefactor*((double)wmMaxWidth/(double)(wmMaxWidth-WM_BD_TOTAL))); if (noImage){ //first time through draw a worldmap if dataset is big: worldmap = new BufferedImage((int)(chartSize.width/scalefactor)+wmBorder.getBorderInsets(this).left*2, (int)(chartSize.height/scalefactor)+wmBorder.getBorderInsets(this).top*2+WM_BD_TOTAL, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(1,1,worldmap.getWidth()-1,worldmap.getHeight()-1); //make a pretty border gw2.setColor(Color.black); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth(),worldmap.getHeight()); wmInteriorRect = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth(), worldmap.getHeight()); float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < dPrimeTable.length-1; x++){ for (int y = x+1; y < dPrimeTable.length; y++){ if (dPrimeTable[x][y] == null){ continue; } double xx = (x + y)*prefBoxSize/2+wmBorder.getBorderInsets(this).left; double yy = (y - x)*prefBoxSize/2+wmBorder.getBorderInsets(this).top + WM_BD_TOTAL; smallDiamondX[0] = (float)xx; smallDiamondY[0] = (float)(yy - prefBoxSize/2); smallDiamondX[1] = (float)(xx + prefBoxSize/2); smallDiamondY[1] = (float)yy; smallDiamondX[2] = (float)xx; smallDiamondY[2] = (float)(yy + prefBoxSize/2); smallDiamondX[3] = (float)(xx - prefBoxSize/2); smallDiamondY[3] = (float)yy; gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, smallDiamondX.length); gp.moveTo(smallDiamondX[0],smallDiamondY[0]); for (int i = 1; i < smallDiamondX.length; i++){ gp.lineTo(smallDiamondX[i], smallDiamondY[i]); } gp.closePath(); gw2.setColor(dPrimeTable[x][y].getColor()); gw2.fill(gp); } } noImage = false; } //draw block display in worldmap Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(wmBorder.getBorderInsets(this).left, wmBorder.getBorderInsets(this).top+WM_BD_GAP, wmInteriorRect.width, WM_BD_HEIGHT); gw2.setColor(Color.black); even = true; for (int i = 0; i < blocks.size(); i++){ int first = ((int[])blocks.elementAt(i))[0]; int last = ((int[])blocks.elementAt(i))[((int[])blocks.elementAt(i)).length-1]; int voffset; if (even){ voffset = 0; }else{ voffset = WM_BD_HEIGHT/2; } gw2.fillRect(wmBorder.getBorderInsets(this).left+(int)(prefBoxSize*first), wmBorder.getBorderInsets(this).top+voffset+WM_BD_GAP, (int)((last-first+1)*prefBoxSize), WM_BD_HEIGHT/2); even = !even; } wmResizeCorner = new Rectangle(visRect.x + worldmap.getWidth() - (worldmap.getWidth()-wmInteriorRect.width)/2, visRect.y + visRect.height - worldmap.getHeight(), (worldmap.getWidth()-wmInteriorRect.width)/2, (worldmap.getHeight() -wmInteriorRect.height)/2); g2.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); wmInteriorRect.x = visRect.x + (worldmap.getWidth() - wmInteriorRect.width)/2; wmInteriorRect.y = visRect.y+visRect.height-worldmap.getHeight() + (worldmap.getHeight() - wmInteriorRect.height)/2; //draw the outline of the viewport g2.setColor(Color.black); double hRatio = wmInteriorRect.getWidth()/pref.getWidth(); double vRatio = wmInteriorRect.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-wmInteriorRect.width; int vBump = worldmap.getHeight()-wmInteriorRect.height; //bump a few pixels to avoid drawing on the border g2.drawRect((int)(visRect.x*hRatio)+hBump/2+visRect.x, (int)(visRect.y*vRatio)+vBump/2+(visRect.y + visRect.height - worldmap.getHeight()), (int)(visRect.width*hRatio), (int)(visRect.height*vRatio)); } //see if we're drawing a worldmap resize rect if (resizeRectExists){ g2.setColor(Color.black); g2.drawRect(resizeWMRect.x, resizeWMRect.y, resizeWMRect.width, resizeWMRect.height); } //see if we're drawing a block selector rect if (blockRectExists){ g2.setColor(Color.black); g2.setStroke(dashedThinStroke); g2.drawRect(blockRect.x, blockRect.y, blockRect.width, blockRect.height); } }
public boolean addDriverJar(String fullPath) { return driverJarList.add(fullPath); }
public boolean addDriverJar(String fullPath);
public boolean addDriverJar(String fullPath) { return driverJarList.add(fullPath); }
System.out.println("start");
public Vector findTags() { tags = new Vector(); untagged = new Vector(); taggedSoFar = 0; //potentialTagsHash stores the PotentialTag objects keyed on the corresponding sequences Hashtable potentialTagHash = new Hashtable(); PotentialTagComparator ptcomp = new PotentialTagComparator(); VariantSequence currentVarSeq; //create SequenceComparison objects for each potential Tag, and //add any comparisons which have an r-squared greater than the minimum. for(int i=0;i<snps.size();i++) { currentVarSeq = (VariantSequence)snps.get(i); if(!(forceExclude.contains(currentVarSeq) ) ){//|| (currentVarSeq instanceof SNP && ((SNP)currentVarSeq).getMAF() < .05))) { PotentialTag tempPT = new PotentialTag(currentVarSeq); for(int j=0;j<snps.size();j++) { if( getPairwiseCompRsq(currentVarSeq,(VariantSequence) snps.get(j)) >= minRSquared) { tempPT.addTagged((VariantSequence) snps.get(j)); } } potentialTagHash.put(currentVarSeq,tempPT); } } Vector sitesToCapture = (Vector) snps.clone(); Iterator potItr = sitesToCapture.iterator(); debugPrint("snps to tag: " + sitesToCapture.size()); Vector potentialTags = new Vector(potentialTagHash.values()); int countTagged = 0; //add Tags for the ones which are forced in. Vector includedPotentialTags = new Vector(); //construct a list of PotentialTag objects for forced in sequences for (int i = 0; i < forceInclude.size(); i++) { VariantSequence variantSequence = (VariantSequence) forceInclude.elementAt(i); if(variantSequence != null && potentialTagHash.containsKey(variantSequence)) { includedPotentialTags.add((PotentialTag) potentialTagHash.get(variantSequence)); } } //add each forced in sequence to the list of tags for(int i=0;i<includedPotentialTags.size();i++) { PotentialTag curPT = (PotentialTag) includedPotentialTags.get(i); Vector newlyTagged = addTag(curPT,potentialTagHash,sitesToCapture); countTagged += newlyTagged.size(); sitesToCapture.removeAll(newlyTagged); sitesToCapture.remove(curPT.sequence); } //loop until all snps are tagged System.out.println("start"); while(sitesToCapture.size() > 0) { potentialTags = new Vector(potentialTagHash.values()); if(potentialTags.size() == 0) { //we still have sites left to capture, but we have no more available tags. //this should only happen if the sites remaining in sitesToCapture were specifically //excluded from being tags. Since we can't add any more tags, break out of the loop. break; } //sorts the array of potential tags according to the number of untagged sites they can tag. //the last element is the one which tags the most untagged sites, so we choose that as our next tag. Collections.sort(potentialTags,ptcomp); PotentialTag currentBestTag = (PotentialTag) potentialTags.lastElement(); Vector newlyTagged = addTag(currentBestTag,potentialTagHash,sitesToCapture); countTagged += newlyTagged.size(); sitesToCapture.removeAll(newlyTagged); sitesToCapture.remove(currentBestTag.sequence); taggedSoFar = countTagged; } if(sitesToCapture.size() > 0) { //any sites left in sitesToCapture could not be tagged, so we add them all to the untagged Vector untagged.addAll(sitesToCapture); } System.out.println("tagged " + countTagged + " SNPS using " + tags.size() +" tags" ); System.out.println("# of SNPs that could not be tagged: " + untagged.size()); if (aggression != PAIRWISE_ONLY){ //peelback starting with the worst tag (i.e. the one that tags the fewest other snps. Vector tags2BPeeled = (Vector)tags.clone(); Collections.reverse(tags2BPeeled); peelBack(tags2BPeeled); } return new Vector(tags); }
System.out.println("tagged " + countTagged + " SNPS using " + tags.size() +" tags" ); System.out.println("# of SNPs that could not be tagged: " + untagged.size());
debugPrint("tagged " + countTagged + " SNPS using " + tags.size() +" tags" ); debugPrint("# of SNPs that could not be tagged: " + untagged.size());
public Vector findTags() { tags = new Vector(); untagged = new Vector(); taggedSoFar = 0; //potentialTagsHash stores the PotentialTag objects keyed on the corresponding sequences Hashtable potentialTagHash = new Hashtable(); PotentialTagComparator ptcomp = new PotentialTagComparator(); VariantSequence currentVarSeq; //create SequenceComparison objects for each potential Tag, and //add any comparisons which have an r-squared greater than the minimum. for(int i=0;i<snps.size();i++) { currentVarSeq = (VariantSequence)snps.get(i); if(!(forceExclude.contains(currentVarSeq) ) ){//|| (currentVarSeq instanceof SNP && ((SNP)currentVarSeq).getMAF() < .05))) { PotentialTag tempPT = new PotentialTag(currentVarSeq); for(int j=0;j<snps.size();j++) { if( getPairwiseCompRsq(currentVarSeq,(VariantSequence) snps.get(j)) >= minRSquared) { tempPT.addTagged((VariantSequence) snps.get(j)); } } potentialTagHash.put(currentVarSeq,tempPT); } } Vector sitesToCapture = (Vector) snps.clone(); Iterator potItr = sitesToCapture.iterator(); debugPrint("snps to tag: " + sitesToCapture.size()); Vector potentialTags = new Vector(potentialTagHash.values()); int countTagged = 0; //add Tags for the ones which are forced in. Vector includedPotentialTags = new Vector(); //construct a list of PotentialTag objects for forced in sequences for (int i = 0; i < forceInclude.size(); i++) { VariantSequence variantSequence = (VariantSequence) forceInclude.elementAt(i); if(variantSequence != null && potentialTagHash.containsKey(variantSequence)) { includedPotentialTags.add((PotentialTag) potentialTagHash.get(variantSequence)); } } //add each forced in sequence to the list of tags for(int i=0;i<includedPotentialTags.size();i++) { PotentialTag curPT = (PotentialTag) includedPotentialTags.get(i); Vector newlyTagged = addTag(curPT,potentialTagHash,sitesToCapture); countTagged += newlyTagged.size(); sitesToCapture.removeAll(newlyTagged); sitesToCapture.remove(curPT.sequence); } //loop until all snps are tagged System.out.println("start"); while(sitesToCapture.size() > 0) { potentialTags = new Vector(potentialTagHash.values()); if(potentialTags.size() == 0) { //we still have sites left to capture, but we have no more available tags. //this should only happen if the sites remaining in sitesToCapture were specifically //excluded from being tags. Since we can't add any more tags, break out of the loop. break; } //sorts the array of potential tags according to the number of untagged sites they can tag. //the last element is the one which tags the most untagged sites, so we choose that as our next tag. Collections.sort(potentialTags,ptcomp); PotentialTag currentBestTag = (PotentialTag) potentialTags.lastElement(); Vector newlyTagged = addTag(currentBestTag,potentialTagHash,sitesToCapture); countTagged += newlyTagged.size(); sitesToCapture.removeAll(newlyTagged); sitesToCapture.remove(currentBestTag.sequence); taggedSoFar = countTagged; } if(sitesToCapture.size() > 0) { //any sites left in sitesToCapture could not be tagged, so we add them all to the untagged Vector untagged.addAll(sitesToCapture); } System.out.println("tagged " + countTagged + " SNPS using " + tags.size() +" tags" ); System.out.println("# of SNPs that could not be tagged: " + untagged.size()); if (aggression != PAIRWISE_ONLY){ //peelback starting with the worst tag (i.e. the one that tags the fewest other snps. Vector tags2BPeeled = (Vector)tags.clone(); Collections.reverse(tags2BPeeled); peelBack(tags2BPeeled); } return new Vector(tags); }
/*
public TagScript createTagScript(String name, Attributes attributes) throws Exception { Project project = getProject(); // custom Ant tags if ( name.equals("fileScanner") ) { Tag tag = new FileScannerTag(new FileScanner(project)); return TagScript.newInstance(tag); } // is it an Ant task? Class type = (Class) project.getTaskDefinitions().get(name); if ( type != null ) { TaskTag tag = new TaskTag( project, type, name ); tag.setTrim( true ); if ( name.equals( "echo" ) ) { tag.setTrim(false); } return new AntTagScript(tag); } /* // an Ant DataType? DataType dataType = null; type = (Class) project.getDataTypeDefinitions().get(name); if ( type != null ) { try { java.lang.reflect.Constructor ctor = null; boolean noArg = false; // DataType can have a "no arg" constructor or take a single // Project argument. try { ctor = type.getConstructor(new Class[0]); noArg = true; } catch (NoSuchMethodException nse) { ctor = type.getConstructor(new Class[] { Project.class }); noArg = false; } if (noArg) { dataType = (DataType) ctor.newInstance(new Object[0]); } else { dataType = (DataType) ctor.newInstance(new Object[] {project}); } dataType.setProject( project ); } catch (Throwable t) { t.printStackTrace(); // ignore } } if ( dataType != null ) { DataTypeTag tag = new DataTypeTag( name, dataType ); tag.setAntProject( getProject() ); tag.getDynaBean().set( "project", project ); return TagScript.newInstance(tag); } */ // Since ant resolves so many dynamically loaded/created // things at run-time, we can make virtually no assumptions // as to what this tag might be. OtherAntTag tag = new OtherAntTag( project, name ); return new AntTagScript( tag ); }