Import views plugins
[deliverable/tracecompass.git] / tmf / org.lttng.scope.tmf2.views.ui / src / org / lttng / scope / tmf2 / views / ui / timeline / DebugOptions.java
1 /*
2 * Copyright (C) 2017 EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com>
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 */
9
10 package org.lttng.scope.tmf2.views.ui.timeline;
11
12 import static java.util.Objects.requireNonNull;
13
14 import org.lttng.scope.tmf2.views.core.config.ConfigOption;
15 import org.lttng.scope.tmf2.views.ui.timeline.widgets.timegraph.TimeGraphWidget;
16
17 import javafx.scene.paint.Color;
18 import javafx.scene.paint.CycleMethod;
19 import javafx.scene.paint.LinearGradient;
20 import javafx.scene.paint.Paint;
21 import javafx.scene.paint.Stop;
22 import javafx.scene.text.Font;
23 import javafx.scene.text.Text;
24
25 /**
26 * Debug options for the {@link TimeGraphWidget}. Advanced users or unit
27 * tests might want to modify these.
28 *
29 * @author Alexandre Montplaisir
30 */
31 public class DebugOptions {
32
33 /**
34 * Constructor using the default options
35 */
36 public DebugOptions() {
37 recomputeEllipsisWidth();
38 }
39
40 // ------------------------------------------------------------------------
41 // General options
42 // ------------------------------------------------------------------------
43
44 /**
45 * Painting flag. Indicates if automatic redrawing of the view is enabled
46 */
47 public final ConfigOption<Boolean> isPaintingEnabled = new ConfigOption<>(true);
48
49 /**
50 * Entry padding. Number of tree elements to print above *and* below the
51 * visible range
52 */
53 public final ConfigOption<Integer> entryPadding = new ConfigOption<>(5);
54
55 /**
56 * How much "padding" around the current visible window, on the left and
57 * right, should be pre-rendered. Expressed as a fraction of the current
58 * window (for example, 1.0 would render one "page" on each side).
59 */
60 public final ConfigOption<Double> renderRangePadding = new ConfigOption<>(0.1);
61
62 /**
63 * Time between UI updates, in milliseconds
64 */
65 public final ConfigOption<Integer> uiUpdateDelay = new ConfigOption<>(250);
66
67 /**
68 * Whether the view should respond to vertical or horizontal scrolling
69 * actions.
70 */
71 public final ConfigOption<Boolean> isScrollingListenersEnabled = new ConfigOption<>(true);
72
73 // ------------------------------------------------------------------------
74 // Loading overlay
75 // ------------------------------------------------------------------------
76
77 public final ConfigOption<Boolean> isLoadingOverlayEnabled = new ConfigOption<>(true);
78
79 public final ConfigOption<Color> loadingOverlayColor = new ConfigOption<>(requireNonNull(Color.GRAY));
80
81 public final ConfigOption<Double> loadingOverlayFullOpacity = new ConfigOption<>(0.3);
82 public final ConfigOption<Double> loadingOverlayTransparentOpacity = new ConfigOption<>(0.0);
83
84 public final ConfigOption<Double> loadingOverlayFadeInDuration = new ConfigOption<>(1000.0);
85 public final ConfigOption<Double> loadingOverlayFadeOutDuration = new ConfigOption<>(100.0);
86
87 // ------------------------------------------------------------------------
88 // Zoom animation
89 // ------------------------------------------------------------------------
90
91 /**
92 * The zoom animation duration, which is the amount of milliseconds it takes
93 * to complete the zoom animation (smaller number means a faster animation).
94 */
95 public final ConfigOption<Integer> zoomAnimationDuration = new ConfigOption<>(50);
96
97 /**
98 * Each zoom action (typically, one mouse-scroll == one zoom action) will
99 * increase or decrease the current visible time range by this factor.
100 */
101 public final ConfigOption<Double> zoomStep = new ConfigOption<>(0.08);
102
103 /**
104 * Each zoom action will be centered on the center of the selection if it's
105 * currently visible.
106 */
107 public final ConfigOption<Boolean> zoomPivotOnSelection = new ConfigOption<>(true);
108
109 /**
110 * Each zoom action will be centered on the current mouse position if the
111 * zoom action originates from a mouse event. If zoomPivotOnSelection is
112 * enabled, it has priority.
113 */
114 public final ConfigOption<Boolean> zoomPivotOnMousePosition = new ConfigOption<>(true);
115
116 // ------------------------------------------------------------------------
117 // State rectangles
118 // ------------------------------------------------------------------------
119
120 public final ConfigOption<Double> stateIntervalOpacity = new ConfigOption<>(1.0);
121
122 public final ConfigOption<Paint> multiStatePaint;
123 {
124 Stop[] stops = new Stop[] { new Stop(0, Color.BLACK), new Stop(1, Color.WHITE) };
125 LinearGradient lg = new LinearGradient(0, 0, 0, 1, true, CycleMethod.NO_CYCLE, stops);
126 multiStatePaint = new ConfigOption<>(lg);
127 }
128
129 // ------------------------------------------------------------------------
130 // State labels
131 // ------------------------------------------------------------------------
132
133 public final ConfigOption<Font> stateLabelFont = new ConfigOption<Font>(requireNonNull(new Text().getFont())) {
134 @Override
135 public void set(Font value) {
136 super.set(value);
137 recomputeEllipsisWidth();
138 }
139 };
140
141 public static final String ELLIPSIS_STRING = "..."; //$NON-NLS-1$
142
143 private transient double fEllipsisWidth;
144
145 public double getEllipsisWidth() {
146 return fEllipsisWidth;
147 }
148
149 private synchronized void recomputeEllipsisWidth() {
150 Text text = new Text(ELLIPSIS_STRING);
151 text.setFont(stateLabelFont.get());
152 text.applyCss();
153 fEllipsisWidth = text.getLayoutBounds().getWidth();
154 }
155
156 // ------------------------------------------------------------------------
157 // Tooltips
158 // ------------------------------------------------------------------------
159
160 public final ConfigOption<Font> toolTipFont = new ConfigOption<>(Font.font(14));
161
162 public final ConfigOption<Color> toolTipFontFill = new ConfigOption<>(requireNonNull(Color.WHITE));
163
164 }
This page took 0.035797 seconds and 5 git commands to generate.