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);
}
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;
}
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()]);
}
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));
}
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;
}
Aggregations