Skip to content

Commit

Permalink
tmf: Fix default Eclipse formatting for these two
Browse files Browse the repository at this point in the history
Fix the default Eclipse formatting for these files, while preserving
(slightly amending) some one-liner comments. Reformat namely
TmfCommonXAxisChartViewer and AbstractStateSystemTimeGraphView.

Change-Id: I56157cabf25206cc1cb97a78bb3a3c08f044e969
Signed-off-by: Marco Miller <marco.miller@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass/org.eclipse.tracecompass/+/201569
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
  • Loading branch information
marco-miller committed Apr 28, 2023
1 parent 7bd87f5 commit 17e409b
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ public abstract class TmfCommonXAxisChartViewer extends TmfXYChartViewer {
* Constructor
*
* @param parent
* The parent composite
* The parent composite
* @param settings
* See {@link TmfXYChartSettings} to know what it contains
* See {@link TmfXYChartSettings} to know what it contains
*/
public TmfCommonXAxisChartViewer(Composite parent, TmfXYChartSettings settings) {
super(parent, settings.getTitle(), settings.getXLabel(), settings.getYLabel());
Expand Down Expand Up @@ -204,9 +204,9 @@ public boolean isDirty() {
* Force the number of points to a fixed value
*
* @param nbPoints
* The number of points to display, cannot be negative. 0
* means use native resolution. any positive integer means
* that number of points
* The number of points to display, cannot be negative. 0 means
* use native resolution. any positive integer means that number
* of points
*/
public synchronized void setNbPoints(int nbPoints) {
if (nbPoints < 0) {
Expand All @@ -220,7 +220,7 @@ public synchronized void setNbPoints(int nbPoints) {
* Initialize the data provider of this viewer
*
* @param trace
* The trace
* The trace
* @return the data provider
*/
protected abstract ITmfXYDataProvider initializeDataProvider(@NonNull ITmfTrace trace);
Expand Down Expand Up @@ -270,9 +270,9 @@ public BaseXYPresentationProvider getPresentationProvider() {
}

/**
* Cancels the currently running update thread. It is automatically called when
* the content is updated, but child viewers may want to call it manually to do
* some operations before calling
* Cancels the currently running update thread. It is automatically called
* when the content is updated, but child viewers may want to call it
* manually to do some operations before calling
* {@link TmfCommonXAxisChartViewer#updateContent}
*/
protected synchronized void cancelUpdate() {
Expand All @@ -290,8 +290,8 @@ protected void updateContent() {
cancelUpdate();
try (FlowScopeLog parentScope = new FlowScopeLogBuilder(LOGGER, Level.FINE, "CommonXLineChart:ContentUpdateRequested").setCategory(getViewerId()).build()) { //$NON-NLS-1$
/*
* Content is not up to date, so we increment fDirty. It will be decremented at
* the end of the update thread
* Content is not up to date, so we increment fDirty. It will be
* decremented at the end of the update thread
*/
fDirty.incrementAndGet();
getDisplay().asyncExec(() -> {
Expand Down Expand Up @@ -350,8 +350,8 @@ public void run() {
updateData(dataProvider, parameters, fMonitor);
} finally {
/*
* fDirty should have been incremented before creating the thread, so we
* decrement it once it is finished
* fDirty should have been incremented before creating the
* thread, so we decrement it once it is finished
*/
if (fDirty.decrementAndGet() < 0) {
Activator.getDefault().logError(DIRTY_UNDERFLOW_ERROR, new Throwable());
Expand All @@ -368,15 +368,15 @@ public void cancel() {

/**
* This method is responsible for calling the
* {@link UpdateThread#updateDisplay(ITmfCommonXAxisModel)} when needed for the
* new values to be displayed.
* {@link UpdateThread#updateDisplay(ITmfCommonXAxisModel)} when needed
* for the new values to be displayed.
*
* @param dataProvider
* A data provider
* A data provider
* @param parameters
* A query filter
* A query filter
* @param monitor
* A monitor for canceling task
* A monitor for canceling task
*/
private void updateData(@NonNull ITmfXYDataProvider dataProvider, @NonNull Map<String, Object> parameters, IProgressMonitor monitor) {
boolean isComplete = false;
Expand All @@ -389,23 +389,25 @@ private void updateData(@NonNull ITmfXYDataProvider dataProvider, @NonNull Map<S

ITmfResponse.Status status = response.getStatus();
if (status == ITmfResponse.Status.COMPLETED) {
/* Model is complete, no need to request again the data provider */
/*
* Model complete, no need to query the data provider again
*/
isComplete = true;
} else if (status == ITmfResponse.Status.FAILED || status == ITmfResponse.Status.CANCELLED) {
/* Error occurred, log and return */
TraceCompassLogUtils.traceInstant(LOGGER, Level.WARNING, response.getStatusMessage());
isComplete = true;
} else {
/**
* Status is RUNNING. Sleeping current thread to wait before request data
* provider again
* Status is RUNNING. Sleeping current thread to wait before
* request data provider again
**/
try {
Thread.sleep(BUILD_UPDATE_TIMEOUT);
} catch (InterruptedException e) {
/**
* InterruptedException is throw by Thread.Sleep and we should retry querying
* the data provider
* InterruptedException is throw by Thread.Sleep and we
* should retry querying the data provider
**/
TraceCompassLogUtils.traceInstant(LOGGER, Level.INFO, e.getMessage());
Thread.currentThread().interrupt();
Expand All @@ -414,7 +416,6 @@ private void updateData(@NonNull ITmfXYDataProvider dataProvider, @NonNull Map<S
} while (!isComplete);
}


/**
* Update the chart's values before refreshing the viewer
*/
Expand Down Expand Up @@ -454,7 +455,8 @@ private void updateDisplay(ITmfXyModel model, IProgressMonitor monitor) {
for (int i = 0; i < extractXValuesToDisplay.length; i++) {
double value = data[i];
/*
* Find the minimal and maximum values in this series
* Find the minimal and maximum values in
* this series
*/
maxy = Math.max(maxy, value);
miny = Math.min(miny, value);
Expand Down Expand Up @@ -527,7 +529,7 @@ private void updateDisplay(ITmfXyModel model, IProgressMonitor monitor) {
delta = 1;
}
getSwtChart().getPlotArea().removeCustomPaintListener(NO_DATA);
if(seriesValues.getSeriesData().isEmpty()) {
if (seriesValues.getSeriesData().isEmpty()) {
getSwtChart().getPlotArea().addCustomPaintListener(NO_DATA);
}
// Set the formatters for the axis
Expand All @@ -541,7 +543,8 @@ private void updateDisplay(ITmfXyModel model, IProgressMonitor monitor) {
axisSet.getYAxis(0).getTick().setFormat(DataTypeUtils.getFormat(yAxisDescription.getDataType(), yAxisDescription.getUnit()));
}
ITitle title = axisSet.getYAxis(0).getTitle();
// Set the Y title if it was not previously set (ie it is invisible)
// Set the Y title if it was not previously set (ie
// it is invisible)
if (!title.isVisible()) {
title.setText(yAxisDescription.getLabel());
title.setVisible(true);
Expand All @@ -560,8 +563,9 @@ private void updateDisplay(ITmfXyModel model, IProgressMonitor monitor) {
getSwtChart().redraw();
if (isSendTimeAlignSignals()) {
/*
* The width of the chart might have changed and its time axis might be
* misaligned with the other views
* The width of the chart might have changed and its
* time axis might be misaligned with the other
* views
*/
Composite parent = TmfCommonXAxisChartViewer.this.getParent();
if (parent == null || parent.getParent() == null) {
Expand All @@ -585,8 +589,9 @@ private void updateDisplay(ITmfXyModel model, IProgressMonitor monitor) {
}

/**
* Since the XY Model returned by data provider contains directly the requested
* time as long array, we need to convert it to double array for the SWT Chart.
* Since the XY Model returned by data provider contains directly the
* requested time as long array, we need to convert it to double array
* for the SWT Chart.
*/
private double[] extractXValuesToDisplay(long[] xValuesRequested) {
double[] xValuesToDisplay = new double[xValuesRequested.length];
Expand Down Expand Up @@ -714,16 +719,16 @@ public void traceClosed(@Nullable TmfTraceClosedSignal signal) {
* Set or remove the global regex filter value
*
* @param signal
* the signal carrying the regex value
* the signal carrying the regex value
*/
@TmfSignalHandler
public void regexFilterApplied(TmfFilterAppliedSignal signal) {
updateContent();
}

/**
* This method build the multimap of regexes by property that will be used to
* filter the timegraph states
* This method build the multimap of regexes by property that will be used
* to filter the timegraph states
*
* Override this method to add other regexes with their properties. The data
* provider should handle everything after.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ private void zoomByTime(final ITmfStateSystem ss, final List<TimeGraphEntry> ent
@NonNull Map<@NonNull Integer, @NonNull Predicate<@NonNull Multimap<@NonNull String, @NonNull Object>>> predicates = generateRegexPredicate();
Sampling sampling = new Sampling(getZoomStartTime(), getZoomEndTime(), predicates, getResolution());
Iterable<@NonNull TimeGraphEntry> incorrectSample = Iterables.filter(fVisibleEntries, entry -> !sampling.equals(entry.getSampling()));
/* Only keep entries that are a member or child of the ss entry list */
/*
* Only keep entries that are a member or child of the ss entry list
*/
Iterable<@NonNull TimeGraphEntry> entries = Iterables.filter(incorrectSample, entry -> isMember(entry, entryList));
// set gaps to null when there is no active filter
Map<TimeGraphEntry, List<ITimeEvent>> gaps = isFilterActive ? new HashMap<>() : null;
Expand Down Expand Up @@ -253,7 +255,7 @@ private void zoom(@NonNull TimeGraphEntry entry, ITmfStateSystem ss, @NonNull Li
doFilterEventList(entry, eventList, predicates);
applyResults(() -> {
for (ITimeEvent event : eventList) {
entry.addZoomedEvent(event);
entry.addZoomedEvent(event);
}
});
}
Expand All @@ -266,10 +268,10 @@ private void doBgSearch(ITmfStateSystem ss, int resolution, @NonNull IProgressMo
ViewFilterDialog timeEventFilterDialog = getViewFilterDialog();
boolean hasActiveSavedFilters = timeEventFilterDialog.hasActiveSavedFilters();

//Regroup the gaps by overlapping gaps
// Regroup the gaps by overlapping gaps
Table<ITimeGraphEntry, @NonNull Pair<Long, Long>, List<ITimeEvent>> gapsTable = regroupOverlappingGaps(gaps);

//Get the quarks per entry once
// Get the quarks per entry once
Map<ITimeGraphEntry, Collection<Integer>> quarksPerEntry = new HashMap<>();
for (ITimeGraphEntry entry : gapsTable.rowKeySet()) {
Collection<Integer> quarks = getQuarksForEntry(entry, ss);
Expand All @@ -280,7 +282,7 @@ private void doBgSearch(ITmfStateSystem ss, int resolution, @NonNull IProgressMo
Map<ITimeGraphEntry, List<ITimeEvent>> row = tableEntry.getValue();
List<Integer> quarks = new ArrayList<>();

//Get the need quarks for this slot
// Get the need quarks for this slot
for (ITimeGraphEntry entry : row.keySet()) {
Collection<Integer> entryQuarks = quarksPerEntry.get(entry);
if (entryQuarks != null) {
Expand All @@ -302,18 +304,19 @@ private void doBgSearch(ITmfStateSystem ss, int resolution, @NonNull IProgressMo
if (pos >= 0) {
ITimeEvent gap = gapEvents.get(pos);
if (!monitor.isCanceled()) {
// if any underlying event is not dimmed,
// then set the related gap event dimmed
// property to false
// if any underlying event is not
// dimmed, then set the related gap
// event dimmed property to false
boolean dimmed = gap.isPropertyActive(CoreFilterProperty.DIMMED);
if (dimmed && !event.isPropertyActive(CoreFilterProperty.DIMMED)) {
gap.setProperty(CoreFilterProperty.DIMMED, false);
}

// if any underlying event is not excluded,
// then set the related gap event exclude
// status property to false and add the gap
// back to the zoom event list
// if any underlying event is not
// excluded, then set the related
// gap event exclude status property
// to false and add the gap back to
// the zoom event list
if (hasActiveSavedFilters && !event.isPropertyActive(CoreFilterProperty.EXCLUDE)) {
gap.setProperty(CoreFilterProperty.EXCLUDE, false);
applyResults(() -> {
Expand Down Expand Up @@ -372,7 +375,7 @@ private boolean isMember(TimeGraphEntry entry, List<TimeGraphEntry> ssEntryList)
PriorityQueue<ITimeEvent> queue = new PriorityQueue<>(TIME_EVENT_COMPARATOR);
gapsMap.values().forEach(events -> queue.addAll(events));
Pair<Long, Long> previous = null;
while(!queue.isEmpty()) {
while (!queue.isEmpty()) {
ITimeEvent event = Objects.requireNonNull(queue.poll());

ITimeGraphEntry entry = event.getEntry();
Expand Down Expand Up @@ -451,7 +454,7 @@ public AbstractStateSystemTimeGraphView(String id, TimeGraphPresentationProvider
* @since 4.3
*/
protected void getEnventListGaps(@NonNull TimeGraphEntry entry, List<ITimeEvent> eventList, Map<TimeGraphEntry, List<ITimeEvent>> gaps) {
// Do nothing here. Must be implemented by subclasses that need this behavior
// Do nothing. Must be implemented by subclasses that need this behavior
}

/**
Expand Down Expand Up @@ -602,7 +605,10 @@ protected void removeFromEntryList(ITmfTrace trace, ITmfStateSystem ss, List<Tim
protected void queryFullStates(ITmfStateSystem ss, long start, long end, long resolution,
@NonNull IProgressMonitor monitor, @NonNull IQueryHandler handler) {
if (end < start) {
/* We have an empty trace, the state system will be empty: nothing to do here. */
/*
* We have an empty trace, the state system will be empty: nothing
* to do here.
*/
return;
}
List<List<ITmfStateInterval>> fullStates = new ArrayList<>();
Expand Down Expand Up @@ -726,7 +732,7 @@ private static List<ITmfStateInterval> getFullStateForTime(long time, @NonNull M
int index = Objects.requireNonNull(ptr.get(key));

ITmfStateInterval interval = Objects.requireNonNull(intervals.get(index));
while(!isBounded(time, interval) && ++index < intervals.size()) {
while (!isBounded(time, interval) && ++index < intervals.size()) {
interval = Objects.requireNonNull(intervals.get(index));
ptr.put(key, index);
}
Expand Down

0 comments on commit 17e409b

Please sign in to comment.