本文整理匯總了Java中org.eclipse.swt.graphics.Color類的典型用法代碼示例。如果您正苦於以下問題:Java Color類的具體用法?Java Color怎麽用?Java Color使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Color類屬於org.eclipse.swt.graphics包,在下文中一共展示了Color類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initializeColors
import org.eclipse.swt.graphics.Color; //導入依賴的package包/類
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;
}
示例2: TestProgressBar
import org.eclipse.swt.graphics.Color; //導入依賴的package包/類
/**
* 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();
});
}
示例3: getCurrent
import org.eclipse.swt.graphics.Color; //導入依賴的package包/類
/**
* 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);
}
示例4: update
import org.eclipse.swt.graphics.Color; //導入依賴的package包/類
@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);
}
示例5: displayMessage
import org.eclipse.swt.graphics.Color; //導入依賴的package包/類
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;
}
示例6: AbstractNodeFigure
import org.eclipse.swt.graphics.Color; //導入依賴的package包/類
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);
}
示例7: allButtonListener
import org.eclipse.swt.graphics.Color; //導入依賴的package包/類
/**
* 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);
}
}
}
示例8: setStyledText
import org.eclipse.swt.graphics.Color; //導入依賴的package包/類
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]));
}
示例9: createComposite
import org.eclipse.swt.graphics.Color; //導入依賴的package包/類
/**
* 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);
}
示例10: ValueSourceImpl
import org.eclipse.swt.graphics.Color; //導入依賴的package包/類
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;
}
示例11: updateColor
import org.eclipse.swt.graphics.Color; //導入依賴的package包/類
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));
}
}
示例12: disposeColors
import org.eclipse.swt.graphics.Color; //導入依賴的package包/類
/**
* Dispose of all the cached {@link Color}'s.
*/
public static void disposeColors() {
for (Color color : m_colorMap.values()) {
color.dispose();
}
m_colorMap.clear();
}
示例13: toColor
import org.eclipse.swt.graphics.Color; //導入依賴的package包/類
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.");
}
}
示例14: initialize
import org.eclipse.swt.graphics.Color; //導入依賴的package包/類
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));
}
示例15: setTwistieForeground
import org.eclipse.swt.graphics.Color; //導入依賴的package包/類
/**
* Delegating to the <code>TwistieLabel</code>
* @param color
*/
public void setTwistieForeground(Color color) {
if (null != label && !label.isDisposed()) {
label.setTwistieForeground(color);
}
}