API java : StyledDocument


javax.swing.text
Interface StyledDocument

All Superinterfaces:
Document
All Known Implementing Classes:
DefaultStyledDocument, HTMLDocument

public interface StyledDocument
extends Document

Interface for a generic styled document.


Field Summary
 
Fields inherited from interface javax.swing.text.Document
StreamDescriptionProperty, TitleProperty
 
Method Summary
 Style addStyle(String nm, Style parent)
          Adds a new style into the logical style hierarchy.
 Color getBackground(AttributeSet attr)
          Takes a set of attributes and turn it into a background color specification.
 Element getCharacterElement(int pos)
          Gets the element that represents the character that is at the given offset within the document.
 Font getFont(AttributeSet attr)
          Takes a set of attributes and turn it into a font specification.
 Color getForeground(AttributeSet attr)
          Takes a set of attributes and turn it into a foreground color specification.
 Style getLogicalStyle(int p)
          Gets a logical style for a given position in a paragraph.
 Element getParagraphElement(int pos)
          Gets the element that represents the paragraph that encloses the given offset within the document.
 Style getStyle(String nm)
          Fetches a named style previously added.
 void removeStyle(String nm)
          Removes a named style previously added to the document.
 void setCharacterAttributes(int offset, int length, AttributeSet s, boolean replace)
          Changes the content element attributes used for the given range of existing content in the document.
 void setLogicalStyle(int pos, Style s)
          Sets the logical style to use for the paragraph at the given position.
 void setParagraphAttributes(int offset, int length, AttributeSet s, boolean replace)
          Sets paragraph attributes.
 
Methods inherited from interface javax.swing.text.Document
addDocumentListener, addUndoableEditListener, createPosition, getDefaultRootElement, getEndPosition, getLength, getProperty, getRootElements, getStartPosition, getText, getText, insertString, putProperty, remove, removeDocumentListener, removeUndoableEditListener, render
 

Method Detail

addStyle

Style addStyle(String nm,
               Style parent)
Adds a new style into the logical style hierarchy. Style attributes resolve from bottom up so an attribute specified in a child will override an attribute specified in the parent.

Parameters:
nm - the name of the style (must be unique within the collection of named styles). The name may be null if the style is unnamed, but the caller is responsible for managing the reference returned as an unnamed style can't be fetched by name. An unnamed style may be useful for things like character attribute overrides such as found in a style run.
parent - the parent style. This may be null if unspecified attributes need not be resolved in some other style.
Returns:
the style

removeStyle

void removeStyle(String nm)
Removes a named style previously added to the document.

Parameters:
nm - the name of the style to remove

getStyle

Style getStyle(String nm)
Fetches a named style previously added.

Parameters:
nm - the name of the style
Returns:
the style

setCharacterAttributes

void setCharacterAttributes(int offset,
                            int length,
                            AttributeSet s,
                            boolean replace)
Changes the content element attributes used for the given range of existing content in the document. All of the attributes defined in the given Attributes argument are applied to the given range. This method can be used to completely remove all content level attributes for the given range by giving an Attributes argument that has no attributes defined and setting replace to true.

Parameters:
offset - the start of the change >= 0
length - the length of the change >= 0
s - the non-null attributes to change to. Any attributes defined will be applied to the text for the given range.
replace - indicates whether or not the previous attributes should be cleared before the new attributes as set. If true, the operation will replace the previous attributes entirely. If false, the new attributes will be merged with the previous attributes.

setParagraphAttributes

void setParagraphAttributes(int offset,
                            int length,
                            AttributeSet s,
                            boolean replace)
Sets paragraph attributes.

Parameters:
offset - the start of the change >= 0
length - the length of the change >= 0
s - the non-null attributes to change to. Any attributes defined will be applied to the text for the given range.
replace - indicates whether or not the previous attributes should be cleared before the new attributes are set. If true, the operation will replace the previous attributes entirely. If false, the new attributes will be merged with the previous attributes.

setLogicalStyle

void setLogicalStyle(int pos,
                     Style s)
Sets the logical style to use for the paragraph at the given position. If attributes aren't explicitly set for character and paragraph attributes they will resolve through the logical style assigned to the paragraph, which in turn may resolve through some hierarchy completely independent of the element hierarchy in the document.

Parameters:
pos - the starting position >= 0
s - the style to set

getLogicalStyle

Style getLogicalStyle(int p)
Gets a logical style for a given position in a paragraph.

Parameters:
p - the position >= 0
Returns:
the style

getParagraphElement

Element getParagraphElement(int pos)
Gets the element that represents the paragraph that encloses the given offset within the document.

Parameters:
pos - the offset >= 0
Returns:
the element

getCharacterElement

Element getCharacterElement(int pos)
Gets the element that represents the character that is at the given offset within the document.

Parameters:
pos - the offset >= 0
Returns:
the element

getForeground

Color getForeground(AttributeSet attr)
Takes a set of attributes and turn it into a foreground color specification. This might be used to specify things like brighter, more hue, etc.

Parameters:
attr - the set of attributes
Returns:
the color

getBackground

Color getBackground(AttributeSet attr)
Takes a set of attributes and turn it into a background color specification. This might be used to specify things like brighter, more hue, etc.

Parameters:
attr - the set of attributes
Returns:
the color

getFont

Font getFont(AttributeSet attr)
Takes a set of attributes and turn it into a font specification. This can be used to turn things like family, style, size, etc into a font that is available on the system the document is currently being used on.

Parameters:
attr - the set of attributes
Returns:
the font

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

6 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-2135
Document créé le 30/08/06 23:23, dernière modification le Vendredi 17 Juin 2011, 12:12
Source du document imprimé : http://www.gaudry.be/java-api-rf-javax/swing/text/StyledDocument.html Document affiché 3 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,38 seconde

Mises à jour :
Mises à jour du site
Citation (masquer)
Ne parlez jamais de vous, ni en bien, car on ne vous croirait pas, ni en mal car on ne vous croirait que trop.

Confucius
 
l'infobrol
Nous sommes le Samedi 02 Juin 2012, 09:21, toutes les heures sont au format GMT+1.00 Heure, heure d'été (+1)