Java 类org.eclipse.swt.graphics.Color 实例源码

项目:SWET    文件:JavaLineStyler.java   
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;
}
项目:n4js    文件:TestProgressBar.java   
/**
 * 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();
    });
}
项目:n4js    文件:TestProgressBar.java   
/**
 * 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);
}
项目:avro-schema-editor    文件:SchemaViewerStyledCellLabelProvider.java   
@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);
  }
项目:n4js    文件:SpecProcessPage.java   
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;
}
项目:bdf2    文件:AbstractNodeFigure.java   
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);
}
项目:Hydrograph    文件:StyledTextEventListener.java   
/**
 * 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);
          }
      }
}
项目:vertigo-chroma-kspplugin    文件:KspOutlinePage.java   
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]));
}
项目:convertigo-eclipse    文件:SequenceEditorPart.java   
/**
 * 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);
}
项目:BiglyBT    文件:DownloadActivityView.java   
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;
}
项目:BiglyBT    文件:TrackerCellUtils.java   
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));
    }
}
项目:pdi    文件:SWTResourceManager.java   
/**
 * Dispose of all the cached {@link Color}'s.
 */
public static void disposeColors() {
    for (Color color : m_colorMap.values()) {
        color.dispose();
    }
    m_colorMap.clear();
}
项目:Sensors    文件:SWTResourceManager.java   
/**
 * Dispose of all the cached {@link Color}'s.
 */
public static void disposeColors() {
    for (Color color : m_colorMap.values()) {
        color.dispose();
    }
    m_colorMap.clear();
}
项目:n4js    文件:ConsoleOutputStreamProvider.java   
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.");
    }
}
项目:convertigo-eclipse    文件:CicsConnectorComposite.java   
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));
}
项目:BiglyBT    文件:TwistieSection.java   
/**
 * Delegating to the <code>TwistieLabel</code>
 * @param color
 */

public void setTwistieForeground(Color color) {
    if (null != label && !label.isDisposed()) {
        label.setTwistieForeground(color);
    }
}
项目:n4js    文件:TestResultsView.java   
@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;
}
项目:BiglyBT    文件:PieUtils.java   
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);
}
项目:scanning    文件:MultiStepCompositeTest.java   
/**
 * 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();
    }
}
项目:n4js    文件:GraphUtils.java   
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);
}
项目:BiglyBT    文件:TwistieSection.java   
@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);
}
项目:n4js    文件:CFEdge.java   
/** 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);
}
项目:n4js    文件:Node.java   
/** 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;
}
项目:BiglyBT    文件:TagStatsView.java   
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;
}
项目:n4js    文件:ColorUtils.java   
/** 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);
}
项目:eclipse-bash-editor    文件:ReducedBrowserInformationControl.java   
@Override
public void setBackgroundColor(Color background) {
    super.setBackgroundColor(background);
    if (isBrowserNotDisposed()) {
        browser.setBackground(background);
    }
}
项目:convertigo-eclipse    文件:ConnectorEditorPart.java   
/**
 * 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);
}
项目:AgentWorkbench    文件:SWTResourceManager.java   
/**
 * Dispose of all the cached {@link Color}'s.
 */
public static void disposeColors() {
    for (Color color : m_colorMap.values()) {
        color.dispose();
    }
    m_colorMap.clear();
}
项目:ide-plugins    文件:PluginDialog.java   
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);
}
项目:gemoc-studio-modeldebugging    文件:DecoratingColumLabelProvider.java   
@Override
public Color getForeground(Object element) {
    final Color res;

    if (colorProvider == null) {
        res = null;
    } else {
        res = colorProvider.getForeground(element);
    }

    return res;
}
项目:AppleCommander    文件:DiskMapTab.java   
/**
 * Construct the DiskMapTab.
 */
public DiskMapTab(CTabFolder tabFolder, FormattedDisk disk) {
    this.disk = disk;

    // these items are reused; need to dispose of them when done!
    freeFill = new Color(tabFolder.getDisplay(), 100,200,100);
    usedFill = new Color(tabFolder.getDisplay(), 200,100,100);
    black = new Color(tabFolder.getDisplay(), 0,0,0);
    gray = new Color(tabFolder.getDisplay(), 50,50,50);

    createDiskMapTab(tabFolder);
}
项目:RefDiff    文件:ProgressBarDialog.java   
private Control createDialogArea(Composite shell) {
       GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    shell.setLayout(layout);

    lblStep = new Label(shell, SWT.NONE);
    lblStep.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
    lblStep.setText("Step 1 / 999");

    lblMessage = new Label(shell, SWT.NONE);
    lblMessage.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
    lblMessage.setText("Idle");

    pbProg = new ProgressBar(shell, SWT.SMOOTH | SWT.INDETERMINATE);
    pbProg.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
    pbProg.setMaximum(1000);
    pbProg.setSelection(0);
    pbProg.setSelection(256);

    final Label lblSeparator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
    lblSeparator.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));

    txtLog = new Text(shell, SWT.MULTI
              | SWT.BORDER
              | SWT.H_SCROLL
              | SWT.V_SCROLL);
    txtLog.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
    txtLog.setEditable(false);
    txtLog.setBackground(new Color(shell.getDisplay(), 10,10,10));
    txtLog.setForeground(new Color(shell.getDisplay(), 200,200,200));

    shell.layout();

    return shell;
}
项目:neoscada    文件:SWTGraphics.java   
@Override
public void setForeground ( final RGB color )
{
    if ( color != null )
    {
        this.gc.setForeground ( (Color)this.resourceManager.get ( ColorDescriptor.createFrom ( color ) ) );
    }
    else
    {
        this.gc.setForeground ( this.gc.getDevice ().getSystemColor ( SWT.COLOR_WIDGET_FOREGROUND ) );
    }
}
项目:scanning    文件:ModelFieldLabelProvider.java   
@Override
public Color getForeground(Object ofield) {
    Color ret = super.getForeground(ofield);
    if (ret!=null) return ret;
    if (ofield instanceof FieldValue && viewer.isValidationError((FieldValue)ofield)) {
        return Display.getDefault().getSystemColor(SWT.COLOR_RED);
    } else {
        return null;
    }
}
项目:applecommander    文件:DiskMapTab.java   
/**
 * Draw a box on the screen.  The shadowed box is only drawn if there is
 * enough space within the box; otherwise, the box is just filled in with
 * the fill color.  Additionally, drawBox ensures that a square is drawn.
 */
protected void drawBox(Rectangle box, GC gc, Color fill, Color outline, Color shadow) {
    if (box.width >= 10 && box.height >= 10) {
        // square the rectangle shape:
        int size = Math.min(box.height, box.width);
        box.height = size + ((box.height - size) / 2);
        box.width = size + ((box.width - size) / 2);
        // offset internal box:
        box.x+= 2;
        box.y+= 2;
        box.width-= 5;
        box.height-= 5;
        // draw!
        gc.setBackground(shadow);
        gc.fillRectangle(box);
        box.x-= 2;
        box.y-= 2;
        gc.setBackground(fill);
        gc.fillRectangle(box);
        gc.setForeground(outline);
        gc.drawRectangle(box);
    } else {
        // just fill:
        gc.setBackground(fill);
        gc.fillRectangle(box);
    }
}
项目:Hydrograph    文件:SWTResourceManager.java   
/**
 * Dispose of all the cached {@link Color}'s.
 */
public static void disposeColors() {
    for (Color color : m_colorMap.values()) {
        color.dispose();
    }
    m_colorMap.clear();
}
项目:BiglyBT    文件:Colors.java   
public static Color getSystemColor (Device d, int id) {
    if (Utils.isGTK3) {
        if (id == SWT.COLOR_INFO_BACKGROUND) {
            return ColorCache.getColor(d, 0, 0,0 );
        }
        if (id == SWT.COLOR_INFO_FOREGROUND) {
            return ColorCache.getColor(d, 255, 255,255 );
        }
    }
    return d.getSystemColor(id);
}
项目:BiglyBT    文件:TwistieSection.java   
@Override
public void setBackground(Color color) {
    if (null != label && !label.isDisposed()) {
        label.setBackground(color);
    }

    if (null != content && !content.isDisposed()) {
        content.setBackground(color);
    }

    super.setBackground(color);
}
项目:neoscada    文件:StyleHandler.java   
public Style ( final Image[] images, final Color[] foregroundColor, final Color[] backgroundColor, final Font[] font )
{
    this.images = images;
    this.foregroundColor = foregroundColor;
    this.backgroundColor = backgroundColor;
    this.font = font;
}
项目:gemoc-studio    文件:EclipseConsoleIO.java   
/** deal with not justified and large string
 * this is because large string may block Eclipse UI
 */
protected void safePrint(String message, final Color c, final int style, IProgressMonitor monitor){
    try {
        String justifiedMsg = justifyMessage(message);
        if(justifiedMsg.length() > LARGE_MESSAGE_SIZE){
            // deal with large messages ... chunk the message
            int nbChunk = justifiedMsg.length()/LARGE_MESSAGE_SIZE;
            monitor.beginTask("writing large string to the console", nbChunk+1);
            int start, end= 0;
            for(int i = 0; i< nbChunk; i++){
                start = LARGE_MESSAGE_SIZE*i;
                end = LARGE_MESSAGE_SIZE*i + LARGE_MESSAGE_SIZE;
                changeStream();
                safeChangeStyle(c, style);
                ((IOConsoleOutputStream)getOutputStream()).write(justifiedMsg.substring(start, end));
                monitor.worked(1);
            }
            changeStream();
            safeChangeStyle(c, style);
            ((IOConsoleOutputStream)getOutputStream()).write(justifiedMsg.substring(end, justifiedMsg.length()));
            monitor.done();
        }
        else{
            safeChangeStyle(c, style);
            ((IOConsoleOutputStream)getOutputStream()).write(justifiedMsg);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}