本文整理汇总了Java中org.eclipse.swt.graphics.Device类的典型用法代码示例。如果您正苦于以下问题:Java Device类的具体用法?Java Device怎么用?Java Device使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Device类属于org.eclipse.swt.graphics包,在下文中一共展示了Device类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createStyledTextRenderer
import org.eclipse.swt.graphics.Device; //导入依赖的package包/类
private static /* org.eclipse.swt.custom.StyledTextRenderer */ Object createStyledTextRenderer(
StyledText styledText, ILineSpacingProvider lineSpacingProvider) throws Exception {
// get the org.eclipse.swt.custom.StyledTextRenderer instance of
// StyledText
/* org.eclipse.swt.custom.StyledTextRenderer */ Object originalRenderer = getRendererField(styledText)
.get(styledText);
// Create a Javassist proxy
ProxyFactory factory = new ProxyFactory();
factory.setSuperclass(originalRenderer.getClass());
StyledTextRenderer renderer = new StyledTextRenderer(styledText, originalRenderer.getClass());
renderer.setLineSpacingProvider(lineSpacingProvider);
factory.setHandler(renderer);
return factory.create(new Class[] { Device.class, StyledText.class },
new Object[] { styledText.getDisplay(), styledText });
}
示例2: ViewLabelProvider
import org.eclipse.swt.graphics.Device; //导入依赖的package包/类
public ViewLabelProvider() {
Device device = Display.getCurrent();
fontSystem = device.getSystemFont();
FontData fontData = fontSystem.getFontData()[0];
fontDetectedDatabaseObject = new Font(device, fontData);
FontData fontDataModified = fontSystem.getFontData()[0];
fontDataModified.setStyle(SWT.BOLD);
fontModifiedDatabaseObject = new Font(device, fontDataModified);
colorUnloadedProject = new Color(device, 12, 116, 176);
colorDisabledDatabaseObject = new Color(device, 255, 0, 0);
colorInheritedDatabaseObject = new Color(device, 150, 150, 150);
colorUnreachableDatabaseObject = new Color(device, 255, 140, 0);
colorDetectedDatabaseObject = new Color(device, 192, 219, 207);
}
示例3: toSwtColor
import org.eclipse.swt.graphics.Device; //导入依赖的package包/类
/**
* Creates a swt color instance to match the rgb values
* of the specified awt paint. For now, this method test
* if the paint is a color and then return the adequate
* swt color. Otherwise plain black is assumed.
*
* @param device The swt device to draw on (display or gc device).
* @param paint The awt color to match.
* @return a swt color object.
*/
public static Color toSwtColor(Device device, java.awt.Paint paint) {
java.awt.Color color;
if (paint instanceof java.awt.Color) {
color = (java.awt.Color) paint;
}
else {
try {
throw new Exception("only color is supported at present... "
+ "setting paint to uniform black color" );
}
catch (Exception e) {
e.printStackTrace();
color = new java.awt.Color(0, 0, 0);
}
}
return new org.eclipse.swt.graphics.Color(device,
color.getRed(), color.getGreen(), color.getBlue());
}
示例4: getColor
import org.eclipse.swt.graphics.Device; //导入依赖的package包/类
public static CachedColor
getColor(
Device device,
RGB rgb )
{
synchronized( color_map ){
CachedColorManaged entry = color_map.get( rgb );
if ( entry == null ){
entry = new CachedColorManaged( new Color( device, rgb ));
color_map.put( rgb, entry );
}else{
entry.addRef();
}
return( new CachedColorManagedFacade( entry ));
}
}
示例5: getColor
import org.eclipse.swt.graphics.Device; //导入依赖的package包/类
/**
*
* @since 3.1.1.1
*/
public static Color getColor(Device device, float[] hsb) {
if (hsb[0] < 0) {
hsb[0] = 0;
} else if (hsb[0] > 360) {
hsb[0] = 360;
}
if (hsb[1] < 0) {
hsb[1] = 0;
} else if (hsb[1] > 1) {
hsb[1] = 1;
}
if (hsb[2] < 0) {
hsb[2] = 0;
} else if (hsb[2] > 1) {
hsb[2] = 1;
}
RGB rgb = new RGB(hsb[0], hsb[1], hsb[2]);
return getColor(device, rgb.red, rgb.green, rgb.blue);
}
示例6: toSwtColor
import org.eclipse.swt.graphics.Device; //导入依赖的package包/类
/**
* Creates a swt color instance to match the rgb values
* of the specified awt paint. For now, this method test
* if the paint is a color and then return the adequate
* swt color. Otherwise plain black is assumed.
*
* @param device The swt device to draw on (display or gc device).
* @param paint The awt color to match.
* @return a swt color object.
*/
public static Color toSwtColor(Device device, java.awt.Paint paint) {
java.awt.Color color;
if (paint instanceof java.awt.Color) {
color = (java.awt.Color) paint;
}
else {
try {
throw new Exception("only color is supported at present... "
+ "setting paint to uniform black color");
}
catch (Exception e) {
e.printStackTrace();
color = new java.awt.Color(0, 0, 0);
}
}
return new org.eclipse.swt.graphics.Color(device,
color.getRed(), color.getGreen(), color.getBlue());
}
示例7: modifyText
import org.eclipse.swt.graphics.Device; //导入依赖的package包/类
@Override
public void modifyText(ModifyEvent e) {
if(onlyNumericTexts.contains(e.getSource())) {
Text text = (Text) e.getSource();
String tooltip = "";
Color background = null;
if(isNumberic(text.getText())) {
tooltip = "Only integer values allowed";
Device device = Display.getCurrent();
background = new Color(device, 255,0,0);
}
else {
tooltip = "";
}
text.setBackground(background);
text.setToolTipText(tooltip);
}
}
示例8: toSWT
import org.eclipse.swt.graphics.Device; //导入依赖的package包/类
/**
* Converts an AWT based buffered image into an SWT <code>Image</code>. This will always return an <code>Image</code> that has 24 bit depth regardless of the
* type of AWT buffered image that is passed into the method.
*
* @param device
* @param awtImage
* the {@link java.awt.image.BufferedImage} to be converted to an <code>Image</code>
*
* @return an <code>Image</code> that represents the same image data as the AWT <code>BufferedImage</code> type.
*/
public static org.eclipse.swt.graphics.Image toSWT(Device device, BufferedImage awtImage) {
device = (device!=null) ? device : Display.getCurrent();
// We can force bitdepth to be 24 bit because BufferedImage getRGB
// allows us to always retrieve 24 bit data regardless of source color depth.
PaletteData palette = new PaletteData(0xFF0000, 0xFF00, 0xFF);
ImageData swtImageData = new ImageData(awtImage.getWidth(), awtImage.getHeight(), 24, palette);
// Ensure scansize is aligned on 32 bit.
int scansize = (((awtImage.getWidth() * 3) + 3) * 4) / 4;
WritableRaster alphaRaster = awtImage.getAlphaRaster();
byte[] alphaBytes = new byte[awtImage.getWidth()];
for (int y = 0; y < awtImage.getHeight(); y++) {
int[] buff = awtImage.getRGB(0, y, awtImage.getWidth(), 1, null, 0, scansize);
swtImageData.setPixels(0, y, awtImage.getWidth(), buff, 0);
if (alphaRaster != null) {
int[] alpha = alphaRaster.getPixels(0, y, awtImage.getWidth(), 1, (int[]) null);
for (int i = 0; i < awtImage.getWidth(); i++) {
alphaBytes[i] = (byte) alpha[i];
}
swtImageData.setAlphas(0, y, awtImage.getWidth(), alphaBytes, 0);
}
}
return new org.eclipse.swt.graphics.Image(device, swtImageData);
}
示例9: DialogLayerViewerToolTip
import org.eclipse.swt.graphics.Device; //导入依赖的package包/类
public DialogLayerViewerToolTip(final ContainerCheckedTreeViewer propViewer) {
super(propViewer.getTree());
_propViewer = propViewer;
_tree = propViewer.getTree();
_tree.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(final DisposeEvent e) {
onDispose();
}
});
final Device display = _tree.getDisplay();
_bgColor = display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
_fgColor = display.getSystemColor(SWT.COLOR_INFO_FOREGROUND);
}
示例10: FontKey
import org.eclipse.swt.graphics.Device; //导入依赖的package包/类
public FontKey(Device device, String name, int height, int style, FontData[] fontDatas) {
this.device = device;
this.name = name;
this.height = height;
this.style = style;
this.fontDatas = fontDatas;
int fontDataHash = 0;
if(fontDatas != null) {
for(FontData fontData : fontDatas) {
fontDataHash += fontData.hashCode();
}
}
int deviceHashCode = 0;
if(device != null) {
deviceHashCode = 0;
}
int nameHashCode = 0;
if(name != null) {
nameHashCode = name.hashCode();
}
this.hashCode = deviceHashCode + nameHashCode + height + style + fontDataHash;
}
示例11: SWTGC
import org.eclipse.swt.graphics.Device; //导入依赖的package包/类
public SWTGC(Device device, Point area, int iconsize) {
this.image = new Image(device, area.x, area.y);
this.gc = new GC(image);
this.images = GUIResource.getInstance().getImagesSteps();
this.iconsize = iconsize;
this.area = area;
this.colors = new ArrayList<Color>();
this.fonts = new ArrayList<Font>();
this.background = GUIResource.getInstance().getColorGraph();
this.black = GUIResource.getInstance().getColorBlack();
this.red = GUIResource.getInstance().getColorRed();
this.yellow = GUIResource.getInstance().getColorYellow();
this.orange = GUIResource.getInstance().getColorOrange();
this.green = GUIResource.getInstance().getColorGreen();
this.blue = GUIResource.getInstance().getColorBlue();
this.magenta = GUIResource.getInstance().getColorMagenta();
this.gray = GUIResource.getInstance().getColorGray();
this.lightGray = GUIResource.getInstance().getColorLightGray();
this.darkGray = GUIResource.getInstance().getColorDarkGray();
}
示例12: getColor
import org.eclipse.swt.graphics.Device; //导入依赖的package包/类
public static CachedColor
getColor(
Device device,
RGB rgb )
{
synchronized( color_map ){
CachedColorManaged entry = color_map.get( rgb );
if ( entry == null ){
entry = new CachedColorManaged( new Color( device, rgb ));
color_map.put( rgb, entry );
}else{
entry.addRef();
}
return( new CachedColorManagedFacade( entry ));
}
}
示例13: getColor
import org.eclipse.swt.graphics.Device; //导入依赖的package包/类
/**
* @param display
* @param hsb
* @return
*
* @since 3.1.1.1
*/
public static Color getColor(Device device, float[] hsb) {
if (hsb[0] < 0) {
hsb[0] = 0;
} else if (hsb[0] > 360) {
hsb[0] = 360;
}
if (hsb[1] < 0) {
hsb[1] = 0;
} else if (hsb[1] > 1) {
hsb[1] = 1;
}
if (hsb[2] < 0) {
hsb[2] = 0;
} else if (hsb[2] > 1) {
hsb[2] = 1;
}
RGB rgb = new RGB(hsb[0], hsb[1], hsb[2]);
return getColor(device, rgb.red, rgb.green, rgb.blue);
}
示例14: createImage
import org.eclipse.swt.graphics.Device; //导入依赖的package包/类
public Image createImage(boolean returnMissingImageOnError, Device device) {
Image img = ImageDescriptorHelper.getInstance()
.getImage(location, name);
if (img != null) {
return img;
}
String path = getFilePath();
if (path == null)
return createDefaultImage(returnMissingImageOnError, device);
try {
return new Image(device, path);
} catch (SWTException exception) {
// if we fail try the default way using a stream
}
return super.createImage(returnMissingImageOnError, device);
}
示例15: createResource
import org.eclipse.swt.graphics.Device; //导入依赖的package包/类
/**
* Creates and returns a new image descriptor from a URL.
*
* @param url
* The URL of the image file.
* @return a new image descriptor
*/
// public static ImageDescriptor createFromURL(URL url) {
// if (url == null) {
// return getMissingImageDescriptor();
// }
// return new URLImageDescriptor(url);
// }
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.resource.DeviceResourceDescriptor#createResource(org
* .eclipse.swt.graphics.Device)
*/
public Object createResource(Device device) throws DeviceResourceException {
Image result = createImage(false, device);
if (result == null) {
throw new DeviceResourceException(this);
}
return result;
}