Module org.autogui
Package org.autogui.swing
Class GuiSwingViewDocumentEditor.PreferencesForDocumentSetting
java.lang.Object
org.autogui.swing.GuiSwingViewDocumentEditor.PreferencesForDocumentSetting
- All Implemented Interfaces:
GuiSwingPrefsSupports.Preferences
- Enclosing class:
GuiSwingViewDocumentEditor
public static class GuiSwingViewDocumentEditor.PreferencesForDocumentSetting
extends Object
implements GuiSwingPrefsSupports.Preferences
prefs obj for document-settings; currently the settings have properties of entire document styling only for editing plain-texts;
minimize properties.
Currently supports the following properties;
- float
lineSpacing: the factor of spaces between lines.StyleConstants.LineSpacing - float
spaceAbove: points of spaces before the paragraph.StyleConstants.SpaceAbove - String
fontFamily: the name of the font.StyleConstants.FontFamily - int
fontSize: points of the font.StyleConstants.FontSize - boolean
bold: font-style bold.StyleConstants.Bold - boolean
italic: font-style italic.StyleConstants.Italic - boolean
backgroundCustom: the flag for enablingbackgroundColor - boolean
foregroundCustom: the flag for enablingforegroundColor - Color
backgroundColor: the background color. available only ifbackgroundCustom=true.StyleConstants.Background - Color
foreground: the text color. available only ifforegrooundCustom=true.StyleConstants.Foreground - boolean
wrapText: the flag for wrapping-line; can be implemented by horizontal-scroll-bar-policy and preferred-size
- Since:
- 1.7
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected Colorprotected booleanprotected booleanstatic final Stringstatic final intprotected Colorprotected Colorprotected Stringprotected intprotected Colorprotected booleanprotected booleanstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected floatprotected floatprotected boolean -
Constructor Summary
ConstructorsConstructorDescriptioninitialize by null-values and black and white colors.initialize with the target pane (or if null, it sets default null values). -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyTo(JComponent pane) set style of the target-text-pane bygetTargetStyle(JComponent)andapplyTo(MutableAttributeSet),applyToDocument(StyledDocument, MutableAttributeSet)andapplyToComponentWithoutDocument(JComponent).voidapplyTo(MutableAttributeSet style) update the target style by properties of the prefs, or if remove attributes by null-valuesvoidset the background and foreground properties (JComponent.setBackground(Color)andJComponent.setForeground(Color)) and wrapText bysetWrapLine(JScrollPane, JComponent, boolean).voidapplyToDocument(StyledDocument doc, MutableAttributeSet style) set the style of the entire-text of the documentstatic Colorstatic ColorintfloatfloatgetTargetDocument(JComponent pane) getTargetStyle(JComponent pane) booleanbooleanisBold()booleanbooleanisItalic()booleanisWrapLineNotMatch(JScrollPane pane, boolean tested) booleanbooleanloadFromAndChanged(GuiPreferences prefs) voidsaveTo(GuiPreferences prefs) voidsetBackgroundColor(Color backgroundColor) voidsetBackgroundCustom(boolean backgroundCustom) voidsetBold(boolean bold) voidsetFontFamily(String fontFamily) voidsetFontSize(int fontSize) voidsetForegroundColor(Color foregroundColor) voidsetForegroundCustom(boolean foregroundCustom) voidsetFrom(JComponent pane) voidsetFrom(MutableAttributeSet style) set propertis from the given style.voidsetItalic(boolean italic) voidsetLineSpacing(float lineSpacing) voidsetSpaceAbove(float spaceAbove) voidoverwrites properties by values fromUIManagerUtil; alsolineSpacingis 0.2,spaceAboveis 2.0, no background and foregorund custom, andwrapTextis true.voidsetup(JComponent pane) callssetup(MutableAttributeSet)for the document of the pane (getTargetStyle(JComponent)); andapplyToDocument(StyledDocument, MutableAttributeSet)for overwritng the style to the entire text.voidsetup(MutableAttributeSet style) set properties from the given style; only the properties the style have, andapplyTo(MutableAttributeSet)to reflect the all propertis of the prefs to the target-panevoidsetWrapLine(JScrollPane parentScroll, JComponent field, boolean f) if parentScroll is non-null andisWrapLineNotMatch(JScrollPane, boolean)with f, changes the wrapping-line byGuiSwingViewDocumentEditor.setWrapLine(JScrollPane, boolean).voidsetWrapText(boolean wrapLine) static ObjecttoJsonColor(int r, int g, int b, int a) static ObjecttoJsonColor(Color c) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.autogui.swing.prefs.GuiSwingPrefsSupports.Preferences
loadFrom
-
Field Details
-
KEY_LINE_SPACING
- See Also:
-
KEY_SPACE_ABOVE
- See Also:
-
KEY_FONT_FAMILY
- See Also:
-
KEY_FONT_SIZE
- See Also:
-
KEY_BOLD
- See Also:
-
KEY_ITALIC
- See Also:
-
KEY_BACKGROUND_COLOR
- See Also:
-
KEY_FOREGROUND_COLOR
- See Also:
-
KEY_BACKGROUND_CUSTOM
- See Also:
-
KEY_FOREGROUND_CUSTOM
- See Also:
-
KEY_WRAP_TEXT
- See Also:
-
lineSpacing
protected float lineSpacing -
spaceAbove
protected float spaceAbove -
fontFamily
-
fontSize
protected int fontSize -
bold
protected boolean bold -
italic
protected boolean italic -
backgroundColor
-
foregroundColor
-
backgroundCustom
protected boolean backgroundCustom -
foregroundCustom
protected boolean foregroundCustom -
wrapText
protected boolean wrapText -
DEFAULT_FONT_FAMILY
- See Also:
-
DEFAULT_NUM
public static final int DEFAULT_NUM- See Also:
-
defaultBackground
-
defaultForeground
-
allowNullValues
protected boolean allowNullValues
-
-
Constructor Details
-
PreferencesForDocumentSetting
public PreferencesForDocumentSetting()initialize by null-values and black and white colors. -
PreferencesForDocumentSetting
initialize with the target pane (or if null, it sets default null values). it has 2 modes, 1. the property mode with no pane which allows null values for representing saved prefs values, 2. the practical mode with target pane which (basically) does not allow null-values, instead, it merges actual pane's value if null-values arrived.- Parameters:
pane- the target text-pane or null
-
-
Method Details
-
getLineSpacing
public float getLineSpacing() -
getSpaceAbove
public float getSpaceAbove() -
getFontFamily
-
getFontSize
public int getFontSize() -
isBold
public boolean isBold() -
isItalic
public boolean isItalic() -
getBackgroundColor
-
getForegroundColor
-
isBackgroundCustom
public boolean isBackgroundCustom() -
isForegroundCustom
public boolean isForegroundCustom() -
isWrapText
public boolean isWrapText() -
setLineSpacing
public void setLineSpacing(float lineSpacing) -
setSpaceAbove
public void setSpaceAbove(float spaceAbove) -
setFontFamily
-
setFontSize
public void setFontSize(int fontSize) -
setBackgroundColor
-
setForegroundColor
-
setBold
public void setBold(boolean bold) -
setItalic
public void setItalic(boolean italic) -
setBackgroundCustom
public void setBackgroundCustom(boolean backgroundCustom) -
setForegroundCustom
public void setForegroundCustom(boolean foregroundCustom) -
setWrapText
public void setWrapText(boolean wrapLine) -
setUiDefault
public void setUiDefault()overwrites properties by values fromUIManagerUtil; alsolineSpacingis 0.2,spaceAboveis 2.0, no background and foregorund custom, andwrapTextis true. -
toJsonColor
-
toJsonColor
-
fromJsonColorSource
-
fromJsonColor
-
setFrom
set propertis from the given style. if the style has no attribute-value, the property will be the null-value.- Parameters:
style- the source style can beStyle
-
setFrom
- Parameters:
pane- the target-text-pane- See Also:
-
setup
set properties from the given style; only the properties the style have, andapplyTo(MutableAttributeSet)to reflect the all propertis of the prefs to the target-pane- Parameters:
style- the source style
-
setup
callssetup(MutableAttributeSet)for the document of the pane (getTargetStyle(JComponent)); andapplyToDocument(StyledDocument, MutableAttributeSet)for overwritng the style to the entire text. Also updatewrapTextandapplyToComponentWithoutDocument(JComponent)- Parameters:
pane- the target text-pane- See Also:
-
applyTo
update the target style by properties of the prefs, or if remove attributes by null-values- Parameters:
style- the modified style
-
applyTo
set style of the target-text-pane bygetTargetStyle(JComponent)andapplyTo(MutableAttributeSet),applyToDocument(StyledDocument, MutableAttributeSet)andapplyToComponentWithoutDocument(JComponent).- Parameters:
pane- the target text-pane
-
applyToDocument
set the style of the entire-text of the document- Parameters:
doc- the target-document or nullstyle- the stytle to be set
-
applyToComponentWithoutDocument
set the background and foreground properties (JComponent.setBackground(Color)andJComponent.setForeground(Color)) and wrapText bysetWrapLine(JScrollPane, JComponent, boolean). Implementation note: it seemed to change the attributes of the default document-style. So it needs to call the method before updating the style- Parameters:
pane- the target text-pane
-
getTargetDocument
-
getTargetStyle
-
isWrapLineNotMatch
-
setWrapLine
if parentScroll is non-null andisWrapLineNotMatch(JScrollPane, boolean)with f, changes the wrapping-line byGuiSwingViewDocumentEditor.setWrapLine(JScrollPane, boolean). Also if the field is aGuiSwingViewDocumentEditor.WrapLineSupport, callGuiSwingViewDocumentEditor.WrapLineSupport.setWrapLine(boolean)- Parameters:
parentScroll- the parent pane of the fieldfield- the target text-componentf- the new flag value ofwrapText
-
loadFromAndChanged
- Specified by:
loadFromAndChangedin interfaceGuiSwingPrefsSupports.Preferences- Parameters:
prefs- the laoding source- Returns:
- true if a part of the preferences is actually changed
-
saveTo
- Specified by:
saveToin interfaceGuiSwingPrefsSupports.Preferences
-