List of usage examples for org.eclipse.jface.resource ResourceManager createColor
public final Color createColor(RGB descriptor)
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 . j a 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.egit.ui.internal.components.CheckboxLabelProvider.java
License:Open Source License
private static Image createCheckboxImage(final ResourceManager resourceManager, final Control control, boolean checked, boolean enabled) { String checkboxhack = System.getProperty("egit.swt.checkboxhack"); //$NON-NLS-1$ if (checkboxhack == null) if (Platform.getOS().equals(Platform.OS_MACOSX)) checkboxhack = "hardwired"; //$NON-NLS-1$ else//from w ww. j a v a 2s.com checkboxhack = "screenshot"; //$NON-NLS-1$ if (checkboxhack == "hardwired") { //$NON-NLS-1$ if (enabled) { if (checked) return UIIcons.CHECKBOX_ENABLED_CHECKED.createImage(); return UIIcons.CHECKBOX_ENABLED_UNCHECKED.createImage(); } if (checked) return UIIcons.CHECKBOX_DISABLED_CHECKED.createImage(); return UIIcons.CHECKBOX_DISABLED_UNCHECKED.createImage(); } // else if checkboxhack = "screenshot"; // FIXME: Shawn says that blinking shell caused by below code is very // annoying...(at least on Mac) - anyone knows better workaround? final Shell s = new Shell(control.getShell(), SWT.NO_TRIM); // Hopefully no platform uses exactly this color because we'll make // it transparent in the image. final Color greenScreen = resourceManager.createColor(new RGB(222, 223, 224)); // otherwise we have a default gray color s.setBackground(greenScreen); final Button b = new Button(s, SWT.CHECK); b.setSelection(checked); b.setEnabled(enabled); b.setBackground(greenScreen); // otherwise an image is located in a corner b.setLocation(0, 0); final Point bSize = b.computeSize(SWT.DEFAULT, SWT.DEFAULT); // otherwise an image is stretched by width bSize.x = Math.max(bSize.x, bSize.y); bSize.y = Math.max(bSize.x, bSize.y); b.setSize(bSize); s.setSize(bSize); s.open(); final GC gc = new GC(b); final Image image = new Image(control.getShell().getDisplay(), bSize.x, bSize.y); gc.copyArea(image, 0, 0); gc.dispose(); s.close(); final ImageData imageData = image.getImageData(); imageData.transparentPixel = imageData.palette.getPixel(greenScreen.getRGB()); final Image checkboxImage = resourceManager.createImage(ImageDescriptor.createFromImageData(imageData)); image.dispose(); return checkboxImage; }
From source file:org.eclipse.egit.ui.internal.history.SWTCommitList.java
License:Open Source License
SWTCommitList(final Control control, final ResourceManager resources) { this.control = control; allColors = new ArrayList<Color>(COMMIT_RGB.length); for (RGB rgb : COMMIT_RGB) allColors.add(resources.createColor(rgb)); availableColors = new LinkedList<Color>(); repackColors();// w w w .j a va2 s . c o m control.addDisposeListener(this); }
From source file:org.eclipse.egit.ui.internal.history.SWTPlotRenderer.java
License:Open Source License
SWTPlotRenderer(final Display d, final ResourceManager resources) { this.resources = resources; sys_black = d.getSystemColor(SWT.COLOR_BLACK); sys_gray = d.getSystemColor(SWT.COLOR_GRAY); sys_white = d.getSystemColor(SWT.COLOR_WHITE); commitDotFill = resources.createColor(new RGB(220, 220, 220)); commitDotOutline = resources.createColor(new RGB(110, 110, 110)); }
From source file:org.eclipse.emf.cdo.internal.ui.history.NetRenderer.java
License:Open Source License
public NetRenderer(TableViewer tableViewer) { labelProvider = (LabelProvider) tableViewer.getLabelProvider(); ResourceManager resourceManager = labelProvider.getResourceManager(); colorDotFill = resourceManager.createColor(new RGB(220, 220, 220)); colorDotOutline = resourceManager.createColor(new RGB(110, 110, 110)); Table table = tableViewer.getTable(); table.addListener(SWT.MeasureItem, this); table.addListener(SWT.PaintItem, this); table.addListener(SWT.EraseItem, this); }
From source file:org.eclipse.scada.ca.ui.importer.wizard.DiffEntryLabelProvider.java
License:Open Source License
public DiffEntryLabelProvider(final ResourceManager resourceManager) { this.resourceManager = resourceManager; this.equalFgColor = resourceManager.createColor(this.equalFgColorDesc); }
From source file:org.eclipse.scada.vi.ui.draw2d.primitives.SymbolReferenceController.java
License:Open Source License
public SymbolReferenceController(final SymbolController controller, final SymbolReference symbolReference, final BasicViewElementFactory factory, final ResourceManager manager, final FactoryContext factoryContext) { if (symbolReference.getZoom() != null) { this.figure = new org.eclipse.draw2d.ScalableLayeredPane(); ((org.eclipse.draw2d.ScalableLayeredPane) this.figure).setScale(symbolReference.getZoom()); } else {/*from w ww .j ava 2 s . c o m*/ this.figure = new LayeredPane(); } final Layer layer = new Layer(); layer.setLayoutManager(new StackLayout()); layer.setOpaque(false); this.figure.setOpaque(false); this.figure.add(layer); try { final SymbolLoader symbolLoader = factory.getRoot(); final Map<String, String> properties = new HashMap<String, String>( convert(symbolReference.getProperties())); createProperties(controller, symbolReference, properties); final SymbolController childController = new SymbolController(controller.getShell(), controller, symbolLoader, properties, controller.getScriptObjects(), factoryContext); final Symbol symbol = symbolLoader.loadSymbol(); final Controller elementController = factory.create(childController, symbol.getRoot()); final IFigure rootFigure = elementController.getFigure(); layer.add(rootFigure); final RGB color = org.eclipse.scada.vi.ui.draw2d.primitives.Helper .makeColor(symbol.getBackgroundColor()); if (color != null) { layer.setBackgroundColor(manager.createColor(color)); } // register the symbol element controller controller.addElement(symbolReference, elementController); } catch (final Exception e) { logger.warn("Failed to create symbol", e); //$NON-NLS-1$ StatusManager.getManager().handle(StatusHelper.convertStatus(Activator.PLUGIN_ID, e), StatusManager.LOG); layer.add(Helper.createErrorFigure(e)); } }
From source file:org.eclipse.triquetrum.workflow.editor.shapes.ptolemy.LineDrawingStrategy.java
License:Open Source License
@Override public void draw(LineAttribute lineAttr, Graphics graphics, ResourceManager resourceManager) { Color fgColor = graphics.getForegroundColor(); java.awt.Color color = lineAttr.lineColor.asColor(); if (color != null) { Color rgb = resourceManager.createColor(new RGB(color.getRed(), color.getGreen(), color.getBlue())); graphics.setForegroundColor(rgb); }/*from w ww. j av a2 s . c o m*/ try { float lineWidth = (float) ((DoubleToken) lineAttr.lineWidth.getToken()).doubleValue(); graphics.setLineWidthFloat(lineWidth); int x2_step = (int) ((DoubleToken) lineAttr.x.getToken()).doubleValue(); int y2_step = (int) ((DoubleToken) lineAttr.y.getToken()).doubleValue(); Point tlp = getTopLeftLocation(lineAttr, graphics); graphics.drawLine(tlp, tlp.getTranslated(x2_step, y2_step)); } catch (IllegalActionException e) { LOGGER.error("Error reading dimensions for " + lineAttr.getFullName(), e); } graphics.setForegroundColor(fgColor); }
From source file:org.eclipse.triquetrum.workflow.editor.shapes.ptolemy.RectangleDrawingStrategy.java
License:Open Source License
@Override public void draw(RectangleAttribute rectangleAttr, Graphics graphics, ResourceManager resourceManager) { Color fgColor = graphics.getBackgroundColor(); java.awt.Color color = rectangleAttr.fillColor.asColor(); if (color != null) { Color rgb = resourceManager.createColor(new RGB(color.getRed(), color.getGreen(), color.getBlue())); graphics.setBackgroundColor(rgb); }// www.j a va 2s. c om try { int width = (int) ((DoubleToken) rectangleAttr.width.getToken()).doubleValue(); int height = (int) ((DoubleToken) rectangleAttr.height.getToken()).doubleValue(); Point tlp = getTopLeftLocation(rectangleAttr, graphics); graphics.fillRectangle(tlp.x, tlp.y, width, height); } catch (IllegalActionException e) { LOGGER.error("Error reading dimensions for " + rectangleAttr.getFullName(), e); } graphics.setBackgroundColor(fgColor); }
From source file:org.eclipse.triquetrum.workflow.editor.shapes.ptolemy.TextDrawingStrategy.java
License:Open Source License
@Override public void draw(TextAttribute textAttr, Graphics graphics, ResourceManager resourceManager) { Color fgColor = graphics.getForegroundColor(); java.awt.Color color = textAttr.textColor.asColor(); if (color != null) { Color rgb = resourceManager.createColor(new RGB(color.getRed(), color.getGreen(), color.getBlue())); graphics.setForegroundColor(rgb); }/*from w ww . j a va 2 s.com*/ try { String text = textAttr.text.getExpression(); int fontSize = ((IntToken) textAttr.textSize.getToken()).intValue(); String fontFamily = textAttr.fontFamily.stringValue(); boolean italic = ((BooleanToken) textAttr.italic.getToken()).booleanValue(); boolean bold = ((BooleanToken) textAttr.bold.getToken()).booleanValue(); int style = SWT.NORMAL | (italic ? SWT.ITALIC : SWT.NORMAL) | (bold ? SWT.BOLD : SWT.NORMAL); Font f = resourceManager.createFont(FontDescriptor.createFrom(fontFamily, fontSize, style)); graphics.setFont(f); Point tlp = getTopLeftLocation(textAttr, graphics); graphics.drawText(text, tlp); } catch (IllegalActionException e) { LOGGER.error("Error reading properties for " + textAttr.getFullName(), e); } graphics.setForegroundColor(fgColor); }