|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.text.JTextComponent
javax.swing.JEditorPane
javax.swing.JTextPane
proyecto.editor.JavaTextPane
public class JavaTextPane
El componente de texto que hemos seleccionado admite texto con cierto formato: texto plano, HTML y RTF por defecto, aunque en nuestro caso lo hemos ampliado para nuestro uso específico. También nos admite mezclar fuentes y colores, dichas características asociadas a las cadenas de texto se realizan a través de los estilos. Un estilo es un conjunto de características como son: FontSize, ForegroundColor, isBold, isItalic, etc. y se manipula a través de constantes del estilo( StyleConstants.setForeground( estilo,Color.red )).
Para todas estas necesidades ampliamos la clase DefaultStyledDocument para poder colorear las palabras según nos indique nuestro analizador léxico.
El coloreado lo hacemos a través del Threard Colorer que es el encargado de llamar a léxico para que nos defina el estilo de pintado. La llamada al coloreado lo hacemos desde la subclase HighLightedDocument en los métodos de insertString
De todo el proceso del reconocedor se encarga la librería agregada a nuestro proyecto syntax.jar.
Vamos a comentar algunas características importantes de la librería:
JTextPane
,
Serialized FormNested Class Summary | |
---|---|
(package private) class |
JavaTextPane.DocPosition
A wrapper for a position in a document appropriate for storing in a collection. |
(package private) class |
JavaTextPane.DocPositionComparator
A comparator appropriate for use with Collections of DocPositions. |
(package private) class |
JavaTextPane.DocumentReader
A reader interface for an abstract document. |
Nested classes/interfaces inherited from class javax.swing.JEditorPane |
---|
JEditorPane.AccessibleJEditorPane, JEditorPane.AccessibleJEditorPaneHTML, JEditorPane.JEditorPaneAccessibleHypertextSupport |
Nested classes/interfaces inherited from class javax.swing.text.JTextComponent |
---|
JTextComponent.AccessibleJTextComponent, JTextComponent.DropLocation, JTextComponent.KeyBinding |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected proyecto.editor.JavaTextPane.Colorer |
colorer
colorer. |
protected proyecto.editor.JavaTextPane.HighLightedDocument |
document
document. |
protected JavaTextPane.DocumentReader |
documentReader
document reader. |
(package private) PanelEdicion |
ipPanelEdicion
ip panel edicion. |
protected com.Ostermiller.Syntax.Lexer.Lexer |
syntaxLexer
|
protected StringBuffer |
textoFormImpri
texto form impri. |
Fields inherited from class javax.swing.JEditorPane |
---|
HONOR_DISPLAY_PROPERTIES, W3C_LENGTH_UNITS |
Fields inherited from class javax.swing.text.JTextComponent |
---|
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
JavaTextPane()
Constructor java text pane. |
|
JavaTextPane(PanelEdicion aPanel,
StyleContext aStyleContext,
String texto)
Constructor java text pane. |
Method Summary | |
---|---|
void |
color(int position,
int adjustment)
Color a section of document. actual coloring will start somewhere before requested position and continue as long as needed. |
void |
colorAll()
COloreamos entero nuestro documento. |
void |
copiar()
Copiar. |
void |
cortar()
Cortar. |
void |
deshacer()
Undo. |
void |
formatearCodigo()
formatearCodigo. |
boolean |
getCambios()
Obtener el cambios. |
boolean |
getOkImprimir()
Obtener el ok imprimir. |
PanelEdicion |
getPanelEdicion()
Obtener el panel edicion. |
boolean |
getScrollableTracksViewportWidth()
(non-Javadoc) Forma de hacer LineWrap al TextPane |
StringBuffer |
getTextoFormateadoImprir()
Obtener el texto formateado imprir. |
void |
imprimir()
Imprimir. |
void |
pegar()
Pegar. |
void |
rehacer()
Redo. |
void |
selecionarTodo()
Selecionar todo. |
void |
setCambios(boolean aValor)
Modificar la propiedad cambios. |
void |
setCursorANumeroLinea(int linenumber)
Modificar la propiedad del caret. |
void |
setOkImprimir(boolean okImprimir)
Modificar la propiedad ok imprimir. |
void |
setTabs(JTextPane textPane,
int aCaracteresParaTab)
setTabs Establece a nuestro JTextPane los tabuladores, no cuenta por carecteres sino por píxeles. |
void |
setUndoManager()
Modifica la propiedad undo manager. |
void |
suprimir()
Suprimir. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
PanelEdicion ipPanelEdicion
protected proyecto.editor.JavaTextPane.HighLightedDocument document
protected JavaTextPane.DocumentReader documentReader
protected com.Ostermiller.Syntax.Lexer.Lexer syntaxLexer
Lexer
protected proyecto.editor.JavaTextPane.Colorer colorer
protected StringBuffer textoFormImpri
Constructor Detail |
---|
public JavaTextPane()
public JavaTextPane(PanelEdicion aPanel, StyleContext aStyleContext, String texto)
aPanel
- a panelaStyleContext
- a style contexttexto
- textoMethod Detail |
---|
public void setUndoManager()
public void setTabs(JTextPane textPane, int aCaracteresParaTab)
Establece a nuestro JTextPane los tabuladores, no cuenta por carecteres sino por píxeles.
textPane
- textPaneaCaracteresParaTab
- caracteres para los tabpublic void setCursorANumeroLinea(int linenumber)
Para colocar el caret en la linea que queremos
linenumber
- Numero lineapublic boolean getScrollableTracksViewportWidth()
getScrollableTracksViewportWidth
in interface Scrollable
getScrollableTracksViewportWidth
in class JEditorPane
JEditorPane.getScrollableTracksViewportWidth()
public PanelEdicion getPanelEdicion()
public boolean getCambios()
public void setCambios(boolean aValor)
aValor
- La propiedad cambiospublic void deshacer()
public void formatearCodigo()
public void rehacer()
public void copiar()
public void pegar()
public void cortar()
public void selecionarTodo()
public void suprimir()
public void colorAll()
public void color(int position, int adjustment)
position
- starting point for coloring.adjustment
- amount of text inserted or removed at starting point.public StringBuffer getTextoFormateadoImprir()
public void imprimir()
public boolean getOkImprimir()
public void setOkImprimir(boolean okImprimir)
okImprimir
- La propiedad ok imprimir
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |