001: /***********************************************************************************************
002: * Copyright 2002 (C) Nathaniel G. Auvil. All Rights Reserved.
003: *
004: * Redistribution and use of this software and associated documentation ("Software"), with or
005: * without modification, are permitted provided that the following conditions are met:
006: *
007: * 1. Redistributions of source code must retain copyright statements and notices.
008: * Redistributions must also contain a copy of this document.
009: *
010: * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
011: * conditions and the following disclaimer in the documentation and/or other materials
012: * provided with the distribution.
013: *
014: * 3. The name "jCharts" or "Nathaniel G. Auvil" must not be used to endorse or promote
015: * products derived from this Software without prior written permission of Nathaniel G.
016: * Auvil. For written permission, please contact nathaniel_auvil@users.sourceforge.net
017: *
018: * 4. Products derived from this Software may not be called "jCharts" nor may "jCharts" appear
019: * in their names without prior written permission of Nathaniel G. Auvil. jCharts is a
020: * registered trademark of Nathaniel G. Auvil.
021: *
022: * 5. Due credit should be given to the jCharts Project (http://jcharts.sourceforge.net/).
023: *
024: * THIS SOFTWARE IS PROVIDED BY Nathaniel G. Auvil AND CONTRIBUTORS ``AS IS'' AND ANY
025: * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
026: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
027: * jCharts OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
028: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
029: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
030: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,STRICT LIABILITY, OR TORT
031: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
032: * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
033: ************************************************************************************************/package org.krysalis.jcharts.properties.util;
034:
035: import java.awt.*;
036:
037: /*************************************************************************************
038: * Immutable Class to simplify the use of Strokes in Charts
039: *
040: * @author Nathaniel Auvil
041: * @version $Id: ChartStroke.java,v 1.2 2003/06/25 01:39:25 nathaniel_auvil Exp $
042: ************************************************************************************/
043: public class ChartStroke extends ChartItem {
044: private static final Stroke DEFAULT_STROKE = new BasicStroke(1.0f);
045: private static final Stroke DEFAULT_STROKE_1_5 = new BasicStroke(
046: 1.5f);
047:
048: public static final ChartStroke DEFAULT_AXIS = new ChartStroke(
049: DEFAULT_STROKE_1_5, Color.black);
050: public static final ChartStroke DEFAULT_GRIDLINES = new ChartStroke(
051: DEFAULT_STROKE, Color.lightGray);
052: public static final ChartStroke DEFAULT_TICKS = new ChartStroke(
053: DEFAULT_STROKE, Color.black);
054: public static final ChartStroke DEFAULT_ZERO_LINE = new ChartStroke(
055: DEFAULT_STROKE, Color.darkGray);
056:
057: public static final ChartStroke DEFAULT_BAR_OUTLINE = new ChartStroke(
058: DEFAULT_STROKE, Color.black);
059: public static final ChartStroke DEFAULT_CHART_OUTLINE = new ChartStroke(
060: DEFAULT_STROKE, Color.black);
061: public static final ChartStroke DEFAULT_LEGEND_OUTLINE = new ChartStroke(
062: DEFAULT_STROKE, Color.black);
063:
064: public static final ChartStroke DEFAULT_PIE_OUTLINE = new ChartStroke(
065: DEFAULT_STROKE, Color.black);
066:
067: private Stroke stroke;
068:
069: /*********************************************************************************
070: *
071: * @param stroke
072: * @param paint
073: **********************************************************************************/
074: public ChartStroke(Stroke stroke, Paint paint) {
075: super (paint);
076:
077: this .stroke = stroke;
078: }
079:
080: /**********************************************************************************
081: * Sets the Paint and Stroke implementations on the Graphics2D Object
082: *
083: * @param graphics2D
084: **********************************************************************************/
085: public void setupGraphics2D(Graphics2D graphics2D) {
086: super .setupGraphics2D(graphics2D);
087: graphics2D.setStroke(this .stroke);
088: }
089:
090: /*********************************************************************************
091: *
092: * @param graphics2D
093: * @param shape
094: ********************************************************************************/
095: public void draw(Graphics2D graphics2D, Shape shape) {
096: this .setupGraphics2D(graphics2D);
097: graphics2D.draw(shape);
098: }
099:
100: /*********************************************************************************
101: *
102: * @param graphics2D
103: * @param shape
104: ********************************************************************************/
105: public void fill(Graphics2D graphics2D, Shape shape) {
106: this.setupGraphics2D(graphics2D);
107: graphics2D.fill(shape);
108: }
109:
110: }
|