diff --git a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/actions/emoji/EmojiAction.kt b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/actions/emoji/EmojiAction.kt index ecbc5ba1..893c7344 100644 --- a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/actions/emoji/EmojiAction.kt +++ b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/actions/emoji/EmojiAction.kt @@ -15,11 +15,11 @@ class EmojiAction : AnAction(), TooltipDescriptionProvider { override fun getActionUpdateThread() = ActionUpdateThread.EDT override fun update(e: AnActionEvent) { - val emoji = GlobalPluginStorage.currentEmotion - e.presentation.icon = emoji.icon + val emotion = GlobalPluginStorage.currentEmotion + e.presentation.icon = emotion.icon // To be able to show the description in several lines e.presentation.text = "" - e.presentation.description = emoji.getRandomAffirmDescription() + e.presentation.description = emotion.randomAffirmDescription super.update(e) } } diff --git a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/actions/emoji/EmojiActionIcons.kt b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/actions/emoji/EmojiActionIcons.kt deleted file mode 100644 index fa29dcff..00000000 --- a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/actions/emoji/EmojiActionIcons.kt +++ /dev/null @@ -1,63 +0,0 @@ -@file:Suppress("MaximumLineLength", "MaxLineLength") - -package org.jetbrains.research.tasktracker.actions.emoji - -import com.intellij.openapi.util.IconLoader - -object EmojiActionIcons { - // Emotions - @JvmField - val defaultIcon = IconLoader.getIcon("/icons/emoji/emotions/sun_with_face.png", javaClass) - - @JvmField - val angryFaceIcon = IconLoader.getIcon("/icons/emoji/emotions/angry_face.png", javaClass) - - @JvmField - val expressionlessFaceIcon = IconLoader.getIcon("/icons/emoji/emotions/expressionless_face.png", javaClass) - - @JvmField - val confoundedFaceIcon = IconLoader.getIcon("/icons/emoji/emotions/confounded_face.png", javaClass) - - @JvmField - val frowningFaceWithOpenMouthIcon = IconLoader.getIcon("/icons/emoji/emotions/frowning_face_with_open_mouth.png", javaClass) - - @JvmField - val smilingFaceWithSmilingEyesIcon = IconLoader.getIcon("/icons/emoji/emotions/smiling_face_with_smiling_eyes.png", javaClass) - - @JvmField - val relievedFaceIcon = IconLoader.getIcon("/icons/emoji/emotions/relieved_face.png", javaClass) - - @JvmField - val pensiveFaceIcon = IconLoader.getIcon("/icons/emoji/emotions/pensive_face.png", javaClass) - - @JvmField - val faceWithOpenMouthIcon = IconLoader.getIcon("/icons/emoji/emotions/face_with_open_mouth.png", javaClass) - - // Modal window - @JvmField - val defaultModalIcon = IconLoader.getIcon("/icons/emoji/modal/sun_with_face.png", javaClass) - - @JvmField - val doveIcon = IconLoader.getIcon("/icons/emoji/modal/dove.png", javaClass) - - @JvmField - val foldedHandsIcon = IconLoader.getIcon("/icons/emoji/modal/folded_hands.png", javaClass) - - @JvmField - val cherryBlossomIcon = IconLoader.getIcon("/icons/emoji/modal/cherry_blossom.png", javaClass) - - @JvmField - val leafFlutteringIcon = IconLoader.getIcon("/icons/emoji/modal/leaf_fluttering.png", javaClass) - - @JvmField - val glowingStarIcon = IconLoader.getIcon("/icons/emoji/modal/glowing_star.png", javaClass) - - @JvmField - val seedlingIcon = IconLoader.getIcon("/icons/emoji/modal/seedling.png", javaClass) - - @JvmField - val waterWaveIcon = IconLoader.getIcon("/icons/emoji/modal/water_wave.png", javaClass) - - @JvmField - val wrappedGiftIcon = IconLoader.getIcon("/icons/emoji/modal/wrapped_gift.png", javaClass) -} diff --git a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/actions/emoji/EmojiDialogWrapper.kt b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/actions/emoji/EmojiDialogWrapper.kt index e5d740ba..5e48a096 100644 --- a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/actions/emoji/EmojiDialogWrapper.kt +++ b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/actions/emoji/EmojiDialogWrapper.kt @@ -1,11 +1,12 @@ package org.jetbrains.research.tasktracker.actions.emoji import org.jetbrains.research.tasktracker.actions.BaseWrapper -import javax.swing.* +import org.jetbrains.research.tasktracker.config.emoji.Emotion +import javax.swing.Icon -class EmojiDialogWrapper(emotion: EmotionType) : BaseWrapper() { +class EmojiDialogWrapper(emotion: Emotion) : BaseWrapper() { override val icon: Icon? = emotion.modalWindowIcon - override val text: String = emotion.getRandomAdviceDescription() + override val text: String = emotion.randomAdviceDescription init { isResizable = false diff --git a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/actions/emoji/EmotionType.kt b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/actions/emoji/EmotionType.kt deleted file mode 100644 index 3eb89cf2..00000000 --- a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/actions/emoji/EmotionType.kt +++ /dev/null @@ -1,163 +0,0 @@ -@file:Suppress("MaximumLineLength", "MaxLineLength", "MagicNumber") - -package org.jetbrains.research.tasktracker.actions.emoji - -import javax.swing.Icon - -enum class EmotionType( - val modelPosition: Int, - private val affirmDescriptions: List, - private val adviceDescriptions: List = emptyList(), - val icon: Icon? = null, - val modalWindowIcon: Icon? = null -) { - DEFAULT( - -1, - listOf("New beginnings bring the promise of unexplored opportunities and the chance to create a brighter future."), - listOf( - "

Here, you’ll find advice on handling your current emotions.

Since you just started, we haven’t tracked your emotions yet.

Please check back later!

" - ), - icon = EmojiActionIcons.defaultIcon, - modalWindowIcon = EmojiActionIcons.defaultModalIcon - ), - NEUTRAL( - 0, - listOf( - "Being neutral allows people to fully experience what's happening now.", - "Recognize that neutral states offer a valuable break from intense emotions.", - "It's okay to embrace moments of calm and tranquility." - ), - listOf( - "

Value emotional stability and balance

as signs of emotional maturity.

", - "

Neutral times can be ideal for setting

and planning future objectives.

", - "

Use neutral moments for mindfulness.

Pay attention to your thoughts, sensations,

and surroundings without judgment.

" - ), - icon = EmojiActionIcons.relievedFaceIcon, - modalWindowIcon = EmojiActionIcons.seedlingIcon - ), - HAPPINESS( - 1, - listOf( - "Even small accomplishments contribute to happiness.", - "Your happiness is a wonderful and valid emotion.", - "You deserve to feel joy." - ), - listOf( - "

Objectively evaluate the situation to

determine if there is a genuine threat.

", - "

Try to reframe your perception of the situation.

What is the worst-case scenario,

and how likely is it to happen?

", - "

Reflect on times when you've overcome similar fears.

Use these experiences as sources of strength and confidence.

" - ), - icon = EmojiActionIcons.smilingFaceWithSmilingEyesIcon, - modalWindowIcon = EmojiActionIcons.glowingStarIcon - ), - SURPRISE( - 2, - listOf( - "Surprises add spice to life and keep things interesting", - "Acknowledging your surprise shows that you're in tune with your environment and open to new experiences.", - "Surprise is a completely natural and spontaneous emotion. It's a sign of your adaptability to unexpected situations." - ), - listOf( - "

View surprises as adventures and avoid making

judgments before experiencing them.

", - "

If the surprise is confusing or unsettling,

ask questions to gain a better understanding.

", - "

In unsettling surprise, take a moment to

collect your thoughts before reacting.

" - ), - icon = EmojiActionIcons.faceWithOpenMouthIcon, - modalWindowIcon = EmojiActionIcons.wrappedGiftIcon - ), - SADNESS( - 3, - listOf( - "This sadness is temporary; brighter moments will come.", - "Your sadness is a valid and natural response to difficult situations.", - "Sadness is a temporary state. It doesn't define your future; it's just a part of your journey." - ), - listOf( - "

Reach out to others for comfort and perspective,

recognizing that you don't have to face sadness alone.

", - "

Treat yourself with kindness and understanding

during moments of sadness.

", - "

Set small, achievable goals for the day.

Accomplishing even minor tasks can boost your mood.

" - ), - icon = EmojiActionIcons.pensiveFaceIcon, - modalWindowIcon = EmojiActionIcons.waterWaveIcon - ), - ANGER( - 4, - listOf( - "You might be angry and going through a tough time right now.", - "It's okay to feel angry right now.", - "Feeling angry is a sign that you care about something." - ), - listOf( - "

Inhale deeply and exhale slowly to

calm your anger and regain control.

", - "

Take a deep breath and think about whether

this situation is worth getting so upset about.

", - "

Take a step back, assess the situation objectively,

and consider whether there's a different way to interpret it.

" - ), - icon = EmojiActionIcons.angryFaceIcon, - modalWindowIcon = EmojiActionIcons.doveIcon - ), - DISGUST( - 5, - listOf( - "Disgust is a natural emotion, but it doesn't have to control you.", - "Pay attention to your bodily sensations and thoughts related to disgust without judgment.", - "Feeling disgust is a natural human response." - ), - listOf( - "

Identify the specific aspect of the situation

causing disgust to gain clarity.

", - "

Engage in an activity or focus your attention on

something else to divert your thoughts away

from the source of disgust.

", - "

If possible, remove yourself from the source of disgust

or minimize exposure to it. Creating physical distance can help

reduce the intensity of the emotion.

" - ), - icon = EmojiActionIcons.confoundedFaceIcon, - modalWindowIcon = EmojiActionIcons.cherryBlossomIcon - ), - FEAR( - 6, - listOf( - "Many people experience anxiety in similar situations.", - "Fear and anxiety are a natural response to perceived threats. It's okay to feel this way; it's your body's way of keeping you safe.", - "Anxiety is a common human emotion, and you're not alone in experiencing it." - ), - listOf( - "

Objectively evaluate the situation

to determine if there is a genuine threat.

", - "

Try to reframe your perception of the situation.

What is the worst-case scenario,

and how likely is it to happen?

", - "

Reflect on times when you've overcome similar fears.

Use these experiences as sources of strength and confidence.

" - ), - icon = EmojiActionIcons.frowningFaceWithOpenMouthIcon, - modalWindowIcon = EmojiActionIcons.leafFlutteringIcon - ), - CONTEMPT( - 7, - listOf( - "Being open-minded doesn't mean you have to agree and ignore your contempt.", - "Acknowledging your contempt doesn't mean you have to dwell on it.", - "Your feelings of contempt are a part of your emotional landscape, and you have the ability to navigate them wisely." - ), - listOf( - "

Examine your assumptions and gather

more information before passing judgment.

", - "

If the contemptuous situation becomes too heated,

it's okay to take a break from it to

cool off and regain perspective.

", - "

Take a moment to reflect on why you're feeling contempt.

Understanding the source of your contempt is the first step.

" - ), - icon = EmojiActionIcons.expressionlessFaceIcon, - modalWindowIcon = EmojiActionIcons.foldedHandsIcon - ); - - companion object { - fun byModelScore(modelScore: Int): EmotionType { - return when (modelScore) { - 0 -> NEUTRAL - 1 -> HAPPINESS - 2 -> SURPRISE - 3 -> SADNESS - 4 -> ANGER - 5 -> DISGUST - 6 -> FEAR - 7 -> CONTEMPT - else -> DEFAULT - } - } - } - - fun getRandomAffirmDescription() = affirmDescriptions.random() - - fun getRandomAdviceDescription() = adviceDescriptions.random() -} diff --git a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/DefaultConfigsFactory.kt b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/DefaultConfigsFactory.kt index 68f0755a..30761f6f 100644 --- a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/DefaultConfigsFactory.kt +++ b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/DefaultConfigsFactory.kt @@ -5,7 +5,7 @@ import org.jetbrains.research.tasktracker.config.content.FinalPageContentConfig import org.jetbrains.research.tasktracker.config.content.MainPageContentConfig import org.jetbrains.research.tasktracker.config.content.ServerErrorPageConfig import org.jetbrains.research.tasktracker.config.content.TaskContentConfig -import org.jetbrains.research.tasktracker.config.emoji.EmojiConfig +import org.jetbrains.research.tasktracker.config.emoji.EmotionConfig import org.jetbrains.research.tasktracker.config.ide.inspection.InspectionConfig import org.jetbrains.research.tasktracker.config.ide.settings.SettingsConfig import org.jetbrains.research.tasktracker.config.scenario.ScenarioConfig @@ -31,7 +31,7 @@ object DefaultConfigsFactory { FinalPageContentConfig.CONFIG_FILE_PREFIX, ServerErrorPageConfig.CONFIG_FILE_PREFIX, SurveyConfig.CONFIG_FILE_PREFIX, - EmojiConfig.CONFIG_FILE_PREFIX + EmotionConfig.CONFIG_FILE_PREFIX ) fun createDefaultConfigs() { diff --git a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/MainTaskTrackerConfig.kt b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/MainTaskTrackerConfig.kt index e38ff6dd..85034e91 100644 --- a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/MainTaskTrackerConfig.kt +++ b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/MainTaskTrackerConfig.kt @@ -6,7 +6,7 @@ import org.jetbrains.research.tasktracker.config.content.FinalPageContentConfig import org.jetbrains.research.tasktracker.config.content.MainPageContentConfig import org.jetbrains.research.tasktracker.config.content.ServerErrorPageConfig import org.jetbrains.research.tasktracker.config.content.TaskContentConfig -import org.jetbrains.research.tasktracker.config.emoji.EmojiConfig +import org.jetbrains.research.tasktracker.config.emoji.EmotionConfig import org.jetbrains.research.tasktracker.config.ide.MainIdeConfig import org.jetbrains.research.tasktracker.config.scenario.ScenarioConfig import org.jetbrains.research.tasktracker.config.survey.SurveyConfig @@ -31,7 +31,7 @@ data class MainTaskTrackerConfig( var mainPageConfig: MainPageContentConfig? = null, var finalPageConfig: FinalPageContentConfig? = null, var serverErrorPageConfig: ServerErrorPageConfig? = null, - var emojiConfig: EmojiConfig? = null, + var emotionConfig: EmotionConfig? = null, var scenarioConfig: ScenarioConfig? = null, var surveyConfig: SurveyConfig? = null, @@ -46,7 +46,7 @@ data class MainTaskTrackerConfig( mainPageConfig, finalPageConfig, serverErrorPageConfig, - emojiConfig + emotionConfig ) companion object { @@ -60,6 +60,7 @@ data class MainTaskTrackerConfig( private fun File.isConfigFile() = this.extension == "yaml" // TODO: add a builder for server-based properties + @Suppress("LongMethod") fun buildConfig(pluginProperties: PluginProperties, configRoot: File): MainTaskTrackerConfig { val mainConfig = MainTaskTrackerConfig(pluginProperties) @@ -122,9 +123,9 @@ data class MainTaskTrackerConfig( ) } - fileName.startsWith(EmojiConfig.CONFIG_FILE_PREFIX) -> { - mainConfig.emojiConfig = buildBaseConfig( - mainConfig.emojiConfig, configFile, EmojiConfig::buildConfig, logger + fileName.startsWith(EmotionConfig.CONFIG_FILE_PREFIX) -> { + mainConfig.emotionConfig = buildBaseConfig( + mainConfig.emotionConfig, configFile, EmotionConfig::buildConfig, logger ) } } diff --git a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/emoji/DefaultEmotion.kt b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/emoji/DefaultEmotion.kt new file mode 100644 index 00000000..75eaa91e --- /dev/null +++ b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/emoji/DefaultEmotion.kt @@ -0,0 +1,20 @@ +package org.jetbrains.research.tasktracker.config.emoji + +// TODO make 2 config types? +object DefaultEmotion : Emotion( + -1, + "DEFAULT", + listOf("New beginnings bring the promise of unexplored opportunities and the chance to create a brighter future."), + listOf( + buildString { + append("

Here, you’ll find advice on handling your current emotions.

") + append("

Since you just started, we haven’t tracked your emotions yet.

") + append("

Please check back later!

") + } + ) +) { + override val iconName: String + get() = "sun_with_face.png" + override val modalWindowIconName: String + get() = "modal_sun_with_face.png" +} diff --git a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/emoji/Emoji.kt b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/emoji/Emotion.kt similarity index 78% rename from ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/emoji/Emoji.kt rename to ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/emoji/Emotion.kt index 645bf89d..07efe1f9 100644 --- a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/emoji/Emoji.kt +++ b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/emoji/Emotion.kt @@ -6,24 +6,24 @@ import kotlinx.serialization.Transient import javax.swing.Icon @Serializable -data class Emoji( +open class Emotion( val modelPosition: Int, val name: String, private val affirmDescriptions: List, private val adviceDescriptions: List = emptyList() ) { - private val iconName: String? = null - private val modalWindowIconName: String? = null + protected open val iconName: String? = null + protected open val modalWindowIconName: String? = null @Transient - val icon: Icon? = iconName?.let { IconLoader.getIcon(it, Emoji::class.java) } + val icon: Icon? = iconName?.let { IconLoader.getIcon(it, Emotion::class.java) } @Transient - val modalWindowIcon: Icon? = modalWindowIconName?.let { IconLoader.getIcon(it, Emoji::class.java) } + val modalWindowIcon: Icon? = modalWindowIconName?.let { IconLoader.getIcon(it, Emotion::class.java) } val randomAffirmDescription get() = affirmDescriptions.random() val randomAdviceDescription get() = adviceDescriptions.random() -} \ No newline at end of file +} diff --git a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/emoji/EmojiConfig.kt b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/emoji/EmotionConfig.kt similarity index 58% rename from ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/emoji/EmojiConfig.kt rename to ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/emoji/EmotionConfig.kt index 7bef9ef7..bf567579 100644 --- a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/emoji/EmojiConfig.kt +++ b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/emoji/EmotionConfig.kt @@ -4,22 +4,22 @@ import kotlinx.serialization.Serializable import org.jetbrains.research.tasktracker.config.BaseConfig import org.jetbrains.research.tasktracker.config.YamlConfigLoadStrategy import org.jetbrains.research.tasktracker.handler.BaseHandler -import org.jetbrains.research.tasktracker.handler.emoji.EmojiHandler +import org.jetbrains.research.tasktracker.handler.emoji.EmotionHandler import java.io.File @Serializable -data class EmojiConfig( - val emojis: List +data class EmotionConfig( + val emotions: List ) : BaseConfig { override val configName: String - get() = "emoji" + get() = "emotion" - override fun buildHandler(): BaseHandler = EmojiHandler(this) + override fun buildHandler(): BaseHandler = EmotionHandler(this) companion object { - const val CONFIG_FILE_PREFIX: String = "emoji" + const val CONFIG_FILE_PREFIX: String = "emotion" - fun buildConfig(configFile: File): EmojiConfig = + fun buildConfig(configFile: File): EmotionConfig = YamlConfigLoadStrategy.load(configFile.readText(), serializer()) } -} \ No newline at end of file +} diff --git a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/handler/emoji/EmojiHandler.kt b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/handler/emoji/EmotionHandler.kt similarity index 65% rename from ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/handler/emoji/EmojiHandler.kt rename to ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/handler/emoji/EmotionHandler.kt index cb9b14ae..85414f77 100644 --- a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/handler/emoji/EmojiHandler.kt +++ b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/handler/emoji/EmotionHandler.kt @@ -1,12 +1,12 @@ package org.jetbrains.research.tasktracker.handler.emoji import com.intellij.openapi.project.Project -import org.jetbrains.research.tasktracker.config.BaseConfig +import org.jetbrains.research.tasktracker.config.emoji.EmotionConfig import org.jetbrains.research.tasktracker.handler.BaseHandler -class EmojiHandler(override val config: BaseConfig) : BaseHandler { +class EmotionHandler(override val config: EmotionConfig) : BaseHandler { override fun setup(project: Project) { // TODO("Setup emojis according to the config") } -} \ No newline at end of file +} diff --git a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/modelInference/EmoClient.kt b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/modelInference/EmoClient.kt deleted file mode 100644 index 4c447174..00000000 --- a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/modelInference/EmoClient.kt +++ /dev/null @@ -1,55 +0,0 @@ -// -//import io.ktor.client.* -//import io.ktor.client.call.* -//import io.ktor.client.engine.cio.* -//import io.ktor.client.plugins.contentnegotiation.* -//import io.ktor.client.request.* -//import io.ktor.http.* -//import io.ktor.serialization.kotlinx.json.* -//import kotlinx.serialization.Serializable -//import kotlinx.serialization.json.Json -//import org.jetbrains.research.tasktracker.modelInference.EmoPrediction -//import org.jetbrains.research.tasktracker.modelInference.EmoPredictor -//import org.jetbrains.research.tasktracker.modelInference.prepare -//import org.opencv.core.Mat -// -//@Serializable -//data class ImageData(val image: List>) -//class EmoClient(private var serverUrl: String = "http://localhost:5230/predict") : EmoPredictor { -// -// private val client = HttpClient(CIO) { -// install(ContentNegotiation) { -// json( -// Json { -// prettyPrint = true -// isLenient = true -// }, -// ) -// } -// } -// -// override suspend fun predict(image: Mat): EmoPrediction { -// val prepImage = image.prepare() -// -// val imageList = mutableListOf>() -// for (row in 0 until prepImage.rows()) { -// val rowList = mutableListOf() -// for (col in 0 until prepImage.cols()) { -// val pixelValue = prepImage.get(row, col)[0] -// rowList.add(pixelValue) -// } -// imageList.add(rowList) -// } -// -// val imageData = ImageData(imageList) -// -// val response: Map = client.post(serverUrl) { -// contentType(ContentType.Application.Json) -// setBody(imageData) -// }.body() -// -// println("Emotion Probabilities: $response") -// -// return EmoPrediction(response) -// } -//} diff --git a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/modelInference/model/EmoModel.kt b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/modelInference/model/EmoModel.kt index 67ac5f61..ae4be998 100644 --- a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/modelInference/model/EmoModel.kt +++ b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/modelInference/model/EmoModel.kt @@ -43,10 +43,8 @@ class EmoModel : EmoPredictor { return EmoPrediction(probabilities) } - companion object { private const val MODEL_PATH = "emotion-ferplus-18.onnx" private val INPUT_SHAPE = intArrayOf(1, 1, 64, 64) } - } diff --git a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/tracking/logger/WebCamLogger.kt b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/tracking/logger/WebCamLogger.kt index 379c3faa..e6d13726 100644 --- a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/tracking/logger/WebCamLogger.kt +++ b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/tracking/logger/WebCamLogger.kt @@ -1,7 +1,7 @@ package org.jetbrains.research.tasktracker.tracking.logger import com.intellij.openapi.project.Project -import org.jetbrains.research.tasktracker.actions.emoji.EmotionType +import org.jetbrains.research.tasktracker.config.emoji.Emotion import org.jetbrains.research.tasktracker.tracking.webcam.WebCamData import org.joda.time.DateTime @@ -11,7 +11,7 @@ class WebCamLogger(val project: Project) : BaseLogger() { get() = WebcamLoggedData fun log( - emotion: EmotionType, + emotion: Emotion, scores: Map, isRegular: Boolean, date: DateTime = DateTime.now() diff --git a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/tracking/webcam/WebCamData.kt b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/tracking/webcam/WebCamData.kt index 2700035d..d46fa532 100644 --- a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/tracking/webcam/WebCamData.kt +++ b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/tracking/webcam/WebCamData.kt @@ -1,11 +1,11 @@ package org.jetbrains.research.tasktracker.tracking.webcam -import org.jetbrains.research.tasktracker.actions.emoji.EmotionType +import org.jetbrains.research.tasktracker.config.emoji.Emotion import org.joda.time.DateTime data class WebCamData( val time: DateTime, - val emotionShown: EmotionType, + val emotionShown: Emotion, /** * false – when collected because an active window changed, true – when collected on the minute basis */ diff --git a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/tracking/webcam/WebCamUtils.kt b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/tracking/webcam/WebCamUtils.kt index e426aa65..86a01507 100644 --- a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/tracking/webcam/WebCamUtils.kt +++ b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/tracking/webcam/WebCamUtils.kt @@ -2,7 +2,7 @@ package org.jetbrains.research.tasktracker.tracking.webcam import kotlinx.coroutines.runBlocking import nu.pattern.OpenCV -import org.jetbrains.research.tasktracker.actions.emoji.EmotionType +import org.jetbrains.research.tasktracker.TaskTrackerPlugin import org.jetbrains.research.tasktracker.config.MainTaskTrackerConfig import org.jetbrains.research.tasktracker.modelInference.EmoPredictor import org.jetbrains.research.tasktracker.tracking.logger.WebCamLogger @@ -89,7 +89,8 @@ suspend fun Mat.guessEmotionAndLog(emoPredictor: EmoPredictor, webcamLogger: Web val photoDate = DateTime.now() val prediction = emoPredictor.predict(this) val modelScore = prediction.getPrediction() - EmotionType.byModelScore(modelScore).also { + // TODO + TaskTrackerPlugin.mainConfig.emotionConfig!!.emotions.find { it.modelPosition == modelScore }!!.let { webcamLogger.log(it, prediction.probabilities, isRegular, photoDate) GlobalPluginStorage.currentEmotion = it } diff --git a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/ui/main/panel/storage/GlobalPluginStorage.kt b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/ui/main/panel/storage/GlobalPluginStorage.kt index 4c9f0a7f..89f7de15 100644 --- a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/ui/main/panel/storage/GlobalPluginStorage.kt +++ b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/ui/main/panel/storage/GlobalPluginStorage.kt @@ -1,13 +1,14 @@ package org.jetbrains.research.tasktracker.ui.main.panel.storage -import org.jetbrains.research.tasktracker.actions.emoji.EmotionType +import org.jetbrains.research.tasktracker.config.emoji.DefaultEmotion +import org.jetbrains.research.tasktracker.config.emoji.Emotion import org.jetbrains.research.tasktracker.modelInference.EmoPredictor import org.jetbrains.research.tasktracker.tracking.webcam.WebCamInfo object GlobalPluginStorage { val camerasInfo: MutableList = mutableListOf() var currentDeviceNumber: Int? = null - var currentEmotion = EmotionType.DEFAULT + var currentEmotion: Emotion = DefaultEmotion var emoPredictor: EmoPredictor? = null } diff --git a/ijPlugin/src/main/resources/META-INF/plugin.xml b/ijPlugin/src/main/resources/META-INF/plugin.xml index 851ba8cf..e3baf2c8 100644 --- a/ijPlugin/src/main/resources/META-INF/plugin.xml +++ b/ijPlugin/src/main/resources/META-INF/plugin.xml @@ -19,7 +19,7 @@ diff --git a/ijPlugin/src/main/resources/org/jetbrains/research/tasktracker/config/emoji_default.yaml b/ijPlugin/src/main/resources/org/jetbrains/research/tasktracker/config/emotion_default.yaml similarity index 88% rename from ijPlugin/src/main/resources/org/jetbrains/research/tasktracker/config/emoji_default.yaml rename to ijPlugin/src/main/resources/org/jetbrains/research/tasktracker/config/emotion_default.yaml index 45d9aff7..1b4a75d7 100644 --- a/ijPlugin/src/main/resources/org/jetbrains/research/tasktracker/config/emoji_default.yaml +++ b/ijPlugin/src/main/resources/org/jetbrains/research/tasktracker/config/emotion_default.yaml @@ -1,12 +1,12 @@ -emojis: +emotions: - modelPosition: -1 name: "DEFAULT" affirmDescriptions: - "New beginnings bring the promise of unexplored opportunities and the chance to create a brighter future." adviceDescriptions: - "

Here, you’ll find advice on handling your current emotions.

Since you just started, we haven’t tracked your emotions yet.

Please check back later!

" - iconName: "defaultIcon.png" - modalWindowIconName: "defaultModalIcon.png" + iconName: "sun_with_face.png" + modalWindowIconName: "modal_sun_with_face.png" - modelPosition: 0 name: "NEUTRAL" @@ -18,8 +18,8 @@ emojis: - "

Value emotional stability and balance

as signs of emotional maturity.

" - "

Neutral times can be ideal for setting

and planning future objectives.

" - "

Use neutral moments for mindfulness.

Pay attention to your thoughts, sensations,

and surroundings without judgment.

" - iconName: "relievedFaceIcon.png" - modalWindowIconName: "seedlingIcon.png" + iconName: "relieved_face.png" + modalWindowIconName: "modal_seedling.png" - modelPosition: 1 name: "HAPPINESS" @@ -31,8 +31,8 @@ emojis: - "

Objectively evaluate the situation to

determine if there is a genuine threat.

" - "

Try to reframe your perception of the situation.

What is the worst-case scenario,

and how likely is it to happen?

" - "

Reflect on times when you've overcome similar fears.

Use these experiences as sources of strength and confidence.

" - iconName: "smilingFaceWithSmilingEyesIcon.png" - modalWindowIconName: "glowingStarIcon.png" + iconName: "smiling_face_with_smiling_eyes.png" + modalWindowIconName: "modal_glowing_star.png" - modelPosition: 2 name: "SURPRISE" @@ -44,8 +44,8 @@ emojis: - "

View surprises as adventures and avoid making

judgments before experiencing them.

" - "

If the surprise is confusing or unsettling,

ask questions to gain a better understanding.

" - "

In unsettling surprise, take a moment to

collect your thoughts before reacting.

" - iconName: "faceWithOpenMouthIcon.png" - modalWindowIconName: "wrappedGiftIcon.png" + iconName: "face_with_open_mouth.png" + modalWindowIconName: "modal_wrapped_gift.png" - modelPosition: 3 name: "SADNESS" @@ -57,8 +57,8 @@ emojis: - "

Reach out to others for comfort and perspective,

recognizing that you don't have to face sadness alone.

" - "

Treat yourself with kindness and understanding

during moments of sadness.

" - "

Set small, achievable goals for the day.

Accomplishing even minor tasks can boost your mood.

" - iconName: "pensiveFaceIcon.png" - modalWindowIconName: "waterWaveIcon.png" + iconName: "pensive_face.png" + modalWindowIconName: "modal_water_wave.png" - modelPosition: 4 name: "ANGER" @@ -70,8 +70,8 @@ emojis: - "

Inhale deeply and exhale slowly to

calm your anger and regain control.

" - "

Take a deep breath and think about whether

this situation is worth getting so upset about.

" - "

Take a step back, assess the situation objectively,

and consider whether there's a different way to interpret it.

" - iconName: "angryFaceIcon.png" - modalWindowIconName: "doveIcon.png" + iconName: "angry_face.png" + modalWindowIconName: "modal_dove.png" - modelPosition: 5 name: "DISGUST" @@ -83,8 +83,8 @@ emojis: - "

Identify the specific aspect of the situation

causing disgust to gain clarity.

" - "

Engage in an activity or focus your attention on

something else to divert your thoughts away

from the source of disgust.

" - "

If possible, remove yourself from the source of disgust

or minimize exposure to it. Creating physical distance can help

reduce the intensity of the emotion.

" - iconName: "confoundedFaceIcon.png" - modalWindowIconName: "cherryBlossomIcon.png" + iconName: "confounded_face.png" + modalWindowIconName: "modal_cherry_blossom.png" - modelPosition: 6 name: "FEAR" @@ -96,8 +96,8 @@ emojis: - "

Objectively evaluate the situation

to determine if there is a genuine threat.

" - "

Try to reframe your perception of the situation.

What is the worst-case scenario,

and how likely is it to happen?

" - "

Reflect on times when you've overcome similar fears.

Use these experiences as sources of strength and confidence.

" - iconName: "frowningFaceWithOpenMouthIcon.png" - modalWindowIconName: "leafFlutteringIcon.png" + iconName: "frowning_face_with_open_mouth.png" + modalWindowIconName: "modal_leaf_fluttering.png" - modelPosition: 7 name: "CONTEMPT" @@ -109,5 +109,5 @@ emojis: - "

Examine your assumptions and gather

more information before passing judgment.

" - "

If the contemptuous situation becomes too heated,

it's okay to take a break from it to

cool off and regain perspective.

" - "

Take a moment to reflect on why you're feeling contempt.

Understanding the source of your contempt is the first step.

" - iconName: "expressionlessFaceIcon.png" - modalWindowIconName: "foldedHandsIcon.png" + iconName: "expressionless_face.png" + modalWindowIconName: "modal_folded_hands.png"