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 boolean
protected Color
protected boolean
protected boolean
static final String
static final int
protected Color
protected Color
protected String
protected int
protected Color
protected boolean
protected boolean
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
protected float
protected float
protected 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 TypeMethodDescriptionvoid
applyTo
(JComponent pane) set style of the target-text-pane bygetTargetStyle(JComponent)
andapplyTo(MutableAttributeSet)
,applyToDocument(StyledDocument, MutableAttributeSet)
andapplyToComponentWithoutDocument(JComponent)
.void
applyTo
(MutableAttributeSet style) update the target style by properties of the prefs, or if remove attributes by null-valuesvoid
set the background and foreground properties (JComponent.setBackground(Color)
andJComponent.setForeground(Color)
) and wrapText bysetWrapLine(JScrollPane, JComponent, boolean)
.void
applyToDocument
(StyledDocument doc, MutableAttributeSet style) set the style of the entire-text of the documentstatic Color
static Color
int
float
float
getTargetDocument
(JComponent pane) getTargetStyle
(JComponent pane) boolean
boolean
isBold()
boolean
boolean
isItalic()
boolean
isWrapLineNotMatch
(JScrollPane pane, boolean tested) boolean
void
loadFrom
(GuiPreferences prefs) void
saveTo
(GuiPreferences prefs) void
setBackgroundColor
(Color backgroundColor) void
setBackgroundCustom
(boolean backgroundCustom) void
setBold
(boolean bold) void
setFontFamily
(String fontFamily) void
setFontSize
(int fontSize) void
setForegroundColor
(Color foregroundColor) void
setForegroundCustom
(boolean foregroundCustom) void
setFrom
(JComponent pane) void
setFrom
(MutableAttributeSet style) set propertis from the given style.void
setItalic
(boolean italic) void
setLineSpacing
(float lineSpacing) void
setSpaceAbove
(float spaceAbove) void
overwrites properties by values fromUIManagerUtil
; alsolineSpacing
is 0.2,spaceAbove
is 2.0, no background and foregorund custom, andwrapText
is true.void
setup
(JComponent pane) callssetup(MutableAttributeSet)
for the document of the pane (getTargetStyle(JComponent)
); andapplyToDocument(StyledDocument, MutableAttributeSet)
for overwritng the style to the entire text.void
setup
(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-panevoid
setWrapLine
(JScrollPane parentScroll, JComponent field, boolean f) if parentScroll is non-null andisWrapLineNotMatch(JScrollPane, boolean)
with f, changes the wrapping-line byGuiSwingViewDocumentEditor.setWrapLine(JScrollPane, boolean)
.void
setWrapText
(boolean wrapLine) static Object
toJsonColor
(int r, int g, int b, int a) static Object
toJsonColor
(Color c)
-
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
; alsolineSpacing
is 0.2,spaceAbove
is 2.0, no background and foregorund custom, andwrapText
is 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 updatewrapText
andapplyToComponentWithoutDocument(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
-
loadFrom
- Specified by:
loadFrom
in interfaceGuiSwingPrefsSupports.Preferences
-
saveTo
- Specified by:
saveTo
in interfaceGuiSwingPrefsSupports.Preferences
-