Update of /cvsroot/squirrel-sql/mavenize/thirdparty-non-maven/ilf-gpl-1.6.1/src/main/java/net/infonode/gui
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv4128/thirdparty-non-maven/ilf-gpl-1.6.1/src/main/java/net/infonode/gui
Added Files:
FlatIconButtonUI.java UIManagerUtil.java GraphicsUtil.java
ButtonFactory.java InsetsUtil.java FontUtil.java
ReleaseInfoDialog.java ComponentUtil.java Colors.java
BackgroundPainter.java
Log Message:
pom and Source for thirdparty dependency. Maven central requires a valid source code repository for artifacts that it hosts. This project has none, so we host it here for the time being.
--- NEW FILE: UIManagerUtil.java ---
/*
* Copyright (C) 2004 NNL Technology AB
* Visit www.infonode.net for information about InfoNode(R)
* products and how to contact NNL Technology AB.
*
* 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 (at your option) 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.
*/
// $Id: UIManagerUtil.java,v 1.1 2010/01/26 21:09:41 manningr Exp $
package net.infonode.gui;
import net.infonode.gui.border.BorderUtil;
import net.infonode.util.ColorUtil;
import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;
/**
* @author $Author: manningr $
* @version $Revision: 1.1 $
*/
public class UIManagerUtil {
private UIManagerUtil() {
}
public static Insets getInsets(String key) {
return InsetsUtil.copy(UIManager.getInsets(key));
}
public static Insets getInsets(String key, Insets insets) {
Insets i = getInsets(key);
return i == null ? insets : i;
}
public static Insets getInsets(String key, String defaultKey) {
Insets i = getInsets(key);
if (i != null)
return i;
i = getInsets(defaultKey);
return i == null ? new Insets(0, 0, 0, 0) : i;
}
public static Color getColor(String key) {
return ColorUtil.copy(UIManager.getColor(key));
}
public static Color getColor(String key, String defaultKey) {
return getColor(key, defaultKey, Color.BLACK);
}
public static Color getColor(String key, String defaultKey, Color defaultColor) {
Color i = getColor(key);
if (i != null)
return i;
i = getColor(defaultKey);
return i == null ? defaultColor : i;
}
public static Border getBorder(String key) {
return BorderUtil.copy(UIManager.getBorder(key));
}
public static Border getBorder(String key, String defaultKey) {
Border i = getBorder(key);
if (i != null)
return i;
i = getBorder(defaultKey);
return i == null ? BorderFactory.createEmptyBorder() : i;
}
public static Font getFont(String key) {
Font font = UIManager.getFont(key);
if (font == null)
font = new JLabel().getFont();
return FontUtil.copy(font);
}
public static Font getFont(String key, String defaultKey) {
Font i = getFont(key);
if (i != null)
return i;
i = getFont(defaultKey);
return i == null ? new Font("Dialog", 0, 11) : i;
}
public static Color getColor(String key, Color defaultColor) {
Color c = getColor(key);
return c == null ? defaultColor : c;
}
}
--- NEW FILE: FlatIconButtonUI.java ---
/*
* Copyright (C) 2004 NNL Technology AB
* Visit www.infonode.net for information about InfoNode(R)
* products and how to contact NNL Technology AB.
*
* 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 (at your option) 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.
*/
// $Id: FlatIconButtonUI.java,v 1.1 2010/01/26 21:09:41 manningr Exp $
package net.infonode.gui;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicButtonUI;
/**
* @author $Author: manningr $
* @version $Revision: 1.1 $
*/
public class FlatIconButtonUI extends BasicButtonUI {
private final static FlatIconButtonUI buttonUI = new FlatIconButtonUI();
public static ComponentUI createUI(JComponent c) {
return buttonUI;
}
protected void installDefaults(AbstractButton b) {
}
/* public void paint(Graphics g, JComponent c) {
AbstractButton button = (AbstractButton) c;
Insets i = getInsets(button);
button.getIcon().paintIcon(c, g, i.left, i.top);
paintIcon(g, c, new Rectangle(i.left, i.top, c.getWidth(), c.getHeight()));
}
public Dimension getPreferredSize(JComponent c) {
AbstractButton button = (AbstractButton) c;
Insets i = getInsets(button);
return new Dimension(i.left + i.right + button.getIcon().getIconWidth(),
i.top + i.bottom + button.getIcon().getIconWidth());
}
private Insets getInsets(AbstractButton button) {
return InsetsUtil.add(button.getInsets(), button.getMargin());
}
*/
}
--- NEW FILE: ButtonFactory.java ---
/*
* Copyright (C) 2004 NNL Technology AB
* Visit www.infonode.net for information about InfoNode(R)
* products and how to contact NNL Technology AB.
*
* 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 (at your option) 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.
*/
// $Id: ButtonFactory.java,v 1.1 2010/01/26 21:09:41 manningr Exp $
package net.infonode.gui;
import net.infonode.gui.border.HighlightBorder;
import net.infonode.util.ColorUtil;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.plaf.ButtonUI;
import java.awt.*;
import java.awt.event.*;
import java.net.URL;
public class ButtonFactory {
private ButtonFactory() {
}
private static class ButtonHighlighter implements ComponentListener, HierarchyListener {
/* private static final Color HIGHLIGHTED_COLOR = new Color(140, 160, 255);
private static final Color PRESSED_COLOR = new Color(60, 80, 200);
*/
private JButton button;
private Border pressedBorder;
private Border highlightedBorder;
private Border normalBorder;
private boolean rollover;
private long rolloverStart; // Ugly hack to avoid false rollover callbacks which occur when the button is moved
ButtonHighlighter(JButton button, int padding) {
this.button = button;
normalBorder = new EmptyBorder(padding + 2, padding + 2, padding + 2, padding + 2);
pressedBorder = new EmptyBorder(padding + 2, padding + 2, padding, padding);
highlightedBorder = new EmptyBorder(padding + 1, padding + 1, padding + 1, padding + 1);
button.setContentAreaFilled(false);
setNormalState();
button.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
rollover = (System.currentTimeMillis() - rolloverStart) > 20 &&
ButtonHighlighter.this.button.getModel().isRollover();
update();
if (ButtonHighlighter.this.button.getModel().isRollover())
rolloverStart = 0;
}
});
button.addHierarchyListener(this);
button.addComponentListener(this);
}
private void setNormalState() {
button.setBackground(null);
button.setOpaque(false);
button.setBorder(normalBorder);
rollover = false;
}
public void componentHidden(ComponentEvent e) {
setNormalState();
rolloverStart = System.currentTimeMillis();
}
public void componentMoved(ComponentEvent e) {
setNormalState();
rolloverStart = System.currentTimeMillis();
}
public void componentResized(ComponentEvent e) {
setNormalState();
rolloverStart = System.currentTimeMillis();
}
public void componentShown(ComponentEvent e) {
setNormalState();
rolloverStart = System.currentTimeMillis();
}
public void hierarchyChanged(HierarchyEvent e) {
setNormalState();
rolloverStart = System.currentTimeMillis();
}
private void update() {
boolean pressed = button.getModel().isArmed();
if (button.isEnabled() && (rollover || pressed)) {
button.setOpaque(true);
Color backgroundColor = ComponentUtil.getBackgroundColor(button.getParent());
backgroundColor = backgroundColor == null ?
UIManagerUtil.getColor("control", Color.LIGHT_GRAY) : backgroundColor;
button.setBackground(ColorUtil.mult(backgroundColor, pressed ? 0.8 : 1.15));
button.setBorder(pressed ?
new CompoundBorder(new LineBorder(ColorUtil.mult(backgroundColor, 0.3)),
pressedBorder) :
new CompoundBorder(new LineBorder(ColorUtil.mult(backgroundColor, 0.5)),
highlightedBorder));
}
else {
setNormalState();
}
}
}
private static final Border normalBorder = new CompoundBorder(new LineBorder(new Color(70, 70, 70)),
new CompoundBorder(new HighlightBorder(),
new EmptyBorder(1, 6, 1, 6)));
private static final Border pressedBorder = new CompoundBorder(new LineBorder(new Color(70, 70, 70)),
new CompoundBorder(new HighlightBorder(true),
new EmptyBorder(2, 7, 0, 5)));
private static JButton initButton(final JButton button) {
button.setMargin(null);
button.setBorder(normalBorder);
button.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
button.setBorder(pressedBorder);
}
public void mouseReleased(MouseEvent e) {
button.setBorder(normalBorder);
}
});
return button;
}
private static JButton newButton(String text) {
return initButton(new JButton(text));
}
private static JButton newButton(Icon icon) {
return initButton(new JButton(icon));
}
private static JButton newButton(Icon icon, String text) {
return initButton(new JButton(text, icon));
}
public static final JButton createDialogButton(String text, ActionListener action) {
JButton b = new JButton(text);
b.setFont(b.getFont().deriveFont(Font.BOLD));
b.addActionListener(action);
return b;
}
public static final JButton createButton(String text, ActionListener action) {
return createButton(text, true, action);
}
public static final JButton createButton(String text, boolean opaque, ActionListener action) {
JButton b = newButton(text);
b.setOpaque(opaque);
b.addActionListener(action);
return b;
}
public static final JButton createButton(String iconResource, String text, ActionListener action) {
URL iconURL = ButtonFactory.class.getClassLoader().getResource(iconResource);
return createButton(iconURL == null ? null : new ImageIcon(iconURL), text, action);
}
public static final JButton createButton(Icon icon, String text, ActionListener action) {
JButton b;
if (icon != null) {
b = newButton(icon);
b.setToolTipText(text);
}
else {
b = newButton(text);
}
b.addActionListener(action);
return b;
}
public static final JButton createButton(Icon icon, String tooltipText, boolean opaque, ActionListener action) {
JButton b = newButton(icon);
b.setToolTipText(tooltipText);
b.addActionListener(action);
b.setOpaque(opaque);
return b;
}
public static final JButton createFlatHighlightButton(Icon icon, String tooltipText, int padding,
ActionListener action) {
final JButton b = new JButton(icon) {
public void setUI(ButtonUI ui) {
super.setUI(new FlatIconButtonUI());
}
};
b.setVerticalAlignment(SwingConstants.CENTER);
b.setToolTipText(tooltipText);
b.setMargin(new Insets(0, 0, 0, 0));
new ButtonHighlighter(b, padding);
b.setRolloverEnabled(true);
if (action != null)
b.addActionListener(action);
return b;
}
public static final void applyButtonHighlighter(JButton b, int padding) {
b.setVerticalAlignment(SwingConstants.CENTER);
b.setMargin(new Insets(0, 0, 0, 0));
new ButtonHighlighter(b, padding);
b.setRolloverEnabled(true);
}
public static final JButton createFlatHighlightButton(Icon icon, String tooltipText, int padding,
boolean focusable, ActionListener action) {
final JButton b = createFlatHighlightButton(icon, tooltipText, padding, action);
b.setFocusable(focusable);
return b;
}
public static final JButton createHighlightButton(String text, ActionListener action) {
JButton b = newButton(text);
b.addActionListener(action);
return b;
}
public static final JButton createHighlightButton(Icon icon, ActionListener action) {
JButton b = newButton(icon);
b.addActionListener(action);
return b;
}
public static final JButton createHighlightButton(Icon icon, String text, ActionListener action) {
JButton b = newButton(icon, text);
b.addActionListener(action);
return b;
}
public static final JButton createFlatIconHoverButton(Icon icon, Icon hovered, Icon pressed) {
final JButton b = new JButton(icon) {
public void setUI(ButtonUI ui) {
super.setUI(new FlatIconButtonUI());
}
};
b.setPressedIcon(pressed);
b.setRolloverEnabled(true);
b.setRolloverIcon(hovered);
b.setVerticalAlignment(SwingConstants.CENTER);
return b;
}
}
--- NEW FILE: ComponentUtil.java ---
/*
* Copyright (C) 2004 NNL Technology AB
* Visit www.infonode.net for information about InfoNode(R)
* products and how to contact NNL Technology AB.
*
* 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 (at your option) 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.
*/
// $Id: ComponentUtil.java,v 1.1 2010/01/26 21:09:41 manningr Exp $
package net.infonode.gui;
import net.infonode.gui.componentpainter.ComponentPainter;
import net.infonode.util.Direction;
import javax.swing.*;
import java.applet.Applet;
import java.awt.*;
import java.util.ArrayList;
public class ComponentUtil {
private ComponentUtil() {
}
public static final Component getChildAt(Container container, Point p) {
Component c = container.getComponentAt(p);
return c == null || c.getParent() != container ? null : c;
}
public static final Component getVisibleChildAt(Container container, Point p) {
for (int i = 0; i < container.getComponentCount(); i++) {
Component c = container.getComponent(i);
if (c.isVisible() && c.contains(p.x - c.getX(), p.y - c.getY()))
return c;
}
return null;
}
public static final Component getChildAtLine(Container container, Point p, boolean horizontal) {
if (horizontal) {
for (int i = 0; i < container.getComponentCount(); i++) {
Component c = container.getComponent(i);
if (p.x >= c.getX() && p.x < c.getX() + c.getWidth())
return c;
}
}
else {
for (int i = 0; i < container.getComponentCount(); i++) {
Component c = container.getComponent(i);
if (p.y >= c.getY() && p.y < c.getY() + c.getHeight())
return c;
}
}
return null;
}
public static void getComponentTreePosition(Component c, ArrayList pos) {
if (c.getParent() == null) {
return;
}
getComponentTreePosition(c.getParent(), pos);
pos.add(new Integer(c.getParent().getComponentCount() - ComponentUtil.getComponentIndex(c)));
}
public static Component findComponentUnderGlassPaneAt(Point p, Component top) {
Component c = null;
if (top.isShowing()) {
if (top instanceof RootPaneContainer)
c =
((RootPaneContainer) top).getLayeredPane().findComponentAt(
SwingUtilities.convertPoint(top, p, ((RootPaneContainer) top).getLayeredPane()));
else
c = ((Container) top).findComponentAt(p);
}
return c;
}
public static final int getComponentIndex(Component component) {
if (component != null && component.getParent() != null) {
Container c = component.getParent();
for (int i = 0; i < c.getComponentCount(); i++) {
if (c.getComponent(i) == component)
return i;
}
}
return -1;
}
public static final String getBorderLayoutOrientation(Direction d) {
return d == Direction.UP ?
BorderLayout.NORTH :
d == Direction.LEFT ? BorderLayout.WEST : d == Direction.DOWN ? BorderLayout.SOUTH : BorderLayout.EAST;
}
public static Color getBackgroundColor(Component component) {
if (component == null)
return null;
if (component instanceof BackgroundPainter) {
ComponentPainter painter = ((BackgroundPainter) component).getComponentPainter();
if (painter != null) {
Color c = painter.getColor(component);
if (c != null)
return c;
}
}
return component.isOpaque() ? component.getBackground() : getBackgroundColor(component.getParent());
}
public static int countComponents(Container c) {
int num = 1;
for (int i = 0; i < c.getComponentCount(); i++) {
Component comp = c.getComponent(i);
if (comp instanceof Container)
num += countComponents((Container) comp);
else
num++;
}
return num;
}
public static int getVisibleChildrenCount(Component c) {
if (c == null || !(c instanceof Container))
return 0;
int count = 0;
Container container = (Container) c;
for (int i = 0; i < container.getComponentCount(); i++)
if (container.getComponent(i).isVisible())
count++;
return count;
}
public static Component getTopLevelAncestor(Component c) {
while (c != null) {
if (c instanceof Window || c instanceof Applet)
break;
c = c.getParent();
}
return c;
}
public static boolean hasVisibleChildren(Component c) {
return getVisibleChildrenCount(c) > 0;
}
public static boolean isOnlyVisibleComponent(Component c) {
return c != null && c.isVisible() && getVisibleChildrenCount(c.getParent()) == 1;
}
public static boolean isOnlyVisibleComponents(Component[] c) {
if (c != null && c.length > 0) {
boolean visible = getVisibleChildrenCount(c[0].getParent()) == c.length;
if (visible)
for (int i = 0; i < c.length; i++)
visible = visible && c[i].isVisible();
return visible;
}
return false;
}
public static Component findFirstComponentOfType(Component comp, Class c) {
if (c.isInstance(comp))
return comp;
if (comp instanceof Container) {
Container container = (Container) comp;
for (int i = 0; i < container.getComponentCount(); i++) {
Component comp2 = findFirstComponentOfType(container.getComponent(i), c);
if (comp2 != null)
return comp2;
}
}
return null;
}
public static boolean isFocusable(Component c) {
return c.isFocusable() && c.isDisplayable() && c.isVisible() && c.isEnabled();
}
/**
* Requests focus unless the component already has focus. For some weird
* reason calling {@link Component#requestFocusInWindow()}when the
* component is focus owner changes focus owner to another component!
*
* @param component the component to request focus for
* @return true if the component has focus or probably will get focus,
* otherwise false
*/
public static boolean requestFocus(Component component) {
/*
* System.out.println("Owner: " +
* System.identityHashCode(KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()) + ", " +
* System.identityHashCode(component) + ", " +
* (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() ==
* component));
*/
return KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() == component ||
component.requestFocusInWindow();
}
/**
* Requests focus for a component. If that's not possible it's
* {@link FocusTraversalPolicy}is checked. If that doesn't work all it's
* children is recursively checked with this method.
*
* @param component the component to request focus for
* @return the component which has focus or probably will obtain focus, null
* if no component will receive focus
*/
public static Component smartRequestFocus(Component component) {
if (requestFocus(component))
return component;
if (component instanceof JComponent) {
FocusTraversalPolicy policy = ((JComponent) component).getFocusTraversalPolicy();
if (policy != null) {
Component focusComponent = policy.getDefaultComponent((Container) component);
if (focusComponent != null && requestFocus(focusComponent)) {
return focusComponent;
}
}
}
if (component instanceof Container) {
Component[] children = ((Container) component).getComponents();
for (int i = 0; i < children.length; i++) {
component = smartRequestFocus(children[i]);
if (component != null)
return component;
}
}
return null;
}
/**
* Calculates preferred max height for the given components without checking
* isVisible.
*
* @param components Components to check
* @return max height
*/
public static int getPreferredMaxHeight(Component[] components) {
int height = 0;
for (int i = 0; i < components.length; i++) {
int k = (int) components[i].getPreferredSize().getHeight();
if (k > height)
height = k;
}
return height;
}
/**
* Calculates preferred max width for the given components without checking
* isVisible.
*
* @param components Components to check
* @return max width
*/
public static int getPreferredMaxWidth(Component[] components) {
int width = 0;
for (int i = 0; i < components.length; i++) {
int k = (int) components[i].getPreferredSize().getWidth();
if (k > width)
width = k;
}
return width;
}
public static void setAllOpaque(Container c, boolean opaque) {
if (c instanceof JComponent) {
((JComponent) c).setOpaque(opaque);
for (int i = 0; i < c.getComponentCount(); i++) {
Component comp = c.getComponent(i);
if (comp instanceof Container)
setAllOpaque((Container) comp, opaque);
}
}
}
public static void validate(JComponent c) {
c.revalidate();
}
public static void validate(Component c) {
if (c instanceof JComponent)
((JComponent) c).revalidate();
else
c.validate();
}
}
--- NEW FILE: ReleaseInfoDialog.java ---
/*
* Copyright (C) 2004 NNL Technology AB
* Visit www.infonode.net for information about InfoNode(R)
* products and how to contact NNL Technology AB.
*
* 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 (at your option) 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.
*/
// $Id: ReleaseInfoDialog.java,v 1.1 2010/01/26 21:09:41 manningr Exp $
package net.infonode.gui;
import net.infonode.util.ReleaseInfo;
import javax.swing.*;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import java.awt.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
public class ReleaseInfoDialog {
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss z");
static {
DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
}
public static void showDialog(ReleaseInfo info, String text) {
showDialog(new ReleaseInfo[]{info}, text == null ? null : new String[]{text});
}
public static void showDialog(ReleaseInfo[] info, String[] text) {
final JComponent message = constructMessage(info, text);
JScrollPane scrollPane = new JScrollPane(message,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER) {
public Dimension getPreferredSize() {
Dimension d = message.getPreferredSize();
int height = (int) d.getHeight();
return new Dimension((int) d.getWidth() + 50, height < 300 ? (int) super.getPreferredSize().getHeight() : 400);
}
};
message.setBorder(new EmptyBorder(10, 20, 10, 20));
scrollPane.getViewport().setBackground(Color.white);
JOptionPane.showMessageDialog(null, scrollPane, "Product Release Information", JOptionPane.INFORMATION_MESSAGE);
}
private static JComponent constructMessage(ReleaseInfo[] info, String[] text) {
Box box = new Box(BoxLayout.Y_AXIS);
for (int i = 0; i < info.length; i++) {
JLabel l = new JLabel("<html><body>" + (text == null || text[i] == null ? "" : text[i] + "<br>") + "<table>" +
"<tr><td style='font-weight: bold;'>Product Name:</td><td>"
+ info[i].getProductName() + "</td></tr>" + "<tr><td style='font-weight: bold;'>Version:</td><td>" +
info[i].getProductVersion()
.toString() +
"</td></tr>"
+ "<tr><td style='font-weight: bold;'>Build Time:</td><td>" + DATE_FORMAT.format(
new Date(info[i].getBuildTime())) + "</td></tr>"
+ "<tr><td style='font-weight: bold;'>License:</td><td>" + info[i].getLicense() + "</td></tr>" +
"<tr><td style='font-weight: bold;'>Vendor:</td><td>" +
info[i].getProductVendor()
+ "</td></tr>" + "<tr><td style='font-weight: bold;'>Homepage:</td><td>" + info[i].getHomepage() +
"</td></tr>" +
"</table></body></html>");
l.setFont(l.getFont().deriveFont(Font.PLAIN));
l.setBorder(new CompoundBorder(new EmptyBorder(0, 0, i == info.length - 1 ? 0 : 10, 0),
new TitledBorder(" " + info[i].getProductName() + " ")));
box.add(l);
}
return box;
}
}
--- NEW FILE: GraphicsUtil.java ---
/*
* Copyright (C) 2004 NNL Technology AB
* Visit www.infonode.net for information about InfoNode(R)
* products and how to contact NNL Technology AB.
*
* 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 (at your option) 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.
*/
// $Id: GraphicsUtil.java,v 1.1 2010/01/26 21:09:41 manningr Exp $
package net.infonode.gui;
import javax.swing.*;
import java.awt.*;
/**
* @author johan
*/
public class GraphicsUtil {
public static void drawOptimizedLine(Graphics g, int x1, int y1, int x2, int y2) {
if (g.getColor().getAlpha() < 255 && (x1 == x2 || y1 == y2))
g.fillRect(x1 < x2 ? x1 : x2, y1 < y2 ? y1 : y2, Math.abs(x2 - x1) + 1, Math.abs(y2 - y1) + 1);
else
g.drawLine(x1, y1, x2, y2);
}
public static Rectangle calculateIntersectionClip(int x, int y, int width, int height, Shape originalClip) {
Rectangle bounds = originalClip.getBounds();
SwingUtilities.computeIntersection(x, y, width, height, bounds);
return bounds;
}
}
--- NEW FILE: BackgroundPainter.java ---
/*
* Copyright (C) 2004 NNL Technology AB
* Visit www.infonode.net for information about InfoNode(R)
* products and how to contact NNL Technology AB.
*
* 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 (at your option) 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.
*/
// $Id: BackgroundPainter.java,v 1.1 2010/01/26 21:09:41 manningr Exp $
package net.infonode.gui;
import net.infonode.gui.componentpainter.ComponentPainter;
/**
* An object that paints its background using a {@link ComponentPainter}.
*
* @author $Author: manningr $
* @version $Revision: 1.1 $
* @since IDW 1.2.0
*/
public interface BackgroundPainter {
/**
* Returns the {@link ComponentPainter} that is used to paint the background of this object.
*
* @return the {@link ComponentPainter} that is used to paint the background of this object, null if there is none
*/
ComponentPainter getComponentPainter();
}
--- NEW FILE: Colors.java ---
/*
* Copyright (C) 2004 NNL Technology AB
* Visit www.infonode.net for information about InfoNode(R)
* products and how to contact NNL Technology AB.
*
* 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 (at your option) 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.
*/
// $Id: Colors.java,v 1.1 2010/01/26 21:09:41 manningr Exp $
package net.infonode.gui;
/**
* @author $Author: manningr $
* @version $Revision: 1.1 $
*/
public class Colors {
public static final float RED_HUE = 0f;
public static final float BROWN_HUE = 0.0833f;
public static final float COPPER_HUE = 0.09f;
public static final float ORANGE_HUE = 0.1055f;
public static final float YELLOW_HUE = 1f / 6;
public static final float SAND_HUE = 0.12f;
public static final float GREEN_HUE = 1f / 3;
public static final float CYAN_HUE = 0.5f;
public static final float AZURE_BLUE_HUE = 0.58f;
public static final float ROYAL_BLUE_HUE = 0.61f;
public static final float BLUE_HUE = 2f / 3;
public static final float PURPLE_BUE = 0.77777f;
public static final float MAGENTA_HUE = 0.83f;
private Colors() {
}
}
--- NEW FILE: FontUtil.java ---
/*
* Copyright (C) 2004 NNL Technology AB
* Visit www.infonode.net for information about InfoNode(R)
* products and how to contact NNL Technology AB.
*
* 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 (at your option) 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.
*/
// $Id: FontUtil.java,v 1.1 2010/01/26 21:09:41 manningr Exp $
package net.infonode.gui;
import java.awt.*;
public class FontUtil {
private FontUtil() {
}
public static Font copy(Font font) {
return font == null ? null : new Font(font.getName(), font.getStyle(), font.getSize());
}
}
--- NEW FILE: InsetsUtil.java ---
/*
* Copyright (C) 2004 NNL Technology AB
* Visit www.infonode.net for information about InfoNode(R)
* products and how to contact NNL Technology AB.
*
* 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 (at your option) 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.
*/
// $Id: InsetsUtil.java,v 1.1 2010/01/26 21:09:41 manningr Exp $
package net.infonode.gui;
import net.infonode.util.Direction;
import java.awt.*;
public class InsetsUtil {
public static final Insets EMPTY_INSETS = new Insets(0, 0, 0, 0);
private InsetsUtil() {
}
public static Insets getDiff(Insets source, Insets other) {
int top = other.top - source.top;
int left = other.left - source.left;
int bottom = other.bottom - source.bottom;
int right = other.right - source.right;
return new Insets(top > 0 ? top : 0,
left > 0 ? left : 0,
bottom > 0 ? bottom : 0,
right > 0 ? right : 0);
}
public static Insets sub(Insets i1, Insets i2) {
return new Insets(i1.top - i2.top,
i1.left - i2.left,
i1.bottom - i2.bottom,
i1.right - i2.right);
}
public static Insets add(Insets i, Insets i2) {
return new Insets(i.top + i2.top,
i.left + i2.left,
i.bottom + i2.bottom,
i.right + i2.right);
}
public static final Insets flip(Insets insets, boolean horizontalFlip, boolean verticalFlip) {
return horizontalFlip ? (verticalFlip ? new Insets(insets.bottom, insets.right, insets.top, insets.left) :
new Insets(insets.top, insets.right, insets.bottom, insets.left)) :
(verticalFlip ? new Insets(insets.bottom, insets.left, insets.top, insets.right) :
insets);
}
public static final Insets rotate(Direction d, Insets insets) {
if (d == Direction.LEFT)
return new Insets(insets.bottom,
insets.right,
insets.top,
insets.left);
else if (d == Direction.DOWN)
return new Insets(insets.left,
insets.bottom,
insets.right,
insets.top);
else if (d == Direction.UP)
return new Insets(insets.right,
insets.top,
insets.left,
insets.bottom);
return (Insets) insets.clone();
}
public static Insets max(Insets insets1, Insets insets2) {
return new Insets(Math.max(insets1.top, insets2.top),
Math.max(insets1.left, insets2.left),
Math.max(insets1.bottom, insets2.bottom),
Math.max(insets1.right, insets2.right));
}
public static int maxInset(Insets i) {
return Math.max(i.top, Math.max(i.bottom, Math.max(i.left, i.right)));
}
public static int getInset(Insets insets, Direction direction) {
return direction == Direction.UP ? insets.top :
direction == Direction.LEFT ? insets.left :
direction == Direction.DOWN ? insets.bottom :
insets.right;
}
public static Insets setInset(Insets insets, Direction direction, int value) {
return direction == Direction.UP ? new Insets(value, insets.left, insets.bottom, insets.right) :
direction == Direction.LEFT ? new Insets(insets.top, value, insets.bottom, insets.right) :
direction == Direction.DOWN ? new Insets(insets.top, insets.left, value, insets.right) :
new Insets(insets.top, insets.left, insets.bottom, value);
}
public static Insets copy(Insets insets) {
return insets == null ? null : new Insets(insets.top, insets.left, insets.bottom, insets.right);
}
public static void addTo(Insets insets, Insets addition) {
insets.top += addition.top;
insets.bottom += addition.bottom;
insets.left += addition.left;
insets.right += addition.right;
}
public static Insets flipHorizontal(Insets insets) {
return new Insets(insets.top, insets.right, insets.bottom, insets.left);
}
public static Insets flipVertical(Insets insets) {
return new Insets(insets.bottom, insets.left, insets.top, insets.right);
}
}
|