Search in sources :

Example 16 with Color

use of org.eclipse.swt.graphics.Color in project tdi-studio-se by Talend.

the class CustomTableFigure method fillShape.

protected void fillShape(Graphics graphics) {
    Rectangle r = getBounds();
    Rectangle.SINGLETON.setBounds(r);
    Rectangle.SINGLETON.y += 1;
    Rectangle.SINGLETON.height -= 1;
    int shadowDepth = 0;
    int rectangleWidth = r.width - shadowDepth;
    int rectangleHeight = r.height - shadowDepth;
    Color foreground = graphics.getForegroundColor();
    Color background = graphics.getBackgroundColor(), shadow = ColorUtilities.darker(foreground);
    int x = r.x + shadowDepth;
    int y = r.y + shadowDepth;
    /**
         * trace shadow
         */
    for (int i = shadowDepth - 1; i >= 0; i--) {
        shadow = lighter(background, i + 1, shadowDepth + 1);
        graphics.setBackgroundColor(shadow);
        graphics.fillRectangle(x, y, rectangleWidth, rectangleHeight);
        if (i > 0) {
            x--;
            y--;
        }
    }
    graphics.setBackgroundColor(background);
    graphics.setForegroundColor(foreground);
    graphics.fillRectangle(x, y, rectangleWidth, rectangleHeight);
    // Gradient
    graphics.setForegroundColor(foreground);
    graphics.fillGradient(x, y - 20, rectangleWidth, figure.getBounds().height + 25, true);
    graphics.setForegroundColor(foreground);
    graphics.drawRectangle(x, y - 1, rectangleWidth - 1, rectangleHeight);
}
Also used : Color(org.eclipse.swt.graphics.Color) Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 17 with Color

use of org.eclipse.swt.graphics.Color in project tesb-studio-se by Talend.

the class AnsiConsoleAttributes method updateRangeStyle.

// This function maps from the current attributes as "described" by escape sequences to real,
// Eclipse console specific attributes (resolving color palette, default colors, etc.)
public static void updateRangeStyle(StyleRange range, AnsiConsoleAttributes attribute) {
    AnsiConsoleAttributes tempAttrib = attribute.clone();
    boolean hilite = false;
    // Prepare the foreground color
    if (hilite) {
        if (tempAttrib.currentFgColor == null) {
            range.foreground = AnsiConsoleUtils.getDebugConsoleFgColor();
            range.foreground = hiliteRgbColor(range.foreground);
        } else {
            if (tempAttrib.currentFgColor < AnsiCommands.COMMAND_COLOR_INTENSITY_DELTA)
                range.foreground = new Color(null, AnsiConsoleColorPalette.getColor(tempAttrib.currentFgColor + AnsiCommands.COMMAND_COLOR_INTENSITY_DELTA));
            else
                range.foreground = new Color(null, AnsiConsoleColorPalette.getColor(tempAttrib.currentFgColor));
        }
    } else {
        if (tempAttrib.currentFgColor != null)
            range.foreground = new Color(null, AnsiConsoleColorPalette.getColor(tempAttrib.currentFgColor));
    }
    // Prepare the background color
    if (tempAttrib.currentBgColor != null)
        range.background = new Color(null, AnsiConsoleColorPalette.getColor(tempAttrib.currentBgColor));
    // We need to solve them before we use them for strike/underline/frame colors
    if (tempAttrib.invert) {
        if (range.foreground == null)
            range.foreground = AnsiConsoleUtils.getDebugConsoleFgColor();
        if (range.background == null)
            range.background = AnsiConsoleUtils.getDebugConsoleBgColor();
        Color tmp = range.background;
        range.background = range.foreground;
        range.foreground = tmp;
    }
    if (tempAttrib.conceal) {
        if (range.background == null)
            range.background = AnsiConsoleUtils.getDebugConsoleBgColor();
        range.foreground = range.background;
    }
    range.font = null;
    range.fontStyle = SWT.NORMAL;
    // Prepare the rest of the attributes
    if (tempAttrib.bold)
        range.fontStyle |= SWT.BOLD;
    if (tempAttrib.italic)
        range.fontStyle |= SWT.ITALIC;
    if (tempAttrib.underline != UNDERLINE_NONE) {
        range.underline = true;
        range.underlineColor = range.foreground;
        range.underlineStyle = tempAttrib.underline;
    } else
        range.underline = false;
    range.strikeout = tempAttrib.strike;
    range.strikeoutColor = range.foreground;
    if (tempAttrib.framed) {
        range.borderStyle = SWT.BORDER_SOLID;
        range.borderColor = range.foreground;
    } else
        range.borderStyle = SWT.NONE;
}
Also used : Color(org.eclipse.swt.graphics.Color)

Example 18 with Color

use of org.eclipse.swt.graphics.Color in project tesb-studio-se by Talend.

the class AnsiConsoleStyleListener method lineGetStyle.

@Override
public void lineGetStyle(LineStyleEvent event) {
    if (event == null || event.lineText == null || event.lineText.length() == 0)
        return;
    StyleRange defStyle;
    if (event.styles != null && event.styles.length > 0) {
        defStyle = (StyleRange) event.styles[0].clone();
        if (defStyle.background == null)
            defStyle.background = AnsiConsoleUtils.getDebugConsoleBgColor();
    } else {
        defStyle = new StyleRange(1, lastRangeEnd, new Color(null, AnsiConsoleColorPalette.getColor(0)), new Color(null, AnsiConsoleColorPalette.getColor(15)), SWT.NORMAL);
    }
    lastRangeEnd = 0;
    List<StyleRange> ranges = new ArrayList<StyleRange>();
    String currentText = event.lineText;
    Matcher matcher = pattern.matcher(currentText);
    while (matcher.find()) {
        int start = matcher.start();
        int end = matcher.end();
        String theEscape = currentText.substring(matcher.start() + 2, matcher.end() - 1);
        char code = currentText.charAt(matcher.end() - 1);
        if (code == ESCAPE_SGR) {
            // Select Graphic Rendition (SGR) escape sequence
            List<Integer> nCommands = new ArrayList<Integer>();
            for (String cmd : theEscape.split(";")) {
                int nCmd = AnsiConsoleUtils.tryParseInteger(cmd);
                if (nCmd != -1)
                    nCommands.add(nCmd);
            }
            if (nCommands.isEmpty())
                nCommands.add(0);
            interpretCommand(nCommands);
        }
        if (lastRangeEnd != start)
            addRange(ranges, event.lineOffset + lastRangeEnd, start - lastRangeEnd, defStyle.foreground, false);
        lastAttributes = currentAttributes.clone();
        addRange(ranges, event.lineOffset + start, end - start, defStyle.foreground, true);
    }
    if (lastRangeEnd != currentText.length())
        addRange(ranges, event.lineOffset + lastRangeEnd, currentText.length() - lastRangeEnd, defStyle.foreground, false);
    lastAttributes = currentAttributes.clone();
    if (!ranges.isEmpty())
        event.styles = ranges.toArray(new StyleRange[ranges.size()]);
}
Also used : Matcher(java.util.regex.Matcher) StyleRange(org.eclipse.swt.custom.StyleRange) Color(org.eclipse.swt.graphics.Color) ArrayList(java.util.ArrayList)

Example 19 with Color

use of org.eclipse.swt.graphics.Color in project tesb-studio-se by Talend.

the class AnsiConsoleAttributes method hiliteRgbColor.

public static Color hiliteRgbColor(Color c) {
    if (c == null)
        return new Color(null, new RGB(0xff, 0xff, 0xff));
    int red = c.getRed() * 2;
    int green = c.getGreen() * 2;
    int blue = c.getBlue() * 2;
    if (red > 0xff)
        red = 0xff;
    if (green > 0xff)
        green = 0xff;
    if (blue > 0xff)
        blue = 0xff;
    // here
    return new Color(null, new RGB(red, green, blue));
}
Also used : Color(org.eclipse.swt.graphics.Color) RGB(org.eclipse.swt.graphics.RGB)

Example 20 with Color

use of org.eclipse.swt.graphics.Color in project tesb-studio-se by Talend.

the class AnsiConsoleUtils method colorFromStringRgb.

static Color colorFromStringRgb(String strRgb) {
    Color result = null;
    String[] splitted = strRgb.split(",");
    if (splitted != null && splitted.length == 3) {
        int red = tryParseInteger(splitted[0]);
        int green = tryParseInteger(splitted[1]);
        int blue = tryParseInteger(splitted[2]);
        result = new Color(null, new RGB(red, green, blue));
    }
    return result;
}
Also used : Color(org.eclipse.swt.graphics.Color) RGB(org.eclipse.swt.graphics.RGB)

Aggregations

Color (org.eclipse.swt.graphics.Color)1008 Point (org.eclipse.swt.graphics.Point)145 RGB (org.eclipse.swt.graphics.RGB)127 GridData (org.eclipse.swt.layout.GridData)120 Composite (org.eclipse.swt.widgets.Composite)118 Rectangle (org.eclipse.swt.graphics.Rectangle)116 Image (org.eclipse.swt.graphics.Image)115 GridLayout (org.eclipse.swt.layout.GridLayout)99 Display (org.eclipse.swt.widgets.Display)97 Test (org.junit.Test)95 Font (org.eclipse.swt.graphics.Font)86 Label (org.eclipse.swt.widgets.Label)79 GC (org.eclipse.swt.graphics.GC)74 SelectionEvent (org.eclipse.swt.events.SelectionEvent)65 Shell (org.eclipse.swt.widgets.Shell)54 ArrayList (java.util.ArrayList)51 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)51 StyleRange (org.eclipse.swt.custom.StyleRange)49 TableItem (org.eclipse.swt.widgets.TableItem)48 Button (org.eclipse.swt.widgets.Button)45