Example usage for org.eclipse.jface.resource FontRegistry FontRegistry

List of usage examples for org.eclipse.jface.resource FontRegistry FontRegistry

Introduction

In this page you can find the example usage for org.eclipse.jface.resource FontRegistry FontRegistry.

Prototype

public FontRegistry(Display display) 

Source Link

Document

Creates an empty font registry.

Usage

From source file:ccw.CCWPlugin.java

License:Open Source License

private synchronized void createFontRegistry() {
    if (fontRegistry == null) {
        DisplayUtil.syncExec(new Runnable() {
            public void run() {
                fontRegistry = new FontRegistry(getWorkbench().getDisplay());

                // Forces initializations
                fontRegistry.getItalic(""); // readOnlyFont
                fontRegistry.getBold(""); // abstractFont
            }/* w  w w .  j a  va  2s. co m*/
        });
    }
}

From source file:com.agynamix.platform.infra.ApplicationContext.java

License:Open Source License

public FontRegistry getFontRegistry() {
    if (fontRegistry == null) {
        fontRegistry = new FontRegistry(Display.getDefault());
    }
    return fontRegistry;
}

From source file:com.android.ide.eclipse.gltrace.editors.DurationMinimap.java

License:Apache License

private void initializeFonts() {
    mFontRegistry = new FontRegistry(getDisplay());
    mFontRegistry.put(FONT_KEY, new FontData[] { new FontData("Arial", 8, SWT.NORMAL) }); //$NON-NLS-1$

    GC gc = new GC(getDisplay());
    gc.setFont(mFontRegistry.get(FONT_KEY));
    mFontWidth = gc.getFontMetrics().getAverageCharWidth();
    mFontHeight = gc.getFontMetrics().getHeight();
    gc.dispose();/*  www  .j  a  v a 2 s.  c  o  m*/
}

From source file:com.android.traceview.TimeLineView.java

License:Apache License

public TimeLineView(Composite parent, TraceReader reader, SelectionController selectionController) {
    super(parent, SWT.NONE);
    mRowByName = new HashMap<String, RowData>();
    this.mSelectionController = selectionController;
    selectionController.addObserver(this);
    mUnits = reader.getTraceUnits();//ww  w.  j a  v a 2 s. c om
    mClockSource = reader.getClockSource();
    mHaveCpuTime = reader.haveCpuTime();
    mHaveRealTime = reader.haveRealTime();
    mThreadLabels = reader.getThreadLabels();

    Display display = getDisplay();
    mColorGray = display.getSystemColor(SWT.COLOR_GRAY);
    mColorDarkGray = display.getSystemColor(SWT.COLOR_DARK_GRAY);
    mColorBlack = display.getSystemColor(SWT.COLOR_BLACK);
    // mColorBackground = display.getSystemColor(SWT.COLOR_WHITE);
    mColorForeground = display.getSystemColor(SWT.COLOR_BLACK);
    mColorRowBack = new Color(display, 240, 240, 255);
    mColorZoomSelection = new Color(display, 230, 230, 230);

    mFontRegistry = new FontRegistry(display);
    mFontRegistry.put("small", //$NON-NLS-1$
            new FontData[] { new FontData("Arial", 8, SWT.NORMAL) }); //$NON-NLS-1$
    mFontRegistry.put("courier8", //$NON-NLS-1$
            new FontData[] { new FontData("Courier New", 8, SWT.BOLD) }); //$NON-NLS-1$
    mFontRegistry.put("medium", //$NON-NLS-1$
            new FontData[] { new FontData("Courier New", 10, SWT.NORMAL) }); //$NON-NLS-1$

    Image image = new Image(display, new Rectangle(100, 100, 100, 100));
    GC gc = new GC(image);
    if (mSetFonts) {
        gc.setFont(mFontRegistry.get("small")); //$NON-NLS-1$
    }
    mSmallFontWidth = gc.getFontMetrics().getAverageCharWidth();
    mSmallFontHeight = gc.getFontMetrics().getHeight();

    image.dispose();
    gc.dispose();

    setLayout(new FillLayout());

    // Create a sash form for holding two canvas views, one for the
    // thread labels and one for the thread timeline.
    mSashForm = new SashForm(this, SWT.HORIZONTAL);
    mSashForm.setBackground(mColorGray);
    mSashForm.SASH_WIDTH = 3;

    // Create a composite for the left side of the sash
    Composite composite = new Composite(mSashForm, SWT.NONE);
    GridLayout layout = new GridLayout(1, true /* make columns equal width */);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 1;
    composite.setLayout(layout);

    // Create a blank corner space in the upper left corner
    BlankCorner corner = new BlankCorner(composite);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.heightHint = topMargin;
    corner.setLayoutData(gridData);

    // Add the thread labels below the blank corner.
    mLabels = new RowLabels(composite);
    gridData = new GridData(GridData.FILL_BOTH);
    mLabels.setLayoutData(gridData);

    // Create another composite for the right side of the sash
    composite = new Composite(mSashForm, SWT.NONE);
    layout = new GridLayout(1, true /* make columns equal width */);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 1;
    composite.setLayout(layout);

    mTimescale = new Timescale(composite);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.heightHint = topMargin;
    mTimescale.setLayoutData(gridData);

    mSurface = new Surface(composite);
    gridData = new GridData(GridData.FILL_BOTH);
    mSurface.setLayoutData(gridData);
    mSashForm.setWeights(new int[] { 1, 5 });

    final ScrollBar vBar = mSurface.getVerticalBar();
    vBar.addListener(SWT.Selection, new Listener() {
        @Override
        public void handleEvent(Event e) {
            mScrollOffsetY = vBar.getSelection();
            Point dim = mSurface.getSize();
            int newScrollOffsetY = computeVisibleRows(dim.y);
            if (newScrollOffsetY != mScrollOffsetY) {
                mScrollOffsetY = newScrollOffsetY;
                vBar.setSelection(newScrollOffsetY);
            }
            mLabels.redraw();
            mSurface.redraw();
        }
    });

    final ScrollBar hBar = mSurface.getHorizontalBar();
    hBar.addListener(SWT.Selection, new Listener() {
        @Override
        public void handleEvent(Event e) {
            mSurface.setScaleFromHorizontalScrollBar(hBar.getSelection());
            mSurface.redraw();
        }
    });

    mSurface.addListener(SWT.Resize, new Listener() {
        @Override
        public void handleEvent(Event e) {
            Point dim = mSurface.getSize();

            // If we don't need the scroll bar then don't display it.
            if (dim.y >= mNumRows * rowYSpace) {
                vBar.setVisible(false);
            } else {
                vBar.setVisible(true);
            }
            int newScrollOffsetY = computeVisibleRows(dim.y);
            if (newScrollOffsetY != mScrollOffsetY) {
                mScrollOffsetY = newScrollOffsetY;
                vBar.setSelection(newScrollOffsetY);
            }

            int spaceNeeded = mNumRows * rowYSpace;
            vBar.setMaximum(spaceNeeded);
            vBar.setThumb(dim.y);

            mLabels.redraw();
            mSurface.redraw();
        }
    });

    mSurface.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseUp(MouseEvent me) {
            mSurface.mouseUp(me);
        }

        @Override
        public void mouseDown(MouseEvent me) {
            mSurface.mouseDown(me);
        }

        @Override
        public void mouseDoubleClick(MouseEvent me) {
            mSurface.mouseDoubleClick(me);
        }
    });

    mSurface.addMouseMoveListener(new MouseMoveListener() {
        @Override
        public void mouseMove(MouseEvent me) {
            mSurface.mouseMove(me);
        }
    });

    mSurface.addMouseWheelListener(new MouseWheelListener() {
        @Override
        public void mouseScrolled(MouseEvent me) {
            mSurface.mouseScrolled(me);
        }
    });

    mTimescale.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseUp(MouseEvent me) {
            mTimescale.mouseUp(me);
        }

        @Override
        public void mouseDown(MouseEvent me) {
            mTimescale.mouseDown(me);
        }

        @Override
        public void mouseDoubleClick(MouseEvent me) {
            mTimescale.mouseDoubleClick(me);
        }
    });

    mTimescale.addMouseMoveListener(new MouseMoveListener() {
        @Override
        public void mouseMove(MouseEvent me) {
            mTimescale.mouseMove(me);
        }
    });

    mLabels.addMouseMoveListener(new MouseMoveListener() {
        @Override
        public void mouseMove(MouseEvent me) {
            mLabels.mouseMove(me);
        }
    });

    setData(reader.getThreadTimeRecords());
}

From source file:com.ibm.research.tours.ToursPlugin.java

License:Open Source License

public FontRegistry getFontRegistry() {
    if (fFontRegistry == null)
        fFontRegistry = new FontRegistry(Display.getDefault());

    return fFontRegistry;
}

From source file:com.mobilesorcery.sdk.ui.MosyncUIPlugin.java

License:Open Source License

private synchronized FontRegistry getFontRegistry(Display current) {
    FontRegistry registry = fontRegistries.get(current);
    if (registry == null) {
        registry = new FontRegistry(current);
        fontRegistries.put(current, registry);
        initRegistry(registry);//from  w  w  w .  j  a  v  a  2s  .  c  o m
    }

    return registry;
}

From source file:com.nokia.s60tools.crashanalyser.ui.editors.CallStackPage.java

License:Open Source License

/**
 * Creates all UI elements to the page/*from  w ww  .  ja va  2s . co  m*/
 * @param parent
 * @return composite
 */
Composite doCreate(Composite parent) {
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    parent.setLayout(layout);
    parent.setLayoutData(new GridData(GridData.FILL_BOTH));
    fontRegistry = new FontRegistry(Display.getCurrent());
    fontRegistry.put("monospace", new FontData[] { new FontData("Courier", 8, SWT.NORMAL) });
    SashForm sashFormMain = new SashForm(parent, SWT.VERTICAL);
    sashFormMain.setLayoutData(new GridData(GridData.FILL_BOTH));
    createCallStackGroup(sashFormMain);

    setHelps();

    return parent;
}

From source file:com.nokia.s60tools.crashanalyser.ui.editors.CodesegmentsPage.java

License:Open Source License

/**
 * Creates all UI elements to the page/*w  w  w.  j av a  2 s.  c om*/
 * @param parent
 * @return composite
 */
Composite doCreatePage(Composite parent) {
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    parent.setLayout(layout);
    parent.setLayoutData(new GridData(GridData.FILL_BOTH));

    fontRegistry = new FontRegistry(Display.getCurrent());
    fontRegistry.put("monospace", new FontData[] { new FontData("Courier", 8, SWT.NORMAL) });

    SashForm sashFormMain = new SashForm(parent, SWT.VERTICAL);
    sashFormMain.setLayoutData(new GridData(GridData.FILL_BOTH));
    createCodeSegmentsGroup(sashFormMain);

    /*
    SashForm sashFormTop = new SashForm(sashFormMain, SWT.HORIZONTAL);
    createRegistersGroup(sashFormTop);
    createCodeSegmentsGroup(sashFormTop);
    SashForm sashFormBottom = new SashForm(sashFormMain, SWT.HORIZONTAL);
    createEventLogGroup(sashFormBottom);
    createCpsrDetailsGroup(sashFormBottom);
            
    sashFormTop.setWeights(new int[]{3,2});
    sashFormBottom.setWeights(new int[]{3,7});
       */
    setHelps();

    return parent;
}

From source file:com.nokia.s60tools.crashanalyser.ui.editors.RegistersPage.java

License:Open Source License

/**
 * Creates all UI elements to the page/*  ww w  . j  a v a  2s .  c  om*/
 * @param parent
 * @return composite
 */
Composite doCreatePage(Composite parent) {
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    parent.setLayout(layout);
    parent.setLayoutData(new GridData(GridData.FILL_BOTH));

    fontRegistry = new FontRegistry(Display.getCurrent());
    fontRegistry.put("monospace", new FontData[] { new FontData("Courier", 8, SWT.NORMAL) });

    SashForm sashFormMain = new SashForm(parent, SWT.VERTICAL);
    sashFormMain.setLayoutData(new GridData(GridData.FILL_BOTH));
    //      SashForm sashFormTop = new SashForm(sashFormMain, SWT.HORIZONTAL);
    createRegistersGroup(sashFormMain);
    //      createCodeSegmentsGroup(sashFormTop);
    //      SashForm sashFormBottom = new SashForm(sashFormMain, SWT.HORIZONTAL);
    //      createEventLogGroup(sashFormBottom);
    createCpsrDetailsGroup(sashFormMain);

    //      sashFormTop.setWeights(new int[]{3,2});
    //      sashFormBottom.setWeights(new int[]{3,7});

    setHelps();

    return parent;
}

From source file:com.nokia.s60tools.crashanalyser.ui.editors.SummaryPage.java

License:Open Source License

/**
 * Creates all UI elements to the page/*from  w w w  . j  a va 2 s  . c  o m*/
 * @param parent
 * @return composite
 */
Composite doCreate(Composite parent) {
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    parent.setLayout(layout);
    parent.setLayoutData(new GridData(GridData.FILL_BOTH));
    fontRegistry = new FontRegistry(Display.getCurrent());
    fontRegistry.put("monospace", new FontData[] { new FontData("Courier", 8, SWT.NORMAL) });
    SashForm sashFormMain = new SashForm(parent, SWT.VERTICAL);
    sashFormMain.setLayoutData(new GridData(GridData.FILL_BOTH));
    createSummaryGroup(sashFormMain);
    createExitInfoGroup(sashFormMain);

    setHelps();

    return parent;
}