1 30 31 package com.jgoodies.animation.components; 32 33 import java.awt.Color ; 34 import java.awt.Graphics ; 35 import java.awt.Graphics2D ; 36 import java.awt.RenderingHints ; 37 38 import javax.swing.JComponent ; 39 40 import com.jgoodies.animation.renderer.BasicTextRenderer; 41 import com.jgoodies.animation.renderer.HeightMode; 42 43 50 public final class BasicTextLabel extends JComponent { 51 52 private final BasicTextRenderer renderer; 53 54 59 public BasicTextLabel(String text) { 60 renderer = new BasicTextRenderer(text); 61 } 62 63 public Color getColor() { 64 return renderer.getColor(); 65 } 66 67 public HeightMode getHeightMode() { 68 return renderer.getHeightMode(); 69 } 70 71 public float getScaleX() { 72 return renderer.getScaleX(); 73 } 74 75 public float getScaleY() { 76 return renderer.getScaleY(); 77 } 78 79 public float getSpace() { 80 return renderer.getSpace(); 81 } 82 83 public float getOffsetX() { 84 return renderer.getOffsetX(); 85 } 86 87 public float getOffsetY() { 88 return renderer.getOffsetY(); 89 } 90 91 public String getText() { 92 return renderer.getText(); 93 } 94 95 public void setColor(Color color) { 96 renderer.setColor(color); 97 repaint(); 98 } 99 100 public void setHeightMode(HeightMode heightMode) { 101 renderer.setHeightMode(heightMode); 102 } 103 104 public void setScale(float scale) { 105 renderer.setScaleX(scale); 106 renderer.setScaleY(scale); 107 repaint(); 108 } 109 110 public void setScaleX(float scaleX) { 111 renderer.setScaleX(scaleX); 112 repaint(); 113 } 114 115 public void setScaleY(float scaleY) { 116 renderer.setScaleY(scaleY); 117 repaint(); 118 } 119 120 public void setSpace(float space) { 121 renderer.setSpace(space); 122 repaint(); 123 } 124 125 public void setOffsetX(float offsetX) { 126 renderer.setOffsetX(offsetX); 127 repaint(); 128 } 129 130 public void setOffsetY(float offsetY) { 131 renderer.setOffsetY(offsetY); 132 repaint(); 133 } 134 135 public void setText(String newText) { 136 renderer.setText(newText); 137 repaint(); 138 } 139 140 146 public void paintComponent(Graphics g) { 147 Graphics2D g2 = (Graphics2D ) g; 148 149 g2.setRenderingHint( 150 RenderingHints.KEY_ANTIALIASING, 151 RenderingHints.VALUE_ANTIALIAS_ON); 152 g2.setRenderingHint( 153 RenderingHints.KEY_RENDERING, 154 RenderingHints.VALUE_RENDER_QUALITY); 155 156 renderer.setFont(getFont()); 157 renderer.render(g2, getWidth(), getHeight()); 158 } 159 } | Popular Tags |