| | 1 | package org.sophie2.main.app.halos.huds.gradient; |
| | 2 | |
| | 3 | import org.apache.batik.ext.awt.MultipleGradientPaint; |
| | 4 | import org.jdesktop.swingx.color.GradientPreviewPanel; |
| | 5 | import org.sophie2.base.commons.util.ImmGradient; |
| | 6 | import org.sophie2.core.logging.SophieLog; |
| | 7 | |
| | 8 | /** |
| | 9 | * Class for the gradient preview. Used only to catch the exception from the |
| | 10 | * {@link GradientPreviewPanel#getGradient()} method when the two points |
| | 11 | * are equal. |
| | 12 | * |
| | 13 | * @author diana |
| | 14 | * |
| | 15 | */ |
| | 16 | public class SophieGradientPreviewPanel extends GradientPreviewPanel{ |
| | 17 | |
| | 18 | private static final long serialVersionUID = -8287150527672235602L; |
| | 19 | private MultipleGradientPaint lastGradient = |
| | 20 | ImmGradient.DEFAULT_GRADIENT.getGradientPaint(); |
| | 21 | |
| | 22 | @Override |
| | 23 | public MultipleGradientPaint getGradient() { |
| | 24 | try { |
| | 25 | this.lastGradient = super.getGradient(); |
| | 26 | return this.lastGradient; |
| | 27 | } catch (IllegalArgumentException e){ |
| | 28 | SophieLog.debug(e); |
| | 29 | return this.lastGradient; |
| | 30 | } |
| | 31 | } |
| | 32 | } |