Skip to content

Commit

Permalink
Feature/2 (#14)
Browse files Browse the repository at this point in the history
* Added CI tests (#8)

* Updated README.md

* Added github workflow

* Added tests

* Fix/no task (#10)

* Updated README.md

* Added github workflow

* Added tests

* Updated workflow

* Feature/2 (#13)

* Added CONTRIBUTING.md

* Added README.md to repl

* Added basic plugin-api

* Added Trello badge

* Fixed pom.xml

* Changed plugin-api JDK version to 11

* Changed JDK in workflows to 17

* Added plugins to GUI. Added sonatype deploy for Plugin API. Added SLF4J

* Added raw plugins loading. Fixed imports. Moved to GroovyShell.parse(File)

* Fixed log4j.properties for tests

* Fixed FileUtils#writeToFile

* Fixes

* Added javadoc

* Fixed imports

* Added global events

* Added package-info.java
  • Loading branch information
CrissNamon authored Mar 27, 2023
1 parent 27a05a0 commit 629aabf
Show file tree
Hide file tree
Showing 51 changed files with 1,362 additions and 238 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Test
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/javadoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Setup JDK 11
- name: Setup JDK 17
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Test
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Setup JDK 11
- name: Setup JDK 17
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Test
Expand Down
90 changes: 90 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Contributing

When contributing to this repository, please first discuss the change you wish to make via issue,
email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

## Contribution process

1. fork the repository
2. clone your fork locally
3. make a pull request into dev branch

> `NOTE:` Always remember to describe you PR with the exact issue id.
> OR if you are making PR which doesn't solves any listed issue then please mention it(*this PR
doesn't resembles with
> any listed issue*) into your PR
### Git workflow

- _main_ - stable release branch, can be updated only by PR from dev
- _dev_ - development branch, should be updated by PR from other branches

## Code of Conduct

### Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.

### Our Standards

Examples of behavior that contributes to creating a positive environment
include:

- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

### Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

### Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

### Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at d.rassokhin@hiddenproject.tech. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# CompaJ Project

[![Build](https://github.com/CrissNamon/compaj/actions/workflows/main.yml/badge.svg)](https://github.com/CrissNamon/compaj/actions/workflows/main.yml)
[![Trello](https://img.shields.io/badge/Trello-Follow%20progress-blueviolet)](https://trello.com/b/4c7FvMFI/compaj-desktop)

<img width="640" alt="Compaj logo wide" src="https://user-images.githubusercontent.com/22001123/227656456-b43f3ef3-80d0-4c36-b5ef-d8e84e40ddcf.png">

This is the home of the CompaJ Project - open source, cross-platform programming and numeric
computing platform for math modelling.
Expand All @@ -18,6 +21,8 @@ computing platform for math modelling.
___
Project is under active development. CompaJ supports only basic functions and models now, which are
not intended to use in real projects.
See project progress and feature on
public [Trello board](https://trello.com/b/4c7FvMFI/compaj-desktop).

### Structure

Expand All @@ -29,12 +34,16 @@ CompaJ has modular structure based on Maven modules.
- [CompaJ Applied](https://github.com/CrissNamon/compaj/tree/main/applied)
- Applied module contains ready to use models.
- [CompaJ Lang](https://github.com/CrissNamon/compaj/tree/main/lang)
- CompaJ Lang is an object oriented and optionally typed programming language based on Groovy
- CompaJ Lang is an object-oriented and optionally typed programming language based on Groovy
with useful extensions to reduce redundant symbols and simplify calculations.
- [CompaJ Plugin API](https://github.com/CrissNamon/compaj/tree/main/plugin-api)
- CompaJ can load external plugins using Plugin API
- [CompaJ REPL](https://github.com/CrissNamon/compaj/tree/main/repl)
- CompaJ REPL is a console application which provides all functionality of CompaJ Lang.
- [CompaJ](https://github.com/CrissNamon/compaj/tree/main/gui)
- CompaJ is a standalone application with GUI and many useful tools for CompaJ REPL.
- [CompaJ Cloud](https://github.com/CrissNamon/compaj-cloud)
- Cloud infrastructure to run CompaJ as SaaS

### Learn

Expand All @@ -59,6 +68,11 @@ in [Wiki](https://github.com/CrissNamon/compaj/wiki/CompaJ-Math).
CompaJ uses widgets system for visualization in _WorkSpace_. Documentation available
in [Wiki](https://github.com/CrissNamon/compaj/wiki/CompaJ-WorkSpace)

#### Plugin API

Plugin API provides a way for developers to extend CompaJ system with new features.
Documentation available in [Wiki](https://github.com/CrissNamon/compaj/wiki/Plugin-API)

#### Other

All documentation and necessary information with tutorials will be released soon.
Expand All @@ -67,7 +81,7 @@ All documentation and necessary information with tutorials will be released soon

___

* [Danila Rassokhin](https://gihub.com/crissnamon) [![Twitter](https://img.shields.io/twitter/follow/kpekepsalt?style=social)](https://twitter.com/kpekepsalt)
* [Danila Rassokhin](https://github.com/crissnamon) [![Twitter](https://img.shields.io/twitter/follow/kpekepsalt_en?style=social)](https://twitter.com/kpekepsalt_en)

### Copyright

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Contains epidemic models.
*/
package tech.hiddenproject.compaj.applied.epidemic;
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
public class GridAgent implements Agent<GridLocation, String> {

private final Map<String, Double> numericProperties;
private final Map<String, String> stringProperties;
private Object id;
private GridLocation location;
private Supplier<GridLocation> locationSupplier;
Expand All @@ -27,8 +29,6 @@ public class GridAgent implements Agent<GridLocation, String> {
private BiFunction<Long, Agent<GridLocation, ?>, GridLocation> moveFunction;
private BiFunction<EnvironmentObject<GridLocation>, GridLocation, GridLocation> collideFunction;
private BiConsumer<Long, Agent<GridLocation, String>> stepFunction;
private final Map<String, Double> numericProperties;
private final Map<String, String> stringProperties;

public GridAgent(String group) {
this.id = 1;
Expand Down Expand Up @@ -216,7 +216,8 @@ public GridAgent clone() {
newAgent.moveAs(moveFunction);
newAgent.collidesAs(collideFunction);
for (Entry<String, Double> entry : numericProperties.entrySet()) {
newAgent.setProperty(entry.getKey(), new Double(entry.getValue()));
Double v = entry.getValue();
newAgent.setProperty(entry.getKey(), v);
}
for (Entry<String, String> entry : stringProperties.entrySet()) {
newAgent.setProperty(entry.getKey(), new String(entry.getValue()));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Contains basic implementations of data classes for basic models.
*/
package tech.hiddenproject.compaj.core.data.base;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Contains interfaces for data classes used in models.
*/
package tech.hiddenproject.compaj.core.data;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Contains basic models.
*/
package tech.hiddenproject.compaj.core.model.base;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Contains interfaces for models.
*/
package tech.hiddenproject.compaj.core.model;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Contains core classes for math models.
*/
package tech.hiddenproject.compaj.core;
26 changes: 23 additions & 3 deletions gui/src/main/java/tech/hiddenproject/compaj/gui/AppSettings.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package tech.hiddenproject.compaj.gui;

import java.io.File;
import java.io.FileFilter;
import java.util.prefs.Preferences;

public class AppSettings {

private static final String APP_DIRECTORY = "CompaJ";
private static final String SCRIPTS_FOLDER = "scripts";
private static final String SCRIPTS_DIRECTORY = "scripts";
private static final String PLUGINS_DIRECTORY = "plugins";
private static AppSettings INSTANCE;
private Preferences preferences;
private final Preferences preferences;

private AppSettings() {
preferences = Preferences.userNodeForPackage(tech.hiddenproject.compaj.gui.Compaj.class);
Expand All @@ -26,7 +28,7 @@ public File getScriptsDirectoryFor(String project) {
}

private File createScriptsDirectory(File projectDir) {
File scriptsDir = new File(projectDir.toString() + "/" + SCRIPTS_FOLDER);
File scriptsDir = new File(projectDir.toString() + "/" + SCRIPTS_DIRECTORY);
scriptsDir.mkdir();
return scriptsDir;
}
Expand All @@ -44,11 +46,29 @@ public File getAppDirectory() {
return dir;
}

public File getLibrariesDirectory() {
File appDirectory = getAppDirectory();
File libDirectory = new File(appDirectory.getAbsolutePath() + "/lib/");
libDirectory.mkdir();
return libDirectory;
}

public File getPluginsDirectory() {
File appDirectory = getAppDirectory();
File pluginsDir = new File(appDirectory.getAbsolutePath() + "/" + PLUGINS_DIRECTORY + "/");
pluginsDir.mkdir();
return pluginsDir;
}

public void put(AppPreference preference, String value) {
preferences.put(preference.getName(), value);
}

public String get(AppPreference preference, String defaultValue) {
return preferences.get(preference.getName(), defaultValue);
}

public FileFilter pluginsFileFilter() {
return pathname -> pathname.getName().endsWith(".jar");
}
}
Loading

0 comments on commit 629aabf

Please sign in to comment.