krysalis-jcharts/src/java/org/krysalis/jcharts/designer/tabs/allChart/legendProperties LegendPropertiesTab.java,NONE,1.1 Padding.java,NONE,1.1
"Nathaniel G. Auvil" <[email protected]> Wed, 09 Jun 2004 01:47:00 +0000
| Newsgroups | gmane.comp.krysalis.jcharts.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/designer/tabs/allChart/legendProperties
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24429/src/java/org/krysalis/jcharts/designer/tabs/allChart/legendProperties
Added Files:
LegendPropertiesTab.java Padding.java
Log Message:
--- NEW FILE: LegendPropertiesTab.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.tabs.allChart.legendProperties;
import java.awt.Color;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import org.krysalis.jcharts.designer.common.paint.PaintChooser;
import org.krysalis.jcharts.designer.common.stroke.StrokeChooser;
import org.krysalis.jcharts.designer.exceptions.DesignerException;
import org.krysalis.jcharts.designer.tabs.allChart.items.EdgePadding;
import org.krysalis.jcharts.properties.LegendProperties;
import org.krysalis.jcharts.properties.util.ChartStroke;
/*************************************************************************************
*
* @author Nathaniel Auvil
* @version $Id: LegendPropertiesTab.java,v 1.1 2004/06/09 01:46:53 nathaniel_auvil Exp $
************************************************************************************/
public class LegendPropertiesTab extends JScrollPane
{
private StrokeChooser borderStroke;
private Padding padding;
private PaintChooser backgroundPaint;
private StrokeChooser iconBorderStroke;
//private int numColumns = COLUMNS_AS_MANY_AS_NEEDED;
//---for LineCharts, length of line around point shapes as part of the icon in the legend.
//---for example, ---o---. here iconLineStrokeLength is the length of --- on either sides of 'o'
//private int iconLineStrokeLength = 20;
//---where Legend should be drawn in relation to the chart.
//private int placement = BOTTOM;
/************************************************************************************
*
***********************************************************************************/
public LegendPropertiesTab()
{
JPanel jPanel= new JPanel();
BoxLayout boxLayout= new BoxLayout( jPanel, BoxLayout.Y_AXIS );
jPanel.setLayout( boxLayout );
this.borderStroke= new StrokeChooser( "Border Stroke" );
this.borderStroke.setWidth( 1.0f );
jPanel.add( this.borderStroke );
this.padding= new Padding();
jPanel.add( this.padding );
JPanel background= new JPanel();
background.setBorder( BorderFactory.createTitledBorder( "Background Paint" ) );
this.backgroundPaint= new PaintChooser( false, Color.white, Color.black );
background.add( this.backgroundPaint );
jPanel.add( background );
this.iconBorderStroke= new StrokeChooser( "Icon Border Stroke" );
this.iconBorderStroke.setWidth( 1.0f );
jPanel.add( this.iconBorderStroke );
super.setViewportView( jPanel );
}
/******************************************************************
*
* @param legendProperties
* @throws DesignerException
*****************************************************************/
public void updateChartProperties( LegendProperties legendProperties ) throws DesignerException
{
legendProperties.setBorderStroke( this.borderStroke.getChartStroke() );
legendProperties.setRowPadding( (int) this.padding.getRowPadding() );
legendProperties.setColumnPadding( (int) this.padding.getColumnPadding() );
legendProperties.setIconPadding( (int) this.padding.getIconPadding() );
legendProperties.setChartPadding( (int) this.padding.getChartPadding() );
legendProperties.setEdgePadding( this.padding.getEdgePadding() );
legendProperties.setBackgroundPaint( this.backgroundPaint.getPaint() );
//TODO how to display a NULL Background Paint?
ChartStroke chartStroke= this.iconBorderStroke.getChartStroke();
legendProperties.setIconBorderStroke( chartStroke.getStroke() );
legendProperties.setIconBorderPaint( chartStroke.getPaint() );
}
}
--- NEW FILE: Padding.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.tabs.allChart.legendProperties;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JPanel;
import org.krysalis.jcharts.designer.common.LabelledTextfield;
import org.krysalis.jcharts.designer.exceptions.DesignerException;
/*****************************************************************************************
*
* @author Nathaniel Auvil
* @version $Id: Padding.java,v 1.1 2004/06/09 01:46:53 nathaniel_auvil Exp $
****************************************************************************************/
public class Padding extends JPanel
{
private LabelledTextfield row;
private LabelledTextfield column;
private LabelledTextfield icon;
private LabelledTextfield chart;
private LabelledTextfield edge;
/***************************************************************************************
*
**************************************************************************************/
public Padding()
{
super.setBorder( BorderFactory.createTitledBorder( "Padding" ) );
this.setLayout( new BoxLayout( this, BoxLayout.X_AXIS ) );
this.row = new LabelledTextfield( "Row",3 );
this.row.setText( Float.toString( 5 ) );
this.add( this.row );
this.column = new LabelledTextfield( "Column", 3 );
this.column.setText( Float.toString( 5 ) );
this.add( this.column );
this.icon = new LabelledTextfield( "Icon", 3 );
this.icon.setText( Float.toString( 5 ) );
this.add( this.icon );
this.chart = new LabelledTextfield( "Chart", 3 );
this.chart.setText( Float.toString( 5 ) );
this.add( this.chart );
this.edge = new LabelledTextfield( "Edge", 3 );
this.edge.setText( Float.toString( 5 ) );
this.add( this.edge );
}
/***************************************************************************
*
* @param field
* @return float
* @throws DesignerException
**************************************************************************/
private static float getValue( LabelledTextfield field ) throws DesignerException
{
if( field.getText().trim().equals( "" ) )
{
throw new DesignerException( field.getLabel() + " can not be NULL." );
}
return Float.parseFloat( field.getText() );
}
/***************************************************************************************
*
* @return float
**************************************************************************************/
public float getRowPadding() throws DesignerException
{
return Padding.getValue( this.row );
}
/***************************************************************************************
*
* @return float
**************************************************************************************/
public float getColumnPadding() throws DesignerException
{
return Padding.getValue( this.column );
}
/***************************************************************************************
*
* @return float
**************************************************************************************/
public float getIconPadding() throws DesignerException
{
return Padding.getValue( this.icon );
}
/***************************************************************************************
*
* @return float
**************************************************************************************/
public float getChartPadding() throws DesignerException
{
return Padding.getValue( this.chart );
}
/***************************************************************************************
*
* @return float
**************************************************************************************/
public float getEdgePadding() throws DesignerException
{
return Padding.getValue( this.edge );
}
}
-------------------------------------------------------
This SF.Net email is sponsored by: GNOME Foundation
Hackers Unite! GUADEC: The world's #1 Open Source Desktop Event.
GNOME Users and Developers European Conference, 28-30th June in Norway
http://2004/guadec.org