https://github.com/arnobl/malai
https://github.com/arnobl/malai
event-processing java javafx typescript undo-redo user-interaction user-interface
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/arnobl/malai
- Owner: arnobl
- Archived: true
- Created: 2012-04-10T12:57:43.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2019-07-01T16:58:11.000Z (over 6 years ago)
- Last Synced: 2024-12-30T11:35:18.220Z (about 1 year ago)
- Topics: event-processing, java, javafx, typescript, undo-redo, user-interaction, user-interface
- Language: Java
- Homepage:
- Size: 17.6 MB
- Stars: 1
- Watchers: 5
- Forks: 8
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://ci.inria.fr/malai/job/malai_core/) [](https://ci.inria.fr/malai/job/malai_javafx/)
## Examples
The following Java code defines an undoable action that changes the unit system used in a drawing editor.
```java
public class SetUnit extends ActionImpl implements Undoable {
private Unit unit;
private Unit oldUnit;
@Override
public boolean canDo() { // Checks whether the action can be executed
return unit != null;
}
@Override
protected void doActionBody() { // Execution of the action.
oldUnit = ScaleRuler.getUnit();
redo();
}
@Override
public void undo() { // Undoes the action
ScaleRuler.setUnit(oldUnit);
}
@Override
public void redo() { // Redoes the action
ScaleRuler.setUnit(unit);
}
@Override
public String getUndoName() { // Provides a short textual description of this undoable action.
return "Changing the unit";
}
//...
}
```
This action can be then used in an instrument to be binded to a predefined user interaction and widgets.
```java
// An instrument is a controller/presenter/viewModel/component/etc:
// it gather events produced by widgets as user interactions into actions that modify the system.
public class PreferencesSetter extends JfxInstrument implements Initializable {
@FXML private ComboBox unitChoice;
//...
@Override
protected void configureBindings() throws IllegalAccessException, InstantiationException {
//...
// Defines an widget binding that binds a combobox to the action SetUnit
bindComboBox(SetUnit.class, // The type of the action to produce
action -> action.setUnit(Unit.getUnit(unitChoice.getSelectionModel().getSelectedItem())), // The initialisation of the action
unitChoice); // The source widget to listen
}
}
```
# Implementations
Malai fully supports **Java Swing** and **JavaFX**. A **TypeScript/Javascript** version is in progress.
# How to use
As Maven libraries. In your POM file, adds the Malai repositories:
```xml
mavenInriaSnapshot
http://maven.inria.fr-snapshots
http://maven.inria.fr/artifactory/malai-public-snapshot
mavenInriaRelease
http://maven.inria.fr-releases
http://maven.inria.fr/artifactory/malai-public-release
```
And adds the dependencies:
```xml
org.malai
malai.core
3.0-SNAPSHOT
org.malai
malai.javafx
3.0-SNAPSHOT
```
# Who uses Malai?
[Latexdraw](https://github.com/arnobl/latexdraw) is a vector drawing editors for LaTeX. It is developed on the top of Malai JavaFX.