uk.ac.starlink.ast.gui
Class FontControls

java.lang.Object
  extended by uk.ac.starlink.ast.gui.FontControls

public class FontControls
extends Object

FontControls add a series of controls for selecting from the available families of fonts and assigning a size and style.

This class assumes that it will be laying out its components using the standard GridBagLayouter.

Users of this class should implement the FontChangedListener interface to be informed when the selected font is updated.

Version:
$Id$
Author:
Peter W. Draper

Field Summary
protected  String currentFont
          Selected font name
protected  int currentSize
          Selected font size.
protected  int currentStyle
          Selected font style.
protected  JComboBox fontBox
          List of all available font families.
protected  EventListenerList listeners
           
protected  JComboBox sizeBox
          List of pre-selected sizes.
protected  JComboBox styleBox
          List of possible styles.
protected static int[] styleInts
          Styles as indexed array.
protected static String[] styleStrings
          Styles as formatted string.
 
Constructor Summary
FontControls(GridBagLayouter layouter, String postfix)
          Construct an instance.
 
Method Summary
protected  void addFonts()
          Add all the available fonts.
 void addListener(FontChangedListener l)
          Registers a listener who wants to be informed about font changes.
protected  void fireChanged()
          Send FontChangedEvent event to all listeners.
 Font getSelectedFont()
          Get the selected font.
 void setDefaults()
          Set/reset interface to default values.
 void setFont(Font font)
          Set the control to match a given font.
protected  void setFontName()
          Set a new default font name from the value in the font name combobox.
protected  void setSize()
          Set a new default font size from the value in the size combobox.
protected  void setStyle()
          Set the font style from the value in the style combobox.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

styleBox

protected JComboBox styleBox
List of possible styles.


sizeBox

protected JComboBox sizeBox
List of pre-selected sizes.


fontBox

protected JComboBox fontBox
List of all available font families.


currentFont

protected String currentFont
Selected font name


currentSize

protected int currentSize
Selected font size.


currentStyle

protected int currentStyle
Selected font style.


styleStrings

protected static final String[] styleStrings
Styles as formatted string.


styleInts

protected static final int[] styleInts
Styles as indexed array.


listeners

protected EventListenerList listeners
Constructor Detail

FontControls

public FontControls(GridBagLayouter layouter,
                    String postfix)
Construct an instance. Add the postfix to the standard labels (set to "" for none).

Method Detail

setDefaults

public void setDefaults()
Set/reset interface to default values.


addFonts

protected void addFonts()
Add all the available fonts.


setFontName

protected void setFontName()
Set a new default font name from the value in the font name combobox.


setSize

protected void setSize()
Set a new default font size from the value in the size combobox.


setStyle

protected void setStyle()
Set the font style from the value in the style combobox.


getSelectedFont

public Font getSelectedFont()
Get the selected font.


setFont

public void setFont(Font font)
Set the control to match a given font. If null then the default font is used.


addListener

public void addListener(FontChangedListener l)
Registers a listener who wants to be informed about font changes.

Parameters:
l - the FontChangedListener listener.

fireChanged

protected void fireChanged()
Send FontChangedEvent event to all listeners.



Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.