1 /* StyledEditorKit.java --
2 Copyright (C) 2002, 2004 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package javax
.swing
.text
;
41 import java
.awt
.Color
;
42 import java
.awt
.event
.ActionEvent
;
43 import java
.beans
.PropertyChangeEvent
;
44 import java
.beans
.PropertyChangeListener
;
45 import java
.io
.Serializable
;
47 import javax
.swing
.Action
;
48 import javax
.swing
.JEditorPane
;
49 import javax
.swing
.event
.CaretEvent
;
50 import javax
.swing
.event
.CaretListener
;
55 * @author Andrew Selkirk
57 public class StyledEditorKit
extends DefaultEditorKit
59 private static final long serialVersionUID
= 7002391892985555948L;
64 public static class UnderlineAction
extends StyledEditorKit
.StyledTextAction
67 * Constructor UnderlineAction
69 public UnderlineAction()
79 public void actionPerformed(ActionEvent event
)
88 public static class ItalicAction
extends StyledEditorKit
.StyledTextAction
91 * Constructor ItalicAction
103 public void actionPerformed(ActionEvent event
)
112 public static class BoldAction
extends StyledEditorKit
.StyledTextAction
115 * Constructor BoldAction
127 public void actionPerformed(ActionEvent event
)
136 public static class AlignmentAction
extends StyledEditorKit
.StyledTextAction
144 * Constructor AlignmentAction
148 public AlignmentAction(String nm
, int a
)
158 public void actionPerformed(ActionEvent event
)
167 public static class ForegroundAction
extends StyledEditorKit
.StyledTextAction
175 * Constructor ForegroundAction
179 public ForegroundAction(String nm
, Color fg
)
189 public void actionPerformed(ActionEvent event
)
198 public static class FontSizeAction
extends StyledEditorKit
.StyledTextAction
206 * Constructor FontSizeAction
210 public FontSizeAction(String nm
, int size
)
220 public void actionPerformed(ActionEvent event
)
229 public static class FontFamilyAction
extends StyledEditorKit
.StyledTextAction
234 private String family
;
237 * Constructor FontFamilyAction
241 public FontFamilyAction(String nm
, String family
)
251 public void actionPerformed(ActionEvent event
)
260 public abstract static class StyledTextAction
extends TextAction
263 * Constructor StyledTextAction
266 public StyledTextAction(String nm
)
275 * @returns JEditorPane
277 protected final JEditorPane
getEditor(ActionEvent event
)
283 * setCharacterAttributes
288 protected final void setCharacterAttributes(JEditorPane value0
,
298 * @returns StyledDocument
300 protected final StyledDocument
getStyledDocument(JEditorPane value0
)
308 * @returns StyledEditorKit
310 protected final StyledEditorKit
getStyledEditorKit(JEditorPane value0
)
316 * setParagraphAttributes
321 protected final void setParagraphAttributes(JEditorPane value0
,
332 static class StyledViewFactory
333 implements ViewFactory
336 * Constructor StyledViewFactory
348 public View
create(Element value0
)
357 class AttributeTracker
358 implements CaretListener
, PropertyChangeListener
, Serializable
361 * Constructor AttributeTracker
364 AttributeTracker(StyledEditorKit value0
)
370 * updateInputAttributes
375 void updateInputAttributes(int value0
, int value1
, JTextComponent value2
)
384 public void propertyChange(PropertyChangeEvent value0
)
393 public void caretUpdate(CaretEvent value0
)
407 Element currentParagraph
;
412 MutableAttributeSet inputAttributes
;
415 * Constructor StyledEditorKit
417 public StyledEditorKit()
426 public Object
clone()
435 public Action
[] getActions()
442 * @returns MutableAttributeSet
444 public MutableAttributeSet
getInputAttributes()
450 * getCharacterAttributeRun
453 public Element
getCharacterAttributeRun()
459 * createDefaultDocument
462 public Document
createDefaultDocument()
469 * @param component TODO
471 public void install(JEditorPane component
)
478 * @param component TODO
480 public void deinstall(JEditorPane component
)
487 * @returns ViewFactory
489 public ViewFactory
getViewFactory()
495 * createInputAttributes
496 * @param element TODO
499 protected void createInputAttributes(Element element
, MutableAttributeSet set
)