Update of /cvsroot/squirrel-sql/mavenize/thirdparty-non-maven/ilf-gpl-1.6.1/src/main/java/net/infonode/gui/border
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/border
Added Files:
HighlightBorder.java EtchedLineBorder.java EdgeBorder.java
PopupMenuBorder.java BorderUtil.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: EtchedLineBorder.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: EtchedLineBorder.java,v 1.1 2010/01/26 21:09:41 manningr Exp $
package net.infonode.gui.border;
import net.infonode.gui.ComponentUtil;
import net.infonode.gui.GraphicsUtil;
import net.infonode.util.ColorUtil;
import javax.swing.border.Border;
import java.awt.*;
import java.io.Serializable;
/**
* @author $Author: manningr $
* @version $Revision: 1.1 $
*/
public class EtchedLineBorder implements Border, Serializable {
private static final long serialVersionUID = 1;
private boolean drawTop;
private boolean drawBottom;
private boolean drawLeft;
private boolean drawRight;
private Insets insets;
private Color highlightColor;
private Color shadowColor;
public EtchedLineBorder() {
this(true, true, true, true);
}
public EtchedLineBorder(boolean drawTop, boolean drawLeft, boolean drawBottom, boolean drawRight) {
this(drawTop, drawLeft, drawBottom, drawRight, null, null);
}
public EtchedLineBorder(boolean drawTop, boolean drawLeft, boolean drawBottom, boolean drawRight,
Color highlightColor, Color shadowColor) {
this.drawBottom = drawBottom;
this.drawLeft = drawLeft;
this.drawRight = drawRight;
this.drawTop = drawTop;
insets = new Insets(drawTop ? 2 : 0, drawLeft ? 2 : 0, drawBottom ? 2 : 0, drawRight ? 2 : 0);
this.highlightColor = highlightColor;
this.shadowColor = shadowColor;
}
public Insets getBorderInsets(Component c) {
return insets;
}
public boolean isBorderOpaque() {
return false;
}
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
Color c1 = highlightColor == null ? ColorUtil.mult(ComponentUtil.getBackgroundColor(c), 1.70) : highlightColor;
Color c2 = shadowColor == null ? ColorUtil.mult(ComponentUtil.getBackgroundColor(c), 0.5) : shadowColor;
g.setColor(c1);
if (drawTop)
GraphicsUtil.drawOptimizedLine(g, x, y + 1, x + width - 1, y + 1);
if (drawLeft)
GraphicsUtil.drawOptimizedLine(g, x + 1, y, x + 1, y + height - 1);
g.setColor(c2);
if (drawBottom)
GraphicsUtil.drawOptimizedLine(g, x, y + height - 2, x + width - 1, y + height - 2);
if (drawRight)
GraphicsUtil.drawOptimizedLine(g, x + width - 2, y, x + width - 2, y + height - 1);
g.setColor(c1);
if (drawBottom)
GraphicsUtil.drawOptimizedLine(g, x, y + height - 1, x + width - 1, y + height - 1);
if (drawRight)
GraphicsUtil.drawOptimizedLine(g, x + width - 1, y, x + width - 1, y + height - 1);
g.setColor(c2);
if (drawTop)
GraphicsUtil.drawOptimizedLine(g, x, y, x + width - 1, y);
if (drawLeft)
GraphicsUtil.drawOptimizedLine(g, x, y, x, y + height - 1);
g.setColor(ComponentUtil.getBackgroundColor(c));
if (drawTop && drawRight)
GraphicsUtil.drawOptimizedLine(g, x + width - 2, y + 1, x + width - 1, y);
if (drawBottom && drawLeft)
GraphicsUtil.drawOptimizedLine(g, x, y + height - 1, x + 1, y + height - 2);
}
}
--- NEW FILE: BorderUtil.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: BorderUtil.java,v 1.1 2010/01/26 21:09:41 manningr Exp $
package net.infonode.gui.border;
import net.infonode.gui.InsetsUtil;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import java.awt.*;
/**
* @author $Author: manningr $
* @version $Revision: 1.1 $
*/
public class BorderUtil {
private BorderUtil() {
}
public static Insets getInsetsOutside(Component c, Border border, Border outside) {
Insets insets = new Insets(0, 0, 0, 0);
getInsetsOutside(c, border, outside, insets);
return insets;
}
private static boolean getInsetsOutside(Component c, Border border, Border outside, Insets insets) {
if (border == null)
return false;
else if (border == outside)
return true;
else if (border instanceof CompoundBorder) {
CompoundBorder b = (CompoundBorder) border;
return getInsetsOutside(c, b.getOutsideBorder(), outside, insets) ||
getInsetsOutside(c, b.getInsideBorder(), outside, insets);
}
else {
InsetsUtil.addTo(insets, border.getBorderInsets(c));
return false;
}
}
public static Border copy(final Border border) {
return new Border() {
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
border.paintBorder(c, g, x, y, width, height);
}
public Insets getBorderInsets(Component c) {
return border.getBorderInsets(c);
}
public boolean isBorderOpaque() {
return border.isBorderOpaque();
}
};
}
}
--- NEW FILE: HighlightBorder.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: HighlightBorder.java,v 1.1 2010/01/26 21:09:41 manningr Exp $
package net.infonode.gui.border;
import net.infonode.gui.GraphicsUtil;
import net.infonode.gui.InsetsUtil;
import net.infonode.gui.colorprovider.BackgroundPainterColorProvider;
import net.infonode.gui.colorprovider.ColorMultiplier;
import net.infonode.gui.colorprovider.ColorProvider;
import net.infonode.gui.colorprovider.ColorProviderUtil;
import net.infonode.util.Direction;
import javax.swing.border.Border;
import java.awt.*;
import java.io.Serializable;
/**
* @author $Author: manningr $
* @version $Revision: 1.1 $
*/
public class HighlightBorder implements Border, Serializable {
private static final long serialVersionUID = 1;
private static final Insets INSETS = new Insets(1, 1, 0, 0);
private boolean lowered;
private boolean pressed;
private ColorProvider colorProvider;
public HighlightBorder() {
this(false);
}
public HighlightBorder(boolean lowered) {
this(lowered, null);
}
public HighlightBorder(boolean lowered, Color color) {
this(lowered, false, color);
}
public HighlightBorder(boolean lowered, boolean pressed, Color color) {
this(lowered, pressed, ColorProviderUtil.getColorProvider(color,
new ColorMultiplier(
BackgroundPainterColorProvider.INSTANCE,
lowered ? 0.7 : 1.70)));
}
public HighlightBorder(boolean lowered, boolean pressed, ColorProvider colorProvider) {
this.lowered = lowered;
this.pressed = pressed;
this.colorProvider = colorProvider;
}
public Insets getBorderInsets(Component c) {
return pressed ? InsetsUtil.rotate(Direction.LEFT, INSETS) : INSETS;
}
public boolean isBorderOpaque() {
return false;
}
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
g.setColor(colorProvider.getColor(c));
if (pressed) {
GraphicsUtil.drawOptimizedLine(g, x + (lowered ? 0 : 1), y + height - 1, x + width - 1, y + height - 1);
GraphicsUtil.drawOptimizedLine(g, x + width - 1, y + (lowered ? 0 : 1), x + width - 1, y + height - 2);
}
else {
GraphicsUtil.drawOptimizedLine(g, x, y, x + width - (lowered ? 1 : 2), y);
GraphicsUtil.drawOptimizedLine(g, x, y, x, y + height - (lowered ? 1 : 2));
}
}
}
--- NEW FILE: PopupMenuBorder.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: PopupMenuBorder.java,v 1.1 2010/01/26 21:09:41 manningr Exp $
package net.infonode.gui.border;
import net.infonode.gui.GraphicsUtil;
import javax.swing.border.Border;
import java.awt.*;
import java.io.Serializable;
/**
* @author $Author: manningr $
* @version $Revision: 1.1 $
*/
public class PopupMenuBorder implements Border, Serializable {
private static final long serialVersionUID = 1;
private static final Insets INSETS = new Insets(3, 1, 2, 1);
private Color highlightColor;
private Color shadowColor;
public PopupMenuBorder(Color highlightColor, Color shadowColor) {
this.highlightColor = highlightColor;
this.shadowColor = shadowColor;
}
public boolean isBorderOpaque() {
return false;
}
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
g.setColor(shadowColor);
g.drawRect(x, y, width - 1, height - 1);
g.setColor(highlightColor);
GraphicsUtil.drawOptimizedLine(g, x + 1, y + 1, x + width - 2, y + 1);
GraphicsUtil.drawOptimizedLine(g, x + 1, y + 2, x + 1, y + 2);
GraphicsUtil.drawOptimizedLine(g, x + 1, y + height - 2, x + 1, y + height - 2);
}
public Insets getBorderInsets(Component c) {
return INSETS;
}
}
--- NEW FILE: EdgeBorder.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: EdgeBorder.java,v 1.1 2010/01/26 21:09:41 manningr Exp $
package net.infonode.gui.border;
import net.infonode.gui.ComponentUtil;
import net.infonode.gui.GraphicsUtil;
import net.infonode.gui.colorprovider.ColorProvider;
import net.infonode.gui.colorprovider.FixedColorProvider;
import net.infonode.util.ColorUtil;
import javax.swing.border.Border;
import java.awt.*;
import java.io.Serializable;
/**
* @author $Author: manningr $
* @version $Revision: 1.1 $
*/
public class EdgeBorder implements Border, Serializable {
private static final long serialVersionUID = 1;
private ColorProvider topLeftColor;
private ColorProvider bottomRightColor;
private boolean drawTop;
private boolean drawBottom;
private boolean drawLeft;
private boolean drawRight;
private Insets insets;
public EdgeBorder() {
this(true, true, true, true);
}
public EdgeBorder(boolean drawTop, boolean drawBottom, boolean drawLeft, boolean drawRight) {
this(null, drawTop, drawBottom, drawLeft, drawRight);
}
public EdgeBorder(Color color, boolean drawTop, boolean drawBottom, boolean drawLeft, boolean drawRight) {
ColorProvider c = color == null ? null : new FixedColorProvider(color);
init(c, c, drawTop, drawBottom, drawLeft, drawRight);
}
public EdgeBorder(ColorProvider color) {
init(color, color, true, true, true, true);
}
public EdgeBorder(ColorProvider topLeftColor,
ColorProvider bottomRightColor,
boolean drawTop,
boolean drawBottom,
boolean drawLeft,
boolean drawRight) {
init(topLeftColor, bottomRightColor, drawTop, drawBottom, drawLeft, drawRight);
}
private void init(ColorProvider topLeftColor,
ColorProvider bottomRightColor,
boolean drawTop,
boolean drawBottom,
boolean drawLeft,
boolean drawRight) {
this.topLeftColor = topLeftColor;
this.bottomRightColor = bottomRightColor;
this.drawTop = drawTop;
this.drawBottom = drawBottom;
this.drawLeft = drawLeft;
this.drawRight = drawRight;
insets = new Insets(drawTop ? 1 : 0, drawLeft ? 1 : 0, drawBottom ? 1 : 0, drawRight ? 1 : 0);
}
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
Color topLeft = getColor(topLeftColor, c);
Color bottomRight = getColor(bottomRightColor, c);
if (topLeft != null && bottomRight != null) {
g.setColor(topLeft);
if (drawTop)
GraphicsUtil.drawOptimizedLine(g, x, y, x + width - 1, y);
if (drawLeft)
GraphicsUtil.drawOptimizedLine(g, x, y, x, y + height - 1);
g.setColor(bottomRight);
if (drawRight)
GraphicsUtil.drawOptimizedLine(g, x + width - 1, y, x + width - 1, y + height - 1);
if (drawBottom)
GraphicsUtil.drawOptimizedLine(g, x, y + height - 1, x + width - 1, y + height - 1);
}
}
public Insets getBorderInsets(Component c) {
return insets;
}
public boolean isBorderOpaque() {
return false;
}
private Color getColor(ColorProvider color, Component c) {
Color col = color != null ? color.getColor() : null;
if (col == null) {
Color background = ComponentUtil.getBackgroundColor(c);
return background == null ? null : ColorUtil.mult(background, 0.7f);
}
return col;
}
}
|