Revision: 30
http://patchanim.svn.sourceforge.net/patchanim/?rev=30&view=rev
Author: dbrosius
Date: 2008-01-26 17:44:22 -0800 (Sat, 26 Jan 2008)
Log Message:
-----------
Switch to double document from integer document
Added Paths:
-----------
trunk/patchanim/src/com/mebigfatguy/patchanim/gui/DoubleDocument.java
Added: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/DoubleDocument.java
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/DoubleDocument.java (rev 0)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/DoubleDocument.java 2008-01-27 01:44:22 UTC (rev 30)
@@ -0,0 +1,46 @@
+/*
+ * patchanim - A bezier surface patch color blend gif builder
+ * Copyright (C) 2008 Dave Brosius
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.mebigfatguy.patchanim.gui;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.swing.text.AttributeSet;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.PlainDocument;
+
+
+public class DoubleDocument extends PlainDocument
+{
+ private static final long serialVersionUID = 2390424803444456428L;
+
+ private static final Pattern DOUBLEPATTERN = Pattern.compile("-?[0-9]*(\\.[0-9]*)?");
+
+ @Override
+ public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
+ String start = getText(0, offs);
+ String end = getText(offs, this.getLength() - offs);
+ String newIntegerString = (start + str + end).trim();
+
+ Matcher m = DOUBLEPATTERN.matcher(newIntegerString);
+ if (m.matches()) {
+ super.insertString(offs, str, a);
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/DoubleDocument.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|