org.eclipse.swt.graphics.RGBA Java Examples
The following examples show how to use
org.eclipse.swt.graphics.RGBA.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TimeGraphViewStub.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
@Override protected @NonNull List<IMarkerEvent> getViewMarkerList(long startTime, long endTime, long resolution, @NonNull IProgressMonitor monitor) { ITmfTrace trace = getTrace(); if (trace == null) { return Collections.emptyList(); } long start = trace.getStartTime().toNanos(); return Arrays.<IMarkerEvent> asList( (IMarkerEvent) new MarkerEvent(fHead1, 120 + start, 50, MARKER_GROUP, new RGBA(33, 33, 33, 33), "Wind", true), (IMarkerEvent) new MarkerEvent(fRow4, 20 + start, 60, MARKER_GROUP, new RGBA(22, 33, 44, 22), "Speed", false), (IMarkerEvent) new MarkerEvent(fRow2, 20 + start, 0, MARKER_GROUP, new RGBA(22, 33, 44, 22), "", false, 0), (IMarkerEvent) new MarkerEvent(fRow2, 26 + start, 0, MARKER_GROUP, new RGBA(22, 33, 44, 22), "", false, 1), (IMarkerEvent) new MarkerEvent(fRow2, 32 + start, 0, MARKER_GROUP, new RGBA(22, 33, 44, 22), "", false, 2), (IMarkerEvent) new MarkerEvent(fRow2, 38 + start, 0, MARKER_GROUP, new RGBA(22, 33, 44, 22), "", false, 3), (IMarkerEvent) new MarkerEvent(fRow2, 44 + start, 0, MARKER_GROUP, new RGBA(22, 33, 44, 22), "", false, 4), (IMarkerEvent) new MarkerEvent(fRow2, 50 + start, 0, MARKER_GROUP, new RGBA(22, 33, 44, 22), "", true, 5)); }
Example #2
Source File: ConfigurableMarkerEventSource.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
private void getSubMarkerList(SplitMarker splitMarker, IMarkerEvent markerEvent, @NonNull List<@NonNull IMarkerEvent> markerList, long startTime, long endTime, long minDuration) { if (markerEvent.getTime() > endTime || markerEvent.getTime() + markerEvent.getDuration() < startTime) { return; } long lower = splitMarker.getRange().lowerEndpoint(); long upper = splitMarker.getRange().upperEndpoint(); long segments = upper - lower + 1; long start = markerEvent.getTime(); for (int i = 0; i < segments; i++) { long end = markerEvent.getTime() + Math.round((double) (i + 1) / segments * markerEvent.getDuration()); long duration = end - start; long labelIndex = lower + i; if (end >= startTime && duration > minDuration && splitMarker.getIndexRange().contains(labelIndex)) { RGBA color = (labelIndex & 1) == 0 ? getColor(splitMarker) : getOddColor(getColor(splitMarker)); IMarkerEvent subMarkerEvent = new MarkerEvent(null, start, end - start, splitMarker.getName(), color, String.format(splitMarker.getLabel(), labelIndex), false); for (SubMarker subMarker : splitMarker.getSubMarkers()) { getSubMarkerList(subMarker, subMarkerEvent, markerList, startTime, endTime, minDuration); } markerList.add(subMarkerEvent); } if (start >= endTime) { break; } start = end; } }
Example #3
Source File: PeriodicMarkerEventSource.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
private PeriodicMarkerEventSource(String category, Reference reference, double period, long rollover, boolean foreground, RGBA color1, @Nullable RGBA color2) { if (period <= 0) { throw new IllegalArgumentException("period cannot be less than or equal to zero"); //$NON-NLS-1$ } if (rollover < 0) { throw new IllegalArgumentException("rollover cannot be less than zero"); //$NON-NLS-1$ } fCategory = category; fReference = reference; fPeriod = period; fPeriodInteger = (long) period; try { fPeriodFraction = Fraction.getFraction(fPeriod - fPeriodInteger); } catch (ArithmeticException e) { /* can't convert to fraction, use floating-point arithmetic */ fPeriodFraction = null; } fRollover = rollover; fColor1 = color1; fColor2 = color2; fForeground = foreground; }
Example #4
Source File: ConfigurableMarkerEventSource.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
private void configure(Marker marker) { if (marker instanceof PeriodicMarker) { PeriodicMarker periodicMarker = (PeriodicMarker) marker; String referenceId = periodicMarker.getReferenceId(); Reference baseReference = null; if (fTrace instanceof IAdaptable && !referenceId.isEmpty()) { @Nullable IMarkerReferenceProvider adapter = ((IAdaptable) fTrace).getAdapter(IMarkerReferenceProvider.class); if (adapter != null) { baseReference = adapter.getReference(referenceId); } } if (baseReference == null) { baseReference = Reference.ZERO; } long rollover = periodicMarker.getRange().hasUpperBound() ? (periodicMarker.getRange().upperEndpoint() - periodicMarker.getRange().lowerEndpoint() + 1) : 0; RGBA evenColor = getColor(periodicMarker); RGBA oddColor = getOddColor(evenColor); double period = convertToNanos(periodicMarker.getPeriod(), periodicMarker.getUnit()); Reference reference = new Reference(baseReference.getTime() + Math.round(convertToNanos(periodicMarker.getOffset(), periodicMarker.getUnit())), baseReference.getIndex()); ConfigurablePeriodicMarkerEventSource markerEventSource = new ConfigurablePeriodicMarkerEventSource(marker, checkNotNull(periodicMarker.getName()), reference, period, rollover, evenColor, oddColor, false, periodicMarker.getRange().lowerEndpoint(), checkNotNull(periodicMarker.getLabel()), periodicMarker.getIndexRange()); fMarkerEventSources.add(markerEventSource); } }
Example #5
Source File: TmfCommonXAxisChartViewer.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
private @NonNull ISeries createDimmedSeriesFromModel(ISeriesModel yModel) { ISeriesSet seriesSet = getSwtChart().getSeriesSet(); String seriesName = yModel.getName() + DIMMED_SERIES_SUFFIX; OutputElementStyle appearance = getSeriesStyle(yModel.getId()); BaseXYPresentationProvider presProvider = getPresentationProvider2(); String type = (String) presProvider.getStyleOrDefault(appearance, StyleProperties.SERIES_TYPE, StyleProperties.SeriesType.LINE); RGBAColor rgbaColor = presProvider.getColorStyleOrDefault(appearance, StyleProperties.COLOR, DEFAULT_COLOR); float[] rgb = rgbaColor.getHSBA(); COLOR_REGISTRY.put(rgb.toString(), new RGBA(rgb[0], rgb[1] * 0.5f, rgb[2] * 0.5f, rgb[3]).rgb); Color color = COLOR_REGISTRY.get(rgb.toString()); String symbolType = (String) presProvider.getStyle(appearance, StyleProperties.SYMBOL_TYPE); if (type.equals(StyleProperties.SeriesType.BAR)) { IBarSeries barSeries = (IBarSeries) seriesSet.createSeries(SeriesType.BAR, seriesName); barSeries.enableStack(true); barSeries.setBarColor(color); barSeries.setBarPadding(0); barSeries.setVisible(true); return barSeries; } /** * Default is line chart */ ILineSeries lineSeries = (ILineSeries) seriesSet.createSeries(SeriesType.LINE, seriesName); lineSeries.enableArea(StyleProperties.SeriesType.AREA.equals(type)); lineSeries.setLineStyle(LineStyle.valueOf((String) presProvider.getStyle(appearance, StyleProperties.SERIES_STYLE))); lineSeries.setSymbolType(SYMBOL_MAP.getOrDefault(symbolType, ILineSeries.PlotSymbolType.NONE)); lineSeries.setLineColor(color); lineSeries.setSymbolColor(color); lineSeries.setVisible(true); lineSeries.setLineWidth(((Number) presProvider.getFloatStyleOrDefault(appearance, StyleProperties.WIDTH, 1.0f)).intValue()); return lineSeries; }
Example #6
Source File: ConfigurableMarkerEventSource.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
public ConfigurablePeriodicMarkerEventSource(Marker marker, @NonNull String category, @NonNull Reference reference, double period, long rollover, @NonNull RGBA evenColor, @NonNull RGBA oddColor, boolean foreground, long startIndex, @NonNull String label, RangeSet<Long> indexRange) { super(category, reference, period, rollover, evenColor, oddColor, foreground); fMarker = marker; fStartIndex = startIndex; fLabel = label; fIndexRange = indexRange; fMaxDuration = period; }
Example #7
Source File: ConfigurableMarkerEventSource.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
private @NonNull RGBA getColor(Marker marker) { RGBA color = fColors.get(marker); if (color == null) { color = parseColor(marker.getColor()); fColors.put(marker, color); } return color; }
Example #8
Source File: ConfigurableMarkerEventSourceTest.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
private static void validateMarker(IMarkerEvent marker, long time, long duration, String category, String label, RGBA color) { assertEquals(time, marker.getTime()); assertEquals(duration, marker.getDuration()); assertEquals(category, marker.getCategory()); assertEquals(label, marker.getLabel()); assertEquals(color, marker.getColor()); assertEquals(false, marker.isForeground()); }
Example #9
Source File: TmfCommonXAxisChartViewer.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
private @NonNull ISeries<?> createDimmedSeriesFromModel(ISeriesModel yModel) { ISeriesSet seriesSet = getSwtChart().getSeriesSet(); String seriesName = yModel.getName() + DIMMED_SERIES_SUFFIX; OutputElementStyle appearance = getSeriesStyle(yModel.getId()); BaseXYPresentationProvider presProvider = getPresentationProvider(); String type = (String) presProvider.getStyleOrDefault(appearance, StyleProperties.SERIES_TYPE, StyleProperties.SeriesType.LINE); RGBAColor rgbaColor = presProvider.getColorStyleOrDefault(appearance, StyleProperties.COLOR, DEFAULT_COLOR); float[] rgb = rgbaColor.getHSBA(); COLOR_REGISTRY.put(rgb.toString(), new RGBA(rgb[0], rgb[1] * 0.5f, rgb[2] * 0.5f, rgb[3]).rgb); Color color = COLOR_REGISTRY.get(rgb.toString()); String symbolType = (String) presProvider.getStyle(appearance, StyleProperties.SYMBOL_TYPE); if (type.equals(IYAppearance.Type.BAR)) { IBarSeries<?> barSeries = (IBarSeries<?>) seriesSet.createSeries(SeriesType.BAR, seriesName); barSeries.setBarColor(color); barSeries.setBarPadding(0); barSeries.setVisible(true); return barSeries; } /** * Default is line chart */ ILineSeries<?> lineSeries = (ILineSeries<?>) seriesSet.createSeries(SeriesType.LINE, seriesName); lineSeries.enableArea(StyleProperties.SeriesType.AREA.equals(type)); lineSeries.setLineStyle(LineStyle.valueOf((String) presProvider.getStyle(appearance, StyleProperties.SERIES_STYLE))); lineSeries.setSymbolType(SYMBOL_MAP.getOrDefault(symbolType, ILineSeries.PlotSymbolType.NONE)); lineSeries.setLineColor(color); lineSeries.setSymbolColor(color); lineSeries.setVisible(true); lineSeries.setLineWidth(((Number) presProvider.getFloatStyleOrDefault(appearance, StyleProperties.WIDTH, 1.0f)).intValue()); return lineSeries; }
Example #10
Source File: PeriodicMarkerEventSource.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
@Override public List<IMarkerEvent> getMarkerList(String category, long startTime, long endTime, long resolution, IProgressMonitor monitor) { if (startTime > endTime) { return Collections.emptyList(); } List<IMarkerEvent> markers = new ArrayList<>(); /* Subtract 1.5 periods to ensure previous marker is included */ long time = startTime - Math.max(Math.round(1.5 * fPeriod), resolution); Reference reference = adjustReference(fReference, time); IMarkerEvent markerEvent = null; while (true) { long index = Math.round((time - reference.time) / fPeriod) + reference.index; time = Math.round((index - reference.index) * fPeriod) + reference.time; long duration = (fColor2 == null) ? 0 : Math.round((index + 1 - reference.index) * fPeriod) + reference.time - time; long labelIndex = index; if (fRollover != 0) { labelIndex %= fRollover; if (labelIndex < 0) { labelIndex += fRollover; } } /* Add previous marker if current is visible */ if ((time >= startTime || time + duration > startTime) && markerEvent != null) { markers.add(markerEvent); } if (isApplicable(labelIndex)) { RGBA color = (fColor2 == null) ? fColor1 : (index % 2 == 0) ? fColor1 : fColor2; markerEvent = new MarkerEvent(null, time, duration, fCategory, color, getMarkerLabel(labelIndex), fForeground); } else { markerEvent = null; } if (time > endTime) { if (markerEvent != null) { /* The next marker out of range is included */ markers.add(markerEvent); } break; } time += Math.max(Math.round(fPeriod), resolution); } return markers; }
Example #11
Source File: Colors.java From olca-app with Mozilla Public License 2.0 | 4 votes |
public static Color get(int r, int g, int b, int a) { return get(new RGBA(r, g, b, a)); }
Example #12
Source File: Colors.java From olca-app with Mozilla Public License 2.0 | 4 votes |
public static Color get(RGB rgb) { RGBA rgba = new RGBA(rgb.red, rgb.green, rgb.blue, 255); return get(rgba); }
Example #13
Source File: Colors.java From olca-app with Mozilla Public License 2.0 | 4 votes |
public static Color get(int r, int g, int b) { return get(new RGBA(r, g, b, 255)); }
Example #14
Source File: TabbedPropertyTitle.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
public void setColor(String key, RGBA color) { this.factory.getColors().createColor(key, color.rgb); }
Example #15
Source File: ConfigurableMarkerEventSource.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
private static @NonNull RGBA getOddColor(RGBA color) { return new RGBA(color.rgb.red, color.rgb.green, color.rgb.blue, 0); }
Example #16
Source File: MarkerEvent.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
@Override public RGBA getColor() { return fColor; }
Example #17
Source File: MarkerEvent.java From tracecompass with Eclipse Public License 2.0 | 3 votes |
/** * Constructor * * @param annotation * {@link IAnnotation} that represent this marker event * @param entry * The entry to which this marker event is assigned * @param category * The category of the marker * @param foreground * true if the marker is drawn in foreground, and false otherwise * @since 5.2 */ public MarkerEvent(IAnnotation annotation, ITimeGraphEntry entry, String category, boolean foreground) { super(entry, annotation); fCategory = category; fLabel = annotation.getLabel(); fColor = new RGBA(0, 0, 0, 255); fForeground = foreground; }
Example #18
Source File: MarkerEvent.java From tracecompass with Eclipse Public License 2.0 | 3 votes |
/** * Standard constructor * * @param entry * The entry of the marker, or null * @param time * The timestamp of this marker * @param duration * The duration of the marker * @param category * The category of the marker * @param color * The marker color * @param label * The label of the marker, or null * @param foreground * true if the marker is drawn in foreground, and false otherwise */ public MarkerEvent(ITimeGraphEntry entry, long time, long duration, String category, RGBA color, String label, boolean foreground) { super(entry, time, duration); fCategory = category; fColor = color; fLabel = label; fForeground = foreground; }
Example #19
Source File: MarkerEvent.java From tracecompass with Eclipse Public License 2.0 | 3 votes |
/** * Constructor * * @param entry * The entry of the marker, or null * @param time * The timestamp of this marker * @param duration * The duration of the marker * @param category * The category of the marker * @param color * The marker color * @param label * The label of the marker, or null * @param foreground * true if the marker is drawn in foreground, and false otherwise * @param value * The value of the marker */ public MarkerEvent(ITimeGraphEntry entry, long time, long duration, String category, RGBA color, String label, boolean foreground, int value) { super(entry, time, duration, value); fCategory = category; fColor = color; fLabel = label; fForeground = foreground; }
Example #20
Source File: RGBAUtil.java From tracecompass with Eclipse Public License 2.0 | 2 votes |
/** * Convert to an integer from a RGBA * * @param value * the RGBA * @return the integer encoded RGBA */ public static int fromRGBA(RGBA value) { RGB rgb = value.rgb; return (rgb.red << 24) | (rgb.green << 16) | (rgb.blue << 8) | value.alpha; }
Example #21
Source File: RGBAUtil.java From tracecompass with Eclipse Public License 2.0 | 2 votes |
/** * Convert from an RGBAColor to an RGBA, useful for dealing with palettes. * * @param color The {@link RGBAColor} * @return an {@link RGBA} */ public static RGBA fromRGBAColor(RGBAColor color) { return fromInt(color.toInt()); }
Example #22
Source File: IMarkerEvent.java From tracecompass with Eclipse Public License 2.0 | 2 votes |
/** * Get this marker's color. * * @return The color */ RGBA getColor();
Example #23
Source File: RGBAUtil.java From tracecompass with Eclipse Public License 2.0 | 2 votes |
/** * Convert to an RGBA from an integer * * @param value * the integer encoded RGBA * @return the RGBA */ public static RGBA fromInt(int value) { return new RGBA((value >> 24) & 0xff, (value >> 16) & 0xff, (value >>> 8) & 0xff, value & 0xff); }
Example #24
Source File: PeriodicMarkerEventSource.java From tracecompass with Eclipse Public License 2.0 | 2 votes |
/** * Constructs a periodic marker event source with alternating shading * markers. * <p> * The markers will have the given category. Periods will be shaded with the * first and second colors alternatively. The reference defines the marker * with the given index to be at the specified time. The reference will be * shaded with the first color if its index is even, or the second color * if it is odd. * * @param category * the marker category * @param reference * the reference marker time and index * @param period * the period in time units * @param rollover * the number of periods before the index rolls-over to 0, or 0 * for no roll-over * @param color1 * the first marker color * @param color2 * the second marker color * @param foreground * true if the marker is drawn in foreground, and false otherwise */ public PeriodicMarkerEventSource(String category, Reference reference, double period, long rollover, RGBA color1, RGBA color2, boolean foreground) { this(category, reference, period, rollover, foreground, color1, color2); }
Example #25
Source File: PeriodicMarkerEventSource.java From tracecompass with Eclipse Public License 2.0 | 2 votes |
/** * Constructs a periodic marker event source with line markers at period * boundaries. * <p> * The markers will have the given category and color. The reference defines * the marker with the given index to be at the specified time. * * @param category * the marker category * @param reference * the reference marker time and index * @param period * the period in time units * @param rollover * the number of periods before the index rolls-over to 0, or 0 * for no roll-over * @param color * the marker color * @param foreground * true if the marker is drawn in foreground, and false otherwise */ public PeriodicMarkerEventSource(String category, Reference reference, double period, long rollover, RGBA color, boolean foreground) { this(category, reference, period, rollover, foreground, color, null); }
Example #26
Source File: AddBookmarkDialog.java From tracecompass with Eclipse Public License 2.0 | 2 votes |
/** * Returns the color selected in this dialog. * * @return the color RGBA value */ public RGBA getColorValue() { RGB rgb = fColorSelector.getColorValue(); return new RGBA(rgb.red, rgb.green, rgb.blue, fAlpha); }
Example #27
Source File: TimeGraphColorScheme.java From tracecompass with Eclipse Public License 2.0 | 2 votes |
/** * Get a color resource for the specified RGBA color descriptor * * @param rgba * the color descriptor * @return a color resource * @since 2.0 */ public Color getColor(RGBA rgba) { return fColorMap.computeIfAbsent(rgba, colorRgba -> new Color(Display.getDefault(), colorRgba)); }