API java : MinimalHTMLWriter


javax.swing.text.html
Class MinimalHTMLWriter

java.lang.Object
  extended by javax.swing.text.AbstractWriter
      extended by javax.swing.text.html.MinimalHTMLWriter

public class MinimalHTMLWriter
extends AbstractWriter

MinimalHTMLWriter is a fallback writer used by the HTMLEditorKit to write out HTML for a document that is a not produced by the EditorKit. The format for the document is:

  1. <head>
  2. <!-- list of named styles
  3. p.normal {
  4. font-family: SansSerif;
  5. margin-height: 0;
  6. font-size: 14
  7. }
  8. -->
  9. </style>
  10. </head>
  11. <body>
  12. <p style=normal>
  13. <b>Bold, italic, and underline attributes
  14. of the run are emitted as HTML tags.
  15. The remaining attributes are emitted as
  16. part of the style attribute of a <span> tag.
  17. The syntax is similar to inline styles.</b>
  18. </p>
  19. </body>
  20. </html>


Field Summary
 
Fields inherited from class javax.swing.text.AbstractWriter
NEWLINE
 
Constructor Summary
MinimalHTMLWriter(Writer w, StyledDocument doc)
          Creates a new MinimalHTMLWriter.
MinimalHTMLWriter(Writer w, StyledDocument doc, int pos, int len)
          Creates a new MinimalHTMLWriter.
 
Method Summary
protected  void endFontTag()
          This is no longer used, instead <span> will be written out.
protected  boolean inFontTag()
          Returns true if we are currently in a <font> tag.
protected  boolean isText(Element elem)
          Returns true if the element is a text element.
protected  void startFontTag(String style)
          This is no longer used, instead <span> will be written out.
protected  void text(Element elem)
          Writes out text.
 void write()
          Generates HTML output from a StyledDocument.
protected  void writeAttributes(AttributeSet attr)
          Writes out all the attributes for the following types: StyleConstants.ParagraphConstants, StyleConstants.CharacterConstants, StyleConstants.FontConstants, StyleConstants.ColorConstants.
protected  void writeBody()
          Iterates over the elements in the document and processes elements based on whether they are branch elements or leaf elements.
protected  void writeComponent(Element elem)
          Responsible for handling Component Elements; deliberately unimplemented.
protected  void writeContent(Element elem, boolean needsIndenting)
          Writes out the attribute set in an HTML-compliant manner.
protected  void writeEndParagraph()
          Emits an end tag for a <p> tag.
protected  void writeEndTag(String endTag)
          Writes out an end tag appropriately indented.
protected  void writeHeader()
          Writes out the <head> and <style> tags, and then invokes writeStyles() to write out all the named styles as the content of the <style> tag.
protected  void writeHTMLTags(AttributeSet attr)
          Generates bold <b>, italic <i>, and <u> tags for the text based on its attribute settings.
protected  void writeImage(Element elem)
          Responsible for handling Icon Elements; deliberately unimplemented.
protected  void writeLeaf(Element elem)
          Responsible for writing out other non-text leaf elements.
protected  void writeNonHTMLAttributes(AttributeSet attr)
          Writes out the remaining character-level attributes (attributes other than bold, italic, and underline) in an HTML-compliant way.
protected  void writeStartParagraph(Element elem)
          Emits the start tag for a paragraph.
protected  void writeStartTag(String tag)
          Writes out a start tag appropriately indented.
protected  void writeStyles()
          Writes out all the named styles as the content of the <style> tag.
 
Methods inherited from class javax.swing.text.AbstractWriter
decrIndent, getCanWrapLines, getCurrentLineLength, getDocument, getElementIterator, getEndOffset, getIndentLevel, getIndentSpace, getLineLength, getLineSeparator, getStartOffset, getText, getWriter, incrIndent, indent, inRange, isLineEmpty, output, setCanWrapLines, setCurrentLineLength, setIndentSpace, setLineLength, setLineSeparator, write, write, write, writeLineSeparator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MinimalHTMLWriter

public MinimalHTMLWriter(Writer w,
                         StyledDocument doc)
Creates a new MinimalHTMLWriter.

Parameters:
w - Writer
doc - StyledDocument

MinimalHTMLWriter

public MinimalHTMLWriter(Writer w,
                         StyledDocument doc,
                         int pos,
                         int len)
Creates a new MinimalHTMLWriter.

Parameters:
w - Writer
doc - StyledDocument
pos - The location in the document to fetch the content.
len - The amount to write out.
Method Detail

write

public void write()
           throws IOException,
                  BadLocationException
Generates HTML output from a StyledDocument.

Specified by:
write in class AbstractWriter
Throws:
IOException - on any I/O error
BadLocationException - if pos represents an invalid location within the document.

writeAttributes

protected void writeAttributes(AttributeSet attr)
                        throws IOException
Writes out all the attributes for the following types: StyleConstants.ParagraphConstants, StyleConstants.CharacterConstants, StyleConstants.FontConstants, StyleConstants.ColorConstants. The attribute name and value are separated by a colon. Each pair is separated by a semicolon.

Overrides:
writeAttributes in class AbstractWriter
Parameters:
attr - an AttributeSet.
Throws:
IOException - on any I/O error

text

protected void text(Element elem)
             throws IOException,
                    BadLocationException
Writes out text.

Overrides:
text in class AbstractWriter
Parameters:
elem - an Element.
Throws:
IOException - on any I/O error
BadLocationException - if pos represents an invalid location within the document.

writeStartTag

protected void writeStartTag(String tag)
                      throws IOException
Writes out a start tag appropriately indented. Also increments the indent level.

Throws:
IOException - on any I/O error

writeEndTag

protected void writeEndTag(String endTag)
                    throws IOException
Writes out an end tag appropriately indented. Also decrements the indent level.

Throws:
IOException - on any I/O error

writeHeader

protected void writeHeader()
                    throws IOException
Writes out the <head> and <style> tags, and then invokes writeStyles() to write out all the named styles as the content of the <style> tag. The content is surrounded by valid HTML comment markers to ensure that the document is viewable in applications/browsers that do not support the tag.

Throws:
IOException - on any I/O error

writeStyles

protected void writeStyles()
                    throws IOException
Writes out all the named styles as the content of the <style> tag.

Throws:
IOException - on any I/O error

writeBody

protected void writeBody()
                  throws IOException,
                         BadLocationException
Iterates over the elements in the document and processes elements based on whether they are branch elements or leaf elements. This method specially handles leaf elements that are text.

Throws:
IOException - on any I/O error
BadLocationException

writeEndParagraph

protected void writeEndParagraph()
                          throws IOException
Emits an end tag for a <p> tag. Before writing out the tag, this method ensures that all other tags that have been opened are appropriately closed off.

Throws:
IOException - on any I/O error

writeStartParagraph

protected void writeStartParagraph(Element elem)
                            throws IOException
Emits the start tag for a paragraph. If the paragraph has a named style associated with it, then this method also generates a class attribute for the <p> tag and sets its value to be the name of the style.

Throws:
IOException - on any I/O error

writeLeaf

protected void writeLeaf(Element elem)
                  throws IOException
Responsible for writing out other non-text leaf elements.

Throws:
IOException - on any I/O error

writeImage

protected void writeImage(Element elem)
                   throws IOException
Responsible for handling Icon Elements; deliberately unimplemented. How to implement this method is an issue of policy. For example, if you're generating an <img> tag, how should you represent the src attribute (the location of the image)? In certain cases it could be a URL, in others it could be read from a stream.

Parameters:
elem - element of type StyleConstants.IconElementName
Throws:
IOException

writeComponent

protected void writeComponent(Element elem)
                       throws IOException
Responsible for handling Component Elements; deliberately unimplemented. How this method is implemented is a matter of policy.

Throws:
IOException

isText

protected boolean isText(Element elem)
Returns true if the element is a text element.


writeContent

protected void writeContent(Element elem,
                            boolean needsIndenting)
                     throws IOException,
                            BadLocationException
Writes out the attribute set in an HTML-compliant manner.

Throws:
IOException - on any I/O error
BadLocationException - if pos represents an invalid location within the document.

writeHTMLTags

protected void writeHTMLTags(AttributeSet attr)
                      throws IOException
Generates bold <b>, italic <i>, and <u> tags for the text based on its attribute settings.

Throws:
IOException - on any I/O error

writeNonHTMLAttributes

protected void writeNonHTMLAttributes(AttributeSet attr)
                               throws IOException
Writes out the remaining character-level attributes (attributes other than bold, italic, and underline) in an HTML-compliant way. Given that attributes such as font family and font size have no direct mapping to HTML tags, a <span> tag is generated and its style attribute is set to contain the list of remaining attributes just like inline styles.

Throws:
IOException - on any I/O error

inFontTag

protected boolean inFontTag()
Returns true if we are currently in a <font> tag.


endFontTag

protected void endFontTag()
                   throws IOException
This is no longer used, instead <span> will be written out.

Writes out an end tag for the <font> tag.

Throws:
IOException - on any I/O error

startFontTag

protected void startFontTag(String style)
                     throws IOException
This is no longer used, instead <span> will be written out.

Writes out a start tag for the <font> tag. Because font tags cannot be nested, this method closes out any enclosing font tag before writing out a new start tag.

Throws:
IOException - on any I/O error

Ces informations proviennent du site de http://java.sun.com

Remarques

Contenu

Le contenu de cette page provient du site de Sun, et est généré depuis un cache sur l'infobrol après certains traitements automatisés. La présentation peut donc différer du document original, mais le contenu aussi. Vous pouvez utiliser ce bouton pour afficher la page originale du site de Sun :

Quels sont les motivations de cette démarche?

Maintenir les pages en cache sur différents sites peut offrir plus de disponibilité.

Chaque page est indexée dans la base de donnée, ce qui permet de retrouver facilement les informations, au moyen des sommaires, du moteur de recherche interne, etc.

Des facilités sont mises en place pour que les membres de l'infobrol puissent effectuer des traductions en français des différents documents. Ceci devrait permettre aux débutants en programmation Java de consulter les API en français s'ils maîtrisent moins bien la langue de Shakespeare. Dans le cas où une traduction a été soumise, elle est disponible au moyen d'un lien en bas de page. Si la traduction a été validée, la page s'affiche par défaut en français, et un lien en bas de page permet d'atteindre la version en anglais.

Le code sur l'infobrol est automatiquement coloré selon la syntaxe, et les différents mots clés sont transformés en liens pour accéder rapidement aux informations.

Vous avez la possibilité de partager vos expériences en proposant vos propres extraits de code en utilisant le bouton "ajouter un commentaire" en bas de page. Si vous visitez simplement l'infobrol, vous avez déjà accès à cette fonction, mais si vous étes membre du brol, vous pouvez en plus utiliser des boutons supplémentaires de mise en forme, dont la coloration automatique de vos extraits de codes.

Réseaux sociaux

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.

 

Nuage de mots clés

7 mots clés dont 0 définis manuellement (plus d'information...).

Avertissement

Cette page ne possède pas encore de mots clés manuels, ceci est donc un exemple automatique (les niveaux de pertinence sont fictifs, mais les liens sont valables). Pour tester le nuage avec une page qui contient des mots définis manuellement, vous pouvez cliquer ici.

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.

 

Astuce pour imprimer les couleurs des cellules de tableaux : http://www.gaudry.be/ast-rf-450.html
Aucun commentaire pour cette page

© Ce document issu de l′infobrol est enregistré sous le certificat Cyber PrInterDeposit Digital Numbertection. Enregistrement IDDN n° 5329-2985
Document créé le 01/09/06 00:00, dernière modification le Vendredi 17 Juin 2011, 12:12
Source du document imprimé : http://www.gaudry.be/java-api-rf-javax/swing/text/html/MinimalHTMLWriter.html Document affiché 1 fois ce mois de Juin.
St.Gaudry©07.01.02
Outils (masquer)
||
Recherche (afficher)
Recherche :

Utilisateur (masquer)
Navigation (masquer)
Apparence (afficher)
Stats (afficher)
15832 documents
452 astuces.
549 niouzes.
3099 definitions.
447 membres.
8115 messages.

Document genere en :
0,39 seconde

Mises à jour :
Mises à jour du site
Citation (masquer)
Il est parfois des regards d'enfant qui vous entraînent si loin dans vos souvenirs, qu'il est impossible de rester sans réponse à la question posée.

Marc Levy [Extrait de Et si c'était vrai...]
 
l'infobrol
Nous sommes le Samedi 02 Juin 2012, 09:24, toutes les heures sont au format GMT+1.00 Heure, heure d'été (+1)