Clover coverage report -
Coverage timestamp: Sun Apr 18 2004 21:32:30 EDT
file stats: LOC: 602   Methods: 26
NCLOC: 407   Classes: 4
 
 Source file Conditionals Statements Methods TOTAL
FontPanel.java 48.2% 63.7% 65.4% 61%
coverage coverage
 1   
 /*
 2   
  * SimplyHTML, a word processor based on Java, HTML and CSS
 3   
  * Copyright (C) 2002 Ulrich Hilger
 4   
  *
 5   
  * This program is free software; you can redistribute it and/or
 6   
  * modify it under the terms of the GNU General Public License
 7   
  * as published by the Free Software Foundation; either version 2
 8   
  * of the License, or (at your option) any later version.
 9   
  *
 10   
  * This program is distributed in the hope that it will be useful,
 11   
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12   
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13   
  * GNU General Public License for more details.
 14   
  *
 15   
  * You should have received a copy of the GNU General Public License
 16   
  * along with this program; if not, write to the Free Software
 17   
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 18   
  */
 19   
 
 20   
 import javax.swing.JPanel;
 21   
 import javax.swing.JLabel;
 22   
 import javax.swing.JList;
 23   
 import javax.swing.ListSelectionModel;
 24   
 import javax.swing.JScrollPane;
 25   
 import javax.swing.JTextField;
 26   
 import javax.swing.event.ListSelectionListener;
 27   
 import javax.swing.event.ListSelectionEvent;
 28   
 import javax.swing.ListModel;
 29   
 import javax.swing.JButton;
 30   
 import javax.swing.text.StyleConstants;
 31   
 import java.awt.Frame;
 32   
 import java.awt.GraphicsEnvironment;
 33   
 import java.awt.Dimension;
 34   
 import java.awt.GridLayout;
 35   
 import java.awt.BorderLayout;
 36   
 import java.awt.FlowLayout;
 37   
 import java.awt.Component;
 38   
 import javax.swing.SwingConstants;
 39   
 import javax.swing.border.TitledBorder;
 40   
 import javax.swing.border.EtchedBorder;
 41   
 import javax.swing.text.AttributeSet;
 42   
 import javax.swing.text.SimpleAttributeSet;
 43   
 import java.awt.Font;
 44   
 import java.awt.Color;
 45   
 import java.awt.event.ActionListener;
 46   
 import java.awt.event.ActionEvent;
 47   
 import javax.swing.UIManager;
 48   
 import java.util.ResourceBundle;
 49   
 import javax.swing.text.html.CSS;
 50   
 import javax.swing.text.html.StyleSheet;
 51   
 import javax.swing.text.MutableAttributeSet;
 52   
 import java.util.Vector;
 53   
 import java.util.Enumeration;
 54   
 
 55   
 /**
 56   
  * A panel for showing and manipulating font information.
 57   
  *
 58   
  * <p><code>FontPanel</code> shows and manipulates CSS attributes. To
 59   
  * set it to HTML attributes, methods setAttributes and getAttributes
 60   
  * have to be overridden.</p>
 61   
  *
 62   
  * @author Ulrich Hilger
 63   
  * @author Light Development
 64   
  * @author <a href="http://www.lightdev.com">http://www.lightdev.com</a>
 65   
  * @author <a href="mailto:info@lightdev.com">info@lightdev.com</a>
 66   
  * @author published under the terms and conditions of the
 67   
  *      GNU General Public License,
 68   
  *      for details see file gpl.txt in the distribution
 69   
  *      package of this software
 70   
  *
 71   
  * @version stage 11, April 27, 2003
 72   
  */
 73   
 
 74   
 public class FontPanel extends JPanel implements TitledPickList.TitledPickListListener,
 75   
       ColorPanel.ColorPanelListener
 76   
 {
 77   
 
 78   
   /** a text field to show a sample of the selected font attributes */
 79   
   JTextField sample = new JTextField();
 80   
 
 81   
   /** table for automatic font component value read/write */
 82   
   private Vector fontComponents = new Vector(0);
 83   
 
 84  4
   public FontPanel() {
 85  4
     setLayout(new BorderLayout(5,5));
 86   
 
 87   
     /** create a label for previewing font selections */
 88  4
     sample.setText("");
 89  4
     sample.setEditable(false);
 90  4
     sample.setPreferredSize(new Dimension(200, 50));
 91  4
     sample.setHorizontalAlignment(SwingConstants.CENTER);
 92  4
     sample.setText(FrmMain.dynRes.getResourceString(FrmMain.resources, "previewText"));
 93  4
     JPanel previewPanel = new JPanel(new BorderLayout());
 94  4
     previewPanel.add(sample, BorderLayout.CENTER);
 95  4
     previewPanel.setBorder(new TitledBorder(new EtchedBorder(
 96   
           EtchedBorder.LOWERED), FrmMain.dynRes.getResourceString(FrmMain.resources, "previewLabel")));
 97   
 
 98   
     /**
 99   
      * create a pick list for family filled with
 100   
      * available font family names
 101   
      */
 102  4
     GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
 103  4
     FamilyPickList family = new FamilyPickList(ge.getAvailableFontFamilyNames(),
 104   
                           FrmMain.dynRes.getResourceString(FrmMain.resources, "familyLabel"));
 105  4
     family.addTitledPickListListener(this);
 106  4
     fontComponents.add(family);
 107   
 
 108   
     /** create a pick list for font size */
 109  4
     String[] fontSizes = new String[] {"8", "10", "12", "14", "18", "24"};
 110  4
     SizePickList size = new SizePickList(fontSizes,
 111   
         FrmMain.dynRes.getResourceString(FrmMain.resources, "sizeLabel"), CSS.Attribute.FONT_SIZE);
 112  4
     size.addTitledPickListListener(this);
 113  4
     fontComponents.add(size);
 114   
 
 115   
     /** wrap together family and size */
 116  4
     JPanel familySizePanel = new JPanel(new BorderLayout(5,5));
 117  4
     familySizePanel.add(family, BorderLayout.CENTER);
 118  4
     familySizePanel.add(size, BorderLayout.EAST);
 119   
 
 120   
     /** create a panel to put font parts family, size and stlye in */
 121  4
     JPanel fontPartsPanel = new JPanel(new BorderLayout(5,5));
 122  4
     fontPartsPanel.add(familySizePanel, BorderLayout.CENTER);
 123  4
     String[] fontStyles = new String[] {
 124   
       FrmMain.dynRes.getResourceString(FrmMain.resources, "plainName"),
 125   
       FrmMain.dynRes.getResourceString(FrmMain.resources, "boldName"),
 126   
       FrmMain.dynRes.getResourceString(FrmMain.resources, "italicName"),
 127   
       FrmMain.dynRes.getResourceString(FrmMain.resources, "boldItalicName")};
 128  4
     StylePickList style = new StylePickList(
 129   
         fontStyles,
 130   
         FrmMain.dynRes.getResourceString(FrmMain.resources, "styleLabel"));
 131  4
     style.addTitledPickListListener(this);
 132  4
     fontPartsPanel.add(style, BorderLayout.EAST);
 133  4
     fontComponents.add(style);
 134   
 
 135   
     /** create a panel for underline / line through */
 136  4
     EffectPanel linePanel = new EffectPanel();
 137  4
     fontComponents.add(linePanel);
 138   
 
 139   
     /** create a panel for color choices */
 140  4
     JPanel colorPanel = new JPanel(new GridLayout(2,1,3,3));
 141  4
     colorPanel.setBorder(new TitledBorder(new EtchedBorder(
 142   
           EtchedBorder.LOWERED), FrmMain.dynRes.getResourceString(FrmMain.resources, "colorLabel")));
 143  4
     ColorPanel fCol = new ColorPanel(FrmMain.dynRes.getResourceString(FrmMain.resources, "foregroundLabel"),
 144   
                                   Color.black, CSS.Attribute.COLOR);
 145  4
     fCol.addColorPanelListener(this);
 146  4
     fontComponents.add(fCol);
 147  4
     ColorPanel bCol = new ColorPanel(FrmMain.dynRes.getResourceString(FrmMain.resources, "backgroundLabel"),
 148   
                                     Color.white, CSS.Attribute.BACKGROUND_COLOR);
 149  4
     bCol.addColorPanelListener(this);
 150  4
     fontComponents.add(bCol);
 151  4
     colorPanel.add(fCol);
 152  4
     colorPanel.add(bCol);
 153   
 
 154  4
     sample.setForeground(Color.black);
 155  4
     sample.setBackground(Color.white);
 156   
 
 157   
     /** create a panel to combine line and color choices */
 158  4
     JPanel eastPanel = new JPanel(new BorderLayout());
 159  4
     eastPanel.add(linePanel, BorderLayout.NORTH);
 160  4
     eastPanel.add(colorPanel, BorderLayout.SOUTH);
 161   
 
 162   
     /** add all font controls to our font panel */
 163  4
     add(fontPartsPanel, BorderLayout.CENTER);
 164  4
     add(eastPanel, BorderLayout.EAST);
 165  4
     add(previewPanel, BorderLayout.SOUTH);
 166  4
     add(new JPanel(), BorderLayout.NORTH);
 167  4
     add(new JPanel(), BorderLayout.WEST);
 168   
   }
 169   
 
 170   
   /**
 171   
    * construct a FontPanel and display a set of attributes
 172   
    *
 173   
    * @param frame  the main frame having the ResourceBundle
 174   
    * @param a  the set of attributes to display
 175   
    */
 176  2
   public FontPanel(AttributeSet a) {
 177  2
     this();
 178   
 
 179   
     /** set the new FontPanel to display our set of attributes */
 180  2
     setAttributes(a);
 181   
   }
 182   
 
 183   
   /**
 184   
    * handle ColorChangeEvents from one of our color panels
 185   
    *
 186   
    * @param e  the ColorPanelEvent to handle
 187   
    */
 188  8
   public void colorChanged(ColorPanel.ColorPanelEvent e) {
 189  8
     ColorPanel source = (ColorPanel) e.getSource();
 190  8
     if(source.getAttributeKey() == CSS.Attribute.COLOR) {
 191  4
       sample.setForeground(source.getColor());
 192   
     }
 193  4
     else if(source.getAttributeKey() == CSS.Attribute.BACKGROUND_COLOR) {
 194  4
       sample.setBackground(source.getColor());
 195   
     }
 196   
   }
 197   
 
 198   
   /**
 199   
    * set all components of this FontPanel to reflect a set of
 200   
    * attributes.
 201   
    *
 202   
    * @param a  the set of attributes to show
 203   
    */
 204  4
   public void setAttributes(AttributeSet a) {
 205  4
     Enumeration components = fontComponents.elements();
 206  4
     while(components.hasMoreElements()) {
 207  24
       ((AttributeComponent) components.nextElement()).setValue(a);
 208   
     }
 209   
   }
 210   
 
 211   
   /**
 212   
    * get the set of attributes resulting from the settings on
 213   
    * this FontPanel.
 214   
    *
 215   
    * @return the set of attributes set in this FontPanel
 216   
    */
 217  3
   public AttributeSet getAttributes() {
 218  3
     SimpleAttributeSet attributes = new SimpleAttributeSet();
 219  3
     Enumeration components = fontComponents.elements();
 220  3
     while(components.hasMoreElements()) {
 221  18
       attributes.addAttributes(
 222   
         ((AttributeComponent) components.nextElement()).getValue());
 223   
     }
 224  3
     return attributes;
 225   
   }
 226   
 
 227  0
   public AttributeSet getAttributes(boolean includeUnchanged) {
 228  0
     if(includeUnchanged) {
 229  0
       SimpleAttributeSet attributes = new SimpleAttributeSet();
 230  0
       Enumeration components = fontComponents.elements();
 231  0
       while(components.hasMoreElements()) {
 232  0
         attributes.addAttributes(
 233   
               ((AttributeComponent) components.nextElement()).getValue(includeUnchanged));
 234   
       }
 235  0
       return attributes;
 236   
     }
 237   
     else {
 238  0
       return getAttributes();
 239   
     }
 240   
   }
 241   
 
 242  0
   public void reset() {
 243  0
     Object c;
 244  0
     for(int i = 0; i < fontComponents.size(); i++) {
 245  0
       c = fontComponents.get(i);
 246  0
       if(c instanceof FamilyPickList) {
 247  0
         ((FamilyPickList) c).reset();
 248   
       }
 249  0
       else if(c instanceof SizePickList) {
 250  0
         ((SizePickList) c).reset();
 251   
       }
 252  0
       else if(c instanceof StylePickList) {
 253  0
         ((StylePickList) c).reset();
 254   
       }
 255   
     }
 256   
   }
 257   
 
 258   
   /**
 259   
    * if another value was picked from a list, update the
 260   
    * sample
 261   
    */
 262  16
   public void valueChanged(TitledPickList.TitledPickListEvent e) {
 263  16
     Object source = e.getSource();
 264  16
     Font saveFont = sample.getFont();
 265  16
     if(source instanceof FamilyPickList) {
 266  4
       sample.setFont(new Font(  ((FamilyPickList) source).getFamily(),
 267   
                                 saveFont.getStyle(),
 268   
                 saveFont.getSize()));
 269   
     }
 270  12
     else if(source instanceof SizePickList) {
 271  8
       sample.setFont(new Font(  saveFont.getFamily(),
 272   
                                 saveFont.getStyle(),
 273   
                                 Integer.parseInt((String) ((SizePickList) source).getSelection())));
 274   
     /*adjustFontSize(Integer.parseInt((String) ((SizePickList) source).getSelection()))));*/
 275   
     }
 276  4
     else if(source instanceof StylePickList) {
 277  4
       sample.setFont(new Font(  saveFont.getFamily(),
 278   
                                 ((StylePickList) source).getFontStyle(),
 279   
                 saveFont.getSize()));
 280   
     }
 281   
   }
 282   
 
 283   
   /**
 284   
    * fix for bug id 4765271
 285   
    * (see http://developer.java.sun.com/developer/bugParade/bugs/4765271.html)
 286   
    */
 287  0
   private int adjustFontSize(int size) {
 288  0
     return (int) (((float) size) * 1.3f);
 289   
   }
 290   
 
 291   
   /**
 292   
    * extend <code>TitledPickList</code> with a way to set values
 293   
    * special to font family values
 294   
    */
 295   
   class FamilyPickList extends TitledPickList implements AttributeComponent {
 296   
 
 297   
     private int setValCount = 0;
 298   
     private Object originalValue;
 299   
 
 300   
     /**
 301   
      * constructor
 302   
      *
 303   
      * @param options  the options to be selectable in this list
 304   
      * @param titleText  the title for the pick list
 305   
      */
 306  4
     FamilyPickList(String[] options, String titleText) {
 307  4
       super(options, titleText);
 308   
     }
 309   
 
 310   
     /**
 311   
      * set the value of this <code>TitledPickList</code>
 312   
      *
 313   
      * @param a  the set of attributes possibly having a
 314   
      *          font family attribute this pick list could display
 315   
      *
 316   
      * @return true, if the set of attributes had a font family attribute,
 317   
      *            false if not
 318   
      */
 319  4
     public boolean setValue(AttributeSet a) {
 320  4
       boolean success = false;
 321  4
       ignoreTextChanges = true;
 322  4
       Object newSelection;
 323  4
       if(a.isDefined(CSS.Attribute.FONT_FAMILY)) {
 324  3
         newSelection = a.getAttribute(CSS.Attribute.FONT_FAMILY);
 325  3
      setSelection(a.getAttribute(CSS.Attribute.FONT_FAMILY));
 326  3
     success = true;
 327   
       }
 328   
       else {
 329  1
         newSelection = (Object) "SansSerif";
 330  1
     setSelection(newSelection);
 331   
       }
 332  4
       ignoreTextChanges = false;
 333  4
       if(++setValCount < 2) {
 334  4
         originalValue = newSelection;
 335   
       }
 336  4
       return success;
 337   
     }
 338   
 
 339  3
     public AttributeSet getValue() {
 340  3
       SimpleAttributeSet set = new SimpleAttributeSet();
 341  3
       Object value = getSelection();
 342   
       //System.out.println("FamilyPicker getValue originalValue=" + originalValue);
 343   
       //System.out.println("FamilyPicker getValue value=" + value);
 344  3
       if(((originalValue == null) && (value != null)) ||
 345   
          ((originalValue != null) && (value != null) && (!originalValue.toString().equalsIgnoreCase(value.toString()))))
 346   
       {
 347  0
         Util.styleSheet().addCSSAttribute(set,
 348   
             CSS.Attribute.FONT_FAMILY, value.toString());
 349   
       }
 350  3
       return set;
 351   
     }
 352   
 
 353  0
     public AttributeSet getValue(boolean includeUnchanged) {
 354  0
       if(includeUnchanged) {
 355  0
         SimpleAttributeSet set = new SimpleAttributeSet();
 356  0
         Object value = getSelection();
 357   
         //System.out.println("FamilyPicker getValue originalValue=" + originalValue);
 358   
         //System.out.println("FamilyPicker getValue value=" + value);
 359  0
         Util.styleSheet().addCSSAttribute(set,
 360   
             CSS.Attribute.FONT_FAMILY, value.toString());
 361  0
         return set;
 362   
       }
 363   
       else {
 364  0
         return getValue();
 365   
       }
 366   
     }
 367   
 
 368  4
     public String getFamily() {
 369  4
       return (String) getSelection();
 370   
     }
 371   
 
 372  0
     public void reset() {
 373  0
       setValCount = 0;
 374  0
       originalValue = null;
 375   
     }
 376   
   }
 377   
 
 378   
   /**
 379   
    * extend <code>TitledPickList</code> with a way to set values
 380   
    * special to font size values
 381   
    */
 382   
   class SizePickList extends TitledPickList implements AttributeComponent {
 383   
 
 384   
     private Object key;
 385   
     private int setValCount = 0;
 386   
     private String originalValue;
 387   
 
 388   
     /**
 389   
      * constructor
 390   
      *
 391   
      * @param options  the options to be selectable in this list
 392   
      * @param titleText  the title for the pick list
 393   
      */
 394  4
     SizePickList(String[] options, String titleText, Object key) {
 395  4
       super(options, titleText);
 396  4
       this.key = key;
 397   
     }
 398   
 
 399   
     /**
 400   
      * set the value of this <code>TitledPickList</code>
 401   
      *
 402   
      * @param a  the set of attributes possibly having a
 403   
      *          font size attribute this pick list could display
 404   
      *
 405   
      * @return true, if the set of attributes had a font size attribute,
 406   
      *            false if not
 407   
      */
 408  4
     public boolean setValue(AttributeSet a) {
 409  4
       ignoreTextChanges = true;
 410  4
       boolean success = false;
 411  4
       Object attr = a.getAttribute(key);
 412  4
       String newSelection;
 413  4
       if(attr != null) {
 414   
         //LengthValue lv = new LengthValue(a.getAttribute(key));
 415   
         //int val = new Float(lv.getAttrValue(attr.toString(), LengthValue.pt)).intValue();
 416  3
         int val = (int) Util.getAttrValue(a.getAttribute(key));
 417  3
         if(val > 0) {
 418  3
           success = true;
 419  3
           newSelection = new Integer(val).toString();
 420  3
           setSelection(newSelection);
 421   
         }
 422   
         else {
 423  0
           newSelection = "12";
 424  0
           setSelection(newSelection);
 425   
         }
 426   
       }
 427   
       else {
 428  1
         newSelection = "12";
 429  1
         setSelection(newSelection);
 430   
       }
 431  4
       ignoreTextChanges = false;
 432  4
       if(++setValCount < 2) {
 433  4
         originalValue = newSelection;
 434   
       }
 435  4
       return success;
 436   
     }
 437   
 
 438  3
     public AttributeSet getValue() {
 439  3
       SimpleAttributeSet set = new SimpleAttributeSet();
 440  3
       String value = (String) getSelection();
 441  3
       if(((originalValue == null) && (value != null)) ||
 442   
          ((originalValue != null) && (!originalValue.equalsIgnoreCase(value)))) {
 443  2
         Util.styleSheet().addCSSAttribute(set, CSS.Attribute.FONT_SIZE,
 444   
             (String) getSelection() /*+ "pt"*/);
 445   
       }
 446  3
       return set;
 447   
     }
 448   
 
 449  0
     public AttributeSet getValue(boolean includeUnchanged) {
 450  0
       if(includeUnchanged) {
 451  0
         SimpleAttributeSet set = new SimpleAttributeSet();
 452  0
         String value = (String) getSelection();
 453  0
         Util.styleSheet().addCSSAttribute(set, CSS.Attribute.FONT_SIZE,
 454   
             (String) getSelection() /*+ "pt"*/);
 455  0
         return set;
 456   
       }
 457   
       else {
 458  0
         return getValue();
 459   
       }
 460   
     }
 461   
 
 462  0
     public void reset() {
 463  0
       setValCount = 0;
 464  0
       originalValue = null;
 465   
     }
 466   
   }
 467   
 
 468   
   /**
 469   
    * extend <code>TitledPickList</code> with a way to set values
 470   
    * special to font style values
 471   
    */
 472   
   class StylePickList extends TitledPickList implements AttributeComponent {
 473   
 
 474   
     private int originalValue;
 475   
     private int setValCount = 0;
 476   
 
 477   
     /**
 478   
      * constructor
 479   
      *
 480   
      * @param options  the options to be selectable in this list
 481   
      * @param titleText  the title for the pick list
 482   
      */
 483  4
     StylePickList(String[] options, String titleText) {
 484  4
       super(options, titleText);
 485   
     }
 486   
 
 487   
     /**
 488   
      * set the value of this <code>TitledPickList</code>
 489   
      *
 490   
      * @param a  the set of attributes possibly having a
 491   
      *          font style attribute this pick list could display
 492   
      *
 493   
      * @return true, if the set of attributes had a font style attribute,
 494   
      *            false if not
 495   
      */
 496  4
     public boolean setValue(AttributeSet a) {
 497  4
       ignoreTextChanges = true;
 498  4
       boolean success = false;
 499  4
       int styleNo = 0;
 500  4
       String value;
 501  4
       if(a.isDefined(CSS.Attribute.FONT_WEIGHT)) {
 502  3
     value = a.getAttribute(CSS.Attribute.FONT_WEIGHT).toString();
 503  3
     if(value.equalsIgnoreCase(StyleConstants.Bold.toString())) {
 504  0
       styleNo++;
 505   
     }
 506   
       }
 507  4
       if(a.isDefined(CSS.Attribute.FONT_STYLE)) {
 508  0
     value = a.getAttribute(CSS.Attribute.FONT_STYLE).toString();
 509  0
     if(value.equalsIgnoreCase(StyleConstants.Italic.toString())) {
 510  0
       styleNo += 2;
 511   
     }
 512   
       }
 513  4
       setSelection(styleNo);
 514  4
       if(++setValCount < 2) {
 515  4
         originalValue = styleNo;
 516   
       }
 517  4
       ignoreTextChanges = false;
 518  4
       return success;
 519   
     }
 520   
 
 521  3
     public AttributeSet getValue() {
 522  3
       String value = Util.CSS_ATTRIBUTE_NORMAL;
 523  3
       SimpleAttributeSet set = new SimpleAttributeSet();
 524  3
       int styleNo = getIndex();
 525  3
       switch(styleNo) {
 526  3
         case 0:
 527  3
           Util.styleSheet().addCSSAttribute(set, CSS.Attribute.FONT_STYLE, value);
 528  3
           break;
 529  0
         case 1:
 530  0
           Util.styleSheet().addCSSAttribute(set, CSS.Attribute.FONT_WEIGHT,
 531   
             StyleConstants.Bold.toString());
 532  0
           break;
 533  0
         case 2:
 534  0
           Util.styleSheet().addCSSAttribute(set, CSS.Attribute.FONT_STYLE,
 535   
               StyleConstants.Italic.toString());
 536  0
           break;
 537  0
         case 3:
 538  0
           Util.styleSheet().addCSSAttribute(set, CSS.Attribute.FONT_WEIGHT,
 539   
             StyleConstants.Bold.toString());
 540  0
           Util.styleSheet().addCSSAttribute(set, CSS.Attribute.FONT_STYLE,
 541   
               StyleConstants.Italic.toString());
 542  0
           break;
 543   
       }
 544  3
       return set;
 545   
     }
 546   
 
 547  0
     public AttributeSet getValue(boolean includeUnchanged) {
 548  0
       if(includeUnchanged) {
 549  0
         String value = Util.CSS_ATTRIBUTE_NORMAL;
 550  0
         SimpleAttributeSet set = new SimpleAttributeSet();
 551  0
         int styleNo = getIndex();
 552  0
         switch(styleNo) {
 553  0
           case 0:
 554  0
             Util.styleSheet().addCSSAttribute(set, CSS.Attribute.FONT_STYLE, value);
 555  0
             break;
 556  0
           case 1:
 557  0
             Util.styleSheet().addCSSAttribute(set, CSS.Attribute.FONT_WEIGHT,
 558   
               StyleConstants.Bold.toString());
 559  0
             break;
 560  0
           case 2:
 561  0
             Util.styleSheet().addCSSAttribute(set, CSS.Attribute.FONT_STYLE,
 562   
                 StyleConstants.Italic.toString());
 563  0
             break;
 564  0
           case 3:
 565  0
             Util.styleSheet().addCSSAttribute(set, CSS.Attribute.FONT_WEIGHT,
 566   
               StyleConstants.Bold.toString());
 567  0
             Util.styleSheet().addCSSAttribute(set, CSS.Attribute.FONT_STYLE,
 568   
                 StyleConstants.Italic.toString());
 569  0
             break;
 570   
         }
 571  0
         return set;
 572   
       }
 573   
       else {
 574  0
         return getValue();
 575   
       }
 576   
     }
 577   
 
 578  4
     public int getFontStyle() {
 579  4
       int fontStyle = 0;
 580  4
       switch(getIndex()) {
 581  4
     case 0:
 582  4
       fontStyle = Font.PLAIN;
 583  4
       break;
 584  0
     case 1:
 585  0
       fontStyle = Font.BOLD;
 586  0
       break;
 587  0
     case 2:
 588  0
       fontStyle = Font.ITALIC;
 589  0
       break;
 590  0
     case 3:
 591  0
       fontStyle = Font.BOLD | Font.ITALIC;
 592  0
       break;
 593   
       }
 594  4
       return fontStyle;
 595   
     }
 596   
 
 597  0
     public void reset() {
 598  0
       setValCount = 0;
 599  0
       originalValue = -2;
 600   
     }
 601   
   }
 602   
 }