use of org.eclipse.swt.graphics.FontMetrics in project cubrid-manager by CUBRID.
the class ChartSettingDlg method createPlotItem.
/**
* Create plot appearance tab item
*
*/
public void createPlotItem() {
CTabItem ttlItem = new CTabItem(folder, SWT.NONE);
ttlItem.setText(Messages.tabItemPlotTtl);
Composite tabComp = new Composite(folder, SWT.NONE);
tabComp.setLayout(new GridLayout());
tabComp.setLayoutData(new GridData(GridData.FILL_BOTH));
ttlItem.setControl(tabComp);
Group group = new Group(tabComp, SWT.NONE);
group.setLayout(new GridLayout(2, false));
group.setLayoutData(new GridData(GridData.FILL_BOTH));
group.setText(Messages.plotAppearanceGroupTxt);
appearanceColorList = new List(group, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
GridData gd = new GridData(GridData.FILL_BOTH);
GC gc = new GC(folder.getParent());
gc.setFont(folder.getParent().getFont());
FontMetrics fontMetrics = gc.getFontMetrics();
gc.dispose();
gd.heightHint = Dialog.convertHeightInCharsToPixels(fontMetrics, 15);
appearanceColorList.setLayoutData(gd);
for (int i = 0; i < appearanceColorListModel.length; i++) {
appearanceColorList.add(appearanceColorListModel[i][0]);
}
Composite stylesComposite = new Composite(group, SWT.NONE);
GridLayout layout = new GridLayout(2, true);
stylesComposite.setLayout(layout);
stylesComposite.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
Label colorlbl = new Label(stylesComposite, SWT.LEFT);
colorlbl.setText(Messages.plotColorLbl);
gd = new GridData();
gd.horizontalAlignment = GridData.BEGINNING;
colorlbl.setLayoutData(gd);
appearanceColorEditor = new ColorSelector(stylesComposite);
Button foregroundColorButton = appearanceColorEditor.getButton();
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalAlignment = GridData.BEGINNING;
foregroundColorButton.setLayoutData(gd);
appearanceColorList.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent ex) {
widgetSelected(ex);
}
public void widgetSelected(SelectionEvent ex) {
int i = appearanceColorList.getSelectionIndex();
if (i == -1) {
return;
}
RGB rgb = StringConverter.asRGB(appearanceColorListModel[i][1]);
appearanceColorEditor.setColorValue(rgb);
}
});
foregroundColorButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent ex) {
widgetSelected(ex);
}
public void widgetSelected(SelectionEvent ex) {
int i = appearanceColorList.getSelectionIndex();
if (i == -1) {
return;
}
RGB rgb = appearanceColorEditor.getColorValue();
appearanceColorListModel[i][1] = StringConverter.asString(rgb);
}
});
appearanceColorListModel[0][1] = plotBgColor;
appearanceColorListModel[1][1] = plotDomainGridColor;
appearanceColorListModel[2][1] = plotRangGridColor;
if (appearanceColorListModel.length > 3) {
appearanceColorListModel[3][1] = plotDateAxisColor;
}
if (appearanceColorListModel.length > 4) {
appearanceColorListModel[4][1] = plotNumberAxisColor;
}
if (appearanceColorList.getItemCount() > 0) {
appearanceColorList.select(0);
RGB rgb = StringConverter.asRGB(appearanceColorListModel[0][1]);
appearanceColorEditor.setColorValue(rgb);
}
}
Aggregations