@ -1,6 +1,7 @@
package com.fr.van.chart.designer.component.marker ;
import com.fr.chart.chartglyph.Marker ;
import com.fr.design.i18n.Toolkit ;
import com.fr.design.beans.BasicBeanPane ;
import com.fr.design.gui.ilable.UILabel ;
import com.fr.design.gui.ispinner.UISpinner ;
@ -12,17 +13,23 @@ import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.component.background.VanChartMarkerBackgroundPane ;
import javax.swing.JPanel ;
import java.awt.BorderLayout ;
import java.awt.Component ;
import java.awt.event.ActionEvent ;
import java.awt.event.ActionListener ;
/ * *
* Created by Mitisky on 16 / 5 / 19 .
* 通用标记点 , 标记点类型 / 颜色 / 半径
* /
public class VanChartCommonMarkerPane extends BasicBeanPane < VanChartAttrMarker > {
private MarkerComboBox markerPane ;
private MarkerComboBox markerTypeComboBox ;
private VanChartMarkerBackgroundPane markerFillColor ;
private UISpinner radius ;
private JPanel markerTypePane ;
private JPanel markerConfigPane ;
private static final MarkerType [ ] NORMAL_TYPES = {
MarkerType . MARKER_NULL ,
MarkerType . MARKER_CIRCLE ,
@ -46,6 +53,20 @@ public class VanChartCommonMarkerPane extends BasicBeanPane<VanChartAttrMarker>
return normalMarkers ;
}
protected static Marker [ ] getNormalMarkersWithAuto ( ) {
if ( normalMarkers = = null ) {
normalMarkers = new Marker [ NORMAL_TYPES . length + 1 ] ;
normalMarkers [ 0 ] = Marker . createMarker ( MarkerType . MARKER_AUTO ) ;
int i = 1 ;
for ( MarkerType markerType : NORMAL_TYPES ) {
normalMarkers [ i + + ] = Marker . createMarker ( markerType ) ;
}
}
return normalMarkers ;
}
//没有无这个选项
private static final MarkerType [ ] MAP_TYPES = {
MarkerType . MARKER_CIRCLE ,
@ -88,13 +109,16 @@ public class VanChartCommonMarkerPane extends BasicBeanPane<VanChartAttrMarker>
return ganttMarkers ;
}
public MarkerComboBox getMarkerTypeComboBox ( ) {
return markerTypeComboBox ;
}
protected MarkerComboBox getMarkerPane ( ) {
return markerPane ;
public UISpinner getRadius ( ) {
return radius ;
}
public VanChartCommonMarkerPane ( ) {
markerPane = new MarkerComboBox ( getMarkers ( ) ) ;
markerTypeComboBox = new MarkerComboBox ( getMarkers ( ) ) ;
markerFillColor = new VanChartMarkerBackgroundPane ( ) {
protected Component [ ] [ ] getPaneComponents ( ) {
return new Component [ ] [ ] {
@ -106,42 +130,55 @@ public class VanChartCommonMarkerPane extends BasicBeanPane<VanChartAttrMarker>
radius = new UISpinner ( 0 , 100 , 0 . 5 , 0 ) ;
double p = TableLayout . PREFERRED ;
double e = TableLayout4VanChartHelper . EDIT_AREA_WIDTH ;
double d = TableLayout4VanChartHelper . DESCRIPTION_AREA_WIDTH ;
double [ ] row = { p , p , p } ;
Component [ ] [ ] components = getUseComponent ( ) ;
markerTypePane = TableLayout4VanChartHelper . createGapTableLayoutPane ( getMarkerTypeComponent ( ) , new double [ ] { p } , getColumnSize ( ) ) ;
markerConfigPane = TableLayout4VanChartHelper . createGapTableLayoutPane ( getMarkerConfigComponent ( ) , new double [ ] { p , p } , getColumnSize ( ) ) ;
JPanel jPanel = TableLayout4VanChartHelper . createGapTableLayoutPane ( components , row , getcolumnSize ( ) ) ;
markerTypeComboBox . addActionListener ( new ActionListener ( ) {
@Override
public void actionPerformed ( ActionEvent e ) {
checkMarkType ( ) ;
}
} ) ;
this . add ( jPanel ) ;
}
JPanel contentPane = new JPanel ( new BorderLayout ( 0 , 6 ) ) ;
protected double [ ] getcolumnSize ( ) {
double e = TableLayout4VanChartHelper . EDIT_AREA_WIDTH ;
double d = TableLayout4VanChartHelper . DESCRIPTION_AREA_WIDTH ;
return new double [ ] { d , e } ;
}
contentPane . add ( markerTypePane , BorderLayout . CENTER ) ;
contentPane . add ( markerConfigPane , BorderLayout . SOUTH ) ;
protected Marker [ ] getMarkers ( ) {
return getNormalMarkers ( ) ;
this . add ( contentPane ) ;
}
protected Component [ ] [ ] getUseComponent ( ) {
return new Component [ ] [ ] {
new Component [ ] { new UILabel ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Chart_Type" ) ) , markerPane } ,
new Component [ ] { new UILabel ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Chart_Fill_Color" ) ) , markerFillColor } ,
new Component [ ] { new UILabel ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Chart_Radius" ) ) , radius } ,
protected Component [ ] [ ] getMarkerTypeComponent ( ) {
return new Component [ ] [ ] {
new Component [ ] { new UILabel ( Toolkit . i18nText ( "Fine-Design_Chart_Type" ) ) , markerTypeComboBox }
} ;
}
protected Component [ ] [ ] getUseComponentWithOutFillColor ( ) {
return new Component [ ] [ ] {
new Component [ ] { new UILabel ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Chart_Type " ) ) , markerPane } ,
new Component [ ] { new UILabel ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Chart_Radius" ) ) , radius } ,
protected Component [ ] [ ] getMarkerConfigComponent ( ) {
return new Component [ ] [ ] {
new Component [ ] { new UILabel ( Toolkit . i18nText ( "Fine-Design_Chart_Fill_Color " ) ) , markerFillColor } ,
new Component [ ] { new UILabel ( Toolkit . i18nText ( "Fine-Design_Chart_Radius" ) ) , radius }
} ;
}
private void checkMarkType ( ) {
if ( markerConfigPane ! = null & & markerTypeComboBox ! = null ) {
MarkerType type = MarkerType . parse ( markerTypeComboBox . getSelectedMarkder ( ) . getMarkerType ( ) ) ;
markerConfigPane . setVisible ( ! ( type = = MarkerType . MARKER_AUTO | | type = = MarkerType . MARKER_NULL ) ) ;
}
}
protected double [ ] getColumnSize ( ) {
double e = TableLayout4VanChartHelper . EDIT_AREA_WIDTH ;
double d = TableLayout4VanChartHelper . DESCRIPTION_AREA_WIDTH ;
return new double [ ] { d , e } ;
}
protected Marker [ ] getMarkers ( ) {
return getNormalMarkers ( ) ;
}
/ * *
* title应该是一个属性 , 不只是对话框的标题时用到 , 与其他组件结合时 , 也会用得到
@ -162,9 +199,11 @@ public class VanChartCommonMarkerPane extends BasicBeanPane<VanChartAttrMarker>
marker = new VanChartAttrMarker ( ) ;
marker . setCommon ( true ) ;
}
markerPane . setSelectedMarker ( Marker . createMarker ( populateMarkType ( marker ) ) ) ;
markerTypeComboBox . setSelectedMarker ( Marker . createMarker ( populateMarkType ( marker ) ) ) ;
populateColor ( marker ) ;
radius . setValue ( marker . getRadius ( ) ) ;
checkMarkType ( ) ;
}
protected void populateColor ( VanChartAttrMarker marker ) {
@ -188,7 +227,7 @@ public class VanChartCommonMarkerPane extends BasicBeanPane<VanChartAttrMarker>
marker . setCommon ( true ) ;
updateColor ( marker ) ;
marker . setRadius ( radius . getValue ( ) ) ;
marker . setMarkerType ( MarkerType . parse ( markerPane . getSelectedMarkder ( ) . getMarkerType ( ) ) ) ;
marker . setMarkerType ( MarkerType . parse ( markerTypeComboBox . getSelectedMarkder ( ) . getMarkerType ( ) ) ) ;
}
protected void updateColor ( VanChartAttrMarker marker ) {