Skip to content

Commit

Permalink
Merge pull request #123 from gatech-csl/jes-updates
Browse files Browse the repository at this point in the history
Jes updates
  • Loading branch information
Nigel2016 authored Dec 9, 2019
2 parents 56b6799 + 9959d14 commit 1a6964d
Show file tree
Hide file tree
Showing 26 changed files with 388 additions and 44 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ jmusic.tmp
*.pylog

.firsttimebuilding
.idea/*
.DS_Store
releases/resources/.DS_Store
releases/resources/macosx/.DS_Store
75 changes: 75 additions & 0 deletions Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleAllowMixedLocalizations</key>
<string>false</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>py</string>
</array>
<key>CFBundleTypeMIMETypes</key>
<array>
<string>application/x-python</string>
</array>
<key>CFBundleTypeName</key>
<string>Python Program</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSHandlerRank</key>
<string>Alternate</string>
<key>LSItemContentTypes</key>
<array>
<string>public.python-script</string>
</array>
</dict>
</array>
<key>CFBundleExecutable</key>
<string>jes.sh</string>
<key>CFBundleGetInfoString</key>
<string>5.020</string>
<key>CFBundleIconFile</key>
<string>JESi2.icns</string>
<key>CFBundleIdentifier</key>
<string>edu.gatech.cc.csl.JES</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>JES</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>5.020</string>
<key>CFBundleSignature</key>
<string>JESX</string>
<key>JavaX</key>
<dict>
<key>ClassPath</key>
<array>
<string>$JAVAROOT/dependencies/jars/AVIDemo.jar</string>
<string>$JAVAROOT/dependencies/jars/imgscalr-lib-4.2.jar</string>
<string>$JAVAROOT/dependencies/jars/jMusic1.7.jar</string>
<string>$JAVAROOT/dependencies/jars/javaosc-core.jar</string>
<string>$JAVAROOT/dependencies/jars/jl1.0.jar</string>
<string>$JAVAROOT/dependencies/jars/jmf.jar</string>
<string>$JAVAROOT/dependencies/jars/jmusic-instruments.jar</string>
<string>$JAVAROOT/dependencies/jars/jsyn.jar</string>
<string>$JAVAROOT/dependencies/jars/jython-2.5.3.jar</string>
<string>$JAVAROOT/jes/classes.jar</string>
</array>
<key>JVMVersion</key>
<string>1.8</string>
<key>MainClass</key>
<string>JESstartup</string>
</dict>
<key>NSHumanReadableCopyright</key>
<string>© 2015 Matthew Frazier, Mark Guzdial, and others</string>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>
Binary file added JESi2.icns
Binary file not shown.
1 change: 1 addition & 0 deletions PkgInfo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
APPLJESX
8 changes: 5 additions & 3 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</resourceexists>
</condition>

<loadproperties srcFile="${basedir}/build.properties"
<loadproperties srcFile="${basedir}/build.properties"
if:set="build.properties.exists" />


Expand All @@ -38,7 +38,6 @@
<contains string="${jes.basename}" substring="jes" />
</and>
</condition>
<fail unless:set="jes.name.contain-jes">Your build's name should include the name "JES."</fail> -->

<!-- Other metadata -->
Expand Down Expand Up @@ -78,7 +77,7 @@
<filter token="issueshost" value="${jes.issues.host}" />

<!-- Source code properties -->
<property name="jes.target-java" value="1.5" />
<property name="jes.target-java" value="1.8" />


<!-- Paths to things in the repository -->
Expand Down Expand Up @@ -132,6 +131,9 @@
<property name="jes.launcher.current" value="${jes.launcher.sh}"
unless:set="windows" />

<target name="go">
<exec dir="${basedir}" executable="${basedir}/dpior.bat" osfamily="windows" />
</target>

<!-- JES classpath -->
<fileset id="jes.deps.jars" dir="${jes.deps.jardir}">
Expand Down
7 changes: 7 additions & 0 deletions demos/makePicture.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
p = makePicture(pickAFile())
explore(p)
pixels = getPixels(p)
show(makePicture(pixels))

p = makePicture(pickAFile())
explore(makePicture([px for px in getPixels(p) if getRed(px) < 120]))
7 changes: 7 additions & 0 deletions demos/makeSound.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
s = makeSound(pickAFile())
s.play()
samples = getSamples(s)
makeSound(samples).explore()

s = makeSound(pickAFile())
explore(makeSound([smpl for smpl in getSamples(s) if getIndex(smpl)%5==0]))
1 change: 1 addition & 0 deletions dpior.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REG ADD "HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /V "%programfiles%\jes\JES.exe" /T REG_SZ /D ~HIGHDPIAWARE /F
49 changes: 39 additions & 10 deletions jes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,28 @@
# Launches JES in place on Mac and Linux.

# Where are we?
PRG=$0

while [ -h "$PRG" ]; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '^.*-> \(.*\)$' 2>/dev/null`
if expr "$link" : '^/' 2> /dev/null >/dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done

JES_BASE="$(dirname $(readlink -f $0))"
JES_BASE=`dirname "$PRG"`
JES_HOME="$JES_BASE/jes"

InfoPlistFile="$JES_BASE/Info.plist"

# read the program name from CFBundleName
CFBundleName=`/usr/libexec/PlistBuddy -c "print :CFBundleName" ${InfoPlistFile}`

# read the icon file name
CFBundleIconFile=`/usr/libexec/PlistBuddy -c "print :CFBundleIconFile" ${InfoPlistFile}`

# See if there's a user configuration file...

Expand All @@ -30,11 +48,21 @@ if ! test -z "$JES_JAVA_HOME"; then
elif ! test -z "$JAVA_HOME"; then
JAVA="$JAVA_HOME/bin/java"
else
JAVA=java
JAVA="`/usr/libexec/java_home -v 1.8`/bin/java"
fi

# ...Did we find one?

if [ ! -x "$JAVA" ]; then
# display error message with applescript
osascript -e "tell application \"System Events\" to display dialog \"Error launching ${CFBundleName}!\n\nYou need to have Java installed on your Mac!\nVisit http://java.com for more information.\" with title \"${CFBundleName}\" buttons {\"OK\"} default button 1 with icon path to resource \"${CFBundleIconFile}\" in bundle (path to me)"

# exit with error
exit 1
fi


# Where's our Java code?
# Where's our Java code?gt

JARS="$JES_BASE/dependencies/jars"

Expand All @@ -44,7 +72,6 @@ for jar in "$JARS"/*.jar; do
CLASSPATH="$CLASSPATH:$jar"
done


# Where's our Python code?

PYTHONHOME="$JES_BASE/dependencies/jython"
Expand All @@ -54,6 +81,7 @@ PYTHONPATH="$JES_HOME/python:$JES_BASE/dependencies/python"

# Do we have any plugins to load?
# User plugins:
JES_USER_PLUGINS="$HOME/Library/Application Support/JES/Plugins"

if test -d "$JES_USER_PLUGINS"; then
for jar in "$JES_USER_PLUGINS"/*.jar; do
Expand Down Expand Up @@ -81,14 +109,9 @@ if test -d "$JES_BUILTIN_PLUGINS"; then
done
fi


# Where should the Jython cache live?

if test -d "$HOME/Library/Caches"; then
PYTHONCACHE="$HOME/Library/Caches/JES/jython-cache"
else
PYTHONCACHE="${XDG_CACHE_HOME:-$HOME/.cache}/jes/jython-cache"
fi
PYTHONCACHE="$HOME/Library/Caches/JES/jython-cache"

mkdir -p $PYTHONCACHE

Expand All @@ -100,10 +123,16 @@ JESCONFIG=$JESCONFIGDIR/JESConfig.properties
mkdir -p "$JESCONFIGDIR"


# Enable drag & drop to the dock icon.

export CFProcessPath="$0"

# All right, time to actually run it!

exec "$JAVA" \
-classpath "$CLASSPATH" \
-Xdock:icon="${CFBundleIconFile}" \
-Xdock:name="${CFBundleName}" \
-Dfile.encoding="UTF-8" \
-Djes.home="$JES_HOME" \
-Djes.configfile="$JESCONFIG" \
Expand Down
4 changes: 2 additions & 2 deletions jes/help/JESAPIHelp.html
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,15 @@
import java.awt.Font as Font
str = "Today is the first day of the rest of your life."
myFont = makeStyle("Comic Sans", Font.BOLD, 96)
addTextWithStyle(picture, 0, 0, str, myFont)
addTextWithStyle(picture, 0, 100, str, myFont)
</pre>
This takes in a picture and adds a black date stamp to the upper left corner in Size 96 bold Comic Sans.<br>
<pre>
def addHappyBirthday(picture):
import java.awt.Font as Font
str = "Happy Birthday!!!"
myFont = makeStyle("Wingdings", Font.ITALICS, 24)
addText(picture, 0, 0, str, orange)
addText(picture, 0, 100, str, orange)
</pre>
This takes in a picture and adds an orange Happy Birthday message to the upper left corner in Size 24 italcized Wingdings.<br>
_
Expand Down
8 changes: 8 additions & 0 deletions jes/help/JESChangelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ JES Changelog
This changelog only covers changes in JES versions 5.0 and later.
Our records of what changed in version 4.3 and earlier are fragmentary.

JES 6.00
--------
Release Date: May 1, 2019

Miscellaneous bug fixes

Ability to create pictures and sounds from collections of pixels and samples.

JES 5.01
--------
Release Date: Sept 10, 2014
Expand Down
1 change: 1 addition & 0 deletions jes/help/JESCopyright.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
JES: Jython Environment for Students
https://github.com/gatech-csl/jes

Version 6.00: © 2019 Veronica Day, Audrey Zhang, Matthew Frazier, and Mark Guzdial
Version 5.01: © 2014 Mark Guzdial
Version 5.0: © 2014 Matthew Frazier and Mark Guzdial
Version 4.3: © 2009 Brian Dorn and Barbara Ericson
Expand Down
12 changes: 11 additions & 1 deletion jes/java/JESstartup.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import java.awt.AWTEvent;
import java.awt.event.AWTEventListener;
import java.awt.Toolkit;
import java.io.File;
import java.io.*;
import java.util.Arrays;
import java.util.Properties;
import javax.swing.RepaintManager;
Expand Down Expand Up @@ -34,6 +34,16 @@ public static void showHelp () {
* The main method which launches JES
*/
public static void main(String[] strings) {
//Runtime.getRuntime().exec("cmd /c start \"\" dpior.bat");
//run dpior.bat in build.xml
/*Runtime runtime = Runtime.getRuntime();
try {
Process p1 = runtime.exec("cmd /c start \"\" dpior.bat");
} catch(IOException ioException) {
System.out.println(ioException.getMessage() );
}
*/

System.setProperty("jes.starttimens", String.valueOf(System.nanoTime()));

String home = JESResources.getHomePath();
Expand Down
61 changes: 61 additions & 0 deletions jes/java/SoundSample.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,67 @@ public class SoundSample {
/** the frame number of this sample in the buffer */
private int frameNumber = 0;


///////////////////// configuration (wraparound) //////////////////////////////////
private static boolean wrapLevels = false;

/**
* Indicates whether levels outside the range (-32768, 32767) are clamped
* or wrapped around (saturating or modular arithmetic).
*
* @return False to clamp levels, true to modulo them.
*/
public static boolean getWrapLevels () {
return wrapLevels;
}

/**
* Changes Sample's behavior for dealing with levels outside the range
* (-32768, 32767).
*
* @param wrap If true, values will be wrapped (modular arithmetic).
* If false, values will be clamped (saturating arithmetic).
*/
public static void setWrapLevels (boolean wrap) {
wrapLevels = wrap;
}

/**
* Round and correct a color level to be within (-32768, 32767),
* according to the current wrapLevels setting.
*
* @param level The user-provided level.
* @return A value within (-32768, 32767).
*/
public static int correctLevel (double level) {
return correctLevel((int) Math.round(level));
}

/**
* Correct a sample level to be within (-32768, 32767),
* according to the current wrapLevels setting.
*
* @param level The user-provided level.
* @return A value within (-32768, 32767).
*/
public static int correctLevel (int level) {
if (wrapLevels) {
if (level < 0) {
return -1*((-1*level) % 32768);
}
else if (level > 0) {
return level % 32767;
}
}
else if (level < -32768) {
return 0;
}
else if (level > 32767) {
return 32767;
}
return level;
}

///////////////////// Constructors //////////////////////////////////

/**
Expand Down
3 changes: 2 additions & 1 deletion jes/python/jes/gui/filemanager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def writeFile(self, filename):
if JESConfig.getInstance().getBooleanProperty(JESConfig.CONFIG_BACKUPSAVE):
try:
backupPath = self.filename + "bak"
with open(filename, 'w') as fd:
with open(backupPath, 'w') as fd:
fd.write(sourceText)
except EnvironmentError, exc:
self.showErrorMessage(
Expand Down Expand Up @@ -218,6 +218,7 @@ def validateFileForSave(self, filename):
return self.confirmSave(
"Only .py files whose names are made up of letters, numbers,\n"
"and underscores can be imported as Python modules.\n"
"Python modules also cannot start with a numeral.\n"
"(You will still be able to load it in JES regardless.)\n"
"Are you sure you want to save the file with this name?"
)
Expand Down
Loading

0 comments on commit 1a6964d

Please sign in to comment.