Example usage for org.eclipse.jface.resource ResourceManager getDevice

List of usage examples for org.eclipse.jface.resource ResourceManager getDevice

Introduction

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

Prototype

public abstract Device getDevice();

Source Link

Document

Returns the Device for which this ResourceManager will create resources

Usage

From source file:com.nokia.carbide.remoteconnections.internal.ui.mylyn.NotificationPopupColors.java

License:Open Source License

private Color getColor(ResourceManager manager, RGB rgb) {
    try {// www  .  ja  v  a 2s. c o m
        return manager.createColor(rgb);
    } catch (DeviceResourceException e) {
        return manager.getDevice().getSystemColor(SWT.COLOR_BLACK);
    }
}

From source file:org.eclipse.scada.chart.swt.render.TitleRenderer.java

License:Open Source License

@Override
public Rectangle resize(final ResourceManager resourceManager, final Rectangle clientRectangle) {
    if (this.title == null || this.title.isEmpty()) {
        return null;
    }/*www.  ja  v  a  2s.  c  o m*/

    final GC gc = new GC(resourceManager.getDevice());
    gc.setFont(createFont(resourceManager));

    try {
        final Point size = gc.textExtent(this.title);
        this.rect = new Rectangle(clientRectangle.x, clientRectangle.y, clientRectangle.width,
                size.y + this.padding * 2);
        return new Rectangle(clientRectangle.x, this.rect.y + this.rect.height, clientRectangle.width,
                clientRectangle.height - this.rect.height);
    } finally {
        gc.dispose();
    }
}

From source file:org.eclipse.scada.chart.swt.render.TitleRenderer.java

License:Open Source License

private Font createFont(final ResourceManager resourceManager) {
    final Font defaultFont = resourceManager.getDevice().getSystemFont();

    if (defaultFont == null) {
        return null;
    }//from w w w . j a  va 2  s.  c  o  m

    final FontData fd[] = FontDescriptor.copy(defaultFont.getFontData());
    if (fd == null) {
        return null;
    }

    for (final FontData f : fd) {
        if (this.fontSize > 0) {
            f.setHeight(this.fontSize);
        }
    }
    return resourceManager.createFont(FontDescriptor.createFrom(fd));
}

From source file:org.eclipse.scada.chart.swt.render.XAxisDynamicRenderer.java

License:Open Source License

private int calcHeight(final ResourceManager resourceManager) {
    if (this.axis == null) {
        return 0;
    }// www .  j  a va2  s  .c o m

    final GC gc = new GC(resourceManager.getDevice());
    try {
        gc.setFont(makeFont(resourceManager));

        final DateFormat format = makeFormat(this.axis.getMax() - this.axis.getMin());

        final Point markerSize = getExtent(gc, format.format(new Date()));
        final Point labelSize = getExtent(gc, this.axis.getLabel());

        int height = markerSize.y + labelSize.y + this.textPadding * 2 + this.markerSize;

        if (labelSize.y > 0) {
            height += this.textPadding;
        }

        return height;
    } finally {
        gc.dispose();
    }
}

From source file:org.eclipse.scada.chart.swt.render.YAxisDynamicRenderer.java

License:Open Source License

private int calcWidth(final ResourceManager resourceManager, final int height) {
    int maxTextWidth = 0;

    if (this.axis == null || this.axis.getMax() - this.axis.getMin() <= 0) {
        return 0;
    }//from  w w  w .  j  av  a  2  s.co  m

    final GC gc = new GC(resourceManager.getDevice());

    final Point axisLabelSize;
    try {
        if (this.axis.getLabel() != null && !this.axis.getLabel().isEmpty()) {
            axisLabelSize = gc.textExtent(this.axis.getLabel());
        } else {
            axisLabelSize = new Point(0, 0);
        }

        if (this.showLabels) {
            final int fontHeight = gc.getFontMetrics().getHeight();
            final List<Entry<Double>> markers = Helper.chartValues(this.axis.getMin(), this.axis.getMax(),
                    height, fontHeight + this.labelSpacing);

            for (final Entry<Double> marker : markers) {
                final Point sampleLabelSize = gc.textExtent(marker.label);
                maxTextWidth = Math.max(maxTextWidth, sampleLabelSize.x);
            }
        }
    } finally {
        gc.dispose();
    }

    return maxTextWidth + (this.showLabels ? 2 * this.textPadding + this.markerSize : 0) + axisLabelSize.y
            + this.textPadding + 1;
}

From source file:org.rssowl.ui.internal.OwlUI.java

License:Open Source License

/**
 * @param manager/*from  w  ww . j  a  v a2  s  .c o m*/
 * @param rgb
 * @return Color
 */
public static Color getColor(ResourceManager manager, RGB rgb) {
    try {
        return manager.createColor(rgb);
    } catch (DeviceResourceException e) {
        return manager.getDevice().getSystemColor(SWT.COLOR_BLACK);
    }
}

From source file:org.rssowl.ui.internal.OwlUI.java

License:Open Source License

/**
 * @param manager//from  w  w w  .j a  va2  s .  c o m
 * @param descriptor
 * @return Color
 */
public static Color getColor(ResourceManager manager, ColorDescriptor descriptor) {
    try {
        return manager.createColor(descriptor);
    } catch (DeviceResourceException e) {
        return manager.getDevice().getSystemColor(SWT.COLOR_BLACK);
    }
}

From source file:org.sonarlint.eclipse.ui.internal.popup.GradientColors.java

License:Open Source License

private static Color getColor(ResourceManager manager, RGB rgb) {
    try {/*from   w  w  w.  j av  a2 s . c o  m*/
        return manager.createColor(rgb);
    } catch (DeviceResourceException e) {
        return manager.getDevice().getSystemColor(SWT.COLOR_BLACK);
    }
}

From source file:raptor.swt.RaptorImageRegistry.java

License:BSD License

/**
 * Creates an empty image registry using the given resource manager to
 * allocate images.//from   w ww . ja  v a 2  s  .  c  om
 * 
 * @param manager
 *            the resource manager used to allocate images
 * 
 * @since 3.1
 */
public RaptorImageRegistry(ResourceManager manager) {
    Assert.isNotNull(manager);
    Device dev = manager.getDevice();
    if (dev instanceof Display) {
        display = (Display) dev;
    }
    this.manager = manager;
    manager.disposeExec(disposeRunnable);
}