List of usage examples for org.eclipse.jface.resource JFaceResources getColorRegistry
public static ColorRegistry getColorRegistry()
From source file:net.bpelunit.toolsupport.editors.formwidgets.HyperlinkField.java
License:Open Source License
private static Color getHyperlinkText(Display display) { return JFaceResources.getColorRegistry().get(JFacePreferences.HYPERLINK_COLOR); }
From source file:net.hydromatic.clapham.chart.draw2d.Draw2dChart.java
License:Open Source License
public void drawAndExport(String symbolName, File output) { OutputStream out = null;/*from w ww . j a v a2 s.com*/ Dimension size = size(symbolName); Image image = null; GC gc = null; Graphics g = null; try { out = new BufferedOutputStream(new FileOutputStream(output)); image = new Image(Display.getDefault(), size.width, size.height); Color color = JFaceResources.getColorRegistry().get(AntlrPreferenceConstants.EDITOR_BACKGROUND_COLOR); image.setBackground(color == null ? ColorConstants.white : color); gc = new GC(image); g = new SWTGraphics(gc); g.translate(0, 0); setGraphics(g); draw(symbolName); ImageLoader imageLoader = new ImageLoader(); imageLoader.data = new ImageData[] { image.getImageData() }; imageLoader.save(out, SWT.IMAGE_PNG); } catch (FileNotFoundException e) { e.printStackTrace(); } finally { if (g != null) { g.dispose(); } if (gc != null) { gc.dispose(); } if (image != null) { image.dispose(); } if (out != null) { try { out.close(); } catch (IOException e) { e.printStackTrace(); } } } }
From source file:net.hydromatic.clapham.chart.draw2d.Draw2dChart.java
License:Open Source License
@Override protected void internalDrawArc(int x, int y, int width, int height, int startAngle, int arcAngle) { // tracePath.add(new ArcPath(x, y, width, height, startAngle, arcAngle)); Color foregroundColor = graphics.getForegroundColor(); Color otherColor = JFaceResources.getColorRegistry().get(AntlrPreferenceConstants.EDITOR_OTHERS_COLOR); graphics.setForegroundColor(otherColor); graphics.drawArc(x, y, width, height, startAngle, arcAngle); graphics.setForegroundColor(foregroundColor); }
From source file:net.hydromatic.clapham.chart.draw2d.Draw2dChart.java
License:Open Source License
@Override protected void internalDrawArrow(int x1, int y1, int x2, int y2, int[] xpoints, int[] ypoints) { Color foregroundColor = graphics.getForegroundColor(); Color backgroundColor = graphics.getBackgroundColor(); Color fgColor = JFaceResources.getColorRegistry().get(AntlrPreferenceConstants.EDITOR_OTHERS_COLOR); graphics.setForegroundColor(fgColor); internalDrawLine(x1, y1, x2, y2);// w w w . j ava2s. co m PointList pointList = new PointList(xpoints.length); for (int i = 0; i < xpoints.length; i++) { pointList.addPoint(xpoints[i], ypoints[i]); } graphics.setBackgroundColor(fgColor); graphics.fillPolygon(pointList); graphics.setBackgroundColor(backgroundColor); graphics.setForegroundColor(foregroundColor); }
From source file:net.hydromatic.clapham.chart.draw2d.Draw2dChart.java
License:Open Source License
protected void internalDrawLine(int x1, int y1, int x2, int y2) { Color foregroundColor = graphics.getForegroundColor(); Color fgColor = JFaceResources.getColorRegistry().get(AntlrPreferenceConstants.EDITOR_OTHERS_COLOR); graphics.setForegroundColor(fgColor); graphics.drawLine(x1, y1, x2, y2);/*from w w w .j ava2 s.c om*/ graphics.setForegroundColor(foregroundColor); // tracePath.add(new LinePath(x1, y1, x2, y2)); }
From source file:net.hydromatic.clapham.chart.draw2d.Draw2dChart.java
License:Open Source License
protected void internalDrawRectangle(int x, int y, int width, int height) { Color foregroundColor = graphics.getForegroundColor(); Color fgColor = JFaceResources.getColorRegistry().get(AntlrPreferenceConstants.EDITOR_OTHERS_COLOR); graphics.setForegroundColor(fgColor); graphics.drawRectangle(x, y, width, height); graphics.setForegroundColor(foregroundColor); }
From source file:net.hydromatic.clapham.chart.draw2d.Draw2dChart.java
License:Open Source License
protected void internalDrawString(NodeType nodeType, String name, int x, int y) { ColorRegistry colorRegistry = JFaceResources.getColorRegistry(); String colorKey;//from w w w .j a va 2 s . c om if (nodeType == NodeType.TERM) { colorKey = AntlrPreferenceConstants.EDITOR_STRING_COLOR; } else if (nodeType == NodeType.NONTERM) { if (Character.isUpperCase(name.charAt(0))) { colorKey = AntlrPreferenceConstants.EDITOR_LEXER_RULE_COLOR; } else { colorKey = AntlrPreferenceConstants.EDITOR_RULE_COLOR; } } else { colorKey = AntlrPreferenceConstants.EDITOR_OTHERS_COLOR; } // tracePath.add(new LabeledPath(name, x, y)); Color prevColor = graphics.getForegroundColor(); Color color = colorRegistry.get(colorKey); graphics.setForegroundColor(color); graphics.drawString(name, x, y); graphics.setForegroundColor(prevColor); }
From source file:net.openchrom.xxd.processor.supplier.rscripting.ui.code.RGrid.java
License:Open Source License
/** * Sets the background colors in the current active sheet. * /* w ww . ja v a2 s .co m*/ * @param row * the row * @param column * the column * @param r * r the red component. * @param g * g the green component. * @param b * b the blue component. * */ public static void setColor(final int row, final int column, final int r, final int g, final int b) { final Grid grid = SampleView.getGrid(); if (grid != null) { Display display = PlatformUI.getWorkbench().getDisplay(); display.syncExec(new Runnable() { public void run() { ColorRegistry colorRegistry = JFaceResources.getColorRegistry(); String colorAsString = "RGB {" + r + ", " + g + ", " + b + "}"; Color col = colorRegistry.get(colorAsString); if (col == null) { colorRegistry.put(colorAsString, new RGB(r, g, b)); } grid.getItem(row).setBackground(column, col); } }); } }
From source file:net.openchrom.xxd.processor.supplier.rscripting.ui.jobs.LoadGridXMLJob.java
License:Open Source License
private void loadXml(final String fileXml) { XStream xs = new XStream(new DomDriver()); xs.setClassLoader(DataDescriptorGrids.class.getClassLoader()); try {//from www .ja v a 2s . c o m gridXml = (GridXmlObject) xs.fromXML(new FileReader(fileXml)); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } values = gridXml.getGridValues(); fonts = gridXml.getFontObject(); cellHeights = gridXml.getCellHeight(); cellWidths = gridXml.getCellWidth(); colors = gridXml.getCellColor(); final File fil = new File(fileXml); if (fil.exists()) { display.syncExec(new Runnable() { public void run() { fontRegistry = new FontRegistry(display); grid = new Spread().spread(SampleView.getTabFolder(), values.length, values[0].length, new File(file).getName()); Color co = gridXml.getGridLineColor(); ColorRegistry colorRegistry = JFaceResources.getColorRegistry(); String colorAsString = "RGB {" + co.getRed() + ", " + co.getGreen() + ", " + co.getBlue() + "}"; org.eclipse.swt.graphics.Color col = colorRegistry.get(colorAsString); if (col == null) { colorRegistry.put(colorAsString, new org.eclipse.swt.graphics.RGB(co.getRed(), co.getGreen(), co.getBlue())); } grid.setLineColor(colorRegistry.get(colorAsString)); if (grid != null) { SampleView.setGrid(grid); for (int items = 0; items < grid.getItemCount(); items++) { for (int columns = 0; columns < grid.getColumnCount(); columns++) { GridItem item = grid.getItem(items); item.setText(columns, values[columns][items]); gxml = fonts[columns][items]; if (gxml != null) { fontData.setHeight(gxml.getHeight()); fontData.setLocale(gxml.getLocale()); fontData.setName(gxml.getName()); fontData.setStyle(gxml.getStyle()); fontRegistry.put("c", new FontData[] { new FontData(gxml.getName(), gxml.getHeight(), gxml.getStyle()) }); item.setFont(columns, fontRegistry.get("c")); } Color cob = colors[columns][items]; int r = cob.getRed(); int g = cob.getGreen(); int b = cob.getBlue(); String colBackgrString = "RGB {" + r + ", " + g + ", " + b + "}"; org.eclipse.swt.graphics.Color colBack = colorRegistry.get(colBackgrString); if (colBack == null) { colorRegistry.put(colBackgrString, new RGB(r, g, b)); } item.setBackground(columns, colorRegistry.get(colBackgrString)); item.setHeight(cellHeights[columns][items]); grid.getColumn(columns).setWidth(cellWidths[columns][items]); } } } } }); } else { MsgDialog.message("File not found!"); } boolean success = new File(fileXml).delete(); }
From source file:net.sf.eclipsensis.console.NSISConsole.java
License:Open Source License
@Override protected void init() { super.init(); Display.getDefault().asyncExec(new Runnable() { public void run() { JFaceResources.getColorRegistry().addListener(NSISConsole.this); JFaceResources.getFontRegistry().addListener(NSISConsole.this); initializeStreams();/*from www.j a v a 2s. c om*/ dump(); } }); }