mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
[pycharm] PY-79603 Debugger: review fixes
GitOrigin-RevId: 811987a3e9fc0a9c34eb5dd34fe712233e8879fe
This commit is contained in:
committed by
intellij-monorepo-bot
parent
72ed1b50a8
commit
662cdcc255
@@ -11,8 +11,9 @@ import org.intellij.images.scientific.BinarizationThresholdConfig
|
||||
import java.awt.BorderLayout
|
||||
import java.awt.Dimension
|
||||
import javax.swing.JComponent
|
||||
import javax.swing.JLabel
|
||||
import javax.swing.JPanel
|
||||
import javax.swing.JTextField
|
||||
import javax.swing.JSlider
|
||||
|
||||
class ConfigureActions : AnAction(
|
||||
ImagesBundle.message("image.color.mode.configure.actions"),
|
||||
@@ -36,12 +37,7 @@ class ConfigureActions : AnAction(
|
||||
}
|
||||
|
||||
private class ThresholdDialogWrapper(project: Project?, initialValue: Int) : DialogWrapper(project) {
|
||||
private val inputField = JTextField(initialValue.toString()).apply {
|
||||
preferredSize = Dimension(150, 10)
|
||||
maximumSize = Dimension(150, 10)
|
||||
minimumSize = Dimension(150, 10)
|
||||
}
|
||||
|
||||
private var sliderValue: Int = initialValue.coerceIn(0, 255)
|
||||
var thresholdValue: Int? = null
|
||||
|
||||
init {
|
||||
@@ -50,24 +46,31 @@ class ConfigureActions : AnAction(
|
||||
}
|
||||
|
||||
override fun createCenterPanel(): JComponent {
|
||||
val panel = JPanel(BorderLayout())
|
||||
panel.add(inputField, BorderLayout.CENTER)
|
||||
return panel
|
||||
val slider = JSlider(0, 255, sliderValue).apply {
|
||||
majorTickSpacing = 50
|
||||
minorTickSpacing = 5
|
||||
paintTicks = true
|
||||
paintLabels = true
|
||||
value = sliderValue
|
||||
addChangeListener { sliderValue = this.value }
|
||||
}
|
||||
val valueLabel = JLabel("$sliderValue").apply {
|
||||
slider.addChangeListener { text = slider.value.toString() }
|
||||
}
|
||||
return JPanel(BorderLayout()).apply {
|
||||
add(slider, BorderLayout.CENTER)
|
||||
add(valueLabel, BorderLayout.SOUTH)
|
||||
preferredSize = Dimension(300, 120)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getPreferredFocusedComponent(): JComponent {
|
||||
return inputField
|
||||
return createCenterPanel()
|
||||
}
|
||||
|
||||
override fun doOKAction() {
|
||||
val value = inputField.text.toIntOrNull()
|
||||
if (value != null && value in 0..255) {
|
||||
thresholdValue = value
|
||||
super.doOKAction()
|
||||
}
|
||||
else {
|
||||
setErrorText(ImagesBundle.message("image.binarize.dialog.invalid"))
|
||||
}
|
||||
thresholdValue = sliderValue
|
||||
super.doOKAction()
|
||||
}
|
||||
|
||||
override fun getInitialSize(): Dimension {
|
||||
|
||||
@@ -44,6 +44,8 @@ def get_bytes(arr):
|
||||
|
||||
if arr_to_convert.ndim == 1:
|
||||
arr_to_convert = np.expand_dims(arr_to_convert, axis=0)
|
||||
elif arr_to_convert.ndim == 3 and arr_to_convert.shape[2] == 1:
|
||||
arr_to_convert = arr_to_convert[:, :, 0]
|
||||
|
||||
arr_min, arr_max = np.min(arr_to_convert), np.max(arr_to_convert)
|
||||
if arr_min == arr_max: # handle constant values
|
||||
|
||||
@@ -25,6 +25,8 @@ def get_bytes(arr):
|
||||
|
||||
if arr_to_convert.ndim == 1:
|
||||
arr_to_convert = np.expand_dims(arr_to_convert, axis=0)
|
||||
elif arr_to_convert.ndim == 3 and arr_to_convert.shape[2] == 1:
|
||||
arr_to_convert = arr_to_convert[:, :, 0]
|
||||
|
||||
arr_min, arr_max = np.min(arr_to_convert), np.max(arr_to_convert)
|
||||
if arr_min == arr_max: # handle constant values
|
||||
|
||||
Reference in New Issue
Block a user