Search in sources :

Example 6 with FontMetrics

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);
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) RGB(org.eclipse.swt.graphics.RGB) CTabItem(org.eclipse.swt.custom.CTabItem) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) FontMetrics(org.eclipse.swt.graphics.FontMetrics) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) List(org.eclipse.swt.widgets.List) GC(org.eclipse.swt.graphics.GC) ColorSelector(org.eclipse.jface.preference.ColorSelector) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

FontMetrics (org.eclipse.swt.graphics.FontMetrics)6 GC (org.eclipse.swt.graphics.GC)4 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Label (org.eclipse.swt.widgets.Label)3 ColorSelector (org.eclipse.jface.preference.ColorSelector)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 SelectionListener (org.eclipse.swt.events.SelectionListener)2 RGB (org.eclipse.swt.graphics.RGB)2 Button (org.eclipse.swt.widgets.Button)2 Composite (org.eclipse.swt.widgets.Composite)2 Group (org.eclipse.swt.widgets.Group)2 List (org.eclipse.swt.widgets.List)2 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 Matcher (java.util.regex.Matcher)1 CTabItem (org.eclipse.swt.custom.CTabItem)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1