• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2017 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     https://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package traceviewer.ui.tracks
18 
19 import traceviewer.ui.LayoutConstants
20 import traceviewer.ui.RenderState
21 import trebuchet.model.SchedSlice
22 import trebuchet.model.SchedulingState
23 import java.awt.Color
24 import java.awt.FontMetrics
25 import java.awt.Graphics
26 
27 class SchedTrack(slices: List<SchedSlice>, renderState: RenderState)
28         : SliceTrack<SchedSlice>(slices, renderState, trackHeight = LayoutConstants.SchedTrackHeight) {
29 
colorFornull30     override fun colorFor(slice: SchedSlice): Color {
31         return when (slice.state) {
32             SchedulingState.WAKING,
33             SchedulingState.RUNNABLE -> Runnable
34             SchedulingState.RUNNING -> Running
35             SchedulingState.SLEEPING -> Sleeping
36             else -> UnintrSleep
37         }
38     }
39 
drawLabelnull40     override fun drawLabel(slice: SchedSlice, g: Graphics, metrics: FontMetrics, x: Int, y: Int, width: Int) {
41     }
42 
43     companion object Colors {
44         val Runnable = Color.decode("#03A9F4")
45         val Running = Color.decode("#4CAF50")
46         val Sleeping = Color.decode("#424242")
47         val UnintrSleep = Color.decode("#A71C1C")
48     }
49 }