Java AWT/SWT/Swing: How to plan a GUI?

I’m not a big fan of GUI builders: They typically autogenerate bucket-loads of code that then locks in your whole development team to using one IDE. Also, this code is often unreadable (check the code generated when using Matisse under Netbeans). My recommendations for GUI design / debugging would be: Add a main method to … Read more

Java 2D Drawing Optimal Performance

A synthesis of the answers to this post, the answers to Consty’s, and my own research: What works: Use GraphicsConfiguration.createCompatibleImage to create images compatible with what you’re drawing on. This is absolutely essential! Use double-buffered drawing via Canvas.createBufferStrategy. Use -Dsun.java2d.opengl=True where available to speed up drawing. Avoid using transforms for scaling. Instead, cache scaled versions … Read more

Graphics on indexed image

Refering to this, it can be solved by creating a blank bitmap with the same dimensions and the correct PixelFormat and the draw on that bitmap. // The original bitmap with the wrong pixel format. // You can check the pixel format with originalBmp.PixelFormat Bitmap originalBmp = (Bitmap)Image.FromFile(“YourFileName.gif”); // Create a blank bitmap with the … Read more

In MATLAB, how do I plot to an image and save the result without displaying it?

When you create the figure you set the Visibile property to Off. f = figure(‘visible’,’off’) Which in your case would be im = imread(‘image.tif’); f = figure(‘visible’,’off’), imshow(im, ‘Border’, ‘tight’); rectangle(‘Position’, [100, 100, 10, 10]); print(f, ‘-r80’, ‘-dtiff’, ‘image2.tif’); And if you want to view it again you can do set(f,’visible’,’on’)

Java2D: Increase the line width

You should use setStroke to set a stroke of the Graphics2D object. The example at http://www.java2s.com gives you some code examples. The following code produces the image below: import java.awt.*; import java.awt.geom.Line2D; import javax.swing.*; public class FrameTest { public static void main(String[] args) { JFrame jf = new JFrame(“Demo”); Container cp = jf.getContentPane(); cp.add(new JComponent() … Read more