Skip to content

Commit

Permalink
composition-drawer: refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
akolomentsev committed Apr 5, 2018
1 parent 56d8aec commit 0105e16
Show file tree
Hide file tree
Showing 14 changed files with 230 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group=com.satori
version=0.5.11-SNAPSHOT
version=0.5.12-SNAPSHOT

#nexusUsername=
#nexusPassword=
Expand Down
1 change: 1 addition & 0 deletions libs/composition-drawer/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply from: rootProject.file('metainfo.gradle')
apply from: rootProject.file('readme.gradle')

// main dependencies
dependencies {
Expand Down
82 changes: 82 additions & 0 deletions libs/composition-drawer/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
## Composition diagram drawer


#### Example using dedicated 'GenerateCompositionDiagram' gradle task
```gradle
buildscript{
repositories {
mavenCentral()
maven {
url('https://oss.sonatype.org/content/repositories/snapshots/')
}
}
dependencies {
classpath "com.satori:satori-libs-composition-drawer:0.5.12-SNAPSHOT"
}
}
task generateCompositionDiagram(type: GenerateCompositionDiagramTask) {
group "codegen"
cfgPath = file("path/to/config.json")
imgPath = file("path/to/diagram.png")
blockWidth = 230
blockHeight = 45
inputs.file("build.gradle")
}
```

### Example using 'JavaExec' gradle task
```gradle
repositories {
mavenCentral()
maven {
url('https://oss.sonatype.org/content/repositories/snapshots/')
}
}
configurations{compositionDrawer}
dependencies {
compositionDrawer "com.satori:satori-libs-composition-drawer:0.5.12-SNAPSHOT"
}
task generateCompositionDiagram(type: JavaExec) {
group "codegen"
def cfgPath = file("path/to/config.json")
def imgPath = file("path/to/diagram.png")
inputs.file(cfgPath)
outputs.file(imgPath)
classpath = configurations.compositionDrawer
main = 'com.satori.libs.composition.drawer.App'
args "--cfg-path", cfgPath
args "--img-path", imgPath
args "--block-width", 230
args "--block-height", 45
doFirst {
println "generating composition diagram ...."
println commandLine.join(" ")
}
}
```


### Maven (snapshots)
```xml
<repository>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
```
```xml
<dependency>
<groupId>com.satori</groupId>
<artifactId>satori-libs-composition-drawer</artifactId>
<version>0.5.12-SNAPSHOT</version>
</dependency>
```

91 changes: 91 additions & 0 deletions libs/composition-drawer/readme.template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
## Composition diagram drawer


#### Example using dedicated 'GenerateCompositionDiagram' gradle task
```gradle
buildscript{
repositories {
mavenCentral()
maven {
url('https://oss.sonatype.org/content/repositories/snapshots/')
}
}
dependencies {
classpath "com.satori:satori-libs-composition-drawer:${project.version}"
}
}
task generateCompositionDiagram(type: GenerateCompositionDiagramTask) {
group "codegen"
cfgPath = file("path/to/config.json")
imgPath = file("path/to/diagram.png")
blockWidth = 230
blockHeight = 45
inputs.file("build.gradle")
}
```

### Example using 'JavaExec' gradle task
```gradle
repositories {
mavenCentral()
maven {
url('https://oss.sonatype.org/content/repositories/snapshots/')
}
}
configurations{compositionDrawer}
dependencies {
compositionDrawer "com.satori:satori-libs-composition-drawer:${project.version}"
}
task generateCompositionDiagram(type: JavaExec) {
group "codegen"
def cfgPath = file("path/to/config.json")
def imgPath = file("path/to/diagram.png")
inputs.file(cfgPath)
outputs.file(imgPath)
classpath = configurations.compositionDrawer
main = 'com.satori.libs.composition.drawer.App'
args "--cfg-path", cfgPath
args "--img-path", imgPath
args "--block-width", 230
args "--block-height", 45
doFirst {
println "generating composition diagram ...."
println commandLine.join(" ")
}
}
```

<% if(!project.version.endsWith("-SNAPSHOT")) {%>
### Maven (releases)
```xml
<dependency>
<groupId>com.satori</groupId>
<artifactId>satori-libs-composition-drawer</artifactId>
<version>${project.version}</version>
</dependency>
```
<% } else {%>
### Maven (snapshots)
```xml
<repository>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
```
```xml
<dependency>
<groupId>com.satori</groupId>
<artifactId>satori-libs-composition-drawer</artifactId>
<version>${project.version}</version>
</dependency>
```
<% }%>
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package com.satori.libs.composition.drawer

import com.mxgraph.util.*
import com.satori.libs.composition.drawer.*
import org.gradle.api.*
import org.gradle.api.tasks.*
import java.awt.*
import java.io.*
import javax.imageio.*

open class GenerateCompositionImageTask : DefaultTask() {
open class GenerateCompositionDiagramTask : DefaultTask() {

@InputFile
var cfgPath: File? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@ fun createGraph(cfgPath: String) = createGraph(
)

fun createGraph(cfgPath: String, width: Double, height: Double) = createGraph(
File(cfgPath), CompositionGraphWriter.defaultWidth, CompositionGraphWriter.defaultHeight
File(cfgPath), width, height
)

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ object AppExample {
fun main(vararg args: String) {
App.main(
"--cfg-path", "mods-examples/big-blue-bus/res/com/satori/mods/resources/config.json",
"--block-width", "100",
"--block-height", "100",
"--img-path", "big-blue-bus.png"
)
}
Expand Down
4 changes: 2 additions & 2 deletions libs/gtfs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ classes are generated based on [gtfs-realtime.proto](https://developers.google.c
<dependency>
<groupId>com.satori</groupId>
<artifactId>satori-libs-gtfs</artifactId>
<version>0.5.11-SNAPSHOT</version>
<version>0.5.12-SNAPSHOT</version>
</dependency>
```


### Download
[satori-libs-gtfs.v0.5.11-SNAPSHOT.zip](https://github.com/satori-com/satori-composer/releases/download/v0.5.11-SNAPSHOT/satori-libs-gtfs.v0.5.11-SNAPSHOT.zip)<br/>
[satori-libs-gtfs.v0.5.12-SNAPSHOT.zip](https://github.com/satori-com/satori-composer/releases/download/v0.5.12-SNAPSHOT/satori-libs-gtfs.v0.5.12-SNAPSHOT.zip)<br/>
[or see latest releases](https://github.com/satori-com/satori-composer/releases/latest)

### Examples
Expand Down
36 changes: 35 additions & 1 deletion mods-examples/composition-drawer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,47 @@ buildscript{
}
}

task generateCompositionImage(type: GenerateCompositionImageTask){
task generateCompositionImage(type: GenerateCompositionImageTask) {
group "codegen"
cfgPath = file("res/com/satori/mods/resources/config.json")
imgPath = file("docs/diagram.png")
blockWidth = 230
blockHeight = 45
inputs.file("build.gradle")
}
generateCode.dependsOn generateCompositionImage



configurations{compositionDrawer}
dependencies {
compositionDrawer "com.satori:satori-libs-composition-drawer:0.5.11-SNAPSHOT"
}

task generateCompositionImage2(type: JavaExec) {
group 'codegen'

def cfgPath = file("res/com/satori/mods/resources/config.json")
def imgPath = file("docs/diagram2.png")

inputs.file(cfgPath)
outputs.file(imgPath)

classpath = configurations.compositionDrawer
main = 'com.satori.libs.composition.drawer.App'

args "--cfg-path", cfgPath
args "--img-path", imgPath
args "--block-width", 230
args "--block-height", 45

doFirst {
println "generating composition diagram ...."
println commandLine.join(" ")
}
}
generateCode.dependsOn generateCompositionImage2

dependencies {
testCompile project(':libs-testlib')
}
Binary file modified mods-examples/composition-drawer/docs/diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions readme.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

task generateReadme(type: TransformTask) {
group 'codegen'

template = file('readme.template.md')
output = file('readme.md')
}

generateCode.dependsOn generateReadme
5 changes: 3 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Satori Composer (preview)
[![Build Status](https://travis-ci.org/satori-com/satori-composer.svg?branch=dev)](https://travis-ci.org/satori-com/satori-composer)
[![Build Status](https://img.shields.io/nexus/s/https/oss.sonatype.org/com.satori/satori-composer.svg)](https://oss.sonatype.org/content/repositories/snapshots/com/satori/satori-composer/0.5.11-SNAPSHOT/)
[![Build Status](https://img.shields.io/nexus/s/https/oss.sonatype.org/com.satori/satori-composer.svg)](https://oss.sonatype.org/content/repositories/snapshots/com/satori/satori-composer/0.5.12-SNAPSHOT/)

#### Example
![diagram](docs/files/big-blue-bus-composition.png)
Expand Down Expand Up @@ -71,6 +71,7 @@
- [Mods Suite](https://www.satori.com/docs/opensource/composer#mods-suite)
- [Building and Running](https://www.satori.com/docs/opensource/composer#building-and-running)
- [Async support library](docs/async/readme.md)
- [Composition diagram drawer](libs/composition-drawer/readme.md)

### Common Libraries
- [Gtfs Library For Real-Time](https://github.com/satori-com/satori-composer/tree/dev/libs/gtfs)
Expand All @@ -86,7 +87,7 @@
<dependency>
<groupId>com.satori</groupId>
<artifactId>satori-composer</artifactId>
<version>0.5.11-SNAPSHOT</version>
<version>0.5.12-SNAPSHOT</version>
</dependency>
```

Expand Down
1 change: 1 addition & 0 deletions readme.template.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- [Mods Suite](https://www.satori.com/docs/opensource/composer#mods-suite)
- [Building and Running](https://www.satori.com/docs/opensource/composer#building-and-running)
- [Async support library](docs/async/readme.md)
- [Composition diagram drawer](libs/composition-drawer/readme.md)

### Common Libraries
- [Gtfs Library For Real-Time](https://github.com/satori-com/satori-composer/tree/dev/libs/gtfs)
Expand Down

0 comments on commit 0105e16

Please sign in to comment.