rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
getBody().run( context, output); | invokeBody( output); | public void doTag(final XMLOutput output) throws Exception { getGoal(getName()).addPostActionCallback( new PostActionCallback() { public void firePostAction(Goal goal) throws Exception { // lets run the body log.info( "Running post action: " + getName() ); getBody().run( context, output); } } ); } |
getBody().run( context, output); | invokeBody( output); | public void firePostAction(Goal goal) throws Exception { // lets run the body log.info( "Running post action: " + getName() ); getBody().run( context, output); } |
HandlerContext(Command command, boolean isAuthRequired){ this.command = command; this.serviceContext = getServiceContext(command, isAuthRequired); | HandlerContext(Command command){ this(command, true); | HandlerContext(Command command, boolean isAuthRequired){ this.command = command; this.serviceContext = getServiceContext(command, isAuthRequired); } |
if (o == null) return false; | public boolean equals(Object o) { ArchitectDataSource other = (ArchitectDataSource) o; return this.properties.equals(other.properties); } |
|
if(metaAppConfig.isDisplayURL()) appForm.setURL(config.getURL()); | public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) { ApplicationConfig config = context.getApplicationConfig(); ApplicationForm appForm = (ApplicationForm)actionForm; ModuleConfig moduleConfig = ModuleRegistry.getModule(config.getType()); MetaApplicationConfig metaAppConfig = moduleConfig.getMetaApplicationConfig(); /* populate the form */ appForm.setApplicationId(config.getApplicationId()); appForm.setName(config.getName()); appForm.setType(config.getType()); if(metaAppConfig.isDisplayHost()) appForm.setHost(config.getHost()); if(metaAppConfig.isDisplayPort()) appForm.setPort(String.valueOf(config.getPort())); if(metaAppConfig.isDisplayUsername()) appForm.setUsername(config.getUsername()); if(metaAppConfig.isDisplayPassword() && config.getPassword() != null && config.getPassword().length()>0) appForm.setPassword(ApplicationForm.FORM_PASSWORD); request.setAttribute(RequestAttributes.META_APP_CONFIG, metaAppConfig); return mapping.findForward(Forwards.SUCCESS); } |
|
out.println("-- Created by SQLPower Oracle 8i/9i DDL Generator "+GENERATOR_VERSION+" --"); | println("-- Created by SQLPower Oracle 8i/9i DDL Generator "+GENERATOR_VERSION+" --"); | public void writeHeader() { out.println("-- Created by SQLPower Oracle 8i/9i DDL Generator "+GENERATOR_VERSION+" --"); } |
public void doTag(XMLOutput output) throws Exception { | public void doTag(XMLOutput output) throws JellyTagException { | public void doTag(XMLOutput output) throws Exception { String message = getBodyText(); Object expectedValue = expected.evaluate(context); Object actualValue = actual.evaluate(context); if (expectedValue == null && actualValue == null) { return; } if (actualValue != null && expectedValue.equals(actualValue)) { return; } String expressions = "\nExpected expression: " + expected.getExpressionText() + "\nActual expression: " + actual.getExpressionText(); failNotEquals(message, expectedValue, actualValue, expressions); } |
file.delete(); | file.renameTo(new File(KEY_FILE_PATH + ".bak")); | public static void writeKey(EncryptedKey encryptedKey) throws FileNotFoundException, IOException { File file = new File(KEY_FILE_PATH); if(file.exists()){ file.delete(); } file.createNewFile(); FileOutputStream fos = new FileOutputStream(file); fos.write(encryptedKey.get()); fos.flush(); fos.close(); } |
if(password == null){ assert plaintextPassword != null; password = Crypto.hash(plaintextPassword); } | public String getPassword() { return password; } |
|
System.err.println( "Is rot handle? " + isHandle ); | log.debug( "Is rot handle? " + isHandle ); | private boolean isRotHandleAt( int x, int y ) { int accuracy = 10; int dx = x - rotHandleX[1]; int dy = y - rotHandleY[1]; boolean isHandle = ( dx*dx + dy*dy < accuracy * accuracy ); System.err.println( "Is rot handle? " + isHandle ); return isHandle; } |
System.err.println( "Moving handle " + handleMoving ); | log.debug( "Moving handle " + handleMoving ); | public void mousePressed(MouseEvent mouseEvent) { if ( !drawCropped ) { // Check if we clicked on a handle handleMoving = getHandleAt( mouseEvent.getX(), mouseEvent.getY() ); System.err.println( "Moving handle " + handleMoving ); if ( handleMoving < 0 ) { isRotating = isRotHandleAt( mouseEvent.getX(), mouseEvent.getY() ); } } } |
System.err.println( "New rotation " + cropBorderRot ); | log.debug( "New rotation " + cropBorderRot ); | private void rotateCrop( int newx, int newy ) { // Calculate new rotation double dx = newx-imgX-cropBorderX; double dy = newy-imgY-cropBorderY; if ( Math.abs( dy ) > 0.0001 ) { cropBorderRot = -Math.atan( dx/dy ); } else { cropBorderRot = 0; } if ( dy > 0 ) { cropBorderRot += Math.PI; } System.err.println( "New rotation " + cropBorderRot ); calcCropBorderCoords(); } |
ServiceDiscovery discovery = getServiceDiscovery(); | DiscoverClasses discovery = getDiscoverClasses(); | public TagLibrary resolveTagLibrary(String uri) { ServiceDiscovery discovery = getServiceDiscovery(); String name = uri; if ( uri.startsWith( "jelly:" ) ) { name = "jelly." + uri.substring(6); } log.info( "Looking up service name: " + name ); ServiceInfo[] infoArray = discovery.findServices(name); if ( infoArray != null && infoArray.length > 0 ) { for (int i = 0; i < infoArray.length; i++ ) { ServiceInfo info = infoArray[i]; try { Class typeClass = info.getLoader().loadClass( info.getImplName() ); if ( typeClass != null ) { return newInstance(uri, typeClass); } } catch (Exception e) { log.error( "Could not load service: " + info.getImplName() + " with loader: " + info.getLoader() ); } } } else { log.info( "Could not find any services for name: " + name ); } return null; } |
ServiceInfo[] infoArray = discovery.findServices(name); if ( infoArray != null && infoArray.length > 0 ) { for (int i = 0; i < infoArray.length; i++ ) { ServiceInfo info = infoArray[i]; try { Class typeClass = info.getLoader().loadClass( info.getImplName() ); if ( typeClass != null ) { return newInstance(uri, typeClass); } } catch (Exception e) { log.error( "Could not load service: " + info.getImplName() + " with loader: " + info.getLoader() ); | ResourceClassIterator iter = discovery.findResourceClasses(name); while (iter.hasNext()) { ResourceClass resource = iter.nextResourceClass(); try { Class typeClass = resource.loadClass(); if ( typeClass != null ) { return newInstance(uri, typeClass); | public TagLibrary resolveTagLibrary(String uri) { ServiceDiscovery discovery = getServiceDiscovery(); String name = uri; if ( uri.startsWith( "jelly:" ) ) { name = "jelly." + uri.substring(6); } log.info( "Looking up service name: " + name ); ServiceInfo[] infoArray = discovery.findServices(name); if ( infoArray != null && infoArray.length > 0 ) { for (int i = 0; i < infoArray.length; i++ ) { ServiceInfo info = infoArray[i]; try { Class typeClass = info.getLoader().loadClass( info.getImplName() ); if ( typeClass != null ) { return newInstance(uri, typeClass); } } catch (Exception e) { log.error( "Could not load service: " + info.getImplName() + " with loader: " + info.getLoader() ); } } } else { log.info( "Could not find any services for name: " + name ); } return null; } |
else { log.info( "Could not find any services for name: " + name ); } | log.info( "Could not find any services for name: " + name ); | public TagLibrary resolveTagLibrary(String uri) { ServiceDiscovery discovery = getServiceDiscovery(); String name = uri; if ( uri.startsWith( "jelly:" ) ) { name = "jelly." + uri.substring(6); } log.info( "Looking up service name: " + name ); ServiceInfo[] infoArray = discovery.findServices(name); if ( infoArray != null && infoArray.length > 0 ) { for (int i = 0; i < infoArray.length; i++ ) { ServiceInfo info = infoArray[i]; try { Class typeClass = info.getLoader().loadClass( info.getImplName() ); if ( typeClass != null ) { return newInstance(uri, typeClass); } } catch (Exception e) { log.error( "Could not load service: " + info.getImplName() + " with loader: " + info.getLoader() ); } } } else { log.info( "Could not find any services for name: " + name ); } return null; } |
architectSession = ArchitectSession.getInstance(); | architectSession = ArchitectSessionImpl.getInstance(); | private ArchitectFrame() throws ArchitectException { synchronized (ArchitectFrame.class) { mainInstance = this; } setIconImage(new ImageIcon(getClass().getResource("/icons/Architect16.png")).getImage()); // close handled by window listener setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); architectSession = ArchitectSession.getInstance(); prefs = PrefsUtils.getUserPrefsNode(architectSession); init(); } |
public CoreUserSettings getUserSettings() { return this.userSettings; } | public CoreUserSettings getUserSettings(); | public CoreUserSettings getUserSettings() { return this.userSettings; } |
logger.debug("Pruning dead jar entry " + i); | public UserSettings read(ArchitectSession session) throws IOException { logger.debug("reading UserSettings from java.util.prefs."); Preferences prefs = ArchitectFrame.getMainInstance().getPrefs(); UserSettings userSettings = new UserSettings(); int i; for (i = 0; i <= 99; i++) { String jarName = prefs.get(jarFilePrefName(i), null); logger.debug("read Jar File entry: " + jarName); if (jarName == null) { break; } logger.debug("Adding JarName: " + jarName); session.addDriverJar(jarName); } for (; i <= 99; i++) { logger.debug("Pruning dead jar entry " + i); prefs.remove(jarFilePrefName(i)); } userSettings.setPlDotIniPath(prefs.get("PL.INI.PATH", defaultHomeFile("pl.ini"))); SwingUserSettings swingUserSettings = userSettings.getSwingSettings(); swingUserSettings.setBoolean(SwingUserSettings.PLAYPEN_RENDER_ANTIALIASED, prefs.getBoolean(SwingUserSettings.PLAYPEN_RENDER_ANTIALIASED, false)); ETLUserSettings etlUserSettings = userSettings.getETLUserSettings(); etlUserSettings.setPowerLoaderEnginePath( prefs.get(ETLUserSettings.PROP_PL_ENGINE_PATH, "")); etlUserSettings.setETLLogPath( prefs.get(ETLUserSettings.PROP_ETL_LOG_PATH, defaultHomeFile("etl.log"))); DDLUserSettings ddlUserSettings = userSettings.getDDLUserSettings(); ddlUserSettings.setDDLLogPath(prefs.get(DDLUserSettings.PROP_DDL_LOG_PATH, defaultHomeFile("ddl.log"))); PrintUserSettings printUserSettings = userSettings.getPrintUserSettings(); printUserSettings.setDefaultPrinterName( prefs.get(PrintUserSettings.DEFAULT_PRINTER_NAME, "")); return userSettings; } |
|
public void setUserSettings(CoreUserSettings argUserSettings) { this.userSettings = argUserSettings; } | public void setUserSettings(CoreUserSettings argUserSettings); | public void setUserSettings(CoreUserSettings argUserSettings) { this.userSettings = argUserSettings; } |
kit = new HTMLEditorKit(); editorPane.setEditorKit(kit); | public HelpAction() { super("Help",ASUtils.createJLFIcon( "general/Help", "Help", ArchitectFrame.getMainInstance().getSprefs().getInt(SwingUserSettings.ICON_SIZE, 24))); putValue(AbstractAction.SHORT_DESCRIPTION, "Help"); editorPane = new JEditorPane(); editorPane.setEditable(false); editorPane.setPreferredSize(new Dimension(600,600)); editorPane.addHyperlinkListener(new Hyperactive()); //kit = (HTMLEditorKit) editorPane.createEditorKitForContentType(null); kit = new HTMLEditorKit(); editorPane.setEditorKit(kit);// doc = (HTMLDocument) kit.createDefaultDocument(); buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); homeAction = new AbstractAction("Home", ASUtils.createJLFIcon( "navigation/Home", "Help", ArchitectFrame.getMainInstance().getSprefs().getInt(SwingUserSettings.ICON_SIZE, 16)) ) { public void actionPerformed(ActionEvent evt) { try { editorPane.setPage(urlStr); history.add(urlStr); } catch (IOException e) { e.printStackTrace(); } resetButtoms(); } }; homeAction.putValue(Action.NAME, "Home"); JButton homeButton = new JButton(homeAction); buttonPanel.add(homeButton); backAction = new AbstractAction("Back", ASUtils.createJLFIcon( "navigation/Back", "Back", ArchitectFrame.getMainInstance().getSprefs().getInt(SwingUserSettings.ICON_SIZE, 16)) ) { public void actionPerformed(ActionEvent evt) { URL url = history.getBack(); if ( url == null ) return; try { editorPane.setPage(url); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } resetButtoms(); } }; backAction.putValue(Action.NAME, "Back"); JButton backButton = new JButton(backAction); buttonPanel.add(backButton); forwardAction = new AbstractAction("Forward", ASUtils.createJLFIcon( "navigation/Forward", "Forward", ArchitectFrame.getMainInstance().getSprefs().getInt(SwingUserSettings.ICON_SIZE, 16)) ) { public void actionPerformed(ActionEvent evt) { URL url = history.getForward(); if ( url == null ) return; try { editorPane.setPage(url); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } resetButtoms(); } }; forwardAction.putValue(Action.NAME, "Forward"); JButton forwardButton = new JButton(forwardAction); buttonPanel.add(forwardButton); printHelpAction = new AbstractAction("Print", ASUtils.createJLFIcon( "general/Print", "Print", ArchitectFrame.getMainInstance().getSprefs().getInt(SwingUserSettings.ICON_SIZE, 16)) ) { public void actionPerformed(ActionEvent evt) { final HelpPrintPanel printPanel = new HelpPrintPanel(editorPane); final JDialog d = ArchitectPanelBuilder.createArchitectPanelDialog( printPanel, ArchitectFrame.getMainInstance(), "Print", "Print"); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); } }; printHelpAction.putValue(Action.NAME, "Print"); JButton printButton = new JButton(printHelpAction); buttonPanel.add(printButton); history = new URLHistroyList(); } |
|
return new Dimension(maxSourceWidth + sourceTargetGap + maxTargetWidth, y - unrelatedSourcesGap); | return new Dimension(maxSourceWidth + sourceTargetGap + maxTargetWidth, y ); | public Dimension drawHighLevelReport(Graphics2D g, Dimension pageSize) throws ArchitectException { int y = 0; for (Map.Entry<SQLTable, Collection<SQLTable>> entry : mappings.entrySet()) { SQLTable st = entry.getKey(); Collection<SQLTable> targets = entry.getValue(); if (pageSize != null) { int clusterSize = drawSourceTargetCluster(null, panes, maxSourceWidth, maxTargetWidth, y, st, targets); if ((y % pageSize.height)+(clusterSize%pageSize.height) >= pageSize.height){ y += pageSize.height - (y % pageSize.height); } } y = drawSourceTargetCluster(g, panes, maxSourceWidth, maxTargetWidth, y, st, targets); } return new Dimension(maxSourceWidth + sourceTargetGap + maxTargetWidth, y - unrelatedSourcesGap); } |
public void setPlayPen(PlayPen newPP) { | public void setPlayPen(PlayPen newPP) throws ArchitectException { | public void setPlayPen(PlayPen newPP) { if (pp != null) { pp.removeSelectionListener(this); } pp = newPP; pp.addSelectionListener(this); } |
setupAction(pp.getSelectedItems()); | public void setPlayPen(PlayPen newPP) { if (pp != null) { pp.removeSelectionListener(this); } pp = newPP; pp.addSelectionListener(this); } |
|
if (pp != null) { pp.removeSelectionListener(this); } this.pp = pp; this.pp.addSelectionListener(this); | setupAction(pp.getSelectedItems()); | public void setPlayPen(PlayPen pp) { if (pp != null) { pp.removeSelectionListener(this); } this.pp = pp; this.pp.addSelectionListener(this); } |
if (pp != null) { pp.removeSelectionListener(this); } this.pp = pp; this.pp.addSelectionListener(this); | if (this.pp != null) { this.pp.removeSelectionListener(this); } this.pp=pp; pp.addSelectionListener(this); setupAction(pp.getSelectedItems()); | public void setPlayPen(PlayPen pp) { if (pp != null) { pp.removeSelectionListener(this); } this.pp = pp; this.pp.addSelectionListener(this); } |
firstMouseEvent = mouseEvent; | public void mousePressed(MouseEvent mouseEvent) { } |
|
firstMouseEvent = null; | public void mouseReleased(MouseEvent mouseEvent) { } |
|
repaint(); } | revalidate(); repaint(); } | public void photoCollectionChanged( PhotoCollectionChangeEvent e ) { repaint(); } |
photoCollection = v; photoCollection.addPhotoCollectionChangeListener( this ); revalidate(); | photoCollection = v; photoCollection.addPhotoCollectionChangeListener( this ); revalidate(); repaint(); | public void setCollection(PhotoCollection v) { if ( photoCollection != null ) { photoCollection.removePhotoCollectionChangeListener( this ); } photoCollection = v; photoCollection.addPhotoCollectionChangeListener( this ); revalidate(); } |
this.mbeanServer = mbeanServer; | this.mbeanServer = (RemoteMBeanServer)mbeanServer; | public WLServerConnection(MBeanServer mbeanServer){ assert mbeanServer != null; this.mbeanServer = mbeanServer; } |
Options.maxDistance = maxDistance; | Options.maxDistance = maxDistance*1000; | public static void setMaxDistance(int maxDistance) { Options.maxDistance = maxDistance; } |
if (filter == null) { return Filter.getOpenFilter(getStorableType()); } | public Filter<S> getFilter() { Filter<S> filter = mIdentityFilter; for (PropertyFilter<S> p : mExclusiveRangeStartFilters) { filter = filter == null ? p : filter.and(p); } for (PropertyFilter<S> p : mInclusiveRangeStartFilters) { filter = filter == null ? p : filter.and(p); } for (PropertyFilter<S> p : mExclusiveRangeEndFilters) { filter = filter == null ? p : filter.and(p); } for (PropertyFilter<S> p : mInclusiveRangeEndFilters) { filter = filter == null ? p : filter.and(p); } return filter; } |
|
/* Uncomment for testing if (mBindID != 0) { | if (mBindID > 1) { | public void appendTo(Appendable app, FilterValues<S> values) throws IOException { mProperty.appendTo(app); app.append(' '); app.append(mOp.toString()); app.append(' '); if (values != null) { Object value = values.getValue(this); if (value != null || values.isAssigned(this)) { app.append(String.valueOf(value)); return; } } if (mBindID == BOUND_CONSTANT) { app.append(String.valueOf(mConstant)); } else { app.append('?'); /* Uncomment for testing if (mBindID != 0) { app.append('[').append(String.valueOf(mBindID)).append(']'); } */ } } |
*/ | public void appendTo(Appendable app, FilterValues<S> values) throws IOException { mProperty.appendTo(app); app.append(' '); app.append(mOp.toString()); app.append(' '); if (values != null) { Object value = values.getValue(this); if (value != null || values.isAssigned(this)) { app.append(String.valueOf(value)); return; } } if (mBindID == BOUND_CONSTANT) { app.append(String.valueOf(mConstant)); } else { app.append('?'); /* Uncomment for testing if (mBindID != 0) { app.append('[').append(String.valueOf(mBindID)).append(']'); } */ } } |
|
println("<setting name=\""+escape(prefName) +"\" value=\""+escape(props.getProperty(prefName))+"\" />"); | println("<setting name=\""+ArchitectUtils.escapeXML(prefName) +"\" value=\""+ArchitectUtils.escapeXML(props.getProperty(prefName))+"\" />"); | protected void writeDDLUserSettings(DDLUserSettings ddlprefs) { println("<ddl-user-settings>"); indent++; Properties props = ddlprefs.toPropList(); Iterator it = props.keySet().iterator(); while (it.hasNext()) { String prefName = (String) it.next(); println("<setting name=\""+escape(prefName) +"\" value=\""+escape(props.getProperty(prefName))+"\" />"); } indent--; println("</ddl-user-settings>"); } |
println("<setting name=\""+escape(prefName) +"\" value=\""+escape(props.getProperty(prefName))+"\" />"); | println("<setting name=\""+ArchitectUtils.escapeXML(prefName) +"\" value=\""+ArchitectUtils.escapeXML(props.getProperty(prefName))+"\" />"); | protected void writeETLUserSettings(ETLUserSettings etlprefs) { println("<etl-user-settings>"); indent++; Properties props = etlprefs.toPropList(); Iterator it = props.keySet().iterator(); while (it.hasNext()) { String prefName = (String) it.next(); println("<setting name=\""+escape(prefName) +"\" value=\""+escape(props.getProperty(prefName))+"\" />"); } indent--; println("</etl-user-settings>"); } |
println("<setting name=\""+escape(prefName) +"\" value=\""+escape(props.getProperty(prefName))+"\" />"); | println("<setting name=\""+ArchitectUtils.escapeXML(prefName) +"\" value=\""+ArchitectUtils.escapeXML(props.getProperty(prefName))+"\" />"); | protected void writePrintUserSettings(PrintUserSettings printPrefs) { println("<print-user-settings>"); indent++; Properties props = printPrefs.toPropList(); Iterator it = props.keySet().iterator(); while (it.hasNext()) { String prefName = (String) it.next(); println("<setting name=\""+escape(prefName) +"\" value=\""+escape(props.getProperty(prefName))+"\" />"); } indent--; println("</print-user-settings>"); } |
println("<setting name=\""+escape(prefName) +"\" class=\""+escape(pref.getClass().getName()) +"\" value=\""+escape(pref.toString())+"\" />"); | println("<setting name=\""+ArchitectUtils.escapeXML(prefName) +"\" class=\""+ArchitectUtils.escapeXML(pref.getClass().getName()) +"\" value=\""+ArchitectUtils.escapeXML(pref.toString())+"\" />"); | protected void writeSwingSettings(SwingUserSettings sprefs) { println("<swing-gui-settings>"); indent++; Iterator it = sprefs.getSettingNames().iterator(); while (it.hasNext()) { String prefName = (String) it.next(); Object pref = sprefs.getObject(prefName, ""); println("<setting name=\""+escape(prefName) +"\" class=\""+escape(pref.getClass().getName()) +"\" value=\""+escape(pref.toString())+"\" />"); } indent--; println("</swing-gui-settings>"); } |
printUserSettings = new PrintUserSettings(); | public UserSettings() { super(); dbConnections = new LinkedList(); swingSettings = new SwingUserSettings(); etlUserSettings = new ETLUserSettings(); ddlUserSettings = new DDLUserSettings(); } |
|
public List<String> getDriverJarList() { return Collections.unmodifiableList(driverJarList); } | public List<String> getDriverJarList(); | public List<String> getDriverJarList() { return Collections.unmodifiableList(driverJarList); } |
public XWikiStoreInterface getStore() { return store; | public XWikiStoreInterface getStore(XWikiContext context) { return context.getWiki().getStore(); | public XWikiStoreInterface getStore() { return store; } |
public String toXML(XWikiContext context) throws XWikiException { Document doc = toXMLDocument(context); return toXML(doc, context); | public String toXML(Document doc, XWikiContext context) { OutputFormat outputFormat = new OutputFormat("", true); if ((context == null) || (context.getWiki() == null)) outputFormat.setEncoding("UTF-8"); else outputFormat.setEncoding(context.getWiki().getEncoding()); StringWriter out = new StringWriter(); XMLWriter writer = new XMLWriter(out, outputFormat); try { writer.write(doc); return out.toString(); } catch (IOException e) { e.printStackTrace(); return ""; } | public String toXML(XWikiContext context) throws XWikiException { Document doc = toXMLDocument(context); return toXML(doc, context); } |
public XWikiDocumentArchive getDocumentArchive() { if (archive==null) return null; else return (XWikiDocumentArchive) archive.get(); | public XWikiDocumentArchive getDocumentArchive(XWikiContext context) throws XWikiException { loadArchive(context); return getDocumentArchive(); | public XWikiDocumentArchive getDocumentArchive() { // We are using a SoftReference which will allow the archive to be // discarded by the Garbage collector as long as the context is closed (usually during the request) if (archive==null) return null; else return (XWikiDocumentArchive) archive.get(); } |
ASUtils.LabelValueBean lvb = (ASUtils.LabelValueBean) connectionsBox.getSelectedItem(); if (lvb.getValue() == null) { | ArchitectDataSource dataSource = (ArchitectDataSource) connectionsBox.getSelectedItem(); if (dataSource == null) { | public void actionPerformed(ActionEvent e) { logger.debug("event was fired"); ASUtils.LabelValueBean lvb = (ASUtils.LabelValueBean) connectionsBox.getSelectedItem(); if (lvb.getValue() == null) { runPLEngine.setSelected(false); runPLEngine.setEnabled(false); plRepOwner.setText(null); plUserName.setText(null); plPassword.setText(null); } else { runPLEngine.setEnabled(true); PLConnectionSpec pldbcon = (PLConnectionSpec) lvb.getValue(); plRepOwner.setText(pldbcon.getPlsOwner()); plUserName.setText(pldbcon.getUid()); plPassword.setText(pldbcon.getPwd()); } } |
PLConnectionSpec pldbcon = (PLConnectionSpec) lvb.getValue(); plRepOwner.setText(pldbcon.getPlsOwner()); plUserName.setText(pldbcon.getUid()); plPassword.setText(pldbcon.getPwd()); | plRepOwner.setText(dataSource.get(ArchitectDataSource.PL_SCHEMA_OWNER)); plUserName.setText(dataSource.get(ArchitectDataSource.PL_UID)); plPassword.setText(dataSource.get(ArchitectDataSource.PL_PWD)); | public void actionPerformed(ActionEvent e) { logger.debug("event was fired"); ASUtils.LabelValueBean lvb = (ASUtils.LabelValueBean) connectionsBox.getSelectedItem(); if (lvb.getValue() == null) { runPLEngine.setSelected(false); runPLEngine.setEnabled(false); plRepOwner.setText(null); plUserName.setText(null); plPassword.setText(null); } else { runPLEngine.setEnabled(true); PLConnectionSpec pldbcon = (PLConnectionSpec) lvb.getValue(); plRepOwner.setText(pldbcon.getPlsOwner()); plUserName.setText(pldbcon.getUid()); plPassword.setText(pldbcon.getPwd()); } } |
double[] prob = new double[num_poss]; | MapWrap probMap = new MapWrap(PSEUDOCOUNT); | private void full_em_breakup( byte[][] input_haplos, int[] block_size, Vector affStatus, Vector kidAffStatus) throws HaploViewException{ int num_poss, iter; double total = 0; int block, start_locus, end_locus, biggest_block_size; int num_indivs = 0; int num_blocks = block_size.length; int num_haplos = input_haplos.length; int num_loci = input_haplos[0].length; Recovery tempRec; if (num_loci > MAXLOCI){ throw new HaploViewException("Too many loci in a single block (> "+MAXLOCI+" non-redundant)"); } //figure out the size of the biggest block biggest_block_size=block_size[0]; for (int i=1; i<num_blocks; i++) { if (block_size[i] > biggest_block_size) biggest_block_size=block_size[i]; } num_poss = two_n[biggest_block_size]; data = new OBS[num_haplos/2]; for (int i=0; i<num_haplos/2; i++) data[i]= new OBS(); superdata = new SUPER_OBS[num_haplos/2]; for (int i=0; i<num_haplos/2; i++) superdata[i]= new SUPER_OBS(num_blocks); double[][] hprob = new double[num_blocks][num_poss]; int[][] hlist = new int[num_blocks][num_poss]; int[] num_hlist = new int[num_blocks]; int[] hint = new int[num_poss]; double[] prob = new double[num_poss]; /*MapWrap probMap = new MapWrap(PSEUDOCOUNT);*/ /* for trio option */ if (Options.getAssocTest() == ASSOC_TRIO) { ambighet = new int[(num_haplos/4)][num_loci]; store_dhet_status(num_haplos,num_loci,input_haplos); } end_locus=-1; //now we loop through the blocks for (block=0; block<num_blocks; block++) { start_locus=end_locus+1; end_locus=start_locus+block_size[block]-1; num_poss=two_n[block_size[block]]; //read_observations initializes the values in data[] (array of OBS) num_indivs=read_observations(num_haplos,num_loci,input_haplos,start_locus,end_locus); prob = estimateProbsSmall(num_indivs,num_poss); int m=0; for(long j=0;j<num_poss; j++){ hint[(int)j]=-1; //if (probMap.get(new Long(j)) > .001) { if(prob[((int) j)] > .001) { // printf("haplo %s p = %.4lf\n",haplo_str(j,block_size[block]),prob[j]); hlist[block][m]=(int)j; /*hprob[block][m]=probMap.get(new Long(j));*/ hprob[block][m] = prob[((int) j)]; hint[(int)j]=m; m++; } } num_hlist[block]=m; // store current block results in super obs structure store_block_haplos(hlist, hprob, hint, block, num_indivs); } /* for each block */ double poss_full=1; for (block=0; block<num_blocks; block++) { poss_full *= num_hlist[block]; } /* LIGATE and finish this mess :) */ create_super_haplos(num_indivs,num_blocks,num_hlist); if(poss_full < Integer.MAX_VALUE) { finishLarge(num_indivs, poss_full,kidAffStatus, num_blocks,block_size,num_hlist,hlist, num_loci); }else { finishSmall(num_indivs,(int) poss_full,kidAffStatus, num_blocks,block_size,num_hlist,hlist, num_loci); } if(Options.getAssocTest() == ASSOC_TRIO) { kidConsistentCache = new boolean[numFilteredTrios][][]; for(int i=0;i<numFilteredTrios*2;i+=2) { if (((Integer)kidAffStatus.elementAt(i)).intValue() == 2){ kidConsistentCache[i/2] = new boolean[superdata[i].nsuper][]; for (int n=0; n<superdata[i].nsuper; n++) { kidConsistentCache[i/2][n] = new boolean[superdata[i+1].nsuper]; for (int m=0; m<superdata[i+1].nsuper; m++) { kidConsistentCache[i/2][n][m] = kid_consistent(superdata[i].superposs[n].h1, superdata[i+1].superposs[m].h1,num_blocks, block_size,hlist,num_hlist,i/2,num_loci); } } } } } realAffectedStatus = affStatus; doAssociationTests(affStatus, null, kidAffStatus); /* if (dump_phased_haplos) { if ((fpdump=fopen("emphased.haps","w"))!=NULL) { for (i=0; i<num_indivs; i++) { best=0; for (k=0; k<superdata[i].nsuper; k++) { if (superdata[i].superposs[k].p > superdata[i].superposs[best].p) { best=k; } } h1 = superdata[i].superposs[best].h1; h2 = superdata[i].superposs[best].h2; fprintf(fpdump,"%s\n",decode_haplo_str(h1,num_blocks,block_size,hlist,num_hlist)); fprintf(fpdump,"%s\n",decode_haplo_str(h2,num_blocks,block_size,hlist,num_hlist)); } fclose(fpdump); } } */ //return 0; } |
prob = estimateProbsSmall(num_indivs,num_poss); | total=(double)num_poss; total *= PSEUDOCOUNT; for (int i=0; i<num_indivs; i++) { if (data[i].nposs==1) { tempRec = (Recovery)data[i].poss.elementAt(0); probMap.put(new Long(tempRec.h1), probMap.get(new Long(tempRec.h1)) + 1.0); probMap.put(new Long(tempRec.h2), probMap.get(new Long(tempRec.h2)) + 1.0); total+=2.0; } } probMap.normalize(total); iter=0; while (iter<20) { for (int i=0; i<num_indivs; i++) { total=0.0; for (int k=0; k<data[i].nposs; k++) { tempRec = (Recovery) data[i].poss.elementAt(k); tempRec.p = (float)(probMap.get(new Long(tempRec.h1))*probMap.get(new Long(tempRec.h2))); total+=tempRec.p; } for (int k=0; k<data[i].nposs; k++) { tempRec = (Recovery) data[i].poss.elementAt(k); tempRec.p /= total; } } probMap = new MapWrap(1e-10); total=num_poss*1e-10; for (int i=0; i<num_indivs; i++) { for (int k=0; k<data[i].nposs; k++) { tempRec = (Recovery) data[i].poss.elementAt(k); probMap.put(new Long(tempRec.h1),probMap.get(new Long(tempRec.h1)) + tempRec.p); probMap.put(new Long(tempRec.h2),probMap.get(new Long(tempRec.h2)) + tempRec.p); total+=(2.0*(tempRec.p)); } } probMap.normalize(total); iter++; } | private void full_em_breakup( byte[][] input_haplos, int[] block_size, Vector affStatus, Vector kidAffStatus) throws HaploViewException{ int num_poss, iter; double total = 0; int block, start_locus, end_locus, biggest_block_size; int num_indivs = 0; int num_blocks = block_size.length; int num_haplos = input_haplos.length; int num_loci = input_haplos[0].length; Recovery tempRec; if (num_loci > MAXLOCI){ throw new HaploViewException("Too many loci in a single block (> "+MAXLOCI+" non-redundant)"); } //figure out the size of the biggest block biggest_block_size=block_size[0]; for (int i=1; i<num_blocks; i++) { if (block_size[i] > biggest_block_size) biggest_block_size=block_size[i]; } num_poss = two_n[biggest_block_size]; data = new OBS[num_haplos/2]; for (int i=0; i<num_haplos/2; i++) data[i]= new OBS(); superdata = new SUPER_OBS[num_haplos/2]; for (int i=0; i<num_haplos/2; i++) superdata[i]= new SUPER_OBS(num_blocks); double[][] hprob = new double[num_blocks][num_poss]; int[][] hlist = new int[num_blocks][num_poss]; int[] num_hlist = new int[num_blocks]; int[] hint = new int[num_poss]; double[] prob = new double[num_poss]; /*MapWrap probMap = new MapWrap(PSEUDOCOUNT);*/ /* for trio option */ if (Options.getAssocTest() == ASSOC_TRIO) { ambighet = new int[(num_haplos/4)][num_loci]; store_dhet_status(num_haplos,num_loci,input_haplos); } end_locus=-1; //now we loop through the blocks for (block=0; block<num_blocks; block++) { start_locus=end_locus+1; end_locus=start_locus+block_size[block]-1; num_poss=two_n[block_size[block]]; //read_observations initializes the values in data[] (array of OBS) num_indivs=read_observations(num_haplos,num_loci,input_haplos,start_locus,end_locus); prob = estimateProbsSmall(num_indivs,num_poss); int m=0; for(long j=0;j<num_poss; j++){ hint[(int)j]=-1; //if (probMap.get(new Long(j)) > .001) { if(prob[((int) j)] > .001) { // printf("haplo %s p = %.4lf\n",haplo_str(j,block_size[block]),prob[j]); hlist[block][m]=(int)j; /*hprob[block][m]=probMap.get(new Long(j));*/ hprob[block][m] = prob[((int) j)]; hint[(int)j]=m; m++; } } num_hlist[block]=m; // store current block results in super obs structure store_block_haplos(hlist, hprob, hint, block, num_indivs); } /* for each block */ double poss_full=1; for (block=0; block<num_blocks; block++) { poss_full *= num_hlist[block]; } /* LIGATE and finish this mess :) */ create_super_haplos(num_indivs,num_blocks,num_hlist); if(poss_full < Integer.MAX_VALUE) { finishLarge(num_indivs, poss_full,kidAffStatus, num_blocks,block_size,num_hlist,hlist, num_loci); }else { finishSmall(num_indivs,(int) poss_full,kidAffStatus, num_blocks,block_size,num_hlist,hlist, num_loci); } if(Options.getAssocTest() == ASSOC_TRIO) { kidConsistentCache = new boolean[numFilteredTrios][][]; for(int i=0;i<numFilteredTrios*2;i+=2) { if (((Integer)kidAffStatus.elementAt(i)).intValue() == 2){ kidConsistentCache[i/2] = new boolean[superdata[i].nsuper][]; for (int n=0; n<superdata[i].nsuper; n++) { kidConsistentCache[i/2][n] = new boolean[superdata[i+1].nsuper]; for (int m=0; m<superdata[i+1].nsuper; m++) { kidConsistentCache[i/2][n][m] = kid_consistent(superdata[i].superposs[n].h1, superdata[i+1].superposs[m].h1,num_blocks, block_size,hlist,num_hlist,i/2,num_loci); } } } } } realAffectedStatus = affStatus; doAssociationTests(affStatus, null, kidAffStatus); /* if (dump_phased_haplos) { if ((fpdump=fopen("emphased.haps","w"))!=NULL) { for (i=0; i<num_indivs; i++) { best=0; for (k=0; k<superdata[i].nsuper; k++) { if (superdata[i].superposs[k].p > superdata[i].superposs[best].p) { best=k; } } h1 = superdata[i].superposs[best].h1; h2 = superdata[i].superposs[best].h2; fprintf(fpdump,"%s\n",decode_haplo_str(h1,num_blocks,block_size,hlist,num_hlist)); fprintf(fpdump,"%s\n",decode_haplo_str(h2,num_blocks,block_size,hlist,num_hlist)); } fclose(fpdump); } } */ //return 0; } |
if(prob[((int) j)] > .001) { | if (probMap.get(new Long(j)) > .001) { | private void full_em_breakup( byte[][] input_haplos, int[] block_size, Vector affStatus, Vector kidAffStatus) throws HaploViewException{ int num_poss, iter; double total = 0; int block, start_locus, end_locus, biggest_block_size; int num_indivs = 0; int num_blocks = block_size.length; int num_haplos = input_haplos.length; int num_loci = input_haplos[0].length; Recovery tempRec; if (num_loci > MAXLOCI){ throw new HaploViewException("Too many loci in a single block (> "+MAXLOCI+" non-redundant)"); } //figure out the size of the biggest block biggest_block_size=block_size[0]; for (int i=1; i<num_blocks; i++) { if (block_size[i] > biggest_block_size) biggest_block_size=block_size[i]; } num_poss = two_n[biggest_block_size]; data = new OBS[num_haplos/2]; for (int i=0; i<num_haplos/2; i++) data[i]= new OBS(); superdata = new SUPER_OBS[num_haplos/2]; for (int i=0; i<num_haplos/2; i++) superdata[i]= new SUPER_OBS(num_blocks); double[][] hprob = new double[num_blocks][num_poss]; int[][] hlist = new int[num_blocks][num_poss]; int[] num_hlist = new int[num_blocks]; int[] hint = new int[num_poss]; double[] prob = new double[num_poss]; /*MapWrap probMap = new MapWrap(PSEUDOCOUNT);*/ /* for trio option */ if (Options.getAssocTest() == ASSOC_TRIO) { ambighet = new int[(num_haplos/4)][num_loci]; store_dhet_status(num_haplos,num_loci,input_haplos); } end_locus=-1; //now we loop through the blocks for (block=0; block<num_blocks; block++) { start_locus=end_locus+1; end_locus=start_locus+block_size[block]-1; num_poss=two_n[block_size[block]]; //read_observations initializes the values in data[] (array of OBS) num_indivs=read_observations(num_haplos,num_loci,input_haplos,start_locus,end_locus); prob = estimateProbsSmall(num_indivs,num_poss); int m=0; for(long j=0;j<num_poss; j++){ hint[(int)j]=-1; //if (probMap.get(new Long(j)) > .001) { if(prob[((int) j)] > .001) { // printf("haplo %s p = %.4lf\n",haplo_str(j,block_size[block]),prob[j]); hlist[block][m]=(int)j; /*hprob[block][m]=probMap.get(new Long(j));*/ hprob[block][m] = prob[((int) j)]; hint[(int)j]=m; m++; } } num_hlist[block]=m; // store current block results in super obs structure store_block_haplos(hlist, hprob, hint, block, num_indivs); } /* for each block */ double poss_full=1; for (block=0; block<num_blocks; block++) { poss_full *= num_hlist[block]; } /* LIGATE and finish this mess :) */ create_super_haplos(num_indivs,num_blocks,num_hlist); if(poss_full < Integer.MAX_VALUE) { finishLarge(num_indivs, poss_full,kidAffStatus, num_blocks,block_size,num_hlist,hlist, num_loci); }else { finishSmall(num_indivs,(int) poss_full,kidAffStatus, num_blocks,block_size,num_hlist,hlist, num_loci); } if(Options.getAssocTest() == ASSOC_TRIO) { kidConsistentCache = new boolean[numFilteredTrios][][]; for(int i=0;i<numFilteredTrios*2;i+=2) { if (((Integer)kidAffStatus.elementAt(i)).intValue() == 2){ kidConsistentCache[i/2] = new boolean[superdata[i].nsuper][]; for (int n=0; n<superdata[i].nsuper; n++) { kidConsistentCache[i/2][n] = new boolean[superdata[i+1].nsuper]; for (int m=0; m<superdata[i+1].nsuper; m++) { kidConsistentCache[i/2][n][m] = kid_consistent(superdata[i].superposs[n].h1, superdata[i+1].superposs[m].h1,num_blocks, block_size,hlist,num_hlist,i/2,num_loci); } } } } } realAffectedStatus = affStatus; doAssociationTests(affStatus, null, kidAffStatus); /* if (dump_phased_haplos) { if ((fpdump=fopen("emphased.haps","w"))!=NULL) { for (i=0; i<num_indivs; i++) { best=0; for (k=0; k<superdata[i].nsuper; k++) { if (superdata[i].superposs[k].p > superdata[i].superposs[best].p) { best=k; } } h1 = superdata[i].superposs[best].h1; h2 = superdata[i].superposs[best].h2; fprintf(fpdump,"%s\n",decode_haplo_str(h1,num_blocks,block_size,hlist,num_hlist)); fprintf(fpdump,"%s\n",decode_haplo_str(h2,num_blocks,block_size,hlist,num_hlist)); } fclose(fpdump); } } */ //return 0; } |
hprob[block][m] = prob[((int) j)]; | hprob[block][m]=probMap.get(new Long(j)); | private void full_em_breakup( byte[][] input_haplos, int[] block_size, Vector affStatus, Vector kidAffStatus) throws HaploViewException{ int num_poss, iter; double total = 0; int block, start_locus, end_locus, biggest_block_size; int num_indivs = 0; int num_blocks = block_size.length; int num_haplos = input_haplos.length; int num_loci = input_haplos[0].length; Recovery tempRec; if (num_loci > MAXLOCI){ throw new HaploViewException("Too many loci in a single block (> "+MAXLOCI+" non-redundant)"); } //figure out the size of the biggest block biggest_block_size=block_size[0]; for (int i=1; i<num_blocks; i++) { if (block_size[i] > biggest_block_size) biggest_block_size=block_size[i]; } num_poss = two_n[biggest_block_size]; data = new OBS[num_haplos/2]; for (int i=0; i<num_haplos/2; i++) data[i]= new OBS(); superdata = new SUPER_OBS[num_haplos/2]; for (int i=0; i<num_haplos/2; i++) superdata[i]= new SUPER_OBS(num_blocks); double[][] hprob = new double[num_blocks][num_poss]; int[][] hlist = new int[num_blocks][num_poss]; int[] num_hlist = new int[num_blocks]; int[] hint = new int[num_poss]; double[] prob = new double[num_poss]; /*MapWrap probMap = new MapWrap(PSEUDOCOUNT);*/ /* for trio option */ if (Options.getAssocTest() == ASSOC_TRIO) { ambighet = new int[(num_haplos/4)][num_loci]; store_dhet_status(num_haplos,num_loci,input_haplos); } end_locus=-1; //now we loop through the blocks for (block=0; block<num_blocks; block++) { start_locus=end_locus+1; end_locus=start_locus+block_size[block]-1; num_poss=two_n[block_size[block]]; //read_observations initializes the values in data[] (array of OBS) num_indivs=read_observations(num_haplos,num_loci,input_haplos,start_locus,end_locus); prob = estimateProbsSmall(num_indivs,num_poss); int m=0; for(long j=0;j<num_poss; j++){ hint[(int)j]=-1; //if (probMap.get(new Long(j)) > .001) { if(prob[((int) j)] > .001) { // printf("haplo %s p = %.4lf\n",haplo_str(j,block_size[block]),prob[j]); hlist[block][m]=(int)j; /*hprob[block][m]=probMap.get(new Long(j));*/ hprob[block][m] = prob[((int) j)]; hint[(int)j]=m; m++; } } num_hlist[block]=m; // store current block results in super obs structure store_block_haplos(hlist, hprob, hint, block, num_indivs); } /* for each block */ double poss_full=1; for (block=0; block<num_blocks; block++) { poss_full *= num_hlist[block]; } /* LIGATE and finish this mess :) */ create_super_haplos(num_indivs,num_blocks,num_hlist); if(poss_full < Integer.MAX_VALUE) { finishLarge(num_indivs, poss_full,kidAffStatus, num_blocks,block_size,num_hlist,hlist, num_loci); }else { finishSmall(num_indivs,(int) poss_full,kidAffStatus, num_blocks,block_size,num_hlist,hlist, num_loci); } if(Options.getAssocTest() == ASSOC_TRIO) { kidConsistentCache = new boolean[numFilteredTrios][][]; for(int i=0;i<numFilteredTrios*2;i+=2) { if (((Integer)kidAffStatus.elementAt(i)).intValue() == 2){ kidConsistentCache[i/2] = new boolean[superdata[i].nsuper][]; for (int n=0; n<superdata[i].nsuper; n++) { kidConsistentCache[i/2][n] = new boolean[superdata[i+1].nsuper]; for (int m=0; m<superdata[i+1].nsuper; m++) { kidConsistentCache[i/2][n][m] = kid_consistent(superdata[i].superposs[n].h1, superdata[i+1].superposs[m].h1,num_blocks, block_size,hlist,num_hlist,i/2,num_loci); } } } } } realAffectedStatus = affStatus; doAssociationTests(affStatus, null, kidAffStatus); /* if (dump_phased_haplos) { if ((fpdump=fopen("emphased.haps","w"))!=NULL) { for (i=0; i<num_indivs; i++) { best=0; for (k=0; k<superdata[i].nsuper; k++) { if (superdata[i].superposs[k].p > superdata[i].superposs[best].p) { best=k; } } h1 = superdata[i].superposs[best].h1; h2 = superdata[i].superposs[best].h2; fprintf(fpdump,"%s\n",decode_haplo_str(h1,num_blocks,block_size,hlist,num_hlist)); fprintf(fpdump,"%s\n",decode_haplo_str(h2,num_blocks,block_size,hlist,num_hlist)); } fclose(fpdump); } } */ //return 0; } |
if(poss_full < Integer.MAX_VALUE) { finishLarge(num_indivs, poss_full,kidAffStatus, num_blocks,block_size,num_hlist,hlist, num_loci); }else { finishSmall(num_indivs,(int) poss_full,kidAffStatus, num_blocks,block_size,num_hlist,hlist, num_loci); } | total = poss_full * PSEUDOCOUNT; for (int i=0; i<num_indivs; i++) { if (superdata[i].nsuper==1) { Long h1 = new Long(superdata[i].superposs[0].h1); Long h2 = new Long(superdata[i].superposs[0].h2); fullProbMap.put(h1,fullProbMap.get(h1) +1.0); fullProbMap.put(h2,fullProbMap.get(h2) +1.0); total+=2.0; } } fullProbMap.normalize(total); iter=0; while (iter<20) { for (int i=0; i<num_indivs; i++) { total=0.0; for (int k=0; k<superdata[i].nsuper; k++) { superdata[i].superposs[k].p = (float) (fullProbMap.get(new Long(superdata[i].superposs[k].h1))* fullProbMap.get(new Long(superdata[i].superposs[k].h2))); total+=superdata[i].superposs[k].p; } for (int k=0; k<superdata[i].nsuper; k++) { superdata[i].superposs[k].p /= total; } } fullProbMap = new MapWrap(1e-10); total=poss_full*1e-10; for (int i=0; i<num_indivs; i++) { for (int k=0; k<superdata[i].nsuper; k++) { fullProbMap.put(new Long(superdata[i].superposs[k].h1),fullProbMap.get(new Long(superdata[i].superposs[k].h1)) + superdata[i].superposs[k].p); fullProbMap.put(new Long(superdata[i].superposs[k].h2),fullProbMap.get(new Long(superdata[i].superposs[k].h2)) + superdata[i].superposs[k].p); total+=(2.0*superdata[i].superposs[k].p); } } fullProbMap.normalize(total); iter++; } | private void full_em_breakup( byte[][] input_haplos, int[] block_size, Vector affStatus, Vector kidAffStatus) throws HaploViewException{ int num_poss, iter; double total = 0; int block, start_locus, end_locus, biggest_block_size; int num_indivs = 0; int num_blocks = block_size.length; int num_haplos = input_haplos.length; int num_loci = input_haplos[0].length; Recovery tempRec; if (num_loci > MAXLOCI){ throw new HaploViewException("Too many loci in a single block (> "+MAXLOCI+" non-redundant)"); } //figure out the size of the biggest block biggest_block_size=block_size[0]; for (int i=1; i<num_blocks; i++) { if (block_size[i] > biggest_block_size) biggest_block_size=block_size[i]; } num_poss = two_n[biggest_block_size]; data = new OBS[num_haplos/2]; for (int i=0; i<num_haplos/2; i++) data[i]= new OBS(); superdata = new SUPER_OBS[num_haplos/2]; for (int i=0; i<num_haplos/2; i++) superdata[i]= new SUPER_OBS(num_blocks); double[][] hprob = new double[num_blocks][num_poss]; int[][] hlist = new int[num_blocks][num_poss]; int[] num_hlist = new int[num_blocks]; int[] hint = new int[num_poss]; double[] prob = new double[num_poss]; /*MapWrap probMap = new MapWrap(PSEUDOCOUNT);*/ /* for trio option */ if (Options.getAssocTest() == ASSOC_TRIO) { ambighet = new int[(num_haplos/4)][num_loci]; store_dhet_status(num_haplos,num_loci,input_haplos); } end_locus=-1; //now we loop through the blocks for (block=0; block<num_blocks; block++) { start_locus=end_locus+1; end_locus=start_locus+block_size[block]-1; num_poss=two_n[block_size[block]]; //read_observations initializes the values in data[] (array of OBS) num_indivs=read_observations(num_haplos,num_loci,input_haplos,start_locus,end_locus); prob = estimateProbsSmall(num_indivs,num_poss); int m=0; for(long j=0;j<num_poss; j++){ hint[(int)j]=-1; //if (probMap.get(new Long(j)) > .001) { if(prob[((int) j)] > .001) { // printf("haplo %s p = %.4lf\n",haplo_str(j,block_size[block]),prob[j]); hlist[block][m]=(int)j; /*hprob[block][m]=probMap.get(new Long(j));*/ hprob[block][m] = prob[((int) j)]; hint[(int)j]=m; m++; } } num_hlist[block]=m; // store current block results in super obs structure store_block_haplos(hlist, hprob, hint, block, num_indivs); } /* for each block */ double poss_full=1; for (block=0; block<num_blocks; block++) { poss_full *= num_hlist[block]; } /* LIGATE and finish this mess :) */ create_super_haplos(num_indivs,num_blocks,num_hlist); if(poss_full < Integer.MAX_VALUE) { finishLarge(num_indivs, poss_full,kidAffStatus, num_blocks,block_size,num_hlist,hlist, num_loci); }else { finishSmall(num_indivs,(int) poss_full,kidAffStatus, num_blocks,block_size,num_hlist,hlist, num_loci); } if(Options.getAssocTest() == ASSOC_TRIO) { kidConsistentCache = new boolean[numFilteredTrios][][]; for(int i=0;i<numFilteredTrios*2;i+=2) { if (((Integer)kidAffStatus.elementAt(i)).intValue() == 2){ kidConsistentCache[i/2] = new boolean[superdata[i].nsuper][]; for (int n=0; n<superdata[i].nsuper; n++) { kidConsistentCache[i/2][n] = new boolean[superdata[i+1].nsuper]; for (int m=0; m<superdata[i+1].nsuper; m++) { kidConsistentCache[i/2][n][m] = kid_consistent(superdata[i].superposs[n].h1, superdata[i+1].superposs[m].h1,num_blocks, block_size,hlist,num_hlist,i/2,num_loci); } } } } } realAffectedStatus = affStatus; doAssociationTests(affStatus, null, kidAffStatus); /* if (dump_phased_haplos) { if ((fpdump=fopen("emphased.haps","w"))!=NULL) { for (i=0; i<num_indivs; i++) { best=0; for (k=0; k<superdata[i].nsuper; k++) { if (superdata[i].superposs[k].p > superdata[i].superposs[best].p) { best=k; } } h1 = superdata[i].superposs[best].h1; h2 = superdata[i].superposs[best].h2; fprintf(fpdump,"%s\n",decode_haplo_str(h1,num_blocks,block_size,hlist,num_hlist)); fprintf(fpdump,"%s\n",decode_haplo_str(h2,num_blocks,block_size,hlist,num_hlist)); } fclose(fpdump); } } */ //return 0; } |
Vector haplos_present = new Vector(); Vector haplo_freq= new Vector(); ArrayList keys = new ArrayList(fullProbMap.theMap.keySet()); Collections.sort(keys); Iterator kitr = keys.iterator(); while(kitr.hasNext()) { Object key = kitr.next(); long keyLong = ((Long)key).longValue(); if(fullProbMap.get(key) > .001) { haplos_present.addElement(decode_haplo_str(keyLong,num_blocks,block_size,hlist,num_hlist)); haplo_freq.addElement(new Double(fullProbMap.get(key))); } } double[] freqs = new double[haplo_freq.size()]; for(int j=0;j<haplo_freq.size();j++) { freqs[j] = ((Double)haplo_freq.elementAt(j)).doubleValue(); } this.haplotypes = (int[][])haplos_present.toArray(new int[0][0]); this.frequencies = freqs; | private void full_em_breakup( byte[][] input_haplos, int[] block_size, Vector affStatus, Vector kidAffStatus) throws HaploViewException{ int num_poss, iter; double total = 0; int block, start_locus, end_locus, biggest_block_size; int num_indivs = 0; int num_blocks = block_size.length; int num_haplos = input_haplos.length; int num_loci = input_haplos[0].length; Recovery tempRec; if (num_loci > MAXLOCI){ throw new HaploViewException("Too many loci in a single block (> "+MAXLOCI+" non-redundant)"); } //figure out the size of the biggest block biggest_block_size=block_size[0]; for (int i=1; i<num_blocks; i++) { if (block_size[i] > biggest_block_size) biggest_block_size=block_size[i]; } num_poss = two_n[biggest_block_size]; data = new OBS[num_haplos/2]; for (int i=0; i<num_haplos/2; i++) data[i]= new OBS(); superdata = new SUPER_OBS[num_haplos/2]; for (int i=0; i<num_haplos/2; i++) superdata[i]= new SUPER_OBS(num_blocks); double[][] hprob = new double[num_blocks][num_poss]; int[][] hlist = new int[num_blocks][num_poss]; int[] num_hlist = new int[num_blocks]; int[] hint = new int[num_poss]; double[] prob = new double[num_poss]; /*MapWrap probMap = new MapWrap(PSEUDOCOUNT);*/ /* for trio option */ if (Options.getAssocTest() == ASSOC_TRIO) { ambighet = new int[(num_haplos/4)][num_loci]; store_dhet_status(num_haplos,num_loci,input_haplos); } end_locus=-1; //now we loop through the blocks for (block=0; block<num_blocks; block++) { start_locus=end_locus+1; end_locus=start_locus+block_size[block]-1; num_poss=two_n[block_size[block]]; //read_observations initializes the values in data[] (array of OBS) num_indivs=read_observations(num_haplos,num_loci,input_haplos,start_locus,end_locus); prob = estimateProbsSmall(num_indivs,num_poss); int m=0; for(long j=0;j<num_poss; j++){ hint[(int)j]=-1; //if (probMap.get(new Long(j)) > .001) { if(prob[((int) j)] > .001) { // printf("haplo %s p = %.4lf\n",haplo_str(j,block_size[block]),prob[j]); hlist[block][m]=(int)j; /*hprob[block][m]=probMap.get(new Long(j));*/ hprob[block][m] = prob[((int) j)]; hint[(int)j]=m; m++; } } num_hlist[block]=m; // store current block results in super obs structure store_block_haplos(hlist, hprob, hint, block, num_indivs); } /* for each block */ double poss_full=1; for (block=0; block<num_blocks; block++) { poss_full *= num_hlist[block]; } /* LIGATE and finish this mess :) */ create_super_haplos(num_indivs,num_blocks,num_hlist); if(poss_full < Integer.MAX_VALUE) { finishLarge(num_indivs, poss_full,kidAffStatus, num_blocks,block_size,num_hlist,hlist, num_loci); }else { finishSmall(num_indivs,(int) poss_full,kidAffStatus, num_blocks,block_size,num_hlist,hlist, num_loci); } if(Options.getAssocTest() == ASSOC_TRIO) { kidConsistentCache = new boolean[numFilteredTrios][][]; for(int i=0;i<numFilteredTrios*2;i+=2) { if (((Integer)kidAffStatus.elementAt(i)).intValue() == 2){ kidConsistentCache[i/2] = new boolean[superdata[i].nsuper][]; for (int n=0; n<superdata[i].nsuper; n++) { kidConsistentCache[i/2][n] = new boolean[superdata[i+1].nsuper]; for (int m=0; m<superdata[i+1].nsuper; m++) { kidConsistentCache[i/2][n][m] = kid_consistent(superdata[i].superposs[n].h1, superdata[i+1].superposs[m].h1,num_blocks, block_size,hlist,num_hlist,i/2,num_loci); } } } } } realAffectedStatus = affStatus; doAssociationTests(affStatus, null, kidAffStatus); /* if (dump_phased_haplos) { if ((fpdump=fopen("emphased.haps","w"))!=NULL) { for (i=0; i<num_indivs; i++) { best=0; for (k=0; k<superdata[i].nsuper; k++) { if (superdata[i].superposs[k].p > superdata[i].superposs[best].p) { best=k; } } h1 = superdata[i].superposs[best].h1; h2 = superdata[i].superposs[best].h2; fprintf(fpdump,"%s\n",decode_haplo_str(h1,num_blocks,block_size,hlist,num_hlist)); fprintf(fpdump,"%s\n",decode_haplo_str(h2,num_blocks,block_size,hlist,num_hlist)); } fclose(fpdump); } } */ //return 0; } |
|
public String getAttachmentURL(String filename, String action, XWikiContext context) { URL url = context.getURLFactory().createAttachmentURL(filename, getWeb(), getName(), action, null, getDatabase(), context); return context.getURLFactory().getURL(url, context); | public String getAttachmentURL(String filename, XWikiContext context) { return getAttachmentURL(filename, "download", context); | public String getAttachmentURL(String filename, String action, XWikiContext context) { URL url = context.getURLFactory().createAttachmentURL(filename, getWeb(), getName(), action, null, getDatabase(), context); return context.getURLFactory().getURL(url, context); } |
public String getURL(String action, XWikiContext context) { return getURL(action, false, context); | public String getURL(String action, boolean redirect, XWikiContext context) { URL url = context.getURLFactory().createURL(getWeb(), getName(), action, null, null, getDatabase(), context); if (redirect) { if (url == null) return null; else return url.toString(); } else return context.getURLFactory().getURL(url, context); | public String getURL(String action, XWikiContext context) { return getURL(action, false, context); } |
public XWikiPluginManager(String classList, XWikiContext context) { String[] classNames = StringUtils.split(classList, " ,"); addPlugins(classNames, context); | public XWikiPluginManager() { | public XWikiPluginManager(String classList, XWikiContext context) { String[] classNames = StringUtils.split(classList, " ,"); addPlugins(classNames, context); } |
dbmd = null; | protected String checkTargetTable(SQLTable t) throws SQLException, ArchitectException { GenericDDLGenerator ddlg = ArchitectFrame.getMainInstance().getProject().getDDLGenerator(); logger.debug("DDLG class is: " + ddlg.getClass().getName()); String tableName = ddlg.toIdentifier(t.getName()); List ourColumns = new ArrayList(); Iterator it = t.getColumns().iterator(); while (it.hasNext()) { SQLColumn c = (SQLColumn) it.next(); ourColumns.add(ddlg.toIdentifier(c.getName()).toLowerCase()); } List actualColumns = new ArrayList(); Connection con = t.getParentDatabase().getConnection(); DatabaseMetaData dbmd = con.getMetaData(); ResultSet rs = null; try { logger.debug("Fetching columns of "+plexp.getTargetSchema()+"."+tableName); rs = dbmd.getColumns(null, plexp.getTargetSchema(), tableName, null); while (rs.next()) { actualColumns.add(rs.getString(4).toLowerCase()); // column name } } finally { if (rs != null) rs.close(); } if (logger.isDebugEnabled()) { logger.debug(" ourColumns = "+ourColumns); logger.debug("actualColumns = "+actualColumns); } if (actualColumns.isEmpty()) { return "Target table \""+tableName+"\" does not exist"; } else { if (actualColumns.containsAll(ourColumns)) { return null; } else { return "Target table \""+tableName+"\" exists but is missing columns"; } } } |
|
public String toIdentifier(String name) { if (name == null) return null; else return name.replace(' ', '_'); | public String toIdentifier(String logicalName, String physicalName) { if (logicalName == null) return null; else return logicalName.replace(' ', '_'); | public String toIdentifier(String name) { if (name == null) return null; else return name.replace(' ', '_'); } |
List connectionHistory = af.getUserSettings().getConnections(); | public PLExportPanel() { setLayout(new GridLayout(1,2)); ArchitectFrame af = ArchitectFrame.getMainInstance(); SwingUIProject project = af.getProject(); projName = new String(project.getName()); newConnButton= new JButton("New"); newConnButton.addActionListener(new NewConnectionListener()); List connectionHistory = af.getUserSettings().getConnections(); String plIniPath = af.getUserSettings().getETLUserSettings().getPlDotIniPath(); List plOdbcCon = new ArrayList(); try { if (plIniPath != null) { plOdbcCon = getPLDBConnection(plIniPath); } else { JOptionPane.showMessageDialog (this, "Warning: You have not set the PL.INI file location." +"\nThe PL Connection box will be empty."); } } catch (FileNotFoundException ie) { JOptionPane.showMessageDialog (this, "PL database config file not found in specified path:\n" +plIniPath+"\nThe PL Connection box will be empty."); } catch (IOException ie){ JOptionPane.showMessageDialog(this, "Error reading PL.ini file "+plIniPath +"\nThe PL Connection box will be empty."); } history = new Vector(); history.add(ASUtils.lvb("(Select PL Connection)", null)); Iterator it = connectionHistory.iterator(); while (it.hasNext()) { DBConnectionSpec spec = (DBConnectionSpec) it.next(); history.add(ASUtils.lvb(spec.getDisplayName(), spec)); } historyBox = new JComboBox(history); historyBox.addActionListener(new HistoryBoxListener()); plodbc = new Vector(); plodbc.add(ASUtils.lvb("(Select PL ODBC Connection)", null)); Iterator itO = plOdbcCon.iterator(); while (itO.hasNext()) { PLdbConn plcon = (PLdbConn) itO.next(); plodbc.add(ASUtils.lvb(plcon.getLogical(), plcon)); } plODBCSourceBox = new JComboBox(plodbc); plODBCSourceBox.addActionListener(new ODBCSourceListener()); runPLEngine = new JCheckBox(); runPLEngine.setEnabled(false); plFolderName = new JTextField(toPLIdentifier(projName)+"_Folder"); plJobId = new JTextField(toPLIdentifier(projName)+"_Job"); JPanel jdbcPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); jdbcPanel.add(historyBox); jdbcPanel.add(newConnButton); JComponent[] jdbcFields = new JComponent[] {jdbcPanel, plRepOwner = new JTextField(), plFolderName, plJobId, plJobDescription = new JTextField(), plJobComment = new JTextField(), plOutputTableOwner = new JTextField()}; String[] jdbcLabels = new String[] {"Architect Connection Name", "PL Repository Owner", "PL Folder Name", "PL Job Id", "PL Job Description", "PL Job Comment", "Target Schema Owner"}; char[] jdbcMnemonics = new char[] {'t', 'r', 'f', 'i', 'd', 'c', 'o'}; int[] jdbcWidths = new int[] {18, 18, 18, 18, 18, 18, 18, 18,10}; String[] jdbcTips = new String[] {"Target database and PL repository", "Owner of PL Repository", "The folder name for transactions", "The Job unique Id", "The Job Description", "Comment about the Job", "Owner (Schema) for output transaction tables"}; TextPanel jdbcForm = new TextPanel(jdbcFields, jdbcLabels, jdbcMnemonics, jdbcWidths, jdbcTips); JComponent[] engineFields = new JComponent[] {plODBCSourceBox, plUserName = new JTextField(), plPassword = new JPasswordField(), runPLEngine}; String[] engineLabels = new String[] {"PL.INI Logical Database Name", "PL User Name", "PL Password", "Run Engine"}; char[] engineMnemonics = new char[] {'l', 'u', 'p', 'e'}; int[] engineWidths = new int[] {18, 18, 18, 10}; String[] engineTips = new String[] {"ODBC Source Name connection for PL", "PowerLoader User Name", "PowerLoader Password", "Run PL Engine immediately?"}; TextPanel engineForm = new TextPanel(engineFields, engineLabels, engineMnemonics, engineWidths, engineTips); add(jdbcForm); add(engineForm); } |
|
plOdbcCon = getPLDBConnection(plIniPath); | plOdbcCon = parsePlDotIni(plIniPath); | public PLExportPanel() { setLayout(new GridLayout(1,2)); ArchitectFrame af = ArchitectFrame.getMainInstance(); SwingUIProject project = af.getProject(); projName = new String(project.getName()); newConnButton= new JButton("New"); newConnButton.addActionListener(new NewConnectionListener()); List connectionHistory = af.getUserSettings().getConnections(); String plIniPath = af.getUserSettings().getETLUserSettings().getPlDotIniPath(); List plOdbcCon = new ArrayList(); try { if (plIniPath != null) { plOdbcCon = getPLDBConnection(plIniPath); } else { JOptionPane.showMessageDialog (this, "Warning: You have not set the PL.INI file location." +"\nThe PL Connection box will be empty."); } } catch (FileNotFoundException ie) { JOptionPane.showMessageDialog (this, "PL database config file not found in specified path:\n" +plIniPath+"\nThe PL Connection box will be empty."); } catch (IOException ie){ JOptionPane.showMessageDialog(this, "Error reading PL.ini file "+plIniPath +"\nThe PL Connection box will be empty."); } history = new Vector(); history.add(ASUtils.lvb("(Select PL Connection)", null)); Iterator it = connectionHistory.iterator(); while (it.hasNext()) { DBConnectionSpec spec = (DBConnectionSpec) it.next(); history.add(ASUtils.lvb(spec.getDisplayName(), spec)); } historyBox = new JComboBox(history); historyBox.addActionListener(new HistoryBoxListener()); plodbc = new Vector(); plodbc.add(ASUtils.lvb("(Select PL ODBC Connection)", null)); Iterator itO = plOdbcCon.iterator(); while (itO.hasNext()) { PLdbConn plcon = (PLdbConn) itO.next(); plodbc.add(ASUtils.lvb(plcon.getLogical(), plcon)); } plODBCSourceBox = new JComboBox(plodbc); plODBCSourceBox.addActionListener(new ODBCSourceListener()); runPLEngine = new JCheckBox(); runPLEngine.setEnabled(false); plFolderName = new JTextField(toPLIdentifier(projName)+"_Folder"); plJobId = new JTextField(toPLIdentifier(projName)+"_Job"); JPanel jdbcPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); jdbcPanel.add(historyBox); jdbcPanel.add(newConnButton); JComponent[] jdbcFields = new JComponent[] {jdbcPanel, plRepOwner = new JTextField(), plFolderName, plJobId, plJobDescription = new JTextField(), plJobComment = new JTextField(), plOutputTableOwner = new JTextField()}; String[] jdbcLabels = new String[] {"Architect Connection Name", "PL Repository Owner", "PL Folder Name", "PL Job Id", "PL Job Description", "PL Job Comment", "Target Schema Owner"}; char[] jdbcMnemonics = new char[] {'t', 'r', 'f', 'i', 'd', 'c', 'o'}; int[] jdbcWidths = new int[] {18, 18, 18, 18, 18, 18, 18, 18,10}; String[] jdbcTips = new String[] {"Target database and PL repository", "Owner of PL Repository", "The folder name for transactions", "The Job unique Id", "The Job Description", "Comment about the Job", "Owner (Schema) for output transaction tables"}; TextPanel jdbcForm = new TextPanel(jdbcFields, jdbcLabels, jdbcMnemonics, jdbcWidths, jdbcTips); JComponent[] engineFields = new JComponent[] {plODBCSourceBox, plUserName = new JTextField(), plPassword = new JPasswordField(), runPLEngine}; String[] engineLabels = new String[] {"PL.INI Logical Database Name", "PL User Name", "PL Password", "Run Engine"}; char[] engineMnemonics = new char[] {'l', 'u', 'p', 'e'}; int[] engineWidths = new int[] {18, 18, 18, 10}; String[] engineTips = new String[] {"ODBC Source Name connection for PL", "PowerLoader User Name", "PowerLoader Password", "Run PL Engine immediately?"}; TextPanel engineForm = new TextPanel(engineFields, engineLabels, engineMnemonics, engineWidths, engineTips); add(jdbcForm); add(engineForm); } |
history = new Vector(); history.add(ASUtils.lvb("(Select PL Connection)", null)); Iterator it = connectionHistory.iterator(); | connections = new Vector(); connections.add(ASUtils.lvb("(Select PL Connection)", null)); Iterator it = af.getUserSettings().getConnections().iterator(); | public PLExportPanel() { setLayout(new GridLayout(1,2)); ArchitectFrame af = ArchitectFrame.getMainInstance(); SwingUIProject project = af.getProject(); projName = new String(project.getName()); newConnButton= new JButton("New"); newConnButton.addActionListener(new NewConnectionListener()); List connectionHistory = af.getUserSettings().getConnections(); String plIniPath = af.getUserSettings().getETLUserSettings().getPlDotIniPath(); List plOdbcCon = new ArrayList(); try { if (plIniPath != null) { plOdbcCon = getPLDBConnection(plIniPath); } else { JOptionPane.showMessageDialog (this, "Warning: You have not set the PL.INI file location." +"\nThe PL Connection box will be empty."); } } catch (FileNotFoundException ie) { JOptionPane.showMessageDialog (this, "PL database config file not found in specified path:\n" +plIniPath+"\nThe PL Connection box will be empty."); } catch (IOException ie){ JOptionPane.showMessageDialog(this, "Error reading PL.ini file "+plIniPath +"\nThe PL Connection box will be empty."); } history = new Vector(); history.add(ASUtils.lvb("(Select PL Connection)", null)); Iterator it = connectionHistory.iterator(); while (it.hasNext()) { DBConnectionSpec spec = (DBConnectionSpec) it.next(); history.add(ASUtils.lvb(spec.getDisplayName(), spec)); } historyBox = new JComboBox(history); historyBox.addActionListener(new HistoryBoxListener()); plodbc = new Vector(); plodbc.add(ASUtils.lvb("(Select PL ODBC Connection)", null)); Iterator itO = plOdbcCon.iterator(); while (itO.hasNext()) { PLdbConn plcon = (PLdbConn) itO.next(); plodbc.add(ASUtils.lvb(plcon.getLogical(), plcon)); } plODBCSourceBox = new JComboBox(plodbc); plODBCSourceBox.addActionListener(new ODBCSourceListener()); runPLEngine = new JCheckBox(); runPLEngine.setEnabled(false); plFolderName = new JTextField(toPLIdentifier(projName)+"_Folder"); plJobId = new JTextField(toPLIdentifier(projName)+"_Job"); JPanel jdbcPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); jdbcPanel.add(historyBox); jdbcPanel.add(newConnButton); JComponent[] jdbcFields = new JComponent[] {jdbcPanel, plRepOwner = new JTextField(), plFolderName, plJobId, plJobDescription = new JTextField(), plJobComment = new JTextField(), plOutputTableOwner = new JTextField()}; String[] jdbcLabels = new String[] {"Architect Connection Name", "PL Repository Owner", "PL Folder Name", "PL Job Id", "PL Job Description", "PL Job Comment", "Target Schema Owner"}; char[] jdbcMnemonics = new char[] {'t', 'r', 'f', 'i', 'd', 'c', 'o'}; int[] jdbcWidths = new int[] {18, 18, 18, 18, 18, 18, 18, 18,10}; String[] jdbcTips = new String[] {"Target database and PL repository", "Owner of PL Repository", "The folder name for transactions", "The Job unique Id", "The Job Description", "Comment about the Job", "Owner (Schema) for output transaction tables"}; TextPanel jdbcForm = new TextPanel(jdbcFields, jdbcLabels, jdbcMnemonics, jdbcWidths, jdbcTips); JComponent[] engineFields = new JComponent[] {plODBCSourceBox, plUserName = new JTextField(), plPassword = new JPasswordField(), runPLEngine}; String[] engineLabels = new String[] {"PL.INI Logical Database Name", "PL User Name", "PL Password", "Run Engine"}; char[] engineMnemonics = new char[] {'l', 'u', 'p', 'e'}; int[] engineWidths = new int[] {18, 18, 18, 10}; String[] engineTips = new String[] {"ODBC Source Name connection for PL", "PowerLoader User Name", "PowerLoader Password", "Run PL Engine immediately?"}; TextPanel engineForm = new TextPanel(engineFields, engineLabels, engineMnemonics, engineWidths, engineTips); add(jdbcForm); add(engineForm); } |
history.add(ASUtils.lvb(spec.getDisplayName(), spec)); | connections.add(ASUtils.lvb(spec.getDisplayName(), spec)); | public PLExportPanel() { setLayout(new GridLayout(1,2)); ArchitectFrame af = ArchitectFrame.getMainInstance(); SwingUIProject project = af.getProject(); projName = new String(project.getName()); newConnButton= new JButton("New"); newConnButton.addActionListener(new NewConnectionListener()); List connectionHistory = af.getUserSettings().getConnections(); String plIniPath = af.getUserSettings().getETLUserSettings().getPlDotIniPath(); List plOdbcCon = new ArrayList(); try { if (plIniPath != null) { plOdbcCon = getPLDBConnection(plIniPath); } else { JOptionPane.showMessageDialog (this, "Warning: You have not set the PL.INI file location." +"\nThe PL Connection box will be empty."); } } catch (FileNotFoundException ie) { JOptionPane.showMessageDialog (this, "PL database config file not found in specified path:\n" +plIniPath+"\nThe PL Connection box will be empty."); } catch (IOException ie){ JOptionPane.showMessageDialog(this, "Error reading PL.ini file "+plIniPath +"\nThe PL Connection box will be empty."); } history = new Vector(); history.add(ASUtils.lvb("(Select PL Connection)", null)); Iterator it = connectionHistory.iterator(); while (it.hasNext()) { DBConnectionSpec spec = (DBConnectionSpec) it.next(); history.add(ASUtils.lvb(spec.getDisplayName(), spec)); } historyBox = new JComboBox(history); historyBox.addActionListener(new HistoryBoxListener()); plodbc = new Vector(); plodbc.add(ASUtils.lvb("(Select PL ODBC Connection)", null)); Iterator itO = plOdbcCon.iterator(); while (itO.hasNext()) { PLdbConn plcon = (PLdbConn) itO.next(); plodbc.add(ASUtils.lvb(plcon.getLogical(), plcon)); } plODBCSourceBox = new JComboBox(plodbc); plODBCSourceBox.addActionListener(new ODBCSourceListener()); runPLEngine = new JCheckBox(); runPLEngine.setEnabled(false); plFolderName = new JTextField(toPLIdentifier(projName)+"_Folder"); plJobId = new JTextField(toPLIdentifier(projName)+"_Job"); JPanel jdbcPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); jdbcPanel.add(historyBox); jdbcPanel.add(newConnButton); JComponent[] jdbcFields = new JComponent[] {jdbcPanel, plRepOwner = new JTextField(), plFolderName, plJobId, plJobDescription = new JTextField(), plJobComment = new JTextField(), plOutputTableOwner = new JTextField()}; String[] jdbcLabels = new String[] {"Architect Connection Name", "PL Repository Owner", "PL Folder Name", "PL Job Id", "PL Job Description", "PL Job Comment", "Target Schema Owner"}; char[] jdbcMnemonics = new char[] {'t', 'r', 'f', 'i', 'd', 'c', 'o'}; int[] jdbcWidths = new int[] {18, 18, 18, 18, 18, 18, 18, 18,10}; String[] jdbcTips = new String[] {"Target database and PL repository", "Owner of PL Repository", "The folder name for transactions", "The Job unique Id", "The Job Description", "Comment about the Job", "Owner (Schema) for output transaction tables"}; TextPanel jdbcForm = new TextPanel(jdbcFields, jdbcLabels, jdbcMnemonics, jdbcWidths, jdbcTips); JComponent[] engineFields = new JComponent[] {plODBCSourceBox, plUserName = new JTextField(), plPassword = new JPasswordField(), runPLEngine}; String[] engineLabels = new String[] {"PL.INI Logical Database Name", "PL User Name", "PL Password", "Run Engine"}; char[] engineMnemonics = new char[] {'l', 'u', 'p', 'e'}; int[] engineWidths = new int[] {18, 18, 18, 10}; String[] engineTips = new String[] {"ODBC Source Name connection for PL", "PowerLoader User Name", "PowerLoader Password", "Run PL Engine immediately?"}; TextPanel engineForm = new TextPanel(engineFields, engineLabels, engineMnemonics, engineWidths, engineTips); add(jdbcForm); add(engineForm); } |
historyBox = new JComboBox(history); historyBox.addActionListener(new HistoryBoxListener()); | connectionsBox = new JComboBox(connections); | public PLExportPanel() { setLayout(new GridLayout(1,2)); ArchitectFrame af = ArchitectFrame.getMainInstance(); SwingUIProject project = af.getProject(); projName = new String(project.getName()); newConnButton= new JButton("New"); newConnButton.addActionListener(new NewConnectionListener()); List connectionHistory = af.getUserSettings().getConnections(); String plIniPath = af.getUserSettings().getETLUserSettings().getPlDotIniPath(); List plOdbcCon = new ArrayList(); try { if (plIniPath != null) { plOdbcCon = getPLDBConnection(plIniPath); } else { JOptionPane.showMessageDialog (this, "Warning: You have not set the PL.INI file location." +"\nThe PL Connection box will be empty."); } } catch (FileNotFoundException ie) { JOptionPane.showMessageDialog (this, "PL database config file not found in specified path:\n" +plIniPath+"\nThe PL Connection box will be empty."); } catch (IOException ie){ JOptionPane.showMessageDialog(this, "Error reading PL.ini file "+plIniPath +"\nThe PL Connection box will be empty."); } history = new Vector(); history.add(ASUtils.lvb("(Select PL Connection)", null)); Iterator it = connectionHistory.iterator(); while (it.hasNext()) { DBConnectionSpec spec = (DBConnectionSpec) it.next(); history.add(ASUtils.lvb(spec.getDisplayName(), spec)); } historyBox = new JComboBox(history); historyBox.addActionListener(new HistoryBoxListener()); plodbc = new Vector(); plodbc.add(ASUtils.lvb("(Select PL ODBC Connection)", null)); Iterator itO = plOdbcCon.iterator(); while (itO.hasNext()) { PLdbConn plcon = (PLdbConn) itO.next(); plodbc.add(ASUtils.lvb(plcon.getLogical(), plcon)); } plODBCSourceBox = new JComboBox(plodbc); plODBCSourceBox.addActionListener(new ODBCSourceListener()); runPLEngine = new JCheckBox(); runPLEngine.setEnabled(false); plFolderName = new JTextField(toPLIdentifier(projName)+"_Folder"); plJobId = new JTextField(toPLIdentifier(projName)+"_Job"); JPanel jdbcPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); jdbcPanel.add(historyBox); jdbcPanel.add(newConnButton); JComponent[] jdbcFields = new JComponent[] {jdbcPanel, plRepOwner = new JTextField(), plFolderName, plJobId, plJobDescription = new JTextField(), plJobComment = new JTextField(), plOutputTableOwner = new JTextField()}; String[] jdbcLabels = new String[] {"Architect Connection Name", "PL Repository Owner", "PL Folder Name", "PL Job Id", "PL Job Description", "PL Job Comment", "Target Schema Owner"}; char[] jdbcMnemonics = new char[] {'t', 'r', 'f', 'i', 'd', 'c', 'o'}; int[] jdbcWidths = new int[] {18, 18, 18, 18, 18, 18, 18, 18,10}; String[] jdbcTips = new String[] {"Target database and PL repository", "Owner of PL Repository", "The folder name for transactions", "The Job unique Id", "The Job Description", "Comment about the Job", "Owner (Schema) for output transaction tables"}; TextPanel jdbcForm = new TextPanel(jdbcFields, jdbcLabels, jdbcMnemonics, jdbcWidths, jdbcTips); JComponent[] engineFields = new JComponent[] {plODBCSourceBox, plUserName = new JTextField(), plPassword = new JPasswordField(), runPLEngine}; String[] engineLabels = new String[] {"PL.INI Logical Database Name", "PL User Name", "PL Password", "Run Engine"}; char[] engineMnemonics = new char[] {'l', 'u', 'p', 'e'}; int[] engineWidths = new int[] {18, 18, 18, 10}; String[] engineTips = new String[] {"ODBC Source Name connection for PL", "PowerLoader User Name", "PowerLoader Password", "Run PL Engine immediately?"}; TextPanel engineForm = new TextPanel(engineFields, engineLabels, engineMnemonics, engineWidths, engineTips); add(jdbcForm); add(engineForm); } |
jdbcPanel.add(historyBox); | jdbcPanel.add(connectionsBox); | public PLExportPanel() { setLayout(new GridLayout(1,2)); ArchitectFrame af = ArchitectFrame.getMainInstance(); SwingUIProject project = af.getProject(); projName = new String(project.getName()); newConnButton= new JButton("New"); newConnButton.addActionListener(new NewConnectionListener()); List connectionHistory = af.getUserSettings().getConnections(); String plIniPath = af.getUserSettings().getETLUserSettings().getPlDotIniPath(); List plOdbcCon = new ArrayList(); try { if (plIniPath != null) { plOdbcCon = getPLDBConnection(plIniPath); } else { JOptionPane.showMessageDialog (this, "Warning: You have not set the PL.INI file location." +"\nThe PL Connection box will be empty."); } } catch (FileNotFoundException ie) { JOptionPane.showMessageDialog (this, "PL database config file not found in specified path:\n" +plIniPath+"\nThe PL Connection box will be empty."); } catch (IOException ie){ JOptionPane.showMessageDialog(this, "Error reading PL.ini file "+plIniPath +"\nThe PL Connection box will be empty."); } history = new Vector(); history.add(ASUtils.lvb("(Select PL Connection)", null)); Iterator it = connectionHistory.iterator(); while (it.hasNext()) { DBConnectionSpec spec = (DBConnectionSpec) it.next(); history.add(ASUtils.lvb(spec.getDisplayName(), spec)); } historyBox = new JComboBox(history); historyBox.addActionListener(new HistoryBoxListener()); plodbc = new Vector(); plodbc.add(ASUtils.lvb("(Select PL ODBC Connection)", null)); Iterator itO = plOdbcCon.iterator(); while (itO.hasNext()) { PLdbConn plcon = (PLdbConn) itO.next(); plodbc.add(ASUtils.lvb(plcon.getLogical(), plcon)); } plODBCSourceBox = new JComboBox(plodbc); plODBCSourceBox.addActionListener(new ODBCSourceListener()); runPLEngine = new JCheckBox(); runPLEngine.setEnabled(false); plFolderName = new JTextField(toPLIdentifier(projName)+"_Folder"); plJobId = new JTextField(toPLIdentifier(projName)+"_Job"); JPanel jdbcPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); jdbcPanel.add(historyBox); jdbcPanel.add(newConnButton); JComponent[] jdbcFields = new JComponent[] {jdbcPanel, plRepOwner = new JTextField(), plFolderName, plJobId, plJobDescription = new JTextField(), plJobComment = new JTextField(), plOutputTableOwner = new JTextField()}; String[] jdbcLabels = new String[] {"Architect Connection Name", "PL Repository Owner", "PL Folder Name", "PL Job Id", "PL Job Description", "PL Job Comment", "Target Schema Owner"}; char[] jdbcMnemonics = new char[] {'t', 'r', 'f', 'i', 'd', 'c', 'o'}; int[] jdbcWidths = new int[] {18, 18, 18, 18, 18, 18, 18, 18,10}; String[] jdbcTips = new String[] {"Target database and PL repository", "Owner of PL Repository", "The folder name for transactions", "The Job unique Id", "The Job Description", "Comment about the Job", "Owner (Schema) for output transaction tables"}; TextPanel jdbcForm = new TextPanel(jdbcFields, jdbcLabels, jdbcMnemonics, jdbcWidths, jdbcTips); JComponent[] engineFields = new JComponent[] {plODBCSourceBox, plUserName = new JTextField(), plPassword = new JPasswordField(), runPLEngine}; String[] engineLabels = new String[] {"PL.INI Logical Database Name", "PL User Name", "PL Password", "Run Engine"}; char[] engineMnemonics = new char[] {'l', 'u', 'p', 'e'}; int[] engineWidths = new int[] {18, 18, 18, 10}; String[] engineTips = new String[] {"ODBC Source Name connection for PL", "PowerLoader User Name", "PowerLoader Password", "Run PL Engine immediately?"}; TextPanel engineForm = new TextPanel(engineFields, engineLabels, engineMnemonics, engineWidths, engineTips); add(jdbcForm); add(engineForm); } |
String name = plFolderName.getText(); | public void applyChanges() { String name = plFolderName.getText(); } |
|
return mOuterLoopFilterValues.withValues(values.getValuesFor(mSourceFilterAsFromTarget)); | return mOuterLoopFilterValues .withValues(values.getSuppliedValuesFor(mSourceFilterAsFromTarget)); | private FilterValues<S> transferValues(FilterValues<T> values) { if (values == null) { return null; } // FIXME: throws exception if not all values supplied return mOuterLoopFilterValues.withValues(values.getValuesFor(mSourceFilterAsFromTarget)); } |
log.debug( "Using config file " + configFile.getAbsolutePath() ); | protected PhotovaultSettings() { // Load XML configuration file String confFileName = System.getProperty( "photovault.configfile" ); if ( confFileName != null ) { System.out.println( "photovault.configfile " + confFileName ); configFile = new File( confFileName ); System.out.println( configFile ); } else { // If the photovault.configfile property is not set, use file photovault.xml // in directory .photovault in user's home directory File homeDir = new File( System.getProperty( "user.home", "" ) ); File photovaultDir = new File( homeDir, ".photovault" ); if ( !photovaultDir.exists() ) { photovaultDir.mkdir(); } configFile = new File( photovaultDir, "photovault.xml" ); } if ( configFile.exists() ) { databases = PhotovaultDatabases.loadDatabases( configFile ); } else { try { configFile.createNewFile(); } catch (IOException ex) { ex.printStackTrace(); } } if ( databases == null ) { databases = new PhotovaultDatabases(); } } |
|
FileInputStream in = new FileInputStream( imgFile ); FileOutputStream out = new FileOutputStream( instanceFile ); byte buf[] = new byte[1024]; int nRead = 0; int offset = 0; while ( (nRead = in.read( buf )) > 0 ) { out.write( buf, 0, nRead ); offset += nRead; } out.close(); in.close(); } catch ( Exception e ) { log.warn( "Error copying file: " + e.getMessage() ); | FileUtils.copyFile( imgFile, instanceFile ); } catch (IOException ex) { log.warn( "Error copying file: " + ex.getMessage() ); | public static PhotoInfo addToDB( File imgFile ) throws PhotoNotFoundException { VolumeBase vol = null; try { vol = VolumeBase.getVolumeOfFile( imgFile ); } catch (IOException ex) { throw new PhotoNotFoundException(); } // Determine the fle that will be added as an instance File instanceFile = null; if ( vol == null ) { /* The "normal" case: we are adding a photo that is not part of any volume. Copy the file to the archive. */ vol = VolumeBase.getDefaultVolume(); instanceFile = vol.getFilingFname( imgFile ); // try { FileInputStream in = new FileInputStream( imgFile ); FileOutputStream out = new FileOutputStream( instanceFile ); byte buf[] = new byte[1024]; int nRead = 0; int offset = 0; while ( (nRead = in.read( buf )) > 0 ) { out.write( buf, 0, nRead ); offset += nRead; } out.close(); in.close(); } catch ( Exception e ) { log.warn( "Error copying file: " + e.getMessage() ); throw new PhotoNotFoundException(); } } else if ( vol instanceof ExternalVolume ) { // Thisfile is in an external volume so we do not need a copy instanceFile = imgFile; } else if ( vol instanceof Volume ) { // Adding file from normal volume is not permitted throw new PhotoNotFoundException(); } else { throw new java.lang.Error( "Unknown subclass of VolumeBase: " + vol.getClass().getName() ); } // Create the image ODMGXAWrapper txw = new ODMGXAWrapper(); PhotoInfo photo = PhotoInfo.create(); txw.lock( photo, Transaction.WRITE ); photo.addInstance( vol, instanceFile, ImageInstance.INSTANCE_TYPE_ORIGINAL ); photo.setOrigFname( imgFile.getName() ); java.util.Date shootTime = new java.util.Date( imgFile.lastModified() ); photo.setShootTime( shootTime ); photo.setCropBounds( new Rectangle2D.Float( 0.0F, 0.0F, 1.0F, 1.0F ) ); photo.updateFromFileMetadata( instanceFile ); txw.commit(); return photo; } |
photos = (PhotoInfo[]) result.toArray( new PhotoInfo[0] ); | photos = (PhotoInfo[]) result.toArray( new PhotoInfo[result.size()] ); | static public PhotoInfo[] retrieveByOrigHash(byte[] hash) { ODMGXAWrapper txw = new ODMGXAWrapper(); Implementation odmg = ODMG.getODMGImplementation(); Transaction tx = odmg.currentTransaction(); PhotoInfo photos[] = null; try { PersistenceBroker broker = ((HasBroker) tx).getBroker(); Criteria crit = new Criteria(); crit.addEqualTo( "hash", hash ); QueryByCriteria q = new QueryByCriteria( PhotoInfo.class, crit ); Collection result = broker.getCollectionByQuery( q ); if ( result.size() > 0 ) { photos = (PhotoInfo[]) result.toArray( new PhotoInfo[0] ); } txw.commit(); } catch ( Exception e ) { log.warn( "Error executing query: " + e.getMessage() ); e.printStackTrace( System.out ); txw.abort(); } return photos; } |
/* JTabbedPane metaAssoc= (JTabbedPane)tabs.getComponentAt(tabNum); | JTabbedPane metaAssoc= (JTabbedPane)tabs.getComponentAt(tabNum); | public void stateChanged(ChangeEvent e) { if (tabs.getSelectedIndex() != -1){ window.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); 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_ASSOC_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_ASSOC_NUM){ //todo: this is borken /* 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(new AssociationTestSet(theData.getHaplotypes(), null)); permutationPanel.setBlocksChanged(); if (custAssocPanel == null){ //change tests if we don't have a custom set AssociationTestSet permSet = new AssociationTestSet(); permSet.cat(tdtPanel.getTestSet()); permSet.cat(hapAssocPanel.getTestSet()); permutationPanel.setTestSet(new PermutationTestSet(0,theData.getSavedEMs(),theData.getPedFile(),permSet)); } }*/ } 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); } Chromosome.doFilter(checkPanel.getMarkerResults()); //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(); } if (taggerConfigPanel != null){ taggerConfigPanel.refreshTable(); } if(permutationPanel != null) { permutationPanel.setBlocksChanged(); if (custAssocPanel == null){ //change tests if we don't have a custom set AssociationTestSet permSet = new AssociationTestSet(); permSet.cat(tdtPanel.getTestSet()); permSet.cat(hapAssocPanel.getTestSet()); permutationPanel.setTestSet(new PermutationTestSet(0,theData.getSavedEMs(),theData.getPedFile(),permSet)); } } checkPanel.changed=false; } if (hapDisplay != null && theData.blocksChanged){ try{ hapDisplay.getHaps(); if(Options.getAssocTest() != ASSOC_NONE) { //this is the haps ass tab inside the assoc super-tab hapAssocPanel.makeTable(new AssociationTestSet(theData.getHaplotypes(), null)); permutationPanel.setBlocksChanged(); if (custAssocPanel == null){ //change tests if we don't have a custom set AssociationTestSet permSet = new AssociationTestSet(); permSet.cat(tdtPanel.getTestSet()); permSet.cat(hapAssocPanel.getTestSet()); permutationPanel.setTestSet(new PermutationTestSet(0,theData.getSavedEMs(),theData.getPedFile(),permSet)); } } }catch(HaploViewException hv){ JOptionPane.showMessageDialog(window, hv.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } hapScroller.setViewportView(hapDisplay); theData.blocksChanged = false; } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } |
}*/ | } | public void stateChanged(ChangeEvent e) { if (tabs.getSelectedIndex() != -1){ window.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); 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_ASSOC_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_ASSOC_NUM){ //todo: this is borken /* 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(new AssociationTestSet(theData.getHaplotypes(), null)); permutationPanel.setBlocksChanged(); if (custAssocPanel == null){ //change tests if we don't have a custom set AssociationTestSet permSet = new AssociationTestSet(); permSet.cat(tdtPanel.getTestSet()); permSet.cat(hapAssocPanel.getTestSet()); permutationPanel.setTestSet(new PermutationTestSet(0,theData.getSavedEMs(),theData.getPedFile(),permSet)); } }*/ } 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); } Chromosome.doFilter(checkPanel.getMarkerResults()); //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(); } if (taggerConfigPanel != null){ taggerConfigPanel.refreshTable(); } if(permutationPanel != null) { permutationPanel.setBlocksChanged(); if (custAssocPanel == null){ //change tests if we don't have a custom set AssociationTestSet permSet = new AssociationTestSet(); permSet.cat(tdtPanel.getTestSet()); permSet.cat(hapAssocPanel.getTestSet()); permutationPanel.setTestSet(new PermutationTestSet(0,theData.getSavedEMs(),theData.getPedFile(),permSet)); } } checkPanel.changed=false; } if (hapDisplay != null && theData.blocksChanged){ try{ hapDisplay.getHaps(); if(Options.getAssocTest() != ASSOC_NONE) { //this is the haps ass tab inside the assoc super-tab hapAssocPanel.makeTable(new AssociationTestSet(theData.getHaplotypes(), null)); permutationPanel.setBlocksChanged(); if (custAssocPanel == null){ //change tests if we don't have a custom set AssociationTestSet permSet = new AssociationTestSet(); permSet.cat(tdtPanel.getTestSet()); permSet.cat(hapAssocPanel.getTestSet()); permutationPanel.setTestSet(new PermutationTestSet(0,theData.getSavedEMs(),theData.getPedFile(),permSet)); } } }catch(HaploViewException hv){ JOptionPane.showMessageDialog(window, hv.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } hapScroller.setViewportView(hapDisplay); theData.blocksChanged = false; } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } |
StringBuffer header = new StringBuffer(); | void export(int tabNum, int format, int start, int stop){ fc.setSelectedFile(new File("")); if (fc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION){ File outfile = fc.getSelectedFile(); if (format == PNG_MODE || format == COMPRESSED_PNG_MODE){ BufferedImage image = null; if (tabNum == VIEW_D_NUM){ try { if (format == PNG_MODE){ image = dPrimeDisplay.export(start, stop, false); }else{ image = dPrimeDisplay.export(start, stop, true); } } catch(HaploViewException hve) { JOptionPane.showMessageDialog(this, hve.getMessage(), "Export Error", JOptionPane.ERROR_MESSAGE); } }else if (tabNum == VIEW_HAP_NUM){ image = hapDisplay.export(); }else{ image = new BufferedImage(1,1,BufferedImage.TYPE_3BYTE_BGR); } if (image != null){ try{ String filename = outfile.getPath(); if (! (filename.endsWith(".png") || filename.endsWith(".PNG"))){ filename += ".png"; } Jimi.putImage("image/png", image, filename); }catch(JimiException je){ JOptionPane.showMessageDialog(this, je.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } } else if (format == TXT_MODE){ try{ if (tabNum == VIEW_D_NUM){ theData.saveDprimeToText(outfile, TABLE_TYPE, start, stop); }else if (tabNum == VIEW_HAP_NUM){ theData.saveHapsToText(hapDisplay.filteredHaplos,hapDisplay.multidprimeArray, outfile); }else if (tabNum == VIEW_CHECK_NUM){ checkPanel.printTable(outfile); }else if (tabNum == VIEW_ASSOC_NUM){ StringBuffer header = new StringBuffer(); Component selectedTab = ((JTabbedPane)tabs.getComponent(tabNum)).getSelectedComponent(); if(selectedTab == tdtPanel){ tdtPanel.getTestSet().saveSNPsToText(outfile); }else if (selectedTab == hapAssocPanel){ hapAssocPanel.getTestSet().saveHapsToText(outfile); }else if (selectedTab == permutationPanel){ permutationPanel.export(outfile); }else if (selectedTab == custAssocPanel){ custAssocPanel.getTestSet().saveResultsToText(outfile); } } }catch(IOException ioe){ JOptionPane.showMessageDialog(this, ioe.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } } } |
|
taggerConfigPanel = new TaggerConfigPanel(theData); JPanel metaTagPanel = new JPanel(); metaTagPanel.setLayout(new BoxLayout(metaTagPanel,BoxLayout.Y_AXIS)); metaTagPanel.add(taggerConfigPanel); JTabbedPane tagTabs = new JTabbedPane(); tagTabs.add("Configuration",metaTagPanel); JPanel resMetaPanel = new JPanel(); resMetaPanel.setLayout(new BoxLayout(resMetaPanel,BoxLayout.Y_AXIS)); TaggerResultsPanel tagResultsPanel = new TaggerResultsPanel(); taggerConfigPanel.addActionListener(tagResultsPanel); resMetaPanel.add(tagResultsPanel); tagTabs.addTab("Results",resMetaPanel); tabs.addTab("Tagger",tagTabs); | void readGenotypes(String[] inputOptions, int type){ //input is a 2 element array with //inputOptions[0] = ped file //inputOptions[1] = info file (null if none) //inputOptions[2] = custom association test list file (null if none) //type is either 3 or 4 for ped and hapmap files respectively final File inFile = new File(inputOptions[0]); final AssociationTestSet customAssocSet; try { if (inputOptions[2] != null && inputOptions[1] == null){ throw new HaploViewException("A marker information file is required if a tests file is specified."); } this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); if (inFile.length() < 1){ throw new HaploViewException("Genotype file is empty or nonexistent: " + inFile.getName()); } if (type == HAPS_FILE){ //these are not available for non ped files viewMenuItems[VIEW_CHECK_NUM].setEnabled(false); viewMenuItems[VIEW_ASSOC_NUM].setEnabled(false); Options.setAssocTest(ASSOC_NONE); } theData = new HaploData(); if (type == HAPS_FILE){ theData.prepareHapsInput(new File(inputOptions[0])); }else{ theData.linkageToChrom(inFile, type); } if(type != HAPS_FILE && theData.getPedFile().isBogusParents()) { JOptionPane.showMessageDialog(this, "One or more individuals in the file reference non-existent parents.\nThese references have been ignored.", "File Error", JOptionPane.ERROR_MESSAGE); } //deal with marker information theData.infoKnown = false; File markerFile; if (inputOptions[1] == null){ markerFile = null; }else{ markerFile = new File(inputOptions[1]); } //turn on/off gbrowse menu if (Options.isGBrowseShown()){ gbEditItem.setEnabled(true); }else{ gbEditItem.setEnabled(false); } checkPanel = null; if (type == HAPS_FILE){ readMarkers(markerFile, null); //initialize realIndex Chromosome.doFilter(Chromosome.getUnfilteredSize()); customAssocSet = null; }else{ readMarkers(markerFile, theData.getPedFile().getHMInfo()); //we read the file in first, so we can whitelist all the markers in the custom test set HashSet whiteListedCustomMarkers = new HashSet(); if (inputOptions[2] != null){ customAssocSet = new AssociationTestSet(inputOptions[2]); whiteListedCustomMarkers = customAssocSet.getWhitelist(); }else{ customAssocSet = null; } theData.setWhiteList(whiteListedCustomMarkers); checkPanel = new CheckDataPanel(this); checkPanel.setAlignmentX(Component.CENTER_ALIGNMENT); //set up the indexing to take into account skipped markers. Chromosome.doFilter(checkPanel.getMarkerResults()); } //let's start the math final SwingWorker worker = new SwingWorker(){ public Object construct(){ dPrimeDisplay=null; changeKey(); theData.generateDPrimeTable(); theData.guessBlocks(BLOX_GABRIEL); //theData.guessBlocks(BLOX_NONE); //for debugging, doesn't call blocks at first blockMenuItems[0].setSelected(true); zoomMenuItems[0].setSelected(true); theData.blocksChanged = false; Container contents = getContentPane(); contents.removeAll(); int currentTab = VIEW_D_NUM; /*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(window); 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); viewMenuItems[VIEW_D_NUM].setEnabled(true); //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); hapScroller.getVerticalScrollBar().setUnitIncrement(60); hapScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(hapScroller); panel.add(hdc); tabs.addTab(viewItems[VIEW_HAP_NUM], panel); viewMenuItems[VIEW_HAP_NUM].setEnabled(true); displayMenu.setEnabled(true); analysisMenu.setEnabled(true); //check data panel if (checkPanel != null){ JPanel metaCheckPanel = new JPanel(); metaCheckPanel.setLayout(new BoxLayout(metaCheckPanel, BoxLayout.Y_AXIS)); metaCheckPanel.add(checkPanel); cdc = new CheckDataController(window); metaCheckPanel.add(cdc); tabs.addTab(viewItems[VIEW_CHECK_NUM], metaCheckPanel); viewMenuItems[VIEW_CHECK_NUM].setEnabled(true); currentTab=VIEW_CHECK_NUM; } //Association panel if(Options.getAssocTest() != ASSOC_NONE) { JTabbedPane metaAssoc = new JTabbedPane(); try{ tdtPanel = new TDTPanel(new AssociationTestSet(theData.getPedFile(), null, Chromosome.getAllMarkers())); } catch(PedFileException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } metaAssoc.add("Single Marker", tdtPanel); hapAssocPanel = new HaploAssocPanel(new AssociationTestSet(theData.getHaplotypes(), null)); metaAssoc.add("Haplotypes", hapAssocPanel); //custom association tests custAssocPanel = null; if(customAssocSet != null) { try { customAssocSet.runFileTests(theData, tdtPanel.getTestSet().getMarkerAssociationResults()); custAssocPanel = new CustomAssocPanel(customAssocSet); metaAssoc.addTab("Custom",custAssocPanel); metaAssoc.setSelectedComponent(custAssocPanel); } catch (HaploViewException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } AssociationTestSet permSet; if (custAssocPanel != null){ permSet = custAssocPanel.getTestSet(); }else{ permSet = new AssociationTestSet(); permSet.cat(tdtPanel.getTestSet()); permSet.cat(hapAssocPanel.getTestSet()); } permutationPanel = new PermutationTestPanel(new PermutationTestSet(0,theData.getSavedEMs(), theData.getPedFile(),permSet)); metaAssoc.add(permutationPanel,"Permutation Tests"); tabs.addTab(VIEW_ASSOC, metaAssoc); viewMenuItems[VIEW_ASSOC_NUM].setEnabled(true); } //tagger display //if(Options.isUseTagger()) { //TaggerController tagControl = new TaggerController(theData,null,null,null); taggerConfigPanel = new TaggerConfigPanel(theData); JPanel metaTagPanel = new JPanel(); metaTagPanel.setLayout(new BoxLayout(metaTagPanel,BoxLayout.Y_AXIS)); metaTagPanel.add(taggerConfigPanel); JTabbedPane tagTabs = new JTabbedPane(); tagTabs.add("Configuration",metaTagPanel); JPanel resMetaPanel = new JPanel(); resMetaPanel.setLayout(new BoxLayout(resMetaPanel,BoxLayout.Y_AXIS)); TaggerResultsPanel tagResultsPanel = new TaggerResultsPanel(); taggerConfigPanel.addActionListener(tagResultsPanel); resMetaPanel.add(tagResultsPanel); tagTabs.addTab("Results",resMetaPanel); tabs.addTab("Tagger",tagTabs); //} tabs.setSelectedIndex(currentTab); contents.add(tabs); repaint(); setVisible(true); theData.finished = true; setTitle(TITLE_STRING + " -- " + inFile.getName()); return null; } }; timer = new javax.swing.Timer(50, new ActionListener(){ public void actionPerformed(ActionEvent evt){ if (theData.finished){ timer.stop(); for (int i = 0; i < blockMenuItems.length; i++){ blockMenuItems[i].setEnabled(true); } clearBlocksItem.setEnabled(true); readMarkerItem.setEnabled(true); blocksItem.setEnabled(true); exportMenuItems[2].setEnabled(true); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } }); worker.start(); timer.start(); }catch(IOException ioexec) { JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); }catch(PedFileException pfe){ JOptionPane.showMessageDialog(this, pfe.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); }catch (HaploViewException hve){ JOptionPane.showMessageDialog(this, hve.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } |
|
taggerConfigPanel = new TaggerConfigPanel(theData); JPanel metaTagPanel = new JPanel(); metaTagPanel.setLayout(new BoxLayout(metaTagPanel,BoxLayout.Y_AXIS)); metaTagPanel.add(taggerConfigPanel); JTabbedPane tagTabs = new JTabbedPane(); tagTabs.add("Configuration",metaTagPanel); JPanel resMetaPanel = new JPanel(); resMetaPanel.setLayout(new BoxLayout(resMetaPanel,BoxLayout.Y_AXIS)); TaggerResultsPanel tagResultsPanel = new TaggerResultsPanel(); taggerConfigPanel.addActionListener(tagResultsPanel); resMetaPanel.add(tagResultsPanel); tagTabs.addTab("Results",resMetaPanel); tabs.addTab("Tagger",tagTabs); | public Object construct(){ dPrimeDisplay=null; changeKey(); theData.generateDPrimeTable(); theData.guessBlocks(BLOX_GABRIEL); //theData.guessBlocks(BLOX_NONE); //for debugging, doesn't call blocks at first blockMenuItems[0].setSelected(true); zoomMenuItems[0].setSelected(true); theData.blocksChanged = false; Container contents = getContentPane(); contents.removeAll(); int currentTab = VIEW_D_NUM; /*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(window); 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); viewMenuItems[VIEW_D_NUM].setEnabled(true); //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); hapScroller.getVerticalScrollBar().setUnitIncrement(60); hapScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(hapScroller); panel.add(hdc); tabs.addTab(viewItems[VIEW_HAP_NUM], panel); viewMenuItems[VIEW_HAP_NUM].setEnabled(true); displayMenu.setEnabled(true); analysisMenu.setEnabled(true); //check data panel if (checkPanel != null){ JPanel metaCheckPanel = new JPanel(); metaCheckPanel.setLayout(new BoxLayout(metaCheckPanel, BoxLayout.Y_AXIS)); metaCheckPanel.add(checkPanel); cdc = new CheckDataController(window); metaCheckPanel.add(cdc); tabs.addTab(viewItems[VIEW_CHECK_NUM], metaCheckPanel); viewMenuItems[VIEW_CHECK_NUM].setEnabled(true); currentTab=VIEW_CHECK_NUM; } //Association panel if(Options.getAssocTest() != ASSOC_NONE) { JTabbedPane metaAssoc = new JTabbedPane(); try{ tdtPanel = new TDTPanel(new AssociationTestSet(theData.getPedFile(), null, Chromosome.getAllMarkers())); } catch(PedFileException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } metaAssoc.add("Single Marker", tdtPanel); hapAssocPanel = new HaploAssocPanel(new AssociationTestSet(theData.getHaplotypes(), null)); metaAssoc.add("Haplotypes", hapAssocPanel); //custom association tests custAssocPanel = null; if(customAssocSet != null) { try { customAssocSet.runFileTests(theData, tdtPanel.getTestSet().getMarkerAssociationResults()); custAssocPanel = new CustomAssocPanel(customAssocSet); metaAssoc.addTab("Custom",custAssocPanel); metaAssoc.setSelectedComponent(custAssocPanel); } catch (HaploViewException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } AssociationTestSet permSet; if (custAssocPanel != null){ permSet = custAssocPanel.getTestSet(); }else{ permSet = new AssociationTestSet(); permSet.cat(tdtPanel.getTestSet()); permSet.cat(hapAssocPanel.getTestSet()); } permutationPanel = new PermutationTestPanel(new PermutationTestSet(0,theData.getSavedEMs(), theData.getPedFile(),permSet)); metaAssoc.add(permutationPanel,"Permutation Tests"); tabs.addTab(VIEW_ASSOC, metaAssoc); viewMenuItems[VIEW_ASSOC_NUM].setEnabled(true); } //tagger display //if(Options.isUseTagger()) { //TaggerController tagControl = new TaggerController(theData,null,null,null); taggerConfigPanel = new TaggerConfigPanel(theData); JPanel metaTagPanel = new JPanel(); metaTagPanel.setLayout(new BoxLayout(metaTagPanel,BoxLayout.Y_AXIS)); metaTagPanel.add(taggerConfigPanel); JTabbedPane tagTabs = new JTabbedPane(); tagTabs.add("Configuration",metaTagPanel); JPanel resMetaPanel = new JPanel(); resMetaPanel.setLayout(new BoxLayout(resMetaPanel,BoxLayout.Y_AXIS)); TaggerResultsPanel tagResultsPanel = new TaggerResultsPanel(); taggerConfigPanel.addActionListener(tagResultsPanel); resMetaPanel.add(tagResultsPanel); tagTabs.addTab("Results",resMetaPanel); tabs.addTab("Tagger",tagTabs); //} tabs.setSelectedIndex(currentTab); contents.add(tabs); repaint(); setVisible(true); theData.finished = true; setTitle(TITLE_STRING + " -- " + inFile.getName()); return null; } |
|
if (taggerConfigPanel != null){ taggerConfigPanel.refreshTable(); } | void readMarkers(File inputFile, String[][] hminfo){ try { theData.prepareMarkerInput(inputFile, hminfo); if (theData.infoKnown){ analysisItem.setEnabled(true); gbrowseItem.setEnabled(true); spacingItem.setEnabled(true); }else{ analysisItem.setEnabled(false); gbrowseItem.setEnabled(false); spacingItem.setEnabled(false); } if (checkPanel != null){ //this is triggered when loading markers after already loading genotypes //it is dumb and sucks, but at least it works. bah. checkPanel = new CheckDataPanel(this); Container checkTab = (Container)tabs.getComponentAt(VIEW_CHECK_NUM); checkTab.removeAll(); JPanel metaCheckPanel = new JPanel(); metaCheckPanel.setLayout(new BoxLayout(metaCheckPanel, BoxLayout.Y_AXIS)); metaCheckPanel.add(checkPanel); cdc = new CheckDataController(window); metaCheckPanel.add(cdc); checkTab.add(metaCheckPanel); repaint(); } if (tdtPanel != null){ tdtPanel.refreshNames(); } if (dPrimeDisplay != null){ dPrimeDisplay.computePreferredSize(); } }catch (HaploViewException e){ JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); }catch (IOException ioexec){ JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } } |
|
long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); | long minpos = Chromosome.getFilteredMarker(0).getPosition(); long maxpos = Chromosome.getFilteredMarker(Chromosome.getFilteredSize()-1).getPosition(); | public void paintComponent(Graphics g){ PairwiseLinkage[][] dPrimeTable = theData.filteredDPrimeTable; if (dPrimeTable.length == 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; } if (zoomLevel == 0){ printMarkerNames = true; } else{ printMarkerNames = false; } 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; left = H_BORDER; top = V_BORDER; if (forExport){ left -= exportStart * boxSize; } FontMetrics metrics; int ascent; g2.setFont(boldMarkerNameFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); //TODO: finish implementing scaling gizmo /*//deal with adding some space to better display data with large gaps int cumulativeGap[] = new int[Chromosome.getFilteredSize()]; for (int i = 0; i < cumulativeGap.length; i++){ cumulativeGap[i] = 0; } if (theData.infoKnown){ double mean = (((SNP)Chromosome.markers[Chromosome.markers.length-1]).getPosition() - ((SNP)Chromosome.markers[0]).getPosition())/Chromosome.markers.length-1; for (int i = 1; i < cumulativeGap.length; i++){ double sep = Chromosome.getMarker(i).getPosition() - Chromosome.getMarker(i-1).getPosition(); if (sep > mean*10){ cumulativeGap[i] = cumulativeGap[i-1] + (int)(sep/mean)*4; }else{ cumulativeGap[i] = cumulativeGap[i-1]; } } } */ //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = (visRect.x-clickXShift-(visRect.y + visRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((visRect.x + visRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((visRect.x-clickXShift)+(visRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } if (forExport){ lowX = exportStart; lowY = exportStart; highX = exportStop; highY = exportStop; } int lineSpan = (dPrimeTable.length-1) * boxSize; long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; if (theData.trackExists){ //draw the analysis track above where the marker positions will be marked g2.setColor(Color.white); g2.fillRect(left, top, lineSpan, TRACK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left, top, lineSpan, TRACK_HEIGHT); //get the data into an easier format double positions[] = new double[theData.analysisPositions.size()]; double values[] = new double[theData.analysisPositions.size()]; for (int x = 0; x < positions.length; x++){ positions[x] = ((Double)theData.analysisPositions.elementAt(x)).doubleValue(); values[x] = ((Double)theData.analysisValues.elementAt(x)).doubleValue(); } g2.setColor(Color.black); double min = Double.MAX_VALUE; double max = -min; for (int x = 0; x < positions.length; x++){ if(values[x] < min){ min = values[x]; } if (values[x] > max){ max = values[x]; } } double range = max-min; //todo: this is kinda hideous for (int x = 0; x < positions.length - 1; x++){ if (positions[x] >= minpos && positions[x+1] <= maxpos){ g2.draw(new Line2D.Double(lineSpan * Math.abs((positions[x] - minpos)/spanpos) + left, top + TRACK_PALETTE + TRACK_BUMPER - (TRACK_PALETTE * Math.abs((values[x] - min)/range)), lineSpan * Math.abs((positions[x+1] - minpos)/spanpos) + left, top + TRACK_PALETTE + TRACK_BUMPER - (TRACK_PALETTE * Math.abs((values[x+1] - min)/range)))); } } top += TRACK_HEIGHT + TRACK_GAP; } if (theData.infoKnown) { 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.fillRect(left+1, top+1, lineSpan-1, TICK_HEIGHT-1); g2.setColor(Color.black); g2.drawRect(left, top, lineSpan, TICK_HEIGHT); for (int i = 0; i < Chromosome.getFilteredSize(); i++){ double pos = (Chromosome.getFilteredMarker(i).getPosition() - minpos) / spanpos; int xx = (int) (left + lineSpan*pos); // 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.getFilteredMarker(i).getExtra() != null && zoomLevel != 0) g2.setColor(green); g2.setStroke(thickerStroke); g2.drawLine(xx, top, xx, top + TICK_HEIGHT); if (Chromosome.getFilteredMarker(i).getExtra() != null && zoomLevel != 0) g2.setStroke(thickerStroke); else g2.setStroke(thinnerStroke); g2.drawLine(xx, top + TICK_HEIGHT, left + i*boxSize, top+TICK_BOTTOM); if (Chromosome.getFilteredMarker(i).getExtra() != null && zoomLevel != 0) g2.setColor(Color.black); } top += TICK_BOTTOM + TICK_HEIGHT; //// draw the marker names if (printMarkerNames){ widestMarkerName = metrics.stringWidth(Chromosome.getFilteredMarker(0).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(Chromosome.getFilteredMarker(x).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { if (theData.isInBlock[x]){ g2.setFont(boldMarkerNameFont); }else{ g2.setFont(markerNameFont); } if (Chromosome.getFilteredMarker(x).getExtra() != null) g2.setColor(green); g2.drawString(Chromosome.getFilteredMarker(x).getName(),TEXT_GAP, x*boxSize + ascent/3); if (Chromosome.getFilteredMarker(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 < dPrimeTable.length; x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g2.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(theData.infoKnown)){ clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g2.setColor(boxColor); g2.fillPolygon(diamond); if(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); } } } } boolean even = true; //highlight blocks g2.setFont(markerNameFont); ascent = g2.getFontMetrics().getAscent(); //g.setColor(new Color(153,255,153)); g2.setColor(Color.black); //g.setColor(new Color(51,153,51)); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; //big vee around whole thing g2.setStroke(fatStroke); g2.drawLine(left + (2*first) * boxSize/2 - boxRadius, top, left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius); g2.drawLine(left + (first + last) * boxSize/2, top + (last - first) * boxSize/2 + boxRadius, left + (2*last) * boxSize/2+boxRadius, top); for (int j = first; j <= last; j++){ if (theData.isInBlock[j]){ g2.setStroke(fatStroke); }else{ g2.setStroke(dashedFatStroke); } g2.drawLine(left+j*boxSize-boxSize/2, top-blockDispHeight, left+j*boxSize+boxSize/2, top-blockDispHeight); } //lines to connect to block display g2.setStroke(fatStroke); g2.drawLine(left + first*boxSize-boxSize/2, top-1, left+first*boxSize-boxSize/2, top-blockDispHeight); g2.drawLine(left+last*boxSize+boxSize/2, top-1, left+last*boxSize+boxSize/2, top-blockDispHeight); if (printMarkerNames){ String labelString = new String ("Block " + (i+1)); if (theData.infoKnown){ long blockSize = Chromosome.getFilteredMarker(last).getPosition() - Chromosome.getFilteredMarker(first).getPosition(); labelString += " (" + blockSize/1000 + " kb)"; } g2.drawString(labelString, left+first*boxSize-boxSize/2+TEXT_GAP, top-boxSize/3); } } g2.setStroke(thickerStroke); //see if the user has right-clicked to popup some marker info if(popupExists){ int smallDatasetSlopH = 0; int smallDatasetSlopV = 0; if (pref.getWidth() < visRect.width){ //dumb bug where little datasets popup the box in the wrong place smallDatasetSlopH = (int)(visRect.width - pref.getWidth())/2; smallDatasetSlopV = (int)(visRect.height - pref.getHeight())/2; } g2.setColor(Color.white); g2.fillRect(popupDrawRect.x+1-smallDatasetSlopH, popupDrawRect.y+1-smallDatasetSlopV, popupDrawRect.width-1, popupDrawRect.height-1); g2.setColor(Color.black); g2.drawRect(popupDrawRect.x-smallDatasetSlopH, popupDrawRect.y-smallDatasetSlopV, popupDrawRect.width, popupDrawRect.height); for (int x = 0; x < displayStrings.length; x++){ g.drawString(displayStrings[x],popupDrawRect.x + popupLeftMargin-smallDatasetSlopH, popupDrawRect.y+((x+1)*metrics.getHeight())-smallDatasetSlopV); } } if (showWM && !forExport){ //dataset is big enough to require worldmap final int WM_BD_GAP = 1; final int WM_BD_HEIGHT = 2; final int WM_BD_TOTAL = WM_BD_HEIGHT + 2*WM_BD_GAP; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); if (wmMaxWidth == 0){ wmMaxWidth = visRect.width/3; } double scalefactor; scalefactor = (double)(chartSize.width)/wmMaxWidth; double prefBoxSize = boxSize/(scalefactor*((double)wmMaxWidth/(double)(wmMaxWidth-WM_BD_TOTAL))); if (noImage){ //first time through draw a worldmap if dataset is big: worldmap = new BufferedImage((int)(chartSize.width/scalefactor)+wmBorder.getBorderInsets(this).left*2, (int)(chartSize.height/scalefactor)+wmBorder.getBorderInsets(this).top*2+WM_BD_TOTAL, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(1,1,worldmap.getWidth()-1,worldmap.getHeight()-1); //make a pretty border gw2.setColor(Color.black); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth(),worldmap.getHeight()); wmInteriorRect = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth(), worldmap.getHeight()); float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < dPrimeTable.length-1; x++){ for (int y = x+1; y < dPrimeTable.length; y++){ if (dPrimeTable[x][y] == null){ continue; } double xx = (x + y)*prefBoxSize/2+wmBorder.getBorderInsets(this).left; double yy = (y - x)*prefBoxSize/2+wmBorder.getBorderInsets(this).top + WM_BD_TOTAL; smallDiamondX[0] = (float)xx; smallDiamondY[0] = (float)(yy - prefBoxSize/2); smallDiamondX[1] = (float)(xx + prefBoxSize/2); smallDiamondY[1] = (float)yy; smallDiamondX[2] = (float)xx; smallDiamondY[2] = (float)(yy + prefBoxSize/2); smallDiamondX[3] = (float)(xx - prefBoxSize/2); smallDiamondY[3] = (float)yy; gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, smallDiamondX.length); gp.moveTo(smallDiamondX[0],smallDiamondY[0]); for (int i = 1; i < smallDiamondX.length; i++){ gp.lineTo(smallDiamondX[i], smallDiamondY[i]); } gp.closePath(); gw2.setColor(dPrimeTable[x][y].getColor()); gw2.fill(gp); } } noImage = false; } //draw block display in worldmap Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(wmBorder.getBorderInsets(this).left, wmBorder.getBorderInsets(this).top+WM_BD_GAP, wmInteriorRect.width, WM_BD_HEIGHT); gw2.setColor(Color.black); even = true; for (int i = 0; i < blocks.size(); i++){ int first = ((int[])blocks.elementAt(i))[0]; int last = ((int[])blocks.elementAt(i))[((int[])blocks.elementAt(i)).length-1]; int voffset; if (even){ voffset = 0; }else{ voffset = WM_BD_HEIGHT/2; } gw2.fillRect(wmBorder.getBorderInsets(this).left+(int)(prefBoxSize*first), wmBorder.getBorderInsets(this).top+voffset+WM_BD_GAP, (int)((last-first+1)*prefBoxSize), WM_BD_HEIGHT/2); even = !even; } wmResizeCorner = new Rectangle(visRect.x + worldmap.getWidth() - (worldmap.getWidth()-wmInteriorRect.width)/2, visRect.y + visRect.height - worldmap.getHeight(), (worldmap.getWidth()-wmInteriorRect.width)/2, (worldmap.getHeight() -wmInteriorRect.height)/2); g2.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); wmInteriorRect.x = visRect.x + (worldmap.getWidth() - wmInteriorRect.width)/2; wmInteriorRect.y = visRect.y+visRect.height-worldmap.getHeight() + (worldmap.getHeight() - wmInteriorRect.height)/2; //draw the outline of the viewport g2.setColor(Color.black); double hRatio = wmInteriorRect.getWidth()/pref.getWidth(); double vRatio = wmInteriorRect.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-wmInteriorRect.width; int vBump = worldmap.getHeight()-wmInteriorRect.height; //bump a few pixels to avoid drawing on the border g2.drawRect((int)(visRect.x*hRatio)+hBump/2+visRect.x, (int)(visRect.y*vRatio)+vBump/2+(visRect.y + visRect.height - worldmap.getHeight()), (int)(visRect.width*hRatio), (int)(visRect.height*vRatio)); } //see if we're drawing a worldmap resize rect if (resizeRectExists){ g2.setColor(Color.black); g2.drawRect(resizeWMRect.x, resizeWMRect.y, resizeWMRect.width, resizeWMRect.height); } //see if we're drawing a block selector rect if (blockRectExists){ g2.setColor(Color.black); g2.setStroke(dashedThinStroke); g2.drawRect(blockRect.x, blockRect.y, blockRect.width, blockRect.height); } } |
float scale = 1.0f; imgRot = newRotDegrees; if ( fitSize ) { log.debug( "fitSize" ); float widthScale = ((float)maxWidth)/origImage.getWidth(); float heightScale = ((float)maxHeight)/origImage.getHeight(); scale = widthScale; if ( heightScale < scale ) { scale = heightScale; } log.debug( "scale: " + scale ); } else { scale = (float) imgScale; log.debug( "scale: " + scale ); } Cursor oldCursor = getCursor(); setCursor( new Cursor( Cursor.WAIT_CURSOR ) ); Rectangle2D cropUsed = newCrop; if ( !drawCropped ) { cropUsed = new Rectangle2D.Double( 0.0, 0.0, 1.0, 1.0 ); } else { crop = newCrop; | Cursor oldCursor = getCursor(); try { float scale = 1.0f; imgRot = newRotDegrees; if ( fitSize ) { log.debug( "fitSize" ); float widthScale = ((float)maxWidth)/origImage.getWidth(); float heightScale = ((float)maxHeight)/origImage.getHeight(); scale = widthScale; if ( heightScale < scale ) { scale = heightScale; } log.debug( "scale: " + scale ); } else { scale = (float) imgScale; log.debug( "scale: " + scale ); } setCursor( new Cursor( Cursor.WAIT_CURSOR ) ); Rectangle2D cropUsed = newCrop; if ( !drawCropped ) { cropUsed = new Rectangle2D.Double( 0.0, 0.0, 1.0, 1.0 ); } else { crop = newCrop; } AffineTransform at = null; if ( fitSize ) { at = org.photovault.image.ImageXform.getFittingXform( (int)maxWidth, (int)maxHeight, imgRot, (int)( origImage.getWidth() * cropUsed.getWidth() ), (int)(( cropUsed.getHeight()* origImage.getHeight() ) ) ); } else { at = org.photovault.image.ImageXform.getScaleXform( imgScale, imgRot, (int)( origImage.getWidth() * cropUsed.getWidth() ), (int)(( cropUsed.getHeight()* origImage.getHeight() ) ) ); } ParameterBlockJAI scaleParams = new ParameterBlockJAI( "affine" ); scaleParams.addSource( origImage ); scaleParams.setParameter( "transform", at ); scaleParams.setParameter( "interpolation", new InterpolationBilinear()); RenderedOp tmp = JAI.create( "affine", scaleParams, null ); ParameterBlockJAI cropParams = new ParameterBlockJAI( "crop" ); cropParams.addSource( tmp ); float cropX = (float)( Math.rint( tmp.getMinX() + cropUsed.getMinX() * tmp.getWidth() )); float cropY = (float)( Math.rint( tmp.getMinY() + cropUsed.getMinY() * tmp.getHeight() )); float cropW = (float)( Math.rint( cropUsed.getWidth() * tmp.getWidth() )); float cropH = (float) ( Math.rint( cropUsed.getHeight() * tmp.getHeight() )); cropParams.setParameter( "x", cropX ); cropParams.setParameter( "y", cropY ); cropParams.setParameter( "width", cropW ); cropParams.setParameter( "height", cropH ); RenderedOp cropped = JAI.create("crop", cropParams, null); ParameterBlockJAI pbXlate = new ParameterBlockJAI( "translate" ); pbXlate.addSource( cropped ); pbXlate.setParameter( "xTrans", (float) (-cropped.getMinX() ) ); pbXlate.setParameter( "yTrans", (float) (-cropped.getMinY() ) ); xformImage = JAI.create( "translate", pbXlate ); cropBorderXpoints = null; cropBorderYpoints = null; } catch ( Exception ex ) { final String exMsg = ex.getMessage(); final JAIPhotoView staticThis = this; staticThis.origImage = null; SwingUtilities.invokeLater( new Runnable() { public void run() { JOptionPane.showMessageDialog( staticThis, "Error while showing an image\n" + exMsg + "\nMost likely the image file in Photovault database is corrupted.", "Error displaying image", JOptionPane.ERROR_MESSAGE ); } }); | private void buildXformImage() { // ParameterBlock pbRen = new ParameterBlock();// pbRen.addSource( origImage );// pbRen.add(null).add(null).add(null).add(null).add(null); // RenderableImage renSrc = JAI.createRenderable( "renderable", pbRen ); float scale = 1.0f; imgRot = newRotDegrees; if ( fitSize ) { log.debug( "fitSize" ); float widthScale = ((float)maxWidth)/origImage.getWidth(); float heightScale = ((float)maxHeight)/origImage.getHeight(); scale = widthScale; if ( heightScale < scale ) { scale = heightScale; } log.debug( "scale: " + scale ); } else { scale = (float) imgScale; log.debug( "scale: " + scale ); } // Set the hourglass cursor Cursor oldCursor = getCursor(); setCursor( new Cursor( Cursor.WAIT_CURSOR ) ); Rectangle2D cropUsed = newCrop; if ( !drawCropped ) { cropUsed = new Rectangle2D.Double( 0.0, 0.0, 1.0, 1.0 ); } else { crop = newCrop; } // Create the zoom xform AffineTransform at = null; if ( fitSize ) { at = org.photovault.image.ImageXform.getFittingXform( (int)maxWidth, (int)maxHeight, imgRot, (int)( origImage.getWidth() * cropUsed.getWidth() ), (int)(( cropUsed.getHeight()* origImage.getHeight() ) ) ); } else { at = org.photovault.image.ImageXform.getScaleXform( imgScale, imgRot, (int)( origImage.getWidth() * cropUsed.getWidth() ), (int)(( cropUsed.getHeight()* origImage.getHeight() ) ) ); } // Create a ParameterBlock and specify the source and // parameters ParameterBlockJAI scaleParams = new ParameterBlockJAI( "affine" ); scaleParams.addSource( origImage ); scaleParams.setParameter( "transform", at ); scaleParams.setParameter( "interpolation", new InterpolationBilinear()); // Create the scale operation RenderedOp tmp = JAI.create( "affine", scaleParams, null ); ParameterBlockJAI cropParams = new ParameterBlockJAI( "crop" ); cropParams.addSource( tmp ); float cropX = (float)( Math.rint( tmp.getMinX() + cropUsed.getMinX() * tmp.getWidth() )); float cropY = (float)( Math.rint( tmp.getMinY() + cropUsed.getMinY() * tmp.getHeight() )); float cropW = (float)( Math.rint( cropUsed.getWidth() * tmp.getWidth() )); float cropH = (float) ( Math.rint( cropUsed.getHeight() * tmp.getHeight() )); cropParams.setParameter( "x", cropX ); cropParams.setParameter( "y", cropY ); cropParams.setParameter( "width", cropW ); cropParams.setParameter( "height", cropH ); RenderedOp cropped = JAI.create("crop", cropParams, null); // Translate the image so that it begins in origo ParameterBlockJAI pbXlate = new ParameterBlockJAI( "translate" ); pbXlate.addSource( cropped ); pbXlate.setParameter( "xTrans", (float) (-cropped.getMinX() ) ); pbXlate.setParameter( "yTrans", (float) (-cropped.getMinY() ) ); xformImage = JAI.create( "translate", pbXlate ); // We need to update also the crop border since image size & orientation // has changed cropBorderXpoints = null; cropBorderYpoints = null; setCursor( oldCursor ); } |
AffineTransform at = null; if ( fitSize ) { at = org.photovault.image.ImageXform.getFittingXform( (int)maxWidth, (int)maxHeight, imgRot, (int)( origImage.getWidth() * cropUsed.getWidth() ), (int)(( cropUsed.getHeight()* origImage.getHeight() ) ) ); } else { at = org.photovault.image.ImageXform.getScaleXform( imgScale, imgRot, (int)( origImage.getWidth() * cropUsed.getWidth() ), (int)(( cropUsed.getHeight()* origImage.getHeight() ) ) ); } ParameterBlockJAI scaleParams = new ParameterBlockJAI( "affine" ); scaleParams.addSource( origImage ); scaleParams.setParameter( "transform", at ); scaleParams.setParameter( "interpolation", new InterpolationBilinear()); RenderedOp tmp = JAI.create( "affine", scaleParams, null ); ParameterBlockJAI cropParams = new ParameterBlockJAI( "crop" ); cropParams.addSource( tmp ); float cropX = (float)( Math.rint( tmp.getMinX() + cropUsed.getMinX() * tmp.getWidth() )); float cropY = (float)( Math.rint( tmp.getMinY() + cropUsed.getMinY() * tmp.getHeight() )); float cropW = (float)( Math.rint( cropUsed.getWidth() * tmp.getWidth() )); float cropH = (float) ( Math.rint( cropUsed.getHeight() * tmp.getHeight() )); cropParams.setParameter( "x", cropX ); cropParams.setParameter( "y", cropY ); cropParams.setParameter( "width", cropW ); cropParams.setParameter( "height", cropH ); RenderedOp cropped = JAI.create("crop", cropParams, null); ParameterBlockJAI pbXlate = new ParameterBlockJAI( "translate" ); pbXlate.addSource( cropped ); pbXlate.setParameter( "xTrans", (float) (-cropped.getMinX() ) ); pbXlate.setParameter( "yTrans", (float) (-cropped.getMinY() ) ); xformImage = JAI.create( "translate", pbXlate ); cropBorderXpoints = null; cropBorderYpoints = null; setCursor( oldCursor ); | setCursor( oldCursor ); | private void buildXformImage() { // ParameterBlock pbRen = new ParameterBlock();// pbRen.addSource( origImage );// pbRen.add(null).add(null).add(null).add(null).add(null); // RenderableImage renSrc = JAI.createRenderable( "renderable", pbRen ); float scale = 1.0f; imgRot = newRotDegrees; if ( fitSize ) { log.debug( "fitSize" ); float widthScale = ((float)maxWidth)/origImage.getWidth(); float heightScale = ((float)maxHeight)/origImage.getHeight(); scale = widthScale; if ( heightScale < scale ) { scale = heightScale; } log.debug( "scale: " + scale ); } else { scale = (float) imgScale; log.debug( "scale: " + scale ); } // Set the hourglass cursor Cursor oldCursor = getCursor(); setCursor( new Cursor( Cursor.WAIT_CURSOR ) ); Rectangle2D cropUsed = newCrop; if ( !drawCropped ) { cropUsed = new Rectangle2D.Double( 0.0, 0.0, 1.0, 1.0 ); } else { crop = newCrop; } // Create the zoom xform AffineTransform at = null; if ( fitSize ) { at = org.photovault.image.ImageXform.getFittingXform( (int)maxWidth, (int)maxHeight, imgRot, (int)( origImage.getWidth() * cropUsed.getWidth() ), (int)(( cropUsed.getHeight()* origImage.getHeight() ) ) ); } else { at = org.photovault.image.ImageXform.getScaleXform( imgScale, imgRot, (int)( origImage.getWidth() * cropUsed.getWidth() ), (int)(( cropUsed.getHeight()* origImage.getHeight() ) ) ); } // Create a ParameterBlock and specify the source and // parameters ParameterBlockJAI scaleParams = new ParameterBlockJAI( "affine" ); scaleParams.addSource( origImage ); scaleParams.setParameter( "transform", at ); scaleParams.setParameter( "interpolation", new InterpolationBilinear()); // Create the scale operation RenderedOp tmp = JAI.create( "affine", scaleParams, null ); ParameterBlockJAI cropParams = new ParameterBlockJAI( "crop" ); cropParams.addSource( tmp ); float cropX = (float)( Math.rint( tmp.getMinX() + cropUsed.getMinX() * tmp.getWidth() )); float cropY = (float)( Math.rint( tmp.getMinY() + cropUsed.getMinY() * tmp.getHeight() )); float cropW = (float)( Math.rint( cropUsed.getWidth() * tmp.getWidth() )); float cropH = (float) ( Math.rint( cropUsed.getHeight() * tmp.getHeight() )); cropParams.setParameter( "x", cropX ); cropParams.setParameter( "y", cropY ); cropParams.setParameter( "width", cropW ); cropParams.setParameter( "height", cropH ); RenderedOp cropped = JAI.create("crop", cropParams, null); // Translate the image so that it begins in origo ParameterBlockJAI pbXlate = new ParameterBlockJAI( "translate" ); pbXlate.addSource( cropped ); pbXlate.setParameter( "xTrans", (float) (-cropped.getMinX() ) ); pbXlate.setParameter( "yTrans", (float) (-cropped.getMinY() ) ); xformImage = JAI.create( "translate", pbXlate ); // We need to update also the crop border since image size & orientation // has changed cropBorderXpoints = null; cropBorderYpoints = null; setCursor( oldCursor ); } |
if ( getTrim() | if ( isTrim() | public Script getBody() { if ( getTrim() && ! hasTrimmed ) { trimBody(); } return body; } |
if(context.getUser().isAdmin()){ EncryptedKey encryptedKey = KeyManager.readKey(changePasswordForm.getOldPassword().toCharArray()); encryptedKey.setPassword(changePasswordForm.getNewPassword().toCharArray()); KeyManager.writeKey(encryptedKey); } | public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { ChangePasswordForm changePasswordForm = (ChangePasswordForm)actionForm; ActionErrors errors = new ActionErrors(); /*Make sure that entered password is valid*/ if(!Crypto.hash(changePasswordForm.getOldPassword()).equals (context.getUser().getPassword())){ errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(ErrorCodes.INVALID_OLD_PASSWORD)); request.setAttribute(Globals.ERROR_KEY, errors); return mapping.getInputForward(); } /*Make sure that both entered passwords match */ if(!changePasswordForm.getNewPassword().equals (changePasswordForm.getConfirmPassword())){ errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(ErrorCodes.PASSWORD_MISMATCH)); request.setAttribute(Globals.ERROR_KEY, errors); return mapping.getInputForward(); } String username = context.getUser().getUsername(); String password = changePasswordForm.getNewPassword(); UserManager.getInstance().updatePassword(username, password); return mapping.findForward(Forwards.SUCCESS); } |
|
public Tag createTag() { | public Tag createTag(String name, Attributes attributes) { | public TagScript createTagScript( final String name, Attributes attrs ) throws Exception { if ( name.equals( "tagdef" ) ) { return new TagScript( new TagFactory() { public Tag createTag() { return new TagDefTag( JeezTagLibrary.this ); } } ); } if ( name.equals( "target" ) ) { return new TagScript( new TagFactory() { public Tag createTag() { return new TargetTag(); } } ); } TagScript script = this.werkzTagLib.createTagScript( name, attrs ); if ( script == null ) { script = antTagLib.createCustomTagScript( name, attrs ); if ( script == null ) { return new TagScript( new TagFactory() { public Tag createTag() throws Exception { // lets try create a dynamic tag first Tag tag = JeezTagLibrary.this.createTag(name); if ( tag != null ) { return tag; } else { return antTagLib.createTag( name ); } } } ); } } return script; } |
public Tag createTag() throws Exception { | public Tag createTag(String name, Attributes attributes) throws Exception { | public TagScript createTagScript( final String name, Attributes attrs ) throws Exception { if ( name.equals( "tagdef" ) ) { return new TagScript( new TagFactory() { public Tag createTag() { return new TagDefTag( JeezTagLibrary.this ); } } ); } if ( name.equals( "target" ) ) { return new TagScript( new TagFactory() { public Tag createTag() { return new TargetTag(); } } ); } TagScript script = this.werkzTagLib.createTagScript( name, attrs ); if ( script == null ) { script = antTagLib.createCustomTagScript( name, attrs ); if ( script == null ) { return new TagScript( new TagFactory() { public Tag createTag() throws Exception { // lets try create a dynamic tag first Tag tag = JeezTagLibrary.this.createTag(name); if ( tag != null ) { return tag; } else { return antTagLib.createTag( name ); } } } ); } } return script; } |
Tag tag = JeezTagLibrary.this.createTag(name); | Tag tag = JeezTagLibrary.this.createTag(name, attributes); | public TagScript createTagScript( final String name, Attributes attrs ) throws Exception { if ( name.equals( "tagdef" ) ) { return new TagScript( new TagFactory() { public Tag createTag() { return new TagDefTag( JeezTagLibrary.this ); } } ); } if ( name.equals( "target" ) ) { return new TagScript( new TagFactory() { public Tag createTag() { return new TargetTag(); } } ); } TagScript script = this.werkzTagLib.createTagScript( name, attrs ); if ( script == null ) { script = antTagLib.createCustomTagScript( name, attrs ); if ( script == null ) { return new TagScript( new TagFactory() { public Tag createTag() throws Exception { // lets try create a dynamic tag first Tag tag = JeezTagLibrary.this.createTag(name); if ( tag != null ) { return tag; } else { return antTagLib.createTag( name ); } } } ); } } return script; } |
return antTagLib.createTag( name ); | return antTagLib.createTag( name, attributes ); | public TagScript createTagScript( final String name, Attributes attrs ) throws Exception { if ( name.equals( "tagdef" ) ) { return new TagScript( new TagFactory() { public Tag createTag() { return new TagDefTag( JeezTagLibrary.this ); } } ); } if ( name.equals( "target" ) ) { return new TagScript( new TagFactory() { public Tag createTag() { return new TargetTag(); } } ); } TagScript script = this.werkzTagLib.createTagScript( name, attrs ); if ( script == null ) { script = antTagLib.createCustomTagScript( name, attrs ); if ( script == null ) { return new TagScript( new TagFactory() { public Tag createTag() throws Exception { // lets try create a dynamic tag first Tag tag = JeezTagLibrary.this.createTag(name); if ( tag != null ) { return tag; } else { return antTagLib.createTag( name ); } } } ); } } return script; } |
public Tag createTag() { | public Tag createTag(String name, Attributes attributes) { | public Tag createTag() { return new TagDefTag( JeezTagLibrary.this ); } |
public Tag createTag() { | public Tag createTag(String name, Attributes attributes) { | public Tag createTag() { return new TargetTag(); } |
public Tag createTag() throws Exception { | public Tag createTag(String name, Attributes attributes) throws Exception { | public Tag createTag() throws Exception { // lets try create a dynamic tag first Tag tag = JeezTagLibrary.this.createTag(name); if ( tag != null ) { return tag; } else { return antTagLib.createTag( name ); } } |
Tag tag = JeezTagLibrary.this.createTag(name); | Tag tag = JeezTagLibrary.this.createTag(name, attributes); | public Tag createTag() throws Exception { // lets try create a dynamic tag first Tag tag = JeezTagLibrary.this.createTag(name); if ( tag != null ) { return tag; } else { return antTagLib.createTag( name ); } } |
return antTagLib.createTag( name ); | return antTagLib.createTag( name, attributes ); | public Tag createTag() throws Exception { // lets try create a dynamic tag first Tag tag = JeezTagLibrary.this.createTag(name); if ( tag != null ) { return tag; } else { return antTagLib.createTag( name ); } } |
public TagDefTag() { | public TagDefTag(DynamicTagLibrary tagLibrary) { this.tagLibrary = tagLibrary; | public TagDefTag() { } |
g.fillRect(clickX+1,clickY+1,strlen+leftMargin+4,5*metrics.getHeight()+9); | g.fillRect(clickX+1-rightEdgeShift, clickY+1-botEdgeShift, strlen+leftMargin+4, 5*metrics.getHeight()+9); | public void mousePressed (MouseEvent e) { if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK){ final int clickX = e.getX(); final int clickY = e.getY(); double dboxX = (double)(clickX - clickXShift - (clickY-clickYShift))/boxSize; double dboxY = (double)(clickX - clickXShift + (clickY-clickYShift))/boxSize; final int boxX, boxY; if (dboxX < 0){ boxX = (int)(dboxX - 0.5); } else{ boxX = (int)(dboxX + 0.5); } if (dboxY < 0){ boxY = (int)(dboxY - 0.5); }else{ boxY = (int)(dboxY + 0.5); } if ((boxX >= lowX && boxX <= highX) && (boxY > boxX && boxY < highY)){ if (dPrimeTable[boxX][boxY] != null){ final SwingWorker worker = new SwingWorker(){ public Object construct(){ final int leftMargin = 12; String[] displayStrings = new String[5]; if (markersLoaded){ displayStrings[0] = new String ("(" +((SNP)markers.elementAt(boxX)).getName() + ", " + ((SNP)markers.elementAt(boxY)).getName() + ")"); }else{ displayStrings[0] = new String("(" + (boxX+1) + ", " + (boxY+1) + ")"); } displayStrings[1] = new String ("D': " + dPrimeTable[boxX][boxY].getDPrime()); displayStrings[2] = new String ("LOD: " + dPrimeTable[boxX][boxY].getLOD()); displayStrings[3] = new String ("r^2: " + dPrimeTable[boxX][boxY].getRSquared()); displayStrings[4] = new String ("D' conf. bounds: " + dPrimeTable[boxX][boxY].getConfidenceLow() + "-" + dPrimeTable[boxX][boxY].getConfidenceHigh()); Graphics g = caller.getGraphics(); g.setFont(boxFont); FontMetrics metrics = g.getFontMetrics(); int strlen = 0; for (int x = 0; x < 5; x++){ if (strlen < metrics.stringWidth(displayStrings[x])){ strlen = metrics.stringWidth(displayStrings[x]); } } g.setColor(Color.WHITE); g.fillRect(clickX+1,clickY+1,strlen+leftMargin+4,5*metrics.getHeight()+9); g.setColor(Color.BLACK); g.drawRect(clickX,clickY,strlen+leftMargin+5,5*metrics.getHeight()+10); for (int x = 0; x < 5; x++){ g.drawString(displayStrings[x],clickX + leftMargin, clickY+5+((x+1)*metrics.getHeight())); } return ""; } }; worker.start(); } } } } |
g.drawRect(clickX,clickY,strlen+leftMargin+5,5*metrics.getHeight()+10); | g.drawRect(clickX-rightEdgeShift, clickY-botEdgeShift, strlen+leftMargin+5, 5*metrics.getHeight()+10); | public void mousePressed (MouseEvent e) { if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK){ final int clickX = e.getX(); final int clickY = e.getY(); double dboxX = (double)(clickX - clickXShift - (clickY-clickYShift))/boxSize; double dboxY = (double)(clickX - clickXShift + (clickY-clickYShift))/boxSize; final int boxX, boxY; if (dboxX < 0){ boxX = (int)(dboxX - 0.5); } else{ boxX = (int)(dboxX + 0.5); } if (dboxY < 0){ boxY = (int)(dboxY - 0.5); }else{ boxY = (int)(dboxY + 0.5); } if ((boxX >= lowX && boxX <= highX) && (boxY > boxX && boxY < highY)){ if (dPrimeTable[boxX][boxY] != null){ final SwingWorker worker = new SwingWorker(){ public Object construct(){ final int leftMargin = 12; String[] displayStrings = new String[5]; if (markersLoaded){ displayStrings[0] = new String ("(" +((SNP)markers.elementAt(boxX)).getName() + ", " + ((SNP)markers.elementAt(boxY)).getName() + ")"); }else{ displayStrings[0] = new String("(" + (boxX+1) + ", " + (boxY+1) + ")"); } displayStrings[1] = new String ("D': " + dPrimeTable[boxX][boxY].getDPrime()); displayStrings[2] = new String ("LOD: " + dPrimeTable[boxX][boxY].getLOD()); displayStrings[3] = new String ("r^2: " + dPrimeTable[boxX][boxY].getRSquared()); displayStrings[4] = new String ("D' conf. bounds: " + dPrimeTable[boxX][boxY].getConfidenceLow() + "-" + dPrimeTable[boxX][boxY].getConfidenceHigh()); Graphics g = caller.getGraphics(); g.setFont(boxFont); FontMetrics metrics = g.getFontMetrics(); int strlen = 0; for (int x = 0; x < 5; x++){ if (strlen < metrics.stringWidth(displayStrings[x])){ strlen = metrics.stringWidth(displayStrings[x]); } } g.setColor(Color.WHITE); g.fillRect(clickX+1,clickY+1,strlen+leftMargin+4,5*metrics.getHeight()+9); g.setColor(Color.BLACK); g.drawRect(clickX,clickY,strlen+leftMargin+5,5*metrics.getHeight()+10); for (int x = 0; x < 5; x++){ g.drawString(displayStrings[x],clickX + leftMargin, clickY+5+((x+1)*metrics.getHeight())); } return ""; } }; worker.start(); } } } } |
g.drawString(displayStrings[x],clickX + leftMargin, clickY+5+((x+1)*metrics.getHeight())); | g.drawString(displayStrings[x],clickX + leftMargin - rightEdgeShift, clickY+5+((x+1)*metrics.getHeight())-botEdgeShift); | public void mousePressed (MouseEvent e) { if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK){ final int clickX = e.getX(); final int clickY = e.getY(); double dboxX = (double)(clickX - clickXShift - (clickY-clickYShift))/boxSize; double dboxY = (double)(clickX - clickXShift + (clickY-clickYShift))/boxSize; final int boxX, boxY; if (dboxX < 0){ boxX = (int)(dboxX - 0.5); } else{ boxX = (int)(dboxX + 0.5); } if (dboxY < 0){ boxY = (int)(dboxY - 0.5); }else{ boxY = (int)(dboxY + 0.5); } if ((boxX >= lowX && boxX <= highX) && (boxY > boxX && boxY < highY)){ if (dPrimeTable[boxX][boxY] != null){ final SwingWorker worker = new SwingWorker(){ public Object construct(){ final int leftMargin = 12; String[] displayStrings = new String[5]; if (markersLoaded){ displayStrings[0] = new String ("(" +((SNP)markers.elementAt(boxX)).getName() + ", " + ((SNP)markers.elementAt(boxY)).getName() + ")"); }else{ displayStrings[0] = new String("(" + (boxX+1) + ", " + (boxY+1) + ")"); } displayStrings[1] = new String ("D': " + dPrimeTable[boxX][boxY].getDPrime()); displayStrings[2] = new String ("LOD: " + dPrimeTable[boxX][boxY].getLOD()); displayStrings[3] = new String ("r^2: " + dPrimeTable[boxX][boxY].getRSquared()); displayStrings[4] = new String ("D' conf. bounds: " + dPrimeTable[boxX][boxY].getConfidenceLow() + "-" + dPrimeTable[boxX][boxY].getConfidenceHigh()); Graphics g = caller.getGraphics(); g.setFont(boxFont); FontMetrics metrics = g.getFontMetrics(); int strlen = 0; for (int x = 0; x < 5; x++){ if (strlen < metrics.stringWidth(displayStrings[x])){ strlen = metrics.stringWidth(displayStrings[x]); } } g.setColor(Color.WHITE); g.fillRect(clickX+1,clickY+1,strlen+leftMargin+4,5*metrics.getHeight()+9); g.setColor(Color.BLACK); g.drawRect(clickX,clickY,strlen+leftMargin+5,5*metrics.getHeight()+10); for (int x = 0; x < 5; x++){ g.drawString(displayStrings[x],clickX + leftMargin, clickY+5+((x+1)*metrics.getHeight())); } return ""; } }; worker.start(); } } } } |
g.fillRect(clickX+1,clickY+1,strlen+leftMargin+4,5*metrics.getHeight()+9); | g.fillRect(clickX+1-rightEdgeShift, clickY+1-botEdgeShift, strlen+leftMargin+4, 5*metrics.getHeight()+9); | public Object construct(){ final int leftMargin = 12; String[] displayStrings = new String[5]; if (markersLoaded){ displayStrings[0] = new String ("(" +((SNP)markers.elementAt(boxX)).getName() + ", " + ((SNP)markers.elementAt(boxY)).getName() + ")"); }else{ displayStrings[0] = new String("(" + (boxX+1) + ", " + (boxY+1) + ")"); } displayStrings[1] = new String ("D': " + dPrimeTable[boxX][boxY].getDPrime()); displayStrings[2] = new String ("LOD: " + dPrimeTable[boxX][boxY].getLOD()); displayStrings[3] = new String ("r^2: " + dPrimeTable[boxX][boxY].getRSquared()); displayStrings[4] = new String ("D' conf. bounds: " + dPrimeTable[boxX][boxY].getConfidenceLow() + "-" + dPrimeTable[boxX][boxY].getConfidenceHigh()); Graphics g = caller.getGraphics(); g.setFont(boxFont); FontMetrics metrics = g.getFontMetrics(); int strlen = 0; for (int x = 0; x < 5; x++){ if (strlen < metrics.stringWidth(displayStrings[x])){ strlen = metrics.stringWidth(displayStrings[x]); } } g.setColor(Color.WHITE); g.fillRect(clickX+1,clickY+1,strlen+leftMargin+4,5*metrics.getHeight()+9); g.setColor(Color.BLACK); g.drawRect(clickX,clickY,strlen+leftMargin+5,5*metrics.getHeight()+10); for (int x = 0; x < 5; x++){ g.drawString(displayStrings[x],clickX + leftMargin, clickY+5+((x+1)*metrics.getHeight())); } return ""; } |
g.drawRect(clickX,clickY,strlen+leftMargin+5,5*metrics.getHeight()+10); | g.drawRect(clickX-rightEdgeShift, clickY-botEdgeShift, strlen+leftMargin+5, 5*metrics.getHeight()+10); | public Object construct(){ final int leftMargin = 12; String[] displayStrings = new String[5]; if (markersLoaded){ displayStrings[0] = new String ("(" +((SNP)markers.elementAt(boxX)).getName() + ", " + ((SNP)markers.elementAt(boxY)).getName() + ")"); }else{ displayStrings[0] = new String("(" + (boxX+1) + ", " + (boxY+1) + ")"); } displayStrings[1] = new String ("D': " + dPrimeTable[boxX][boxY].getDPrime()); displayStrings[2] = new String ("LOD: " + dPrimeTable[boxX][boxY].getLOD()); displayStrings[3] = new String ("r^2: " + dPrimeTable[boxX][boxY].getRSquared()); displayStrings[4] = new String ("D' conf. bounds: " + dPrimeTable[boxX][boxY].getConfidenceLow() + "-" + dPrimeTable[boxX][boxY].getConfidenceHigh()); Graphics g = caller.getGraphics(); g.setFont(boxFont); FontMetrics metrics = g.getFontMetrics(); int strlen = 0; for (int x = 0; x < 5; x++){ if (strlen < metrics.stringWidth(displayStrings[x])){ strlen = metrics.stringWidth(displayStrings[x]); } } g.setColor(Color.WHITE); g.fillRect(clickX+1,clickY+1,strlen+leftMargin+4,5*metrics.getHeight()+9); g.setColor(Color.BLACK); g.drawRect(clickX,clickY,strlen+leftMargin+5,5*metrics.getHeight()+10); for (int x = 0; x < 5; x++){ g.drawString(displayStrings[x],clickX + leftMargin, clickY+5+((x+1)*metrics.getHeight())); } return ""; } |
g.drawString(displayStrings[x],clickX + leftMargin, clickY+5+((x+1)*metrics.getHeight())); | g.drawString(displayStrings[x],clickX + leftMargin - rightEdgeShift, clickY+5+((x+1)*metrics.getHeight())-botEdgeShift); | public Object construct(){ final int leftMargin = 12; String[] displayStrings = new String[5]; if (markersLoaded){ displayStrings[0] = new String ("(" +((SNP)markers.elementAt(boxX)).getName() + ", " + ((SNP)markers.elementAt(boxY)).getName() + ")"); }else{ displayStrings[0] = new String("(" + (boxX+1) + ", " + (boxY+1) + ")"); } displayStrings[1] = new String ("D': " + dPrimeTable[boxX][boxY].getDPrime()); displayStrings[2] = new String ("LOD: " + dPrimeTable[boxX][boxY].getLOD()); displayStrings[3] = new String ("r^2: " + dPrimeTable[boxX][boxY].getRSquared()); displayStrings[4] = new String ("D' conf. bounds: " + dPrimeTable[boxX][boxY].getConfidenceLow() + "-" + dPrimeTable[boxX][boxY].getConfidenceHigh()); Graphics g = caller.getGraphics(); g.setFont(boxFont); FontMetrics metrics = g.getFontMetrics(); int strlen = 0; for (int x = 0; x < 5; x++){ if (strlen < metrics.stringWidth(displayStrings[x])){ strlen = metrics.stringWidth(displayStrings[x]); } } g.setColor(Color.WHITE); g.fillRect(clickX+1,clickY+1,strlen+leftMargin+4,5*metrics.getHeight()+9); g.setColor(Color.BLACK); g.drawRect(clickX,clickY,strlen+leftMargin+5,5*metrics.getHeight()+10); for (int x = 0; x < 5; x++){ g.drawString(displayStrings[x],clickX + leftMargin, clickY+5+((x+1)*metrics.getHeight())); } return ""; } |
Rectangle clipRect = (Rectangle)g.getClip(); | clipRect = (Rectangle)g.getClip(); | public void paintComponent(Graphics g){ Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); Rectangle clipRect = (Rectangle)g.getClip(); //first paint grab the cliprect for the whole viewport if (viewRect.width == 0){viewRect=clipRect;} //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. //clickxshift and clickyshift are used later to translate from x,y coords to the //pair of markers comparison at those coords if (!(markersLoaded)){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { g2.translate((size.width - pref.width) / 2, 0); clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } FontMetrics boxFontMetrics = g.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; FontMetrics metrics; int ascent; g2.setColor(this.getBackground()); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.BLACK); if (markersLoaded) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations BasicStroke thickerStroke = new BasicStroke(1); BasicStroke thinnerStroke = new BasicStroke(0.25f); int wide = (dPrimeTable.length-1) * boxSize; //TODO: talk to kirby about locusview scaling gizmo int lineLeft = wide/20; int lineSpan = (wide/10)*9; long minpos = ((SNP)markers.elementAt(0)).getPosition(); long maxpos = ((SNP)markers.elementAt(markers.size()-1)).getPosition(); double spanpos = maxpos - minpos; g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); for (int i = 0; i < markers.size(); i++) { double pos = (((SNP)markers.elementAt(i)).getPosition() - minpos) / spanpos; int xx = (int) (left + lineLeft + lineSpan*pos); g2.setStroke(thickerStroke); g.drawLine(xx, 5, xx, 5 + TICK_HEIGHT); g2.setStroke(thinnerStroke); g.drawLine(xx, 5 + TICK_HEIGHT, left + i*boxSize, TICK_BOTTOM); } top += TICK_BOTTOM; //// draw the marker names if (printDetails){ g.setFont(markerNameFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); widestMarkerName = metrics.stringWidth(((SNP)markers.elementAt(0)).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(((SNP)markers.elementAt(x)).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } //System.out.println(widest); g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { g2.drawString(((SNP)markers.elementAt(x)).getName(),TEXT_NUMBER_GAP, x*boxSize + ascent/3); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_NUMBER_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } //// draw the marker numbers if (printDetails){ g.setFont(markerNumFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < dPrimeTable.length; x++) { String mark = String.valueOf(x + 1); g.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } //if (pref.getWidth() > viewRect.width){ //this means that the table is bigger than the display. //the following values are the bounds on the boxes we want to //display given that the current window is 'clipRect' lowX = (clipRect.x-clickXShift-(clipRect.y+clipRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((clipRect.x + clipRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((clipRect.x-clickXShift)+(clipRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((clipRect.x-clickXShift+clipRect.width) + (clipRect.y-clickYShift+clipRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } /** boxSize = (int)((clipRect.width-2*H_BORDER)/dPrimeTable.length-1); if (boxSize < 12){boxSize=12;} if (boxSize < 25){ printDetails = false; boxRadius = boxSize/2; }else{ boxRadius = boxSize/2 - 1; } } else{ lowX = 0; highX = dPrimeTable.length-1; lowY = 0; highY = dPrimeTable.length; } **/ // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g.setColor(boxColor); g.fillPolygon(diamond); if (boxColor == Color.white) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.lightGray); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } if(printDetails){ g.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g.setColor((val < 50) ? Color.gray : Color.black); if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } } |
/** if (pref.getWidth() > viewRect.width){ | public void paintComponent(Graphics g){ Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); Rectangle clipRect = (Rectangle)g.getClip(); //first paint grab the cliprect for the whole viewport if (viewRect.width == 0){viewRect=clipRect;} //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. //clickxshift and clickyshift are used later to translate from x,y coords to the //pair of markers comparison at those coords if (!(markersLoaded)){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { g2.translate((size.width - pref.width) / 2, 0); clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } FontMetrics boxFontMetrics = g.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; left = H_BORDER; top = V_BORDER; FontMetrics metrics; int ascent; g2.setColor(this.getBackground()); g2.fillRect(0,0,pref.width,pref.height); g2.setColor(Color.BLACK); if (markersLoaded) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations BasicStroke thickerStroke = new BasicStroke(1); BasicStroke thinnerStroke = new BasicStroke(0.25f); int wide = (dPrimeTable.length-1) * boxSize; //TODO: talk to kirby about locusview scaling gizmo int lineLeft = wide/20; int lineSpan = (wide/10)*9; long minpos = ((SNP)markers.elementAt(0)).getPosition(); long maxpos = ((SNP)markers.elementAt(markers.size()-1)).getPosition(); double spanpos = maxpos - minpos; g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fillRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); g2.setColor(Color.black); g2.drawRect(left + lineLeft, 5, lineSpan, TICK_HEIGHT); for (int i = 0; i < markers.size(); i++) { double pos = (((SNP)markers.elementAt(i)).getPosition() - minpos) / spanpos; int xx = (int) (left + lineLeft + lineSpan*pos); g2.setStroke(thickerStroke); g.drawLine(xx, 5, xx, 5 + TICK_HEIGHT); g2.setStroke(thinnerStroke); g.drawLine(xx, 5 + TICK_HEIGHT, left + i*boxSize, TICK_BOTTOM); } top += TICK_BOTTOM; //// draw the marker names if (printDetails){ g.setFont(markerNameFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); widestMarkerName = metrics.stringWidth(((SNP)markers.elementAt(0)).getName()); for (int x = 1; x < dPrimeTable.length; x++) { int thiswide = metrics.stringWidth(((SNP)markers.elementAt(x)).getName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } //System.out.println(widest); g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < dPrimeTable.length; x++) { g2.drawString(((SNP)markers.elementAt(x)).getName(),TEXT_NUMBER_GAP, x*boxSize + ascent/3); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_NUMBER_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } //// draw the marker numbers if (printDetails){ g.setFont(markerNumFont); metrics = g.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < dPrimeTable.length; x++) { String mark = String.valueOf(x + 1); g.drawString(mark, left + x*boxSize - metrics.stringWidth(mark)/2, top + ascent); } top += boxRadius/2; // give a little space between numbers and boxes } //if (pref.getWidth() > viewRect.width){ //this means that the table is bigger than the display. //the following values are the bounds on the boxes we want to //display given that the current window is 'clipRect' lowX = (clipRect.x-clickXShift-(clipRect.y+clipRect.height-clickYShift))/boxSize; if (lowX < 0) { lowX = 0; } highX = ((clipRect.x + clipRect.width)/boxSize)+1; if (highX > dPrimeTable.length-1){ highX = dPrimeTable.length-1; } lowY = ((clipRect.x-clickXShift)+(clipRect.y-clickYShift))/boxSize; if (lowY < lowX+1){ lowY = lowX+1; } highY = (((clipRect.x-clickXShift+clipRect.width) + (clipRect.y-clickYShift+clipRect.height))/boxSize)+1; if (highY > dPrimeTable.length){ highY = dPrimeTable.length; } /** boxSize = (int)((clipRect.width-2*H_BORDER)/dPrimeTable.length-1); if (boxSize < 12){boxSize=12;} if (boxSize < 25){ printDetails = false; boxRadius = boxSize/2; }else{ boxRadius = boxSize/2 - 1; } } else{ lowX = 0; highX = dPrimeTable.length-1; lowY = 0; highY = dPrimeTable.length; } **/ // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable[x][y] == null){ continue; } double d = dPrimeTable[x][y].getDPrime(); //double l = dPrimeTable[x][y].getLOD(); Color boxColor = dPrimeTable[x][y].getColor(); // draw markers above int xx = left + (x + y) * boxSize / 2; int yy = top + (y - x) * boxSize / 2; diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g.setColor(boxColor); g.fillPolygon(diamond); if (boxColor == Color.white) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.lightGray); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } if(printDetails){ g.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val = (int) (d * 100); g.setColor((val < 50) ? Color.gray : Color.black); if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } } |
|
httpResponse.setContentLength(writer.length()); | httpResponse.setContentLength(writer.size()); | public void doTag(XMLOutput xmlOutput) throws Exception { // get the response from the context HttpResponse httpResponse = (HttpResponse) getContext().getVariable("response"); if (null == httpResponse) { throw new JellyException("HttpResponse variable not available in Jelly context"); } ByteArrayISO8859Writer writer = new ByteArrayISO8859Writer(1500); writer.write(getBodyText()); writer.flush(); httpResponse.setContentLength(writer.length()); writer.writeTo(httpResponse.getOutputStream()); } |
MBeanServer server = MBeanServerFactory.createMBeanServer(DOMAIN_CONNECTOR); String objName = ":appType=connector,appName=" + config.getName() | MBeanServer server = MBeanServerFactory.newMBeanServer(DOMAIN_CONNECTOR); String objName = ":appId=" + appId + ",appType=connector,appName=" + config.getName() | private static ConnectorRegistry create(ApplicationConfig config) throws Exception { Map paramValues = config.getParamValues(); String appId = config.getApplicationId(); String connectorId = (String) paramValues.get("connectorId"); File file1 = new File(CoreUtils.getConnectorDir() + File.separatorChar + connectorId); URL[] urls = new URL[]{file1.toURL()}; ClassLoader cl = ClassLoaderRepository.getClassLoader(urls, true); //URLClassLoader cl = new URLClassLoader(urls, // ConnectorMBeanRegistry.class.getClassLoader()); Registry.MODELER_MANIFEST = MBEANS_DESCRIPTOR; URL res = cl.getResource(MBEANS_DESCRIPTOR); logger.log(Level.INFO, "Application ID : " + appId); logger.log(Level.INFO, "Connector Archive: " + file1.getAbsoluteFile()); logger.log(Level.INFO, "MBean Descriptor : " + res.toString()); //Thread.currentThread().setContextClassLoader(cl); //Registry.setUseContextClassLoader(true); ConnectorRegistry registry = new ConnectorRegistry(); registry.loadMetadata(cl); String[] mbeans = registry.findManagedBeans(); MBeanServer server = MBeanServerFactory.createMBeanServer(DOMAIN_CONNECTOR); String objName = ":appType=connector,appName=" + config.getName() + ",connectorType=" + connectorId; for (int i = 0; i < mbeans.length; i++) { ManagedBean managed = registry.findManagedBean(mbeans[i]); String clsName = managed.getType(); String domain = managed.getDomain(); if (domain == null) { domain = DOMAIN_CONNECTOR; } Class cls = Class.forName(clsName, true, cl); Object obj = cls.newInstance(); // Call the initialize method if the MBean extends ConnectorSupport class if (cls.getSuperclass().getName().equals(CLASS_CONNECTOR_SUPPORT)) { Method method = cls.getMethod("initialize", new Class[] {Map.class}); Map props = config.getParamValues(); method.invoke(obj, new Object[] {props}); } ModelMBean mm = managed.createMBean(obj); String beanObjName = domain + objName + ",name=" + mbeans[i]; server.registerMBean(mm, new ObjectName(beanObjName)); } registry.setMBeanServer(server); entries.put(appId, registry); return registry; } |
markerResults[i] = ((Boolean)table.getValueAt(i,9)).booleanValue(); | markerResults[i] = ((Boolean)table.getValueAt(i,CheckDataPanel.STATUS_COL)).booleanValue(); | 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 (tabNum == VIEW_D_NUM){ keyMenu.setEnabled(true); }else{ keyMenu.setEnabled(false); } viewMenuItems[tabs.getSelectedIndex()].setSelected(true); if (checkPanel != null && checkPanel.changed){ 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,9)).booleanValue(); } int count = 0; for (int i = 0; i < Chromosome.getSize(); i++){ if (markerResults[i]){ count++; } } Chromosome.realIndex = new int[count]; int k = 0; for (int i =0; i < Chromosome.getSize(); i++){ if (markerResults[i]){ Chromosome.realIndex[k] = i; k++; } } theData.filteredDPrimeTable = theData.getFilteredTable(); //after editing the filtered marker list, needs to be prodded into //resizing correctly Dimension size = dPrimeDisplay.getSize(); Dimension pref = dPrimeDisplay.getPreferredSize(); Rectangle visRect = dPrimeDisplay.getVisibleRect(); if (size.width != pref.width && pref.width > visRect.width){ ((JViewport)dPrimeDisplay.getParent()).setViewSize(pref); } hapDisplay.theData = theData; changeBlocks(currentBlockDef); 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(); }catch(HaploViewException hv){ JOptionPane.showMessageDialog(window, hv.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } hapScroller.setViewportView(hapDisplay); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); theData.blocksChanged = false; } } |
window.readPhasedGenotypes(inputArray); | window.readGenotypes(inputArray, HAPS); | public static void main(String[] args) { boolean nogui = false; //HaploView window; for(int i = 0;i<args.length;i++) { if(args[i].equals("-n") || args[i].equals("-h") || args[i].equals("-help")) { nogui = true; } } if(nogui) { HaploText textOnly = new HaploText(args); } else { 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 HaploText argParser = new HaploText(args); String[] inputArray = new String[3]; if (argParser.getHapsFileName() != ""){ inputArray[0] = argParser.getHapsFileName(); inputArray[1] = argParser.getInfoFileName(); inputArray[2] = String.valueOf(argParser.getMaxDistance()); window.readPhasedGenotypes(inputArray); }else if (argParser.getPedFileName() != ""){ inputArray[0] = argParser.getPedFileName(); inputArray[1] = argParser.getInfoFileName(); inputArray[2] = String.valueOf(argParser.getMaxDistance()); window.readPedGenotypes(inputArray, 3); }else if (argParser.getHapmapFileName() != ""){ inputArray[0] = argParser.getHapmapFileName(); inputArray[1] = ""; inputArray[2] = String.valueOf(argParser.getMaxDistance()); window.readPedGenotypes(inputArray, 4); }else{ ReadDataDialog readDialog = new ReadDataDialog("Welcome to HaploView", window); readDialog.pack(); readDialog.setVisible(true); } } } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.