From: Gerardo H. <ma...@us...> - 2007-02-28 00:02:49
|
Update of /cvsroot/jrman/drafts/src/net/falappa/swing In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv4501/src/net/falappa/swing Modified Files: CheckeredPaint.java ExtensionFileFilter.java Log Message: Finished reformatting code :) Code is almost 100% clean (no more hideous Eclipse formatting, no tabs, no line longer than 80 columns, no CR/LF) Index: ExtensionFileFilter.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/net/falappa/swing/ExtensionFileFilter.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ExtensionFileFilter.java 26 Feb 2007 15:25:14 -0000 1.2 --- ExtensionFileFilter.java 28 Feb 2007 00:02:40 -0000 1.3 *************** *** 1,60 **** ! /* ! * Created on 26-ott-2003 ! */ ! package net.falappa.swing; ! ! import java.io.File; ! import java.text.MessageFormat; ! import java.util.ResourceBundle; ! ! import javax.swing.filechooser.FileFilter; ! ! /** ! * A <code>JFileChooser</code> file filter based on an extension string. ! * The file filter accepts directories and files ending with the extension it is ! * built with. ! * ! * @author Alessandro Falappa ! */ ! public class ExtensionFileFilter extends FileFilter { ! private String ext; ! private String desc; ! private static final ResourceBundle messagesBundle= ! ResourceBundle.getBundle( ! ExtensionFileFilter.class.getPackage().getName() ! + ".res.ExtensionFileFilter"); ! ! /** ! * Constructs a <code>ExtensionFileFilter</code> object. ! * ! * @param ext ! * the extension this filter will allow to select ! */ ! public ExtensionFileFilter(String ext) { ! if (ext == null) ! throw new NullPointerException("invalid extension"); //$NON-NLS-1$ ! this.ext= ext; ! desc= ! MessageFormat.format( ! messagesBundle.getString("ExtensionFileFilter.description"), //$NON-NLS-1$ ! ext.toUpperCase(), ext ); ! } ! ! /* ! * (non-Javadoc) ! * ! * @see javax.swing.filechooser.FileFilter#accept(java.io.File) ! */ ! public boolean accept(File f) { ! return f.isDirectory() || f.getName().toLowerCase().endsWith(ext); ! } ! ! /* ! * (non-Javadoc) ! * ! * @see javax.swing.filechooser.FileFilter#getDescription() ! */ ! public String getDescription() { ! return desc; ! } ! } --- 1,60 ---- ! /* ! * Created on 26-ott-2003 ! */ ! package net.falappa.swing; ! ! import java.io.File; ! import java.text.MessageFormat; ! import java.util.ResourceBundle; ! ! import javax.swing.filechooser.FileFilter; ! ! /** ! * A <code>JFileChooser</code> file filter based on an extension string. ! * The file filter accepts directories and files ending with the extension it is ! * built with. ! * ! * @author Alessandro Falappa ! */ ! public class ExtensionFileFilter extends FileFilter { ! private String ext; ! private String desc; ! private static final ResourceBundle messagesBundle= ! ResourceBundle.getBundle( ! ExtensionFileFilter.class.getPackage().getName() ! + ".res.ExtensionFileFilter"); ! ! /** ! * Constructs a <code>ExtensionFileFilter</code> object. ! * ! * @param ext ! * the extension this filter will allow to select ! */ ! public ExtensionFileFilter(String ext) { ! if (ext == null) ! throw new NullPointerException("invalid extension"); //$NON-NLS-1$ ! this.ext= ext; ! desc= ! MessageFormat.format( ! messagesBundle.getString("ExtensionFileFilter.description"), //$NON-NLS-1$ ! ext.toUpperCase(), ext ); ! } ! ! /* ! * (non-Javadoc) ! * ! * @see javax.swing.filechooser.FileFilter#accept(java.io.File) ! */ ! public boolean accept(File f) { ! return f.isDirectory() || f.getName().toLowerCase().endsWith(ext); ! } ! ! /* ! * (non-Javadoc) ! * ! * @see javax.swing.filechooser.FileFilter#getDescription() ! */ ! public String getDescription() { ! return desc; ! } ! } Index: CheckeredPaint.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/net/falappa/swing/CheckeredPaint.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CheckeredPaint.java 25 Nov 2003 06:00:57 -0000 1.2 --- CheckeredPaint.java 28 Feb 2007 00:02:40 -0000 1.3 *************** *** 8,72 **** public class CheckeredPaint extends TexturePaint { ! private static final int TONE_BITMASK= 0x0f; ! private static final int SIZE_BITMASK= 0xf0; ! public static final int PRESET_LIGHT_TONE_SMALL= 0x00; ! public static final int PRESET_MID_TONE_SMALL= 0x01; ! public static final int PRESET_DARK_TONE_SMALL= 0x02; ! public static final int PRESET_LIGHT_TONE_MEDIUM= 0x10; ! public static final int PRESET_MID_TONE_MEDIUM= 0x11; ! public static final int PRESET_DARK_TONE_MEDIUM= 0x12; ! public static final int PRESET_LIGHT_TONE_LARGE= 0x20; ! public static final int PRESET_MID_TONE_LARGE= 0x21; ! public static final int PRESET_DARK_TONE_LARGE= 0x22; ! private void init(int squareSize, Color color1, Color color2) { ! Graphics g= getImage().getGraphics(); ! g.setColor(color1); ! g.fillRect(0, 0, squareSize, squareSize); ! g.fillRect(squareSize, squareSize, squareSize, squareSize); ! g.setColor(color2); ! g.fillRect(squareSize, 0, squareSize, squareSize); ! g.fillRect(0, squareSize, squareSize, squareSize); ! } ! public CheckeredPaint(int squareSize, Color color1, Color color2) { ! super( ! new BufferedImage( 2 * squareSize, 2 * squareSize, BufferedImage.TYPE_INT_RGB), ! new Rectangle2D.Float(0.f, 0.f, 2 * squareSize, 2 * squareSize)); ! init(squareSize, color1, color2); ! } ! public CheckeredPaint() { ! this(8, Color.white, Color.lightGray); ! } ! public static CheckeredPaint createPreset(int preset) { ! int checkSize; ! Color c1, c2; ! int i= (preset & SIZE_BITMASK) >> 4; ! if (i == 2) ! checkSize= 32; ! else if (i == 1) ! checkSize= 16; ! else ! checkSize= 8; ! i= (preset & TONE_BITMASK); ! if (i == 2) { ! c1= Color.lightGray; ! c2= Color.darkGray; ! } ! else if (i == 1) { ! c1= Color.white; ! c2= Color.gray; ! } ! else { ! c1= Color.white; ! c2= Color.lightGray; ! } ! return new CheckeredPaint(checkSize, c1, c2); ! } } --- 8,72 ---- public class CheckeredPaint extends TexturePaint { ! private static final int TONE_BITMASK= 0x0f; ! private static final int SIZE_BITMASK= 0xf0; ! public static final int PRESET_LIGHT_TONE_SMALL= 0x00; ! public static final int PRESET_MID_TONE_SMALL= 0x01; ! public static final int PRESET_DARK_TONE_SMALL= 0x02; ! public static final int PRESET_LIGHT_TONE_MEDIUM= 0x10; ! public static final int PRESET_MID_TONE_MEDIUM= 0x11; ! public static final int PRESET_DARK_TONE_MEDIUM= 0x12; ! public static final int PRESET_LIGHT_TONE_LARGE= 0x20; ! public static final int PRESET_MID_TONE_LARGE= 0x21; ! public static final int PRESET_DARK_TONE_LARGE= 0x22; ! private void init(int squareSize, Color color1, Color color2) { ! Graphics g= getImage().getGraphics(); ! g.setColor(color1); ! g.fillRect(0, 0, squareSize, squareSize); ! g.fillRect(squareSize, squareSize, squareSize, squareSize); ! g.setColor(color2); ! g.fillRect(squareSize, 0, squareSize, squareSize); ! g.fillRect(0, squareSize, squareSize, squareSize); ! } ! public CheckeredPaint(int squareSize, Color color1, Color color2) { ! super( ! new BufferedImage( 2 * squareSize, 2 * squareSize, BufferedImage.TYPE_INT_RGB), ! new Rectangle2D.Float(0.f, 0.f, 2 * squareSize, 2 * squareSize)); ! init(squareSize, color1, color2); ! } ! public CheckeredPaint() { ! this(8, Color.white, Color.lightGray); ! } ! public static CheckeredPaint createPreset(int preset) { ! int checkSize; ! Color c1, c2; ! int i= (preset & SIZE_BITMASK) >> 4; ! if (i == 2) ! checkSize= 32; ! else if (i == 1) ! checkSize= 16; ! else ! checkSize= 8; ! i= (preset & TONE_BITMASK); ! if (i == 2) { ! c1= Color.lightGray; ! c2= Color.darkGray; ! } ! else if (i == 1) { ! c1= Color.white; ! c2= Color.gray; ! } ! else { ! c1= Color.white; ! c2= Color.lightGray; ! } ! return new CheckeredPaint(checkSize, c1, c2); ! } } |