krysalis-jcharts/src/java/org/krysalis/jcharts/designer/common/paint ColorPanel.java,NONE,1.1 PaintChooser.java,1.1,1.2
"Nathaniel G. Auvil" <[email protected]> Thu, 03 Jun 2004 00:57:36 +0000
| Newsgroups | gmane.comp.krysalis.jcharts.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/designer/common/paint
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2119/src/java/org/krysalis/jcharts/designer/common/paint
Modified Files:
PaintChooser.java
Added Files:
ColorPanel.java
Log Message:
Index: PaintChooser.java
===================================================================
RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/designer/common/paint/PaintChooser.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** PaintChooser.java 9 Aug 2003 17:05:12 -0000 1.1
--- PaintChooser.java 3 Jun 2004 00:57:34 -0000 1.2
***************
*** 1,8 ****
/***********************************************************************************************
- * File Info: Id: $
- * Copyright (C) 2002
- * Author: Nathaniel G. Auvil
- * Contributor(s):
- *
* Copyright 2002 (C) Nathaniel G. Auvil. All Rights Reserved.
*
--- 1,3 ----
***************
*** 38,57 ****
************************************************************************************************/
-
package org.krysalis.jcharts.designer.common.paint;
! /*************************************************************************************
! *
* @author Nathaniel Auvil
* @version $Id$
! ************************************************************************************/
! public class PaintChooser
{
!
!
! public PaintChooser()
{
}
! }
--- 33,192 ----
************************************************************************************************/
package org.krysalis.jcharts.designer.common.paint;
! import java.awt.Color;
! import java.awt.GradientPaint;
! import java.awt.GridLayout;
! import java.awt.Paint;
! import java.awt.event.ActionEvent;
! import java.awt.event.ActionListener;
!
! import javax.swing.BorderFactory;
! import javax.swing.BoxLayout;
! import javax.swing.ButtonGroup;
! import javax.swing.JPanel;
! import javax.swing.JRadioButton;
!
! import org.krysalis.jcharts.designer.common.LabelledTextfield;
!
!
! /*****************************************************************************************
! *
* @author Nathaniel Auvil
* @version $Id$
! ****************************************************************************************/
! public class PaintChooser extends JPanel implements ActionListener
{
! private JPanel radios;
! private JRadioButton color;
! private JRadioButton gradiant;
!
! private JPanel colors;
! private ColorPanel colorPanel1;
! private ColorPanel colorPanel2;
!
! private JPanel coordinates;
! private LabelledTextfield x1;
! private LabelledTextfield y1;
! private LabelledTextfield x2;
! private LabelledTextfield y2;
!
!
! /********************************************************************
! *
! * @param showTitle
! * @param color1
! * @param color2
! *******************************************************************/
! public PaintChooser( boolean showTitle, Color color1, Color color2 )
{
+ //---radios
+ this.radios= new JPanel();
+ this.radios.setLayout( new BoxLayout( this.radios, BoxLayout.Y_AXIS ) );
+ this.color= new JRadioButton( "Color" );
+ this.color.setActionCommand( "color" );
+ this.color.setSelected( true );
+ this.color.addActionListener( this );
+ this.radios.add( this.color );
+ this.gradiant= new JRadioButton( "Gradiant" );
+ this.gradiant.setActionCommand( "gradiant" );
+ this.gradiant.addActionListener( this );
+ this.radios.add( this.gradiant );
+ super.add( this.radios );
+
+ ButtonGroup buttonGroup= new ButtonGroup();
+ buttonGroup.add( this.color );
+ buttonGroup.add( this.gradiant );
+
+
+ //---colors
+ this.colors= new JPanel();
+ this.colors.setLayout( new BoxLayout( this.colors, BoxLayout.Y_AXIS ) );
+ this.colorPanel1= new ColorPanel( color1 );
+ this.colors.add( this.colorPanel1 );
+ this.colorPanel2= new ColorPanel( color2 );
+ this.colorPanel2.setEnabled( false );
+ this.colors.add( this.colorPanel2 );
+ super.add( this.colors );
+
+ //---coordinates
+ this.coordinates= new JPanel();
+ this.coordinates.setLayout( new GridLayout( 2, 2 ) );
+ this.x1= new LabelledTextfield( "x1", 3 );
+ this.x1.setText( "0" );
+ this.x1.setEnabled( false );
+ this.coordinates.add( this.x1 );
+ this.y1= new LabelledTextfield( "y1", 3 );
+ this.y1.setText( "0" );
+ this.y1.setEnabled( false );
+ this.coordinates.add( this.y1 );
+ this.x2= new LabelledTextfield( "x2", 3 );
+ this.x2.setText( "400" );
+ this.x2.setEnabled( false );
+ this.coordinates.add( this.x2 );
+ this.y2= new LabelledTextfield( "y2", 3 );
+ this.y2.setText( "400" );
+ this.y2.setEnabled( false );
+ this.coordinates.add( this.y2 );
+ super.add( this.coordinates );
+
+ if( showTitle )
+ {
+ super.setBorder( BorderFactory.createTitledBorder( "Choose Paint" ) );
+ }
}
!
!
! /**********************************************************************
! *
! * @return Paint
! *********************************************************************/
! public Paint getPaint()
! {
! if( this.color.isSelected() )
! {
! return this.colorPanel1.getPaint();
! }
! else
! {
! float xx1= Float.parseFloat( this.x1.getText() );
! float yy1= Float.parseFloat( this.y1.getText() );
! float xx2= Float.parseFloat( this.x2.getText() );
! float yy2= Float.parseFloat( this.y2.getText() );
! GradientPaint g= new GradientPaint( xx1,
! yy1,
! (Color) this.colorPanel1.getPaint(),
! xx2,
! yy2,
! (Color) this.colorPanel2.getPaint() );
! return g;
! }
! }
!
!
! /************************************************************************
! *
! * @param actionEvent
! ***********************************************************************/
! public void actionPerformed( ActionEvent actionEvent )
! {
! if( actionEvent.getSource().equals( this.color ) )
! {
! this.colorPanel2.setEnabled( false );
! this.x1.setEnabled( false );
! this.y1.setEnabled( false );
! this.x2.setEnabled( false );
! this.y2.setEnabled( false );
! }
! else if( actionEvent.getSource().equals( this.gradiant ) )
! {
! this.colorPanel2.setEnabled( true );
! this.x1.setEnabled( true );
! this.y1.setEnabled( true );
! this.x2.setEnabled( true );
! this.y2.setEnabled( true );
! }
! }
! }
\ No newline at end of file
--- NEW FILE: ColorPanel.java ---
/***********************************************************************************************
* Copyright 2002 (C) Nathaniel G. Auvil. All Rights Reserved.
*
* Redistribution and use of this software and associated documentation ("Software"), with or
* without modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain copyright statements and notices.
* Redistributions must also contain a copy of this document.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. The name "jCharts" or "Nathaniel G. Auvil" must not be used to endorse or promote
* products derived from this Software without prior written permission of Nathaniel G.
* Auvil. For written permission, please contact [email protected]
*
* 4. Products derived from this Software may not be called "jCharts" nor may "jCharts" appear
* in their names without prior written permission of Nathaniel G. Auvil. jCharts is a
* registered trademark of Nathaniel G. Auvil.
*
* 5. Due credit should be given to the jCharts Project (http://jcharts.sourceforge.net/).
*
* THIS SOFTWARE IS PROVIDED BY Nathaniel G. Auvil AND CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* jCharts OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
************************************************************************************************/
package org.krysalis.jcharts.designer.common.paint;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Paint;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JColorChooser;
import javax.swing.JPanel;
import org.krysalis.jcharts.designer.common.LabelledTextfield;
/**********************************************************************
* @author Nathaniel Auvil
* @version $Id: ColorPanel.java,v 1.1 2004/06/03 00:57:34 nathaniel_auvil Exp $
**********************************************************************/
public class ColorPanel extends JPanel implements ActionListener
{
private JButton jButton;
private LabelledTextfield alpha;
private JPanel preview;
/************************************************************
*
* @param color
************************************************************/
public ColorPanel( Color color )
{
this.jButton = new JButton( "Show Color Chooser..." );
this.jButton.addActionListener( this );
super.add( this.jButton );
this.alpha= new LabelledTextfield( "Alpha", 3 );
this.alpha.setText( "255" );
super.add( this.alpha );
this.preview= new JPanel();
this.preview.setBackground( color );
this.preview.setPreferredSize( new Dimension( 50, 20 ) );
super.add( this.preview );
}
/**************************************************************
*
* @param actionEvent
**************************************************************/
public void actionPerformed( ActionEvent actionEvent )
{
Color newColor = JColorChooser.showDialog( this, "Choose Paint", super.getBackground() );
if( newColor != null )
{
this.preview.setBackground( new Color( newColor.getRed(),
newColor.getGreen(),
newColor.getBlue(),
Integer.parseInt( this.alpha.getText() ) ) );
}
}
/******************************************************************
*
* @return Paint
*****************************************************************/
public Paint getPaint()
{
return this.preview.getBackground();
}
/********************************************************************
*
* @param enabled
********************************************************************/
public void setEnabled( boolean enabled )
{
this.jButton.setEnabled( enabled );
this.alpha.setEnabled( enabled );
}
}
-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
From Windows to Linux, servers to mobile, InstallShield X is the one
installation-authoring solution that does it all. Learn more and
evaluate today! http://www.installshield.com/Dev2Dev/0504