rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
String testImgDir = "c:\\java\\photovault\\testfiles";
public void testGetThumbnail() { String testImgDir = "c:\\java\\photovault\\testfiles"; String fname = "test1.jpg"; File f = new File( testImgDir, fname ); PhotoInfo photo = null; try { photo = PhotoInfo.addToDB( f ); } catch ( PhotoNotFoundException e ) { fail( "Could not find photo: " + e.getMessage() ); } assertNotNull( photo ); int instanceCount = photo.getNumInstances(); Thumbnail thumb = photo.getThumbnail(); assertNotNull( thumb ); assertFalse( "Thumbnail exists, should not return default thumbnail", thumb == Thumbnail.getDefaultThumbnail() ); assertEquals( "Thumbnail exists, getThumbnail should not create a new instance", instanceCount+1, photo.getNumInstances() ); assertEquals( "InstanceNum should be 1 greater after adding thumbnail", instanceCount+1, photo.getNumInstances() ); // Try to find the new thumbnail boolean foundThumbnail = false; ImageInstance thumbnail = null; for ( int n = 0; n < instanceCount+1; n++ ) { ImageInstance instance = photo.getInstance( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_THUMBNAIL ) { foundThumbnail = true; thumbnail = instance; break; } } assertTrue( "Could not find the created thumbnail", foundThumbnail ); assertEquals( "Thumbnail width should be 100", 100, thumbnail.getWidth() ); File thumbnailFile = thumbnail.getImageFile(); assertTrue( "Image file does not exist", thumbnailFile.exists() ); photo.delete(); assertFalse( "Image file does exist after delete", thumbnailFile.exists() ); }
File testFile = new File( "c:\\java\\photovault\\testfiles\\test1.jpg" );
File testFile = new File( testImgDir, "test1.jpg" );
public void testInstanceAddition() { File testFile = new File( "c:\\java\\photovault\\testfiles\\test1.jpg" ); File instanceFile = Volume.getDefaultVolume().getFilingFname( testFile ); try { FileUtils.copyFile( testFile, instanceFile ); } catch ( IOException e ) { fail( e.getMessage() ); } PhotoInfo photo = PhotoInfo.create(); assertNotNull( photo ); int numInstances = photo.getNumInstances(); photo.addInstance( Volume.getDefaultVolume(), instanceFile, ImageInstance.INSTANCE_TYPE_ORIGINAL ); // Check that number of instances is consistent with addition assertEquals( numInstances+1, photo.getNumInstances() ); Vector instances = photo.getInstances(); assertEquals( instances.size(), numInstances+1 ); // Try to find the instance boolean found = false; for ( int i = 0 ; i < photo.getNumInstances(); i++ ) { ImageInstance ifile = photo.getInstance( i ); if ( ifile.getImageFile().equals( instanceFile ) ) { found = true; } } if ( found == false ) { fail( "Created instance not found" ); } // Clean the DB photo.delete(); }
File testFile = new File( "c:\\java\\photovault\\testfiles\\test1.jpg" );
File testFile = new File( testImgDir, "test1.jpg" );
public void testThumbWithNoInstances() { PhotoInfo photo = PhotoInfo.create(); Thumbnail thumb = photo.getThumbnail(); assertTrue( "getThumbnail should return default thumbnail", thumb == Thumbnail.getDefaultThumbnail() ) ; assertEquals( "No new instances should have been created", 0, photo.getNumInstances() ); // Create a new instance and check that a valid thumbnail is returned after this File testFile = new File( "c:\\java\\photovault\\testfiles\\test1.jpg" ); File instanceFile = Volume.getDefaultVolume().getFilingFname( testFile ); try { FileUtils.copyFile( testFile, instanceFile ); } catch ( IOException e ) { fail( e.getMessage() ); } photo.addInstance( Volume.getDefaultVolume(), instanceFile, ImageInstance.INSTANCE_TYPE_ORIGINAL ); Thumbnail thumb2 = photo.getThumbnail(); assertFalse( "After instance addition, getThumbnail should not return default thumbnail", thumb == thumb2 ); assertEquals( "There should be 2 instances: original & thumbnail", 2, photo.getNumInstances() ); photo.delete(); }
String testImgDir = "c:\\java\\photovault\\testfiles";
public void testThumbnailCreate() { String testImgDir = "c:\\java\\photovault\\testfiles"; String fname = "test1.jpg"; File f = new File( testImgDir, fname ); PhotoInfo photo = null; try { photo = PhotoInfo.addToDB( f ); } catch ( PhotoNotFoundException e ) { fail( "Could not find photo: " + e.getMessage() ); } assertNotNull( photo ); int instanceCount = photo.getNumInstances(); photo.createThumbnail(); assertEquals( "InstanceNum should be 1 greater after adding thumbnail", instanceCount+1, photo.getNumInstances() ); // Try to find the new thumbnail boolean foundThumbnail = false; ImageInstance thumbnail = null; for ( int n = 0; n < instanceCount+1; n++ ) { ImageInstance instance = photo.getInstance( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_THUMBNAIL ) { foundThumbnail = true; thumbnail = instance; break; } } assertTrue( "Could not find the created thumbnail", foundThumbnail ); assertEquals( "Thumbnail width should be 100", 100, thumbnail.getWidth() ); File thumbnailFile = thumbnail.getImageFile(); assertTrue( "Image file does not exist", thumbnailFile.exists() ); // Test the getThumbnail method Thumbnail thumb = photo.getThumbnail(); assertNotNull( thumb ); assertFalse( "Thumbnail exists, should not return default thumbnail", thumb == Thumbnail.getDefaultThumbnail() ); assertEquals( "Thumbnail exists, getThumbnail should not create a new instance", instanceCount+1, photo.getNumInstances() ); // Assert that the thumbnail is saved correctly to the database PhotoInfo photo2 = null; try { photo2 = PhotoInfo.retrievePhotoInfo( photo.getUid() ); } catch( PhotoNotFoundException e ) { fail( "Photo not storein into DB" ); } // Try to find the new thumbnail foundThumbnail = false; ImageInstance thumbnail2 = null; for ( int n = 0; n < instanceCount+1; n++ ) { ImageInstance instance = photo2.getInstance( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_THUMBNAIL ) { foundThumbnail = true; thumbnail2 = instance; break; } } assertTrue( "Could not find the created thumbnail", foundThumbnail ); assertEquals( "Thumbnail width should be 100", 100, thumbnail2.getWidth() ); assertTrue( "Thumbnail filename not saved correctly", thumbnailFile.equals( thumbnail2.getImageFile() )); photo.delete(); assertFalse( "Image file does exist after delete", thumbnailFile.exists() ); }
String testImgDir = "c:\\java\\photovault\\testfiles";
public void testThumbnailCreateCorruptInstances() throws Exception { String testImgDir = "c:\\java\\photovault\\testfiles"; String fname = "test1.jpg"; File f = new File( testImgDir, fname ); PhotoInfo photo = null; try { photo = PhotoInfo.addToDB( f ); } catch ( PhotoNotFoundException e ) { fail( "Could not find photo: " + e.getMessage() ); } // Corrupt the database by deleting the actual image files // that instances refer to int numInstances = photo.getNumInstances(); for ( int n = 0; n < numInstances ; n++ ) { ImageInstance instance = photo.getInstance( n ); File instFile = instance.getImageFile(); instFile.delete(); } // Create the thumbnail photo.createThumbnail(); try { Thumbnail thumb = photo.getThumbnail(); assertNotNull( thumb ); assertTrue( "Database is corrupt, should return default thumbnail", thumb == Thumbnail.getDefaultThumbnail() ); assertEquals( "Database is corrupt, getThumbnail should not create a new instance", numInstances, photo.getNumInstances() ); } finally { // Clean up in any case photo.delete(); } }
String testImgDir = "c:\\java\\photovault\\testfiles";
public void testThumbnailRotation() { String testImgDir = "c:\\java\\photovault\\testfiles"; String fname = "test1.jpg"; File f = new File( testImgDir, fname ); PhotoInfo photo = null; try { photo = PhotoInfo.addToDB( f ); } catch ( PhotoNotFoundException e ) { fail( "Could not find photo: " + e.getMessage() ); } photo.setPrefRotation( -45 ); Thumbnail thumb = photo.getThumbnail(); // Compare thumbnail to the one saved File testFile = new File ( testRefImageDir, "thumbnailRotation1.png" ); assertTrue( "Thumbnail with 45 deg rotation does not match", photovault.test.ImgTestUtils.compareImgToFile( thumb.getImage(), testFile ) ); photo.setPrefRotation( -90 ); thumb = photo.getThumbnail(); testFile = new File ( testRefImageDir, "thumbnailRotation2.png" ); assertTrue( "Thumbnail with 90 deg rotation does not match", photovault.test.ImgTestUtils.compareImgToFile( thumb.getImage(), testFile ) ); photo.delete(); }
String testImgDir = "c:\\_directoryThatDoesNotExist";
public void testfailedCreation() { String testImgDir = "c:\\_directoryThatDoesNotExist"; String fname = "test1.jpg"; File f = new File( testImgDir, fname ); PhotoInfo photo = null; try { photo = PhotoInfo.addToDB( f ); // Execution should never proceed this far since addToDB // should produce exception fail( "Image file should have been nonexistent" ); } catch ( PhotoNotFoundException e ) { // This is what we except } }
File f = new File( testImgDir, fname );
File f = new File( nonExistingDir, fname );
public void testfailedCreation() { String testImgDir = "c:\\_directoryThatDoesNotExist"; String fname = "test1.jpg"; File f = new File( testImgDir, fname ); PhotoInfo photo = null; try { photo = PhotoInfo.addToDB( f ); // Execution should never proceed this far since addToDB // should produce exception fail( "Image file should have been nonexistent" ); } catch ( PhotoNotFoundException e ) { // This is what we except } }
protected void createThumbnail() { Volume vol = Volume.getDefaultVolume(); createThumbnail( vol );
protected void createThumbnail( Volume volume ) { ODMGXAWrapper txw = new ODMGXAWrapper(); txw.lock( this, Transaction.WRITE ); ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_ORIGINAL ) { original = instance; txw.lock( original, Transaction.READ ); break; } } if ( original == null || original.getImageFile() == null || !original.getImageFile().exists() ) { log.warn( "Error - no original image was found!!!" ); txw.commit(); return; } BufferedImage origImage = null; try { origImage = ImageIO.read( original.getImageFile() ); } catch ( IOException e ) { log.warn( "Error reading image: " + e.getMessage() ); txw.abort(); return; } File thumbnailFile = volume.getInstanceName( this, "jpg" ); int origWidth = origImage.getWidth(); int origHeight = origImage.getHeight(); int maxThumbWidth = 100; int maxThumbHeight = 100; AffineTransform xform = photovault.image.ImageXform.getFittingXform( maxThumbWidth, maxThumbHeight, prefRotation -original.getRotated(), origWidth, origHeight ); AffineTransformOp atOp = new AffineTransformOp( xform, AffineTransformOp.TYPE_BILINEAR ); BufferedImage thumbImage = atOp.filter( origImage, null ); try { ImageIO.write( thumbImage, "jpg", thumbnailFile ); } catch ( IOException e ) { log.warn( "Error writing thumbnail: " + e.getMessage() ); txw.abort(); return; } ImageInstance thumbInstance = addInstance( volume, thumbnailFile, ImageInstance.INSTANCE_TYPE_THUMBNAIL ); thumbInstance.setRotated( prefRotation -original.getRotated() ); thumbnail = Thumbnail.createThumbnail( this, thumbnailFile ); txw.commit();
protected void createThumbnail() { Volume vol = Volume.getDefaultVolume(); createThumbnail( vol ); }
File f = new File( "c:\\temp", "error_" + file.getName() );
File f = new File( tmpDir, "error_" + file.getName() );
public static boolean compareImgToFile( BufferedImage img, File file ) { if ( file.exists() ) { System.err.println( "File " + file.getName() + " exists" ); BufferedImage fImg = null; try { fImg = ImageIO.read( file ); System.err.println( "Read image" ); } catch ( IOException e ) { System.err.println( "Error reading image: " + e.getMessage() ); return false; } boolean eq = equals( img, fImg ); if ( !eq ) { File f = new File( "c:\\temp", "error_" + file.getName() ); Iterator writers = ImageIO.getImageWritersByFormatName("png"); ImageWriter writer = (ImageWriter)writers.next(); ImageOutputStream ios = null; try { ios = ImageIO.createImageOutputStream(f); writer.setOutput(ios); writer.write( img ); } catch( IOException e ) { System.err.println( "Cannot write to " + f.getName()); return false; } finally { if ( ios != null ) { try { ios.close(); } catch (IOException e ) {} } } } return eq; } // The image file does not yet exist, so save it // First, make sure that the directory is created System.err.println( "Image " + file.getName() + " does not exist, creating a new." ); Iterator writers = ImageIO.getImageWritersByFormatName("png"); ImageWriter writer = (ImageWriter)writers.next(); file.getParentFile().mkdirs(); // Create the image file with a name like candidate_name.png file = new File( file.getParentFile(), "candidate_" + file.getName() ); ImageOutputStream ios = null; try { ios = ImageIO.createImageOutputStream(file); writer.setOutput(ios); writer.write(img); } catch( IOException e ) { System.err.println( "Could not write file " + file.getName()); return false; } finally { if ( ios != null ) { try { ios.close(); } catch (IOException e ) {} } } return false; }
return (byte)CHARSET[getRandomInt()];
return (byte)(Math.random() * 255);
public static byte getRandomByte() { return (byte)CHARSET[getRandomInt()]; }
UserActivityLogger logger = UserActivityLogger.getInstance(); logger.log(context.getUser().getUsername(),"Add User", user.getName()+"/"+user.getPassword());
public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { User user = buildUser(actionForm); UserManager.getInstance().addUser(user); return mapping.findForward(Forwards.SUCCESS); }
org.apache.log4j.Logger folderLog = org.apache.log4j.Logger.getLogger( PhotoFolder.class.getName() ); folderLog.setLevel( org.apache.log4j.Level.DEBUG );
public static void main( String[] args ) { org.apache.log4j.BasicConfigurator.configure(); log.setLevel( org.apache.log4j.Level.DEBUG ); JFrame frame = new JFrame( "PhotoFoldertree test" ); PhotoFolderTree view = new PhotoFolderTree(); frame.getContentPane().add( view, BorderLayout.CENTER ); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } } ); frame.pack(); frame.setVisible( true ); }
log.warn( "Not implemented: renameSelectedFolder()" );
if ( selected != null ) { String origName = selected.getName(); String newName = (String) JOptionPane.showInputDialog( this, "Enter new name", "Rename folder", JOptionPane.PLAIN_MESSAGE, null, null, origName ); if ( newName != null ) { PhotoFolder f = selected; f.setName( newName ); f.setDescription( "Changed name to " + newName ); } }
void renameSelectedFolder() { log.warn( "Not implemented: renameSelectedFolder()" ); }
ODMGXAWrapper txw = new ODMGXAWrapper(); Implementation odmg = ODMG.getODMGImplementation();
PhotoFolder rootFolder = PhotoFolder.rootFolder; if ( rootFolder == null ) { ODMGXAWrapper txw = new ODMGXAWrapper(); Implementation odmg = ODMG.getODMGImplementation();
public static PhotoFolder getRoot() { ODMGXAWrapper txw = new ODMGXAWrapper(); Implementation odmg = ODMG.getODMGImplementation(); DList folders = null; boolean mustCommit = false; try { OQLQuery query = odmg.newOQLQuery(); query.create( "select folders from " + PhotoFolder.class.getName() + " where folderId = 1" ); folders = (DList) query.execute(); } catch ( Exception e ) { txw.abort(); return null; } PhotoFolder rootFolder = (PhotoFolder) folders.get( 0 ); if ( PhotoFolder.rootFolder == null ) { PhotoFolder.rootFolder = rootFolder; } if ( rootFolder == PhotoFolder.rootFolder ) { log.warn( "root folders match" ); } else { log.error( "root folders do not match" ); } // If a new transaction was created, commit it txw.commit(); return rootFolder; }
DList folders = null; boolean mustCommit = false; try { OQLQuery query = odmg.newOQLQuery(); query.create( "select folders from " + PhotoFolder.class.getName() + " where folderId = 1" ); folders = (DList) query.execute(); } catch ( Exception e ) { txw.abort(); return null; } PhotoFolder rootFolder = (PhotoFolder) folders.get( 0 ); if ( PhotoFolder.rootFolder == null ) { PhotoFolder.rootFolder = rootFolder; } if ( rootFolder == PhotoFolder.rootFolder ) { log.warn( "root folders match" ); } else { log.error( "root folders do not match" ); } txw.commit();
DList folders = null; boolean mustCommit = false; try { OQLQuery query = odmg.newOQLQuery(); query.create( "select folders from " + PhotoFolder.class.getName() + " where folderId = 1" ); folders = (DList) query.execute(); } catch ( Exception e ) { txw.abort(); return null; } rootFolder = (PhotoFolder) folders.get( 0 ); PhotoFolder.rootFolder = rootFolder; txw.commit(); }
public static PhotoFolder getRoot() { ODMGXAWrapper txw = new ODMGXAWrapper(); Implementation odmg = ODMG.getODMGImplementation(); DList folders = null; boolean mustCommit = false; try { OQLQuery query = odmg.newOQLQuery(); query.create( "select folders from " + PhotoFolder.class.getName() + " where folderId = 1" ); folders = (DList) query.execute(); } catch ( Exception e ) { txw.abort(); return null; } PhotoFolder rootFolder = (PhotoFolder) folders.get( 0 ); if ( PhotoFolder.rootFolder == null ) { PhotoFolder.rootFolder = rootFolder; } if ( rootFolder == PhotoFolder.rootFolder ) { log.warn( "root folders match" ); } else { log.error( "root folders do not match" ); } // If a new transaction was created, commit it txw.commit(); return rootFolder; }
public PrintPreviewPanel(PrintPanel settings) { this.settings = settings;
public PrintPreviewPanel() {
public PrintPreviewPanel(PrintPanel settings) { this.settings = settings; setDoubleBuffered(false); settings.addPropertyChangeListener(this); }
settings.addPropertyChangeListener(this);
PrintPanel.this.addPropertyChangeListener(this); PreviewZoomAdjuster adjuster = new PreviewZoomAdjuster(); addMouseMotionListener(adjuster); addMouseListener(adjuster);
public PrintPreviewPanel(PrintPanel settings) { this.settings = settings; setDoubleBuffered(false); settings.addPropertyChangeListener(this); }
settings.validateLayout(); double iW = settings.pageFormat.getImageableWidth(); double iH = settings.pageFormat.getImageableHeight(); double printoutWidth = settings.pagesAcross * iW; double printoutHeight = settings.pagesDown * iH;
validateLayout(); double iW = pageFormat.getImageableWidth(); double iH = pageFormat.getImageableHeight(); double printoutWidth = pagesAcross * iW; double printoutHeight = pagesDown * iH;
public Dimension getPreferredSize() { settings.validateLayout(); double iW = settings.pageFormat.getImageableWidth(); double iH = settings.pageFormat.getImageableHeight(); double printoutWidth = settings.pagesAcross * iW; double printoutHeight = settings.pagesDown * iH; double preferredScale = 500.0/printoutWidth; return new Dimension((int) (printoutWidth * preferredScale), (int) (printoutHeight * preferredScale)); }
settings.validateLayout(); double iW = settings.pageFormat.getImageableWidth(); double iH = settings.pageFormat.getImageableHeight(); double printoutWidth = settings.pagesAcross * iW; double printoutHeight = settings.pagesDown * iH;
validateLayout();
public void paintComponent(Graphics g) { settings.validateLayout(); double iW = settings.pageFormat.getImageableWidth(); double iH = settings.pageFormat.getImageableHeight(); double printoutWidth = settings.pagesAcross * iW; double printoutHeight = settings.pagesDown * iH; // create a bitmapped image of the scaled playpen Graphics2D g2 = (Graphics2D) g; g2.setColor(settings.getBackground()); g2.fill(new Rectangle(0, 0, getWidth(), getHeight())); double previewZoomX = (double) getWidth() / printoutWidth; double previewZoomY = (double) getHeight() / printoutHeight; double zoom = Math.min(previewZoomX, previewZoomY); int scaledWidth = (int) (getWidth()/zoom); int scaledHeight = (int) (getHeight()/zoom); logger.debug("After scaling, preview will seem to be size ("+scaledWidth+","+scaledHeight+")"); // print the page background at the panel's zoom setting, centered in available space g2.scale(zoom, zoom); g2.translate((scaledWidth - printoutWidth) / 2, (scaledHeight - printoutHeight) / 2); AffineTransform backup = g2.getTransform(); g2.setColor(settings.pp.getBackground()); g2.fill(new Rectangle(0, 0, (int) printoutWidth, (int) printoutHeight)); // now print the playpen at the user's zoom setting, compounded with ours. g2.scale(settings.zoom, settings.zoom); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); logger.debug("Printout size = ("+printoutWidth+","+printoutHeight +"); playpen size = "+settings.pp.getPreferredSize()); //settings.pp.paint(g2); This is slow in win32 and x11 SwingUtilities.paintComponent(g2, settings.pp, new Container(), 0, 0, (int) (printoutWidth/settings.zoom), (int) (printoutHeight/settings.zoom)); ArchitectFrame.getMainInstance().splitPane.setRightComponent(settings.pp); // and draw the lines where the page boundaries fall, at our own zoom scale g2.setTransform(backup); g2.setColor(getForeground()); for (int i = 0; i <= settings.pagesAcross; i++) { g2.drawLine((int) (i * iW), 0, (int) (i * iW), (int) printoutHeight); logger.debug("Drew page separator at x="+(i*iW)); } for (int i = 0; i <= settings.pagesDown; i++) { g2.drawLine(0, (int) (i * iH), (int) printoutWidth, (int) (i * iH)); logger.debug("Drew page separator at y="+(i*iH)); } }
g2.setColor(settings.getBackground());
g2.setColor(pp.getBackground());
public void paintComponent(Graphics g) { settings.validateLayout(); double iW = settings.pageFormat.getImageableWidth(); double iH = settings.pageFormat.getImageableHeight(); double printoutWidth = settings.pagesAcross * iW; double printoutHeight = settings.pagesDown * iH; // create a bitmapped image of the scaled playpen Graphics2D g2 = (Graphics2D) g; g2.setColor(settings.getBackground()); g2.fill(new Rectangle(0, 0, getWidth(), getHeight())); double previewZoomX = (double) getWidth() / printoutWidth; double previewZoomY = (double) getHeight() / printoutHeight; double zoom = Math.min(previewZoomX, previewZoomY); int scaledWidth = (int) (getWidth()/zoom); int scaledHeight = (int) (getHeight()/zoom); logger.debug("After scaling, preview will seem to be size ("+scaledWidth+","+scaledHeight+")"); // print the page background at the panel's zoom setting, centered in available space g2.scale(zoom, zoom); g2.translate((scaledWidth - printoutWidth) / 2, (scaledHeight - printoutHeight) / 2); AffineTransform backup = g2.getTransform(); g2.setColor(settings.pp.getBackground()); g2.fill(new Rectangle(0, 0, (int) printoutWidth, (int) printoutHeight)); // now print the playpen at the user's zoom setting, compounded with ours. g2.scale(settings.zoom, settings.zoom); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); logger.debug("Printout size = ("+printoutWidth+","+printoutHeight +"); playpen size = "+settings.pp.getPreferredSize()); //settings.pp.paint(g2); This is slow in win32 and x11 SwingUtilities.paintComponent(g2, settings.pp, new Container(), 0, 0, (int) (printoutWidth/settings.zoom), (int) (printoutHeight/settings.zoom)); ArchitectFrame.getMainInstance().splitPane.setRightComponent(settings.pp); // and draw the lines where the page boundaries fall, at our own zoom scale g2.setTransform(backup); g2.setColor(getForeground()); for (int i = 0; i <= settings.pagesAcross; i++) { g2.drawLine((int) (i * iW), 0, (int) (i * iW), (int) printoutHeight); logger.debug("Drew page separator at x="+(i*iW)); } for (int i = 0; i <= settings.pagesDown; i++) { g2.drawLine(0, (int) (i * iH), (int) printoutWidth, (int) (i * iH)); logger.debug("Drew page separator at y="+(i*iH)); } }
double previewZoomX = (double) getWidth() / printoutWidth; double previewZoomY = (double) getHeight() / printoutHeight; double zoom = Math.min(previewZoomX, previewZoomY);
double zoom = calculateZoom();
public void paintComponent(Graphics g) { settings.validateLayout(); double iW = settings.pageFormat.getImageableWidth(); double iH = settings.pageFormat.getImageableHeight(); double printoutWidth = settings.pagesAcross * iW; double printoutHeight = settings.pagesDown * iH; // create a bitmapped image of the scaled playpen Graphics2D g2 = (Graphics2D) g; g2.setColor(settings.getBackground()); g2.fill(new Rectangle(0, 0, getWidth(), getHeight())); double previewZoomX = (double) getWidth() / printoutWidth; double previewZoomY = (double) getHeight() / printoutHeight; double zoom = Math.min(previewZoomX, previewZoomY); int scaledWidth = (int) (getWidth()/zoom); int scaledHeight = (int) (getHeight()/zoom); logger.debug("After scaling, preview will seem to be size ("+scaledWidth+","+scaledHeight+")"); // print the page background at the panel's zoom setting, centered in available space g2.scale(zoom, zoom); g2.translate((scaledWidth - printoutWidth) / 2, (scaledHeight - printoutHeight) / 2); AffineTransform backup = g2.getTransform(); g2.setColor(settings.pp.getBackground()); g2.fill(new Rectangle(0, 0, (int) printoutWidth, (int) printoutHeight)); // now print the playpen at the user's zoom setting, compounded with ours. g2.scale(settings.zoom, settings.zoom); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); logger.debug("Printout size = ("+printoutWidth+","+printoutHeight +"); playpen size = "+settings.pp.getPreferredSize()); //settings.pp.paint(g2); This is slow in win32 and x11 SwingUtilities.paintComponent(g2, settings.pp, new Container(), 0, 0, (int) (printoutWidth/settings.zoom), (int) (printoutHeight/settings.zoom)); ArchitectFrame.getMainInstance().splitPane.setRightComponent(settings.pp); // and draw the lines where the page boundaries fall, at our own zoom scale g2.setTransform(backup); g2.setColor(getForeground()); for (int i = 0; i <= settings.pagesAcross; i++) { g2.drawLine((int) (i * iW), 0, (int) (i * iW), (int) printoutHeight); logger.debug("Drew page separator at x="+(i*iW)); } for (int i = 0; i <= settings.pagesDown; i++) { g2.drawLine(0, (int) (i * iH), (int) printoutWidth, (int) (i * iH)); logger.debug("Drew page separator at y="+(i*iH)); } }
logger.debug("After scaling, preview will seem to be size ("+scaledWidth+","+scaledHeight+")");
public void paintComponent(Graphics g) { settings.validateLayout(); double iW = settings.pageFormat.getImageableWidth(); double iH = settings.pageFormat.getImageableHeight(); double printoutWidth = settings.pagesAcross * iW; double printoutHeight = settings.pagesDown * iH; // create a bitmapped image of the scaled playpen Graphics2D g2 = (Graphics2D) g; g2.setColor(settings.getBackground()); g2.fill(new Rectangle(0, 0, getWidth(), getHeight())); double previewZoomX = (double) getWidth() / printoutWidth; double previewZoomY = (double) getHeight() / printoutHeight; double zoom = Math.min(previewZoomX, previewZoomY); int scaledWidth = (int) (getWidth()/zoom); int scaledHeight = (int) (getHeight()/zoom); logger.debug("After scaling, preview will seem to be size ("+scaledWidth+","+scaledHeight+")"); // print the page background at the panel's zoom setting, centered in available space g2.scale(zoom, zoom); g2.translate((scaledWidth - printoutWidth) / 2, (scaledHeight - printoutHeight) / 2); AffineTransform backup = g2.getTransform(); g2.setColor(settings.pp.getBackground()); g2.fill(new Rectangle(0, 0, (int) printoutWidth, (int) printoutHeight)); // now print the playpen at the user's zoom setting, compounded with ours. g2.scale(settings.zoom, settings.zoom); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); logger.debug("Printout size = ("+printoutWidth+","+printoutHeight +"); playpen size = "+settings.pp.getPreferredSize()); //settings.pp.paint(g2); This is slow in win32 and x11 SwingUtilities.paintComponent(g2, settings.pp, new Container(), 0, 0, (int) (printoutWidth/settings.zoom), (int) (printoutHeight/settings.zoom)); ArchitectFrame.getMainInstance().splitPane.setRightComponent(settings.pp); // and draw the lines where the page boundaries fall, at our own zoom scale g2.setTransform(backup); g2.setColor(getForeground()); for (int i = 0; i <= settings.pagesAcross; i++) { g2.drawLine((int) (i * iW), 0, (int) (i * iW), (int) printoutHeight); logger.debug("Drew page separator at x="+(i*iW)); } for (int i = 0; i <= settings.pagesDown; i++) { g2.drawLine(0, (int) (i * iH), (int) printoutWidth, (int) (i * iH)); logger.debug("Drew page separator at y="+(i*iH)); } }
if (logger.isDebugEnabled()) { Dimension ppSize = pp.getPreferredSize(); logger.debug("PlayPen preferred size = "+ppSize.width+"x"+ppSize.height); logger.debug("After scaling, preview panel coordinate space is "+scaledWidth+"x"+scaledHeight); }
public void paintComponent(Graphics g) { settings.validateLayout(); double iW = settings.pageFormat.getImageableWidth(); double iH = settings.pageFormat.getImageableHeight(); double printoutWidth = settings.pagesAcross * iW; double printoutHeight = settings.pagesDown * iH; // create a bitmapped image of the scaled playpen Graphics2D g2 = (Graphics2D) g; g2.setColor(settings.getBackground()); g2.fill(new Rectangle(0, 0, getWidth(), getHeight())); double previewZoomX = (double) getWidth() / printoutWidth; double previewZoomY = (double) getHeight() / printoutHeight; double zoom = Math.min(previewZoomX, previewZoomY); int scaledWidth = (int) (getWidth()/zoom); int scaledHeight = (int) (getHeight()/zoom); logger.debug("After scaling, preview will seem to be size ("+scaledWidth+","+scaledHeight+")"); // print the page background at the panel's zoom setting, centered in available space g2.scale(zoom, zoom); g2.translate((scaledWidth - printoutWidth) / 2, (scaledHeight - printoutHeight) / 2); AffineTransform backup = g2.getTransform(); g2.setColor(settings.pp.getBackground()); g2.fill(new Rectangle(0, 0, (int) printoutWidth, (int) printoutHeight)); // now print the playpen at the user's zoom setting, compounded with ours. g2.scale(settings.zoom, settings.zoom); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); logger.debug("Printout size = ("+printoutWidth+","+printoutHeight +"); playpen size = "+settings.pp.getPreferredSize()); //settings.pp.paint(g2); This is slow in win32 and x11 SwingUtilities.paintComponent(g2, settings.pp, new Container(), 0, 0, (int) (printoutWidth/settings.zoom), (int) (printoutHeight/settings.zoom)); ArchitectFrame.getMainInstance().splitPane.setRightComponent(settings.pp); // and draw the lines where the page boundaries fall, at our own zoom scale g2.setTransform(backup); g2.setColor(getForeground()); for (int i = 0; i <= settings.pagesAcross; i++) { g2.drawLine((int) (i * iW), 0, (int) (i * iW), (int) printoutHeight); logger.debug("Drew page separator at x="+(i*iW)); } for (int i = 0; i <= settings.pagesDown; i++) { g2.drawLine(0, (int) (i * iH), (int) printoutWidth, (int) (i * iH)); logger.debug("Drew page separator at y="+(i*iH)); } }
g2.translate((scaledWidth - printoutWidth) / 2, (scaledHeight - printoutHeight) / 2); AffineTransform backup = g2.getTransform(); g2.setColor(settings.pp.getBackground()); g2.fill(new Rectangle(0, 0, (int) printoutWidth, (int) printoutHeight));
public void paintComponent(Graphics g) { settings.validateLayout(); double iW = settings.pageFormat.getImageableWidth(); double iH = settings.pageFormat.getImageableHeight(); double printoutWidth = settings.pagesAcross * iW; double printoutHeight = settings.pagesDown * iH; // create a bitmapped image of the scaled playpen Graphics2D g2 = (Graphics2D) g; g2.setColor(settings.getBackground()); g2.fill(new Rectangle(0, 0, getWidth(), getHeight())); double previewZoomX = (double) getWidth() / printoutWidth; double previewZoomY = (double) getHeight() / printoutHeight; double zoom = Math.min(previewZoomX, previewZoomY); int scaledWidth = (int) (getWidth()/zoom); int scaledHeight = (int) (getHeight()/zoom); logger.debug("After scaling, preview will seem to be size ("+scaledWidth+","+scaledHeight+")"); // print the page background at the panel's zoom setting, centered in available space g2.scale(zoom, zoom); g2.translate((scaledWidth - printoutWidth) / 2, (scaledHeight - printoutHeight) / 2); AffineTransform backup = g2.getTransform(); g2.setColor(settings.pp.getBackground()); g2.fill(new Rectangle(0, 0, (int) printoutWidth, (int) printoutHeight)); // now print the playpen at the user's zoom setting, compounded with ours. g2.scale(settings.zoom, settings.zoom); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); logger.debug("Printout size = ("+printoutWidth+","+printoutHeight +"); playpen size = "+settings.pp.getPreferredSize()); //settings.pp.paint(g2); This is slow in win32 and x11 SwingUtilities.paintComponent(g2, settings.pp, new Container(), 0, 0, (int) (printoutWidth/settings.zoom), (int) (printoutHeight/settings.zoom)); ArchitectFrame.getMainInstance().splitPane.setRightComponent(settings.pp); // and draw the lines where the page boundaries fall, at our own zoom scale g2.setTransform(backup); g2.setColor(getForeground()); for (int i = 0; i <= settings.pagesAcross; i++) { g2.drawLine((int) (i * iW), 0, (int) (i * iW), (int) printoutHeight); logger.debug("Drew page separator at x="+(i*iW)); } for (int i = 0; i <= settings.pagesDown; i++) { g2.drawLine(0, (int) (i * iH), (int) printoutWidth, (int) (i * iH)); logger.debug("Drew page separator at y="+(i*iH)); } }
g2.scale(settings.zoom, settings.zoom);
public void paintComponent(Graphics g) { settings.validateLayout(); double iW = settings.pageFormat.getImageableWidth(); double iH = settings.pageFormat.getImageableHeight(); double printoutWidth = settings.pagesAcross * iW; double printoutHeight = settings.pagesDown * iH; // create a bitmapped image of the scaled playpen Graphics2D g2 = (Graphics2D) g; g2.setColor(settings.getBackground()); g2.fill(new Rectangle(0, 0, getWidth(), getHeight())); double previewZoomX = (double) getWidth() / printoutWidth; double previewZoomY = (double) getHeight() / printoutHeight; double zoom = Math.min(previewZoomX, previewZoomY); int scaledWidth = (int) (getWidth()/zoom); int scaledHeight = (int) (getHeight()/zoom); logger.debug("After scaling, preview will seem to be size ("+scaledWidth+","+scaledHeight+")"); // print the page background at the panel's zoom setting, centered in available space g2.scale(zoom, zoom); g2.translate((scaledWidth - printoutWidth) / 2, (scaledHeight - printoutHeight) / 2); AffineTransform backup = g2.getTransform(); g2.setColor(settings.pp.getBackground()); g2.fill(new Rectangle(0, 0, (int) printoutWidth, (int) printoutHeight)); // now print the playpen at the user's zoom setting, compounded with ours. g2.scale(settings.zoom, settings.zoom); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); logger.debug("Printout size = ("+printoutWidth+","+printoutHeight +"); playpen size = "+settings.pp.getPreferredSize()); //settings.pp.paint(g2); This is slow in win32 and x11 SwingUtilities.paintComponent(g2, settings.pp, new Container(), 0, 0, (int) (printoutWidth/settings.zoom), (int) (printoutHeight/settings.zoom)); ArchitectFrame.getMainInstance().splitPane.setRightComponent(settings.pp); // and draw the lines where the page boundaries fall, at our own zoom scale g2.setTransform(backup); g2.setColor(getForeground()); for (int i = 0; i <= settings.pagesAcross; i++) { g2.drawLine((int) (i * iW), 0, (int) (i * iW), (int) printoutHeight); logger.debug("Drew page separator at x="+(i*iW)); } for (int i = 0; i <= settings.pagesDown; i++) { g2.drawLine(0, (int) (i * iH), (int) printoutWidth, (int) (i * iH)); logger.debug("Drew page separator at y="+(i*iH)); } }
logger.debug("Printout size = ("+printoutWidth+","+printoutHeight +"); playpen size = "+settings.pp.getPreferredSize());
public void paintComponent(Graphics g) { settings.validateLayout(); double iW = settings.pageFormat.getImageableWidth(); double iH = settings.pageFormat.getImageableHeight(); double printoutWidth = settings.pagesAcross * iW; double printoutHeight = settings.pagesDown * iH; // create a bitmapped image of the scaled playpen Graphics2D g2 = (Graphics2D) g; g2.setColor(settings.getBackground()); g2.fill(new Rectangle(0, 0, getWidth(), getHeight())); double previewZoomX = (double) getWidth() / printoutWidth; double previewZoomY = (double) getHeight() / printoutHeight; double zoom = Math.min(previewZoomX, previewZoomY); int scaledWidth = (int) (getWidth()/zoom); int scaledHeight = (int) (getHeight()/zoom); logger.debug("After scaling, preview will seem to be size ("+scaledWidth+","+scaledHeight+")"); // print the page background at the panel's zoom setting, centered in available space g2.scale(zoom, zoom); g2.translate((scaledWidth - printoutWidth) / 2, (scaledHeight - printoutHeight) / 2); AffineTransform backup = g2.getTransform(); g2.setColor(settings.pp.getBackground()); g2.fill(new Rectangle(0, 0, (int) printoutWidth, (int) printoutHeight)); // now print the playpen at the user's zoom setting, compounded with ours. g2.scale(settings.zoom, settings.zoom); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); logger.debug("Printout size = ("+printoutWidth+","+printoutHeight +"); playpen size = "+settings.pp.getPreferredSize()); //settings.pp.paint(g2); This is slow in win32 and x11 SwingUtilities.paintComponent(g2, settings.pp, new Container(), 0, 0, (int) (printoutWidth/settings.zoom), (int) (printoutHeight/settings.zoom)); ArchitectFrame.getMainInstance().splitPane.setRightComponent(settings.pp); // and draw the lines where the page boundaries fall, at our own zoom scale g2.setTransform(backup); g2.setColor(getForeground()); for (int i = 0; i <= settings.pagesAcross; i++) { g2.drawLine((int) (i * iW), 0, (int) (i * iW), (int) printoutHeight); logger.debug("Drew page separator at x="+(i*iW)); } for (int i = 0; i <= settings.pagesDown; i++) { g2.drawLine(0, (int) (i * iH), (int) printoutWidth, (int) (i * iH)); logger.debug("Drew page separator at y="+(i*iH)); } }
SwingUtilities.paintComponent(g2, settings.pp, new Container(), 0, 0, (int) (printoutWidth/settings.zoom), (int) (printoutHeight/settings.zoom)); ArchitectFrame.getMainInstance().splitPane.setRightComponent(settings.pp);
SwingUtilities.paintComponent(g2, pp, new Container(), 0, 0, scaledWidth, scaledHeight); ArchitectFrame.getMainInstance().splitPane.setRightComponent(pp);
public void paintComponent(Graphics g) { settings.validateLayout(); double iW = settings.pageFormat.getImageableWidth(); double iH = settings.pageFormat.getImageableHeight(); double printoutWidth = settings.pagesAcross * iW; double printoutHeight = settings.pagesDown * iH; // create a bitmapped image of the scaled playpen Graphics2D g2 = (Graphics2D) g; g2.setColor(settings.getBackground()); g2.fill(new Rectangle(0, 0, getWidth(), getHeight())); double previewZoomX = (double) getWidth() / printoutWidth; double previewZoomY = (double) getHeight() / printoutHeight; double zoom = Math.min(previewZoomX, previewZoomY); int scaledWidth = (int) (getWidth()/zoom); int scaledHeight = (int) (getHeight()/zoom); logger.debug("After scaling, preview will seem to be size ("+scaledWidth+","+scaledHeight+")"); // print the page background at the panel's zoom setting, centered in available space g2.scale(zoom, zoom); g2.translate((scaledWidth - printoutWidth) / 2, (scaledHeight - printoutHeight) / 2); AffineTransform backup = g2.getTransform(); g2.setColor(settings.pp.getBackground()); g2.fill(new Rectangle(0, 0, (int) printoutWidth, (int) printoutHeight)); // now print the playpen at the user's zoom setting, compounded with ours. g2.scale(settings.zoom, settings.zoom); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); logger.debug("Printout size = ("+printoutWidth+","+printoutHeight +"); playpen size = "+settings.pp.getPreferredSize()); //settings.pp.paint(g2); This is slow in win32 and x11 SwingUtilities.paintComponent(g2, settings.pp, new Container(), 0, 0, (int) (printoutWidth/settings.zoom), (int) (printoutHeight/settings.zoom)); ArchitectFrame.getMainInstance().splitPane.setRightComponent(settings.pp); // and draw the lines where the page boundaries fall, at our own zoom scale g2.setTransform(backup); g2.setColor(getForeground()); for (int i = 0; i <= settings.pagesAcross; i++) { g2.drawLine((int) (i * iW), 0, (int) (i * iW), (int) printoutHeight); logger.debug("Drew page separator at x="+(i*iW)); } for (int i = 0; i <= settings.pagesDown; i++) { g2.drawLine(0, (int) (i * iH), (int) printoutWidth, (int) (i * iH)); logger.debug("Drew page separator at y="+(i*iH)); } }
g2.setTransform(backup); g2.setColor(getForeground()); for (int i = 0; i <= settings.pagesAcross; i++) { g2.drawLine((int) (i * iW), 0, (int) (i * iW), (int) printoutHeight); logger.debug("Drew page separator at x="+(i*iW));
double iW = pageFormat.getImageableWidth(); double iH = pageFormat.getImageableHeight(); g2.scale(1/PrintPanel.this.zoom, 1/PrintPanel.this.zoom); g2.setColor(pp.getForeground()); for (int i = 0; i <= pagesAcross; i++) { g2.drawLine((int) (i * iW), 0, (int) (i * iW), (int) (scaledHeight*PrintPanel.this.zoom)); if (logger.isDebugEnabled()) logger.debug("Drew page separator at x="+(i*iW));
public void paintComponent(Graphics g) { settings.validateLayout(); double iW = settings.pageFormat.getImageableWidth(); double iH = settings.pageFormat.getImageableHeight(); double printoutWidth = settings.pagesAcross * iW; double printoutHeight = settings.pagesDown * iH; // create a bitmapped image of the scaled playpen Graphics2D g2 = (Graphics2D) g; g2.setColor(settings.getBackground()); g2.fill(new Rectangle(0, 0, getWidth(), getHeight())); double previewZoomX = (double) getWidth() / printoutWidth; double previewZoomY = (double) getHeight() / printoutHeight; double zoom = Math.min(previewZoomX, previewZoomY); int scaledWidth = (int) (getWidth()/zoom); int scaledHeight = (int) (getHeight()/zoom); logger.debug("After scaling, preview will seem to be size ("+scaledWidth+","+scaledHeight+")"); // print the page background at the panel's zoom setting, centered in available space g2.scale(zoom, zoom); g2.translate((scaledWidth - printoutWidth) / 2, (scaledHeight - printoutHeight) / 2); AffineTransform backup = g2.getTransform(); g2.setColor(settings.pp.getBackground()); g2.fill(new Rectangle(0, 0, (int) printoutWidth, (int) printoutHeight)); // now print the playpen at the user's zoom setting, compounded with ours. g2.scale(settings.zoom, settings.zoom); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); logger.debug("Printout size = ("+printoutWidth+","+printoutHeight +"); playpen size = "+settings.pp.getPreferredSize()); //settings.pp.paint(g2); This is slow in win32 and x11 SwingUtilities.paintComponent(g2, settings.pp, new Container(), 0, 0, (int) (printoutWidth/settings.zoom), (int) (printoutHeight/settings.zoom)); ArchitectFrame.getMainInstance().splitPane.setRightComponent(settings.pp); // and draw the lines where the page boundaries fall, at our own zoom scale g2.setTransform(backup); g2.setColor(getForeground()); for (int i = 0; i <= settings.pagesAcross; i++) { g2.drawLine((int) (i * iW), 0, (int) (i * iW), (int) printoutHeight); logger.debug("Drew page separator at x="+(i*iW)); } for (int i = 0; i <= settings.pagesDown; i++) { g2.drawLine(0, (int) (i * iH), (int) printoutWidth, (int) (i * iH)); logger.debug("Drew page separator at y="+(i*iH)); } }
for (int i = 0; i <= settings.pagesDown; i++) { g2.drawLine(0, (int) (i * iH), (int) printoutWidth, (int) (i * iH)); logger.debug("Drew page separator at y="+(i*iH));
for (int i = 0; i <= pagesDown; i++) { g2.drawLine(0, (int) (i * iH), (int) (scaledWidth*PrintPanel.this.zoom), (int) (i * iH)); if (logger.isDebugEnabled()) logger.debug("Drew page separator at y="+(i*iH));
public void paintComponent(Graphics g) { settings.validateLayout(); double iW = settings.pageFormat.getImageableWidth(); double iH = settings.pageFormat.getImageableHeight(); double printoutWidth = settings.pagesAcross * iW; double printoutHeight = settings.pagesDown * iH; // create a bitmapped image of the scaled playpen Graphics2D g2 = (Graphics2D) g; g2.setColor(settings.getBackground()); g2.fill(new Rectangle(0, 0, getWidth(), getHeight())); double previewZoomX = (double) getWidth() / printoutWidth; double previewZoomY = (double) getHeight() / printoutHeight; double zoom = Math.min(previewZoomX, previewZoomY); int scaledWidth = (int) (getWidth()/zoom); int scaledHeight = (int) (getHeight()/zoom); logger.debug("After scaling, preview will seem to be size ("+scaledWidth+","+scaledHeight+")"); // print the page background at the panel's zoom setting, centered in available space g2.scale(zoom, zoom); g2.translate((scaledWidth - printoutWidth) / 2, (scaledHeight - printoutHeight) / 2); AffineTransform backup = g2.getTransform(); g2.setColor(settings.pp.getBackground()); g2.fill(new Rectangle(0, 0, (int) printoutWidth, (int) printoutHeight)); // now print the playpen at the user's zoom setting, compounded with ours. g2.scale(settings.zoom, settings.zoom); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); logger.debug("Printout size = ("+printoutWidth+","+printoutHeight +"); playpen size = "+settings.pp.getPreferredSize()); //settings.pp.paint(g2); This is slow in win32 and x11 SwingUtilities.paintComponent(g2, settings.pp, new Container(), 0, 0, (int) (printoutWidth/settings.zoom), (int) (printoutHeight/settings.zoom)); ArchitectFrame.getMainInstance().splitPane.setRightComponent(settings.pp); // and draw the lines where the page boundaries fall, at our own zoom scale g2.setTransform(backup); g2.setColor(getForeground()); for (int i = 0; i <= settings.pagesAcross; i++) { g2.drawLine((int) (i * iW), 0, (int) (i * iW), (int) printoutHeight); logger.debug("Drew page separator at x="+(i*iW)); } for (int i = 0; i <= settings.pagesDown; i++) { g2.drawLine(0, (int) (i * iH), (int) printoutWidth, (int) (i * iH)); logger.debug("Drew page separator at y="+(i*iH)); } }
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
public PrintPanel(PlayPen pp) { super(); setOpaque(true); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); this.pp = pp; job = PrinterJob.getPrinterJob(); jobAttributes = new HashPrintRequestAttributeSet(); pageFormat = job.defaultPage(); JPanel formPanel = new JPanel(new FormLayout()); formPanel.add(new JLabel("Printer")); formPanel.add(printerBox = new JComboBox(PrinterJob.lookupPrintServices())); printerBox.setSelectedItem(getPreferredPrinter()); formPanel.add(new JLabel("Page Format")); formPanel.add(pageFormatLabel = new JLabel(pageFormat.toString())); formPanel.add(new JLabel("Change Page Format")); formPanel.add(pageFormatButton = new JButton("Change Page Format")); pageFormatButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setPageFormat(job.pageDialog(jobAttributes)); } }); formPanel.add(zoomLabel = new JLabel("Scaling = 100%")); formPanel.add(zoomSlider = new JSlider(JSlider.HORIZONTAL, 1, 300, 100)); setZoom(1.0); zoomSlider.addChangeListener(this); add(formPanel); }
add(new PrintPreviewPanel());
public PrintPanel(PlayPen pp) { super(); setOpaque(true); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); this.pp = pp; job = PrinterJob.getPrinterJob(); jobAttributes = new HashPrintRequestAttributeSet(); pageFormat = job.defaultPage(); JPanel formPanel = new JPanel(new FormLayout()); formPanel.add(new JLabel("Printer")); formPanel.add(printerBox = new JComboBox(PrinterJob.lookupPrintServices())); printerBox.setSelectedItem(getPreferredPrinter()); formPanel.add(new JLabel("Page Format")); formPanel.add(pageFormatLabel = new JLabel(pageFormat.toString())); formPanel.add(new JLabel("Change Page Format")); formPanel.add(pageFormatButton = new JButton("Change Page Format")); pageFormatButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setPageFormat(job.pageDialog(jobAttributes)); } }); formPanel.add(zoomLabel = new JLabel("Scaling = 100%")); formPanel.add(zoomSlider = new JSlider(JSlider.HORIZONTAL, 1, 300, 100)); setZoom(1.0); zoomSlider.addChangeListener(this); add(formPanel); }
throws ClassNotFoundException, InstantiationException, IllegalAccessException { log.info("Loading JDBC driver: [" + driverClassName + "]");
throws ClassNotFoundException, InstantiationException, IllegalAccessException {
public void setDriverClassName(String driverClassName) throws ClassNotFoundException, InstantiationException, IllegalAccessException { log.info("Loading JDBC driver: [" + driverClassName + "]"); this.driverClassName = driverClassName; getClass().getClassLoader().loadClass(driverClassName).newInstance(); }
this.driverClassName = driverClassName; getClass().getClassLoader().loadClass(driverClassName).newInstance(); }
if (log.isDebugEnabled()) { log.debug("Loading JDBC driver: [" + driverClassName + "]"); } this.driverClassName = driverClassName; getClass().getClassLoader().loadClass(driverClassName).newInstance(); }
public void setDriverClassName(String driverClassName) throws ClassNotFoundException, InstantiationException, IllegalAccessException { log.info("Loading JDBC driver: [" + driverClassName + "]"); this.driverClassName = driverClassName; getClass().getClassLoader().loadClass(driverClassName).newInstance(); }
log.info("Setting url to: " + jdbcURL); this.jdbcURL = jdbcURL; }
this.jdbcURL = jdbcURL; }
public void setJdbcURL(String jdbcURL) { log.info("Setting url to: " + jdbcURL); this.jdbcURL = jdbcURL; }
} else if (str.startsWith("\\q")){ System.exit(0);
private void doEscape(String str) throws IOException, SQLException, ArchitectException { String rest = null; if (str.length() > 2) { rest = str.substring(2); } if (str.startsWith("\\d")) { // Display if (rest == null){ throw new ArchitectException("\\d needs display arg"); } display(rest); } else if (str.startsWith("\\m")) { // MODE if (rest == null){ throw new ArchitectException("\\m needs output mode arg"); } setOutputMode(rest); } else if (str.startsWith("\\o")){ if (rest == null){ throw new ArchitectException("\\o needs output file arg"); } setOutputFile(rest); } else if (str.startsWith("\\q")){ System.exit(0); } else { throw new ArchitectException("Unknown escape: " + str); } }
public static void deleteApplication(String applicationId) {
public static ApplicationConfig deleteApplication(String applicationId) {
public static void deleteApplication(String applicationId) { assert applicationId != null: "applicationId is null"; ApplicationConfig config = getApplicationConfig(applicationId); assert config != null: "there is no application with id="+applicationId; deleteApplication(config); }
return(config);
public static void deleteApplication(String applicationId) { assert applicationId != null: "applicationId is null"; ApplicationConfig config = getApplicationConfig(applicationId); assert config != null: "there is no application with id="+applicationId; deleteApplication(config); }
List<DashboardConfig> dashboardConfigList = null; Element dashboards = config.getRootElement().getChild(DASHBOARDS); if(dashboards != null){ dashboardConfigList = getDashboardConfigList(dashboards.getChildren()); }else{ dashboardConfigList = new LinkedList<DashboardConfig>(); } return new Config(appConfigList, dashboardConfigList);
return new Config(appConfigList);
public Config read(){ List applications = config.getRootElement().getChild(APPLICATIONS).getChildren(); List<ApplicationConfig> appConfigList = getApplicationConfigList(applications, null); List<DashboardConfig> dashboardConfigList = null; Element dashboards = config.getRootElement().getChild(DASHBOARDS); if(dashboards != null){ dashboardConfigList = getDashboardConfigList(dashboards.getChildren()); }else{ dashboardConfigList = new LinkedList<DashboardConfig>(); } return new Config(appConfigList, dashboardConfigList); }
for(Iterator it=config.getApplications().iterator(); it.hasNext();){ ApplicationConfig application = (ApplicationConfig)it.next();
for(ApplicationConfig application : config.getApplications()){
public void write(Config config) { try { Document doc = new Document(); Element rootElement = new Element(ConfigConstants.APPLICATION_CONFIG); /* applications */ Element applicationsElement = new Element(ConfigConstants.APPLICATIONS); rootElement.addContent(applicationsElement); for(Iterator it=config.getApplications().iterator(); it.hasNext();){ ApplicationConfig application = (ApplicationConfig)it.next(); /* get the application or application-cluster element */ Element applicationElement = null; if(application.isCluster()){ applicationElement = createApplicationClusterElement(application); }else{ applicationElement = createApplicationElement(application); } /* add this application element to the root node */ applicationsElement.addContent(applicationElement); } /* dashboards */ Element dashboardsElement = new Element(ConfigConstants.DASHBOARDS); rootElement.addContent(dashboardsElement); for(Iterator it=config.getDashboards().iterator(); it.hasNext();){ DashboardConfig dashboard = (DashboardConfig)it.next(); Element dashboardElement = new Element(ConfigConstants.DASHBOARD);; dashboardElement.setAttribute(ConfigConstants.DASHBOARD_ID, dashboard.getDashboardId()); dashboardElement.setAttribute(ConfigConstants.DASHBOARD_NAME, dashboard.getName()); /* add this dashboard element to the root node */ dashboardsElement.addContent(dashboardElement); } doc.setRootElement(rootElement); /* write to the disc */ XMLOutputter writer = new XMLOutputter(); writer.output(doc, new FileOutputStream(ConfigConstants.DEFAULT_CONFIG_FILE_NAME)); } catch (Exception e) { throw new RuntimeException(e); } }
Element dashboardsElement = new Element(ConfigConstants.DASHBOARDS); rootElement.addContent(dashboardsElement); for(Iterator it=config.getDashboards().iterator(); it.hasNext();){ DashboardConfig dashboard = (DashboardConfig)it.next(); Element dashboardElement = new Element(ConfigConstants.DASHBOARD);; dashboardElement.setAttribute(ConfigConstants.DASHBOARD_ID, dashboard.getDashboardId()); dashboardElement.setAttribute(ConfigConstants.DASHBOARD_NAME, dashboard.getName()); dashboardsElement.addContent(dashboardElement); }
public void write(Config config) { try { Document doc = new Document(); Element rootElement = new Element(ConfigConstants.APPLICATION_CONFIG); /* applications */ Element applicationsElement = new Element(ConfigConstants.APPLICATIONS); rootElement.addContent(applicationsElement); for(Iterator it=config.getApplications().iterator(); it.hasNext();){ ApplicationConfig application = (ApplicationConfig)it.next(); /* get the application or application-cluster element */ Element applicationElement = null; if(application.isCluster()){ applicationElement = createApplicationClusterElement(application); }else{ applicationElement = createApplicationElement(application); } /* add this application element to the root node */ applicationsElement.addContent(applicationElement); } /* dashboards */ Element dashboardsElement = new Element(ConfigConstants.DASHBOARDS); rootElement.addContent(dashboardsElement); for(Iterator it=config.getDashboards().iterator(); it.hasNext();){ DashboardConfig dashboard = (DashboardConfig)it.next(); Element dashboardElement = new Element(ConfigConstants.DASHBOARD);; dashboardElement.setAttribute(ConfigConstants.DASHBOARD_ID, dashboard.getDashboardId()); dashboardElement.setAttribute(ConfigConstants.DASHBOARD_NAME, dashboard.getName()); /* add this dashboard element to the root node */ dashboardsElement.addContent(dashboardElement); } doc.setRootElement(rootElement); /* write to the disc */ XMLOutputter writer = new XMLOutputter(); writer.output(doc, new FileOutputStream(ConfigConstants.DEFAULT_CONFIG_FILE_NAME)); } catch (Exception e) { throw new RuntimeException(e); } }
(int)(Options.getSpacingThreshold()*100));
(int)(Options.getSpacingThreshold()*200));
public ProportionalSpacingDialog(HaploView h, String title){ super (h, title); hv = h; JPanel contents = new JPanel(); contents.setLayout(new BoxLayout(contents, BoxLayout.Y_AXIS)); JSlider slider = new JSlider(0,100, (int)(Options.getSpacingThreshold()*100)); Hashtable labeltable = new Hashtable(); labeltable.put(new Integer(0), new JLabel("None")); labeltable.put(new Integer(100), new JLabel ("Full")); slider.setLabelTable( labeltable ); slider.setPaintLabels(true); slider.addChangeListener(this); contents.add(slider); JButton doneButton = new JButton("Done"); doneButton.addActionListener(this); contents.add(doneButton); this.setContentPane(contents); this.setLocation(this.getParent().getX() + 100, this.getParent().getY() + 100); this.setModal(true); }
Options.setSpacingThreshold(thresh);
Options.setSpacingThreshold(thresh*0.5);
public void stateChanged(ChangeEvent e) { JSlider source = (JSlider)e.getSource(); if (!source.getValueIsAdjusting()) { double thresh = ((double)source.getValue())/100; Options.setSpacingThreshold(thresh); hv.dPrimeDisplay.computePreferredSize(); if (hv.dPrimeDisplay != null && hv.tabs.getSelectedIndex() == VIEW_D_NUM){ hv.dPrimeDisplay.repaint(); } } }
} catch (ArchitectException ex) { logger.error("Error in Profile Action ", ex); ASUtils.showExceptionDialog(dbTree, "Error during profile run", ex);
} catch (ArchitectException e1) { e1.printStackTrace();
public void taskFinished(TaskTerminationEvent e) { System.out.println("\n\n\n========================================="); try { for ( SQLTable t : tables ) { ProfileResult pr = profileManager.getResult(t); System.out.println(t.getName()+" "+pr.toString()); for ( SQLColumn c : t.getColumns() ) { pr = profileManager.getResult(c); System.out.println(c.getName()+"["+c.getSourceDataTypeName()+"] "+pr); } } } catch (ArchitectException ex) { logger.error("Error in Profile Action ", ex); ASUtils.showExceptionDialog(dbTree, "Error during profile run", ex); } return; }
d = new JDialog(ArchitectFrame.getMainInstance(), "Table Profiles"); ProfilePanel p = new ProfilePanel(); List<SQLTable> list = new ArrayList(tables); p.setTables(list);
d = new JDialog(ArchitectFrame.getMainInstance(),"Table Profiles"); final JPanel cp = new JPanel(new BorderLayout()); final JProgressBar bar = new JProgressBar(); bar.setPreferredSize(new Dimension(450,20)); cp.add(bar, BorderLayout.CENTER); cp.add(buttonPanel, BorderLayout.SOUTH);
public void actionPerformed(ActionEvent e) { if (dbTree == null) { logger.debug("dbtree was null when actionPerformed called"); return; } try { if ( dbTree.getSelectionPaths() == null ) return; final Set <SQLTable> tables = new HashSet(); for ( TreePath p : dbTree.getSelectionPaths() ) { SQLObject so = (SQLObject) p.getLastPathComponent(); Collection<SQLTable> tablesUnder = tablesUnder(so); System.out.println("Tables under "+so+" are: "+tablesUnder); tables.addAll(tablesUnder); } final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); Action okAction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { d.setVisible(false); } }; okAction.putValue(Action.NAME, "OK"); final JDefaultButton okButton = new JDefaultButton(okAction); buttonPanel.add(okButton); d = new JDialog(ArchitectFrame.getMainInstance(), "Table Profiles"); ProfilePanel p = new ProfilePanel(); List<SQLTable> list = new ArrayList(tables); p.setTables(list);// final JProgressBar bar = new JProgressBar();// bar.setPreferredSize(new Dimension(450,20));// cp.add(bar, BorderLayout.CENTER); ArchitectPanelBuilder.makeJDialogCancellable( d, new CommonCloseAction(d)); d.setContentPane(p); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true);// // new ProgressWatcher(bar,profileManager);// // new Thread( new Runnable() {// // public void run() {// try {// profileManager.createProfiles(tables);// // bar.setVisible(false);// JEditorPane editorPane = new JEditorPane();// editorPane.setEditable(false);// editorPane.setContentType("text/html");// ProfileResultFormatter prf = new ProfileResultFormatter();// editorPane.setText(prf.format(tables,profileManager) );//// JScrollPane editorScrollPane = new JScrollPane(editorPane);// editorScrollPane.setVerticalScrollBarPolicy(// JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);// editorScrollPane.setPreferredSize(new Dimension(800, 600));// editorScrollPane.setMinimumSize(new Dimension(10, 10));// // } catch (SQLException e) {// logger.error("Error in Profile Action ", e);// ASUtils.showExceptionDialogNoReport(dbTree, "Error during profile run", e);// } catch (ArchitectException e) {// // TODO Auto-generated catch block// e.printStackTrace();// }// }// // }).start();// } catch (Exception ex) { logger.error("Error in Profile Action ", ex); ASUtils.showExceptionDialog(dbTree, "Error during profile run", ex); } }
d.setContentPane(p);
d.getRootPane().setDefaultButton(okButton); d.setContentPane(cp);
public void actionPerformed(ActionEvent e) { if (dbTree == null) { logger.debug("dbtree was null when actionPerformed called"); return; } try { if ( dbTree.getSelectionPaths() == null ) return; final Set <SQLTable> tables = new HashSet(); for ( TreePath p : dbTree.getSelectionPaths() ) { SQLObject so = (SQLObject) p.getLastPathComponent(); Collection<SQLTable> tablesUnder = tablesUnder(so); System.out.println("Tables under "+so+" are: "+tablesUnder); tables.addAll(tablesUnder); } final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); Action okAction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { d.setVisible(false); } }; okAction.putValue(Action.NAME, "OK"); final JDefaultButton okButton = new JDefaultButton(okAction); buttonPanel.add(okButton); d = new JDialog(ArchitectFrame.getMainInstance(), "Table Profiles"); ProfilePanel p = new ProfilePanel(); List<SQLTable> list = new ArrayList(tables); p.setTables(list);// final JProgressBar bar = new JProgressBar();// bar.setPreferredSize(new Dimension(450,20));// cp.add(bar, BorderLayout.CENTER); ArchitectPanelBuilder.makeJDialogCancellable( d, new CommonCloseAction(d)); d.setContentPane(p); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true);// // new ProgressWatcher(bar,profileManager);// // new Thread( new Runnable() {// // public void run() {// try {// profileManager.createProfiles(tables);// // bar.setVisible(false);// JEditorPane editorPane = new JEditorPane();// editorPane.setEditable(false);// editorPane.setContentType("text/html");// ProfileResultFormatter prf = new ProfileResultFormatter();// editorPane.setText(prf.format(tables,profileManager) );//// JScrollPane editorScrollPane = new JScrollPane(editorPane);// editorScrollPane.setVerticalScrollBarPolicy(// JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);// editorScrollPane.setPreferredSize(new Dimension(800, 600));// editorScrollPane.setMinimumSize(new Dimension(10, 10));// // } catch (SQLException e) {// logger.error("Error in Profile Action ", e);// ASUtils.showExceptionDialogNoReport(dbTree, "Error during profile run", e);// } catch (ArchitectException e) {// // TODO Auto-generated catch block// e.printStackTrace();// }// }// // }).start();// } catch (Exception ex) { logger.error("Error in Profile Action ", ex); ASUtils.showExceptionDialog(dbTree, "Error during profile run", ex); } }
new ProgressWatcher(bar,profileManager); new Thread( new Runnable() { public void run() { try { profileManager.createProfiles(tables);
public void actionPerformed(ActionEvent e) { if (dbTree == null) { logger.debug("dbtree was null when actionPerformed called"); return; } try { if ( dbTree.getSelectionPaths() == null ) return; final Set <SQLTable> tables = new HashSet(); for ( TreePath p : dbTree.getSelectionPaths() ) { SQLObject so = (SQLObject) p.getLastPathComponent(); Collection<SQLTable> tablesUnder = tablesUnder(so); System.out.println("Tables under "+so+" are: "+tablesUnder); tables.addAll(tablesUnder); } final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); Action okAction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { d.setVisible(false); } }; okAction.putValue(Action.NAME, "OK"); final JDefaultButton okButton = new JDefaultButton(okAction); buttonPanel.add(okButton); d = new JDialog(ArchitectFrame.getMainInstance(), "Table Profiles"); ProfilePanel p = new ProfilePanel(); List<SQLTable> list = new ArrayList(tables); p.setTables(list);// final JProgressBar bar = new JProgressBar();// bar.setPreferredSize(new Dimension(450,20));// cp.add(bar, BorderLayout.CENTER); ArchitectPanelBuilder.makeJDialogCancellable( d, new CommonCloseAction(d)); d.setContentPane(p); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true);// // new ProgressWatcher(bar,profileManager);// // new Thread( new Runnable() {// // public void run() {// try {// profileManager.createProfiles(tables);// // bar.setVisible(false);// JEditorPane editorPane = new JEditorPane();// editorPane.setEditable(false);// editorPane.setContentType("text/html");// ProfileResultFormatter prf = new ProfileResultFormatter();// editorPane.setText(prf.format(tables,profileManager) );//// JScrollPane editorScrollPane = new JScrollPane(editorPane);// editorScrollPane.setVerticalScrollBarPolicy(// JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);// editorScrollPane.setPreferredSize(new Dimension(800, 600));// editorScrollPane.setMinimumSize(new Dimension(10, 10));// // } catch (SQLException e) {// logger.error("Error in Profile Action ", e);// ASUtils.showExceptionDialogNoReport(dbTree, "Error during profile run", e);// } catch (ArchitectException e) {// // TODO Auto-generated catch block// e.printStackTrace();// }// }// // }).start();// } catch (Exception ex) { logger.error("Error in Profile Action ", ex); ASUtils.showExceptionDialog(dbTree, "Error during profile run", ex); } }
FileOutputStream file = null; ByteArrayOutputStream buffer = new ByteArrayOutputStream(); List tabList = new ArrayList(tables); try { new ProfilePDFFormat().createPdf(buffer,tabList,profileManager); file = new FileOutputStream(new File("M:\\architect_profile.pdf")); buffer.writeTo(file); } catch (Exception e) { ASUtils.showExceptionDialog(d,"Could not save PDF File", e); } finally { if ( file != null ) { try { file.close(); } catch (IOException e) { ASUtils.showExceptionDialog(d,"Could not close PDF File", e); } } } cp.remove(bar); bar.setVisible(false); JEditorPane editorPane = new JEditorPane(); editorPane.setEditable(false); editorPane.setContentType("text/html"); ProfileResultFormatter prf = new ProfileResultFormatter(); editorPane.setText(prf.format(tables,profileManager) ); JScrollPane editorScrollPane = new JScrollPane(editorPane); editorScrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(800, 600)); editorScrollPane.setMinimumSize(new Dimension(10, 10)); cp.add(editorScrollPane, BorderLayout.CENTER); d.pack(); } catch (SQLException e) { logger.error("Error in Profile Action ", e); ASUtils.showExceptionDialogNoReport(dbTree, "Error during profile run", e); } catch (ArchitectException e) { e.printStackTrace(); } } }).start();
public void actionPerformed(ActionEvent e) { if (dbTree == null) { logger.debug("dbtree was null when actionPerformed called"); return; } try { if ( dbTree.getSelectionPaths() == null ) return; final Set <SQLTable> tables = new HashSet(); for ( TreePath p : dbTree.getSelectionPaths() ) { SQLObject so = (SQLObject) p.getLastPathComponent(); Collection<SQLTable> tablesUnder = tablesUnder(so); System.out.println("Tables under "+so+" are: "+tablesUnder); tables.addAll(tablesUnder); } final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); Action okAction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { d.setVisible(false); } }; okAction.putValue(Action.NAME, "OK"); final JDefaultButton okButton = new JDefaultButton(okAction); buttonPanel.add(okButton); d = new JDialog(ArchitectFrame.getMainInstance(), "Table Profiles"); ProfilePanel p = new ProfilePanel(); List<SQLTable> list = new ArrayList(tables); p.setTables(list);// final JProgressBar bar = new JProgressBar();// bar.setPreferredSize(new Dimension(450,20));// cp.add(bar, BorderLayout.CENTER); ArchitectPanelBuilder.makeJDialogCancellable( d, new CommonCloseAction(d)); d.setContentPane(p); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true);// // new ProgressWatcher(bar,profileManager);// // new Thread( new Runnable() {// // public void run() {// try {// profileManager.createProfiles(tables);// // bar.setVisible(false);// JEditorPane editorPane = new JEditorPane();// editorPane.setEditable(false);// editorPane.setContentType("text/html");// ProfileResultFormatter prf = new ProfileResultFormatter();// editorPane.setText(prf.format(tables,profileManager) );//// JScrollPane editorScrollPane = new JScrollPane(editorPane);// editorScrollPane.setVerticalScrollBarPolicy(// JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);// editorScrollPane.setPreferredSize(new Dimension(800, 600));// editorScrollPane.setMinimumSize(new Dimension(10, 10));// // } catch (SQLException e) {// logger.error("Error in Profile Action ", e);// ASUtils.showExceptionDialogNoReport(dbTree, "Error during profile run", e);// } catch (ArchitectException e) {// // TODO Auto-generated catch block// e.printStackTrace();// }// }// // }).start();// } catch (Exception ex) { logger.error("Error in Profile Action ", ex); ASUtils.showExceptionDialog(dbTree, "Error during profile run", ex); } }
public synchronized void createProfiles(Collection<SQLTable> tables ) throws SQLException, ArchitectException { createProfiles(tables,null);
public synchronized void createProfiles(Collection<SQLTable> tables, JLabel workingOn) throws SQLException, ArchitectException { synchronized (monitorableMutex) { int objCount = 0; for (SQLTable t : tables) { objCount += 1; objCount += t.getColumns().size(); } jobSize = new Integer(objCount); finished = false; progress = 0; userCancel = false; logger.debug("Job Size:"+jobSize+" progress="+progress); } try { for (SQLTable t : tables) { synchronized (monitorableMutex) { currentProfilingTable = t.getName(); if ( workingOn != null ) workingOn.setText("Profiling: "+currentProfilingTable); if (userCancel) break; } doTableProfile(t); synchronized (monitorableMutex) { progress++; if (userCancel) break; logger.debug("Job Size:"+jobSize+" progress="+progress); } } } finally { synchronized (monitorableMutex) { finished = true; jobSize = null; } fireProfileAddedEvent(new ProfileChangeEvent(this, null)); }
public synchronized void createProfiles(Collection<SQLTable> tables ) throws SQLException, ArchitectException { createProfiles(tables,null); }
totalColumn = headings.length;
public ProfilePDFFormat() { super(); // TODO Auto-generated constructor stub }
public static void createPdf(OutputStream out,
public void createPdf(OutputStream out,
public static void createPdf(OutputStream out, java.util.List<SQLTable> tables, ProfileManager pm) throws DocumentException, IOException, SQLException, ArchitectException, InstantiationException, IllegalAccessException { final int minRowsTogether = 5; // counts smaller than this are considered orphan/widow final int mtop = 50; // margin at top of page (in points) final int mbot = 50; // margin at bottom of page (page numbers are below this) final int pbot = 20; // padding between bottom margin and bottom of body text final int mlft = 50; // margin at left side of page final int mrgt = 50; // margin at right side of page final Rectangle pagesize = PageSize.LETTER.rotate(); final Document document = new Document(pagesize, mlft, mrgt, mtop, mbot); final PdfWriter writer = PdfWriter.getInstance(document, out); final float fsize = 12f; // the font size to use in the table body final BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, false); document.addTitle("Table Profiling Report"); document.addSubject("Tables: " + tables); document.addAuthor(System.getProperty("user.name")); document.addCreator("Power*Architect version "+ArchitectUtils.APP_VERSION); document.open(); // vertical position where next element should start // (bottom is 0; top is pagesize.height()) float pos = pagesize.height() - mtop; final PdfContentByte cb = writer.getDirectContent(); final PdfTemplate nptemplate = cb.createTemplate(50, 50); writer.setPageEvent(new PdfPageEventHelper() { // prints the "page N of <template>" footer public void onEndPage(PdfWriter writer, Document document) { int pageN = writer.getPageNumber(); String text = "Page " + pageN + " of "; float len = bf.getWidthPoint(text, fsize-2); cb.beginText(); cb.setFontAndSize(bf, fsize-2); cb.setTextMatrix(pagesize.width()/2 - len/2, mbot/2); cb.showText(text); cb.endText(); cb.addTemplate(nptemplate, pagesize.width()/2 - len/2 + len, mbot/2); } public void onCloseDocument(PdfWriter writer, Document document) { nptemplate.beginText(); nptemplate.setFontAndSize(bf, fsize-2); nptemplate.showText(String.valueOf(writer.getPageNumber() - 1)); nptemplate.endText(); } }); document.add(new Paragraph("Power*Architect Profiling Report")); document.add(new Paragraph("Generated "+new java.util.Date() +" by "+System.getProperty("user.name"))); int vcols = 18; float[] widths = new float[vcols]; // widths of widest cells per row in pdf table LinkedList<PdfPTable> profiles = new LinkedList<PdfPTable>(); // 1 table per profile result for (SQLTable t : tables) { ProfileResult tpr = pm.getResult(t); PdfPTable table = makeNextTable(pm,t, bf, fsize, widths); profiles.add(table); } // add the PdfPTables to the document; try to avoid orphan and widow rows pos = writer.getVerticalPosition(true) - fsize; logger.debug("Starting at pos="+pos); for (PdfPTable table : profiles) { table.setTotalWidth(pagesize.width() - mrgt - mlft); table.setWidths(widths); int startrow = table.getHeaderRows(); int endrow = startrow; // current page will contain header+startrow..endrow while (endrow < table.size()) { // figure out how many body rows fit nicely on the page float endpos = pos - calcHeaderHeight(table); while (endpos > (mbot + pbot) && endrow < table.size() ) { endpos -= table.getRowHeight(endrow); endrow++; } // adjust for orphan rows. Might create widows or make // endrow < startrow, which is handled later by deferring the table if (endrow < table.size() && endrow + minRowsTogether >= table.size()) { if (endrow + 1 == table.size()) { // short by 1 row.. just squeeze it in endrow = table.size(); } else { // more than 1 row remains: shorten this page so orphans aren't lonely endrow = table.size() - minRowsTogether; } } if (endrow == table.size() || endrow - startrow > minRowsTogether) { // this is the end of the table, or we have enough rows to bother printing pos = table.writeSelectedRows(0, table.getHeaderRows(), mlft, pos, cb); pos = table.writeSelectedRows(startrow, endrow, mlft, pos, cb); startrow = endrow; } else { // not the end of the table and not enough rows to print out endrow = startrow; } // new page if necessary (that is, when we aren't finished the table yet) if (endrow != table.size()) { document.newPage(); pos = pagesize.height() - mtop; } } } document.close(); }
final int minRowsTogether = 5;
final int minRowsTogether = 1;
public static void createPdf(OutputStream out, java.util.List<SQLTable> tables, ProfileManager pm) throws DocumentException, IOException, SQLException, ArchitectException, InstantiationException, IllegalAccessException { final int minRowsTogether = 5; // counts smaller than this are considered orphan/widow final int mtop = 50; // margin at top of page (in points) final int mbot = 50; // margin at bottom of page (page numbers are below this) final int pbot = 20; // padding between bottom margin and bottom of body text final int mlft = 50; // margin at left side of page final int mrgt = 50; // margin at right side of page final Rectangle pagesize = PageSize.LETTER.rotate(); final Document document = new Document(pagesize, mlft, mrgt, mtop, mbot); final PdfWriter writer = PdfWriter.getInstance(document, out); final float fsize = 12f; // the font size to use in the table body final BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, false); document.addTitle("Table Profiling Report"); document.addSubject("Tables: " + tables); document.addAuthor(System.getProperty("user.name")); document.addCreator("Power*Architect version "+ArchitectUtils.APP_VERSION); document.open(); // vertical position where next element should start // (bottom is 0; top is pagesize.height()) float pos = pagesize.height() - mtop; final PdfContentByte cb = writer.getDirectContent(); final PdfTemplate nptemplate = cb.createTemplate(50, 50); writer.setPageEvent(new PdfPageEventHelper() { // prints the "page N of <template>" footer public void onEndPage(PdfWriter writer, Document document) { int pageN = writer.getPageNumber(); String text = "Page " + pageN + " of "; float len = bf.getWidthPoint(text, fsize-2); cb.beginText(); cb.setFontAndSize(bf, fsize-2); cb.setTextMatrix(pagesize.width()/2 - len/2, mbot/2); cb.showText(text); cb.endText(); cb.addTemplate(nptemplate, pagesize.width()/2 - len/2 + len, mbot/2); } public void onCloseDocument(PdfWriter writer, Document document) { nptemplate.beginText(); nptemplate.setFontAndSize(bf, fsize-2); nptemplate.showText(String.valueOf(writer.getPageNumber() - 1)); nptemplate.endText(); } }); document.add(new Paragraph("Power*Architect Profiling Report")); document.add(new Paragraph("Generated "+new java.util.Date() +" by "+System.getProperty("user.name"))); int vcols = 18; float[] widths = new float[vcols]; // widths of widest cells per row in pdf table LinkedList<PdfPTable> profiles = new LinkedList<PdfPTable>(); // 1 table per profile result for (SQLTable t : tables) { ProfileResult tpr = pm.getResult(t); PdfPTable table = makeNextTable(pm,t, bf, fsize, widths); profiles.add(table); } // add the PdfPTables to the document; try to avoid orphan and widow rows pos = writer.getVerticalPosition(true) - fsize; logger.debug("Starting at pos="+pos); for (PdfPTable table : profiles) { table.setTotalWidth(pagesize.width() - mrgt - mlft); table.setWidths(widths); int startrow = table.getHeaderRows(); int endrow = startrow; // current page will contain header+startrow..endrow while (endrow < table.size()) { // figure out how many body rows fit nicely on the page float endpos = pos - calcHeaderHeight(table); while (endpos > (mbot + pbot) && endrow < table.size() ) { endpos -= table.getRowHeight(endrow); endrow++; } // adjust for orphan rows. Might create widows or make // endrow < startrow, which is handled later by deferring the table if (endrow < table.size() && endrow + minRowsTogether >= table.size()) { if (endrow + 1 == table.size()) { // short by 1 row.. just squeeze it in endrow = table.size(); } else { // more than 1 row remains: shorten this page so orphans aren't lonely endrow = table.size() - minRowsTogether; } } if (endrow == table.size() || endrow - startrow > minRowsTogether) { // this is the end of the table, or we have enough rows to bother printing pos = table.writeSelectedRows(0, table.getHeaderRows(), mlft, pos, cb); pos = table.writeSelectedRows(startrow, endrow, mlft, pos, cb); startrow = endrow; } else { // not the end of the table and not enough rows to print out endrow = startrow; } // new page if necessary (that is, when we aren't finished the table yet) if (endrow != table.size()) { document.newPage(); pos = pagesize.height() - mtop; } } } document.close(); }
final float fsize = 12f;
final float fsize = 6f;
public static void createPdf(OutputStream out, java.util.List<SQLTable> tables, ProfileManager pm) throws DocumentException, IOException, SQLException, ArchitectException, InstantiationException, IllegalAccessException { final int minRowsTogether = 5; // counts smaller than this are considered orphan/widow final int mtop = 50; // margin at top of page (in points) final int mbot = 50; // margin at bottom of page (page numbers are below this) final int pbot = 20; // padding between bottom margin and bottom of body text final int mlft = 50; // margin at left side of page final int mrgt = 50; // margin at right side of page final Rectangle pagesize = PageSize.LETTER.rotate(); final Document document = new Document(pagesize, mlft, mrgt, mtop, mbot); final PdfWriter writer = PdfWriter.getInstance(document, out); final float fsize = 12f; // the font size to use in the table body final BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, false); document.addTitle("Table Profiling Report"); document.addSubject("Tables: " + tables); document.addAuthor(System.getProperty("user.name")); document.addCreator("Power*Architect version "+ArchitectUtils.APP_VERSION); document.open(); // vertical position where next element should start // (bottom is 0; top is pagesize.height()) float pos = pagesize.height() - mtop; final PdfContentByte cb = writer.getDirectContent(); final PdfTemplate nptemplate = cb.createTemplate(50, 50); writer.setPageEvent(new PdfPageEventHelper() { // prints the "page N of <template>" footer public void onEndPage(PdfWriter writer, Document document) { int pageN = writer.getPageNumber(); String text = "Page " + pageN + " of "; float len = bf.getWidthPoint(text, fsize-2); cb.beginText(); cb.setFontAndSize(bf, fsize-2); cb.setTextMatrix(pagesize.width()/2 - len/2, mbot/2); cb.showText(text); cb.endText(); cb.addTemplate(nptemplate, pagesize.width()/2 - len/2 + len, mbot/2); } public void onCloseDocument(PdfWriter writer, Document document) { nptemplate.beginText(); nptemplate.setFontAndSize(bf, fsize-2); nptemplate.showText(String.valueOf(writer.getPageNumber() - 1)); nptemplate.endText(); } }); document.add(new Paragraph("Power*Architect Profiling Report")); document.add(new Paragraph("Generated "+new java.util.Date() +" by "+System.getProperty("user.name"))); int vcols = 18; float[] widths = new float[vcols]; // widths of widest cells per row in pdf table LinkedList<PdfPTable> profiles = new LinkedList<PdfPTable>(); // 1 table per profile result for (SQLTable t : tables) { ProfileResult tpr = pm.getResult(t); PdfPTable table = makeNextTable(pm,t, bf, fsize, widths); profiles.add(table); } // add the PdfPTables to the document; try to avoid orphan and widow rows pos = writer.getVerticalPosition(true) - fsize; logger.debug("Starting at pos="+pos); for (PdfPTable table : profiles) { table.setTotalWidth(pagesize.width() - mrgt - mlft); table.setWidths(widths); int startrow = table.getHeaderRows(); int endrow = startrow; // current page will contain header+startrow..endrow while (endrow < table.size()) { // figure out how many body rows fit nicely on the page float endpos = pos - calcHeaderHeight(table); while (endpos > (mbot + pbot) && endrow < table.size() ) { endpos -= table.getRowHeight(endrow); endrow++; } // adjust for orphan rows. Might create widows or make // endrow < startrow, which is handled later by deferring the table if (endrow < table.size() && endrow + minRowsTogether >= table.size()) { if (endrow + 1 == table.size()) { // short by 1 row.. just squeeze it in endrow = table.size(); } else { // more than 1 row remains: shorten this page so orphans aren't lonely endrow = table.size() - minRowsTogether; } } if (endrow == table.size() || endrow - startrow > minRowsTogether) { // this is the end of the table, or we have enough rows to bother printing pos = table.writeSelectedRows(0, table.getHeaderRows(), mlft, pos, cb); pos = table.writeSelectedRows(startrow, endrow, mlft, pos, cb); startrow = endrow; } else { // not the end of the table and not enough rows to print out endrow = startrow; } // new page if necessary (that is, when we aren't finished the table yet) if (endrow != table.size()) { document.newPage(); pos = pagesize.height() - mtop; } } } document.close(); }
int vcols = 18; float[] widths = new float[vcols];
float[] widths = new float[totalColumn];
public static void createPdf(OutputStream out, java.util.List<SQLTable> tables, ProfileManager pm) throws DocumentException, IOException, SQLException, ArchitectException, InstantiationException, IllegalAccessException { final int minRowsTogether = 5; // counts smaller than this are considered orphan/widow final int mtop = 50; // margin at top of page (in points) final int mbot = 50; // margin at bottom of page (page numbers are below this) final int pbot = 20; // padding between bottom margin and bottom of body text final int mlft = 50; // margin at left side of page final int mrgt = 50; // margin at right side of page final Rectangle pagesize = PageSize.LETTER.rotate(); final Document document = new Document(pagesize, mlft, mrgt, mtop, mbot); final PdfWriter writer = PdfWriter.getInstance(document, out); final float fsize = 12f; // the font size to use in the table body final BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, false); document.addTitle("Table Profiling Report"); document.addSubject("Tables: " + tables); document.addAuthor(System.getProperty("user.name")); document.addCreator("Power*Architect version "+ArchitectUtils.APP_VERSION); document.open(); // vertical position where next element should start // (bottom is 0; top is pagesize.height()) float pos = pagesize.height() - mtop; final PdfContentByte cb = writer.getDirectContent(); final PdfTemplate nptemplate = cb.createTemplate(50, 50); writer.setPageEvent(new PdfPageEventHelper() { // prints the "page N of <template>" footer public void onEndPage(PdfWriter writer, Document document) { int pageN = writer.getPageNumber(); String text = "Page " + pageN + " of "; float len = bf.getWidthPoint(text, fsize-2); cb.beginText(); cb.setFontAndSize(bf, fsize-2); cb.setTextMatrix(pagesize.width()/2 - len/2, mbot/2); cb.showText(text); cb.endText(); cb.addTemplate(nptemplate, pagesize.width()/2 - len/2 + len, mbot/2); } public void onCloseDocument(PdfWriter writer, Document document) { nptemplate.beginText(); nptemplate.setFontAndSize(bf, fsize-2); nptemplate.showText(String.valueOf(writer.getPageNumber() - 1)); nptemplate.endText(); } }); document.add(new Paragraph("Power*Architect Profiling Report")); document.add(new Paragraph("Generated "+new java.util.Date() +" by "+System.getProperty("user.name"))); int vcols = 18; float[] widths = new float[vcols]; // widths of widest cells per row in pdf table LinkedList<PdfPTable> profiles = new LinkedList<PdfPTable>(); // 1 table per profile result for (SQLTable t : tables) { ProfileResult tpr = pm.getResult(t); PdfPTable table = makeNextTable(pm,t, bf, fsize, widths); profiles.add(table); } // add the PdfPTables to the document; try to avoid orphan and widow rows pos = writer.getVerticalPosition(true) - fsize; logger.debug("Starting at pos="+pos); for (PdfPTable table : profiles) { table.setTotalWidth(pagesize.width() - mrgt - mlft); table.setWidths(widths); int startrow = table.getHeaderRows(); int endrow = startrow; // current page will contain header+startrow..endrow while (endrow < table.size()) { // figure out how many body rows fit nicely on the page float endpos = pos - calcHeaderHeight(table); while (endpos > (mbot + pbot) && endrow < table.size() ) { endpos -= table.getRowHeight(endrow); endrow++; } // adjust for orphan rows. Might create widows or make // endrow < startrow, which is handled later by deferring the table if (endrow < table.size() && endrow + minRowsTogether >= table.size()) { if (endrow + 1 == table.size()) { // short by 1 row.. just squeeze it in endrow = table.size(); } else { // more than 1 row remains: shorten this page so orphans aren't lonely endrow = table.size() - minRowsTogether; } } if (endrow == table.size() || endrow - startrow > minRowsTogether) { // this is the end of the table, or we have enough rows to bother printing pos = table.writeSelectedRows(0, table.getHeaderRows(), mlft, pos, cb); pos = table.writeSelectedRows(startrow, endrow, mlft, pos, cb); startrow = endrow; } else { // not the end of the table and not enough rows to print out endrow = startrow; } // new page if necessary (that is, when we aren't finished the table yet) if (endrow != table.size()) { document.newPage(); pos = pagesize.height() - mtop; } } } document.close(); }
ProfileResult tpr = pm.getResult(t);
public static void createPdf(OutputStream out, java.util.List<SQLTable> tables, ProfileManager pm) throws DocumentException, IOException, SQLException, ArchitectException, InstantiationException, IllegalAccessException { final int minRowsTogether = 5; // counts smaller than this are considered orphan/widow final int mtop = 50; // margin at top of page (in points) final int mbot = 50; // margin at bottom of page (page numbers are below this) final int pbot = 20; // padding between bottom margin and bottom of body text final int mlft = 50; // margin at left side of page final int mrgt = 50; // margin at right side of page final Rectangle pagesize = PageSize.LETTER.rotate(); final Document document = new Document(pagesize, mlft, mrgt, mtop, mbot); final PdfWriter writer = PdfWriter.getInstance(document, out); final float fsize = 12f; // the font size to use in the table body final BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, false); document.addTitle("Table Profiling Report"); document.addSubject("Tables: " + tables); document.addAuthor(System.getProperty("user.name")); document.addCreator("Power*Architect version "+ArchitectUtils.APP_VERSION); document.open(); // vertical position where next element should start // (bottom is 0; top is pagesize.height()) float pos = pagesize.height() - mtop; final PdfContentByte cb = writer.getDirectContent(); final PdfTemplate nptemplate = cb.createTemplate(50, 50); writer.setPageEvent(new PdfPageEventHelper() { // prints the "page N of <template>" footer public void onEndPage(PdfWriter writer, Document document) { int pageN = writer.getPageNumber(); String text = "Page " + pageN + " of "; float len = bf.getWidthPoint(text, fsize-2); cb.beginText(); cb.setFontAndSize(bf, fsize-2); cb.setTextMatrix(pagesize.width()/2 - len/2, mbot/2); cb.showText(text); cb.endText(); cb.addTemplate(nptemplate, pagesize.width()/2 - len/2 + len, mbot/2); } public void onCloseDocument(PdfWriter writer, Document document) { nptemplate.beginText(); nptemplate.setFontAndSize(bf, fsize-2); nptemplate.showText(String.valueOf(writer.getPageNumber() - 1)); nptemplate.endText(); } }); document.add(new Paragraph("Power*Architect Profiling Report")); document.add(new Paragraph("Generated "+new java.util.Date() +" by "+System.getProperty("user.name"))); int vcols = 18; float[] widths = new float[vcols]; // widths of widest cells per row in pdf table LinkedList<PdfPTable> profiles = new LinkedList<PdfPTable>(); // 1 table per profile result for (SQLTable t : tables) { ProfileResult tpr = pm.getResult(t); PdfPTable table = makeNextTable(pm,t, bf, fsize, widths); profiles.add(table); } // add the PdfPTables to the document; try to avoid orphan and widow rows pos = writer.getVerticalPosition(true) - fsize; logger.debug("Starting at pos="+pos); for (PdfPTable table : profiles) { table.setTotalWidth(pagesize.width() - mrgt - mlft); table.setWidths(widths); int startrow = table.getHeaderRows(); int endrow = startrow; // current page will contain header+startrow..endrow while (endrow < table.size()) { // figure out how many body rows fit nicely on the page float endpos = pos - calcHeaderHeight(table); while (endpos > (mbot + pbot) && endrow < table.size() ) { endpos -= table.getRowHeight(endrow); endrow++; } // adjust for orphan rows. Might create widows or make // endrow < startrow, which is handled later by deferring the table if (endrow < table.size() && endrow + minRowsTogether >= table.size()) { if (endrow + 1 == table.size()) { // short by 1 row.. just squeeze it in endrow = table.size(); } else { // more than 1 row remains: shorten this page so orphans aren't lonely endrow = table.size() - minRowsTogether; } } if (endrow == table.size() || endrow - startrow > minRowsTogether) { // this is the end of the table, or we have enough rows to bother printing pos = table.writeSelectedRows(0, table.getHeaderRows(), mlft, pos, cb); pos = table.writeSelectedRows(startrow, endrow, mlft, pos, cb); startrow = endrow; } else { // not the end of the table and not enough rows to print out endrow = startrow; } // new page if necessary (that is, when we aren't finished the table yet) if (endrow != table.size()) { document.newPage(); pos = pagesize.height() - mtop; } } } document.close(); }
public static void showExceptionDialogNoReport(Component parent,String string, Throwable ex) { displayExceptionDialog(parent, string, ex); }
public static void showExceptionDialogNoReport(String string, Throwable ex) { displayExceptionDialog(ArchitectFrame.getMainInstance(), string, ex); }
public static void showExceptionDialogNoReport(Component parent,String string, Throwable ex) { displayExceptionDialog(parent, string, ex); }
Set mbeans = connection.queryNames(monitorObjName); if(mbeans != null && mbeans.size() > 0){ connection.unregisterMBean(monitorObjName); }
public void register(AlertHandler handler, String alertId, String alertName){ assert this.handler == null; assert connection == null; this.handler = handler; /* start looking for this notification */ connection = ServerConnector.getServerConnection( sourceConfig.getApplicationConfig()); monitorObjName = new ObjectName("jmanage:name=" + alertName + ",id=" + alertId + ",type=GaugeMonitor"); /* create the MBean */ connection.createMBean("javax.management.monitor.GaugeMonitor", monitorObjName, null, null); /* set attributes */ List attributes = new LinkedList(); attributes.add(new ObjectAttribute("GranularityPeriod", new Long(5000))); attributes.add(new ObjectAttribute("NotifyHigh", Boolean.TRUE)); attributes.add(new ObjectAttribute("NotifyLow", Boolean.TRUE)); attributes.add(new ObjectAttribute("ObservedAttribute", sourceConfig.getAttributeName())); // note the following is deprecated, but this is what weblogic exposes attributes.add(new ObjectAttribute("ObservedObject", connection.buildObjectName(sourceConfig.getObjectName()))); connection.setAttributes(monitorObjName, attributes); /* add observed object */ /* connection.invoke(monitorObjName, "addObservedObject", new Object[]{new ObjectName(sourceConfig.getObjectName())}, new String[]{"javax.management.ObjectName"}); */ /* set thresholds */ Object[] params = new Object[]{sourceConfig.getHighThreshold(), sourceConfig.getLowThreshold()}; String[] signature = new String[]{Number.class.getName(), Number.class.getName()}; connection.invoke(monitorObjName, "setThresholds", params, signature); /* start the monitor */ connection.invoke(monitorObjName, "start", new Object[0], new String[0]); /* now look for notifications from this mbean */ listener = new ObjectNotificationListener(){ public void handleNotification(ObjectNotification notification, Object handback) { try { GaugeAlertSource.this.handler.handle( new AlertInfo(notification)); } catch (Exception e) { logger.log(Level.SEVERE, "Error while handling alert", e); } } }; filter = new ObjectNotificationFilterSupport(); filter.enableType("jmx.monitor.gauge.high"); filter.enableType("jmx.monitor.gauge.low"); filter.enableType("jmx.monitor.error.attribute"); filter.enableType("jmx.monitor.error.type"); filter.enableType("jmx.monitor.error.mbean"); filter.enableType("jmx.monitor.error.runtime"); filter.enableType("jmx.monitor.error.threshold"); connection.addNotificationListener(monitorObjName, listener, filter, null); }
connection.removeNotificationListener(monitorObjName, listener, filter, null);
try { connection.removeNotificationListener(monitorObjName, listener, filter, null); } catch (Exception e) { logger.log(Level.WARNING, "Error while Removing Notification Listener", e); }
public void unregister() { assert connection != null; assert monitorObjName != null; /* remove notification listener */ connection.removeNotificationListener(monitorObjName, listener, filter, null); /* unregister GaugeMonitor MBean */ connection.unregisterMBean(monitorObjName); /* close the connection */ try { connection.close(); } catch (IOException e) { logger.log(Level.SEVERE, "Error while closing connection", e); } connection = null; handler = null; listener = null; filter = null; }
connection.unregisterMBean(monitorObjName);
try { connection.unregisterMBean(monitorObjName); } catch (Exception e) { logger.log(Level.WARNING, "Error while unregistering MBean: " + monitorObjName, e); }
public void unregister() { assert connection != null; assert monitorObjName != null; /* remove notification listener */ connection.removeNotificationListener(monitorObjName, listener, filter, null); /* unregister GaugeMonitor MBean */ connection.unregisterMBean(monitorObjName); /* close the connection */ try { connection.close(); } catch (IOException e) { logger.log(Level.SEVERE, "Error while closing connection", e); } connection = null; handler = null; listener = null; filter = null; }
logger.info("Connected to " + appConfig.getURL());
getServerConnection(ApplicationConfig appConfig) throws ConnectionFailedException{ ModuleConfig moduleConfig = ModuleRegistry.getModule(appConfig.getType()); assert moduleConfig != null: "Invalid type=" + appConfig.getType(); final ClassLoader classLoader = moduleConfig.getClassLoader(); assert classLoader != null; final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); /* temporarily change the thread context classloader */ Thread.currentThread().setContextClassLoader(classLoader); try { final ServerConnectionFactory factory = getServerConnectionFactory(moduleConfig, classLoader); ServerConnection connection = factory.getServerConnection(appConfig); return new ServerConnectionProxy(connection, classLoader); } finally { /* change the thread context classloader back to the original classloader*/ Thread.currentThread().setContextClassLoader(contextClassLoader); } }
public AlertInfo(ObjectNotification notification){ setAlertId(notification.getType() + System.currentTimeMillis()); setType(notification.getType()); setSequenceNumber(notification.getSequenceNumber()); setMessage(notification.getMessage()); setTimeStamp(notification.getTimeStamp()); setUserData(notification.getUserData()); setSource(notification.getMySource()); }
public AlertInfo(){}
public AlertInfo(ObjectNotification notification){ // todo: figure out a better way to generate unique alert ids setAlertId(notification.getType() + System.currentTimeMillis()); setType(notification.getType()); setSequenceNumber(notification.getSequenceNumber()); setMessage(notification.getMessage()); setTimeStamp(notification.getTimeStamp()); setUserData(notification.getUserData()); setSource(notification.getMySource()); }
public TextScript(String text) { this.text = text;
public TextScript() {
public TextScript(String text) { this.text = text; }
if (myRating%(-2) != 0){ myRating++;
myRating *= -1; if ((myRating & 1) != 0){
public Component getTableCellRendererComponent (JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component cell = super.getTableCellRendererComponent (table, value, isSelected, hasFocus, row, column); int myRating = ((CheckDataTableModel)table.getModel()).getRating(row); String thisColumnName = table.getColumnName(column); cell.setForeground(Color.black); //bitmasking to decode the status bits if (myRating < 0){ if (myRating%(-2) != 0){ myRating++; if(thisColumnName.equals("ObsHET")){ cell.setForeground(Color.red); } } if (myRating%(-4) != 0){ myRating += 2; if (thisColumnName.equals("%Geno")){ cell.setForeground(Color.red); } } if (myRating%(-8) != 0){ myRating += 4; if (thisColumnName.equals("HWpval")){ cell.setForeground(Color.red); } } if (myRating < -7 && thisColumnName.equals("MendErr")){ cell.setForeground(Color.red); } } return cell; }
if (myRating%(-4) != 0){ myRating += 2;
if ((myRating & 2) != 0){
public Component getTableCellRendererComponent (JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component cell = super.getTableCellRendererComponent (table, value, isSelected, hasFocus, row, column); int myRating = ((CheckDataTableModel)table.getModel()).getRating(row); String thisColumnName = table.getColumnName(column); cell.setForeground(Color.black); //bitmasking to decode the status bits if (myRating < 0){ if (myRating%(-2) != 0){ myRating++; if(thisColumnName.equals("ObsHET")){ cell.setForeground(Color.red); } } if (myRating%(-4) != 0){ myRating += 2; if (thisColumnName.equals("%Geno")){ cell.setForeground(Color.red); } } if (myRating%(-8) != 0){ myRating += 4; if (thisColumnName.equals("HWpval")){ cell.setForeground(Color.red); } } if (myRating < -7 && thisColumnName.equals("MendErr")){ cell.setForeground(Color.red); } } return cell; }
if (myRating%(-8) != 0){ myRating += 4;
if ((myRating & 4) != 0){
public Component getTableCellRendererComponent (JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component cell = super.getTableCellRendererComponent (table, value, isSelected, hasFocus, row, column); int myRating = ((CheckDataTableModel)table.getModel()).getRating(row); String thisColumnName = table.getColumnName(column); cell.setForeground(Color.black); //bitmasking to decode the status bits if (myRating < 0){ if (myRating%(-2) != 0){ myRating++; if(thisColumnName.equals("ObsHET")){ cell.setForeground(Color.red); } } if (myRating%(-4) != 0){ myRating += 2; if (thisColumnName.equals("%Geno")){ cell.setForeground(Color.red); } } if (myRating%(-8) != 0){ myRating += 4; if (thisColumnName.equals("HWpval")){ cell.setForeground(Color.red); } } if (myRating < -7 && thisColumnName.equals("MendErr")){ cell.setForeground(Color.red); } } return cell; }
if (myRating < -7 && thisColumnName.equals("MendErr")){ cell.setForeground(Color.red);
if ((myRating & 8) != 0){ if (thisColumnName.equals("MendErr")){ cell.setForeground(Color.red); }
public Component getTableCellRendererComponent (JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component cell = super.getTableCellRendererComponent (table, value, isSelected, hasFocus, row, column); int myRating = ((CheckDataTableModel)table.getModel()).getRating(row); String thisColumnName = table.getColumnName(column); cell.setForeground(Color.black); //bitmasking to decode the status bits if (myRating < 0){ if (myRating%(-2) != 0){ myRating++; if(thisColumnName.equals("ObsHET")){ cell.setForeground(Color.red); } } if (myRating%(-4) != 0){ myRating += 2; if (thisColumnName.equals("%Geno")){ cell.setForeground(Color.red); } } if (myRating%(-8) != 0){ myRating += 4; if (thisColumnName.equals("HWpval")){ cell.setForeground(Color.red); } } if (myRating < -7 && thisColumnName.equals("MendErr")){ cell.setForeground(Color.red); } } return cell; }
if ((myRating & 16) != 0){ if (thisColumnName.equals("MAF")){ cell.setForeground(Color.red); } }
public Component getTableCellRendererComponent (JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component cell = super.getTableCellRendererComponent (table, value, isSelected, hasFocus, row, column); int myRating = ((CheckDataTableModel)table.getModel()).getRating(row); String thisColumnName = table.getColumnName(column); cell.setForeground(Color.black); //bitmasking to decode the status bits if (myRating < 0){ if (myRating%(-2) != 0){ myRating++; if(thisColumnName.equals("ObsHET")){ cell.setForeground(Color.red); } } if (myRating%(-4) != 0){ myRating += 2; if (thisColumnName.equals("%Geno")){ cell.setForeground(Color.red); } } if (myRating%(-8) != 0){ myRating += 4; if (thisColumnName.equals("HWpval")){ cell.setForeground(Color.red); } } if (myRating < -7 && thisColumnName.equals("MendErr")){ cell.setForeground(Color.red); } } return cell; }
public CheckDataPanel(File file, int type) throws IOException, PedFileException{
public CheckDataPanel(PedFile pf) throws IOException, PedFileException{
public CheckDataPanel(File file, int type) throws IOException, PedFileException{ setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); //okay, for now we're going to assume the ped file has no header Vector pedFileStrings = new Vector(); BufferedReader reader = new BufferedReader(new FileReader(file)); String line; while((line = reader.readLine())!=null){ if (line.length() == 0){ //skip blank lines continue; } if (line.startsWith("#")){ //skip comments continue; } pedFileStrings.add(line); } pedfile = new PedFile(); if (type == 3){ pedfile.parseLinkage(pedFileStrings); }else{ pedfile.parseHapMap(pedFileStrings); } Vector result = pedfile.check(); int numResults = result.size(); Vector tableColumnNames = new Vector(); tableColumnNames.add("Name"); tableColumnNames.add("ObsHET"); tableColumnNames.add("PredHET"); tableColumnNames.add("HWpval"); tableColumnNames.add("%Geno"); tableColumnNames.add("FamTrio"); tableColumnNames.add("MendErr"); tableColumnNames.add("Rating"); Vector tableData = new Vector(); int[] ratingArray = new int[numResults]; for (int i = 0; i < numResults; i++){ Vector tempVect = new Vector(); MarkerResult currentResult = (MarkerResult)result.get(i); tempVect.add(currentResult.getName()); tempVect.add(new Double(currentResult.getObsHet())); tempVect.add(new Double(currentResult.getPredHet())); tempVect.add(new Double(currentResult.getHWpvalue())); tempVect.add(new Double(currentResult.getGenoPercent())); tempVect.add(new Integer(currentResult.getFamTrioNum())); tempVect.add(new Integer(currentResult.getMendErrNum())); if (currentResult.getRating() > 0){ tempVect.add(new Boolean(true)); }else{ tempVect.add(new Boolean(false)); } //this value is never displayed, just kept for bookkeeping ratingArray[i] = currentResult.getRating(); tableData.add(tempVect.clone()); } final CheckDataTableModel tableModel = new CheckDataTableModel(tableColumnNames, tableData, ratingArray); tableModel.addTableModelListener(this); table = new JTable(tableModel); final CheckDataCellRenderer renderer = new CheckDataCellRenderer(); try{ table.setDefaultRenderer(Class.forName("java.lang.Double"), renderer); table.setDefaultRenderer(Class.forName("java.lang.Integer"), renderer); }catch (Exception e){ } table.getColumnModel().getColumn(0).setPreferredWidth(100); JScrollPane tableScroller = new JScrollPane(table); add(tableScroller); }
Vector pedFileStrings = new Vector(); BufferedReader reader = new BufferedReader(new FileReader(file)); String line; while((line = reader.readLine())!=null){ if (line.length() == 0){ continue; } if (line.startsWith("#")){ continue; } pedFileStrings.add(line); } pedfile = new PedFile(); if (type == 3){ pedfile.parseLinkage(pedFileStrings); }else{ pedfile.parseHapMap(pedFileStrings); }
pedfile = pf;
public CheckDataPanel(File file, int type) throws IOException, PedFileException{ setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); //okay, for now we're going to assume the ped file has no header Vector pedFileStrings = new Vector(); BufferedReader reader = new BufferedReader(new FileReader(file)); String line; while((line = reader.readLine())!=null){ if (line.length() == 0){ //skip blank lines continue; } if (line.startsWith("#")){ //skip comments continue; } pedFileStrings.add(line); } pedfile = new PedFile(); if (type == 3){ pedfile.parseLinkage(pedFileStrings); }else{ pedfile.parseHapMap(pedFileStrings); } Vector result = pedfile.check(); int numResults = result.size(); Vector tableColumnNames = new Vector(); tableColumnNames.add("Name"); tableColumnNames.add("ObsHET"); tableColumnNames.add("PredHET"); tableColumnNames.add("HWpval"); tableColumnNames.add("%Geno"); tableColumnNames.add("FamTrio"); tableColumnNames.add("MendErr"); tableColumnNames.add("Rating"); Vector tableData = new Vector(); int[] ratingArray = new int[numResults]; for (int i = 0; i < numResults; i++){ Vector tempVect = new Vector(); MarkerResult currentResult = (MarkerResult)result.get(i); tempVect.add(currentResult.getName()); tempVect.add(new Double(currentResult.getObsHet())); tempVect.add(new Double(currentResult.getPredHet())); tempVect.add(new Double(currentResult.getHWpvalue())); tempVect.add(new Double(currentResult.getGenoPercent())); tempVect.add(new Integer(currentResult.getFamTrioNum())); tempVect.add(new Integer(currentResult.getMendErrNum())); if (currentResult.getRating() > 0){ tempVect.add(new Boolean(true)); }else{ tempVect.add(new Boolean(false)); } //this value is never displayed, just kept for bookkeeping ratingArray[i] = currentResult.getRating(); tableData.add(tempVect.clone()); } final CheckDataTableModel tableModel = new CheckDataTableModel(tableColumnNames, tableData, ratingArray); tableModel.addTableModelListener(this); table = new JTable(tableModel); final CheckDataCellRenderer renderer = new CheckDataCellRenderer(); try{ table.setDefaultRenderer(Class.forName("java.lang.Double"), renderer); table.setDefaultRenderer(Class.forName("java.lang.Integer"), renderer); }catch (Exception e){ } table.getColumnModel().getColumn(0).setPreferredWidth(100); JScrollPane tableScroller = new JScrollPane(table); add(tableScroller); }
int[] ratingArray = new int[numResults];
int[] markerRatings = new int[numResults];
public CheckDataPanel(File file, int type) throws IOException, PedFileException{ setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); //okay, for now we're going to assume the ped file has no header Vector pedFileStrings = new Vector(); BufferedReader reader = new BufferedReader(new FileReader(file)); String line; while((line = reader.readLine())!=null){ if (line.length() == 0){ //skip blank lines continue; } if (line.startsWith("#")){ //skip comments continue; } pedFileStrings.add(line); } pedfile = new PedFile(); if (type == 3){ pedfile.parseLinkage(pedFileStrings); }else{ pedfile.parseHapMap(pedFileStrings); } Vector result = pedfile.check(); int numResults = result.size(); Vector tableColumnNames = new Vector(); tableColumnNames.add("Name"); tableColumnNames.add("ObsHET"); tableColumnNames.add("PredHET"); tableColumnNames.add("HWpval"); tableColumnNames.add("%Geno"); tableColumnNames.add("FamTrio"); tableColumnNames.add("MendErr"); tableColumnNames.add("Rating"); Vector tableData = new Vector(); int[] ratingArray = new int[numResults]; for (int i = 0; i < numResults; i++){ Vector tempVect = new Vector(); MarkerResult currentResult = (MarkerResult)result.get(i); tempVect.add(currentResult.getName()); tempVect.add(new Double(currentResult.getObsHet())); tempVect.add(new Double(currentResult.getPredHet())); tempVect.add(new Double(currentResult.getHWpvalue())); tempVect.add(new Double(currentResult.getGenoPercent())); tempVect.add(new Integer(currentResult.getFamTrioNum())); tempVect.add(new Integer(currentResult.getMendErrNum())); if (currentResult.getRating() > 0){ tempVect.add(new Boolean(true)); }else{ tempVect.add(new Boolean(false)); } //this value is never displayed, just kept for bookkeeping ratingArray[i] = currentResult.getRating(); tableData.add(tempVect.clone()); } final CheckDataTableModel tableModel = new CheckDataTableModel(tableColumnNames, tableData, ratingArray); tableModel.addTableModelListener(this); table = new JTable(tableModel); final CheckDataCellRenderer renderer = new CheckDataCellRenderer(); try{ table.setDefaultRenderer(Class.forName("java.lang.Double"), renderer); table.setDefaultRenderer(Class.forName("java.lang.Integer"), renderer); }catch (Exception e){ } table.getColumnModel().getColumn(0).setPreferredWidth(100); JScrollPane tableScroller = new JScrollPane(table); add(tableScroller); }
ratingArray[i] = currentResult.getRating();
markerRatings[i] = currentResult.getRating();
public CheckDataPanel(File file, int type) throws IOException, PedFileException{ setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); //okay, for now we're going to assume the ped file has no header Vector pedFileStrings = new Vector(); BufferedReader reader = new BufferedReader(new FileReader(file)); String line; while((line = reader.readLine())!=null){ if (line.length() == 0){ //skip blank lines continue; } if (line.startsWith("#")){ //skip comments continue; } pedFileStrings.add(line); } pedfile = new PedFile(); if (type == 3){ pedfile.parseLinkage(pedFileStrings); }else{ pedfile.parseHapMap(pedFileStrings); } Vector result = pedfile.check(); int numResults = result.size(); Vector tableColumnNames = new Vector(); tableColumnNames.add("Name"); tableColumnNames.add("ObsHET"); tableColumnNames.add("PredHET"); tableColumnNames.add("HWpval"); tableColumnNames.add("%Geno"); tableColumnNames.add("FamTrio"); tableColumnNames.add("MendErr"); tableColumnNames.add("Rating"); Vector tableData = new Vector(); int[] ratingArray = new int[numResults]; for (int i = 0; i < numResults; i++){ Vector tempVect = new Vector(); MarkerResult currentResult = (MarkerResult)result.get(i); tempVect.add(currentResult.getName()); tempVect.add(new Double(currentResult.getObsHet())); tempVect.add(new Double(currentResult.getPredHet())); tempVect.add(new Double(currentResult.getHWpvalue())); tempVect.add(new Double(currentResult.getGenoPercent())); tempVect.add(new Integer(currentResult.getFamTrioNum())); tempVect.add(new Integer(currentResult.getMendErrNum())); if (currentResult.getRating() > 0){ tempVect.add(new Boolean(true)); }else{ tempVect.add(new Boolean(false)); } //this value is never displayed, just kept for bookkeeping ratingArray[i] = currentResult.getRating(); tableData.add(tempVect.clone()); } final CheckDataTableModel tableModel = new CheckDataTableModel(tableColumnNames, tableData, ratingArray); tableModel.addTableModelListener(this); table = new JTable(tableModel); final CheckDataCellRenderer renderer = new CheckDataCellRenderer(); try{ table.setDefaultRenderer(Class.forName("java.lang.Double"), renderer); table.setDefaultRenderer(Class.forName("java.lang.Integer"), renderer); }catch (Exception e){ } table.getColumnModel().getColumn(0).setPreferredWidth(100); JScrollPane tableScroller = new JScrollPane(table); add(tableScroller); }
final CheckDataTableModel tableModel = new CheckDataTableModel(tableColumnNames, tableData, ratingArray);
final CheckDataTableModel tableModel = new CheckDataTableModel(tableColumnNames, tableData, markerRatings);
public CheckDataPanel(File file, int type) throws IOException, PedFileException{ setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); //okay, for now we're going to assume the ped file has no header Vector pedFileStrings = new Vector(); BufferedReader reader = new BufferedReader(new FileReader(file)); String line; while((line = reader.readLine())!=null){ if (line.length() == 0){ //skip blank lines continue; } if (line.startsWith("#")){ //skip comments continue; } pedFileStrings.add(line); } pedfile = new PedFile(); if (type == 3){ pedfile.parseLinkage(pedFileStrings); }else{ pedfile.parseHapMap(pedFileStrings); } Vector result = pedfile.check(); int numResults = result.size(); Vector tableColumnNames = new Vector(); tableColumnNames.add("Name"); tableColumnNames.add("ObsHET"); tableColumnNames.add("PredHET"); tableColumnNames.add("HWpval"); tableColumnNames.add("%Geno"); tableColumnNames.add("FamTrio"); tableColumnNames.add("MendErr"); tableColumnNames.add("Rating"); Vector tableData = new Vector(); int[] ratingArray = new int[numResults]; for (int i = 0; i < numResults; i++){ Vector tempVect = new Vector(); MarkerResult currentResult = (MarkerResult)result.get(i); tempVect.add(currentResult.getName()); tempVect.add(new Double(currentResult.getObsHet())); tempVect.add(new Double(currentResult.getPredHet())); tempVect.add(new Double(currentResult.getHWpvalue())); tempVect.add(new Double(currentResult.getGenoPercent())); tempVect.add(new Integer(currentResult.getFamTrioNum())); tempVect.add(new Integer(currentResult.getMendErrNum())); if (currentResult.getRating() > 0){ tempVect.add(new Boolean(true)); }else{ tempVect.add(new Boolean(false)); } //this value is never displayed, just kept for bookkeeping ratingArray[i] = currentResult.getRating(); tableData.add(tempVect.clone()); } final CheckDataTableModel tableModel = new CheckDataTableModel(tableColumnNames, tableData, ratingArray); tableModel.addTableModelListener(this); table = new JTable(tableModel); final CheckDataCellRenderer renderer = new CheckDataCellRenderer(); try{ table.setDefaultRenderer(Class.forName("java.lang.Double"), renderer); table.setDefaultRenderer(Class.forName("java.lang.Integer"), renderer); }catch (Exception e){ } table.getColumnModel().getColumn(0).setPreferredWidth(100); JScrollPane tableScroller = new JScrollPane(table); add(tableScroller); }
table.setValueAt(new Boolean(true),i,7);
table.setValueAt(new Boolean(true),i,STATUS_COL);
public void redoRatings(){ try{ Vector result = pedfile.check(); for (int i = 0; i < table.getRowCount(); i++){ MarkerResult cur = (MarkerResult)result.get(i); int rating = cur.getRating(); if (rating > 0){ table.setValueAt(new Boolean(true),i,7); }else{ table.setValueAt(new Boolean(false),i,7); } } }catch (PedFileException pfe){ } }
table.setValueAt(new Boolean(false),i,7);
table.setValueAt(new Boolean(false),i,STATUS_COL);
public void redoRatings(){ try{ Vector result = pedfile.check(); for (int i = 0; i < table.getRowCount(); i++){ MarkerResult cur = (MarkerResult)result.get(i); int rating = cur.getRating(); if (rating > 0){ table.setValueAt(new Boolean(true),i,7); }else{ table.setValueAt(new Boolean(false),i,7); } } }catch (PedFileException pfe){ } }
}catch (PedFileException pfe){
((CheckDataTableModel)table.getModel()).ratings = ratings; table.repaint(); }catch (Exception e){ e.printStackTrace();
public void redoRatings(){ try{ Vector result = pedfile.check(); for (int i = 0; i < table.getRowCount(); i++){ MarkerResult cur = (MarkerResult)result.get(i); int rating = cur.getRating(); if (rating > 0){ table.setValueAt(new Boolean(true),i,7); }else{ table.setValueAt(new Boolean(false),i,7); } } }catch (PedFileException pfe){ } }
table.setValueAt(new Boolean(true), i, 7);
table.setValueAt(new Boolean(true), i, STATUS_COL);
public void selectAll(){ for (int i = 0; i < table.getRowCount(); i++){ table.setValueAt(new Boolean(true), i, 7); } }
if (e.getColumn() == 7){
if (e.getColumn() == STATUS_COL){
public void tableChanged(TableModelEvent e) { if (e.getColumn() == 7){ changed = true; } }
if (! xpath.evaluateAsBoolean(context)) {
Object xpathContext = getXPathContext(); if (! xpath.booleanValueOf(xpathContext)) {
public void doTag(XMLOutput output) throws Exception { if (test == null && xpath == null) { throw new MissingAttributeException( "test" ); } if (test != null) { if (! test.evaluateAsBoolean(context)) { fail( getBodyText(), "evaluating test: "+ test ); } } else { if (! xpath.evaluateAsBoolean(context)) { fail( getBodyText(), "evaluating xpath: "+ xpath ); } } }
public void setXpath(Expression xpath) {
public void setXpath(XPath xpath) {
public void setXpath(Expression xpath) { this.xpath = xpath; }
public boolean evaluateAsBoolean(Context context);
public boolean evaluateAsBoolean(JellyContext context);
public boolean evaluateAsBoolean(Context context);
JComponent[] fields = new JComponent[] {dbNameField,
JComponent[] fields = new JComponent[] {historyBox, dbNameField,
public DBCSPanel() { setLayout(new BorderLayout()); dbDriverField = new JComboBox(getDriverClasses()); dbDriverField.insertItemAt("", 0); dbNameField = new JTextField(); JComponent[] fields = new JComponent[] {dbNameField, dbDriverField, dbUrlField = new JTextField(), dbUserField = new JTextField(), dbPassField = new JPasswordField()}; String[] labels = new String[] {"Connection Name", "JDBC Driver", "JDBC URL", "Username", "Password"}; char[] mnemonics = new char[] {'n', 'd', 'u', 'r', 'p'}; int[] widths = new int[] {30, 30, 40, 20, 20}; String[] tips = new String[] {"The name of this database", "The class name of the JDBC Driver", "Vendor-specific JDBC URL", "Username for this database", "Password for this database"}; // update url field when user picks new driver dbDriverField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String t = getTemplateForDriver(dbDriverField.getSelectedItem().toString()); if (t == null) t = "jdbc:"; dbUrlField.setText(t); } }); form = new TextPanel(fields, labels, mnemonics, widths, tips); add(form, BorderLayout.CENTER); }
String[] labels = new String[] {"Connection Name",
String[] labels = new String[] {"History", "Connection Name",
public DBCSPanel() { setLayout(new BorderLayout()); dbDriverField = new JComboBox(getDriverClasses()); dbDriverField.insertItemAt("", 0); dbNameField = new JTextField(); JComponent[] fields = new JComponent[] {dbNameField, dbDriverField, dbUrlField = new JTextField(), dbUserField = new JTextField(), dbPassField = new JPasswordField()}; String[] labels = new String[] {"Connection Name", "JDBC Driver", "JDBC URL", "Username", "Password"}; char[] mnemonics = new char[] {'n', 'd', 'u', 'r', 'p'}; int[] widths = new int[] {30, 30, 40, 20, 20}; String[] tips = new String[] {"The name of this database", "The class name of the JDBC Driver", "Vendor-specific JDBC URL", "Username for this database", "Password for this database"}; // update url field when user picks new driver dbDriverField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String t = getTemplateForDriver(dbDriverField.getSelectedItem().toString()); if (t == null) t = "jdbc:"; dbUrlField.setText(t); } }); form = new TextPanel(fields, labels, mnemonics, widths, tips); add(form, BorderLayout.CENTER); }
char[] mnemonics = new char[] {'n', 'd', 'u', 'r', 'p'}; int[] widths = new int[] {30, 30, 40, 20, 20}; String[] tips = new String[] {"The name of this database", "The class name of the JDBC Driver", "Vendor-specific JDBC URL", "Username for this database", "Password for this database"};
char[] mnemonics = new char[] {'h', 'n', 'd', 'u', 'r', 'p'}; int[] widths = new int[] {30, 30, 30, 40, 20, 20}; String[] tips = new String[] {"A list of connections you have made in the past", "The name of this database", "The class name of the JDBC Driver", "Vendor-specific JDBC URL", "Username for this database", "Password for this database"};
public DBCSPanel() { setLayout(new BorderLayout()); dbDriverField = new JComboBox(getDriverClasses()); dbDriverField.insertItemAt("", 0); dbNameField = new JTextField(); JComponent[] fields = new JComponent[] {dbNameField, dbDriverField, dbUrlField = new JTextField(), dbUserField = new JTextField(), dbPassField = new JPasswordField()}; String[] labels = new String[] {"Connection Name", "JDBC Driver", "JDBC URL", "Username", "Password"}; char[] mnemonics = new char[] {'n', 'd', 'u', 'r', 'p'}; int[] widths = new int[] {30, 30, 40, 20, 20}; String[] tips = new String[] {"The name of this database", "The class name of the JDBC Driver", "Vendor-specific JDBC URL", "Username for this database", "Password for this database"}; // update url field when user picks new driver dbDriverField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String t = getTemplateForDriver(dbDriverField.getSelectedItem().toString()); if (t == null) t = "jdbc:"; dbUrlField.setText(t); } }); form = new TextPanel(fields, labels, mnemonics, widths, tips); add(form, BorderLayout.CENTER); }
if (historyBox.getSelectedIndex() == 0) { ArchitectFrame.getMainInstance().getUserSettings().getConnections().add(dbcs); history.add(ASUtils.lvb(name, dbcs)); }
public void applyChanges() { String name = dbNameField.getText(); dbcs.setName(name); dbcs.setDisplayName(name); dbcs.setDriverClass(dbDriverField.getSelectedItem().toString()); dbcs.setUrl(dbUrlField.getText()); dbcs.setUser(dbUserField.getText()); dbcs.setPass(new String(dbPassField.getPassword())); // completely defeats the purpose for JPasswordField.getText() being deprecated, but we're saving passwords to the config file so it hardly matters. }
historyBox.setSelectedIndex(findHistoryConnection(dbcs));
public void setDbcs(DBConnectionSpec dbcs) { dbNameField.setText(dbcs.getName()); dbDriverField.removeItemAt(0); if (dbcs.getDriverClass() != null) { dbDriverField.insertItemAt(dbcs.getDriverClass(), 0); } else { dbDriverField.insertItemAt("", 0); } dbDriverField.setSelectedIndex(0); dbUrlField.setText(dbcs.getUrl()); dbUserField.setText(dbcs.getUser()); dbPassField.setText(dbcs.getPass()); this.dbcs = dbcs; }
if ( log.isDebugEnabled() ) { log.debug( "About to evaluate stylesheet on source: " + source ); }
public void doTag(XMLOutput output) throws Exception { // for use by inner classes this.output = output; try { // run the body to add the rules getBody().run(context, output); stylesheet.setModeName( getMode() ); stylesheet.run( source ); } finally { // help the GC this.output = null; stylesheet.clear(); } }
two_n[0]=1; for (i=1; i<31; i++) two_n[i]=2*two_n[i-1];
public void full_em_breakup( byte[][] input_haplos, int max_missing, int[] num_haplos_present, Vector haplos_present, Vector haplo_freq, int[] block_size, int dump_phased_haplos) throws HaploViewException{ int i, j, k, num_poss, iter;//, maxk, numk; double total;//, maxprob; int block, start_locus, end_locus, biggest_block_size; int poss_full;//, best, h1, h2; int num_indivs=0; int num_blocks = block_size.length; int num_haplos = input_haplos.length; int num_loci = input_haplos[0].length; if (num_loci > MAXLOCI){ throw new HaploViewException("Too many loci in a single block (> 100)"); } biggest_block_size=block_size[0]; for (i=1; i<num_blocks; i++) { if (block_size[i] > biggest_block_size) biggest_block_size=block_size[i]; } two_n[0]=1; for (i=1; i<31; i++) two_n[i]=2*two_n[i-1]; num_poss = two_n[biggest_block_size]; data = new OBS[num_haplos/2]; //todo: this is in a bad way. doesn't always allocate enough mem, but if you bump it up, slows everything down for (i=0; i<num_haplos/2; i++) data[i]= new OBS(num_poss*two_n[max_missing]); superdata = new SUPER_OBS[num_haplos/2]; for (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]; prob = new double[num_poss]; end_locus=-1; 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]]; num_indivs=read_observations(num_haplos,num_loci,input_haplos,start_locus,end_locus); /* start prob array with probabilities from full observations */ for (j=0; j<num_poss; j++) { prob[j]=PSEUDOCOUNT; } total=(double)num_poss; total *= PSEUDOCOUNT; /* starting prob is phase known haps + 0.1 (PSEUDOCOUNT) count of every haplotype - i.e., flat when nothing is known, close to phase known if a great deal is known */ for (i=0; i<num_indivs; i++) { if (data[i].nposs==1) { prob[data[i].poss[0].h1]+=1.0; prob[data[i].poss[0].h2]+=1.0; total+=2.0; } } /* normalize */ for (j=0; j<num_poss; j++) { prob[j] /= total; } /* EM LOOP: assign ambiguous data based on p, then re-estimate p */ iter=0; while (iter<20) { /* compute probabilities of each possible observation */ for (i=0; i<num_indivs; i++) { total=0.0; for (k=0; k<data[i].nposs; k++) { data[i].poss[k].p = (float)(prob[data[i].poss[k].h1]*prob[data[i].poss[k].h2]); total+=data[i].poss[k].p; } /* normalize */ for (k=0; k<data[i].nposs; k++) { data[i].poss[k].p /= total; } } /* re-estimate prob */ for (j=0; j<num_poss; j++) { prob[j]=1e-10; } total=num_poss*1e-10; for (i=0; i<num_indivs; i++) { for (k=0; k<data[i].nposs; k++) { prob[data[i].poss[k].h1]+=data[i].poss[k].p; prob[data[i].poss[k].h2]+=data[i].poss[k].p; total+=(2.0*data[i].poss[k].p); } } /* normalize */ for (j=0; j<num_poss; j++) { prob[j] /= total; } iter++; } /* printf("FINAL PROBABILITIES:\n"); */ k=0; for (j=0; j<num_poss; j++) { hint[j]=-1; if (prob[j] > .001) { /* printf("haplo %s p = %.4lf\n",haplo_str(j,block_size[block]),prob[j]); */ hlist[block][k]=j; hprob[block][k]=prob[j]; hint[j]=k; k++; } } num_hlist[block]=k; /* store current block results in super obs structure */ store_block_haplos(hlist, hprob, hint, block, num_indivs); } /* for each block */ poss_full=1; for (block=0; block<num_blocks; block++) { poss_full *= num_hlist[block]; } //TODO:System.out.println(poss_full); /* LIGATE and finish this mess :) *//* if (poss_full > 1000000) { /* what we really need to do is go through and pare back to using a smaller number (e.g., > .002, .005) //printf("too many possibilities: %d\n",poss_full); return(-5); }*/ double[] superprob = new double[poss_full]; create_super_haplos(num_indivs,num_blocks,num_hlist); /* run standard EM on supercombos */ /* start prob array with probabilities from full observations */ for (j=0; j<poss_full; j++) { superprob[j]=PSEUDOCOUNT; } total=(double)poss_full; total *= PSEUDOCOUNT; /* starting prob is phase known haps + 0.1 (PSEUDOCOUNT) count of every haplotype - i.e., flat when nothing is known, close to phase known if a great deal is known */ for (i=0; i<num_indivs; i++) { if (superdata[i].nsuper==1) { //TODO: somehow fix this so that it doesn't break with weird trio hh00 stuff... maybe not fix here. SUPER_OBS foo = superdata[i]; int bar = foo.superposs[0].h1; //System.out.println("i= " + i); superprob[bar] += 1.0; //superprob[superdata[i].superposs[0].h1]+=1.0; superprob[superdata[i].superposs[0].h2]+=1.0; total+=2.0; } } /* normalize */ for (j=0; j<poss_full; j++) { superprob[j] /= total; } /* EM LOOP: assign ambiguous data based on p, then re-estimate p */ iter=0; while (iter<20) { /* compute probabilities of each possible observation */ for (i=0; i<num_indivs; i++) { total=0.0; for (k=0; k<superdata[i].nsuper; k++) { superdata[i].superposs[k].p = (float) (superprob[superdata[i].superposs[k].h1]* superprob[superdata[i].superposs[k].h2]); total+=superdata[i].superposs[k].p; } /* normalize */ for (k=0; k<superdata[i].nsuper; k++) { superdata[i].superposs[k].p /= total; } } /* re-estimate prob */ for (j=0; j<poss_full; j++) { superprob[j]=1e-10; } total=poss_full*1e-10; for (i=0; i<num_indivs; i++) { for (k=0; k<superdata[i].nsuper; k++) { superprob[superdata[i].superposs[k].h1]+=superdata[i].superposs[k].p; superprob[superdata[i].superposs[k].h2]+=superdata[i].superposs[k].p; total+=(2.0*superdata[i].superposs[k].p); } } /* normalize */ for (j=0; j<poss_full; j++) { superprob[j] /= total; } iter++; } /* we're done - the indices of superprob now have to be decoded to reveal the actual haplotypes they represent */ k=0; for (j=0; j<poss_full; j++) { if (superprob[j] > .001) { haplos_present.addElement(decode_haplo_str(j,num_blocks,block_size,hlist,num_hlist)); //sprintf(haplos_present[k],"%s",decode_haplo_str(j,num_blocks,block_size,hlist,num_hlist)); haplo_freq.addElement(String.valueOf(superprob[j])); k++; } } num_haplos_present[0]=k; /* 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; }
SUPER_OBS foo = superdata[i]; int bar = foo.superposs[0].h1; superprob[bar] += 1.0;
superprob[superdata[i].superposs[0].h1]+=1.0;
public void full_em_breakup( byte[][] input_haplos, int max_missing, int[] num_haplos_present, Vector haplos_present, Vector haplo_freq, int[] block_size, int dump_phased_haplos) throws HaploViewException{ int i, j, k, num_poss, iter;//, maxk, numk; double total;//, maxprob; int block, start_locus, end_locus, biggest_block_size; int poss_full;//, best, h1, h2; int num_indivs=0; int num_blocks = block_size.length; int num_haplos = input_haplos.length; int num_loci = input_haplos[0].length; if (num_loci > MAXLOCI){ throw new HaploViewException("Too many loci in a single block (> 100)"); } biggest_block_size=block_size[0]; for (i=1; i<num_blocks; i++) { if (block_size[i] > biggest_block_size) biggest_block_size=block_size[i]; } two_n[0]=1; for (i=1; i<31; i++) two_n[i]=2*two_n[i-1]; num_poss = two_n[biggest_block_size]; data = new OBS[num_haplos/2]; //todo: this is in a bad way. doesn't always allocate enough mem, but if you bump it up, slows everything down for (i=0; i<num_haplos/2; i++) data[i]= new OBS(num_poss*two_n[max_missing]); superdata = new SUPER_OBS[num_haplos/2]; for (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]; prob = new double[num_poss]; end_locus=-1; 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]]; num_indivs=read_observations(num_haplos,num_loci,input_haplos,start_locus,end_locus); /* start prob array with probabilities from full observations */ for (j=0; j<num_poss; j++) { prob[j]=PSEUDOCOUNT; } total=(double)num_poss; total *= PSEUDOCOUNT; /* starting prob is phase known haps + 0.1 (PSEUDOCOUNT) count of every haplotype - i.e., flat when nothing is known, close to phase known if a great deal is known */ for (i=0; i<num_indivs; i++) { if (data[i].nposs==1) { prob[data[i].poss[0].h1]+=1.0; prob[data[i].poss[0].h2]+=1.0; total+=2.0; } } /* normalize */ for (j=0; j<num_poss; j++) { prob[j] /= total; } /* EM LOOP: assign ambiguous data based on p, then re-estimate p */ iter=0; while (iter<20) { /* compute probabilities of each possible observation */ for (i=0; i<num_indivs; i++) { total=0.0; for (k=0; k<data[i].nposs; k++) { data[i].poss[k].p = (float)(prob[data[i].poss[k].h1]*prob[data[i].poss[k].h2]); total+=data[i].poss[k].p; } /* normalize */ for (k=0; k<data[i].nposs; k++) { data[i].poss[k].p /= total; } } /* re-estimate prob */ for (j=0; j<num_poss; j++) { prob[j]=1e-10; } total=num_poss*1e-10; for (i=0; i<num_indivs; i++) { for (k=0; k<data[i].nposs; k++) { prob[data[i].poss[k].h1]+=data[i].poss[k].p; prob[data[i].poss[k].h2]+=data[i].poss[k].p; total+=(2.0*data[i].poss[k].p); } } /* normalize */ for (j=0; j<num_poss; j++) { prob[j] /= total; } iter++; } /* printf("FINAL PROBABILITIES:\n"); */ k=0; for (j=0; j<num_poss; j++) { hint[j]=-1; if (prob[j] > .001) { /* printf("haplo %s p = %.4lf\n",haplo_str(j,block_size[block]),prob[j]); */ hlist[block][k]=j; hprob[block][k]=prob[j]; hint[j]=k; k++; } } num_hlist[block]=k; /* store current block results in super obs structure */ store_block_haplos(hlist, hprob, hint, block, num_indivs); } /* for each block */ poss_full=1; for (block=0; block<num_blocks; block++) { poss_full *= num_hlist[block]; } //TODO:System.out.println(poss_full); /* LIGATE and finish this mess :) *//* if (poss_full > 1000000) { /* what we really need to do is go through and pare back to using a smaller number (e.g., > .002, .005) //printf("too many possibilities: %d\n",poss_full); return(-5); }*/ double[] superprob = new double[poss_full]; create_super_haplos(num_indivs,num_blocks,num_hlist); /* run standard EM on supercombos */ /* start prob array with probabilities from full observations */ for (j=0; j<poss_full; j++) { superprob[j]=PSEUDOCOUNT; } total=(double)poss_full; total *= PSEUDOCOUNT; /* starting prob is phase known haps + 0.1 (PSEUDOCOUNT) count of every haplotype - i.e., flat when nothing is known, close to phase known if a great deal is known */ for (i=0; i<num_indivs; i++) { if (superdata[i].nsuper==1) { //TODO: somehow fix this so that it doesn't break with weird trio hh00 stuff... maybe not fix here. SUPER_OBS foo = superdata[i]; int bar = foo.superposs[0].h1; //System.out.println("i= " + i); superprob[bar] += 1.0; //superprob[superdata[i].superposs[0].h1]+=1.0; superprob[superdata[i].superposs[0].h2]+=1.0; total+=2.0; } } /* normalize */ for (j=0; j<poss_full; j++) { superprob[j] /= total; } /* EM LOOP: assign ambiguous data based on p, then re-estimate p */ iter=0; while (iter<20) { /* compute probabilities of each possible observation */ for (i=0; i<num_indivs; i++) { total=0.0; for (k=0; k<superdata[i].nsuper; k++) { superdata[i].superposs[k].p = (float) (superprob[superdata[i].superposs[k].h1]* superprob[superdata[i].superposs[k].h2]); total+=superdata[i].superposs[k].p; } /* normalize */ for (k=0; k<superdata[i].nsuper; k++) { superdata[i].superposs[k].p /= total; } } /* re-estimate prob */ for (j=0; j<poss_full; j++) { superprob[j]=1e-10; } total=poss_full*1e-10; for (i=0; i<num_indivs; i++) { for (k=0; k<superdata[i].nsuper; k++) { superprob[superdata[i].superposs[k].h1]+=superdata[i].superposs[k].p; superprob[superdata[i].superposs[k].h2]+=superdata[i].superposs[k].p; total+=(2.0*superdata[i].superposs[k].p); } } /* normalize */ for (j=0; j<poss_full; j++) { superprob[j] /= total; } iter++; } /* we're done - the indices of superprob now have to be decoded to reveal the actual haplotypes they represent */ k=0; for (j=0; j<poss_full; j++) { if (superprob[j] > .001) { haplos_present.addElement(decode_haplo_str(j,num_blocks,block_size,hlist,num_hlist)); //sprintf(haplos_present[k],"%s",decode_haplo_str(j,num_blocks,block_size,hlist,num_hlist)); haplo_freq.addElement(String.valueOf(superprob[j])); k++; } } num_haplos_present[0]=k; /* 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; }
float cutHighCI = 0.98f; float cutLowCI = 0.70f; float recHighCI = 0.90f;
double cutHighCI = 0.98; double cutLowCI = 0.70; double recHighCI = 0.90;
Vector doSFS(){ float cutHighCI = 0.98f; float cutLowCI = 0.70f; float recHighCI = 0.90f; int numStrong = 0; int numRec = 0; int numInGroup = 0; Vector blocks = new Vector(); Vector strongPairs = new Vector(); //first make a list of marker pairs in "strong LD", sorted by distance apart for (int x = 0; x < dPrime.length-1; x++){ for (int y = x+1; y < dPrime.length; y++){ StringTokenizer st = new StringTokenizer(dPrime[x][y]); //get the right bits from the string st.nextToken(); float lod = Float.parseFloat(st.nextToken()); st.nextToken(); float lowCI = Float.parseFloat(st.nextToken()); float highCI = Float.parseFloat(st.nextToken()); if (lod < -90) continue; //missing data if (highCI < cutHighCI || lowCI < cutLowCI) continue; //must pass "strong LD" test Vector addMe = new Vector(); //a vector of x, y, separation int sep = y - x - 1; //compute separation of two markers addMe.add(String.valueOf(x)); addMe.add(String.valueOf(y)); addMe.add(String.valueOf(sep)); if (strongPairs.size() == 0){ //put first pair first strongPairs.add(addMe); }else{ //sort by descending separation of markers in each pair for (int v = 0; v < strongPairs.size(); v ++){ if (sep >= Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(2))){ strongPairs.insertElementAt(addMe, v); break; } } } } } //now take this list of pairs with "strong LD" and construct blocks boolean[] usedInBlock = new boolean[dPrime.length + 1]; for (int v = 0; v < strongPairs.size(); v++){ int first = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(0)); int last = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(1)); //first see if this block overlaps with another: if (usedInBlock[first] || usedInBlock[last]) continue; //test this block. requires 95% of informative markers to be "strong" for (int y = first+1; y <= last; y++){ //loop over columns in row y for (int x = first; x < y; x++){ StringTokenizer st = new StringTokenizer(dPrime[x][y]); //get the right bits st.nextToken(); float lod = Float.parseFloat(st.nextToken()); st.nextToken(); float lowCI = Float.parseFloat(st.nextToken()); float highCI = Float.parseFloat(st.nextToken()); if (lod < -90) continue; //monomorphic marker error if (lod == 0 && lowCI == 0 && highCI == 0) continue; //skip bad markers if (lowCI > cutLowCI && highCI > cutHighCI) { //System.out.println(first + "\t" + last + "\t" + x + "\t" + y); numStrong++; //strong LD } if (highCI < recHighCI) numRec++; //recombination numInGroup ++; } } //change the definition somewhat for small blocks if (numInGroup > 3){ if (numStrong + numRec < 6) continue; }else if (numInGroup > 2){ if (numStrong + numRec < 3) continue; }else{ if (numStrong + numRec < 1) continue; } if (numStrong/(numStrong + numRec) > 0.95){ //this qualifies as a block //add to the block list, but in order by first marker number: if (blocks.size() == 0){ //put first block first blocks.add(first + " " + last); }else{ //sort by ascending separation of markers in each pair boolean placed = false; for (int b = 0; b < blocks.size(); b ++){ StringTokenizer st = new StringTokenizer((String)blocks.elementAt(b)); if (first < Integer.parseInt(st.nextToken())){ blocks.insertElementAt(first + " " + last, b); placed = true; break; } } //make sure to put in blocks which fall on the tail end if (!placed) blocks.add(first + " " + last); } for (int used = first; used <= last; used++){ usedInBlock[used] = true; } } numStrong = 0; numRec = 0; numInGroup = 0; } return stringVec2intVec(blocks); }
StringTokenizer st = new StringTokenizer(dPrime[x][y]);
PairwiseLinkage thisPair = dPrime[x][y];
Vector doSFS(){ float cutHighCI = 0.98f; float cutLowCI = 0.70f; float recHighCI = 0.90f; int numStrong = 0; int numRec = 0; int numInGroup = 0; Vector blocks = new Vector(); Vector strongPairs = new Vector(); //first make a list of marker pairs in "strong LD", sorted by distance apart for (int x = 0; x < dPrime.length-1; x++){ for (int y = x+1; y < dPrime.length; y++){ StringTokenizer st = new StringTokenizer(dPrime[x][y]); //get the right bits from the string st.nextToken(); float lod = Float.parseFloat(st.nextToken()); st.nextToken(); float lowCI = Float.parseFloat(st.nextToken()); float highCI = Float.parseFloat(st.nextToken()); if (lod < -90) continue; //missing data if (highCI < cutHighCI || lowCI < cutLowCI) continue; //must pass "strong LD" test Vector addMe = new Vector(); //a vector of x, y, separation int sep = y - x - 1; //compute separation of two markers addMe.add(String.valueOf(x)); addMe.add(String.valueOf(y)); addMe.add(String.valueOf(sep)); if (strongPairs.size() == 0){ //put first pair first strongPairs.add(addMe); }else{ //sort by descending separation of markers in each pair for (int v = 0; v < strongPairs.size(); v ++){ if (sep >= Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(2))){ strongPairs.insertElementAt(addMe, v); break; } } } } } //now take this list of pairs with "strong LD" and construct blocks boolean[] usedInBlock = new boolean[dPrime.length + 1]; for (int v = 0; v < strongPairs.size(); v++){ int first = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(0)); int last = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(1)); //first see if this block overlaps with another: if (usedInBlock[first] || usedInBlock[last]) continue; //test this block. requires 95% of informative markers to be "strong" for (int y = first+1; y <= last; y++){ //loop over columns in row y for (int x = first; x < y; x++){ StringTokenizer st = new StringTokenizer(dPrime[x][y]); //get the right bits st.nextToken(); float lod = Float.parseFloat(st.nextToken()); st.nextToken(); float lowCI = Float.parseFloat(st.nextToken()); float highCI = Float.parseFloat(st.nextToken()); if (lod < -90) continue; //monomorphic marker error if (lod == 0 && lowCI == 0 && highCI == 0) continue; //skip bad markers if (lowCI > cutLowCI && highCI > cutHighCI) { //System.out.println(first + "\t" + last + "\t" + x + "\t" + y); numStrong++; //strong LD } if (highCI < recHighCI) numRec++; //recombination numInGroup ++; } } //change the definition somewhat for small blocks if (numInGroup > 3){ if (numStrong + numRec < 6) continue; }else if (numInGroup > 2){ if (numStrong + numRec < 3) continue; }else{ if (numStrong + numRec < 1) continue; } if (numStrong/(numStrong + numRec) > 0.95){ //this qualifies as a block //add to the block list, but in order by first marker number: if (blocks.size() == 0){ //put first block first blocks.add(first + " " + last); }else{ //sort by ascending separation of markers in each pair boolean placed = false; for (int b = 0; b < blocks.size(); b ++){ StringTokenizer st = new StringTokenizer((String)blocks.elementAt(b)); if (first < Integer.parseInt(st.nextToken())){ blocks.insertElementAt(first + " " + last, b); placed = true; break; } } //make sure to put in blocks which fall on the tail end if (!placed) blocks.add(first + " " + last); } for (int used = first; used <= last; used++){ usedInBlock[used] = true; } } numStrong = 0; numRec = 0; numInGroup = 0; } return stringVec2intVec(blocks); }
st.nextToken(); float lod = Float.parseFloat(st.nextToken()); st.nextToken(); float lowCI = Float.parseFloat(st.nextToken()); float highCI = Float.parseFloat(st.nextToken());
double lod = thisPair.getLOD(); double lowCI = thisPair.getConfidenceLow(); double highCI = thisPair.getConfidenceHigh();
Vector doSFS(){ float cutHighCI = 0.98f; float cutLowCI = 0.70f; float recHighCI = 0.90f; int numStrong = 0; int numRec = 0; int numInGroup = 0; Vector blocks = new Vector(); Vector strongPairs = new Vector(); //first make a list of marker pairs in "strong LD", sorted by distance apart for (int x = 0; x < dPrime.length-1; x++){ for (int y = x+1; y < dPrime.length; y++){ StringTokenizer st = new StringTokenizer(dPrime[x][y]); //get the right bits from the string st.nextToken(); float lod = Float.parseFloat(st.nextToken()); st.nextToken(); float lowCI = Float.parseFloat(st.nextToken()); float highCI = Float.parseFloat(st.nextToken()); if (lod < -90) continue; //missing data if (highCI < cutHighCI || lowCI < cutLowCI) continue; //must pass "strong LD" test Vector addMe = new Vector(); //a vector of x, y, separation int sep = y - x - 1; //compute separation of two markers addMe.add(String.valueOf(x)); addMe.add(String.valueOf(y)); addMe.add(String.valueOf(sep)); if (strongPairs.size() == 0){ //put first pair first strongPairs.add(addMe); }else{ //sort by descending separation of markers in each pair for (int v = 0; v < strongPairs.size(); v ++){ if (sep >= Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(2))){ strongPairs.insertElementAt(addMe, v); break; } } } } } //now take this list of pairs with "strong LD" and construct blocks boolean[] usedInBlock = new boolean[dPrime.length + 1]; for (int v = 0; v < strongPairs.size(); v++){ int first = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(0)); int last = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(1)); //first see if this block overlaps with another: if (usedInBlock[first] || usedInBlock[last]) continue; //test this block. requires 95% of informative markers to be "strong" for (int y = first+1; y <= last; y++){ //loop over columns in row y for (int x = first; x < y; x++){ StringTokenizer st = new StringTokenizer(dPrime[x][y]); //get the right bits st.nextToken(); float lod = Float.parseFloat(st.nextToken()); st.nextToken(); float lowCI = Float.parseFloat(st.nextToken()); float highCI = Float.parseFloat(st.nextToken()); if (lod < -90) continue; //monomorphic marker error if (lod == 0 && lowCI == 0 && highCI == 0) continue; //skip bad markers if (lowCI > cutLowCI && highCI > cutHighCI) { //System.out.println(first + "\t" + last + "\t" + x + "\t" + y); numStrong++; //strong LD } if (highCI < recHighCI) numRec++; //recombination numInGroup ++; } } //change the definition somewhat for small blocks if (numInGroup > 3){ if (numStrong + numRec < 6) continue; }else if (numInGroup > 2){ if (numStrong + numRec < 3) continue; }else{ if (numStrong + numRec < 1) continue; } if (numStrong/(numStrong + numRec) > 0.95){ //this qualifies as a block //add to the block list, but in order by first marker number: if (blocks.size() == 0){ //put first block first blocks.add(first + " " + last); }else{ //sort by ascending separation of markers in each pair boolean placed = false; for (int b = 0; b < blocks.size(); b ++){ StringTokenizer st = new StringTokenizer((String)blocks.elementAt(b)); if (first < Integer.parseInt(st.nextToken())){ blocks.insertElementAt(first + " " + last, b); placed = true; break; } } //make sure to put in blocks which fall on the tail end if (!placed) blocks.add(first + " " + last); } for (int used = first; used <= last; used++){ usedInBlock[used] = true; } } numStrong = 0; numRec = 0; numInGroup = 0; } return stringVec2intVec(blocks); }
StringTokenizer st = new StringTokenizer(dPrime[i][j]);
PairwiseLinkage thisPair = dPrime[i][j];
Vector doMJD(){ // find blocks by searching for stretches between two markers A,B where // D prime is > 0.8 for all informative combinations of A, (A+1...B) int baddies; int verticalExtent=0; int horizontalExtent=0; Vector blocks = new Vector(); for (int i = 0; i < dPrime.length; i++){ baddies=0; //find how far LD from marker i extends for (int j = i+1; j < dPrime[i].length; j++){ StringTokenizer st = new StringTokenizer(dPrime[i][j]); //LD extends if D' > 0.8 if (Float.parseFloat(st.nextToken()) < 0.8){ //LD extends through one 'bad' marker if (baddies < 1){ baddies++; } else { verticalExtent = j-1; break; } } verticalExtent=j; } //now we need to find a stretch of LD of all markers between i and j //start with the longest possible block of LD and work backwards to find //one which is good for (int m = verticalExtent; m > i; m--){ for (int k = i; k < m; k++){ StringTokenizer st = new StringTokenizer(dPrime[k][m]); if(Float.parseFloat(st.nextToken()) < 0.8){ if (baddies < 1){ baddies++; } else { break; } } horizontalExtent=k+1; } //is this a block of LD? //previously, this algorithm was more complex and made some calls better //but caused major problems in others. since the guessing is somewhat //arbitrary, this new and simple method is fine. if(horizontalExtent == m){ blocks.add(i + " " + m); i=m; } } } return stringVec2intVec(blocks); }
if (Float.parseFloat(st.nextToken()) < 0.8){
if (thisPair.getDPrime() < 0.8){
Vector doMJD(){ // find blocks by searching for stretches between two markers A,B where // D prime is > 0.8 for all informative combinations of A, (A+1...B) int baddies; int verticalExtent=0; int horizontalExtent=0; Vector blocks = new Vector(); for (int i = 0; i < dPrime.length; i++){ baddies=0; //find how far LD from marker i extends for (int j = i+1; j < dPrime[i].length; j++){ StringTokenizer st = new StringTokenizer(dPrime[i][j]); //LD extends if D' > 0.8 if (Float.parseFloat(st.nextToken()) < 0.8){ //LD extends through one 'bad' marker if (baddies < 1){ baddies++; } else { verticalExtent = j-1; break; } } verticalExtent=j; } //now we need to find a stretch of LD of all markers between i and j //start with the longest possible block of LD and work backwards to find //one which is good for (int m = verticalExtent; m > i; m--){ for (int k = i; k < m; k++){ StringTokenizer st = new StringTokenizer(dPrime[k][m]); if(Float.parseFloat(st.nextToken()) < 0.8){ if (baddies < 1){ baddies++; } else { break; } } horizontalExtent=k+1; } //is this a block of LD? //previously, this algorithm was more complex and made some calls better //but caused major problems in others. since the guessing is somewhat //arbitrary, this new and simple method is fine. if(horizontalExtent == m){ blocks.add(i + " " + m); i=m; } } } return stringVec2intVec(blocks); }
StringTokenizer st = new StringTokenizer(dPrime[k][m]); if(Float.parseFloat(st.nextToken()) < 0.8){
PairwiseLinkage thisPair = dPrime[k][m]; if(thisPair.getDPrime() < 0.8){
Vector doMJD(){ // find blocks by searching for stretches between two markers A,B where // D prime is > 0.8 for all informative combinations of A, (A+1...B) int baddies; int verticalExtent=0; int horizontalExtent=0; Vector blocks = new Vector(); for (int i = 0; i < dPrime.length; i++){ baddies=0; //find how far LD from marker i extends for (int j = i+1; j < dPrime[i].length; j++){ StringTokenizer st = new StringTokenizer(dPrime[i][j]); //LD extends if D' > 0.8 if (Float.parseFloat(st.nextToken()) < 0.8){ //LD extends through one 'bad' marker if (baddies < 1){ baddies++; } else { verticalExtent = j-1; break; } } verticalExtent=j; } //now we need to find a stretch of LD of all markers between i and j //start with the longest possible block of LD and work backwards to find //one which is good for (int m = verticalExtent; m > i; m--){ for (int k = i; k < m; k++){ StringTokenizer st = new StringTokenizer(dPrime[k][m]); if(Float.parseFloat(st.nextToken()) < 0.8){ if (baddies < 1){ baddies++; } else { break; } } horizontalExtent=k+1; } //is this a block of LD? //previously, this algorithm was more complex and made some calls better //but caused major problems in others. since the guessing is somewhat //arbitrary, this new and simple method is fine. if(horizontalExtent == m){ blocks.add(i + " " + m); i=m; } } } return stringVec2intVec(blocks); }
Chromosome(String p, String i, byte[] g, boolean isTransmitted){
Chromosome(String p, String i, byte[] g, boolean a, String o){
Chromosome(String p, String i, byte[] g, boolean isTransmitted){ ped = p; individual = i; genotypes = g; origin = "unknown"; trueSize = genotypes.length; transmitted = isTransmitted; }
origin = "unknown";
affected = a; origin = o;
Chromosome(String p, String i, byte[] g, boolean isTransmitted){ ped = p; individual = i; genotypes = g; origin = "unknown"; trueSize = genotypes.length; transmitted = isTransmitted; }
transmitted = isTransmitted;
Chromosome(String p, String i, byte[] g, boolean isTransmitted){ ped = p; individual = i; genotypes = g; origin = "unknown"; trueSize = genotypes.length; transmitted = isTransmitted; }
if ((evt.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) { TablePane tp = (TablePane) evt.getComponent(); PlayPen pp = (PlayPen) tp.getParent(); try { pp.selectNone(); tp.setSelected(true); tp.selectNone(); tp.selectColumn(tp.pointToColumnIndex(evt.getPoint())); } catch (ArchitectException e) { logger.error("Exception converting point to column", e); } }
public void mousePressed(MouseEvent evt) { evt.getComponent().requestFocus(); maybeShowPopup(evt); }
if ((evt.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) { TablePane tp = (TablePane) evt.getComponent(); PlayPen pp = (PlayPen) tp.getParent(); try { pp.selectNone(); tp.setSelected(true); tp.selectNone(); tp.selectColumn(tp.pointToColumnIndex(evt.getPoint())); } catch (ArchitectException e) { logger.error("Exception converting point to column", e); } }
public void mouseReleased(MouseEvent evt) { maybeShowPopup(evt); // table/column selection if ((evt.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) { TablePane tp = (TablePane) evt.getComponent(); PlayPen pp = (PlayPen) tp.getParent(); try { pp.selectNone(); tp.setSelected(true); tp.selectNone(); tp.selectColumn(tp.pointToColumnIndex(evt.getPoint())); } catch (ArchitectException e) { logger.error("Exception converting point to column", e); } } }
selectNone();
public void dbChildrenRemoved(SQLObjectEvent e) { if (e.getSource() == this.model.getColumnsFolder()) { int ci[] = e.getChangedIndices(); for (int i = 0; i < ci.length; i++) { columnSelection.remove(ci[i]); } if (columnSelection.size() > 0) { columnSelection.set(Math.min(ci[0], columnSelection.size()-1), Boolean.TRUE); } } try { ArchitectUtils.unlistenToHierarchy(this, e.getChildren()); if (columnSelection.size() != this.model.getColumns().size()) { logger.error("Selection list and children are out of sync: selection="+columnSelection+"; children="+model.getChildren()); } } catch (ArchitectException ex) { logger.error("Couldn't remove children", ex); JOptionPane.showMessageDialog(this, "Couldn't delete column: "+ex.getMessage()); } firePropertyChange("model.children", null, null); revalidate(); }