Update of /cvsroot/squirrel-sql/mavenize/thirdparty-non-maven/ilf-gpl-1.6.1/src/main/java/net/infonode/gui/colorprovider
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/colorprovider
Added Files:
package.html AbstractColorProvider.java ColorMultiplier.java
BackgroundPainterColorProvider.java ColorProviderUtil.java
FixedColorProvider.java ColorProvider.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: AbstractColorProvider.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: AbstractColorProvider.java,v 1.1 2010/01/26 21:09:41 manningr Exp $
package net.infonode.gui.colorprovider;
import java.awt.*;
/**
* Base class for color providers. It returns the color black.
*
* @author $Author: manningr $
* @version $Revision: 1.1 $
*/
abstract public class AbstractColorProvider implements ColorProvider {
public Color getColor() {
return Color.BLACK;
}
public Color getColor(Component component) {
return getColor();
}
}
--- NEW FILE: FixedColorProvider.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: FixedColorProvider.java,v 1.1 2010/01/26 21:09:41 manningr Exp $
package net.infonode.gui.colorprovider;
import java.awt.Color;
import java.io.ObjectStreamException;
/**
* A {@link ColorProvider} which always returns the same color.
*
* @author $Author: manningr $
* @version $Revision: 1.1 $
*/
public class FixedColorProvider extends AbstractColorProvider {
private static final long serialVersionUID = 1;
/**
* A provider for the color black.
*/
public static final FixedColorProvider BLACK = new FixedColorProvider(Color.BLACK);
/**
* A provider for the color white.
*/
public static final FixedColorProvider WHITE = new FixedColorProvider(Color.WHITE);
private final Color color;
/**
* Constructor.
*
* @param color the color which this provider will return
*/
public FixedColorProvider(Color color) {
this.color = color;
}
public Color getColor() {
return color;
}
protected Object readResolve() throws ObjectStreamException {
return color.equals(Color.BLACK) ? BLACK : this;
}
}
--- NEW FILE: ColorMultiplier.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: ColorMultiplier.java,v 1.1 2010/01/26 21:09:41 manningr Exp $
package net.infonode.gui.colorprovider;
import java.awt.Color;
import java.awt.Component;
import net.infonode.util.ColorUtil;
/**
* Multiplies the RGB components of a color with the given factor.
*
* @author $Author: manningr $
* @version $Revision: 1.1 $
*/
public class ColorMultiplier extends AbstractColorProvider {
private static final long serialVersionUID = 1;
private final ColorProvider colorProvider;
private final double factor;
/**
* Constructor.
*
* @param colorProvider provides the color which RGB components will be multiplied
* @param factor the multiply factor
*/
public ColorMultiplier(ColorProvider colorProvider, double factor) {
this.colorProvider = colorProvider;
this.factor = factor;
}
public Color getColor(Component component) {
return ColorUtil.mult(colorProvider.getColor(component), factor);
}
public Color getColor() {
return ColorUtil.mult(colorProvider.getColor(), factor);
}
}
--- NEW FILE: package.html ---
<html>
<body>
Package for color providers. A color provider is an object that provides a color given a component.
</body>
</html>
--- NEW FILE: ColorProviderUtil.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: ColorProviderUtil.java,v 1.1 2010/01/26 21:09:41 manningr Exp $
package net.infonode.gui.colorprovider;
import java.awt.*;
/**
* Utility methods for {@link ColorProvider}'s.
*
* @author $Author: manningr $
* @version $Revision: 1.1 $
*/
public class ColorProviderUtil {
private ColorProviderUtil() {
}
/**
* Returns a {@link ColorProvider} for the color. If the color is null the default provider is returned.
*
* @param color the color for which to return a provider
* @param defaultProvider the default provider
* @return a color provider for the color, if the color is null the default provider is returned
*/
public static ColorProvider getColorProvider(Color color, ColorProvider defaultProvider) {
return color == null ? (ColorProvider) defaultProvider : new FixedColorProvider(color);
}
}
--- NEW FILE: BackgroundPainterColorProvider.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: BackgroundPainterColorProvider.java,v 1.1 2010/01/26 21:09:41 manningr Exp $
package net.infonode.gui.colorprovider;
import java.awt.Color;
import java.awt.Component;
import java.io.ObjectStreamException;
import javax.swing.UIManager;
import net.infonode.gui.ComponentUtil;
/**
* Finds the most suitable background color of a component.
* If the component has a {@link net.infonode.gui.componentpainter.ComponentPainter}
* that paint its background, like for example a shaped panel, the
* color is taken from this painter, otherwise the component background color is used.
*
* @author $Author: manningr $
* @version $Revision: 1.1 $
*/
public class BackgroundPainterColorProvider extends AbstractColorProvider {
private static final long serialVersionUID = 1;
/**
* The only instance of this class.
*/
public static final BackgroundPainterColorProvider INSTANCE = new BackgroundPainterColorProvider();
private BackgroundPainterColorProvider() {
}
public Color getColor(Component component) {
Color color = ComponentUtil.getBackgroundColor(component);
return color == null ? UIManager.getColor("control") : color;
}
protected Object readResolve() throws ObjectStreamException {
return INSTANCE;
}
}
--- NEW FILE: ColorProvider.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: ColorProvider.java,v 1.1 2010/01/26 21:09:41 manningr Exp $
package net.infonode.gui.colorprovider;
import java.awt.*;
import java.io.Serializable;
/**
* An object that provides colors. Instances of this class is typically used by {@link javax.swing.border.Border}
* implementations to obtain border colors which might change depending on the current Look and Feel or which component
* the border is painted on.
*
* @author $Author: manningr $
* @version $Revision: 1.1 $
*/
public interface ColorProvider extends Serializable {
/**
* Returns the default color when no component is available.
*
* @return the default color when no component is available
*/
Color getColor();
/**
* Returns the color obtained from the given component.
*
* @param component the component
* @return the color obtained from the given component
*/
Color getColor(Component component);
}
|