Skip to content

Commit

Permalink
Fixed README
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorFilimonov committed Oct 8, 2024
2 parents b82e220 + 2235480 commit 02f5091
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 95 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ A comprehensive user guide is available in Russian in the [Wiki of this reposito
- Group selection
- Graph pane zooming and scrolling
- Undoing and redoing performed operations
- State-transition table and adjacency matrix representations also
* State-transition table and adjacency matrix representations
- State and transition addition, editing, and deletion
- Group selection
- Undoing and redoing performed operations
* Simulation
- Instant simulation
- Step-by-state simulation
Expand All @@ -42,14 +45,13 @@ A comprehensive user guide is available in Russian in the [Wiki of this reposito
- Advancing and restarting execution for individual execution states
- Freezing executions states
- Viewing execution states associated with a given state
* Transformations
* Algorithms
- Determinization of finite automata
- Minimization of finite automata
- Conversion of regular expression to finite automata
- Elimination of epsilon-transitions
- Conversion of Mealy machine to Moore machine
- Conversion of Moore machine to Mealy machine
* Algorithms
- Conversion of PDA to context-free grammar
- Hellings algorithm
* Other features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ class TestsController(val openedAutomaton: Automaton) : Controller() {
mode = mode,
owner = testsWindow.currentWindow,
initialFileName = openedAutomaton.name + "_tests"
).firstOrNull()
).firstOrNull()?.let { file ->
if (mode == FileChooserMode.Save && file.extension.isEmpty())
File(file.path + ".json")
else file
}

private fun defaultDirectory() = runCatching {
File("${System.getProperty("user.home")}/Documents/automaton-constructor").takeIf { it.isDirectory || it.mkdirs() }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,100 +1,14 @@
package automaton.constructor.view

import automaton.constructor.model.element.AutomatonVertex
import automaton.constructor.model.element.BuildingBlock
import automaton.constructor.model.module.hasProblems
import automaton.constructor.model.module.hasProblemsBinding
import automaton.constructor.utils.I18N
import automaton.constructor.utils.Setting
import automaton.constructor.utils.SettingGroup
import javafx.beans.property.SimpleIntegerProperty
import javafx.beans.property.SimpleStringProperty
import javafx.scene.control.CheckBox
import javafx.scene.control.TextField
import javafx.scene.paint.Color
import tornadofx.*

open class AutomatonBasicVertexView(val vertex: AutomatonVertex) : AutomatonElementView(vertex) {
val colourProperty = SimpleStringProperty("none")
private var colour by colourProperty
init {
hbox {
label {
textProperty().bind(vertex.nameProperty)
textFill = Color.BLACK
}
val startFinalCount = SimpleIntegerProperty(0)
if (vertex.isInitial) {
startFinalCount.set(1)
}
if (vertex.isFinal) {
startFinalCount.set(startFinalCount.value + 1)
}
val startFinalLabel = label {
if (startFinalCount.value == 1) {
if (vertex.isInitial) {
text = " (start)"
} else {
text = " (final)"
}
text = if (vertex.isInitial) {
" (start)"
} else {
" (final)"
}
}
if (startFinalCount.value == 2) {
text = " (start, final)"
}
textFill = Color.BLACK
isVisible = vertex.isInitial || vertex.isFinal
}
vertex.isInitialProperty.addListener { _, _, newValue ->
if (newValue) {
startFinalCount.set(startFinalCount.value + 1)
} else {
startFinalCount.set(startFinalCount.value - 1)
}
}
vertex.isFinalProperty.addListener { _, _, newValue ->
if (newValue) {
startFinalCount.set(startFinalCount.value + 1)
} else {
startFinalCount.set(startFinalCount.value - 1)
}
}
startFinalCount.addListener { _, _, newValue ->
when (newValue) {
0 -> startFinalLabel.isVisible = false
1 -> {
startFinalLabel.text = if (vertex.isInitial) {
" (start)"
} else {
" (final)"
}
startFinalLabel.isVisible = true
}
else -> {
startFinalLabel.text = " (start, final)"
startFinalLabel.isVisible = true
}
}
}
}
if (vertex is BuildingBlock) {
if (vertex.subAutomaton.hasProblems) {
colour = "red"
}
vertex.subAutomaton.hasProblemsBinding.addListener(ChangeListener { _, _, newValue ->
colour = if (newValue) {
"red"
} else {
"none"
}
})
}
}

override fun getSettings() = listOf(
SettingGroup(
I18N.messages.getString("StateView.State").toProperty(), listOf(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package automaton.constructor.view

import automaton.constructor.model.element.AutomatonVertex
import automaton.constructor.model.element.BuildingBlock
import automaton.constructor.model.module.hasProblems
import automaton.constructor.model.module.hasProblemsBinding
import javafx.beans.property.SimpleIntegerProperty
import javafx.beans.property.SimpleStringProperty
import javafx.scene.paint.Color
import tornadofx.*

class AutomatonTableVertexView(vertex: AutomatonVertex): AutomatonBasicVertexView(vertex) {
val colourProperty = SimpleStringProperty("none")
private var colour by colourProperty
init {
hbox {
label {
textProperty().bind(vertex.nameProperty)
textFill = Color.BLACK
}
val startFinalCount = SimpleIntegerProperty(0)
if (vertex.isInitial) {
startFinalCount.set(1)
}
if (vertex.isFinal) {
startFinalCount.set(startFinalCount.value + 1)
}
val startFinalLabel = label {
if (startFinalCount.value == 1) {
if (vertex.isInitial) {
text = " (start)"
} else {
text = " (final)"
}
text = if (vertex.isInitial) {
" (start)"
} else {
" (final)"
}
}
if (startFinalCount.value == 2) {
text = " (start, final)"
}
textFill = Color.BLACK
isVisible = vertex.isInitial || vertex.isFinal
}
vertex.isInitialProperty.addListener { _, _, newValue ->
if (newValue) {
startFinalCount.set(startFinalCount.value + 1)
} else {
startFinalCount.set(startFinalCount.value - 1)
}
}
vertex.isFinalProperty.addListener { _, _, newValue ->
if (newValue) {
startFinalCount.set(startFinalCount.value + 1)
} else {
startFinalCount.set(startFinalCount.value - 1)
}
}
startFinalCount.addListener { _, _, newValue ->
when (newValue) {
0 -> startFinalLabel.isVisible = false
1 -> {
startFinalLabel.text = if (vertex.isInitial) {
" (start)"
} else {
" (final)"
}
startFinalLabel.isVisible = true
}
else -> {
startFinalLabel.text = " (start, final)"
startFinalLabel.isVisible = true
}
}
}
}
if (vertex is BuildingBlock) {
if (vertex.subAutomaton.hasProblems) {
colour = "red"
}
vertex.subAutomaton.hasProblemsBinding.addListener(ChangeListener { _, _, newValue ->
colour = if (newValue) {
"red"
} else {
"none"
}
})
}
}
}
4 changes: 3 additions & 1 deletion src/main/kotlin/automaton/constructor/view/MainWindow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ class MainWindow(
fileController.onOpen()
}
item(I18N.messages.getString("MainView.Examples")).action {
find<ExamplesView>(mapOf(ExamplesView::fileController to fileController)).openModal()
find<ExamplesView>(mapOf(ExamplesView::fileController to fileController)).apply {
title = I18N.automatonExamples.getString("ExamplesFragment.Title")
}.openModal()
}
shortcutItem(I18N.messages.getString("MainView.File.Save"), "Shortcut+S") {
fileController.onSave()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import automaton.constructor.model.element.Transition
import automaton.constructor.utils.I18N
import automaton.constructor.utils.addOnSuccess
import automaton.constructor.utils.hoverableTooltip
import automaton.constructor.view.AutomatonBasicVertexView
import automaton.constructor.view.AutomatonTableVertexView
import automaton.constructor.view.AutomatonViewContext
import automaton.constructor.view.TableTransitionView
import javafx.beans.property.ReadOnlyDoubleProperty
Expand Down Expand Up @@ -38,8 +38,8 @@ class VertexCell<T: TableTransitionView, M: TransitionMap>(
private val colourProperty = SimpleStringProperty("")
private var colour by colourProperty

private fun registerVertex(vertex: AutomatonVertex): AutomatonBasicVertexView {
val vertexView = AutomatonBasicVertexView(vertex)
private fun registerVertex(vertex: AutomatonVertex): AutomatonTableVertexView {
val vertexView = AutomatonTableVertexView(vertex)
table.controller.registerAutomatonElementView(vertexView)
if (vertex is BuildingBlock) {
vertexView.hoverableTooltip(stopManagingOnInteraction = true) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/examples.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ExamplesFragment.Title=Examples
ExamplesFragment.evenBinaryNumbersRecognizer=Even binary numbers recognizer
ExamplesFragment.correctBracketSeqRecognizer=Correct bracket sequence recognizer
ExamplesFragment.binaryNumberAdder=Binary number adder
Expand All @@ -9,4 +10,4 @@ ExamplesFragment.correctBracketSeqRecognizerDescription=Implemented with pushdow
ExamplesFragment.binaryNumberAdderDescription=Implemented with Turing machine.\nRunning on test example:
ExamplesFragment.evenPalindromesRecognizerDescription=Implemented with pushdown automaton.\nRunning on test example:
ExamplesFragment.threeZerosAndOneOneDescription=Implemented with register automaton.\nRunning on test example:
ExamplesFragment.zeroRemoverDescription=Implemented with Mealy/Moore machine.\nRunning on test example:
ExamplesFragment.zeroRemoverDescription=Implemented with Mealy/Moore machine.\nRunning on test example:
1 change: 1 addition & 0 deletions src/main/resources/examples_ru.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ExamplesFragment.Title=Примеры
ExamplesFragment.evenBinaryNumbersRecognizer=Распознаватель четных двоичных чисел
ExamplesFragment.correctBracketSeqRecognizer=Распознаватель правильных скобочных последовательностей
ExamplesFragment.binaryNumberAdder=Сумматор двоичных чисел
Expand Down
Binary file added wiki/examples.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wiki/testing_panel.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified wiki/visual_editor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 02f5091

Please sign in to comment.