1 34 35 36 package org.krysalis.jcharts.designer.common.stroke; 37 38 39 import java.awt.BasicStroke ; 40 import java.awt.Color ; 41 import java.awt.Stroke ; 42 43 import org.krysalis.jcharts.designer.common.LabelledTextfield; 44 import org.krysalis.jcharts.properties.util.ChartStroke; 45 46 import javax.swing.*; 47 48 49 54 public class StrokeChooser extends JPanel 55 { 56 private LabelledTextfield widthField; 57 private EndCapsCombo endCaps; 58 private LineJoinsCombo lineJoins; 59 60 private JRadioButton noStroke; 61 62 63 public StrokeChooser( String title, boolean showNoStroke ) 64 { 65 super(); 66 super.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder( title ), 67 BorderFactory.createEmptyBorder( 5, 5, 5, 5 ) ) ); 68 69 this.setLayout( new BoxLayout( this, BoxLayout.Y_AXIS ) ); 70 71 this.widthField= new LabelledTextfield( "Width", 4 ); 72 super.add( this.widthField ); 73 74 this.endCaps= new EndCapsCombo(); 75 super.add( this.endCaps ); 76 77 this.lineJoins= new LineJoinsCombo(); 78 super.add( this.lineJoins ); 79 80 } 81 82 83 84 88 public StrokeChooser( String title ) 89 { 90 super(); 91 super.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder( title ), 92 BorderFactory.createEmptyBorder( 5, 5, 5, 5 ) ) ); 93 94 this.setLayout( new BoxLayout( this, BoxLayout.Y_AXIS ) ); 95 96 this.widthField= new LabelledTextfield( "Width", 3 ); 97 this.widthField.setText( "1" ); 98 super.add( this.widthField ); 99 100 this.endCaps= new EndCapsCombo(); 101 super.add( this.endCaps ); 102 103 this.lineJoins= new LineJoinsCombo(); 104 super.add( this.lineJoins ); 105 } 106 107 108 112 public ChartStroke getChartStroke() 113 { 114 Stroke stroke= new BasicStroke ( Float.valueOf( this.widthField.getText() ).floatValue(), 115 this.endCaps.getEndCapsConstant(), 116 this.lineJoins.getLineJoinsConstant() ); 117 return new ChartStroke( stroke, Color.BLACK ); 118 } 120 } 121 | Popular Tags |