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.designer.common.stroke;
034:
035: import java.awt.BasicStroke;
036: import java.awt.Color;
037: import java.awt.Stroke;
038:
039: import org.krysalis.jcharts.designer.common.LabelledTextfield;
040: import org.krysalis.jcharts.properties.util.ChartStroke;
041:
042: import javax.swing.*;
043:
044: /*************************************************************************************
045: *
046: * @author Nathaniel Auvil
047: * @version $Id: StrokeChooser.java,v 1.2 2004/05/25 01:04:07 nathaniel_auvil Exp $
048: ************************************************************************************/
049: public class StrokeChooser extends JPanel {
050: private LabelledTextfield widthField;
051: private EndCapsCombo endCaps;
052: private LineJoinsCombo lineJoins;
053:
054: private JRadioButton noStroke;
055:
056: public StrokeChooser(String title, boolean showNoStroke) {
057: super ();
058: super .setBorder(BorderFactory.createCompoundBorder(
059: BorderFactory.createTitledBorder(title), BorderFactory
060: .createEmptyBorder(5, 5, 5, 5)));
061:
062: this .setLayout(new BoxLayout(this , BoxLayout.Y_AXIS));
063:
064: this .widthField = new LabelledTextfield("Width", 4);
065: super .add(this .widthField);
066:
067: this .endCaps = new EndCapsCombo();
068: super .add(this .endCaps);
069:
070: this .lineJoins = new LineJoinsCombo();
071: super .add(this .lineJoins);
072:
073: }
074:
075: /***********************************************************************************
076: *
077: * @param title
078: **********************************************************************************/
079: public StrokeChooser(String title) {
080: super ();
081: super .setBorder(BorderFactory.createCompoundBorder(
082: BorderFactory.createTitledBorder(title), BorderFactory
083: .createEmptyBorder(5, 5, 5, 5)));
084:
085: this .setLayout(new BoxLayout(this , BoxLayout.Y_AXIS));
086:
087: this .widthField = new LabelledTextfield("Width", 3);
088: this .widthField.setText("1");
089: super .add(this .widthField);
090:
091: this .endCaps = new EndCapsCombo();
092: super .add(this .endCaps);
093:
094: this .lineJoins = new LineJoinsCombo();
095: super .add(this .lineJoins);
096: }
097:
098: /*****************************************************************
099: *
100: * @return ChartStroke
101: ****************************************************************/
102: public ChartStroke getChartStroke() {
103: Stroke stroke = new BasicStroke(Float.valueOf(
104: this .widthField.getText()).floatValue(), this .endCaps
105: .getEndCapsConstant(), this .lineJoins
106: .getLineJoinsConstant());
107: return new ChartStroke(stroke, Color.BLACK);
108: //TODO need to get the Paint
109: }
110: }
|