Search Results

Search found 5 results on 1 pages for 'jon077'.

Page 1/1 | 1 

  • Can XMLCatalog be used for schema imports?

    - by jon077
    Can you use XMLCatalog to resolve xsds in schema import statements? If so, what is the preferred/best practice? I want to package the xsds in a jar, so using a relative schemaLocation has not worked. So far I am trying to do something like: SchemaFactory factory = SchemaFactory .newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); XMLCatalogResolver catalogResolver = new XMLCatalogResolver( new String[]{"/path/to/catalog.xml"}); factory.setResourceResolver(catalogResolver); Schema schema = factory.newSchema(new StreamSource(ClassLoader .getSystemResourceAsStream("config.xsd"))); Without much luck.

    Read the article

  • Java 2D Resize

    - by jon077
    I have some old Java 2D code I want to reuse, but was wondering, is this the best way to get the highest quality images? public static BufferedImage getScaled(BufferedImage imgSrc, Dimension dim) { // This code ensures that all the pixels in the image are loaded. Image scaled = imgSrc.getScaledInstance( dim.width, dim.height, Image.SCALE_SMOOTH); // This code ensures that all the pixels in the image are loaded. Image temp = new ImageIcon(scaled).getImage(); // Create the buffered image. BufferedImage bufferedImage = new BufferedImage(temp.getWidth(null), temp.getHeight(null), BufferedImage.TYPE_INT_RGB); // Copy image to buffered image. Graphics g = bufferedImage.createGraphics(); // Clear background and paint the image. g.setColor(Color.white); g.fillRect(0, 0, temp.getWidth(null),temp.getHeight(null)); g.drawImage(temp, 0, 0, null); g.dispose(); // j2d's image scaling quality is rather poor, especially when // scaling down an image to a much smaller size. We'll post filter // our images using a trick found at // http://blogs.cocoondev.org/mpo/archives/003584.html // to increase the perceived quality.... float origArea = imgSrc.getWidth() * imgSrc.getHeight(); float newArea = dim.width * dim.height; if (newArea <= (origArea / 2.)) { bufferedImage = blurImg(bufferedImage); } return bufferedImage; } public static BufferedImage blurImg(BufferedImage src) { // soften factor - increase to increase blur strength float softenFactor = 0.010f; // convolution kernel (blur) float[] softenArray = { 0, softenFactor, 0, softenFactor, 1-(softenFactor*4), softenFactor, 0, softenFactor, 0}; Kernel kernel = new Kernel(3, 3, softenArray); ConvolveOp cOp = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null); return cOp.filter(src, null); }

    Read the article

  • Comparing text files w/ Junit

    - by jon077
    I am comparing text files in junit using: public static void assertReaders(BufferedReader expected, BufferedReader actual) throws IOException { String line; while ((line = expected.readLine()) != null) { assertEquals(line, actual.readLine()); } assertNull("Actual had more lines then the expected.", actual.readLine()); assertNull("Expected had more lines then the actual.", expected.readLine()); } Is this a good way to compare text files? What is preferred?

    Read the article

  • JNDI Issues: Jboss 4.2.2 Spring 2.5 and hibernate ejb

    - by jon077
    I have a strange problem, that is causing me some grief. If the following jar is in my classpath: <dependency> <groupId>org.hibernate</groupId> <artifactId>org.hibernate.ejb</artifactId> <version>3.3.2.GA</version> </dependency> My JNDI lookup for my datasource returns null. Here is the basic code I am using to do the lookup: InitialDirContext ctx = new InitialDirContext(env); DataSource dataSource = (DataSource)ctx.lookup("java:dataContent"); Otherwise, the DataSource returns fine from the context. Unfortunately, I need the jar in order to avoid ClassCastExceptions within Jboss 4.2.2. Any help is appreciated.

    Read the article

1