com.actelion.research.gui.dock.ShadowBorder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openchemlib Show documentation
Show all versions of openchemlib Show documentation
Open Source Chemistry Library
package com.actelion.research.gui.dock;
import com.actelion.research.gui.hidpi.HiDPIHelper;
import com.actelion.research.util.ColorHelper;
import java.awt.*;
import javax.swing.border.AbstractBorder;
public class ShadowBorder extends AbstractBorder {
private static final long serialVersionUID = 0x20070807;
private static int sBorderWidth,sThinSize;
private Insets mInsets;
/**
* Creates a border with a grey 1 pixel line on left and top
* and a 3 pixel (scaled to Hi-dpi factor) wide shadow on right and bottom.
* Insets are as large as needed for the drawn border.
*/
public ShadowBorder() {
mInsets = new Insets(thinSize(), thinSize(), shadowSize(), shadowSize());
}
public static int thinSize() {
if (sThinSize == 0)
sThinSize = HiDPIHelper.scale(1);
return sThinSize;
}
public static int shadowSize() {
if (sBorderWidth == 0)
sBorderWidth = HiDPIHelper.scale(3);
return sBorderWidth;
}
/**
* Creates a border with a grey 1 pixel line on left and top
* and a 3 pixel wide shadow on right and bottom.
* Insets can be specified to be larger than the drawn border,
* which allows to adjust the spacing outside the drawn border.
*/
public ShadowBorder(int top, int left, int bottom, int right) {
mInsets = new Insets(HiDPIHelper.scale(top), HiDPIHelper.scale(left), HiDPIHelper.scale(bottom), HiDPIHelper.scale(right));
}
public Insets getBorderInsets(Component c) {
return mInsets;
}
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
super.paintBorder(c, g, x, y, w, h);
Color[] shadow = new Color[shadowSize()];
shadow[0] = c.getBackground().darker();
for (int i=1; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy