1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 package org.apache.openoffice.ooxml.viewer.tokenview; 23 24 import java.awt.Color; 25 import java.awt.Font; 26 import java.awt.Graphics2D; 27 28 import javax.swing.UIManager; 29 30 public class Style 31 { Style()32 public Style () 33 { 34 maForegroundColor = Color.BLACK; 35 if (DefaultFont == null) 36 DefaultFont = UIManager.getDefaults().getFont("TextField.font"); 37 maFont = DefaultFont; 38 } 39 40 41 42 Set(Graphics2D aG2)43 public void Set(Graphics2D aG2) 44 { 45 aG2.setColor(maForegroundColor); 46 aG2.setFont(maFont); 47 } 48 49 50 51 SetForegroundColor(final Color aColor)52 public Style SetForegroundColor (final Color aColor) 53 { 54 maForegroundColor = aColor; 55 return this; 56 } 57 58 59 60 GetForegroundColor()61 public Color GetForegroundColor() 62 { 63 return maForegroundColor; 64 } 65 66 67 68 SetBackgroundColor(final Color aColor)69 public Style SetBackgroundColor (final Color aColor) 70 { 71 maBackgroundColor = aColor; 72 return this; 73 } 74 75 76 77 GetBackgroundColor()78 public Color GetBackgroundColor() 79 { 80 return maBackgroundColor; 81 } 82 83 84 85 SetBold()86 public Style SetBold() 87 { 88 maFont = maFont.deriveFont(Font.BOLD); 89 return this; 90 } 91 92 93 94 GetFont()95 public Font GetFont() 96 { 97 return maFont; 98 } 99 100 101 102 103 public static final Style DefaultStyle = new Style(); 104 public static Font DefaultFont = null; 105 106 private Color maBackgroundColor; 107 private Color maForegroundColor; 108 private Font maFont; 109 } 110