void initializeColors() {
Display display = Display.getDefault();
colors = new Color[] { new Color(display, new RGB(0, 0, 0)), // black
new Color(display, new RGB(128, 0, 0)), // red
new Color(display, new RGB(0, 128, 0)), // green
new Color(display, new RGB(0, 0, 128)) // blue
};
tokenColors = new int[MAXIMUM_TOKEN];
tokenColors[OTHER] = 0;
tokenColors[NUMBER] = 0;
tokenColors[WORD] = 0;
tokenColors[WHITE] = 0;
tokenColors[COMMENT] = 1;
tokenColors[STRING] = 2;
tokenColors[KEY] = 3;
}
java类org.eclipse.swt.graphics.Color的实例源码
JavaLineStyler.java 文件源码
项目:SWET
阅读 36
收藏 0
点赞 0
评论 0
TestProgressBar.java 文件源码
项目:n4js
阅读 32
收藏 0
点赞 0
评论 0
/**
* Create instance.
*/
public TestProgressBar(Composite parent, int style) {
super(parent, style);
// damn you, SWT color management
// Color sample is form: http://www.colorpicker.com/c6f2b1
colorSkipped = new Color(Display.getCurrent(), 230, 232, 235);
colorPassed = new Color(Display.getCurrent(), 198, 242, 177);
colorFailed = new Color(Display.getCurrent(), 242, 188, 177);
colorError = new Color(Display.getCurrent(), 242, 188, 177);
colorFixme = new Color(Display.getCurrent(), 177, 231, 242);
addPaintListener((ev) -> {
onPaint(ev.gc);
});
addDisposeListener((ev) -> {
onDispose();
});
}
TestProgressBar.java 文件源码
项目:n4js
阅读 35
收藏 0
点赞 0
评论 0
/**
* Returns the color this widget will use for the given status. This allows {@link TestResultsView} to reuse these
* colors.
*/
/* package */final Color getColorForStatus(TestStatus status) {
if (status != null) {
switch (status) {
case SKIPPED_IGNORE: //$FALL-THROUGH$
case SKIPPED_PRECONDITION: //$FALL-THROUGH$
case SKIPPED_NOT_IMPLEMENTED: //$FALL-THROUGH$
case SKIPPED:
return colorSkipped;
case PASSED:
return colorPassed;
case SKIPPED_FIXME:
return colorFixme;
case FAILED:
return colorFailed;
case ERROR:
return colorError;
default:
break;
}
}
return getCurrent().getSystemColor(COLOR_WHITE);
}
SchemaViewerStyledCellLabelProvider.java 文件源码
项目:avro-schema-editor
阅读 27
收藏 0
点赞 0
评论 0
@Override
public void update(ViewerCell cell) {
AvroNode node = nodeConverter.convertToAvroNode(cell.getElement());
String text = labelProvider.getText(node);
Image image = labelProvider.getImage(node);
StyleRange[] styleRanges = labelProvider.getStyleRanges(node);
cell.setText(text);
cell.setImage(image);
cell.setStyleRanges(styleRanges);
Color backgroundColor = labelProvider.getBackgroundColor(node);
if (backgroundColor != null) {
cell.setBackground(backgroundColor);
}
super.update(cell);
}
SpecProcessPage.java 文件源码
项目:n4js
阅读 28
收藏 0
点赞 0
评论 0
private String displayMessage(String msg, Color color) {
String formattedDate = dateFormatter.format(System.currentTimeMillis());
String timeMsg = formattedDate + msg;
Message m = null;
synchronized (msgStack) {
if (!msgStack.isEmpty()) { // merge messages for better performance
Message lastM = msgStack.lastElement();
if (lastM != null && lastM.color == color) {
msgStack.remove(msgStack.size() - 1);
m = new Message(lastM.msg + "\n" + timeMsg, color);
}
}
if (m == null) {
m = new Message(timeMsg, color);
}
msgStack.push(m);
}
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
asyncDisplayMessages();
}
});
return msg;
}
AbstractNodeFigure.java 文件源码
项目:bdf2
阅读 27
收藏 0
点赞 0
评论 0
public AbstractNodeFigure(AbstractNodeElement node,Image icon){
this.node=node;
BorderLayout layout=new BorderLayout();
this.setLayoutManager(layout);
ImageFigure iconFigure=new ImageFigure(icon);
this.add(iconFigure,BorderLayout.LEFT);
this.label=new Label(this.node.getLabel());
this.label.setForegroundColor(ColorConstants.black);
this.add(this.label,BorderLayout.CENTER);
this.setAntialias(SWT.ON);
RGB rgb=Activator.getPreference().getBorderColor();
this.setForegroundColor(new Color(null,rgb.red,rgb.green,rgb.blue));
rgb=Activator.getPreference().getBackgroundColor();
this.setBackgroundColor(new Color(null,rgb.red,rgb.green,rgb.blue));
this.setLineWidth(2);
}
StyledTextEventListener.java 文件源码
项目:Hydrograph
阅读 36
收藏 0
点赞 0
评论 0
/**
* The function will change selected text background color.
* @param styledText
* @param text
* @param foreground
* @param background
*/
public void allButtonListener(StyledText styledText, String text, Color foreground, Color background, Label label){
logger.debug("StyledText All button selected");
int index = 0;
int recordCount = 0;
if(styledText == null){return;}
for(;index < styledText.getText().length();){
int lastIndex = StringUtils.indexOf(StringUtils.lowerCase(styledText.getText()), StringUtils.lowerCase(text), index);
if(lastIndex < 0){return;}
else{
setStyledRange(styledText, lastIndex, text.length(), null, background);
index = lastIndex + 1;
recordCount++ ;
label.setVisible(true);
label.setText("Matching count - " + recordCount);
}
}
}
KspOutlinePage.java 文件源码
项目:vertigo-chroma-kspplugin
阅读 36
收藏 0
点赞 0
评论 0
private void setStyledText(ViewerCell cell, TreeObject obj) {
/* Calcul du texte. */
String mainText = obj.getMainText();
if (mainText == null) {
return;
}
String subText = obj.getSubText();
String subTextFinal = subText == null ? "" : (" : " + subText);
String fullText = mainText + subTextFinal;
cell.setText(fullText);
/* Calcul du style. */
List<StyleRange> styles = new ArrayList<>();
StyleRange styleMainText = new StyleRange(0, mainText.length(), null, null);
styles.add(styleMainText);
if (!subTextFinal.isEmpty()) {
Display display = Display.getCurrent();
Color blue = display.getSystemColor(SWT.COLOR_DARK_YELLOW);
StyleRange styleSubText = new StyleRange(mainText.length(), subTextFinal.length(), blue, null);
styles.add(styleSubText);
}
cell.setStyleRanges(styles.toArray(new StyleRange[0]));
}
SequenceEditorPart.java 文件源码
项目:convertigo-eclipse
阅读 26
收藏 0
点赞 0
评论 0
/**
* This method initializes composite
*
*/
private void createComposite() {
GridData gridData7 = new org.eclipse.swt.layout.GridData();
gridData7.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
gridData7.verticalAlignment = org.eclipse.swt.layout.GridData.CENTER;
GridData gridData4 = new org.eclipse.swt.layout.GridData();
gridData4.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
gridData4.grabExcessHorizontalSpace = false;
gridData4.verticalAlignment = org.eclipse.swt.layout.GridData.CENTER;
GridLayout gridLayout4 = new GridLayout();
gridLayout4.numColumns = 2;
compositeOutputFooter = new Composite(compositeOutput, SWT.NONE);
compositeOutputFooter.setBackground(new Color(Display.getCurrent(), 162, 194, 250));
compositeOutputFooter.setLayout(gridLayout4);
compositeOutputFooter.setLayoutData(gridData4);
}
DownloadActivityView.java 文件源码
项目:BiglyBT
阅读 25
收藏 0
点赞 0
评论 0
private
ValueSourceImpl(
String _name,
int _index,
Color[] _colours,
boolean _is_up,
boolean _trimmable,
boolean _is_dotted )
{
name = _name;
index = _index;
colours = _colours;
is_up = _is_up;
trimmable = _trimmable;
is_dotted = _is_dotted;
}
TrackerCellUtils.java 文件源码
项目:BiglyBT
阅读 26
收藏 0
点赞 0
评论 0
public static void updateColor(TableCell cell, DownloadManager dm, boolean show_errors ) {
if (dm == null || cell == null)
return;
if ( show_errors ){
if ( dm.isTrackerError()){
cell.setForegroundToErrorColor();
return;
}
}
TRTrackerScraperResponse response = dm.getTrackerScrapeResponse();
if (response instanceof TRTrackerBTScraperResponseImpl && response.getStatus() == TRTrackerScraperResponse.ST_ONLINE) {
boolean bMultiHashScrapes = ((TRTrackerBTScraperResponseImpl) response).getTrackerStatus().getSupportsMultipeHashScrapes();
Color color = (bMultiHashScrapes) ? null : Colors.grey;
cell.setForeground(Utils.colorToIntArray(color));
}else{
cell.setForeground(Utils.colorToIntArray(null));
}
}
SWTResourceManager.java 文件源码
项目:pdi
阅读 29
收藏 0
点赞 0
评论 0
/**
* Dispose of all the cached {@link Color}'s.
*/
public static void disposeColors() {
for (Color color : m_colorMap.values()) {
color.dispose();
}
m_colorMap.clear();
}
SWTResourceManager.java 文件源码
项目:Sensors
阅读 28
收藏 0
点赞 0
评论 0
/**
* Dispose of all the cached {@link Color}'s.
*/
public static void disposeColors() {
for (Color color : m_colorMap.values()) {
color.dispose();
}
m_colorMap.clear();
}
ConsoleOutputStreamProvider.java 文件源码
项目:n4js
阅读 30
收藏 0
点赞 0
评论 0
private Color toColor(OutputStreamType type) {
switch (type) {
case STD_OUT:
return getDisplay().getSystemColor(COLOR_LIST_FOREGROUND);
case STD_ERR:
return getDisplay().getSystemColor(COLOR_RED);
default:
throw new IllegalArgumentException("Unexpected output stream type.");
}
}
CicsConnectorComposite.java 文件源码
项目:convertigo-eclipse
阅读 31
收藏 0
点赞 0
评论 0
protected void initialize() {
GridData gridData = new org.eclipse.swt.layout.GridData();
gridData.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = true;
gridData.verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
cicsData = new Text(this, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
cicsData.setEditable(false);
cicsData.setBackground(new Color(null,253,253,244));
cicsData.setFont(new Font(null,"Courier New",10,1));
cicsData.setLayoutData(gridData);
cicsData.setText("");
this.setLayout(new GridLayout());
setSize(new Point(300, 200));
}
TwistieSection.java 文件源码
项目:BiglyBT
阅读 26
收藏 0
点赞 0
评论 0
/**
* Delegating to the <code>TwistieLabel</code>
* @param color
*/
public void setTwistieForeground(Color color) {
if (null != label && !label.isDisposed()) {
label.setTwistieForeground(color);
}
}
TestResultsView.java 文件源码
项目:n4js
阅读 27
收藏 0
点赞 0
评论 0
@Override
public Color getBackground(Object element, int columnIndex) {
if (columnIndex == 1) {
final ResultNode node = (ResultNode) element;
if (node.isLeaf()) {
// show actual status
return progressBar.getColorForStatus(node.getStatus());
} else {
// show aggregated status of children
return progressBar.getColorForStatus(node.getChildrenStatus().getAggregatedStatus());
}
}
return null;
}
PieUtils.java 文件源码
项目:BiglyBT
阅读 26
收藏 0
点赞 0
评论 0
public static void drawPie(GC gc,int x, int y,int width,int height,int percent) {
Color background = gc.getBackground();
gc.setForeground(Colors.blue);
int angle = (percent * 360) / 100;
if(angle<4)
angle = 0; // workaround fillArc rendering bug
gc.setBackground(Colors.white);
gc.fillArc(x,y,width,height,0,360);
gc.setBackground(background);
gc.fillArc(x,y,width,height,90,angle*-1);
gc.drawOval(x , y , width-1, height-1);
}
MultiStepCompositeTest.java 文件源码
项目:scanning
阅读 28
收藏 0
点赞 0
评论 0
/**
* This test checks that the 'energy' scannable changed the default
* bounds to its bounds (35000)
* @throws Exception
*/
@Test
public void checkRedWhenOutOfBounds() throws Exception {
try {
model.addRange(35000.1, 45000, 100);
synchExec(()->controller.beanToUI());
Color red = new Color(bot.getDisplay(), 255, 0, 0, 255);
assertEquals(red, bot.styledText(0).foregroundColor());
assertEquals(red, bot.styledText(1).foregroundColor());
} finally {
model.clear();
}
}
GraphUtils.java 文件源码
项目:n4js
阅读 21
收藏 0
点赞 0
评论 0
public static Color getColor(RGB rgb) {
if (!colors.containsKey(rgb)) {
RGB rgbKey = new RGB(rgb.red, rgb.green, rgb.blue);
Color rgbColor = new Color(Display.getCurrent(), rgb.red, rgb.green, rgb.blue);
colors.put(rgbKey, rgbColor);
}
return colors.get(rgb);
}
TwistieSection.java 文件源码
项目:BiglyBT
阅读 29
收藏 0
点赞 0
评论 0
@Override
public void setForeground(Color color) {
if (null != label && !label.isDisposed()) {
label.setForeground(color);
}
if (null != content && !content.isDisposed()) {
content.setForeground(color);
}
super.setForeground(color);
}
CFEdge.java 文件源码
项目:n4js
阅读 29
收藏 0
点赞 0
评论 0
/** Sets the color of the {@link GC} depending on the edge type. */
void setColor(GC gc) {
Display displ = Display.getCurrent();
Color color = GraphUtils.getColor(50, 50, 50);
if (isDead || cfTypes.contains(ControlFlowType.DeadCode)) {
color = displ.getSystemColor(SWT.COLOR_GRAY);
} else {
for (ControlFlowType cfType : cfTypes) {
switch (cfType) {
case LoopEnter:
case LoopReenter:
case LoopInfinite:
case Break:
case Continue:
case Return:
color = displ.getSystemColor(SWT.COLOR_BLUE);
break;
case Throw:
color = displ.getSystemColor(SWT.COLOR_RED);
break;
default:
break;
}
}
}
gc.setForeground(color);
}
Node.java 文件源码
项目:n4js
阅读 29
收藏 0
点赞 0
评论 0
/** Constructor */
public Node(Object element, String title, String description, Color color, float x, float y, float width,
float height) {
this.element = element;
this.title = title;
this.description = description;
this.color = color;
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
TagStatsView.java 文件源码
项目:BiglyBT
阅读 28
收藏 0
点赞 0
评论 0
private
ValueSourceImpl(
TagFeatureRateLimit _tag,
String _name,
int _index,
Color[] _colours,
boolean _is_up )
{
tag = _tag;
name = _name;
index = _index;
colours = _colours;
is_up = _is_up;
}
ColorUtils.java 文件源码
项目:n4js
阅读 33
收藏 0
点赞 0
评论 0
/** returns {@link Color} based on the provided {@link RGB} color. */
public static Color getColor(RGB rgb) {
if (!colors.containsKey(rgb)) {
colors.put(
new RGB(rgb.red, rgb.green, rgb.blue),
new Color(Display.getCurrent(), rgb.red, rgb.green, rgb.blue));
}
return colors.get(rgb);
}
ReducedBrowserInformationControl.java 文件源码
项目:eclipse-bash-editor
阅读 28
收藏 0
点赞 0
评论 0
@Override
public void setBackgroundColor(Color background) {
super.setBackgroundColor(background);
if (isBrowserNotDisposed()) {
browser.setBackground(background);
}
}
ConnectorEditorPart.java 文件源码
项目:convertigo-eclipse
阅读 26
收藏 0
点赞 0
评论 0
/**
* This method initializes compositeOutputHeader
*
*/
private void createCompositeOutputHeader() {
final Color background = getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
GridLayout gridLayout3 = new GridLayout();
gridLayout3.numColumns = 2;
GridData gridData1 = new org.eclipse.swt.layout.GridData();
gridData1.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
gridData1.grabExcessHorizontalSpace = true;
gridData1.grabExcessVerticalSpace = false;
gridData1.verticalAlignment = org.eclipse.swt.layout.GridData.BEGINNING;
compositeOutputHeader = new Composite(compositeOutput, SWT.NONE);
compositeOutputHeader.setBackground(background);
compositeOutputHeader.setLayoutData(gridData1);
compositeOutputHeader.setLayout(gridLayout3);
createToolBar();
GridData gridData6 = new org.eclipse.swt.layout.GridData();
gridData6.horizontalAlignment = org.eclipse.swt.layout.GridData.END;
gridData6.heightHint = 16;
gridData6.widthHint = 104;
gridData6.verticalAlignment = org.eclipse.swt.layout.GridData.BEGINNING;
canvas = new Canvas(compositeOutputHeader, SWT.NONE);
canvas.setLayoutData(gridData6);
canvas.setVisible(true);
}
SWTResourceManager.java 文件源码
项目:AgentWorkbench
阅读 27
收藏 0
点赞 0
评论 0
/**
* Dispose of all the cached {@link Color}'s.
*/
public static void disposeColors() {
for (Color color : m_colorMap.values()) {
color.dispose();
}
m_colorMap.clear();
}
PluginDialog.java 文件源码
项目:ide-plugins
阅读 25
收藏 0
点赞 0
评论 0
public PluginDialog(Shell shell) {
super(shell);
this.display = Display.getDefault();
fontName = display.getSystemFont().getFontData()[0].getName();
backColor = new Color(display, 244, 244, 244);
rowColorSelection = display.getSystemColor(SWT.COLOR_WHITE);
titleFont = new Font(display, fontName, getTitleFontSize(), SWT.NORMAL);
topFont = new Font(display, fontName, getTopFontSize(), SWT.NORMAL);
}
DecoratingColumLabelProvider.java 文件源码
项目:gemoc-studio-modeldebugging
阅读 32
收藏 0
点赞 0
评论 0
@Override
public Color getForeground(Object element) {
final Color res;
if (colorProvider == null) {
res = null;
} else {
res = colorProvider.getForeground(element);
}
return res;
}