/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eSet ( int featureID, Object newValue ) { switch ( featureID ) { case ChartPackage.AXIS__LABEL: setLabel ( (String)newValue ); return; case ChartPackage.AXIS__TEXT_PADDING: setTextPadding ( (Integer)newValue ); return; case ChartPackage.AXIS__COLOR: setColor ( (RGB)newValue ); return; case ChartPackage.AXIS__LABEL_VISIBLE: setLabelVisible ( (Boolean)newValue ); return; case ChartPackage.AXIS__FORMAT: setFormat ( (String)newValue ); return; } super.eSet ( featureID, newValue ); }
private RGB encontraPixel(int x, int y, int indice) { labelPosicaoCor.setText(x + "," + y); ImageData imageData = null; PaletteData paletteData = null; if (indice == 1 && imagem1 != null) { imageData = imagem1.getImageData(); paletteData = imageData.palette; } else if (indice == 2 && imagem2 != null) { imageData = imagem2.getImageData(); paletteData = imageData.palette; } else if (indice == 3 && imagem3 != null) { imageData = imagem3.getImageData(); paletteData = imageData.palette; } if (paletteData != null && x > -1 && y > -1) { int pixel = imageData.getPixel(x, y); RGB rgb = paletteData.getRGB(pixel); return rgb; } return null; }
/** * Set the border color format Node * @param DNodeContainer currentNode * @param Color * @return */ public static boolean resetBorderColorStyle(AbstractDNode currentNode, RGB color) { if ((currentNode != null) && (color != null)) { Style style = getCurrentStyle(currentNode); if (style instanceof BorderedStyle) { BorderedStyle bStyle = (BorderedStyle) style; RGBValues vColor = convertRGBtoRGBValues(color); if (!isSameColor(vColor, bStyle.getBorderColor())) { bStyle.setBorderColor(vColor); ShapeUtil.removeCustomisation(style, new EStructuralFeature[] { DiagramPackage.Literals.BORDERED_STYLE__BORDER_COLOR }); getStyleHelper(currentNode).refreshStyle(style); return true; } } } return false; }
private void allocateColorWarning() { if (display == null || display.isDisposed()) return; Utils.execSWTThread(new AERunnable() { @Override public void runSupport() { Color colorTables = Colors.getSystemColor(display, SWT.COLOR_LIST_BACKGROUND); HSLColor hslBG = new HSLColor(); hslBG.initHSLbyRGB(colorTables.getRed(), colorTables.getGreen(), colorTables.getBlue()); int lum = hslBG.getLuminence(); HSLColor hslColor = new HSLColor(); hslColor.initRGBbyHSL(25, 200, 128 + (lum < 160 ? 10 : -10)); colorWarning = new AllocateColor("warning", new RGB(hslColor.getRed(), hslColor.getGreen(), hslColor.getBlue()), colorWarning).getColor(); } }, false); }
public boolean setRowColors(RGB c[]) { SWTAsync.assertGUI(); boolean needRefresh = false; if (tableColors != null && tableColors.length != c.length) { for (Color tableColor : tableColors) { tableColor.dispose(); } tableColors = null; } if (tableColors == null) { tableColors = new Color[c.length]; } for (int x = 0; x < tableColors.length; x++) { if (tableColors[x] == null || !tableColors[x].getRGB().equals(c[x])) { tableColors[x] = PaintShop.newColor(c[x]); needRefresh = true; } } return needRefresh; }
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; }
@Override public Image getPreview ( final int width, final int height ) { final Point p = new Point ( width, height ); final Image img = this.previews.get ( p ); if ( img == null ) { RGB rgb = getLineRenderer ().getLineColor (); if ( rgb == null ) { rgb = DEFAULT_COLOR; } final Color color = (Color)this.resourceManager.get ( ColorDescriptor.createFrom ( rgb ) ); final Image newImage = makePreview ( Display.getDefault (), getLineRenderer ().getLineAttributes (), color, p ); this.previews.put ( p, newImage ); return newImage; } return img; }
public static RGB makeColor ( final String color ) { if ( color == null ) { return null; } if ( color.startsWith ( "#" ) ) { if ( color.length () == 1 + 3 ) { return makeRGB ( color.substring ( 1, 2 ) + "0", color.substring ( 2, 3 ) + "0", color.substring ( 3, 4 ) + "0" ); } else if ( color.length () >= 1 + 6 ) { return makeRGB ( color.substring ( 1, 3 ), color.substring ( 3, 5 ), color.substring ( 5, 7 ) ); } } return null; }
/** * * @since 3.1.1.1 */ public static Color getColor(Device device, float[] hsb) { if (hsb[0] < 0) { hsb[0] = 0; } else if (hsb[0] > 360) { hsb[0] = 360; } if (hsb[1] < 0) { hsb[1] = 0; } else if (hsb[1] > 1) { hsb[1] = 1; } if (hsb[2] < 0) { hsb[2] = 0; } else if (hsb[2] > 1) { hsb[2] = 1; } RGB rgb = new RGB(hsb[0], hsb[1], hsb[2]); return getColor(device, rgb.red, rgb.green, rgb.blue); }
@SuppressWarnings("unchecked") private RankedItem<T> applyCellDefaultStyles(final ColumnOptions<T> options, ViewerCell cell) { final RankedItem<T> rankedItem = (RankedItem<T>) cell.getElement(); cell.setForeground(fromRegistry(options.getFontColor())); int rowState = rowStateResolver.apply(rankedItem); if ((rowState & RowState.SELECTED.value) != 0 && options.isEnableBackgroundSelection()) { cell.setBackground(fromRegistry(new RGB(225,226,206))); } else { cell.setBackground(fromRegistry(options.getBackgroundColor())); } if ((rowState & RowState.CURSOR.value) != 0 && options.isEnableBackgroundSelection()) { cell.setBackground(fromRegistry(ColorUtil.blend(cell.getBackground().getRGB(), new RGB(200,200,200)))); } Font font = createColumnFont(options, cell); cell.setFont(font); return rankedItem; }
/** * Set the color format edge * @param DEdge currentEdge * @param color */ public static void setEdgeColorStyle(DEdge currentEdge, RGB color) { if ((currentEdge != null) && (color != null)) { EdgeStyle edgeStyle = currentEdge.getOwnedStyle(); RGBValues c = convertRGBtoRGBValues(color); if ((edgeStyle != null) && !isSameColor(c, edgeStyle.getStrokeColor())) { edgeStyle.setStrokeColor(c); ShapeUtil.addCustomisation(edgeStyle, new EStructuralFeature[] { DiagramPackage.Literals.EDGE_STYLE__STROKE_COLOR }); getStyleHelper(currentEdge).refreshStyle(edgeStyle); } } }
public RGB getBorderColor(){ if(customBorderColor==null){ return this.defaultBorderColor; }else{ return customBorderColor; } }
/** Darkens provided color based on the provided factor. */ public static Color darken(RGB color, float factor) { factor = (float) Math.cbrt(factor); int dr = clamp(color.red * factor); int dg = clamp(color.green * factor); int db = clamp(color.blue * factor); return ColorUtils.getColor(dr, dg, db); }
/** * Returns an RGB that lies between the given foreground and background * colors using the given mixing factor. A <code>factor</code> of 1.0 will produce a * color equal to <code>fg</code>, while a <code>factor</code> of 0.0 will produce one * equal to <code>bg</code>. * @param bg the background color * @param fg the foreground color * @param factor the mixing factor, must be in [0, 1] * * @return the interpolated color */ private static RGB blend(RGB bg, RGB fg, float factor) { // copy of org.eclipse.jface.internal.text.revisions.Colors#blend(..) Assert.isLegal(bg != null); Assert.isLegal(fg != null); Assert.isLegal(factor >= 0f && factor <= 1f); float complement = 1f - factor; return new RGB((int) (complement * bg.red + factor * fg.red), (int) (complement * bg.green + factor * fg.green), (int) (complement * bg.blue + factor * fg.blue)); }
/** * Returns Color from color registry * * @return */ public Color getColorFromRegistry(int red, int green, int blue) { RGB colorValue = new RGB(red, green, blue); Color color = COLOR_REGISTRY.get(colorValue.toString()); if (color == null || (color !=null && color.isDisposed())) { COLOR_REGISTRY.put(colorValue.toString(), colorValue); } return COLOR_REGISTRY.get(colorValue.toString()); }
/** * Generate a new color entry for the configuration file. It will save values for * red, green and blue. * @param name The name of the setting to store. * @param rgb The SWT RGB object to save. * @param rgbDefault The default RGB values. * @return The entry as a String. */ private static String generateNewEntry(String name, RGB rgb, RGB rgbDefault) { return "\t<setting name=\"" + name + "\" type=\"rgb\">"+LINE_SEPARATOR + "\t\t<value name=\"red\">" + rgb.red + "</value>"+LINE_SEPARATOR + "\t\t<value name=\"green\">" + rgb.green + "</value>"+LINE_SEPARATOR + "\t\t<value name=\"blue\">" + rgb.blue + "</value>"+LINE_SEPARATOR + "\t\t<value name=\"default red\">" + rgbDefault.red + "</value>"+LINE_SEPARATOR + "\t\t<value name=\"default green\">" + rgbDefault.green + "</value>"+LINE_SEPARATOR + "\t\t<value name=\"default blue\">" + rgbDefault.blue + "</value>"+LINE_SEPARATOR + "\t</setting>"+LINE_SEPARATOR; }
public static String convertToHexColor(RGB rgb) { if (rgb == null) { return null; } String hex = String.format("#%02x%02x%02x", rgb.red, rgb.green, rgb.blue); return hex; }
private void addPresentation(PresentationReconciler reconciler, String id, RGB rgb, int style) { TextAttribute textAttribute = new TextAttribute(colorManager.getColor(rgb), defaultTextAttribute.getBackground(), style); PresentationSupport presentation = new PresentationSupport(textAttribute); reconciler.setDamager(presentation, id); reconciler.setRepairer(presentation, id); }
public void updateTextScannerDefaultColorToken() { if (gradleScanner == null) { return; } RGB color = getPreferences().getColor(COLOR_NORMAL_TEXT); gradleScanner.setDefaultReturnToken(createColorToken(color)); }
public RGB getBackgroundColor(){ if(customBackgroundColor==null){ return this.defaultBackgroundColor; }else{ return customBackgroundColor; } }
public void customizeStepColor(DDiagramElement functionNode, RGBValues color) { // Change color border style RGB rgbColor = new RGB(color.getRed(), color.getGreen(), color.getBlue()); if (functionNode instanceof AbstractDNode) { ShapeUtil.setBorderColorStyle(((AbstractDNode) functionNode), rgbColor); } }
public void changeFontColor() { ColorDialog cd = new ColorDialog(getShell()); cd.setRGB(text.getBackground().getRGB()); cd.setText("Choose a color"); RGB newColor = cd.open(); if (newColor != null) Config.getInstance().setValue(Config.FONT_COLOR, new Color(Display.getCurrent(), newColor)); updateFont(); }
public Color getColor(String prop) { String color = getString(prop); if (color.isEmpty()) return Display.getCurrent().getSystemColor(SWT.COLOR_WHITE); String rgb[] = color.split(";"); return new Color(Display.getCurrent(), new RGB( Integer.parseInt(rgb[0]), Integer.parseInt(rgb[1]), Integer.parseInt(rgb[2]))); }
@Override public void setBackground ( final RGB color ) { if ( color != null ) { this.gc.setBackground ( (Color)this.resourceManager.get ( ColorDescriptor.createFrom ( color ) ) ); } else { this.gc.setBackground ( this.gc.getDevice ().getSystemColor ( SWT.COLOR_WIDGET_BACKGROUND ) ); } }
private void renderData ( final Graphics g, final Rectangle chartRect, final DataSet data ) { // reset clipping g.setClipping ( null ); int y = chartRect.y + this.margin; int x = chartRect.x + this.margin; g.setAntialias ( true ); g.setForeground ( this.foregroundColor ); g.setBackground ( this.backgroundColor ); // draw the frame g.fillRoundRectangle ( x, y, data.width + this.padding * 2, data.height + this.padding * 2, 10, 10 ); g.drawRoundRectangle ( x, y, data.width + this.padding * 2, data.height + this.padding * 2, 10, 10 ); x += this.padding; y += this.padding; g.setForeground ( new RGB ( 0, 0, 0 ) ); for ( final Data d : data.allData ) { renderDataEntry ( g, data, d, x, y ); y += Math.max ( d.getHeight (), this.previewSize ) + this.textPadding; } }
/** * Convert a RGB value to RGBValues * @param RGB color * @return RGBValues */ public static RGBValues convertRGBtoRGBValues(RGB color) { if (color == null) { return null; } RGBValues newValuesContent = RGBValues.create(color.red, color.green, color.blue); return newValuesContent; }
@Override public void setLineColor ( final RGB rgb ) { this.lineColor = rgb; getLineRenderer ().setLineColor ( rgb ); fireUpdatePreviews (); firePropertyChange ( PROP_COLOR, null, rgb ); }
public void update ( final DataItemValue value ) { this.ruler.setVisible ( false ); if ( value != null ) { final Variant levelValue = value.getAttributes ().get ( this.prefix + ".preset" ); //$NON-NLS-1$ if ( levelValue != null ) { this.ruler.setPosition ( levelValue.asDouble ( null ) ); this.ruler.setVisible ( true ); } final boolean active = value.getAttributeAsBoolean ( this.prefix + ".active" ); //$NON-NLS-1$ final boolean unsafe = value.getAttributeAsBoolean ( this.prefix + ".unsafe" ); //$NON-NLS-1$ final boolean error = value.getAttributeAsBoolean ( this.prefix + ".error" ); //$NON-NLS-1$ final boolean alarm = value.getAttributeAsBoolean ( this.prefix + ".alarm" ); //$NON-NLS-1$ if ( !active ) { this.ruler.setColor ( new RGB ( 128, 128, 128 ) ); } else if ( unsafe ) { this.ruler.setColor ( new RGB ( 255, 0, 255 ) ); } else if ( error || alarm ) { this.ruler.setColor ( new RGB ( 255, 0, 0 ) ); } else { this.ruler.setColor ( new RGB ( 0, 255, 0 ) ); } } }
protected void updateState () { final org.eclipse.scada.chart.XAxis x; x = getTimeRulerViewer (); // update mouse controllers if ( this.mouseHover != null ) { this.mouseHover.dispose (); this.mouseHover = null; } if ( isHoverable () ) { this.mouseHover = new MouseHover ( this.manager ); this.mouseHover.setVisible ( true ); } // update current time tracker if ( this.timeRuler == null && this.showTimeRuler && x != null ) { this.timeRuler = new CurrentTimeRuler ( x ); this.timeRuler.setColor ( new RGB ( 0, 0, 255 ) ); this.manager.addRenderer ( this.timeRuler, 100 ); } else if ( this.timeRuler != null && !this.showTimeRuler || x == null ) { disposeTimeRuler (); } }
/** * Set the color format edge * @param DEdge currentEdge * @param color */ public static void resetEdgeColorStyle(DEdge currentEdge, RGB color) { if ((currentEdge != null) && (color != null)) { EdgeStyle edgeStyle = currentEdge.getOwnedStyle(); RGBValues c = convertRGBtoRGBValues(color); if ((edgeStyle != null) && !isSameColor(c, edgeStyle.getStrokeColor())) { edgeStyle.setStrokeColor(c); ShapeUtil.removeCustomisation(edgeStyle, new EStructuralFeature[] { DiagramPackage.Literals.EDGE_STYLE__STROKE_COLOR }); getStyleHelper(currentEdge).refreshStyle(edgeStyle); } } }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setColor ( RGB newColor ) { RGB oldColor = color; color = newColor; if ( eNotificationRequired () ) eNotify ( new ENotificationImpl ( this, Notification.SET, ChartPackage.LINE_PROPERTIES__COLOR, oldColor, color ) ); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setBackgroundColor ( RGB newBackgroundColor ) { RGB oldBackgroundColor = backgroundColor; backgroundColor = newBackgroundColor; if ( eNotificationRequired () ) eNotify ( new ENotificationImpl ( this, Notification.SET, ChartPackage.CHART__BACKGROUND_COLOR, oldBackgroundColor, backgroundColor ) ); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object createFromString ( EDataType eDataType, String initialValue ) { switch ( eDataType.getClassifierID () ) { case ChartPackage.PROFILE_SWITCHER_TYPE: return createProfileSwitcherTypeFromString ( eDataType, initialValue ); case ChartPackage.RGB: return createRGBFromString ( eDataType, initialValue ); default: throw new IllegalArgumentException ( "The datatype '" + eDataType.getName () + "' is not a valid classifier" ); //$NON-NLS-1$ //$NON-NLS-2$ } }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated NOT */ public String convertRGBToString ( final EDataType eDataType, final Object instanceValue ) { final RGB rgb = (RGB)instanceValue; if ( rgb == null ) { return null; } return String.format ( "#%02X%02X%02X", rgb.red, rgb.green, rgb.blue ); //$NON-NLS-1$ }
@Override protected IFigure createFigure() { final PolylineConnection connection = new PolylineConnection(); connection.setConnectionRouter(new BendpointConnectionRouter()); PolygonDecoration decoration = new PolygonDecoration(); decoration.setTemplate(new PointList(new int[]{0, 0, -2, 2, -2, 0, -2, -2, 0, 0})); RGB rgb=Activator.getPreference().getTransitionColor(); decoration.setBackgroundColor(new Color(null,rgb)); connection.setTargetDecoration(decoration); connection.setAntialias(SWT.ON); connection.setForegroundColor(new Color(null,rgb)); return connection; }
private void drawChart ( final Device device, final GC gc, final double minX, final double maxX, final Calendar startTimestamp, final Calendar endTimestamp ) { final Rectangle bounds = device.getBounds (); final Color color = new Color ( device, new RGB ( 0, 0, 0 ) ); final Rectangle drawBounds = new Rectangle ( bounds.x + 10, bounds.y + 10, bounds.width - 20, bounds.height - 20 ); gc.setForeground ( color ); gc.drawRectangle ( drawBounds ); for ( final Map.Entry<String, List<Double>> row : this.values.entrySet () ) { drawRow ( device, gc, row.getKey (), row.getValue (), drawBounds, minX, maxX ); } }
private void applyColor ( final Symbol symbol ) { final RGB color = org.eclipse.scada.vi.ui.draw2d.primitives.Helper.makeColor ( symbol.getBackgroundColor () ); if ( color != null ) { this.canvas.setBackground ( this.manager.createColor ( color ) ); } }
public AllocateColor(String sName, final Color colorDefault, Color colorOld) { this.sName = sName; Utils.execSWTThread(new AERunnable() { @Override public void runSupport() { if (!colorDefault.isDisposed()) AllocateColor.this.rgbDefault = colorDefault.getRGB(); else AllocateColor.this.rgbDefault = new RGB(0, 0, 0); } }, false); }