org.netbeans.modules.editor.lib/3 3.23.0 19

org.netbeans.editor
Class Coloring

java.lang.Object
  extended by org.netbeans.editor.Coloring
All Implemented Interfaces:
Serializable

public final class Coloring
extends Object
implements Serializable

Immutable class that stores font and foreground and background colors. The coloring can be applied to either the drawing context, component or some other coloring. Applying first checks whether each of the font and the colors is non-null. If it's null the particular thing is left unchanged. For example to change the background color only the Coloring must be created with the font and foreground color being null. It's also possible to use a more advanced way to apply the coloring by using the modes. There are two modes - font-mode and color-mode. The deafult font-mode simply overwrites the whole font. The font-mode constants allow to change the underlying font by only changing some of the font-name, style or size. The FONT_MODE_APPLY_STYLE for example will only apply the style of the coloring's font. The "rest" of the coloring's font (name and size in this case) is not used so there can be any valid values ("Monospaced" and 12 for example). The colors can use the alpha value. It's also possible to set the color of the underline line or the color of the strikethrough line. Generally the editor uses two sets of the colorings to colorize the text. They are component-set and printing-set. The component-set is used for the editor component while the printing-set is used solely for colorizing the printed text.

See Also:
Serialized Form

Field Summary
static int FONT_MODE_APPLY_NAME
          Apply only the name from the font.
static int FONT_MODE_APPLY_SIZE
          Apply only the size from the font.
static int FONT_MODE_APPLY_STYLE
          Apply only the style from the font.
static int FONT_MODE_DEFAULT
          Replace the underlying font by the coloring's font.
 
Constructor Summary
Coloring()
          Construct empty coloring
Coloring(Font font, Color foreColor, Color backColor)
          Construct new coloring
Coloring(Font font, int fontMode, Color foreColor, Color backColor)
          Construct new coloring
Coloring(Font font, int fontMode, Color foreColor, Color backColor, Color underlineColor, Color strikeThroughColor)
          Construct new coloring
Coloring(Font font, int fontMode, Color foreColor, Color backColor, Color underlineColor, Color strikeThroughColor, Color waveUnderlineColor)
          Construct new coloring
Coloring(Font font, int fontMode, Color foreColor, Color backColor, Color underlineColor, Color strikeThroughColor, Color waveUnderlineColor, Color topBorderLineColor, Color rightBorderLineColor, Color bottomBorderLineColor, Color leftBorderLineColor)
           
 
Method Summary
 Coloring apply(Coloring c)
          Apply this coloring to some other coloring c and return the resulting coloring.
 void apply(JComponent c)
          Apply this coloring to component colors/font.
static Coloring changeBackColor(Coloring c, Color newBackColor)
          Derive a new coloring by changing the background-color and its color-mode and leaving the rest of the coloring unchanged.
static Coloring changeFont(Coloring c, Font newFont)
          Derive a new coloring by changing the font and leaving the rest of the coloring (including the font-mode) unchanged.
static Coloring changeFont(Coloring c, Font newFont, int newFontMode)
          Derive a new coloring by changing the font and font-mode and leaving the rest of the coloring unchanged.
static Coloring changeForeColor(Coloring c, Color newForeColor)
          Derive a new coloring by changing the foreground-color and its color-mode and leaving the rest of the coloring unchanged.
 boolean equals(Object o)
          All font, foreColor and backColor are the same.
static Coloring fromAttributeSet(AttributeSet as)
          Converts AttributeSet to a Coloring.
 Color getBackColor()
          Getter for background color
 Color getBottomBorderLineColor()
          Getter for bottom border line color
 Font getFont()
          Getter for font
 int getFontMode()
          Getter for font-mode
 Color getForeColor()
          Getter for foreground color
 Color getLeftBorderLineColor()
          Getter for left border line color
 Color getRightBorderLineColor()
          Getter for right border line color
 Color getStrikeThroughColor()
          Getter for strikethrough line color
 Color getTopBorderLineColor()
          Getter for top border line color
 Color getUnderlineColor()
          Getter for underline line color
 Color getWaveUnderlineColor()
          Getter for wave underline line color
 int hashCode()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

FONT_MODE_APPLY_NAME

public static final int FONT_MODE_APPLY_NAME
Apply only the name from the font. This flag can be combined with other FONT_MODE flags. When using solely this constant the "rest" of the coloring's font (style and size in this case) is unused so there can be any valid values used to create the font (Font.PLAIN and 12 for example).

See Also:
Constant Field Values

FONT_MODE_APPLY_STYLE

public static final int FONT_MODE_APPLY_STYLE
Apply only the style from the font. This flag can be combined with other FONT_MODE flags. When using solely this constant the "rest" of the coloring's font (name and size in this case) is unused so there can be any valid values used ("Monospaced" and 12 for example).

See Also:
Constant Field Values

FONT_MODE_APPLY_SIZE

public static final int FONT_MODE_APPLY_SIZE
Apply only the size from the font. This flag can be combined with other FONT_MODE flags. When using solely this constant the "rest" of the coloring's font (name and style in this case) is unused so there can be any valid values used to create the font ("Monospaced" and Font.PLAIN for example).

See Also:
Constant Field Values

FONT_MODE_DEFAULT

public static final int FONT_MODE_DEFAULT
Replace the underlying font by the coloring's font. This value is a binary combination of FONT_MODE_APPLY_NAME, FONT_MODE_APPLY_STYLE, FONT_MODE_APPLY_SIZE.

See Also:
Constant Field Values
Constructor Detail

Coloring

public Coloring()
Construct empty coloring


Coloring

public Coloring(Font font,
                Color foreColor,
                Color backColor)
Construct new coloring


Coloring

public Coloring(Font font,
                int fontMode,
                Color foreColor,
                Color backColor)
Construct new coloring


Coloring

public Coloring(Font font,
                int fontMode,
                Color foreColor,
                Color backColor,
                Color underlineColor,
                Color strikeThroughColor)
Construct new coloring


Coloring

public Coloring(Font font,
                int fontMode,
                Color foreColor,
                Color backColor,
                Color underlineColor,
                Color strikeThroughColor,
                Color waveUnderlineColor)
Construct new coloring


Coloring

public Coloring(Font font,
                int fontMode,
                Color foreColor,
                Color backColor,
                Color underlineColor,
                Color strikeThroughColor,
                Color waveUnderlineColor,
                Color topBorderLineColor,
                Color rightBorderLineColor,
                Color bottomBorderLineColor,
                Color leftBorderLineColor)
Since:
1.22
Method Detail

getFont

public Font getFont()
Getter for font


getFontMode

public int getFontMode()
Getter for font-mode


getForeColor

public Color getForeColor()
Getter for foreground color


getBackColor

public Color getBackColor()
Getter for background color


getUnderlineColor

public Color getUnderlineColor()
Getter for underline line color


getWaveUnderlineColor

public Color getWaveUnderlineColor()
Getter for wave underline line color


getStrikeThroughColor

public Color getStrikeThroughColor()
Getter for strikethrough line color


getTopBorderLineColor

public Color getTopBorderLineColor()
Getter for top border line color

Since:
1.22

getRightBorderLineColor

public Color getRightBorderLineColor()
Getter for right border line color

Since:
1.22

getBottomBorderLineColor

public Color getBottomBorderLineColor()
Getter for bottom border line color

Since:
1.22

getLeftBorderLineColor

public Color getLeftBorderLineColor()
Getter for left border line color

Since:
1.22

apply

public void apply(JComponent c)
Apply this coloring to component colors/font. The underline and strikeThrough line colors have no effect here.


apply

public Coloring apply(Coloring c)
Apply this coloring to some other coloring c and return the resulting coloring.

Parameters:
c - coloring to which this coloring will be applied. If it's null then this coloring will be returned as result.

equals

public boolean equals(Object o)
All font, foreColor and backColor are the same.

Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

changeFont

public static Coloring changeFont(Coloring c,
                                  Font newFont)
Derive a new coloring by changing the font and leaving the rest of the coloring (including the font-mode) unchanged.


changeFont

public static Coloring changeFont(Coloring c,
                                  Font newFont,
                                  int newFontMode)
Derive a new coloring by changing the font and font-mode and leaving the rest of the coloring unchanged.


changeForeColor

public static Coloring changeForeColor(Coloring c,
                                       Color newForeColor)
Derive a new coloring by changing the foreground-color and its color-mode and leaving the rest of the coloring unchanged.


changeBackColor

public static Coloring changeBackColor(Coloring c,
                                       Color newBackColor)
Derive a new coloring by changing the background-color and its color-mode and leaving the rest of the coloring unchanged.


toString

public String toString()
Overrides:
toString in class Object

fromAttributeSet

public static Coloring fromAttributeSet(AttributeSet as)
Converts AttributeSet to a Coloring. This method will extract any font related information as well as the 'well-known' colors from the AttributeSet passed in and will use them for creating a Coloring instance that will be returned.

The list of supported colors:

Parameters:
as - The AttributeSet to convert.
Returns:
Coloring that will contain font and color information from the supplied AttributeSet.
Since:
1.11

org.netbeans.modules.editor.lib/3 3.23.0 19

Built on May 22 2012.  |  Portions Copyright 1997-2012 Oracle. All rights reserved.