mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java, compilation-charts] shade-filtered modules IDEA-363131
GitOrigin-RevId: a88ad26148d10a31a86dea23e7e1d85b0624180d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
872f71bebd
commit
e348bfef3c
@@ -5,6 +5,9 @@ import com.intellij.ide.nls.NlsMessages
|
||||
import com.intellij.java.compiler.charts.CompilationChartsViewModel.Filter
|
||||
import com.intellij.java.compiler.charts.CompilationChartsViewModel.Modules.*
|
||||
import com.intellij.java.compiler.charts.CompilationChartsViewModel.StatisticData
|
||||
import com.intellij.java.compiler.charts.ui.Colors.FILTERED_ALPHA
|
||||
import com.intellij.java.compiler.charts.ui.Colors.NO_ALPHA
|
||||
import com.intellij.java.compiler.charts.ui.Settings.Block.MIN_SIZE
|
||||
import com.intellij.openapi.util.text.Formats
|
||||
import com.intellij.ui.JBColor
|
||||
import com.intellij.util.ui.UIUtil
|
||||
@@ -105,13 +108,11 @@ class ChartProgress(private val zoom: Zoom, internal val state: ChartModel, thre
|
||||
) {
|
||||
data.list().forEachIndexed { thread, events ->
|
||||
events.forEach { event ->
|
||||
if (state.filter.test(event.key) &&
|
||||
compareWithViewport(event.start.target.time,
|
||||
if (compareWithViewport(event.start.target.time,
|
||||
event.finish?.target?.time,
|
||||
settings, zoom, bracket) == 0 &&
|
||||
!isSmall(event, state)) {
|
||||
|
||||
|
||||
val rect = getRectangle(event, thread, settings)
|
||||
|
||||
settings.mouse.module(rect, event.key, mutableMapOf(
|
||||
@@ -122,29 +123,37 @@ class ChartProgress(private val zoom: Zoom, internal val state: ChartModel, thre
|
||||
"fileBased" to event.start.target.isFileBased.toString(),
|
||||
))
|
||||
|
||||
withColor(block.color(event.start)) { // module
|
||||
val alpha = if (state.filter.test(event.key)) NO_ALPHA else FILTERED_ALPHA
|
||||
withColor(block.color(event.start).alpha(alpha)) { // module
|
||||
fill(rect)
|
||||
}
|
||||
withColor(if (selected == event.key) block.selected(event.start) else block.outline(event.start)) { // module border
|
||||
withColor(block.color(event, selected).alpha(alpha)) { // module border
|
||||
draw(rect)
|
||||
}
|
||||
create().withColor(settings.font.color) {
|
||||
create().withColor(settings.font.color.alpha(alpha)) {
|
||||
withFont(UIUtil.getLabelFont(settings.font.size)) { // name
|
||||
clip(rect)
|
||||
drawString(" ${event.start.target.name}", rect.x.toFloat(), (rect.y + (height - block.padding * 2) / 2 + fontMetrics().ascent / 2).toFloat())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun ModuleBlock.color(event: ProgressEvent, selected: EventKey?): Color {
|
||||
if (selected == event.key) {
|
||||
return selected(event.start)
|
||||
} else {
|
||||
return outline(event.start)
|
||||
}
|
||||
}
|
||||
|
||||
private fun isSmall(event: ProgressEvent, state: ChartModel): Boolean {
|
||||
val filter = state.filter
|
||||
if (filter is Filter && filter.text.isEmpty()) {
|
||||
val finish = event.finish ?: return false
|
||||
return zoom.toPixels(finish.target.time) - zoom.toPixels(event.start.target.time) < 2
|
||||
return zoom.toPixels(finish.target.time) - zoom.toPixels(event.start.target.time) < MIN_SIZE
|
||||
}
|
||||
else {
|
||||
return false
|
||||
@@ -170,12 +179,12 @@ class ChartProgress(private val zoom: Zoom, internal val state: ChartModel, thre
|
||||
for ((idx, thread) in events.withIndex()) {
|
||||
if (canBeAdded(thread, event)) {
|
||||
thread.add(event)
|
||||
index[event.key] = Pair(idx, thread.size - 1)
|
||||
index[event.key] = idx to thread.size - 1
|
||||
return
|
||||
}
|
||||
}
|
||||
events.add(mutableListOf(event))
|
||||
index[event.key] = Pair(events.size - 1, 0)
|
||||
index[event.key] = events.size - 1 to 0
|
||||
threadAddedEvent()
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
package com.intellij.java.compiler.charts.ui
|
||||
|
||||
import com.intellij.icons.AllIcons
|
||||
import com.intellij.ui.ColorUtil
|
||||
import com.intellij.ui.JBColor
|
||||
import com.intellij.ui.table.JBTable
|
||||
import com.intellij.util.ui.UIUtil.FontSize
|
||||
@@ -17,6 +16,9 @@ object Colors {
|
||||
fun getRowColor(row: Int): JBColor = if (row % 2 == 0) EVEN else ODD
|
||||
}
|
||||
|
||||
const val NO_ALPHA = 1.0
|
||||
const val FILTERED_ALPHA = 0.25
|
||||
|
||||
@Suppress("PropertyName")
|
||||
interface Block {
|
||||
val ENABLED: JBColor
|
||||
@@ -63,10 +65,6 @@ object Colors {
|
||||
private fun exact(propertyName: String): JBColor {
|
||||
return JBColor.namedColor(propertyName)
|
||||
}
|
||||
|
||||
private fun JBColor.alpha(alpha: Double): JBColor {
|
||||
return ColorUtil.withAlpha(this, alpha) as JBColor
|
||||
}
|
||||
}
|
||||
|
||||
object Settings {
|
||||
@@ -74,6 +72,7 @@ object Settings {
|
||||
const val PADDING: Double = 1.0
|
||||
const val BORDER: Double = 2.0
|
||||
val HEIGHT = JBTable().rowHeight * 1.5
|
||||
const val MIN_SIZE = 7
|
||||
}
|
||||
|
||||
object Axis {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.compiler.charts.ui
|
||||
|
||||
import com.intellij.ui.ColorUtil
|
||||
import com.intellij.util.JBHiDPIScaledImage
|
||||
import java.awt.Color
|
||||
import java.awt.geom.Path2D
|
||||
import java.awt.geom.Rectangle2D
|
||||
import java.awt.image.BufferedImage
|
||||
@@ -90,4 +92,8 @@ internal fun compareWithViewport(startTime: Long, finishTime: Long?, settings: C
|
||||
val finishPixel = zoom.toPixels(finishTime - settings.duration.from)
|
||||
if (finishPixel < x0) return -1
|
||||
return 0
|
||||
}
|
||||
|
||||
fun Color.alpha(alpha: Double): Color {
|
||||
return ColorUtil.withAlpha(this, alpha)
|
||||
}
|
||||
Reference in New Issue
Block a user