All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jcckit.graphic.ShapeAttributes Maven / Gradle / Ivy

/*
 * 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.graphic;

import java.awt.Color;

import jcckit.util.ConfigParameters;

/**
 *  Basic attributes for shapes.
 *
 *  @author Franz-Josef Elmer
 */
public class ShapeAttributes implements LineAttributes, FillAttributes {
  /** Configuration parameter key. */
  public static final String FILL_COLOR_KEY = "fillColor",
                             LINE_COLOR_KEY = "lineColor",
                             LINE_THICKNESS_KEY = "lineThickness",
                             LINE_PATTERN_KEY = "linePattern";

  private final Color _fillColor;
  private final Color _lineColor;
  private final double _lineThickness;
  private final double[] _linePattern;

  /**
   * Creates a new instance based on the specified configuration
   * parameters.
   * 
   * 
   *     
   * 
   *     
   * 
   *     
   * 
   *     
   *     
   * 
   *     
   *     
   * 
Key & Default ValueTypeMandatoryDescription
fillColor = no fillingColornoThe fill color of the shape.
lineColor = no lineColornoThe color of a line, a polygon, or the border of a shape.
lineThickness = 0doublenoThe thickness of a line. A thickness of zero means that * the renderer will draw the thinest line possible.
linePattern = solid linedouble[]noA sequence of lengths where the pen is alternatively * down or up. For example, 0.1 0.1 will lead to a dashed * line whereas 0.02 0.02 is the pattern of a dotted * line and 0.02 0.02 0.1 0.02 of a dashed-dotted * line.
*/ public ShapeAttributes(ConfigParameters config) { this(config.getColor(FILL_COLOR_KEY, null), config.getColor(LINE_COLOR_KEY, null), config.getDouble(LINE_THICKNESS_KEY, 0), config.getDoubleArray(LINE_PATTERN_KEY, null)); } /** * Creates a new instance. * @param fillColor The fill color. May be null. * @param lineColor The line color. May be null. * @param lineThickness Thickness of the line. * Negative numbers will be trimmed to zero. * @param linePattern Line pattern. May be null. */ public ShapeAttributes(Color fillColor, Color lineColor, double lineThickness, double[] linePattern) { _fillColor = fillColor; _lineColor = lineColor; _lineThickness = Math.max(0, lineThickness); _linePattern = linePattern; } public Color getFillColor() { return _fillColor; } public Color getLineColor() { return _lineColor; } public double getLineThickness() { return _lineThickness; } public double[] getLinePattern() { return _linePattern; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy