001/* 002 * Copyright 2010-2015 Institut Pasteur. 003 * 004 * This file is part of Icy. 005 * 006 * Icy is free software: you can redistribute it and/or modify 007 * it under the terms of the GNU General Public License as published by 008 * the Free Software Foundation, either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * Icy is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU General Public License for more details. 015 * 016 * You should have received a copy of the GNU General Public License 017 * along with Icy. If not, see <http://www.gnu.org/licenses/>. 018 */ 019package icy.gui.plugin; 020 021import icy.plugin.PluginDescriptor; 022import icy.util.StringUtil; 023 024import java.awt.Image; 025 026import javax.swing.ImageIcon; 027 028import org.pushingpixels.flamingo.api.common.RichTooltip; 029 030/** 031 * {@link RichTooltip} component for a {@link PluginDescriptor}. 032 * 033 * @author Stephane 034 */ 035public class PluginRichToolTip extends RichTooltip 036{ 037 public PluginRichToolTip(PluginDescriptor plugin) 038 { 039 super(); 040 041 final String name = plugin.getName(); 042 final String description = plugin.getDescription(); 043 final String website = plugin.getWeb(); 044 final String author = plugin.getAuthor(); 045 final ImageIcon plugIcon = plugin.getIcon(); 046 final Image plugImg = plugin.getImage(); 047 048 setTitle(name); 049 if (plugIcon != PluginDescriptor.DEFAULT_ICON) 050 setMainImage(plugIcon.getImage()); 051 052 if (!StringUtil.isEmpty(description)) 053 { 054 for (String str : description.split("\n")) 055 if (!StringUtil.isEmpty(str)) 056 addDescriptionSection(str); 057 } 058 if (!StringUtil.isEmpty(website)) 059 addDescriptionSection(website); 060 if (!StringUtil.isEmpty(author)) 061 addDescriptionSection(author); 062 063 if (plugImg != PluginDescriptor.DEFAULT_IMAGE) 064 setFooterImage(plugin.getImage()); 065 } 066}