Skip to content

Commit 5a30cfe

Browse files
committed
Merge branch 'develop' into 'master'
2 parents ffd1386 + 0c1a2d6 commit 5a30cfe

37 files changed

+1700
-1227
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ ijp-scala-console
33

44
Simple user interface for executing Scala scripts. Can be run stand-alone or embedded in a desktop application.
55

6-
Currently, it is primarily developed to be run as an [ImageJ](http://rsb.info.nih.gov/ij/) plugin.
6+
Currently, it is primarily developed to be run as an [ImageJ](http://rsb.info.nih.gov/ij/) plugin. It can also run as a stand-alone application, see [ScalaConsoleApp](scala-console/src/main/scala/net/sf/ij_plugins/scala/console/ScalaConsoleApp.scala)
77

8-
![Screenshot](http://ij-plugins.sourceforge.net/plugins/scala/Screenshot-ScalaConsole.png)
8+
![Screenshot](docs/images/Scala-Console-2_screenshot.png)
99

1010
Binaries can be downloaded from the [releases] page. Some additional info is at the old [IJ Plugins](http://ij-plugins.sourceforge.net/plugins/scala/index.html) project site.
1111

149 KB
Loading

scala-console/build.sbt

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
name := "ijp-scala-console"
44
organization := "net.sf.ij-plugins"
5-
version := "1.4.0"
5+
version := "1.4.1-SNAPSHOT"
66

7-
crossScalaVersions := Seq("2.11.8", "2.10.6", "2.12.0-M4", "2.12.0-M5")
7+
crossScalaVersions := Seq("2.11.8", "2.12.1")
88
scalaVersion <<= crossScalaVersions { versions => versions.head }
99

1010
// set the main class for packaging the main jar
@@ -17,16 +17,20 @@ mainClass in(Compile, packageBin) := Some("net.sf.ij_plugins.scala.console.Scala
1717
mainClass in(Compile, run) := Some("net.sf.ij_plugins.scala.console.ScalaConsoleApp")
1818

1919
libraryDependencies ++= Seq(
20-
"org.scala-lang" % "scala-compiler" % scalaVersion.value,
21-
"org.scala-lang.modules" %% "scala-swing" % "2.0.0-M2",
22-
"net.imagej" % "ij" % "1.51f",
23-
"com.fifesoft" % "rsyntaxtextarea" % "2.5.8",
24-
"junit" % "junit" % "4.12" % "test",
25-
"com.novocode" % "junit-interface" % "0.11" % "test"
20+
"com.beachape" %% "enumeratum" % "1.5.3",
21+
"org.fxmisc.richtext" % "richtextfx" % "0.7-M2",
22+
"org.scala-lang" % "scala-compiler" % scalaVersion.value,
23+
"org.scala-lang.modules" %% "scala-java8-compat" % "0.8.0",
24+
"org.scalafx" %% "scalafx" % "8.0.102-R11",
25+
"org.scalafx" %% "scalafxml-core-sfx8" % "0.3",
26+
"org.scalafx" %% "scalafx-extras" % "0.1.0-SNAPSHOT",
27+
"net.imagej" % "ij" % "1.51f",
28+
"junit" % "junit" % "4.12" % "test",
29+
"com.novocode" % "junit-interface" % "0.11" % "test"
2630
)
2731

2832
scalacOptions in(Compile, compile) ++= Seq(
29-
// "-target:jvm-1.8",
33+
"-target:jvm-1.8",
3034
"-encoding", "UTF-8",
3135
"-unchecked",
3236
"-deprecation",
@@ -50,6 +54,11 @@ fork := true
5054
// add a JVM option to use when forking a JVM for 'run'
5155
javaOptions += "-Xmx2G"
5256

57+
58+
// Needed by ScalaFXML
59+
autoCompilerPlugins := true
60+
addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full)
61+
5362
// Set the prompt (for this build) to include the project id.
5463
shellPrompt in ThisBuild := { state => "sbt:" + Project.extract(state).currentRef.project + "> " }
5564

Lines changed: 37 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,37 @@
1-
/////////////////////////////////////////////////////////////////////////////
2-
// .__ __ .__ .__ //
3-
// |__| |__| ______ | | __ __ ____ |__| ____ ______ //
4-
// | | | | ______ \____ \| | | | \/ ___\| |/ \ / ___/ //
5-
// | | | | /_____/ | |_> > |_| | / /_/ > | | \\___ \ //
6-
// |__/\__| | | __/|____/____/\___ /|__|___| /____ > //
7-
// \______| |__| /_____/ \/ \/ //
8-
// //
9-
/////////////////////////////////////////////////////////////////////////////
10-
11-
12-
import ij.IJ._
13-
import ij.ImagePlus
14-
import ij.WindowManager._
15-
import scala.math._
16-
17-
18-
// get the current image
19-
val imp = getCurrentImage
20-
21-
// check that it's a valid image and if so start processing it!
22-
if (imp == null) {
23-
noImage()
24-
} else {
25-
val ip = imp.getProcessor.crop().convertToByte(false)
26-
27-
// add random noise to its pixels
28-
val width = ip.getWidth
29-
val height = ip.getHeight
30-
for (x <- 0 until width) {
31-
showProgress(x, width)
32-
for (y <- 0 until height) {
33-
val noise = round(random * 255 - 128).toInt
34-
ip.putPixel(x, y, ip.getPixel(x, y) + noise)
35-
}
36-
}
37-
showProgress(width, width)
38-
39-
// show it in a new image
40-
ip.resetMinAndMax()
41-
new ImagePlus("Noisy", ip).show()
42-
}
43-
1+
//
2+
// Add noise to the current image in ImageJ
3+
//
4+
5+
import ij.IJ._
6+
import ij.ImagePlus
7+
import ij.WindowManager._
8+
9+
import scala.math._
10+
11+
12+
// get the current image
13+
val imp = getCurrentImage
14+
15+
// check that it's a valid image and if so start processing it!
16+
if (imp == null) {
17+
noImage()
18+
} else {
19+
val ip = imp.getProcessor.crop().convertToByte(false)
20+
21+
// add random noise to its pixels
22+
val width = ip.getWidth
23+
val height = ip.getHeight
24+
for (x <- 0 until width) {
25+
showProgress(x, width)
26+
for (y <- 0 until height) {
27+
val noise = round(random * 255 - 128).toInt
28+
ip.putPixel(x, y, ip.getPixel(x, y) + noise)
29+
}
30+
}
31+
showProgress(width, width)
32+
33+
// show it in a new image
34+
ip.resetMinAndMax()
35+
new ImagePlus("Noisy", ip).show()
36+
}
37+

scala-console/examples/batchProcessImages.scala

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,12 @@
1-
/*
2-
* ImageJ Plugins
3-
* Copyright (C) 2002-2016 Jarek Sacha
4-
* Author's email: jpsacha at gmail dot com
5-
*
6-
* This library is free software; you can redistribute it and/or
7-
* modify it under the terms of the GNU Lesser General Public
8-
* License as published by the Free Software Foundation; either
9-
* version 2.1 of the License, or (at your option) any later version.
10-
*
11-
* This library is distributed in the hope that it will be useful,
12-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14-
* Lesser General Public License for more details.
15-
*
16-
* You should have received a copy of the GNU Lesser General Public
17-
* License along with this library; if not, write to the Free Software
18-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19-
*
20-
* Latest release available at https://github.com/ij-plugins
21-
*/
1+
//
2+
// Batch process images in ImageJ applying a median filter.
3+
//
224

235
import java.io.File
246

257
import ij.{IJ, ImagePlus}
268

27-
//
28-
// Batch process images applying a median filter.
29-
//
9+
3010
batchProcess(
3111
filter = {
3212
imp =>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import scala.math._
2+
3+
//
4+
// Print a wave to the standard output
5+
//
6+
val scale = 2
7+
for (x <- Range.Double(-Pi / 2, 3.5 * Pi, Pi / 5)) {
8+
// Prepare empty line
9+
val line = Array.fill(scale * 2 + 1)(" ")
10+
// Create marker at location `y`
11+
val y = round((sin(x) + 1) * scale).toInt
12+
line(y) = "*"
13+
// Print line as string
14+
println(line.mkString(" "))
15+
}

scala-console/examples/processCurrentImage.scala

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,6 @@
1-
/*
2-
* ImageJ Plugins
3-
* Copyright (C) 2002-2016 Jarek Sacha
4-
* Author's email: jpsacha at gmail dot com
5-
*
6-
* This library is free software; you can redistribute it and/or
7-
* modify it under the terms of the GNU Lesser General Public
8-
* License as published by the Free Software Foundation; either
9-
* version 2.1 of the License, or (at your option) any later version.
10-
*
11-
* This library is distributed in the hope that it will be useful,
12-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14-
* Lesser General Public License for more details.
15-
*
16-
* You should have received a copy of the GNU Lesser General Public
17-
* License along with this library; if not, write to the Free Software
18-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19-
*
20-
* Latest release available at https://github.com/ij-plugins
21-
*/
1+
//
2+
// Apply some processing to the current image in ImageJ
3+
//
224

235
import ij.IJ
246

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// [https://github.com/xerial/sbt-sonatype]
22
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "1.1")
3-
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")
3+
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.1")
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
~ ImageJ Plugins
5+
~ Copyright (C) 2002-2016 Jarek Sacha
6+
~ Author's email: jpsacha at gmail dot com
7+
~
8+
~ This library is free software; you can redistribute it and/or
9+
~ modify it under the terms of the GNU Lesser General Public
10+
~ License as published by the Free Software Foundation; either
11+
~ version 2.1 of the License, or (at your option) any later version.
12+
~
13+
~ This library is distributed in the hope that it will be useful,
14+
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
~ Lesser General Public License for more details.
17+
~
18+
~ You should have received a copy of the GNU Lesser General Public
19+
~ License along with this library; if not, write to the Free Software
20+
~ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21+
~
22+
~ Latest release available at https://github.com/ij-plugins
23+
-->
24+
25+
<?import javafx.scene.control.*?>
26+
<?import javafx.scene.image.Image?>
27+
<?import javafx.scene.image.ImageView?>
28+
<?import javafx.scene.layout.*?>
29+
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0"
30+
prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1"
31+
fx:controller="net.sf.ij_plugins.scala.console.ScalaConsolePaneView">
32+
<top>
33+
<MenuBar BorderPane.alignment="CENTER">
34+
<menus>
35+
<Menu fx:id="fileMenu" mnemonicParsing="false" text="File" />
36+
<Menu mnemonicParsing="false" text="Script">
37+
<items>
38+
<MenuItem fx:id="runMenuItem" mnemonicParsing="false" text="Run">
39+
<graphic>
40+
<ImageView>
41+
<image>
42+
<Image url="@resources/icons/script_go.png"/>
43+
</image>
44+
</ImageView>
45+
</graphic>
46+
</MenuItem>
47+
</items>
48+
</Menu>
49+
</menus>
50+
</MenuBar>
51+
</top>
52+
<bottom>
53+
<HBox BorderPane.alignment="CENTER">
54+
<children>
55+
<Label fx:id="statusLabel" text="&lt;Status&gt;" />
56+
</children>
57+
</HBox>
58+
</bottom>
59+
<center>
60+
<BorderPane BorderPane.alignment="CENTER">
61+
<top>
62+
<ToolBar fx:id="toolBar" BorderPane.alignment="CENTER"/>
63+
</top>
64+
<center>
65+
<SplitPane dividerPositions="0.75" orientation="VERTICAL" BorderPane.alignment="CENTER">
66+
<items>
67+
<BorderPane fx:id="editorPane" />
68+
<BorderPane fx:id="outputPane" />
69+
</items>
70+
</SplitPane>
71+
</center>
72+
</BorderPane>
73+
</center>
74+
</BorderPane>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* ImageJ Plugins
3+
* Copyright (C) 2002-2016 Jarek Sacha
4+
* Author's email: jpsacha at gmail dot com
5+
*
6+
* This library is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public
8+
* License as published by the Free Software Foundation; either
9+
* version 2.1 of the License, or (at your option) any later version.
10+
*
11+
* This library is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public
17+
* License along with this library; if not, write to the Free Software
18+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19+
*
20+
* Latest release available at https://github.com/ij-plugins
21+
*/
22+
23+
.keyword {
24+
-fx-fill: purple;
25+
-fx-font-weight: bold;
26+
}
27+
.semicolon {
28+
-fx-font-weight: bold;
29+
}
30+
.paren {
31+
-fx-fill: firebrick;
32+
-fx-font-weight: bold;
33+
}
34+
.bracket {
35+
-fx-fill: darkgreen;
36+
-fx-font-weight: bold;
37+
}
38+
.brace {
39+
-fx-fill: teal;
40+
-fx-font-weight: bold;
41+
}
42+
.string {
43+
-fx-fill: blue;
44+
}
45+
46+
.comment {
47+
-fx-fill: cadetblue;
48+
}
49+
50+
.paragraph-box:has-caret {
51+
-fx-background-color: #f2f9fc;
52+
}

0 commit comments

Comments
 (0)