rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
boolean success = tp.insertObjects(droppedItems, insertionPoint);
boolean success = false; try { success = tp.insertObjects(droppedItems, insertionPoint); } catch (LockedColumnException ex ) { JOptionPane.showConfirmDialog(pp, "Could not delete the column " + ex.getCol().getName() + " because it is part of\n" + "the relationship \""+ex.getLockingRelationship()+"\".\n\n", "Column is Locked", JOptionPane.CLOSED_OPTION); success = false; }
public void drop(DropTargetDropEvent dtde) { PlayPen pp = tp.getPlayPen(); Point loc = pp.unzoomPoint(new Point(dtde.getLocation())); loc.x -= tp.getX(); loc.y -= tp.getY(); logger.debug("Drop target drop event on "+tp.getName()+": "+dtde); Transferable t = dtde.getTransferable(); DataFlavor importFlavor = bestImportFlavor(pp, t.getTransferDataFlavors()); if (importFlavor == null) { dtde.rejectDrop(); tp.setInsertionPoint(COLUMN_INDEX_NONE); } else { try { DBTree dbtree = ArchitectFrame.getMainInstance().dbTree; // XXX: bad int insertionPoint = tp.pointToColumnIndex(loc); ArrayList<int[]> paths = (ArrayList<int[]>) t.getTransferData(importFlavor); logger.debug("Importing items from tree: "+paths); // put the undo event adapter into a drag and drop state ArchitectFrame.getMainInstance().playpen.startCompoundEdit("Drag and Drop"); ArrayList<SQLObject> droppedItems = new ArrayList<SQLObject>(); for (int[] path : paths) { droppedItems.add(dbtree.getNodeForDnDPath(path)); } boolean success = tp.insertObjects(droppedItems, insertionPoint); if (success) { dtde.acceptDrop(DnDConstants.ACTION_COPY); // XXX: not always true } else { dtde.rejectDrop(); } dtde.dropComplete(success); } catch (Exception ex) { // Trying to show this dialog sometimes hangs the app in OS X //JOptionPane.showMessageDialog(tp, "Drop failed: "+ex.getMessage()); logger.error("Error processing drop operation", ex); dtde.rejectDrop(); dtde.dropComplete(false); ASUtils.showExceptionDialog("Error processing drop operation", ex); } finally { tp.setInsertionPoint(COLUMN_INDEX_NONE); tp.getModel().normalizePrimaryKey(); // put the undo event adapter into a regular state ArchitectFrame.getMainInstance().playpen.endCompoundEdit("End drag and drop"); } } }
return (byte[]) origInstanceHash.clone();
return (origInstanceHash != null) ? ((byte[])origInstanceHash.clone()) : null;
public byte[] getOrigInstanceHash() { return (byte[]) origInstanceHash.clone(); }
};
}
private void setupMapping(SQLTable newTable, SQLTable otherTable, SQLRelationship newRel, SQLRelationship.ColumnMapping m, boolean newTableIsPk) throws ArchitectException { SQLColumn pkCol = null; SQLColumn fkCol = null; if (newTableIsPk) { pkCol=newTable.getColumnByName(m.getPkColumn().getName()); fkCol=otherTable.getColumnByName(m.getFkColumn().getName()); if (pkCol == null) { // this shouldn't happen throw new IllegalStateException("Couldn't find pkCol "+m.getPkColumn().getName()+" in new table"); } if (fkCol == null) { // this might reasonably happen (user deleted the column) return; } } else { pkCol=otherTable.getColumnByName(m.getPkColumn().getName()); fkCol=newTable.getColumnByName(m.getFkColumn().getName()); if (fkCol == null) { // this shouldn't happen throw new IllegalStateException("Couldn't find fkCol "+m.getFkColumn().getName()+" in new table"); } if (pkCol == null) { // this might reasonably happen (user deleted the column) return; }; } fkCol.addReference(); SQLRelationship.ColumnMapping newMapping = new SQLRelationship.ColumnMapping(); newMapping.setPkColumn(pkCol); newMapping.setFkColumn(fkCol); newRel.addChild(newMapping); }
printPanel.showPreviewDialog();
public void actionPerformed(ActionEvent evt) { final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Print"); JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createMatteBorder(12,12,12,12, cp.getBackground())); final PrintPanel printPanel = new PrintPanel(pp); cp.add(printPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Print"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { printPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { printPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); d.setContentPane(cp); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); printPanel.showPreviewDialog(); }
printerBox.setSelectedItem(getPreferredPrinter());
public PrintPanel(PlayPen pp) { super(); setOpaque(true); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); this.pp = pp; job = PrinterJob.getPrinterJob(); jobAttributes = new HashPrintRequestAttributeSet(); pageFormat = job.defaultPage(); JPanel formPanel = new JPanel(new FormLayout()); formPanel.add(new JLabel("Printer")); formPanel.add(printerBox = new JComboBox(PrinterJob.lookupPrintServices())); formPanel.add(new JLabel("Page Format")); formPanel.add(pageFormatLabel = new JLabel(pageFormat.toString())); formPanel.add(new JLabel("Change Page Format")); formPanel.add(pageFormatButton = new JButton("Change Page Format")); pageFormatButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setPageFormat(job.pageDialog(jobAttributes)); } }); formPanel.add(zoomLabel = new JLabel("Scaling = 100%")); formPanel.add(zoomSlider = new JSlider(JSlider.HORIZONTAL, 1, 300, 100)); setZoom(1.0); zoomSlider.addChangeListener(this); add(formPanel); }
if (printerBox.getItemCount() > 0 && printerBox.getSelectedItem() instanceof PrintService) { ArchitectFrame.getMainInstance().getUserSettings().getPrintUserSettings().setDefaultPrinterName( ((PrintService)printerBox.getSelectedItem()).getName() ); }
public void applyChanges() { try { validateLayout(); job.setPrintService((PrintService) printerBox.getSelectedItem()); job.setPageable(this); job.print(jobAttributes); } catch (PrinterException ex) { logger.error("Printing failure", ex); JOptionPane.showMessageDialog(this, "Printing failed: "+ex.getMessage()); } }
request.setAttribute(RequestAttributes.NAV_CURRENT_PAGE, "Add Application");
public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { AccessController.canAccess(context.getUser(), ACL_ADD_APPLICATIONS); Map availableApplications = ModuleRegistry.getModules(); request.setAttribute(RequestAttributes.AVAILABLE_APPLICATIONS, availableApplications); return mapping.findForward(Forwards.SUCCESS); }
public DashboardConfig(String dashboardId, String name, String template, Map<String, DashboardComponent> components, List<DashboardQualifier> qualifiers) {
public DashboardConfig(String dashboardId){
public DashboardConfig(String dashboardId, String name, String template, Map<String, DashboardComponent> components, List<DashboardQualifier> qualifiers) { this.dashboardId = dashboardId; this.name = name; this.template = template; this.components = components; this.qualifiers = qualifiers; }
this.name = name; this.template = template; this.components = components; this.qualifiers = qualifiers;
public DashboardConfig(String dashboardId, String name, String template, Map<String, DashboardComponent> components, List<DashboardQualifier> qualifiers) { this.dashboardId = dashboardId; this.name = name; this.template = template; this.components = components; this.qualifiers = qualifiers; }
return null;
return defaultClass;
protected Class getDefaultClass() { return null; }
try { Iterator it = getModel().getChildren().iterator(); while (it.hasNext()) { SQLRelationship.ColumnMapping m = (ColumnMapping) it.next(); int pkColIdx = pkTable.getModel().getColumnIndex(m.getPkColumn()); int fkColIdx = fkTable.getModel().getColumnIndex(m.getFkColumn()); pkTable.setColumnHighlight(pkColIdx, isSelected ? columnHighlightColour : null); fkTable.setColumnHighlight(fkColIdx, isSelected ? columnHighlightColour : null); } } catch (ArchitectException e) { logger.error("Couldn't modify highlights for columns in the mapping", e); }
public void setSelected(boolean isSelected) { if (selected != isSelected) { selected = isSelected; fireSelectionEvent(new SelectionEvent(this, selected ? SelectionEvent.SELECTION_EVENT : SelectionEvent.DESELECTION_EVENT)); repaint(); } }
Object dataType = null;
DataType dataType = null;
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 ); return TagScript.newInstance(tag); } // an Ant DataType? Object dataType = null; type = (Class) project.getDataTypeDefinitions().get(name); if ( type != null ) { dataType = type.newInstance(); } else { dataType = project.createDataType(name); } if ( dataType != null ) { DataTypeTag tag = new DataTypeTag( name, dataType ); tag.getDynaBean().set( "project", project ); return TagScript.newInstance(tag); } // assume its an Ant property object (classpath, arg etc). Tag tag = new TaskPropertyTag( name ); return TagScript.newInstance(tag); }
dataType = type.newInstance(); } else { dataType = project.createDataType(name);
try { java.lang.reflect.Constructor ctor = null; boolean noArg = false; 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(); }
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 ); return TagScript.newInstance(tag); } // an Ant DataType? Object dataType = null; type = (Class) project.getDataTypeDefinitions().get(name); if ( type != null ) { dataType = type.newInstance(); } else { dataType = project.createDataType(name); } if ( dataType != null ) { DataTypeTag tag = new DataTypeTag( name, dataType ); tag.getDynaBean().set( "project", project ); return TagScript.newInstance(tag); } // assume its an Ant property object (classpath, arg etc). Tag tag = new TaskPropertyTag( name ); return TagScript.newInstance(tag); }
Tag tag = new TaskPropertyTag( name ); return TagScript.newInstance(tag);
Tag tag = new OtherAntTag( project, name ); return TagScript.newInstance( tag );
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 ); return TagScript.newInstance(tag); } // an Ant DataType? Object dataType = null; type = (Class) project.getDataTypeDefinitions().get(name); if ( type != null ) { dataType = type.newInstance(); } else { dataType = project.createDataType(name); } if ( dataType != null ) { DataTypeTag tag = new DataTypeTag( name, dataType ); tag.getDynaBean().set( "project", project ); return TagScript.newInstance(tag); } // assume its an Ant property object (classpath, arg etc). Tag tag = new TaskPropertyTag( name ); return TagScript.newInstance(tag); }
public FieldController( Object[] model ) { setModel( model, false );
public FieldController( Object model ) { this.model = new Object[1]; this.model[0] = model; if ( model != null ) { value = getModelValue( model ); }
public FieldController( Object[] model ) { setModel( model, false ); }
dbNameField.setName("dbNameField");
public DBCSPanel() { setLayout(new BorderLayout()); dbDriverField = new JComboBox(getDriverClasses()); dbDriverField.insertItemAt("", 0); dbNameField = new JTextField(); platformSpecificOptions = new JPanel(); platformSpecificOptions.setLayout(new PlatformOptionsLayout()); platformSpecificOptions.setBorder(BorderFactory.createEmptyBorder()); platformSpecificOptions.add(new JLabel("(No options for current driver)")); JComponent[] fields = new JComponent[] {dbNameField, dbDriverField, platformSpecificOptions, dbUrlField = new JTextField(), dbUserField = new JTextField(), dbPassField = new JPasswordField(), plSchemaField = new JTextField(), plDbTypeField = new JComboBox(getDriverTypes()), odbcDSNField = new JTextField()}; String[] labels = new String[] {"Connection Name", "JDBC Driver", "Connect Options", "JDBC URL", "Username", "Password", "PL Schema Owner", "Database Type", "ODBC Data Source Name"}; char[] mnemonics = new char[] {'n', 'd', 'o', 'u', 'r', 'p', 's', 't', 'b'}; int[] widths = new int[] {40, 40, 40, 40, 40, 40, 40, 40, 40}; String[] tips = new String[] {"Your nickname for this database", "The class name of the JDBC Driver", "Connection parameters specific to this driver", "Vendor-specific JDBC URL", "Username for this database", "Password for this database", "Qualifier to put before references to PL system tables", "The Power*Loader type code for this database", "The ODBC data source name for this database"}; // update url and type field when user picks new driver dbDriverField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String driverField; String typeField; HashMap driverToType = (HashMap)ArchitectUtils.getDriverTypeMap(); createFieldsFromTemplate(); updateUrlFromFields(); driverField = (String) dbDriverField.getSelectedItem(); typeField =(String) driverToType.get(driverField); plDbTypeField.setSelectedItem(typeField); } }); dbUrlField.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e) { updateFieldsFromUrl(); } public void removeUpdate(DocumentEvent e) { updateFieldsFromUrl(); } public void changedUpdate(DocumentEvent e) { updateFieldsFromUrl(); } }); form = new TextPanel(fields, labels, mnemonics, widths, tips); add(form, BorderLayout.CENTER); }
pp.setIgnoreReset(true);
pp.setPlayPenDatabase(true);
public void testGetDerivedInstance() throws Exception { SQLTable derivedTable; SQLTable table1; // Check to make sure it can be added to a playpen like database SQLDatabase pp = new SQLDatabase(); pp.setIgnoreReset(true); assertNotNull(table1 = db.getTableByName("REGRESSION_TEST1")); derivedTable = SQLTable.getDerivedInstance(table1, pp); TreeMap derivedPropertyMap = new TreeMap(BeanUtils.describe(derivedTable)); TreeMap table1PropertyMap = new TreeMap(BeanUtils.describe(table1)); derivedPropertyMap.remove("parent"); derivedPropertyMap.remove("parentDatabase"); derivedPropertyMap.remove("schemaName"); derivedPropertyMap.remove("schema"); derivedPropertyMap.remove("shortDisplayName"); table1PropertyMap.remove("parent"); table1PropertyMap.remove("schemaName"); table1PropertyMap.remove("schema"); table1PropertyMap.remove("parentDatabase"); table1PropertyMap.remove("shortDisplayName"); assertEquals("Derived table not properly copied", derivedPropertyMap.toString(), table1PropertyMap.toString()); }
UserActivityLogger.getInstance().logActivity( context.getUser().getUsername(), "Added application cluster "+ "\""+clusterConfig.getName()+"\"");
public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { ApplicationClusterForm clusterForm = (ApplicationClusterForm)actionForm; String[] childAppIds = Utils.csvToStringArray(clusterForm.getSelectedChildApplications()); /* build list of new child applications */ List newChildApplications = getNewChildApplications(childAppIds); String applicationId = clusterForm.getApplicationId(); if(applicationId != null){ /* update existing application */ ApplicationClusterConfig clusterConfig = (ApplicationClusterConfig) ApplicationConfigManager.getApplicationConfig(applicationId); assert clusterConfig != null; clusterConfig.setName(clusterForm.getName()); final List oldChildApplications = clusterConfig.getApplications(); /* add applications outside the cluster (applications that are no longer in the cluster) */ for(Iterator it=oldChildApplications.iterator();it.hasNext();){ ApplicationConfig appConfig = (ApplicationConfig)it.next(); if(!newChildApplications.contains(appConfig)){ ApplicationConfigManager.addApplication(appConfig); appConfig.setClusterConfig(null); } } /* remove applications outside the cluster (applications that are now part of cluster) */ for(Iterator it=newChildApplications.iterator();it.hasNext();){ ApplicationConfig appConfig = (ApplicationConfig)it.next(); if(!oldChildApplications.contains(appConfig)){ ApplicationConfigManager.deleteApplication(appConfig); appConfig.setClusterConfig(clusterConfig); } } clusterConfig.setApplications(newChildApplications); ApplicationConfigManager.updateApplication(clusterConfig); }else{ /* add new application cluster */ ApplicationClusterConfig clusterConfig = new ApplicationClusterConfig( ApplicationConfig.getNextApplicationId(), clusterForm.getName()); for(Iterator it=newChildApplications.iterator();it.hasNext();){ ApplicationConfig appConfig = (ApplicationConfig)it.next(); appConfig.setClusterConfig(clusterConfig); ApplicationConfigManager.deleteApplication(appConfig); } clusterConfig.setApplications(newChildApplications); /* remove from stand-alone list */ ApplicationConfigManager.addApplication(clusterConfig); } return mapping.findForward(Forwards.SUCCESS); }
printDPrimeValues = false; printMarkerNames = false;
return;
public void paintComponent(Graphics g){ DPrimeTable dPrimeTable = theData.dpTable; if (Chromosome.getSize() == 0){ //if there are no valid markers, but info is known we don't want //to paint any of that stuff. printDPrimeValues = false; printMarkerNames = false; } Vector blocks = theData.blocks; Rectangle visRect = getVisibleRect(); //deal with zooming if (chartSize.getWidth() > (3*visRect.width)){ showWM = true; }else{ showWM = false; } if (zoomLevel != 0 || currentScheme == WMF_SCHEME || currentScheme == 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; //System.out.println(Chromosome.dataChrom + " " + Chromosome.getMarker(0).getPosition() + " " + // Chromosome.getMarker(Chromosome.getSize()-1).getPosition()); /*#################START OF SIMON'S HACKS#################See http://www.hapmap.org/cgi-perl/gbrowse/gbrowse_imgfor more info on GBrowse img. URL imgUrl; int imgHeight = 0; int gbLineSpan = (dPrimeTable.length-1) * boxSize; long gbminpos = Chromosome.getMarker(0).getPosition(); long gbmaxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); try {// imgUrl = new URL("http://www.hapmap.org/cgi-perl/gbrowse/gbrowse_img?source=hapmap;name=chr5:" + gbminpos + ".." + gbmaxpos + ";width=" + gbLineSpan + ";type=genotyped_SNPs+LocusLink+RefSeq_mRNA");// fake the real region, actual file coordinates are not in actual genomic bp imgUrl = new URL("http://www.hapmap.org/cgi-perl/gbrowse/gbrowse_img?source=hapmap;name=chr5:131856314..131999887;width=" + gbLineSpan + ";type=genotyped_SNPs+LocusLink+RefSeq_mRNA"); Toolkit toolkit = Toolkit.getDefaultToolkit(); Image gbrowse_img = toolkit.getImage(imgUrl); // get from the URL MediaTracker mediaTracker = new MediaTracker(this); mediaTracker.addImage(gbrowse_img, 0); try { mediaTracker.waitForID(0); } catch (InterruptedException ie) { System.err.println(ie); System.exit(1); } g2.drawImage(gbrowse_img, H_BORDER,0,this); // not sure if this is an imageObserver, however imgHeight = gbrowse_img.getHeight(this); // get height so we can shift everything down } catch(MalformedURLException mue) { System.err.println(mue); System.exit(1); } */ left = H_BORDER; top = V_BORDER;// + imgHeight; // push the haplotype display down to make room for gbrowse image./*###############END OF HIS HACKS###############*/ 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(); } /*lowX = (visRect.x-clickXShift-(visRect.y + visRect.height-clickYShift))/boxSize; highX = ((visRect.x + visRect.width)/boxSize)+1; lowY = ((visRect.x-clickXShift)+(visRect.y-clickYShift))/boxSize; highY = (((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height))/boxSize)+1; */ if (forExport){ lowX = exportStart; lowY = exportStart; highX = exportStop; highY = exportStop; } 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; 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); 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 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 < 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])/(scalefactor*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.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); } }
if (custAssocButton != null){
if (hv.custAssocPanel != null){
public ExportDialog(HaploView h){ super(h, "Export Data"); hv = h; JPanel contents = new JPanel(); contents.setLayout(new BoxLayout(contents, BoxLayout.Y_AXIS)); JPanel tabPanel = new JPanel(); int currTab = hv.tabs.getSelectedIndex(); tabPanel.setBorder(new TitledBorder("Tab to Export")); tabPanel.setLayout(new BoxLayout(tabPanel,BoxLayout.Y_AXIS)); tabPanel.setAlignmentX(CENTER_ALIGNMENT); ButtonGroup g1 = new ButtonGroup(); dpButton = new JRadioButton("LD"); dpButton.setActionCommand("ldtab"); dpButton.addActionListener(this); g1.add(dpButton); tabPanel.add(dpButton); if (currTab == VIEW_D_NUM){ dpButton.setSelected(true); } hapButton = new JRadioButton("Haplotypes"); hapButton.setActionCommand("haptab"); hapButton.addActionListener(this); g1.add(hapButton); tabPanel.add(hapButton); if (currTab == VIEW_HAP_NUM){ hapButton.setSelected(true); } if (hv.checkPanel != null){ checkButton = new JRadioButton("Data Checks"); checkButton.setActionCommand("checktab"); checkButton.addActionListener(this); g1.add(checkButton); tabPanel.add(checkButton); if (currTab == VIEW_CHECK_NUM){ checkButton.setSelected(true); } } if (Options.getAssocTest() != ASSOC_NONE){ singleAssocButton = new JRadioButton("Single Marker Association Tests"); singleAssocButton.setActionCommand("assoctab"); singleAssocButton.addActionListener(this); g1.add(singleAssocButton); tabPanel.add(singleAssocButton); hapAssocButton = new JRadioButton("Haplotype Association Tests"); hapAssocButton.setActionCommand("assoctab"); hapAssocButton.addActionListener(this); g1.add(hapAssocButton); tabPanel.add(hapAssocButton); if (custAssocButton != null){ custAssocButton = new JRadioButton("Custom Association Tests"); custAssocButton.setActionCommand("assoctab"); custAssocButton.addActionListener(this); g1.add(custAssocButton); tabPanel.add(custAssocButton); } permAssocButton = new JRadioButton("Permutation Results"); permAssocButton.setActionCommand("assoctab"); permAssocButton.addActionListener(this); g1.add(permAssocButton); tabPanel.add(permAssocButton); if (currTab == VIEW_ASSOC_NUM){ Component c = ((JTabbedPane)((HaploviewTab)hv.tabs.getComponent(currTab)).getComponent(0)).getSelectedComponent(); if(c == hv.tdtPanel){ singleAssocButton.setSelected(true); }else if (c == hv.hapAssocPanel){ hapAssocButton.setSelected(true); }else if (c == hv.permutationPanel){ permAssocButton.setSelected(true); }else if (c == hv.custAssocPanel){ custAssocButton.setSelected(true); } } } if (hv.taggerResultsPanel != null){ taggerButton = new JRadioButton("Tagger output"); taggerButton.setActionCommand("taggertab"); taggerButton.addActionListener(this); g1.add(taggerButton); tabPanel.add(taggerButton); } contents.add(tabPanel); JPanel formatPanel = new JPanel(); formatPanel.setBorder(new TitledBorder("Output Format")); ButtonGroup g2 = new ButtonGroup(); txtButton = new JRadioButton("Text"); txtButton.addActionListener(this); formatPanel.add(txtButton); g2.add(txtButton); txtButton.setSelected(true); pngButton = new JRadioButton("PNG Image"); pngButton.addActionListener(this); formatPanel.add(pngButton); g2.add(pngButton); compressCheckBox = new JCheckBox("Compress image (smaller file)"); formatPanel.add(compressCheckBox); compressCheckBox.setEnabled(false); if (currTab == VIEW_CHECK_NUM || currTab == VIEW_ASSOC_NUM){ pngButton.setEnabled(false); } contents.add(formatPanel); JPanel rangePanel = new JPanel(); rangePanel.setBorder(new TitledBorder("Range")); ButtonGroup g3 = new ButtonGroup(); allButton = new JRadioButton("All"); allButton.addActionListener(this); rangePanel.add(allButton); g3.add(allButton); allButton.setSelected(true); someButton = new JRadioButton("Marker "); someButton.addActionListener(this); rangePanel.add(someButton); g3.add(someButton); lowRange = new NumberTextField("",5,false); rangePanel.add(lowRange); rangePanel.add(new JLabel(" to ")); upperRange = new NumberTextField("",5,false); rangePanel.add(upperRange); upperRange.setEnabled(false); lowRange.setEnabled(false); adjButton = new JRadioButton("Adjacent markers only"); adjButton.addActionListener(this); rangePanel.add(adjButton); g3.add(adjButton); if (currTab != VIEW_D_NUM){ someButton.setEnabled(false); adjButton.setEnabled(false); } contents.add(rangePanel); JPanel choicePanel = new JPanel(); JButton okButton = new JButton("OK"); okButton.addActionListener(this); choicePanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(this); choicePanel.add(cancelButton); contents.add(choicePanel); this.setContentPane(contents); this.setLocation(this.getParent().getX() + 100, this.getParent().getY() + 100); this.setModal(true); }
throw new JellyException( "This tag must have a 'test' attribute defined" );
throw new MissingAttributeException( "test" );
public void doTag(XMLOutput output) throws Exception { if (test != null) { if (test.evaluateAsBoolean(context)) { getBody().run(context, output); } } else { throw new JellyException( "This tag must have a 'test' attribute defined" ); } }
String appType = config.getType(); if (appType.equals("connector")) { ConnectorRegistry.remove(config); }
public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { AccessController.checkAccess(context.getServiceContext(), ACL_EDIT_APPLICATIONS); ApplicationForm appForm = (ApplicationForm)actionForm; ApplicationConfig config=ApplicationConfigManager.deleteApplication (appForm.getApplicationId()); /* unregister alerts for this application */ AlertEngine.getInstance().removeApplication(config); UserActivityLogger.getInstance().logActivity( context.getUser().getUsername(), "Deleted application "+"\""+config.getName()+"\""); return mapping.findForward(Forwards.SUCCESS); }
keys.add(key);
public void addContent(PedFileEntry entry){ String key = entry.getFamilyID() + " " + entry.getIndivID(); this._contents.put(key, entry); }
final String hashedPassword = Crypto.hash(userForm.getPassword()); if(!hashedPassword.equals(user.getPassword())){
if(!userForm.getPassword().equals(UserForm.FORM_PASSWORD)){ String hashedPassword = Crypto.hash(userForm.getPassword());
private User buildUser(ActionForm form){ UserForm userForm = (UserForm)form; User user = UserManager.getInstance().getUser(userForm.getUsername()); assert user != null; List roles = new ArrayList(1); roles.add(new Role(userForm.getRole())); user.setRoles(roles); // TODO: this is bug while updating final String hashedPassword = Crypto.hash(userForm.getPassword()); if(!hashedPassword.equals(user.getPassword())){ user.setPassword(hashedPassword); } user.setStatus(userForm.getStatus()); return user; }
registerTag("style", StyleTag.class);
public JSLTagLibrary() { registerTag("stylesheet", StylesheetTag.class); registerTag("template", TemplateTag.class); registerTag("applyTemplates", ApplyTemplatesTag.class); registerTag("valueOf", ExprTag.class); }
Connection conn = null; if (userName != null) { log.info("Creating connection from url: " + jdbcURL + " userName: " + userName); conn = DriverManager.getConnection(jdbcURL, userName, password); } else { log.info("Creating connection from url: " + jdbcURL); conn = DriverManager.getConnection(jdbcURL); } return conn; }
Connection conn = null; if (userName != null) { if (log.isDebugEnabled()) { log.debug( "Creating connection from url: " + jdbcURL + " userName: " + userName); } conn = DriverManager.getConnection(jdbcURL, userName, password); } else { if (log.isDebugEnabled()) { log.debug("Creating connection from url: " + jdbcURL); } conn = DriverManager.getConnection(jdbcURL); } return conn; }
public Connection getConnection() throws SQLException { Connection conn = null; if (userName != null) { log.info("Creating connection from url: " + jdbcURL + " userName: " + userName); conn = DriverManager.getConnection(jdbcURL, userName, password); } else { log.info("Creating connection from url: " + jdbcURL); conn = DriverManager.getConnection(jdbcURL); } return conn; }
for ( int i = 0; i < accuracyFormatLimits.length; i++ ) { log.warn( "Trying format " + accuracyFormatStrings[i] ); DateFormat df = new SimpleDateFormat( accuracyFormatStrings[i] ); try { Date d = df.parse( str ); if ( d != null ) { log.warn( "Success with " + accuracyFormatStrings[i] ); d = new Date( d.getTime() + (long)(accuracyFormatLimits[i] *24*3600*1000) ); fd = new FuzzyDate( d, accuracyFormatLimits[i] ); break; } } catch ( ParseException e ) { log.warn( "ParseException: " + e.getMessage() ); }
for ( int i = 0; i < fdParsers.length; i++ ) { fd = fdParsers[i].parse( str ); if ( fd != null ) { break; }
static public FuzzyDate parse( String str ) { log.warn( "Parsing " + str ); FuzzyDate fd = null; // First check whether the string contains a range with start and end dates String rangeSeparator = " - "; int separatorIdx = str.indexOf( rangeSeparator ); if ( separatorIdx > 0 ) { // Yes, it is. Parse both sides separately and set the fuzzy date to cover // the whole range if ( str.lastIndexOf( rangeSeparator ) != separatorIdx || separatorIdx > str.length() - rangeSeparator.length() ) { // Only 1 range separator is allowed, return null return null; } FuzzyDate date1 = FuzzyDate.parse( str.substring( 0, separatorIdx ) ); FuzzyDate date2 = FuzzyDate.parse( str.substring( separatorIdx + rangeSeparator.length() ) ); if ( date1 == null || date2 == null ) { return null; } // Set the date as average of begin and end long t1 = date1.getMinDate().getTime(); long t2 = date2.getMaxDate().getTime(); if ( t1 > t2 ) { // The range is not valid since end time is smaller than start time!!! return null; } Date avgDate = new Date( (t1+t2)/2 ); long accuracy = (t2-t1)/2; fd = new FuzzyDate( avgDate, ((double)accuracy) / MILLIS_IN_DAY ); } else { // No, just one date given // attempt to parse the date using all format strings for ( int i = 0; i < accuracyFormatLimits.length; i++ ) { log.warn( "Trying format " + accuracyFormatStrings[i] ); DateFormat df = new SimpleDateFormat( accuracyFormatStrings[i] ); try { Date d = df.parse( str ); if ( d != null ) { // Succeeded!!! log.warn( "Success with " + accuracyFormatStrings[i] ); d = new Date( d.getTime() + (long)(accuracyFormatLimits[i] *24*3600*1000) ); fd = new FuzzyDate( d, accuracyFormatLimits[i] ); break; } } catch ( ParseException e ) { log.warn( "ParseException: " + e.getMessage() ); } } } return fd; }
List<Integer> newRowMap = new ArrayList<Integer>(); CharSequence searchSubSequence = searchText.toLowerCase().subSequence(0,searchText.length());
List<Integer> newRowMap = new ArrayList<Integer>(); CharSequence searchSubSequence = searchText == null ? null : searchText.subSequence(0,searchText.length());
private void search(String searchText) { rowMapping = null; fireTableDataChanged(); List<Integer> newRowMap = new ArrayList<Integer>(); CharSequence searchSubSequence = searchText.toLowerCase().subSequence(0,searchText.length()); for ( int row = 0; row < tableModel.getRowCount(); row++ ) { boolean match = false; for ( int column = 0; column < tableModel.getColumnCount(); column++ ) { String value = tableTextConverter.getTextForCell(row, column); if (value.toLowerCase().contains(searchSubSequence)) { if (logger.isDebugEnabled()) { logger.debug("Match: "+value.toLowerCase()+" contains "+searchSubSequence); } match = true; break; } } if ( match ) newRowMap.add(row); } setSearchText(searchText); rowMapping = newRowMap; if (logger.isDebugEnabled()) { logger.debug("new row mapping after search: "+rowMapping); } fireTableDataChanged(); }
for ( int column = 0; column < tableModel.getColumnCount(); column++ ) { String value = tableTextConverter.getTextForCell(row, column); if (value.toLowerCase().contains(searchSubSequence)) { if (logger.isDebugEnabled()) { logger.debug("Match: "+value.toLowerCase()+" contains "+searchSubSequence);
if ( searchSubSequence == null ) { match = true; } else { for ( int column = 0; column < tableModel.getColumnCount(); column++ ) { String value = tableTextConverter.getTextForCell(row, column); if (value.toLowerCase().contains(searchSubSequence)) { if (logger.isDebugEnabled()) { logger.debug("Match: "+value.toLowerCase()+" contains "+searchSubSequence); } match = true; break;
private void search(String searchText) { rowMapping = null; fireTableDataChanged(); List<Integer> newRowMap = new ArrayList<Integer>(); CharSequence searchSubSequence = searchText.toLowerCase().subSequence(0,searchText.length()); for ( int row = 0; row < tableModel.getRowCount(); row++ ) { boolean match = false; for ( int column = 0; column < tableModel.getColumnCount(); column++ ) { String value = tableTextConverter.getTextForCell(row, column); if (value.toLowerCase().contains(searchSubSequence)) { if (logger.isDebugEnabled()) { logger.debug("Match: "+value.toLowerCase()+" contains "+searchSubSequence); } match = true; break; } } if ( match ) newRowMap.add(row); } setSearchText(searchText); rowMapping = newRowMap; if (logger.isDebugEnabled()) { logger.debug("new row mapping after search: "+rowMapping); } fireTableDataChanged(); }
match = true; break;
private void search(String searchText) { rowMapping = null; fireTableDataChanged(); List<Integer> newRowMap = new ArrayList<Integer>(); CharSequence searchSubSequence = searchText.toLowerCase().subSequence(0,searchText.length()); for ( int row = 0; row < tableModel.getRowCount(); row++ ) { boolean match = false; for ( int column = 0; column < tableModel.getColumnCount(); column++ ) { String value = tableTextConverter.getTextForCell(row, column); if (value.toLowerCase().contains(searchSubSequence)) { if (logger.isDebugEnabled()) { logger.debug("Match: "+value.toLowerCase()+" contains "+searchSubSequence); } match = true; break; } } if ( match ) newRowMap.add(row); } setSearchText(searchText); rowMapping = newRowMap; if (logger.isDebugEnabled()) { logger.debug("new row mapping after search: "+rowMapping); } fireTableDataChanged(); }
fkTable.getColumnsFolder().setSecondaryChangeMode(false); fkTable.getImportedKeysFolder().setSecondaryChangeMode(false);
if ( fkTable != null ) { fkTable.getColumnsFolder().setSecondaryChangeMode(false); fkTable.getImportedKeysFolder().setSecondaryChangeMode(false); }
public void attachRelationship(SQLTable pkTable, SQLTable fkTable, boolean autoGenerateMapping) throws ArchitectException { SQLTable oldPkt = this.pkTable; SQLTable oldFkt = this.fkTable; if (this.pkTable != null || this.fkTable != null) { this.detachListeners(); } this.pkTable = pkTable; this.fkTable = fkTable; this.fireDbObjectChanged("pkTable",oldPkt,pkTable); this.fireDbObjectChanged("fkTable",oldFkt,fkTable); try { fkTable.getColumnsFolder().setSecondaryChangeMode(true); fkTable.getImportedKeysFolder().setSecondaryChangeMode(true); pkTable.addExportedKey(this); fkTable.addImportedKey(this); if (autoGenerateMapping) { // iterate over a copy of pktable's column list to avoid comodification // when creating a self-referencing table java.util.List<SQLColumn> pkColListCopy = new ArrayList<SQLColumn>(pkTable.getColumns().size()); pkColListCopy.addAll(pkTable.getColumns()); for (SQLColumn pkCol : pkColListCopy) { if (pkCol.getPrimaryKeySeq() == null) break; SQLColumn fkCol; SQLColumn match = fkTable.getColumnByName(pkCol.getName()); if (match != null) { // does the matching column have a compatible data type? if (match.getType() == pkCol.getType() && match.getPrecision() == pkCol.getPrecision() && match.getScale() == pkCol.getScale()) { // column is an exact match, so we don't have to recreate it fkCol = match; } else { fkCol = new SQLColumn(pkCol); fkCol.setName(generateUniqueColumnName(pkCol,fkTable)); } } else { // no match, so we need to import this column from PK table fkCol = new SQLColumn(pkCol); } this.addMapping(pkCol, fkCol); } } realizeMapping(); this.attachListeners(); } finally { fkTable.getColumnsFolder().setSecondaryChangeMode(false); fkTable.getImportedKeysFolder().setSecondaryChangeMode(false); } }
registerBean( "customer", Customer.class );
public MyTagLibrary() { registerBean( "customer", Customer.class ); }
ArchitectFrame.getMainInstance().getProject().getPlayPen().fireUndoCompoundEvent(new UndoCompoundEvent(this,EventTypes.MULTI_SELECT_END,"Ending multi-select"));
public void doStuff () { if ( !isCancelled()){ hasStarted = true; logger.info("AddObjectsTask starting on thread "+Thread.currentThread().getName()); try { int pmMax = 0; Iterator soIt = sqlObjects.iterator(); // first pass: figure out how much work we need to do... while (soIt.hasNext()) { pmMax += ArchitectUtils.countTablesSnapshot((SQLObject)soIt.next()); } jobSize = new Integer(pmMax); // reset iterator soIt = sqlObjects.iterator(); while (soIt.hasNext() && !isCancelled()) { Object someData = soIt.next(); if (someData instanceof SQLTable) { TablePane tp = importTableCopy((SQLTable) someData, preferredLocation); message = ArchitectUtils.truncateString(((SQLTable)someData).getName()); preferredLocation.x += tp.getPreferredSize().width + 5; progress++; } else if (someData instanceof SQLSchema) { SQLSchema sourceSchema = (SQLSchema) someData; Iterator it = sourceSchema.getChildren().iterator(); while (it.hasNext() && !isCancelled()) { SQLTable sourceTable = (SQLTable) it.next(); message = ArchitectUtils.truncateString(sourceTable.getName()); TablePane tp = importTableCopy(sourceTable, preferredLocation); preferredLocation.x += tp.getPreferredSize().width + 5; progress++; } } else if (someData instanceof SQLCatalog) { SQLCatalog sourceCatalog = (SQLCatalog) someData; Iterator cit = sourceCatalog.getChildren().iterator(); if (sourceCatalog.isSchemaContainer()) { while (cit.hasNext() && !isCancelled()) { SQLSchema sourceSchema = (SQLSchema) cit.next(); Iterator it = sourceSchema.getChildren().iterator(); while (it.hasNext() && !isCancelled()) { SQLTable sourceTable = (SQLTable) it.next(); message = ArchitectUtils.truncateString(sourceTable.getName()); TablePane tp = importTableCopy(sourceTable, preferredLocation); preferredLocation.x += tp.getPreferredSize().width + 5; progress++; } } } else { while (cit.hasNext() && !isCancelled()) { SQLTable sourceTable = (SQLTable) cit.next(); message = ArchitectUtils.truncateString(sourceTable.getName()); TablePane tp = importTableCopy(sourceTable, preferredLocation); preferredLocation.x += tp.getPreferredSize().width + 5; progress++; } } } else if (someData instanceof SQLColumn) { SQLColumn column = (SQLColumn) someData; JLabel colName = new JLabel(column.getName()); colName.setSize(colName.getPreferredSize()); add(colName, preferredLocation); logger.debug("Added "+column.getName()+" to playpen (temporary, only for testing)"); colName.revalidate(); } else { logger.error("Unknown object dropped in PlayPen: "+someData); } } } catch (ArchitectException e) { e.printStackTrace(); } finally { finished = true; hasStarted = false; } logger.info("AddObjectsTask done"); } }
PlayPen c = (PlayPen) dtde.getDropTargetContext().getComponent(); DataFlavor importFlavor = bestImportFlavor(c, t.getTransferDataFlavors());
PlayPen playpen = (PlayPen) dtde.getDropTargetContext().getComponent(); DataFlavor importFlavor = bestImportFlavor(playpen, t.getTransferDataFlavors());
public void drop(DropTargetDropEvent dtde) { logger.info("Drop: I am over dtde="+dtde); if (tpTarget != null) { tpTarget.getDropTargetListener().drop(dtde); return; } Transferable t = dtde.getTransferable(); PlayPen c = (PlayPen) dtde.getDropTargetContext().getComponent(); DataFlavor importFlavor = bestImportFlavor(c, t.getTransferDataFlavors()); if (importFlavor == null) { dtde.rejectDrop(); } else { try { dtde.acceptDrop(DnDConstants.ACTION_COPY); Point dropLoc = c.unzoomPoint(new Point(dtde.getLocation())); ArrayList paths = (ArrayList) t.getTransferData(importFlavor); // turn into a Collection of SQLObjects to make this more generic Iterator it = paths.iterator(); DBTree dbtree = ArchitectFrame.getMainInstance().dbTree; List sqlObjects = new ArrayList(); while(it.hasNext()) { Object oo = dbtree.getNodeForDnDPath((int[])it.next()); if (oo instanceof SQLObject) { sqlObjects.add(oo); } else { logger.error("Unknown object dropped in PlayPen: "+oo); } } // null: no next task is chained off this c.addObjects(sqlObjects, dropLoc, null); dtde.dropComplete(true); } catch (UnsupportedFlavorException ufe) { logger.error(ufe); dtde.rejectDrop(); } catch (IOException ioe) { logger.error(ioe); dtde.rejectDrop(); } catch (InvalidDnDOperationException ex) { logger.error(ex); dtde.rejectDrop(); } catch (ArchitectException ex) { logger.error(ex); dtde.rejectDrop(); } } }
Point dropLoc = c.unzoomPoint(new Point(dtde.getLocation()));
Point dropLoc = playpen.unzoomPoint(new Point(dtde.getLocation()));
public void drop(DropTargetDropEvent dtde) { logger.info("Drop: I am over dtde="+dtde); if (tpTarget != null) { tpTarget.getDropTargetListener().drop(dtde); return; } Transferable t = dtde.getTransferable(); PlayPen c = (PlayPen) dtde.getDropTargetContext().getComponent(); DataFlavor importFlavor = bestImportFlavor(c, t.getTransferDataFlavors()); if (importFlavor == null) { dtde.rejectDrop(); } else { try { dtde.acceptDrop(DnDConstants.ACTION_COPY); Point dropLoc = c.unzoomPoint(new Point(dtde.getLocation())); ArrayList paths = (ArrayList) t.getTransferData(importFlavor); // turn into a Collection of SQLObjects to make this more generic Iterator it = paths.iterator(); DBTree dbtree = ArchitectFrame.getMainInstance().dbTree; List sqlObjects = new ArrayList(); while(it.hasNext()) { Object oo = dbtree.getNodeForDnDPath((int[])it.next()); if (oo instanceof SQLObject) { sqlObjects.add(oo); } else { logger.error("Unknown object dropped in PlayPen: "+oo); } } // null: no next task is chained off this c.addObjects(sqlObjects, dropLoc, null); dtde.dropComplete(true); } catch (UnsupportedFlavorException ufe) { logger.error(ufe); dtde.rejectDrop(); } catch (IOException ioe) { logger.error(ioe); dtde.rejectDrop(); } catch (InvalidDnDOperationException ex) { logger.error(ex); dtde.rejectDrop(); } catch (ArchitectException ex) { logger.error(ex); dtde.rejectDrop(); } } }
c.addObjects(sqlObjects, dropLoc, null);
playpen.addObjects(sqlObjects, dropLoc, null);
public void drop(DropTargetDropEvent dtde) { logger.info("Drop: I am over dtde="+dtde); if (tpTarget != null) { tpTarget.getDropTargetListener().drop(dtde); return; } Transferable t = dtde.getTransferable(); PlayPen c = (PlayPen) dtde.getDropTargetContext().getComponent(); DataFlavor importFlavor = bestImportFlavor(c, t.getTransferDataFlavors()); if (importFlavor == null) { dtde.rejectDrop(); } else { try { dtde.acceptDrop(DnDConstants.ACTION_COPY); Point dropLoc = c.unzoomPoint(new Point(dtde.getLocation())); ArrayList paths = (ArrayList) t.getTransferData(importFlavor); // turn into a Collection of SQLObjects to make this more generic Iterator it = paths.iterator(); DBTree dbtree = ArchitectFrame.getMainInstance().dbTree; List sqlObjects = new ArrayList(); while(it.hasNext()) { Object oo = dbtree.getNodeForDnDPath((int[])it.next()); if (oo instanceof SQLObject) { sqlObjects.add(oo); } else { logger.error("Unknown object dropped in PlayPen: "+oo); } } // null: no next task is chained off this c.addObjects(sqlObjects, dropLoc, null); dtde.dropComplete(true); } catch (UnsupportedFlavorException ufe) { logger.error(ufe); dtde.rejectDrop(); } catch (IOException ioe) { logger.error(ioe); dtde.rejectDrop(); } catch (InvalidDnDOperationException ex) { logger.error(ex); dtde.rejectDrop(); } catch (ArchitectException ex) { logger.error(ex); dtde.rejectDrop(); } } }
Map<String,Object> description = new HashMap<String,Object>();
private static Map<String,Object> setAllInterestingProperties(SQLObject target, Set<String> propertiesToIgnore) throws Exception { Map<String,Object> description = new HashMap<String,Object>(); PropertyDescriptor props[] = PropertyUtils.getPropertyDescriptors(target); for (int i = 0; i < props.length; i++) { Object oldVal = null; if (PropertyUtils.isReadable(target, props[i].getName()) && props[i].getReadMethod() != null && !propertiesToIgnore.contains(props[i].getName())) { oldVal = PropertyUtils.getProperty(target, props[i].getName()); } if (PropertyUtils.isWriteable(target, props[i].getName()) && props[i].getWriteMethod() != null && !propertiesToIgnore.contains(props[i].getName())) { // XXX: factor this (and the same thing in SQLTestCase) // out into a changeValue() method in some util class. Object newVal; // don't init here so compiler can warn if the following code doesn't always give it a value if (props[i].getPropertyType() == Integer.TYPE) { newVal = ((Integer)oldVal)+1; } else if (props[i].getPropertyType() == Integer.class) { if (oldVal == null) { newVal = new Integer(1); } else { newVal = new Integer((Integer)oldVal+1); } } else if (props[i].getPropertyType() == String.class) { // make sure it's unique newVal ="new " + oldVal; } else if (props[i].getPropertyType() == Boolean.TYPE){ newVal = new Boolean(! ((Boolean) oldVal).booleanValue()); } else if (props[i].getPropertyType() == SQLColumn.class) { newVal = new SQLColumn(); ((SQLColumn) newVal).setName("testing!"); } else { throw new RuntimeException("This test case lacks a value for "+ props[i].getName()+ " (type "+props[i].getPropertyType().getName()+")"); } PropertyUtils.setProperty(target, props[i].getName(), newVal); } } // read them all back at the end in case there were dependencies between properties return getAllInterestingProperties(target, propertiesToIgnore); }
PrintWriter out = new PrintWriter(tmp);
PrintWriter out = new PrintWriter(tmp,ENCODING);
public void testSaveCoversAllCatalogProperties() throws Exception { ArchitectDataSource ds = new ArchitectDataSource(); ds.setDisplayName("Schemaless Database"); ds.setDriverClass("regress.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"); DBTree dbTree; DBTreeModel dbTreeModel = null; testLoad(); dbTree = project.getSourceDatabases(); dbTreeModel = (DBTreeModel) dbTree.getModel(); SQLDatabase db = new SQLDatabase(); db.setDataSource(ds); db.setPopulated(true); ((SQLObject) dbTreeModel.getRoot()).addChild(db); SQLCatalog target = new SQLCatalog(db, "my test catalog"); db.addChild(target); Set<String> propertiesToIgnore = new HashSet<String>(); propertiesToIgnore.add("SQLObjectListeners"); propertiesToIgnore.add("children"); propertiesToIgnore.add("parent"); propertiesToIgnore.add("parentDatabase"); propertiesToIgnore.add("class"); propertiesToIgnore.add("childCount"); propertiesToIgnore.add("populated"); Map<String,Object> oldDescription = setAllInterestingProperties(target, propertiesToIgnore); File tmp = File.createTempFile("test", ".architect"); if (deleteOnExit) { tmp.deleteOnExit(); } PrintWriter out = new PrintWriter(tmp); assertNotNull(out); project.save(out); SwingUIProject project2 = new SwingUIProject("new test project"); project2.load(new BufferedInputStream(new FileInputStream(tmp))); // grab the second database in the dbtree's model (the first is the play pen) db = (SQLDatabase) project2.getSourceDatabases().getDatabaseList().get(1); target = (SQLCatalog) db.getChild(0); Map<String, Object> newDescription = getAllInterestingProperties(target, propertiesToIgnore); assertMapsEqual(oldDescription, newDescription); }
project.save(out);
project.save(out,ENCODING);
public void testSaveCoversAllCatalogProperties() throws Exception { ArchitectDataSource ds = new ArchitectDataSource(); ds.setDisplayName("Schemaless Database"); ds.setDriverClass("regress.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"); DBTree dbTree; DBTreeModel dbTreeModel = null; testLoad(); dbTree = project.getSourceDatabases(); dbTreeModel = (DBTreeModel) dbTree.getModel(); SQLDatabase db = new SQLDatabase(); db.setDataSource(ds); db.setPopulated(true); ((SQLObject) dbTreeModel.getRoot()).addChild(db); SQLCatalog target = new SQLCatalog(db, "my test catalog"); db.addChild(target); Set<String> propertiesToIgnore = new HashSet<String>(); propertiesToIgnore.add("SQLObjectListeners"); propertiesToIgnore.add("children"); propertiesToIgnore.add("parent"); propertiesToIgnore.add("parentDatabase"); propertiesToIgnore.add("class"); propertiesToIgnore.add("childCount"); propertiesToIgnore.add("populated"); Map<String,Object> oldDescription = setAllInterestingProperties(target, propertiesToIgnore); File tmp = File.createTempFile("test", ".architect"); if (deleteOnExit) { tmp.deleteOnExit(); } PrintWriter out = new PrintWriter(tmp); assertNotNull(out); project.save(out); SwingUIProject project2 = new SwingUIProject("new test project"); project2.load(new BufferedInputStream(new FileInputStream(tmp))); // grab the second database in the dbtree's model (the first is the play pen) db = (SQLDatabase) project2.getSourceDatabases().getDatabaseList().get(1); target = (SQLCatalog) db.getChild(0); Map<String, Object> newDescription = getAllInterestingProperties(target, propertiesToIgnore); assertMapsEqual(oldDescription, newDescription); }
PrintWriter out = new PrintWriter(tmp);
PrintWriter out = new PrintWriter(tmp,ENCODING);
public void testSaveCoversAllColumnProperties() throws Exception { final String tableName = "harry"; testLoad(); SQLDatabase ppdb = project.getPlayPen().getDatabase(); SQLTable table = new SQLTable(ppdb, true); table.setName(tableName); SQLColumn target = new SQLColumn(table, "my cool test column", Types.INTEGER, 10, 10); ppdb.addChild(table); table.addColumn(target); Set<String> propertiesToIgnore = new HashSet<String>(); propertiesToIgnore.add("SQLObjectListeners"); propertiesToIgnore.add("children"); propertiesToIgnore.add("parent"); propertiesToIgnore.add("parentTable"); propertiesToIgnore.add("class"); propertiesToIgnore.add("childCount"); propertiesToIgnore.add("populated"); propertiesToIgnore.add("undoEventListeners"); Map<String,Object> oldDescription = setAllInterestingProperties(target, propertiesToIgnore); // need to set sourceColumn manually because it has to exist in the database. { // different variable scope DBTree dbTree = project.getSourceDatabases(); DBTreeModel dbTreeModel = (DBTreeModel) dbTree.getModel(); ArchitectDataSource fakeDataSource = new ArchitectDataSource(); SQLDatabase db = new SQLDatabase(); db.setDataSource(fakeDataSource); db.setPopulated(true); ((SQLObject) dbTreeModel.getRoot()).addChild(db); SQLTable sourceTable = new SQLTable(db, true); SQLColumn sourceColumn = new SQLColumn(sourceTable, "my cool source column", Types.INTEGER, 10, 10); sourceTable.addColumn(sourceColumn); db.addChild(sourceTable); // make sure target has a source column that can be saved in the project target.setSourceColumn(sourceColumn); oldDescription.put("sourceColumn", sourceColumn); } File tmp = File.createTempFile("test", ".architect"); if (deleteOnExit) { tmp.deleteOnExit(); } else { System.out.println("MY TEMP FILE: "+tmp.getAbsolutePath()); } PrintWriter out = new PrintWriter(tmp); assertNotNull(out); project.save(out); SwingUIProject project2 = new SwingUIProject("new test project"); project2.load(new BufferedInputStream(new FileInputStream(tmp))); // grab the second database in the dbtree's model (the first is the play pen) ppdb = (SQLDatabase) project2.getPlayPen().getDatabase(); target = ((SQLTable) ppdb.getTableByName(tableName)).getColumn(0); Map<String, Object> newDescription = getAllInterestingProperties(target, propertiesToIgnore); assertMapsEqual(oldDescription, newDescription); }
project.save(out);
project.save(out,ENCODING);
public void testSaveCoversAllColumnProperties() throws Exception { final String tableName = "harry"; testLoad(); SQLDatabase ppdb = project.getPlayPen().getDatabase(); SQLTable table = new SQLTable(ppdb, true); table.setName(tableName); SQLColumn target = new SQLColumn(table, "my cool test column", Types.INTEGER, 10, 10); ppdb.addChild(table); table.addColumn(target); Set<String> propertiesToIgnore = new HashSet<String>(); propertiesToIgnore.add("SQLObjectListeners"); propertiesToIgnore.add("children"); propertiesToIgnore.add("parent"); propertiesToIgnore.add("parentTable"); propertiesToIgnore.add("class"); propertiesToIgnore.add("childCount"); propertiesToIgnore.add("populated"); propertiesToIgnore.add("undoEventListeners"); Map<String,Object> oldDescription = setAllInterestingProperties(target, propertiesToIgnore); // need to set sourceColumn manually because it has to exist in the database. { // different variable scope DBTree dbTree = project.getSourceDatabases(); DBTreeModel dbTreeModel = (DBTreeModel) dbTree.getModel(); ArchitectDataSource fakeDataSource = new ArchitectDataSource(); SQLDatabase db = new SQLDatabase(); db.setDataSource(fakeDataSource); db.setPopulated(true); ((SQLObject) dbTreeModel.getRoot()).addChild(db); SQLTable sourceTable = new SQLTable(db, true); SQLColumn sourceColumn = new SQLColumn(sourceTable, "my cool source column", Types.INTEGER, 10, 10); sourceTable.addColumn(sourceColumn); db.addChild(sourceTable); // make sure target has a source column that can be saved in the project target.setSourceColumn(sourceColumn); oldDescription.put("sourceColumn", sourceColumn); } File tmp = File.createTempFile("test", ".architect"); if (deleteOnExit) { tmp.deleteOnExit(); } else { System.out.println("MY TEMP FILE: "+tmp.getAbsolutePath()); } PrintWriter out = new PrintWriter(tmp); assertNotNull(out); project.save(out); SwingUIProject project2 = new SwingUIProject("new test project"); project2.load(new BufferedInputStream(new FileInputStream(tmp))); // grab the second database in the dbtree's model (the first is the play pen) ppdb = (SQLDatabase) project2.getPlayPen().getDatabase(); target = ((SQLTable) ppdb.getTableByName(tableName)).getColumn(0); Map<String, Object> newDescription = getAllInterestingProperties(target, propertiesToIgnore); assertMapsEqual(oldDescription, newDescription); }
PrintWriter out = new PrintWriter(tmp);
PrintWriter out = new PrintWriter(tmp,ENCODING);
public void testSaveCoversAllDatabaseProperties() throws Exception { testLoad(); DBTree dbTree = project.getSourceDatabases(); DBTreeModel dbTreeModel = (DBTreeModel) dbTree.getModel(); ArchitectDataSource fakeDataSource = new ArchitectDataSource(); SQLDatabase db = new SQLDatabase() { @Override public Connection getConnection() throws ArchitectException { return null; } }; db.setDataSource(fakeDataSource); db.setPopulated(true); ((SQLObject) dbTreeModel.getRoot()).addChild(db); Set<String> propertiesToIgnore = new HashSet<String>(); propertiesToIgnore.add("SQLObjectListeners"); propertiesToIgnore.add("children"); propertiesToIgnore.add("tables"); propertiesToIgnore.add("parent"); propertiesToIgnore.add("parentDatabase"); propertiesToIgnore.add("class"); propertiesToIgnore.add("childCount"); propertiesToIgnore.add("connection"); propertiesToIgnore.add("populated"); propertiesToIgnore.add("dataSource"); // we set this already! propertiesToIgnore.add("ignoreReset"); // only used (and set) by playpen code propertiesToIgnore.add("progressMonitor"); Map<String,Object> oldDescription = setAllInterestingProperties(db, propertiesToIgnore); File tmp = File.createTempFile("test", ".architect"); if (deleteOnExit) { tmp.deleteOnExit(); } PrintWriter out = new PrintWriter(tmp); assertNotNull(out); project.save(out); SwingUIProject project2 = new SwingUIProject("new test project"); project2.load(new BufferedInputStream(new FileInputStream(tmp))); // grab the second database in the dbtree's model (the first is the play pen) db = (SQLDatabase) project2.getSourceDatabases().getDatabaseList().get(1); Map<String, Object> newDescription = getAllInterestingProperties(db, propertiesToIgnore); assertEquals("loaded-in version of database doesn't match the original!", oldDescription.toString(), newDescription.toString()); }
project.save(out);
project.save(out,ENCODING);
public void testSaveCoversAllDatabaseProperties() throws Exception { testLoad(); DBTree dbTree = project.getSourceDatabases(); DBTreeModel dbTreeModel = (DBTreeModel) dbTree.getModel(); ArchitectDataSource fakeDataSource = new ArchitectDataSource(); SQLDatabase db = new SQLDatabase() { @Override public Connection getConnection() throws ArchitectException { return null; } }; db.setDataSource(fakeDataSource); db.setPopulated(true); ((SQLObject) dbTreeModel.getRoot()).addChild(db); Set<String> propertiesToIgnore = new HashSet<String>(); propertiesToIgnore.add("SQLObjectListeners"); propertiesToIgnore.add("children"); propertiesToIgnore.add("tables"); propertiesToIgnore.add("parent"); propertiesToIgnore.add("parentDatabase"); propertiesToIgnore.add("class"); propertiesToIgnore.add("childCount"); propertiesToIgnore.add("connection"); propertiesToIgnore.add("populated"); propertiesToIgnore.add("dataSource"); // we set this already! propertiesToIgnore.add("ignoreReset"); // only used (and set) by playpen code propertiesToIgnore.add("progressMonitor"); Map<String,Object> oldDescription = setAllInterestingProperties(db, propertiesToIgnore); File tmp = File.createTempFile("test", ".architect"); if (deleteOnExit) { tmp.deleteOnExit(); } PrintWriter out = new PrintWriter(tmp); assertNotNull(out); project.save(out); SwingUIProject project2 = new SwingUIProject("new test project"); project2.load(new BufferedInputStream(new FileInputStream(tmp))); // grab the second database in the dbtree's model (the first is the play pen) db = (SQLDatabase) project2.getSourceDatabases().getDatabaseList().get(1); Map<String, Object> newDescription = getAllInterestingProperties(db, propertiesToIgnore); assertEquals("loaded-in version of database doesn't match the original!", oldDescription.toString(), newDescription.toString()); }
PrintWriter out = new PrintWriter(tmp);
PrintWriter out = new PrintWriter(tmp,ENCODING);
public void testSaveCoversAllSchemaProperties() throws Exception { testLoad(); DBTree dbTree = project.getSourceDatabases(); DBTreeModel dbTreeModel = (DBTreeModel) dbTree.getModel(); ArchitectDataSource fakeDataSource = new ArchitectDataSource(); SQLDatabase db = new SQLDatabase(); db.setDataSource(fakeDataSource); db.setPopulated(true); ((SQLObject) dbTreeModel.getRoot()).addChild(db); SQLSchema target = new SQLSchema(db, "my test schema", true); db.addChild(target); Set<String> propertiesToIgnore = new HashSet<String>(); propertiesToIgnore.add("SQLObjectListeners"); propertiesToIgnore.add("children"); propertiesToIgnore.add("parent"); propertiesToIgnore.add("parentDatabase"); propertiesToIgnore.add("class"); propertiesToIgnore.add("childCount"); propertiesToIgnore.add("populated"); Map<String,Object> oldDescription = setAllInterestingProperties(target, propertiesToIgnore); File tmp = File.createTempFile("test", ".architect"); if (deleteOnExit) { tmp.deleteOnExit(); } PrintWriter out = new PrintWriter(tmp); assertNotNull(out); project.save(out); SwingUIProject project2 = new SwingUIProject("new test project"); project2.load(new BufferedInputStream(new FileInputStream(tmp))); // grab the second database in the dbtree's model (the first is the play pen) db = (SQLDatabase) project2.getSourceDatabases().getDatabaseList().get(1); target = (SQLSchema) db.getChild(0); Map<String, Object> newDescription = getAllInterestingProperties(target, propertiesToIgnore); assertMapsEqual(oldDescription, newDescription); }
project.save(out);
project.save(out,ENCODING);
public void testSaveCoversAllSchemaProperties() throws Exception { testLoad(); DBTree dbTree = project.getSourceDatabases(); DBTreeModel dbTreeModel = (DBTreeModel) dbTree.getModel(); ArchitectDataSource fakeDataSource = new ArchitectDataSource(); SQLDatabase db = new SQLDatabase(); db.setDataSource(fakeDataSource); db.setPopulated(true); ((SQLObject) dbTreeModel.getRoot()).addChild(db); SQLSchema target = new SQLSchema(db, "my test schema", true); db.addChild(target); Set<String> propertiesToIgnore = new HashSet<String>(); propertiesToIgnore.add("SQLObjectListeners"); propertiesToIgnore.add("children"); propertiesToIgnore.add("parent"); propertiesToIgnore.add("parentDatabase"); propertiesToIgnore.add("class"); propertiesToIgnore.add("childCount"); propertiesToIgnore.add("populated"); Map<String,Object> oldDescription = setAllInterestingProperties(target, propertiesToIgnore); File tmp = File.createTempFile("test", ".architect"); if (deleteOnExit) { tmp.deleteOnExit(); } PrintWriter out = new PrintWriter(tmp); assertNotNull(out); project.save(out); SwingUIProject project2 = new SwingUIProject("new test project"); project2.load(new BufferedInputStream(new FileInputStream(tmp))); // grab the second database in the dbtree's model (the first is the play pen) db = (SQLDatabase) project2.getSourceDatabases().getDatabaseList().get(1); target = (SQLSchema) db.getChild(0); Map<String, Object> newDescription = getAllInterestingProperties(target, propertiesToIgnore); assertMapsEqual(oldDescription, newDescription); }
PrintWriter out = new PrintWriter(tmp);
PrintWriter out = new PrintWriter(tmp,ENCODING);
public void testSaveCoversAllTableProperties() throws Exception { testLoad(); DBTree dbTree = project.getSourceDatabases(); DBTreeModel dbTreeModel = (DBTreeModel) dbTree.getModel(); ArchitectDataSource fakeDataSource = new ArchitectDataSource(); SQLDatabase db = new SQLDatabase(); db.setDataSource(fakeDataSource); db.setPopulated(true); ((SQLObject) dbTreeModel.getRoot()).addChild(db); SQLTable target = new SQLTable(db, true); db.addChild(target); Set<String> propertiesToIgnore = new HashSet<String>(); propertiesToIgnore.add("SQLObjectListeners"); propertiesToIgnore.add("children"); propertiesToIgnore.add("parent"); propertiesToIgnore.add("parentDatabase"); propertiesToIgnore.add("class"); propertiesToIgnore.add("childCount"); propertiesToIgnore.add("populated"); propertiesToIgnore.add("columnsFolder"); Map<String,Object> oldDescription = setAllInterestingProperties(target, propertiesToIgnore); File tmp = File.createTempFile("test", ".architect"); if (deleteOnExit) { tmp.deleteOnExit(); } PrintWriter out = new PrintWriter(tmp); assertNotNull(out); project.save(out); SwingUIProject project2 = new SwingUIProject("new test project"); project2.load(new BufferedInputStream(new FileInputStream(tmp))); // grab the second database in the dbtree's model (the first is the play pen) db = (SQLDatabase) project2.getSourceDatabases().getDatabaseList().get(1); target = (SQLTable) db.getChild(0); Map<String, Object> newDescription = getAllInterestingProperties(target, propertiesToIgnore); assertMapsEqual(oldDescription, newDescription); }
project.save(out);
project.save(out,ENCODING);
public void testSaveCoversAllTableProperties() throws Exception { testLoad(); DBTree dbTree = project.getSourceDatabases(); DBTreeModel dbTreeModel = (DBTreeModel) dbTree.getModel(); ArchitectDataSource fakeDataSource = new ArchitectDataSource(); SQLDatabase db = new SQLDatabase(); db.setDataSource(fakeDataSource); db.setPopulated(true); ((SQLObject) dbTreeModel.getRoot()).addChild(db); SQLTable target = new SQLTable(db, true); db.addChild(target); Set<String> propertiesToIgnore = new HashSet<String>(); propertiesToIgnore.add("SQLObjectListeners"); propertiesToIgnore.add("children"); propertiesToIgnore.add("parent"); propertiesToIgnore.add("parentDatabase"); propertiesToIgnore.add("class"); propertiesToIgnore.add("childCount"); propertiesToIgnore.add("populated"); propertiesToIgnore.add("columnsFolder"); Map<String,Object> oldDescription = setAllInterestingProperties(target, propertiesToIgnore); File tmp = File.createTempFile("test", ".architect"); if (deleteOnExit) { tmp.deleteOnExit(); } PrintWriter out = new PrintWriter(tmp); assertNotNull(out); project.save(out); SwingUIProject project2 = new SwingUIProject("new test project"); project2.load(new BufferedInputStream(new FileInputStream(tmp))); // grab the second database in the dbtree's model (the first is the play pen) db = (SQLDatabase) project2.getSourceDatabases().getDatabaseList().get(1); target = (SQLTable) db.getChild(0); Map<String, Object> newDescription = getAllInterestingProperties(target, propertiesToIgnore); assertMapsEqual(oldDescription, newDescription); }
PrintWriter out = new PrintWriter(tmp);
PrintWriter out = new PrintWriter(tmp,ENCODING);
public void testSaveCoversCompareDMSettings() throws Exception { testLoad(); CompareDMSettings cds = project.getCompareDMSettings(); File tmp = File.createTempFile("test", ".architect"); assertFalse (cds.getSaveFlag()); if (deleteOnExit) { tmp.deleteOnExit(); } PrintWriter out = new PrintWriter(tmp); assertNotNull(out); project.save(out); assertFalse (cds.getSaveFlag()); assertEquals("SQLServer 2000", cds.getSqlScriptFormat()); assertEquals("ENGLISH", cds.getOutputFormatAsString()); assertEquals("PROJECT", cds.getSourceSettings().getButtonSelection().toString()); assertEquals("Arthur_test", cds.getSourceSettings().getConnectName()); assertEquals("ARCHITECT_REGRESS", cds.getSourceSettings().getSchema()); assertEquals("FILE", cds.getTargetSettings().getButtonSelection().toString()); assertEquals("Testpath", cds.getTargetSettings().getFilePath()); }
project.save(out);
project.save(out,ENCODING);
public void testSaveCoversCompareDMSettings() throws Exception { testLoad(); CompareDMSettings cds = project.getCompareDMSettings(); File tmp = File.createTempFile("test", ".architect"); assertFalse (cds.getSaveFlag()); if (deleteOnExit) { tmp.deleteOnExit(); } PrintWriter out = new PrintWriter(tmp); assertNotNull(out); project.save(out); assertFalse (cds.getSaveFlag()); assertEquals("SQLServer 2000", cds.getSqlScriptFormat()); assertEquals("ENGLISH", cds.getOutputFormatAsString()); assertEquals("PROJECT", cds.getSourceSettings().getButtonSelection().toString()); assertEquals("Arthur_test", cds.getSourceSettings().getConnectName()); assertEquals("ARCHITECT_REGRESS", cds.getSourceSettings().getSchema()); assertEquals("FILE", cds.getTargetSettings().getButtonSelection().toString()); assertEquals("Testpath", cds.getTargetSettings().getFilePath()); }
PrintWriter out = new PrintWriter(tmp);
PrintWriter out = new PrintWriter(tmp,ENCODING);
public void testSaveIsWellFormed() throws Exception { boolean validate = false; testLoad(); File tmp = File.createTempFile("test", ".architect"); if (deleteOnExit) { tmp.deleteOnExit(); } PrintWriter out = new PrintWriter(tmp); assertNotNull(out); project.setName("FOO<BAR"); // Implicitly testing sanitizeXML method here! project.save(out); System.err.println("Parsing " + tmp + "..."); // Make the document a URL so relative DTD works. String uri = "file:" + tmp.getAbsolutePath(); DocumentBuilderFactory f = DocumentBuilderFactory.newInstance(); if (validate) f.setValidating(true); DocumentBuilder p = f.newDocumentBuilder(); p.parse(uri); System.out.println("Parsed OK"); }
project.save(out);
project.save(out,ENCODING);
public void testSaveIsWellFormed() throws Exception { boolean validate = false; testLoad(); File tmp = File.createTempFile("test", ".architect"); if (deleteOnExit) { tmp.deleteOnExit(); } PrintWriter out = new PrintWriter(tmp); assertNotNull(out); project.setName("FOO<BAR"); // Implicitly testing sanitizeXML method here! project.save(out); System.err.println("Parsing " + tmp + "..."); // Make the document a URL so relative DTD works. String uri = "file:" + tmp.getAbsolutePath(); DocumentBuilderFactory f = DocumentBuilderFactory.newInstance(); if (validate) f.setValidating(true); DocumentBuilder p = f.newDocumentBuilder(); p.parse(uri); System.out.println("Parsed OK"); }
PrintWriter out = new PrintWriter(tmp);
PrintWriter out = new PrintWriter(tmp,ENCODING);
public void testSavePrintWriter() throws Exception { testLoad(); File tmp = File.createTempFile("test", ".architect"); if (deleteOnExit) { tmp.deleteOnExit(); } PrintWriter out = new PrintWriter(tmp); assertNotNull(out); project.save(out); SwingUIProject p2 = new SwingUIProject("test2"); p2.load(new FileInputStream(tmp)); File tmp2 = File.createTempFile("test2", ".architect"); if (deleteOnExit) { tmp2.deleteOnExit(); } p2.save(new PrintWriter(tmp2)); assertEquals(tmp.length(), tmp2.length()); // Quick test }
project.save(out);
project.save(out,ENCODING);
public void testSavePrintWriter() throws Exception { testLoad(); File tmp = File.createTempFile("test", ".architect"); if (deleteOnExit) { tmp.deleteOnExit(); } PrintWriter out = new PrintWriter(tmp); assertNotNull(out); project.save(out); SwingUIProject p2 = new SwingUIProject("test2"); p2.load(new FileInputStream(tmp)); File tmp2 = File.createTempFile("test2", ".architect"); if (deleteOnExit) { tmp2.deleteOnExit(); } p2.save(new PrintWriter(tmp2)); assertEquals(tmp.length(), tmp2.length()); // Quick test }
p2.save(new PrintWriter(tmp2));
p2.save(new PrintWriter(tmp2,ENCODING),ENCODING);
public void testSavePrintWriter() throws Exception { testLoad(); File tmp = File.createTempFile("test", ".architect"); if (deleteOnExit) { tmp.deleteOnExit(); } PrintWriter out = new PrintWriter(tmp); assertNotNull(out); project.save(out); SwingUIProject p2 = new SwingUIProject("test2"); p2.load(new FileInputStream(tmp)); File tmp2 = File.createTempFile("test2", ".architect"); if (deleteOnExit) { tmp2.deleteOnExit(); } p2.save(new PrintWriter(tmp2)); assertEquals(tmp.length(), tmp2.length()); // Quick test }
p2.save(new PrintWriter(tmp2));
p2.save(new PrintWriter(tmp2,ENCODING),ENCODING);
public void testSaveProgressMonitor() throws Exception { System.out.println("TestSwingUIProject.testSaveProgressMonitor()"); MockProgressMonitor mockProgressMonitor = new MockProgressMonitor(null, "Hello", "Hello again", 0, 100); File file = File.createTempFile("test", "architect"); project.setFile(file); project.save(mockProgressMonitor); SwingUIProject p2 = new SwingUIProject("test2"); p2.load(new FileInputStream(file)); File tmp2 = File.createTempFile("test2", ".architect"); if (deleteOnExit) { tmp2.deleteOnExit(); } p2.save(new PrintWriter(tmp2)); assertEquals(file.length(), tmp2.length()); // Quick test }
int tabNum = tabs.getSelectedIndex(); if (tabNum == VIEW_D_NUM || tabNum == VIEW_HAP_NUM){ exportMenuItems[0].setEnabled(true); exportMenuItems[1].setEnabled(true); }else if (tabNum == VIEW_TDT_NUM || tabNum == VIEW_CHECK_NUM){ exportMenuItems[0].setEnabled(true); exportMenuItems[1].setEnabled(false); }else{ exportMenuItems[0].setEnabled(false); exportMenuItems[1].setEnabled(false); }
if (tabs.getSelectedIndex() != -1){ int tabNum = tabs.getSelectedIndex(); if (tabNum == VIEW_D_NUM || tabNum == VIEW_HAP_NUM){ exportMenuItems[0].setEnabled(true); exportMenuItems[1].setEnabled(true); }else if (tabNum == VIEW_TDT_NUM || tabNum == VIEW_CHECK_NUM){ exportMenuItems[0].setEnabled(true); exportMenuItems[1].setEnabled(false); }else{ exportMenuItems[0].setEnabled(false); exportMenuItems[1].setEnabled(false); }
public void stateChanged(ChangeEvent e) { int tabNum = tabs.getSelectedIndex(); if (tabNum == VIEW_D_NUM || tabNum == VIEW_HAP_NUM){ exportMenuItems[0].setEnabled(true); exportMenuItems[1].setEnabled(true); }else if (tabNum == VIEW_TDT_NUM || tabNum == VIEW_CHECK_NUM){ exportMenuItems[0].setEnabled(true); exportMenuItems[1].setEnabled(false); }else{ exportMenuItems[0].setEnabled(false); exportMenuItems[1].setEnabled(false); } //if we've adjusted the haps display thresh we need to change the haps ass panel if (tabNum == VIEW_TDT_NUM){ JTabbedPane metaAssoc= (JTabbedPane)tabs.getComponentAt(tabNum); //this is the haps ass tab inside the assoc super-tab HaploAssocPanel htp = (HaploAssocPanel) metaAssoc.getComponent(1); if (htp.initialHaplotypeDisplayThreshold != Options.getHaplotypeDisplayThreshold()){ htp.makeTable(theData.getHaplotypes()); } } if (tabNum == VIEW_D_NUM){ keyMenu.setEnabled(true); }else{ keyMenu.setEnabled(false); } viewMenuItems[tabs.getSelectedIndex()].setSelected(true); if (checkPanel != null && checkPanel.changed){ //first store up the current blocks Vector currentBlocks = new Vector(); for (int blocks = 0; blocks < theData.blocks.size(); blocks++){ int thisBlock[] = (int[]) theData.blocks.elementAt(blocks); int thisBlockReal[] = new int[thisBlock.length]; for (int marker = 0; marker < thisBlock.length; marker++){ thisBlockReal[marker] = Chromosome.realIndex[thisBlock[marker]]; } currentBlocks.add(thisBlockReal); } window.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); JTable table = checkPanel.getTable(); boolean[] markerResults = new boolean[table.getRowCount()]; for (int i = 0; i < table.getRowCount(); i++){ markerResults[i] = ((Boolean)table.getValueAt(i,CheckDataPanel.STATUS_COL)).booleanValue(); } Chromosome.doFilter(markerResults); //after editing the filtered marker list, needs to be prodded into //resizing correctly dPrimeDisplay.computePreferredSize(); dPrimeDisplay.colorDPrime(); hapDisplay.theData = theData; if (currentBlockDef != BLOX_CUSTOM){ changeBlocks(currentBlockDef); }else{ //adjust the blocks Vector theBlocks = new Vector(); for (int x = 0; x < currentBlocks.size(); x++){ Vector goodies = new Vector(); int currentBlock[] = (int[])currentBlocks.elementAt(x); for (int marker = 0; marker < currentBlock.length; marker++){ for (int y = 0; y < Chromosome.realIndex.length; y++){ //we only keep markers from the input that are "good" from checkdata //we also realign the input file to the current "good" subset since input is //indexed of all possible markers in the dataset if (Chromosome.realIndex[y] == currentBlock[marker]){ goodies.add(new Integer(y)); } } } int thisBlock[] = new int[goodies.size()]; for (int marker = 0; marker < thisBlock.length; marker++){ thisBlock[marker] = ((Integer)goodies.elementAt(marker)).intValue(); } if (thisBlock.length > 1){ theBlocks.add(thisBlock); } } theData.guessBlocks(BLOX_CUSTOM, theBlocks); } if (tdtPanel != null){ tdtPanel.refreshTable(); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); checkPanel.changed=false; } if (hapDisplay != null && theData.blocksChanged){ setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); try{ hapDisplay.getHaps(); if(Options.getAssocTest() != ASSOC_NONE) { JTabbedPane metaAssoc= (JTabbedPane)tabs.getComponentAt(VIEW_TDT_NUM); //this is the haps ass tab inside the assoc super-tab HaploAssocPanel hasp = (HaploAssocPanel)metaAssoc.getComponent(1); hasp.makeTable(theData.getHaplotypes()); } }catch(HaploViewException hv){ JOptionPane.showMessageDialog(window, hv.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } hapScroller.setViewportView(hapDisplay); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); theData.blocksChanged = false; } }
if (tabNum == VIEW_TDT_NUM){ JTabbedPane metaAssoc= (JTabbedPane)tabs.getComponentAt(tabNum); HaploAssocPanel htp = (HaploAssocPanel) metaAssoc.getComponent(1); if (htp.initialHaplotypeDisplayThreshold != Options.getHaplotypeDisplayThreshold()){ htp.makeTable(theData.getHaplotypes());
if (tabNum == VIEW_TDT_NUM){ JTabbedPane metaAssoc= (JTabbedPane)tabs.getComponentAt(tabNum); HaploAssocPanel htp = (HaploAssocPanel) metaAssoc.getComponent(1); if (htp.initialHaplotypeDisplayThreshold != Options.getHaplotypeDisplayThreshold()){ htp.makeTable(theData.getHaplotypes()); } } if (tabNum == VIEW_D_NUM){ keyMenu.setEnabled(true); }else{ keyMenu.setEnabled(false); } viewMenuItems[tabs.getSelectedIndex()].setSelected(true); if (checkPanel != null && checkPanel.changed){ Vector currentBlocks = new Vector(); for (int blocks = 0; blocks < theData.blocks.size(); blocks++){ int thisBlock[] = (int[]) theData.blocks.elementAt(blocks); int thisBlockReal[] = new int[thisBlock.length]; for (int marker = 0; marker < thisBlock.length; marker++){ thisBlockReal[marker] = Chromosome.realIndex[thisBlock[marker]]; } currentBlocks.add(thisBlockReal); } window.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); JTable table = checkPanel.getTable(); boolean[] markerResults = new boolean[table.getRowCount()]; for (int i = 0; i < table.getRowCount(); i++){ markerResults[i] = ((Boolean)table.getValueAt(i,CheckDataPanel.STATUS_COL)).booleanValue(); } Chromosome.doFilter(markerResults); dPrimeDisplay.computePreferredSize(); dPrimeDisplay.colorDPrime(); hapDisplay.theData = theData; if (currentBlockDef != BLOX_CUSTOM){ changeBlocks(currentBlockDef); }else{ Vector theBlocks = new Vector(); for (int x = 0; x < currentBlocks.size(); x++){ Vector goodies = new Vector(); int currentBlock[] = (int[])currentBlocks.elementAt(x); for (int marker = 0; marker < currentBlock.length; marker++){ for (int y = 0; y < Chromosome.realIndex.length; y++){ if (Chromosome.realIndex[y] == currentBlock[marker]){ goodies.add(new Integer(y)); } } } int thisBlock[] = new int[goodies.size()]; for (int marker = 0; marker < thisBlock.length; marker++){ thisBlock[marker] = ((Integer)goodies.elementAt(marker)).intValue(); } if (thisBlock.length > 1){ theBlocks.add(thisBlock); } } theData.guessBlocks(BLOX_CUSTOM, theBlocks); } if (tdtPanel != null){ tdtPanel.refreshTable(); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); checkPanel.changed=false; } if (hapDisplay != null && theData.blocksChanged){ setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); try{ hapDisplay.getHaps(); if(Options.getAssocTest() != ASSOC_NONE) { JTabbedPane metaAssoc= (JTabbedPane)tabs.getComponentAt(VIEW_TDT_NUM); HaploAssocPanel hasp = (HaploAssocPanel)metaAssoc.getComponent(1); hasp.makeTable(theData.getHaplotypes()); } }catch(HaploViewException hv){ JOptionPane.showMessageDialog(window, hv.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } hapScroller.setViewportView(hapDisplay); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); theData.blocksChanged = false;
public void stateChanged(ChangeEvent e) { int tabNum = tabs.getSelectedIndex(); if (tabNum == VIEW_D_NUM || tabNum == VIEW_HAP_NUM){ exportMenuItems[0].setEnabled(true); exportMenuItems[1].setEnabled(true); }else if (tabNum == VIEW_TDT_NUM || tabNum == VIEW_CHECK_NUM){ exportMenuItems[0].setEnabled(true); exportMenuItems[1].setEnabled(false); }else{ exportMenuItems[0].setEnabled(false); exportMenuItems[1].setEnabled(false); } //if we've adjusted the haps display thresh we need to change the haps ass panel if (tabNum == VIEW_TDT_NUM){ JTabbedPane metaAssoc= (JTabbedPane)tabs.getComponentAt(tabNum); //this is the haps ass tab inside the assoc super-tab HaploAssocPanel htp = (HaploAssocPanel) metaAssoc.getComponent(1); if (htp.initialHaplotypeDisplayThreshold != Options.getHaplotypeDisplayThreshold()){ htp.makeTable(theData.getHaplotypes()); } } if (tabNum == VIEW_D_NUM){ keyMenu.setEnabled(true); }else{ keyMenu.setEnabled(false); } viewMenuItems[tabs.getSelectedIndex()].setSelected(true); if (checkPanel != null && checkPanel.changed){ //first store up the current blocks Vector currentBlocks = new Vector(); for (int blocks = 0; blocks < theData.blocks.size(); blocks++){ int thisBlock[] = (int[]) theData.blocks.elementAt(blocks); int thisBlockReal[] = new int[thisBlock.length]; for (int marker = 0; marker < thisBlock.length; marker++){ thisBlockReal[marker] = Chromosome.realIndex[thisBlock[marker]]; } currentBlocks.add(thisBlockReal); } window.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); JTable table = checkPanel.getTable(); boolean[] markerResults = new boolean[table.getRowCount()]; for (int i = 0; i < table.getRowCount(); i++){ markerResults[i] = ((Boolean)table.getValueAt(i,CheckDataPanel.STATUS_COL)).booleanValue(); } Chromosome.doFilter(markerResults); //after editing the filtered marker list, needs to be prodded into //resizing correctly dPrimeDisplay.computePreferredSize(); dPrimeDisplay.colorDPrime(); hapDisplay.theData = theData; if (currentBlockDef != BLOX_CUSTOM){ changeBlocks(currentBlockDef); }else{ //adjust the blocks Vector theBlocks = new Vector(); for (int x = 0; x < currentBlocks.size(); x++){ Vector goodies = new Vector(); int currentBlock[] = (int[])currentBlocks.elementAt(x); for (int marker = 0; marker < currentBlock.length; marker++){ for (int y = 0; y < Chromosome.realIndex.length; y++){ //we only keep markers from the input that are "good" from checkdata //we also realign the input file to the current "good" subset since input is //indexed of all possible markers in the dataset if (Chromosome.realIndex[y] == currentBlock[marker]){ goodies.add(new Integer(y)); } } } int thisBlock[] = new int[goodies.size()]; for (int marker = 0; marker < thisBlock.length; marker++){ thisBlock[marker] = ((Integer)goodies.elementAt(marker)).intValue(); } if (thisBlock.length > 1){ theBlocks.add(thisBlock); } } theData.guessBlocks(BLOX_CUSTOM, theBlocks); } if (tdtPanel != null){ tdtPanel.refreshTable(); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); checkPanel.changed=false; } if (hapDisplay != null && theData.blocksChanged){ setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); try{ hapDisplay.getHaps(); if(Options.getAssocTest() != ASSOC_NONE) { JTabbedPane metaAssoc= (JTabbedPane)tabs.getComponentAt(VIEW_TDT_NUM); //this is the haps ass tab inside the assoc super-tab HaploAssocPanel hasp = (HaploAssocPanel)metaAssoc.getComponent(1); hasp.makeTable(theData.getHaplotypes()); } }catch(HaploViewException hv){ JOptionPane.showMessageDialog(window, hv.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } hapScroller.setViewportView(hapDisplay); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); theData.blocksChanged = false; } }
if (tabNum == VIEW_D_NUM){ keyMenu.setEnabled(true); }else{ keyMenu.setEnabled(false); } viewMenuItems[tabs.getSelectedIndex()].setSelected(true); if (checkPanel != null && checkPanel.changed){ Vector currentBlocks = new Vector(); for (int blocks = 0; blocks < theData.blocks.size(); blocks++){ int thisBlock[] = (int[]) theData.blocks.elementAt(blocks); int thisBlockReal[] = new int[thisBlock.length]; for (int marker = 0; marker < thisBlock.length; marker++){ thisBlockReal[marker] = Chromosome.realIndex[thisBlock[marker]]; } currentBlocks.add(thisBlockReal); } window.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); JTable table = checkPanel.getTable(); boolean[] markerResults = new boolean[table.getRowCount()]; for (int i = 0; i < table.getRowCount(); i++){ markerResults[i] = ((Boolean)table.getValueAt(i,CheckDataPanel.STATUS_COL)).booleanValue(); } Chromosome.doFilter(markerResults); dPrimeDisplay.computePreferredSize(); dPrimeDisplay.colorDPrime(); hapDisplay.theData = theData; if (currentBlockDef != BLOX_CUSTOM){ changeBlocks(currentBlockDef); }else{ Vector theBlocks = new Vector(); for (int x = 0; x < currentBlocks.size(); x++){ Vector goodies = new Vector(); int currentBlock[] = (int[])currentBlocks.elementAt(x); for (int marker = 0; marker < currentBlock.length; marker++){ for (int y = 0; y < Chromosome.realIndex.length; y++){ if (Chromosome.realIndex[y] == currentBlock[marker]){ goodies.add(new Integer(y)); } } } int thisBlock[] = new int[goodies.size()]; for (int marker = 0; marker < thisBlock.length; marker++){ thisBlock[marker] = ((Integer)goodies.elementAt(marker)).intValue(); } if (thisBlock.length > 1){ theBlocks.add(thisBlock); } } theData.guessBlocks(BLOX_CUSTOM, theBlocks); } if (tdtPanel != null){ tdtPanel.refreshTable(); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); checkPanel.changed=false; } if (hapDisplay != null && theData.blocksChanged){ setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); try{ hapDisplay.getHaps(); if(Options.getAssocTest() != ASSOC_NONE) { JTabbedPane metaAssoc= (JTabbedPane)tabs.getComponentAt(VIEW_TDT_NUM); HaploAssocPanel hasp = (HaploAssocPanel)metaAssoc.getComponent(1); hasp.makeTable(theData.getHaplotypes()); } }catch(HaploViewException hv){ JOptionPane.showMessageDialog(window, hv.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } hapScroller.setViewportView(hapDisplay); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); theData.blocksChanged = false; }
public void stateChanged(ChangeEvent e) { int tabNum = tabs.getSelectedIndex(); if (tabNum == VIEW_D_NUM || tabNum == VIEW_HAP_NUM){ exportMenuItems[0].setEnabled(true); exportMenuItems[1].setEnabled(true); }else if (tabNum == VIEW_TDT_NUM || tabNum == VIEW_CHECK_NUM){ exportMenuItems[0].setEnabled(true); exportMenuItems[1].setEnabled(false); }else{ exportMenuItems[0].setEnabled(false); exportMenuItems[1].setEnabled(false); } //if we've adjusted the haps display thresh we need to change the haps ass panel if (tabNum == VIEW_TDT_NUM){ JTabbedPane metaAssoc= (JTabbedPane)tabs.getComponentAt(tabNum); //this is the haps ass tab inside the assoc super-tab HaploAssocPanel htp = (HaploAssocPanel) metaAssoc.getComponent(1); if (htp.initialHaplotypeDisplayThreshold != Options.getHaplotypeDisplayThreshold()){ htp.makeTable(theData.getHaplotypes()); } } if (tabNum == VIEW_D_NUM){ keyMenu.setEnabled(true); }else{ keyMenu.setEnabled(false); } viewMenuItems[tabs.getSelectedIndex()].setSelected(true); if (checkPanel != null && checkPanel.changed){ //first store up the current blocks Vector currentBlocks = new Vector(); for (int blocks = 0; blocks < theData.blocks.size(); blocks++){ int thisBlock[] = (int[]) theData.blocks.elementAt(blocks); int thisBlockReal[] = new int[thisBlock.length]; for (int marker = 0; marker < thisBlock.length; marker++){ thisBlockReal[marker] = Chromosome.realIndex[thisBlock[marker]]; } currentBlocks.add(thisBlockReal); } window.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); JTable table = checkPanel.getTable(); boolean[] markerResults = new boolean[table.getRowCount()]; for (int i = 0; i < table.getRowCount(); i++){ markerResults[i] = ((Boolean)table.getValueAt(i,CheckDataPanel.STATUS_COL)).booleanValue(); } Chromosome.doFilter(markerResults); //after editing the filtered marker list, needs to be prodded into //resizing correctly dPrimeDisplay.computePreferredSize(); dPrimeDisplay.colorDPrime(); hapDisplay.theData = theData; if (currentBlockDef != BLOX_CUSTOM){ changeBlocks(currentBlockDef); }else{ //adjust the blocks Vector theBlocks = new Vector(); for (int x = 0; x < currentBlocks.size(); x++){ Vector goodies = new Vector(); int currentBlock[] = (int[])currentBlocks.elementAt(x); for (int marker = 0; marker < currentBlock.length; marker++){ for (int y = 0; y < Chromosome.realIndex.length; y++){ //we only keep markers from the input that are "good" from checkdata //we also realign the input file to the current "good" subset since input is //indexed of all possible markers in the dataset if (Chromosome.realIndex[y] == currentBlock[marker]){ goodies.add(new Integer(y)); } } } int thisBlock[] = new int[goodies.size()]; for (int marker = 0; marker < thisBlock.length; marker++){ thisBlock[marker] = ((Integer)goodies.elementAt(marker)).intValue(); } if (thisBlock.length > 1){ theBlocks.add(thisBlock); } } theData.guessBlocks(BLOX_CUSTOM, theBlocks); } if (tdtPanel != null){ tdtPanel.refreshTable(); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); checkPanel.changed=false; } if (hapDisplay != null && theData.blocksChanged){ setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); try{ hapDisplay.getHaps(); if(Options.getAssocTest() != ASSOC_NONE) { JTabbedPane metaAssoc= (JTabbedPane)tabs.getComponentAt(VIEW_TDT_NUM); //this is the haps ass tab inside the assoc super-tab HaploAssocPanel hasp = (HaploAssocPanel)metaAssoc.getComponent(1); hasp.makeTable(theData.getHaplotypes()); } }catch(HaploViewException hv){ JOptionPane.showMessageDialog(window, hv.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } hapScroller.setViewportView(hapDisplay); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); theData.blocksChanged = false; } }
Options.setLDColorScheme(Integer.valueOf(command.substring(5)).intValue()+1);
Options.setLDColorScheme(Integer.valueOf(command.substring(5)).intValue());
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(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); /*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")){ Options.setLDColorScheme(Integer.valueOf(command.substring(5)).intValue()+1); dPrimeDisplay.colorDPrime(); changeKey(); //exporting clauses }else if (command.equals(EXPORT_PNG)){ export(tabs.getSelectedIndex(), PNG_MODE, 0, Chromosome.getSize()); }else if (command.equals(EXPORT_TEXT)){ export(tabs.getSelectedIndex(), TXT_MODE, 0, Chromosome.getSize()); }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("Tutorial")){ showHelp(); } else if (command.equals("Quit")){ quit(); } else { for (int i = 0; i < viewItems.length; i++) { if (command.equals(viewItems[i])) tabs.setSelectedIndex(i); } } }
if (dPrimeDisplay != null){ dPrimeDisplay.setVisible(false); dPrimeDisplay = null; } if (hapDisplay != null){ hapDisplay.setVisible(false); hapDisplay = null; } if (tdtPanel != null){ tdtPanel.setVisible(false); tdtPanel = null;
if (tabs != null){ tabs.removeAll();
public void clearDisplays() { if (dPrimeDisplay != null){ dPrimeDisplay.setVisible(false); dPrimeDisplay = null; } if (hapDisplay != null){ hapDisplay.setVisible(false); hapDisplay = null; } if (tdtPanel != null){ tdtPanel.setVisible(false); tdtPanel = null; } }
Options.setShowGBrowse(false);
public static void main(String[] args) { //set defaults Options.setMissingThreshold(1.0); Options.setSpacingThreshold(0.0); Options.setAssocTest(ASSOC_NONE); Options.setHaplotypeDisplayThreshold(1); Options.setMaxDistance(500); Options.setLDColorScheme(STD_SCHEME); //this parses the command line arguments. if nogui mode is specified, //then haploText will execute whatever the user specified HaploText argParser = new HaploText(args); //if nogui is specified, then HaploText has already executed everything, and let Main() return //otherwise, we want to actually load and run the gui if(!argParser.isNogui()) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { } //System.setProperty("swing.disableFileChooserSpeedFix", "true"); window = new HaploView(); //setup view object window.setTitle(TITLE_STRING); window.setSize(800,600); //center the window on the screen Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); window.setLocation((screen.width - window.getWidth()) / 2, (screen.height - window.getHeight()) / 2); window.setVisible(true); //parse command line stuff for input files or prompt data dialog String[] inputArray = new String[2]; if (argParser.getHapsFileName() != null){ inputArray[0] = argParser.getHapsFileName(); inputArray[1] = argParser.getInfoFileName(); window.readGenotypes(inputArray, HAPS); }else if (argParser.getPedFileName() != null){ inputArray[0] = argParser.getPedFileName(); inputArray[1] = argParser.getInfoFileName(); window.readGenotypes(inputArray, PED); }else if (argParser.getHapmapFileName() != null){ inputArray[0] = argParser.getHapmapFileName(); inputArray[1] = ""; window.readGenotypes(inputArray, HMP); }else{ ReadDataDialog readDialog = new ReadDataDialog("Welcome to HaploView", window); readDialog.pack(); readDialog.setVisible(true); } } }
getBody().run(context, output);
invokeBody(output);
public void doTag(final XMLOutput output) throws Exception { log.debug("doTag(..):" + name); Goal goal = getProject().getGoal( getName(), true ); goal.setDescription( this.description ); addPrereqs( goal ); Action action = new DefaultAction() { public void performAction() throws Exception { log.debug("Running action of target: " + getName() ); getBody().run(context, output); } }; goal.setAction( action ); }
getBody().run(context, output);
invokeBody(output);
public void performAction() throws Exception { log.debug("Running action of target: " + getName() ); getBody().run(context, output); }
getBody().run(context, output);
invokeBody(output);
public void doTag(XMLOutput output) throws Exception { // run the body first to configure the task via nested getBody().run(context, output); // output the fileScanner if ( var == null ) { throw new MissingAttributeException( "var" ); } context.setVariable( var, fileScanner ); }
columnHighlight.add(ci[i], null);
public void dbChildrenInserted(SQLObjectEvent e) { int ci[] = e.getChangedIndices(); for (int i = 0; i < ci.length; i++) { columnSelection.add(ci[i], Boolean.FALSE); } try { ArchitectUtils.listenToHierarchy(this, e.getChildren()); } catch (ArchitectException ex) { logger.error("Caught exception while listening to added children", ex); } firePropertyChange("model.children", null, null); revalidate(); }
columnSelection.remove(ci[i]);
columnSelection.remove(ci[i]); columnHighlight.remove(ci[i]);
public void dbChildrenRemoved(SQLObjectEvent e) { if (e.getSource() == this.model.getColumnsFolder()) { int ci[] = e.getChangedIndices(); for (int i = 0; i < ci.length; i++) { columnSelection.remove(ci[i]); } if (columnSelection.size() > 0) { selectNone(); columnSelection.set(Math.min(ci[0], columnSelection.size()-1), Boolean.TRUE); } } try { ArchitectUtils.unlistenToHierarchy(this, e.getChildren()); if (columnSelection.size() != this.model.getColumns().size()) { logger.error("Selection list and children are out of sync: selection="+columnSelection+"; children="+this.model.getColumns()); } } catch (ArchitectException ex) { logger.error("Couldn't remove children", ex); JOptionPane.showMessageDialog(this, "Couldn't delete column: "+ex.getMessage()); } firePropertyChange("model.children", null, null); revalidate(); }
logger.error("Selection list and children are out of sync: selection="+columnSelection+"; children="+this.model.getColumns());
logger.error("Repairing out-of-sync selection list: selection="+columnSelection+"; children="+this.model.getColumns()); columnSelection = new ArrayList(); for (int j = 0; j < model.getColumns().size(); j++) { columnSelection.add(Boolean.FALSE); } } if (columnHighlight.size() != this.model.getColumns().size()) { logger.error("Repairing out-of-sync highlight list: highlights="+columnHighlight+"; children="+this.model.getColumns()); columnHighlight = new ArrayList(); for (int j = 0; j < model.getColumns().size(); j++) { columnHighlight.add(null); }
public void dbChildrenRemoved(SQLObjectEvent e) { if (e.getSource() == this.model.getColumnsFolder()) { int ci[] = e.getChangedIndices(); for (int i = 0; i < ci.length; i++) { columnSelection.remove(ci[i]); } if (columnSelection.size() > 0) { selectNone(); columnSelection.set(Math.min(ci[0], columnSelection.size()-1), Boolean.TRUE); } } try { ArchitectUtils.unlistenToHierarchy(this, e.getChildren()); if (columnSelection.size() != this.model.getColumns().size()) { logger.error("Selection list and children are out of sync: selection="+columnSelection+"; children="+this.model.getColumns()); } } catch (ArchitectException ex) { logger.error("Couldn't remove children", ex); JOptionPane.showMessageDialog(this, "Couldn't delete column: "+ex.getMessage()); } firePropertyChange("model.children", null, null); revalidate(); }
columnHighlight = new ArrayList(numCols); for (int i = 0; i < numCols; i++) { columnHighlight.add(null); }
public void dbStructureChanged(SQLObjectEvent e) { if (e.getSource() == model.getColumnsFolder()) { int numCols = e.getChildren().length; columnSelection = new ArrayList(numCols); for (int i = 0; i < numCols; i++) { columnSelection.add(Boolean.FALSE); } firePropertyChange("model.children", null, null); revalidate(); } }
TablePane t3 = (TablePane)it.next(); logger.debug("(" + tp.getModel().getTableName() + ") zoomed selected table point: " + tp.getLocationOnScreen()); logger.debug("(" + t3.getModel().getTableName() + ") zoomed iterator table point: " + t3.getLocationOnScreen());
TablePane t3 = (TablePane) it.next(); if (logger.isDebugEnabled()) { logger.debug("(" + tp.getModel().getTableName() + ") zoomed selected table point: " + tp.getLocationOnScreen()); logger.debug("(" + t3.getModel().getTableName() + ") zoomed iterator table point: " + t3.getLocationOnScreen()); }
private void deSelectEverythingElse (MouseEvent evt) { TablePane tp = (TablePane) evt.getSource(); Iterator it = getPlayPen().getSelectedTables().iterator(); while (it.hasNext()) { TablePane t3 = (TablePane)it.next(); logger.debug("(" + tp.getModel().getTableName() + ") zoomed selected table point: " + tp.getLocationOnScreen()); logger.debug("(" + t3.getModel().getTableName() + ") zoomed iterator table point: " + t3.getLocationOnScreen()); if (!tp.getLocationOnScreen().equals(t3.getLocationOnScreen())) { // equals operation might not work so good here // unselect logger.debug("found matching table!"); t3.setSelected(false); t3.selectNone(); } } }
columnHighlight = new ArrayList(m.getColumns().size()); for (int i = 0; i < m.getColumns().size(); i++) { columnHighlight.add(null); }
public void setModel(SQLTable m) { SQLTable old = model; if (old != null) { try { ArchitectUtils.listenToHierarchy(this, old); } catch (ArchitectException e) { logger.error("Caught exception while unlistening to old model", e); } } if (m == null) { throw new IllegalArgumentException("model may not be null"); } else { model = m; } try { columnSelection = new ArrayList(m.getColumns().size()); for (int i = 0; i < m.getColumns().size(); i++) { columnSelection.add(Boolean.FALSE); } } catch (ArchitectException e) { logger.error("Error getting children on new model", e); } try { ArchitectUtils.listenToHierarchy(this, model); } catch (ArchitectException e) { logger.error("Caught exception while listening to new model", e); } setName("TablePane: "+model.getShortDisplayName()); firePropertyChange("model", old, model); }
invokeBody(output);
XMLOutput actualOutput = tag.getStylesheetOutput(); if (actualOutput == null) { actualOutput = output; } invokeBody(actualOutput);
protected Action createAction(final StylesheetTag tag, final XMLOutput output) { return new Action() { public void run(Node node) throws Exception { // store the context for use by applyTemplates tag tag.setXPathSource( node ); xpathSource = node; if (log.isDebugEnabled()) { log.debug( "Firing template body for match: " + match + " and node: " + node ); } invokeBody(output); } }; }
invokeBody(output);
XMLOutput actualOutput = tag.getStylesheetOutput(); if (actualOutput == null) { actualOutput = output; } invokeBody(actualOutput);
public void run(Node node) throws Exception { // store the context for use by applyTemplates tag tag.setXPathSource( node ); xpathSource = node; if (log.isDebugEnabled()) { log.debug( "Firing template body for match: " + match + " and node: " + node ); } invokeBody(output); }
"-b <batchfile> batch mode. batchfile should contain a list of haps files\n" +
"-b <batchfile> batch mode. batchfile should contain a list of files either all genotype or alternating genotype/info\n" +
private void argHandler(String[] args){ //TODO: -specify values from HaplotypeDisplayController (min hap percentage etc) // -want to be able to output haps file from pedfile boolean nogui = false; String batchMode = ""; String hapsFileName = ""; String pedFileName = ""; String infoFileName = ""; boolean showCheck = false; boolean skipCheck = false; Vector ignoreMarkers = new Vector(); int outputType = -1; int maxDistance = -1; boolean quietMode = false; boolean outputDprime=false; for(int i =0; i < args.length; i++) { if(args[i].equals("-help") || args[i].equals("-h")) { System.out.println("HaploView command line options\n" + "-h, -help print this message\n" + "-n command line output only\n" + "-q quiet mode- doesnt print any warnings or information to screen\n" + "-p <pedfile> specify an input file in pedigree file format\n" + " pedfile specific options (nogui mode only): \n" + " --showcheck displays the results of the various pedigree integrity checks\n" + " --skipcheck skips the various pedfile checks\n" + //TODO: fix ignoremarkers //" --ignoremarkers <markers> ignores the specified markers.<markers> is a comma\n" + //" seperated list of markers. eg. 1,5,7,19,25\n" + "-ha <hapsfile> specify an input file in .haps format\n" + "-i <infofile> specify a marker info file\n" + "-b <batchfile> batch mode. batchfile should contain a list of haps files\n" + "--dprime outputs dprime to <inputfile>.DPRIME\n" + " note: --dprime defaults to no blocks output. use -o to also output blocks\n" + "-o <SFS,GAM,MJD,ALL> output type. SFS, 4 gamete, MJD output or all 3. default is SFS.\n" + "-m <distance> maximum comparison distance in kilobases (integer). default is 500"); System.exit(0); } else if(args[i].equals("-n")) { nogui = true; } else if(args[i].equals("-p")) { i++; if( i>=args.length || (args[i].charAt(0) == '-') || args[i].equals("showcheck") ){ System.out.println("-p requires a filename"); System.exit(1); } else{ if(!pedFileName.equals("")){ System.out.println("multiple -p arguments found. only last pedfile listed will be used"); } pedFileName = args[i]; } } else if (args[i].equals("--showcheck")){ showCheck = true; } else if (args[i].equals("--skipcheck")){ skipCheck = true; } /* else if (args[i].equals("--ignoremarkers")){ i++; if(i>=args.length || (args[i].charAt(0) == '-')){ System.out.println("--ignoremarkers requires a list of markers"); System.exit(1); } else { StringTokenizer str = new StringTokenizer(args[i],","); while(str.hasMoreTokens()) { ignoreMarkers.add(str.nextToken()); } } } */ else if(args[i].equals("-ha")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-ha requires a filename"); System.exit(1); } else{ if(!hapsFileName.equals("")){ System.out.println("multiple -ha arguments found. only last haps file listed will be used"); } hapsFileName = args[i]; } } else if(args[i].equals("-i")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-i requires a filename"); System.exit(1); } else{ if(!infoFileName.equals("")){ System.out.println("multiple -i arguments found. only last info file listed will be used"); } infoFileName = args[i]; } } else if(args[i].equals("-o")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(outputType != -1){ System.out.println("only one -o argument is allowed"); System.exit(1); } if(args[i].equals("SFS")){ outputType = 0; } else if(args[i].equals("GAM")){ outputType = 1; } else if(args[i].equals("MJD")){ outputType = 2; } else if(args[i].equals("ALL")) { outputType = 3; } } else { //defaults to SFS output outputType =0; i--; } } else if(args[i].equals("--dprime")) { outputDprime = true; } else if(args[i].equals("-m")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-m requires an integer argument"); System.exit(1); } else { if(maxDistance != -1){ System.out.println("only one -m argument allowed"); System.exit(1); } maxDistance = Integer.parseInt(args[i]); if(maxDistance<0){ System.out.println("-m argument must be a positive integer"); System.exit(1); } } } else if(args[i].equals("-b")) { //batch mode i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-b requires a filename"); System.exit(1); } else{ if(!batchMode.equals("")){ System.out.println("multiple -b arguments found. only last batch file listed will be used"); } batchMode = args[i]; } } else if(args[i].equals("-q")) { quietMode = true; } else { System.out.println("invalid parameter specified: " + args[i]); } } //mess with vars, set defaults, etc if( outputType == -1 && ( !pedFileName.equals("") || !hapsFileName.equals("") || !batchMode.equals("")) && !outputDprime ) { outputType = 0; if(nogui && !quietMode) { System.out.println("No output type specified. Default of SFS will be used"); } } if(showCheck && !nogui && !quietMode) { System.out.println("pedfile showcheck option only applies in nogui mode. ignored."); } if(skipCheck && !quietMode) { System.out.println("Skipping pedigree file check"); } if(maxDistance == -1){ maxDistance = 500; } //set the global variables arg_nogui = nogui; arg_hapsfile = hapsFileName; arg_infoFileName = infoFileName; arg_pedfile = pedFileName; arg_showCheck = showCheck; arg_skipCheck = skipCheck; arg_ignoreMarkers = ignoreMarkers; arg_output = outputType; arg_distance = maxDistance; arg_batchMode = batchMode; arg_quiet = quietMode; arg_dprime = outputDprime; }
PedFile ped; Vector pedFileStrings; BufferedReader reader; String line; boolean[] markerResultArray; ped = new PedFile(); pedFileStrings = new Vector(); reader = new BufferedReader(new FileReader(inputFile)); result = new Vector(); while((line = reader.readLine())!=null){ pedFileStrings.add(line); } ped.parseLinkage(pedFileStrings); if(!arg_skipCheck) { result = ped.check(); } markerResultArray = new boolean[ped.getNumMarkers()]; for (int i = 0; i < markerResultArray.length; i++){ if(this.arg_skipCheck) { markerResultArray[i] = true; } else if(((MarkerResult)result.get(i)).getRating() > 0) { markerResultArray[i] = true; } else { markerResultArray[i] = false; } }
private void processFile(String fileName,boolean fileType,String infoFileName){ try { int outputType; long maxDistance; long negMaxDistance; HaploData textData; File OutputFile; File inputFile; inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } maxDistance = this.arg_distance * 1000; negMaxDistance = -maxDistance; outputType = this.arg_output; textData = new HaploData(); Vector result = null; if(!fileType){ //read in haps file textData.prepareHapsInput(inputFile); } else { //read in ped file PedFile ped; Vector pedFileStrings; BufferedReader reader; String line; boolean[] markerResultArray; ped = new PedFile(); pedFileStrings = new Vector(); reader = new BufferedReader(new FileReader(inputFile)); result = new Vector(); while((line = reader.readLine())!=null){ pedFileStrings.add(line); } ped.parseLinkage(pedFileStrings); if(!arg_skipCheck) { result = ped.check(); } markerResultArray = new boolean[ped.getNumMarkers()]; for (int i = 0; i < markerResultArray.length; i++){ if(this.arg_skipCheck) { markerResultArray[i] = true; } else if(((MarkerResult)result.get(i)).getRating() > 0) { markerResultArray[i] = true; } else { markerResultArray[i] = false; } } /* if(this.arg_ignoreMarkers.size()>0) { for(int i=0;i<this.arg_ignoreMarkers.size();i++){ int index = Integer.parseInt((String)this.arg_ignoreMarkers.get(i)); if(index>0 && index<markerResultArray.length){ markerResultArray[index] = false; if(!this.arg_quiet) { System.out.println("Ignoring marker " + (index)); } } } }*/ textData.linkageToChrom(markerResultArray,ped,null); } String name = fileName; String baseName = fileName.substring(0,name.length()-5); if(!infoFileName.equals("")) { File infoFile = new File(infoFileName); if(infoFile.exists()) { textData.prepareMarkerInput(infoFile,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + infoFile.getName()); } textData.infoKnown = true; } else if(!this.arg_quiet) { System.out.println("info file " + infoFileName + " does not exist"); } } else { File maybeInfo = new File(baseName + ".info"); if (maybeInfo.exists()){ textData.prepareMarkerInput(maybeInfo,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + maybeInfo.getName()); } textData.infoKnown = true; } } if(this.arg_showCheck && result != null) { System.out.println("Data check results:\n" + "Name\t\tObsHET\tPredHET\tHWpval\t%Geno\tFamTrio\tMendErr"); for(int i=0;i<result.size();i++){ MarkerResult currentResult = (MarkerResult)result.get(i); System.out.println( Chromosome.getMarker(i).getName() +"\t"+ currentResult.getObsHet() +"\t"+ currentResult.getPredHet() +"\t"+ currentResult.getHWpvalue() +"\t"+ currentResult.getGenoPercent() +"\t"+ currentResult.getFamTrioNum() +"\t"+ currentResult.getMendErrNum()); } } if(outputType != -1){ textData.generateDPrimeTable(maxDistance); Haplotype[][] haplos; switch(outputType){ case 0: OutputFile = new File(fileName + ".SFSblocks"); break; case 1: OutputFile = new File(fileName + ".4GAMblocks"); break; case 2: OutputFile = new File(fileName + ".MJDblocks"); break; default: OutputFile = new File(fileName + ".SFSblocks"); break; } //this handles output type ALL if(outputType == 3) { OutputFile = new File(fileName + ".SFSblocks"); textData.guessBlocks(0); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".4GAMblocks"); textData.guessBlocks(1); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".MJDblocks"); textData.guessBlocks(2); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); }else{ textData.guessBlocks(outputType); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); } } if(this.arg_dprime) { OutputFile = new File(fileName + ".DPRIME"); if (textData.filteredDPrimeTable != null){ textData.saveDprimeToText(OutputFile); }else{ //this means that we're just writing dprime so we won't //keep the (potentially huge) dprime table in memory but instead //write out one line at a time forget FileWriter saveDprimeWriter = new FileWriter(OutputFile); if (textData.infoKnown){ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\tDist\n"); long dist; PairwiseLinkage linkageResult; for (int i = 0; i < Chromosome.getFilteredSize(); i++){ for (int j = 0; j < Chromosome.getFilteredSize(); j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); if (maxDistance > 0){ if ((dist > maxDistance || dist < negMaxDistance)){ continue; } } linkageResult = textData.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); if(linkageResult != null) { saveDprimeWriter.write(Chromosome.getFilteredMarker(i).getName() + "\t" + Chromosome.getFilteredMarker(j).getName() + "\t" + linkageResult.toString() + "\t" + dist + "\n"); } } } } }else{ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\n"); long dist; PairwiseLinkage linkageResult; for (int i = 0; i < Chromosome.getFilteredSize(); i++){ for (int j = 0; j < Chromosome.getFilteredSize(); j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); if (maxDistance > 0){ if ((dist > maxDistance || dist < negMaxDistance)){ continue; } } linkageResult = textData.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); if(linkageResult != null) { saveDprimeWriter.write((Chromosome.realIndex[i]+1) + "\t" + (Chromosome.realIndex[j]+1) + "\t" + linkageResult + "\n"); } } } } } saveDprimeWriter.close(); } } if(fileType){ //TDT.calcTrioTDT(textData.chromosomes); //TODO: Deal with this. why do we calc TDT? and make sure not to do it except when appropriate } } catch(IOException e){ System.err.println("An error has occured. This probably has to do with file input or output"); } catch(HaploViewException e){ System.err.println(e.getMessage()); } catch(PedFileException pfe) { System.err.println(pfe.getMessage()); } }
textData.linkageToChrom(markerResultArray,ped,null);
textData.linkageToChrom(inputFile, 3, arg_skipCheck);
private void processFile(String fileName,boolean fileType,String infoFileName){ try { int outputType; long maxDistance; long negMaxDistance; HaploData textData; File OutputFile; File inputFile; inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } maxDistance = this.arg_distance * 1000; negMaxDistance = -maxDistance; outputType = this.arg_output; textData = new HaploData(); Vector result = null; if(!fileType){ //read in haps file textData.prepareHapsInput(inputFile); } else { //read in ped file PedFile ped; Vector pedFileStrings; BufferedReader reader; String line; boolean[] markerResultArray; ped = new PedFile(); pedFileStrings = new Vector(); reader = new BufferedReader(new FileReader(inputFile)); result = new Vector(); while((line = reader.readLine())!=null){ pedFileStrings.add(line); } ped.parseLinkage(pedFileStrings); if(!arg_skipCheck) { result = ped.check(); } markerResultArray = new boolean[ped.getNumMarkers()]; for (int i = 0; i < markerResultArray.length; i++){ if(this.arg_skipCheck) { markerResultArray[i] = true; } else if(((MarkerResult)result.get(i)).getRating() > 0) { markerResultArray[i] = true; } else { markerResultArray[i] = false; } } /* if(this.arg_ignoreMarkers.size()>0) { for(int i=0;i<this.arg_ignoreMarkers.size();i++){ int index = Integer.parseInt((String)this.arg_ignoreMarkers.get(i)); if(index>0 && index<markerResultArray.length){ markerResultArray[index] = false; if(!this.arg_quiet) { System.out.println("Ignoring marker " + (index)); } } } }*/ textData.linkageToChrom(markerResultArray,ped,null); } String name = fileName; String baseName = fileName.substring(0,name.length()-5); if(!infoFileName.equals("")) { File infoFile = new File(infoFileName); if(infoFile.exists()) { textData.prepareMarkerInput(infoFile,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + infoFile.getName()); } textData.infoKnown = true; } else if(!this.arg_quiet) { System.out.println("info file " + infoFileName + " does not exist"); } } else { File maybeInfo = new File(baseName + ".info"); if (maybeInfo.exists()){ textData.prepareMarkerInput(maybeInfo,maxDistance,null); if(!arg_quiet){ System.out.println("Using marker file " + maybeInfo.getName()); } textData.infoKnown = true; } } if(this.arg_showCheck && result != null) { System.out.println("Data check results:\n" + "Name\t\tObsHET\tPredHET\tHWpval\t%Geno\tFamTrio\tMendErr"); for(int i=0;i<result.size();i++){ MarkerResult currentResult = (MarkerResult)result.get(i); System.out.println( Chromosome.getMarker(i).getName() +"\t"+ currentResult.getObsHet() +"\t"+ currentResult.getPredHet() +"\t"+ currentResult.getHWpvalue() +"\t"+ currentResult.getGenoPercent() +"\t"+ currentResult.getFamTrioNum() +"\t"+ currentResult.getMendErrNum()); } } if(outputType != -1){ textData.generateDPrimeTable(maxDistance); Haplotype[][] haplos; switch(outputType){ case 0: OutputFile = new File(fileName + ".SFSblocks"); break; case 1: OutputFile = new File(fileName + ".4GAMblocks"); break; case 2: OutputFile = new File(fileName + ".MJDblocks"); break; default: OutputFile = new File(fileName + ".SFSblocks"); break; } //this handles output type ALL if(outputType == 3) { OutputFile = new File(fileName + ".SFSblocks"); textData.guessBlocks(0); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".4GAMblocks"); textData.guessBlocks(1); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".MJDblocks"); textData.guessBlocks(2); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); }else{ textData.guessBlocks(outputType); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); } } if(this.arg_dprime) { OutputFile = new File(fileName + ".DPRIME"); if (textData.filteredDPrimeTable != null){ textData.saveDprimeToText(OutputFile); }else{ //this means that we're just writing dprime so we won't //keep the (potentially huge) dprime table in memory but instead //write out one line at a time forget FileWriter saveDprimeWriter = new FileWriter(OutputFile); if (textData.infoKnown){ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\tDist\n"); long dist; PairwiseLinkage linkageResult; for (int i = 0; i < Chromosome.getFilteredSize(); i++){ for (int j = 0; j < Chromosome.getFilteredSize(); j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); if (maxDistance > 0){ if ((dist > maxDistance || dist < negMaxDistance)){ continue; } } linkageResult = textData.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); if(linkageResult != null) { saveDprimeWriter.write(Chromosome.getFilteredMarker(i).getName() + "\t" + Chromosome.getFilteredMarker(j).getName() + "\t" + linkageResult.toString() + "\t" + dist + "\n"); } } } } }else{ saveDprimeWriter.write("L1\tL2\tD'\tLOD\tr^2\tCIlow\tCIhi\n"); long dist; PairwiseLinkage linkageResult; for (int i = 0; i < Chromosome.getFilteredSize(); i++){ for (int j = 0; j < Chromosome.getFilteredSize(); j++){ //many "slots" in table aren't filled in because it is a 1/2 matrix if (i < j){ dist = (Chromosome.getFilteredMarker(j)).getPosition() - (Chromosome.getFilteredMarker(i)).getPosition(); if (maxDistance > 0){ if ((dist > maxDistance || dist < negMaxDistance)){ continue; } } linkageResult = textData.computeDPrime(Chromosome.realIndex[i],Chromosome.realIndex[j]); if(linkageResult != null) { saveDprimeWriter.write((Chromosome.realIndex[i]+1) + "\t" + (Chromosome.realIndex[j]+1) + "\t" + linkageResult + "\n"); } } } } } saveDprimeWriter.close(); } } if(fileType){ //TDT.calcTrioTDT(textData.chromosomes); //TODO: Deal with this. why do we calc TDT? and make sure not to do it except when appropriate } } catch(IOException e){ System.err.println("An error has occured. This probably has to do with file input or output"); } catch(HaploViewException e){ System.err.println(e.getMessage()); } catch(PedFileException pfe) { System.err.println(pfe.getMessage()); } }
derivedTable = SQLTable.getDerivedInstance(table1, table1.getParentDatabase());
derivedTable = SQLTable.getDerivedInstance(table1, pp);
public void testGetDerivedInstance() throws Exception { SQLTable derivedTable; SQLTable table1; assertNotNull(table1 = db.getTableByName("REGRESSION_TEST1")); derivedTable = SQLTable.getDerivedInstance(table1, table1.getParentDatabase()); TreeMap derivedPropertyMap = new TreeMap(BeanUtils.describe(derivedTable)); TreeMap table1PropertyMap = new TreeMap(BeanUtils.describe(table1)); derivedPropertyMap.remove("parent"); derivedPropertyMap.remove("schemaName"); derivedPropertyMap.remove("schema"); derivedPropertyMap.remove("shortDisplayName"); table1PropertyMap.remove("parent"); table1PropertyMap.remove("schemaName"); table1PropertyMap.remove("schema"); table1PropertyMap.remove("shortDisplayName"); assertEquals("Derived table not properly copied", derivedPropertyMap.toString(), table1PropertyMap.toString()); }
table1PropertyMap.remove("parentDatabase");
public void testGetDerivedInstance() throws Exception { SQLTable derivedTable; SQLTable table1; assertNotNull(table1 = db.getTableByName("REGRESSION_TEST1")); derivedTable = SQLTable.getDerivedInstance(table1, table1.getParentDatabase()); TreeMap derivedPropertyMap = new TreeMap(BeanUtils.describe(derivedTable)); TreeMap table1PropertyMap = new TreeMap(BeanUtils.describe(table1)); derivedPropertyMap.remove("parent"); derivedPropertyMap.remove("schemaName"); derivedPropertyMap.remove("schema"); derivedPropertyMap.remove("shortDisplayName"); table1PropertyMap.remove("parent"); table1PropertyMap.remove("schemaName"); table1PropertyMap.remove("schema"); table1PropertyMap.remove("shortDisplayName"); assertEquals("Derived table not properly copied", derivedPropertyMap.toString(), table1PropertyMap.toString()); }
Haplotype[][] orderedHaplos; Haplotype[][] crossedHaplos;
private void processFile(String fileName, int fileType, String infoFileName){ try { HaploData textData; File OutputFile; File inputFile; if(!quietMode && fileName != null){ System.out.println("Using data file " + fileName); } inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } textData = new HaploData(); Vector result = null; if(fileType == HAPS){ //read in haps file textData.prepareHapsInput(inputFile); } else if (fileType == PED) { //read in ped file /* if(this.arg_ignoreMarkers.size()>0) { for(int i=0;i<this.arg_ignoreMarkers.size();i++){ int index = Integer.parseInt((String)this.arg_ignoreMarkers.get(i)); if(index>0 && index<markerResultArray.length){ markerResultArray[index] = false; if(!this.quietMode) { System.out.println("Ignoring marker " + (index)); } } } }*/ result = textData.linkageToChrom(inputFile, 3, skipCheck); if(textData.getPedFile().isBogusParents()) { System.out.println("Error: One or more individuals in the file reference non-existent parents.\nThese references have been ignored."); } }else{ //read in hapmapfile result = textData.linkageToChrom(inputFile,4,skipCheck); } File infoFile = null; if (infoFileName != null){ infoFile = new File(infoFileName); } if (result != null){ textData.prepareMarkerInput(infoFile,textData.getPedFile().getHMInfo()); }else{ textData.prepareMarkerInput(infoFile,null); } if(!quietMode && infoFile != null){ System.out.println("Using marker file " + infoFile.getName()); } if(outputCheck && result != null){ CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(validateOutputFile(fileName + ".CHECK")); } Vector cust = new Vector(); if(outputType != -1){ textData.generateDPrimeTable(); Haplotype[][] haplos; switch(outputType){ case BLOX_GABRIEL: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; case BLOX_4GAM: OutputFile = validateOutputFile(fileName + ".4GAMblocks"); break; case BLOX_SPINE: OutputFile = validateOutputFile(fileName + ".SPINEblocks"); break; case BLOX_CUSTOM: OutputFile = validateOutputFile(fileName + ".CUSTblocks"); //read in the blocks file File blocksFile = new File(blockFileName); cust = textData.readBlocks(blocksFile); break; default: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; } //this handles output type ALL Haplotype[][] orderedHaplos; Haplotype[][] crossedHaplos; if(outputType == BLOX_ALL) { OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); textData.guessBlocks(BLOX_GABRIEL); haplos = textData.generateHaplotypes(textData.blocks, false); orderedHaplos = orderHaps(haplos); crossedHaplos = textData.generateCrossovers(orderedHaplos); textData.saveHapsToText(crossedHaplos, textData.getMultiDprime(), OutputFile); OutputFile = validateOutputFile(fileName + ".4GAMblocks"); textData.guessBlocks(BLOX_4GAM); haplos = textData.generateHaplotypes(textData.blocks, false); orderedHaplos = orderHaps(haplos); crossedHaplos = textData.generateCrossovers(orderedHaplos); textData.saveHapsToText(crossedHaplos, textData.getMultiDprime(), OutputFile); OutputFile = validateOutputFile(fileName + ".SPINEblocks"); textData.guessBlocks(BLOX_SPINE); haplos = textData.generateHaplotypes(textData.blocks, false); orderedHaplos = orderHaps(haplos); crossedHaplos = textData.generateCrossovers(orderedHaplos); textData.saveHapsToText(crossedHaplos, textData.getMultiDprime(), OutputFile); }else{ textData.guessBlocks(outputType, cust); haplos = textData.generateHaplotypes(textData.blocks, false); orderedHaplos = orderHaps(haplos); crossedHaplos = textData.generateCrossovers(orderedHaplos); textData.saveHapsToText(crossedHaplos, textData.getMultiDprime(), OutputFile); } //todo: should this output hap assoc for each block type if they do more than one? if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC) { //Haplotype[][] orderedHaps = orderHaps(textData.getHaplotypes()); HaploData.saveHapAssocToText(orderedHaplos, fileName + ".HAPASSOC"); } } if(outputDprime) { OutputFile = validateOutputFile(fileName + ".LD"); if (textData.dpTable != null){ textData.saveDprimeToText(OutputFile, TABLE_TYPE, 0, Chromosome.getSize()); }else{ textData.saveDprimeToText(OutputFile, LIVE_TYPE, 0, Chromosome.getSize()); } } if (outputPNG || outputCompressedPNG){ OutputFile = validateOutputFile(fileName + ".LD.PNG"); if (textData.dpTable == null){ textData.generateDPrimeTable(); textData.guessBlocks(BLOX_CUSTOM, new Vector()); } if (trackFileName != null){ textData.readAnalysisTrack(new File(trackFileName)); } DPrimeDisplay dpd = new DPrimeDisplay(textData); BufferedImage i = dpd.export(0,Chromosome.getSize(),outputCompressedPNG); try{ Jimi.putImage("image/png", i, OutputFile.getName()); }catch(JimiException je){ System.out.println(je.getMessage()); } } if(Options.getAssocTest() == ASSOC_TRIO){ Vector tdtResults = TDT.calcTrioTDT(textData.getPedFile()); HaploData.saveMarkerAssocToText(tdtResults, fileName + ".ASSOC"); } else if(Options.getAssocTest() == ASSOC_CC) { Vector ccResults = TDT.calcCCTDT(textData.getPedFile()); HaploData.saveMarkerAssocToText(ccResults, fileName + ".ASSOC"); } } catch(IOException e){ System.err.println("An error has occured. This probably has to do with file input or output"); } catch(HaploViewException e){ System.err.println(e.getMessage()); } catch(PedFileException pfe) { System.err.println(pfe.getMessage()); } }
orderedHaplos = orderHaps(haplos); crossedHaplos = textData.generateCrossovers(orderedHaplos); textData.saveHapsToText(crossedHaplos, textData.getMultiDprime(), OutputFile);
textData.pickTags(haplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(haplos), OutputFile);
private void processFile(String fileName, int fileType, String infoFileName){ try { HaploData textData; File OutputFile; File inputFile; if(!quietMode && fileName != null){ System.out.println("Using data file " + fileName); } inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } textData = new HaploData(); Vector result = null; if(fileType == HAPS){ //read in haps file textData.prepareHapsInput(inputFile); } else if (fileType == PED) { //read in ped file /* if(this.arg_ignoreMarkers.size()>0) { for(int i=0;i<this.arg_ignoreMarkers.size();i++){ int index = Integer.parseInt((String)this.arg_ignoreMarkers.get(i)); if(index>0 && index<markerResultArray.length){ markerResultArray[index] = false; if(!this.quietMode) { System.out.println("Ignoring marker " + (index)); } } } }*/ result = textData.linkageToChrom(inputFile, 3, skipCheck); if(textData.getPedFile().isBogusParents()) { System.out.println("Error: One or more individuals in the file reference non-existent parents.\nThese references have been ignored."); } }else{ //read in hapmapfile result = textData.linkageToChrom(inputFile,4,skipCheck); } File infoFile = null; if (infoFileName != null){ infoFile = new File(infoFileName); } if (result != null){ textData.prepareMarkerInput(infoFile,textData.getPedFile().getHMInfo()); }else{ textData.prepareMarkerInput(infoFile,null); } if(!quietMode && infoFile != null){ System.out.println("Using marker file " + infoFile.getName()); } if(outputCheck && result != null){ CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(validateOutputFile(fileName + ".CHECK")); } Vector cust = new Vector(); if(outputType != -1){ textData.generateDPrimeTable(); Haplotype[][] haplos; switch(outputType){ case BLOX_GABRIEL: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; case BLOX_4GAM: OutputFile = validateOutputFile(fileName + ".4GAMblocks"); break; case BLOX_SPINE: OutputFile = validateOutputFile(fileName + ".SPINEblocks"); break; case BLOX_CUSTOM: OutputFile = validateOutputFile(fileName + ".CUSTblocks"); //read in the blocks file File blocksFile = new File(blockFileName); cust = textData.readBlocks(blocksFile); break; default: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; } //this handles output type ALL Haplotype[][] orderedHaplos; Haplotype[][] crossedHaplos; if(outputType == BLOX_ALL) { OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); textData.guessBlocks(BLOX_GABRIEL); haplos = textData.generateHaplotypes(textData.blocks, false); orderedHaplos = orderHaps(haplos); crossedHaplos = textData.generateCrossovers(orderedHaplos); textData.saveHapsToText(crossedHaplos, textData.getMultiDprime(), OutputFile); OutputFile = validateOutputFile(fileName + ".4GAMblocks"); textData.guessBlocks(BLOX_4GAM); haplos = textData.generateHaplotypes(textData.blocks, false); orderedHaplos = orderHaps(haplos); crossedHaplos = textData.generateCrossovers(orderedHaplos); textData.saveHapsToText(crossedHaplos, textData.getMultiDprime(), OutputFile); OutputFile = validateOutputFile(fileName + ".SPINEblocks"); textData.guessBlocks(BLOX_SPINE); haplos = textData.generateHaplotypes(textData.blocks, false); orderedHaplos = orderHaps(haplos); crossedHaplos = textData.generateCrossovers(orderedHaplos); textData.saveHapsToText(crossedHaplos, textData.getMultiDprime(), OutputFile); }else{ textData.guessBlocks(outputType, cust); haplos = textData.generateHaplotypes(textData.blocks, false); orderedHaplos = orderHaps(haplos); crossedHaplos = textData.generateCrossovers(orderedHaplos); textData.saveHapsToText(crossedHaplos, textData.getMultiDprime(), OutputFile); } //todo: should this output hap assoc for each block type if they do more than one? if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC) { //Haplotype[][] orderedHaps = orderHaps(textData.getHaplotypes()); HaploData.saveHapAssocToText(orderedHaplos, fileName + ".HAPASSOC"); } } if(outputDprime) { OutputFile = validateOutputFile(fileName + ".LD"); if (textData.dpTable != null){ textData.saveDprimeToText(OutputFile, TABLE_TYPE, 0, Chromosome.getSize()); }else{ textData.saveDprimeToText(OutputFile, LIVE_TYPE, 0, Chromosome.getSize()); } } if (outputPNG || outputCompressedPNG){ OutputFile = validateOutputFile(fileName + ".LD.PNG"); if (textData.dpTable == null){ textData.generateDPrimeTable(); textData.guessBlocks(BLOX_CUSTOM, new Vector()); } if (trackFileName != null){ textData.readAnalysisTrack(new File(trackFileName)); } DPrimeDisplay dpd = new DPrimeDisplay(textData); BufferedImage i = dpd.export(0,Chromosome.getSize(),outputCompressedPNG); try{ Jimi.putImage("image/png", i, OutputFile.getName()); }catch(JimiException je){ System.out.println(je.getMessage()); } } if(Options.getAssocTest() == ASSOC_TRIO){ Vector tdtResults = TDT.calcTrioTDT(textData.getPedFile()); HaploData.saveMarkerAssocToText(tdtResults, fileName + ".ASSOC"); } else if(Options.getAssocTest() == ASSOC_CC) { Vector ccResults = TDT.calcCCTDT(textData.getPedFile()); HaploData.saveMarkerAssocToText(ccResults, fileName + ".ASSOC"); } } catch(IOException e){ System.err.println("An error has occured. This probably has to do with file input or output"); } catch(HaploViewException e){ System.err.println(e.getMessage()); } catch(PedFileException pfe) { System.err.println(pfe.getMessage()); } }
HaploData.saveHapAssocToText(orderedHaplos, fileName + ".HAPASSOC");
HaploData.saveHapAssocToText(haplos, fileName + ".HAPASSOC");
private void processFile(String fileName, int fileType, String infoFileName){ try { HaploData textData; File OutputFile; File inputFile; if(!quietMode && fileName != null){ System.out.println("Using data file " + fileName); } inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } textData = new HaploData(); Vector result = null; if(fileType == HAPS){ //read in haps file textData.prepareHapsInput(inputFile); } else if (fileType == PED) { //read in ped file /* if(this.arg_ignoreMarkers.size()>0) { for(int i=0;i<this.arg_ignoreMarkers.size();i++){ int index = Integer.parseInt((String)this.arg_ignoreMarkers.get(i)); if(index>0 && index<markerResultArray.length){ markerResultArray[index] = false; if(!this.quietMode) { System.out.println("Ignoring marker " + (index)); } } } }*/ result = textData.linkageToChrom(inputFile, 3, skipCheck); if(textData.getPedFile().isBogusParents()) { System.out.println("Error: One or more individuals in the file reference non-existent parents.\nThese references have been ignored."); } }else{ //read in hapmapfile result = textData.linkageToChrom(inputFile,4,skipCheck); } File infoFile = null; if (infoFileName != null){ infoFile = new File(infoFileName); } if (result != null){ textData.prepareMarkerInput(infoFile,textData.getPedFile().getHMInfo()); }else{ textData.prepareMarkerInput(infoFile,null); } if(!quietMode && infoFile != null){ System.out.println("Using marker file " + infoFile.getName()); } if(outputCheck && result != null){ CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(validateOutputFile(fileName + ".CHECK")); } Vector cust = new Vector(); if(outputType != -1){ textData.generateDPrimeTable(); Haplotype[][] haplos; switch(outputType){ case BLOX_GABRIEL: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; case BLOX_4GAM: OutputFile = validateOutputFile(fileName + ".4GAMblocks"); break; case BLOX_SPINE: OutputFile = validateOutputFile(fileName + ".SPINEblocks"); break; case BLOX_CUSTOM: OutputFile = validateOutputFile(fileName + ".CUSTblocks"); //read in the blocks file File blocksFile = new File(blockFileName); cust = textData.readBlocks(blocksFile); break; default: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; } //this handles output type ALL Haplotype[][] orderedHaplos; Haplotype[][] crossedHaplos; if(outputType == BLOX_ALL) { OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); textData.guessBlocks(BLOX_GABRIEL); haplos = textData.generateHaplotypes(textData.blocks, false); orderedHaplos = orderHaps(haplos); crossedHaplos = textData.generateCrossovers(orderedHaplos); textData.saveHapsToText(crossedHaplos, textData.getMultiDprime(), OutputFile); OutputFile = validateOutputFile(fileName + ".4GAMblocks"); textData.guessBlocks(BLOX_4GAM); haplos = textData.generateHaplotypes(textData.blocks, false); orderedHaplos = orderHaps(haplos); crossedHaplos = textData.generateCrossovers(orderedHaplos); textData.saveHapsToText(crossedHaplos, textData.getMultiDprime(), OutputFile); OutputFile = validateOutputFile(fileName + ".SPINEblocks"); textData.guessBlocks(BLOX_SPINE); haplos = textData.generateHaplotypes(textData.blocks, false); orderedHaplos = orderHaps(haplos); crossedHaplos = textData.generateCrossovers(orderedHaplos); textData.saveHapsToText(crossedHaplos, textData.getMultiDprime(), OutputFile); }else{ textData.guessBlocks(outputType, cust); haplos = textData.generateHaplotypes(textData.blocks, false); orderedHaplos = orderHaps(haplos); crossedHaplos = textData.generateCrossovers(orderedHaplos); textData.saveHapsToText(crossedHaplos, textData.getMultiDprime(), OutputFile); } //todo: should this output hap assoc for each block type if they do more than one? if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC) { //Haplotype[][] orderedHaps = orderHaps(textData.getHaplotypes()); HaploData.saveHapAssocToText(orderedHaplos, fileName + ".HAPASSOC"); } } if(outputDprime) { OutputFile = validateOutputFile(fileName + ".LD"); if (textData.dpTable != null){ textData.saveDprimeToText(OutputFile, TABLE_TYPE, 0, Chromosome.getSize()); }else{ textData.saveDprimeToText(OutputFile, LIVE_TYPE, 0, Chromosome.getSize()); } } if (outputPNG || outputCompressedPNG){ OutputFile = validateOutputFile(fileName + ".LD.PNG"); if (textData.dpTable == null){ textData.generateDPrimeTable(); textData.guessBlocks(BLOX_CUSTOM, new Vector()); } if (trackFileName != null){ textData.readAnalysisTrack(new File(trackFileName)); } DPrimeDisplay dpd = new DPrimeDisplay(textData); BufferedImage i = dpd.export(0,Chromosome.getSize(),outputCompressedPNG); try{ Jimi.putImage("image/png", i, OutputFile.getName()); }catch(JimiException je){ System.out.println(je.getMessage()); } } if(Options.getAssocTest() == ASSOC_TRIO){ Vector tdtResults = TDT.calcTrioTDT(textData.getPedFile()); HaploData.saveMarkerAssocToText(tdtResults, fileName + ".ASSOC"); } else if(Options.getAssocTest() == ASSOC_CC) { Vector ccResults = TDT.calcCCTDT(textData.getPedFile()); HaploData.saveMarkerAssocToText(ccResults, fileName + ".ASSOC"); } } catch(IOException e){ System.err.println("An error has occured. This probably has to do with file input or output"); } catch(HaploViewException e){ System.err.println(e.getMessage()); } catch(PedFileException pfe) { System.err.println(pfe.getMessage()); } }
ppBar.setToolTipText("PlayPen Toolbar"); ppBar.setName("PlayPen ToolBar");
protected void init() throws ArchitectException { int accelMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); 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(); 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)); openProjectAction = new OpenProjectAction(); 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)); menuBar = new JMenuBar(); //Settingup JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic('f'); fileMenu.add(new JMenuItem(newProjectAction)); fileMenu.add(new JMenuItem(openProjectAction)); fileMenu.add(new JMenuItem(saveProjectAction)); fileMenu.add(new JMenuItem(saveProjectAsAction)); fileMenu.add(new JMenuItem(printAction)); fileMenu.add(new JMenuItem(prefAction)); fileMenu.add(new JMenuItem(projectSettingsAction)); fileMenu.add(new JMenuItem(saveSettingsAction)); fileMenu.add(new JMenuItem(exitAction)); menuBar.add(fileMenu); JMenu editMenu = new JMenu("Edit"); editMenu.setMnemonic('e'); editMenu.add(undoAction); editMenu.add(redoAction); editMenu.addSeparator(); editMenu.add(new JMenuItem(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(new JMenuItem(exportPLTransAction)); etlSubmenuOne.add(new JMenuItem("PL Transaction File Export")); etlSubmenuOne.add(new JMenuItem("Run Power*Loader")); etlSubmenuOne.add(new JMenuItem(quickStartAction)); etlMenu.add(etlSubmenuOne); menuBar.add(etlMenu); JMenu toolsMenu = new JMenu("Tools"); toolsMenu.setMnemonic('t'); toolsMenu.add(new JMenuItem(exportDDLAction)); toolsMenu.add(new JMenuItem(compareDMAction)); menuBar.add(toolsMenu); JMenu helpMenu = new JMenu("Help"); helpMenu.setMnemonic('h'); helpMenu.add(new JMenuItem(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); JButton tempButton = null; // shared actions need to report where they are coming from 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 = sprefs.getInt(SwingUserSettings.MAIN_FRAME_X, 40); bounds.y = sprefs.getInt(SwingUserSettings.MAIN_FRAME_Y, 40); bounds.width = sprefs.getInt(SwingUserSettings.MAIN_FRAME_WIDTH, 600); bounds.height = sprefs.getInt(SwingUserSettings.MAIN_FRAME_HEIGHT, 440); setBounds(bounds); addWindowListener(afWindowListener = new ArchitectFrameWindowListener()); setProject(new SwingUIProject("New Project")); }
log.debug( "Creating thumbnail" );
log.debug( "Creating thumbnail for " + uid );
protected void createThumbnail( Volume volume ) { log.debug( "Creating thumbnail" ); ODMGXAWrapper txw = new ODMGXAWrapper(); txw.lock( this, Transaction.WRITE ); // Find the original image to use as a staring point ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_ORIGINAL ) { original = instance; txw.lock( original, Transaction.READ ); break; } } if ( original == null || original.getImageFile() == null || !original.getImageFile().exists() ) { // If there are uncorrupted instances, no thumbnail can be created log.warn( "Error - no original image was found!!!" ); txw.commit(); return; } log.warn( "Found original, reading it..." ); // Read the image BufferedImage origImage = null; try { origImage = ImageIO.read( original.getImageFile() ); } catch ( IOException e ) { log.warn( "Error reading image: " + e.getMessage() ); txw.abort(); return; } log.warn( "Done, finding name" ); // Find where to store the file in the target volume File thumbnailFile = volume.getInstanceName( this, "jpg" ); log.warn( "name = " + thumbnailFile.getName() ); // Shrink the image to desired state and save it // Find first the correct transformation for doing this int origWidth = origImage.getWidth(); int origHeight = origImage.getHeight(); int maxThumbWidth = 100; int maxThumbHeight = 100; AffineTransform xform = photovault.image.ImageXform.getFittingXform( maxThumbWidth, maxThumbHeight, prefRotation -original.getRotated(), origWidth, origHeight ); // Create the target image AffineTransformOp atOp = new AffineTransformOp( xform, AffineTransformOp.TYPE_NEAREST_NEIGHBOR ); log.warn( "Filtering..." ); BufferedImage thumbImage = atOp.filter( origImage, null ); log.warn( "done Filtering..." ); // Save it try { ImageIO.write( thumbImage, "jpg", thumbnailFile ); } catch ( IOException e ) { log.warn( "Error writing thumbnail: " + e.getMessage() ); txw.abort(); return; } // add the created instance to this persistent object ImageInstance thumbInstance = addInstance( volume, thumbnailFile, ImageInstance.INSTANCE_TYPE_THUMBNAIL ); thumbInstance.setRotated( prefRotation -original.getRotated() ); log.warn( "Loading thumbnail..." ); thumbnail = Thumbnail.createThumbnail( this, thumbnailFile ); txw.commit(); }
log.warn( "Found original, reading it..." );
log.debug( "Found original, reading it..." );
protected void createThumbnail( Volume volume ) { log.debug( "Creating thumbnail" ); ODMGXAWrapper txw = new ODMGXAWrapper(); txw.lock( this, Transaction.WRITE ); // Find the original image to use as a staring point ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_ORIGINAL ) { original = instance; txw.lock( original, Transaction.READ ); break; } } if ( original == null || original.getImageFile() == null || !original.getImageFile().exists() ) { // If there are uncorrupted instances, no thumbnail can be created log.warn( "Error - no original image was found!!!" ); txw.commit(); return; } log.warn( "Found original, reading it..." ); // Read the image BufferedImage origImage = null; try { origImage = ImageIO.read( original.getImageFile() ); } catch ( IOException e ) { log.warn( "Error reading image: " + e.getMessage() ); txw.abort(); return; } log.warn( "Done, finding name" ); // Find where to store the file in the target volume File thumbnailFile = volume.getInstanceName( this, "jpg" ); log.warn( "name = " + thumbnailFile.getName() ); // Shrink the image to desired state and save it // Find first the correct transformation for doing this int origWidth = origImage.getWidth(); int origHeight = origImage.getHeight(); int maxThumbWidth = 100; int maxThumbHeight = 100; AffineTransform xform = photovault.image.ImageXform.getFittingXform( maxThumbWidth, maxThumbHeight, prefRotation -original.getRotated(), origWidth, origHeight ); // Create the target image AffineTransformOp atOp = new AffineTransformOp( xform, AffineTransformOp.TYPE_NEAREST_NEIGHBOR ); log.warn( "Filtering..." ); BufferedImage thumbImage = atOp.filter( origImage, null ); log.warn( "done Filtering..." ); // Save it try { ImageIO.write( thumbImage, "jpg", thumbnailFile ); } catch ( IOException e ) { log.warn( "Error writing thumbnail: " + e.getMessage() ); txw.abort(); return; } // add the created instance to this persistent object ImageInstance thumbInstance = addInstance( volume, thumbnailFile, ImageInstance.INSTANCE_TYPE_THUMBNAIL ); thumbInstance.setRotated( prefRotation -original.getRotated() ); log.warn( "Loading thumbnail..." ); thumbnail = Thumbnail.createThumbnail( this, thumbnailFile ); txw.commit(); }
origImage = ImageIO.read( original.getImageFile() );
Iterator readers = ImageIO.getImageReadersByFormatName( "jpg" ); if ( readers.hasNext() ) { ImageReader reader = (ImageReader)readers.next(); log.debug( "Creating stream" ); ImageInputStream iis = ImageIO.createImageInputStream( original.getImageFile() ); reader.setInput( iis, true ); if ( reader.getNumThumbnails(0) > 0 ) { log.debug( "Original has thumbnail, size " + reader.getThumbnailWidth( 0, 0 ) + " x " + reader.getThumbnailHeight( 0, 0 ) ); origImage = reader.readThumbnail( 0, 0 ); log.debug( "Read thumbnail" ); } else { log.debug( "No thumbnail in original" ); ImageReadParam param = reader.getDefaultReadParam(); param.setSourceSubsampling( 16, 16, 0, 0 ); origImage = reader.read( 0, param ); log.debug( "Read original" ); } }
protected void createThumbnail( Volume volume ) { log.debug( "Creating thumbnail" ); ODMGXAWrapper txw = new ODMGXAWrapper(); txw.lock( this, Transaction.WRITE ); // Find the original image to use as a staring point ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_ORIGINAL ) { original = instance; txw.lock( original, Transaction.READ ); break; } } if ( original == null || original.getImageFile() == null || !original.getImageFile().exists() ) { // If there are uncorrupted instances, no thumbnail can be created log.warn( "Error - no original image was found!!!" ); txw.commit(); return; } log.warn( "Found original, reading it..." ); // Read the image BufferedImage origImage = null; try { origImage = ImageIO.read( original.getImageFile() ); } catch ( IOException e ) { log.warn( "Error reading image: " + e.getMessage() ); txw.abort(); return; } log.warn( "Done, finding name" ); // Find where to store the file in the target volume File thumbnailFile = volume.getInstanceName( this, "jpg" ); log.warn( "name = " + thumbnailFile.getName() ); // Shrink the image to desired state and save it // Find first the correct transformation for doing this int origWidth = origImage.getWidth(); int origHeight = origImage.getHeight(); int maxThumbWidth = 100; int maxThumbHeight = 100; AffineTransform xform = photovault.image.ImageXform.getFittingXform( maxThumbWidth, maxThumbHeight, prefRotation -original.getRotated(), origWidth, origHeight ); // Create the target image AffineTransformOp atOp = new AffineTransformOp( xform, AffineTransformOp.TYPE_NEAREST_NEIGHBOR ); log.warn( "Filtering..." ); BufferedImage thumbImage = atOp.filter( origImage, null ); log.warn( "done Filtering..." ); // Save it try { ImageIO.write( thumbImage, "jpg", thumbnailFile ); } catch ( IOException e ) { log.warn( "Error writing thumbnail: " + e.getMessage() ); txw.abort(); return; } // add the created instance to this persistent object ImageInstance thumbInstance = addInstance( volume, thumbnailFile, ImageInstance.INSTANCE_TYPE_THUMBNAIL ); thumbInstance.setRotated( prefRotation -original.getRotated() ); log.warn( "Loading thumbnail..." ); thumbnail = Thumbnail.createThumbnail( this, thumbnailFile ); txw.commit(); }
log.warn( "Done, finding name" );
log.debug( "Done, finding name" );
protected void createThumbnail( Volume volume ) { log.debug( "Creating thumbnail" ); ODMGXAWrapper txw = new ODMGXAWrapper(); txw.lock( this, Transaction.WRITE ); // Find the original image to use as a staring point ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_ORIGINAL ) { original = instance; txw.lock( original, Transaction.READ ); break; } } if ( original == null || original.getImageFile() == null || !original.getImageFile().exists() ) { // If there are uncorrupted instances, no thumbnail can be created log.warn( "Error - no original image was found!!!" ); txw.commit(); return; } log.warn( "Found original, reading it..." ); // Read the image BufferedImage origImage = null; try { origImage = ImageIO.read( original.getImageFile() ); } catch ( IOException e ) { log.warn( "Error reading image: " + e.getMessage() ); txw.abort(); return; } log.warn( "Done, finding name" ); // Find where to store the file in the target volume File thumbnailFile = volume.getInstanceName( this, "jpg" ); log.warn( "name = " + thumbnailFile.getName() ); // Shrink the image to desired state and save it // Find first the correct transformation for doing this int origWidth = origImage.getWidth(); int origHeight = origImage.getHeight(); int maxThumbWidth = 100; int maxThumbHeight = 100; AffineTransform xform = photovault.image.ImageXform.getFittingXform( maxThumbWidth, maxThumbHeight, prefRotation -original.getRotated(), origWidth, origHeight ); // Create the target image AffineTransformOp atOp = new AffineTransformOp( xform, AffineTransformOp.TYPE_NEAREST_NEIGHBOR ); log.warn( "Filtering..." ); BufferedImage thumbImage = atOp.filter( origImage, null ); log.warn( "done Filtering..." ); // Save it try { ImageIO.write( thumbImage, "jpg", thumbnailFile ); } catch ( IOException e ) { log.warn( "Error writing thumbnail: " + e.getMessage() ); txw.abort(); return; } // add the created instance to this persistent object ImageInstance thumbInstance = addInstance( volume, thumbnailFile, ImageInstance.INSTANCE_TYPE_THUMBNAIL ); thumbInstance.setRotated( prefRotation -original.getRotated() ); log.warn( "Loading thumbnail..." ); thumbnail = Thumbnail.createThumbnail( this, thumbnailFile ); txw.commit(); }
log.warn( "name = " + thumbnailFile.getName() );
log.debug( "name = " + thumbnailFile.getName() );
protected void createThumbnail( Volume volume ) { log.debug( "Creating thumbnail" ); ODMGXAWrapper txw = new ODMGXAWrapper(); txw.lock( this, Transaction.WRITE ); // Find the original image to use as a staring point ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_ORIGINAL ) { original = instance; txw.lock( original, Transaction.READ ); break; } } if ( original == null || original.getImageFile() == null || !original.getImageFile().exists() ) { // If there are uncorrupted instances, no thumbnail can be created log.warn( "Error - no original image was found!!!" ); txw.commit(); return; } log.warn( "Found original, reading it..." ); // Read the image BufferedImage origImage = null; try { origImage = ImageIO.read( original.getImageFile() ); } catch ( IOException e ) { log.warn( "Error reading image: " + e.getMessage() ); txw.abort(); return; } log.warn( "Done, finding name" ); // Find where to store the file in the target volume File thumbnailFile = volume.getInstanceName( this, "jpg" ); log.warn( "name = " + thumbnailFile.getName() ); // Shrink the image to desired state and save it // Find first the correct transformation for doing this int origWidth = origImage.getWidth(); int origHeight = origImage.getHeight(); int maxThumbWidth = 100; int maxThumbHeight = 100; AffineTransform xform = photovault.image.ImageXform.getFittingXform( maxThumbWidth, maxThumbHeight, prefRotation -original.getRotated(), origWidth, origHeight ); // Create the target image AffineTransformOp atOp = new AffineTransformOp( xform, AffineTransformOp.TYPE_NEAREST_NEIGHBOR ); log.warn( "Filtering..." ); BufferedImage thumbImage = atOp.filter( origImage, null ); log.warn( "done Filtering..." ); // Save it try { ImageIO.write( thumbImage, "jpg", thumbnailFile ); } catch ( IOException e ) { log.warn( "Error writing thumbnail: " + e.getMessage() ); txw.abort(); return; } // add the created instance to this persistent object ImageInstance thumbInstance = addInstance( volume, thumbnailFile, ImageInstance.INSTANCE_TYPE_THUMBNAIL ); thumbInstance.setRotated( prefRotation -original.getRotated() ); log.warn( "Loading thumbnail..." ); thumbnail = Thumbnail.createThumbnail( this, thumbnailFile ); txw.commit(); }
log.warn( "Filtering..." );
log.debug( "Filtering..." );
protected void createThumbnail( Volume volume ) { log.debug( "Creating thumbnail" ); ODMGXAWrapper txw = new ODMGXAWrapper(); txw.lock( this, Transaction.WRITE ); // Find the original image to use as a staring point ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_ORIGINAL ) { original = instance; txw.lock( original, Transaction.READ ); break; } } if ( original == null || original.getImageFile() == null || !original.getImageFile().exists() ) { // If there are uncorrupted instances, no thumbnail can be created log.warn( "Error - no original image was found!!!" ); txw.commit(); return; } log.warn( "Found original, reading it..." ); // Read the image BufferedImage origImage = null; try { origImage = ImageIO.read( original.getImageFile() ); } catch ( IOException e ) { log.warn( "Error reading image: " + e.getMessage() ); txw.abort(); return; } log.warn( "Done, finding name" ); // Find where to store the file in the target volume File thumbnailFile = volume.getInstanceName( this, "jpg" ); log.warn( "name = " + thumbnailFile.getName() ); // Shrink the image to desired state and save it // Find first the correct transformation for doing this int origWidth = origImage.getWidth(); int origHeight = origImage.getHeight(); int maxThumbWidth = 100; int maxThumbHeight = 100; AffineTransform xform = photovault.image.ImageXform.getFittingXform( maxThumbWidth, maxThumbHeight, prefRotation -original.getRotated(), origWidth, origHeight ); // Create the target image AffineTransformOp atOp = new AffineTransformOp( xform, AffineTransformOp.TYPE_NEAREST_NEIGHBOR ); log.warn( "Filtering..." ); BufferedImage thumbImage = atOp.filter( origImage, null ); log.warn( "done Filtering..." ); // Save it try { ImageIO.write( thumbImage, "jpg", thumbnailFile ); } catch ( IOException e ) { log.warn( "Error writing thumbnail: " + e.getMessage() ); txw.abort(); return; } // add the created instance to this persistent object ImageInstance thumbInstance = addInstance( volume, thumbnailFile, ImageInstance.INSTANCE_TYPE_THUMBNAIL ); thumbInstance.setRotated( prefRotation -original.getRotated() ); log.warn( "Loading thumbnail..." ); thumbnail = Thumbnail.createThumbnail( this, thumbnailFile ); txw.commit(); }
log.warn( "done Filtering..." );
log.debug( "done Filtering..." );
protected void createThumbnail( Volume volume ) { log.debug( "Creating thumbnail" ); ODMGXAWrapper txw = new ODMGXAWrapper(); txw.lock( this, Transaction.WRITE ); // Find the original image to use as a staring point ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_ORIGINAL ) { original = instance; txw.lock( original, Transaction.READ ); break; } } if ( original == null || original.getImageFile() == null || !original.getImageFile().exists() ) { // If there are uncorrupted instances, no thumbnail can be created log.warn( "Error - no original image was found!!!" ); txw.commit(); return; } log.warn( "Found original, reading it..." ); // Read the image BufferedImage origImage = null; try { origImage = ImageIO.read( original.getImageFile() ); } catch ( IOException e ) { log.warn( "Error reading image: " + e.getMessage() ); txw.abort(); return; } log.warn( "Done, finding name" ); // Find where to store the file in the target volume File thumbnailFile = volume.getInstanceName( this, "jpg" ); log.warn( "name = " + thumbnailFile.getName() ); // Shrink the image to desired state and save it // Find first the correct transformation for doing this int origWidth = origImage.getWidth(); int origHeight = origImage.getHeight(); int maxThumbWidth = 100; int maxThumbHeight = 100; AffineTransform xform = photovault.image.ImageXform.getFittingXform( maxThumbWidth, maxThumbHeight, prefRotation -original.getRotated(), origWidth, origHeight ); // Create the target image AffineTransformOp atOp = new AffineTransformOp( xform, AffineTransformOp.TYPE_NEAREST_NEIGHBOR ); log.warn( "Filtering..." ); BufferedImage thumbImage = atOp.filter( origImage, null ); log.warn( "done Filtering..." ); // Save it try { ImageIO.write( thumbImage, "jpg", thumbnailFile ); } catch ( IOException e ) { log.warn( "Error writing thumbnail: " + e.getMessage() ); txw.abort(); return; } // add the created instance to this persistent object ImageInstance thumbInstance = addInstance( volume, thumbnailFile, ImageInstance.INSTANCE_TYPE_THUMBNAIL ); thumbInstance.setRotated( prefRotation -original.getRotated() ); log.warn( "Loading thumbnail..." ); thumbnail = Thumbnail.createThumbnail( this, thumbnailFile ); txw.commit(); }
log.warn( "Loading thumbnail..." );
log.debug( "Loading thumbnail..." );
protected void createThumbnail( Volume volume ) { log.debug( "Creating thumbnail" ); ODMGXAWrapper txw = new ODMGXAWrapper(); txw.lock( this, Transaction.WRITE ); // Find the original image to use as a staring point ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_ORIGINAL ) { original = instance; txw.lock( original, Transaction.READ ); break; } } if ( original == null || original.getImageFile() == null || !original.getImageFile().exists() ) { // If there are uncorrupted instances, no thumbnail can be created log.warn( "Error - no original image was found!!!" ); txw.commit(); return; } log.warn( "Found original, reading it..." ); // Read the image BufferedImage origImage = null; try { origImage = ImageIO.read( original.getImageFile() ); } catch ( IOException e ) { log.warn( "Error reading image: " + e.getMessage() ); txw.abort(); return; } log.warn( "Done, finding name" ); // Find where to store the file in the target volume File thumbnailFile = volume.getInstanceName( this, "jpg" ); log.warn( "name = " + thumbnailFile.getName() ); // Shrink the image to desired state and save it // Find first the correct transformation for doing this int origWidth = origImage.getWidth(); int origHeight = origImage.getHeight(); int maxThumbWidth = 100; int maxThumbHeight = 100; AffineTransform xform = photovault.image.ImageXform.getFittingXform( maxThumbWidth, maxThumbHeight, prefRotation -original.getRotated(), origWidth, origHeight ); // Create the target image AffineTransformOp atOp = new AffineTransformOp( xform, AffineTransformOp.TYPE_NEAREST_NEIGHBOR ); log.warn( "Filtering..." ); BufferedImage thumbImage = atOp.filter( origImage, null ); log.warn( "done Filtering..." ); // Save it try { ImageIO.write( thumbImage, "jpg", thumbnailFile ); } catch ( IOException e ) { log.warn( "Error writing thumbnail: " + e.getMessage() ); txw.abort(); return; } // add the created instance to this persistent object ImageInstance thumbInstance = addInstance( volume, thumbnailFile, ImageInstance.INSTANCE_TYPE_THUMBNAIL ); thumbInstance.setRotated( prefRotation -original.getRotated() ); log.warn( "Loading thumbnail..." ); thumbnail = Thumbnail.createThumbnail( this, thumbnailFile ); txw.commit(); }
log.debug( "Thumbnail loaded" );
protected void createThumbnail( Volume volume ) { log.debug( "Creating thumbnail" ); ODMGXAWrapper txw = new ODMGXAWrapper(); txw.lock( this, Transaction.WRITE ); // Find the original image to use as a staring point ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_ORIGINAL ) { original = instance; txw.lock( original, Transaction.READ ); break; } } if ( original == null || original.getImageFile() == null || !original.getImageFile().exists() ) { // If there are uncorrupted instances, no thumbnail can be created log.warn( "Error - no original image was found!!!" ); txw.commit(); return; } log.warn( "Found original, reading it..." ); // Read the image BufferedImage origImage = null; try { origImage = ImageIO.read( original.getImageFile() ); } catch ( IOException e ) { log.warn( "Error reading image: " + e.getMessage() ); txw.abort(); return; } log.warn( "Done, finding name" ); // Find where to store the file in the target volume File thumbnailFile = volume.getInstanceName( this, "jpg" ); log.warn( "name = " + thumbnailFile.getName() ); // Shrink the image to desired state and save it // Find first the correct transformation for doing this int origWidth = origImage.getWidth(); int origHeight = origImage.getHeight(); int maxThumbWidth = 100; int maxThumbHeight = 100; AffineTransform xform = photovault.image.ImageXform.getFittingXform( maxThumbWidth, maxThumbHeight, prefRotation -original.getRotated(), origWidth, origHeight ); // Create the target image AffineTransformOp atOp = new AffineTransformOp( xform, AffineTransformOp.TYPE_NEAREST_NEIGHBOR ); log.warn( "Filtering..." ); BufferedImage thumbImage = atOp.filter( origImage, null ); log.warn( "done Filtering..." ); // Save it try { ImageIO.write( thumbImage, "jpg", thumbnailFile ); } catch ( IOException e ) { log.warn( "Error writing thumbnail: " + e.getMessage() ); txw.abort(); return; } // add the created instance to this persistent object ImageInstance thumbInstance = addInstance( volume, thumbnailFile, ImageInstance.INSTANCE_TYPE_THUMBNAIL ); thumbInstance.setRotated( prefRotation -original.getRotated() ); log.warn( "Loading thumbnail..." ); thumbnail = Thumbnail.createThumbnail( this, thumbnailFile ); txw.commit(); }
log.debug( "getThumbnail: Finding thumbnail for " + uid );
log.debug( "getThumbnail: entry, Finding thumbnail for " + uid );
public Thumbnail getThumbnail() { log.debug( "getThumbnail: Finding thumbnail for " + uid ); if ( thumbnail == null ) { // First try to find an instance from existing instances ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_THUMBNAIL && instance.getRotated() == prefRotation ) { thumbnail = Thumbnail.createThumbnail( this, instance.getImageFile() ); break; } } if ( thumbnail == null ) { // Next try to create a new thumbnail instance log.debug( "No thumbnail found, creating" ); createThumbnail(); } } if ( thumbnail == null ) { // Thumbnail creating was not successful, most probably because there is no available instance// return Thumbnail.getDefaultThumbnail(); thumbnail = Thumbnail.getDefaultThumbnail(); } return thumbnail; }
log.debug( "getThumbnail: exit" );
public Thumbnail getThumbnail() { log.debug( "getThumbnail: Finding thumbnail for " + uid ); if ( thumbnail == null ) { // First try to find an instance from existing instances ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_THUMBNAIL && instance.getRotated() == prefRotation ) { thumbnail = Thumbnail.createThumbnail( this, instance.getImageFile() ); break; } } if ( thumbnail == null ) { // Next try to create a new thumbnail instance log.debug( "No thumbnail found, creating" ); createThumbnail(); } } if ( thumbnail == null ) { // Thumbnail creating was not successful, most probably because there is no available instance// return Thumbnail.getDefaultThumbnail(); thumbnail = Thumbnail.getDefaultThumbnail(); } return thumbnail; }
log.debug( "hasThumbnail: Finding thumbnail for " + uid );
log.debug( "hasThumbnail: entry, Finding thumbnail for " + uid );
public boolean hasThumbnail() { log.debug( "hasThumbnail: Finding thumbnail for " + uid ); if ( thumbnail == null ) { // First try to find an instance from existing instances ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_THUMBNAIL && instance.getRotated() == prefRotation ) { thumbnail = Thumbnail.createThumbnail( this, instance.getImageFile() ); break; } } } return ( thumbnail != null ); }
log.debug( "hasThumbnail: exit" );
public boolean hasThumbnail() { log.debug( "hasThumbnail: Finding thumbnail for " + uid ); if ( thumbnail == null ) { // First try to find an instance from existing instances ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_THUMBNAIL && instance.getRotated() == prefRotation ) { thumbnail = Thumbnail.createThumbnail( this, instance.getImageFile() ); break; } } } return ( thumbnail != null ); }
CheckDataPanel cp = new CheckDataPanel(textData);
CheckDataPanel cp = new CheckDataPanel(textData, false);
private void processFile(String fileName, int fileType, String infoFileName){ try { int outputType; long maxDistance; HaploData textData; File OutputFile; File inputFile; inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } maxDistance = this.arg_distance * 1000; outputType = this.arg_output; textData = new HaploData(0); Vector result = null; if(fileType == 0){ //read in haps file textData.prepareHapsInput(inputFile); } else if (fileType == 1) { //read in ped file /* if(this.arg_ignoreMarkers.size()>0) { for(int i=0;i<this.arg_ignoreMarkers.size();i++){ int index = Integer.parseInt((String)this.arg_ignoreMarkers.get(i)); if(index>0 && index<markerResultArray.length){ markerResultArray[index] = false; if(!this.arg_quiet) { System.out.println("Ignoring marker " + (index)); } } } }*/ result = textData.linkageToChrom(inputFile, 3, arg_skipCheck); }else{ //read in hapmapfile result = textData.linkageToChrom(inputFile,4,arg_skipCheck); } File infoFile; if(infoFileName.equals("")) { infoFile = null; }else{ infoFile = new File(infoFileName); } if (result != null){ textData.prepareMarkerInput(infoFile,maxDistance,textData.getPedFile().getHMInfo()); }else{ textData.prepareMarkerInput(infoFile,maxDistance,null); } if(!arg_quiet && infoFile != null){ System.out.println("Using marker file " + infoFile.getName()); } if(this.arg_showCheck && result != null) { CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(null); } if(this.arg_check && result != null){ CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(new File (fileName + ".CHECK")); } Vector cust = new Vector(); if(outputType != -1){ textData.generateDPrimeTable(); Haplotype[][] haplos; switch(outputType){ case BLOX_GABRIEL: OutputFile = new File(fileName + ".GABRIELblocks"); break; case BLOX_4GAM: OutputFile = new File(fileName + ".4GAMblocks"); break; case BLOX_SPINE: OutputFile = new File(fileName + ".SPINEblocks"); break; case BLOX_CUSTOM: OutputFile = new File(fileName + ".CUSTblocks"); //read in the blocks file File blocksFile = new File(arg_blockfile); cust = textData.readBlocks(blocksFile); break; default: OutputFile = new File(fileName + ".GABRIELblocks"); break; } //this handles output type ALL int start = 0; int stop = Chromosome.getFilteredSize(); if(outputType == BLOX_ALL) { OutputFile = new File(fileName + ".GABRIELblocks"); textData.guessBlocks(BLOX_GABRIEL); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".4GAMblocks"); textData.guessBlocks(BLOX_4GAM); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".SPINEblocks"); textData.guessBlocks(BLOX_SPINE); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); }else{ textData.guessBlocks(outputType, cust); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); } } if(this.arg_dprime) { OutputFile = new File(fileName + ".DPRIME"); if (textData.filteredDPrimeTable != null){ textData.saveDprimeToText(OutputFile, TABLE_TYPE, 0, Chromosome.getFilteredSize()); }else{ textData.saveDprimeToText(OutputFile, LIVE_TYPE, 0, Chromosome.getFilteredSize()); } } if (this.arg_png || this.arg_smallpng){ OutputFile = new File(fileName + ".LD.PNG"); if (textData.filteredDPrimeTable == null){ textData.generateDPrimeTable(); textData.guessBlocks(BLOX_CUSTOM, new Vector()); } if (this.arg_trackName != null){ textData.readAnalysisTrack(new File(arg_trackName)); } DPrimeDisplay dpd = new DPrimeDisplay(textData); BufferedImage i = dpd.export(0,Chromosome.getSize(),this.arg_smallpng); try{ Jimi.putImage("image/png", i, OutputFile.getName()); }catch(JimiException je){ System.out.println(je.getMessage()); } } //if(fileType){ //TDT.calcTrioTDT(textData.chromosomes); //TODO: Deal with this. why do we calc TDT? and make sure not to do it except when appropriate //} } catch(IOException e){ System.err.println("An error has occured. This probably has to do with file input or output"); } catch(HaploViewException e){ System.err.println(e.getMessage()); } catch(PedFileException pfe) { System.err.println(pfe.getMessage()); } }
viewMenuItems[i].setEnabled(false);
public HaploView(){ //menu setup JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenuItem menuItem; //file menu JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); menuItem = new JMenuItem(READ_GENOTYPES); setAccelerator(menuItem, 'O', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /* viewGenotypesItem = new JMenuItem(VIEW_GENOTYPES); viewGenotypesItem.addActionListener(this); //viewGenotypesItem.setEnabled(false); fileMenu.add(viewGenotypesItem); */ readMarkerItem = new JMenuItem(READ_MARKERS); setAccelerator(readMarkerItem, 'I', false); readMarkerItem.addActionListener(this); readMarkerItem.setEnabled(false); fileMenu.add(readMarkerItem); /* viewMarkerItem = new JMenuItem(VIEW_MARKERS); viewMarkerItem.addActionListener(this); //viewMarkerItem.setEnabled(false); fileMenu.add(viewMarkerItem); */ fileMenu.addSeparator(); exportMenuItems = new JMenuItem[exportItems.length]; for (int i = 0; i < exportItems.length; i++) { exportMenuItems[i] = new JMenuItem(exportItems[i]); exportMenuItems[i].addActionListener(this); exportMenuItems[i].setEnabled(false); fileMenu.add(exportMenuItems[i]); } fileMenu.addSeparator(); menuItem = new JMenuItem(QUIT); setAccelerator(menuItem, 'Q', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /// display menu JMenu displayMenu = new JMenu("Display"); menuBar.add(displayMenu); ButtonGroup group = new ButtonGroup(); viewMenuItems = new JRadioButtonMenuItem[viewItems.length]; for (int i = 0; i < viewItems.length; i++) { viewMenuItems[i] = new JRadioButtonMenuItem(viewItems[i], i == 0); viewMenuItems[i].addActionListener(this); KeyStroke ks = KeyStroke.getKeyStroke('1' + i, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); viewMenuItems[i].setAccelerator(ks); displayMenu.add(viewMenuItems[i]); group.add(viewMenuItems[i]); } //analysis menu JMenu analysisMenu = new JMenu("Analysis"); menuBar.add(analysisMenu); defineBlocksItem = new JMenuItem(DEFINE_BLOCKS); setAccelerator(defineBlocksItem, 'B', false); defineBlocksItem.addActionListener(this); defineBlocksItem.setEnabled(false); analysisMenu.add(defineBlocksItem); clearBlocksItem = new JMenuItem(CLEAR_BLOCKS); setAccelerator(clearBlocksItem, 'C', false); clearBlocksItem.addActionListener(this); clearBlocksItem.setEnabled(false); analysisMenu.add(clearBlocksItem); // maybe //displayMenu.addSeparator(); //displayOptionsItem = new JMenuItem(DISPLAY_OPTIONS); //setAccelerator(displayOptionsItem, 'D', false); /** NEEDS FIXING helpMenu = new JMenu("Help"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(helpMenu); menuItem = new JMenuItem("Tutorial"); menuItem.addActionListener(this); helpMenu.add(menuItem); **/ /* clearBlocksMenuItem.addActionListener(this); clearBlocksMenuItem.setEnabled(false); toolMenu.add(clearBlocksMenuItem); */ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e){ quit(); } }); }
viewMenuItems[VIEW_HAP_NUM].setEnabled(true);
void processData() { maxCompDist = Long.parseLong(inputOptions[2])*1000; this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); final SwingWorker worker = new SwingWorker(){ public Object construct(){ dPrimeDisplay=null; theData.infoKnown = false; if (!(inputOptions[1].equals(""))){ readMarkers(new File(inputOptions[1])); } theData.generateDPrimeTable(maxCompDist); theData.guessBlocks(0); //drawPicture(theData); //void drawPicture(HaploData theData) { Container contents = getContentPane(); contents.removeAll(); int currentTab = 0; /*if (!(tabs == null)){ currentTab = tabs.getSelectedIndex(); } */ tabs = new JTabbedPane(); tabs.addChangeListener(new TabChangeListener()); //first, draw the D' picture JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); dPrimeDisplay = new DPrimeDisplay(theData); JScrollPane dPrimeScroller = new JScrollPane(dPrimeDisplay); dPrimeScroller.getViewport().setScrollMode(JViewport.BLIT_SCROLL_MODE); dPrimeScroller.getVerticalScrollBar().setUnitIncrement(60); dPrimeScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(dPrimeScroller); tabs.addTab(viewItems[VIEW_D_NUM], panel); //compute and show haps on next tab panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); try { hapDisplay = new HaplotypeDisplay(theData); } catch(HaploViewException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } HaplotypeDisplayController hdc = new HaplotypeDisplayController(hapDisplay); hapScroller = new JScrollPane(hapDisplay); panel.add(hapScroller); panel.add(hdc); tabs.addTab(viewItems[VIEW_HAP_NUM], panel); //TDT panel if(doTDT) { tdtPanel = new TDTPanel(theData.chromosomes); tabs.addTab(viewItems[VIEW_TDT_NUM], tdtPanel); viewMenuItems[VIEW_TDT_NUM].setEnabled(true); } //check data panel if (checkPanel != null){ tabs.addTab(viewItems[VIEW_CHECK_NUM], checkPanel); viewMenuItems[VIEW_CHECK_NUM].setEnabled(true); currentTab=VIEW_CHECK_NUM; } tabs.setSelectedIndex(currentTab); contents.add(tabs); //next add a little spacer //ontents.add(Box.createRigidArea(new Dimension(0,5))); //and then add the block display //theBlocks = new BlockDisplay(theData.markerInfo, theData.blocks, dPrimeDisplay, infoKnown); //contents.setBackground(Color.black); //put the block display in a scroll pane in case the data set is very large. //JScrollPane blockScroller = new JScrollPane(theBlocks, // JScrollPane.VERTICAL_SCROLLBAR_NEVER, // JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); //blockScroller.getHorizontalScrollBar().setUnitIncrement(60); //blockScroller.setMinimumSize(new Dimension(800, 100)); //contents.add(blockScroller); repaint(); setVisible(true); //} theData.finished = true; return ""; } }; timer = new javax.swing.Timer(50, new ActionListener(){ public void actionPerformed(ActionEvent evt){ if (theData.finished){ timer.stop(); defineBlocksItem.setEnabled(true); clearBlocksItem.setEnabled(true); readMarkerItem.setEnabled(true); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } }); worker.start(); timer.start(); }
viewMenuItems[VIEW_HAP_NUM].setEnabled(true);
public Object construct(){ dPrimeDisplay=null; theData.infoKnown = false; if (!(inputOptions[1].equals(""))){ readMarkers(new File(inputOptions[1])); } theData.generateDPrimeTable(maxCompDist); theData.guessBlocks(0); //drawPicture(theData); //void drawPicture(HaploData theData) { Container contents = getContentPane(); contents.removeAll(); int currentTab = 0; /*if (!(tabs == null)){ currentTab = tabs.getSelectedIndex(); } */ tabs = new JTabbedPane(); tabs.addChangeListener(new TabChangeListener()); //first, draw the D' picture JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); dPrimeDisplay = new DPrimeDisplay(theData); JScrollPane dPrimeScroller = new JScrollPane(dPrimeDisplay); dPrimeScroller.getViewport().setScrollMode(JViewport.BLIT_SCROLL_MODE); dPrimeScroller.getVerticalScrollBar().setUnitIncrement(60); dPrimeScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(dPrimeScroller); tabs.addTab(viewItems[VIEW_D_NUM], panel); //compute and show haps on next tab panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); try { hapDisplay = new HaplotypeDisplay(theData); } catch(HaploViewException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } HaplotypeDisplayController hdc = new HaplotypeDisplayController(hapDisplay); hapScroller = new JScrollPane(hapDisplay); panel.add(hapScroller); panel.add(hdc); tabs.addTab(viewItems[VIEW_HAP_NUM], panel); //TDT panel if(doTDT) { tdtPanel = new TDTPanel(theData.chromosomes); tabs.addTab(viewItems[VIEW_TDT_NUM], tdtPanel); viewMenuItems[VIEW_TDT_NUM].setEnabled(true); } //check data panel if (checkPanel != null){ tabs.addTab(viewItems[VIEW_CHECK_NUM], checkPanel); viewMenuItems[VIEW_CHECK_NUM].setEnabled(true); currentTab=VIEW_CHECK_NUM; } tabs.setSelectedIndex(currentTab); contents.add(tabs); //next add a little spacer //ontents.add(Box.createRigidArea(new Dimension(0,5))); //and then add the block display //theBlocks = new BlockDisplay(theData.markerInfo, theData.blocks, dPrimeDisplay, infoKnown); //contents.setBackground(Color.black); //put the block display in a scroll pane in case the data set is very large. //JScrollPane blockScroller = new JScrollPane(theBlocks, // JScrollPane.VERTICAL_SCROLLBAR_NEVER, // JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); //blockScroller.getHorizontalScrollBar().setUnitIncrement(60); //blockScroller.setMinimumSize(new Dimension(800, 100)); //contents.add(blockScroller); repaint(); setVisible(true); //} theData.finished = true; return ""; }
if(status == null){ status = User.STATUS_ACTIVE; }
public String getStatus() { return status; }
TablePane tp = new TablePane(tab);
TablePane tp = new TablePane(tab, playPen.getFontRenderContext());
public Object createObject(Attributes attributes) { int x = Integer.parseInt(attributes.getValue("x")); int y = Integer.parseInt(attributes.getValue("y")); SQLTable tab = (SQLTable) objectIdMap.get(attributes.getValue("table-ref")); TablePane tp = new TablePane(tab); playPen.add(tp, new Point(x, y)); return tp; }