summaryrefslogtreecommitdiffstats
path: root/libjava/javax/swing/text
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/javax/swing/text')
-rw-r--r--libjava/javax/swing/text/AbstractDocument.java3
-rw-r--r--libjava/javax/swing/text/AttributeSet.java4
-rw-r--r--libjava/javax/swing/text/Caret.java2
-rw-r--r--libjava/javax/swing/text/DefaultCaret.java1
-rw-r--r--libjava/javax/swing/text/DefaultEditorKit.java5
-rw-r--r--libjava/javax/swing/text/DefaultHighlighter.java15
-rw-r--r--libjava/javax/swing/text/Document.java2
-rw-r--r--libjava/javax/swing/text/DocumentFilter.java42
-rw-r--r--libjava/javax/swing/text/EditorKit.java5
-rw-r--r--libjava/javax/swing/text/FieldView.java2
-rw-r--r--libjava/javax/swing/text/GapContent.java2
-rw-r--r--libjava/javax/swing/text/Highlighter.java3
-rw-r--r--libjava/javax/swing/text/JTextComponent.java62
-rw-r--r--libjava/javax/swing/text/LayeredHighlighter.java4
-rw-r--r--libjava/javax/swing/text/NavigationFilter.java30
-rw-r--r--libjava/javax/swing/text/PasswordView.java138
-rw-r--r--libjava/javax/swing/text/PlainDocument.java53
-rw-r--r--libjava/javax/swing/text/PlainView.java10
-rw-r--r--libjava/javax/swing/text/SimpleAttributeSet.java9
-rw-r--r--libjava/javax/swing/text/StyleConstants.java88
-rw-r--r--libjava/javax/swing/text/StyleContext.java8
-rw-r--r--libjava/javax/swing/text/StyledEditorKit.java3
-rw-r--r--libjava/javax/swing/text/TextAction.java3
-rw-r--r--libjava/javax/swing/text/Utilities.java32
-rw-r--r--libjava/javax/swing/text/View.java2
-rw-r--r--libjava/javax/swing/text/html/HTML.java5
26 files changed, 424 insertions, 109 deletions
diff --git a/libjava/javax/swing/text/AbstractDocument.java b/libjava/javax/swing/text/AbstractDocument.java
index a7c8c907e60..f579fbb213b 100644
--- a/libjava/javax/swing/text/AbstractDocument.java
+++ b/libjava/javax/swing/text/AbstractDocument.java
@@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.text;
import java.io.Serializable;
@@ -43,6 +44,7 @@ import java.util.Dictionary;
import java.util.Enumeration;
import java.util.EventListener;
import java.util.Vector;
+
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.EventListenerList;
@@ -53,7 +55,6 @@ import javax.swing.undo.AbstractUndoableEdit;
import javax.swing.undo.CompoundEdit;
import javax.swing.undo.UndoableEdit;
-
public abstract class AbstractDocument
implements Document, Serializable
{
diff --git a/libjava/javax/swing/text/AttributeSet.java b/libjava/javax/swing/text/AttributeSet.java
index 3f38a4cd249..68d36bcf49f 100644
--- a/libjava/javax/swing/text/AttributeSet.java
+++ b/libjava/javax/swing/text/AttributeSet.java
@@ -57,8 +57,8 @@ public interface AttributeSet
{
}
- static Object NameAttribute = StyleConstants.NameAttribute;
- static Object ResolveAttribute = StyleConstants.ResolveAttribute;
+ Object NameAttribute = StyleConstants.NameAttribute;
+ Object ResolveAttribute = StyleConstants.ResolveAttribute;
boolean containsAttribute(Object name, Object value);
boolean containsAttributes(AttributeSet attributes);
diff --git a/libjava/javax/swing/text/Caret.java b/libjava/javax/swing/text/Caret.java
index 7393a753e2c..62263a62ac3 100644
--- a/libjava/javax/swing/text/Caret.java
+++ b/libjava/javax/swing/text/Caret.java
@@ -35,10 +35,12 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.text;
import java.awt.Graphics;
import java.awt.Point;
+
import javax.swing.event.ChangeListener;
public interface Caret
diff --git a/libjava/javax/swing/text/DefaultCaret.java b/libjava/javax/swing/text/DefaultCaret.java
index 516f0726ba0..15a76699601 100644
--- a/libjava/javax/swing/text/DefaultCaret.java
+++ b/libjava/javax/swing/text/DefaultCaret.java
@@ -37,7 +37,6 @@ exception statement from your version. */
package javax.swing.text;
-import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
diff --git a/libjava/javax/swing/text/DefaultEditorKit.java b/libjava/javax/swing/text/DefaultEditorKit.java
index 03d4ef3040e..0e3be209688 100644
--- a/libjava/javax/swing/text/DefaultEditorKit.java
+++ b/libjava/javax/swing/text/DefaultEditorKit.java
@@ -35,19 +35,20 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.text;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
-import java.io.InputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
+
import javax.swing.Action;
import javax.swing.JEditorPane;
-
public class DefaultEditorKit extends EditorKit
{
public static class BeepAction
diff --git a/libjava/javax/swing/text/DefaultHighlighter.java b/libjava/javax/swing/text/DefaultHighlighter.java
index 234fcad60ff..8d0491b6612 100644
--- a/libjava/javax/swing/text/DefaultHighlighter.java
+++ b/libjava/javax/swing/text/DefaultHighlighter.java
@@ -44,10 +44,6 @@ import java.awt.Rectangle;
import java.awt.Shape;
import java.util.Vector;
-import javax.swing.text.JTextComponent;
-import javax.swing.text.View;
-
-
public class DefaultHighlighter extends LayeredHighlighter
{
public static class DefaultHighlightPainter
@@ -168,11 +164,22 @@ public class DefaultHighlighter extends LayeredHighlighter
private JTextComponent textComponent;
private Vector highlights = new Vector();
+ private boolean drawsLayeredHighlights = true;
public DefaultHighlighter()
{
}
+ public boolean getDrawsLayeredHighlights()
+ {
+ return drawsLayeredHighlights;
+ }
+
+ public void setDrawsLayeredHighlights(boolean newValue)
+ {
+ drawsLayeredHighlights = newValue;
+ }
+
private void checkPositions(int p0, int p1)
throws BadLocationException
{
diff --git a/libjava/javax/swing/text/Document.java b/libjava/javax/swing/text/Document.java
index d197924bdf9..d3bbabb5369 100644
--- a/libjava/javax/swing/text/Document.java
+++ b/libjava/javax/swing/text/Document.java
@@ -44,7 +44,7 @@ import javax.swing.event.UndoableEditListener;
public interface Document
{
String StreamDescriptionProperty = "stream";
- String TitleProperty = "text";
+ String TitleProperty = "title";
void addDocumentListener(DocumentListener listener);
diff --git a/libjava/javax/swing/text/DocumentFilter.java b/libjava/javax/swing/text/DocumentFilter.java
index 7a8e95df98d..ff96d07299b 100644
--- a/libjava/javax/swing/text/DocumentFilter.java
+++ b/libjava/javax/swing/text/DocumentFilter.java
@@ -1,5 +1,5 @@
/* DocumentFilter.java --
- Copyright (C) 2003 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,4 +40,44 @@ package javax.swing.text;
public class DocumentFilter
{
+ public abstract static class FilterBypass
+ {
+ public FilterBypass()
+ {
+ // Do nothing here.
+ }
+
+ public abstract Document getDocument();
+
+ public abstract void insertString(int offset, String string,
+ AttributeSet attr)
+ throws BadLocationException;
+
+ public abstract void remove(int offset, int length)
+ throws BadLocationException;
+
+ public abstract void replace(int offset, int length, String string,
+ AttributeSet attrs)
+ throws BadLocationException;
+ }
+
+ public void insertString(DocumentFilter.FilterBypass fb, int offset,
+ String string, AttributeSet attr)
+ throws BadLocationException
+ {
+ fb.insertString(offset, string, attr);
+ }
+
+ public void remove(DocumentFilter.FilterBypass fb, int offset, int length)
+ throws BadLocationException
+ {
+ fb.remove(offset, length);
+ }
+
+ public void replace(DocumentFilter.FilterBypass fb, int offset, int length,
+ String text, AttributeSet attr)
+ throws BadLocationException
+ {
+ fb.replace(offset, length, text, attr);
+ }
}
diff --git a/libjava/javax/swing/text/EditorKit.java b/libjava/javax/swing/text/EditorKit.java
index 0609332f0b8..efca9657e26 100644
--- a/libjava/javax/swing/text/EditorKit.java
+++ b/libjava/javax/swing/text/EditorKit.java
@@ -35,18 +35,19 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.text;
-import java.io.InputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Serializable;
import java.io.Writer;
+
import javax.swing.Action;
import javax.swing.JEditorPane;
-
public abstract class EditorKit
implements Cloneable, Serializable
{
diff --git a/libjava/javax/swing/text/FieldView.java b/libjava/javax/swing/text/FieldView.java
index 06514b73f14..3f1de377230 100644
--- a/libjava/javax/swing/text/FieldView.java
+++ b/libjava/javax/swing/text/FieldView.java
@@ -43,7 +43,6 @@ import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Shape;
-
public class FieldView extends PlainView
{
public FieldView(Element elem)
@@ -79,7 +78,6 @@ public class FieldView extends PlainView
{
// This should never happen.
text = "";
- System.out.println("Michael: FieldView.getPreferredSpan: Error");
}
return fm.stringWidth(text);
diff --git a/libjava/javax/swing/text/GapContent.java b/libjava/javax/swing/text/GapContent.java
index 93446826868..5826128724f 100644
--- a/libjava/javax/swing/text/GapContent.java
+++ b/libjava/javax/swing/text/GapContent.java
@@ -93,7 +93,7 @@ public class GapContent
public String getString(int where, int len) throws BadLocationException
{
- return buf.toString();
+ return buf.substring(where, where+len);
}
public void getChars(int where, int len, Segment txt)
diff --git a/libjava/javax/swing/text/Highlighter.java b/libjava/javax/swing/text/Highlighter.java
index 77471d17768..affec9b7a99 100644
--- a/libjava/javax/swing/text/Highlighter.java
+++ b/libjava/javax/swing/text/Highlighter.java
@@ -55,8 +55,7 @@ public interface Highlighter
public interface HighlightPainter
{
- public void paint(Graphics g, int p0, int p1, Shape bounds,
- JTextComponent c);
+ void paint(Graphics g, int p0, int p1, Shape bounds, JTextComponent c);
}
void install(JTextComponent c);
diff --git a/libjava/javax/swing/text/JTextComponent.java b/libjava/javax/swing/text/JTextComponent.java
index ea69f5d16d9..0bca84b0fcf 100644
--- a/libjava/javax/swing/text/JTextComponent.java
+++ b/libjava/javax/swing/text/JTextComponent.java
@@ -35,19 +35,17 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.text;
import java.awt.AWTEvent;
import java.awt.Color;
-import java.awt.Component;
import java.awt.Dimension;
-import java.awt.Image;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.InputMethodListener;
import java.awt.event.KeyEvent;
-
import java.util.Enumeration;
import java.util.Hashtable;
@@ -58,7 +56,6 @@ import javax.accessibility.AccessibleStateSet;
import javax.accessibility.AccessibleText;
import javax.swing.Action;
import javax.swing.ActionMap;
-import javax.swing.Icon;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JViewport;
@@ -73,7 +70,6 @@ import javax.swing.plaf.ActionMapUIResource;
import javax.swing.plaf.InputMapUIResource;
import javax.swing.plaf.TextUI;
-
public abstract class JTextComponent extends JComponent
implements Scrollable, Accessible
{
@@ -629,7 +625,7 @@ public abstract class JTextComponent extends JComponent
* @see #setKeymap()
* @see #keymap
*/
- Keymap getKeymap()
+ public Keymap getKeymap()
{
return keymap;
}
@@ -800,6 +796,7 @@ public abstract class JTextComponent extends JComponent
private Color selectionColor;
private boolean editable;
private Insets margin;
+ private boolean dragEnabled;
/**
* Creates a new <code>JTextComponent</code> instance.
@@ -921,6 +918,26 @@ public abstract class JTextComponent extends JComponent
}
/**
+ * Retrieves the currently selected text in this text document.
+ *
+ * @return the selected text
+ *
+ * @exception NullPointerException if the underlaying document is null
+ */
+ public String getSelectedText()
+ {
+ try
+ {
+ return doc.getText(getSelectionStart(), getSelectionEnd());
+ }
+ catch (BadLocationException e)
+ {
+ // This should never happen.
+ return null;
+ }
+ }
+
+ /**
* Returns a string that specifies the name of the Look and Feel class
* that renders this component.
*
@@ -998,12 +1015,16 @@ public abstract class JTextComponent extends JComponent
/**
* Enables/disabled this text component's editability.
*
- * @param editable true to make it editable, false otherwise.
+ * @param newValue true to make it editable, false otherwise.
*/
- public void setEditable(boolean editable)
+ public void setEditable(boolean newValue)
{
- firePropertyChange("editable", this.editable, editable);
- this.editable = editable;
+ if (editable == newValue)
+ return;
+
+ boolean oldValue = editable;
+ editable = newValue;
+ firePropertyChange("editable", oldValue, newValue);
}
/**
@@ -1225,17 +1246,22 @@ public abstract class JTextComponent extends JComponent
try
{
+ int start = getSelectionStart();
+ int end = getSelectionEnd();
+
// Remove selected text.
if (dot != mark)
- doc.remove(Math.min(dot, mark), Math.max(dot, mark));
+ doc.remove(start, end - start);
// Insert new text.
- doc.insertString(Math.min(dot, mark), content, null);
+ doc.insertString(start, content, null);
+
+ // Set dot to new position.
+ setCaretPosition(start + content.length());
}
catch (BadLocationException e)
{
// This should never happen.
- System.out.println("Michael: JTextComponent.replaceSelection: Error");
}
}
@@ -1333,4 +1359,14 @@ public abstract class JTextComponent extends JComponent
{
return getUI().modelToView(this, position);
}
+
+ public boolean getDragEnabled()
+ {
+ return dragEnabled;
+ }
+
+ public void setDragEnabled(boolean enabled)
+ {
+ dragEnabled = enabled;
+ }
}
diff --git a/libjava/javax/swing/text/LayeredHighlighter.java b/libjava/javax/swing/text/LayeredHighlighter.java
index 45932217a02..0b063e5a1df 100644
--- a/libjava/javax/swing/text/LayeredHighlighter.java
+++ b/libjava/javax/swing/text/LayeredHighlighter.java
@@ -40,10 +40,6 @@ package javax.swing.text;
import java.awt.Graphics;
import java.awt.Shape;
-import javax.swing.text.JTextComponent;
-import javax.swing.text.View;
-
-
public abstract class LayeredHighlighter
implements Highlighter
{
diff --git a/libjava/javax/swing/text/NavigationFilter.java b/libjava/javax/swing/text/NavigationFilter.java
index 37d1c380a65..cdf9e77b7eb 100644
--- a/libjava/javax/swing/text/NavigationFilter.java
+++ b/libjava/javax/swing/text/NavigationFilter.java
@@ -1,5 +1,5 @@
/* NavigationFilter.java --
- Copyright (C) 2003 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,4 +40,32 @@ package javax.swing.text;
public class NavigationFilter
{
+ public abstract static class FilterBypass
+ {
+ public FilterBypass()
+ {
+ // Do nothing here.
+ }
+
+ public abstract Caret getCaret();
+ public abstract void moveDot(int dot, Position.Bias bias);
+ public abstract void setDot(int dot, Position.Bias bias);
+ }
+
+ public NavigationFilter()
+ {
+ // Do nothing here.
+ }
+
+ public void moveDot(NavigationFilter.FilterBypass fb, int dot,
+ Position.Bias bias)
+ {
+ fb.moveDot(dot, bias);
+ }
+
+ public void setDot(NavigationFilter.FilterBypass fb, int dot,
+ Position.Bias bias)
+ {
+ fb.setDot(dot, bias);
+ }
}
diff --git a/libjava/javax/swing/text/PasswordView.java b/libjava/javax/swing/text/PasswordView.java
new file mode 100644
index 00000000000..f9db0417057
--- /dev/null
+++ b/libjava/javax/swing/text/PasswordView.java
@@ -0,0 +1,138 @@
+/* PasswordView.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.text;
+
+import java.awt.Color;
+import java.awt.Graphics;
+
+import javax.swing.JPasswordField;
+
+public class PasswordView extends FieldView
+{
+ /**
+ * Buffer for putting the echo char into it and
+ * then using it to draw it into the view.
+ */
+ private char[] oneCharBuffer = new char[1];
+
+ public PasswordView(Element elem)
+ {
+ super(elem);
+ }
+
+ protected int drawEchoCharacter(Graphics g, int x, int y, char ch)
+ {
+ // Update font metrics.
+ updateMetrics();
+
+ // Draw character.
+ oneCharBuffer[0] = ch;
+ g.drawChars(oneCharBuffer, 0, 1, x, y);
+
+ // Return new x position right of drawn character.
+ return x + metrics.charWidth(ch);
+ }
+
+ private char getEchoChar()
+ {
+ char ch = ((JPasswordField) getContainer()).getEchoChar();
+
+ if (ch == 0)
+ ch = '*';
+
+ return ch;
+ }
+
+ protected int drawSelectedText(Graphics g, int x, int y, int p0, int p1)
+ throws BadLocationException
+ {
+ // FIXME: Throw BadLocationException somehow.
+
+ // Update font metrics.
+ updateMetrics();
+
+ // Get echo character.
+ char ch = getEchoChar();
+
+ // Set color for selected text.
+ g.setColor(selectedColor);
+ g.setColor(Color.BLACK);
+
+ // Initialize buffer for faster drawing of all characters.
+ int len = p1 - p0;
+ char[] buffer = new char[len];
+ for (int index = 0; index < len; ++index)
+ buffer[index] = ch;
+
+ // Draw echo charaters.
+ g.drawChars(buffer, 0, len, x, y);
+
+ // Return new x position right of all drawn characters.
+ return x + len * metrics.charWidth(ch);
+ }
+
+ protected int drawUnselectedText(Graphics g, int x, int y, int p0, int p1)
+ throws BadLocationException
+ {
+ // FIXME: Throw BadLocationException somehow.
+
+ // Update font metrics.
+ updateMetrics();
+
+ // Get echo character.
+ char ch = getEchoChar();
+
+ // Set color for unselected text.
+ g.setColor(unselectedColor);
+ g.setColor(Color.BLACK);
+
+ // Initialize buffer for faster drawing of all characters.
+ int len = p1 - p0;
+ char[] buffer = new char[len];
+ for (int index = 0; index < len; ++index)
+ buffer[index] = ch;
+
+ // Draw echo charaters.
+ g.drawChars(buffer, 0, len, x, y);
+
+ // Return new x position right of all drawn characters.
+ return x + len * metrics.charWidth(ch);
+ }
+}
+
diff --git a/libjava/javax/swing/text/PlainDocument.java b/libjava/javax/swing/text/PlainDocument.java
index 4a8adfca54d..22808700a03 100644
--- a/libjava/javax/swing/text/PlainDocument.java
+++ b/libjava/javax/swing/text/PlainDocument.java
@@ -37,6 +37,8 @@ exception statement from your version. */
package javax.swing.text;
+import java.util.ArrayList;
+
public class PlainDocument extends AbstractDocument
{
private static final long serialVersionUID = 4758290289196893664L;
@@ -59,14 +61,53 @@ public class PlainDocument extends AbstractDocument
rootElement = createDefaultRoot();
}
+ protected void reindex()
+ {
+ Element[] lines;
+ try
+ {
+ String str = content.getString(0, content.length());
+
+ ArrayList elts = new ArrayList();
+ int j = 0;
+ for (int i = str.indexOf('\n', 0); i != -1; i = str.indexOf('\n', i+1))
+ {
+ elts.add(createLeafElement(rootElement, null, j, i));
+ j = i;
+ }
+
+ if (j < content.length())
+ elts.add(createLeafElement(rootElement, null, j, content.length()));
+
+ lines = new Element[elts.size()];
+ for (int i = 0; i < elts.size(); ++i)
+ lines[i] = (Element) elts.get(i);
+
+ }
+ catch (BadLocationException e)
+ {
+ lines = new Element[1];
+ lines[0] = createLeafElement(rootElement, null, 0, 1);
+ }
+
+ ((BranchElement) rootElement).replace(0, rootElement.getElementCount(), lines);
+ }
+
protected AbstractDocument.AbstractElement createDefaultRoot()
{
- BranchElement rootElement =
- (BranchElement) createBranchElement(null, null);
- Element[] lines = new Element[1];
- lines[0] = createLeafElement(rootElement, null, 0, 1);
- rootElement.replace(0, 0, lines);
- return rootElement;
+ rootElement = createBranchElement(null, null);
+ reindex();
+ return (AbstractElement) rootElement;
+ }
+
+ protected void insertUpdate(DefaultDocumentEvent chng, AttributeSet attr)
+ {
+ reindex();
+ }
+
+ protected void removeUpdate(DefaultDocumentEvent chng)
+ {
+ reindex();
}
public Element getDefaultRootElement()
diff --git a/libjava/javax/swing/text/PlainView.java b/libjava/javax/swing/text/PlainView.java
index 3dd8fe44842..bcec3538d64 100644
--- a/libjava/javax/swing/text/PlainView.java
+++ b/libjava/javax/swing/text/PlainView.java
@@ -50,9 +50,9 @@ import java.awt.Shape;
public class PlainView extends View
implements TabExpander
{
- private Color selectedColor;
- private Color unselectedColor;
- private Font font;
+ Color selectedColor;
+ Color unselectedColor;
+ Font font;
protected FontMetrics metrics;
@@ -130,7 +130,7 @@ public class PlainView extends View
}
}
- public int drawSelectedText(Graphics g, int x, int y, int p0, int p1)
+ protected int drawSelectedText(Graphics g, int x, int y, int p0, int p1)
throws BadLocationException
{
g.setColor(selectedColor);
@@ -139,7 +139,7 @@ public class PlainView extends View
return Utilities.drawTabbedText(segment, x, y, g, this, 0);
}
- public int drawUnselectedText(Graphics g, int x, int y, int p0, int p1)
+ protected int drawUnselectedText(Graphics g, int x, int y, int p0, int p1)
throws BadLocationException
{
g.setColor(unselectedColor);
diff --git a/libjava/javax/swing/text/SimpleAttributeSet.java b/libjava/javax/swing/text/SimpleAttributeSet.java
index 746056dfe7a..1578a48ab27 100644
--- a/libjava/javax/swing/text/SimpleAttributeSet.java
+++ b/libjava/javax/swing/text/SimpleAttributeSet.java
@@ -35,19 +35,19 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.text;
import java.io.Serializable;
import java.util.Enumeration;
import java.util.Hashtable;
-import java.lang.Cloneable;
public class SimpleAttributeSet
implements MutableAttributeSet, Serializable, Cloneable
{
- Hashtable tab;
+ public static final AttributeSet EMPTY = new SimpleAttributeSet();
- static AttributeSet EMPTY = new SimpleAttributeSet();
+ Hashtable tab;
public SimpleAttributeSet()
{
@@ -57,7 +57,8 @@ public class SimpleAttributeSet
public SimpleAttributeSet(AttributeSet a)
{
tab = new Hashtable();
- addAttributes(a);
+ if (a != null)
+ addAttributes(a);
}
public void addAttribute(Object name, Object value)
diff --git a/libjava/javax/swing/text/StyleConstants.java b/libjava/javax/swing/text/StyleConstants.java
index 2201c47b5b9..e1232af8725 100644
--- a/libjava/javax/swing/text/StyleConstants.java
+++ b/libjava/javax/swing/text/StyleConstants.java
@@ -35,16 +35,55 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.text;
import java.awt.Color;
import java.awt.Component;
+
import javax.swing.Icon;
public class StyleConstants
{
+ public static final int ALIGN_LEFT = 0;
+ public static final int ALIGN_CENTER = 1;
+ public static final int ALIGN_RIGHT = 2;
+ public static final int ALIGN_JUSTIFIED = 3;
+
+ public static final Object Background = CharacterConstants.Background;
+ public static final Object BidiLevel = CharacterConstants.BidiLevel;
+ public static final Object Bold = CharacterConstants.Bold;
+ public static final Object ComponentAttribute = CharacterConstants.ComponentAttribute;
+ public static final Object FontFamily = CharacterConstants.Family;
+ public static final Object FontSize = CharacterConstants.Size;
+ public static final Object Foreground = CharacterConstants.Foreground;
+ public static final Object IconAttribute = CharacterConstants.IconAttribute;
+ public static final Object Italic = CharacterConstants.Italic;
+ public static final Object StrikeThrough = CharacterConstants.StrikeThrough;
+ public static final Object Subscript = CharacterConstants.Subscript;
+ public static final Object Superscript = CharacterConstants.Superscript;
+ public static final Object Underline = CharacterConstants.Underline;
+
+ public static final Object Alignment = ParagraphConstants.Alignment;
+ public static final Object FirstLineIndent = ParagraphConstants.FirstLineIndent;
+ public static final Object LeftIndent = ParagraphConstants.LeftIndent;
+ public static final Object LineSpacing = ParagraphConstants.LineSpacing;
+ public static final Object Orientation = ParagraphConstants.Orientation;
+ public static final Object RightIndent = ParagraphConstants.RightIndent;
+ public static final Object SpaceAbove = ParagraphConstants.SpaceAbove;
+ public static final Object SpaceBelow = ParagraphConstants.SpaceBelow;
+ public static final Object TabSet = ParagraphConstants.TabSet;
+
+ public static final String ComponentElementName = "component";
+ public static final String IconElementName = "icon";
+
+ public static final Object ComposedTextAttribute = new StyleConstants("composed text");
+ public static final Object ModelAttribute = new StyleConstants("model");
+ public static final Object NameAttribute = new StyleConstants("name");
+ public static final Object ResolveAttribute = new StyleConstants("resolver");
String keyname;
+
private StyleConstants(String k)
{
keyname = k;
@@ -55,43 +94,6 @@ public class StyleConstants
return keyname;
}
- public static int ALIGN_CENTER;
- public static int ALIGN_JUSTIFIED;
- public static int ALIGN_LEFT;
- public static int ALIGN_RIGHT;
-
- public static Object Background = CharacterConstants.Background;
- public static Object BidiLevel = CharacterConstants.BidiLevel;
- public static Object Bold = CharacterConstants.Bold;
- public static Object ComponentAttribute = CharacterConstants.ComponentAttribute;
- public static Object FontFamily = CharacterConstants.Family;
- public static Object FontSize = CharacterConstants.Size;
- public static Object Foreground = CharacterConstants.Foreground;
- public static Object IconAttribute = CharacterConstants.IconAttribute;
- public static Object Italic = CharacterConstants.Italic;
- public static Object StrikeThrough = CharacterConstants.StrikeThrough;
- public static Object Subscript = CharacterConstants.Subscript;
- public static Object Superscript = CharacterConstants.Superscript;
- public static Object Underline = CharacterConstants.Underline;
-
- public static Object Alignment = ParagraphConstants.Alignment;
- public static Object FirstLineIndent = ParagraphConstants.FirstLineIndent;
- public static Object LeftIndent = ParagraphConstants.LeftIndent;
- public static Object LineSpacing = ParagraphConstants.LineSpacing;
- public static Object Orientation = ParagraphConstants.Orientation;
- public static Object RightIndent = ParagraphConstants.RightIndent;
- public static Object SpaceAbove = ParagraphConstants.SpaceAbove;
- public static Object SpaceBelow = ParagraphConstants.SpaceBelow;
- public static Object TabSet = ParagraphConstants.TabSet;
-
- public static String ComponentElementName = new String("component");
- public static String IconElementName = new String("icon");
-
- public static Object ComposedTextAttribute = new StyleConstants("composed text");
- public static Object ModelAttribute = new StyleConstants("model");
- public static Object NameAttribute = new StyleConstants("name");
- public static Object ResolveAttribute = new StyleConstants("resolver");
-
public static int getAlignment(AttributeSet a)
{
if (a.isDefined(Alignment))
@@ -277,7 +279,7 @@ public class StyleConstants
public static void setBold(MutableAttributeSet a, boolean b)
{
- a.addAttribute(Bold, new Boolean(b));
+ a.addAttribute(Bold, Boolean.valueOf(b));
}
public static void setComponent(MutableAttributeSet a, Component c)
@@ -312,7 +314,7 @@ public class StyleConstants
public static void setItalic(MutableAttributeSet a, boolean b)
{
- a.addAttribute(Italic, new Boolean(b));
+ a.addAttribute(Italic, Boolean.valueOf(b));
}
public static void setLeftIndent(MutableAttributeSet a, float i)
@@ -342,17 +344,17 @@ public class StyleConstants
public static void setStrikeThrough(MutableAttributeSet a, boolean b)
{
- a.addAttribute(StrikeThrough, new Boolean(b));
+ a.addAttribute(StrikeThrough, Boolean.valueOf(b));
}
public static void setSubscript(MutableAttributeSet a, boolean b)
{
- a.addAttribute(Subscript, new Boolean(b));
+ a.addAttribute(Subscript, Boolean.valueOf(b));
}
public static void setSuperscript(MutableAttributeSet a, boolean b)
{
- a.addAttribute(Superscript, new Boolean(b));
+ a.addAttribute(Superscript, Boolean.valueOf(b));
}
public static void setTabSet(MutableAttributeSet a, javax.swing.text.TabSet tabs)
@@ -362,7 +364,7 @@ public class StyleConstants
public static void setUnderline(MutableAttributeSet a, boolean b)
{
- a.addAttribute(Underline, new Boolean(b));
+ a.addAttribute(Underline, Boolean.valueOf(b));
}
// The remainder are so-called "typesafe enumerations" which
diff --git a/libjava/javax/swing/text/StyleContext.java b/libjava/javax/swing/text/StyleContext.java
index 8accd9b905b..beb809b89e4 100644
--- a/libjava/javax/swing/text/StyleContext.java
+++ b/libjava/javax/swing/text/StyleContext.java
@@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.text;
import java.awt.Color;
@@ -45,13 +46,14 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
-import javax.swing.event.EventListenerList;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
import java.util.Enumeration;
import java.util.EventListener;
import java.util.Hashtable;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import javax.swing.event.EventListenerList;
+
public class StyleContext
implements Serializable, AbstractDocument.AttributeContext
{
diff --git a/libjava/javax/swing/text/StyledEditorKit.java b/libjava/javax/swing/text/StyledEditorKit.java
index d3db03e208d..f1858309a5a 100644
--- a/libjava/javax/swing/text/StyledEditorKit.java
+++ b/libjava/javax/swing/text/StyledEditorKit.java
@@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.text;
import java.awt.Color;
@@ -42,12 +43,12 @@ import java.awt.event.ActionEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.Serializable;
+
import javax.swing.Action;
import javax.swing.JEditorPane;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
-
/**
* StyledEditorKit
*
diff --git a/libjava/javax/swing/text/TextAction.java b/libjava/javax/swing/text/TextAction.java
index 029eed9c5e4..d07bcbf1f43 100644
--- a/libjava/javax/swing/text/TextAction.java
+++ b/libjava/javax/swing/text/TextAction.java
@@ -35,13 +35,14 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.text;
import java.awt.event.ActionEvent;
+
import javax.swing.AbstractAction;
import javax.swing.Action;
-
/**
* TextAction
* @author Andrew Selkirk
diff --git a/libjava/javax/swing/text/Utilities.java b/libjava/javax/swing/text/Utilities.java
index 61c13eef509..6d2b54680a0 100644
--- a/libjava/javax/swing/text/Utilities.java
+++ b/libjava/javax/swing/text/Utilities.java
@@ -91,13 +91,29 @@ public class Utilities
FontMetrics metrics = g.getFontMetrics();
int ascent = metrics.getAscent();
+ int pixelWidth = 0;
+ int pos = 0;
+ int len = 0;
+
for (int offset = s.offset; offset < (s.offset + s.count); ++offset)
{
- switch (buffer[offset])
+ char c = buffer[offset];
+ if (c == '\t' || c == '\n')
+ {
+ if (len > 0) {
+ g.drawChars(buffer, pos, len, pixelX, pixelY + ascent);
+ pixelX += pixelWidth;
+ pixelWidth = 0;
+ }
+ pos = offset+1;
+ len = 0;
+ }
+
+ switch (c)
{
case '\t':
// In case we have a tab, we just 'jump' over the tab.
- // When we have no tab expander we just use the width of 'm'.
+ // When we have no tab expander we just use the width of ' '.
if (e != null)
pixelX = (int) e.nextTabStop((float) pixelX,
startOffset + offset - s.offset);
@@ -105,20 +121,20 @@ public class Utilities
pixelX += metrics.charWidth(' ');
break;
case '\n':
- // In case we have a newline, we must draw
- // the buffer and jump on the next line.
- g.drawChars(buffer, offset, 1, pixelX, y);
+ // In case we have a newline, we must jump to the next line.
pixelY += metrics.getHeight();
pixelX = x;
break;
default:
- // Here we draw the char.
- g.drawChars(buffer, offset, 1, pixelX, pixelY + ascent);
- pixelX += metrics.charWidth(buffer[offset]);
+ ++len;
+ pixelWidth += metrics.charWidth(buffer[offset]);
break;
}
}
+ if (len > 0)
+ g.drawChars(buffer, pos, len, pixelX, pixelY + ascent);
+
return pixelX;
}
diff --git a/libjava/javax/swing/text/View.java b/libjava/javax/swing/text/View.java
index 730753a342b..f9e44a90f54 100644
--- a/libjava/javax/swing/text/View.java
+++ b/libjava/javax/swing/text/View.java
@@ -40,7 +40,7 @@ package javax.swing.text;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Shape;
-import java.util.Vector;
+
import javax.swing.SwingConstants;
public abstract class View implements SwingConstants
diff --git a/libjava/javax/swing/text/html/HTML.java b/libjava/javax/swing/text/html/HTML.java
index 7a24036317f..098a14715cb 100644
--- a/libjava/javax/swing/text/html/HTML.java
+++ b/libjava/javax/swing/text/html/HTML.java
@@ -59,6 +59,11 @@ public class HTML
public static class UnknownTag extends Tag implements Serializable
{
+ /**
+ * For compatability with Sun's JDK 1.4.2 rev. 5
+ */
+ private static final long serialVersionUID = -1534369342247250625L;
+
public UnknownTag(String id)
{
super(id);
OpenPOWER on IntegriCloud