This is an automated email from the git hooks/post-receive script. fnatter-guest pushed a commit to branch master in repository jajuk.
commit 3d14ec967e02b7c43fb7314a961a2b974ee4a61d Author: Felix Natter <[email protected]> Date: Sat Apr 9 14:43:02 2016 +0200 add patch from jajuk develop branch to rewplace scrollablepopupmenu/* and JScrollingText.java --- debian/patches/06_scrolling_stuff.patch | 997 ++++++++++++++++++++++++++++++++ debian/patches/series | 1 + 2 files changed, 998 insertions(+) diff --git a/debian/patches/06_scrolling_stuff.patch b/debian/patches/06_scrolling_stuff.patch new file mode 100644 index 0000000..5b649a6 --- /dev/null +++ b/debian/patches/06_scrolling_stuff.patch @@ -0,0 +1,997 @@ +Description: Rewrite code with unclear license in 1.10.9 + (src/main/java/ext/scrollablepopupmenu/*, + src/main/java/ext/JScrollingText.java) +Author: Bertrand Florat <[email protected]> +Origin: upstream +Forwarded: not-needed +Applied-Upstream: commit, https://github.com/jajuk-team/jajuk/commit/76cb3ab196f9e4a8cb6962cbfbf827c312a42abb#diff-45157af1fa71b3dc9df4ee3daa6682c2 +Last-Update: 2016-04-09 +--- /dev/null ++++ b/src/main/java/ext/MenuScroller.java +@@ -0,0 +1,704 @@ ++/* ++ * Licensed to the Apache Software Foundation (ASF) under one or more ++ * contributor license agreements. See the NOTICE file distributed with ++ * this work for additional information regarding copyright ownership. ++ * The ASF licenses this file to You under the Apache License, Version 2.0 ++ * (the "License"); you may not use this file except in compliance with ++ * the License. You may obtain a copy of the License at ++ * ++ * http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, software ++ * distributed under the License is distributed on an "AS IS" BASIS, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ * ++ */ ++ ++package ext; ++ ++import java.awt.Color; ++import java.awt.Component; ++import java.awt.Dimension; ++import java.awt.Graphics; ++import java.awt.event.ActionEvent; ++import java.awt.event.ActionListener; ++import java.awt.event.MouseWheelEvent; ++import java.awt.event.MouseWheelListener; ++ ++import javax.swing.Icon; ++import javax.swing.JComponent; ++import javax.swing.JMenu; ++import javax.swing.JMenuItem; ++import javax.swing.JPopupMenu; ++import javax.swing.MenuSelectionManager; ++import javax.swing.Timer; ++import javax.swing.event.ChangeEvent; ++import javax.swing.event.ChangeListener; ++import javax.swing.event.PopupMenuEvent; ++import javax.swing.event.PopupMenuListener; ++ ++/** ++ * A class that provides scrolling capabilities to a long menu dropdown or popup ++ * menu. A number of items can optionally be frozen at the top and/or bottom of ++ * the menu. ++ * <P> ++ * <B>Implementation note:</B> The default number of items to display at a time ++ * is 15, and the default scrolling interval is 125 milliseconds. ++ * <P> ++ * ++ * Class is slightly changed as per comments on the webpage ++ * @version 1.5.0 04/05/12 ++ * @author Darryl Burke (http://tips4java.wordpress.com/2009/02/01/menu-scroller/) ++ * ++ * Adapted by Jajuk team ++ */ ++public class MenuScroller { ++ ++ // private JMenu menu; ++ private JPopupMenu menu; ++ private Component[] menuItems; ++ private MenuScrollItem upItem; ++ private MenuScrollItem downItem; ++ private final MenuScrollListener menuListener = new MenuScrollListener(); ++ private final MouseWheelListener mouseWheelListener = new MouseScrollListener(); ++ private int scrollCount; ++ private int interval; ++ private int topFixedCount; ++ private int bottomFixedCount; ++ private int firstIndex = 0; ++ private int keepVisibleIndex = -1; ++ ++ /** ++ * Registers a menu to be scrolled with the default number of items to ++ * display at a time and the default scrolling interval. ++ * ++ * @param menu ++ * the menu ++ * @return the MenuScroller ++ */ ++ public static MenuScroller setScrollerFor(JMenu menu) { ++ return new MenuScroller(menu); ++ } ++ ++ /** ++ * Registers a popup menu to be scrolled with the default number of items to ++ * display at a time and the default scrolling interval. ++ * ++ * @param menu ++ * the popup menu ++ * @return the MenuScroller ++ */ ++ public static MenuScroller setScrollerFor(JPopupMenu menu) { ++ return new MenuScroller(menu); ++ } ++ ++ /** ++ * Registers a menu to be scrolled with the default number of items to ++ * display at a time and the specified scrolling interval. ++ * ++ * @param menu ++ * the menu ++ * @param scrollCount ++ * the number of items to display at a time ++ * @return the MenuScroller ++ * @throws IllegalArgumentException ++ * if scrollCount is 0 or negative ++ */ ++ public static MenuScroller setScrollerFor(JMenu menu, int scrollCount) { ++ return new MenuScroller(menu, scrollCount); ++ } ++ ++ /** ++ * Registers a popup menu to be scrolled with the default number of items to ++ * display at a time and the specified scrolling interval. ++ * ++ * @param menu ++ * the popup menu ++ * @param scrollCount ++ * the number of items to display at a time ++ * @return the MenuScroller ++ * @throws IllegalArgumentException ++ * if scrollCount is 0 or negative ++ */ ++ public static MenuScroller setScrollerFor(JPopupMenu menu, int scrollCount) { ++ return new MenuScroller(menu, scrollCount); ++ } ++ ++ /** ++ * Registers a menu to be scrolled, with the specified number of items to ++ * display at a time and the specified scrolling interval. ++ * ++ * @param menu ++ * the menu ++ * @param scrollCount ++ * the number of items to be displayed at a time ++ * @param interval ++ * the scroll interval, in milliseconds ++ * @return the MenuScroller ++ * @throws IllegalArgumentException ++ * if scrollCount or interval is 0 or negative ++ */ ++ public static MenuScroller setScrollerFor(JMenu menu, int scrollCount, ++ int interval) { ++ return new MenuScroller(menu, scrollCount, interval); ++ } ++ ++ /** ++ * Registers a popup menu to be scrolled, with the specified number of items ++ * to display at a time and the specified scrolling interval. ++ * ++ * @param menu ++ * the popup menu ++ * @param scrollCount ++ * the number of items to be displayed at a time ++ * @param interval ++ * the scroll interval, in milliseconds ++ * @return the MenuScroller ++ * @throws IllegalArgumentException ++ * if scrollCount or interval is 0 or negative ++ */ ++ public static MenuScroller setScrollerFor(JPopupMenu menu, int scrollCount, ++ int interval) { ++ return new MenuScroller(menu, scrollCount, interval); ++ } ++ ++ /** ++ * Registers a menu to be scrolled, with the specified number of items to ++ * display in the scrolling region, the specified scrolling interval, and ++ * the specified numbers of items fixed at the top and bottom of the menu. ++ * ++ * @param menu ++ * the menu ++ * @param scrollCount ++ * the number of items to display in the scrolling portion ++ * @param interval ++ * the scroll interval, in milliseconds ++ * @param topFixedCount ++ * the number of items to fix at the top. May be 0. ++ * @param bottomFixedCount ++ * the number of items to fix at the bottom. May be 0 ++ * @throws IllegalArgumentException ++ * if scrollCount or interval is 0 or negative or if ++ * topFixedCount or bottomFixedCount is negative ++ * @return the MenuScroller ++ */ ++ public static MenuScroller setScrollerFor(JMenu menu, int scrollCount, ++ int interval, int topFixedCount, int bottomFixedCount) { ++ return new MenuScroller(menu, scrollCount, interval, topFixedCount, ++ bottomFixedCount); ++ } ++ ++ /** ++ * Registers a popup menu to be scrolled, with the specified number of items ++ * to display in the scrolling region, the specified scrolling interval, and ++ * the specified numbers of items fixed at the top and bottom of the popup ++ * menu. ++ * ++ * @param menu ++ * the popup menu ++ * @param scrollCount ++ * the number of items to display in the scrolling portion ++ * @param interval ++ * the scroll interval, in milliseconds ++ * @param topFixedCount ++ * the number of items to fix at the top. May be 0 ++ * @param bottomFixedCount ++ * the number of items to fix at the bottom. May be 0 ++ * @throws IllegalArgumentException ++ * if scrollCount or interval is 0 or negative or if ++ * topFixedCount or bottomFixedCount is negative ++ * @return the MenuScroller ++ */ ++ public static MenuScroller setScrollerFor(JPopupMenu menu, int scrollCount, ++ int interval, int topFixedCount, int bottomFixedCount) { ++ return new MenuScroller(menu, scrollCount, interval, topFixedCount, ++ bottomFixedCount); ++ } ++ ++ /** ++ * Constructs a <code>MenuScroller</code> that scrolls a menu with the ++ * default number of items to display at a time, and default scrolling ++ * interval. ++ * ++ * @param menu ++ * the menu ++ */ ++ public MenuScroller(JMenu menu) { ++ this(menu, 15); ++ } ++ ++ /** ++ * Constructs a <code>MenuScroller</code> that scrolls a popup menu with the ++ * default number of items to display at a time, and default scrolling ++ * interval. ++ * ++ * @param menu ++ * the popup menu ++ */ ++ public MenuScroller(JPopupMenu menu) { ++ this(menu, 15); ++ } ++ ++ /** ++ * Constructs a <code>MenuScroller</code> that scrolls a menu with the ++ * specified number of items to display at a time, and default scrolling ++ * interval. ++ * ++ * @param menu ++ * the menu ++ * @param scrollCount ++ * the number of items to display at a time ++ * @throws IllegalArgumentException ++ * if scrollCount is 0 or negative ++ */ ++ public MenuScroller(JMenu menu, int scrollCount) { ++ this(menu, scrollCount, 150); ++ } ++ ++ /** ++ * Constructs a <code>MenuScroller</code> that scrolls a popup menu with the ++ * specified number of items to display at a time, and default scrolling ++ * interval. ++ * ++ * @param menu ++ * the popup menu ++ * @param scrollCount ++ * the number of items to display at a time ++ * @throws IllegalArgumentException ++ * if scrollCount is 0 or negative ++ */ ++ public MenuScroller(JPopupMenu menu, int scrollCount) { ++ this(menu, scrollCount, 150); ++ } ++ ++ /** ++ * Constructs a <code>MenuScroller</code> that scrolls a menu with the ++ * specified number of items to display at a time, and specified scrolling ++ * interval. ++ * ++ * @param menu ++ * the menu ++ * @param scrollCount ++ * the number of items to display at a time ++ * @param interval ++ * the scroll interval, in milliseconds ++ * @throws IllegalArgumentException ++ * if scrollCount or interval is 0 or negative ++ */ ++ public MenuScroller(JMenu menu, int scrollCount, int interval) { ++ this(menu, scrollCount, interval, 0, 0); ++ } ++ ++ /** ++ * Constructs a <code>MenuScroller</code> that scrolls a popup menu with the ++ * specified number of items to display at a time, and specified scrolling ++ * interval. ++ * ++ * @param menu ++ * the popup menu ++ * @param scrollCount ++ * the number of items to display at a time ++ * @param interval ++ * the scroll interval, in milliseconds ++ * @throws IllegalArgumentException ++ * if scrollCount or interval is 0 or negative ++ */ ++ public MenuScroller(JPopupMenu menu, int scrollCount, int interval) { ++ this(menu, scrollCount, interval, 0, 0); ++ } ++ ++ /** ++ * Constructs a <code>MenuScroller</code> that scrolls a menu with the ++ * specified number of items to display in the scrolling region, the ++ * specified scrolling interval, and the specified numbers of items fixed at ++ * the top and bottom of the menu. ++ * ++ * @param menu ++ * the menu ++ * @param scrollCount ++ * the number of items to display in the scrolling portion ++ * @param interval ++ * the scroll interval, in milliseconds ++ * @param topFixedCount ++ * the number of items to fix at the top. May be 0 ++ * @param bottomFixedCount ++ * the number of items to fix at the bottom. May be 0 ++ * @throws IllegalArgumentException ++ * if scrollCount or interval is 0 or negative or if ++ * topFixedCount or bottomFixedCount is negative ++ */ ++ public MenuScroller(JMenu menu, int scrollCount, int interval, ++ int topFixedCount, int bottomFixedCount) { ++ this(menu.getPopupMenu(), scrollCount, interval, topFixedCount, ++ bottomFixedCount); ++ } ++ ++ /** ++ * Constructs a <code>MenuScroller</code> that scrolls a popup menu with the ++ * specified number of items to display in the scrolling region, the ++ * specified scrolling interval, and the specified numbers of items fixed at ++ * the top and bottom of the popup menu. ++ * ++ * @param menu ++ * the popup menu ++ * @param scrollCount ++ * the number of items to display in the scrolling portion ++ * @param interval ++ * the scroll interval, in milliseconds ++ * @param topFixedCount ++ * the number of items to fix at the top. May be 0 ++ * @param bottomFixedCount ++ * the number of items to fix at the bottom. May be 0 ++ * @throws IllegalArgumentException ++ * if scrollCount or interval is 0 or negative or if ++ * topFixedCount or bottomFixedCount is negative ++ */ ++ public MenuScroller(JPopupMenu menu, int scrollCount, int interval, ++ int topFixedCount, int bottomFixedCount) { ++ if (scrollCount <= 0 || interval <= 0) { ++ throw new IllegalArgumentException( ++ "scrollCount and interval must be greater than 0"); ++ } ++ if (topFixedCount < 0 || bottomFixedCount < 0) { ++ throw new IllegalArgumentException( ++ "topFixedCount and bottomFixedCount cannot be negative"); ++ } ++ ++ upItem = new MenuScrollItem(MenuIcon.UP, -1); ++ downItem = new MenuScrollItem(MenuIcon.DOWN, +1); ++ setScrollCount(scrollCount); ++ setInterval(interval); ++ setTopFixedCount(topFixedCount); ++ setBottomFixedCount(bottomFixedCount); ++ ++ this.menu = menu; ++ menu.addPopupMenuListener(menuListener); ++ menu.addMouseWheelListener(mouseWheelListener); ++ } ++ ++ /** ++ * Returns the scroll interval in milliseconds ++ * ++ * @return the scroll interval in milliseconds ++ */ ++ public int getInterval() { ++ return interval; ++ } ++ ++ /** ++ * Sets the scroll interval in milliseconds ++ * ++ * @param interval ++ * the scroll interval in milliseconds ++ * @throws IllegalArgumentException ++ * if interval is 0 or negative ++ */ ++ public void setInterval(int interval) { ++ if (interval <= 0) { ++ throw new IllegalArgumentException( ++ "interval must be greater than 0"); ++ } ++ upItem.setInterval(interval); ++ downItem.setInterval(interval); ++ this.interval = interval; ++ } ++ ++ /** ++ * Returns the number of items in the scrolling portion of the menu. ++ * ++ * @return the number of items to display at a time ++ */ ++ public int getscrollCount() { ++ return scrollCount; ++ } ++ ++ /** ++ * Sets the number of items in the scrolling portion of the menu. ++ * ++ * @param scrollCount ++ * the number of items to display at a time ++ * @throws IllegalArgumentException ++ * if scrollCount is 0 or negative ++ */ ++ public void setScrollCount(int scrollCount) { ++ if (scrollCount <= 0) { ++ throw new IllegalArgumentException( ++ "scrollCount must be greater than 0"); ++ } ++ this.scrollCount = scrollCount; ++ MenuSelectionManager.defaultManager().clearSelectedPath(); ++ } ++ ++ /** ++ * Returns the number of items fixed at the top of the menu or popup menu. ++ * ++ * @return the number of items ++ */ ++ public int getTopFixedCount() { ++ return topFixedCount; ++ } ++ ++ /** ++ * Sets the number of items to fix at the top of the menu or popup menu. ++ * ++ * @param topFixedCount ++ * the number of items ++ */ ++ public void setTopFixedCount(int topFixedCount) { ++ if (firstIndex <= topFixedCount) { ++ firstIndex = topFixedCount; ++ } else { ++ firstIndex += (topFixedCount - this.topFixedCount); ++ } ++ this.topFixedCount = topFixedCount; ++ } ++ ++ /** ++ * Returns the number of items fixed at the bottom of the menu or popup ++ * menu. ++ * ++ * @return the number of items ++ */ ++ public int getBottomFixedCount() { ++ return bottomFixedCount; ++ } ++ ++ /** ++ * Sets the number of items to fix at the bottom of the menu or popup menu. ++ * ++ * @param bottomFixedCount ++ * the number of items ++ */ ++ public void setBottomFixedCount(int bottomFixedCount) { ++ this.bottomFixedCount = bottomFixedCount; ++ } ++ ++ /** ++ * Scrolls the specified item into view each time the menu is opened. Call ++ * this method with <code>null</code> to restore the default behavior, which ++ * is to show the menu as it last appeared. ++ * ++ * @param item ++ * the item to keep visible ++ * @see #keepVisible(int) ++ */ ++ public void keepVisible(JMenuItem item) { ++ if (item == null) { ++ keepVisibleIndex = -1; ++ } else { ++ int index = menu.getComponentIndex(item); ++ keepVisibleIndex = index; ++ } ++ } ++ ++ /** ++ * Scrolls the item at the specified index into view each time the menu is ++ * opened. Call this method with <code>-1</code> to restore the default ++ * behavior, which is to show the menu as it last appeared. ++ * ++ * @param index ++ * the index of the item to keep visible ++ * @see #keepVisible(javax.swing.JMenuItem) ++ */ ++ public void keepVisible(int index) { ++ keepVisibleIndex = index; ++ } ++ ++ /** ++ * Removes this MenuScroller from the associated menu and restores the ++ * default behavior of the menu. ++ */ ++ public void dispose() { ++ if (menu != null) { ++ menu.removePopupMenuListener(menuListener); ++ menu.removeMouseWheelListener(mouseWheelListener); ++ menu = null; ++ } ++ } ++ ++ /** ++ * Ensures that the <code>dispose</code> method of this MenuScroller is ++ * called when there are no more refrences to it. ++ * ++ * @exception Throwable ++ * if an error occurs. ++ * @see MenuScroller#dispose() ++ */ ++ @Override ++ public void finalize() throws Throwable { ++ dispose(); ++ } ++ ++ private void refreshMenu() { ++ if (menuItems != null && menuItems.length > 0) { ++ firstIndex = Math.max(topFixedCount, firstIndex); ++ firstIndex = Math.min(menuItems.length - bottomFixedCount ++ - scrollCount, firstIndex); ++ ++ upItem.setEnabled(firstIndex > topFixedCount); ++ downItem.setEnabled(firstIndex + scrollCount < menuItems.length ++ - bottomFixedCount); ++ ++ menu.removeAll(); ++ for (int i = 0; i < topFixedCount; i++) { ++ menu.add(menuItems[i]); ++ } ++ if (topFixedCount > 0) { ++ menu.addSeparator(); ++ } ++ ++ menu.add(upItem); ++ for (int i = firstIndex; i < scrollCount + firstIndex; i++) { ++ menu.add(menuItems[i]); ++ } ++ menu.add(downItem); ++ ++ if (bottomFixedCount > 0) { ++ menu.addSeparator(); ++ } ++ for (int i = menuItems.length - bottomFixedCount; i < menuItems.length; i++) { ++ menu.add(menuItems[i]); ++ } ++ ++ int preferredWidth = 0; ++ for (Component item : menuItems) { ++ preferredWidth = Math.max(preferredWidth, item.getPreferredSize().width); ++ } ++ menu.setPreferredSize(new Dimension(preferredWidth, menu.getPreferredSize().height)); ++ JComponent parent = (JComponent) upItem.getParent(); ++ parent.revalidate(); ++ parent.repaint(); ++ } ++ } ++ ++ private class MouseScrollListener implements MouseWheelListener { ++ @Override ++ public void mouseWheelMoved(MouseWheelEvent mwe){ ++ // Jajuk change : Accelerate the move with x3 factor ++ firstIndex += mwe.getWheelRotation() * 3; ++ refreshMenu(); ++ mwe.consume(); // (Comment 16, Huw) ++ } ++ } ++ ++ private class MenuScrollListener implements PopupMenuListener { ++ ++ @Override ++ public void popupMenuWillBecomeVisible(PopupMenuEvent e) { ++ setMenuItems(); ++ } ++ ++ @Override ++ public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { ++ restoreMenuItems(); ++ } ++ ++ @Override ++ public void popupMenuCanceled(PopupMenuEvent e) { ++ restoreMenuItems(); ++ } ++ ++ private void setMenuItems() { ++ menuItems = menu.getComponents(); ++ if (keepVisibleIndex >= topFixedCount ++ && keepVisibleIndex <= menuItems.length - bottomFixedCount ++ && (keepVisibleIndex > firstIndex + scrollCount || keepVisibleIndex < firstIndex)) { ++ firstIndex = Math.min(firstIndex, keepVisibleIndex); ++ firstIndex = Math.max(firstIndex, keepVisibleIndex ++ - scrollCount + 1); ++ } ++ if (menuItems.length > topFixedCount + scrollCount ++ + bottomFixedCount) { ++ refreshMenu(); ++ } ++ } ++ ++ private void restoreMenuItems() { ++ menu.removeAll(); ++ for (Component component : menuItems) { ++ menu.add(component); ++ } ++ } ++ } ++ ++ private class MenuScrollTimer extends Timer { ++ ++ private static final long serialVersionUID = 1; ++ ++ public MenuScrollTimer(final int increment, int interval) { ++ super(interval, new ActionListener() { ++ ++ @Override ++ public void actionPerformed(ActionEvent e) { ++ firstIndex += increment; ++ refreshMenu(); ++ } ++ }); ++ } ++ } ++ ++ private class MenuScrollItem extends JMenuItem implements ChangeListener { ++ ++ private static final long serialVersionUID = 1; ++ ++ private MenuScrollTimer timer; ++ ++ public MenuScrollItem(MenuIcon icon, int increment) { ++ setIcon(icon); ++ setDisabledIcon(icon); ++ timer = new MenuScrollTimer(increment, interval); ++ addChangeListener(this); ++ } ++ ++ public void setInterval(int interval) { ++ timer.setDelay(interval); ++ } ++ ++ @Override ++ public void stateChanged(ChangeEvent e) { ++ if (isArmed() && !timer.isRunning()) { ++ timer.start(); ++ } ++ if (!isArmed() && timer.isRunning()) { ++ timer.stop(); ++ } ++ } ++ } ++ ++ private enum MenuIcon implements Icon { ++ ++ UP(9, 1, 9), DOWN(1, 9, 1); ++ final int[] xPoints = { 1, 5, 9 }; ++ final int[] yPoints; ++ ++ MenuIcon(int... yPoints) { ++ this.yPoints = yPoints; ++ } ++ ++ @Override ++ public void paintIcon(Component c, Graphics g, int x, int y) { ++ Dimension size = c.getSize(); ++ Graphics g2 = g.create(size.width / 2 - 5, size.height / 2 - 5, 10, ++ 10); ++ g2.setColor(Color.GRAY); ++ g2.drawPolygon(xPoints, yPoints, 3); ++ if (c.isEnabled()) { ++ g2.setColor(Color.BLACK); ++ g2.fillPolygon(xPoints, yPoints, 3); ++ } ++ g2.dispose(); ++ } ++ ++ @Override ++ public int getIconWidth() { ++ return 0; ++ } ++ ++ @Override ++ public int getIconHeight() { ++ return 10; ++ } ++ } ++} +--- /dev/null ++++ b/src/main/java/org/jajuk/ui/widgets/ScrollingLabel.java +@@ -0,0 +1,68 @@ ++/* ++ * Jajuk ++ * Copyright (C) The Jajuk Team ++ * http://jajuk.info ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * as published by the Free Software Foundation; either version 2 ++ * of the License, or any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ * ++ */ ++ ++package org.jajuk.ui.widgets; ++ ++import javax.swing.*; ++import java.awt.*; ++import java.util.concurrent.ScheduledThreadPoolExecutor; ++import java.util.concurrent.TimeUnit; ++ ++/** ++ * Label that scrolls text horizontally ++ */ ++public class ScrollingLabel extends JLabel { ++ private static final long serialVersionUID = 1L; ++ private int posHoriz = 250; ++ ++ ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1); ++ ++ public ScrollingLabel(String text) { ++ super(text); ++ } ++ ++ public void startScrolling() { ++ executor.scheduleAtFixedRate(new Runnable() { ++ @Override ++ public void run() { ++ repaint(); ++ } ++ }, 100, 100, TimeUnit.MILLISECONDS); ++ } ++ ++ ++ /* (non-Javadoc) ++ * @see javax.swing.JComponent#paintComponent(java.awt.Graphics) ++ */ ++ @Override ++ public void paintComponent(Graphics g) { ++ FontMetrics fm = g.getFontMetrics(); ++ posHoriz = (posHoriz - 10) % getWidth(); ++ int textSize = fm.stringWidth(super.getText()); ++ if (posHoriz <= -1 * textSize) { ++ posHoriz = getWidth(); ++ } ++ //Draw the text on the left ++ g.drawString(getText(), posHoriz, fm.getHeight()); ++ // Draw the text on the right ++ g.drawString(getText(), posHoriz + textSize, fm.getHeight()); ++ } ++} +--- a/src/main/java/ext/JSplash.java ++++ b/src/main/java/ext/JSplash.java +@@ -44,6 +44,7 @@ + + import org.jajuk.ui.helpers.FontManager; + import org.jajuk.ui.helpers.FontManager.JajukFont; ++import org.jajuk.ui.widgets.ScrollingLabel; + import org.jajuk.util.Messages; + import org.jajuk.util.UtilSystem; + +@@ -130,13 +131,13 @@ + totd = totd.substring(0, totd.indexOf("<a")); + } + totd += " "; +- JScrollingText scrollingText = new JScrollingText(totd, -5); ++ ScrollingLabel scrollingText = new ScrollingLabel(totd); + scrollingText.setPreferredSize(new Dimension(400, 20)); + scrollingText.setMaximumSize(new Dimension(400, 20)); + GridLayout layout = new GridLayout(2, 1, 0, 0); + JPanel jpTotdAndProgress = new JPanel(layout); + jpTotdAndProgress.setBorder(new EmptyBorder(4, 5, 0, 5)); +- scrollingText.start(); ++ scrollingText.startScrolling(); + if (mProgressBar) { + mProgress = new JProgressBar(); + if (mProgressBarMessages || mProgressBarPercent) { +--- a/src/main/java/org/jajuk/ui/widgets/WebRadioButton.java ++++ b/src/main/java/org/jajuk/ui/widgets/WebRadioButton.java +@@ -21,104 +21,100 @@ + package org.jajuk.ui.widgets; + + import ext.DropDownButton; +-import ext.scrollablepopupmenu.XCheckedButton; +-import ext.scrollablepopupmenu.XJPopupMenu; +- +-import java.awt.event.ActionEvent; +-import java.awt.event.ActionListener; +- +-import javax.swing.ImageIcon; +-import javax.swing.JPopupMenu; +- ++import ext.MenuScroller; + import org.jajuk.services.webradio.WebRadio; + import org.jajuk.services.webradio.WebRadioHelper; + import org.jajuk.services.webradio.WebRadioManager; + import org.jajuk.ui.actions.ActionManager; + import org.jajuk.ui.actions.JajukAction; + import org.jajuk.ui.actions.JajukActions; +-import org.jajuk.ui.windows.JajukMainWindow; + import org.jajuk.util.Conf; + import org.jajuk.util.Const; + import org.jajuk.util.Messages; + import org.jajuk.util.UtilString; + import org.jajuk.util.log.Log; + ++import javax.swing.*; ++import java.awt.event.ActionEvent; ++import java.awt.event.ActionListener; ++ + /** + * Factorizes code dealing with Web Radio button shared by command panel and slimbar. + */ + public class WebRadioButton extends DropDownButton { +- /** Associated popup. */ +- private XJPopupMenu popupWebRadio; +- /** Generated serialVersionUID. */ +- private static final long serialVersionUID = 1L; +- +- /** +- * Instantiates a new web radio button. +- * @param icon : button icon +- */ +- public WebRadioButton(ImageIcon icon) { +- super(icon); +- setText(""); +- popupWebRadio = new XJPopupMenu(JajukMainWindow.getInstance()); +- setAction(ActionManager.getAction(JajukActions.WEB_RADIO)); +- // Force 16x16 icon +- setIcon(icon); +- populateWebRadios(); +- } +- +- /* (non-Javadoc) +- * @see ext.DropDownButton#getPopupMenu() +- */ +- @Override +- protected JPopupMenu getPopupMenu() { +- // Force populating the radios each time the drop down button is pressed to make sure the +- // current radio icon is synchronized between slimar and main window, see #1866 +- populateWebRadios(); +- return popupWebRadio; +- } +- +- /** +- * Populate webradios. +- */ +- public void populateWebRadios() { +- try { +- // Update button tooltip +- setToolTipText(WebRadioHelper.getCurrentWebRadioTooltip()); +- // Clear previous elements +- popupWebRadio.removeAll(); +- for (final WebRadio radio : WebRadioManager.getInstance().getWebRadios()) { +- String label = radio.getName(); +- if (UtilString.isNotEmpty(radio.getGenre())) { +- label += " [" + radio.getGenre() + "]"; +- } +- XCheckedButton jmi = new XCheckedButton(label); +- jmi.addActionListener(new ActionListener() { +- @Override +- public void actionPerformed(ActionEvent e) { +- Conf.setProperty(Const.CONF_DEFAULT_WEB_RADIO, radio.getName()); +- // force to reselect the item +- populateWebRadios(); +- // update action tooltip on main button with right item +- JajukAction action = ActionManager.getAction(JajukActions.WEB_RADIO); +- action.setShortDescription(Const.HTML + Messages.getString("CommandJPanel.25") +- + Const.P_B + radio.getName() + Const.B_P_HTML); +- // Actually launch the webradio +- try { +- action.perform(null); +- } catch (Exception e1) { +- Log.error(e1); ++ /** ++ * Associated popup menu. ++ */ ++ private JPopupMenu webradios; ++ /** ++ * Generated serialVersionUID. ++ */ ++ private static final long serialVersionUID = 1L; ++ ++ /** ++ * Instantiates a new web radio button. ++ * ++ * @param icon : button icon ++ */ ++ public WebRadioButton(ImageIcon icon) { ++ super(icon); ++ setText(""); ++ webradios = new JPopupMenu(); ++ MenuScroller.setScrollerFor(webradios, 30, 100); ++ setAction(ActionManager.getAction(JajukActions.WEB_RADIO)); ++ // Force 16x16 icon ++ setIcon(icon); ++ populateWebRadios(); ++ } ++ ++ /* (non-Javadoc) ++ * @see ext.DropDownButton#getPopupMenu() ++ */ ++ @Override ++ protected JPopupMenu getPopupMenu() { ++ // Force populating the radios each time the drop down button is pressed to make sure the ++ // current radio icon is synchronized between slimar and main window, see #1866 ++ populateWebRadios(); ++ return webradios; ++ } ++ ++ /** ++ * Populate webradios. ++ */ ++ public void populateWebRadios() { ++ try { ++ // Update button tooltip ++ setToolTipText(WebRadioHelper.getCurrentWebRadioTooltip()); ++ // Clear previous elements ++ webradios.removeAll(); ++ for (final WebRadio radio : WebRadioManager.getInstance().getWebRadios()) { ++ String label = radio.getName(); ++ if (UtilString.isNotEmpty(radio.getGenre())) { ++ label += " [" + radio.getGenre() + "]"; ++ } ++ JMenuItem jmi = new JMenuItem(label); ++ jmi.addActionListener(new ActionListener() { ++ @Override ++ public void actionPerformed(ActionEvent e) { ++ Conf.setProperty(Const.CONF_DEFAULT_WEB_RADIO, radio.getName()); ++ // force to reselect the item ++ populateWebRadios(); ++ // update action tooltip on main button with right item ++ JajukAction action = ActionManager.getAction(JajukActions.WEB_RADIO); ++ action.setShortDescription(Const.HTML + Messages.getString("CommandJPanel.25") ++ + Const.P_B + radio.getName() + Const.B_P_HTML); ++ // Actually launch the webradio ++ try { ++ action.perform(null); ++ } catch (Exception e1) { ++ Log.error(e1); ++ } ++ } ++ }); ++ webradios.add(jmi); + } +- } +- }); +- jmi.setSelected(Conf.getString(Const.CONF_DEFAULT_WEB_RADIO).equals(radio.getName())); +- // Show the check icon +- jmi.setDisplayCheck(true); +- popupWebRadio.add(jmi); +- } +- // Force popup resizing +- popupWebRadio.init(); +- } catch (Exception e) { +- Log.error(e); ++ } catch (Exception e) { ++ Log.error(e); ++ } + } +- } + } diff --git a/debian/patches/series b/debian/patches/series index 791becb..c9d4c89 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -3,3 +3,4 @@ 03_remove_WindowsHotKeyManager.patch 04_disable_update_check.patch 05_fix_version.patch +06_scrolling_stuff.patch -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jajuk.git _______________________________________________ pkg-java-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-java-commits

