20 package org.sleuthkit.autopsy.geolocation;
 
   22 import java.awt.Dimension;
 
   23 import java.awt.FontMetrics;
 
   24 import java.awt.Graphics;
 
   25 import java.awt.Graphics2D;
 
   26 import java.awt.Insets;
 
   27 import java.awt.Rectangle;
 
   28 import java.awt.geom.AffineTransform;
 
   30 import javax.swing.Icon;
 
   31 import javax.swing.JComponent;
 
   32 import javax.swing.JLabel;
 
   33 import javax.swing.plaf.basic.BasicLabelUI;
 
   43 final class VerticalLabelUI 
extends BasicLabelUI {
 
   45     private static final Rectangle paintIconR = 
new Rectangle();
 
   46     private static final Rectangle paintTextR = 
new Rectangle();
 
   47     private static final Rectangle paintViewR = 
new Rectangle();
 
   48     private static Insets paintViewInsets = 
new Insets(0, 0, 0, 0);
 
   51         labelUI = 
new VerticalLabelUI(
false);
 
   54     final boolean clockwise;
 
   60     VerticalLabelUI(
boolean clockwise) {
 
   62         this.clockwise = clockwise;
 
   66     public Dimension getPreferredSize(JComponent c) {
 
   67         Dimension dim = super.getPreferredSize(c);
 
   68         return new Dimension( dim.height, dim.width );
 
   72     public void paint(Graphics g, JComponent c) {
 
   73         JLabel label = (JLabel)c;
 
   74         String text = label.getText();
 
   75         Icon icon = (label.isEnabled()) ? label.getIcon() : label.getDisabledIcon();
 
   77         if ((icon == null) && (text == null)) {
 
   81         FontMetrics fm = g.getFontMetrics();
 
   82         paintViewInsets = c.getInsets(paintViewInsets);
 
   84         paintViewR.x = paintViewInsets.left;
 
   85         paintViewR.y = paintViewInsets.top;
 
   88         paintViewR.height = c.getWidth() - (paintViewInsets.left + paintViewInsets.right);
 
   89         paintViewR.width = c.getHeight() - (paintViewInsets.top + paintViewInsets.bottom);
 
   91         paintIconR.x = paintIconR.y = paintIconR.width = paintIconR.height = 0;
 
   92         paintTextR.x = paintTextR.y = paintTextR.width = paintTextR.height = 0;
 
   94         String clippedText = layoutCL(label, fm, text, icon, paintViewR, paintIconR, paintTextR);
 
   96         Graphics2D g2 = (Graphics2D) g;
 
   97         AffineTransform tr = g2.getTransform();
 
   99             g2.rotate( Math.PI / 2 );
 
  100             g2.translate( 0, - c.getWidth() );
 
  102             g2.rotate( - Math.PI / 2 );
 
  103             g2.translate( - c.getHeight(), 0 );
 
  107             icon.paintIcon(c, g, paintIconR.x, paintIconR.y);
 
  111             int textX = paintTextR.x;
 
  112             int textY = paintTextR.y + fm.getAscent();
 
  114             if (label.isEnabled()) {
 
  115                 paintEnabledText(label, g, clippedText, textX, textY);
 
  117                 paintDisabledText(label, g, clippedText, textX, textY);
 
  120         g2.setTransform( tr );