|
| 1 | +/******************************************************************************* |
| 2 | + * Copyright (c) 2026 IBM Corporation and others. |
| 3 | + * |
| 4 | + * This program and the accompanying materials are made available under the |
| 5 | + * terms of the Eclipse Public License 2.0 which is available at |
| 6 | + * http://www.eclipse.org/legal/epl-2.0. |
| 7 | + * |
| 8 | + * SPDX-License-Identifier: EPL-2.0 |
| 9 | + * |
| 10 | + * Contributors: |
| 11 | + * IBM Corporation - initial API and implementation |
| 12 | + *******************************************************************************/ |
| 13 | + |
| 14 | +package org.eclipse.draw2d.shadows; |
| 15 | + |
| 16 | +import org.eclipse.draw2d.Graphics; |
| 17 | +import org.eclipse.draw2d.geometry.Rectangle; |
| 18 | + |
| 19 | +/** |
| 20 | + * A versatile border that provides a CSS-style drop shadow effect for circular |
| 21 | + * and elliptical figures. |
| 22 | + * |
| 23 | + * This border simulates visual depth by layering semi-transparent shapes using |
| 24 | + * multi-pass exponential decay. It is designed to work "out of the box" for |
| 25 | + * standard diagramming nodes while remaining highly tunable for other use |
| 26 | + * cases. |
| 27 | + * |
| 28 | + * @since 3.2 |
| 29 | + */ |
| 30 | +public class EllipseDropShadowBorder extends AbstractDropShadowBorder { |
| 31 | + |
| 32 | + @Override |
| 33 | + protected void paintDropShadow(Graphics graphics, Rectangle shadowRect, int size) { |
| 34 | + final Rectangle r = shadowRect.getCopy(); |
| 35 | + for (int i = 0; i < size; i++) { |
| 36 | + final double progress = (double) i / size; |
| 37 | + graphics.setAlpha(calcAlphaValue(progress)); |
| 38 | + graphics.drawArc(r, 270 + i, 90 - i); |
| 39 | + r.translate(1, 1); |
| 40 | + } |
| 41 | + } |
| 42 | + |
| 43 | + @Override |
| 44 | + protected void paintHalo(Graphics graphics, Rectangle shadowRect, int size) { |
| 45 | + final Rectangle r = shadowRect.getCopy(); |
| 46 | + for (int i = 0; i < size; i++) { |
| 47 | + final double progress = (double) i / size; |
| 48 | + graphics.setAlpha(calcAlphaValue(progress)); |
| 49 | + graphics.drawOval(r); |
| 50 | + r.expand(1, 1); |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | +} |
0 commit comments