/* * Copyright 2003-2004, Franz-Josef Elmer, All rights reserved * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details * (http://www.gnu.org/copyleft/lesser.html). * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package jcckit.plot; import java.awt.Color; import jcckit.graphic.GraphicAttributes; import jcckit.graphic.ShapeAttributes; import jcckit.util.ConfigParameters; /** * An {@link AttributesHint} which wraps {@link ShapeAttributes}. * Each call of {@link #getNextHint()} returns a new instance of * ShapeAttributes where fill color, line color and/or * line thickness has been increased by a constant amount. * * @author Franz-Josef Elmer */ public class ShapeAttributesHint implements AttributesHint, Cloneable { /** Configuration parameter key. */ public static final String INITIAL_ATTRIBUTES_KEY = "initialAttributes", FILL_COLOR_HSB_INCREMENT_KEY = "fillColorHSBIncrement", LINE_COLOR_HSB_INCREMENT_KEY = "lineColorHSBIncrement", LINE_THICKNESS_INCREMENT_KEY = "lineThicknessIncrement"; private static float[] extractHSB(Color color) { return color == null ? null : Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null); } private static Color createColor(float[] colorHSB) { return colorHSB == null ? null : Color.getHSBColor(colorHSB[0], colorHSB[1], colorHSB[2]); } private static float[] incrementColor(float[] colorHSB, double[] increments) { float[] result = null; if (colorHSB != null) { result = (float[]) colorHSB.clone(); for (int i = 0; i < 3; i++) { result[i] += increments[i]; } } return result; } private float[] _fillColorHSB; private float[] _lineColorHSB; private double _lineThickness; private double[] _linePattern; private double[] _fillColorHSBIncrement; private double[] _lineColorHSBIncrement; private double _lineThicknessIncrement; /** * Creates an instance from the specified configuration parameters. *
Key & Default Value | Type | Mandatory | *Description |
---|---|---|---|
initialAttributes = default values of * {@link ShapeAttributes} | *ConfigParameters | no | *Initial values of shape attributes. Note, that default * fill and line colors are undefined (they depend on the * Renderer). In this case color increments have no effects. * |
fillColorHSBIncrement = 0 0 0 | *double[] | no | *Hue, saturation, and brightness increments of the fill color. * |
lineColorHSBIncrement = 0 0 0 | *double[] | no | *Hue, saturation, and brightness increments of the line color. * |
lineThicknessIncrement = 0 | *double | no | *Line thickness increment. |