// Path: src/net/i2p/itoopie/gui/component/MultiLineLabel.java
// public class MultiLineLabel extends JLabel {
// 
//     /** Default serial version UID. */
//     private static final long serialVersionUID = 1L;
// 
//     /** Horizontal text alignment. */
//     private int halign = LEFT;
// 
//     /** Vertical text alignment. */
//     private int valign = CENTER;
// 
//     /** Cache to save heap allocations. */
//     private Rectangle bounds;
// 
//     /**
//      * Creates a new empty label.
//      */
//     public MultiLineLabel() {
//         super();
//         setUI(MultiLineLabelUI.labelUI);
//     }
// 
//     /**
//      * Creates a new label with <code>text</code> value.
//      * 
//      * @param text
//      *            the value of the label
//      */
//     public MultiLineLabel(String text) {
//         this();
//         setText(text);
//     }
// 
//     /** {@inheritDoc} */
//     public Rectangle getBounds() {
//         if (bounds == null) {
//             bounds = new Rectangle();
//         }
//         return super.getBounds(bounds);
//     }
// 
//     /**
//      * Set the vertical text alignment.
//      * 
//      * @param alignment
//      *            vertical alignment
//      */
//     public void setVerticalTextAlignment(int alignment) {
//         firePropertyChange("verticalTextAlignment", valign, alignment);
//         valign = alignment;
//     }
// 
//     /**
//      * Set the horizontal text alignment.
//      * 
//      * @param alignment
//      *            horizontal alignment
//      */
//     public void setHorizontalTextAlignment(int alignment) {
//         firePropertyChange("horizontalTextAlignment", halign, alignment);
//         halign = alignment;
//     }
// 
//     /**
//      * Get the vertical text alignment.
//      * 
//      * @return vertical text alignment
//      */
//     public int getVerticalTextAlignment() {
//         return valign;
//     }
// 
//     /**
//      * Get the horizontal text alignment.
//      * 
//      * @return horizontal text alignment
//      */
//     public int getHorizontalTextAlignment() {
//         return halign;
//     }
// }


import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.beans.PropertyChangeEvent;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.LabelUI;
import javax.swing.plaf.basic.BasicLabelUI;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.Element;
import javax.swing.text.PlainDocument;
import javax.swing.text.Segment;
import javax.swing.text.Utilities;
import javax.swing.text.View;
import net.i2p.itoopie.gui.component.MultiLineLabel;
     *            the text bounds
     * @return the clipped string
     */
    protected String clip(String text, FontMetrics fm, Rectangle bounds) {
        // Fast and lazy way to insert a clip indication is to simply replace
        // the last characters in the string with the clip indication.
        // A better way would be to use metrics and calculate how many (if any)
        // characters that need to be replaced.
        if (text.length() < 3) {
            return "...";
        }
        return text.substring(0, text.length() - 3) + "...";
    }

    /**
     * Establish the vertical text alignment. The default alignment is to center
     * the text in the label.
     * 
     * @param label
     *            the label to paint
     * @param fm
     *            font metrics
     * @param bounds
     *            the text bounds rectangle
     * @return the vertical text alignment, defaults to CENTER.
     */
    protected int alignmentY(JLabel label, FontMetrics fm, Rectangle bounds) {
        final int height = getAvailableHeight(label);
        int textHeight = bounds.height;

// Path: src/net/i2p/itoopie/gui/component/MultiLineLabel.java
// public class MultiLineLabel extends JLabel {
// 
//     /** Default serial version UID. */
//     private static final long serialVersionUID = 1L;
// 
//     /** Horizontal text alignment. */
//     private int halign = LEFT;
// 
//     /** Vertical text alignment. */
//     private int valign = CENTER;
// 
//     /** Cache to save heap allocations. */
//     private Rectangle bounds;
// 
//     /**
//      * Creates a new empty label.
//      */
//     public MultiLineLabel() {
//         super();
//         setUI(MultiLineLabelUI.labelUI);
//     }
// 
//     /**
//      * Creates a new label with <code>text</code> value.
//      * 
//      * @param text
//      *            the value of the label
//      */
//     public MultiLineLabel(String text) {
//         this();
//         setText(text);
//     }
// 
//     /** {@inheritDoc} */
//     public Rectangle getBounds() {
//         if (bounds == null) {
//             bounds = new Rectangle();
//         }
//         return super.getBounds(bounds);
//     }
// 
//     /**
//      * Set the vertical text alignment.
//      * 
//      * @param alignment
//      *            vertical alignment
//      */
//     public void setVerticalTextAlignment(int alignment) {
//         firePropertyChange("verticalTextAlignment", valign, alignment);
//         valign = alignment;
//     }
// 
//     /**
//      * Set the horizontal text alignment.
//      * 
//      * @param alignment
//      *            horizontal alignment
//      */
//     public void setHorizontalTextAlignment(int alignment) {
//         firePropertyChange("horizontalTextAlignment", halign, alignment);
//         halign = alignment;
//     }
// 
//     /**
//      * Get the vertical text alignment.
//      * 
//      * @return vertical text alignment
//      */
//     public int getVerticalTextAlignment() {
//         return valign;
//     }
// 
//     /**
//      * Get the horizontal text alignment.
//      * 
//      * @return horizontal text alignment
//      */
//     public int getHorizontalTextAlignment() {
//         return halign;
//     }
// }


// Path: src/net/i2p/itoopie/gui/component/multilinelabel/MultiLineLabelUI.java
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.beans.PropertyChangeEvent;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.LabelUI;
import javax.swing.plaf.basic.BasicLabelUI;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.Element;
import javax.swing.text.PlainDocument;
import javax.swing.text.Segment;
import javax.swing.text.Utilities;
import javax.swing.text.View;
import net.i2p.itoopie.gui.component.MultiLineLabel;

     *            the text bounds
     * @return the clipped string
     */
    protected String clip(String text, FontMetrics fm, Rectangle bounds) {
        // Fast and lazy way to insert a clip indication is to simply replace
        // the last characters in the string with the clip indication.
        // A better way would be to use metrics and calculate how many (if any)
        // characters that need to be replaced.
        if (text.length() < 3) {
            return "...";
        }
        return text.substring(0, text.length() - 3) + "...";
    }

    /**
     * Establish the vertical text alignment. The default alignment is to center
     * the text in the label.
     * 
     * @param label
     *            the label to paint
     * @param fm
     *            font metrics
     * @param bounds
     *            the text bounds rectangle
     * @return the vertical text alignment, defaults to CENTER.
     */
    protected int alignmentY(JLabel label, FontMetrics fm, Rectangle bounds) {
        final int height = getAvailableHeight(label);
        int textHeight = bounds.height;

        if (label instanceof MultiLineLabel) {