Skip to content

Commit ffd1386

Browse files
committed
Merge branch 'origin/develop'
2 parents b4c607c + 99ff354 commit ffd1386

24 files changed

+701
-557
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea
2+
*.iml
3+
target
4+
sandbox

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
ijp-scala-console
2+
=================
3+
4+
Simple user interface for executing Scala scripts. Can be run stand-alone or embedded in a desktop application.
5+
6+
Currently, it is primarily developed to be run as an [ImageJ](http://rsb.info.nih.gov/ij/) plugin.
7+
8+
![Screenshot](http://ij-plugins.sourceforge.net/plugins/scala/Screenshot-ScalaConsole.png)
9+
10+
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.
11+
12+
License
13+
-------
14+
15+
This library is free software; you can redistribute it and/or
16+
modify it under the terms of the GNU Lesser General Public
17+
License as published by the Free Software Foundation; either
18+
version 2.1 of the License, or (at your option) any later version.
19+
20+
This library is distributed in the hope that it will be useful,
21+
but WITHOUT ANY WARRANTY; without even the implied warranty of
22+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23+
Lesser General Public License for more details.
24+
25+
You should have received a copy of the GNU Lesser General Public
26+
License along with this library; if not, write to the Free Software
27+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

scala-console/build.sbt

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,46 @@
1-
// Project name
2-
name := "scala-console"
1+
// @formatter:off
32

4-
// Publishing organization
3+
name := "ijp-scala-console"
54
organization := "net.sf.ij-plugins"
5+
version := "1.4.0"
66

7-
// Current version
8-
version := "1.1.3"
9-
10-
// Version of scala to use
11-
crossScalaVersions := Seq("2.11.7", "2.10.6")
12-
13-
scalaVersion <<= crossScalaVersions {versions => versions.head}
7+
crossScalaVersions := Seq("2.11.8", "2.10.6", "2.12.0-M4", "2.12.0-M5")
8+
scalaVersion <<= crossScalaVersions { versions => versions.head }
149

1510
// set the main class for packaging the main jar
1611
// 'run' will still auto-detect and prompt
1712
// change Compile to Test to set it for the test jar
18-
mainClass in (Compile, packageBin) := Some("net.sf.ij_plugins.scala.console.ScalaConsoleApp")
13+
mainClass in(Compile, packageBin) := Some("net.sf.ij_plugins.scala.console.ScalaConsoleApp")
1914

2015
// set the main class for the main 'run' task
2116
// change Compile to Test to set it for 'test:run'
22-
mainClass in (Compile, run) := Some("net.sf.ij_plugins.scala.console.ScalaConsoleApp")
17+
mainClass in(Compile, run) := Some("net.sf.ij_plugins.scala.console.ScalaConsoleApp")
2318

2419
libraryDependencies ++= Seq(
25-
"org.scala-lang" % "scala-compiler" % scalaVersion.value,
26-
"net.imagej" % "ij" % "1.49v",
27-
"com.fifesoft" % "rsyntaxtextarea" % "2.0.7",
28-
"junit" % "junit" % "4.12" % "test",
29-
"com.novocode" % "junit-interface" % "0.11" % "test"
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"
3026
)
3127

32-
libraryDependencies ++= (if (scalaVersion.value.startsWith("2.11."))
33-
Seq("org.scala-lang.modules" %% "scala-swing" % "1.0.2")
34-
else
35-
Seq("org.scala-lang" % "scala-swing" % scalaVersion.value))
28+
scalacOptions in(Compile, compile) ++= Seq(
29+
// "-target:jvm-1.8",
30+
"-encoding", "UTF-8",
31+
"-unchecked",
32+
"-deprecation",
33+
"-Xlint",
34+
"-feature",
35+
"-Xfuture",
36+
"–optimise",
37+
"-Yno-adapted-args",
38+
"-Ywarn-dead-code",
39+
"-Ywarn-numeric-widen"
40+
// "-Ywarn-value-discard",
41+
// "-Ywarn-unused",
42+
// "-Ywarn-unused-import"
43+
)
3644

3745
resolvers += "ImageJ Releases" at "http://maven.imagej.net/content/repositories/releases/"
3846

@@ -43,17 +51,13 @@ fork := true
4351
javaOptions += "-Xmx2G"
4452

4553
// Set the prompt (for this build) to include the project id.
46-
shellPrompt in ThisBuild := { state => "sbt:"+Project.extract(state).currentRef.project + "> " }
54+
shellPrompt in ThisBuild := { state => "sbt:" + Project.extract(state).currentRef.project + "> " }
4755

4856
enablePlugins(SbtImageJ)
4957

5058
ijRuntimeSubDir := "sandbox"
51-
5259
ijPluginsSubDir := "ij-plugins"
53-
54-
ijExclusions += """nativelibs4java\S*"""
55-
56-
cleanFiles += ijPluginsDir.value
60+
cleanFiles += ijPluginsDir.value
5761

5862
// Info needed sync with Maven central.
5963
pomExtra in Global := {

scala-console/build.xml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

33
<!--
4-
~ Image/J Plugins
5-
~ Copyright (C) 2002-2013 Jarek Sacha
6-
~ Author's email: jsacha at users dot sourceforge dot net
4+
~ ImageJ Plugins
5+
~ Copyright (C) 2002-2016 Jarek Sacha
6+
~ Author's email: jpsacha at gmail dot com
77
~
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.
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.
1212
~
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.
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.
1717
~
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
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
2121
~
22-
~ Latest release available at http://sourceforge.net/projects/ij-plugins/
22+
~ Latest release available at https://github.com/ij-plugins
2323
-->
2424

2525
<project name="scala-console" basedir=".">
@@ -40,7 +40,7 @@
4040
fork="true"
4141
failonerror="true">
4242
<jvmarg line="-Dfile.encoding=UTF8 -Xmx1G -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m -Djava.net.useSystemProxies=true"/>
43-
<arg line="ijp-color/imagejPrepareRun"/>
43+
<arg line="ijPrepareRun"/>
4444
</java>
4545
</target>
4646

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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+
import java.io.File
24+
25+
import ij.{IJ, ImagePlus}
26+
27+
//
28+
// Batch process images applying a median filter.
29+
//
30+
batchProcess(
31+
filter = {
32+
imp =>
33+
IJ.run(imp, "Median...", "radius=4")
34+
imp
35+
},
36+
inputDir = new File("my_input_dir"),
37+
inputExtension = ".png",
38+
outputDir = new File("my_output_dir")
39+
)
40+
41+
//-------------------------------------------------------------------------------------------------
42+
43+
44+
/**
45+
* Apply filter to files in input directory, save modified files in the output directory.
46+
*
47+
* @param filter operation to be applied to processed images
48+
* @param inputDir input directory
49+
* @param inputExtension input file name extension
50+
* @param outputDir output directory
51+
*/
52+
def batchProcess(inputDir: File,
53+
inputExtension: String,
54+
outputDir: File,
55+
filter: ImagePlus => ImagePlus) {
56+
val title = "Batch Process"
57+
58+
// Input directory
59+
if (!inputDir.exists) {
60+
IJ.error(title, "Input directory does not exist: " + inputDir.getAbsolutePath)
61+
return
62+
}
63+
64+
// Output directory
65+
if (!outputDir.mkdirs()) {
66+
IJ.error(title, "Failed to create output directory: " + outputDir.getAbsolutePath)
67+
return
68+
}
69+
70+
// List all files with extension ".png"
71+
val inputFiles = inputDir.listFiles.filter(_.getName.endsWith(inputExtension))
72+
73+
// batch process iterating through all input files
74+
for (inputFile <- inputFiles) {
75+
println("Processing: " + inputFile.getAbsolutePath)
76+
val src = IJ.openImage(inputFile.getPath)
77+
val dest = filter(src)
78+
val outputFile = new File(outputDir, inputFile.getName)
79+
IJ.saveAs(dest, "tif", outputFile.getAbsolutePath)
80+
}
81+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
import ij.IJ
24+
25+
process()
26+
27+
/**
28+
* Get a reference to currently selected image in ImageJ then apply median filter to it.
29+
* If no image is opened show "No image" error message.
30+
*/
31+
def process() {
32+
// Get currently selected image
33+
val imp = IJ.getImage
34+
if (imp == null) {
35+
// Show error message
36+
IJ.noImage()
37+
return
38+
}
39+
40+
// Do some processing
41+
IJ.run(imp, "Median...", "radius=4")
42+
// ...
43+
}

scala-console/libs/ij-1.47h.jar

-1.7 MB
Binary file not shown.
-900 KB
Binary file not shown.
Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
#
2-
# Image/J Plugins
3-
# Copyright (C) 2002-2014 Jarek Sacha
4-
# Author's email: jsacha at users dot sourceforge dot net
2+
# ImageJ Plugins
3+
# Copyright (C) 2002-2016 Jarek Sacha
4+
# Author's email: jpsacha at gmail dot com
55
#
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.
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.
1010
#
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.
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.
1515
#
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
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
1919
#
20-
# Latest release available at http://sourceforge.net/projects/ij-plugins/
20+
# Latest release available at https://github.com/ij-plugins
2121
#
22-
23-
sbt.version=0.13.9
22+
sbt.version=0.13.12
2423

scala-console/src/main/scala/net/sf/ij_plugins/scala/ScalaConsolePlugin.scala

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
/*
2-
* Image/J Plugins
3-
* Copyright (C) 2002-2014 Jarek Sacha
4-
* Author's email: jsacha at users dot sourceforge dot net
2+
* ImageJ Plugins
3+
* Copyright (C) 2002-2016 Jarek Sacha
4+
* Author's email: jpsacha at gmail dot com
55
*
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.
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.
1010
*
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.
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.
1515
*
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
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
1919
*
20-
* Latest release available at http://sourceforge.net/projects/ij-plugins/
20+
* Latest release available at https://github.com/ij-plugins
2121
*/
2222

2323
package net.sf.ij_plugins.scala
2424

25-
import console.ScalaConsole
25+
import java.io.File
26+
2627
import ij.IJ
2728
import ij.plugin.PlugIn
28-
import java.io.File
29-
import java.lang.String
29+
import net.sf.ij_plugins.scala.console.ScalaConsole
3030

3131

3232
private object ScalaConsolePlugin {
@@ -46,7 +46,7 @@ private object ScalaConsolePlugin {
4646
*/
4747
class ScalaConsolePlugin extends PlugIn {
4848

49-
def run(arg: String) {
49+
def run(arg: String): Unit = {
5050
val scripFile = if (arg != null && !arg.isEmpty) {
5151
val file = new File(arg.trim)
5252
if (file.exists) Some(file) else None

0 commit comments

Comments
 (0)